From dchelimsky at gmail.com Mon Oct 2 11:12:39 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 2 Oct 2006 10:12:39 -0500 Subject: [Rspec-users] [ANN] RSpec 0.6.4 released Message-ID: <57c63afe0610020812r301b5744qfaae607a7ae79933@mail.gmail.com> We've released RSpec 0.6.4. Check it out! Check it out! Release info: http://rubyforge.org/frs/shownotes.php?release_id=7178 General info: http://rspec.rubyforge.org/ Questions? Right here! Enjoy, David From mike.pence at gmail.com Mon Oct 2 12:20:37 2006 From: mike.pence at gmail.com (Mike Pence) Date: Mon, 2 Oct 2006 12:20:37 -0400 Subject: [Rspec-users] [ANN] RSpec 0.6.4 released In-Reply-To: <57c63afe0610020812r301b5744qfaae607a7ae79933@mail.gmail.com> References: <57c63afe0610020812r301b5744qfaae607a7ae79933@mail.gmail.com> Message-ID: I think the biggest question is the one that has been posed most recently on these lists and not answered: How do you use RSpec for integration testing (in the Rails sense of integration testing meaning tests that span controllers)? Great work. Mike Pence On 10/2/06, David Chelimsky wrote: > We've released RSpec 0.6.4. Check it out! Check it out! > > Release info: > http://rubyforge.org/frs/shownotes.php?release_id=7178 > > General info: > http://rspec.rubyforge.org/ > > Questions? Right here! > > Enjoy, > David > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Oct 2 12:34:31 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 2 Oct 2006 11:34:31 -0500 Subject: [Rspec-users] [ANN] RSpec 0.6.4 released In-Reply-To: References: <57c63afe0610020812r301b5744qfaae607a7ae79933@mail.gmail.com> Message-ID: <57c63afe0610020934n4ad13fb2oef8a742d46a645db@mail.gmail.com> On 10/2/06, Mike Pence wrote: > I think the biggest question is the one that has been posed most > recently on these lists and not answered: > > How do you use RSpec for integration testing (in the Rails sense of > integration testing meaning tests that span controllers)? There's no explicit support for this at this point. Does anyone else have any experience trying to do this? From jerry.west at ntlworld.com Tue Oct 3 05:23:22 2006 From: jerry.west at ntlworld.com (Jerry West) Date: Tue, 03 Oct 2006 10:23:22 +0100 Subject: [Rspec-users] [ANN] RSpec 0.6.4 released In-Reply-To: <57c63afe0610020934n4ad13fb2oef8a742d46a645db@mail.gmail.com> References: <57c63afe0610020812r301b5744qfaae607a7ae79933@mail.gmail.com> <57c63afe0610020934n4ad13fb2oef8a742d46a645db@mail.gmail.com> Message-ID: <45222C0A.1090006@ntlworld.com> I have just integrated IntegrationTest support into REL_0_6_3 (doh! what timing!). As soon as my subscription to rspec-devel comes through I'll post the diffs (to the plugin, nothing else) for discussion - it works for me but may not for others. It doesn't work for REL_0_6_4 out of the box, as #sugarize_for_rspec [spec/lib/api/...] has disappeared, but presumably the plugin authors have to fix that one too. Rgds, Jerry David Chelimsky wrote: > On 10/2/06, Mike Pence wrote: > >> I think the biggest question is the one that has been posed most >> recently on these lists and not answered: >> >> How do you use RSpec for integration testing (in the Rails sense of >> integration testing meaning tests that span controllers)? >> > > There's no explicit support for this at this point. Does anyone else > have any experience trying to do this? > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Tue Oct 3 20:30:11 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 3 Oct 2006 19:30:11 -0500 Subject: [Rspec-users] stubbing/partial mocking Message-ID: <57c63afe0610031730u3d736aafs960ed6c28082abf0@mail.gmail.com> All, Brian Takita has been contributing to a stubs branch to support stubbing and partial mocking on Modules (and therefore classes). I tweaked the syntax a bit and merged it into the trunk, so you can update from the trunk and check out the new stubbing/mocking love. If you prefer to wait for a release, there should be one coming soon-ish (I'm aiming for later this week). As Brian pointed out in an earlier email, partial mocking is generally somewhat of a last resort, but it is very useful in some cases - like spec'ing rails controllers that interact with rails model classes: #stubbing - when you don't care about verification Person.stub!(:find).and_return(@person) #partial mocking: when you do care about verification Person.should_receive(:find).with("1").and_return(@person) This is not yet documented on the website - that will be happening over the next few days. Also, this does not preclude our slightly longer term goal of supporting the integration of other mocking/stubbing frameworks. That is in the works as well. Enjoy! And thanks to Brian for the excellent contributions. Cheers, David From dchelimsky at gmail.com Wed Oct 4 10:03:07 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Oct 2006 09:03:07 -0500 Subject: [Rspec-users] do we need stubbing? Message-ID: <57c63afe0610040703o6216d340j5783110c325b07ef@mail.gmail.com> Hey all - The trunk currently supports three types of mocking/stubbing: Mock Objects (created dynamically at runtime) Partial Mocking of methods on existing classes Stubbing of methods on existing objects or classes The main difference between Partial Mocking and Stubbing is that Stubs don't verify. I'm wondering if we really need the stubbing facility at all, given that we can do the same thing using Partial Mocks. If we decided to yank the Stubs, we could add Partial Mocks support to objects (right now it only works on classes). Note that this functionality is not part of a release yet, so any such changes would only affect the brave trunk-dwellers among you. Any thoughts on this? Can anyone explain to me why stubs are useful in addition to partial mocks? David From micah at 8thlight.com Wed Oct 4 10:44:01 2006 From: micah at 8thlight.com (Micah Martin) Date: Wed, 4 Oct 2006 09:44:01 -0500 Subject: [Rspec-users] String.should_hav_tag Message-ID: I've just upgraded to rspec 0.6.4 and several specs were broken. All for the same reason. String.should_have_tag doesn't seem to be supported any longer. It used to be possible to write assertions like: response.body.should_have_tag :tag => "form" or "".should_have_tag :tag => "body" But these fail with 0.6.4. The documentation still suggests this should work. I was able to solve the problem by adding the following to my spec files: class String include Spec::Expectations::TagExpectations end Micah Martin 8th Light, Inc. www.8thlight.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061004/833c050d/attachment-0001.html From micah at 8thlight.com Wed Oct 4 10:55:37 2006 From: micah at 8thlight.com (Micah Martin) Date: Wed, 4 Oct 2006 09:55:37 -0500 Subject: [Rspec-users] spec task prints usage Message-ID: <598B4222-967F-47E8-B4FB-D953EE596A0C@8thlight.com> A small feature request. When running the spec rake task, if any of the folders 'spec/models', 'spec/controller', or 'spec/views' doesn't exist or if they don't contain any specs, the spec usage is printed. In my case I didn't have a views directory. I was able to get rid of the usage output by creating the views directory and adding a blank spec. It'd be convenient if RSpec would ignore missing/empty spec directories. BTW, thanks for the cool tool. Micah Martin 8th Light, Inc. www.8thlight.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061004/7def3e0d/attachment.html From aslak.hellesoy at gmail.com Wed Oct 4 13:09:14 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 4 Oct 2006 19:09:14 +0200 Subject: [Rspec-users] do we need stubbing? In-Reply-To: <57c63afe0610040703o6216d340j5783110c325b07ef@mail.gmail.com> References: <57c63afe0610040703o6216d340j5783110c325b07ef@mail.gmail.com> Message-ID: <8d961d900610041009o5244f509iaf8899cd005c7baa@mail.gmail.com> On 10/4/06, David Chelimsky wrote: > Hey all - > > The trunk currently supports three types of mocking/stubbing: > > Mock Objects (created dynamically at runtime) > Partial Mocking of methods on existing classes > Stubbing of methods on existing objects or classes > > The main difference between Partial Mocking and Stubbing is that Stubs > don't verify. > > I'm wondering if we really need the stubbing facility at all, given > that we can do the same thing using Partial Mocks. If we decided to > yank the Stubs, we could add Partial Mocks support to objects (right > now it only works on classes). > Sounds good to me. Just to be precise - one or more methods could be mocked on an individual *Object* (Class is an Object). So this would work for any Object, not just Class. Right? I don't see a lot of value in stubbing without verification if partial mocking (or should we call it "object method mocking" to be more precise?) can be used on *any* object. > Note that this functionality is not part of a release yet, so any such > changes would only affect the brave trunk-dwellers among you. > > Any thoughts on this? Can anyone explain to me why stubs are useful in > addition to partial mocks? > I can't think of a compelling reason. Cheers, Aslak > David > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Oct 4 13:34:23 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Oct 2006 12:34:23 -0500 Subject: [Rspec-users] String.should_hav_tag In-Reply-To: References: Message-ID: <57c63afe0610041034h5f312a6aibd79e6914784325d@mail.gmail.com> On 10/4/06, Micah Martin wrote: > I've just upgraded to rspec 0.6.4 and several specs were broken. All for > the same reason. String.should_have_tag doesn't seem to be supported any > longer. > > It used to be possible to write assertions like: > > response.body.should_have_tag :tag => "form" > > or > "".should_have_tag :tag => "body" > > But these fail with 0.6.4. The documentation still suggests this should > work. > > I was able to solve the problem by adding the following to my spec files: > > class String > include Spec::Expectations::TagExpectations > end Doh! Thanks for pointing this out Micah. This changed in this release and I neglected to point it out in the release notes. As of 0.6.4, instead of using this: response.body.should_have_tag you should use this: response.should_have_tag (see http://rspec.rubyforge.org/documentation/rails/rails.html) Micah's suggestion above will work in the short run, but I would recommend that you change the specs. In the next release (0.6.5) there will no longer be a module named Spec::Expectations::TagExpectations. Thanks, David ps - sorry for the inconvenience. It is our intent to NOT break backwards compatibility on any minor (0.6.x) releases or without any warning. From dchelimsky at gmail.com Wed Oct 4 13:39:13 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Oct 2006 12:39:13 -0500 Subject: [Rspec-users] spec task prints usage In-Reply-To: <598B4222-967F-47E8-B4FB-D953EE596A0C@8thlight.com> References: <598B4222-967F-47E8-B4FB-D953EE596A0C@8thlight.com> Message-ID: <57c63afe0610041039i12280345tfc7b2de0459bd773@mail.gmail.com> On 10/4/06, Micah Martin wrote: > > A small feature request. > > When running the spec rake task, if any of the folders 'spec/models', > 'spec/controller', or 'spec/views' doesn't exist or if they don't contain > any specs, the spec usage is printed. > > In my case I didn't have a views directory. I was able to get rid of the > usage output by creating the views directory and adding a blank spec. It'd > be convenient if RSpec would ignore missing/empty spec directories. Thanks for this request. I added a feature request to the tracker at rubyforge: http://rubyforge.org/tracker/index.php?func=detail&aid=6017&group_id=797&atid=3152 Feel free to put feature requests, bugs, etc directly up there. > > BTW, thanks for the cool tool. You're welcome! From aslak.hellesoy at gmail.com Wed Oct 4 15:05:29 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 4 Oct 2006 21:05:29 +0200 Subject: [Rspec-users] spec task prints usage In-Reply-To: <598B4222-967F-47E8-B4FB-D953EE596A0C@8thlight.com> References: <598B4222-967F-47E8-B4FB-D953EE596A0C@8thlight.com> Message-ID: <8d961d900610041205s5ba7c56aj8031e716666add3b@mail.gmail.com> On 10/4/06, Micah Martin wrote: > > A small feature request. > > When running the spec rake task, if any of the folders 'spec/models', > 'spec/controller', or 'spec/views' doesn't exist or if they don't contain > any specs, the spec usage is printed. > That's been bugging me too, but I've been too lazy to do anything about it until you asked. I've just committed a fix on trunk (in the rspec rake task in rspec core). You'll have to build and install the rspec gem until a new release is made. > In my case I didn't have a views directory. I was able to get rid of the > usage output by creating the views directory and adding a blank spec. It'd > be convenient if RSpec would ignore missing/empty spec directories. > > BTW, thanks for the cool tool. > > Micah Martin > 8th Light, Inc. > www.8thlight.com > > > > > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From aslak.hellesoy at gmail.com Wed Oct 4 17:08:07 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 4 Oct 2006 23:08:07 +0200 Subject: [Rspec-users] spec task prints usage In-Reply-To: <57c63afe0610041039i12280345tfc7b2de0459bd773@mail.gmail.com> References: <598B4222-967F-47E8-B4FB-D953EE596A0C@8thlight.com> <57c63afe0610041039i12280345tfc7b2de0459bd773@mail.gmail.com> Message-ID: <8d961d900610041408y262d04d2i711c4ebade5430c1@mail.gmail.com> On 10/4/06, David Chelimsky wrote: > On 10/4/06, Micah Martin wrote: > > > > A small feature request. > > > > When running the spec rake task, if any of the folders 'spec/models', > > 'spec/controller', or 'spec/views' doesn't exist or if they don't contain > > any specs, the spec usage is printed. > > > > In my case I didn't have a views directory. I was able to get rid of the > > usage output by creating the views directory and adding a blank spec. It'd > > be convenient if RSpec would ignore missing/empty spec directories. > > Thanks for this request. I added a feature request to the tracker at rubyforge: > > http://rubyforge.org/tracker/index.php?func=detail&aid=6017&group_id=797&atid=3152 > Fixed and closed A > Feel free to put feature requests, bugs, etc directly up there. > > > > > BTW, thanks for the cool tool. > > You're welcome! > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists-rspec at shopwatch.org Thu Oct 5 00:21:06 2006 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Thu, 05 Oct 2006 00:21:06 -0400 Subject: [Rspec-users] do we need stubbing? In-Reply-To: <8d961d900610041009o5244f509iaf8899cd005c7baa@mail.gmail.com> References: <57c63afe0610040703o6216d340j5783110c325b07ef@mail.gmail.com> <8d961d900610041009o5244f509iaf8899cd005c7baa@mail.gmail.com> Message-ID: <45248832.8030901@shopwatch.org> David Chelimsky wrote: >> >> The main difference between Partial Mocking and Stubbing is that Stubs >> don't verify. >> >> I'm wondering if we really need the stubbing facility at all, given >> that we can do the same thing using Partial Mocks. If we decided to >> yank the Stubs, we could add Partial Mocks support to objects (right >> now it only works on classes). It seems to me that this is a big difference, even if it is only a difference of intent, not execution. A stub is a fake object I put in to make things work. A mock is a core part of my test/spec. Since BDD is all about expressing intent in vocabulary, I think stubs should stay even if they can be accomplished another way; it's like the difference between "if" and "unless". Time.stubs(:now).returns(Time.parse("Jan 1 1901")) is my most common stub with Mocha/Stubba. I don't care how many times it's called, and it isn't actually passed any arguments to verify; I'm just, well, killing Time. What's the argument for yanking stubs? Just duplicating code? Perhaps stubs can be implemented in terms of mocks, or vice versa? Jay Levitt From dchelimsky at gmail.com Thu Oct 5 13:02:38 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 5 Oct 2006 12:02:38 -0500 Subject: [Rspec-users] [rspec-devel] do we need stubbing? In-Reply-To: <1d7ddd110610050943x2f62b30dv4570d1481a0d3b66@mail.gmail.com> References: <57c63afe0610040703o6216d340j5783110c325b07ef@mail.gmail.com> <8d961d900610041009o5244f509iaf8899cd005c7baa@mail.gmail.com> <1d7ddd110610041853k2c3cc44ay7f938842d74ad3c5@mail.gmail.com> <1d7ddd110610041855l2dbbe502ue4915c7612386b6e@mail.gmail.com> <1d7ddd110610050943x2f62b30dv4570d1481a0d3b66@mail.gmail.com> Message-ID: <57c63afe0610051002i6c83e7bbk44c9893e1e8561a7@mail.gmail.com> On 10/5/06, Brian Takita wrote: > I talked with David last night. We agreed to make the stub! method quivalent > to the expectation: > obj.should_receive(:foobar).any_number_of_times > > So instead of: > obj.stub!(:foobar).with(true) > > one would use: > obj.stub!(:foobar).and_return(true) > > Does adding the stub! method to Mock sound good? > > class Mock > def stub!(method_name) > return should_receive(method_name).any_number_of_times > end > end That's more or less what I did. Basically there is a MockInstanceMethods module with should_receive, should_not_receive and stub!. This gets included in Mock and Object and becomes the entry point for all mocking (complete, partial) and stubbing. It's committed to the trunk, so please check it out and have a look. I'm pretty psyched about it. David > > Thanks for leaving in the stub! method. > > Brian > > > On 10/4/06, Brian Takita wrote: > > > > > Also, stub! is a method of Object. If we where to replace it with > partial mocking, we would have to move partial mocking to Object to replace > this behaviour. > > > > > > Unless things have changed, partial mocking is a feature of Module > objects. > > > > > > > > > > On 10/4/06, Brian Takita wrote: > > > I like the Object#stub! method because it's syntax is more focused and > clearer than using a mock for the purpose of stubbing a method. > > > > > > obj.stub!(:foobar).with(true) > > > vs. > > > > obj.should_receive(:foobar).and_return(true).any_number_of_times > > > > > > The stub method also communicates my intention to stub out the method, > just as mocking the method communicates my intention to verify that a > certain message was passed to the object. I believe this makes my > tests/specs clearer. > > > > > > Also, stub! is a method of Object. If we where to replace it with > partial mocking, we would have to move partial mocking to Object to replace > this behaviour. > > > > > > > > > > > > On 10/4/06, aslak hellesoy wrote: > > > > On 10/4/06, David Chelimsky wrote: > > > > > Hey all - > > > > > > > > > > The trunk currently supports three types of mocking/stubbing: > > > > > > > > > > Mock Objects (created dynamically at runtime) > > > > > Partial Mocking of methods on existing classes > > > > > Stubbing of methods on existing objects or classes > > > > > > > > > > The main difference between Partial Mocking and Stubbing is that > Stubs > > > > > don't verify. > > > > > > > > > > I'm wondering if we really need the stubbing facility at all, given > > > > > that we can do the same thing using Partial Mocks. If we decided to > > > > > yank the Stubs, we could add Partial Mocks support to objects (right > > > > > now it only works on classes). > > > > > > > > > > > > > Sounds good to me. > > > > > > > > Just to be precise - one or more methods could be mocked on an > > > > individual *Object* (Class is an Object). So this would work for any > > > > Object, not just Class. Right? > > > > > > > > I don't see a lot of value in stubbing without verification if partial > > > > mocking (or should we call it "object method mocking" to be more > > > > precise?) can be used on *any* object. > > > > > > > > > Note that this functionality is not part of a release yet, so any > such > > > > > changes would only affect the brave trunk-dwellers among you. > > > > > > > > > > Any thoughts on this? Can anyone explain to me why stubs are useful > in > > > > > addition to partial mocks? > > > > > > > > > > > > > I can't think of a compelling reason. > > > > > > > > Cheers, > > > > Aslak > > > > > > > > > David > > > > > _______________________________________________ > > > > > Rspec-users mailing list > > > > > Rspec-users at rubyforge.org > > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > _______________________________________________ > > > > rspec-devel mailing list > > > > rspec-devel at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/rspec-devel > > > > > > > > > > > > > > > > From lists-rspec at shopwatch.org Sat Oct 7 19:07:45 2006 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Sat, 07 Oct 2006 19:07:45 -0400 Subject: [Rspec-users] should_have_tag: What am I doing wrong? Message-ID: <45283341.3060701@shopwatch.org> My spec contains: response.should_have_tag "", :content => "Add new Contact" The output is: Spec::Expectations::ExpectationNotMetError in 'The ResourceController should do something when I try to edit contacts' .. Add new Contact .. should include [[{:content=>"Add new Contact", :tag=>""}]] This looks right to me... Jay Levitt From aslak.hellesoy at gmail.com Tue Oct 10 08:30:34 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 10 Oct 2006 14:30:34 +0200 Subject: [Rspec-users] Shameless plug Message-ID: <8d961d900610100530n5e49ff4djf5b81cc7cb3808cc@mail.gmail.com> Geoff is interviewing me about RSpec and continuous integration: http://podcast.rubyonrails.org/ The interview is a month old, and there has been a lot of great development in RSpec's mocking/stubbing and Rails controller/view area in the meanwhile. I'm not so sure we'll ditch our own mocking yet :-) Cheers, Aslak From aslak.hellesoy at gmail.com Tue Oct 10 21:11:50 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 11 Oct 2006 03:11:50 +0200 Subject: [Rspec-users] Retiring test2spec? Message-ID: <8d961d900610101811q26555cc6v55523a1a63d3971a@mail.gmail.com> Hi all, We're thinking about retiring the test2spec translation tool because it's becoming a maintenance problem. Is anyone using it? Would anyone miss it if it went away? Aslak From jchris at mfdz.com Tue Oct 10 23:57:07 2006 From: jchris at mfdz.com (Chris Anderson) Date: Tue, 10 Oct 2006 20:57:07 -0700 Subject: [Rspec-users] Retiring test2spec? In-Reply-To: <8d961d900610101811q26555cc6v55523a1a63d3971a@mail.gmail.com> References: <8d961d900610101811q26555cc6v55523a1a63d3971a@mail.gmail.com> Message-ID: I've always preferred writing fresh specs to converting tests to specs. I've tried test2spec, and can see how I could use it, but I don't ever anticipate doing so. Putting more energy into Rails integration and autospec would make developers like me happy. Chris On 10/10/06, aslak hellesoy wrote: > Hi all, > > We're thinking about retiring the test2spec translation tool because > it's becoming a maintenance problem. > > Is anyone using it? Would anyone miss it if it went away? > > Aslak > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Chris Anderson http://mfdz.com/jchris From dchelimsky at gmail.com Wed Oct 11 17:53:39 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 11 Oct 2006 17:53:39 -0400 Subject: [Rspec-users] stubbing/mocking Message-ID: <57c63afe0610111453x37fcbc3awc46e70ac4d732dd3@mail.gmail.com> All, Inspired by a conversation on the mocha list, I added the ability to mix stubs w/ mocks on the same methods. Here's what it allows: context "a mock" do specify "can stub! and mock the same message" do mock = mock("stubbing mock") mock.stub!(:msg).and_return(:stub_value) mock.should_receive(:msg).with(:arg).and_return(:mock_value) mock.msg.should_equal :stub_value mock.msg(:other_arg).should_equal :stub_value mock.msg(:arg).should_equal :mock_value mock.msg(:another_arg).should_equal :stub_value mock.msg(:yet_another_arg).should_equal :stub_value mock.msg.should_equal :stub_value end end Basically, the stub will be invoked for any calls to :msg without :arg. Does this seem useful? Check out the trunk if you think so and give it a shot. Thanks, David From margrymouse-newsletters at yahoo.com Thu Oct 12 17:26:51 2006 From: margrymouse-newsletters at yahoo.com (Pauli's List Subscriptions) Date: Thu, 12 Oct 2006 14:26:51 -0700 (PDT) Subject: [Rspec-users] how to spec elements of config file usage Message-ID: <20061012212651.64168.qmail@web31802.mail.mud.yahoo.com> Hi! I'm pretty newbie in Ruby and certainly in rspec. I'm writing a wrapper to a 3rd party API in Ruby, and will use a config file to persist the API user keys. In setting up my specs I want to say things like: "should raise exception if config file not found" "should raise exception if config file does not contain key" I figure that I'll swap config files in the beginning of each spec. If I 'require rake' in my spec script, I'll be able to use the File methods from rake to swap out versions of my config file - right? Any reason not to do it that way, i.e. some other Ruby library is better? Other recommended methods to handle specs around presence / contents of file system objects? Thanks, Pauli From lists-rspec at shopwatch.org Sun Oct 15 04:44:22 2006 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Sun, 15 Oct 2006 04:44:22 -0400 Subject: [Rspec-users] DRb delays using rails_spec_server? Message-ID: <4531F4E6.3030102@shopwatch.org> I've been successfully using rails_spec_server for some time. Somehow, in the process of deleting and recreating my rspec directory a few times for SVN (or, less believably, in the process of building SVN 1.4.0 and its dependencies), something got hosed. Now, script/rails_spec takes 5-10 seconds to get past DRb.start_server. This is on a fast Windows machine under cygwin. Anyone ever run into this? strace is way too voluminous to help here. Jay Levitt From mike.pence at gmail.com Sun Oct 15 14:14:59 2006 From: mike.pence at gmail.com (Mike Pence) Date: Sun, 15 Oct 2006 14:14:59 -0400 Subject: [Rspec-users] *what* to test? Message-ID: So I dig rspec and BDD, of course. I thought that Dave's Google Video was a great intro () -- even if it was a bit heavy on theory and a bit loose on the nuts and bolts. But I don't see anyone sufficiently answering the big question: What do you test? How do you define higher level and lower level behaviors that should have tests written for them? From aslak.hellesoy at gmail.com Sun Oct 15 17:22:43 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 15 Oct 2006 23:22:43 +0200 Subject: [Rspec-users] *what* to test? In-Reply-To: References: Message-ID: <8d961d900610151422q38d879c9u4aed93de7f07dead@mail.gmail.com> On 10/15/06, Mike Pence wrote: > So I dig rspec and BDD, of course. I thought that Dave's Google Video > was a great intro () -- even if it was a bit heavy on theory and a bit > loose on the nuts and bolts. But I don't see anyone sufficiently > answering the big question: > > What do you test? How do you define higher level and lower level > behaviors that should have tests written for them? I'm going to be elaborate here. There is no quick answer. Here is how I teach it: Start by asking yourself (or better - whomever wants the software): "what do you want to accomplish with the software". Try to come up with simple tasks that you can do with the software and elaborate each of those. These are called User Stories (look it up). Here is an example of a User Story for someone who wants to play bowling: == See total score == As a player I want to see the total score at the end of the game So that I can compare scores with other players and my own personal record What you see here is the Narrative of the User Story. It's not enough to leap into BDD/TDD yet, but a good starting point. Now, write down some Acceptance Criteria for the User Story. The purpose of Acceptance Criteria is to help the programmers know When They Are Done. A second (and very important role) of Acceptance Criteria is that they are the primary input for the spec writing activity. I recommend that Acceptance Ariteria be written in a Given-When-Then style (GWT). Each one of them should be an example of how the software should work. They are meant to be examples. == Acceptance Criteria == The programmer will know when (s)he is done when: Given I have a new game # Initial known state When I throw all balls in the gutter # An action or event Then the final score should be zero # An observable outcome Given I have a new game When I knock down 3 pins, then all balls in the gutter Then the final score should be 3 Given I have a new game When I knock down 3 pins, then 7, then 2, then all balls in the gutter Then the final score should be 14 etc. Try to come up with really simple acceptance criteria (examples) and make them gradually more complex. You'll start developing specs to satisfy the simple ones first. Let's turn the first Acceptance Criterion (for the gutter game) into a spec: context "An empty game" do # This is the "Given" specify "should give zero score when all balls go in the gutter" do # This is the When+Then game = Game.new (1..20).each do game.roll(0) end game.score.should_be 0 end end This is all the code you have. You haven't written the Game class yet. The spec expresses the first GWT acceptance criterion, and as you see, it's a fairly verbatim translation of it. When you run it you'll get the following error: NameError in 'An empty game should give zero score when all balls go in the gutter' uninitialized constant Game Hooray. That is good. It's good because RSpec is now telling you what to do next. You'll implement the Game class: class Game end Run the spec again and see it fail with a new error message: NoMethodError in 'An empty game should give zero score when all balls go in the gutter' undefined method `roll' for # Now, define it: class Game def roll(pins) end end Run the spec again: NoMethodError in 'An empty game should give zero score when all balls go in the gutter' undefined method `score' for # And fix it: class Game def roll(pins) end def score 0 end end Run the spec again and see it pass. You have satisfied the first acceptance criterion. You now have a bowling game that will correctly calculate the score for people who always throw the balls in the gutter. Now you attack the next acceptance criterion. In the real world you'll have more complex things than this of course, but the approach can be the same. Start at the high level and drill down. Start with something that is at the border of your system - something that can be verified by an end user. Let the guts evolve gradually, and let them evolve from functional user stories. I highly recommend doing the Bowling Game Kata (from which this intro was inspired): http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata. It's trivial programming, but a mind-bending excercise for those who are unfamiliar with TDD and BDD. Cheers, Aslak > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mike.pence at gmail.com Sun Oct 15 19:20:59 2006 From: mike.pence at gmail.com (Mike Pence) Date: Sun, 15 Oct 2006 19:20:59 -0400 Subject: [Rspec-users] *what* to test? In-Reply-To: <8d961d900610151422q38d879c9u4aed93de7f07dead@mail.gmail.com> References: <8d961d900610151422q38d879c9u4aed93de7f07dead@mail.gmail.com> Message-ID: Thank you both so much. Very, very helpful. On 10/15/06, aslak hellesoy wrote: > On 10/15/06, Mike Pence wrote: > > So I dig rspec and BDD, of course. I thought that Dave's Google Video > > was a great intro () -- even if it was a bit heavy on theory and a bit > > loose on the nuts and bolts. But I don't see anyone sufficiently > > answering the big question: > > > > What do you test? How do you define higher level and lower level > > behaviors that should have tests written for them? > > I'm going to be elaborate here. There is no quick answer. Here is how > I teach it: > > Start by asking yourself (or better - whomever wants the software): > "what do you want to accomplish with the software". > > Try to come up with simple tasks that you can do with the software and > elaborate each of those. These are called User Stories (look it up). > Here is an example of a User Story for someone who wants to play > bowling: > > == See total score == > As a player > I want to see the total score at the end of the game > So that I can compare scores with other players and my own personal record > > What you see here is the Narrative of the User Story. It's not enough > to leap into BDD/TDD yet, but a good starting point. Now, write down > some Acceptance Criteria for the User Story. The purpose of Acceptance > Criteria is to help the programmers know When They Are Done. A second > (and very important role) of Acceptance Criteria is that they are the > primary input for the spec writing activity. > > I recommend that Acceptance Ariteria be written in a Given-When-Then > style (GWT). Each one of them should be an example of how the software > should work. They are meant to be examples. > > == Acceptance Criteria == > The programmer will know when (s)he is done when: > > Given I have a new game # Initial known state > When I throw all balls in the gutter # An action or event > Then the final score should be zero # An observable outcome > > Given I have a new game > When I knock down 3 pins, then all balls in the gutter > Then the final score should be 3 > > Given I have a new game > When I knock down 3 pins, then 7, then 2, then all balls in the gutter > Then the final score should be 14 > > etc. > > Try to come up with really simple acceptance criteria (examples) and > make them gradually more complex. You'll start developing specs to > satisfy the simple ones first. > > Let's turn the first Acceptance Criterion (for the gutter game) into a spec: > > context "An empty game" do # This is the "Given" > specify "should give zero score when all balls go in the gutter" do > # This is the When+Then > game = Game.new > (1..20).each do > game.roll(0) > end > game.score.should_be 0 > end > end > > This is all the code you have. You haven't written the Game class yet. > The spec expresses the first GWT acceptance criterion, and as you see, > it's a fairly verbatim translation of it. When you run it you'll get > the following error: > > NameError in 'An empty game should give zero score when all balls go > in the gutter' > uninitialized constant Game > > Hooray. That is good. It's good because RSpec is now telling you what > to do next. You'll implement the Game class: > > class Game > end > > Run the spec again and see it fail with a new error message: > > NoMethodError in 'An empty game should give zero score when all balls > go in the gutter' > undefined method `roll' for # > > Now, define it: > > class Game > def roll(pins) > end > end > > Run the spec again: > > NoMethodError in 'An empty game should give zero score when all balls > go in the gutter' > undefined method `score' for # > > And fix it: > > class Game > def roll(pins) > end > > def score > 0 > end > end > > Run the spec again and see it pass. You have satisfied the first > acceptance criterion. You now have a bowling game that will correctly > calculate the score for people who always throw the balls in the > gutter. > > Now you attack the next acceptance criterion. > > In the real world you'll have more complex things than this of course, > but the approach can be the same. Start at the high level and drill > down. Start with something that is at the border of your system - > something that can be verified by an end user. Let the guts evolve > gradually, and let them evolve from functional user stories. > > I highly recommend doing the Bowling Game Kata (from which this intro > was inspired): > http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata. It's > trivial programming, but a mind-bending excercise for those who are > unfamiliar with TDD and BDD. > > Cheers, > Aslak > > > _______________________________________________ > > Rspec-users mailing list > > Rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > From dchelimsky at gmail.com Sun Oct 15 22:31:13 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 15 Oct 2006 22:31:13 -0400 Subject: [Rspec-users] subject.should_be true Message-ID: <57c63afe0610151931w1ed6fe2egd639078e7198c447@mail.gmail.com> As things stand now, the following will all pass: true.should_be true "true".should_be true "false".should_be true 3.should_be true etc My feeling is that "should_be true" should only pass if it returns boolean true even though ruby says that non-nil/non-false is true. Anybody else? David From geeksam at gmail.com Mon Oct 16 00:01:23 2006 From: geeksam at gmail.com (Sam Livingston-Gray) Date: Sun, 15 Oct 2006 21:01:23 -0700 Subject: [Rspec-users] subject.should_be true In-Reply-To: <57c63afe0610151931w1ed6fe2egd639078e7198c447@mail.gmail.com> References: <57c63afe0610151931w1ed6fe2egd639078e7198c447@mail.gmail.com> Message-ID: <7beb6b8c0610152101o50ba533mdac887a6e24fa078@mail.gmail.com> If :should_be is intended to be used with :foo? methods, it seems like it should only accept booleans. Besides, :should_equal will still be consistent with Ruby's equality semantics, right? So you'd have the option of using either: 3.should_equal true #=> true 3.should_be true #=> false In the first case, you're being consistent with Ruby, but in the second, you're not only saying that something should evaluate to true, you're actually saying "this should *be* true." -Sam On 10/15/06, David Chelimsky wrote: > As things stand now, the following will all pass: > > true.should_be true > "true".should_be true > "false".should_be true > 3.should_be true > etc > > My feeling is that "should_be true" should only pass if it returns > boolean true even though ruby says that non-nil/non-false is true. > > Anybody else? > > David > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Mon Oct 16 05:39:52 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 16 Oct 2006 11:39:52 +0200 Subject: [Rspec-users] subject.should_be true In-Reply-To: <57c63afe0610151931w1ed6fe2egd639078e7198c447@mail.gmail.com> References: <57c63afe0610151931w1ed6fe2egd639078e7198c447@mail.gmail.com> Message-ID: <8d961d900610160239q5366b6f5i8a97d528b9b94ac9@mail.gmail.com> On 10/16/06, David Chelimsky wrote: > As things stand now, the following will all pass: > > true.should_be true > "true".should_be true > "false".should_be true > 3.should_be true > etc > > My feeling is that "should_be true" should only pass if it returns > boolean true even though ruby says that non-nil/non-false is true. > The old discussion about this topic is here: http://rubyforge.org/pipermail/rspec-devel/2006-June/thread.html#228 (The "5.should.be true" thread) I recommend reading it. > Anybody else? > > David > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Tue Oct 17 00:01:41 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 17 Oct 2006 00:01:41 -0400 Subject: [Rspec-users] new handling of equality Message-ID: <57c63afe0610162101i30315405t6dbc66260d2966a3@mail.gmail.com> All, Based mostly on the earlier thread on "should_be", we have introduced a new branch called should_be_working_like_ruby with the new proposed handling for equality. Per the CHANGES file in that branch (rev 896): ============================================ IMPORTANT NOTE: THIS RELEASE IS NOT 100% BACKWARDS COMPATIBLE TO 0.6.x This release changes the way RSpec handles equality. Previous releases tried to handle equality based on the way the words read, rather than the way ruby actually handles equality. So, with this release and going forward: * actual.should_equal(expected) will pass if actual.equal?(expected) returns true * actual.should_eql(expected) will pass if actual.eql?(expected) returns true * actual.should == expected will pass if actual == expected) returns true At the high level, eql? implies equivalence, while equal? implies object identity. For more information on how ruby deals w/ equality, you should do this: ri equal? or look at this: http://www.ruby-doc.org/core/classes/Object.html#M001057 Also, we left in should_be as a synonym for should_equal, so the only specs that should break are the ones using should_equal (which used to use == instead of .equal?). Lastly, should_be used to handle true and false differently from any other values. We've removed this special handling, so now actual.should_be true will fail for any value other than true (it used to pass for any non-nil, non-false value), and actual.should_be false will fail for any value other than false (it used to pass for nil or false). Here's what you'll need to do to update your specs: 1. search for "should_equal" and replace with "should_eql" 2. run specs If any specs still fail, they are probably related to should_be(true) or should_be(false) using non-boolean values. Those you'll just have to inspect manually and adjust appropriately (sorry!). ============================================ There are two outstanding issues. 1. actual.should != expected does not work (right now you can use should_not_eql) 2. lambda { expr }.should_eql expected compares to the proc rather than the result I'll bring these up in separate threads, so please don't respond to this thread w/ either of these issues. I'd encourage any and all of you who can check out and build from source to check out and build this branch and let us know what other issues you encounter. We'll be releasing this soon, and would like to make the transition from 0.6.x to 0.7.0 as smooth as possible for all. Thanks, David From dchelimsky at gmail.com Tue Oct 17 05:54:36 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 17 Oct 2006 05:54:36 -0400 Subject: [Rspec-users] actual.should != not_expected Message-ID: <57c63afe0610170254h1ee8688bx986962c0c3e3858a@mail.gmail.com> All, In dealing with the changes to should in the should_be_working_like_ruby branch, I am reminded that while we got the following to work ... actual.should_be < value actual.should_be <= value actual.should == value actual.should =~ value actual.should_be >= value actual.should_be > value ... we were not able to get this to work: actual.should != value Here's what the test looked like: context "should[_be] :" do specify "should pass when != operator returns true" do (2+2).should != 3 end end and the result. $ bin/spec spec/spec/expectations/helper/ \ -s "should pass when != operator returns true" F 1) Spec::Expectations::ExpectationNotMetError in 'should[_be] : should pass when != operator returns true' 4 should == 3 ./spec/spec/expectations/helper//should_be_arbitrary_operator_spec.rb:14:in `should pass when != operator returns true' Finished in 0.000647 seconds 1 specification, 1 failure NOTE that the error reads "4 should == 3". It looks as though ruby is actually delivering the == operator instead of !=. Now if you do this: irb(main):003:0> Object.methods.sort => ["<", "<=", "<=>", "==", "===", "=~", ">", ">=",...] ... you'll note that != is not an actual operator. So I'm not convinced that we can get this to work without a big change to rspec's internals. So the challenge is on. If any one is interested in making this work, please check out the should_be_working_like_ruby branch or the trunk, give it a shot, and submit a patch (with specs!) if you succeed. If you do submit a patch, please make sure that the spec above and all other specs are passing. Also - I view this as a bell (or whistle, if you prefer). Specifying something as vague as != seems almost useless to me to begin with, but if you really do need to specify inequality you'll be ableto do it with should_not_eql or should_not_equal. That said, we will reserve the right to not incorporate a working solution if we feel that it is not cleanly aligned with the rest of RSpec's internals, or makes us all go "wow, that's cool, but what a hack!". So please do not submit anything unless the sheer satisfaction of having gotten it to work will be enough for you to feel that the effort was worthwhile. Thanks, David From lists-rspec at shopwatch.org Tue Oct 17 11:42:01 2006 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Tue, 17 Oct 2006 11:42:01 -0400 Subject: [Rspec-users] Should fixtures be transactional? Message-ID: <4534F9C9.7040507@jay.fm> I started using the new Model.should_have(1).records expectation in rspec_on_rails, and quickly realized that my fixtures were remaining loaded, even in contexts that didn't use them. Bug or feature? Jay Levitt From aslak.hellesoy at gmail.com Tue Oct 17 13:23:48 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 17 Oct 2006 19:23:48 +0200 Subject: [Rspec-users] Should fixtures be transactional? In-Reply-To: <4534F9C9.7040507@jay.fm> References: <4534F9C9.7040507@jay.fm> Message-ID: <8d961d900610171023p49758074iaa45161581c3da68@mail.gmail.com> On 10/17/06, Jay Levitt wrote: > I started using the new Model.should_have(1).records expectation in > rspec_on_rails, and quickly realized that my fixtures were remaining > loaded, even in contexts that didn't use them. Bug or feature? > Looks like a bug. I reproduced this by standing in rspec_on_rails and running: spec spec/models/person_spec.rb -s "A new Person" ; echo "select * from people;" | sqlite3 db/test.db It prints out the following at the end: 1|Lachie I put some debug statements in AR's fixtures.rb#teardown_with_fixtures right before ActiveRecord::Base.connection.rollback_db_transaction. And the rollback is definitely being executed. So I'm inclined to think this is a Rails bug with sqlite3. I haven't tried with Test::Unit to see if it behaves the same way. What Rails version and what database are you using? Aslak > Jay Levitt > > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Tue Oct 17 14:58:10 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 17 Oct 2006 20:58:10 +0200 Subject: [Rspec-users] Should fixtures be transactional? In-Reply-To: <45351CAE.1010102@shopwatch.org> References: <4534F9C9.7040507@jay.fm> <8d961d900610171023p49758074iaa45161581c3da68@mail.gmail.com> <45351CAE.1010102@shopwatch.org> Message-ID: <8d961d900610171158r7f71d65fx51b2663ea17001a4@mail.gmail.com> On 10/17/06, Jay Levitt wrote: > aslak hellesoy wrote: > > So I'm inclined to think this is a Rails bug with sqlite3. > > I haven't tried with Test::Unit to see if it behaves the same way. I tried with Test::Unit in RSpec's vendor/rspec_on_rails: 1) Get the latest svn trunk 2) cd vendor/rspec_on_rails 3) rake db:migrate db:test:clone ; ruby test/unit/animal_test.rb ; echo "select * from animals;" | sqlite3 db/test.db I get: 1 tests, 1 assertions, 0 failures, 0 errors 1|Pig|1 2|Horse|1 The records are left in the database - even with Test::Unit and transactional fixtures ON. I'd say it's a Rails bug (I've tried both bleeding edge and 1.1.6). To be 100% sure - could you please try to run a Test::Unit test in your app and see how it works with that? Cheers, Aslak > > > > What Rails version and what database are you using? > > Older edge rails (4913) and PostgreSQL 8.1. > > Jay > > From lists-rspec at shopwatch.org Tue Oct 17 21:39:31 2006 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Tue, 17 Oct 2006 21:39:31 -0400 Subject: [Rspec-users] Should fixtures be transactional? In-Reply-To: <8d961d900610171158r7f71d65fx51b2663ea17001a4@mail.gmail.com> References: <4534F9C9.7040507@jay.fm> <8d961d900610171023p49758074iaa45161581c3da68@mail.gmail.com> <45351CAE.1010102@shopwatch.org> <8d961d900610171158r7f71d65fx51b2663ea17001a4@mail.gmail.com> Message-ID: <453585D3.9090105@jay.fm> aslak hellesoy wrote: > On 10/17/06, Jay Levitt wrote: >> aslak hellesoy wrote: >>> So I'm inclined to think this is a Rails bug with sqlite3. >>> I haven't tried with Test::Unit to see if it behaves the same way. > > I tried with Test::Unit in RSpec's vendor/rspec_on_rails: > 1) Get the latest svn trunk > 2) cd vendor/rspec_on_rails > 3) rake db:migrate db:test:clone ; ruby test/unit/animal_test.rb ; > echo "select * from animals;" | sqlite3 db/test.db > > I get: > > 1 tests, 1 assertions, 0 failures, 0 errors > 1|Pig|1 > 2|Horse|1 > > The records are left in the database - even with Test::Unit and > transactional fixtures ON. > > I'd say it's a Rails bug (I've tried both bleeding edge and 1.1.6). To > be 100% sure - could you please try to run a Test::Unit test in your > app and see how it works with that? Actually, I've just read an article from back when transactional fixtures first came out, and it seems that this is by design; Rails commits the fixtures to disk so that it can keep rolling back to that point. Ah, well. I suppose I prefer to search for the specific records I've created, not just count the total records, so this will stop me from being lazy! See: http://clarkware.com/cgi/blosxom/2005/10/24 From cowboysolitude at gmail.com Fri Oct 20 08:10:04 2006 From: cowboysolitude at gmail.com (J.D. Hollis) Date: Fri, 20 Oct 2006 08:10:04 -0400 Subject: [Rspec-users] slow rails_spec Message-ID: My rails_spec runs are taking around 75 seconds. I'm on REL_0_6_4 with edge rails. This is a fresh application I just started this morning?I've got four specs that take less than a second to run via rake. Any ideas why it's so slow? From richcollins at gmail.com Fri Oct 20 22:53:25 2006 From: richcollins at gmail.com (Rich Collins) Date: Fri, 20 Oct 2006 19:53:25 -0700 Subject: [Rspec-users] Usage Error Message-ID: <3849412E-DBC5-4876-9D14-9DA99EF706E5@gmail.com> rake spec seems to work fine, but I keep getting a usage error at the end of the spec run: /usr/local/bin/ruby -I"/usr/local/lib/ruby/gems/1.8/gems/rspec-0.6.4/ lib" "/usr/local/lib/ruby/gems/1.8/gems/rspec-0.6.4/bin/spec" Usage: spec [options] (FILE|DIRECTORY|GLOB)+ --diff Show unified diff of Strings that are expected to be equal when they are not -c, --colour, --color Show coloured (red/green) output -s, --spec SPECIFICATION_NAME Execute a single specification -f, --format FORMAT Builtin formats: specdoc|s|rdoc| r|html|h You can also specify a custom formatter class (in which case you should also specify --require) -r, --require FILE Require FILE before running specs Useful for loading custom formatters or other extensions -b, --backtrace Output full backtrace -d, --dry-run Don't execute specs -v, --version Show version -h, --help You're looking at it The noise is a bit annoying and may interfere with commit hooks for my repo From aslak.hellesoy at gmail.com Sat Oct 21 06:35:59 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 21 Oct 2006 12:35:59 +0200 Subject: [Rspec-users] Great BDD article Message-ID: <8d961d900610210335y6a779246y1a2d369bfcb1aba0@mail.gmail.com> Recommended reading for everyone - my Ex-colleague Dan North's BDD article from Better Software Magazine: http://dannorth.net/introducing-bdd From aslak.hellesoy at gmail.com Sat Oct 21 05:59:35 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 21 Oct 2006 11:59:35 +0200 Subject: [Rspec-users] Usage Error In-Reply-To: <3849412E-DBC5-4876-9D14-9DA99EF706E5@gmail.com> References: <3849412E-DBC5-4876-9D14-9DA99EF706E5@gmail.com> Message-ID: <8d961d900610210259n118cac61gb96afe7f3afdc084@mail.gmail.com> This is fixed on trunk. Ypu're getting this because 0.6.4 doesn't know how to deal with empty spec directories. The spec task runs spec:models, spec:controllers etc. Find out which one of them is failing (run them individually) and just create a dummy spec. Aslak On 10/21/06, Rich Collins wrote: > rake spec seems to work fine, but I keep getting a usage error at the > end of the spec run: > > /usr/local/bin/ruby -I"/usr/local/lib/ruby/gems/1.8/gems/rspec-0.6.4/ > lib" "/usr/local/lib/ruby/gems/1.8/gems/rspec-0.6.4/bin/spec" > Usage: spec [options] (FILE|DIRECTORY|GLOB)+ > > --diff Show unified diff of Strings > that are expected to be equal when they are not > -c, --colour, --color Show coloured (red/green) output > -s, --spec SPECIFICATION_NAME Execute a single specification > -f, --format FORMAT Builtin formats: specdoc|s|rdoc| > r|html|h > You can also specify a custom > formatter class > (in which case you should also > specify --require) > -r, --require FILE Require FILE before running specs > Useful for loading custom > formatters or other extensions > -b, --backtrace Output full backtrace > -d, --dry-run Don't execute specs > -v, --version Show version > -h, --help You're looking at it > > The noise is a bit annoying and may interfere with commit hooks for > my repo > > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From micah at 8thlight.com Mon Oct 23 18:34:00 2006 From: micah at 8thlight.com (Micah Martin) Date: Mon, 23 Oct 2006 17:34:00 -0500 Subject: [Rspec-users] overriding mock expectations Message-ID: <27EAA06F-10F5-4BAB-97A6-941101752114@8thlight.com> There is one annoyance I'm encountering with the Mock API in rSpec. Overall it works well, as far as dynamic mocks go ;)... but there's this one thing... It doesn't allow overriding of expectations. example: m = mock("blah") m.should_receive(:one).any_number_of_times().and_return(1) m.should_receive(:one).and_return(1) The second call to should_receive is ignored. I believe it would be most convenient if the second call to should_receive would override the first. Why? What I would like to do is define all the should_receives once in the setup using any_number_of_times. This establishes a default context. Then in each spec I'd like to override a specific should_receive relevant to the spec. Without being able to override, I am force to define all the should_receives for each spec..... duplication. Is there another solution I'm missing? Micah Martin 8th Light, Inc. www.8thlight.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061023/24f10a56/attachment.html From srbaker at pobox.com Mon Oct 23 18:55:19 2006 From: srbaker at pobox.com (Steven R. Baker) Date: Mon, 23 Oct 2006 15:55:19 -0700 Subject: [Rspec-users] overriding mock expectations In-Reply-To: <27EAA06F-10F5-4BAB-97A6-941101752114@8thlight.com> References: <27EAA06F-10F5-4BAB-97A6-941101752114@8thlight.com> Message-ID: <0CEACD6D-EC4A-4B15-86B6-B0828387C7C8@pobox.com> > What I would like to do is define all the should_receives once in > the setup using any_number_of_times. This establishes a default > context. Then in each spec I'd like to override a specific > should_receive relevant to the spec. > > Without being able to override, I am force to define all the > should_receives for each spec..... duplication. > > Is there another solution I'm missing? We need you to write a patch for this. If you don't feel confident doing it, I'll take a crack at it when I get home if you harass me on IM. srbaker0 yahoo stevenrbaker at mac.com .mac srbaker0 at hotmail.com msn -Steven > From dchelimsky at gmail.com Mon Oct 23 19:52:15 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 23 Oct 2006 18:52:15 -0500 Subject: [Rspec-users] Fwd: overriding mock expectations In-Reply-To: <57c63afe0610231651p752da52dsb258b59c6dff3f15@mail.gmail.com> References: <27EAA06F-10F5-4BAB-97A6-941101752114@8thlight.com> <57c63afe0610231651p752da52dsb258b59c6dff3f15@mail.gmail.com> Message-ID: <57c63afe0610231652x58abaf91s4a5b9a4d21ccf38f@mail.gmail.com> This was intended for the list.... ---------- Forwarded message ---------- From: David Chelimsky Date: Oct 23, 2006 6:51 PM Subject: Re: [Rspec-users] overriding mock expectations To: Micah Martin On 10/23/06, Micah Martin wrote: > > There is one annoyance I'm encountering with the Mock API in rSpec. > Overall it works well, as far as dynamic mocks go ;) Hmmmmm. >... but there's this one > thing... It doesn't allow overriding of expectations. > > example: > > m = mock("blah") > m.should_receive(:one).any_number_of_times().and_return(1) > m.should_receive(:one).and_return(1) > > The second call to should_receive is ignored. I believe it would be most > convenient if the second call to should_receive would override the first. > > Why? > > What I would like to do is define all the should_receives once in the setup > using any_number_of_times. This establishes a default context. Then in > each spec I'd like to override a specific should_receive relevant to the > spec. > > Without being able to override, I am force to define all the should_receives > for each spec..... duplication. > > Is there another solution I'm missing? In 0.7 (currently in trunk - to be released within a couple of weeks - maybe even this week), you can do something close: setup do mock = mock("blah") mock.stub!(:msg).and_return(value) end specify "something" do mock.should_receive(:msg).and_return(other_value) end Would that solve your problem? If so, you can build it now from trunk, though you will have some changes you'll need to to your existing specs. See the CHANGES file in the trunk root if you decide to do this. Cheers, David > > Micah Martin > 8th Light, Inc. > www.8thlight.com From demmer12 at fastmail.us Mon Oct 23 22:42:53 2006 From: demmer12 at fastmail.us (Craig Demyanovich) Date: Mon, 23 Oct 2006 22:42:53 -0400 Subject: [Rspec-users] overriding mock expectations In-Reply-To: <27EAA06F-10F5-4BAB-97A6-941101752114@8thlight.com> References: <27EAA06F-10F5-4BAB-97A6-941101752114@8thlight.com> Message-ID: <5B13DA48-3F54-41DB-9304-BFF7232700A0@fastmail.us> On Oct 23, 2006, at 6:34 PM, Micah Martin wrote: > There is one annoyance I'm encountering with the Mock API in > rSpec. Overall it works well, as far as dynamic mocks go ;)... but > there's this one thing... It doesn't allow overriding of expectations. > > example: > > m = mock("blah") > m.should_receive(:one).any_number_of_times().and_return(1) > m.should_receive(:one).and_return(1) > > The second call to should_receive is ignored. I believe it would > be most convenient if the second call to should_receive would > override the first. > > Why? > > What I would like to do is define all the should_receives once in > the setup using any_number_of_times. This establishes a default > context. Then in each spec I'd like to override a specific > should_receive relevant to the spec. > > Without being able to override, I am force to define all the > should_receives for each spec..... duplication. > > Is there another solution I'm missing? I'm wondering if you should just move the specs that you want to override to another context, since the setup is different. Curious, Craig From micah at 8thlight.com Mon Oct 23 23:02:47 2006 From: micah at 8thlight.com (Micah Martin) Date: Mon, 23 Oct 2006 22:02:47 -0500 Subject: [Rspec-users] overriding mock expectations In-Reply-To: <0CEACD6D-EC4A-4B15-86B6-B0828387C7C8@pobox.com> References: <27EAA06F-10F5-4BAB-97A6-941101752114@8thlight.com> <0CEACD6D-EC4A-4B15-86B6-B0828387C7C8@pobox.com> Message-ID: <87C92D7F-FCD0-4D35-A17B-F4A976EC2706@8thlight.com> Here's a quick fix.... in mock.rb in the add method ... def add(expectation_class, expected_from, sym, &block) define_expected_method(sym) expectation = expectation_class.send(:new, @name, @expectation_ordering, expected_from, sym, block_given? ? block : nil) @expectations << expectation expectation end Line 47 could read: @expectations.insert(0, expectation) instead of @expectation << expectation As for a test...er spec.... specify "Mock expectations are overrideable" do m = mock("blah") m.should_not_receive(:one) m.should_receive(:one) m.one end Micah Martin 8th Light, Inc. www.8thlight.com On Oct 23, 2006, at 5:55 PM, Steven R. Baker wrote: >> What I would like to do is define all the should_receives once in >> the setup using any_number_of_times. This establishes a default >> context. Then in each spec I'd like to override a specific >> should_receive relevant to the spec. >> >> Without being able to override, I am force to define all the >> should_receives for each spec..... duplication. >> >> Is there another solution I'm missing? > > We need you to write a patch for this. > > If you don't feel confident doing it, I'll take a crack at it when > I get home if you harass me on IM. > > srbaker0 yahoo > stevenrbaker at mac.com .mac > srbaker0 at hotmail.com msn > > -Steven > > >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061023/bd32afd3/attachment.html From dchelimsky at gmail.com Tue Oct 24 05:41:08 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 24 Oct 2006 04:41:08 -0500 Subject: [Rspec-users] overriding mock expectations In-Reply-To: <5B13DA48-3F54-41DB-9304-BFF7232700A0@fastmail.us> References: <27EAA06F-10F5-4BAB-97A6-941101752114@8thlight.com> <5B13DA48-3F54-41DB-9304-BFF7232700A0@fastmail.us> Message-ID: <57c63afe0610240241l2c442947tbe2c692221fa2752@mail.gmail.com> On 10/23/06, Craig Demyanovich wrote: > On Oct 23, 2006, at 6:34 PM, Micah Martin wrote: > > > There is one annoyance I'm encountering with the Mock API in > > rSpec. Overall it works well, as far as dynamic mocks go ;)... but > > there's this one thing... It doesn't allow overriding of expectations. > > > > example: > > > > m = mock("blah") > > m.should_receive(:one).any_number_of_times().and_return(1) > > m.should_receive(:one).and_return(1) > > > > The second call to should_receive is ignored. I believe it would > > be most convenient if the second call to should_receive would > > override the first. > > > > Why? > > > > What I would like to do is define all the should_receives once in > > the setup using any_number_of_times. This establishes a default > > context. Then in each spec I'd like to override a specific > > should_receive relevant to the spec. > > > > Without being able to override, I am force to define all the > > should_receives for each spec..... duplication. > > > > Is there another solution I'm missing? > > I'm wondering if you should just move the specs that you want to > override to another context, since the setup is different. What Micah describes is a fairly common need. The idea is that the defaults are part of setup, but the overrides are part of a given spec. The stubbing feature coming up in 0.7 supports this very well. And using stub! in the setup and should_receive in the specs helps to clarify what is "interesting" in a given spec. > > Curious, > Craig > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Tue Oct 24 05:34:27 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 24 Oct 2006 04:34:27 -0500 Subject: [Rspec-users] Fwd: Fwd: overriding mock expectations In-Reply-To: <57c63afe0610240231o34272f65u8f583b59c185909@mail.gmail.com> References: <27EAA06F-10F5-4BAB-97A6-941101752114@8thlight.com> <57c63afe0610231651p752da52dsb258b59c6dff3f15@mail.gmail.com> <57c63afe0610231652x58abaf91s4a5b9a4d21ccf38f@mail.gmail.com> <40EDF710-70D5-4FC1-9F30-A57A8D0E8269@8thlight.com> <57c63afe0610240231o34272f65u8f583b59c185909@mail.gmail.com> Message-ID: <57c63afe0610240234m7a91b545y9349ad70e5176bb@mail.gmail.com> again, intended for the list - hitting reply on these goes to the individual, not the list - i need to fix that. ---------- Forwarded message ---------- From: David Chelimsky Date: Oct 24, 2006 4:31 AM Subject: Re: [Rspec-users] Fwd: overriding mock expectations To: Micah Martin On 10/23/06, Micah Martin wrote: > On Oct 23, 2006, at 6:52 PM, David Chelimsky wrote: > > In 0.7 (currently in trunk - to be released within a couple of weeks - > > maybe even this week), you can do something close: > > > > setup do > > mock = mock("blah") > > mock.stub!(:msg).and_return(value) > > end > > > > specify "something" do > > mock.should_receive(:msg).and_return(other_value) > > end > > > > Would that solve your problem? > > Off the bat, it looks like that'd do. It seems like should_receive > (...).any_number_of_times is virtually the same as stubbing. Is that > correct? Yes, with one additional bit. Stub messages and mock expectations are stored separately. This allows the framework to first look for a mock expectation and then look for a stub if it can't find a mock expectation. Under the hood, they are instances of the subtypes of the same class and the message expectation is actually should_receive(:msg).any_number_of_times, as you suggest. > > Micah > From micah at 8thlight.com Tue Oct 24 09:43:31 2006 From: micah at 8thlight.com (Micah Martin) Date: Tue, 24 Oct 2006 08:43:31 -0500 Subject: [Rspec-users] 1 should be 2. huh? Message-ID: <2A2A2FAA-2BC8-4756-8BAB-08A5250681D5@8thlight.com> There's another quirk I wanted to bring up. It's about the failure message with should_equal and should_be. x.should_equal 2 a.should_not_be nil When they fail they yield messages like: 1 should equal 2 nil should not be nil When I'm caught off guard, which can be often, these messages confuse me. 1 should equal 2? No it shouldn't. nil should not be nil? But they are the same! You get my drift? When taken out side the context of a specification, these statements are just absurd. In my humble opinion, these messages should include their context and read like this: x should equal 2 but was 1 a should not be nil but was nil I realize there might be an issue printing the expression that gets evaluated, but you guys have done some cool magic to this point. Have you got a bit more up your sleeves? Micah Martin 8th Light, Inc. www.8thlight.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061024/21a37e7b/attachment.html From dchelimsky at gmail.com Tue Oct 24 09:47:29 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 24 Oct 2006 08:47:29 -0500 Subject: [Rspec-users] 1 should be 2. huh? In-Reply-To: <2A2A2FAA-2BC8-4756-8BAB-08A5250681D5@8thlight.com> References: <2A2A2FAA-2BC8-4756-8BAB-08A5250681D5@8thlight.com> Message-ID: <57c63afe0610240647i5e93eda6h54163936719adb64@mail.gmail.com> Can you please submit an RFE on this one? http://rubyforge.org/tracker/?group_id=797 Thanks, David On 10/24/06, Micah Martin wrote: > > There's another quirk I wanted to bring up. It's about the failure message > with should_equal and should_be. > > x.should_equal 2 > a.should_not_be nil > > When they fail they yield messages like: > > 1 should equal 2 > nil should not be nil > > When I'm caught off guard, which can be often, these messages confuse me. 1 > should equal 2? No it shouldn't. nil should not be nil? But they are the > same! > You get my drift? When taken out side the context of a specification, these > statements are just absurd. > > In my humble opinion, these messages should include their context and read > like this: > > x should equal 2 but was 1 > a should not be nil but was nil > > I realize there might be an issue printing the expression that gets > evaluated, but you guys have done some cool magic to this point. Have you > got a bit more up your sleeves? > > Micah Martin > 8th Light, Inc. > www.8thlight.com > > > > > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From aslak.hellesoy at gmail.com Tue Oct 24 19:45:54 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 25 Oct 2006 01:45:54 +0200 Subject: [Rspec-users] 1 should be 2. huh? In-Reply-To: <57c63afe0610240647i5e93eda6h54163936719adb64@mail.gmail.com> References: <2A2A2FAA-2BC8-4756-8BAB-08A5250681D5@8thlight.com> <57c63afe0610240647i5e93eda6h54163936719adb64@mail.gmail.com> Message-ID: <8d961d900610241645t73f5db1eld5ea7da41e56492b@mail.gmail.com> On 10/24/06, David Chelimsky wrote: > Can you please submit an RFE on this one? > > http://rubyforge.org/tracker/?group_id=797 > > Thanks, > David > > On 10/24/06, Micah Martin wrote: > > > > There's another quirk I wanted to bring up. It's about the failure message > > with should_equal and should_be. > > > > x.should_equal 2 > > a.should_not_be nil > > > > When they fail they yield messages like: > > The simple solution would be: > > 1 should equal 2 1 (actual value) should equal 2 (expected value) > > nil should not be nil > > > > When I'm caught off guard, which can be often, these messages confuse me. 1 > > should equal 2? No it shouldn't. nil should not be nil? But they are the > > same! > > You get my drift? When taken out side the context of a specification, these > > statements are just absurd. > > > > In my humble opinion, these messages should include their context and read > > like this: > > > > x should equal 2 but was 1 > > a should not be nil but was nil > > > > I realize there might be an issue printing the expression that gets > > evaluated, but you guys have done some cool magic to this point. Have you > > got a bit more up your sleeves? > > I'll pick up the glove on this. It will be a fun exercise in parsing the source file to extract the variable names. We have all the info available (file, line number) in the stack trace. Could you file an RFE in the form of failing specs expressing what you want the error message to be? Hint: lambda do x = 1 x.should_equal 2 end.should_raise(ExpectationNotMetError, "x should equal 2 but was 1") -enough to cover all the cases you can think of? Aslak > > Micah Martin > > 8th Light, Inc. > > www.8thlight.com > > > > > > > > > > _______________________________________________ > > Rspec-users mailing list > > Rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From micah at 8thlight.com Tue Oct 24 23:08:22 2006 From: micah at 8thlight.com (Micah Martin) Date: Tue, 24 Oct 2006 22:08:22 -0500 Subject: [Rspec-users] mock parameter problem Message-ID: <081A1C0E-69F7-4F98-AD2B-D1FC9608A365@8thlight.com> Here's another one. spec: m = mock("blah") m.should_receive(:foo).with(1) code: m.foo(2) Failure message: Mock 'blah' expected 'foo' once, but received it 0 times ------ Twice now I've gotten this failure message and wasted time trying to understand why the method foo() was not being called despite all evidence suggesting that it was being called. The problem is that rSpec is lying to me. foo() is being called. The parameter is not what's expected, but foo() is being called. I'm not sure how fancy you guys want to get with the failure messages, but more information is needed. Maybe: Mock 'blah' expected 'foo(1)' once, but received it 0 times or Mock 'blah' expected 'foo' once with 1, but received it 1 time with 2 or to avoid the problem printing unknown parameters Mock 'blah' expected 'foo' with one parameter, but received it 1 time with the wrong parameter Perhaps existing mock frameworks already have elegant terminology that could be referenced. I'll submit an RFE as soon as I figure out how. Micah Martin 8th Light, Inc. www.8thlight.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061024/fe07aa2d/attachment.html From dchelimsky at gmail.com Wed Oct 25 00:00:25 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 24 Oct 2006 23:00:25 -0500 Subject: [Rspec-users] Fwd: mock parameter problem In-Reply-To: <57c63afe0610242100k3164516epe59834c0d5da83f4@mail.gmail.com> References: <081A1C0E-69F7-4F98-AD2B-D1FC9608A365@8thlight.com> <57c63afe0610242100k3164516epe59834c0d5da83f4@mail.gmail.com> Message-ID: <57c63afe0610242100w1e4f4038y72d84a8008774bd6@mail.gmail.com> On 10/24/06, Micah Martin wrote: > > Here's another one. > > spec: > > m = mock("blah") > m.should_receive(:foo).with(1) > > code: > > m.foo(2) > > Failure message: > > Mock 'blah' expected 'foo' once, but received it 0 times > > ------ > > Twice now I've gotten this failure message and wasted time trying to > understand why the method foo() was not being called despite all evidence > suggesting that it was being called. The problem is that rSpec is lying to > me. foo() is being called. The parameter is not what's expected, but foo() > is being called. > > I'm not sure how fancy you guys want to get with the failure messages, but > more information is needed. Maybe: > > Mock 'blah' expected 'foo(1)' once, but received it 0 times > or > Mock 'blah' expected 'foo' once with 1, but received it 1 time with 2 > or to avoid the problem printing unknown parameters > Mock 'blah' expected 'foo' with one parameter, but received it 1 time with > the wrong parameter This is actually fixed in the trunk. So now if you do this: mock.should_receive(:foo).with(:arg) mock.blah(:wrong_arg) You'll get this: Mock 'blah' expected :foo with [:arg] once, and received it 0 times. > > Perhaps existing mock frameworks already have elegant terminology that could > be referenced. > > I'll submit an RFE as soon as I figure out how. To raise RFE (Request for Enhancement): 1. go to http://rubyforge.org/tracker/?atid=3152&group_id=797&func=browse 2. Click "Submit New" The rest should be self explanatory. Thanks for pointing these things out, and thanks for using our mock framework! > > Micah Martin > 8th Light, Inc. > www.8thlight.com > > > > > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From micah at 8thlight.com Wed Oct 25 00:11:58 2006 From: micah at 8thlight.com (Micah Martin) Date: Tue, 24 Oct 2006 23:11:58 -0500 Subject: [Rspec-users] Fwd: mock parameter problem In-Reply-To: <57c63afe0610242100w1e4f4038y72d84a8008774bd6@mail.gmail.com> References: <081A1C0E-69F7-4F98-AD2B-D1FC9608A365@8thlight.com> <57c63afe0610242100k3164516epe59834c0d5da83f4@mail.gmail.com> <57c63afe0610242100w1e4f4038y72d84a8008774bd6@mail.gmail.com> Message-ID: On Oct 24, 2006, at 11:00 PM, David Chelimsky wrote: > This is actually fixed in the trunk. So now if you do this: > > mock.should_receive(:foo).with(:arg) > mock.blah(:wrong_arg) > > You'll get this: > > Mock 'blah' expected :foo with [:arg] once, and received it 0 times. Wonderful! The next release is going to be a value packed release! Micah From alan.maybourne at hotmail.co.uk Wed Oct 25 16:13:19 2006 From: alan.maybourne at hotmail.co.uk (alan maybourne) Date: Wed, 25 Oct 2006 20:13:19 +0000 Subject: [Rspec-users] fixtures data persists? Message-ID: I'm not sure if this is a feature or a bug, but if I load a set of fixtures in one context, the data remains in the database and is available to the next context, even if the next context doesn't explicitly load that set of fixtures context "saved User objects" do fixtures :users end context "new User objects" do end if I call User.find(1) from a spec in the 'new User objects' context, it'll find the object loaded in the earlier context. I'd like to disable this if possible. Could someone tell me how? thanks alan _________________________________________________________________ Windows Live? Messenger has arrived. Click here to download it for free! http://imagine-msn.com/messenger/launch80/?locale=en-gb From chrisjroos at gmail.com Thu Oct 26 09:40:46 2006 From: chrisjroos at gmail.com (Chris Roos) Date: Thu, 26 Oct 2006 14:40:46 +0100 Subject: [Rspec-users] reply-to address of this list Message-ID: <3a5e51050610260640s3b8973e3jf9b67bd0826c9172@mail.gmail.com> Could one of the admins maybe specify the reply-to address for this mailing list? It's frustrating to realise you've just sent a message to an individual, having meant to send to list. Chris From dchelimsky at gmail.com Thu Oct 26 10:02:33 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 26 Oct 2006 09:02:33 -0500 Subject: [Rspec-users] reply-to address of this list In-Reply-To: <3a5e51050610260640s3b8973e3jf9b67bd0826c9172@mail.gmail.com> References: <3a5e51050610260640s3b8973e3jf9b67bd0826c9172@mail.gmail.com> Message-ID: <57c63afe0610260702p13356fb3s81bfe0ceeae96a8a@mail.gmail.com> I'm waiting to get the admin pw from the former admin. This will be the first thing I do once I have that. Cheers, David On 10/26/06, Chris Roos wrote: > Could one of the admins maybe specify the reply-to address for this > mailing list? It's frustrating to realise you've just sent a message > to an individual, having meant to send to list. > > Chris > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From phlip2005 at gmail.com Thu Oct 26 10:24:25 2006 From: phlip2005 at gmail.com (Phlip) Date: Thu, 26 Oct 2006 07:24:25 -0700 Subject: [Rspec-users] reply-to address of this list References: <3a5e51050610260640s3b8973e3jf9b67bd0826c9172@mail.gmail.com> Message-ID: <063601c6f90a$7425eeb0$81a1b04c@Marley> Chris Roos wrote: > Could one of the admins maybe specify the reply-to address for this > mailing list? It's frustrating to realise you've just sent a message > to an individual, having meant to send to list. > http://rubyforge.org/mailman/listinfo/rspec-users Mailman's default is to the individual, which is completely wrong for any technical group. I think a RubyForge administrator (such as Tom Copeland) should tweak their installation so all their mailmen default to the group, including new mailmen for new projects yet to come. -- Phlip http://www.greencheese.us/ZeekLand <-- NOT a blog!!! From aslak.hellesoy at gmail.com Thu Oct 26 11:25:02 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 26 Oct 2006 17:25:02 +0200 Subject: [Rspec-users] fixtures data persists? In-Reply-To: References: Message-ID: <8d961d900610260825h29d7136bhc7dc8c48663e7988@mail.gmail.com> On 10/25/06, alan maybourne wrote: > I'm not sure if this is a feature or a bug, but if I load a set of fixtures > in one context, the data remains in the database and is available to the > next context, even if the next context doesn't explicitly load that set of > fixtures > > context "saved User objects" do > fixtures :users > end > > context "new User objects" do > > end > > if I call User.find(1) from a spec in the 'new User objects' context, it'll > find the object loaded in the earlier context. I'd like to disable this if > possible. Could someone tell me how? > This is a Rails feature. You'd get the same behaviour with Test::Unit. See the two "Should fixtures be transactional?" threads here: http://rubyforge.org/pipermail/rspec-users/2006-October/thread.html Please ask further questions about this in the Rails forum. > thanks > alan > > _________________________________________________________________ > Windows Live? Messenger has arrived. Click here to download it for free! > http://imagine-msn.com/messenger/launch80/?locale=en-gb > > > > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From micah at 8thlight.com Thu Oct 26 13:15:43 2006 From: micah at 8thlight.com (Micah Martin) Date: Thu, 26 Oct 2006 12:15:43 -0500 Subject: [Rspec-users] rescue_action overridden Message-ID: <7BC0B411-8A97-4DF3-99CA-0A8963876D17@8thlight.com> In rspec_on_rails, method setup_with_controller, exists the following line: @controller_class.send(:define_method, :rescue_action) { | e| raise e } I understand that this is a better way to handle errors than the default. However, it gets in the way when you've defined your own rescue_action and are trying to test it. No good solutions came to me while I pondered the problem. Anyhow, there it is. Micah Martin 8th Light, Inc. www.8thlight.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061026/76a06f28/attachment.html From richcollins at gmail.com Fri Oct 27 14:07:42 2006 From: richcollins at gmail.com (Rich Collins) Date: Fri, 27 Oct 2006 11:07:42 -0700 Subject: [Rspec-users] scaffold_resource should create specs instead of tests Message-ID: Is this in the works? From micah at 8thlight.com Fri Oct 27 16:34:11 2006 From: micah at 8thlight.com (Micah Martin) Date: Fri, 27 Oct 2006 15:34:11 -0500 Subject: [Rspec-users] and_return broken when using arrays Message-ID: m = mock("blah") m.should_receive(:foo).and_return([1, 2, 3]) When foo() is called on the mock it returns the first elements of the array, 1. Shouldn't it return the whole array? Micah Martin 8th Light, Inc. www.8thlight.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061027/60d8fce9/attachment.html From dchelimsky at gmail.com Fri Oct 27 19:01:02 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 27 Oct 2006 18:01:02 -0500 Subject: [Rspec-users] and_return broken when using arrays In-Reply-To: References: Message-ID: <57c63afe0610271601y6cc4d2dah424bfec33d233beb@mail.gmail.com> On 10/27/06, Micah Martin wrote: > > m = mock("blah") > m.should_receive(:foo).and_return([1, 2, 3]) > > When foo() is called on the mock it returns the first elements of the array, > 1. Shouldn't it return the whole array? Yes it should. And it does in 0.7. The "feature" that you are experiencing was an early attempt to support consecutive return values. For 0.6, if you want it to return an Array you have to wrap it in an array: m.should_receive(:foo).and_return([[1, 2, 3]]) 0.7 is coming up very soon though! David > > Micah Martin > 8th Light, Inc. > www.8thlight.com > > > > > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From aslak.hellesoy at gmail.com Fri Oct 27 19:09:50 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 28 Oct 2006 00:09:50 +0100 Subject: [Rspec-users] and_return broken when using arrays In-Reply-To: References: Message-ID: <8d961d900610271609vfece3bcn221dbd71dfe89e02@mail.gmail.com> On 10/27/06, Micah Martin wrote: > > m = mock("blah") > m.should_receive(:foo).and_return([1, 2, 3]) > > When foo() is called on the mock it returns the first elements of the array, > 1. Shouldn't it return the whole array? > rspec version? the semantics of and_return have recently changed on trunk. see changelog. > Micah Martin > 8th Light, Inc. > www.8thlight.com > > > > > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From jeff at jefdean.com Sat Oct 28 03:37:03 2006 From: jeff at jefdean.com (Jeff Dean) Date: Sat, 28 Oct 2006 03:37:03 -0400 Subject: [Rspec-users] RSpec, REST and different formats Message-ID: <246e442a0610280037o29bc2a6cia41e489d5ca1393c@mail.gmail.com> Is anyone using RSpec with RESTful rails apps? In my rails controllers I check request.respond_to? and render different views accordingly. I noticed that the get method in the rails plugin doesn't accept headers: controller_mixin.rb line 92 def get(action, parameters = nil) @request.env['REQUEST_METHOD'] = 'GET' process action, parameters end Has anyone found a way around this? Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061028/9c428c7c/attachment.html From aslak.hellesoy at gmail.com Sat Oct 28 05:44:32 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 28 Oct 2006 10:44:32 +0100 Subject: [Rspec-users] scaffold_resource should create specs instead of tests In-Reply-To: References: Message-ID: <8d961d900610280244i7ba6db26uaf6a17e65dd54aa1@mail.gmail.com> On 10/27/06, Rich Collins wrote: > Is this in the works? Here is the RFE: http://rubyforge.org/tracker/index.php?func=detail&aid=6098&group_id=797&atid=9464 David Goodland (other lurker on the list) said he was working on it but I think he got interrupted by life :-) It will be done eventually by someone. I just don't know who that someone is yet. Aslak > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sat Oct 28 12:46:34 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 28 Oct 2006 11:46:34 -0500 Subject: [Rspec-users] RSpec, REST and different formats In-Reply-To: <246e442a0610280037o29bc2a6cia41e489d5ca1393c@mail.gmail.com> References: <246e442a0610280037o29bc2a6cia41e489d5ca1393c@mail.gmail.com> Message-ID: <57c63afe0610280946q1232a036g555f7a1d2067683d@mail.gmail.com> On 10/28/06, Jeff Dean wrote: > Is anyone using RSpec with RESTful rails apps? In my rails controllers I > check request.respond_to? and render different views accordingly. > > I noticed that the get method in the rails plugin doesn't accept headers: > > controller_mixin.rb line 92 > def get(action, parameters = nil) > @request.env['REQUEST_METHOD'] = 'GET' > process action, parameters > end > > Has anyone found a way around this? Hi Jeff. We're getting ready to release a new version of the plugin so now is a good time to at least consider addressing this. Can you write an example of how you'd want to be able to write the spec (and controller code) for a restful get request? Don't worry about how rspec would do it. I just want to know what you want it to do. Thanks, David > > Jeff > > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From jeff at jefdean.com Sat Oct 28 16:30:37 2006 From: jeff at jefdean.com (Jeff Dean) Date: Sat, 28 Oct 2006 16:30:37 -0400 Subject: [Rspec-users] RSpec, REST and different formats In-Reply-To: <57c63afe0610280946q1232a036g555f7a1d2067683d@mail.gmail.com> References: <246e442a0610280037o29bc2a6cia41e489d5ca1393c@mail.gmail.com> <57c63afe0610280946q1232a036g555f7a1d2067683d@mail.gmail.com> Message-ID: <246e442a0610281330s293203je7b10bf374770299@mail.gmail.com> Thanks for the quick reply - I would be looking for a way to easily specify the most common types in shorthand, but have the ability to specify full HTTP headers if I want to. Ideally I would look for a third parameter in the get/post/put/delete methods that accepts a hash of http headers like http://api.rubyonrails.org/classes/ActionController/Integration/Session.html#M000083. The spec might look like: context "A get to /index" do specify "from a browser should show html" do get :index # should statements... end specify "in xml format should render xml" do get :index, {}, {:content_type=>'application/xml', :accept => 'application/xml'} # should statements... end end It seems like the convention in rails right now is to request rss and atom feeds by using the .rss/.atom extensions and changing the 'accepts' header in application.rb - so that leaves us with 4 fairly standard request types: html, javascript, xml and mobile devices (which I know little about). Since these will be so common, some syntactic sugar would be nice as well - maybe something like: context "A get to /index" do specify "from an ajax call should render rjs" do get :index, {}, :format => :js # where the magic word 'format' correctly sets the accept header # should statements... end end References: - http://www.loudthinking.com/arc/000572.html I'd love to see these generators and plugins become part of core, too. After working with RSpec for a few days now, I doubt I'll ever go back to the unit and functional tests. Thanks for the hard work - Jeff On 10/28/06, David Chelimsky wrote: > > On 10/28/06, Jeff Dean wrote: > > Is anyone using RSpec with RESTful rails apps? In my rails controllers > I > > check request.respond_to? and render different views accordingly. > > > > I noticed that the get method in the rails plugin doesn't accept > headers: > > > > controller_mixin.rb line 92 > > def get(action, parameters = nil) > > @request.env['REQUEST_METHOD'] = 'GET' > > process action, parameters > > end > > > > Has anyone found a way around this? > > Hi Jeff. We're getting ready to release a new version of the plugin so > now is a good time to at least consider addressing this. Can you write > an example of how you'd want to be able to write the spec (and > controller code) for a restful get request? Don't worry about how > rspec would do it. I just want to know what you want it to do. > > Thanks, > David > > > > > Jeff > > > > _______________________________________________ > > Rspec-users mailing list > > Rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061028/78ca665d/attachment-0001.html From jeff at jefdean.com Sat Oct 28 21:05:45 2006 From: jeff at jefdean.com (Jeff Dean) Date: Sat, 28 Oct 2006 21:05:45 -0400 Subject: [Rspec-users] RSpec, REST and different formats In-Reply-To: <246e442a0610281330s293203je7b10bf374770299@mail.gmail.com> References: <246e442a0610280037o29bc2a6cia41e489d5ca1393c@mail.gmail.com> <57c63afe0610280946q1232a036g555f7a1d2067683d@mail.gmail.com> <246e442a0610281330s293203je7b10bf374770299@mail.gmail.com> Message-ID: <246e442a0610281805t428bed4t1dc2ab7aa13af857@mail.gmail.com> It looks like there's another way to do this in rails I just found in AWDWR: xhr(:get, :add_to_cart, :id => 11) I'm not sure if there are other methods like xml() etc... but that looks easier than the example I provided below. On 10/28/06, Jeff Dean wrote: > > Thanks for the quick reply - > > I would be looking for a way to easily specify the most common types in > shorthand, but have the ability to specify full HTTP headers if I want to. > Ideally I would look for a third parameter in the get/post/put/delete > methods that accepts a hash of http headers like > http://api.rubyonrails.org/classes/ActionController/Integration/Session.html#M000083. > The spec might look like: > > context "A get to /index" do > > > specify "from a browser should show html" do > get :index > # should statements... > > end > > specify "in xml format should render xml > " do > get :index, {}, {:content_type=>'application/xml', :accept => 'application/xml'} > # should statements... > end > > > end > > It seems like the convention in rails right now is to request rss and atom > feeds by using the .rss/.atom extensions and changing the 'accepts' header > in application.rb - so that leaves us with 4 fairly standard request > types: html, javascript, xml and mobile devices (which I know little > about). Since these will be so common, some syntactic sugar would be nice > as well - maybe something like: > > context "A get to /index" do > > > specify "from an ajax call should render rjs" do > get :index, {}, :format => :js # where the magic word 'format' correctly sets the accept header > > # should statements... > end > > end > > References: > > - http://www.loudthinking.com/arc/000572.html > > I'd love to see these generators and plugins become part of core, too. > After working with RSpec for a few days now, I doubt I'll ever go back to > the unit and functional tests. Thanks for the hard work - > > Jeff > > > On 10/28/06, David Chelimsky wrote: > > > > On 10/28/06, Jeff Dean wrote: > > > Is anyone using RSpec with RESTful rails apps? In my rails > > controllers I > > > check request.respond_to? and render different views accordingly. > > > > > > I noticed that the get method in the rails plugin doesn't accept > > headers: > > > > > > controller_mixin.rb line 92 > > > def get(action, parameters = nil) > > > @request.env['REQUEST_METHOD'] = 'GET' > > > process action, parameters > > > end > > > > > > Has anyone found a way around this? > > > > Hi Jeff. We're getting ready to release a new version of the plugin so > > now is a good time to at least consider addressing this. Can you write > > an example of how you'd want to be able to write the spec (and > > controller code) for a restful get request? Don't worry about how > > rspec would do it. I just want to know what you want it to do. > > > > Thanks, > > David > > > > > > > > Jeff > > > > > > _______________________________________________ > > > Rspec-users mailing list > > > Rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > _______________________________________________ > > Rspec-users mailing list > > Rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061028/e1372d49/attachment.html From jchris at mfdz.com Sun Oct 29 04:29:43 2006 From: jchris at mfdz.com (Chris Anderson) Date: Sun, 29 Oct 2006 02:29:43 -0700 Subject: [Rspec-users] RSpec, REST and different formats In-Reply-To: <246e442a0610281805t428bed4t1dc2ab7aa13af857@mail.gmail.com> References: <246e442a0610280037o29bc2a6cia41e489d5ca1393c@mail.gmail.com> <57c63afe0610280946q1232a036g555f7a1d2067683d@mail.gmail.com> <246e442a0610281330s293203je7b10bf374770299@mail.gmail.com> <246e442a0610281805t428bed4t1dc2ab7aa13af857@mail.gmail.com> Message-ID: Of course, it is important to note that Rails also supports a few other http verbs in addition to get: post, put and delete. I really think rspec will be the ideal vehicle for Rails integration tests, once it is mature. I look forward to the day I can start a new application by writing high-level integration specs, and then see those tests pass as I stitch together the controllers and models. Chris On 10/28/06, Jeff Dean wrote: > > It looks like there's another way to do this in rails I just found in > AWDWR: > > xhr(:get, :add_to_cart, :id => 11) > > I'm not sure if there are other methods like xml() etc... but that looks > easier than the example I provided below. > > On 10/28/06, Jeff Dean wrote: > > > > Thanks for the quick reply - > > > > I would be looking for a way to easily specify the most common types in > > shorthand, but have the ability to specify full HTTP headers if I want to. > > Ideally I would look for a third parameter in the get/post/put/delete > > methods that accepts a hash of http headers like http://api.rubyonrails.org/classes/ActionController/Integration/Session.html#M000083 > > . The spec might look like: > > > > context "A get to /index" do > > > > > > specify "from a browser should show html" do > > get :index > > # should statements... > > > > end > > > > specify > > "in xml format should render xml > > " do > > get :index, {}, {:content_type=>'application/xml', :accept => 'application/xml'} > > # should statements... > > end > > > > > > end > > > > It seems like the convention in rails right now is to request rss and > > atom feeds by using the .rss/.atom extensions and changing the 'accepts' > > header in application.rb - so that leaves us with 4 fairly standard > > request types: html, javascript, xml and mobile devices (which I know little > > about). Since these will be so common, some syntactic sugar would be nice > > as well - maybe something like: > > > > context "A get to /index" do > > > > > > specify "from an ajax call should render rjs" do > > get :index, {}, :format => :js # where the magic word 'format' correctly sets the accept header > > > > > > # should statements... > > end > > > > end > > > > References: > > > > - http://www.loudthinking.com/arc/000572.html > > > > I'd love to see these generators and plugins become part of core, too. > > After working with RSpec for a few days now, I doubt I'll ever go back to > > the unit and functional tests. Thanks for the hard work - > > > > Jeff > > > > > > On 10/28/06, David Chelimsky < dchelimsky at gmail.com> wrote: > > > > > > On 10/28/06, Jeff Dean wrote: > > > > Is anyone using RSpec with RESTful rails apps? In my rails > > > controllers I > > > > check request.respond_to? and render different views accordingly. > > > > > > > > I noticed that the get method in the rails plugin doesn't accept > > > headers: > > > > > > > > controller_mixin.rb line 92 > > > > def get(action, parameters = nil) > > > > @request.env['REQUEST_METHOD'] = 'GET' > > > > process action, parameters > > > > end > > > > > > > > Has anyone found a way around this? > > > > > > Hi Jeff. We're getting ready to release a new version of the plugin so > > > now is a good time to at least consider addressing this. Can you write > > > > > > an example of how you'd want to be able to write the spec (and > > > controller code) for a restful get request? Don't worry about how > > > rspec would do it. I just want to know what you want it to do. > > > > > > Thanks, > > > David > > > > > > > > > > > Jeff > > > > > > > > _______________________________________________ > > > > Rspec-users mailing list > > > > Rspec-users at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > _______________________________________________ > > > Rspec-users mailing list > > > Rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > -- Chris Anderson http://mfdz.com/jchris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061029/3b7a23a6/attachment.html From dchelimsky at gmail.com Sun Oct 29 05:17:50 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 29 Oct 2006 04:17:50 -0600 Subject: [Rspec-users] RSpec, REST and different formats In-Reply-To: References: <246e442a0610280037o29bc2a6cia41e489d5ca1393c@mail.gmail.com> <57c63afe0610280946q1232a036g555f7a1d2067683d@mail.gmail.com> <246e442a0610281330s293203je7b10bf374770299@mail.gmail.com> <246e442a0610281805t428bed4t1dc2ab7aa13af857@mail.gmail.com> Message-ID: <57c63afe0610290217s938f211w7f0d10e0dfac41b4@mail.gmail.com> On 10/29/06, Chris Anderson wrote: > Of course, it is important to note that Rails also supports a few other http > verbs in addition to get: post, put and delete. > > I really think rspec will be the ideal vehicle for Rails integration tests, > once it is mature. I look forward to the day I can start a new application > by writing high-level integration specs, and then see those tests pass as I > stitch together the controllers and models. Ah, if only maturation didn't require real time! Thanks for sharing your vision. We feel the same way. Cheers, David > > Chris > > > On 10/28/06, Jeff Dean wrote: > > It looks like there's another way to do this in rails I just found in > AWDWR: > > > > xhr(:get, :add_to_cart, :id => 11) > > > > I'm not sure if there are other methods like xml() etc... but that looks > easier than the example I provided below. > > > > > > > > On 10/28/06, Jeff Dean < jeff at jefdean.com> wrote: > > > Thanks for the quick reply - > > > > > > I would be looking for a way to easily specify the most common types in > shorthand, but have the ability to specify full HTTP headers if I want to. > Ideally I would look for a third parameter in the get/post/put/delete > methods that accepts a hash of http headers like > http://api.rubyonrails.org/classes/ActionController/Integration/Session.html#M000083 > . The spec might look like: > > > > > > context "A get to /index" do > > > > > > > > > specify "from a browser should show html" do > > > get :index > > > # should statements... > > > > > > end > > > > > > specify > > > > > > "in xml format should render xml > > > " do > > > get :index, {}, {:content_type=>'application/xml', > :accept => 'application/xml'} > > > # should statements... > > > end > > > > > > > > > end > > > > > > It seems like the convention in rails right now is to request rss and > atom feeds by using the .rss/.atom extensions and changing the 'accepts' > header in application.rb - so that leaves us with 4 fairly standard request > types: html, javascript, xml and mobile devices (which I know little about). > Since these will be so common, some syntactic sugar would be nice as well - > maybe something like: > > > context "A get to /index" do > > > > > > > > > specify "from an ajax call should render rjs" do > > > get :index, {}, :format => :js # where the magic word 'format' correctly > sets the accept header > > > > > > > > > > > > # should statements... > > > end > > > > > > end > > > > > > References: > > > > > > > > > http://www.loudthinking.com/arc/000572.htmlI'd love to > see these generators and plugins become part of core, too. After working > with RSpec for a few days now, I doubt I'll ever go back to the unit and > functional tests. Thanks for the hard work - > > > > > > Jeff > > > > > > > > > > > > > > > On 10/28/06, David Chelimsky < dchelimsky at gmail.com> wrote: > > > > On 10/28/06, Jeff Dean wrote: > > > > > Is anyone using RSpec with RESTful rails apps? In my rails > controllers I > > > > > check request.respond_to? and render different views accordingly. > > > > > > > > > > I noticed that the get method in the rails plugin doesn't accept > headers: > > > > > > > > > > controller_mixin.rb line 92 > > > > > def get(action, parameters = nil) > > > > > @request.env['REQUEST_METHOD'] = 'GET' > > > > > process action, parameters > > > > > end > > > > > > > > > > Has anyone found a way around this? > > > > > > > > Hi Jeff. We're getting ready to release a new version of the plugin so > > > > now is a good time to at least consider addressing this. Can you write > > > > an example of how you'd want to be able to write the spec (and > > > > controller code) for a restful get request? Don't worry about how > > > > rspec would do it. I just want to know what you want it to do. > > > > > > > > Thanks, > > > > David > > > > > > > > > > > > > > Jeff > > > > > > > > > > _______________________________________________ > > > > > Rspec-users mailing list > > > > > Rspec-users at rubyforge.org > > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > > > > _______________________________________________ > > > > Rspec-users mailing list > > > > Rspec-users at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > > > > > > _______________________________________________ > > Rspec-users mailing list > > Rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > -- > Chris Anderson > http://mfdz.com/jchris > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From phlip2005 at gmail.com Mon Oct 30 13:02:15 2006 From: phlip2005 at gmail.com (Phlip) Date: Mon, 30 Oct 2006 10:02:15 -0800 Subject: [Rspec-users] domain language? Message-ID: <860c114f0610301002t3ec7539cm7976f869bcd19f5d@mail.gmail.com> RSpeckers: I went with RSpec instead of Systir because I downloaded and installed the former first. (I know that's not exactly a ringing endorsement! ;-) I want to compete with FIT and Fitnesse, like this: http://www.zeroplayer.com/cgi-bin/wiki?TestFlea#tropism (Click on a Green Bar to distend one test case.) I want a domain-specific language in the parchment-colored area on the right. I don't want to invent it the bass-ackwards way FIT does, with its Java-style Action Fixture. That just gets me back to writing each line as a custom function. Ruby solutions tend to be much more elegant than that! Now here's my RSpec_Watir solution, to log into a site: snapshot() @browser.should_contain("login") @browser.text_field(:id, 'login').should_exist @browser.ie.document.activeElement.name.should_equal('login') # .because login field should have the focus Those lines violate the Systir principles; they use parens () and variables and state. They use a comment instead of an assertion documentation string. RSpec has gone a long way towards producing readable sentences - "should_contain" instead of "assert ... contains?" etc. How to go the extra step? How to improve my RSpec style? How to get rid of @browser, and have a true domain language, without writing a private function for every stinkin' operation on my website? Oh, and soon my tests must use 2 or more browsers, too... (I suspect I can't just cram in Systir, because it has a competing test runner. And I have a bug report on ZenTest that I don't want to work around yet.) -- Phlip http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!! From aslak.hellesoy at gmail.com Mon Oct 30 18:57:01 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 31 Oct 2006 00:57:01 +0100 Subject: [Rspec-users] domain language? In-Reply-To: <860c114f0610301002t3ec7539cm7976f869bcd19f5d@mail.gmail.com> References: <860c114f0610301002t3ec7539cm7976f869bcd19f5d@mail.gmail.com> Message-ID: <8d961d900610301557x1aed4effue10a3b6f4a9335c6@mail.gmail.com> On 10/30/06, Phlip wrote: > RSpeckers: > > I went with RSpec instead of Systir because I downloaded and installed > the former first. > > (I know that's not exactly a ringing endorsement! ;-) > maybe not, but it's a start :-) And systir doesn't have a gem, which might have put you off, I don't know. I have to admit I don't understand what problem systir attempts to solve though.... > I want to compete with FIT and Fitnesse, like this: > > http://www.zeroplayer.com/cgi-bin/wiki?TestFlea#tropism > > (Click on a Green Bar to distend one test case.) > > I want a domain-specific language in the parchment-colored area on the right. > > I don't want to invent it the bass-ackwards way FIT does, with its > Java-style Action Fixture. That just gets me back to writing each line > as a custom function. Ruby solutions tend to be much more elegant than > that! > Personally I'm a big fan of FIT. I like the way it allows business rules to be expressed at a very high level. Browser testing tools like Watir and Selenium-RC are good too, but I tend to prefer a UI agnostic framework for most of the business logic and only use Watir/Selenium-RC to verify navigation. > Now here's my RSpec_Watir solution, to log into a site: > > snapshot() > @browser.should_contain("login") > @browser.text_field(:id, 'login').should_exist > > @browser.ie.document.activeElement.name.should_equal('login') > # .because login field should have the focus > Have you looked at RSpec's vendor/watir directory? (Only available if you check out the code from svn - it's not in the gem yet). > Those lines violate the Systir principles; they use parens () and > variables and state. They use a comment instead of an assertion > documentation string. > > RSpec has gone a long way towards producing readable sentences - > "should_contain" instead of "assert ... contains?" etc. > > How to go the extra step? How to improve my RSpec style? How to get > rid of @browser, and have a true domain language, without writing a > private function for every stinkin' operation on my website? > Wouldn't systir also require you to define higher wrapper methods? > Oh, and soon my tests must use 2 or more browsers, too... > Selenium-RC can do that. See RSpec's vendor/selenium for an example. Aslak > (I suspect I can't just cram in Systir, because it has a competing > test runner. And I have a bug report on ZenTest that I don't want to > work around yet.) > > -- > Phlip > http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!! > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From george at benevolentcode.com Tue Oct 31 12:14:48 2006 From: george at benevolentcode.com (George Anderson) Date: Tue, 31 Oct 2006 12:14:48 -0500 Subject: [Rspec-users] How to run edge RSpec (on Rails)? Message-ID: <782d66f30610310914k294b5472jf073c7ac5ec9daba@mail.gmail.com> I'm interested in tracking edge development of the RSpec on Rails plugin and I'm a bit confused. The installation guide (http://rspec.rubyforge.org/documentation/rails/install.html) says, "You'll have to install the RSpec core gem first." It also says, "Take note of what rspec version you're installing ? it's very important that you install a compatible RSpec on Rails plugin." >From the "Installation" section (for RSpec on Rails) I understand how to track the HEAD of trunk for the plugin development, but I'm not sure if I can use the edge plugin with the RSpec core gem (via "gem install rspec"). In order to use the edge plugin, do I also need to use edge rspec? If so, how do I install edge rspec and ensure it gets used instead of the RSpec gem (0.6.4)? I've done my best to RTFM, but I'm still climbing the Ruby curve and apparently missing some key bits to pull this together. Thanks for any direction you might provide. /george From dchelimsky at gmail.com Tue Oct 31 20:22:45 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 31 Oct 2006 20:22:45 -0500 Subject: [Rspec-users] revision 1000 Message-ID: <57c63afe0610311722r2e1e177cmed7d7d3562214ba1@mail.gmail.com> Brian Takita committed revision 1000 last night. I don't know what that means - but it seems like an interesting milestone. Congrats to Brian for hitting 1000. Congrats and thank to all of those who have contributed by providing ideas, code, feedback, or simply using rspec and spreading the love. Cheers, David From dchelimsky at gmail.com Tue Oct 31 23:37:59 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 31 Oct 2006 23:37:59 -0500 Subject: [Rspec-users] How to run edge RSpec (on Rails)? In-Reply-To: <782d66f30610310914k294b5472jf073c7ac5ec9daba@mail.gmail.com> References: <782d66f30610310914k294b5472jf073c7ac5ec9daba@mail.gmail.com> Message-ID: <57c63afe0610312037i162e9d07rcf19f8e577145107@mail.gmail.com> On 10/31/06, George Anderson wrote: > I'm interested in tracking edge development of the RSpec on Rails > plugin and I'm a bit confused. > > The installation guide > (http://rspec.rubyforge.org/documentation/rails/install.html) says, > "You'll have to install the RSpec core gem first." It also says, > "Take note of what rspec version you're installing ? it's very > important that you install a compatible RSpec on Rails plugin." > > >From the "Installation" section (for RSpec on Rails) I understand how > to track the HEAD of trunk for the plugin development, but I'm not > sure if I can use the edge plugin with the RSpec core gem (via "gem > install rspec"). > > In order to use the edge plugin, do I also need to use edge rspec? Yes. > If so, how do I install edge rspec and ensure it gets used instead of > the RSpec gem (0.6.4)? check out the trunk read the README - that should tell you what you need to build rspec once you have the dependencies in place you should be able to do this: rake gem gem install pkg/rspec-X.X.X.gem Let us know if that works for you. Cheers, David > > I've done my best to RTFM, but I'm still climbing the Ruby curve and > apparently missing some key bits to pull this together. > > Thanks for any direction you might provide. > > /george > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From brian.takita at gmail.com Tue Oct 31 23:23:28 2006 From: brian.takita at gmail.com (Brian Takita) Date: Tue, 31 Oct 2006 20:23:28 -0800 Subject: [Rspec-users] [rspec-devel] revision 1000 In-Reply-To: <57c63afe0610311722r2e1e177cmed7d7d3562214ba1@mail.gmail.com> References: <57c63afe0610311722r2e1e177cmed7d7d3562214ba1@mail.gmail.com> Message-ID: <1d7ddd110610312023h35098009g83a1210088b38870@mail.gmail.com> On 10/31/06, David Chelimsky wrote: > > Brian Takita committed revision 1000 last night. I don't know what > that means - but it seems like an interesting milestone. > > Congrats to Brian for hitting 1000. Thanks. Sorry for causing you and Aslak to cringe. :) Congrats and thank to all of those who have contributed by providing > ideas, code, feedback, or simply using rspec and spreading the love. > > Cheers, > David > _______________________________________________ > rspec-devel mailing list > rspec-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061031/8d7d2dd5/attachment-0001.html From richcollins at gmail.com Fri Oct 20 21:58:21 2006 From: richcollins at gmail.com (Rich Collins) Date: Fri, 20 Oct 2006 18:58:21 -0700 Subject: [Rspec-users] Usage Error Message-ID: rake spec seems to work fine, but I keep getting a usage error at the end of the spec run: /usr/local/bin/ruby -I"/usr/local/lib/ruby/gems/1.8/gems/rspec-0.6.4/ lib" "/usr/local/lib/ruby/gems/1.8/gems/rspec-0.6.4/bin/spec" Usage: spec [options] (FILE|DIRECTORY|GLOB)+ --diff Show unified diff of Strings that are expected to be equal when they are not -c, --colour, --color Show coloured (red/green) output -s, --spec SPECIFICATION_NAME Execute a single specification -f, --format FORMAT Builtin formats: specdoc|s|rdoc| r|html|h You can also specify a custom formatter class (in which case you should also specify --require) -r, --require FILE Require FILE before running specs Useful for loading custom formatters or other extensions -b, --backtrace Output full backtrace -d, --dry-run Don't execute specs -v, --version Show version -h, --help You're looking at it The noise is a bit annoying and may interfere with commit hooks for my repo From tom at infoether.com Thu Oct 26 22:45:44 2006 From: tom at infoether.com (Tom Copeland) Date: Thu, 26 Oct 2006 22:45:44 -0400 Subject: [Rspec-users] reply-to address of this list In-Reply-To: <063601c6f90a$7425eeb0$81a1b04c@Marley> References: <3a5e51050610260640s3b8973e3jf9b67bd0826c9172@mail.gmail.com> <063601c6f90a$7425eeb0$81a1b04c@Marley> Message-ID: <1161917144.12546.11.camel@bugs.hal> On Thu, 2006-10-26 at 07:24 -0700, Phlip wrote: > Chris Roos wrote: > > > Could one of the admins maybe specify the reply-to address for this > > mailing list? It's frustrating to realise you've just sent a message > > to an individual, having meant to send to list. > > > http://rubyforge.org/mailman/listinfo/rspec-users > > Mailman's default is to the individual, which is completely wrong for any > technical group. I think a RubyForge administrator (such as Tom Copeland) > should tweak their installation so all their mailmen default to the group, > including new mailmen for new projects yet to come. Not a bad idea at all; I've added an RFE for it here: http://rubyforge.org/tracker/index.php?func=detail&aid=6347&group_id=5&atid=104 Thanks for the suggestion, Yours, Tom