Re: [rspec-users] subject in the before block?

2010-04-01 Thread David Chelimsky
Looks like a bug. Wanna file a report? This is rspec-1, so http://rspec.lighthouseapp.com is fine. Thx On Wed, Mar 31, 2010 at 9:51 PM, Brian Cardarella wrote: > RSpec 1 and before :each > > On Mar 31, 5:33 pm, David Chelimsky wrote: >> On Mar 31, 2010, at 3:54 PM, Brian Cardarella wrote: >> >>

Re: [rspec-users] subject in the before block?

2010-04-01 Thread Brian Cardarella
So I did some deeper investigation and it seems that it actually is not an issue with the before block but with 'its' I have an example here: http://github.com/bcardarella/thingy subject is updated in the before block and that update is reflected in 'it' but not in 'its' I also opened a Lightho

Re: [rspec-users] subject in the before block?

2010-04-01 Thread David Chelimsky
On Apr 1, 2010, at 9:56 AM, Brian Cardarella wrote: > So I did some deeper investigation and it seems that it actually is > not an issue with the before block but with 'its' > > I have an example here: > > http://github.com/bcardarella/thingy > > subject is updated in the before block and that

[rspec-users] Broken pipe error in progress_bar_formatter when autotest detects changes and try to run the specs again

2010-04-01 Thread Edgar Gonzalez
Hi, I have a Broken pipe error in progress_bar_formatter when autotest detects changes and try to run the specs again: 508 $ autospec loading autotest/rspec /usr/bin/ruby1.8 /usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/bin/spec --autospec /home/edgar/sandboxes/buzz/models/spec/domain_spec.rb /home/edg

Re: [rspec-users] matcher for bad request

2010-04-01 Thread drewB
Thanks! On Mar 31, 11:37 pm, David Chelimsky wrote: > On Apr 1, 2010, at 1:30 AM, drewB wrote: > > > Is there a built-in matcher for a response returning a bad request > > (e.g. header code in the 400s)?  For example, "response.should > > be_bad_request". > > No, but its dead simple to write your

[rspec-users] setting partial stub for just one value and letting obj handle the rest

2010-04-01 Thread drewB
Occasionally, I find myself in a situation where I want to have a mock obj returned if a method is called with a particular argument but handled normally otherwise. For example, lets say I have a Model named User and I am specing a controller that sends messages from one user to another. When Use

Re: [rspec-users] setting partial stub for just one value and letting obj handle the rest

2010-04-01 Thread David Chelimsky
On Apr 1, 2010, at 3:14 PM, drewB wrote: > Occasionally, I find myself in a situation where I want to have a mock > obj returned if a method is called with a particular argument but > handled normally otherwise. For example, lets say I have a Model > named User and I am specing a controller that

Re: [rspec-users] setting partial stub for just one value and letting obj handle the rest

2010-04-01 Thread Matt Wynne
On 1 Apr 2010, at 21:35, David Chelimsky wrote: On Apr 1, 2010, at 3:14 PM, drewB wrote: Occasionally, I find myself in a situation where I want to have a mock obj returned if a method is called with a particular argument but handled normally otherwise. For example, lets say I have a Model

[rspec-users] rspec and resque - tips?

2010-04-01 Thread Matthew Van Horn
I've just gotten started refactoring my app to use Resque/Redis to do things like email and order capture asynchronously. I'm wondering if anyone has any tips on how to test my job classes, and how to run integration tests for this kind of thing. BTW - we're a very small group, and the tests

Re: [rspec-users] setting partial stub for just one value and letting obj handle the rest

2010-04-01 Thread drewB
David, thanks for your response. Matt, I totally hear you. In this contrived example, you probably could but in the project I am working on it would be very difficult. One of the challenges of joining a project already in progress... On Apr 1, 1:45 pm, Matt Wynne wrote: > On 1 Apr 2010, at 21:3

Re: [rspec-users] setting partial stub for just one value and letting obj handle the rest

2010-04-01 Thread drewB
For anyone who might come across this message looking for a solution to the same problem, I wrote the following function to take care of it (http://gist.github.com/352449) def stub_find_for_specific_values(model, stubs) model.stub!(:find).at_least(1).and_return do |id| if stubs.has_key? id

Re: [rspec-users] setting partial stub for just one value and letting obj handle the rest

2010-04-01 Thread Matt Wynne
On 1 Apr 2010, at 23:12, drewB wrote: David, thanks for your response. Matt, I totally hear you. In this contrived example, you probably could but in the project I am working on it would be very difficult. One of the challenges of joining a project already in progress... I have felt that pa

Re: [rspec-users] setting partial stub for just one value and letting obj handle the rest

2010-04-01 Thread Brian Takita
I used to do the following when I used rspec mocks. user = mock_model(User) find_method = User.method(:find) User.stub!(:find).at_least(1).and_return do |id| if id == mock_user.id.to_s user else find_method.call(id) # May need to instance_eval here, but I think .call is sufficient.