Re: [rspec-users] Story for Rest

2008-06-20 Thread Pat Maddox
On Fri, Jun 20, 2008 at 9:32 AM, Olivier Dupuis <[EMAIL PROTECTED]> wrote: > Hello all, > > I'm trying to write a story for a rest resource. > > Here's what I have so far: > > Story "Get prices for specific book", %{ > As a client > I want to get a list of prices for a specific book > So that

Re: [rspec-users] Story for Rest

2008-06-20 Thread Jim Morris
Attached is a custom matcher using hpricot, (and the spec for it) it has a "have_xpath matcher for checking xml. I has an earlier one using rexml but hpricot is faster, you can read about that here http://blog.wolfman.com/articles/2008/01/02/xpath-matchers-for-rspec This new hpricot one i

Re: [rspec-users] MVC testing vs. models & Webrat+RailsStory?

2008-06-20 Thread Kyle Hargraves
On Thu, Jun 19, 2008 at 11:56 AM, Christopher Bailey <[EMAIL PROTECTED]> wrote: > Kyle, thanks much for sharing your experience. You mention the speed > and so on. I've read that it is slow. Question: does Autotest work > the same way with stories, or have a way to detect what file(s) > changed

[rspec-users] Story for Rest

2008-06-20 Thread Olivier Dupuis
Hello all, I'm trying to write a story for a rest resource. Here's what I have so far: Story "Get prices for specific book", %{ As a client I want to get a list of prices for a specific book So that I can use it on my own application }, :type => RailsStory do Scenario "Requesting /books

Re: [rspec-users] before_save model callback rspec testing

2008-06-20 Thread Csongor Bartus
[Offtopic question] I might be paranoic testing if the password is salted/hashed correctly since all my login tests passed? In learning RSpec I find the most important to draw a line and don't look behind ... but what if, in this case, accidentally something happens with 'digest/sha1' and the

Re: [rspec-users] before_save model callback rspec testing

2008-06-20 Thread Csongor Bartus
David Chelimsky wrote: > > Try using create! or save! - I'll bet the record is not being saved > correctly and you're not seeing the error. done, still the same errors (exactly) -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rs

Re: [rspec-users] before_save model callback rspec testing

2008-06-20 Thread David Chelimsky
On Jun 20, 2008, at 11:01 AM, Csongor Bartus wrote: I'm trying "your" way: u = User.create(:login => "test", :email => "[EMAIL PROTECTED]", :password => "test123", :password_confirmation => "test123") u.crypted_password.should_not be_nil the error message is: NoMethodError in 'User ActiveRecord

Re: [rspec-users] before_save model callback rspec testing

2008-06-20 Thread Csongor Bartus
Thanks Pat, I've tried this way but the test did not passed ... I'm trying to Rspec Authorization's plugin User class (http://www.writertopia.com/developers/authorization) Which looks like this: # == Schema Information # Schema version: 92 # # Table name: users # # id:i

Re: [rspec-users] MVC testing vs. models & Webrat+RailsStory?

2008-06-20 Thread Josh Knowles
On 6/19/08, Christopher Bailey <[EMAIL PROTECTED]> wrote: > Specifically, I'm wondering, or contemplating, if I do unit tests for > my models, and then I use WebRat plus RailsStory, do I even need to > then do functional testing of my controllers and views? I can see > that I might want to do

Re: [rspec-users] before_save model callback rspec testing

2008-06-20 Thread Pat Maddox
Hey, This isn't doing much to test the *behavior* of the object. Why do you want to encrypt the password? Probably so you can authenticate, right? I would probably start off with describe "authenticate" do it "finds the user with the given credentials" do u = User.create!(:login => "pat"

Re: [rspec-users] before_save model callback rspec testing

2008-06-20 Thread Csongor Bartus
It might be I've done this : it "should encrypt password before save" do user = mock("User") user.should_receive(:encrypt_password).with("password") user.save end but I've got : Spec::Mocks::MockExpectationError in 'User ActiveRecord Callbacks before save encrypt passwor

Re: [rspec-users] before_save model callback rspec testing

2008-06-20 Thread Yi Wen
user.should_receive(:encrypt_password).with(your_password) user.save Is this what you want? On Fri, Jun 20, 2008 at 10:12 AM, Csongor Bartus <[EMAIL PROTECTED]> wrote: > hi all, > > i'm learning rspec and i can't figure out how to test if a callback is > executed in a model. > > my model code is:

[rspec-users] before_save model callback rspec testing

2008-06-20 Thread Csongor Bartus
hi all, i'm learning rspec and i can't figure out how to test if a callback is executed in a model. my model code is: class User < ActiveRecord::Base before_save :encrypt_password ... def encrypt(password) self.class.encrypt(password, salt) end thanks a lot, cs. -- Posted via http:/

Re: [rspec-users] Testing routes

2008-06-20 Thread Olivier Dupuis
Hi MaurĂ­cio, Thanks for your help. It now works. Olivier On Thu, Jun 19, 2008 at 3:06 PM, MaurĂ­cio Linhares < [EMAIL PROTECTED]> wrote: > Try this: > > it "should render properly when getting /books/:id/prices" do > get "prices", :id => '0' > response.should be_success > end > > Or even be