Re: [rspec-users] Assigning instance variable :expected and :got appear to be the same

2009-08-25 Thread Christoph Schiessl
On Aug 25, 2009, at 1:09 AM, jg wrote: I have a very fairly simple spec it should assign an instance variable do get 'new' assigns[:city].should == City.new end In my controller def new @city = City.new end but when I run it, I get 'CitiesController GET 'new' should assign an instance

Re: [rspec-users] Assigning instance variable :expected and :got appear to be the same

2009-08-25 Thread jg
Ahh, got it! Thanks alot guys. On Aug 25, 2:09 am, Christoph Schiessl c...@proactive.or.at wrote: On Aug 25, 2009, at 1:09 AM, jg wrote: I have a very fairly simple spec it should assign an instance variable do   get 'new'   assigns[:city].should == City.new end In my

[rspec-users] mocks stubs

2009-08-25 Thread Denis Haskin
This isn't really an rspec question, but about mocks and stubs in general, and maybe I'm looking for some best practices with rspec. I like mocks and stubs until code starts to change, and then I always get frustrated because examples then seem so brittle and sensitive to implementation

Re: [rspec-users] mocks stubs

2009-08-25 Thread Tom Stuart
On 25 Aug 2009, at 18:12, Denis Haskin wrote: The key expectation in this example is: @discount.should_not be_available(@order) But I changed the implementation of Discount#available? so that it calls Order#num_products instead of Order#line_items. My examples now fail. Why am I

Re: [rspec-users] mocks stubs

2009-08-25 Thread Denis Haskin
Tom -- perfect. That's exactly the kind of explanation I was looking for, and now I can go and deal with these changes with a worry-free mind. I find it too easy to forget that a class's public methods are, in fact, an API (particularly when there are no libraries involved) and need to be

Re: [rspec-users] mocks stubs

2009-08-25 Thread Alex Chaffee
Yep. That's why most people who are uncomfortable with mocks are uncomfortable with mocks. In my experience mocks work best at well-defined, relatively stable interfaces to external(ish) services. Otherwise you're testing the implementation, which makes refactoring difficult. But there are lots

[rspec-users] arbitrary handling of received messages in mocks

2009-08-25 Thread Chuck Remes
I am trying to process a message sent to a mock to verify it contains the correct keys. In my case I am sending a JSON string to the mock built from data passed in via the test. The object internally builds a hash and then constructs the JSON string from it. I can't get my mock to fail

Re: [rspec-users] arbitrary handling of received messages in mocks

2009-08-25 Thread Ben Mabey
Chuck Remes wrote: I am trying to process a message sent to a mock to verify it contains the correct keys. In my case I am sending a JSON string to the mock built from data passed in via the test. The object internally builds a hash and then constructs the JSON string from it. I can't get my

Re: [rspec-users] arbitrary handling of received messages in mocks

2009-08-25 Thread Tom Stuart
On 25 Aug 2009, at 20:59, Chuck Remes wrote: The documentation says the expectation passes or fails based upon the return value of the block. I can't even force it to fail by returning false. The docs (http://rspec.info/documentation/mocks/message_expectations.html ) say: You can supply

Re: [rspec-users] metaprogrammatically generating spec examples

2009-08-25 Thread Scott Taylor
On Aug 25, 2009, at 6:39 PM, Joaquin Rivera Padron wrote: hey there, I have a question that may be raised from some misunderstanding of my current problem. But the answer might well serve me for other things. The issue is I would like to be able to metaprogramatically (this may be a

Re: [rspec-users] metaprogrammatically generating spec examples

2009-08-25 Thread Joaquin Rivera Padron
hey scott, thanks for your answer, but I still don't seem to get the 'contextual' part of the validations I am missing something? (it's maybe thay I should get some sleep) cheers, joaquin ___ rspec-users mailing list rspec-users@rubyforge.org

[rspec-users] undefined method `and_return'

2009-08-25 Thread Oliver Barnes
Hello, I'm struggling with this controller spec for a few hours now http://pastie.org/594775 which is failing with an error I can't find any references about, neither on the list nor on the web in general: Admin::ImagesController handling PUT /images/1 with successful update should find the

Re: [rspec-users] running rake spec:remote

2009-08-25 Thread oren
any clues? On Aug 21, 1:13 pm, oren orengo...@gmail.com wrote: When running autotest only 'rake spec' is running and I want it to run 'rake spec:remote' as well. How do i achieve that? thanks ___ rspec-users mailing list

Re: [rspec-users] running rake spec:remote

2009-08-25 Thread Ben Mabey
oren wrote: When running autotest only 'rake spec' is running and I want it to run 'rake spec:remote' as well. How do i achieve that? IIRC, autospec (not autotest) does not use rake at all. It uses the opts defined in spec/spec.opts. I would suggest making any needed changes in that