From peter_marklund at fastmail.fm Sat Sep 1 02:52:37 2007 From: peter_marklund at fastmail.fm (Peter Marklund) Date: Sat, 1 Sep 2007 08:52:37 +0200 Subject: [rspec-users] Setting use_transactional_fixtures=false for a single spec - a bad idea? In-Reply-To: <57c63afe0708310818v2ef9405bw5aa399f7c79ffda1@mail.gmail.com> References: <57c63afe0708310818v2ef9405bw5aa399f7c79ffda1@mail.gmail.com> Message-ID: > I'd set up a separate folder for these specs and tweak the rake tasks > to run those specs in a separate process, w/ its own spec_helper that > sets config.use_transactional_fixtures to false. Thanks for the quick reply David! Sounds like your solution would be fairly easy to set up. For now though I'm running all my specs with use_transactional_fixtures=false. Slowed my specs down from about 6 to 12 seconds. Cheers peter From rupert_apsc at rupespad.com Sat Sep 1 04:31:31 2007 From: rupert_apsc at rupespad.com (rupert) Date: Sat, 1 Sep 2007 09:31:31 +0100 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> Message-ID: > I saw in one of Dave C.'s comments to a ticket that "our current plan > is to deprecate the mocking framework." I hadn't heard anything about > that, but then again I haven't paid super close attention to the list. > Are we planning on dumping the mock framework in favor of using Mocha > (or any other framework one might want to plug in?). The idea has been banded around on the dev list recently, see..... http://www.nabble.com/mock-framework-tf4312137.html#a12276473 for the discussion Cheers Rupert From tom at experthuman.com Sat Sep 1 05:04:34 2007 From: tom at experthuman.com (Tom Stuart) Date: Sat, 1 Sep 2007 10:04:34 +0100 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> Message-ID: <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> On 1 Sep 2007, at 09:31, rupert wrote: >> Are we planning on dumping the mock framework in favor of using >> Mocha > The idea has been banded around on the dev list recently This makes me sad, because it means only one thing for the majority of users: more hassle. So now I have to choose a mocking framework too (an arbitrary choice, thus a gamble), or else configure RSpec to keep working the way it used to work, and watch my mocking code slide into obsolescence? Sigh. I agree that it's a big win for the RSpec developers to not have to deal with the distraction of maintaining a mocking framework, but it's vaguely surprising that nobody's mentioned how valuable it is that RSpec is a tidy, coherent, consistent, integrated BDD tool that just works out of the box right now. (And newcomers still find it impenetrable!) It looks like it's inevitable that it'll be broken up, but, yeah, it's a real shame. Cheers, -Tom From peter_marklund at fastmail.fm Sat Sep 1 05:15:25 2007 From: peter_marklund at fastmail.fm (Peter Marklund) Date: Sat, 1 Sep 2007 11:15:25 +0200 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> Message-ID: I understand where you're coming from Tom. But it's currently two script/plugin installs to start using RSpec with Rails, making it be three (the current two plus a mocking framework) is presumably not going to change adoption or the hurdle of using RSpec by much. I currently use Mocha because I can use it both with Test::Unit and RSpec. I have a big legacy of Test::Unit tests and I want to be able to maintain those and use mocking there, with the same syntax as in RSpec. That's why I don't use the built in mocking in RSpec. Peter On Sep 1, 2007, at 11:04 AM, Tom Stuart wrote: > On 1 Sep 2007, at 09:31, rupert wrote: >>> Are we planning on dumping the mock framework in favor of using >>> Mocha >> The idea has been banded around on the dev list recently > > This makes me sad, because it means only one thing for the majority > of users: more hassle. So now I have to choose a mocking framework > too (an arbitrary choice, thus a gamble), or else configure RSpec to > keep working the way it used to work, and watch my mocking code slide > into obsolescence? Sigh. > > I agree that it's a big win for the RSpec developers to not have to > deal with the distraction of maintaining a mocking framework, but > it's vaguely surprising that nobody's mentioned how valuable it is > that RSpec is a tidy, coherent, consistent, integrated BDD tool that > just works out of the box right now. (And newcomers still find it > impenetrable!) It looks like it's inevitable that it'll be broken up, > but, yeah, it's a real shame. > > Cheers, > -Tom > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users ---------------------------- Peter Marklund Garvar Lundins Gr?nd 7 11220 Stockholm Sweden Mobile Phone: +46-(0)70-4164857 Home Phone: +46-(0)8-50091315 Skype: peter_marklund IM: AIM - petermarklund, MSN - peter_marklund at hotmail.com, Yahoo - peter_marklund2002 http://marklunds.com ---------------------------- From pergesu at gmail.com Sat Sep 1 05:38:08 2007 From: pergesu at gmail.com (Pat Maddox) Date: Sat, 1 Sep 2007 02:38:08 -0700 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> Message-ID: <810a540e0709010238v69342956p68e9f299bb91d3e0@mail.gmail.com> On 9/1/07, rupert wrote: > > I saw in one of Dave C.'s comments to a ticket that "our current plan > > is to deprecate the mocking framework." I hadn't heard anything about > > that, but then again I haven't paid super close attention to the list. > > Are we planning on dumping the mock framework in favor of using Mocha > > (or any other framework one might want to plug in?). > > The idea has been banded around on the dev list recently, see..... > > http://www.nabble.com/mock-framework-tf4312137.html#a12276473 > > for the discussion > > Cheers > > Rupert > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Thanks for the link. Pat From win at wincent.com Sat Sep 1 06:34:28 2007 From: win at wincent.com (Wincent Colaiuta) Date: Sat, 1 Sep 2007 12:34:28 +0200 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> Message-ID: El 1/9/2007, a las 11:15, Peter Marklund escribi?: > I understand where you're coming from Tom. But it's currently two > script/plugin installs to start using RSpec with Rails, making it be > three (the current two plus a mocking framework) is presumably not > going to change adoption or the hurdle of using RSpec by much. I > currently use Mocha because I can use it both with Test::Unit and > RSpec. I have a big legacy of Test::Unit tests and I want to be able > to maintain those and use mocking there, with the same syntax as in > RSpec. That's why I don't use the built in mocking in RSpec. Ouch. I used the built-in RSpec mocking because it was the default and I figured that it would be less likely to have compatibility issues in the future (say when Mocha or any of the others made subtle updates outside the control of the RSpec team). I liked the idea of having one integrated package which just worked. I actually thought the trend was in the opposite direction; to include things in RSpec (isn't RBehave part of trunk now?) rather than pare them down. Luckily, however, I don't have too many mocks yet, and the ones which are there aren't that complex. Could probably convert them over to something else in about a day's work. Cheers, Wincent From rupert_apsc at rupespad.com Sat Sep 1 06:35:19 2007 From: rupert_apsc at rupespad.com (rupert) Date: Sat, 1 Sep 2007 11:35:19 +0100 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> Message-ID: <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> On 1 Sep 2007, at 10:04, Tom Stuart wrote: > On 1 Sep 2007, at 09:31, rupert wrote: >>> Are we planning on dumping the mock framework in favor of using >>> Mocha >> The idea has been banded around on the dev list recently > > This makes me sad, because it means only one thing for the majority > of users: more hassle. So now I have to choose a mocking framework > too (an arbitrary choice, thus a gamble), or else configure RSpec to > keep working the way it used to work, and watch my mocking code slide > into obsolescence? Sigh. It won't be removed, so you'll still be able to use it (as Peter pointed out) . I had exactly the same initial reaction as you (mine was a sort of "nooooo, they can't do that") so I know where you're coming from. But having read through the discussion on the dev list and thought about it, the rspec mocking framework is pretty stable and complete so I don't think depreciating it is going to be too big a problem for those (like me!) that have a bundle of specs that use the rspec mocking framework - I'm going to keep using it for now, but have a look at the alternatives as a background task with the intent to use one of them on a new project as some point in the future. Cheers Rupert From dchelimsky at gmail.com Sat Sep 1 10:10:09 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 1 Sep 2007 09:10:09 -0500 Subject: [rspec-users] How to spec routes for a resource nested in multiples resources? In-Reply-To: References: Message-ID: <57c63afe0709010710r37934f1dw1cc49e5fc3852d03@mail.gmail.com> On 8/31/07, Edgar Gonzalez wrote: > Hi, > > I got the resource "Llamadas" nested in: > - Operadores > - Productos > - Centros > > Here is part of my routes http://pastie.caboo.se/92767 > > I want to spec that the routes for Llamadas, I tried several approachs: > > - route_for(:controller => "llamadas", :action => "exitosas", > :operador_id => 1).should == "/operador/1/llamadas;exitosas" route_for wraps ActionController::Routing::Routes.generate(options), so whatever route_for is producing is what rails actually produces. You may want to ask on the Rails list how people are approaching this w/ test/unit. If you get an answer, please report it back here. Cheers, David > > - controller.send(:operador_exitosas_llamadas_path, at operador).should > == "/operador/22/llamadas;exitosas" > > but nothing works. > > any clue? > > thanks in advance > -- > Edgar Gonz?lez Gonz?lez > E-mail: edgargonzalez at gmail.com > http://www.hasmanydevelopers.com > http://www.rubycorner.com > http://www.to2blogs.com > http://www.lacaraoscura.com > -- > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From rupert_apsc at rupespad.com Sat Sep 1 10:54:47 2007 From: rupert_apsc at rupespad.com (rupert) Date: Sat, 1 Sep 2007 15:54:47 +0100 Subject: [rspec-users] How to spec routes for a resource nested in multiples resources? In-Reply-To: <57c63afe0709010710r37934f1dw1cc49e5fc3852d03@mail.gmail.com> References: <57c63afe0709010710r37934f1dw1cc49e5fc3852d03@mail.gmail.com> Message-ID: <0A234D32-C201-4327-8D91-A4F35C5DB3E8@rupespad.com> > On 8/31/07, Edgar Gonzalez wrote: >> Hi, >> >> I got the resource "Llamadas" nested in: >> - Operadores >> - Productos >> - Centros >> >> Here is part of my routes http://pastie.caboo.se/92767 >> >> I want to spec that the routes for Llamadas, I tried several >> approachs: >> >> - route_for(:controller => "llamadas", :action => "exitosas", >> :operador_id => 1).should == "/operador/1/llamadas;exitosas" > > route_for wraps ActionController::Routing::Routes.generate(options), > so whatever route_for is producing is what rails actually produces. > You may want to ask on the Rails list how people are approaching this > w/ test/unit. If you get an answer, please report it back here. another suggestion... you could take the code from http://pastie.caboo.se/74249 and paste it into a file called (say) routes.rake in your lib/tasks directory then run rake routes to get a listing of all the routes and their mappings in your terminal window. This will show you how the controllers, actions and parameters are mapped to urls and might help you work out what's going on. Cheers Rupert From omen.king at gmail.com Sat Sep 1 13:16:26 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sat, 1 Sep 2007 13:16:26 -0400 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> Message-ID: My question is what would you recommend for Mocking? Mocha or FlexMock? On 9/1/07, rupert wrote: > > > On 1 Sep 2007, at 10:04, Tom Stuart wrote: > > > On 1 Sep 2007, at 09:31, rupert wrote: > >>> Are we planning on dumping the mock framework in favor of using > >>> Mocha > >> The idea has been banded around on the dev list recently > > > > This makes me sad, because it means only one thing for the majority > > of users: more hassle. So now I have to choose a mocking framework > > too (an arbitrary choice, thus a gamble), or else configure RSpec to > > keep working the way it used to work, and watch my mocking code slide > > into obsolescence? Sigh. > > It won't be removed, so you'll still be able to use it (as Peter > pointed out) . I had exactly the same initial reaction as you (mine > was a sort of "nooooo, they can't do that") so I know where you're > coming from. But having read through the discussion on the dev list > and thought about it, the rspec mocking framework is pretty stable > and complete so I don't think depreciating it is going to be too big > a problem for those (like me!) that have a bundle of specs that use > the rspec mocking framework - I'm going to keep using it for now, but > have a look at the alternatives as a background task with the intent > to use one of them on a new project as some point in the future. > > Cheers > > Rupert > _______________________________________________ > 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/20070901/0ee4ed1b/attachment.html From rupert_apsc at rupespad.com Sat Sep 1 13:31:25 2007 From: rupert_apsc at rupespad.com (rupert) Date: Sat, 1 Sep 2007 18:31:25 +0100 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> Message-ID: On 1 Sep 2007, at 18:16, Andrew WC Brown wrote: > My question is what would you recommend for Mocking? > > Mocha or FlexMock? Personally, I've not got a clue as all I've used to date is the rspec mocking framework. I've had a quick look at Mocha and it seems pretty good, but haven't looked into FlexMock at all yet. +1 to anyone who's used both these can comment on the differences! From omen.king at gmail.com Sat Sep 1 13:35:43 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sat, 1 Sep 2007 13:35:43 -0400 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> Message-ID: After a quick google search: http://www.slideshare.net/viget/mockfight-flexmock-vs-mocha I have no problem using a external mocking framework but its the choosing. convention over configuration. On 9/1/07, rupert wrote: > > > On 1 Sep 2007, at 18:16, Andrew WC Brown wrote: > > > My question is what would you recommend for Mocking? > > > > Mocha or FlexMock? > > Personally, I've not got a clue as all I've used to date is the rspec > mocking framework. I've had a quick look at Mocha and it seems > pretty good, but haven't looked into FlexMock at all yet. > > +1 to anyone who's used both these can comment on the differences! > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Monsterbox Productions putting small businesses on-line 1319 Victoria Avenue East Thunder Bay, Ontario P7C 1C3 Canada Andrew WC Brown web-developer and owner andrew at monsterboxpro.com P: 807-626-9009 F: 807-624-2705 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070901/7645460f/attachment.html From dchelimsky at gmail.com Sat Sep 1 13:48:00 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 1 Sep 2007 12:48:00 -0500 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> Message-ID: <57c63afe0709011048j681316e6kb94145fc682c6aca@mail.gmail.com> On 9/1/07, Andrew WC Brown wrote: > After a quick google search: > > http://www.slideshare.net/viget/mockfight-flexmock-vs-mocha In fairness - there is something lacking in the slide set - it suggests that mocha supports parameter matchers and flexmock does not. In fact, flexmock does. You can do this: mock.should_receive(:message).with(String).once and it will pass if the mock receives the message w/ a String. In mocha, you have to say: mock.expects(:message).with(kind_of(String)) Flexmock compares args using ===, which is why this works implicitly. Similarly, mocha, flexmock, and rspec can all take an argument matcher - an object that responds to == and gives you the right answer. So, you can do this w/ any of these frameworks: class LessThan def initialize(threshold) @threshold = threshold end def ==(other) other < @threshold end end def less_than(expected) LessThan.new(expected) end mock.expects(:message).with(less_than(3)) mock.should_receive(:message).with(less_than(3)) Cheers, David > > I have no problem using a external mocking framework but its the choosing. > convention over configuration. > > > > On 9/1/07, rupert wrote: > > > > On 1 Sep 2007, at 18:16, Andrew WC Brown wrote: > > > > > My question is what would you recommend for Mocking? > > > > > > Mocha or FlexMock? > > > > Personally, I've not got a clue as all I've used to date is the rspec > > mocking framework. I've had a quick look at Mocha and it seems > > pretty good, but haven't looked into FlexMock at all yet. > > > > +1 to anyone who's used both these can comment on the differences! > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > Monsterbox Productions > putting small businesses on-line > > 1319 Victoria Avenue East > Thunder Bay, Ontario P7C 1C3 > Canada > > Andrew WC Brown > web-developer and owner > andrew at monsterboxpro.com > P: 807-626-9009 > F: 807-624-2705 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From wilsonb at gmail.com Sun Sep 2 02:39:20 2007 From: wilsonb at gmail.com (Wilson Bilkovich) Date: Sun, 2 Sep 2007 02:39:20 -0400 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> Message-ID: On 9/1/07, rupert wrote: > > On 1 Sep 2007, at 10:04, Tom Stuart wrote: > > > On 1 Sep 2007, at 09:31, rupert wrote: > >>> Are we planning on dumping the mock framework in favor of using > >>> Mocha > >> The idea has been bandied around on the dev list recently This decision, if it is made in this manner, is suicide for RSpec. I have been a huge RSpec booster, but this will make me drop it like a hot coal. =( From pergesu at gmail.com Sun Sep 2 02:45:28 2007 From: pergesu at gmail.com (Pat Maddox) Date: Sat, 1 Sep 2007 23:45:28 -0700 Subject: [rspec-users] testing behaviour or testing code? In-Reply-To: <57c63afe0708241012o6c5bf76bib536656bf69ee323@mail.gmail.com> References: <12309322.post@talk.nabble.com> <57c63afe0708240659y1ea3668qc2065333f199a7bb@mail.gmail.com> <810a540e0708241006m23118ed7k9248705c13c2678a@mail.gmail.com> <57c63afe0708241012o6c5bf76bib536656bf69ee323@mail.gmail.com> Message-ID: <810a540e0709012345t5aba354ai6f2f7414fe5a5ea@mail.gmail.com> On 8/24/07, David Chelimsky wrote: > On 8/24/07, Pat Maddox wrote: > > On 8/24/07, David Chelimsky wrote: > > > describe Widget, "class" do > > > it "should provide a list of widgets sorted alphabetically" do > > > Widget.should_receive(:find).with(:order => "name ASC") > > > Widget.find_alphabetically > > > end > > > end > > > > > > You're correct that the refactoring requires you to change the > > > object-level examples, and that is something that would be nice to > > > avoid. But also keep in mind that in java and C# people refactor > > > things like that all the time without batting an eye, because the > > > tools make it a one-step activity. Refactoring is changing the design > > > of your *system* without changing its behaviour. That doesn't really > > > fly all the way down to the object level 100% of the time. > > > > > > WDYT? > > > > I think that example is fine up until the model spec. The > > find_alphabetically example should hit the db, imo. With the current > > spec there's no way to know whether find_alphabetically actually works > > or not. You're relying on knowledge of ActiveRecord here, trusting > > that the arguments to find are correct. > > Au contrare! This all starts with an Integration Test. I didn't post > the code but I did mention it. > > > What I've found when I write specs is that I discover new layers of > > services until eventually I get to a layer that actually does > > something. When I get there, it's important to have specs that > > describe what it does, not how it does it. In the case of > > find_alphabetically we care that it returns the items in alphabetical > > order. Not that it makes a certain call to the db. > > I play this both ways and haven't come to a preference, but I'm > leaning towards blocking database access from the rspec examples and > only allowing it my end to end tests (using Rails Integration Tests or > - soon - RSpec's new Story Runner). Now that I've had a chance to play with Story Runner, I want to revisit this topic a bit. Let's say in your example you wanted to refactor find_alphabetically to use enumerable's sort_by to do the sorting. def self.find_alphabetically find(:all).sort_by {|w| w.name } end Your model spec will fail, but your integration test will still pass. I've been thinking about this situation a lot over the last few months. It's been entirely theoretical because I haven't had a suite of integration tests ;) Most XP advocates lean heavily on unit tests when doing refactoring. Mocking tends to get in the way of refactoring though. In the example above, we rely on the integration test to give us confidence while refactoring. In fact I would ignore the unit test (model-level spec) altogether, and rewrite it when the refactoring is complete. Here's how I reconcile this with traditional XP unit testing. First of all our integration tests are relatively light weight. In a web app, a user story consists of making a request and verifying the response. Authentication included, you'll be making at most 3-5 HTTP requests per test. This means that our integration tests still run in just a few seconds. Integration tests in a Rails app are a completely different beast from the integration tests in the Chrysler payroll app that Beck, Jeffries, et al worked on. The second point of reconciliation is that mock objects and refactoring are two distinct tools you use to design your code. When I'm writing greenfield code I'll use mocks to drive the design. When I refactor though, I'm following known steps to improve the design of my existing code. The vast majority of the time I will perform a known refactoring, which means I know the steps and the resulting design. In this situation I'll ignore my model specs because they'll blow up, giving me no information other than I changed the design of my code. I can use the integration tests to ensure that I haven't broken any behavior. At this point I would edit the model specs to use the correct mock calls. As I mentioned, this has been something that's been on my mind for a while. I find mock objects to be very useful, but they seem to clash with most of the existing TDD and XP literature. To summarize, here are the points where I think they clash: * Classical TDD relies on unit tests for confidence in refactoring. BDD relies on integration tests * XP acceptance tests are customer tests, whereas RSpec User Stories are programmer tests. They can serve a dual-purpose because you can easily show them to a customer, but they're programmer tests in the sense that the programmer writes and is responsible for those particular tests. In the end it boils down to getting stuff done. After a bit of experimentation I'm thinking that the process of 1. Write a user story 2. Write detailed specs using mocks to drive design 3. Refactor, using stories to ensure that expected behavior is maintained, ignoring detailed specs 4. Retrofit specs with correct mock expectations is a solid approach. I'd like others to weigh in with their thoughts. Pat From pergesu at gmail.com Sun Sep 2 03:05:59 2007 From: pergesu at gmail.com (Pat Maddox) Date: Sun, 2 Sep 2007 00:05:59 -0700 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> Message-ID: <810a540e0709020005t4a7a04d4jd09fefc46018feb4@mail.gmail.com> On 9/1/07, Wilson Bilkovich wrote: > On 9/1/07, rupert wrote: > > > > On 1 Sep 2007, at 10:04, Tom Stuart wrote: > > > > > On 1 Sep 2007, at 09:31, rupert wrote: > > >>> Are we planning on dumping the mock framework in favor of using > > >>> Mocha > > >> The idea has been bandied around on the dev list recently > > This decision, if it is made in this manner, is suicide for RSpec. > I have been a huge RSpec booster, but this will make me drop it like a hot coal. > =( While I won't drop RSpec ;) I agree that removing the mocking framework is a mistake. With the integration of rbehave, RSpec is a complete BDD framework. It allows for behavior specification at the app-level and at the object-level. I'm sure everyone will agree that mocking is integral to the object specification component of BDD. To paraphrase Aslak, "if you're not using mock objects then it ain't BDD." I can understand not wanting to reinvent the wheel, and there are mock frameworks that sufficiently do the job. However the whole point of RSpec is that we're not satisfied with "sufficient" but instead demand a tool that works the way our brains think. I haven't used Mocha or Flexmock extensively because RSpec's mocking has been great for me...but I remember taking a look at them when Mocha support was first added to RSpec. There were some things that RSpec's framework did better and more clearly than Mocha. I wish I could remember them precisely, but it was quite a while back. The point is, if the mock framework feels off even a little bit, it basically defeats the purpose of RSpec. At the very least, it undermines it to a degree. RSpec should keep its mocking framework because it's the only framework that is designed with the same philosophy as RSpec. In fact I feel insanely strange thinking of them as separate entities. The best scenario, imo, is one where we have a mocking framework tightly coupled to the overall vision of the RSpec project, but that allows people to use something else if they really want. I think it's important that RSpec remain a complete BDD framework with all necessary components working in harmony. Pat From priit.tamboom at eesti.ee Sun Sep 2 03:35:17 2007 From: priit.tamboom at eesti.ee (Priit Tamboom) Date: Sun, 2 Sep 2007 15:35:17 +0800 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> Message-ID: On 9/2/07, Wilson Bilkovich wrote: > On 9/1/07, rupert wrote: > > > > On 1 Sep 2007, at 10:04, Tom Stuart wrote: > > > > > On 1 Sep 2007, at 09:31, rupert wrote: > > >>> Are we planning on dumping the mock framework in favor of using > > >>> Mocha > > >> The idea has been bandied around on the dev list recently > > This decision, if it is made in this manner, is suicide for RSpec. > I have been a huge RSpec booster, but this will make me drop it like a hot coal. > =( > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Eh! The first reactions :-) However I also have to admit and wonder why rspec dev didn't make this kind of decisions before version 1.0. I hate (as a nuby) that now I have to make decision (mocka or flexmock) at the time where I'm not even a big mock fan yet (now it's even more harder to sell the idea to co-workers as well). For the very first look, I prefer mocka syntax more than flexmock. However I like rspec's clean it 'should' specs (and generating doc from it) so much more compared to test::unit way is. Oki, Priit From dchelimsky at gmail.com Sun Sep 2 03:56:58 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 2 Sep 2007 02:56:58 -0500 Subject: [rspec-users] testing behaviour or testing code? In-Reply-To: <810a540e0709012345t5aba354ai6f2f7414fe5a5ea@mail.gmail.com> References: <12309322.post@talk.nabble.com> <57c63afe0708240659y1ea3668qc2065333f199a7bb@mail.gmail.com> <810a540e0708241006m23118ed7k9248705c13c2678a@mail.gmail.com> <57c63afe0708241012o6c5bf76bib536656bf69ee323@mail.gmail.com> <810a540e0709012345t5aba354ai6f2f7414fe5a5ea@mail.gmail.com> Message-ID: <57c63afe0709020056y26081df7labe53761f20fa90a@mail.gmail.com> On 9/2/07, Pat Maddox wrote: > On 8/24/07, David Chelimsky wrote: > > On 8/24/07, Pat Maddox wrote: > > > On 8/24/07, David Chelimsky wrote: > > > > describe Widget, "class" do > > > > it "should provide a list of widgets sorted alphabetically" do > > > > Widget.should_receive(:find).with(:order => "name ASC") > > > > Widget.find_alphabetically > > > > end > > > > end > > > > > > > > You're correct that the refactoring requires you to change the > > > > object-level examples, and that is something that would be nice to > > > > avoid. But also keep in mind that in java and C# people refactor > > > > things like that all the time without batting an eye, because the > > > > tools make it a one-step activity. Refactoring is changing the design > > > > of your *system* without changing its behaviour. That doesn't really > > > > fly all the way down to the object level 100% of the time. > > > > > > > > WDYT? > > > > > > I think that example is fine up until the model spec. The > > > find_alphabetically example should hit the db, imo. With the current > > > spec there's no way to know whether find_alphabetically actually works > > > or not. You're relying on knowledge of ActiveRecord here, trusting > > > that the arguments to find are correct. > > > > Au contrare! This all starts with an Integration Test. I didn't post > > the code but I did mention it. > > > > > What I've found when I write specs is that I discover new layers of > > > services until eventually I get to a layer that actually does > > > something. When I get there, it's important to have specs that > > > describe what it does, not how it does it. In the case of > > > find_alphabetically we care that it returns the items in alphabetical > > > order. Not that it makes a certain call to the db. > > > > I play this both ways and haven't come to a preference, but I'm > > leaning towards blocking database access from the rspec examples and > > only allowing it my end to end tests (using Rails Integration Tests or > > - soon - RSpec's new Story Runner). > > Now that I've had a chance to play with Story Runner, I want to > revisit this topic a bit. > > Let's say in your example you wanted to refactor find_alphabetically > to use enumerable's sort_by to do the sorting. > > def self.find_alphabetically > find(:all).sort_by {|w| w.name } > end > > Your model spec will fail, but your integration test will still pass. > > I've been thinking about this situation a lot over the last few > months. It's been entirely theoretical because I haven't had a suite > of integration tests ;) Most XP advocates lean heavily on unit tests > when doing refactoring. Mocking tends to get in the way of > refactoring though. In the example above, we rely on the integration > test to give us confidence while refactoring. In fact I would ignore > the unit test (model-level spec) altogether, and rewrite it when the > refactoring is complete. > > Here's how I reconcile this with traditional XP unit testing. First > of all our integration tests are relatively light weight. In a web > app, a user story consists of making a request and verifying the > response. Authentication included, you'll be making at most 3-5 HTTP > requests per test. This means that our integration tests still run in > just a few seconds. Integration tests in a Rails app are a completely > different beast from the integration tests in the Chrysler payroll app > that Beck, Jeffries, et al worked on. > > The second point of reconciliation is that mock objects and > refactoring are two distinct tools you use to design your code. When > I'm writing greenfield code I'll use mocks to drive the design. When > I refactor though, I'm following known steps to improve the design of > my existing code. The vast majority of the time I will perform a > known refactoring, which means I know the steps and the resulting > design. In this situation I'll ignore my model specs because they'll > blow up, giving me no information other than I changed the design of > my code. I can use the integration tests to ensure that I haven't > broken any behavior. At this point I would edit the model specs to > use the correct mock calls. > > As I mentioned, this has been something that's been on my mind for a > while. I find mock objects to be very useful, but they seem to clash > with most of the existing TDD and XP literature. To summarize, here > are the points where I think they clash: > > * Classical TDD relies on unit tests for confidence in refactoring. > BDD relies on integration tests > * XP acceptance tests are customer tests, whereas RSpec User Stories > are programmer tests. They can serve a dual-purpose because you can > easily show them to a customer, but they're programmer tests in the > sense that the programmer writes and is responsible for those > particular tests. > > In the end it boils down to getting stuff done. After a bit of > experimentation I'm thinking that the process of > 1. Write a user story > 2. Write detailed specs using mocks to drive design > 3. Refactor, using stories to ensure that expected behavior is > maintained, ignoring detailed specs > 4. Retrofit specs with correct mock expectations > > is a solid approach. I'd like others to weigh in with their thoughts. Hey Pat, I really appreciate that you're thinking about and sharing this as its something that weighs on a lot of people's minds and it's clear that you have some understanding of the XP context in which all of this was born. That said, I see this quite a bit differently. I don't think this has anything to do w/ TDD vs BDD. "Mock Objects" is not a BDD concept. It just feels that way because we talk more about interaction testing, but interaction testing predates BDD by some years. The problem we experience with mocks relates to the fact that we've chosen to live in the beautiful, free, dynamically typed and POORLY TOOLED land of Ruby. When Ruby refactoring tools catch up with those of java and .NET, this pain will all go away. For example - if I'm in IntelliJ in a java project and I have a method like this: model.getName() and I'm using jmock (the old version), which uses Strings for method names: model.expects(once()).method("getName").will(returnValue("stub value")) and I do a Rename Method refactoring on getName(), IntelliJ will ask me if I want to change the strings it finds that match getName as well as the method invocations. In Ruby, we do this now w/ search and replace. Not quite as elegant. But under the hood, that's all IntelliJ is doing. It just makes it feel like an integrated step of an automated refactoring. re: Story Runner. The intent of Story Runner is exactly the same as tools like FIT, etc, that are typically found in the Acceptance Testing space in XP projects. In my experience using FitNesse, it was rare that a customer actually added new tests to a suite. If there were testing folks on board, they would do it (and they would likely be equipped to do it in Story Runner as well), but if not, then the FitNesse tests were at best the result of a collaborative session with the customer and, at worst, our (developers), interpretation of conversations we had had with the customer. I see Story Runner fitting in exactly like that in the short run. I can also see external DSLs emerging that let customers actually write the outputs that Story Runner should produce and run that through a process that writes what we're writing now in Story Runner. But that's probably some time off. I totally agree with your last statement that "it boils down to getting stuff done." And your approach seems to be the approach that I take, given the tools that we have. But I really think its about tools and not process. And I think that BDD is a lot more like what really experienced TDD'ers do out of the gate. We're just choosing different words and structures to make it easier to communicate across roles on a team (customer, developer, tester, etc). FWIW. Cheers, David > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Sun Sep 2 05:32:40 2007 From: pergesu at gmail.com (Pat Maddox) Date: Sun, 2 Sep 2007 02:32:40 -0700 Subject: [rspec-users] testing behaviour or testing code? In-Reply-To: <57c63afe0709020056y26081df7labe53761f20fa90a@mail.gmail.com> References: <12309322.post@talk.nabble.com> <57c63afe0708240659y1ea3668qc2065333f199a7bb@mail.gmail.com> <810a540e0708241006m23118ed7k9248705c13c2678a@mail.gmail.com> <57c63afe0708241012o6c5bf76bib536656bf69ee323@mail.gmail.com> <810a540e0709012345t5aba354ai6f2f7414fe5a5ea@mail.gmail.com> <57c63afe0709020056y26081df7labe53761f20fa90a@mail.gmail.com> Message-ID: <810a540e0709020232g1a8bc555h129dbbbc0be5d6a7@mail.gmail.com> On 9/2/07, David Chelimsky wrote: > On 9/2/07, Pat Maddox wrote: > > On 8/24/07, David Chelimsky wrote: > > > On 8/24/07, Pat Maddox wrote: > > > > On 8/24/07, David Chelimsky wrote: > > > > > describe Widget, "class" do > > > > > it "should provide a list of widgets sorted alphabetically" do > > > > > Widget.should_receive(:find).with(:order => "name ASC") > > > > > Widget.find_alphabetically > > > > > end > > > > > end > > > > > > > > > > You're correct that the refactoring requires you to change the > > > > > object-level examples, and that is something that would be nice to > > > > > avoid. But also keep in mind that in java and C# people refactor > > > > > things like that all the time without batting an eye, because the > > > > > tools make it a one-step activity. Refactoring is changing the design > > > > > of your *system* without changing its behaviour. That doesn't really > > > > > fly all the way down to the object level 100% of the time. > > > > > > > > > > WDYT? > > > > > > > > I think that example is fine up until the model spec. The > > > > find_alphabetically example should hit the db, imo. With the current > > > > spec there's no way to know whether find_alphabetically actually works > > > > or not. You're relying on knowledge of ActiveRecord here, trusting > > > > that the arguments to find are correct. > > > > > > Au contrare! This all starts with an Integration Test. I didn't post > > > the code but I did mention it. > > > > > > > What I've found when I write specs is that I discover new layers of > > > > services until eventually I get to a layer that actually does > > > > something. When I get there, it's important to have specs that > > > > describe what it does, not how it does it. In the case of > > > > find_alphabetically we care that it returns the items in alphabetical > > > > order. Not that it makes a certain call to the db. > > > > > > I play this both ways and haven't come to a preference, but I'm > > > leaning towards blocking database access from the rspec examples and > > > only allowing it my end to end tests (using Rails Integration Tests or > > > - soon - RSpec's new Story Runner). > > > > Now that I've had a chance to play with Story Runner, I want to > > revisit this topic a bit. > > > > Let's say in your example you wanted to refactor find_alphabetically > > to use enumerable's sort_by to do the sorting. > > > > def self.find_alphabetically > > find(:all).sort_by {|w| w.name } > > end > > > > Your model spec will fail, but your integration test will still pass. > > > > I've been thinking about this situation a lot over the last few > > months. It's been entirely theoretical because I haven't had a suite > > of integration tests ;) Most XP advocates lean heavily on unit tests > > when doing refactoring. Mocking tends to get in the way of > > refactoring though. In the example above, we rely on the integration > > test to give us confidence while refactoring. In fact I would ignore > > the unit test (model-level spec) altogether, and rewrite it when the > > refactoring is complete. > > > > Here's how I reconcile this with traditional XP unit testing. First > > of all our integration tests are relatively light weight. In a web > > app, a user story consists of making a request and verifying the > > response. Authentication included, you'll be making at most 3-5 HTTP > > requests per test. This means that our integration tests still run in > > just a few seconds. Integration tests in a Rails app are a completely > > different beast from the integration tests in the Chrysler payroll app > > that Beck, Jeffries, et al worked on. > > > > The second point of reconciliation is that mock objects and > > refactoring are two distinct tools you use to design your code. When > > I'm writing greenfield code I'll use mocks to drive the design. When > > I refactor though, I'm following known steps to improve the design of > > my existing code. The vast majority of the time I will perform a > > known refactoring, which means I know the steps and the resulting > > design. In this situation I'll ignore my model specs because they'll > > blow up, giving me no information other than I changed the design of > > my code. I can use the integration tests to ensure that I haven't > > broken any behavior. At this point I would edit the model specs to > > use the correct mock calls. > > > > As I mentioned, this has been something that's been on my mind for a > > while. I find mock objects to be very useful, but they seem to clash > > with most of the existing TDD and XP literature. To summarize, here > > are the points where I think they clash: > > > > * Classical TDD relies on unit tests for confidence in refactoring. > > BDD relies on integration tests > > * XP acceptance tests are customer tests, whereas RSpec User Stories > > are programmer tests. They can serve a dual-purpose because you can > > easily show them to a customer, but they're programmer tests in the > > sense that the programmer writes and is responsible for those > > particular tests. > > > > In the end it boils down to getting stuff done. After a bit of > > experimentation I'm thinking that the process of > > 1. Write a user story > > 2. Write detailed specs using mocks to drive design > > 3. Refactor, using stories to ensure that expected behavior is > > maintained, ignoring detailed specs > > 4. Retrofit specs with correct mock expectations > > > > is a solid approach. I'd like others to weigh in with their thoughts. > > Hey Pat, > > I really appreciate that you're thinking about and sharing this as its > something that weighs on a lot of people's minds and it's clear that > you have some understanding of the XP context in which all of this was > born. > > That said, I see this quite a bit differently. > > I don't think this has anything to do w/ TDD vs BDD. "Mock Objects" is > not a BDD concept. It just feels that way because we talk more about > interaction testing, but interaction testing predates BDD by some > years. Hi David, Thanks so much for your thoughtful reply. You're right, and I didn't mean to suggest that mock objects were a BDD concept at all. However it seems to me that BDDers embrace mock objects as a very useful design tool, whereas classical TDDers would use them sparsely, when a resource is expensive or difficult to use directly. For example, Beck talks about mocking a database in his book, and that's that. Astels demonstrates mocking the roll of a die. He does briefly use mocks before he's ready to implement the GUI part of the app. Those are the two TDD books with which I'm most familiar. I'm sure a lot has changed in the TDD community since then, and indeed you can see that Astels' mentality has changed somewhat. His "one assertion per test" article [1] parses an address and then verifies it by asserting the getters. His remake, "one expectation per example" [2] is a bit different in that he passes a mocked builder in and uses that to verify that the parsing code works, exposing no getters at all. That to me signifies a fundamental shift in TDD thought. Instead of thinking about objects in isolation and what services they provide, we think of the services an object provides and how it interacts with other objects and uses their services. I'm certain that it's not a new way of thinking, but hopefully you can see why I'd believe it's probably not mainstream. There's one other roadblock to my thinking, and it results from using RSpec almost exclusively within Rails projects. I think it's obvious why you mock models when writing view and controller specs. However less obvious to me is why mock associations in model specs, and I think it has to do with the fact that AR couples business and persistence logic. If we just had domain objects that never hit a database, then we might initially mock interactions but then use concrete instances when we later implemented those classes. When I think of Beck's Money example, or Martin Fowler's video rental list in Refactoring, it seems silly to me to use mocks in those cases. Perhaps you might at the very beginning, but you'd sub real objects in as you implemented them. We don't do this with AR because they're simply too heavy. This culminates in another general idea I've had which is to mock services in a lower layer, and use concrete instances for objects in the same layer when possible. If we were to split AR into domain objects and a data access layer, the domain objects would mock calls to the data access layer but use concrete domain objects in the tests. The unit tests remain fast and simple, and mocks no longer get in the way of refactoring. Of course then you're writing integration tests at a fairly low level I guess, but that's 100% acceptable to me in the interest of getting stuff done rather than being dogmatic. > The problem we experience with mocks relates to the fact that > we've chosen to live in the beautiful, free, dynamically typed and > POORLY TOOLED land of Ruby. When Ruby refactoring tools catch up with > those of java and .NET, this pain will all go away. > > For example - if I'm in IntelliJ in a java project and I have a method > like this: > > model.getName() > > and I'm using jmock (the old version), which uses Strings for method names: > > model.expects(once()).method("getName").will(returnValue("stub value")) > > and I do a Rename Method refactoring on getName(), IntelliJ will ask > me if I want to change the strings it finds that match getName as well > as the method invocations. > > In Ruby, we do this now w/ search and replace. Not quite as elegant. > But under the hood, that's all IntelliJ is doing. It just makes it > feel like an integrated step of an automated refactoring. Agreed. I guess for me it's easier to get the production code right and then fix the tests after the fact. I'd hate to do all the work of changing the production and test code and then find out it was incorrect. Fixing tests after fixing the production code amounts to the same work as doing it all in one step, because as you mentioned it's essentially a manual process. > re: Story Runner. The intent of Story Runner is exactly the same as > tools like FIT, etc, that are typically found in the Acceptance > Testing space in XP projects. In my experience using FitNesse, it was > rare that a customer actually added new tests to a suite. If there > were testing folks on board, they would do it (and they would likely > be equipped to do it in Story Runner as well), but if not, then the > FitNesse tests were at best the result of a collaborative session with > the customer and, at worst, our (developers), interpretation of > conversations we had had with the customer. > > I see Story Runner fitting in exactly like that in the short run. I > can also see external DSLs emerging that let customers actually write > the outputs that Story Runner should produce and run that through a > process that writes what we're writing now in Story Runner. But that's > probably some time off. > > I totally agree with your last statement that "it boils down to > getting stuff done." And your approach seems to be the approach that I > take, given the tools that we have. But I really think its about tools > and not process. And I think that BDD is a lot more like what really > experienced TDD'ers do out of the gate. We're just choosing different > words and structures to make it easier to communicate across roles on > a team (customer, developer, tester, etc). So "ideally," who would write Story Runner stories? I put it in quotes because I think it would differ greatly depending on the work environment, what kind of level of interaction you have with the customer, etc. Using TDD terms, would we consider SR stories to be Customer or Developer tests? I gather from your insight that they're Customer tests. Finally I agree 100% on not focusing on process. I'm trying to figure out the most effective process given the tools currently available, and will be constantly changing it as more/better tools come along. Although I suppose what I should really be spending my energy on is building the tools that will make all our lives better ;) Pat From papipo at gmail.com Sun Sep 2 06:28:27 2007 From: papipo at gmail.com (=?ISO-8859-1?Q?Rodrigo_Alvarez_Fern=E1ndez?=) Date: Sun, 2 Sep 2007 12:28:27 +0200 Subject: [rspec-users] testing behaviour or testing code? In-Reply-To: <810a540e0709020232g1a8bc555h129dbbbc0be5d6a7@mail.gmail.com> References: <12309322.post@talk.nabble.com> <57c63afe0708240659y1ea3668qc2065333f199a7bb@mail.gmail.com> <810a540e0708241006m23118ed7k9248705c13c2678a@mail.gmail.com> <57c63afe0708241012o6c5bf76bib536656bf69ee323@mail.gmail.com> <810a540e0709012345t5aba354ai6f2f7414fe5a5ea@mail.gmail.com> <57c63afe0709020056y26081df7labe53761f20fa90a@mail.gmail.com> <810a540e0709020232g1a8bc555h129dbbbc0be5d6a7@mail.gmail.com> Message-ID: <6d2bdda0709020328u383598d8rd19cfc80aa610ecc@mail.gmail.com> I have an articleabout this in my blog, with a controller spec example, testing just behaviour and not the code. Please, comment it and tell me what you think. I guess that with the new Story runner, this approach will be even better. Thanks in advance. -- http://papipo.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070902/cda3e993/attachment.html From dchelimsky at gmail.com Sun Sep 2 10:49:33 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 2 Sep 2007 09:49:33 -0500 Subject: [rspec-users] testing behaviour or testing code? In-Reply-To: <6d2bdda0709020328u383598d8rd19cfc80aa610ecc@mail.gmail.com> References: <12309322.post@talk.nabble.com> <57c63afe0708240659y1ea3668qc2065333f199a7bb@mail.gmail.com> <810a540e0708241006m23118ed7k9248705c13c2678a@mail.gmail.com> <57c63afe0708241012o6c5bf76bib536656bf69ee323@mail.gmail.com> <810a540e0709012345t5aba354ai6f2f7414fe5a5ea@mail.gmail.com> <57c63afe0709020056y26081df7labe53761f20fa90a@mail.gmail.com> <810a540e0709020232g1a8bc555h129dbbbc0be5d6a7@mail.gmail.com> <6d2bdda0709020328u383598d8rd19cfc80aa610ecc@mail.gmail.com> Message-ID: <57c63afe0709020749u52ca0437h8f594ea02b69e344@mail.gmail.com> On 9/2/07, Rodrigo Alvarez Fern?ndez wrote: > I have an article about this in my blog, with a controller spec example, > testing just behaviour and not the code. Please, comment it and tell me what > you think. I added comments on the blog: http://papipo.blogspot.com/2007/08/bdd-isolation-integration.html > I guess that with the new Story runner, this approach will be > even better. Be careful here - Story Runner is not really intended to solve these lower level problems. Not that it can't be used for that, but it's a lot more heavyweight and better suited for high level scenarios that exercise the code end to end (including the DB). Cheers, David > > Thanks in advance. > > -- > http://papipo.blogspot.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From papipo at gmail.com Sun Sep 2 11:18:36 2007 From: papipo at gmail.com (=?ISO-8859-1?Q?Rodrigo_Alvarez_Fern=E1ndez?=) Date: Sun, 2 Sep 2007 17:18:36 +0200 Subject: [rspec-users] testing behaviour or testing code? In-Reply-To: <57c63afe0709020749u52ca0437h8f594ea02b69e344@mail.gmail.com> References: <12309322.post@talk.nabble.com> <57c63afe0708240659y1ea3668qc2065333f199a7bb@mail.gmail.com> <810a540e0708241006m23118ed7k9248705c13c2678a@mail.gmail.com> <57c63afe0708241012o6c5bf76bib536656bf69ee323@mail.gmail.com> <810a540e0709012345t5aba354ai6f2f7414fe5a5ea@mail.gmail.com> <57c63afe0709020056y26081df7labe53761f20fa90a@mail.gmail.com> <810a540e0709020232g1a8bc555h129dbbbc0be5d6a7@mail.gmail.com> <6d2bdda0709020328u383598d8rd19cfc80aa610ecc@mail.gmail.com> <57c63afe0709020749u52ca0437h8f594ea02b69e344@mail.gmail.com> Message-ID: <6d2bdda0709020818q71289f5j971238242e5e5afa@mail.gmail.com> On 9/2/07, David Chelimsky wrote: > > On 9/2/07, Rodrigo Alvarez Fern?ndez wrote: > > I have an article about this in my blog, with a controller spec example, > > testing just behaviour and not the code. Please, comment it and tell me > what > > you think. > > I added comments on the blog: > http://papipo.blogspot.com/2007/08/bdd-isolation-integration.html > > > I guess that with the new Story runner, this approach will be > > even better. > > Be careful here - Story Runner is not really intended to solve these > lower level problems. Not that it can't be used for that, but it's a > lot more heavyweight and better suited for high level scenarios that > exercise the code end to end (including the DB). Yes, I meant as integration tests. Cheers, > David > > > > > Thanks in advance. > > > > -- > > http://papipo.blogspot.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 > -- http://papipo.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070902/fc52dc6f/attachment.html From dchelimsky at gmail.com Sun Sep 2 12:43:13 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 2 Sep 2007 11:43:13 -0500 Subject: [rspec-users] testing behaviour or testing code? In-Reply-To: <810a540e0709020232g1a8bc555h129dbbbc0be5d6a7@mail.gmail.com> References: <12309322.post@talk.nabble.com> <57c63afe0708240659y1ea3668qc2065333f199a7bb@mail.gmail.com> <810a540e0708241006m23118ed7k9248705c13c2678a@mail.gmail.com> <57c63afe0708241012o6c5bf76bib536656bf69ee323@mail.gmail.com> <810a540e0709012345t5aba354ai6f2f7414fe5a5ea@mail.gmail.com> <57c63afe0709020056y26081df7labe53761f20fa90a@mail.gmail.com> <810a540e0709020232g1a8bc555h129dbbbc0be5d6a7@mail.gmail.com> Message-ID: <57c63afe0709020943o1a9e4783x65390eb7ad44c87a@mail.gmail.com> On 9/2/07, Pat Maddox wrote: > On 9/2/07, David Chelimsky wrote: > > On 9/2/07, Pat Maddox wrote: > > > On 8/24/07, David Chelimsky wrote: > > > > On 8/24/07, Pat Maddox wrote: > > > > > On 8/24/07, David Chelimsky wrote: > > > > > > describe Widget, "class" do > > > > > > it "should provide a list of widgets sorted alphabetically" do > > > > > > Widget.should_receive(:find).with(:order => "name ASC") > > > > > > Widget.find_alphabetically > > > > > > end > > > > > > end > > > > > > > > > > > > You're correct that the refactoring requires you to change the > > > > > > object-level examples, and that is something that would be nice to > > > > > > avoid. But also keep in mind that in java and C# people refactor > > > > > > things like that all the time without batting an eye, because the > > > > > > tools make it a one-step activity. Refactoring is changing the design > > > > > > of your *system* without changing its behaviour. That doesn't really > > > > > > fly all the way down to the object level 100% of the time. > > > > > > > > > > > > WDYT? > > > > > > > > > > I think that example is fine up until the model spec. The > > > > > find_alphabetically example should hit the db, imo. With the current > > > > > spec there's no way to know whether find_alphabetically actually works > > > > > or not. You're relying on knowledge of ActiveRecord here, trusting > > > > > that the arguments to find are correct. > > > > > > > > Au contrare! This all starts with an Integration Test. I didn't post > > > > the code but I did mention it. > > > > > > > > > What I've found when I write specs is that I discover new layers of > > > > > services until eventually I get to a layer that actually does > > > > > something. When I get there, it's important to have specs that > > > > > describe what it does, not how it does it. In the case of > > > > > find_alphabetically we care that it returns the items in alphabetical > > > > > order. Not that it makes a certain call to the db. > > > > > > > > I play this both ways and haven't come to a preference, but I'm > > > > leaning towards blocking database access from the rspec examples and > > > > only allowing it my end to end tests (using Rails Integration Tests or > > > > - soon - RSpec's new Story Runner). > > > > > > Now that I've had a chance to play with Story Runner, I want to > > > revisit this topic a bit. > > > > > > Let's say in your example you wanted to refactor find_alphabetically > > > to use enumerable's sort_by to do the sorting. > > > > > > def self.find_alphabetically > > > find(:all).sort_by {|w| w.name } > > > end > > > > > > Your model spec will fail, but your integration test will still pass. > > > > > > I've been thinking about this situation a lot over the last few > > > months. It's been entirely theoretical because I haven't had a suite > > > of integration tests ;) Most XP advocates lean heavily on unit tests > > > when doing refactoring. Mocking tends to get in the way of > > > refactoring though. In the example above, we rely on the integration > > > test to give us confidence while refactoring. In fact I would ignore > > > the unit test (model-level spec) altogether, and rewrite it when the > > > refactoring is complete. > > > > > > Here's how I reconcile this with traditional XP unit testing. First > > > of all our integration tests are relatively light weight. In a web > > > app, a user story consists of making a request and verifying the > > > response. Authentication included, you'll be making at most 3-5 HTTP > > > requests per test. This means that our integration tests still run in > > > just a few seconds. Integration tests in a Rails app are a completely > > > different beast from the integration tests in the Chrysler payroll app > > > that Beck, Jeffries, et al worked on. > > > > > > The second point of reconciliation is that mock objects and > > > refactoring are two distinct tools you use to design your code. When > > > I'm writing greenfield code I'll use mocks to drive the design. When > > > I refactor though, I'm following known steps to improve the design of > > > my existing code. The vast majority of the time I will perform a > > > known refactoring, which means I know the steps and the resulting > > > design. In this situation I'll ignore my model specs because they'll > > > blow up, giving me no information other than I changed the design of > > > my code. I can use the integration tests to ensure that I haven't > > > broken any behavior. At this point I would edit the model specs to > > > use the correct mock calls. > > > > > > As I mentioned, this has been something that's been on my mind for a > > > while. I find mock objects to be very useful, but they seem to clash > > > with most of the existing TDD and XP literature. To summarize, here > > > are the points where I think they clash: > > > > > > * Classical TDD relies on unit tests for confidence in refactoring. > > > BDD relies on integration tests > > > * XP acceptance tests are customer tests, whereas RSpec User Stories > > > are programmer tests. They can serve a dual-purpose because you can > > > easily show them to a customer, but they're programmer tests in the > > > sense that the programmer writes and is responsible for those > > > particular tests. > > > > > > In the end it boils down to getting stuff done. After a bit of > > > experimentation I'm thinking that the process of > > > 1. Write a user story > > > 2. Write detailed specs using mocks to drive design > > > 3. Refactor, using stories to ensure that expected behavior is > > > maintained, ignoring detailed specs > > > 4. Retrofit specs with correct mock expectations > > > > > > is a solid approach. I'd like others to weigh in with their thoughts. > > > > Hey Pat, > > > > I really appreciate that you're thinking about and sharing this as its > > something that weighs on a lot of people's minds and it's clear that > > you have some understanding of the XP context in which all of this was > > born. > > > > That said, I see this quite a bit differently. > > > > I don't think this has anything to do w/ TDD vs BDD. "Mock Objects" is > > not a BDD concept. It just feels that way because we talk more about > > interaction testing, but interaction testing predates BDD by some > > years. > > Hi David, > > Thanks so much for your thoughtful reply. Thanks for your thought provoking post! > You're right, and I didn't mean to suggest that mock objects were a > BDD concept at all. However it seems to me that BDDers embrace mock > objects as a very useful design tool, whereas classical TDDers would > use them sparsely, when a resource is expensive or difficult to use > directly. This is true to some extent, but the mock objects paper, which introduced the idea of mocks-as-design-tool (http://mockobjects.com/files/mockrolesnotobjects.pdf) was presented at OOPSLA 04, and the thinking that it came from had already been evolving. > For example, Beck talks about mocking a database in his > book, and that's that. Astels demonstrates mocking the roll of a die. > He does briefly use mocks before he's ready to implement the GUI part > of the app. > > Those are the two TDD books with which I'm most familiar. I'm sure a > lot has changed in the TDD community since then, and indeed you can > see that Astels' mentality has changed somewhat. His "one assertion > per test" article [1] parses an address and then verifies it by > asserting the getters. His remake, "one expectation per example" [2] > is a bit different in that he passes a mocked builder in and uses that > to verify that the parsing code works, exposing no getters at all. > That to me signifies a fundamental shift in TDD thought. Instead of > thinking about objects in isolation and what services they provide, we > think of the services an object provides and how it interacts with > other objects and uses their services. > > I'm certain that it's not a new way of thinking, but hopefully you can > see why I'd believe it's probably not mainstream. > > There's one other roadblock to my thinking, and it results from using > RSpec almost exclusively within Rails projects. I think it's obvious > why you mock models when writing view and controller specs. However > less obvious to me is why mock associations in model specs, and I > think it has to do with the fact that AR couples business and > persistence logic. Absolutely! AR presents quite a testing conundrum. It's clear from the testing approach supported by Rails directly that decoupling from the database is simply not of interested to DHH and company. Or at least it wasn't early on. I see mock frameworks starting to appear in the Rails codebase, so perhaps this is changing. And I don't mean to suggest that the Rails core team approach is the wrong approach. It simply does not align with what you've called "classical TDD thinking". > If we just had domain objects that never hit a database, then we might > initially mock interactions but then use concrete instances when we > later implemented those classes. When I think of Beck's Money > example, or Martin Fowler's video rental list in Refactoring, it seems > silly to me to use mocks in those cases. I think you're right. Even if you're going down what I view as the ideal mockists path - mocking everything that you need that doesn't exist yet - I've often used mocks in process, but replaced them w/ the real deal once the real objects existed. Then you're really using mocks for what they're most powerful at: interface discovery. And then disposing of them once they've passed their usefulness in a given situation. In the case of AR, I keep them around to keep from hitting the DB. > Perhaps you might at the > very beginning, but you'd sub real objects in as you implemented them. D'oh! You ARE an ideal mockist! > We don't do this with AR because they're simply too heavy. Funny - I'm tempted to remove what I wrote above - but this is fun - responding as I go and then discovering that you already made the same point. > This culminates in another general idea I've had which is to mock > services in a lower layer, and use concrete instances for objects in > the same layer when possible. If we were to split AR into domain > objects and a data access layer, the domain objects would mock calls > to the data access layer but use concrete domain objects in the tests. > The unit tests remain fast and simple, and mocks no longer get in the > way of refactoring. Ay, there's the rub. The problem we face is that AR promises huge productivity gains for the non TDD-er, and challenges the thinking of the die-hard TDD-er. I've gone back and forth about whether it's OK to test validations like this: it "should validate_presence_of digits" do PhoneNumber.expects(:validates_presence_of).with(:digits) load "#{RAILS_ROOT}/app/models/phone_number.rb" end On the one hand, it looks immediately like we're testing implementation. On the other, we're not really - we're mocking a call to an API. The confusion is that the API is represented in the same object as the one we're testing (at least its class object). I haven't really done this in anger yet, but I'm starting to think it's the right way to go - especially now that we have Story Runner to cover things end to end. WDYT of this approach? > > Of course then you're writing integration tests at a fairly low level > I guess, but that's 100% acceptable to me in the interest of getting > stuff done rather than being dogmatic. + 1 - in the end this is all about getting stuff done and knowing WHEN you're done. > > The problem we experience with mocks relates to the fact that > > we've chosen to live in the beautiful, free, dynamically typed and > > POORLY TOOLED land of Ruby. When Ruby refactoring tools catch up with > > those of java and .NET, this pain will all go away. > > > > For example - if I'm in IntelliJ in a java project and I have a method > > like this: > > > > model.getName() > > > > and I'm using jmock (the old version), which uses Strings for method names: > > > > model.expects(once()).method("getName").will(returnValue("stub value")) > > > > and I do a Rename Method refactoring on getName(), IntelliJ will ask > > me if I want to change the strings it finds that match getName as well > > as the method invocations. > > > > In Ruby, we do this now w/ search and replace. Not quite as elegant. > > But under the hood, that's all IntelliJ is doing. It just makes it > > feel like an integrated step of an automated refactoring. > > Agreed. I guess for me it's easier to get the production code right > and then fix the tests after the fact. I'd hate to do all the work of > changing the production and test code and then find out it was > incorrect. Fixing tests after fixing the production code amounts to > the same work as doing it all in one step, because as you mentioned > it's essentially a manual process. > > > re: Story Runner. The intent of Story Runner is exactly the same as > > tools like FIT, etc, that are typically found in the Acceptance > > Testing space in XP projects. In my experience using FitNesse, it was > > rare that a customer actually added new tests to a suite. If there > > were testing folks on board, they would do it (and they would likely > > be equipped to do it in Story Runner as well), but if not, then the > > FitNesse tests were at best the result of a collaborative session with > > the customer and, at worst, our (developers), interpretation of > > conversations we had had with the customer. > > > > I see Story Runner fitting in exactly like that in the short run. I > > can also see external DSLs emerging that let customers actually write > > the outputs that Story Runner should produce and run that through a > > process that writes what we're writing now in Story Runner. But that's > > probably some time off. > > > > I totally agree with your last statement that "it boils down to > > getting stuff done." And your approach seems to be the approach that I > > take, given the tools that we have. But I really think its about tools > > and not process. And I think that BDD is a lot more like what really > > experienced TDD'ers do out of the gate. We're just choosing different > > words and structures to make it easier to communicate across roles on > > a team (customer, developer, tester, etc). > > So "ideally," who would write Story Runner stories? I put it in > quotes because I think it would differ greatly depending on the work > environment, what kind of level of interaction you have with the > customer, etc. Using TDD terms, would we consider SR stories to be > Customer or Developer tests? I gather from your insight that they're > Customer tests. Yes - in my view they are Customer Tests - but bear in mind that that means "tests created by the person acting in the customer role." On a team of one, that might be the same person as the developer. > Finally I agree 100% on not focusing on process. I'm trying to figure > out the most effective process given the tools currently available, > and will be constantly changing it as more/better tools come along. > Although I suppose what I should really be spending my energy on is > building the tools that will make all our lives better ;) Patches always welcome! Cheers Pat. David > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sun Sep 2 12:55:27 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 2 Sep 2007 11:55:27 -0500 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> Message-ID: <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> On 9/2/07, Wilson Bilkovich wrote: > On 9/1/07, rupert wrote: > > > > On 1 Sep 2007, at 10:04, Tom Stuart wrote: > > > > > On 1 Sep 2007, at 09:31, rupert wrote: > > >>> Are we planning on dumping the mock framework in favor of using > > >>> Mocha > > >> The idea has been bandied around on the dev list recently > > This decision, if it is made in this manner, is suicide for RSpec. I simply don't understand this statement. Why is this such a big deal? RSpec's mock framework offers pretty much ZERO over mocha or flexmock - the only thing is that it saves you from typing 24 or 27 characters in a config file, depending on your preference. 21 if you use RR. After that, the functionality is pretty much the same as the other frameworks. > I have been a huge RSpec booster, but this will make me drop it like a hot coal. Again - I can't understand where you're coming from here. If you start using test/unit or test/spec or any of the other bdd frameworks you'll still need to make a decision about a mock framework. What is the pain that you're perceiving that will come along w/ us dumping the mock framework? Perhaps there's something we can do to minimize that pain once we know what it is. Cheers, David > =( > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mailing_lists at railsnewbie.com Sun Sep 2 13:36:47 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 2 Sep 2007 13:36:47 -0400 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> Message-ID: <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> On Sep 2, 2007, at 12:55 PM, David Chelimsky wrote: > On 9/2/07, Wilson Bilkovich wrote: >> On 9/1/07, rupert wrote: >>> >>> On 1 Sep 2007, at 10:04, Tom Stuart wrote: >>> >>>> On 1 Sep 2007, at 09:31, rupert wrote: >>>>>> Are we planning on dumping the mock framework in favor of using >>>>>> Mocha >>>>> The idea has been bandied around on the dev list recently >> >> This decision, if it is made in this manner, is suicide for RSpec. > > I simply don't understand this statement. Why is this such a big deal? > RSpec's mock framework offers pretty much ZERO over mocha or flexmock > - the only thing is that it saves you from typing 24 or 27 characters > in a config file, depending on your preference. 21 if you use RR. > > After that, the functionality is pretty much the same as the other > frameworks I'm a little confused about this discussion. Why don't we just do the following: 1. Hand off the mocking/stubbing framework off to someone else. It will be their project 2. Make the mocking/stubbing framework a dependency of the rspec gem 3. Make it the default (as it is now) 4. Provide clear directions for changing mocking frameworks (as we have now). I thought the end goal with refactoring the mocking framework out was not that we shouldn't be using it, but, that we (David, Aslak, Brian, etc) won't have to maintain it. Or am I missing something? Scott From omen.king at gmail.com Sun Sep 2 14:06:03 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 2 Sep 2007 14:06:03 -0400 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> Message-ID: I think that makes sense. Which do you recommend? Flexmock or Mocha? On 9/2/07, Scott Taylor wrote: > > > On Sep 2, 2007, at 12:55 PM, David Chelimsky wrote: > > > On 9/2/07, Wilson Bilkovich wrote: > >> On 9/1/07, rupert wrote: > >>> > >>> On 1 Sep 2007, at 10:04, Tom Stuart wrote: > >>> > >>>> On 1 Sep 2007, at 09:31, rupert wrote: > >>>>>> Are we planning on dumping the mock framework in favor of using > >>>>>> Mocha > >>>>> The idea has been bandied around on the dev list recently > >> > >> This decision, if it is made in this manner, is suicide for RSpec. > > > > I simply don't understand this statement. Why is this such a big deal? > > RSpec's mock framework offers pretty much ZERO over mocha or flexmock > > - the only thing is that it saves you from typing 24 or 27 characters > > in a config file, depending on your preference. 21 if you use RR. > > > > After that, the functionality is pretty much the same as the other > > frameworks > > I'm a little confused about this discussion. Why don't we just do > the following: > > 1. Hand off the mocking/stubbing framework off to someone else. It > will be their project > > 2. Make the mocking/stubbing framework a dependency of the rspec gem > > 3. Make it the default (as it is now) > > 4. Provide clear directions for changing mocking frameworks (as we > have now). > > I thought the end goal with refactoring the mocking framework out was > not that we shouldn't be using it, but, that we (David, Aslak, Brian, > etc) won't have to maintain it. Or am I missing something? > > Scott > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Monsterbox Productions putting small businesses on-line 1319 Victoria Avenue East Thunder Bay, Ontario P7C 1C3 Canada Andrew WC Brown web-developer and owner andrew at monsterboxpro.com P: 807-626-9009 F: 807-624-2705 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070902/52de5bc4/attachment.html From dchelimsky at gmail.com Sun Sep 2 16:04:07 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 2 Sep 2007 15:04:07 -0500 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> Message-ID: <57c63afe0709021304p2cfebe6ct5fce254eac1309f9@mail.gmail.com> On 9/2/07, Scott Taylor wrote: > > On Sep 2, 2007, at 12:55 PM, David Chelimsky wrote: > > > On 9/2/07, Wilson Bilkovich wrote: > >> On 9/1/07, rupert wrote: > >>> > >>> On 1 Sep 2007, at 10:04, Tom Stuart wrote: > >>> > >>>> On 1 Sep 2007, at 09:31, rupert wrote: > >>>>>> Are we planning on dumping the mock framework in favor of using > >>>>>> Mocha > >>>>> The idea has been bandied around on the dev list recently > >> > >> This decision, if it is made in this manner, is suicide for RSpec. > > > > I simply don't understand this statement. Why is this such a big deal? > > RSpec's mock framework offers pretty much ZERO over mocha or flexmock > > - the only thing is that it saves you from typing 24 or 27 characters > > in a config file, depending on your preference. 21 if you use RR. > > > > After that, the functionality is pretty much the same as the other > > frameworks > > I'm a little confused about this discussion. Why don't we just do > the following: > > 1. Hand off the mocking/stubbing framework off to someone else. It > will be their project > > 2. Make the mocking/stubbing framework a dependency of the rspec gem > > 3. Make it the default (as it is now) > > 4. Provide clear directions for changing mocking frameworks (as we > have now). > > I thought the end goal with refactoring the mocking framework out was > not that we shouldn't be using it, but, that we (David, Aslak, Brian, > etc) won't have to maintain it. Or am I missing something? Well, it's not simply a matter of US maintaining it. It's a matter of it being maintained at all in light of the fact that mocha and flexmock exist. Put simply, there never should have been an rspec mock framework. But here we are. In my view, we either put the thing to sleep or keep it part of rspec and forget the whole deprecation thing. Handling it off to someone else to maintain seems silly to me. FWIW, David > > Scott > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists-rspec at shopwatch.org Sun Sep 2 16:35:17 2007 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Sun, 02 Sep 2007 16:35:17 -0400 Subject: [rspec-users] How do you keep mocks updated without pain? In-Reply-To: <85d99afe0708291519t4152d755m3700b024f528a4ac@mail.gmail.com> References: <85d99afe0708291519t4152d755m3700b024f528a4ac@mail.gmail.com> Message-ID: <46DB1E85.8040900@shopwatch.org> On 8/29/2007 6:19 PM, Zach Dennis wrote: > In rspec, controller, model and view specs are just unit tests/specs. And that's really the key; in Rails Test::Unit, model tests are unit tests, and controller tests are higher-level "functional" tests. So you never get to unit-test your controllers. On the other hand, in RSpec through 1.0.8, you never get to integration-test anything at all. But that's all changing! Jay From mailing_lists at railsnewbie.com Sun Sep 2 17:20:49 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 2 Sep 2007 17:20:49 -0400 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <57c63afe0709021304p2cfebe6ct5fce254eac1309f9@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <57c63afe0709021304p2cfebe6ct5fce254eac1309f9@mail.gmail.com> Message-ID: <9924D5AE-5EBA-4992-8892-EEC5FFEDD624@railsnewbie.com> > > Well, it's not simply a matter of US maintaining it. It's a matter of > it being maintained at all in light of the fact that mocha and > flexmock exist. Put simply, there never should have been an rspec mock > framework. > > But here we are. > > In my view, we either put the thing to sleep or keep it part of rspec > and forget the whole deprecation thing. Handling it off to someone > else to maintain seems silly to me. > > FWIW, > David Ah. I had no idea. Why was it originally created, then? Were you guys not happy with mocha at the time? I find it hard to believe that you were ignorant about it. Plus - are you going to change all of rspec's specs to use flexmock or mocha? Scott From mailing_lists at railsnewbie.com Sun Sep 2 17:51:53 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 2 Sep 2007 17:51:53 -0400 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <57c63afe0709021304p2cfebe6ct5fce254eac1309f9@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <57c63afe0709021304p2cfebe6ct5fce254eac1309f9@mail.gmail.com> Message-ID: > > Well, it's not simply a matter of US maintaining it. It's a matter of > it being maintained at all in light of the fact that mocha and > flexmock exist. Put simply, there never should have been an rspec mock > framework. > > But here we are. > > In my view, we either put the thing to sleep or keep it part of rspec > and forget the whole deprecation thing. Handling it off to someone > else to maintain seems silly to me. Just to reiterate on my last point: There are some advantages to keeping the framework - namely that we won't have to convert a lot of specs. But there are other advantages, too. New features are easier for us to implement for ourselves. I've already had some ideas for how the mocking framework could become better (i.e. support for anonymous functions). I think if we keep it, we should be looking to implement some of those advantages that the other mocking frameworks don't have. We also have steam, which I don't think mocha and flexmock have (although I could be wrong about this). I just took a look at flexmock - and must say that I don't like the "partial mock" language, because it is confusing to my brain which distinguishes a stub from a mock. And mocha/stubba has an ugly syntax (In my humble, and inexperienced, opinion). If you did "put the thing [rspec's mocking framework] to sleep" - which would you covert to - Mocha, or Flexmock? Scott From lists-rspec at shopwatch.org Sun Sep 2 18:14:53 2007 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Sun, 02 Sep 2007 18:14:53 -0400 Subject: [rspec-users] testing behaviour or testing code? In-Reply-To: <57c63afe0709020943o1a9e4783x65390eb7ad44c87a@mail.gmail.com> References: <12309322.post@talk.nabble.com> <57c63afe0708240659y1ea3668qc2065333f199a7bb@mail.gmail.com> <810a540e0708241006m23118ed7k9248705c13c2678a@mail.gmail.com> <57c63afe0708241012o6c5bf76bib536656bf69ee323@mail.gmail.com> <810a540e0709012345t5aba354ai6f2f7414fe5a5ea@mail.gmail.com> <57c63afe0709020056y26081df7labe53761f20fa90a@mail.gmail.com> <810a540e0709020232g1a8bc555h129dbbbc0be5d6a7@mail.gmail.com> <57c63afe0709020943o1a9e4783x65390eb7ad44c87a@mail.gmail.com> Message-ID: <46DB35DD.2040701@shopwatch.org> On 9/2/2007 12:43 PM, David Chelimsky wrote: > The problem we face is that AR promises huge productivity gains for > the non TDD-er, and challenges the thinking of the die-hard TDD-er. > > I've gone back and forth about whether it's OK to test validations like this: > > it "should validate_presence_of digits" do > PhoneNumber.expects(:validates_presence_of).with(:digits) > load "#{RAILS_ROOT}/app/models/phone_number.rb" > end > > On the one hand, it looks immediately like we're testing > implementation. On the other, we're not really - we're mocking a call > to an API. The confusion is that the API is represented in the same > object as the one we're testing (at least its class object). I haven't > really done this in anger yet, but I'm starting to think it's the > right way to go - especially now that we have Story Runner to cover > things end to end. WDYT of this approach? Personally, I don't much like it. It feels too much like: it "should validate_presence_of digits" do my_model.line(7).should_read "validates_presence_of :digits" end I can write specs like that all day and ensure absolutely nothing about my code. I like to think of specs as a form of N-version programming where N=2 (or maybe N=3 now with Story Runner). By using a different vocabulary to express the specs than the actual code, we are more likely to think of the problem differently, and thus find places where the two versions of our code differ. Sometimes, it means we miswrote the spec; sometimes, it means we miswrote the code. But if all your spec does is guarantee that your code reads a certain way, you've done nothing but protect against accidental edits. And if you're gonna go that way, why not go all the way: it "shouldn't change unless I change the spec too" do MD5.new(my_model).should == "0xDEADBEEF0FFD2FFE4..." end I'd much rather see: it "should prevent me from entering anything but digits" do PhoneNumber.new("800-MATTRESS").should_not be_valid end And then, every time I find an edge case, I add another spec: it "should allow me to enter dashes" do PhoneNumber.new("800-555-1212").should be_valid end it "should only allow 10 digits" do PhoneNumber.new("800-555-12121212").should_not be_valid end etc. Jay Levitt From dchelimsky at gmail.com Sun Sep 2 23:49:20 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 2 Sep 2007 22:49:20 -0500 Subject: [rspec-users] testing behaviour or testing code? In-Reply-To: <46DB35DD.2040701@shopwatch.org> References: <12309322.post@talk.nabble.com> <57c63afe0708240659y1ea3668qc2065333f199a7bb@mail.gmail.com> <810a540e0708241006m23118ed7k9248705c13c2678a@mail.gmail.com> <57c63afe0708241012o6c5bf76bib536656bf69ee323@mail.gmail.com> <810a540e0709012345t5aba354ai6f2f7414fe5a5ea@mail.gmail.com> <57c63afe0709020056y26081df7labe53761f20fa90a@mail.gmail.com> <810a540e0709020232g1a8bc555h129dbbbc0be5d6a7@mail.gmail.com> <57c63afe0709020943o1a9e4783x65390eb7ad44c87a@mail.gmail.com> <46DB35DD.2040701@shopwatch.org> Message-ID: <57c63afe0709022049m36acf1ebqee936361a5c9981c@mail.gmail.com> On 9/2/07, Jay Levitt wrote: > On 9/2/2007 12:43 PM, David Chelimsky wrote: > > The problem we face is that AR promises huge productivity gains for > > the non TDD-er, and challenges the thinking of the die-hard TDD-er. > > > > I've gone back and forth about whether it's OK to test validations like this: > > > > it "should validate_presence_of digits" do > > PhoneNumber.expects(:validates_presence_of).with(:digits) > > load "#{RAILS_ROOT}/app/models/phone_number.rb" > > end > > > > On the one hand, it looks immediately like we're testing > > implementation. On the other, we're not really - we're mocking a call > > to an API. The confusion is that the API is represented in the same > > object as the one we're testing (at least its class object). I haven't > > really done this in anger yet, but I'm starting to think it's the > > right way to go - especially now that we have Story Runner to cover > > things end to end. WDYT of this approach? > > Personally, I don't much like it. It feels too much like: > > it "should validate_presence_of digits" do > my_model.line(7).should_read "validates_presence_of :digits" > end > > I can write specs like that all day and ensure absolutely nothing about > my code. > > I like to think of specs as a form of N-version programming where N=2 > (or maybe N=3 now with Story Runner). By using a different vocabulary > to express the specs than the actual code, we are more likely to think > of the problem differently, and thus find places where the two versions > of our code differ. Sometimes, it means we miswrote the spec; > sometimes, it means we miswrote the code. > > But if all your spec does is guarantee that your code reads a certain > way, you've done nothing but protect against accidental edits. And if > you're gonna go that way, why not go all the way: > > it "shouldn't change unless I change the spec too" do > MD5.new(my_model).should == "0xDEADBEEF0FFD2FFE4..." > end > > I'd much rather see: > > it "should prevent me from entering anything but digits" do > PhoneNumber.new("800-MATTRESS").should_not be_valid > end > > And then, every time I find an edge case, I add another spec: > > it "should allow me to enter dashes" do > PhoneNumber.new("800-555-1212").should be_valid > end > > it "should only allow 10 digits" do > PhoneNumber.new("800-555-12121212").should_not be_valid > end A couple of things to consider: There's a very useful guideline in TDD that says "test YOUR code, not everyone elses." The validation library we're testing here is ActiveRecord's. It's already tested (we hope!). Also - there's a difference between the behaviour of a system and the behaviour of an object. The system's job is to validate that the phone number is all digits. So it makes sense to have examples like that in high level examples using Story Runner, rails integration tests, or an in-browser suite like Selenium or Watir. This model object's job is to make sure the input gets validated, not to actually validate it. If the model made a more OO-feeling call out to a message library - something like this: class PhoneNumber def validators @validators ||= [] end def add_validator (validator) validators << validator end def validate(input) validators.each {|v| v.validate (input)} end end Then submitting mock validators via add_validator and setting mock expectations that they get called would be totally par for the course. In AR, the validators are added declaratively. This is a Rails design decision that we have to either live with or write other code around. Choosing to live with it, it seems to me that mocking the call to validates_presence_of :digits is no different than mocking validate on an injected validator. That all make sense? > > etc. > > > Jay Levitt > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From zach.dennis at gmail.com Mon Sep 3 00:08:57 2007 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 3 Sep 2007 00:08:57 -0400 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> Message-ID: <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> On 9/2/07, Andrew WC Brown wrote: > I think that makes sense. > > Which do you recommend? Flexmock or Mocha? > I wouldn't recommend either of them by themselves, at least the current way they sit. Jim Weirich may be adding globally ordered strict mocks, which if he does then I think Flexmock will be the first mocking library in ruby to cover all mocking needs (as far as I know). Mocha (and RSpec mocks too) don't support globally strict ordered mocks. Hardmock is another mocking library which is just strict mocking (no stubs, no partial mocks). Right now I prefer Mocha + Hardmock, but I'm eagerly awaiting to see if Flexmock gets globally strict ordered mocks. Zach Dennis http://www.continuousthinking.com From pergesu at gmail.com Mon Sep 3 01:43:10 2007 From: pergesu at gmail.com (Pat Maddox) Date: Sun, 2 Sep 2007 22:43:10 -0700 Subject: [rspec-users] testing behaviour or testing code? In-Reply-To: <57c63afe0709022049m36acf1ebqee936361a5c9981c@mail.gmail.com> References: <12309322.post@talk.nabble.com> <57c63afe0708240659y1ea3668qc2065333f199a7bb@mail.gmail.com> <810a540e0708241006m23118ed7k9248705c13c2678a@mail.gmail.com> <57c63afe0708241012o6c5bf76bib536656bf69ee323@mail.gmail.com> <810a540e0709012345t5aba354ai6f2f7414fe5a5ea@mail.gmail.com> <57c63afe0709020056y26081df7labe53761f20fa90a@mail.gmail.com> <810a540e0709020232g1a8bc555h129dbbbc0be5d6a7@mail.gmail.com> <57c63afe0709020943o1a9e4783x65390eb7ad44c87a@mail.gmail.com> <46DB35DD.2040701@shopwatch.org> <57c63afe0709022049m36acf1ebqee936361a5c9981c@mail.gmail.com> Message-ID: <810a540e0709022243n39ee7a13t5501f58b5cafa848@mail.gmail.com> On 9/2/07, David Chelimsky wrote: > On 9/2/07, Jay Levitt wrote: > > On 9/2/2007 12:43 PM, David Chelimsky wrote: > > > The problem we face is that AR promises huge productivity gains for > > > the non TDD-er, and challenges the thinking of the die-hard TDD-er. > > > > > > I've gone back and forth about whether it's OK to test validations like this: > > > > > > it "should validate_presence_of digits" do > > > PhoneNumber.expects(:validates_presence_of).with(:digits) > > > load "#{RAILS_ROOT}/app/models/phone_number.rb" > > > end > > > > > > On the one hand, it looks immediately like we're testing > > > implementation. On the other, we're not really - we're mocking a call > > > to an API. The confusion is that the API is represented in the same > > > object as the one we're testing (at least its class object). I haven't > > > really done this in anger yet, but I'm starting to think it's the > > > right way to go - especially now that we have Story Runner to cover > > > things end to end. WDYT of this approach? > > > > Personally, I don't much like it. It feels too much like: > > > > it "should validate_presence_of digits" do > > my_model.line(7).should_read "validates_presence_of :digits" > > end > > > > I can write specs like that all day and ensure absolutely nothing about > > my code. > > > > I like to think of specs as a form of N-version programming where N=2 > > (or maybe N=3 now with Story Runner). By using a different vocabulary > > to express the specs than the actual code, we are more likely to think > > of the problem differently, and thus find places where the two versions > > of our code differ. Sometimes, it means we miswrote the spec; > > sometimes, it means we miswrote the code. > > > > But if all your spec does is guarantee that your code reads a certain > > way, you've done nothing but protect against accidental edits. And if > > you're gonna go that way, why not go all the way: > > > > it "shouldn't change unless I change the spec too" do > > MD5.new(my_model).should == "0xDEADBEEF0FFD2FFE4..." > > end > > > > I'd much rather see: > > > > it "should prevent me from entering anything but digits" do > > PhoneNumber.new("800-MATTRESS").should_not be_valid > > end > > > > And then, every time I find an edge case, I add another spec: > > > > it "should allow me to enter dashes" do > > PhoneNumber.new("800-555-1212").should be_valid > > end > > > > it "should only allow 10 digits" do > > PhoneNumber.new("800-555-12121212").should_not be_valid > > end > > A couple of things to consider: > > There's a very useful guideline in TDD that says "test YOUR code, not > everyone elses." The validation library we're testing here is > ActiveRecord's. It's already tested (we hope!). > > Also - there's a difference between the behaviour of a system and the > behaviour of an object. The system's job is to validate that the phone > number is all digits. So it makes sense to have examples like that in > high level examples using Story Runner, rails integration tests, or an > in-browser suite like Selenium or Watir. > > This model object's job is to make sure the input gets validated, not > to actually validate it. If the model made a more OO-feeling call out > to a message library - something like this: > > class PhoneNumber > def validators > @validators ||= [] > end > > def add_validator (validator) > validators << validator > end > > def validate(input) > validators.each {|v| v.validate (input)} > end > end > > Then submitting mock validators via add_validator and setting mock > expectations that they get called would be totally par for the course. > > In AR, the validators are added declaratively. This is a Rails design > decision that we have to either live with or write other code around. > Choosing to live with it, it seems to me that mocking the call to > validates_presence_of :digits is no different than mocking validate on > an injected validator. > > That all make sense? There's nothing technically *wrong* with it, and logically it holds weight. It just doesn't feel right. Your key point is that we're making an API call, which I agree with. We also agree that AR probably does too much, and I think this is a situation where we should go with the flow. We call my_record.valid? and end up with my_record.errors if it's not valid. An AR object is in fact responsible for its own validation (even if you feel it's too much responsibility). It makes sense to specify the object's behavior in the same way. Personally I can't find a strong argument either way. I'm sure it's a matter of taste here. I would prefer to look at a spec and get as much info on how to use an object as possible. In that case, creating an object, calling valid?, and inspecting errors is probably more helpful. But after giving this a lot of thought, I'm not sure it warrants a ton of thought :) Pat From dchelimsky at gmail.com Mon Sep 3 01:53:42 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 3 Sep 2007 00:53:42 -0500 Subject: [rspec-users] blog post on story runner Message-ID: <57c63afe0709022253x15a3b07ev19168560a1636990@mail.gmail.com> Here's an excellent blog post on Story Runner, which will be part of the next release and is undergoing active development in trunk: http://evang.eli.st/blog/2007/9/1/user-stories-with-rspec-s-story-runner From pergesu at gmail.com Mon Sep 3 02:29:24 2007 From: pergesu at gmail.com (Pat Maddox) Date: Sun, 2 Sep 2007 23:29:24 -0700 Subject: [rspec-users] blog post on story runner In-Reply-To: <57c63afe0709022253x15a3b07ev19168560a1636990@mail.gmail.com> References: <57c63afe0709022253x15a3b07ev19168560a1636990@mail.gmail.com> Message-ID: <810a540e0709022329i470f66ebrcae5652c53ba35a4@mail.gmail.com> On 9/2/07, David Chelimsky wrote: > Here's an excellent blog post on Story Runner, which will be part of > the next release and is undergoing active development in trunk: > > http://evang.eli.st/blog/2007/9/1/user-stories-with-rspec-s-story-runner > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > I've updated it to include the output from the integration test and Story Runner. Pat From peter_marklund at fastmail.fm Mon Sep 3 03:07:59 2007 From: peter_marklund at fastmail.fm (Peter Marklund) Date: Mon, 3 Sep 2007 09:07:59 +0200 Subject: [rspec-users] testing behaviour or testing code? In-Reply-To: <57c63afe0709022049m36acf1ebqee936361a5c9981c@mail.gmail.com> References: <12309322.post@talk.nabble.com> <57c63afe0708240659y1ea3668qc2065333f199a7bb@mail.gmail.com> <810a540e0708241006m23118ed7k9248705c13c2678a@mail.gmail.com> <57c63afe0708241012o6c5bf76bib536656bf69ee323@mail.gmail.com> <810a540e0709012345t5aba354ai6f2f7414fe5a5ea@mail.gmail.com> <57c63afe0709020056y26081df7labe53761f20fa90a@mail.gmail.com> <810a540e0709020232g1a8bc555h129dbbbc0be5d6a7@mail.gmail.com> <57c63afe0709020943o1a9e4783x65390eb7ad44c87a@mail.gmail.com> <46DB35DD.2040701@shopwatch.org> <57c63afe0709022049m36acf1ebqee936361a5c9981c@mail.gmail.com> Message-ID: <83B5CE48-0AFC-414D-8609-1E7FAAA35EDC@fastmail.fm> > There's a very useful guideline in TDD that says "test YOUR code, not > everyone elses." The validation library we're testing here is > ActiveRecord's. It's already tested (we hope!). Personally, I don't have the courage to assume Rails code is always working. I know from experience it doesn't always work although it is quite solid in general. The Rails code has been tested but not in conjunction with my particular apps. I also want to test my assumptions of how the Rails API works, maybe it doesn't work as I think. Having tests/specs that cover Rails interaction with my app, which higher level tests of course naturally do (system/integration tests), gives me much more courage to upgrade Rails as well. Peter From pergesu at gmail.com Mon Sep 3 03:48:02 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 3 Sep 2007 00:48:02 -0700 Subject: [rspec-users] testing behaviour or testing code? In-Reply-To: <83B5CE48-0AFC-414D-8609-1E7FAAA35EDC@fastmail.fm> References: <12309322.post@talk.nabble.com> <810a540e0708241006m23118ed7k9248705c13c2678a@mail.gmail.com> <57c63afe0708241012o6c5bf76bib536656bf69ee323@mail.gmail.com> <810a540e0709012345t5aba354ai6f2f7414fe5a5ea@mail.gmail.com> <57c63afe0709020056y26081df7labe53761f20fa90a@mail.gmail.com> <810a540e0709020232g1a8bc555h129dbbbc0be5d6a7@mail.gmail.com> <57c63afe0709020943o1a9e4783x65390eb7ad44c87a@mail.gmail.com> <46DB35DD.2040701@shopwatch.org> <57c63afe0709022049m36acf1ebqee936361a5c9981c@mail.gmail.com> <83B5CE48-0AFC-414D-8609-1E7FAAA35EDC@fastmail.fm> Message-ID: <810a540e0709030048s162c9ecbqc1d731011e1bf8ac@mail.gmail.com> On 9/3/07, Peter Marklund wrote: > > There's a very useful guideline in TDD that says "test YOUR code, not > > everyone elses." The validation library we're testing here is > > ActiveRecord's. It's already tested (we hope!). > > Personally, I don't have the courage to assume Rails code is always > working. I know from experience it doesn't always work although it is > quite solid in general. The Rails code has been tested but not in > conjunction with my particular apps. I also want to test my > assumptions of how the Rails API works, maybe it doesn't work as I > think. Having tests/specs that cover Rails interaction with my app, > which higher level tests of course naturally do (system/integration > tests), gives me much more courage to upgrade Rails as well. > > Peter That's a good point. Having specs in place that demonstrate how you expect the code to behave will alert when a newer version of Rails behaves a bit differently. Granted, in the validates_presence_of example that probably won't be an issue, but you get the idea. I think it was Kevin Clark who said it's a good idea to learn Ruby by writing specs...then whenever you upgrade Ruby or install new libraries, your spec suite will make it clear when your assumptions about the language need to change. Pat From mailing_lists at railsnewbie.com Mon Sep 3 03:59:28 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Mon, 3 Sep 2007 03:59:28 -0400 Subject: [rspec-users] testing behaviour or testing code? In-Reply-To: <810a540e0709030048s162c9ecbqc1d731011e1bf8ac@mail.gmail.com> References: <12309322.post@talk.nabble.com> <810a540e0708241006m23118ed7k9248705c13c2678a@mail.gmail.com> <57c63afe0708241012o6c5bf76bib536656bf69ee323@mail.gmail.com> <810a540e0709012345t5aba354ai6f2f7414fe5a5ea@mail.gmail.com> <57c63afe0709020056y26081df7labe53761f20fa90a@mail.gmail.com> <810a540e0709020232g1a8bc555h129dbbbc0be5d6a7@mail.gmail.com> <57c63afe0709020943o1a9e4783x65390eb7ad44c87a@mail.gmail.com> <46DB35DD.2040701@shopwatch.org> <57c63afe0709022049m36acf1ebqee936361a5c9981c@mail.gmail.com> <83B5CE48-0AFC-414D-8609-1E7FAAA35EDC@fastmail.fm> <810a540e0709030048s162c9ecbqc1d731011e1bf8ac@mail.gmail.com> Message-ID: <2403B620-59D3-4B78-9583-EB1B0E5ECFFD@railsnewbie.com> On Sep 3, 2007, at 3:48 AM, Pat Maddox wrote: > On 9/3/07, Peter Marklund wrote: >>> There's a very useful guideline in TDD that says "test YOUR code, >>> not >>> everyone elses." The validation library we're testing here is >>> ActiveRecord's. It's already tested (we hope!). >> >> Personally, I don't have the courage to assume Rails code is always >> working. I know from experience it doesn't always work although it is >> quite solid in general. I think there are also a lot of leaky abstractions when it comes to rails code. It's tempting to think that rails is just doing a bunch of stuff automatically for you (and it is) - but there are edge cases, and unless you know *exactly* what rails is doing under the cover, testing the behaviour seems to be a good idea. I've already run into one bug in the last week (when doing something rather dynamic in a model class) which I wouldn't have expected. Scott From papipo at gmail.com Mon Sep 3 05:19:35 2007 From: papipo at gmail.com (=?ISO-8859-1?Q?Rodrigo_Alvarez_Fern=E1ndez?=) Date: Mon, 3 Sep 2007 11:19:35 +0200 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> Message-ID: <6d2bdda0709030219s658dae1dv4dddae6747185606@mail.gmail.com> I would like to know if the mock framework will be deprecated, since I have a pair of feature requests, and I don't know where to request them: 1) Alternative expectations: mock.should_receive(:save). and_return(false). or_receive(:save!). and_raise(ActiveRecord::RecordNotSaved) 2) Chained stubs/expectations mock.stub!(:valid?).and_return(false) mock.stub!(:valid?).and_return(true).after_receiving(:save).and_return(true) I'm sure that this needs no more explanation :) On 9/3/07, Zach Dennis wrote: > On 9/2/07, Andrew WC Brown wrote: > > I think that makes sense. > > > > Which do you recommend? Flexmock or Mocha? > > > > I wouldn't recommend either of them by themselves, at least the > current way they sit. > > Jim Weirich may be adding globally ordered strict mocks, which if he > does then I think Flexmock will be the first mocking library in ruby > to cover all mocking needs (as far as I know). > > Mocha (and RSpec mocks too) don't support globally strict ordered > mocks. Hardmock is another mocking library which is just strict > mocking (no stubs, no partial mocks). Right now I prefer Mocha + > Hardmock, but I'm eagerly awaiting to see if Flexmock gets globally > strict ordered mocks. > > Zach Dennis > http://www.continuousthinking.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- http://papipo.blogspot.com From peter_marklund at fastmail.fm Mon Sep 3 05:41:08 2007 From: peter_marklund at fastmail.fm (Peter Marklund) Date: Mon, 3 Sep 2007 11:41:08 +0200 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <6d2bdda0709030219s658dae1dv4dddae6747185606@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <6d2bdda0709030219s658dae1dv4dddae6747185606@mail.gmail.com> Message-ID: <8C3C084F-3BFE-4BEC-A5ED-0F3EBA82F222@fastmail.fm> > 2) Chained stubs/expectations > > mock.stub!(:valid?).and_return(false) > mock.stub!(:valid?).and_return(true).after_receiving > (:save).and_return(true) On first look, that last line is pretty hard to read. I think I understand the intention now, but I'm not sure it harmonizes with the "Clarity over Cleverness" motto. Peter From papipo at gmail.com Mon Sep 3 05:45:53 2007 From: papipo at gmail.com (=?ISO-8859-1?Q?Rodrigo_Alvarez_Fern=E1ndez?=) Date: Mon, 3 Sep 2007 11:45:53 +0200 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <8C3C084F-3BFE-4BEC-A5ED-0F3EBA82F222@fastmail.fm> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <6d2bdda0709030219s658dae1dv4dddae6747185606@mail.gmail.com> <8C3C084F-3BFE-4BEC-A5ED-0F3EBA82F222@fastmail.fm> Message-ID: <6d2bdda0709030245j7315e4eak58d59260ad25eddf@mail.gmail.com> On 9/3/07, Peter Marklund wrote: > > 2) Chained stubs/expectations > > > > mock.stub!(:valid?).and_return(false) > > mock.stub!(:valid?).and_return(true).after_receiving > > (:save).and_return(true) > > On first look, that last line is pretty hard to read. I think I > understand the intention now, but I'm not sure it harmonizes with the > "Clarity over Cleverness" motto. > I understand that there are maybe too many method calls there, but it would be a nice feature. Another approach could be using blocks: mock.stub?(:save).and_return(true) do |saved_mock| saved_mock.stub!(:valid?).and_return(true) end WDYT? -- http://papipo.blogspot.com From pergesu at gmail.com Mon Sep 3 06:01:36 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 3 Sep 2007 03:01:36 -0700 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <6d2bdda0709030245j7315e4eak58d59260ad25eddf@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <6d2bdda0709030219s658dae1dv4dddae6747185606@mail.gmail.com> <8C3C084F-3BFE-4BEC-A5ED-0F3EBA82F222@fastmail.fm> <6d2bdda0709030245j7315e4eak58d59260ad25eddf@mail.gmail.com> Message-ID: <810a540e0709030301l71ecd577l37f3a201296ea53d@mail.gmail.com> On 9/3/07, Rodrigo Alvarez Fern?ndez wrote: > On 9/3/07, Peter Marklund wrote: > > > 2) Chained stubs/expectations > > > > > > mock.stub!(:valid?).and_return(false) > > > mock.stub!(:valid?).and_return(true).after_receiving > > > (:save).and_return(true) > > > > On first look, that last line is pretty hard to read. I think I > > understand the intention now, but I'm not sure it harmonizes with the > > "Clarity over Cleverness" motto. > > > I understand that there are maybe too many method calls there, but it > would be a nice feature. > > Another approach could be using blocks: > > mock.stub?(:save).and_return(true) do |saved_mock| > saved_mock.stub!(:valid?).and_return(true) > end > > WDYT? This seems kind of funky. If an AR object can be saved then it's going to be valid anyway. In other words my_object.valid? # false my_object.save # true my_object.valid? # true is a super weird sequence. What context is this in? At first glance (i.e. with no context) I don't think that's a good use for mocks. You're introducing behavior and state into the mock ("when save is called, change my valid state to true") which is getting a bit clever and mixing concerns imo. The mocks created via the framework should be pretty stupid and just respond how you want them to. If you do need some actual behavior then I suggest you code up another object that behaves as you need. However as I said that's just a strange sequence anyway, which suggests that maybe your design is a bit off. Pat From papipo at gmail.com Mon Sep 3 06:04:50 2007 From: papipo at gmail.com (=?ISO-8859-1?Q?Rodrigo_Alvarez_Fern=E1ndez?=) Date: Mon, 3 Sep 2007 12:04:50 +0200 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <810a540e0709030301l71ecd577l37f3a201296ea53d@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <6d2bdda0709030219s658dae1dv4dddae6747185606@mail.gmail.com> <8C3C084F-3BFE-4BEC-A5ED-0F3EBA82F222@fastmail.fm> <6d2bdda0709030245j7315e4eak58d59260ad25eddf@mail.gmail.com> <810a540e0709030301l71ecd577l37f3a201296ea53d@mail.gmail.com> Message-ID: <6d2bdda0709030304v65c43ce6xd648b40770416f6@mail.gmail.com> On 9/3/07, Pat Maddox wrote: > On 9/3/07, Rodrigo Alvarez Fern?ndez wrote: > > On 9/3/07, Peter Marklund wrote: > > > > 2) Chained stubs/expectations > > > > > > > > mock.stub!(:valid?).and_return(false) > > > > mock.stub!(:valid?).and_return(true).after_receiving > > > > (:save).and_return(true) > > > > > > On first look, that last line is pretty hard to read. I think I > > > understand the intention now, but I'm not sure it harmonizes with the > > > "Clarity over Cleverness" motto. > > > > > I understand that there are maybe too many method calls there, but it > > would be a nice feature. > > > > Another approach could be using blocks: > > > > mock.stub?(:save).and_return(true) do |saved_mock| > > saved_mock.stub!(:valid?).and_return(true) > > end > > > > WDYT? > > This seems kind of funky. If an AR object can be saved then it's > going to be valid anyway. In other words > > my_object.valid? # false > my_object.save # true > my_object.valid? # true > > is a super weird sequence. What context is this in? Ok, I meant new_record? instead of valid? ;-) I think that now it makes sense, doesn't it? > > At first glance (i.e. with no context) I don't think that's a good use > for mocks. You're introducing behavior and state into the mock ("when > save is called, change my valid state to true") which is getting a bit > clever and mixing concerns imo. The mocks created via the framework > should be pretty stupid and just respond how you want them to. If you > do need some actual behavior then I suggest you code up another object > that behaves as you need. > > However as I said that's just a strange sequence anyway, which > suggests that maybe your design is a bit off. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- http://papipo.blogspot.com From mailing_lists at railsnewbie.com Mon Sep 3 06:28:28 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Mon, 3 Sep 2007 06:28:28 -0400 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <6d2bdda0709030219s658dae1dv4dddae6747185606@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <6d2bdda0709030219s658dae1dv4dddae6747185606@mail.gmail.com> Message-ID: <1A8C5D26-889A-4904-877E-EFAAA79B3014@railsnewbie.com> On Sep 3, 2007, at 5:19 AM, Rodrigo Alvarez Fern?ndez wrote: > I would like to know if the mock framework will be deprecated, since I > have a pair of feature requests, and I don't know where to request > them: > > 1) Alternative expectations: > > mock.should_receive(:save). > and_return(false). > or_receive(:save!). > and_raise(ActiveRecord::RecordNotSaved) > > 2) Chained stubs/expectations > > mock.stub!(:valid?).and_return(false) > mock.stub!(:valid?).and_return(true).after_receiving > (:save).and_return(true) > > I'm sure that this needs no more explanation :) Or we could do as flexmock does (and which I find much more readable): mock.stub!("method1.method2.method3").and_return(true) Scott From papipo at gmail.com Mon Sep 3 07:12:21 2007 From: papipo at gmail.com (=?ISO-8859-1?Q?Rodrigo_Alvarez_Fern=E1ndez?=) Date: Mon, 3 Sep 2007 13:12:21 +0200 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <1A8C5D26-889A-4904-877E-EFAAA79B3014@railsnewbie.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <6d2bdda0709030219s658dae1dv4dddae6747185606@mail.gmail.com> <1A8C5D26-889A-4904-877E-EFAAA79B3014@railsnewbie.com> Message-ID: <6d2bdda0709030412x7e72aed9u3085485a091b40a3@mail.gmail.com> On 9/3/07, Scott Taylor wrote: > > On Sep 3, 2007, at 5:19 AM, Rodrigo Alvarez Fern?ndez wrote: > > > I would like to know if the mock framework will be deprecated, since I > > have a pair of feature requests, and I don't know where to request > > them: > > > > 1) Alternative expectations: > > > > mock.should_receive(:save). > > and_return(false). > > or_receive(:save!). > > and_raise(ActiveRecord::RecordNotSaved) > > > > 2) Chained stubs/expectations > > > > mock.stub!(:valid?).and_return(false) > > mock.stub!(:valid?).and_return(true).after_receiving > > (:save).and_return(true) > > Maybe this can be accomplished with ordered stubs. rSpec mocks support only ordered expectations, doesn't it? > > I'm sure that this needs no more explanation :) > > Or we could do as flexmock does (and which I find much more readable): > > mock.stub!("method1.method2.method3").and_return(true) > > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- http://papipo.blogspot.com From work at ashleymoran.me.uk Mon Sep 3 07:59:10 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Mon, 3 Sep 2007 12:59:10 +0100 Subject: [rspec-users] Reason for _spec.rb convention Message-ID: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> Hi Easy one - I just wondered why all spec files for rspec_on_rails end "_spec.rb" instead of just ".rb"? They are all inside the spec folder so surely the fact they are specs is implicit? Ashley From win at wincent.com Mon Sep 3 08:47:56 2007 From: win at wincent.com (Wincent Colaiuta) Date: Mon, 3 Sep 2007 14:47:56 +0200 Subject: [rspec-users] Reason for _spec.rb convention In-Reply-To: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> References: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> Message-ID: El 3/9/2007, a las 13:59, Ashley Moran escribi?: > Hi > > Easy one - I just wondered why all spec files for rspec_on_rails end > "_spec.rb" instead of just ".rb"? They are all inside the spec > folder so surely the fact they are specs is implicit? > > Ashley I know it's very application-specific, but one good reason for this is that it makes finding files in TextMate much easier when you hit Command-T; you type a few characters and at a glance can distinguish between spec and implementation files. Cheers, Wincent From mailing_lists at railsnewbie.com Mon Sep 3 08:50:22 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Mon, 3 Sep 2007 08:50:22 -0400 Subject: [rspec-users] Reason for _spec.rb convention In-Reply-To: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> References: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> Message-ID: On Sep 3, 2007, at 7:59 AM, Ashley Moran wrote: > Hi > > Easy one - I just wondered why all spec files for rspec_on_rails end > "_spec.rb" instead of just ".rb"? They are all inside the spec > folder so surely the fact they are specs is implicit? > Personally, I think the only reason we keep it around is for Autotest, which maps xyz_spec.rb => xyz.rb. But - Feel free to name your specs however you choose. Scott From mailing_lists at railsnewbie.com Mon Sep 3 08:51:48 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Mon, 3 Sep 2007 08:51:48 -0400 Subject: [rspec-users] Reason for _spec.rb convention In-Reply-To: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> References: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> Message-ID: On Sep 3, 2007, at 7:59 AM, Ashley Moran wrote: > Hi > > Easy one - I just wondered why all spec files for rspec_on_rails end > "_spec.rb" instead of just ".rb"? They are all inside the spec > folder so surely the fact they are specs is implicit? > Personally, I think the only reason we keep it around is for Autotest, which maps xyz_spec.rb => xyz.rb. But - Feel free to name your specs however you choose. Scott From chad at spicycode.com Mon Sep 3 09:17:32 2007 From: chad at spicycode.com (Chad Humphries) Date: Mon, 3 Sep 2007 09:17:32 -0400 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> Message-ID: <42099B1D-978A-4C3C-A2E1-131AA1040A61@spicycode.com> Zach, I believe version 0.7.0 has the global ordering you are looking for: Version 0.7.0 Added and_yield as an expectation clause. Inspect on Mocks now yield a more consise description. Global ordering across all mocks in a container is now allowed. Added support for Demeter chain mocking. Deprecated a number of mock_* methods. -Chad On Sep 3, 2007, at 12:08 AM, Zach Dennis wrote: > On 9/2/07, Andrew WC Brown wrote: >> I think that makes sense. >> >> Which do you recommend? Flexmock or Mocha? >> > > I wouldn't recommend either of them by themselves, at least the > current way they sit. > > Jim Weirich may be adding globally ordered strict mocks, which if he > does then I think Flexmock will be the first mocking library in ruby > to cover all mocking needs (as far as I know). > > Mocha (and RSpec mocks too) don't support globally strict ordered > mocks. Hardmock is another mocking library which is just strict > mocking (no stubs, no partial mocks). Right now I prefer Mocha + > Hardmock, but I'm eagerly awaiting to see if Flexmock gets globally > strict ordered mocks. > > Zach Dennis > http://www.continuousthinking.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From work at ashleymoran.me.uk Mon Sep 3 09:36:34 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Mon, 3 Sep 2007 14:36:34 +0100 Subject: [rspec-users] Reason for _spec.rb convention In-Reply-To: References: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> Message-ID: <27638451-F25B-403C-A265-4E1389444B0C@ashleymoran.me.uk> On 3 Sep 2007, at 13:47, Wincent Colaiuta wrote: > I know it's very application-specific, but one good reason for this > is that it makes finding files in TextMate much easier when you hit > Command-T; you type a few characters and at a glance can distinguish > between spec and implementation files. This makes sense! However, after a bit of testing, it turns out TextMate identifies the shortest unique path, so if you have address.rb in app/models and spec/models, it displays this in the Cmd- T window: address.rb ? app/models address.rb ? spec/models TextMate's interface never ceases to amaze me. I suppose also you could set up a spec runner to skip files not ending _spec.rb in case you wanted support code in the spec folders (not sure if this is a good idea in practice or not, just occurred to me). On 3 Sep 2007, at 13:50, Scott Taylor wrote: > Personally, I think the only reason we keep it around is for > Autotest, which maps xyz_spec.rb => xyz.rb. But - Feel free to name > your specs however you choose. Not used Autotest - I'm sure it could be made to map xyz.rb => xyz.rb too though. This satisfied my curiosity anyway - someone mentioned it on nitro- general and I realised I didn't know where _spec came from. Thanks Ashley From dchelimsky at gmail.com Mon Sep 3 09:56:58 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 3 Sep 2007 08:56:58 -0500 Subject: [rspec-users] testing behaviour or testing code? In-Reply-To: <83B5CE48-0AFC-414D-8609-1E7FAAA35EDC@fastmail.fm> References: <12309322.post@talk.nabble.com> <810a540e0708241006m23118ed7k9248705c13c2678a@mail.gmail.com> <57c63afe0708241012o6c5bf76bib536656bf69ee323@mail.gmail.com> <810a540e0709012345t5aba354ai6f2f7414fe5a5ea@mail.gmail.com> <57c63afe0709020056y26081df7labe53761f20fa90a@mail.gmail.com> <810a540e0709020232g1a8bc555h129dbbbc0be5d6a7@mail.gmail.com> <57c63afe0709020943o1a9e4783x65390eb7ad44c87a@mail.gmail.com> <46DB35DD.2040701@shopwatch.org> <57c63afe0709022049m36acf1ebqee936361a5c9981c@mail.gmail.com> <83B5CE48-0AFC-414D-8609-1E7FAAA35EDC@fastmail.fm> Message-ID: <57c63afe0709030656l63e9721ai50afa6543b0f0238@mail.gmail.com> On 9/3/07, Peter Marklund wrote: > > There's a very useful guideline in TDD that says "test YOUR code, not > > everyone elses." The validation library we're testing here is > > ActiveRecord's. It's already tested (we hope!). > > Personally, I don't have the courage to assume Rails code is always > working. The school of thought that says "test your code" addresses this issue as well - you can have examples that specifically test assumptions in an API - but then they should be separated from your other examples (as they are not testing your code). Check out JUnit Recipes by J.B. Rainsberger. > I know from experience it doesn't always work although it is > quite solid in general. The Rails code has been tested but not in > conjunction with my particular apps. I also want to test my > assumptions of how the Rails API works, maybe it doesn't work as I > think. Again - JB calls these "learning tests." > Having tests/specs that cover Rails interaction with my app, > which higher level tests of course naturally do (system/integration > tests), gives me much more courage to upgrade Rails as well. Agreed. And Story Runner is the perfect place for these. Cheers, David > > Peter > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Sep 3 10:02:21 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 3 Sep 2007 09:02:21 -0500 Subject: [rspec-users] Reason for _spec.rb convention In-Reply-To: References: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> Message-ID: <57c63afe0709030702v4907b1f6wccf14b5e5d1c9534@mail.gmail.com> On 9/3/07, Scott Taylor wrote: > > On Sep 3, 2007, at 7:59 AM, Ashley Moran wrote: > > > Hi > > > > Easy one - I just wondered why all spec files for rspec_on_rails end > > "_spec.rb" instead of just ".rb"? They are all inside the spec > > folder so surely the fact they are specs is implicit? > > > > Personally, I think the only reason we keep it around is for > Autotest, which maps xyz_spec.rb => xyz.rb. But - Feel free to name > your specs however you choose. The autotest mapping you speak of ships with rspec, not ZenTest, so if we chose to rename the files there would be no problem. > > Scott > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Sep 3 10:03:30 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 3 Sep 2007 09:03:30 -0500 Subject: [rspec-users] Reason for _spec.rb convention In-Reply-To: <27638451-F25B-403C-A265-4E1389444B0C@ashleymoran.me.uk> References: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> <27638451-F25B-403C-A265-4E1389444B0C@ashleymoran.me.uk> Message-ID: <57c63afe0709030703n39c4f61ag1651679d4a11ad9a@mail.gmail.com> On 9/3/07, Ashley Moran wrote: > > On 3 Sep 2007, at 13:47, Wincent Colaiuta wrote: > > > I know it's very application-specific, but one good reason for this > > is that it makes finding files in TextMate much easier when you hit > > Command-T; you type a few characters and at a glance can distinguish > > between spec and implementation files. > > This makes sense! However, after a bit of testing, it turns out > TextMate identifies the shortest unique path, so if you have > address.rb in app/models and spec/models, it displays this in the Cmd- > T window: > > address.rb ? app/models > address.rb ? spec/models > > TextMate's interface never ceases to amaze me. > > I suppose also you could set up a spec runner to skip files not > ending _spec.rb in case you wanted support code in the spec folders > (not sure if this is a good idea in practice or not, just occurred to > me). > > > > On 3 Sep 2007, at 13:50, Scott Taylor wrote: > > Personally, I think the only reason we keep it around is for > > Autotest, which maps xyz_spec.rb => xyz.rb. But - Feel free to name > > your specs however you choose. > > Not used Autotest You SHOULD! > - I'm sure it could be made to map xyz.rb => xyz.rb > too though. > > > This satisfied my curiosity anyway - someone mentioned it on nitro- > general and I realised I didn't know where _spec came from. > > Thanks > Ashley > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Sep 3 10:05:43 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 3 Sep 2007 09:05:43 -0500 Subject: [rspec-users] Reason for _spec.rb convention In-Reply-To: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> References: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> Message-ID: <57c63afe0709030705g5c20fac4u3f9aa147c8621447@mail.gmail.com> On 9/3/07, Ashley Moran wrote: > Hi > > Easy one - I just wondered why all spec files for rspec_on_rails end > "_spec.rb" instead of just ".rb"? They are all inside the spec > folder so surely the fact they are specs is implicit? For me, personally, if I'm in TextMate and I see a row of tabs that say: thing.rb|thing_controller.rb|thing_controller.rb|thing.rb I'm going to be confused by that. It also makes searching for the file that much more complicated because you have to start looking for the folder when you search for thing.rb instead of just looking for the filename. Thoughts about that? > > Ashley > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Mon Sep 3 10:11:55 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 3 Sep 2007 07:11:55 -0700 Subject: [rspec-users] Reason for _spec.rb convention In-Reply-To: <57c63afe0709030705g5c20fac4u3f9aa147c8621447@mail.gmail.com> References: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> <57c63afe0709030705g5c20fac4u3f9aa147c8621447@mail.gmail.com> Message-ID: <810a540e0709030711o1b7b21c5i48719443ec290148@mail.gmail.com> On 9/3/07, David Chelimsky wrote: > On 9/3/07, Ashley Moran wrote: > > Hi > > > > Easy one - I just wondered why all spec files for rspec_on_rails end > > "_spec.rb" instead of just ".rb"? They are all inside the spec > > folder so surely the fact they are specs is implicit? > > For me, personally, if I'm in TextMate and I see a row of tabs that say: > > thing.rb|thing_controller.rb|thing_controller.rb|thing.rb > > I'm going to be confused by that. It also makes searching for the file > that much more complicated because you have to start looking for the > folder when you search for thing.rb instead of just looking for the > filename. > > Thoughts about that? >From a practical standpoint, _spec is there because it allows me to distinguish files at a glance. >From a philosophical standpoint, .rb is there because I'm writing specifications that just happen to be implemented in Ruby. (no I would not suggest in a million years that the files be changed to .spec. That's silly) Pat From dchelimsky at gmail.com Mon Sep 3 10:14:58 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 3 Sep 2007 09:14:58 -0500 Subject: [rspec-users] Reason for _spec.rb convention In-Reply-To: <810a540e0709030711o1b7b21c5i48719443ec290148@mail.gmail.com> References: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> <57c63afe0709030705g5c20fac4u3f9aa147c8621447@mail.gmail.com> <810a540e0709030711o1b7b21c5i48719443ec290148@mail.gmail.com> Message-ID: <57c63afe0709030714o44802f17k8df5002e8e78e84a@mail.gmail.com> On 9/3/07, Pat Maddox wrote: > On 9/3/07, David Chelimsky wrote: > > On 9/3/07, Ashley Moran wrote: > > > Hi > > > > > > Easy one - I just wondered why all spec files for rspec_on_rails end > > > "_spec.rb" instead of just ".rb"? They are all inside the spec > > > folder so surely the fact they are specs is implicit? > > > > For me, personally, if I'm in TextMate and I see a row of tabs that say: > > > > thing.rb|thing_controller.rb|thing_controller.rb|thing.rb > > > > I'm going to be confused by that. It also makes searching for the file > > that much more complicated because you have to start looking for the > > folder when you search for thing.rb instead of just looking for the > > filename. > > > > Thoughts about that? > > >From a practical standpoint, _spec is there because it allows me to > distinguish files at a glance. > > >From a philosophical standpoint, .rb is there because I'm writing > specifications that just happen to be implemented in Ruby. (no I > would not suggest in a million years that the files be changed to > .spec. That's silly) Can't tell if you're being serious or sarcastic here. Is it really silly? If so, why? Maybe you're on to something here. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Mon Sep 3 10:27:39 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 3 Sep 2007 07:27:39 -0700 Subject: [rspec-users] Reason for _spec.rb convention In-Reply-To: <57c63afe0709030714o44802f17k8df5002e8e78e84a@mail.gmail.com> References: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> <57c63afe0709030705g5c20fac4u3f9aa147c8621447@mail.gmail.com> <810a540e0709030711o1b7b21c5i48719443ec290148@mail.gmail.com> <57c63afe0709030714o44802f17k8df5002e8e78e84a@mail.gmail.com> Message-ID: <810a540e0709030727o282b43det7674d1804dd12f53@mail.gmail.com> On 9/3/07, David Chelimsky wrote: > On 9/3/07, Pat Maddox wrote: > > On 9/3/07, David Chelimsky wrote: > > > On 9/3/07, Ashley Moran wrote: > > > > Hi > > > > > > > > Easy one - I just wondered why all spec files for rspec_on_rails end > > > > "_spec.rb" instead of just ".rb"? They are all inside the spec > > > > folder so surely the fact they are specs is implicit? > > > > > > For me, personally, if I'm in TextMate and I see a row of tabs that say: > > > > > > thing.rb|thing_controller.rb|thing_controller.rb|thing.rb > > > > > > I'm going to be confused by that. It also makes searching for the file > > > that much more complicated because you have to start looking for the > > > folder when you search for thing.rb instead of just looking for the > > > filename. > > > > > > Thoughts about that? > > > > >From a practical standpoint, _spec is there because it allows me to > > distinguish files at a glance. > > > > >From a philosophical standpoint, .rb is there because I'm writing > > specifications that just happen to be implemented in Ruby. (no I > > would not suggest in a million years that the files be changed to > > .spec. That's silly) > > Can't tell if you're being serious or sarcastic here. Is it really > silly? If so, why? Maybe you're on to something here. It's not actually silly. In fact some time last year I made all my specs end in .spec instead of .rb. The only potential problem is integration with tools, which all know how to handle .rb files. Though of course those can be configured. I don't have a personal preference really. If others feel that naming them .spec better conveys the idea of "executable specs that happen to be implemented in Ruby" then cool. It's silly, to me, in the sense that I don't think it warrants much thought. otoh maybe I need to be more forward-thinking in that regard. RSpec works on JRuby, and developers could conceivably use RSpec to drive their Java-only code. RSpec obviously has the makings of a general specification library and I wouldn't be surprised if bindings pop up for other languages now that the core is stable. So I guess I just talked myself into .spec :) Pat From dchelimsky at gmail.com Mon Sep 3 10:37:32 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 3 Sep 2007 09:37:32 -0500 Subject: [rspec-users] Reason for _spec.rb convention In-Reply-To: <810a540e0709030727o282b43det7674d1804dd12f53@mail.gmail.com> References: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> <57c63afe0709030705g5c20fac4u3f9aa147c8621447@mail.gmail.com> <810a540e0709030711o1b7b21c5i48719443ec290148@mail.gmail.com> <57c63afe0709030714o44802f17k8df5002e8e78e84a@mail.gmail.com> <810a540e0709030727o282b43det7674d1804dd12f53@mail.gmail.com> Message-ID: <57c63afe0709030737o6988b228wc66984e7704e95a0@mail.gmail.com> On 9/3/07, Pat Maddox wrote: > On 9/3/07, David Chelimsky wrote: > > On 9/3/07, Pat Maddox wrote: > > > On 9/3/07, David Chelimsky wrote: > > > > On 9/3/07, Ashley Moran wrote: > > > > > Hi > > > > > > > > > > Easy one - I just wondered why all spec files for rspec_on_rails end > > > > > "_spec.rb" instead of just ".rb"? They are all inside the spec > > > > > folder so surely the fact they are specs is implicit? > > > > > > > > For me, personally, if I'm in TextMate and I see a row of tabs that say: > > > > > > > > thing.rb|thing_controller.rb|thing_controller.rb|thing.rb > > > > > > > > I'm going to be confused by that. It also makes searching for the file > > > > that much more complicated because you have to start looking for the > > > > folder when you search for thing.rb instead of just looking for the > > > > filename. > > > > > > > > Thoughts about that? > > > > > > >From a practical standpoint, _spec is there because it allows me to > > > distinguish files at a glance. > > > > > > >From a philosophical standpoint, .rb is there because I'm writing > > > specifications that just happen to be implemented in Ruby. (no I > > > would not suggest in a million years that the files be changed to > > > .spec. That's silly) > > > > Can't tell if you're being serious or sarcastic here. Is it really > > silly? If so, why? Maybe you're on to something here. > > It's not actually silly. In fact some time last year I made all my > specs end in .spec instead of .rb. The only potential problem is > integration with tools, which all know how to handle .rb files. > Though of course those can be configured. > > I don't have a personal preference really. If others feel that naming > them .spec better conveys the idea of "executable specs that happen to > be implemented in Ruby" then cool. It's silly, to me, in the sense > that I don't think it warrants much thought. > > otoh maybe I need to be more forward-thinking in that regard. RSpec > works on JRuby, and developers could conceivably use RSpec to drive > their Java-only code. RSpec obviously has the makings of a general > specification library and I wouldn't be surprised if bindings pop up > for other languages now that the core is stable. > > So I guess I just talked myself into .spec :) When I first got involved w/ rspec we batted this idea around. We landed on the convention of "_spec.rb" and, to be honest, I don't remember why. I vaguely recall there being some problem with .spec. Perhaps it was just that it required teaching editors like TextMate to treat these files as Ruby files. I don't remember for sure. Thinking about this a bit more, I don't think that this is worthy of changing right now. I imagine that it would cause trouble for anybody who's got custom rake tasks, custom actions in IDEs, etc. As for ppl using rspec to drive behaviour on other platforms, it's still got to be interpreted as Ruby first - at least that's how the world of JRuby is now. So I don't think dropping the .rb buys us expansion into other platforms. But it is an interesting idea that we should stay open to. Perhaps more compelling reasons for such a change will appear in the future. Cheers, David > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Mon Sep 3 10:45:04 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 3 Sep 2007 07:45:04 -0700 Subject: [rspec-users] Reason for _spec.rb convention In-Reply-To: <57c63afe0709030737o6988b228wc66984e7704e95a0@mail.gmail.com> References: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> <57c63afe0709030705g5c20fac4u3f9aa147c8621447@mail.gmail.com> <810a540e0709030711o1b7b21c5i48719443ec290148@mail.gmail.com> <57c63afe0709030714o44802f17k8df5002e8e78e84a@mail.gmail.com> <810a540e0709030727o282b43det7674d1804dd12f53@mail.gmail.com> <57c63afe0709030737o6988b228wc66984e7704e95a0@mail.gmail.com> Message-ID: <810a540e0709030745r3326bd83l9e9f94227361d066@mail.gmail.com> On 9/3/07, David Chelimsky wrote: > On 9/3/07, Pat Maddox wrote: > > On 9/3/07, David Chelimsky wrote: > > > On 9/3/07, Pat Maddox wrote: > > > > On 9/3/07, David Chelimsky wrote: > > > > > On 9/3/07, Ashley Moran wrote: > > > > > > Hi > > > > > > > > > > > > Easy one - I just wondered why all spec files for rspec_on_rails end > > > > > > "_spec.rb" instead of just ".rb"? They are all inside the spec > > > > > > folder so surely the fact they are specs is implicit? > > > > > > > > > > For me, personally, if I'm in TextMate and I see a row of tabs that say: > > > > > > > > > > thing.rb|thing_controller.rb|thing_controller.rb|thing.rb > > > > > > > > > > I'm going to be confused by that. It also makes searching for the file > > > > > that much more complicated because you have to start looking for the > > > > > folder when you search for thing.rb instead of just looking for the > > > > > filename. > > > > > > > > > > Thoughts about that? > > > > > > > > >From a practical standpoint, _spec is there because it allows me to > > > > distinguish files at a glance. > > > > > > > > >From a philosophical standpoint, .rb is there because I'm writing > > > > specifications that just happen to be implemented in Ruby. (no I > > > > would not suggest in a million years that the files be changed to > > > > .spec. That's silly) > > > > > > Can't tell if you're being serious or sarcastic here. Is it really > > > silly? If so, why? Maybe you're on to something here. > > > > It's not actually silly. In fact some time last year I made all my > > specs end in .spec instead of .rb. The only potential problem is > > integration with tools, which all know how to handle .rb files. > > Though of course those can be configured. > > > > I don't have a personal preference really. If others feel that naming > > them .spec better conveys the idea of "executable specs that happen to > > be implemented in Ruby" then cool. It's silly, to me, in the sense > > that I don't think it warrants much thought. > > > > otoh maybe I need to be more forward-thinking in that regard. RSpec > > works on JRuby, and developers could conceivably use RSpec to drive > > their Java-only code. RSpec obviously has the makings of a general > > specification library and I wouldn't be surprised if bindings pop up > > for other languages now that the core is stable. > > > > So I guess I just talked myself into .spec :) > > When I first got involved w/ rspec we batted this idea around. We > landed on the convention of "_spec.rb" and, to be honest, I don't > remember why. I vaguely recall there being some problem with .spec. > Perhaps it was just that it required teaching editors like TextMate to > treat these files as Ruby files. I don't remember for sure. > > Thinking about this a bit more, I don't think that this is worthy of > changing right now. I imagine that it would cause trouble for anybody > who's got custom rake tasks, custom actions in IDEs, etc. Agreed. It could turn out to just be a hassle for anyone new coming to RSpec. We don't want that. > As for ppl > using rspec to drive behaviour on other platforms, it's still got to > be interpreted as Ruby first - at least that's how the world of JRuby > is now. So I don't think dropping the .rb buys us expansion into other > platforms. YAGNI, I guess. > But it is an interesting idea that we should stay open to. Perhaps > more compelling reasons for such a change will appear in the future. Can't you tell just how strong my feelings are on this? :) Pat From eivindu at ifi.uio.no Mon Sep 3 10:48:09 2007 From: eivindu at ifi.uio.no (Eivind Uggedal) Date: Mon, 3 Sep 2007 16:48:09 +0200 Subject: [rspec-users] Reason for _spec.rb convention In-Reply-To: <810a540e0709030727o282b43det7674d1804dd12f53@mail.gmail.com> References: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> <57c63afe0709030705g5c20fac4u3f9aa147c8621447@mail.gmail.com> <810a540e0709030711o1b7b21c5i48719443ec290148@mail.gmail.com> <57c63afe0709030714o44802f17k8df5002e8e78e84a@mail.gmail.com> <810a540e0709030727o282b43det7674d1804dd12f53@mail.gmail.com> Message-ID: <824b51d00709030748r601cc964taf3b31cebff3a9f2@mail.gmail.com> > So I guess I just talked myself into .spec :) Please don't make such changes for rspec as a whole. I'm not particularly found of enabling yet another file type to use VIM's ruby ftplugin. -- Cheers, Eivind Uggedal Engineer, Faculty of Social Science, MSc Computer Science, University of Oslo From dchelimsky at gmail.com Mon Sep 3 11:42:12 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 3 Sep 2007 10:42:12 -0500 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <42099B1D-978A-4C3C-A2E1-131AA1040A61@spicycode.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <42099B1D-978A-4C3C-A2E1-131AA1040A61@spicycode.com> Message-ID: <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> Hi all, I've talked this over w/ a couple of the other committers and we've decided that we will NOT be deprecating the mock framework, at least for the foreseeable future. If/when we do, it will happen with plenty of notice and a clear, painless (as much as is possible) upgrade path. To be clear: this decision is purely pragmatic. Benefits of the existing framework cited in this thread are significant (one-stop shop, generated specs for the rails plugin, etc). And the amount of work it would take to do it right (backwards compatibility, easy upgrade path, support for multiple external frameworks, etc) far exceeds the perceived cost of maintaining the existing framework. Cheers, David From dan at tastapod.com Mon Sep 3 14:51:45 2007 From: dan at tastapod.com (Dan North) Date: Mon, 03 Sep 2007 19:51:45 +0100 Subject: [rspec-users] blog post on story runner In-Reply-To: <810a540e0709022329i470f66ebrcae5652c53ba35a4@mail.gmail.com> References: <57c63afe0709022253x15a3b07ev19168560a1636990@mail.gmail.com> <810a540e0709022329i470f66ebrcae5652c53ba35a4@mail.gmail.com> Message-ID: <46DC57C1.8070007@tastapod.com> Pat, if you update from trunk and re-run the formatter, you'll get Given ... And ... instead of Given ... Given ... in the output. Great write-up - thanks for taking the time. Cheers, Dan Pat Maddox wrote: > On 9/2/07, David Chelimsky wrote: > >> Here's an excellent blog post on Story Runner, which will be part of >> the next release and is undergoing active development in trunk: >> >> http://evang.eli.st/blog/2007/9/1/user-stories-with-rspec-s-story-runner >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > > I've updated it to include the output from the integration test and > Story Runner. > > Pat > _______________________________________________ > 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/20070903/770c39f5/attachment.html From cwdinfo at gmail.com Mon Sep 3 14:59:07 2007 From: cwdinfo at gmail.com (s.ross) Date: Mon, 3 Sep 2007 11:59:07 -0700 Subject: [rspec-users] Restatement: The Rspec Mocking Framework In-Reply-To: <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <42099B1D-978A-4C3C-A2E1-131AA1040A61@spicycode.com> <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> Message-ID: <48DA7950-F8F0-4FD8-B434-7728D259AE2F@gmail.com> This is and important enough announcement that I though it wise to put in a new thread so it doesn't get buried: On Sep 3, 2007, at 8:42 AM, David Chelimsky wrote: > Hi all, > > I've talked this over w/ a couple of the other committers and we've > decided that we will NOT be deprecating the mock framework, at least > for the foreseeable future. If/when we do, it will happen with plenty > of notice and a clear, painless (as much as is possible) upgrade path. > > To be clear: this decision is purely pragmatic. Benefits of the > existing framework cited in this thread are significant (one-stop > shop, generated specs for the rails plugin, etc). And the amount of > work it would take to do it right (backwards compatibility, easy > upgrade path, support for multiple external frameworks, etc) far > exceeds the perceived cost of maintaining the existing framework. > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From pergesu at gmail.com Mon Sep 3 17:10:52 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 3 Sep 2007 14:10:52 -0700 Subject: [rspec-users] blog post on story runner In-Reply-To: <46DC57C1.8070007@tastapod.com> References: <57c63afe0709022253x15a3b07ev19168560a1636990@mail.gmail.com> <810a540e0709022329i470f66ebrcae5652c53ba35a4@mail.gmail.com> <46DC57C1.8070007@tastapod.com> Message-ID: <810a540e0709031410k4160171ek2f7cea862b1a803@mail.gmail.com> Hey Dan, I noticed it now becomes "Given...And...Given...And...Given....When....Then...And...Then...And" Desired behavior? Seems a bit strange...I prefer the consistency of "Given...Given...Given" though I think "Given...And...And" would be more natural. Pat On 9/3/07, Dan North wrote: > > Pat, if you update from trunk and re-run the formatter, you'll get Given > ... And ... instead of Given ... Given ... in the output. > > Great write-up - thanks for taking the time. > > Cheers, > Dan > > Pat Maddox wrote: > On 9/2/07, David Chelimsky wrote: > > > Here's an excellent blog post on Story Runner, which will be part of > the next release and is undergoing active development in trunk: > > http://evang.eli.st/blog/2007/9/1/user-stories-with-rspec-s-story-runner > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > I've updated it to include the output from the integration test and > Story Runner. > > Pat > _______________________________________________ > 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 dan at tastapod.com Mon Sep 3 18:08:24 2007 From: dan at tastapod.com (Dan North) Date: Mon, 03 Sep 2007 23:08:24 +0100 Subject: [rspec-users] blog post on story runner In-Reply-To: <810a540e0709031410k4160171ek2f7cea862b1a803@mail.gmail.com> References: <57c63afe0709022253x15a3b07ev19168560a1636990@mail.gmail.com> <810a540e0709022329i470f66ebrcae5652c53ba35a4@mail.gmail.com> <46DC57C1.8070007@tastapod.com> <810a540e0709031410k4160171ek2f7cea862b1a803@mail.gmail.com> Message-ID: <46DC85D8.4020808@tastapod.com> Oops. That sounds like a bug. Pat Maddox wrote: > Hey Dan, > > I noticed it now becomes > "Given...And...Given...And...Given....When....Then...And...Then...And" > > Desired behavior? Seems a bit strange...I prefer the consistency of > "Given...Given...Given" though I think "Given...And...And" would be > more natural. > > Pat > > On 9/3/07, Dan North wrote: > >> Pat, if you update from trunk and re-run the formatter, you'll get Given >> ... And ... instead of Given ... Given ... in the output. >> >> Great write-up - thanks for taking the time. >> >> Cheers, >> Dan >> >> Pat Maddox wrote: >> On 9/2/07, David Chelimsky wrote: >> >> >> Here's an excellent blog post on Story Runner, which will be part of >> the next release and is undergoing active development in trunk: >> >> http://evang.eli.st/blog/2007/9/1/user-stories-with-rspec-s-story-runner >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> I've updated it to include the output from the integration test and >> Story Runner. >> >> Pat >> _______________________________________________ >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070903/d4d0c2fa/attachment.html From dan at tastapod.com Mon Sep 3 18:35:49 2007 From: dan at tastapod.com (Dan North) Date: Mon, 03 Sep 2007 23:35:49 +0100 Subject: [rspec-users] blog post on story runner In-Reply-To: <810a540e0709031410k4160171ek2f7cea862b1a803@mail.gmail.com> References: <57c63afe0709022253x15a3b07ev19168560a1636990@mail.gmail.com> <810a540e0709022329i470f66ebrcae5652c53ba35a4@mail.gmail.com> <46DC57C1.8070007@tastapod.com> <810a540e0709031410k4160171ek2f7cea862b1a803@mail.gmail.com> Message-ID: <46DC8C45.9070606@tastapod.com> Fixed. Sorry about that. Pat Maddox wrote: > Hey Dan, > > I noticed it now becomes > "Given...And...Given...And...Given....When....Then...And...Then...And" > > Desired behavior? Seems a bit strange...I prefer the consistency of > "Given...Given...Given" though I think "Given...And...And" would be > more natural. > > Pat > > On 9/3/07, Dan North wrote: > >> Pat, if you update from trunk and re-run the formatter, you'll get Given >> ... And ... instead of Given ... Given ... in the output. >> >> Great write-up - thanks for taking the time. >> >> Cheers, >> Dan >> >> Pat Maddox wrote: >> On 9/2/07, David Chelimsky wrote: >> >> >> Here's an excellent blog post on Story Runner, which will be part of >> the next release and is undergoing active development in trunk: >> >> http://evang.eli.st/blog/2007/9/1/user-stories-with-rspec-s-story-runner >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> I've updated it to include the output from the integration test and >> Story Runner. >> >> Pat >> _______________________________________________ >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070903/308bf9e5/attachment-0001.html From pergesu at gmail.com Mon Sep 3 19:30:12 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 3 Sep 2007 16:30:12 -0700 Subject: [rspec-users] blog post on story runner In-Reply-To: <46DC8C45.9070606@tastapod.com> References: <57c63afe0709022253x15a3b07ev19168560a1636990@mail.gmail.com> <810a540e0709022329i470f66ebrcae5652c53ba35a4@mail.gmail.com> <46DC57C1.8070007@tastapod.com> <810a540e0709031410k4160171ek2f7cea862b1a803@mail.gmail.com> <46DC8C45.9070606@tastapod.com> Message-ID: <810a540e0709031630p2281b193i17172a46bbc54b8a@mail.gmail.com> Cool, I appreciate it. Updated the post to reflect your changes. Pat On 9/3/07, Dan North wrote: > > Fixed. Sorry about that. > > > > Pat Maddox wrote: > Hey Dan, > > I noticed it now becomes > "Given...And...Given...And...Given....When....Then...And...Then...And" > > Desired behavior? Seems a bit strange...I prefer the consistency of > "Given...Given...Given" though I think "Given...And...And" would be > more natural. > > Pat > > On 9/3/07, Dan North wrote: > > > Pat, if you update from trunk and re-run the formatter, you'll get Given > ... And ... instead of Given ... Given ... in the output. > > Great write-up - thanks for taking the time. > > Cheers, > Dan > > Pat Maddox wrote: > On 9/2/07, David Chelimsky wrote: > > > Here's an excellent blog post on Story Runner, which will be part of > the next release and is undergoing active development in trunk: > > http://evang.eli.st/blog/2007/9/1/user-stories-with-rspec-s-story-runner > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > I've updated it to include the output from the integration test and > Story Runner. > > Pat > _______________________________________________ > 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 > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From smingins at elctech.com Mon Sep 3 22:51:09 2007 From: smingins at elctech.com (Shane Mingins) Date: Tue, 4 Sep 2007 14:51:09 +1200 Subject: [rspec-users] 1.05 to 1.08 Message-ID: <6A8E61FC-BCC7-4209-82F6-1E37AF6F8B34@elctech.com> Hi We are looking at moving a project over from 1.05 to 1.08 but have a problem with some of our helper specs They work fine in 1.05 but error in 1.08 and it is the calls to route helper methods that seems to be the problem. I did some playing around .. because the code being tested is reasonably large etc ... but this sample (using the peepcode app) seems to boil down the problem describe WeathersHelper do it do weather = Weather.new weather.id = 1 weather_path(weather).should == "/weathers/1" end end This passes in 1.05 and throws an exception in 1.08 ... is seems that the route helper method is not available. BTW, in our actual code the call to weather_path is in the helper ... I just put it in the above for simplicity. So I am wondering what may have changed and what do I need to configure?? Thanks Shane Shane Mingins ELC Technologies (TM) PO Box 247 Santa Barbara, CA 93102 Phone: +64 4 568 6684 Mobile: +64 21 435 586 Email: smingins at elctech.com AIM: ShaneMingins Skype: shane.mingins (866) 863-7365 Tel - Santa Barbara Office (866) 893-1902 Fax - Santa Barbara Office +44 020 7504 1346 Tel - London Office +44 020 7504 1347 Fax - London Office http://www.elctech.com -------------------------------------------------------------------- Privacy and Confidentiality Notice: The information contained in this electronic mail message is intended for the named recipient(s) only. It may contain privileged and confidential information. If you are not an intended recipient, you must not copy, forward, distribute or take any action in reliance on it. If you have received this electronic mail message in error, please notify the sender immediately. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070904/54e180b4/attachment.html From ben.askins at gmail.com Mon Sep 3 21:43:08 2007 From: ben.askins at gmail.com (Ben Askins) Date: Tue, 4 Sep 2007 02:43:08 +0100 (BST) Subject: [rspec-users] Invite from Ben Askins (ben.askins@gmail.com) Message-ID: <20070904014309.8FB252B1174@www1.quechup.com> BenAskins (ben.askins at gmail.com) has invited you as a friend on Quechup... ...the social networking platform sweeping the globe Go to: http://quechup.com/join.php/aT0wMDAwMDAwMDA5MjY4NjU2JmM9OTc1NDE%3D to accept Ben's invite You can use Quechup to meet new people, catch up with old friends, maintain a blog, share videos & photos, chat with other members, play games, and more. It's no wonder Quechup is fast becoming 'The Social Networking site to be on' Join Ben and his friends today: http://quechup.com/join.php/aT0wMDAwMDAwMDA5MjY4NjU2JmM9OTc1NDE%3D ------------------------------------------------------------------ You received this because Ben Askins (ben.askins at gmail.com) knows and agreed to invite you. You will only receive one invitation from ben.askins at gmail.com. Quechup will not spam or sell your email address, see our privacy policy - http://quechup.com/privacy.php Go to http://quechup.com/emailunsubscribe.php/ZW09cnNwZWMtdXNlcnNAcnVieWZvcmdlLm9yZw%3D%3D if you do not wish to receive any more emails from Quechup. ------------------------------------------------------------------ Copyright Quechup.com 2007. ------------------------------------ Go to http://quechup.com/emailunsubscribe.php/ZW09cnNwZWMtdXNlcnNAcnVieWZvcmdlLm9yZw%3D%3D if you do not wish to receive any more emails from Quechup -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070904/ba1f82e2/attachment.html From dchelimsky at gmail.com Mon Sep 3 23:44:51 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 3 Sep 2007 22:44:51 -0500 Subject: [rspec-users] 1.05 to 1.08 In-Reply-To: <6A8E61FC-BCC7-4209-82F6-1E37AF6F8B34@elctech.com> References: <6A8E61FC-BCC7-4209-82F6-1E37AF6F8B34@elctech.com> Message-ID: <57c63afe0709032044w4ac1f29dt96b808e67e663b0f@mail.gmail.com> On 9/3/07, Shane Mingins wrote: > Hi > > We are looking at moving a project over from 1.05 to 1.08 but have a problem > with some of our helper specs > > They work fine in 1.05 but error in 1.08 and it is the calls to route helper > methods that seems to be the problem. > > I did some playing around .. because the code being tested is reasonably > large etc ... but this sample (using the peepcode app) seems to boil down > the problem > > describe WeathersHelper do > it do > weather = Weather.new > weather.id = 1 > weather_path(weather).should == "/weathers/1" > end > end > > This passes in 1.05 and throws an exception in 1.08 ... is seems that the > route helper method is not available. > > BTW, in our actual code the call to weather_path is in the helper ... I just > put it in the above for simplicity. > > So I am wondering what may have changed and what do I need to configure?? I am going to guess that it's something like this: You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.<< If not, please post the error (good idea to do that in general). If so, this is fixed in trunk. Attached is a patch you can use to address it in your rails app (apply from vendor/plugins) Please let us know if this fixes the problem. Cheers, David > > Thanks > Shane > > > > Shane Mingins > ELC Technologies (TM) > PO Box 247 > Santa Barbara, CA 93102 > > Phone: +64 4 568 6684 > Mobile: +64 21 435 586 > Email: smingins at elctech.com > AIM: ShaneMingins > Skype: shane.mingins > > (866) 863-7365 Tel - Santa Barbara Office > (866) 893-1902 Fax - Santa Barbara Office > > +44 020 7504 1346 Tel - London Office > +44 020 7504 1347 Fax - London Office > > http://www.elctech.com > > -------------------------------------------------------------------- > Privacy and Confidentiality Notice: > The information contained in this electronic mail message is intended for > the named recipient(s) only. It may contain privileged and confidential > information. If you are not an intended recipient, you > must not copy, forward, distribute or take any action in reliance on it. If > you have received this electronic mail message in error, please notify the > sender immediately. > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- A non-text attachment was scrubbed... Name: helper_bug_fix.patch Type: application/octet-stream Size: 618 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070903/76e8278e/attachment.obj From omen.king at gmail.com Mon Sep 3 23:59:46 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Mon, 3 Sep 2007 23:59:46 -0400 Subject: [rspec-users] Invite from Ben Askins (ben.askins@gmail.com) In-Reply-To: <20070904014309.8FB252B1174@www1.quechup.com> References: <20070904014309.8FB252B1174@www1.quechup.com> Message-ID: but its not even built with Rails. On 9/3/07, Ben Askins wrote: > > [image: Quechup.com] > Trouble viewing this e-mail - click here > *Ben > Askins* (ben.askins at gmail.com) > has invited you as a friend on Quechup... > ...the social networking platform sweeping the globe > Click here to accept Ben's invite > You can use Quechup to meet new people, catch up with old friends, > maintain a blog, share videos & photos, chat with other members, play games, > and more. It's no wonder Quechup is fast becoming 'The Social Networking > site to be on'. > Join Ben and his friends today: > http://quechup.com/join.php/aT0wMDAwMDAwMDA5MjY4NjU2JmM9OTc1NDE%3D > You received this because Ben Askins (ben.askins at gmail.com) knows and > agreed to invite you. You will only receive one invite from > ben.askins at gmail.com. Quechup will not spam or sell your email address - privacy > policy . (c) Quechup 2007. > Click here if you do not wish to receive any more emails from Quechup > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Monsterbox Productions putting small businesses on-line 1319 Victoria Avenue East Thunder Bay, Ontario P7C 1C3 Canada Andrew WC Brown web-developer and owner andrew at monsterboxpro.com P: 807-626-9009 F: 807-624-2705 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070903/3c8e3c07/attachment-0001.html From luislavena at gmail.com Tue Sep 4 00:07:05 2007 From: luislavena at gmail.com (Luis Lavena) Date: Tue, 4 Sep 2007 01:07:05 -0300 Subject: [rspec-users] Invite from Ben Askins (ben.askins@gmail.com) In-Reply-To: References: <20070904014309.8FB252B1174@www1.quechup.com> Message-ID: <71166b3b0709032107q641ab5f1k3c3b5af7fffdf7d8@mail.gmail.com> Oh, this make my day: " You received this because Ben Askins (ben.askins at gmail.com) knows and agreed to invite you. You will only receive one invite from ben.askins at gmail.com. Quechup will not spam or sell your email address - privacy policy . (c) Quechup 2007." Yeah, Ben agreed that Quechup will log into his account, grab all their contacts and mass mail them, without a bit of logic to disregard/filter mailing lists addresses... I love those sites... too viral for my taste :-P Also, another facebook clone hits the web... I even don't like facebook! -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070904/b8ccccdc/attachment.html From ben at benmabey.com Tue Sep 4 00:09:02 2007 From: ben at benmabey.com (Ben Mabey) Date: Mon, 03 Sep 2007 22:09:02 -0600 Subject: [rspec-users] Invite from Ben Askins (ben.askins@gmail.com) In-Reply-To: References: <20070904014309.8FB252B1174@www1.quechup.com> Message-ID: <46DCDA5E.7020205@benmabey.com> Hmm... maybe it was somehow speced out in rspec at least ;) Andrew WC Brown wrote: > but its not even built with Rails. > > On 9/3/07, *Ben Askins* > wrote: > > Quechup.com > Trouble viewing this e-mail - click here > > > *Ben Askins* (ben.askins at gmail.com ) > has invited you as a friend on Quechup... > ...the social networking platform sweeping the globe > Click here to accept Ben's invite > > You can use Quechup to meet new people, catch up with old friends, > maintain a blog, share videos & photos, chat with other members, > play games, and more. It's no wonder Quechup is fast becoming 'The > Social Networking site to be on'. > Join Ben and his friends today: > http://quechup.com/join.php/aT0wMDAwMDAwMDA5MjY4NjU2JmM9OTc1NDE%3D > > You received this because Ben Askins (ben.askins at gmail.com > ) knows and agreed to invite you. You > will only receive one invite from ben.askins at gmail.com > . Quechup will not spam or sell your > email address - privacy policy . ? > Quechup 2007. > Click here if you do not wish to receive any more emails from > Quechup > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > -- > Monsterbox Productions > putting small businesses on-line > > 1319 Victoria Avenue East > Thunder Bay, Ontario P7C 1C3 > Canada > > Andrew WC Brown > web-developer and owner > andrew at monsterboxpro.com > P: 807-626-9009 > F: 807-624-2705 > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From omen.king at gmail.com Tue Sep 4 00:22:37 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Tue, 4 Sep 2007 00:22:37 -0400 Subject: [rspec-users] Invite from Ben Askins (ben.askins@gmail.com) In-Reply-To: <46DCDA5E.7020205@benmabey.com> References: <20070904014309.8FB252B1174@www1.quechup.com> <46DCDA5E.7020205@benmabey.com> Message-ID: What about Caboose Facebook? http://faces.caboo.se On 9/4/07, Ben Mabey wrote: > > Hmm... maybe it was somehow speced out in rspec at least ;) > > Andrew WC Brown wrote: > > but its not even built with Rails. > > > > On 9/3/07, *Ben Askins* > > wrote: > > > > Quechup.com > > Trouble viewing this e-mail - click here > > < > http://quechup.com/Qmail/contacts.php/ZW09YmVuLmFza2luc0BnbWFpbC5jb20maT0wMDAwMDAwMDA5MjY4NjU2JmM9OTc1NDEmZm49QmVuJmxuPUFza2lucyZhbD1iZW4uYXNraW5zJnBoPXBlbmRpbmdBcHByb3ZhbC5naWYmdG09cnNwZWMtdXNlcnNAcnVieWZvcmdlLm9yZw%3D%3D > > > > > > *Ben Askins* (ben.askins at gmail.com ) > > has invited you as a friend on Quechup... > > ...the social networking platform sweeping the globe > > Click here to accept Ben's invite > > > > You can use Quechup to meet new people, catch up with old friends, > > maintain a blog, share videos & photos, chat with other members, > > play games, and more. It's no wonder Quechup is fast becoming 'The > > Social Networking site to be on'. > > Join Ben and his friends today: > > http://quechup.com/join.php/aT0wMDAwMDAwMDA5MjY4NjU2JmM9OTc1NDE%3D > > > > You received this because Ben Askins (ben.askins at gmail.com > > ) knows and agreed to invite you. You > > will only receive one invite from ben.askins at gmail.com > > . Quechup will not spam or sell your > > email address - privacy policy . (c) > > Quechup 2007. > > Click here if you do not wish to receive any more emails from > > Quechup > > < > http://quechup.com/emailunsubscribe.php/ZW09cnNwZWMtdXNlcnNAcnVieWZvcmdlLm9yZw%3D%3D > > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > -- > > Monsterbox Productions > > putting small businesses on-line > > > > 1319 Victoria Avenue East > > Thunder Bay, Ontario P7C 1C3 > > Canada > > > > Andrew WC Brown > > web-developer and owner > > andrew at monsterboxpro.com > > P: 807-626-9009 > > F: 807-624-2705 > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > 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/20070904/86dfc8d6/attachment.html From smingins at elctech.com Tue Sep 4 00:40:42 2007 From: smingins at elctech.com (Shane Mingins) Date: Tue, 4 Sep 2007 16:40:42 +1200 Subject: [rspec-users] 1.05 to 1.08 In-Reply-To: <57c63afe0709032044w4ac1f29dt96b808e67e663b0f@mail.gmail.com> References: <6A8E61FC-BCC7-4209-82F6-1E37AF6F8B34@elctech.com> <57c63afe0709032044w4ac1f29dt96b808e67e663b0f@mail.gmail.com> Message-ID: <5B877A5A-D576-4711-A506-91B0C1A389B1@elctech.com> On 4/09/2007, at 3:44 PM, David Chelimsky wrote: > On 9/3/07, Shane Mingins wrote: >> Hi >> >> We are looking at moving a project over from 1.05 to 1.08 but have >> a problem >> with some of our helper specs >> >> They work fine in 1.05 but error in 1.08 and it is the calls to >> route helper >> methods that seems to be the problem. >> >> I did some playing around .. because the code being tested is >> reasonably >> large etc ... but this sample (using the peepcode app) seems to >> boil down >> the problem >> >> describe WeathersHelper do >> it do >> weather = Weather.new >> weather.id = 1 >> weather_path(weather).should == "/weathers/1" >> end >> end >> >> This passes in 1.05 and throws an exception in 1.08 ... is seems >> that the >> route helper method is not available. >> >> BTW, in our actual code the call to weather_path is in the >> helper ... I just >> put it in the above for simplicity. >> >> So I am wondering what may have changed and what do I need to >> configure?? > > I am going to guess that it's something like this: > > You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.<< > > If not, please post the error (good idea to do that in general). > > If so, this is fixed in trunk. Attached is a patch you can use to > address it in your rails app (apply from vendor/plugins) > > Please let us know if this fixes the problem. > > Cheers, > David > Hi David Thank you .. yes that fixed that problem, although it looks like I have other's to look at regarding routes. Sorry I did not post error message ... I did not think it was such a useful message ;-) Cheers Shane From court3nay at gmail.com Tue Sep 4 00:46:27 2007 From: court3nay at gmail.com (court3nay) Date: Mon, 3 Sep 2007 21:46:27 -0700 Subject: [rspec-users] Invite from Ben Askins (ben.askins@gmail.com) In-Reply-To: References: <20070904014309.8FB252B1174@www1.quechup.com> <46DCDA5E.7020205@benmabey.com> Message-ID: <5B725302-455C-4921-9304-C5BBBD717BC5@gmail.com> Hey! That's private! :) its also OSS and very test::unit Sent from my iPhone On Sep 3, 2007, at 9:22 PM, "Andrew WC Brown" wrote: > What about Caboose Facebook? > > http://faces.caboo.se > > On 9/4/07, Ben Mabey < ben at benmabey.com> wrote: > Hmm... maybe it was somehow speced out in rspec at least ;) > > Andrew WC Brown wrote: > > but its not even built with Rails. > > > > On 9/3/07, *Ben Askins* > > wrote: > > > > Quechup.com > > Trouble viewing this e-mail - click here > > < http://quechup.com/Qmail/contacts.php/ZW09YmVuLmFza2luc0BnbWFpbC5jb20maT0wMDAwMDAwMDA5MjY4NjU2JmM9OTc1NDEmZm49QmVuJmxuPUFza2lucyZhbD1iZW4uYXNraW5zJnBoPXBlbmRpbmdBcHByb3ZhbC5naWYmdG09cnNwZWMtdXNlcnNAcnVieWZvcmdlLm9yZw%3D%3D > > > > > > > *Ben Askins* ( ben.askins at gmail.com > ) > > has invited you as a friend on Quechup... > > ...the social networking platform sweeping the globe > > Click here to accept Ben's invite > > > > > You can use Quechup to meet new people, catch up with old > friends, > > maintain a blog, share videos & photos, chat with other members, > > play games, and more. It's no wonder Quechup is fast becoming > 'The > > Social Networking site to be on'. > > Join Ben and his friends today: > > http://quechup.com/join.php/aT0wMDAwMDAwMDA5MjY4NjU2JmM9OTc1NDE%3D > > > > > You received this because Ben Askins ( ben.askins at gmail.com > > ) knows and agreed to invite you. > You > > will only receive one invite from ben.askins at gmail.com > > . Quechup will not spam or sell > your > > email address - privacy policy < http://quechup.com/ > privacy.php>. ? > > Quechup 2007. > > Click here if you do not wish to receive any more emails from > > Quechup > > < http://quechup.com/emailunsubscribe.php/ZW09cnNwZWMtdXNlcnNAcnVieWZvcmdlLm9yZw%3D%3D > > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > -- > > Monsterbox Productions > > putting small businesses on-line > > > > 1319 Victoria Avenue East > > Thunder Bay, Ontario P7C 1C3 > > Canada > > > > Andrew WC Brown > > web-developer and owner > > andrew at monsterboxpro.com > > P: 807-626-9009 > > F: 807-624-2705 > > > --- > --------------------------------------------------------------------- > > > > _______________________________________________ > > 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070903/daa30aa2/attachment-0001.html From work at ashleymoran.me.uk Tue Sep 4 05:35:12 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Tue, 4 Sep 2007 10:35:12 +0100 Subject: [rspec-users] Reason for _spec.rb convention In-Reply-To: <57c63afe0709030737o6988b228wc66984e7704e95a0@mail.gmail.com> References: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> <57c63afe0709030705g5c20fac4u3f9aa147c8621447@mail.gmail.com> <810a540e0709030711o1b7b21c5i48719443ec290148@mail.gmail.com> <57c63afe0709030714o44802f17k8df5002e8e78e84a@mail.gmail.com> <810a540e0709030727o282b43det7674d1804dd12f53@mail.gmail.com> <57c63afe0709030737o6988b228wc66984e7704e95a0@mail.gmail.com> Message-ID: <71B82737-3B32-44B2-98DD-26AC16AA830F@ashleymoran.me.uk> On 3 Sep 2007, at 15:37, David Chelimsky wrote: > But it is an interesting idea that we should stay open to. Perhaps > more compelling reasons for such a change will appear in the future. I like the sound of .spec in a way. It shortens the filenames which is always a bonus for TM users. I can see the issue with file associations, but it's easy enough to change these for TextMate. (Although, allegedly, there are some Ruby developers that don't use TextMate.) In favour of .spec, Rake has its own extension (.rake). You could argue that RSpec is not much more tied to Ruby code than Rake is. Ashley From work at ashleymoran.me.uk Tue Sep 4 05:39:41 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Tue, 4 Sep 2007 10:39:41 +0100 Subject: [rspec-users] Reason for _spec.rb convention In-Reply-To: <57c63afe0709030703n39c4f61ag1651679d4a11ad9a@mail.gmail.com> References: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> <27638451-F25B-403C-A265-4E1389444B0C@ashleymoran.me.uk> <57c63afe0709030703n39c4f61ag1651679d4a11ad9a@mail.gmail.com> Message-ID: On 3 Sep 2007, at 15:03, David Chelimsky wrote: >> Not used Autotest > > You SHOULD! Why do I have a feeling I will now try it out and go WHY OH WHY DIDN'T I USE THIS BEFORE??? From jonathan at parkerhill.com Tue Sep 4 07:44:28 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 4 Sep 2007 07:44:28 -0400 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> Message-ID: Personally, I dont want to become an expert at the range of possible testing and mocking tools. I just want a solid framework to get my work done, recommended by experts like you. And the less different components I need to install and maintain, the better. So I prefer the integrated approach we've had in Rspec up to now. Jonathan On Sep 3, 2007, at 12:08 AM, Zach Dennis wrote: > On 9/2/07, Andrew WC Brown wrote: >> I think that makes sense. >> >> Which do you recommend? Flexmock or Mocha? >> > > I wouldn't recommend either of them by themselves, at least the > current way they sit. > > Jim Weirich may be adding globally ordered strict mocks, which if he > does then I think Flexmock will be the first mocking library in ruby > to cover all mocking needs (as far as I know). > > Mocha (and RSpec mocks too) don't support globally strict ordered > mocks. Hardmock is another mocking library which is just strict > mocking (no stubs, no partial mocks). Right now I prefer Mocha + > Hardmock, but I'm eagerly awaiting to see if Flexmock gets globally > strict ordered mocks. > > Zach Dennis > http://www.continuousthinking.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From singhi.surendra at gmail.com Tue Sep 4 08:03:50 2007 From: singhi.surendra at gmail.com (Surendra) Date: Tue, 4 Sep 2007 17:33:50 +0530 Subject: [rspec-users] specing helpers fails on restful routes Message-ID: Hi, I am trying to spec helper methods in a Rails project, but it seems the specs fail with the error: You might have expected an instance of Array. The error occurred while evaluating nil.<< if the restful routes helper are used either in spec files, or the helper file. What can I be doing wrong? Or how can I fix this. Thanks! -- Surendra Singhi http://ssinghi.kreeti.com, http://www.kreeti.com From singhi.surendra at gmail.com Tue Sep 4 08:06:52 2007 From: singhi.surendra at gmail.com (Surendra) Date: Tue, 4 Sep 2007 17:36:52 +0530 Subject: [rspec-users] specing helpers fails on restful routes In-Reply-To: References: Message-ID: Nevermind, i just saw an old post mentioning the same issue. Thanks! On 9/4/07, Surendra wrote: > Hi, > I am trying to spec helper methods in a Rails project, but it seems > the specs fail with the error: > > You might have expected an instance of Array. > The error occurred while evaluating nil.<< > > if the restful routes helper are used either in spec files, or the helper file. > > What can I be doing wrong? Or how can I fix this. > > Thanks! > -- > Surendra Singhi > http://ssinghi.kreeti.com, http://www.kreeti.com > -- Surendra Singhi http://ssinghi.kreeti.com, http://www.kreeti.com From lancecarlson at gmail.com Tue Sep 4 08:08:10 2007 From: lancecarlson at gmail.com (lancecarlson at gmail.com) Date: Tue, 4 Sep 2007 12:08:10 +0000 Subject: [rspec-users] specing helpers fails on restful routes In-Reply-To: References: Message-ID: <1446479378-1188907780-cardhu_decombobulator_blackberry.rim.net-908738562-@bxe124.bisx.prod.on.blackberry> Yes I was about to forward you to my blog post Sent via BlackBerry from T-Mobile -----Original Message----- From: Surendra Date: Tue, 4 Sep 2007 17:36:52 To:rspec-users at rubyforge.org Subject: Re: [rspec-users] specing helpers fails on restful routes Nevermind, i just saw an old post mentioning the same issue. Thanks! On 9/4/07, Surendra wrote: > Hi, > I am trying to spec helper methods in a Rails project, but it seems > the specs fail with the error: > > You might have expected an instance of Array. > The error occurred while evaluating nil.<< > > if the restful routes helper are used either in spec files, or the helper file. > > What can I be doing wrong? Or how can I fix this. > > Thanks! > -- > Surendra Singhi > http://ssinghi.kreeti.com, http://www.kreeti.com > -- Surendra Singhi http://ssinghi.kreeti.com, http://www.kreeti.com _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users From lancecarlson at gmail.com Tue Sep 4 09:22:37 2007 From: lancecarlson at gmail.com (Lance Carlson) Date: Tue, 4 Sep 2007 09:22:37 -0400 Subject: [rspec-users] Model Specs: Fixtures vs Mocks + Stubs? Message-ID: <49f64a900709040622g305a0453yd82068f1d4009ef@mail.gmail.com> What is the general opinion about fixtures versus mocking and stubbing in model specs? I heard from agile on IRC that they save the database testing for integration testing, but I also see that the caboose sample applicaiton uses fixtures. I also noticed that on the rspec site, it says "Ironically (for the traditional TDD'er) these are the only specs that we feel should actually interact with the database." (http://rspec.rubyforge.org/documentation/rails/index.html). Thoughts? From dchelimsky at gmail.com Tue Sep 4 09:32:54 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 4 Sep 2007 08:32:54 -0500 Subject: [rspec-users] Model Specs: Fixtures vs Mocks + Stubs? In-Reply-To: <49f64a900709040622g305a0453yd82068f1d4009ef@mail.gmail.com> References: <49f64a900709040622g305a0453yd82068f1d4009ef@mail.gmail.com> Message-ID: <57c63afe0709040632g3a5a2f4td452e30216651097@mail.gmail.com> On 9/4/07, Lance Carlson wrote: > What is the general opinion about fixtures versus mocking and stubbing > in model specs? I heard from agile on IRC that they save the database > testing for integration testing, but I also see that the caboose > sample applicaiton uses fixtures. I also noticed that on the rspec > site, it says "Ironically (for the traditional TDD'er) these are the > only specs that we feel should actually interact with the database." I wrote that bit - but it doesn't suggest that you should use fixtures or not. If I'm going to the DB I generally create the model objects I want right in the examples. re: fixtures - the argument against is that they are a pain to maintain - but there have been some recent developments like http://code.google.com/p/fixture-scenarios/ that seem promising. With the recent addition of Story Runner (in trunk), I'm exploring more and more the ideas espoused by Jay Fields on his blog re: mocking declarative API calls to AR (see http://blog.jayfields.com/2006/12/rails-unit-testing-activerecord.html) to support super-fast object-level examples in concert w/ end-to-end examples in Story Runner. So you have two separate issues here: 1. db or not db 2. if db, fixtures or not fixtures I doubt you'll find general consensus on either question. Good luck! Cheers, David From lancecarlson at gmail.com Tue Sep 4 11:09:13 2007 From: lancecarlson at gmail.com (Lance Carlson) Date: Tue, 4 Sep 2007 11:09:13 -0400 Subject: [rspec-users] Model Specs: Fixtures vs Mocks + Stubs? In-Reply-To: <57c63afe0709040632g3a5a2f4td452e30216651097@mail.gmail.com> References: <49f64a900709040622g305a0453yd82068f1d4009ef@mail.gmail.com> <57c63afe0709040632g3a5a2f4td452e30216651097@mail.gmail.com> Message-ID: <49f64a900709040809o6a3e43dg86aedcd163b6751e@mail.gmail.com> Ok, so to extend this issue, I'm attempting to use mocks and stubs on my model specs. I've got some questions though.. here is my code: module UserSpecHelper def mock_user(user) @user = mock_model(User) if user == :lance || user == :account_owner @user.stub!(:login).and_return('lance') elsif user == :bob || user == :normal_user @user.stub!(:login).and_return('bob') @user.stub!(:email).and_return('test at test.com') @user.stub!(:account).and_return(mock_account(:lances)) end @user end def mock_account(account) @account = mock_model(Account) if account == :lances end @account end end describe "An account owner" do include UserSpecHelper before(:each) do @user = mock_user(:lance) end it "indicate they own the account" do @user.should_receive(:is_account_owner?).and_return(true) @user.is_account_owner?.should be_true end end 1st question: Am I approaching the mocking and stubbing correctly? 2nd question: I feel like I'm not actually testing the is_account_owner? code which I want to do, but can't figure out how to test the implementation. I feel like I want to stub account_id instead of account and have it rely on my model to supply the account method automatically. Where am I going wrong? TIA On 9/4/07, David Chelimsky wrote: > On 9/4/07, Lance Carlson wrote: > > What is the general opinion about fixtures versus mocking and stubbing > > in model specs? I heard from agile on IRC that they save the database > > testing for integration testing, but I also see that the caboose > > sample applicaiton uses fixtures. I also noticed that on the rspec > > site, it says "Ironically (for the traditional TDD'er) these are the > > only specs that we feel should actually interact with the database." > > I wrote that bit - but it doesn't suggest that you should use fixtures > or not. If I'm going to the DB I generally create the model objects I > want right in the examples. > > re: fixtures - the argument against is that they are a pain to > maintain - but there have been some recent developments like > http://code.google.com/p/fixture-scenarios/ that seem promising. > > With the recent addition of Story Runner (in trunk), I'm exploring > more and more the ideas espoused by Jay Fields on his blog re: mocking > declarative API calls to AR (see > http://blog.jayfields.com/2006/12/rails-unit-testing-activerecord.html) > to support super-fast object-level examples in concert w/ end-to-end > examples in Story Runner. > > So you have two separate issues here: > > 1. db or not db > 2. if db, fixtures or not fixtures > > I doubt you'll find general consensus on either question. Good luck! > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lancecarlson at gmail.com Tue Sep 4 11:13:00 2007 From: lancecarlson at gmail.com (Lance Carlson) Date: Tue, 4 Sep 2007 11:13:00 -0400 Subject: [rspec-users] Model Specs: Fixtures vs Mocks + Stubs? In-Reply-To: <49f64a900709040809o6a3e43dg86aedcd163b6751e@mail.gmail.com> References: <49f64a900709040622g305a0453yd82068f1d4009ef@mail.gmail.com> <57c63afe0709040632g3a5a2f4td452e30216651097@mail.gmail.com> <49f64a900709040809o6a3e43dg86aedcd163b6751e@mail.gmail.com> Message-ID: <49f64a900709040813t40f81cb6kfa9e6f55a383c012@mail.gmail.com> Or am I to assume that rails is doing it's job and that the associations I created in my models are working as they should? On 9/4/07, Lance Carlson wrote: > Ok, so to extend this issue, I'm attempting to use mocks and stubs on > my model specs. I've got some questions though.. here is my code: > > module UserSpecHelper > def mock_user(user) > @user = mock_model(User) > if user == :lance || user == :account_owner > @user.stub!(:login).and_return('lance') > elsif user == :bob || user == :normal_user > @user.stub!(:login).and_return('bob') > @user.stub!(:email).and_return('test at test.com') > @user.stub!(:account).and_return(mock_account(:lances)) > end > @user > end > > def mock_account(account) > @account = mock_model(Account) > if account == :lances > > end > @account > end > end > > describe "An account owner" do > include UserSpecHelper > > before(:each) do > @user = mock_user(:lance) > end > > it "indicate they own the account" do > @user.should_receive(:is_account_owner?).and_return(true) > > @user.is_account_owner?.should be_true > end > end > > 1st question: Am I approaching the mocking and stubbing correctly? > > 2nd question: I feel like I'm not actually testing the > is_account_owner? code which I want to do, but can't figure out how to > test the implementation. I feel like I want to stub account_id instead > of account and have it rely on my model to supply the account method > automatically. Where am I going wrong? > > TIA > > On 9/4/07, David Chelimsky wrote: > > On 9/4/07, Lance Carlson wrote: > > > What is the general opinion about fixtures versus mocking and stubbing > > > in model specs? I heard from agile on IRC that they save the database > > > testing for integration testing, but I also see that the caboose > > > sample applicaiton uses fixtures. I also noticed that on the rspec > > > site, it says "Ironically (for the traditional TDD'er) these are the > > > only specs that we feel should actually interact with the database." > > > > I wrote that bit - but it doesn't suggest that you should use fixtures > > or not. If I'm going to the DB I generally create the model objects I > > want right in the examples. > > > > re: fixtures - the argument against is that they are a pain to > > maintain - but there have been some recent developments like > > http://code.google.com/p/fixture-scenarios/ that seem promising. > > > > With the recent addition of Story Runner (in trunk), I'm exploring > > more and more the ideas espoused by Jay Fields on his blog re: mocking > > declarative API calls to AR (see > > http://blog.jayfields.com/2006/12/rails-unit-testing-activerecord.html) > > to support super-fast object-level examples in concert w/ end-to-end > > examples in Story Runner. > > > > So you have two separate issues here: > > > > 1. db or not db > > 2. if db, fixtures or not fixtures > > > > I doubt you'll find general consensus on either question. Good luck! > > > > Cheers, > > David > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > From geoffrey.wiseman at gmail.com Tue Sep 4 13:21:55 2007 From: geoffrey.wiseman at gmail.com (Geoffrey Wiseman) Date: Tue, 4 Sep 2007 13:21:55 -0400 Subject: [rspec-users] Failure Messages in RSpec Message-ID: <835d522e0709041021m50743006qb909391a327abf15@mail.gmail.com> Having used JUnit and Test::Unit, I'm quite used to having the ability to insert a failure message, which helps when tests fail. For instance, the example RSpec that is generated for a model class specifies that the model class is valid. Assuming this were supposed to be true, and it failed, I've now got to duplicate the code in the test in order to find out why it wasn't valid. Whereas if I were writing the same code in Test::Unit, I might write: assert model.valid?, "Expected model to be valid, but found these errors: #{model.errors}" This means that when the model validation fails, I know /why/. I don't see an easy way to include these sorts of messages in RSpec, which seems likely to cause me to waste time on test failures. Am I missing something? How are experienced RSpec users resolving this? Thanks, - Geoffrey -- Geoffrey Wiseman -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070904/558bcc38/attachment.html From dchelimsky at gmail.com Tue Sep 4 13:50:36 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 4 Sep 2007 12:50:36 -0500 Subject: [rspec-users] Failure Messages in RSpec In-Reply-To: <835d522e0709041021m50743006qb909391a327abf15@mail.gmail.com> References: <835d522e0709041021m50743006qb909391a327abf15@mail.gmail.com> Message-ID: <57c63afe0709041050q30045b22rfe371870ffc0c0e1@mail.gmail.com> On 9/4/07, Geoffrey Wiseman wrote: > Having used JUnit and Test::Unit, I'm quite used to having the ability to > insert a failure message, which helps when tests fail. > > For instance, the example RSpec that is generated for a model class > specifies that the model class is valid. Assuming this were supposed to be > true, and it failed, I've now got to duplicate the code in the test in order > to find out why it wasn't valid. > > Whereas if I were writing the same code in Test::Unit, I might write: > assert model.valid?, "Expected model to be valid, but found these errors: > #{model.errors}" > > This means that when the model validation fails, I know /why/. I don't see > an easy way to include these sorts of messages in RSpec, which seems likely > to cause me to waste time on test failures. Am I missing something? How > are experienced RSpec users resolving this? I come from the same background as you, so I hear where you're coming from. We made a conscious decision, however, not to support custom messages almost two years ago and I'm not sure if its ever even come up before. If it has, it was a long time ago. If you follow the conventions of one expectation per example, and your example is well named, this is less of a problem. Here's a common idiom: describe Person do def valid_attributes {:name => 'joe smith'} end before(:each) do @person = Person.new(valid_attributes) end it "should be valid with valid attributes" do @person.should be_valid end it "should be invalid with no name" do @person.name = nil @person.should_not be_valid end end Together, these different examples help to tell the whole story, and when one example fails you know why it's failing - its just that the message is in the example's name instead of a custom assertion message. Make sense? > > Thanks, > > - Geoffrey > -- > Geoffrey Wiseman > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Tue Sep 4 15:55:11 2007 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 4 Sep 2007 12:55:11 -0700 Subject: [rspec-users] Rake tasks getting in the way of edge (uses gem instead) Message-ID: <810a540e0709041255y4157d5d8x2a2f080b88c0bd97@mail.gmail.com> So I'd been running gem releases of rspec for the past several months, and I installed edge rspec so that I can use Story Runner. I'm running into a problem because I've got a couple rake tasks that reference "spec/rake/raketask". If I try to run "rake spec" then it pulls in the gem version instead of the plugin version. rake blows up saying that the versions are incompatible...RSpec is at 1.0.8 and rspec_on_rails is at r2507. If I remove those rake tasks then it runs fine. So it just seems that when rake starts up, it loads all the available task files, which includes a reference to require rspec stuff. Since the plugins haven't been loaded yet it gets the gem version. afaik the solution is to build a new gem. However I don't want to have to tell my team members to update their gem every single day. Also I think including rspec in vendor/plugins is supposed to obviate that anyway, but this is probably just some path loading stuff. Anyone else run into this? How do you handle it? Pat From dchelimsky at gmail.com Tue Sep 4 15:59:15 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 4 Sep 2007 14:59:15 -0500 Subject: [rspec-users] Rake tasks getting in the way of edge (uses gem instead) In-Reply-To: <810a540e0709041255y4157d5d8x2a2f080b88c0bd97@mail.gmail.com> References: <810a540e0709041255y4157d5d8x2a2f080b88c0bd97@mail.gmail.com> Message-ID: <57c63afe0709041259m37245320i3f304ce8b9a9ef49@mail.gmail.com> On 9/4/07, Pat Maddox wrote: > So I'd been running gem releases of rspec for the past several months, > and I installed edge rspec so that I can use Story Runner. > > I'm running into a problem because I've got a couple rake tasks that > reference "spec/rake/raketask". If I try to run "rake spec" then it > pulls in the gem version instead of the plugin version. rake blows up > saying that the versions are incompatible...RSpec is at 1.0.8 and > rspec_on_rails is at r2507. > > If I remove those rake tasks then it runs fine. So it just seems that > when rake starts up, it loads all the available task files, which > includes a reference to require rspec stuff. Since the plugins > haven't been loaded yet it gets the gem version. > > afaik the solution is to build a new gem. However I don't want to > have to tell my team members to update their gem every single day. > Also I think including rspec in vendor/plugins is supposed to obviate > that anyway, but this is probably just some path loading stuff. > > Anyone else run into this? How do you handle it? See http://rspec.rubyforge.org/documentation/rails/install.html > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From drichards at showcase60.com Tue Sep 4 16:12:56 2007 From: drichards at showcase60.com (David Richards) Date: Tue, 4 Sep 2007 14:12:56 -0600 Subject: [rspec-users] Rake tasks getting in the way of edge (uses gem instead) In-Reply-To: <810a540e0709041255y4157d5d8x2a2f080b88c0bd97@mail.gmail.com> References: <810a540e0709041255y4157d5d8x2a2f080b88c0bd97@mail.gmail.com> Message-ID: <25DA20BE-2AC9-4ACE-9EBA-3F1BD4D89D82@showcase60.com> What I've done with this is to just uninstall the gem and commit to working off of the plugins completely. I've found that with gems in general, I try to keep them local to the project I'm on, almost as if they were a plugin. I move them to my project's lib (gem unpack) so that I've got explicit control over versions and dependencies and I can very easily encapsulate my work domain when I go to deploy an app. Committing to the rspec plugins gives me the same features for free. Hope this helps, David On Sep 4, 2007, at 1:55 PM, Pat Maddox wrote: > So I'd been running gem releases of rspec for the past several months, > and I installed edge rspec so that I can use Story Runner. > > I'm running into a problem because I've got a couple rake tasks that > reference "spec/rake/raketask". If I try to run "rake spec" then it > pulls in the gem version instead of the plugin version. rake blows up > saying that the versions are incompatible...RSpec is at 1.0.8 and > rspec_on_rails is at r2507. > > If I remove those rake tasks then it runs fine. So it just seems that > when rake starts up, it loads all the available task files, which > includes a reference to require rspec stuff. Since the plugins > haven't been loaded yet it gets the gem version. > > afaik the solution is to build a new gem. However I don't want to > have to tell my team members to update their gem every single day. > Also I think including rspec in vendor/plugins is supposed to obviate > that anyway, but this is probably just some path loading stuff. > > Anyone else run into this? How do you handle it? > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From geoffrey.wiseman at gmail.com Tue Sep 4 16:51:03 2007 From: geoffrey.wiseman at gmail.com (Geoffrey Wiseman) Date: Tue, 4 Sep 2007 16:51:03 -0400 Subject: [rspec-users] Failure Messages in RSpec Message-ID: <835d522e0709041351va41f1a3y8dc9c6fa92d05c96@mail.gmail.com> > > I come from the same background as you, so I hear where you're coming > from. We made a conscious decision, however, not to support custom > messages almost two years ago and I'm not sure if its ever even come > up before. If it has, it was a long time ago. [nod] Perhaps as I get into the mindset, I'll find this desire slips away. If you follow the conventions of one expectation per example, and your > example is well named, this is less of a problem. Here's a common > idiom: > > describe Person do > def valid_attributes > {:name => 'joe smith'} > end > before(:each) do > @person = Person.new(valid_attributes) > end > it "should be valid with valid attributes" do > @person.should be_valid > end > it "should be invalid with no name" do > @person.name = nil > @person.should_not be_valid > end > end Using this as an example, if a new validation rule is added, this test will fail without indicating /why/. Sure, I can get that answer in other ways, but I'd hate to discover things like: it "should be valid with valid attributes" do # puts @person.errors if !@person.valid @person.should be_valid end (Which I've seen when people have to repeatedly diagnose issues in a test; I'd prefer a failure message to the above) Together, these different examples help to tell the whole story, and > when one example fails you know why it's failing - its just that the > message is in the example's name instead of a custom assertion > message. Make sense? Yes and no; test isolation and good names is a decent practice even in XUnit, but clearly it's that much stronger in RSpec, and I'm in favour of that. However, I find that often test failures involve unexpected changes ( e.g. the REST service didn't return a status code of 201, as you expected, because a validation rule changed and the validation failed), which aren't as easy to message. Still, i'm willing to give this approach a shot and see if this bothers me increasingly less. - Geoffrey -- Geoffrey Wiseman -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070904/9e09ed73/attachment.html From pergesu at gmail.com Tue Sep 4 16:58:44 2007 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 4 Sep 2007 13:58:44 -0700 Subject: [rspec-users] Rake tasks getting in the way of edge (uses gem instead) In-Reply-To: <57c63afe0709041259m37245320i3f304ce8b9a9ef49@mail.gmail.com> References: <810a540e0709041255y4157d5d8x2a2f080b88c0bd97@mail.gmail.com> <57c63afe0709041259m37245320i3f304ce8b9a9ef49@mail.gmail.com> Message-ID: <810a540e0709041358w181d983dtae329f612f38a969@mail.gmail.com> On 9/4/07, David Chelimsky wrote: > On 9/4/07, Pat Maddox wrote: > > So I'd been running gem releases of rspec for the past several months, > > and I installed edge rspec so that I can use Story Runner. > > > > I'm running into a problem because I've got a couple rake tasks that > > reference "spec/rake/raketask". If I try to run "rake spec" then it > > pulls in the gem version instead of the plugin version. rake blows up > > saying that the versions are incompatible...RSpec is at 1.0.8 and > > rspec_on_rails is at r2507. > > > > If I remove those rake tasks then it runs fine. So it just seems that > > when rake starts up, it loads all the available task files, which > > includes a reference to require rspec stuff. Since the plugins > > haven't been loaded yet it gets the gem version. > > > > afaik the solution is to build a new gem. However I don't want to > > have to tell my team members to update their gem every single day. > > Also I think including rspec in vendor/plugins is supposed to obviate > > that anyway, but this is probably just some path loading stuff. > > > > Anyone else run into this? How do you handle it? > > See http://rspec.rubyforge.org/documentation/rails/install.html I managed to fix it by changing the require to use the full path to the plugin: require "vendor/plugins/rspec/lib/spec/rake/spectask" Pat From smingins at elctech.com Tue Sep 4 16:58:40 2007 From: smingins at elctech.com (Shane Mingins) Date: Wed, 5 Sep 2007 08:58:40 +1200 Subject: [rspec-users] Failure Messages in RSpec In-Reply-To: <835d522e0709041351va41f1a3y8dc9c6fa92d05c96@mail.gmail.com> References: <835d522e0709041351va41f1a3y8dc9c6fa92d05c96@mail.gmail.com> Message-ID: <0645D1C9-EC62-4C2D-B4BB-AF3ED87E103A@elctech.com> On 5/09/2007, at 8:51 AM, Geoffrey Wiseman wrote: > > Using this as an example, if a new validation rule is added, this > test will fail without indicating /why/. Sure, I can get that > answer in other ways, but I'd hate to discover things like: > > it "should be valid with valid attributes" do > # puts @person.errors if !@person.valid > @person.should be_valid > end > Sorry if I missed the point of this, but in the context of having an optional failure message.... I am curious as to how an optional message param to the assertion would help you in this case? Cheers Shane -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070905/78ece223/attachment-0001.html From dchelimsky at gmail.com Tue Sep 4 17:00:29 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 4 Sep 2007 16:00:29 -0500 Subject: [rspec-users] Failure Messages in RSpec In-Reply-To: <835d522e0709041351va41f1a3y8dc9c6fa92d05c96@mail.gmail.com> References: <835d522e0709041351va41f1a3y8dc9c6fa92d05c96@mail.gmail.com> Message-ID: <57c63afe0709041400xbf2ba4dp19dae57ad80833b9@mail.gmail.com> On 9/4/07, Geoffrey Wiseman wrote: > > I come from the same background as you, so I hear where you're coming > > from. We made a conscious decision, however, not to support custom > > messages almost two years ago and I'm not sure if its ever even come > > up before. If it has, it was a long time ago. > > [nod] Perhaps as I get into the mindset, I'll find this desire slips away. > > > If you follow the conventions of one expectation per example, and your > > example is well named, this is less of a problem. Here's a common > > idiom: > > > > describe Person do > > def valid_attributes > > {:name => 'joe smith'} > > end > > before(:each) do > > @person = Person.new(valid_attributes) > > end > > it "should be valid with valid attributes" do > > @person.should be_valid > > end > > it "should be invalid with no name" do > > @person.name = nil > > @person.should_not be_valid > > end > > end > > Using this as an example, if a new validation rule is added, this test will > fail without indicating /why/. Sure, I can get that answer in other ways, > but I'd hate to discover things like: > > it "should be valid with valid attributes" do > # puts @person.errors if !@person.valid > @person.should be_valid > end > > (Which I've seen when people have to repeatedly diagnose issues in a test; > I'd prefer a failure message to the above) > > > Together, these different examples help to tell the whole story, and > > when one example fails you know why it's failing - its just that the > > message is in the example's name instead of a custom assertion > > message. > > > Make sense? > > Yes and no; test isolation and good names is a decent practice even in > XUnit, but clearly it's that much stronger in RSpec, and I'm in favour of > that. However, I find that often test failures involve unexpected changes ( > e.g. the REST service didn't return a status code of 201, as you expected, > because a validation rule changed and the validation failed), which aren't > as easy to message. > > Still, i'm willing to give this approach a shot and see if this bothers me > increasingly less. Personally, I'm open to the idea of custom messages - I just have no idea how that work syntactically. If you get to the point where you really feel the need for that feature (or before that point) please feel free to make suggestions about that. Cheers, David > > - Geoffrey > -- > Geoffrey Wiseman > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Tue Sep 4 17:02:04 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 4 Sep 2007 16:02:04 -0500 Subject: [rspec-users] Rake tasks getting in the way of edge (uses gem instead) In-Reply-To: <810a540e0709041358w181d983dtae329f612f38a969@mail.gmail.com> References: <810a540e0709041255y4157d5d8x2a2f080b88c0bd97@mail.gmail.com> <57c63afe0709041259m37245320i3f304ce8b9a9ef49@mail.gmail.com> <810a540e0709041358w181d983dtae329f612f38a969@mail.gmail.com> Message-ID: <57c63afe0709041402g48df5da9n62f818e133482813@mail.gmail.com> On 9/4/07, Pat Maddox wrote: > On 9/4/07, David Chelimsky wrote: > > On 9/4/07, Pat Maddox wrote: > > > So I'd been running gem releases of rspec for the past several months, > > > and I installed edge rspec so that I can use Story Runner. > > > > > > I'm running into a problem because I've got a couple rake tasks that > > > reference "spec/rake/raketask". If I try to run "rake spec" then it > > > pulls in the gem version instead of the plugin version. rake blows up > > > saying that the versions are incompatible...RSpec is at 1.0.8 and > > > rspec_on_rails is at r2507. > > > > > > If I remove those rake tasks then it runs fine. So it just seems that > > > when rake starts up, it loads all the available task files, which > > > includes a reference to require rspec stuff. Since the plugins > > > haven't been loaded yet it gets the gem version. > > > > > > afaik the solution is to build a new gem. However I don't want to > > > have to tell my team members to update their gem every single day. > > > Also I think including rspec in vendor/plugins is supposed to obviate > > > that anyway, but this is probably just some path loading stuff. > > > > > > Anyone else run into this? How do you handle it? > > > > See http://rspec.rubyforge.org/documentation/rails/install.html > > I managed to fix it by changing the require to use the full path to the plugin: > > require "vendor/plugins/rspec/lib/spec/rake/spectask" Ah - so you already had rspec installed as a plugin also? I didn't understand that part (clearly). Where is that require? I'll updated it in the plugin. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists-rspec at shopwatch.org Tue Sep 4 17:08:30 2007 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Tue, 04 Sep 2007 17:08:30 -0400 Subject: [rspec-users] Failure Messages in RSpec In-Reply-To: <0645D1C9-EC62-4C2D-B4BB-AF3ED87E103A@elctech.com> References: <835d522e0709041351va41f1a3y8dc9c6fa92d05c96@mail.gmail.com> <0645D1C9-EC62-4C2D-B4BB-AF3ED87E103A@elctech.com> Message-ID: <46DDC94E.1020407@jay.fm> Shane Mingins wrote: > > On 5/09/2007, at 8:51 AM, Geoffrey Wiseman wrote: > >> >> Using this as an example, if a new validation rule is added, this test >> will fail without indicating /why/. Sure, I can get that answer in >> other ways, but I'd hate to discover things like: >> >> it "should be valid with valid attributes" do >> # puts @person.errors if !@person.valid >> @person.should be_valid >> end >> > > Sorry if I missed the point of this, but in the context of having an > optional failure message.... > > I am curious as to how an optional message param to the assertion would > help you in this case? Seems like, in this case, he'd output @person.errors in his message so he could see *why* person was invalid; the "puts" is his current hack-around for the lack of custom messages. Not a bad idea, really. (the custom messages, not the hackaround!) Jay From pergesu at gmail.com Tue Sep 4 17:12:23 2007 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 4 Sep 2007 14:12:23 -0700 Subject: [rspec-users] Rake tasks getting in the way of edge (uses gem instead) In-Reply-To: <57c63afe0709041402g48df5da9n62f818e133482813@mail.gmail.com> References: <810a540e0709041255y4157d5d8x2a2f080b88c0bd97@mail.gmail.com> <57c63afe0709041259m37245320i3f304ce8b9a9ef49@mail.gmail.com> <810a540e0709041358w181d983dtae329f612f38a969@mail.gmail.com> <57c63afe0709041402g48df5da9n62f818e133482813@mail.gmail.com> Message-ID: <810a540e0709041412v5d84da5elb19b2c878e3416b8@mail.gmail.com> On 9/4/07, David Chelimsky wrote: > On 9/4/07, Pat Maddox wrote: > > On 9/4/07, David Chelimsky wrote: > > > On 9/4/07, Pat Maddox wrote: > > > > So I'd been running gem releases of rspec for the past several months, > > > > and I installed edge rspec so that I can use Story Runner. > > > > > > > > I'm running into a problem because I've got a couple rake tasks that > > > > reference "spec/rake/raketask". If I try to run "rake spec" then it > > > > pulls in the gem version instead of the plugin version. rake blows up > > > > saying that the versions are incompatible...RSpec is at 1.0.8 and > > > > rspec_on_rails is at r2507. > > > > > > > > If I remove those rake tasks then it runs fine. So it just seems that > > > > when rake starts up, it loads all the available task files, which > > > > includes a reference to require rspec stuff. Since the plugins > > > > haven't been loaded yet it gets the gem version. > > > > > > > > afaik the solution is to build a new gem. However I don't want to > > > > have to tell my team members to update their gem every single day. > > > > Also I think including rspec in vendor/plugins is supposed to obviate > > > > that anyway, but this is probably just some path loading stuff. > > > > > > > > Anyone else run into this? How do you handle it? > > > > > > See http://rspec.rubyforge.org/documentation/rails/install.html > > > > I managed to fix it by changing the require to use the full path to the plugin: > > > > require "vendor/plugins/rspec/lib/spec/rake/spectask" > > Ah - so you already had rspec installed as a plugin also? I didn't > understand that part (clearly). > > Where is that require? I'll updated it in the plugin. The require isn't part of the rspec code...one of the guys I work with wrote the following rake task: require "rake" require "spec/rake/spectask" desc "Run all specs and dump to html" Spec::Rake::SpecTask.new('spec:html') do |t| t.spec_opts = ["--format", "html"] if ARGV.size > 1 t.out = ARGV[-1] else t.out = 'test.html' end t.fail_on_error = false end There might be another way to generate the HTML output with rake automatically, I'm not sure... Anyway I'm assuming it loads the gem version because the plugins haven't been loaded yet and the rspec plugin isn't yet part of the classpath. Does that make sense? Pat From dchelimsky at gmail.com Tue Sep 4 17:14:03 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 4 Sep 2007 16:14:03 -0500 Subject: [rspec-users] Rake tasks getting in the way of edge (uses gem instead) In-Reply-To: <810a540e0709041412v5d84da5elb19b2c878e3416b8@mail.gmail.com> References: <810a540e0709041255y4157d5d8x2a2f080b88c0bd97@mail.gmail.com> <57c63afe0709041259m37245320i3f304ce8b9a9ef49@mail.gmail.com> <810a540e0709041358w181d983dtae329f612f38a969@mail.gmail.com> <57c63afe0709041402g48df5da9n62f818e133482813@mail.gmail.com> <810a540e0709041412v5d84da5elb19b2c878e3416b8@mail.gmail.com> Message-ID: <57c63afe0709041414x52292bf1v6c0fcd853632f6d7@mail.gmail.com> On 9/4/07, Pat Maddox wrote: > On 9/4/07, David Chelimsky wrote: > > On 9/4/07, Pat Maddox wrote: > > > On 9/4/07, David Chelimsky wrote: > > > > On 9/4/07, Pat Maddox wrote: > > > > > So I'd been running gem releases of rspec for the past several months, > > > > > and I installed edge rspec so that I can use Story Runner. > > > > > > > > > > I'm running into a problem because I've got a couple rake tasks that > > > > > reference "spec/rake/raketask". If I try to run "rake spec" then it > > > > > pulls in the gem version instead of the plugin version. rake blows up > > > > > saying that the versions are incompatible...RSpec is at 1.0.8 and > > > > > rspec_on_rails is at r2507. > > > > > > > > > > If I remove those rake tasks then it runs fine. So it just seems that > > > > > when rake starts up, it loads all the available task files, which > > > > > includes a reference to require rspec stuff. Since the plugins > > > > > haven't been loaded yet it gets the gem version. > > > > > > > > > > afaik the solution is to build a new gem. However I don't want to > > > > > have to tell my team members to update their gem every single day. > > > > > Also I think including rspec in vendor/plugins is supposed to obviate > > > > > that anyway, but this is probably just some path loading stuff. > > > > > > > > > > Anyone else run into this? How do you handle it? > > > > > > > > See http://rspec.rubyforge.org/documentation/rails/install.html > > > > > > I managed to fix it by changing the require to use the full path to the plugin: > > > > > > require "vendor/plugins/rspec/lib/spec/rake/spectask" > > > > Ah - so you already had rspec installed as a plugin also? I didn't > > understand that part (clearly). > > > > Where is that require? I'll updated it in the plugin. > > The require isn't part of the rspec code...one of the guys I work with > wrote the following rake task: > > require "rake" > require "spec/rake/spectask" > > desc "Run all specs and dump to html" > Spec::Rake::SpecTask.new('spec:html') do |t| > t.spec_opts = ["--format", "html"] > if ARGV.size > 1 > t.out = ARGV[-1] > else > t.out = 'test.html' > end > t.fail_on_error = false > end > > There might be another way to generate the HTML output with rake > automatically, I'm not sure... > > Anyway I'm assuming it loads the gem version because the plugins > haven't been loaded yet and the rspec plugin isn't yet part of the > classpath. > > Does that make sense? yep > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From chad at spicycode.com Tue Sep 4 17:14:52 2007 From: chad at spicycode.com (Chad Humphries) Date: Tue, 4 Sep 2007 17:14:52 -0400 Subject: [rspec-users] Failure Messages in RSpec In-Reply-To: <46DDC94E.1020407@jay.fm> References: <835d522e0709041351va41f1a3y8dc9c6fa92d05c96@mail.gmail.com> <0645D1C9-EC62-4C2D-B4BB-AF3ED87E103A@elctech.com> <46DDC94E.1020407@jay.fm> Message-ID: <93A4EAFC-D69C-4565-A68D-35B6AD36286B@spicycode.com> I generally write custom expectation matchers when I want more specific information on failure scenarios. Granted this might not work in all scenarios (taking time to write a custom matcher I mean), but for most things it has made it very nice. -Chad On Sep 4, 2007, at 5:08 PM, Jay Levitt wrote: > Shane Mingins wrote: >> >> On 5/09/2007, at 8:51 AM, Geoffrey Wiseman wrote: >> >>> >>> Using this as an example, if a new validation rule is added, this >>> test >>> will fail without indicating /why/. Sure, I can get that answer in >>> other ways, but I'd hate to discover things like: >>> >>> it "should be valid with valid attributes" do >>> # puts @person.errors if !@person.valid >>> @person.should be_valid >>> end >>> >> >> Sorry if I missed the point of this, but in the context of having an >> optional failure message.... >> >> I am curious as to how an optional message param to the assertion >> would >> help you in this case? > > Seems like, in this case, he'd output @person.errors in his message so > he could see *why* person was invalid; the "puts" is his current > hack-around for the lack of custom messages. > > Not a bad idea, really. (the custom messages, not the hackaround!) > > Jay > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lancecarlson at gmail.com Tue Sep 4 17:17:52 2007 From: lancecarlson at gmail.com (Lance Carlson) Date: Tue, 4 Sep 2007 17:17:52 -0400 Subject: [rspec-users] A place for modules Message-ID: <49f64a900709041417p3dbcf3d3id2a4ca983fec870c@mail.gmail.com> At the moment I'm including files from the root of my spec directory so I don't touch my spec_helper.rb file because it seems to change every once in awhile when rspec gets upgraded. I think it would be good if we had a place to put modules, perhaps a file that got auto-loaded so you could include them within any one of the specs. Thoughts? From lists-rspec at shopwatch.org Tue Sep 4 17:19:15 2007 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Tue, 04 Sep 2007 17:19:15 -0400 Subject: [rspec-users] Failure Messages in RSpec In-Reply-To: <93A4EAFC-D69C-4565-A68D-35B6AD36286B@spicycode.com> References: <835d522e0709041351va41f1a3y8dc9c6fa92d05c96@mail.gmail.com> <0645D1C9-EC62-4C2D-B4BB-AF3ED87E103A@elctech.com> <46DDC94E.1020407@jay.fm> <93A4EAFC-D69C-4565-A68D-35B6AD36286B@spicycode.com> Message-ID: <46DDCBD3.6070102@jay.fm> Chad Humphries wrote: > I generally write custom expectation matchers when I want more > specific information on failure scenarios. Granted this might not > work in all scenarios (taking time to write a custom matcher I mean), > but for most things it has made it very nice. Hmm, I wonder if rspec_on_rails should come with a custom be_valid matcher that shows .errors? I can't think of a case where that would be bad... Jay From pergesu at gmail.com Tue Sep 4 17:23:05 2007 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 4 Sep 2007 14:23:05 -0700 Subject: [rspec-users] Failure Messages in RSpec In-Reply-To: <57c63afe0709041400xbf2ba4dp19dae57ad80833b9@mail.gmail.com> References: <835d522e0709041351va41f1a3y8dc9c6fa92d05c96@mail.gmail.com> <57c63afe0709041400xbf2ba4dp19dae57ad80833b9@mail.gmail.com> Message-ID: <810a540e0709041423n19ca90d7p8a31d0c43ccf3f14@mail.gmail.com> On 9/4/07, David Chelimsky wrote: > On 9/4/07, Geoffrey Wiseman wrote: > > > I come from the same background as you, so I hear where you're coming > > > from. We made a conscious decision, however, not to support custom > > > messages almost two years ago and I'm not sure if its ever even come > > > up before. If it has, it was a long time ago. > > > > [nod] Perhaps as I get into the mindset, I'll find this desire slips away. > > > > > If you follow the conventions of one expectation per example, and your > > > example is well named, this is less of a problem. Here's a common > > > idiom: > > > > > > describe Person do > > > def valid_attributes > > > {:name => 'joe smith'} > > > end > > > before(:each) do > > > @person = Person.new(valid_attributes) > > > end > > > it "should be valid with valid attributes" do > > > @person.should be_valid > > > end > > > it "should be invalid with no name" do > > > @person.name = nil > > > @person.should_not be_valid > > > end > > > end > > > > Using this as an example, if a new validation rule is added, this test will > > fail without indicating /why/. Sure, I can get that answer in other ways, > > but I'd hate to discover things like: > > > > it "should be valid with valid attributes" do > > # puts @person.errors if !@person.valid > > @person.should be_valid > > end > > > > (Which I've seen when people have to repeatedly diagnose issues in a test; > > I'd prefer a failure message to the above) > > > > > Together, these different examples help to tell the whole story, and > > > when one example fails you know why it's failing - its just that the > > > message is in the example's name instead of a custom assertion > > > message. > > > > > Make sense? > > > > Yes and no; test isolation and good names is a decent practice even in > > XUnit, but clearly it's that much stronger in RSpec, and I'm in favour of > > that. However, I find that often test failures involve unexpected changes ( > > e.g. the REST service didn't return a status code of 201, as you expected, > > because a validation rule changed and the validation failed), which aren't > > as easy to message. > > > > Still, i'm willing to give this approach a shot and see if this bothers me > > increasingly less. > > Personally, I'm open to the idea of custom messages - I just have no > idea how that work syntactically. If you get to the point where you > really feel the need for that feature (or before that point) please > feel free to make suggestions about that. What do you think about using a custom expectation matcher here? be_valid can be its own matcher instead of using the predicate matcher. That way we can include extra info without polluting the syntax, because as you said, this doesn't come up. Of course that gets in the way of other objects that respond to valid?, so I guess you could do a little bit of type-checking (if it's an AR object then display errors, otherwise delegate to predicate matcher) or create a separate matcher altogether. What about something like: it "should validate with valid attributes" do @person.should validate end 'Person should validate with valid attributes' FAILED expected object to validate, failed with errors: Age can't be blank Basically I think a custom expectation matcher works fine here, I just don't know the best way to implement it. Pat From dchelimsky at gmail.com Tue Sep 4 17:24:27 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 4 Sep 2007 16:24:27 -0500 Subject: [rspec-users] Failure Messages in RSpec In-Reply-To: <810a540e0709041423n19ca90d7p8a31d0c43ccf3f14@mail.gmail.com> References: <835d522e0709041351va41f1a3y8dc9c6fa92d05c96@mail.gmail.com> <57c63afe0709041400xbf2ba4dp19dae57ad80833b9@mail.gmail.com> <810a540e0709041423n19ca90d7p8a31d0c43ccf3f14@mail.gmail.com> Message-ID: <57c63afe0709041424r4238a86fu6148df97b0ebf1b4@mail.gmail.com> On 9/4/07, Pat Maddox wrote: > On 9/4/07, David Chelimsky wrote: > > On 9/4/07, Geoffrey Wiseman wrote: > > > > I come from the same background as you, so I hear where you're coming > > > > from. We made a conscious decision, however, not to support custom > > > > messages almost two years ago and I'm not sure if its ever even come > > > > up before. If it has, it was a long time ago. > > > > > > [nod] Perhaps as I get into the mindset, I'll find this desire slips away. > > > > > > > If you follow the conventions of one expectation per example, and your > > > > example is well named, this is less of a problem. Here's a common > > > > idiom: > > > > > > > > describe Person do > > > > def valid_attributes > > > > {:name => 'joe smith'} > > > > end > > > > before(:each) do > > > > @person = Person.new(valid_attributes) > > > > end > > > > it "should be valid with valid attributes" do > > > > @person.should be_valid > > > > end > > > > it "should be invalid with no name" do > > > > @person.name = nil > > > > @person.should_not be_valid > > > > end > > > > end > > > > > > Using this as an example, if a new validation rule is added, this test will > > > fail without indicating /why/. Sure, I can get that answer in other ways, > > > but I'd hate to discover things like: > > > > > > it "should be valid with valid attributes" do > > > # puts @person.errors if !@person.valid > > > @person.should be_valid > > > end > > > > > > (Which I've seen when people have to repeatedly diagnose issues in a test; > > > I'd prefer a failure message to the above) > > > > > > > Together, these different examples help to tell the whole story, and > > > > when one example fails you know why it's failing - its just that the > > > > message is in the example's name instead of a custom assertion > > > > message. > > > > > > > Make sense? > > > > > > Yes and no; test isolation and good names is a decent practice even in > > > XUnit, but clearly it's that much stronger in RSpec, and I'm in favour of > > > that. However, I find that often test failures involve unexpected changes ( > > > e.g. the REST service didn't return a status code of 201, as you expected, > > > because a validation rule changed and the validation failed), which aren't > > > as easy to message. > > > > > > Still, i'm willing to give this approach a shot and see if this bothers me > > > increasingly less. > > > > Personally, I'm open to the idea of custom messages - I just have no > > idea how that work syntactically. If you get to the point where you > > really feel the need for that feature (or before that point) please > > feel free to make suggestions about that. > > What do you think about using a custom expectation matcher here? > be_valid can be its own matcher instead of using the predicate > matcher. That way we can include extra info without polluting the > syntax, because as you said, this doesn't come up. > > Of course that gets in the way of other objects that respond to > valid?, so I guess you could do a little bit of type-checking (if it's > an AR object then display errors, otherwise delegate to predicate > matcher) or create a separate matcher altogether. > > What about something like: > > it "should validate with valid attributes" do > @person.should validate be_valid_model???? > end > > 'Person should validate with valid attributes' FAILED > expected object to validate, failed with errors: > Age can't be blank > > Basically I think a custom expectation matcher works fine here, I just > don't know the best way to implement it. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From geoffrey.wiseman at gmail.com Tue Sep 4 17:24:35 2007 From: geoffrey.wiseman at gmail.com (Geoffrey Wiseman) Date: Tue, 4 Sep 2007 17:24:35 -0400 Subject: [rspec-users] Failure Messages in RSpec In-Reply-To: <46DDC94E.1020407@jay.fm> References: <835d522e0709041351va41f1a3y8dc9c6fa92d05c96@mail.gmail.com> <0645D1C9-EC62-4C2D-B4BB-AF3ED87E103A@elctech.com> <46DDC94E.1020407@jay.fm> Message-ID: <835d522e0709041424i3a08a8e3rdca20debfabda75f@mail.gmail.com> On 9/4/07, Jay Levitt wrote: > > Seems like, in this case, he'd output @person.errors in his message so > he could see *why* person was invalid; the "puts" is his current > hack-around for the lack of custom messages. > > Not a bad idea, really. (the custom messages, not the hackaround!) > Yes, exactly; I often write the simple case with no extra message first, then the first time the failing unit test doesn't give me enough information to fix the problem, I add a custom message that makes it easier. Examples culled from Test::Unit code: - assert_select "a[href*=#{rev_1_url}]", true, "could not find #{rev_1_url} in #{@response.body}" - In this case, it failed to find the URL, but I wasn't sure why that would be; adding the response body made it possible for me to diagnose that the expected URL I'd generated didn't match because the ID was off. This kind of response is pretty spammy (entire response text), so I'd definitely only employ this if it was present only in the case of failure. - assert_response :ok, "Failed to restore contact_info: #{@ response.body}" - A similarly spammy @response.body output; wasn't sure why the response wasn't :ok, turned out to be a validation failure triggered by restoring a no-longer-valid revision. - assert customer.valid?, "Fixture customer is expected to be valid: #{customer.errors.full_messages.join(', ')}" - Pretty similar to the example I used above; unexpected validation failure, it's nice to see the errors. Are any of these critical to RSpec's main goals? Probably not. Will it prevent my adopting RSpec? Probably not. Is it still handy to have so that you don't employ other means (e.g. commented out puts) for repeat diagnosis of failures? I think so. That said, if none of the above convinces you, then by all means, I'll go ahead with the standard RSpec approach and see if, in a few months, I'm still missing this feature and, if so, I'll have good RSpec examples in hand, with which to discuss. ;) - Geoffrey -- Geoffrey Wiseman -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070904/9bc522e4/attachment.html From ben at benmabey.com Tue Sep 4 17:53:23 2007 From: ben at benmabey.com (Ben Mabey) Date: Tue, 04 Sep 2007 15:53:23 -0600 Subject: [rspec-users] Failure Messages in RSpec In-Reply-To: <810a540e0709041423n19ca90d7p8a31d0c43ccf3f14@mail.gmail.com> References: <835d522e0709041351va41f1a3y8dc9c6fa92d05c96@mail.gmail.com> <57c63afe0709041400xbf2ba4dp19dae57ad80833b9@mail.gmail.com> <810a540e0709041423n19ca90d7p8a31d0c43ccf3f14@mail.gmail.com> Message-ID: <46DDD3D3.7060306@benmabey.com> Pat Maddox wrote: > On 9/4/07, David Chelimsky wrote: > >> On 9/4/07, Geoffrey Wiseman wrote: >> >>>> I come from the same background as you, so I hear where you're coming >>>> from. We made a conscious decision, however, not to support custom >>>> messages almost two years ago and I'm not sure if its ever even come >>>> up before. If it has, it was a long time ago. >>>> >>> [nod] Perhaps as I get into the mindset, I'll find this desire slips away. >>> >>> >>>> If you follow the conventions of one expectation per example, and your >>>> example is well named, this is less of a problem. Here's a common >>>> idiom: >>>> >>>> describe Person do >>>> def valid_attributes >>>> {:name => 'joe smith'} >>>> end >>>> before(:each) do >>>> @person = Person.new(valid_attributes) >>>> end >>>> it "should be valid with valid attributes" do >>>> @person.should be_valid >>>> end >>>> it "should be invalid with no name" do >>>> @person.name = nil >>>> @person.should_not be_valid >>>> end >>>> end >>>> >>> Using this as an example, if a new validation rule is added, this test will >>> fail without indicating /why/. Sure, I can get that answer in other ways, >>> but I'd hate to discover things like: >>> >>> it "should be valid with valid attributes" do >>> # puts @person.errors if !@person.valid >>> @person.should be_valid >>> end >>> >>> (Which I've seen when people have to repeatedly diagnose issues in a test; >>> I'd prefer a failure message to the above) >>> >>> >>>> Together, these different examples help to tell the whole story, and >>>> when one example fails you know why it's failing - its just that the >>>> message is in the example's name instead of a custom assertion >>>> message. >>>> >>>> Make sense? >>>> >>> Yes and no; test isolation and good names is a decent practice even in >>> XUnit, but clearly it's that much stronger in RSpec, and I'm in favour of >>> that. However, I find that often test failures involve unexpected changes ( >>> e.g. the REST service didn't return a status code of 201, as you expected, >>> because a validation rule changed and the validation failed), which aren't >>> as easy to message. >>> >>> Still, i'm willing to give this approach a shot and see if this bothers me >>> increasingly less. >>> >> Personally, I'm open to the idea of custom messages - I just have no >> idea how that work syntactically. If you get to the point where you >> really feel the need for that feature (or before that point) please >> feel free to make suggestions about that. >> > > What do you think about using a custom expectation matcher here? > be_valid can be its own matcher instead of using the predicate > matcher. That way we can include extra info without polluting the > syntax, because as you said, this doesn't come up. > > Of course that gets in the way of other objects that respond to > valid?, so I guess you could do a little bit of type-checking (if it's > an AR object then display errors, otherwise delegate to predicate > matcher) or create a separate matcher altogether. > > What about something like: > > it "should validate with valid attributes" do > @person.should validate > end > > 'Person should validate with valid attributes' FAILED > expected object to validate, failed with errors: > Age can't be blank > > Basically I think a custom expectation matcher works fine here, I just > don't know the best way to implement it. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Maybe this is what your thinking? http://opensoul.org/2007/4/18/rspec-model-should-be_valid -Ben From smingins at elctech.com Tue Sep 4 17:56:20 2007 From: smingins at elctech.com (Shane Mingins) Date: Wed, 5 Sep 2007 09:56:20 +1200 Subject: [rspec-users] 1.05 to 1.08 In-Reply-To: <57c63afe0709032044w4ac1f29dt96b808e67e663b0f@mail.gmail.com> References: <6A8E61FC-BCC7-4209-82F6-1E37AF6F8B34@elctech.com> <57c63afe0709032044w4ac1f29dt96b808e67e663b0f@mail.gmail.com> Message-ID: On 4/09/2007, at 3:44 PM, David Chelimsky wrote: > > I am going to guess that it's something like this: > > You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.<< > > If not, please post the error (good idea to do that in general). > > If so, this is fixed in trunk. Attached is a patch you can use to > address it in your rails app (apply from vendor/plugins) > > Please let us know if this fixes the problem. > > Cheers, > David > Boiled down the next routes problem in a helper spec ... using with_routing it do with_routing do |set| set.draw do |map| map.resources :articles do |article| article.resources :comments, :name_prefix => 'a_' do | comment| comment.resources :ratings, :name_prefix => 'a_c_' end end end a_c_rating_path(@article, @comment, @rating).should == "/ articles/1/comments/1/ratings/1" end end This works fine in 1.05 and errors in 1.08 with the error: NoMethodError in 'CommentsHelper NO NAME (Because of Error raised in matcher)' You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.<< Cheers Shane From dchelimsky at gmail.com Tue Sep 4 18:00:14 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 4 Sep 2007 17:00:14 -0500 Subject: [rspec-users] 1.05 to 1.08 In-Reply-To: References: <6A8E61FC-BCC7-4209-82F6-1E37AF6F8B34@elctech.com> <57c63afe0709032044w4ac1f29dt96b808e67e663b0f@mail.gmail.com> Message-ID: <57c63afe0709041500h27677e3dp4668127cd446c936@mail.gmail.com> On 9/4/07, Shane Mingins wrote: > > On 4/09/2007, at 3:44 PM, David Chelimsky wrote: > > > > > I am going to guess that it's something like this: > > > > You have a nil object when you didn't expect it! > > You might have expected an instance of Array. > > The error occurred while evaluating nil.<< > > > > If not, please post the error (good idea to do that in general). > > > > If so, this is fixed in trunk. Attached is a patch you can use to > > address it in your rails app (apply from vendor/plugins) > > > > Please let us know if this fixes the problem. > > > > Cheers, > > David > > > > > Boiled down the next routes problem in a helper spec ... using > with_routing > > it do > with_routing do |set| > > set.draw do |map| > map.resources :articles do |article| > article.resources :comments, :name_prefix => 'a_' do | > comment| > comment.resources :ratings, :name_prefix => 'a_c_' > end > end > end > > a_c_rating_path(@article, @comment, @rating).should == "/ > articles/1/comments/1/ratings/1" > > end > end > > This works fine in 1.05 and errors in 1.08 with the error: > > NoMethodError in 'CommentsHelper NO NAME (Because of Error raised in > matcher)' The NO NAME part is because you wrote 'it do' with no message passed to it. > You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.<< This looks like the same error - can you run just the file w/ this spec like this: spec path/to/file.rb -b That'll produce the full backtrace. Thanks > > Cheers > Shane > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From smingins at elctech.com Tue Sep 4 18:08:43 2007 From: smingins at elctech.com (Shane Mingins) Date: Wed, 5 Sep 2007 10:08:43 +1200 Subject: [rspec-users] 1.05 to 1.08 In-Reply-To: <57c63afe0709041500h27677e3dp4668127cd446c936@mail.gmail.com> References: <6A8E61FC-BCC7-4209-82F6-1E37AF6F8B34@elctech.com> <57c63afe0709032044w4ac1f29dt96b808e67e663b0f@mail.gmail.com> <57c63afe0709041500h27677e3dp4668127cd446c936@mail.gmail.com> Message-ID: On 5/09/2007, at 10:00 AM, David Chelimsky wrote: > This looks like the same error - can you run just the file w/ this > spec like this: > > spec path/to/file.rb -b > > That'll produce the full backtrace. > > Thanks Yeah it does look similar (I was reading the bug report last night) You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.<< /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/ helpers/prototype_helper.rb:538:in `<<' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/ helpers/prototype_helper.rb:695:in `initialize' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/ helpers/prototype_helper.rb:616:in `new' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/ helpers/prototype_helper.rb:616:in `method_missing' /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/matchers.rb: 159:in `method_missing' ./spec/helper/comments_helper_spec.rb:50: /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/test_process.rb:488:in `with_routing' ./spec/helper/comments_helper_spec.rb:37: /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/dsl/example.rb: 81:in `instance_eval' /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/dsl/example.rb: 81:in `run_example' /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/dsl/example.rb: 26:in `run' /opt/local/lib/ruby/1.8/timeout.rb:48:in `timeout' /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/dsl/example.rb: 24:in `run' /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/dsl/ behaviour.rb:81:in `run' /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/dsl/ behaviour.rb:75:in `each' /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/dsl/ behaviour.rb:75:in `run' /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/runner/ behaviour_runner.rb:58:in `run_behaviours' /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/runner/ behaviour_runner.rb:57:in `each' /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/runner/ behaviour_runner.rb:57:in `run_behaviours' /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/runner/ behaviour_runner.rb:21:in `run' /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/runner/ command_line.rb:17:in `run' /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/bin/spec:3: /opt/local/bin/spec:16:in `load' /opt/local/bin/spec:16: From dan at tastapod.com Tue Sep 4 18:36:22 2007 From: dan at tastapod.com (Dan North) Date: Tue, 04 Sep 2007 23:36:22 +0100 Subject: [rspec-users] Reason for _spec.rb convention In-Reply-To: <71B82737-3B32-44B2-98DD-26AC16AA830F@ashleymoran.me.uk> References: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> <57c63afe0709030705g5c20fac4u3f9aa147c8621447@mail.gmail.com> <810a540e0709030711o1b7b21c5i48719443ec290148@mail.gmail.com> <57c63afe0709030714o44802f17k8df5002e8e78e84a@mail.gmail.com> <810a540e0709030727o282b43det7674d1804dd12f53@mail.gmail.com> <57c63afe0709030737o6988b228wc66984e7704e95a0@mail.gmail.com> <71B82737-3B32-44B2-98DD-26AC16AA830F@ashleymoran.me.uk> Message-ID: <46DDDDE6.4020300@tastapod.com> Ashley Moran wrote: > On 3 Sep 2007, at 15:37, David Chelimsky wrote: > > >> But it is an interesting idea that we should stay open to. Perhaps >> more compelling reasons for such a change will appear in the future. >> > > > I like the sound of .spec in a way. It shortens the filenames which > is always a bonus for TM users. I can see the issue with file > associations, but it's easy enough to change these for TextMate. > (Although, allegedly, there are some Ruby developers that don't use > TextMate.) > > In favour of .spec, Rake has its own extension (.rake). You could > argue that RSpec is not much more tied to Ruby code than Rake is. > Ruby isn't the only language where BDD is being used. sheep_spec.rb says to me: this is a behaviour spec(ification) in Ruby for a sheep. SheepSpec.java or SheepSpec.cs says the same for Java or C-hash. If we come up with a programming language-independent way of representing specs, then I'm all for a .spec suffix. (Perhaps the specdoc descriptions might be something along those lines.) > Ashley Cheers, Dan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070904/c7641ef6/attachment-0001.html From luislavena at gmail.com Tue Sep 4 19:07:50 2007 From: luislavena at gmail.com (Luis Lavena) Date: Tue, 4 Sep 2007 20:07:50 -0300 Subject: [rspec-users] Failure Messages in RSpec In-Reply-To: <46DDD3D3.7060306@benmabey.com> References: <835d522e0709041351va41f1a3y8dc9c6fa92d05c96@mail.gmail.com> <57c63afe0709041400xbf2ba4dp19dae57ad80833b9@mail.gmail.com> <810a540e0709041423n19ca90d7p8a31d0c43ccf3f14@mail.gmail.com> <46DDD3D3.7060306@benmabey.com> Message-ID: <71166b3b0709041607y54224277j9b825c8e708bfc65@mail.gmail.com> On 9/4/07, Ben Mabey wrote: > Maybe this is what your thinking? > > http://opensoul.org/2007/4/18/rspec-model-should-be_valid > That should be the default matcher for be_valid... I use that and help me pinpoint some brittle specs (all related to new attributes added later in the development phase). As David himself said on that post: " Perfect use of custom matchers! Nice. Cheers, David " :-D -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From win at wincent.com Wed Sep 5 04:25:30 2007 From: win at wincent.com (Wincent Colaiuta) Date: Wed, 5 Sep 2007 10:25:30 +0200 Subject: [rspec-users] Failure Messages in RSpec In-Reply-To: <835d522e0709041351va41f1a3y8dc9c6fa92d05c96@mail.gmail.com> References: <835d522e0709041351va41f1a3y8dc9c6fa92d05c96@mail.gmail.com> Message-ID: <23CC96AA-7892-4984-A63F-7C1FA62D166C@wincent.com> El 4/9/2007, a las 22:51, Geoffrey Wiseman escribi?: > Using this as an example, if a new validation rule is added, this > test will > fail without indicating /why/. Sure, I can get that answer in > other ways, > but I'd hate to discover things like: > > it "should be valid with valid attributes" do > # puts @person.errors if !@person.valid > @person.should be_valid > end > > (Which I've seen when people have to repeatedly diagnose issues in > a test; > I'd prefer a failure message to the above) My personal approach when a spec fails and I can't figure out *why* just by looking at it is to run the spec under the debugger and set a breakpoint on the line where the corresponding spec fails. In this way I can get as much information as I want about the problem and its context. The suggestion of using a custom matcher is a good one, but I personally don't find it general enough. I actually *like* the way that RSpec doesn't provide a mechanism for specifying error messages; it's one of the things that makes the specs so easy to read. It's difficult to imagine a syntax that would provide what you're asking for without sacrificing readability. Cheers, Wincent From priit.tamboom at eesti.ee Wed Sep 5 05:58:07 2007 From: priit.tamboom at eesti.ee (Priit Tamboom) Date: Wed, 5 Sep 2007 17:58:07 +0800 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <42099B1D-978A-4C3C-A2E1-131AA1040A61@spicycode.com> <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> Message-ID: On 9/3/07, David Chelimsky wrote: > Hi all, > > I've talked this over w/ a couple of the other committers and we've > decided that we will NOT be deprecating the mock framework, at least > for the foreseeable future. If/when we do, it will happen with plenty > of notice and a clear, painless (as much as is possible) upgrade path. > > To be clear: this decision is purely pragmatic. Benefits of the > existing framework cited in this thread are significant (one-stop > shop, generated specs for the rails plugin, etc). And the amount of > work it would take to do it right (backwards compatibility, easy > upgrade path, support for multiple external frameworks, etc) far > exceeds the perceived cost of maintaining the existing framework. > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Very good news indeed, all thanks to rspec core! Priit at happy.nuby.rspecter From christoph.sturm at gmail.com Wed Sep 5 08:39:28 2007 From: christoph.sturm at gmail.com (Christoph Sturm) Date: Wed, 5 Sep 2007 14:39:28 +0200 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <42099B1D-978A-4C3C-A2E1-131AA1040A61@spicycode.com> <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> Message-ID: <11dae57c0709050539n504f02e1l540535cea523021c@mail.gmail.com> everybody in this thread is reacting like you are about to remove the built in mocking. The idea was to deprecate it, something like "if you use the build in mocking right now, fine. If you start a new project dont use it" One thing is clear, mocha is much nicer than the integrated mocking, nicer syntax, better errormessages, better everything. The rspec mocking framework could never compete with mocha or flexmock on its own. At the time it was created there were good reasons for that, just like there are good reasons to deprecate it now. No one should be forced to migrate an old project over to new mocks, but thats not what we are talking about. Maybe you should just keep the built in mocking, but recommend mocha for new projects, and start using mocha for the samples and generated specs. I recognize that some people like flexmock better, but having one recommended framework would make it much easier for people to get started. (It will almost feel like mocha was built in :P) It really feels strange to hear these complains about rspec not having everything built in, because the main complain for me and others about rspec was always that its too big and has its own mocking that you have to use. (This is fixed now and rspec plays very nice with mocha, great) regards christoph On 9/3/07, David Chelimsky wrote: > Hi all, > > I've talked this over w/ a couple of the other committers and we've > decided that we will NOT be deprecating the mock framework, at least > for the foreseeable future. If/when we do, it will happen with plenty > of notice and a clear, painless (as much as is possible) upgrade path. > > To be clear: this decision is purely pragmatic. Benefits of the > existing framework cited in this thread are significant (one-stop > shop, generated specs for the rails plugin, etc). And the amount of > work it would take to do it right (backwards compatibility, easy > upgrade path, support for multiple external frameworks, etc) far > exceeds the perceived cost of maintaining the existing framework. > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- christoph.sturm at gmail.com From ingo at ingoweiss.com Wed Sep 5 09:58:54 2007 From: ingo at ingoweiss.com (Ingo Weiss) Date: Wed, 5 Sep 2007 15:58:54 +0200 Subject: [rspec-users] response.should render_layout .... In-Reply-To: <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <42099B1D-978A-4C3C-A2E1-131AA1040A61@spicycode.com> <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> Message-ID: Hi, is there a way to assert in rspec that a template is rendered in a specific layout? Thanks! Ingo From work at ashleymoran.me.uk Wed Sep 5 10:05:24 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Wed, 5 Sep 2007 15:05:24 +0100 Subject: [rspec-users] Reason for _spec.rb convention In-Reply-To: <46DDDDE6.4020300@tastapod.com> References: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> <57c63afe0709030705g5c20fac4u3f9aa147c8621447@mail.gmail.com> <810a540e0709030711o1b7b21c5i48719443ec290148@mail.gmail.com> <57c63afe0709030714o44802f17k8df5002e8e78e84a@mail.gmail.com> <810a540e0709030727o282b43det7674d1804dd12f53@mail.gmail.com> <57c63afe0709030737o6988b228wc66984e7704e95a0@mail.gmail.com> <71B82737-3B32-44B2-98DD-26AC16AA830F@ashleymoran.me.uk> <46DDDDE6.4020300@tastapod.com> Message-ID: <2F721416-2A93-4B2D-9907-09AF282BBF52@ashleymoran.me.uk> On 4 Sep 2007, at 23:36, Dan North wrote: > If we come up with a programming language-independent way of > representing specs, then I'm all for a .spec suffix. (Perhaps the > specdoc descriptions might be something along those lines.) Good point. I did consider suggesting .rspec as an extention for that reason. Think I will stick to _spec.rb for now. From work at ashleymoran.me.uk Wed Sep 5 10:08:00 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Wed, 5 Sep 2007 15:08:00 +0100 Subject: [rspec-users] Reason for _spec.rb convention In-Reply-To: <46DDDDE6.4020300@tastapod.com> References: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> <57c63afe0709030705g5c20fac4u3f9aa147c8621447@mail.gmail.com> <810a540e0709030711o1b7b21c5i48719443ec290148@mail.gmail.com> <57c63afe0709030714o44802f17k8df5002e8e78e84a@mail.gmail.com> <810a540e0709030727o282b43det7674d1804dd12f53@mail.gmail.com> <57c63afe0709030737o6988b228wc66984e7704e95a0@mail.gmail.com> <71B82737-3B32-44B2-98DD-26AC16AA830F@ashleymoran.me.uk> <46DDDDE6.4020300@tastapod.com> Message-ID: <0CD9AB4C-6438-4FCE-891D-237E62CBC02F@ashleymoran.me.uk> On 4 Sep 2007, at 23:36, Dan North wrote: > C-hash I think you meant C-pound... From znmeb at cesmail.net Wed Sep 5 10:25:07 2007 From: znmeb at cesmail.net (M. Edward (Ed) Borasky) Date: Wed, 05 Sep 2007 07:25:07 -0700 Subject: [rspec-users] Reason for _spec.rb convention In-Reply-To: <0CD9AB4C-6438-4FCE-891D-237E62CBC02F@ashleymoran.me.uk> References: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> <57c63afe0709030705g5c20fac4u3f9aa147c8621447@mail.gmail.com> <810a540e0709030711o1b7b21c5i48719443ec290148@mail.gmail.com> <57c63afe0709030714o44802f17k8df5002e8e78e84a@mail.gmail.com> <810a540e0709030727o282b43det7674d1804dd12f53@mail.gmail.com> <57c63afe0709030737o6988b228wc66984e7704e95a0@mail.gmail.com> <71B82737-3B32-44B2-98DD-26AC16AA830F@ashleymoran.me.uk> <46DDDDE6.4020300@tastapod.com> <0CD9AB4C-6438-4FCE-891D-237E62CBC02F@ashleymoran.me.uk> Message-ID: <46DEBC43.2010300@cesmail.net> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ashley Moran wrote: > On 4 Sep 2007, at 23:36, Dan North wrote: > >> C-hash > > I think you meant C-pound... > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > No, #| (hash-pipe) #! (shebang) # aka ... octothorpe ... pound sign ... sharp ... number sign !!maxwellssilverhammer etc. ... -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFG3rxD8fKMegVjSM8RAuQWAKCBI7HxxpRpd5tTfHgv+0ovbIRXHACgklhE jTg8zGSBsT4zXNzGFEDUksY= =KITf -----END PGP SIGNATURE----- From jonathan at parkerhill.com Wed Sep 5 10:52:12 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Wed, 5 Sep 2007 10:52:12 -0400 Subject: [rspec-users] response.should render_layout .... In-Reply-To: References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <42099B1D-978A-4C3C-A2E1-131AA1040A61@spicycode.com> <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> Message-ID: Here's how I did it http://rubyforge.org/pipermail/rspec-users/2007-May/001818.html linoj On Sep 5, 2007, at 9:58 AM, Ingo Weiss wrote: > Hi, > > is there a way to assert in rspec that a template is rendered in a > specific layout? > > Thanks! > Ingo > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lancecarlson at gmail.com Wed Sep 5 11:07:35 2007 From: lancecarlson at gmail.com (Lance Carlson) Date: Wed, 5 Sep 2007 11:07:35 -0400 Subject: [rspec-users] response.should render_layout .... In-Reply-To: References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <42099B1D-978A-4C3C-A2E1-131AA1040A61@spicycode.com> <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> Message-ID: <49f64a900709050807w77c6878cub6cda34b8a590e39@mail.gmail.com> do you mean get :index response.should render_template(:index) ? On 9/5/07, Jonathan Linowes wrote: > Here's how I did it > > http://rubyforge.org/pipermail/rspec-users/2007-May/001818.html > > linoj > > > On Sep 5, 2007, at 9:58 AM, Ingo Weiss wrote: > > > Hi, > > > > is there a way to assert in rspec that a template is rendered in a > > specific layout? > > > > Thanks! > > Ingo > > _______________________________________________ > > 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 lancecarlson at gmail.com Wed Sep 5 11:09:08 2007 From: lancecarlson at gmail.com (Lance Carlson) Date: Wed, 5 Sep 2007 11:09:08 -0400 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <11dae57c0709050539n504f02e1l540535cea523021c@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <42099B1D-978A-4C3C-A2E1-131AA1040A61@spicycode.com> <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> <11dae57c0709050539n504f02e1l540535cea523021c@mail.gmail.com> Message-ID: <49f64a900709050809w3d8a9f80o9fe2d5432eed0574@mail.gmail.com> If core was to deprecate the included mocking framework, then why would they favor mocha over flexmock? I agree we need to have some agreement as to which one to use, but why the favoritism? On 9/5/07, Christoph Sturm wrote: > everybody in this thread is reacting like you are about to remove the > built in mocking. The idea was to deprecate it, something like > > "if you use the build in mocking right now, fine. If you start a new > project dont use it" > > One thing is clear, mocha is much nicer than the integrated mocking, > nicer syntax, better errormessages, better everything. The rspec > mocking framework could never compete with mocha or flexmock on its > own. At the time it was created there were good reasons for that, just > like there are good reasons to deprecate it now. > > No one should be forced to migrate an old project over to new mocks, > but thats not what we are talking about. > > Maybe you should just keep the built in mocking, but recommend mocha > for new projects, and start using mocha for the samples and generated > specs. > > I recognize that some people like flexmock better, but having one > recommended framework would make it much easier for people to get > started. (It will almost feel like mocha was built in :P) > > It really feels strange to hear these complains about rspec not having > everything built in, because the main complain for me and others about > rspec was always that its too big and has its own mocking that you > have to use. (This is fixed now and rspec plays very nice with mocha, > great) > > regards > christoph > On 9/3/07, David Chelimsky wrote: > > Hi all, > > > > I've talked this over w/ a couple of the other committers and we've > > decided that we will NOT be deprecating the mock framework, at least > > for the foreseeable future. If/when we do, it will happen with plenty > > of notice and a clear, painless (as much as is possible) upgrade path. > > > > To be clear: this decision is purely pragmatic. Benefits of the > > existing framework cited in this thread are significant (one-stop > > shop, generated specs for the rails plugin, etc). And the amount of > > work it would take to do it right (backwards compatibility, easy > > upgrade path, support for multiple external frameworks, etc) far > > exceeds the perceived cost of maintaining the existing framework. > > > > Cheers, > > David > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > -- > christoph.sturm at gmail.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists-rspec at shopwatch.org Wed Sep 5 12:31:12 2007 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Wed, 05 Sep 2007 12:31:12 -0400 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <49f64a900709050809w3d8a9f80o9fe2d5432eed0574@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <42099B1D-978A-4C3C-A2E1-131AA1040A61@spicycode.com> <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> <11dae57c0709050539n504f02e1l540535cea523021c@mail.gmail.com> <49f64a900709050809w3d8a9f80o9fe2d5432eed0574@mail.gmail.com> Message-ID: <46DED9D0.4080608@jay.fm> Lance Carlson wrote: > If core was to deprecate the included mocking framework, then why > would they favor mocha over flexmock? I agree we need to have some > agreement as to which one to use, but why the favoritism? If my grandmother had wheels, would she be a skateboard? They're not deprecating it.. we don't need to choose which one we would potentially hypothetically someday choose. Jay From geoffrey.wiseman at gmail.com Wed Sep 5 13:11:24 2007 From: geoffrey.wiseman at gmail.com (Geoffrey Wiseman) Date: Wed, 5 Sep 2007 13:11:24 -0400 Subject: [rspec-users] False Positives and Autotest on New Folders Message-ID: <835d522e0709051011j28d943bdy65f782af36822488@mail.gmail.com> False Positives I just discovered how easy it was to create a false positive when I, trying my first RSpec test, did this: ob.should eql?('foo') instead of: ob.should eql('foo') or: ob.should == 'foo' As far as I can see, this is roughly equivalent to: ob.should false Neither eql?('foo') nor false causes the spec to fail; this is worrisome, as I can imagine accidentally including that ? again; and I'd hate it to mask a test failure. Autotest Out of curiosity, does anyone know how to get autotest to pick up new folders under spec/? Seems like I might have to modify rails_rspec.rb in lib/autotest. We were considering separating our acceptance tests from the rest. - Geoffrey -- Geoffrey Wiseman -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070905/dd3f3b88/attachment.html From wilsonb at gmail.com Wed Sep 5 14:38:56 2007 From: wilsonb at gmail.com (Wilson Bilkovich) Date: Wed, 5 Sep 2007 14:38:56 -0400 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <9918842A-2A10-4620-9A07-8B0E3E465126@experthuman.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> Message-ID: On 9/2/07, David Chelimsky wrote: > On 9/2/07, Wilson Bilkovich wrote: > > On 9/1/07, rupert wrote: > > > > > > On 1 Sep 2007, at 10:04, Tom Stuart wrote: > > > > > > > On 1 Sep 2007, at 09:31, rupert wrote: > > > >>> Are we planning on dumping the mock framework in favor of using > > > >>> Mocha > > > >> The idea has been bandied around on the dev list recently > > > > This decision, if it is made in this manner, is suicide for RSpec. > > I simply don't understand this statement. Why is this such a big deal? > RSpec's mock framework offers pretty much ZERO over mocha or flexmock > - the only thing is that it saves you from typing 24 or 27 characters > in a config file, depending on your preference. 21 if you use RR. > > After that, the functionality is pretty much the same as the other frameworks. > > > I have been a huge RSpec booster, but this will make me drop it like a hot coal. > > Again - I can't understand where you're coming from here. If you start > using test/unit or test/spec or any of the other bdd frameworks you'll > still need to make a decision about a mock framework. > > What is the pain that you're perceiving that will come along w/ us > dumping the mock framework? Perhaps there's something we can do to > minimize that pain once we know what it is. > > Cheers, > David > > Hi David; While I see that later in the thread you have announced a good (correct, in my opinion) decision, I apologize for being too busy to get back and answer your question. I'll do so now, for posterity, even though it looks like the point is moot. RSpec is now an extremely 'rich' framework of tools. Sometimes that is a good thing, sometimes that is a drawback. I and, if I am overhearing a sane cross-section of folks in #caboose, quite a few others are willing to 'pay' the price of RSpec's complexity in exchange for the integrated, end-to-end experience. RSpec is definitely not the only library that supports 'describe' / 'it' / 'before', 'mock', etc these days. We wrote one for Rubinius, for example, because we weren't yet compatible enough with Ruby 1.8 to run RSpec itself, but we wanted to be able to write specs that would be RSpec-compatible. For me, at least, RSpec is on the edge of being too complex to trust, particularly when probably 95% of my existing specs would pass without modification under mini_rspec, which is currently 313 LOC. I don't mean this as a criticism.. it's simply that RSpec has decided (wisely) to be a 'full stack' BDD framework, and not just a way to execute expectations and print spec output. If RSpec 'splits', by removing mocking support, and I now have to think about which 'RSpec-like combo' a given project decided to use before diving in, that will probably push the cost/benefit ratio into the red for me. I hope I didn't sound like I was planning to boycott RSpec over this decision. It's simply that the vast majority of RSpec's value to me, as a user, lies in its integration. Regards, --Wilson. From wilsonb at gmail.com Wed Sep 5 14:50:37 2007 From: wilsonb at gmail.com (Wilson Bilkovich) Date: Wed, 5 Sep 2007 14:50:37 -0400 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <11dae57c0709050539n504f02e1l540535cea523021c@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <42099B1D-978A-4C3C-A2E1-131AA1040A61@spicycode.com> <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> <11dae57c0709050539n504f02e1l540535cea523021c@mail.gmail.com> Message-ID: On 9/5/07, Christoph Sturm wrote: > everybody in this thread is reacting like you are about to remove the > built in mocking. The idea was to deprecate it, something like > > "if you use the build in mocking right now, fine. If you start a new > project dont use it" > > One thing is clear, mocha is much nicer than the integrated mocking, > nicer syntax, better errormessages, better everything. The rspec > mocking framework could never compete with mocha or flexmock on its > own. At the time it was created there were good reasons for that, just > like there are good reasons to deprecate it now. > I would be 100% OK with this for version 1.1 or 1.2 or whatever, as long as Mocha was the only 'recommendation', and the rspec gem had a listed gem dependency on Mocha. It's the 'choice' I object to, not the specifics of which mock framework we happen to use. From srbaker at pobox.com Wed Sep 5 14:55:20 2007 From: srbaker at pobox.com (Steven R. Baker) Date: Wed, 05 Sep 2007 14:55:20 -0400 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <6E64948B-5A57-49D3-9F76-48FBF9864F56@rupespad.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <42099B1D-978A-4C3C-A2E1-131AA1040A61@spicycode.com> <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> <11dae57c0709050539n504f02e1l540535cea523021c@mail.gmail.com> Message-ID: <46DEFB98.3020209@pobox.com> Wilson Bilkovich wrote: > On 9/5/07, Christoph Sturm wrote: > >> everybody in this thread is reacting like you are about to remove the >> built in mocking. The idea was to deprecate it, something like >> >> "if you use the build in mocking right now, fine. If you start a new >> project dont use it" >> >> One thing is clear, mocha is much nicer than the integrated mocking, >> nicer syntax, better errormessages, better everything. The rspec >> mocking framework could never compete with mocha or flexmock on its >> own. At the time it was created there were good reasons for that, just >> like there are good reasons to deprecate it now. >> >> > > I would be 100% OK with this for version 1.1 or 1.2 or whatever, as > long as Mocha was the only 'recommendation', and the rspec gem had a > listed gem dependency on Mocha. > It's the 'choice' I object to, not the specifics of which mock > framework we happen to use. > To clarify, you just want a default mock framework, instead of being forced to make the decision yourself? I agree with this. I also object to the idea that people should evaluate mock frameworks to get started. We should set one of the existing ones as a default to relieve the maintenance burden. -Steven From wilsonb at gmail.com Wed Sep 5 15:07:29 2007 From: wilsonb at gmail.com (Wilson Bilkovich) Date: Wed, 5 Sep 2007 15:07:29 -0400 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <46DEFB98.3020209@pobox.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <42099B1D-978A-4C3C-A2E1-131AA1040A61@spicycode.com> <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> <11dae57c0709050539n504f02e1l540535cea523021c@mail.gmail.com> <46DEFB98.3020209@pobox.com> Message-ID: On 9/5/07, Steven R. Baker wrote: > Wilson Bilkovich wrote: > > On 9/5/07, Christoph Sturm wrote: > > > >> everybody in this thread is reacting like you are about to remove the > >> built in mocking. The idea was to deprecate it, something like > >> > >> "if you use the build in mocking right now, fine. If you start a new > >> project dont use it" > >> > >> One thing is clear, mocha is much nicer than the integrated mocking, > >> nicer syntax, better errormessages, better everything. The rspec > >> mocking framework could never compete with mocha or flexmock on its > >> own. At the time it was created there were good reasons for that, just > >> like there are good reasons to deprecate it now. > >> > >> > > > > I would be 100% OK with this for version 1.1 or 1.2 or whatever, as > > long as Mocha was the only 'recommendation', and the rspec gem had a > > listed gem dependency on Mocha. > > It's the 'choice' I object to, not the specifics of which mock > > framework we happen to use. > > > To clarify, you just want a default mock framework, instead of being > forced to make the decision yourself? > Yep. Just so. From sudara at modernthings.net Wed Sep 5 15:49:18 2007 From: sudara at modernthings.net (sudara) Date: Wed, 5 Sep 2007 12:49:18 -0700 (PDT) Subject: [rspec-users] Rspec Caveman questions. Message-ID: <12509678.post@talk.nabble.com> Hello! I'm just a caveman with some caveman questions. I've been parsing Rspec for quite a while, and I'm writing my first series of specs. My initial impressions are "Verbose, but understandable. Helpful and intuitive, but so much to digest." I want to congratulate the folks who are dedicating a chunk of their lives to writing this, and ask 2 caveman questions My first is "Why lambda in rpsec"? It doesn't strike me as "reads like english" or "easily understandable." I understand it's place in ruby (um, kind of :), but my thinking is: lambda { do_something_risky }.should raise_error would be more understandable (and fun!) written as: running { something_risky }.should raise_error My second question is: For those folks who are getting up to speed with ruby and rails AND digesting rspec along the way, there is a lot of incoming DSL. As I started with rails before rspec, I found myself using script/console to check my code, poking at different ways of expressing myself with ruby. Is there a way to "poke at my specs"? I can load up my test environment, but can I spec things "live" so that I can find out what works and what doesn't? I find I'm wasting a chunk of time (as I don't have the DSL even 60% down) writing specs and getting it wrong. Am I missing a trick, or I.should_have dsl_down_before_trying.else_return(crying)? um, thanks for any potential caveman responses - the more caveman (pragmatic) the better. sudara -- View this message in context: http://www.nabble.com/Rspec-Caveman-questions.-tf4387721.html#a12509678 Sent from the rspec-users mailing list archive at Nabble.com. From dchelimsky at gmail.com Wed Sep 5 15:53:47 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 5 Sep 2007 14:53:47 -0500 Subject: [rspec-users] False Positives and Autotest on New Folders In-Reply-To: <835d522e0709051011j28d943bdy65f782af36822488@mail.gmail.com> References: <835d522e0709051011j28d943bdy65f782af36822488@mail.gmail.com> Message-ID: <57c63afe0709051253i5a408cc0u53b72028bf5bb4b@mail.gmail.com> On 9/5/07, Geoffrey Wiseman wrote: > False Positives > I just discovered how easy it was to create a false positive when I, trying > my first RSpec test, did this: > ob.should eql?('foo') > instead of: > ob.should eql('foo') > or: > ob.should == 'foo' > > As far as I can see, this is roughly equivalent to: > ob.should false > > Neither eql?('foo') nor false causes the spec to fail; this is worrisome, as > I can imagine accidentally including that ? again; and I'd hate it to mask a > test failure. Please report bugs to http://rubyforge.org/tracker/index.php?group_id=797 > > Autotest > Out of curiosity, does anyone know how to get autotest to pick up new > folders under spec/? Seems like I might have to modify rails_rspec.rb in > lib/autotest. We were considering separating our acceptance tests from the > rest. > > - Geoffrey > -- > Geoffrey Wiseman > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Sep 5 15:54:55 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 5 Sep 2007 14:54:55 -0500 Subject: [rspec-users] False Positives and Autotest on New Folders In-Reply-To: <835d522e0709051011j28d943bdy65f782af36822488@mail.gmail.com> References: <835d522e0709051011j28d943bdy65f782af36822488@mail.gmail.com> Message-ID: <57c63afe0709051254y1680bb65p4d7953a3a1df6b10@mail.gmail.com> On 9/5/07, Geoffrey Wiseman wrote: > False Positives > I just discovered how easy it was to create a false positive when I, trying > my first RSpec test, did this: > ob.should eql?('foo') > instead of: > ob.should eql('foo') > or: > ob.should == 'foo' > > As far as I can see, this is roughly equivalent to: > ob.should false > > Neither eql?('foo') nor false causes the spec to fail; this is worrisome, as > I can imagine accidentally including that ? again; and I'd hate it to mask a > test failure. > > Autotest > Out of curiosity, does anyone know how to get autotest to pick up new > folders under spec/? Seems like I might have to modify rails_rspec.rb in > lib/autotest. We were considering separating our acceptance tests from the > rest. You could either modify rails_rspec.rb, or you could add a .autotest file in the project root and rewrite the mappings there. See autotests docs for how to do that (look for info on hooks). > > - Geoffrey > -- > Geoffrey Wiseman > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From smingins at elctech.com Wed Sep 5 17:22:40 2007 From: smingins at elctech.com (Shane Mingins) Date: Thu, 6 Sep 2007 09:22:40 +1200 Subject: [rspec-users] 1.05 to 1.08 In-Reply-To: <57c63afe0709041500h27677e3dp4668127cd446c936@mail.gmail.com> References: <6A8E61FC-BCC7-4209-82F6-1E37AF6F8B34@elctech.com> <57c63afe0709032044w4ac1f29dt96b808e67e663b0f@mail.gmail.com> <57c63afe0709041500h27677e3dp4668127cd446c936@mail.gmail.com> Message-ID: <26FAFBFB-41B5-4787-9D6E-020C78DBA15C@elctech.com> On 5/09/2007, at 10:00 AM, David Chelimsky wrote: >> Boiled down the next routes problem in a helper spec ... using >> with_routing >> >> it do >> with_routing do |set| >> >> set.draw do |map| >> map.resources :articles do |article| >> article.resources :comments, :name_prefix => 'a_' do | >> comment| >> comment.resources :ratings, :name_prefix => 'a_c_' >> end >> end >> end >> >> a_c_rating_path(@article, @comment, @rating).should == "/ >> articles/1/comments/1/ratings/1" >> >> end >> end >> >> This works fine in 1.05 and errors in 1.08 with the error: >> >> You have a nil object when you didn't expect it! >> You might have expected an instance of Array. >> The error occurred while evaluating nil.<< > > This looks like the same error - can you run just the file w/ this > spec like this: > > spec path/to/file.rb -b > > That'll produce the full backtrace. > > Thanks > >> Hi David I kept poking around but I cannot see why this is now not working .... not quite sure where the changes occurred in rspec that affected this but after using the with_routing method the example does not have access to the new routes (and still has the old ones). With the fix giving the helper spec access to the named_routes .... did anyone actually decide how this was broken in the first place? I was wondering how the helper specs had access to the named_routes previously? Should I add the bug on the projects tracker for this? Cheers Shane From dchelimsky at gmail.com Wed Sep 5 17:28:02 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 5 Sep 2007 16:28:02 -0500 Subject: [rspec-users] 1.05 to 1.08 In-Reply-To: <26FAFBFB-41B5-4787-9D6E-020C78DBA15C@elctech.com> References: <6A8E61FC-BCC7-4209-82F6-1E37AF6F8B34@elctech.com> <57c63afe0709032044w4ac1f29dt96b808e67e663b0f@mail.gmail.com> <57c63afe0709041500h27677e3dp4668127cd446c936@mail.gmail.com> <26FAFBFB-41B5-4787-9D6E-020C78DBA15C@elctech.com> Message-ID: <57c63afe0709051428m7fe56c78rea8e98b572ce1ea1@mail.gmail.com> On 9/5/07, Shane Mingins wrote: > > On 5/09/2007, at 10:00 AM, David Chelimsky wrote: > > >> Boiled down the next routes problem in a helper spec ... using > >> with_routing > >> > >> it do > >> with_routing do |set| > >> > >> set.draw do |map| > >> map.resources :articles do |article| > >> article.resources :comments, :name_prefix => 'a_' do | > >> comment| > >> comment.resources :ratings, :name_prefix => 'a_c_' > >> end > >> end > >> end > >> > >> a_c_rating_path(@article, @comment, @rating).should == "/ > >> articles/1/comments/1/ratings/1" > >> > >> end > >> end > >> > >> This works fine in 1.05 and errors in 1.08 with the error: > >> > >> You have a nil object when you didn't expect it! > >> You might have expected an instance of Array. > >> The error occurred while evaluating nil.<< > > > > This looks like the same error - can you run just the file w/ this > > spec like this: > > > > spec path/to/file.rb -b > > > > That'll produce the full backtrace. > > > > Thanks > > > >> > > > Hi David > > I kept poking around but I cannot see why this is now not > working .... not quite sure where the changes occurred in rspec that > affected this but after using the with_routing method the example > does not have access to the new routes (and still has the old ones). > > With the fix giving the helper spec access to the named_routes .... > did anyone actually decide how this was broken in the first place? I > was wondering how the helper specs had access to the named_routes > previously? > > Should I add the bug on the projects tracker for this? Please. > > Cheers > Shane > > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tor.norbye at sun.com Wed Sep 5 19:05:53 2007 From: tor.norbye at sun.com (Tor Norbye) Date: Wed, 05 Sep 2007 16:05:53 -0700 Subject: [rspec-users] Content assist for spec files Message-ID: <16E87D1B-9B13-4FB2-A905-A07AB0AB736D@sun.com> Hi there, I'm working on Ruby support for NetBeans, and we're bundling RSpec (along with JRuby). One thing I'd really like to fix is having content assist (code completion / intellisense / code insight, it has many names) work inside your spec files such that you can not only hit ctrl-space and see "describe", "before", "it" etc. but also see the documentation for these methods. The problem is that when I'm looking at a spec file, there are no require-statements. Obviously, the methods I see called in the spec files must be defined by the test runner itself before running the spec file. Can somebody enlighten me as to what that context looks like? (As an example, in Ruby on Rails "view" files, I treat the file as if it's extending ActionView::Base, so all the methods on that class (and included modules and such) all become available as methods you can call from the view. I was wondering if there was a similar class, or set of Modules, that I can use to simulate the context for the code inside the _spec.rb file.) -- Tor From bryan at osesm.com Wed Sep 5 20:10:29 2007 From: bryan at osesm.com (Bryan Liles) Date: Wed, 5 Sep 2007 20:10:29 -0400 Subject: [rspec-users] Content assist for spec files In-Reply-To: <16E87D1B-9B13-4FB2-A905-A07AB0AB736D@sun.com> References: <16E87D1B-9B13-4FB2-A905-A07AB0AB736D@sun.com> Message-ID: <86356787-4D8E-4A03-AC31-91A173F8D6BE@osesm.com> On Sep 5, 2007, at 7:05 PM, Tor Norbye wrote: > > The problem is that when I'm looking at a spec file, there are no > require-statements. Obviously, the methods I see called in the spec > files must be defined by the test runner itself before running the > spec file. > > Can somebody enlighten me as to what that context looks like? > > (As an example, in Ruby on Rails "view" files, I treat the file as if > it's extending ActionView::Base, so all the methods on that class > (and included modules and such) all become available as methods you > can call from the view. I was wondering if there was a similar class, > or set of Modules, that I can use to simulate the context for the > code inside the _spec.rb file.) > Hello Tor. At the top of my spec files is: require File.dirname(__FILE__) + '/../spec_helper' (At least in my Rails specs) bryanl http://smartic.us From sudara at modernthings.net Wed Sep 5 10:20:55 2007 From: sudara at modernthings.net (sudara) Date: Wed, 5 Sep 2007 07:20:55 -0700 (PDT) Subject: [rspec-users] Caveman Questions Message-ID: <12498949.post@talk.nabble.com> Hello! I'm just a caveman with some caveman questions. I've been parsing Rspec for quite a while, and I'm writing my first series of specs. My initial impressions are "Verbose, but understandable. Helpful and intuitive, but so much to digest." I want to congratulate the folks who are dedicating a chunk of their lives to writing this, and ask 2 caveman questions My first is "Why lambda in rpsec"? It doesn't strike me as "reads like english" or "easily understandable." I understand it's place in ruby (um, kind of :), but my thinking is: lambda { do_something_risky }.should raise_error would be more understandable (and fun!) written as: running { something_risky }.should raise_error My second question is: For those folks who are getting up to speed with ruby and rails AND digesting rspec along the way, there is a lot of incoming DSL. As I started with rails before rspec, I found myself using script/console to check my code, poking at different ways of expressing myself with ruby. Is there a way to "poke at my specs"? I can load up my test environment, but can I spec things "live" so that I can find out what works and what doesn't? I find I'm wasting a chunk of time (as I don't have the DSL even 60% down) writing specs and getting it wrong. Am I missing a trick, or I.should_have dsl_down_before_trying.else_return(crying)? um, thanks for any potential caveman responses - the more caveman (pragmatic) the better. sudara -- View this message in context: http://www.nabble.com/Caveman-Questions-tf4384357.html#a12498949 Sent from the rspec-users mailing list archive at Nabble.com. From dchelimsky at gmail.com Wed Sep 5 20:31:49 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 5 Sep 2007 19:31:49 -0500 Subject: [rspec-users] Caveman Questions In-Reply-To: <12498949.post@talk.nabble.com> References: <12498949.post@talk.nabble.com> Message-ID: <57c63afe0709051731we0e1dabyb638301c7a1e12ba@mail.gmail.com> On 9/5/07, sudara wrote: > > Hello! > > I'm just a caveman with some caveman questions. > > I've been parsing Rspec for quite a while, and I'm writing my first series > of specs. My initial impressions are "Verbose, but understandable. Helpful > and intuitive, but so much to digest." I want to congratulate the folks who > are dedicating a chunk of their lives to writing this, and ask 2 caveman > questions > > My first is "Why lambda in rpsec"? It doesn't strike me as "reads like > english" or "easily understandable." I understand it's place in ruby (um, > kind of :), but my thinking is: > > lambda { do_something_risky }.should raise_error > > would be more understandable (and fun!) written as: > > running { something_risky }.should raise_error That's a great idea. Why don't you add it to the tracker: http://rubyforge.org/tracker/index.php?group_id=797 > > My second question is: For those folks who are getting up to speed with ruby > and rails AND digesting rspec along the way, there is a lot of incoming DSL. > As I started with rails before rspec, I found myself using script/console to > check my code, poking at different ways of expressing myself with ruby. > > Is there a way to "poke at my specs"? I can load up my test environment, but > can I spec things "live" so that I can find out what works and what doesn't? > I find I'm wasting a chunk of time (as I don't have the DSL even 60% down) > writing specs and getting it wrong. Am I missing a trick, or I.should_have > dsl_down_before_trying.else_return(crying)? irb(main):001:0> require 'rubygems' => true irb(main):002:0> require 'spec' => true irb(main):003:0> include Spec::Matchers => Object irb(main):004:0> 5.should == 5 => nil irb(main):005:0> 5.should be < 4 Spec::Expectations::ExpectationNotMetError: expected < 4, got 5 Cheers, David > > um, thanks for any potential caveman responses - the more caveman > (pragmatic) the better. > > sudara > > > -- > View this message in context: http://www.nabble.com/Caveman-Questions-tf4384357.html#a12498949 > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From christoph.sturm at gmail.com Thu Sep 6 08:45:22 2007 From: christoph.sturm at gmail.com (Christoph Sturm) Date: Thu, 6 Sep 2007 14:45:22 +0200 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <46DEFB98.3020209@pobox.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <57c63afe0709020955u4d63d43fha984929a7a0c93b2@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <42099B1D-978A-4C3C-A2E1-131AA1040A61@spicycode.com> <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> <11dae57c0709050539n504f02e1l540535cea523021c@mail.gmail.com> <46DEFB98.3020209@pobox.com> Message-ID: <11dae57c0709060545h602c4004n297a2fc1693925e3@mail.gmail.com> On 9/5/07, Steven R. Baker wrote: > Wilson Bilkovich wrote: > > On 9/5/07, Christoph Sturm wrote: > >> One thing is clear, mocha is much nicer than the integrated mocking, > >> nicer syntax, better errormessages, better everything. The rspec > >> mocking framework could never compete with mocha or flexmock on its > >> own. At the time it was created there were good reasons for that, just > >> like there are good reasons to deprecate it now. > >> > >> > > > > I would be 100% OK with this for version 1.1 or 1.2 or whatever, as > > long as Mocha was the only 'recommendation', and the rspec gem had a > > listed gem dependency on Mocha. > > It's the 'choice' I object to, not the specifics of which mock > > framework we happen to use. > > > To clarify, you just want a default mock framework, instead of being > forced to make the decision yourself? > Ok, I am in no way saying anything against flexmock, Its probably great, but I never tried it. What I tried was rspec mocking and mocha, and I liked mocha much better. And I do think there should be a default, for the generated code. regards chris From chrisdpratt at gmail.com Thu Sep 6 09:23:58 2007 From: chrisdpratt at gmail.com (Christopher D. Pratt) Date: Thu, 6 Sep 2007 08:23:58 -0500 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <11dae57c0709060545h602c4004n297a2fc1693925e3@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <26853B78-59DA-4EE7-83DE-68D5C3400AD1@railsnewbie.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <42099B1D-978A-4C3C-A2E1-131AA1040A61@spicycode.com> <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> <11dae57c0709050539n504f02e1l540535cea523021c@mail.gmail.com> <46DEFB98.3020209@pobox.com> <11dae57c0709060545h602c4004n297a2fc1693925e3@mail.gmail.com> Message-ID: <79a30c430709060623h52a11b82p175f69f5e4342004@mail.gmail.com> What's the rationale behind removing the integrated mocking framework? Can you not still use Mocha or FlexMock or whatever else you'd like to use still? Meanwhile, the integrated mocking framework in RSpec provides a ready and able mocking framework for anyone just starting out with RSpec. In my experience, people are more apt to begin to use a new thing if it's already there waiting for them. Chris Pratt On 9/6/07, Christoph Sturm wrote: > > On 9/5/07, Steven R. Baker wrote: > > Wilson Bilkovich wrote: > > > On 9/5/07, Christoph Sturm wrote: > > >> One thing is clear, mocha is much nicer than the integrated mocking, > > >> nicer syntax, better errormessages, better everything. The rspec > > >> mocking framework could never compete with mocha or flexmock on its > > >> own. At the time it was created there were good reasons for that, > just > > >> like there are good reasons to deprecate it now. > > >> > > >> > > > > > > I would be 100% OK with this for version 1.1 or 1.2 or whatever, as > > > long as Mocha was the only 'recommendation', and the rspec gem had a > > > listed gem dependency on Mocha. > > > It's the 'choice' I object to, not the specifics of which mock > > > framework we happen to use. > > > > > To clarify, you just want a default mock framework, instead of being > > forced to make the decision yourself? > > > > Ok, I am in no way saying anything against flexmock, Its probably > great, but I never tried it. What I tried was rspec mocking and mocha, > and I liked mocha much better. > > And I do think there should be a default, for the generated code. > > regards > chris > _______________________________________________ > 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/20070906/635bfc17/attachment-0001.html From christoph.sturm at gmail.com Thu Sep 6 11:14:28 2007 From: christoph.sturm at gmail.com (Christoph Sturm) Date: Thu, 6 Sep 2007 17:14:28 +0200 Subject: [rspec-users] Deprecating the mocking framework? In-Reply-To: <79a30c430709060623h52a11b82p175f69f5e4342004@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <42099B1D-978A-4C3C-A2E1-131AA1040A61@spicycode.com> <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> <11dae57c0709050539n504f02e1l540535cea523021c@mail.gmail.com> <46DEFB98.3020209@pobox.com> <11dae57c0709060545h602c4004n297a2fc1693925e3@mail.gmail.com> <79a30c430709060623h52a11b82p175f69f5e4342004@mail.gmail.com> Message-ID: <11dae57c0709060814q6e97d75j83712bedfef0151b@mail.gmail.com> I think bundling/recommending/depending on a mock framework gives you the same comfort and saves a lot of development time :D -chris On 9/6/07, Christopher D. Pratt wrote: > What's the rationale behind removing the integrated mocking framework? Can > you not still use Mocha or FlexMock or whatever else you'd like to use > still? Meanwhile, the integrated mocking framework in RSpec provides a ready > and able mocking framework for anyone just starting out with RSpec. In my > experience, people are more apt to begin to use a new thing if it's already > there waiting for them. > > Chris Pratt > > > On 9/6/07, Christoph Sturm wrote: > > > > On 9/5/07, Steven R. Baker wrote: > > > Wilson Bilkovich wrote: > > > > On 9/5/07, Christoph Sturm wrote: > > > >> One thing is clear, mocha is much nicer than the integrated mocking, > > > >> nicer syntax, better errormessages, better everything. The rspec > > > >> mocking framework could never compete with mocha or flexmock on its > > > >> own. At the time it was created there were good reasons for that, > just > > > >> like there are good reasons to deprecate it now. > > > >> > > > >> > > > > > > > > I would be 100% OK with this for version 1.1 or 1.2 or whatever, as > > > > long as Mocha was the only 'recommendation', and the rspec gem had a > > > > listed gem dependency on Mocha. > > > > It's the 'choice' I object to, not the specifics of which mock > > > > framework we happen to use. > > > > > > > To clarify, you just want a default mock framework, instead of being > > > forced to make the decision yourself? > > > > > > > Ok, I am in no way saying anything against flexmock, Its probably > > great, but I never tried it. What I tried was rspec mocking and mocha, > > and I liked mocha much better. > > > > And I do think there should be a default, for the generated code. > > > > regards > > chris > > _______________________________________________ > > 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 > -- christoph.sturm at gmail.com From ingo at ingoweiss.com Thu Sep 6 11:32:42 2007 From: ingo at ingoweiss.com (Ingo Weiss) Date: Thu, 6 Sep 2007 17:32:42 +0200 Subject: [rspec-users] stubbing out helper method in helper spec In-Reply-To: <11dae57c0709060814q6e97d75j83712bedfef0151b@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <85d99afe0709022108s33017e53k1ff49aa80b253fd2@mail.gmail.com> <42099B1D-978A-4C3C-A2E1-131AA1040A61@spicycode.com> <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> <11dae57c0709050539n504f02e1l540535cea523021c@mail.gmail.com> <46DEFB98.3020209@pobox.com> <11dae57c0709060545h602c4004n297a2fc1693925e3@mail.gmail.com> <79a30c430709060623h52a11b82p175f69f5e4342004@mail.gmail.com> <11dae57c0709060814q6e97d75j83712bedfef0151b@mail.gmail.com> Message-ID: Hi, I am stuck with a problem in my helper specs. Say I have a helper with two methods, method1 and method2, where method2 is calling method1 internally. How can I stub out method1 when testing method2? I guess it boils down to how I can access the helper object from within a helper spec. it 'should behave_correctly' do ???.stub!(:method1).and_return('mock') method2.should eql('...') end Thanks! Ingo From dchelimsky at gmail.com Thu Sep 6 11:40:08 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 6 Sep 2007 10:40:08 -0500 Subject: [rspec-users] stubbing out helper method in helper spec In-Reply-To: References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <42099B1D-978A-4C3C-A2E1-131AA1040A61@spicycode.com> <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> <11dae57c0709050539n504f02e1l540535cea523021c@mail.gmail.com> <46DEFB98.3020209@pobox.com> <11dae57c0709060545h602c4004n297a2fc1693925e3@mail.gmail.com> <79a30c430709060623h52a11b82p175f69f5e4342004@mail.gmail.com> <11dae57c0709060814q6e97d75j83712bedfef0151b@mail.gmail.com> Message-ID: <57c63afe0709060840h75c033f9yde8cf9bf5077d4d5@mail.gmail.com> On 9/6/07, Ingo Weiss wrote: > Hi, > > I am stuck with a problem in my helper specs. Say I have a helper > with two methods, method1 and method2, where method2 is calling > method1 internally. How can I stub out method1 when testing method2? > I guess it boils down to how I can access the helper object from > within a helper spec. > > it 'should behave_correctly' do > ???.stub!(:method1).and_return('mock') > method2.should eql('...') > end 2 schools of thought: it "should behave correctly" do self.should_receive(:method1).with('foo').and_return(whatever) method2('foo') end The other is don't mock the call. Just spec the behaviour of method1 as though it does everything. Deciding between these two approaches is where the art of mocking lies - when to do it, when not to. In the end, it depends on a lot of factors, but the overriding factor should be the answer to "what is the simplest way I can get stuff done?" I'm sure that's not at all helpful :) Cheers, David > > Thanks! > Ingo > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ingo at ingoweiss.com Thu Sep 6 12:07:18 2007 From: ingo at ingoweiss.com (Ingo Weiss) Date: Thu, 6 Sep 2007 18:07:18 +0200 Subject: [rspec-users] stubbing out helper method in helper spec In-Reply-To: <57c63afe0709060840h75c033f9yde8cf9bf5077d4d5@mail.gmail.com> References: <810a540e0708311617r7a85a9d8wf013add5f3647f10@mail.gmail.com> <42099B1D-978A-4C3C-A2E1-131AA1040A61@spicycode.com> <57c63afe0709030842r100926f7mc5e3fcb020a253bb@mail.gmail.com> <11dae57c0709050539n504f02e1l540535cea523021c@mail.gmail.com> <46DEFB98.3020209@pobox.com> <11dae57c0709060545h602c4004n297a2fc1693925e3@mail.gmail.com> <79a30c430709060623h52a11b82p175f69f5e4342004@mail.gmail.com> <11dae57c0709060814q6e97d75j83712bedfef0151b@mail.gmail.com> <57c63afe0709060840h75c033f9yde8cf9bf5077d4d5@mail.gmail.com> Message-ID: Thanks David, in this case stubbing out method1 helped me a lot with focusing on what I want to test, without being distracted by having to follow down the call stack Ingo On Sep 6, 2007, at 5:40 PM, David Chelimsky wrote: > On 9/6/07, Ingo Weiss wrote: >> Hi, >> >> I am stuck with a problem in my helper specs. Say I have a helper >> with two methods, method1 and method2, where method2 is calling >> method1 internally. How can I stub out method1 when testing method2? >> I guess it boils down to how I can access the helper object from >> within a helper spec. >> >> it 'should behave_correctly' do >> ???.stub!(:method1).and_return('mock') >> method2.should eql('...') >> end > > 2 schools of thought: > > it "should behave correctly" do > self.should_receive(:method1).with('foo').and_return(whatever) > method2('foo') > end > > The other is don't mock the call. Just spec the behaviour of method1 > as though it does everything. > > Deciding between these two approaches is where the art of mocking lies > - when to do it, when not to. In the end, it depends on a lot of > factors, but the overriding factor should be the answer to "what is > the simplest way I can get stuff done?" > > I'm sure that's not at all helpful :) > > Cheers, > David > >> >> Thanks! >> Ingo >> >> >> _______________________________________________ >> 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 geoffrey.wiseman at gmail.com Thu Sep 6 21:01:30 2007 From: geoffrey.wiseman at gmail.com (Geoffrey Wiseman) Date: Thu, 6 Sep 2007 21:01:30 -0400 Subject: [rspec-users] Content assist for spec files In-Reply-To: <16E87D1B-9B13-4FB2-A905-A07AB0AB736D@sun.com> References: <16E87D1B-9B13-4FB2-A905-A07AB0AB736D@sun.com> Message-ID: <835d522e0709061801l3f0e7474p33c2cc76be516cfb@mail.gmail.com> On 9/5/07, Tor Norbye wrote: > > I'm working on Ruby support for NetBeans, and we're bundling RSpec > (along with JRuby). Would be pleased to try NB/Ruby again once the RSpec support is in there; any idea which milestone would contain this? -- Geoffrey Wiseman -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070906/32a2f404/attachment.html From lists-rspec at shopwatch.org Thu Sep 6 23:36:41 2007 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Thu, 06 Sep 2007 23:36:41 -0400 Subject: [rspec-users] testing behaviour or testing code? In-Reply-To: <57c63afe0709022049m36acf1ebqee936361a5c9981c@mail.gmail.com> References: <12309322.post@talk.nabble.com> <57c63afe0708240659y1ea3668qc2065333f199a7bb@mail.gmail.com> <810a540e0708241006m23118ed7k9248705c13c2678a@mail.gmail.com> <57c63afe0708241012o6c5bf76bib536656bf69ee323@mail.gmail.com> <810a540e0709012345t5aba354ai6f2f7414fe5a5ea@mail.gmail.com> <57c63afe0709020056y26081df7labe53761f20fa90a@mail.gmail.com> <810a540e0709020232g1a8bc555h129dbbbc0be5d6a7@mail.gmail.com> <57c63afe0709020943o1a9e4783x65390eb7ad44c87a@mail.gmail.com> <46DB35DD.2040701@shopwatch.org> <57c63afe0709022049m36acf1ebqee936361a5c9981c@mail.gmail.com> Message-ID: <46E0C749.5080706@shopwatch.org> On 9/2/2007 11:49 PM, David Chelimsky wrote: > On 9/2/07, Jay Levitt wrote: >> On 9/2/2007 12:43 PM, David Chelimsky wrote: >>> The problem we face is that AR promises huge productivity gains for >>> the non TDD-er, and challenges the thinking of the die-hard TDD-er. >>> >>> I've gone back and forth about whether it's OK to test validations like this: >>> >>> it "should validate_presence_of digits" do >>> PhoneNumber.expects(:validates_presence_of).with(:digits) >>> load "#{RAILS_ROOT}/app/models/phone_number.rb" >>> end >>> >>> On the one hand, it looks immediately like we're testing >>> implementation. On the other, we're not really - we're mocking a call >>> to an API. The confusion is that the API is represented in the same >>> object as the one we're testing (at least its class object). I haven't >>> really done this in anger yet, but I'm starting to think it's the >>> right way to go - especially now that we have Story Runner to cover >>> things end to end. WDYT of this approach? >> Personally, I don't much like it. It feels too much like: >> >> it "should validate_presence_of digits" do >> my_model.line(7).should_read "validates_presence_of :digits" >> end > A couple of things to consider: > > There's a very useful guideline in TDD that says "test YOUR code, not > everyone elses." The validation library we're testing here is > ActiveRecord's. It's already tested (we hope!). Right... and I'm not testing that ActiveRecord's validation works. I'm testing that my model works as I expect it to work. For instance, in your example, you just verify that you call validates_presence_of with fieldname :digits. You're not verifying that that's the right thing to do, or that it behaves the way you expect it to. Also, I think this conflicts with "test behavior, not implementation". All I care about is the behavior of the model; I don't care if it calls validates_presence_of, or if it calls acts_as_phone_number. > Also - there's a difference between the behaviour of a system and the > behaviour of an object. The system's job is to validate that the phone > number is all digits. So it makes sense to have examples like that in > high level examples using Story Runner, rails integration tests, or an > in-browser suite like Selenium or Watir. Ah, but (as Pat pointed out) in Rails, validations are, in fact, the job of the model. They may be done with validates_* "declarations", or with custom code, or with plugins. > This model object's job is to make sure the input gets validated, not > to actually validate it. If the model made a more OO-feeling call out > to a message library - something like this: > > class PhoneNumber > def validators > @validators ||= [] > end > > def add_validator (validator) > validators << validator > end > > def validate(input) > validators.each {|v| v.validate (input)} > end > end > > Then submitting mock validators via add_validator and setting mock > expectations that they get called would be totally par for the course. Yeah, and I guess I still haven't swallowed that part of mocking - because, again, it's brittle and tied to implementation. I have no problem mocking out ActiveRecord, because that's a major part of any Rails app and it's a given that you'll be using it in a certain way. Ditto for any other major library. But validations are so simplistic that you might write a given validation in five different ways, and specifying -which- of those five ways the code should use just feels wrong. And even for AR, as someone pointed out - what if I want to use .new or .build instead of .create, or .update_attributes instead of the setter function? The ideal answer for that is to build a more sophisticated AR mock that lets you write expectations that work in any of those cases. I want to know that User.register.should do_something_that_creates_a_new_record, not that it explicitly called .create. And interestingly, in the case of .update_attributes vs. direct assignment, it seems to me that the proper way to "test the behavior, not the implementation" is to check the value of the field after the fact - which of course apparently conflicts with "test behavior, not state". But, when the behavior IS to set a certain state, I feel like it's OK. Jay From dan at tastapod.com Fri Sep 7 08:28:05 2007 From: dan at tastapod.com (Dan North) Date: Fri, 07 Sep 2007 13:28:05 +0100 Subject: [rspec-users] Content assist for spec files In-Reply-To: <835d522e0709061801l3f0e7474p33c2cc76be516cfb@mail.gmail.com> References: <16E87D1B-9B13-4FB2-A905-A07AB0AB736D@sun.com> <835d522e0709061801l3f0e7474p33c2cc76be516cfb@mail.gmail.com> Message-ID: <46E143D5.3050704@tastapod.com> I'd like to try it too. I'd like an ide with half-decent ruby refactoring support. Geoffrey Wiseman wrote: > On 9/5/07, *Tor Norbye* > wrote: > > I'm working on Ruby support for NetBeans, and we're bundling RSpec > (along with JRuby). > > > Would be pleased to try NB/Ruby again once the RSpec support is in > there; any idea which milestone would contain this? > > -- > Geoffrey Wiseman > ------------------------------------------------------------------------ > > _______________________________________________ > 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/20070907/77170800/attachment.html From win at wincent.com Fri Sep 7 10:24:26 2007 From: win at wincent.com (Wincent Colaiuta) Date: Fri, 7 Sep 2007 16:24:26 +0200 Subject: [rspec-users] testing behaviour or testing code? In-Reply-To: <46E0C749.5080706@shopwatch.org> References: <12309322.post@talk.nabble.com> <57c63afe0708240659y1ea3668qc2065333f199a7bb@mail.gmail.com> <810a540e0708241006m23118ed7k9248705c13c2678a@mail.gmail.com> <57c63afe0708241012o6c5bf76bib536656bf69ee323@mail.gmail.com> <810a540e0709012345t5aba354ai6f2f7414fe5a5ea@mail.gmail.com> <57c63afe0709020056y26081df7labe53761f20fa90a@mail.gmail.com> <810a540e0709020232g1a8bc555h129dbbbc0be5d6a7@mail.gmail.com> <57c63afe0709020943o1a9e4783x65390eb7ad44c87a@mail.gmail.com> <46DB35DD.2040701@shopwatch.org> <57c63afe0709022049m36acf1ebqee936361a5c9981c@mail.gmail.com> <46E0C749.5080706@shopwatch.org> Message-ID: <4CD1DD3A-BEFB-4645-A838-1F655766193C@wincent.com> El 7/9/2007, a las 5:36, Jay Levitt escribi?: >> There's a very useful guideline in TDD that says "test YOUR code, not >> everyone elses." The validation library we're testing here is >> ActiveRecord's. It's already tested (we hope!). > > Right... and I'm not testing that ActiveRecord's validation works. > I'm > testing that my model works as I expect it to work. > > For instance, in your example, you just verify that you call > validates_presence_of with fieldname :digits. You're not verifying > that > that's the right thing to do, or that it behaves the way you expect > it to. > > Also, I think this conflicts with "test behavior, not implementation". > All I care about is the behavior of the model; I don't care if it > calls > validates_presence_of, or if it calls acts_as_phone_number. Very true that you shouldn't be testing ActiveRecord's validation (Rails' own unit tests are there for that). But if you want to do truly *driven* BDD then you will have to test something; in other words, *before* you go ahead and add this line to your model: validates_presence_of :foo You need to write a failing spec for it first. Otherwise, why would you write it? Doing BDD in its purest form you shouldn't be writing *any* line of code without your specs driving it. This means the familiar "write failing spec, write code, confirm working spec" cycle. So the question is, what is the best kind of spec to write to *drive* the writing of your "validates_presence_of" lines? For some validations it's quite easy. For others it is less straightforward. There are probably multiple valid (or valid-ish) answers, but it's sometimes difficult to know which one is best. Cheers, Wincent From drichards at showcase60.com Fri Sep 7 10:52:38 2007 From: drichards at showcase60.com (David Richards) Date: Fri, 7 Sep 2007 08:52:38 -0600 Subject: [rspec-users] testing behaviour or testing code? In-Reply-To: <4CD1DD3A-BEFB-4645-A838-1F655766193C@wincent.com> References: <12309322.post@talk.nabble.com> <57c63afe0708240659y1ea3668qc2065333f199a7bb@mail.gmail.com> <810a540e0708241006m23118ed7k9248705c13c2678a@mail.gmail.com> <57c63afe0708241012o6c5bf76bib536656bf69ee323@mail.gmail.com> <810a540e0709012345t5aba354ai6f2f7414fe5a5ea@mail.gmail.com> <57c63afe0709020056y26081df7labe53761f20fa90a@mail.gmail.com> <810a540e0709020232g1a8bc555h129dbbbc0be5d6a7@mail.gmail.com> <57c63afe0709020943o1a9e4783x65390eb7ad44c87a@mail.gmail.com> <46DB35DD.2040701@shopwatch.org> <57c63afe0709022049m36acf1ebqee936361a5c9981c@mail.gmail.com> <46E0C749.5080706@shopwatch.org> <4CD1DD3A-BEFB-4645-A838-1F655766193C@wincent.com> Message-ID: <26049668-1E83-4E77-BB73-1C65478B1BB6@showcase60.com> On Sep 7, 2007, at 8:24 AM, Wincent Colaiuta wrote: > El 7/9/2007, a las 5:36, Jay Levitt escribi?: > >>> There's a very useful guideline in TDD that says "test YOUR code, >>> not >>> everyone elses." The validation library we're testing here is >>> ActiveRecord's. It's already tested (we hope!). >> >> Right... and I'm not testing that ActiveRecord's validation works. >> I'm >> testing that my model works as I expect it to work. >> >> For instance, in your example, you just verify that you call >> validates_presence_of with fieldname :digits. You're not verifying >> that >> that's the right thing to do, or that it behaves the way you expect >> it to. >> >> Also, I think this conflicts with "test behavior, not >> implementation". >> All I care about is the behavior of the model; I don't care if it >> calls >> validates_presence_of, or if it calls acts_as_phone_number. > > Very true that you shouldn't be testing ActiveRecord's validation > (Rails' own unit tests are there for that). > > But if you want to do truly *driven* BDD then you will have to test > something; in other words, *before* you go ahead and add this line to > your model: > > validates_presence_of :foo > > You need to write a failing spec for it first. Otherwise, why would > you write it? Doing BDD in its purest form you shouldn't be writing > *any* line of code without your specs driving it. This means the > familiar "write failing spec, write code, confirm working spec" cycle. > > So the question is, what is the best kind of spec to write to *drive* > the writing of your "validates_presence_of" lines? For some > validations it's quite easy. For others it is less straightforward. > There are probably multiple valid (or valid-ish) answers, but it's > sometimes difficult to know which one is best. > I've kind of adopted this plain-vanilla approach: http://snippets.dzone.com/posts/show/4508 You'll see I'm a little fat, especially with my polymorphic association. Maybe they can be improved, but it's been the right balance of testing before I write code for me--I gain confidence and momentum, and my later iterations are constrained enough to keep me from stepping out of bounds. I'm sure my ideas will evolve over time. > Cheers, > Wincent > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From tom at hobocentral.net Fri Sep 7 11:03:47 2007 From: tom at hobocentral.net (Tom Locke) Date: Fri, 7 Sep 2007 16:03:47 +0100 Subject: [rspec-users] Problem with spec -l Message-ID: <1B6680A6-31B5-428B-A0AB-450C68834F3D@hobocentral.net> Hiya I used to be able to run a single example with spec -l But now it always just runs 0 tests when I give this option. Any ideas? Thanks Tom From lists-rspec at shopwatch.org Fri Sep 7 11:51:19 2007 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Fri, 07 Sep 2007 11:51:19 -0400 Subject: [rspec-users] testing behaviour or testing code? In-Reply-To: <4CD1DD3A-BEFB-4645-A838-1F655766193C@wincent.com> References: <12309322.post@talk.nabble.com> <57c63afe0708240659y1ea3668qc2065333f199a7bb@mail.gmail.com> <810a540e0708241006m23118ed7k9248705c13c2678a@mail.gmail.com> <57c63afe0708241012o6c5bf76bib536656bf69ee323@mail.gmail.com> <810a540e0709012345t5aba354ai6f2f7414fe5a5ea@mail.gmail.com> <57c63afe0709020056y26081df7labe53761f20fa90a@mail.gmail.com> <810a540e0709020232g1a8bc555h129dbbbc0be5d6a7@mail.gmail.com> <57c63afe0709020943o1a9e4783x65390eb7ad44c87a@mail.gmail.com> <46DB35DD.2040701@shopwatch.org> <57c63afe0709022049m36acf1ebqee936361a5c9981c@mail.gmail.com> <46E0C749.5080706@shopwatch.org> <4CD1DD3A-BEFB-4645-A838-1F655766193C@wincent.com> Message-ID: <46E17377.8070707@jay.fm> Wincent Colaiuta wrote: > El 7/9/2007, a las 5:36, Jay Levitt escribi?: > > Very true that you shouldn't be testing ActiveRecord's validation > (Rails' own unit tests are there for that). > > But if you want to do truly *driven* BDD then you will have to test > something; in other words, *before* you go ahead and add this line to > your model: > > validates_presence_of :foo > > You need to write a failing spec for it first. Otherwise, why would > you write it? Doing BDD in its purest form you shouldn't be writing > *any* line of code without your specs driving it. This means the > familiar "write failing spec, write code, confirm working spec" cycle. > > So the question is, what is the best kind of spec to write to *drive* > the writing of your "validates_presence_of" lines? For some > validations it's quite easy. For others it is less straightforward. > There are probably multiple valid (or valid-ish) answers, but it's > sometimes difficult to know which one is best. Well put! To me, if the spec I write is: Model.expects(:validates_presence_of).with(:digits) then I haven't written a spec at all - I've written the code I plan to write, and spelled it differently! The English version of that spec is: Model - should call validates_presence_of with parameter :digits That's just specifying what a line of my code should *say*, not how Model should *behave*. I really like Wincent's approach - test that valid input yields a valid response and that invalid input yields an invalid response. Jay From geoffrey.wiseman at gmail.com Fri Sep 7 14:55:32 2007 From: geoffrey.wiseman at gmail.com (Geoffrey Wiseman) Date: Fri, 7 Sep 2007 14:55:32 -0400 Subject: [rspec-users] False Positives and Autotest on New Folders In-Reply-To: <57c63afe0709051254y1680bb65p4d7953a3a1df6b10@mail.gmail.com> References: <835d522e0709051011j28d943bdy65f782af36822488@mail.gmail.com> <57c63afe0709051254y1680bb65p4d7953a3a1df6b10@mail.gmail.com> Message-ID: <835d522e0709071155h1455c7aanf7d40e5b257aec2f@mail.gmail.com> On 9/5/07, David Chelimsky wrote: > > > Autotest > > Out of curiosity, does anyone know how to get autotest to pick up new > > folders under spec/? Seems like I might have to modify rails_rspec.rb > in > > lib/autotest. We were considering separating our acceptance tests from > the > > rest. > > You could either modify rails_rspec.rb, or you could add a .autotest > file in the project root and rewrite the mappings there. See autotests > docs for how to do that (look for info on hooks). Unfortunately when rails_rspec.rb runs, it seems to write over anything established in .autotest. Should I file a bug on that as well? loading autotest/rails_rspec Mappings @ .autotest: (?-mix:^test\/test_.*rb$) => # (?-mix:^spec\/(models|controllers|views|helpers|lib|acceptance)\/.*rb$) => # (?-mix:^lib\/.*\.rb$) => # Mappings @ rails_rspec.rb: (?-mix:^(spec\/(spec_helper|shared\/.*)|config\/(boot|environment(s\/test)?))\.rb$) => # (?-mix:^app\/controllers\/(.*)\.rb$) => # (?-mix:^app\/models\/(.*)\.rb$) => # (?-mix:^app\/helpers\/(.*)_helper\.rb$) => # (?-mix:^spec\/(models|controllers|views|helpers|lib)\/.*rb$) => # (?-mix:^config\/database\.yml$) => # (?-mix:^app\/views\/(.*)$) => # (?-mix:^config\/routes\.rb$) => # (?-mix:^app\/helpers\/application_helper\.rb$) => # (?-mix:^(test|spec)\/fixtures\/(.*).yml$) => # (?-mix:^lib\/(.*)\.rb$) => # (?-mix:^app\/controllers\/application\.rb$) => # - Geoffrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070907/ec628e3f/attachment.html From dchelimsky at gmail.com Fri Sep 7 15:03:03 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 7 Sep 2007 14:03:03 -0500 Subject: [rspec-users] False Positives and Autotest on New Folders In-Reply-To: <835d522e0709071155h1455c7aanf7d40e5b257aec2f@mail.gmail.com> References: <835d522e0709051011j28d943bdy65f782af36822488@mail.gmail.com> <57c63afe0709051254y1680bb65p4d7953a3a1df6b10@mail.gmail.com> <835d522e0709071155h1455c7aanf7d40e5b257aec2f@mail.gmail.com> Message-ID: <57c63afe0709071203q144396a4ja446d9aa7f2b36b5@mail.gmail.com> On 9/7/07, Geoffrey Wiseman wrote: > On 9/5/07, David Chelimsky wrote: > > > Autotest > > > Out of curiosity, does anyone know how to get autotest to pick up new > > > folders under spec/? Seems like I might have to modify rails_rspec.rb > in > > > lib/autotest. We were considering separating our acceptance tests from > the > > > rest. > > > > You could either modify rails_rspec.rb, or you could add a .autotest > > file in the project root and rewrite the mappings there. See autotests > > docs for how to do that (look for info on hooks). > > > Unfortunately when rails_rspec.rb runs, it seems to write over anything > established in .autotest. Should I file a bug on that as well? Sure. > > loading autotest/rails_rspec > Mappings @ .autotest: > (?-mix:^test\/test_.*rb$) => > # > > (?-mix:^spec\/(models|controllers|views|helpers|lib|acceptance)\/.*rb$) > => # > (?-mix:^lib\/.*\.rb$) => > # > Mappings @ rails_rspec.rb: > > (?-mix:^(spec\/(spec_helper|shared\/.*)|config\/(boot|environment(s\/test)?))\.rb$) > => > # > (?-mix:^app\/controllers\/(.*)\.rb$) => > # > (?-mix:^app\/models\/(.*)\.rb$) => > # > (?-mix:^app\/helpers\/(.*)_helper\.rb$) => > # > > (?-mix:^spec\/(models|controllers|views|helpers|lib)\/.*rb$) > => > # > (?-mix:^config\/database\.yml$) => > # > (?-mix:^app\/views\/(.*)$) => > # > (?-mix:^config\/routes\.rb$) => > # > (?-mix:^app\/helpers\/application_helper\.rb$) => > # > (?-mix:^(test|spec)\/fixtures\/(.*).yml$) => > # > (?-mix:^lib\/(.*)\.rb$) => > # > (?-mix:^app\/controllers\/application\.rb$) => > # > > - Geoffrey > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From geoffrey.wiseman at gmail.com Fri Sep 7 15:31:58 2007 From: geoffrey.wiseman at gmail.com (Geoffrey Wiseman) Date: Fri, 7 Sep 2007 15:31:58 -0400 Subject: [rspec-users] fixtures in before(:all) Message-ID: <835d522e0709071231y4d33754s5c410bb7b82b5094@mail.gmail.com> I was planning on using a fixture within a description that didn't modify the fixture, so I put it in a before(:all) block: describe "Customer", "xml" do fixtures :customers before(:all) do one = customers(:one) end # ... As a result, I got this message: 1) NoMethodError in 'Customer xml before(:all)' You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.[] ./spec/models/customer_spec.rb:86: script/spec:4: If I convert it to before(:each) or simply before, it works just fine. describe "Customer", "xml" do fixtures :customers before do one = customers(:one) end # ... By design? bug? PEBKAC? Anyone else hit this? - Geoffrey -- Geoffrey Wiseman -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070907/82661968/attachment.html From geoffrey.wiseman at gmail.com Fri Sep 7 16:07:05 2007 From: geoffrey.wiseman at gmail.com (Geoffrey Wiseman) Date: Fri, 7 Sep 2007 16:07:05 -0400 Subject: [rspec-users] Preconditions Message-ID: <835d522e0709071307xfad77d9ob6cc4c4cc1af3a4f@mail.gmail.com> Sorry, lots of questions these days. Is there a normal approach for preconditions? In JUnit, I might put a few assertions in the setUp() just to make sure that the test 'data' I've created meets expectations before going to test it. So, for instance, I've got an object that is audited using acts_as_audited and I'd like to test the XML that results from model.revisions.to_xml(). I've created the object and modified it twice, so I expect there to be three revisions, as far as the test goes. It's not really a 'spec', because it's not part of the contract that model objects have three revisions, it's just something I want to make sure is true before I run off and conduct some tests. I could raise an exception in the before block if the precondition isn't met, any other choices? - Geoffrey -- Geoffrey Wiseman -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070907/855c462c/attachment-0001.html From pergesu at gmail.com Fri Sep 7 16:59:52 2007 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 7 Sep 2007 13:59:52 -0700 Subject: [rspec-users] Preconditions In-Reply-To: <835d522e0709071307xfad77d9ob6cc4c4cc1af3a4f@mail.gmail.com> References: <835d522e0709071307xfad77d9ob6cc4c4cc1af3a4f@mail.gmail.com> Message-ID: <810a540e0709071359j71f75bar9df09716e9f353c8@mail.gmail.com> On 9/7/07, Geoffrey Wiseman wrote: > Sorry, lots of questions these days. > > Is there a normal approach for preconditions? In JUnit, I might put a few > assertions in the setUp() just to make sure that the test 'data' I've > created meets expectations before going to test it. > > So, for instance, I've got an object that is audited using acts_as_audited > and I'd like to test the XML that results from model.revisions.to_xml(). > I've created the object and modified it twice, so I expect there to be three > revisions, as far as the test goes. It's not really a 'spec', because it's > not part of the contract that model objects have three revisions, it's just > something I want to make sure is true before I run off and conduct some > tests. > > I could raise an exception in the before block if the precondition isn't > met, any other choices? > > - Geoffrey > -- > Geoffrey Wiseman > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > I'm not sure why you say this isn't a spec. Specs are about behavior of the system, not contracts. In this case you have two examples (imo). describe MyModel, " when saved twice" do before(:each) do @model = MyModel.create :title => "foo" 2.times { @model.save } end it "should have three revisions" do @model.should have(3).revisions end it "should render all revisions in a single XML doc" do Hash.from_xml(@model.to_xml).should == { "model" => { "revision" => 1, "title" => "foo" }, "model" => { "revision" => 2, "title" => "foo" }, "model" => { "revision" => 3, "title" => "foo" } } end end Also I would just have one description (like above) that verifies that it works as you expect. In specs for other behaviors you can then just assume that it works. Pat From geoffrey.wiseman at gmail.com Fri Sep 7 17:36:10 2007 From: geoffrey.wiseman at gmail.com (Geoffrey Wiseman) Date: Fri, 7 Sep 2007 17:36:10 -0400 Subject: [rspec-users] Preconditions In-Reply-To: <810a540e0709071359j71f75bar9df09716e9f353c8@mail.gmail.com> References: <835d522e0709071307xfad77d9ob6cc4c4cc1af3a4f@mail.gmail.com> <810a540e0709071359j71f75bar9df09716e9f353c8@mail.gmail.com> Message-ID: <835d522e0709071436u3dea7ee5wb857366d0fdf967a@mail.gmail.com> On 9/7/07, Pat Maddox wrote: > > describe MyModel, " when saved twice" do > This is the key point I hadn't considered; makes sense, as long as you make sure that there's a context wherein the specification that it should have a certain number of revisions. Thanks! Realized this afternoon that I need to use finer-grained 'test methods' than I'm used to. In some ways the it blocks are closer to assertions than to test methods in Test::Unit, in some ways. So I went from my first crack, closer to: describe Customer, "xml" do before do # set up customer end it "should generate valid summary xml" do # generate summary xml # a bunch of shoulds about the xml end it "should generate valid full xml" do # generate full xml # a bunch of shoulds end end To something like this: describe Customer, "full xml" do before do # set up customer full xml end it "should have a root node of customer" do @doc.root.name.should == 'customer' end it "should contain a customer id" it "should have a name and address" #etc end describe Customer, "summary xml" do # etc. end So I guess I'm still learning the mindset in places. Although you could ahve test methods like that in Test::Unit, most of the time you wouldn't bother simply because of the shared setup. But when the blocks affect how the spec is described, it's far more important to have fine-grained elements, I think. Actually, on that note -- what's the normal way to share a setup across multiple behaviors, a helper method in an includeable module? So, thanks for the guidance. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070907/1f0d83ce/attachment.html From aslak.hellesoy at gmail.com Fri Sep 7 18:19:00 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 8 Sep 2007 00:19:00 +0200 Subject: [rspec-users] Problem with spec -l In-Reply-To: <1B6680A6-31B5-428B-A0AB-450C68834F3D@hobocentral.net> References: <1B6680A6-31B5-428B-A0AB-450C68834F3D@hobocentral.net> Message-ID: <8d961d900709071519s47cc27c2md5725b1329c20d52@mail.gmail.com> On 9/7/07, Tom Locke wrote: > Hiya > > I used to be able to run a single example with > > spec -l > > But now it always just runs 0 tests when I give this option. > It works fine for me, but I'm not sure what version you're referring to or how to exactly reproduce your situation. Aslak > Any ideas? > > Thanks > > Tom > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri Sep 7 19:58:00 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 7 Sep 2007 18:58:00 -0500 Subject: [rspec-users] Preconditions In-Reply-To: <835d522e0709071436u3dea7ee5wb857366d0fdf967a@mail.gmail.com> References: <835d522e0709071307xfad77d9ob6cc4c4cc1af3a4f@mail.gmail.com> <810a540e0709071359j71f75bar9df09716e9f353c8@mail.gmail.com> <835d522e0709071436u3dea7ee5wb857366d0fdf967a@mail.gmail.com> Message-ID: <57c63afe0709071658v7e814aa8l41a442f520c723c1@mail.gmail.com> On 9/7/07, Geoffrey Wiseman wrote: > On 9/7/07, Pat Maddox wrote: > > describe MyModel, " when saved twice" do > > > > This is the key point I hadn't considered; makes sense, as long as you make > sure that there's a context wherein the specification that it should have a > certain number of revisions. Thanks! > > Realized this afternoon that I need to use finer-grained 'test methods' than > I'm used to. In some ways the it blocks are closer to assertions than to > test methods in Test::Unit, in some ways. So I went from my first crack, > closer to: > > describe Customer, "xml" do > before do > # set up customer > end > > it "should generate valid summary xml" do > # generate summary xml > # a bunch of shoulds about the xml > end > > it "should generate valid full xml" do > # generate full xml > # a bunch of shoulds > end > end > > To something like this: > describe Customer, "full xml" do > before do > # set up customer full xml > end > > it "should have a root node of customer" do > @doc.root.name.should == 'customer' > end > > it "should contain a customer id" > it "should have a name and address" > > #etc > end > > describe Customer, "summary xml" do > # etc. > end > > So I guess I'm still learning the mindset in places. Although you could > ahve test methods like that in Test::Unit, most of the time you wouldn't > bother simply because of the shared setup. But when the blocks affect how > the spec is described, it's far more important to have fine-grained > elements, I think. > > Actually, on that note -- what's the normal way to share a setup across > multiple behaviors, a helper method in an includeable module? You can include callable methods in modules, but they have to be called from within the spec. Alternative is shared behaviours: http://rspec.rubyforge.org/documentation/index.html (scroll down a bit). > > So, thanks for the guidance. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Fri Sep 7 20:15:40 2007 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 7 Sep 2007 17:15:40 -0700 Subject: [rspec-users] Preconditions In-Reply-To: <835d522e0709071436u3dea7ee5wb857366d0fdf967a@mail.gmail.com> References: <835d522e0709071307xfad77d9ob6cc4c4cc1af3a4f@mail.gmail.com> <810a540e0709071359j71f75bar9df09716e9f353c8@mail.gmail.com> <835d522e0709071436u3dea7ee5wb857366d0fdf967a@mail.gmail.com> Message-ID: <810a540e0709071715k3b8315c3ibdf6654f576df8a1@mail.gmail.com> On 9/7/07, Geoffrey Wiseman wrote: > On 9/7/07, Pat Maddox wrote: > > describe MyModel, " when saved twice" do > > > > This is the key point I hadn't considered; makes sense, as long as you make > sure that there's a context wherein the specification that it should have a > certain number of revisions. Thanks! > > Realized this afternoon that I need to use finer-grained 'test methods' than > I'm used to. In some ways the it blocks are closer to assertions than to > test methods in Test::Unit, in some ways. Totally. I highly recommend Dave Astels' "One Expectation per Example" article [1]. A couple separate points: * RSpec kicks ass because you can specify behavior on whatever level you want. You can use Story Runner to specify a feature, exercising a vertical slice of your entire app. You can get really fine-grained and specify what happens when a method runs. * Descriptions should be broken up based on the required fixture. I don't split them up until I actually have to. For example, if I'm writing a Stack class. I'd probably start off with describe Stack do it "should be empty" do Stack.new.should be_empty end end Then I want to write a spec for when I've added an item. describe Stack do it "should be empty" do Stack.new.should be_empty end it "should not be empty after adding an item" do s = Stack.new s.add_item :foo s.should_not be_empty end end For a simple spec like this it's okay. We could factor out the Stack.new call, and there's one other smell, but we'll get to that in a minute. Now what if we want to peek the stack? describe Stack do it "should be empty" do Stack.new.should be_empty end it "should not be empty after adding an item" do s = Stack.new s.add_item :foo s.should_not be_empty end it "should let you peek at the top after adding an item" do s = Stack.new s.add_item s.peek.should == :foo end end Now we've got clear duplication in three places: (1) The constructor (2) Call to add_item (3) the 'it' specifier! It's clear that the fixture for "should not be empty" and "should let you peek" are the same. They're also different from the "should be empty" so we split them up: describe Stack, " empty" do it "should be empty" do Stack.new.should be_empty end end describe Stack, " with one item" do before(:each) do @stack = Stack.new @stack.add_item :foo end it "should not be empty" do @stack.should_not be_empty end it "should let you peek at the top" do @stack.peek.should == :foo end end There are two key benefits to that. The first is that it's obvious where new specifications need to go. The behavior for #pop whether a stack is empty or has an item is going to be different. Also if you need some behavior that changes with 3 items, you can probably figure out that you should create a new description. An even bigger benefit is that it minimizes the brain processing required to figure out a spec. If you create the fixture in the setup and don't vary it, it's trivial to scan through some simple expectations. This has to do with the smell that I alluded to earlier, which was the call to add_item. Ideally your example will contain just one expectation and no other setup. This reduces the concepts that change from example to example. Change is where bugs pop up most of the time. So if you're doing setup in an example, then you probably want to split it out from the current description. In fact, in real life I would have split the descriptions up immediately after writing the "should not be empty" example. > So I went from my first crack, > closer to: > > describe Customer, "xml" do > before do > # set up customer > end > > it "should generate valid summary xml" do > # generate summary xml > # a bunch of shoulds about the xml > end > > it "should generate valid full xml" do > # generate full xml > # a bunch of shoulds > end > end > > To something like this: > describe Customer, "full xml" do > before do > # set up customer full xml > end > > it "should have a root node of customer" do > @doc.root.name.should == 'customer' > end > > it "should contain a customer id" > it "should have a name and address" > > #etc > end > > describe Customer, "summary xml" do > # etc. > end > > So I guess I'm still learning the mindset in places. Although you could > ahve test methods like that in Test::Unit, most of the time you wouldn't > bother simply because of the shared setup. But when the blocks affect how > the spec is described, it's far more important to have fine-grained > elements, I think. There's nothing in Test::Unit that prohibits you from writing tests with the same granularity that you can achieve with RSpec. However I have noticed that it can feel unnatural to do so, whereas RSpec of course highly encourages it. > Actually, on that note -- what's the normal way to share a setup across > multiple behaviors, a helper method in an includeable module? There are a couple ways to do this. The first is writing helper methods, as you said. For example I use this all the time describe ProductsController, " requesting /products/1 using GET as a logged in user" do include UserSpecHelpers before(:each) do login_as mock_user @products_proxy = stub("products proxy", :find => :foo) mock_user.stub!(:products).and_return @products_proxy end def do_get get :show, :id => "1" end it "should find the product" do @products_proxy.should_receive(:find).with("1").and_return :foo do_get end it "should assign the product to the view" do do_get assigns[:product].should == :foo end end module UserSpecHelpers def mock_user @mock_user ||= mock_model(User, :admin? => false) end end You can see that we stubbed mock_user#products there. You can also set expectations if you want. Another way is to use a factory. Check out http://www.dcmanges.com/blog/38 for a description of that technique. Though I'd prefer to use mock objects instead of AR instances of course! Both of those are pretty fine-grained approaches, allowing you to share creation of helper objects. What if there's still duplication, for example you're typing the same 8 lines of creation code in? Or if lots of your examples are the same? That's where shared behaviors come in. Check out the docs [2] for more on how to use them. They let you share setup/teardown code AND examples. In the past if you wrote three different specs for "/products/1" that had some of the same examples, you'd probably just remove the common examples from two of the specs, knowing that the first spec already tested it. With shared specs you can actually factor out that behavior but have it be included into all the specs so they specify the behavior without the hassle and errors that come with duplication. Pat [1] http://daveastels.com/2006/08/26/one-expectation-per-example-a-remake-of-one-assertion-per-test/ [2] http://rspec.rubyforge.org/documentation/index.html From geoffrey.wiseman at gmail.com Fri Sep 7 21:36:30 2007 From: geoffrey.wiseman at gmail.com (Geoffrey Wiseman) Date: Fri, 7 Sep 2007 21:36:30 -0400 Subject: [rspec-users] Preconditions In-Reply-To: <57c63afe0709071658v7e814aa8l41a442f520c723c1@mail.gmail.com> References: <835d522e0709071307xfad77d9ob6cc4c4cc1af3a4f@mail.gmail.com> <810a540e0709071359j71f75bar9df09716e9f353c8@mail.gmail.com> <835d522e0709071436u3dea7ee5wb857366d0fdf967a@mail.gmail.com> <57c63afe0709071658v7e814aa8l41a442f520c723c1@mail.gmail.com> Message-ID: <835d522e0709071836u5a850cbfk98c6d06edf5c4ae3@mail.gmail.com> On 9/7/07, David Chelimsky wrote: > > > Actually, on that note -- what's the normal way to share a setup across > > multiple behaviors, a helper method in an includeable module? > > You can include callable methods in modules, but they have to be > called from within the spec. > > Alternative is shared behaviours: > http://rspec.rubyforge.org/documentation/index.html (scroll down a > bit). I've already got some shared behaviors, they're great; nice way to use a unit-level assertions n higher-level tests for instance without breaking DRY. Hadn't really thought about using these just for setup; the syntax would look a little weird what with it_should_behave_like, but it's still a thought. -- Geoffrey Wiseman -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070907/ed50da40/attachment.html From dchelimsky at gmail.com Fri Sep 7 21:43:00 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 7 Sep 2007 20:43:00 -0500 Subject: [rspec-users] Preconditions In-Reply-To: <835d522e0709071836u5a850cbfk98c6d06edf5c4ae3@mail.gmail.com> References: <835d522e0709071307xfad77d9ob6cc4c4cc1af3a4f@mail.gmail.com> <810a540e0709071359j71f75bar9df09716e9f353c8@mail.gmail.com> <835d522e0709071436u3dea7ee5wb857366d0fdf967a@mail.gmail.com> <57c63afe0709071658v7e814aa8l41a442f520c723c1@mail.gmail.com> <835d522e0709071836u5a850cbfk98c6d06edf5c4ae3@mail.gmail.com> Message-ID: <57c63afe0709071843jae0aff8of6bdfece771e33eb@mail.gmail.com> On 9/7/07, Geoffrey Wiseman wrote: > On 9/7/07, David Chelimsky wrote: > > > Actually, on that note -- what's the normal way to share a setup across > > > multiple behaviors, a helper method in an includeable module? > > > > You can include callable methods in modules, but they have to be > > called from within the spec. > > > > Alternative is shared behaviours: > > http://rspec.rubyforge.org/documentation/index.html > (scroll down a > > bit). > > > I've already got some shared behaviors, they're great; nice way to use a > unit-level assertions n higher-level tests for instance without breaking > DRY. > > Hadn't really thought about using these just for setup; the syntax would > look a little weird what with it_should_behave_like, but it's still a > thought. Sorry - you're right - not the place for setup. So best to stick w/ included modules. > > -- > Geoffrey Wiseman > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tom at hobocentral.net Sat Sep 8 05:42:54 2007 From: tom at hobocentral.net (Tom Locke) Date: Sat, 8 Sep 2007 10:42:54 +0100 Subject: [rspec-users] rspec_on_rails - necessary to force "test" env? Message-ID: <8DE34586-96C6-4FD3-9DFB-E307C50CB10A@hobocentral.net> Hi all rspec_on_rails/lib/spec/rails.rb starts: ------ dir = File.dirname(__FILE__) require 'application' silence_warnings { RAILS_ENV = "test" } ------ That force into "test" environment is causing me trouble and I've commented it out. Why? I'm testing a plugin, and have a sort of mini rails app that I use for the specs. The environments in this app are not dev/ production/staging because the app only exists for testing. Instead they are mysql / sqlite etc. for testing against different DBs. Is there a way to avoid this force into test environment? Ta Tom From win at wincent.com Sat Sep 8 05:55:55 2007 From: win at wincent.com (Wincent Colaiuta) Date: Sat, 8 Sep 2007 11:55:55 +0200 Subject: [rspec-users] Preconditions In-Reply-To: <810a540e0709071715k3b8315c3ibdf6654f576df8a1@mail.gmail.com> References: <835d522e0709071307xfad77d9ob6cc4c4cc1af3a4f@mail.gmail.com> <810a540e0709071359j71f75bar9df09716e9f353c8@mail.gmail.com> <835d522e0709071436u3dea7ee5wb857366d0fdf967a@mail.gmail.com> <810a540e0709071715k3b8315c3ibdf6654f576df8a1@mail.gmail.com> Message-ID: <4306389C-9515-4DF5-9AAB-34E652B151B7@wincent.com> El 8/9/2007, a las 2:15, Pat Maddox escribi?: > * Descriptions should be broken up based on the required fixture. I > don't split them up until I actually have to. For example, if I'm > writing a Stack class. I'd probably start off with > > [snip] > > For a simple spec like this it's okay. We could factor out the > Stack.new call, and there's one other smell, but we'll get to that in > a minute. > > Now what if we want to peek the stack? > > [snip] > > Now we've got clear duplication in three places: > (1) The constructor > (2) Call to add_item > (3) the 'it' specifier! > > It's clear that the fixture for "should not be empty" and "should let > you peek" are the same. They're also different from the "should be > empty" so we split them up: > > [snip] > > There are two key benefits to that. The first is that it's obvious > where new specifications need to go. The behavior for #pop whether a > stack is empty or has an item is going to be different. Also if you > need some behavior that changes with 3 items, you can probably figure > out that you should create a new description. > > An even bigger benefit is that it minimizes the brain processing > required to figure out a spec. If you create the fixture in the setup > and don't vary it, it's trivial to scan through some simple > expectations. > > This has to do with the smell that I alluded to earlier, which was the > call to add_item. Ideally your example will contain just one > expectation and no other setup. This reduces the concepts that change > from example to example. Change is where bugs pop up most of the > time. So if you're doing setup in an example, then you probably want > to split it out from the current description. In fact, in real life I > would have split the descriptions up immediately after writing the > "should not be empty" example. Brilliantly written example, very clear! +1 Cheers, Wincent From aslak.hellesoy at gmail.com Sat Sep 8 06:40:09 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 8 Sep 2007 12:40:09 +0200 Subject: [rspec-users] fixtures in before(:all) In-Reply-To: <835d522e0709071231y4d33754s5c410bb7b82b5094@mail.gmail.com> References: <835d522e0709071231y4d33754s5c410bb7b82b5094@mail.gmail.com> Message-ID: <8d961d900709080340o295fd17r83cfd270e2ad7699@mail.gmail.com> On 9/7/07, Geoffrey Wiseman wrote: > I was planning on using a fixture within a description that didn't modify > the fixture, so I put it in a before(:all) block: > describe "Customer", "xml" do > fixtures :customers > > before(:all) do > one = customers(:one) > end > > # ... > As a result, I got this message: > > 1) > NoMethodError in 'Customer xml before(:all)' > You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.[] > ./spec/models/customer_spec.rb:86: > script/spec:4: > If I convert it to before(:each) or simply before, it works just fine. > describe "Customer", "xml" do > fixtures :customers > > before do > one = customers(:one) > end > > # ... > By design? bug? PEBKAC? Anyone else hit this? > By design. Fixtures don't work with before(:all). There has been several discussions about this on the list previously. Aslak > - Geoffrey > -- > Geoffrey Wiseman > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Sat Sep 8 11:18:16 2007 From: pergesu at gmail.com (Pat Maddox) Date: Sat, 8 Sep 2007 08:18:16 -0700 Subject: [rspec-users] Preconditions In-Reply-To: <4306389C-9515-4DF5-9AAB-34E652B151B7@wincent.com> References: <835d522e0709071307xfad77d9ob6cc4c4cc1af3a4f@mail.gmail.com> <810a540e0709071359j71f75bar9df09716e9f353c8@mail.gmail.com> <835d522e0709071436u3dea7ee5wb857366d0fdf967a@mail.gmail.com> <810a540e0709071715k3b8315c3ibdf6654f576df8a1@mail.gmail.com> <4306389C-9515-4DF5-9AAB-34E652B151B7@wincent.com> Message-ID: <810a540e0709080818x7e31f95bp807be9dbeb50b03e@mail.gmail.com> On 9/8/07, Wincent Colaiuta wrote: > El 8/9/2007, a las 2:15, Pat Maddox escribi?: > > > * Descriptions should be broken up based on the required fixture. I > > don't split them up until I actually have to. For example, if I'm > > writing a Stack class. I'd probably start off with > > > > [snip] > > > > For a simple spec like this it's okay. We could factor out the > > Stack.new call, and there's one other smell, but we'll get to that in > > a minute. > > > > Now what if we want to peek the stack? > > > > [snip] > > > > Now we've got clear duplication in three places: > > (1) The constructor > > (2) Call to add_item > > (3) the 'it' specifier! > > > > It's clear that the fixture for "should not be empty" and "should let > > you peek" are the same. They're also different from the "should be > > empty" so we split them up: > > > > [snip] > > > > There are two key benefits to that. The first is that it's obvious > > where new specifications need to go. The behavior for #pop whether a > > stack is empty or has an item is going to be different. Also if you > > need some behavior that changes with 3 items, you can probably figure > > out that you should create a new description. > > > > An even bigger benefit is that it minimizes the brain processing > > required to figure out a spec. If you create the fixture in the setup > > and don't vary it, it's trivial to scan through some simple > > expectations. > > > > This has to do with the smell that I alluded to earlier, which was the > > call to add_item. Ideally your example will contain just one > > expectation and no other setup. This reduces the concepts that change > > from example to example. Change is where bugs pop up most of the > > time. So if you're doing setup in an example, then you probably want > > to split it out from the current description. In fact, in real life I > > would have split the descriptions up immediately after writing the > > "should not be empty" example. > > Brilliantly written example, very clear! > > +1 > > Cheers, > Wincent > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > To give credit where it's due, I'm pretty sure that's from my memory of the early examples on rspec.rubyforge.org. Pat From win at wincent.com Sat Sep 8 11:43:59 2007 From: win at wincent.com (Wincent Colaiuta) Date: Sat, 8 Sep 2007 17:43:59 +0200 Subject: [rspec-users] Preconditions In-Reply-To: <810a540e0709080818x7e31f95bp807be9dbeb50b03e@mail.gmail.com> References: <835d522e0709071307xfad77d9ob6cc4c4cc1af3a4f@mail.gmail.com> <810a540e0709071359j71f75bar9df09716e9f353c8@mail.gmail.com> <835d522e0709071436u3dea7ee5wb857366d0fdf967a@mail.gmail.com> <810a540e0709071715k3b8315c3ibdf6654f576df8a1@mail.gmail.com> <4306389C-9515-4DF5-9AAB-34E652B151B7@wincent.com> <810a540e0709080818x7e31f95bp807be9dbeb50b03e@mail.gmail.com> Message-ID: El 8/9/2007, a las 17:18, Pat Maddox escribi?: > To give credit where it's due, I'm pretty sure that's from my memory > of the early examples on rspec.rubyforge.org. Yes, but it's one thing to look at a finished set of well-written specs, and it's another to see them built up from scratch in steps and have a clear explanation of the logic behind your decisions. I think you did a great job. Cheers, Wincent From dchelimsky at gmail.com Sat Sep 8 12:05:45 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 8 Sep 2007 11:05:45 -0500 Subject: [rspec-users] Preconditions In-Reply-To: <810a540e0709080818x7e31f95bp807be9dbeb50b03e@mail.gmail.com> References: <835d522e0709071307xfad77d9ob6cc4c4cc1af3a4f@mail.gmail.com> <810a540e0709071359j71f75bar9df09716e9f353c8@mail.gmail.com> <835d522e0709071436u3dea7ee5wb857366d0fdf967a@mail.gmail.com> <810a540e0709071715k3b8315c3ibdf6654f576df8a1@mail.gmail.com> <4306389C-9515-4DF5-9AAB-34E652B151B7@wincent.com> <810a540e0709080818x7e31f95bp807be9dbeb50b03e@mail.gmail.com> Message-ID: <57c63afe0709080905jc25a150i309e85c0ea8d4e06@mail.gmail.com> On 9/8/07, Pat Maddox wrote: > On 9/8/07, Wincent Colaiuta wrote: > > El 8/9/2007, a las 2:15, Pat Maddox escribi?: > > > > > * Descriptions should be broken up based on the required fixture. I > > > don't split them up until I actually have to. For example, if I'm > > > writing a Stack class. I'd probably start off with > > > > > > [snip] > > > > > > For a simple spec like this it's okay. We could factor out the > > > Stack.new call, and there's one other smell, but we'll get to that in > > > a minute. > > > > > > Now what if we want to peek the stack? > > > > > > [snip] > > > > > > Now we've got clear duplication in three places: > > > (1) The constructor > > > (2) Call to add_item > > > (3) the 'it' specifier! > > > > > > It's clear that the fixture for "should not be empty" and "should let > > > you peek" are the same. They're also different from the "should be > > > empty" so we split them up: > > > > > > [snip] > > > > > > There are two key benefits to that. The first is that it's obvious > > > where new specifications need to go. The behavior for #pop whether a > > > stack is empty or has an item is going to be different. Also if you > > > need some behavior that changes with 3 items, you can probably figure > > > out that you should create a new description. > > > > > > An even bigger benefit is that it minimizes the brain processing > > > required to figure out a spec. If you create the fixture in the setup > > > and don't vary it, it's trivial to scan through some simple > > > expectations. > > > > > > This has to do with the smell that I alluded to earlier, which was the > > > call to add_item. Ideally your example will contain just one > > > expectation and no other setup. This reduces the concepts that change > > > from example to example. Change is where bugs pop up most of the > > > time. So if you're doing setup in an example, then you probably want > > > to split it out from the current description. In fact, in real life I > > > would have split the descriptions up immediately after writing the > > > "should not be empty" example. > > > > Brilliantly written example, very clear! > > > > +1 > > > > Cheers, > > Wincent > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > To give credit where it's due, I'm pretty sure that's from my memory > of the early examples on rspec.rubyforge.org. Thanks for that Pat. We pulled that tutorial down a while ago but you can get the textile source for it like so: svn export svn://rubyforge.org/var/svn/rspec/tags/REL_0_8_0/doc/src/tutorials Cheers, David > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Sat Sep 8 12:08:21 2007 From: ben at benmabey.com (Ben Mabey) Date: Sat, 08 Sep 2007 10:08:21 -0600 Subject: [rspec-users] Preconditions In-Reply-To: <57c63afe0709080905jc25a150i309e85c0ea8d4e06@mail.gmail.com> References: <835d522e0709071307xfad77d9ob6cc4c4cc1af3a4f@mail.gmail.com> <810a540e0709071359j71f75bar9df09716e9f353c8@mail.gmail.com> <835d522e0709071436u3dea7ee5wb857366d0fdf967a@mail.gmail.com> <810a540e0709071715k3b8315c3ibdf6654f576df8a1@mail.gmail.com> <4306389C-9515-4DF5-9AAB-34E652B151B7@wincent.com> <810a540e0709080818x7e31f95bp807be9dbeb50b03e@mail.gmail.com> <57c63afe0709080905jc25a150i309e85c0ea8d4e06@mail.gmail.com> Message-ID: <46E2C8F5.9040108@benmabey.com> David Chelimsky wrote: > On 9/8/07, Pat Maddox wrote: > >> On 9/8/07, Wincent Colaiuta wrote: >> >>> El 8/9/2007, a las 2:15, Pat Maddox escribi?: >>> >>> >>>> * Descriptions should be broken up based on the required fixture. I >>>> don't split them up until I actually have to. For example, if I'm >>>> writing a Stack class. I'd probably start off with >>>> >>>> [snip] >>>> >>>> For a simple spec like this it's okay. We could factor out the >>>> Stack.new call, and there's one other smell, but we'll get to that in >>>> a minute. >>>> >>>> Now what if we want to peek the stack? >>>> >>>> [snip] >>>> >>>> Now we've got clear duplication in three places: >>>> (1) The constructor >>>> (2) Call to add_item >>>> (3) the 'it' specifier! >>>> >>>> It's clear that the fixture for "should not be empty" and "should let >>>> you peek" are the same. They're also different from the "should be >>>> empty" so we split them up: >>>> >>>> [snip] >>>> >>>> There are two key benefits to that. The first is that it's obvious >>>> where new specifications need to go. The behavior for #pop whether a >>>> stack is empty or has an item is going to be different. Also if you >>>> need some behavior that changes with 3 items, you can probably figure >>>> out that you should create a new description. >>>> >>>> An even bigger benefit is that it minimizes the brain processing >>>> required to figure out a spec. If you create the fixture in the setup >>>> and don't vary it, it's trivial to scan through some simple >>>> expectations. >>>> >>>> This has to do with the smell that I alluded to earlier, which was the >>>> call to add_item. Ideally your example will contain just one >>>> expectation and no other setup. This reduces the concepts that change >>>> from example to example. Change is where bugs pop up most of the >>>> time. So if you're doing setup in an example, then you probably want >>>> to split it out from the current description. In fact, in real life I >>>> would have split the descriptions up immediately after writing the >>>> "should not be empty" example. >>>> >>> Brilliantly written example, very clear! >>> >>> +1 >>> >>> Cheers, >>> Wincent >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> >> To give credit where it's due, I'm pretty sure that's from my memory >> of the early examples on rspec.rubyforge.org. >> > > Thanks for that Pat. We pulled that tutorial down a while ago but you > can get the textile source for it like so: > > svn export svn://rubyforge.org/var/svn/rspec/tags/REL_0_8_0/doc/src/tutorials > > Cheers, > David > > >> Pat >> _______________________________________________ >> 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 > What was the motivation behind taking that tutorial down, BTW? I really like and benefited from it when I was starting to learn rspec. Was it just a maintenance issue as far as updating the tutorial to the current API (DSL)? -Ben From jeremystellsmith at gmail.com Sat Sep 8 14:39:32 2007 From: jeremystellsmith at gmail.com (Jeremy Stell-Smith) Date: Sat, 8 Sep 2007 11:39:32 -0700 Subject: [rspec-users] why no newlines in failure messages? Message-ID: Instead of : expected "
    \n
  • red
  • \n
  • blue
  • \n
", got "
    \n
  • red
  • \n
  • blue
  • \n
" (using ==) could we make rspec exceptions look more like : expected "
    \n
  • red
  • \n
  • blue
  • \n
", got "
    \n
  • red
  • \n
  • blue
  • \n
" (using ==) or if that is too hard, even : expected "
    \n
  • red
  • \n
  • blue
  • \n
", got "
    \n
  • red
  • \n
  • blue
  • \n
" (using ==) then it becomes readily easy to scan the two values and see differences, as opposed to (something I have done far too often in the last few months) copying the diff, pasting it somewhere and manually doing this. I have looked at the --diff option, but it doesn't show how something has changed, just where it has changed which is not quite what I want. Jeremy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070908/557cc9fe/attachment-0001.html From dchelimsky at gmail.com Sat Sep 8 15:12:50 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 8 Sep 2007 14:12:50 -0500 Subject: [rspec-users] why no newlines in failure messages? In-Reply-To: References: Message-ID: <57c63afe0709081212l40d4b788r7e7f6fbe9928baa2@mail.gmail.com> On 9/8/07, Jeremy Stell-Smith wrote: > Instead of : > > expected "
    \n
  • red
  • \n
  • blue
  • \n
", got "
    \n >
  • red
  • \n
  • blue
  • \n
" (using ==) > > could we make rspec exceptions look more like : > > expected "
    \n
  • red
  • \n
  • blue
  • \n
", > got "
    \n
  • red
  • \n
  • blue
  • \n
" (using ==) Trunk's already doing this. Not released yet. > > or if that is too hard, even : > > expected > "
    \n
  • red
  • \n
  • blue
  • \n
", got > "
    \n
  • red
  • \n
  • blue
  • \n
" (using ==) > > then it becomes readily easy to scan the two values and see differences, as > opposed to (something I have done far too often in the last few months) > copying the diff, pasting it somewhere and manually doing this. > > I have looked at the --diff option, but it doesn't show how something has > changed, just where it has changed which is not quite what I want. > > Jeremy > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From leslief at sunquake.net Sat Sep 8 15:47:58 2007 From: leslief at sunquake.net (Leslie Freeman) Date: Sat, 8 Sep 2007 13:47:58 -0600 Subject: [rspec-users] template.expects_render? Message-ID: Hi All, I'm trying to make use of template.expects_render, is outlined in David's post(http://blog.davidchelimsky.net/articles/2007/06/28/ template-expects_render). I get an undefined method error on expects_render. I made sure I had the 1.0.8 gem as well as reinstalling the plugin and redoing the bootstrap. Still no luck. So I created a clean project, installed the CURRENT plugin, ran script/ generate rspec and generated a vanilla rspec scaffold. I added the template.should_render to a view spec, and am still getting the undefined method error. I had assumed this method would be available in 1.0.8, as it was supposed to be added to 1.0.6. Am I wrong? Or am I missing something crucial about the usage? Thanks, Leslie Below is my view spec: require File.dirname(__FILE__) + '/../../spec_helper' describe "/apples/index.rhtml" do include ApplesHelper before do apple_98 = mock_model(Apple) apple_99 = mock_model(Apple) assigns[:apples] = [apple_98, apple_99] end it "should render list of apples" do template.should_render(:partial => 'apples/apple') render "/apples/index.rhtml" end end From dchelimsky at gmail.com Sat Sep 8 16:11:24 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 8 Sep 2007 15:11:24 -0500 Subject: [rspec-users] template.expects_render? In-Reply-To: References: Message-ID: <57c63afe0709081311y6e235651pa2f840319288e5d7@mail.gmail.com> On 9/8/07, Leslie Freeman wrote: > Hi All, > I'm trying to make use of template.expects_render, is outlined in > David's post(http://blog.davidchelimsky.net/articles/2007/06/28/ > template-expects_render). I get an undefined method error on > expects_render. I made sure I had the 1.0.8 gem as well as > reinstalling the plugin and redoing the bootstrap. Still no luck. So > I created a clean project, installed the CURRENT plugin, ran script/ > generate rspec and generated a vanilla rspec scaffold. I added the > template.should_render to a view spec, and am still getting the > undefined method error. > > I had assumed this method would be available in 1.0.8, as it was > supposed to be added to 1.0.6. Am I wrong? Or am I missing something > crucial about the usage? > > Thanks, > Leslie > > Below is my view spec: > > > require File.dirname(__FILE__) + '/../../spec_helper' > > describe "/apples/index.rhtml" do > include ApplesHelper > > before do > apple_98 = mock_model(Apple) > apple_99 = mock_model(Apple) > > assigns[:apples] = [apple_98, apple_99] > end > > it "should render list of apples" do > template.should_render(:partial => 'apples/apple') The method is expect_render, not should_render. HTH, David > render "/apples/index.rhtml" > end > end > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mailing_lists at railsnewbie.com Sat Sep 8 16:10:56 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 8 Sep 2007 16:10:56 -0400 Subject: [rspec-users] Rake tasks getting in the way of edge (uses gem instead) In-Reply-To: <810a540e0709041255y4157d5d8x2a2f080b88c0bd97@mail.gmail.com> References: <810a540e0709041255y4157d5d8x2a2f080b88c0bd97@mail.gmail.com> Message-ID: <9FEC0AE3-462C-43F6-9A75-254275E57DCD@railsnewbie.com> On Sep 4, 2007, at 3:55 PM, Pat Maddox wrote: > So I'd been running gem releases of rspec for the past several months, > and I installed edge rspec so that I can use Story Runner. > > I'm running into a problem because I've got a couple rake tasks that > reference "spec/rake/raketask". If I try to run "rake spec" then it > pulls in the gem version instead of the plugin version. rake blows up > saying that the versions are incompatible...RSpec is at 1.0.8 and > rspec_on_rails is at r2507. > > If I remove those rake tasks then it runs fine. So it just seems that > when rake starts up, it loads all the available task files, which > includes a reference to require rspec stuff. Since the plugins > haven't been loaded yet it gets the gem version. > > afaik the solution is to build a new gem. However I don't want to > have to tell my team members to update their gem every single day. > Also I think including rspec in vendor/plugins is supposed to obviate > that anyway, but this is probably just some path loading stuff. > > Anyone else run into this? How do you handle it? If I understand you correctly, I think this will work in your rakefile: $:.unshift File.dirname(__FILE__) + '/vendor/plugins/rspec/rspec/lib/' require 'spec/rake/spectask' require 'spec/rake/verify_rcov' Then you can do something like this (as per usual): desc "Run all examples with RCov" Spec::Rake::SpecTask.new(:rcov) do |t| t.spec_files = FileList['spec/**/*.rb'] t.rcov = true t.rcov_opts = ['--exclude', 'spec'] t.rcov_dir = "doc/rcov" end Scott From leslief at sunquake.net Sat Sep 8 16:17:50 2007 From: leslief at sunquake.net (Leslie Freeman) Date: Sat, 8 Sep 2007 14:17:50 -0600 Subject: [rspec-users] template.expects_render? In-Reply-To: <57c63afe0709081311y6e235651pa2f840319288e5d7@mail.gmail.com> References: <57c63afe0709081311y6e235651pa2f840319288e5d7@mail.gmail.com> Message-ID: <2AA074CB-A779-46D9-B816-70CF221C0FDE@sunquake.net> Ack. The devil is in typing errors. I had been trying expets_render (with an s), don't know how I got should_render in here. At any rate, expect_render does work. Sorry for the lame question, thanks for the quick reply. :) Leslie On Sep 8, 2007, at 2:11 PM, David Chelimsky wrote: > On 9/8/07, Leslie Freeman wrote: >> Hi All, >> I'm trying to make use of template.expects_render, is outlined in >> David's post(http://blog.davidchelimsky.net/articles/2007/06/28/ >> template-expects_render). I get an undefined method error on >> expects_render. I made sure I had the 1.0.8 gem as well as >> reinstalling the plugin and redoing the bootstrap. Still no luck. So >> I created a clean project, installed the CURRENT plugin, ran script/ >> generate rspec and generated a vanilla rspec scaffold. I added the >> template.should_render to a view spec, and am still getting the >> undefined method error. >> >> I had assumed this method would be available in 1.0.8, as it was >> supposed to be added to 1.0.6. Am I wrong? Or am I missing something >> crucial about the usage? >> >> Thanks, >> Leslie >> >> Below is my view spec: >> >> >> require File.dirname(__FILE__) + '/../../spec_helper' >> >> describe "/apples/index.rhtml" do >> include ApplesHelper >> >> before do >> apple_98 = mock_model(Apple) >> apple_99 = mock_model(Apple) >> >> assigns[:apples] = [apple_98, apple_99] >> end >> >> it "should render list of apples" do >> template.should_render(:partial => 'apples/apple') > > The method is expect_render, not should_render. > > HTH, > David > > >> render "/apples/index.rhtml" >> end >> end >> _______________________________________________ >> 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 mailing_lists at railsnewbie.com Sat Sep 8 16:19:23 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 8 Sep 2007 16:19:23 -0400 Subject: [rspec-users] Failure Messages in RSpec + inline debugging of a spec In-Reply-To: <23CC96AA-7892-4984-A63F-7C1FA62D166C@wincent.com> References: <835d522e0709041351va41f1a3y8dc9c6fa92d05c96@mail.gmail.com> <23CC96AA-7892-4984-A63F-7C1FA62D166C@wincent.com> Message-ID: <1B683236-2EDD-4B51-9B0B-7B825DB15319@railsnewbie.com> On Sep 5, 2007, at 4:25 AM, Wincent Colaiuta wrote: > El 4/9/2007, a las 22:51, Geoffrey Wiseman escribi?: > >> Using this as an example, if a new validation rule is added, this >> test will >> fail without indicating /why/. Sure, I can get that answer in >> other ways, >> but I'd hate to discover things like: >> >> it "should be valid with valid attributes" do >> # puts @person.errors if !@person.valid >> @person.should be_valid >> end >> >> (Which I've seen when people have to repeatedly diagnose issues in >> a test; >> I'd prefer a failure message to the above) > > My personal approach when a spec fails and I can't figure out *why* > just by looking at it is to run the spec under the debugger and set a > breakpoint on the line where the corresponding spec fails. > I've been doing the same thing with ruby-debug. I have setup a snippet in textmate so that when I type debug(tab), I get the following line: require 'rubygems'; require 'ruby-debug'; debugger And I usually do this *inside* the failing spec. So far it has been a mixed experience - I have found that it doesn't work very well with rails as you end up debugging more of rails then of your own code. It also doesn't work with the DRB server. Any thoughts on how this could be better done? > I actually *like* the way that RSpec doesn't provide a mechanism for > specifying error messages; it's one of the things that makes the > specs so easy to read. It's difficult to imagine a syntax that would > provide what you're asking for without sacrificing readability. > > Cheers, > Wincent I couldn't agree more. I, like David, am not opposed to a custom matcher, but it's hard to imagine how it would play nicely with the syntax. Scott From mailing_lists at railsnewbie.com Sat Sep 8 16:46:52 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 8 Sep 2007 16:46:52 -0400 Subject: [rspec-users] Rspec Caveman questions. In-Reply-To: <12509678.post@talk.nabble.com> References: <12509678.post@talk.nabble.com> Message-ID: On Sep 5, 2007, at 3:49 PM, sudara wrote: > > Hello! > > I'm just a caveman with some caveman questions. > > I've been parsing Rspec for quite a while, and I'm writing my first > series > of specs. My initial impressions are "Verbose, but understandable. > Helpful > and intuitive, but so much to digest." I want to congratulate the > folks who > are dedicating a chunk of their lives to writing this, and ask 2 > caveman > questions > > My first is "Why lambda in rpsec"? It doesn't strike me as "reads like > english" or "easily understandable." I understand it's place in > ruby (um, > kind of :), but my thinking is: > > lambda { do_something_risky }.should raise_error > > would be more understandable (and fun!) written as: > > running { something_risky }.should raise_error It's not too hard to understand is it? Lambda/Procs are used for delayed evaluation. If you did something like this: do_something_risky.should raise_error, then an error would be raised even before the should method could be called to check for an error. The beauty of ruby is that if you really wanted "running", it would be rather easy to add it yourself: alias :running :lambda > > My second question is: For those folks who are getting up to speed > with ruby > and rails AND digesting rspec along the way, there is a lot of > incoming DSL. > As I started with rails before rspec, I found myself using script/ > console to > check my code, poking at different ways of expressing myself with > ruby. > > Is there a way to "poke at my specs"? I can load up my test > environment, but > can I spec things "live" so that I can find out what works and what > doesn't? > I find I'm wasting a chunk of time (as I don't have the DSL even > 60% down) > writing specs and getting it wrong. Am I missing a trick, or > I.should_have > dsl_down_before_trying.else_return(crying)? > Honestly, If you are used to Test::Unit, the difference is mainly how you assert: Test::Unit: assert_equal obj, value RSpec: obj.should == value You might also want to look at my last email about custom matchers + ruby-debug. Regards Scott From mailing_lists at railsnewbie.com Sat Sep 8 17:04:47 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 8 Sep 2007 17:04:47 -0400 Subject: [rspec-users] fixtures in before(:all) In-Reply-To: <835d522e0709071231y4d33754s5c410bb7b82b5094@mail.gmail.com> References: <835d522e0709071231y4d33754s5c410bb7b82b5094@mail.gmail.com> Message-ID: On Sep 7, 2007, at 3:31 PM, Geoffrey Wiseman wrote: > I was planning on using a fixture within a description that didn't > modify the fixture, so I put it in a before(:all) block: > describe "Customer", "xml" do > fixtures :customers > > before(:all) do > one = customers(:one) > end > > # ... > As a result, I got this message: > > 1) > NoMethodError in 'Customer xml before(:all)' > You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.[] > ./spec/models/customer_spec.rb:86: > script/spec:4: > If I convert it to before(:each) or simply before, it works just fine. > describe "Customer", "xml" do > fixtures :customers > > before do > one = customers(:one) > end > > # ... > By design? bug? PEBKAC? Anyone else hit this? > Looks like a bug to me, although I don't know why you would want to load a fixture only once, and not before every test. Generally, I don't find much use for a before(:all) block (they are discouraged in Test::Unit as well, for their unreliable use with more than one test). Scott From dchelimsky at gmail.com Sat Sep 8 17:06:50 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 8 Sep 2007 16:06:50 -0500 Subject: [rspec-users] template.expects_render? In-Reply-To: <2AA074CB-A779-46D9-B816-70CF221C0FDE@sunquake.net> References: <57c63afe0709081311y6e235651pa2f840319288e5d7@mail.gmail.com> <2AA074CB-A779-46D9-B816-70CF221C0FDE@sunquake.net> Message-ID: <57c63afe0709081406id1407cep200de18d8987db60@mail.gmail.com> On 9/8/07, Leslie Freeman wrote: > Ack. The devil is in typing errors. I had been trying expets_render > (with an s), don't know how I got should_render in here. At any rate, > expect_render does work. Sorry for the lame question, thanks for the > quick reply. :) Glad to help. Cheers, David > > Leslie > > > On Sep 8, 2007, at 2:11 PM, David Chelimsky wrote: > > > On 9/8/07, Leslie Freeman wrote: > >> Hi All, > >> I'm trying to make use of template.expects_render, is outlined in > >> David's post(http://blog.davidchelimsky.net/articles/2007/06/28/ > >> template-expects_render). I get an undefined method error on > >> expects_render. I made sure I had the 1.0.8 gem as well as > >> reinstalling the plugin and redoing the bootstrap. Still no luck. So > >> I created a clean project, installed the CURRENT plugin, ran script/ > >> generate rspec and generated a vanilla rspec scaffold. I added the > >> template.should_render to a view spec, and am still getting the > >> undefined method error. > >> > >> I had assumed this method would be available in 1.0.8, as it was > >> supposed to be added to 1.0.6. Am I wrong? Or am I missing something > >> crucial about the usage? > >> > >> Thanks, > >> Leslie > >> > >> Below is my view spec: > >> > >> > >> require File.dirname(__FILE__) + '/../../spec_helper' > >> > >> describe "/apples/index.rhtml" do > >> include ApplesHelper > >> > >> before do > >> apple_98 = mock_model(Apple) > >> apple_99 = mock_model(Apple) > >> > >> assigns[:apples] = [apple_98, apple_99] > >> end > >> > >> it "should render list of apples" do > >> template.should_render(:partial => 'apples/apple') > > > > The method is expect_render, not should_render. > > > > HTH, > > David > > > > > >> render "/apples/index.rhtml" > >> end > >> end > >> _______________________________________________ > >> 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 > From lists-rspec at shopwatch.org Sat Sep 8 17:41:05 2007 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Sat, 08 Sep 2007 17:41:05 -0400 Subject: [rspec-users] Failure Messages in RSpec + inline debugging of a spec In-Reply-To: <1B683236-2EDD-4B51-9B0B-7B825DB15319@railsnewbie.com> References: <835d522e0709041351va41f1a3y8dc9c6fa92d05c96@mail.gmail.com> <23CC96AA-7892-4984-A63F-7C1FA62D166C@wincent.com> <1B683236-2EDD-4B51-9B0B-7B825DB15319@railsnewbie.com> Message-ID: <46E316F1.5090301@shopwatch.org> On 9/8/2007 4:19 PM, Scott Taylor wrote: > So far it has been > a mixed experience - I have found that it doesn't work very well with > rails as you end up debugging more of rails then of your own code. Finally, a debugging environment that matches the production environment! Jay From aslak.hellesoy at gmail.com Sat Sep 8 17:47:58 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 8 Sep 2007 23:47:58 +0200 Subject: [rspec-users] fixtures in before(:all) In-Reply-To: References: <835d522e0709071231y4d33754s5c410bb7b82b5094@mail.gmail.com> Message-ID: <8d961d900709081447pce2eb5eqd2f222f6c41ac13@mail.gmail.com> On 9/8/07, Scott Taylor wrote: > > On Sep 7, 2007, at 3:31 PM, Geoffrey Wiseman wrote: > > > I was planning on using a fixture within a description that didn't > > modify the fixture, so I put it in a before(:all) block: > > describe "Customer", "xml" do > > fixtures :customers > > > > before(:all) do > > one = customers(:one) > > end > > > > # ... > > As a result, I got this message: > > > > 1) > > NoMethodError in 'Customer xml before(:all)' > > You have a nil object when you didn't expect it! > > You might have expected an instance of Array. > > The error occurred while evaluating nil.[] > > ./spec/models/customer_spec.rb:86: > > script/spec:4: > > If I convert it to before(:each) or simply before, it works just fine. > > describe "Customer", "xml" do > > fixtures :customers > > > > before do > > one = customers(:one) > > end > > > > # ... > > By design? bug? PEBKAC? Anyone else hit this? > > > > Looks like a bug to me, although I don't know why you would want to > load a fixture only once, and not before every test. Generally, I > don't find much use for a before(:all) block (they are discouraged in > Test::Unit as well, for their unreliable use with more than one test). > Like I said - it's by design. It's been discussed in previous mail threads. Aslak > Scott > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sat Sep 8 17:59:51 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 8 Sep 2007 16:59:51 -0500 Subject: [rspec-users] changes to TextMate bundle Message-ID: <57c63afe0709081459t7d91040bjc637309553250e02@mail.gmail.com> Hi all, I got some help from James Edward Gray II on the RSpec TextMate bundle. For those of you who don't know James, he runs the Ruby Quiz and also maintains the official TM bundle. Per a couple of patches from him and some advice that I acted on, many of the shortcuts have changed. The bad news is you'll have to learn new shortcuts. The good news is that the new shortcuts follow TextMate conventions (which they really should have from the beginning). The other good news is that we may have a chance to get the bundle into the TextMate repo once we get done w/ the current Story Runner merge. Cheers, David From mailing_lists at railsnewbie.com Sat Sep 8 18:37:18 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 8 Sep 2007 18:37:18 -0400 Subject: [rspec-users] fixtures in before(:all) In-Reply-To: <8d961d900709081447pce2eb5eqd2f222f6c41ac13@mail.gmail.com> References: <835d522e0709071231y4d33754s5c410bb7b82b5094@mail.gmail.com> <8d961d900709081447pce2eb5eqd2f222f6c41ac13@mail.gmail.com> Message-ID: <45B38F52-9DB6-40DC-A31A-E08995A10A9F@railsnewbie.com> On Sep 8, 2007, at 5:47 PM, aslak hellesoy wrote: > On 9/8/07, Scott Taylor wrote: >> >> On Sep 7, 2007, at 3:31 PM, Geoffrey Wiseman wrote: >> >>> I was planning on using a fixture within a description that didn't >>> modify the fixture, so I put it in a before(:all) block: >>> describe "Customer", "xml" do >>> fixtures :customers >>> >>> before(:all) do >>> one = customers(:one) >>> end >>> >>> # ... >>> As a result, I got this message: >>> >>> 1) >>> NoMethodError in 'Customer xml before(:all)' >>> You have a nil object when you didn't expect it! >>> You might have expected an instance of Array. >>> The error occurred while evaluating nil.[] >>> ./spec/models/customer_spec.rb:86: >>> script/spec:4: >>> If I convert it to before(:each) or simply before, it works just >>> fine. >>> describe "Customer", "xml" do >>> fixtures :customers >>> >>> before do >>> one = customers(:one) >>> end >>> >>> # ... >>> By design? bug? PEBKAC? Anyone else hit this? >>> >> >> Looks like a bug to me, although I don't know why you would want to >> load a fixture only once, and not before every test. Generally, I >> don't find much use for a before(:all) block (they are discouraged in >> Test::Unit as well, for their unreliable use with more than one >> test). >> > > Like I said - it's by design. > > It's been discussed in previous mail threads. > > Aslak Sorry, didn't see your post on the thread. Scott From leslief at sunquake.net Sat Sep 8 19:17:45 2007 From: leslief at sunquake.net (Leslie Freeman) Date: Sat, 8 Sep 2007 17:17:45 -0600 Subject: [rspec-users] Writing specs for scriptaculous helper Message-ID: I'm trying to get full specing of my views, which involve calling some Scriptaculous helpers in the views themselves. For instance, I have a div containing a bunch of thumbnails which I'm going to make sortable with sortable_element. I'm trying to figure out a good way to write a spec for this type of call. so far the closest I have gotten is to write something like response.should have_text Regexp.new('Sortable.create\ ("gallery_1_thumbnails"') Which works, but seems a bit ugly (and could possibly break if Scriptaculous changed. It just seems a little too "hard coded". Is there a better way? Thanks, Leslie From dchelimsky at gmail.com Sun Sep 9 03:41:41 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 9 Sep 2007 02:41:41 -0500 Subject: [rspec-users] Preconditions In-Reply-To: <46E2C8F5.9040108@benmabey.com> References: <835d522e0709071307xfad77d9ob6cc4c4cc1af3a4f@mail.gmail.com> <810a540e0709071359j71f75bar9df09716e9f353c8@mail.gmail.com> <835d522e0709071436u3dea7ee5wb857366d0fdf967a@mail.gmail.com> <810a540e0709071715k3b8315c3ibdf6654f576df8a1@mail.gmail.com> <4306389C-9515-4DF5-9AAB-34E652B151B7@wincent.com> <810a540e0709080818x7e31f95bp807be9dbeb50b03e@mail.gmail.com> <57c63afe0709080905jc25a150i309e85c0ea8d4e06@mail.gmail.com> <46E2C8F5.9040108@benmabey.com> Message-ID: <57c63afe0709090041xfcb58eclb80b4fadd8ab34d5@mail.gmail.com> On 9/8/07, Ben Mabey wrote: > What was the motivation behind taking that tutorial down, BTW? I really > like and benefited from it when I was starting to learn rspec. Was it > just a maintenance issue as far as updating the tutorial to the current > API (DSL)? That was part of the deal. The other part was that I thought it would be more demonstrative to have something w/ two or more classes dealing w/ interactions. Just never got around to it. We should probably resurrect the Stack tutorial in the mean time. From priit.tamboom at eesti.ee Sun Sep 9 08:29:49 2007 From: priit.tamboom at eesti.ee (Priit Tamboom) Date: Sun, 9 Sep 2007 20:29:49 +0800 Subject: [rspec-users] Going beyond the default html formatter/report? Message-ID: Hi! I wonder does anybody planning to go beyond the default html formatter/report? The current html report is nice and green but what about to go a little silly and enable also user input. For example to let customer to add a new pending spec, comments etc. I feel it might be mentally easier for some customers to jump into spec world when it is possible to give input at "the same place". Integrate to trac or very lightweight standalone stuff. However it should not be trac reinventing effort. I haven't use rspec with customer yet but planning to do so with next project, so I might overreact about this matter right now. Priit From luislavena at gmail.com Sun Sep 9 09:23:02 2007 From: luislavena at gmail.com (Luis Lavena) Date: Sun, 9 Sep 2007 10:23:02 -0300 Subject: [rspec-users] Failure Messages in RSpec + inline debugging of a spec In-Reply-To: <46E316F1.5090301@shopwatch.org> References: <835d522e0709041351va41f1a3y8dc9c6fa92d05c96@mail.gmail.com> <23CC96AA-7892-4984-A63F-7C1FA62D166C@wincent.com> <1B683236-2EDD-4B51-9B0B-7B825DB15319@railsnewbie.com> <46E316F1.5090301@shopwatch.org> Message-ID: <71166b3b0709090623q3d2d78c9iee6a23d08a2dfac6@mail.gmail.com> On 9/8/07, Jay Levitt wrote: > On 9/8/2007 4:19 PM, Scott Taylor wrote: > > So far it has been > > a mixed experience - I have found that it doesn't work very well with > > rails as you end up debugging more of rails then of your own code. > > Finally, a debugging environment that matches the production environment! > I agree. When debug is required, I switch to script/spec and specify the exact file and specification to run, in that way, reduce the problems loading ruby-debug and getting my feet wet with Rails code :) -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From aslak.hellesoy at gmail.com Sun Sep 9 16:15:25 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 9 Sep 2007 22:15:25 +0200 Subject: [rspec-users] Going beyond the default html formatter/report? In-Reply-To: References: Message-ID: <8d961d900709091315y6c4eb106s532adb47d8c032c4@mail.gmail.com> On 9/9/07, Priit Tamboom wrote: > Hi! > > I wonder does anybody planning to go beyond the default html formatter/report? > > The current html report is nice and green but what about to go a > little silly and enable also user input. For example to let customer > to add a new pending spec, comments etc. I feel it might be mentally > easier for some customers to jump into spec world when it is possible > to give input at "the same place". > > Integrate to trac or very lightweight standalone stuff. However it > should not be trac reinventing effort. > > I haven't use rspec with customer yet but planning to do so with next > project, so I might overreact about this matter right now. > This sounds like a fantastic idea. Why don't you give it a shot? Aslak > Priit > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Mon Sep 10 02:01:14 2007 From: ben at benmabey.com (Ben Mabey) Date: Mon, 10 Sep 2007 00:01:14 -0600 Subject: [rspec-users] BDD your C In-Reply-To: References: Message-ID: <46E4DDAA.6040408@benmabey.com> Hey all, A couple of weeks a go I posted a quested about using rSpec to spec C code. Soon after I posted that I found about about SWIG.. anyways, I have posted a quick example on how easy it is to use rSpec with C: http://www.benmabey.com/2007/09/09/bdd_your_c/ -Ben From ben at benmabey.com Mon Sep 10 02:08:03 2007 From: ben at benmabey.com (Ben Mabey) Date: Mon, 10 Sep 2007 00:08:03 -0600 Subject: [rspec-users] BDD your C In-Reply-To: <46E4DDAA.6040408@benmabey.com> References: <46E4DDAA.6040408@benmabey.com> Message-ID: <46E4DF43.4080204@benmabey.com> Ben Mabey wrote: > Hey all, > A couple of weeks a go I posted a quested about using rSpec to spec C > code. Soon after I posted that I found about about SWIG.. anyways, I > have posted a quick example on how easy it is to use rSpec with C: > http://www.benmabey.com/2007/09/09/bdd_your_c/ > > -Ben > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > heh.. It was actually a 'question' I posted, not a 'quested' :) From pergesu at gmail.com Mon Sep 10 02:42:44 2007 From: pergesu at gmail.com (Pat Maddox) Date: Sun, 9 Sep 2007 23:42:44 -0700 Subject: [rspec-users] BDD your C In-Reply-To: <46E4DDAA.6040408@benmabey.com> References: <46E4DDAA.6040408@benmabey.com> Message-ID: <810a540e0709092342u887e9a0wbdc5ef555a4257bf@mail.gmail.com> On 9/9/07, Ben Mabey wrote: > Hey all, > A couple of weeks a go I posted a quested about using rSpec to spec C > code. Soon after I posted that I found about about SWIG.. anyways, I > have posted a quick example on how easy it is to use rSpec with C: > http://www.benmabey.com/2007/09/09/bdd_your_c/ > > -Ben > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > That's badass. I don't write C, but thanks for sharing. Pat From win at wincent.com Mon Sep 10 06:26:18 2007 From: win at wincent.com (Wincent Colaiuta) Date: Mon, 10 Sep 2007 12:26:18 +0200 Subject: [rspec-users] BDD your C In-Reply-To: <46E4DDAA.6040408@benmabey.com> References: <46E4DDAA.6040408@benmabey.com> Message-ID: <0A816204-FD02-4C48-8B6E-0568D7AC8B0E@wincent.com> El 10/9/2007, a las 8:01, Ben Mabey escribi?: > Hey all, > A couple of weeks a go I posted a quested about using rSpec to spec C > code. Soon after I posted that I found about about SWIG.. anyways, I > have posted a quick example on how easy it is to use rSpec with C: > http://www.benmabey.com/2007/09/09/bdd_your_c/ Great stuff. The other use I've found for RSpec is testing Ruby *extensions* written in C, because then you've got your Ruby API for them anyway. Hadn't thought of using SWIG for testing non-extension C code. I'm looking forward to seeing if I can somehow test Objective-C code with RSpec and the RubyCocoa bridge once Mac OS X Leopard comes out (RubyCocoa is an open-source bridge for communicating between Ruby and Objective-C code, specifically in the Cocoa environment). Haven't looked into it yet (want to wait for RubyCocoa 1.0, and for Leopard to go public) but am hopeful that it will be possible... Cheers, Wincent From scott at tynerblain.com Mon Sep 10 10:44:59 2007 From: scott at tynerblain.com (Scott Sehlhorst) Date: Mon, 10 Sep 2007 09:44:59 -0500 Subject: [rspec-users] RSpec view spec writing problem (unable to generate url_for in RESTful resource link_to) Message-ID: <4f34789a0709100744h28fbd6dcmedb1dd59747241ed@mail.gmail.com> Thanks, first, to everyone who's asked and answered questions on this list, and to the creators of RSpec - it is all very helpful. I've searched the mailing list, and had a couple 2hr googling sessions that didn't help me find an answer. I've run into a problem getting my first non-trivial view spec to run. I get an error when trying to generate a link_to() to another resource. Here is an overview of the situation, then the code: - I'm using a restful design - I'm using nested (multiply nested) resources - I am trying to test a show.rhtml view, that includes links (link_to) to resources managed by another controller - The use_case model has a many-to-may through relationship with actors, and I'm displaying links to the associated actors on the use_case page - I can't get the links to generate when running rspec (but it works great in the app) - I am in the early stages of the project, and want to move forward BDD, but I have some existing code that I need to test before I can start moving forward again. My theories: I need to stub the controller (for the other resource), or I need to stub something else. Here's the command I'm running to drive RSpec ruby script/spec -f s spec/views Here's the error that I get 1) ActionView::TemplateError in 'UseCase showing a use case should display the use case identifier' actor_url failed to generate from {:customer_id=>"1", :controller=>"actors", :action=>"show", :project_id=>"1"}, expecte d: {:controller=>"actors", :action=>"show"}, diff: {:customer_id=>"1", :project_id=>"1"} On line #22 of app/views/use_cases/show.rhtml 19:
    20: <% @primary_actors.each do |a| %> 21:
  • 22: <%= link_to(a.name,actor_path(@customer, at project),{:class=>"show",:title=>"Show actor details"}) -%> 23: <%= link_to("Remove assignment",participation_path(@customer, at project, at use_case.participations.find_by _actor_id(a)),{:class=>"delete",:title=>"Remove the assignment of this actor to this use case", :confirm => 'Are you sur e you want to remove this assignment?', :method => :delete})-%> 24:
  • 25: <% end %> #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1273:in `raise_named_route_error' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1245:in `generate' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:104:in `rewrite_path' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:69:in `rewrite' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:522:in `url_for' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:27:in `url_for' (eval):19:in `actor_path' #{RAILS_ROOT}/app/views/use_cases/show.rhtml:22:in `_run_rhtml_47app47views47use_cases47show46rhtml' #{RAILS_ROOT}/app/views/use_cases/show.rhtml:20:in `_run_rhtml_47app47views47use_cases47show46rhtml' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:326:in `compile_and_render_template' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:301:in `render_template' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:260:in `render_file' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:806:in `render_file' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:741:in `render_with_no_layout' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/layout.rb:256:in `render_without_benchmark' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in `render' c:/dev/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in `render' C:/dev/svn/sherpa/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/view.rb:55:in `render' spec/views/use_cases/show_view_spec.rb:40 C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/composite_proc_builder.rb:17:in `proc' C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/composite_proc_builder.rb:12:in `proc' C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:71:in `before_example' C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:25:in `run' c:/dev/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout' C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:24:in `run' C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:81:in `run' C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:75:in `run' C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:58:in `run_behaviours' C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:57:in `run_behaviours' C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:21:in `run' C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in `run' script/spec:4 Here's part of my routes.rb, showing the nested resources map.resources :customers do |customers| customers.resources :projects do |projects| projects.resources :actors projects.resources :use_cases Here's some of the stubbing that I am using to set up the spec @customer = mock_model(Customer, :id => 1, :to_param => "1" ) @project = mock_model(Project, :id => 1, :customer_id => 1, :to_param => "1" ) I've also stubbed objects to create the following :assigns assigns[:customer] = @customer assigns[:project] = @project assigns[:use_case] = @use_case assigns[:primary_actors] = @primary_actors I suspect that there is something else that needs to be stubbed - actors controller, maybe? I really don't know. If anyone can point me in the right direction, or tell me where in the error message to dig deeper, that would be awesome. If I left out any important information, please let me know! And a huge thanks in advance to anyone who can help me out, or explain why this isn't supported, or point me towards any docs or articles that address this issue (because I will have it a zillion times, as almost all views in my app display content and links from more than one model). Scott -- Scott Sehlhorst, President Tyner Blain LLC http://tynerblain.com/blog http://tynerblain.com/nexus -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070910/2ec6ac69/attachment.html From dchelimsky at gmail.com Mon Sep 10 11:01:50 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 10 Sep 2007 10:01:50 -0500 Subject: [rspec-users] RSpec view spec writing problem (unable to generate url_for in RESTful resource link_to) In-Reply-To: <4f34789a0709100744h28fbd6dcmedb1dd59747241ed@mail.gmail.com> References: <4f34789a0709100744h28fbd6dcmedb1dd59747241ed@mail.gmail.com> Message-ID: <57c63afe0709100801x72760bbg61223b36274b6a55@mail.gmail.com> On 9/10/07, Scott Sehlhorst wrote: > Thanks, first, to everyone who's asked and answered questions on this list, > and to the creators of RSpec - it is all very helpful. I've searched the > mailing list, and had a couple 2hr googling sessions that didn't help me > find an answer. > > I've run into a problem getting my first non-trivial view spec to run. I > get an error when trying to generate a link_to() to another resource. Here > is an overview of the situation, then the code: > > > I'm using a restful design > I'm using nested (multiply nested) resources > I am trying to test a show.rhtml view, that includes links (link_to) to > resources managed by another controller > The use_case model has a many-to-may through relationship with actors, and > I'm displaying links to the associated actors on the use_case page > I can't get the links to generate when running rspec (but it works great in > the app) > I am in the early stages of the project, and want to move forward BDD, but I > have some existing code that I need to test before I can start moving > forward again. > My theories: I need to stub the controller (for the other resource), or I > need to stub something else. > > Here's the command I'm running to drive RSpec > > ruby script/spec -f s spec/views > > Here's the error that I get > > 1) > ActionView::TemplateError in 'UseCase showing a use case should display the > use case identifier' > actor_url failed to generate from {:customer_id=>"1", > :controller=>"actors", :action=>"show", :project_id=>"1"}, expecte > d: {:controller=>"actors", :action=>"show"}, diff: {:customer_id=>"1", > :project_id=>"1"} > On line #22 of app/views/use_cases/show.rhtml > > 19:
      > 20: <% @primary_actors.each do |a| %> > 21:
    • > 22: <%= > link_to(a.name,actor_path(@customer, at project),{:class=>"show",:title=>"Show > actor details"}) -%> > 23: <%= link_to("Remove > assignment",participation_path(@customer, at project, at use_case.participations.find_by > _actor_id(a)),{:class=>"delete",:title=>"Remove the > assignment of this actor to this use case", :confirm => 'Are you sur > e you want to remove this assignment?', :method => :delete})-%> > 24:
    • > 25: <% end %> > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1273:in > `raise_named_route_error' > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1245:in > `generate' > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:104:in > `rewrite_path' > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:69:in > `rewrite' > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:522:in > `url_for' > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:27:in > `url_for' > (eval):19:in `actor_path' > #{RAILS_ROOT}/app/views/use_cases/show.rhtml:22:in > `_run_rhtml_47app47views47use_cases47show46rhtml' > #{RAILS_ROOT}/app/views/use_cases/show.rhtml:20:in > `_run_rhtml_47app47views47use_cases47show46rhtml' > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:326:in > `compile_and_render_template' > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:301:in > `render_template' > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:260:in > `render_file' > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:806:in > `render_file' > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:741:in > `render_with_no_layout' > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/layout.rb:256:in > `render_without_benchmark' > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in > `render' > c:/dev/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in > `render' > > C:/dev/svn/sherpa/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/view.rb:55:in > `render' > spec/views/use_cases/show_view_spec.rb:40 > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/composite_proc_builder.rb:17:in > `proc' > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/composite_proc_builder.rb:12:in > `proc' > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:71:in > `before_example' > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:25:in > `run' > c:/dev/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout' > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:24:in > `run' > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:81:in > `run' > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:75:in > `run' > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:58:in > `run_behaviours' > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:57:in > `run_behaviours' > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:21:in > `run' > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > `run' > script/spec:4 > > Here's part of my routes.rb, showing the nested resources > > map.resources :customers do |customers| > customers.resources :projects do |projects| > projects.resources :actors > projects.resources :use_cases > > > Here's some of the stubbing that I am using to set up the spec > > @customer = mock_model(Customer, > :id => 1, > :to_param => "1" > ) > > @project = mock_model(Project, > :id => 1, > :customer_id => 1, > :to_param => "1" > ) > > I've also stubbed objects to create the following :assigns > > assigns[:customer] = @customer > assigns[:project] = @project > assigns[:use_case] = @use_case > assigns[:primary_actors] = @primary_actors > > I suspect that there is something else that needs to be stubbed - actors > controller, maybe? I really don't know. If anyone can point me in the > right direction, or tell me where in the error message to dig deeper, that > would be awesome. > > If I left out any important information, please let me know! And a huge > thanks in advance to anyone who can help me out, or explain why this isn't > supported, or point me towards any docs or articles that address this issue > (because I will have it a zillion times, as almost all views in my app > display content and links from more than one model). I don't think it's related to rspec. Note that the top of the error stack says: #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1273:in `raise_named_route_error' So the error is likely related to this bit: actor_path(@customer, at project) Given the nesting that you're doing multi-level nesting (which is not recommended btw - read http://weblog.jamisbuck.org/2007/2/5/nesting-resources), I believe that the path should be either: customer_project_actor_path(@customer, @project, @actor) or customer_project_actors_path(@customer, @project) HTH, David From bryan at osesm.com Mon Sep 10 11:41:34 2007 From: bryan at osesm.com (Bryan Liles) Date: Mon, 10 Sep 2007 11:41:34 -0400 Subject: [rspec-users] changes to TextMate bundle In-Reply-To: <57c63afe0709081459t7d91040bjc637309553250e02@mail.gmail.com> References: <57c63afe0709081459t7d91040bjc637309553250e02@mail.gmail.com> Message-ID: <7DEF10CE-B6B3-4FB5-8713-4262DA9F445C@osesm.com> On Sep 8, 2007, at 5:59 PM, David Chelimsky wrote: > Hi all, I got some help from James Edward Gray II on the RSpec > TextMate bundle. For those of you who don't know James, he runs the > Ruby Quiz and also maintains the official TM bundle. > > Per a couple of patches from him and some advice that I acted on, many > of the shortcuts have changed. > These patches are in trunk already? From scott at tynerblain.com Mon Sep 10 12:13:27 2007 From: scott at tynerblain.com (Scott Sehlhorst) Date: Mon, 10 Sep 2007 11:13:27 -0500 Subject: [rspec-users] RSpec view spec writing problem (unable to generate url_for in RESTful resource link_to) In-Reply-To: <57c63afe0709100801x72760bbg61223b36274b6a55@mail.gmail.com> References: <4f34789a0709100744h28fbd6dcmedb1dd59747241ed@mail.gmail.com> <57c63afe0709100801x72760bbg61223b36274b6a55@mail.gmail.com> Message-ID: <4f34789a0709100913g3b6c2463hf03f541c58c36eff@mail.gmail.com> Thanks very much. I feel like a bit of a fool, now, for the odd error. Changing from: <%= link_to(a.name,actor_path(@customer, at project),{:class=>"show",:title=>"Show actor details"}) -%> To <%= link_to(a.name,actor_path(@customer, at project,a),{:class=>"show",:title=>"Show actor details"}) -%> Caused everything to work like a champ. And uncovered an interesting bug. When not specifying the actor 'a', the link is generated (in the page), but with id=1. No idea if/when I would have caught that. Thanks again David, and all the RSpec'ers out there. Also, thanks for the multi-nesting pointer. Scott On 9/10/07, David Chelimsky wrote: > > On 9/10/07, Scott Sehlhorst wrote: > > Thanks, first, to everyone who's asked and answered questions on this > list, > > and to the creators of RSpec - it is all very helpful. I've searched > the > > mailing list, and had a couple 2hr googling sessions that didn't help me > > find an answer. > > > > I've run into a problem getting my first non-trivial view spec to > run. I > > get an error when trying to generate a link_to() to another > resource. Here > > is an overview of the situation, then the code: > > > > > > I'm using a restful design > > I'm using nested (multiply nested) resources > > I am trying to test a show.rhtml view, that includes links (link_to) to > > resources managed by another controller > > The use_case model has a many-to-may through relationship with actors, > and > > I'm displaying links to the associated actors on the use_case page > > I can't get the links to generate when running rspec (but it works great > in > > the app) > > I am in the early stages of the project, and want to move forward BDD, > but I > > have some existing code that I need to test before I can start moving > > forward again. > > My theories: I need to stub the controller (for the other resource), or > I > > need to stub something else. > > > > Here's the command I'm running to drive RSpec > > > > ruby script/spec -f s spec/views > > > > Here's the error that I get > > > > 1) > > ActionView::TemplateError in 'UseCase showing a use case should display > the > > use case identifier' > > actor_url failed to generate from {:customer_id=>"1", > > :controller=>"actors", :action=>"show", :project_id=>"1"}, expecte > > d: {:controller=>"actors", :action=>"show"}, diff: {:customer_id=>"1", > > :project_id=>"1"} > > On line #22 of app/views/use_cases/show.rhtml > > > > 19:
        > > 20: <% @primary_actors.each do |a| %> > > 21:
      • > > 22: <%= > > link_to(a.name > ,actor_path(@customer, at project),{:class=>"show",:title=>"Show > > actor details"}) -%> > > 23: <%= link_to("Remove > > > assignment",participation_path(@customer, at project, at use_case.participations.find_by > > _actor_id(a)),{:class=>"delete",:title=>"Remove the > > assignment of this actor to this use case", :confirm => 'Are you sur > > e you want to remove this assignment?', :method => :delete})-%> > > 24:
      • > > 25: <% end %> > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1273:in > > `raise_named_route_error' > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1245:in > > `generate' > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:104:in > > `rewrite_path' > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:69:in > > `rewrite' > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:522:in > > `url_for' > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:27:in > > `url_for' > > (eval):19:in `actor_path' > > #{RAILS_ROOT}/app/views/use_cases/show.rhtml:22:in > > `_run_rhtml_47app47views47use_cases47show46rhtml' > > #{RAILS_ROOT}/app/views/use_cases/show.rhtml:20:in > > `_run_rhtml_47app47views47use_cases47show46rhtml' > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:326:in > > `compile_and_render_template' > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:301:in > > `render_template' > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:260:in > > `render_file' > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:806:in > > `render_file' > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:741:in > > `render_with_no_layout' > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/layout.rb:256:in > > `render_without_benchmark' > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in > > `render' > > c:/dev/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in > > `render' > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/view.rb:55:in > > `render' > > spec/views/use_cases/show_view_spec.rb:40 > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/composite_proc_builder.rb:17:in > > `proc' > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/composite_proc_builder.rb:12:in > > `proc' > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:71:in > > `before_example' > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:25:in > > `run' > > c:/dev/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout' > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:24:in > > `run' > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:81:in > > `run' > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:75:in > > `run' > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:58:in > > `run_behaviours' > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:57:in > > `run_behaviours' > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:21:in > > `run' > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > `run' > > script/spec:4 > > > > Here's part of my routes.rb, showing the nested resources > > > > map.resources :customers do |customers| > > customers.resources :projects do |projects| > > projects.resources :actors > > projects.resources :use_cases > > > > > > Here's some of the stubbing that I am using to set up the spec > > > > @customer = mock_model(Customer, > > :id => 1, > > :to_param => "1" > > ) > > > > @project = mock_model(Project, > > :id => 1, > > :customer_id => 1, > > :to_param => "1" > > ) > > > > I've also stubbed objects to create the following :assigns > > > > assigns[:customer] = @customer > > assigns[:project] = @project > > assigns[:use_case] = @use_case > > assigns[:primary_actors] = @primary_actors > > > > I suspect that there is something else that needs to be stubbed - actors > > controller, maybe? I really don't know. If anyone can point me in the > > right direction, or tell me where in the error message to dig deeper, > that > > would be awesome. > > > > If I left out any important information, please let me know! And a huge > > thanks in advance to anyone who can help me out, or explain why this > isn't > > supported, or point me towards any docs or articles that address this > issue > > (because I will have it a zillion times, as almost all views in my app > > display content and links from more than one model). > > I don't think it's related to rspec. Note that the top of the error stack > says: > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1273:in > `raise_named_route_error' > > So the error is likely related to this bit: > > actor_path(@customer, at project) > > Given the nesting that you're doing multi-level nesting (which is not > recommended btw - read > http://weblog.jamisbuck.org/2007/2/5/nesting-resources), I believe > that the path should be either: > > customer_project_actor_path(@customer, @project, @actor) > > or > > customer_project_actors_path(@customer, @project) > > HTH, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Scott Sehlhorst, President Tyner Blain LLC http://tynerblain.com/blog http://tynerblain.com/nexus -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070910/a229d0fe/attachment.html From sudara at modernthings.net Mon Sep 10 13:00:34 2007 From: sudara at modernthings.net (sudara) Date: Mon, 10 Sep 2007 10:00:34 -0700 (PDT) Subject: [rspec-users] Rspec Caveman questions. In-Reply-To: References: <12509678.post@talk.nabble.com> Message-ID: <12597802.post@talk.nabble.com> Thanks David and Scott for your comments. @David: Your irb example worked great for exploring matchers. I was looking for a way to be able to literally write my specs in the script/server console, but I think at this point I'm almost good to go on DSL. @Scott: Yes, thanks for the tips. I'm aware that I can alias lambda - the point was more "it would be helpful for incoming users digesting DSL / it is more english-like" -I'll throw a patch in as David suggested - as soon as I figure out why my rails fixtures are not loading due to the last svn up ;) Regarding the DSL being similar to Test::Unit - I'm sure it would be easier to pick up Speccing coming from Test::Unit, but coming from nothing to a ruby/rails/rspec, even when done slowly, requires a fair bit of trial and error. Playing in the console is the most effective way (for me) to learn a DSL inside and out. Thanks both for your time! sudara -- View this message in context: http://www.nabble.com/Rspec-Caveman-questions.-tf4387721.html#a12597802 Sent from the rspec-users mailing list archive at Nabble.com. From dchelimsky at gmail.com Mon Sep 10 13:25:45 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 10 Sep 2007 12:25:45 -0500 Subject: [rspec-users] Rspec Caveman questions. In-Reply-To: <12597802.post@talk.nabble.com> References: <12509678.post@talk.nabble.com> <12597802.post@talk.nabble.com> Message-ID: <57c63afe0709101025m4da21292pc7f7d0d33e3edc4d@mail.gmail.com> On 9/10/07, sudara wrote: > > Thanks David and Scott for your comments. > > @David: Your irb example worked great for exploring matchers. I was looking > for a way to be able to literally write my specs in the script/server > console, but I think at this point I'm almost good to go on DSL. > > @Scott: Yes, thanks for the tips. I'm aware that I can alias lambda - the > point was more "it would be helpful for incoming users digesting DSL / it is > more english-like" -I'll throw a patch in as David suggested - as soon as I > figure out why my rails fixtures are not loading due to the last svn up ;) svn up again - I just fixed that > > Regarding the DSL being similar to Test::Unit - I'm sure it would be easier > to pick up Speccing coming from Test::Unit, but coming from nothing to a > ruby/rails/rspec, even when done slowly, requires a fair bit of trial and > error. Playing in the console is the most effective way (for me) to learn a > DSL inside and out. > > Thanks both for your time! > > sudara > -- > View this message in context: http://www.nabble.com/Rspec-Caveman-questions.-tf4387721.html#a12597802 > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From daniel at danielfischer.com Mon Sep 10 15:26:46 2007 From: daniel at danielfischer.com (Fischer, Daniel) Date: Mon, 10 Sep 2007 12:26:46 -0700 Subject: [rspec-users] changes to TextMate bundle In-Reply-To: <7DEF10CE-B6B3-4FB5-8713-4262DA9F445C@osesm.com> References: <57c63afe0709081459t7d91040bjc637309553250e02@mail.gmail.com> <7DEF10CE-B6B3-4FB5-8713-4262DA9F445C@osesm.com> Message-ID: <7e565b5c0709101226xa582006u444d6fcdf8474155@mail.gmail.com> Please let us know when it's updated :) On 9/10/07, Bryan Liles wrote: > > > On Sep 8, 2007, at 5:59 PM, David Chelimsky wrote: > > > Hi all, I got some help from James Edward Gray II on the RSpec > > TextMate bundle. For those of you who don't know James, he runs the > > Ruby Quiz and also maintains the official TM bundle. > > > > Per a couple of patches from him and some advice that I acted on, many > > of the shortcuts have changed. > > > > These patches are in trunk already? > _______________________________________________ > 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/20070910/ab3d9cf7/attachment.html From dchelimsky at gmail.com Mon Sep 10 15:28:00 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 10 Sep 2007 14:28:00 -0500 Subject: [rspec-users] changes to TextMate bundle In-Reply-To: <7e565b5c0709101226xa582006u444d6fcdf8474155@mail.gmail.com> References: <57c63afe0709081459t7d91040bjc637309553250e02@mail.gmail.com> <7DEF10CE-B6B3-4FB5-8713-4262DA9F445C@osesm.com> <7e565b5c0709101226xa582006u444d6fcdf8474155@mail.gmail.com> Message-ID: <57c63afe0709101228u47205fc2u1ff2fc05a630e325@mail.gmail.com> On 9/10/07, Fischer, Daniel wrote: > Please let us know when it's updated :) > > > On 9/10/07, Bryan Liles wrote: > > > > On Sep 8, 2007, at 5:59 PM, David Chelimsky wrote: > > > > > Hi all, I got some help from James Edward Gray II on the RSpec > > > TextMate bundle. For those of you who don't know James, he runs the > > > Ruby Quiz and also maintains the official TM bundle. > > > > > > Per a couple of patches from him and some advice that I acted on, many > > > of the shortcuts have changed. > > > > > > > These patches are in trunk already? Yes - already in trunk. > > _______________________________________________ > > 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 bryan at osesm.com Mon Sep 10 15:50:00 2007 From: bryan at osesm.com (Bryan Liles) Date: Mon, 10 Sep 2007 15:50:00 -0400 Subject: [rspec-users] changes to TextMate bundle In-Reply-To: <7DEF10CE-B6B3-4FB5-8713-4262DA9F445C@osesm.com> References: <57c63afe0709081459t7d91040bjc637309553250e02@mail.gmail.com> <7DEF10CE-B6B3-4FB5-8713-4262DA9F445C@osesm.com> Message-ID: <4E60F83F-34AC-46B1-ABDE-BE3A9A2567DC@osesm.com> On Sep 10, 2007, at 11:41 AM, Bryan Liles wrote: > > These patches are in trunk already? > Yes they are. ------------------------------------------------------------------------ r2544 | dchelimsky | 2007-09-08 17:43:01 -0400 (Sat, 08 Sep 2007) | 1 line reworked textmate bundle shortcuts per conversation w/ James Edward Gray II re: TextMate conventions From bret at pettichord.com Mon Sep 10 17:52:29 2007 From: bret at pettichord.com (Bret Pettichord) Date: Mon, 10 Sep 2007 16:52:29 -0500 Subject: [rspec-users] Using Rspec with ScenarioFixtures Message-ID: I am currently trying to get Rspec to work with ScenarioFixtures. http://code.google.com/p/fixture-scenarios/ http://errtheblog.com/post/7708 I did a quick search and didn't find any mention that any one else had gotten this to work yet. If i missed something, could you please drop me a line. Otherwise, expect a progress report when i get this working... Bret -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070910/fb30ffdb/attachment.html From pergesu at gmail.com Mon Sep 10 18:12:19 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 10 Sep 2007 15:12:19 -0700 Subject: [rspec-users] Removing an AR class definition, for testing plugins Message-ID: <810a540e0709101512x1054d502x217e21af7758d98@mail.gmail.com> I'm writing an acts_as_* plugin and am trying to BDD it. Ideally my specs would look like: describe ActsAsCloneable, " basic cloning" do load_example_classes School.class_eval do acts_as_cloneable end before(:each) do @old_school = School.create! :name => "Baylake Pines", :city => "Virginia Beach", :guid => "abc123" @clone = @old_school.build_clone end it "should preserve the attributes" do @clone.name.should == "Baylake Pines" @clone.city.should == "Virginia Beach" @clone.guid.should == "abc123" end it "should not clone the id" do @clone.id.should be_blank end end describe ActsAsCloneable, " while specifying an attribute not to clone" do load_example_classes School.class_eval do acts_as_cloneable :except => :guid end before(:each) do @old_school = School.create! :name => "Baylake Pines", :city => "Virginia Beach", :guid => "abc123" @clone = @old_school.build_clone end it "should preserve the regular attributes" do @clone.name.should == "Baylake Pines" @clone.city.should == "Virginia Beach" end it "should not clone the specified attribute" do @clone.guid.should be_blank end it "should not clone the uncloned attribute" do @clone.guid.should be_blank end end load_example_classes is a helper method that just defines the AR::base classes. The undefs would go there too. Unfortunately what's happening is that the definition from the second spec is being used for the first spec...so when running both specs, the first fails. However if I comment out the second spec, the first one passes. I've tried using remove_const and Object.remove_class. Neither seems to work. I need to start with a fresh class definition before each description is run...how can I do that? Pat From badcarl at gmail.com Mon Sep 10 19:40:05 2007 From: badcarl at gmail.com (Carl Porth) Date: Mon, 10 Sep 2007 16:40:05 -0700 Subject: [rspec-users] Removing an AR class definition, for testing plugins In-Reply-To: <810a540e0709101512x1054d502x217e21af7758d98@mail.gmail.com> References: <810a540e0709101512x1054d502x217e21af7758d98@mail.gmail.com> Message-ID: <0E89F544-764B-4079-86E8-63084F928EFE@gmail.com> You can do something like in rspec/spec/spec/mocks/stub_spec.rb where the class is defined in before(:each). This way your specs aren't dependent on an external class definition. Carl On Sep 10, 2007, at 3:12 PM, Pat Maddox wrote: > I'm writing an acts_as_* plugin and am trying to BDD it. Ideally my > specs would look like: > > describe ActsAsCloneable, " basic cloning" do > load_example_classes > School.class_eval do > acts_as_cloneable > end > > before(:each) do > @old_school = School.create! :name => "Baylake Pines", :city => > "Virginia Beach", :guid => "abc123" > @clone = @old_school.build_clone > end > > it "should preserve the attributes" do > @clone.name.should == "Baylake Pines" > @clone.city.should == "Virginia Beach" > @clone.guid.should == "abc123" > end > > it "should not clone the id" do > @clone.id.should be_blank > end > end > > describe ActsAsCloneable, " while specifying an attribute not to > clone" do > load_example_classes > School.class_eval do > acts_as_cloneable :except => :guid > end > > before(:each) do > @old_school = School.create! :name => "Baylake Pines", :city => > "Virginia Beach", :guid => "abc123" > @clone = @old_school.build_clone > end > > it "should preserve the regular attributes" do > @clone.name.should == "Baylake Pines" > @clone.city.should == "Virginia Beach" > end > > it "should not clone the specified attribute" do > @clone.guid.should be_blank > end > > it "should not clone the uncloned attribute" do > @clone.guid.should be_blank > end > end > > load_example_classes is a helper method that just defines the AR::base > classes. The undefs would go there too. > > Unfortunately what's happening is that the definition from the second > spec is being used for the first spec...so when running both specs, > the first fails. However if I comment out the second spec, the first > one passes. > > I've tried using remove_const and Object.remove_class. Neither seems > to work. I need to start with a fresh class definition before each > description is run...how can I do that? > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Mon Sep 10 20:10:27 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 10 Sep 2007 19:10:27 -0500 Subject: [rspec-users] Using Rspec with ScenarioFixtures In-Reply-To: References: Message-ID: <57c63afe0709101710r30c25de7i314159b45b558ce4@mail.gmail.com> On 9/10/07, Bret Pettichord wrote: > I am currently trying to get Rspec to work with ScenarioFixtures. > > http://code.google.com/p/fixture-scenarios/ > http://errtheblog.com/post/7708 > > I did a quick search and didn't find any mention that any one else had > gotten this to work yet. If i missed something, could you please drop me a > line. Hey Bret - this was just fixed in trunk - change this line in spec_helper.rb: config.fixture_path = RAILS_ROOT + '/spec/fixtures' to this: config.fixture_path = RAILS_ROOT + '/spec/fixtures/' (add a trailing slash). That should do it. Cheers, David > > Otherwise, expect a progress report when i get this working... > > Bret > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From brucezuo at gmail.com Mon Sep 10 22:47:50 2007 From: brucezuo at gmail.com (bruce zuo) Date: Mon, 10 Sep 2007 22:47:50 -0400 Subject: [rspec-users] Can NOT overides the stub! in the setup Message-ID: <9684539e0709101947r353602c9pa82a95fc7249e27f@mail.gmail.com> Hello, I am new to rSpec. I tried to search in the list, but could not find the answer, please forgive me if somebody already answered this. Here is my question: I have a stub in setup: before(:each) do @current_user = mock("devsu") # Generally, prefer stub! over should_receive in setup. User.stub!(:find).and_return(@current_user) session[:user] = @current_user.id end Where User is a model. Then I tried to overrides it within a spec in a rails CONTROLLER specs: it "descriptions...." do ... User.should_receive(:find).with("3").and_return(mock_user) get 'show', :id => 3 end I found only '3', that is right, only single quotes can overrides the stub! in setup, the "3", double quotes won't work. I am wondering if this is the way how it works? Thanks. --Bruce From dchelimsky at gmail.com Mon Sep 10 22:52:55 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 10 Sep 2007 21:52:55 -0500 Subject: [rspec-users] Can NOT overides the stub! in the setup In-Reply-To: <9684539e0709101947r353602c9pa82a95fc7249e27f@mail.gmail.com> References: <9684539e0709101947r353602c9pa82a95fc7249e27f@mail.gmail.com> Message-ID: <57c63afe0709101952s324846en860786202d53ca4a@mail.gmail.com> On 9/10/07, bruce zuo wrote: > Hello, > > I am new to rSpec. I tried to search in the list, but could not find > the answer, please forgive me if somebody already answered this. Here > is my question: > > I have a stub in setup: > > before(:each) do > @current_user = mock("devsu") > # Generally, prefer stub! over should_receive in setup. > User.stub!(:find).and_return(@current_user) > session[:user] = @current_user.id > end > Where User is a model. > > Then I tried to overrides it within a spec in a rails CONTROLLER specs: > it "descriptions...." do > ... > User.should_receive(:find).with("3").and_return(mock_user) > get 'show', :id => 3 > end > > I found only '3', that is right, only single quotes can overrides the > stub! in setup, the "3", double quotes won't work. I am wondering if > this is the way how it works? What's the error that you get when you use double quotes? > > Thanks. > > --Bruce > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Sep 10 23:17:46 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 10 Sep 2007 22:17:46 -0500 Subject: [rspec-users] Content assist for spec files In-Reply-To: <16E87D1B-9B13-4FB2-A905-A07AB0AB736D@sun.com> References: <16E87D1B-9B13-4FB2-A905-A07AB0AB736D@sun.com> Message-ID: <57c63afe0709102017j70b851ebw9e391a5006bc4366@mail.gmail.com> On 9/5/07, Tor Norbye wrote: > Hi there, > > I'm working on Ruby support for NetBeans, and we're bundling RSpec > (along with JRuby). > > One thing I'd really like to fix is having content assist (code > completion / intellisense / code insight, it has many names) work > inside your spec files such that you can not only hit ctrl-space and > see "describe", "before", "it" etc. but also see the documentation > for these methods. > > The problem is that when I'm looking at a spec file, there are no > require-statements. Obviously, the methods I see called in the spec > files must be defined by the test runner itself before running the > spec file. > > Can somebody enlighten me as to what that context looks like? > > (As an example, in Ruby on Rails "view" files, I treat the file as if > it's extending ActionView::Base, so all the methods on that class > (and included modules and such) all become available as methods you > can call from the view. I was wondering if there was a similar class, > or set of Modules, that I can use to simulate the context for the > code inside the _spec.rb file.) Hi Tor - we're in the middle of a significant refactoring that is intended, in part, to make jobs like the one you are trying to do easier. I can tell you where to look right now, but it is subject to change over the next couple of weeks. To get an idea, the files you're interested in are currently in /lib/spec/dsl and lib/spec/matchers. I'll try to follow up as things settle down. Feel free to ask here if any specific questions come up. Cheers, David > > -- Tor > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mailing_lists at railsnewbie.com Mon Sep 10 23:23:23 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Mon, 10 Sep 2007 23:23:23 -0400 Subject: [rspec-users] changes to TextMate bundle In-Reply-To: <4E60F83F-34AC-46B1-ABDE-BE3A9A2567DC@osesm.com> References: <57c63afe0709081459t7d91040bjc637309553250e02@mail.gmail.com> <7DEF10CE-B6B3-4FB5-8713-4262DA9F445C@osesm.com> <4E60F83F-34AC-46B1-ABDE-BE3A9A2567DC@osesm.com> Message-ID: <3307BB6B-51CE-4D1E-9406-8F06C3F9BEE9@railsnewbie.com> What happened to pending (with and without the block)? Scott On Sep 10, 2007, at 3:50 PM, Bryan Liles wrote: > > On Sep 10, 2007, at 11:41 AM, Bryan Liles wrote: >> >> These patches are in trunk already? >> > > Yes they are. > > ---------------------------------------------------------------------- > -- > r2544 | dchelimsky | 2007-09-08 17:43:01 -0400 (Sat, 08 Sep 2007) | 1 > line > > reworked textmate bundle shortcuts per conversation w/ James Edward > Gray II re: TextMate conventions > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mailing_lists at railsnewbie.com Mon Sep 10 23:29:36 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Mon, 10 Sep 2007 23:29:36 -0400 Subject: [rspec-users] Going beyond the default html formatter/report? In-Reply-To: <8d961d900709091315y6c4eb106s532adb47d8c032c4@mail.gmail.com> References: <8d961d900709091315y6c4eb106s532adb47d8c032c4@mail.gmail.com> Message-ID: On Sep 9, 2007, at 4:15 PM, aslak hellesoy wrote: > On 9/9/07, Priit Tamboom wrote: >> Hi! >> >> I wonder does anybody planning to go beyond the default html >> formatter/report? >> >> The current html report is nice and green but what about to go a >> little silly and enable also user input. For example to let customer >> to add a new pending spec, comments etc. I feel it might be mentally >> easier for some customers to jump into spec world when it is possible >> to give input at "the same place". >> >> Integrate to trac or very lightweight standalone stuff. However it >> should not be trac reinventing effort. >> >> I haven't use rspec with customer yet but planning to do so with next >> project, so I might overreact about this matter right now. >> > > This sounds like a fantastic idea. Why don't you give it a shot? Yeah - I'm already handing the HTML report off to my boss. He was amazed at it! I agree - this sort of thing would be really nice. Honestly, I was thinking it would be really nice to have some sort of diff'er for the HTML report - so that my boss could see what has been newly implemented between different commits. My best low tech solution was to generate the text specdoc, and diff it in trac. I would help you out with this tool (or set of tools) if they seem intriguing to you. Scott From dchelimsky at gmail.com Mon Sep 10 23:33:30 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 10 Sep 2007 22:33:30 -0500 Subject: [rspec-users] changes to TextMate bundle In-Reply-To: <3307BB6B-51CE-4D1E-9406-8F06C3F9BEE9@railsnewbie.com> References: <57c63afe0709081459t7d91040bjc637309553250e02@mail.gmail.com> <7DEF10CE-B6B3-4FB5-8713-4262DA9F445C@osesm.com> <4E60F83F-34AC-46B1-ABDE-BE3A9A2567DC@osesm.com> <3307BB6B-51CE-4D1E-9406-8F06C3F9BEE9@railsnewbie.com> Message-ID: <57c63afe0709102033p2ac8330dxbd120c06c6ff4ea8@mail.gmail.com> On 9/10/07, Scott Taylor wrote: > > What happened to pending (with and without the block)? Uh.... my dog ate it? I don't think it was in there. Or perhaps it wasn't in there correctly, because James found some errors in the bundle related to items that had no names. Feel free to patch 'em back in if you're in a hurry. If not, just raise a bug and I'll get to it soon. > > Scott > > > On Sep 10, 2007, at 3:50 PM, Bryan Liles wrote: > > > > > On Sep 10, 2007, at 11:41 AM, Bryan Liles wrote: > >> > >> These patches are in trunk already? > >> > > > > Yes they are. > > > > ---------------------------------------------------------------------- > > -- > > r2544 | dchelimsky | 2007-09-08 17:43:01 -0400 (Sat, 08 Sep 2007) | 1 > > line > > > > reworked textmate bundle shortcuts per conversation w/ James Edward > > Gray II re: TextMate conventions > > _______________________________________________ > > 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 flyeminent at hotmail.com Tue Sep 11 01:24:09 2007 From: flyeminent at hotmail.com (Shaker) Date: Mon, 10 Sep 2007 22:24:09 -0700 (PDT) Subject: [rspec-users] How to test 'Paginate'? Message-ID: <12608257.post@talk.nabble.com> Great Hi to everyone: I don't know how to write spec for a controller method which has 'paginate'. Is there any Rspec API for it? To illustrate, I would like to post an example. class PeopleController def paginate_method hash = Hash.new hash[:people_page], hash[:people] = paginate :people, ...#order and conditions omitted render :partial=>"/index", :layout=>false, :locals=>{:hash=>hash} end end Does anyone who knows how to write spec on this method? I appreciate any help. Thank you. -- View this message in context: http://www.nabble.com/How-to-test-%27Paginate%27--tf4420350.html#a12608257 Sent from the rspec-users mailing list archive at Nabble.com. From cwdinfo at gmail.com Tue Sep 11 02:25:40 2007 From: cwdinfo at gmail.com (s.ross) Date: Mon, 10 Sep 2007 23:25:40 -0700 Subject: [rspec-users] Side Effects in Stories In-Reply-To: <57c63afe0708292147k58ab553ag68b064c3fa8d1351@mail.gmail.com> References: <57c63afe0708292147k58ab553ag68b064c3fa8d1351@mail.gmail.com> Message-ID: I have a story where the user resets the password [hey, this story thing really rocks!]. It is expected that the password will change and that the user will be redirected to a login screen. A side effect is that the user will receive email with his/her new password. Where I'm stuck is in ascertaining whether mail was generated. Any thoughts on how this might be accomplished? Thanks ----------------- Story: Reset the Password As a registered user I want to be able to reset the password and have it emailed to me And then I want to log in Scenario: Reset password for an account Given A valid account is given: joe at schmoe.com When Resetting password for joe at schmoe.com Then Password state should change in database joe at schmoe.com And Registered user should be redirected to login screen And Email should be sent to the registered user And the new password should work :) From priit.tamboom at eesti.ee Tue Sep 11 03:32:48 2007 From: priit.tamboom at eesti.ee (Priit Tamboom) Date: Tue, 11 Sep 2007 15:32:48 +0800 Subject: [rspec-users] Going beyond the default html formatter/report? In-Reply-To: References: <8d961d900709091315y6c4eb106s532adb47d8c032c4@mail.gmail.com> Message-ID: > > This sounds like a fantastic idea. Why don't you give it a shot? Thanks for feedback, I'll take more active role and perhaps able to produce some useful stuff as well :-) > > Yeah - I'm already handing the HTML report off to my boss. He was > amazed at it! > > I agree - this sort of thing would be really nice. Honestly, I was > thinking it would be really nice to have some sort of diff'er for the > HTML report - so that my boss could see what has been newly > implemented between different commits. > > My best low tech solution was to generate the text specdoc, and diff > it in trac. I would help you out with this tool (or set of tools) if > they seem intriguing to you. > > Scott Very good idea indeed. Are you hanging out at rspec irc (my name is priidu there). I have more time at weekends, so we can discuss about ideas/details more quickly. Priit From jeremystellsmith at gmail.com Tue Sep 11 12:26:35 2007 From: jeremystellsmith at gmail.com (Jeremy Stell-Smith) Date: Tue, 11 Sep 2007 09:26:35 -0700 Subject: [rspec-users] changes to TextMate bundle In-Reply-To: <57c63afe0709102033p2ac8330dxbd120c06c6ff4ea8@mail.gmail.com> References: <57c63afe0709081459t7d91040bjc637309553250e02@mail.gmail.com> <7DEF10CE-B6B3-4FB5-8713-4262DA9F445C@osesm.com> <4E60F83F-34AC-46B1-ABDE-BE3A9A2567DC@osesm.com> <3307BB6B-51CE-4D1E-9406-8F06C3F9BEE9@railsnewbie.com> <57c63afe0709102033p2ac8330dxbd120c06c6ff4ea8@mail.gmail.com> Message-ID: there's a patch that i submitted to the textmate bundle to run the last example, the only thing I can't figure out is what the keyboard binding should be under the old scheme, I liked cmd+shift+i, but w/ the new... ctrl+shift+r? I use it more than cmd+r or cmd+shift+r these days. On 9/10/07, David Chelimsky wrote: > > On 9/10/07, Scott Taylor wrote: > > > > What happened to pending (with and without the block)? > > Uh.... my dog ate it? > > I don't think it was in there. Or perhaps it wasn't in there > correctly, because James found some errors in the bundle related to > items that had no names. > > Feel free to patch 'em back in if you're in a hurry. If not, just > raise a bug and I'll get to it soon. > > > > > Scott > > > > > > On Sep 10, 2007, at 3:50 PM, Bryan Liles wrote: > > > > > > > > On Sep 10, 2007, at 11:41 AM, Bryan Liles wrote: > > >> > > >> These patches are in trunk already? > > >> > > > > > > Yes they are. > > > > > > ---------------------------------------------------------------------- > > > -- > > > r2544 | dchelimsky | 2007-09-08 17:43:01 -0400 (Sat, 08 Sep 2007) | 1 > > > line > > > > > > reworked textmate bundle shortcuts per conversation w/ James Edward > > > Gray II re: TextMate conventions > > > _______________________________________________ > > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070911/55986843/attachment.html From robertrevans at gmail.com Tue Sep 11 13:39:05 2007 From: robertrevans at gmail.com (Robert Evans) Date: Tue, 11 Sep 2007 10:39:05 -0700 Subject: [rspec-users] Reason for _spec.rb convention In-Reply-To: <46DEBC43.2010300@cesmail.net> References: <32F9D508-B834-4DE6-8560-A4059CA4767E@ashleymoran.me.uk> <57c63afe0709030705g5c20fac4u3f9aa147c8621447@mail.gmail.com> <810a540e0709030711o1b7b21c5i48719443ec290148@mail.gmail.com> <57c63afe0709030714o44802f17k8df5002e8e78e84a@mail.gmail.com> <810a540e0709030727o282b43det7674d1804dd12f53@mail.gmail.com> <57c63afe0709030737o6988b228wc66984e7704e95a0@mail.gmail.com> <71B82737-3B32-44B2-98DD-26AC16AA830F@ashleymoran.me.uk> <46DDDDE6.4020300@tastapod.com> <0CD9AB4C-6438-4FCE-891D-237E62CBC02F@ashleymoran.me.uk> <46DEBC43.2010300@cesmail.net> Message-ID: <90a9a2160709111039l1e1b3a12wc1a2d3cd48a345b7@mail.gmail.com> Just to throw one more opinion into the pot, you can mimic how rails handles views and do: account.spec.rb Just a thought. Robert On 9/5/07, M. Edward (Ed) Borasky wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Ashley Moran wrote: > > On 4 Sep 2007, at 23:36, Dan North wrote: > > > >> C-hash > > > > I think you meant C-pound... > > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > No, #| (hash-pipe) > > #! (shebang) > > # aka ... octothorpe ... pound sign ... sharp ... number sign > > !!maxwellssilverhammer > > etc. ... > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.7 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFG3rxD8fKMegVjSM8RAuQWAKCBI7HxxpRpd5tTfHgv+0ovbIRXHACgklhE > jTg8zGSBsT4zXNzGFEDUksY= > =KITf > -----END PGP SIGNATURE----- > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Robert R Evans http://robertrevans.com http://rubysnips.com From geoffrey.wiseman at gmail.com Tue Sep 11 14:37:38 2007 From: geoffrey.wiseman at gmail.com (Geoffrey Wiseman) Date: Tue, 11 Sep 2007 14:37:38 -0400 Subject: [rspec-users] Caveman Questions In-Reply-To: <57c63afe0709051731we0e1dabyb638301c7a1e12ba@mail.gmail.com> References: <12498949.post@talk.nabble.com> <57c63afe0709051731we0e1dabyb638301c7a1e12ba@mail.gmail.com> Message-ID: <835d522e0709111137g72d2a01co338ff414409055b2@mail.gmail.com> On 9/5/07, David Chelimsky wrote: > > irb(main):001:0> require 'rubygems' > => true > irb(main):002:0> require 'spec' > => true > irb(main):003:0> include Spec::Matchers > => Object > irb(main):004:0> 5.should == 5 > => nil > irb(main):005:0> 5.should be < 4 > Spec::Expectations::ExpectationNotMetError: expected < 4, got 5 > $ script/console Loading development environment. >> require 'rubygems' => [] >> require 'spec' NameError: undefined method `failure_message' for class `Spec::Matchers::Have' from /work/workspace/ng/vendor/plugins/rspec_on_rails/lib/spec/matchers/have.rb:4:in `alias_method' from /work/workspace/ng/vendor/plugins/rspec_on_rails/lib/spec/matchers/have.rb:4 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' -- Geoffrey Wiseman -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070911/10992e51/attachment-0001.html From daniel at danielfischer.com Tue Sep 11 15:50:35 2007 From: daniel at danielfischer.com (Fischer, Daniel) Date: Tue, 11 Sep 2007 12:50:35 -0700 Subject: [rspec-users] changes to TextMate bundle In-Reply-To: References: <57c63afe0709081459t7d91040bjc637309553250e02@mail.gmail.com> <7DEF10CE-B6B3-4FB5-8713-4262DA9F445C@osesm.com> <4E60F83F-34AC-46B1-ABDE-BE3A9A2567DC@osesm.com> <3307BB6B-51CE-4D1E-9406-8F06C3F9BEE9@railsnewbie.com> <57c63afe0709102033p2ac8330dxbd120c06c6ff4ea8@mail.gmail.com> Message-ID: <7e565b5c0709111250n5decddbfxcdb2b2f3747729ec@mail.gmail.com> So is it just me, or is the new rspec bundle not working as intended when using the "run" shortcuts? shift + cmd + r doesn't work. (brings up ruby execution) cmd + r doesn't work. (brings up ruby execution) and option + cmd + r brings up a filter dialog They do work if I select it manually through the bundle though, so... what's up? :( Conflict in shortcuts? On 9/11/07, Jeremy Stell-Smith wrote: > > there's a patch that i submitted to the textmate bundle to run the last > example, the only thing I can't figure out is what the keyboard binding > should be > > under the old scheme, I liked cmd+shift+i, but w/ the new... > > ctrl+shift+r? I use it more than cmd+r or cmd+shift+r these days. > > On 9/10/07, David Chelimsky wrote: > > > > On 9/10/07, Scott Taylor < mailing_lists at railsnewbie.com> wrote: > > > > > > What happened to pending (with and without the block)? > > > > Uh.... my dog ate it? > > > > I don't think it was in there. Or perhaps it wasn't in there > > correctly, because James found some errors in the bundle related to > > items that had no names. > > > > Feel free to patch 'em back in if you're in a hurry. If not, just > > raise a bug and I'll get to it soon. > > > > > > > > Scott > > > > > > > > > On Sep 10, 2007, at 3:50 PM, Bryan Liles wrote: > > > > > > > > > > > On Sep 10, 2007, at 11:41 AM, Bryan Liles wrote: > > > >> > > > >> These patches are in trunk already? > > > >> > > > > > > > > Yes they are. > > > > > > > > > > ---------------------------------------------------------------------- > > > > -- > > > > r2544 | dchelimsky | 2007-09-08 17:43:01 -0400 (Sat, 08 Sep 2007) | > > 1 > > > > line > > > > > > > > reworked textmate bundle shortcuts per conversation w/ James Edward > > > > Gray II re: TextMate conventions > > > > _______________________________________________ > > > > 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 > > > > > _______________________________________________ > 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/20070911/b421c23f/attachment.html From dchelimsky at gmail.com Tue Sep 11 15:53:22 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 11 Sep 2007 14:53:22 -0500 Subject: [rspec-users] changes to TextMate bundle In-Reply-To: <7e565b5c0709111250n5decddbfxcdb2b2f3747729ec@mail.gmail.com> References: <57c63afe0709081459t7d91040bjc637309553250e02@mail.gmail.com> <7DEF10CE-B6B3-4FB5-8713-4262DA9F445C@osesm.com> <4E60F83F-34AC-46B1-ABDE-BE3A9A2567DC@osesm.com> <3307BB6B-51CE-4D1E-9406-8F06C3F9BEE9@railsnewbie.com> <57c63afe0709102033p2ac8330dxbd120c06c6ff4ea8@mail.gmail.com> <7e565b5c0709111250n5decddbfxcdb2b2f3747729ec@mail.gmail.com> Message-ID: <57c63afe0709111253n1bfaedf2jd3840fd5296c53d3@mail.gmail.com> On 9/11/07, Fischer, Daniel wrote: > So is it just me, or is the new rspec bundle not working as intended when > using the "run" shortcuts? > > shift + cmd + r doesn't work. (brings up ruby execution) > cmd + r doesn't work. (brings up ruby execution) > and option + cmd + r brings up a filter dialog You've probably got the Ruby bundle selected, not RSpec. > > They do work if I select it manually through the bundle though, so... what's > up? :( Conflict in shortcuts? > > On 9/11/07, Jeremy Stell-Smith wrote: > > there's a patch that i submitted to the textmate bundle to run the last > example, the only thing I can't figure out is what the keyboard binding > should be > > > > under the old scheme, I liked cmd+shift+i, but w/ the new... > > > > ctrl+shift+r? I use it more than cmd+r or cmd+shift+r these days. > > > > > > > > On 9/10/07, David Chelimsky < dchelimsky at gmail.com > wrote: > > > On 9/10/07, Scott Taylor < mailing_lists at railsnewbie.com> wrote: > > > > > > > > What happened to pending (with and without the block)? > > > > > > Uh.... my dog ate it? > > > > > > I don't think it was in there. Or perhaps it wasn't in there > > > correctly, because James found some errors in the bundle related to > > > items that had no names. > > > > > > Feel free to patch 'em back in if you're in a hurry. If not, just > > > raise a bug and I'll get to it soon. > > > > > > > > > > > Scott > > > > > > > > > > > > On Sep 10, 2007, at 3:50 PM, Bryan Liles wrote: > > > > > > > > > > > > > > On Sep 10, 2007, at 11:41 AM, Bryan Liles wrote: > > > > >> > > > > >> These patches are in trunk already? > > > > >> > > > > > > > > > > Yes they are. > > > > > > > > > > > ---------------------------------------------------------------------- > > > > > -- > > > > > r2544 | dchelimsky | 2007-09-08 17:43:01 -0400 (Sat, 08 Sep 2007) | > 1 > > > > > line > > > > > > > > > > reworked textmate bundle shortcuts per conversation w/ James Edward > > > > > Gray II re: TextMate conventions > > > > > _______________________________________________ > > > > > 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 > > > > > > > > > _______________________________________________ > > 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 daniel at danielfischer.com Tue Sep 11 15:56:00 2007 From: daniel at danielfischer.com (Fischer, Daniel) Date: Tue, 11 Sep 2007 12:56:00 -0700 Subject: [rspec-users] changes to TextMate bundle In-Reply-To: <57c63afe0709111253n1bfaedf2jd3840fd5296c53d3@mail.gmail.com> References: <57c63afe0709081459t7d91040bjc637309553250e02@mail.gmail.com> <7DEF10CE-B6B3-4FB5-8713-4262DA9F445C@osesm.com> <4E60F83F-34AC-46B1-ABDE-BE3A9A2567DC@osesm.com> <3307BB6B-51CE-4D1E-9406-8F06C3F9BEE9@railsnewbie.com> <57c63afe0709102033p2ac8330dxbd120c06c6ff4ea8@mail.gmail.com> <7e565b5c0709111250n5decddbfxcdb2b2f3747729ec@mail.gmail.com> <57c63afe0709111253n1bfaedf2jd3840fd5296c53d3@mail.gmail.com> Message-ID: <7e565b5c0709111256v5408558cxd5d7a060ac4d8997@mail.gmail.com> Okay, I've never "selected" a bundle before. Shouldn't the bundle automatically parse the document to see if it matches that bundle? for e.ghaving "spec" in the file name? What extra steps am I missing? On 9/11/07, David Chelimsky wrote: > > On 9/11/07, Fischer, Daniel wrote: > > So is it just me, or is the new rspec bundle not working as intended > when > > using the "run" shortcuts? > > > > shift + cmd + r doesn't work. (brings up ruby execution) > > cmd + r doesn't work. (brings up ruby execution) > > and option + cmd + r brings up a filter dialog > > You've probably got the Ruby bundle selected, not RSpec. > > > > > They do work if I select it manually through the bundle though, so... > what's > > up? :( Conflict in shortcuts? > > > > On 9/11/07, Jeremy Stell-Smith wrote: > > > there's a patch that i submitted to the textmate bundle to run the > last > > example, the only thing I can't figure out is what the keyboard binding > > should be > > > > > > under the old scheme, I liked cmd+shift+i, but w/ the new... > > > > > > ctrl+shift+r? I use it more than cmd+r or cmd+shift+r these days. > > > > > > > > > > > > On 9/10/07, David Chelimsky < dchelimsky at gmail.com > wrote: > > > > On 9/10/07, Scott Taylor < mailing_lists at railsnewbie.com> wrote: > > > > > > > > > > What happened to pending (with and without the block)? > > > > > > > > Uh.... my dog ate it? > > > > > > > > I don't think it was in there. Or perhaps it wasn't in there > > > > correctly, because James found some errors in the bundle related to > > > > items that had no names. > > > > > > > > Feel free to patch 'em back in if you're in a hurry. If not, just > > > > raise a bug and I'll get to it soon. > > > > > > > > > > > > > > Scott > > > > > > > > > > > > > > > On Sep 10, 2007, at 3:50 PM, Bryan Liles wrote: > > > > > > > > > > > > > > > > > On Sep 10, 2007, at 11:41 AM, Bryan Liles wrote: > > > > > >> > > > > > >> These patches are in trunk already? > > > > > >> > > > > > > > > > > > > Yes they are. > > > > > > > > > > > > > > ---------------------------------------------------------------------- > > > > > > -- > > > > > > r2544 | dchelimsky | 2007-09-08 17:43:01 -0400 (Sat, 08 Sep > 2007) | > > 1 > > > > > > line > > > > > > > > > > > > reworked textmate bundle shortcuts per conversation w/ James > Edward > > > > > > Gray II re: TextMate conventions > > > > > > _______________________________________________ > > > > > > 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 > > > > > > > > > > > > > _______________________________________________ > > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070911/32b6fb40/attachment.html From dchelimsky at gmail.com Tue Sep 11 15:59:23 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 11 Sep 2007 14:59:23 -0500 Subject: [rspec-users] changes to TextMate bundle In-Reply-To: <7e565b5c0709111256v5408558cxd5d7a060ac4d8997@mail.gmail.com> References: <57c63afe0709081459t7d91040bjc637309553250e02@mail.gmail.com> <7DEF10CE-B6B3-4FB5-8713-4262DA9F445C@osesm.com> <4E60F83F-34AC-46B1-ABDE-BE3A9A2567DC@osesm.com> <3307BB6B-51CE-4D1E-9406-8F06C3F9BEE9@railsnewbie.com> <57c63afe0709102033p2ac8330dxbd120c06c6ff4ea8@mail.gmail.com> <7e565b5c0709111250n5decddbfxcdb2b2f3747729ec@mail.gmail.com> <57c63afe0709111253n1bfaedf2jd3840fd5296c53d3@mail.gmail.com> <7e565b5c0709111256v5408558cxd5d7a060ac4d8997@mail.gmail.com> Message-ID: <57c63afe0709111259v480213d2we6f3fd1d8581568b@mail.gmail.com> If this was a brand new bundle you wouldn't have to, but since it's changed, and the means of identifying it has changed, you have to do it once. After that, TextMate should do the right thing. On 9/11/07, Fischer, Daniel wrote: > Okay, I've never "selected" a bundle before. Shouldn't the bundle > automatically parse the document to see if it matches that bundle? for e.g > having "spec" in the file name? What extra steps am I missing? > > > On 9/11/07, David Chelimsky wrote: > > On 9/11/07, Fischer, Daniel wrote: > > > So is it just me, or is the new rspec bundle not working as intended > when > > > using the "run" shortcuts? > > > > > > shift + cmd + r doesn't work. (brings up ruby execution) > > > cmd + r doesn't work. (brings up ruby execution) > > > and option + cmd + r brings up a filter dialog > > > > You've probably got the Ruby bundle selected, not RSpec. > > > > > > > > They do work if I select it manually through the bundle though, so... > what's > > > up? :( Conflict in shortcuts? > > > > > > On 9/11/07, Jeremy Stell-Smith < jeremystellsmith at gmail.com> wrote: > > > > there's a patch that i submitted to the textmate bundle to run the > last > > > example, the only thing I can't figure out is what the keyboard binding > > > should be > > > > > > > > under the old scheme, I liked cmd+shift+i, but w/ the new... > > > > > > > > ctrl+shift+r? I use it more than cmd+r or cmd+shift+r these days. > > > > > > > > > > > > > > > > On 9/10/07, David Chelimsky < dchelimsky at gmail.com > wrote: > > > > > On 9/10/07, Scott Taylor < mailing_lists at railsnewbie.com > wrote: > > > > > > > > > > > > What happened to pending (with and without the block)? > > > > > > > > > > Uh.... my dog ate it? > > > > > > > > > > I don't think it was in there. Or perhaps it wasn't in there > > > > > correctly, because James found some errors in the bundle related to > > > > > items that had no names. > > > > > > > > > > Feel free to patch 'em back in if you're in a hurry. If not, just > > > > > raise a bug and I'll get to it soon. > > > > > > > > > > > > > > > > > Scott > > > > > > > > > > > > > > > > > > On Sep 10, 2007, at 3:50 PM, Bryan Liles wrote: > > > > > > > > > > > > > > > > > > > > On Sep 10, 2007, at 11:41 AM, Bryan Liles wrote: > > > > > > >> > > > > > > >> These patches are in trunk already? > > > > > > >> > > > > > > > > > > > > > > Yes they are. > > > > > > > > > > > > > > > > > > ---------------------------------------------------------------------- > > > > > > > -- > > > > > > > r2544 | dchelimsky | 2007-09-08 17:43:01 -0400 (Sat, 08 Sep > 2007) | > > > 1 > > > > > > > line > > > > > > > > > > > > > > reworked textmate bundle shortcuts per conversation w/ James > Edward > > > > > > > Gray II re: TextMate conventions > > > > > > > _______________________________________________ > > > > > > > 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 > > > > > > > > > > > > > > > > > _______________________________________________ > > > > 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 > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From geoffrey.wiseman at gmail.com Tue Sep 11 16:38:13 2007 From: geoffrey.wiseman at gmail.com (Geoffrey Wiseman) Date: Tue, 11 Sep 2007 16:38:13 -0400 Subject: [rspec-users] Going beyond the default html formatter/report? In-Reply-To: References: Message-ID: <835d522e0709111338v215d0f22h4ad5a6c6f3cc777b@mail.gmail.com> On 9/9/07, Priit Tamboom wrote: > > I wonder does anybody planning to go beyond the default html > formatter/report? > Two things on that subject came up today, during some RSpec work. It would be nice if: 1. The report contained pending messages, when specified, e.g.: > describe "Secure passwords with MD5" do pending "Waiting on selection of an MD5 library." end > The HTML report contains 'Secure passwords with MD5' as pending, but does not add the explanation as to why. 2. It would be nice to be able to use DHTML expansion to see the source of the spec, sometimes; when we're doing walkthroughs with the customer representative, it's useful for him to be able to see the source as well as the descriptions. - Geoffrey -- Geoffrey Wiseman -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070911/48208b08/attachment.html From dchelimsky at gmail.com Tue Sep 11 16:54:34 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 11 Sep 2007 15:54:34 -0500 Subject: [rspec-users] Going beyond the default html formatter/report? In-Reply-To: <835d522e0709111338v215d0f22h4ad5a6c6f3cc777b@mail.gmail.com> References: <835d522e0709111338v215d0f22h4ad5a6c6f3cc777b@mail.gmail.com> Message-ID: <57c63afe0709111354n1fc8628s260986eeea164a18@mail.gmail.com> On 9/11/07, Geoffrey Wiseman wrote: > On 9/9/07, Priit Tamboom wrote: > > I wonder does anybody planning to go beyond the default html > formatter/report? > > > > Two things on that subject came up today, during some RSpec work. It would > be nice if: > > The report contained pending messages, when specified, e.g.: > > describe "Secure passwords with MD5" do > > > pending "Waiting on selection of an MD5 library." > > > end > > > The HTML report contains 'Secure passwords with MD5' as pending, but does > not add the explanation as to why. > It would be nice to be able to use DHTML expansion to see the source of the > spec, sometimes; when we're doing walkthroughs with the customer > representative, it's useful for him to be able to see the source as well as > the descriptions. - Geoffrey These are great suggestions. Please, please, please put these in feature requests where they are guaranteed to stay on the radar and not on this list where they are guaranteed to get lost in the shuffle. Cheers, David > -- > Geoffrey Wiseman > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From geoffrey.wiseman at gmail.com Tue Sep 11 17:23:16 2007 From: geoffrey.wiseman at gmail.com (Geoffrey Wiseman) Date: Tue, 11 Sep 2007 17:23:16 -0400 Subject: [rspec-users] Going beyond the default html formatter/report? In-Reply-To: <57c63afe0709111354n1fc8628s260986eeea164a18@mail.gmail.com> References: <835d522e0709111338v215d0f22h4ad5a6c6f3cc777b@mail.gmail.com> <57c63afe0709111354n1fc8628s260986eeea164a18@mail.gmail.com> Message-ID: <835d522e0709111423x5740dfcbq8e86718bbe2d2b4@mail.gmail.com> On 9/11/07, David Chelimsky wrote: > > On 9/11/07, Geoffrey Wiseman wrote: > > On 9/9/07, Priit Tamboom wrote: > > > I wonder does anybody planning to go beyond the default html > > formatter/report? > > > > > > > Two things on that subject came up today, during some RSpec work. It > would > > be nice if: > > > > The report contained pending messages, when specified, e.g.: > > > describe "Secure passwords with MD5" do > > > > > pending "Waiting on selection of an MD5 library." > > > > > end > > > > > The HTML report contains 'Secure passwords with MD5' as pending, but > does > > not add the explanation as to why. > > It would be nice to be able to use DHTML expansion to see the source of > the > > spec, sometimes; when we're doing walkthroughs with the customer > > representative, it's useful for him to be able to see the source as well > as > > the descriptions. - Geoffrey > > These are great suggestions. Please, please, please put these in > feature requests where they are guaranteed to stay on the radar and > not on this list where they are guaranteed to get lost in the shuffle. > Sure; just wasn't sure if the people volunteering to look at the report were likely to use the tracker, but ... I guess as long as they appear in the tracker, that's the main thing, and then regardless of who implements them and when, it's captured. -- Geoffrey Wiseman -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070911/8d54b8f7/attachment.html From mailing_lists at railsnewbie.com Tue Sep 11 17:28:56 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 11 Sep 2007 17:28:56 -0400 Subject: [rspec-users] Going beyond the default html formatter/report? In-Reply-To: <57c63afe0709111354n1fc8628s260986eeea164a18@mail.gmail.com> References: <835d522e0709111338v215d0f22h4ad5a6c6f3cc777b@mail.gmail.com> <57c63afe0709111354n1fc8628s260986eeea164a18@mail.gmail.com> Message-ID: <144273A2-9EA4-49C9-A57C-270354C426C3@railsnewbie.com> On Sep 11, 2007, at 4:54 PM, David Chelimsky wrote: > On 9/11/07, Geoffrey Wiseman wrote: >> On 9/9/07, Priit Tamboom wrote: >>> I wonder does anybody planning to go beyond the default html >> formatter/report? >>> >> >> Two things on that subject came up today, during some RSpec work. >> It would >> be nice if: >> >> The report contained pending messages, when specified, e.g.: >>> describe "Secure passwords with MD5" do >> >>> pending "Waiting on selection of an MD5 library." >> >>> end >>> >> The HTML report contains 'Secure passwords with MD5' as pending, >> but does >> not add the explanation as to why. >> It would be nice to be able to use DHTML expansion to see the >> source of the >> spec, sometimes; when we're doing walkthroughs with the customer >> representative, it's useful for him to be able to see the source >> as well as >> the descriptions. - Geoffrey > > These are great suggestions. Please, please, please put these in > feature requests where they are guaranteed to stay on the radar and > not on this list where they are guaranteed to get lost in the shuffle. Good idea. I'll do this for my feature now. Scott From mvyver at gmail.com Tue Sep 11 23:02:56 2007 From: mvyver at gmail.com (Mark Van De Vyver) Date: Wed, 12 Sep 2007 13:02:56 +1000 Subject: [rspec-users] A puzzling spec failure in a shared describe Message-ID: <389c43e40709112002q78f7b21fy5f66acad11ffd726@mail.gmail.com> Hi, Thanks for all the effort that has gone into making RSpec available. I'm not a professional developer and I've found the approach articulated has helped me a lot in writing my code, and understanding that of others. To cut my teeth, I'm trying to write an db adapter for the og project. I've being iterating with RSpec and it's exposed some unexpected behavior in OG, and helped me to understand some of OGs behavior, but I've hit a snag..... Perhaps someone will be kind enough to point out why I see the 4 failures listed in the attached log when I run the attached spec file, and even kinder to suggest how I might get this working :) Specifically, I'm puzzled by the following failure: 1) 'A default (DbiAdapter) connection to a new Og store should refer to the default database in its 'name' attribute.' FAILED expected: :memory, got: "test" (using ==) /usr/src/nitro-repo/og/test/og/adapter/dbi.rb:242: /usr/src/nitro-repo/og/test/og/adapter/dbi.rb:318: The text refers to the description of a set of expectatons far away from the lines references, in fact those line numbers refer to different describe section altogether. The 'got "test"' suggest it was running a spec around the line numbers cited, but the describe 'text' is out of sync. I suspect I'm don't understand the scope and contexts of the rspec components, or I may just be doing things back to front - I've read the simple tutorials, but have found and more advanced "how to" just yet - I'd greatly appreciate any pointers/hints someone can offer. There do seem to be some issues, such as 'you can't use an objects method twice in a describe block', but I may be misunderstand something I've seen? Anyway, hopefully it is not necessary, but if you need to run the spec file I can try help you get OG to that point, but that could be tricky - not all changes I've made have been submitted or accepted yet. Hopefully you can just see my error from a glance at the spec file? Perhaps you can comment on what should be done differently to be closer to rspec best-practice. I think this is the first adapter spec file so can probably be used as a template for others in the project? As I said, I suspect I'm missing something about how rspec works... one issue that isn't clear from the rspec site is the scope of variables in a spec file... Final Q: Has there been a resolution of the Mock issue, i.e will it rspec implementation stay in rspec or not. Which of mocha and flexmock are most compatible (i.e. work) with rspec, or is there a 'better' mock project to use with rspec. Appreciate any help or insight you can offer. Regards Mark -------------- next part -------------- A non-text attachment was scrubbed... Name: dbi.rb Type: application/x-ruby Size: 12540 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070912/61840dc6/attachment-0002.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: drbi_rb_test.log Type: text/x-log Size: 1806 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070912/61840dc6/attachment-0003.bin From mvyver at gmail.com Tue Sep 11 23:02:56 2007 From: mvyver at gmail.com (Mark Van De Vyver) Date: Wed, 12 Sep 2007 13:02:56 +1000 Subject: [rspec-users] A puzzling spec failure in a shared describe Message-ID: <389c43e40709112002q78f7b21fy5f66acad11ffd726@mail.gmail.com> Hi, Thanks for all the effort that has gone into making RSpec available. I'm not a professional developer and I've found the approach articulated has helped me a lot in writing my code, and understanding that of others. To cut my teeth, I'm trying to write an db adapter for the og project. I've being iterating with RSpec and it's exposed some unexpected behavior in OG, and helped me to understand some of OGs behavior, but I've hit a snag..... Perhaps someone will be kind enough to point out why I see the 4 failures listed in the attached log when I run the attached spec file, and even kinder to suggest how I might get this working :) Specifically, I'm puzzled by the following failure: 1) 'A default (DbiAdapter) connection to a new Og store should refer to the default database in its 'name' attribute.' FAILED expected: :memory, got: "test" (using ==) /usr/src/nitro-repo/og/test/og/adapter/dbi.rb:242: /usr/src/nitro-repo/og/test/og/adapter/dbi.rb:318: The text refers to the description of a set of expectatons far away from the lines references, in fact those line numbers refer to different describe section altogether. The 'got "test"' suggest it was running a spec around the line numbers cited, but the describe 'text' is out of sync. I suspect I'm don't understand the scope and contexts of the rspec components, or I may just be doing things back to front - I've read the simple tutorials, but have found and more advanced "how to" just yet - I'd greatly appreciate any pointers/hints someone can offer. There do seem to be some issues, such as 'you can't use an objects method twice in a describe block', but I may be misunderstand something I've seen? Anyway, hopefully it is not necessary, but if you need to run the spec file I can try help you get OG to that point, but that could be tricky - not all changes I've made have been submitted or accepted yet. Hopefully you can just see my error from a glance at the spec file? Perhaps you can comment on what should be done differently to be closer to rspec best-practice. I think this is the first adapter spec file so can probably be used as a template for others in the project? As I said, I suspect I'm missing something about how rspec works... one issue that isn't clear from the rspec site is the scope of variables in a spec file... Final Q: Has there been a resolution of the Mock issue, i.e will it rspec implementation stay in rspec or not. Which of mocha and flexmock are most compatible (i.e. work) with rspec, or is there a 'better' mock project to use with rspec. Appreciate any help or insight you can offer. Regards Mark -------------- next part -------------- A non-text attachment was scrubbed... Name: dbi.rb Type: application/x-ruby Size: 12540 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070912/61840dc6/attachment-0004.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: drbi_rb_test.log Type: text/x-log Size: 1806 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070912/61840dc6/attachment-0005.bin From flyeminent at hotmail.com Wed Sep 12 05:01:09 2007 From: flyeminent at hotmail.com (Shaker) Date: Wed, 12 Sep 2007 02:01:09 -0700 (PDT) Subject: [rspec-users] Can not Message-ID: <12631491.post@talk.nabble.com> -- View this message in context: http://www.nabble.com/Can-not-tf4427918.html#a12631491 Sent from the rspec-users mailing list archive at Nabble.com. From flyeminent at hotmail.com Wed Sep 12 05:20:31 2007 From: flyeminent at hotmail.com (Shaker) Date: Wed, 12 Sep 2007 02:20:31 -0700 (PDT) Subject: [rspec-users] Can not 'assigns' value in View test Message-ID: <12631788.post@talk.nabble.com> Hello everyone: I am quit new to View test using rspec. I want to write spec for a partial, which is rendered by a controller. However, the controller does not pass data to the partial using instance variables, it uses symbol variable instead. I read the example of view spec provided in the website. But the example is using instance variable. So I am looking for a way of assigning my test data to the partial to be tested. I would like to show an my code below: class MyController def index hash = {...#data provided here} render :partial=>'index', :layout=>false, :locals=>{:hash=>hash} end end _index.rhtml ......#unrelated code omitted In my spec, I used assigns[:hash] = my_own_data, but an error occurred, saying that "undefined local variable or method 'hash' ". How can I assign my own data to hash in my view spec? Thank you! -- View this message in context: http://www.nabble.com/Can-not-%27assigns%27-value-in-View-test-tf4428018.html#a12631788 Sent from the rspec-users mailing list archive at Nabble.com. From chrisdpratt at gmail.com Wed Sep 12 16:23:32 2007 From: chrisdpratt at gmail.com (Christopher D. Pratt) Date: Wed, 12 Sep 2007 15:23:32 -0500 Subject: [rspec-users] A puzzling spec failure in a shared describe In-Reply-To: <389c43e40709112002q78f7b21fy5f66acad11ffd726@mail.gmail.com> References: <389c43e40709112002q78f7b21fy5f66acad11ffd726@mail.gmail.com> Message-ID: <79a30c430709121323l17095e74xc0c15ed55b93f41a@mail.gmail.com> I'm not really sure about your error, so hopefully someone more skilled than me can help you with that. As far as the "mock issue" goes, I don't think that was anything more than a suggestion. I don't foresee RSpec removing it's built in mocking. If you want/need to use another mocking framework, I know that Mocha and RSpec play well. Not sure about FlexMock. Chris Pratt On 9/11/07, Mark Van De Vyver wrote: > > Hi, > Thanks for all the effort that has gone into making RSpec available. > I'm not a professional developer and I've found the approach > articulated has helped me a lot in writing my code, and understanding > that of others. > > To cut my teeth, I'm trying to write an db adapter for the og project. > > I've being iterating with RSpec and it's exposed some unexpected > behavior in OG, and helped me to understand some of OGs behavior, but > I've hit a snag..... > Perhaps someone will be kind enough to point out why I see the 4 > failures listed in the > attached log when I run the attached spec file, and even kinder to > suggest how I might get this working :) > > Specifically, I'm puzzled by the following failure: > > 1) > 'A default (DbiAdapter) connection to a new Og store should refer to > the default database in its 'name' attribute.' FAILED > expected: :memory, > got: "test" (using ==) > /usr/src/nitro-repo/og/test/og/adapter/dbi.rb:242: > /usr/src/nitro-repo/og/test/og/adapter/dbi.rb:318: > > The text refers to the description of a set of expectatons far away > from the lines references, in fact those line numbers refer to > different describe section altogether. The 'got "test"' suggest it > was running a spec around the line numbers cited, but the describe > 'text' is out of sync. > > I suspect I'm don't understand the scope and contexts of the rspec > components, or I may just be doing things back to front - I've read > the simple tutorials, but have found and more advanced "how to" just > yet - I'd greatly appreciate any pointers/hints someone can offer. > > There do seem to be some issues, such as 'you can't use an objects > method twice in a describe block', but I may be misunderstand > something I've seen? > > Anyway, hopefully it is not necessary, but if you need to run the spec > file I can try help you get OG to that point, but that could be tricky > - not all changes I've made have been > submitted or accepted yet. > > Hopefully you can just see my error from a glance at the spec file? > > Perhaps you can comment on what should be done differently to be > closer to rspec best-practice. > I think this is the first adapter spec file so can probably be used as > a template for others in the project? > > As I said, I suspect I'm missing something about how rspec works... one > issue > that isn't clear from the rspec site is the scope of variables in a > spec file... > > Final Q: > Has there been a resolution of the Mock issue, i.e will it rspec > implementation stay in rspec or not. > Which of mocha and flexmock are most compatible (i.e. work) with > rspec, or is there a 'better' mock project to use with rspec. > > Appreciate any help or insight you can offer. > > Regards > Mark > > _______________________________________________ > 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/20070912/f4da2c9a/attachment-0001.html From evan at tiggerpalace.com Wed Sep 12 15:55:20 2007 From: evan at tiggerpalace.com (Evan David Light) Date: Wed, 12 Sep 2007 15:55:20 -0400 Subject: [rspec-users] Philosophical questions Message-ID: <977ACF0A-3D96-403F-A1F5-6E0132AFA438@tiggerpalace.com> Disclaimer: The following are observations by a relatively new user (couple of weeks) of RSpec and not intended as RSpec trollbait. Also, forgive me if similar topics have been discussed elsewhere on the mailing list. I at least did the due diligence of a quick search. That said... I've been positively thrilled with RSpec for use outside of Rails. It has been in my attempts to use it within Rails that I have begun to question whether and how it can buy me much more than Test::Unit. I recently began using RSpec to drive the design, in BDD fashion, of a Rails app. Believing that behavior is best measured from the user's experience, I started by writing a View spec. I considered this a top-down approach. Were I still using Test::Unit, I likely would have started in the same place that I usually do out of habit: the Model. However, the more googling that I've done, the more that I noticed that most RSpec articles, where they addressed Rails, were primarily focused on the Model. I began to wonder, "are people using RSpec much like people were using Test::Unit?" I've seen that some people eschew View Specs. However, in lieu of that, how does one spec the interface that should, in theory, drive the design of the application? Ultimately, I'm left with similar perspective to Jordan's: View specs will be brittle. They'll span multiple Behaviors as there will be at least one per action -- leading me to wonder if BDD, or at least RSpec, is necessarily the best way to try to spec the View. However, Controllers and Models seem as though they would work reasonably well. Can anyone recommend some approaches for tackling BDD starting from the View down? Thanks, Evan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070912/cef3e0b7/attachment.html From evan at tiggerpalace.com Wed Sep 12 15:57:34 2007 From: evan at tiggerpalace.com (Evan David Light) Date: Wed, 12 Sep 2007 15:57:34 -0400 Subject: [rspec-users] Can not 'assigns' value in View test In-Reply-To: <12631788.post@talk.nabble.com> References: <12631788.post@talk.nabble.com> Message-ID: <061C5749-5D23-4929-AB09-6FB9B1F42A73@tiggerpalace.com> Granted that I'm new too; however, assigns[:hash] creates a member variable @hash that is made available to the view. Maybe that's the problem? Modify your view to use @hash instead. On Sep 12, 2007, at 5:20 AM, Shaker wrote: > > Hello everyone: > I am quit new to View test using rspec. I want to write spec for a > partial, which is rendered by a controller. However, the controller > does not > pass data to the partial using instance variables, it uses symbol > variable > instead. I read the example of view spec provided in the website. > But the > example is using instance variable. So I am looking for a way of > assigning > my test data to the partial to be tested. I would like to show an > my code > below: > class MyController > def index > hash = {...#data provided here} > render :partial=>'index', :layout=>false, :locals=>{:hash=>hash} > end > end > > _index.rhtml > ......#unrelated code omitted > > > In my spec, I used assigns[:hash] = my_own_data, but an error > occurred, > saying that "undefined local variable or method 'hash' ". > How can I assign my own data to hash in my view spec? > Thank you! > > -- > View this message in context: http://www.nabble.com/Can-not-% > 27assigns%27-value-in-View-test-tf4428018.html#a12631788 > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Wed Sep 12 17:36:05 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 12 Sep 2007 16:36:05 -0500 Subject: [rspec-users] Can not 'assigns' value in View test In-Reply-To: <061C5749-5D23-4929-AB09-6FB9B1F42A73@tiggerpalace.com> References: <12631788.post@talk.nabble.com> <061C5749-5D23-4929-AB09-6FB9B1F42A73@tiggerpalace.com> Message-ID: <57c63afe0709121436g6de8dc71teb80fc38bf7c9deb@mail.gmail.com> On 9/12/07, Evan David Light wrote: > Granted that I'm new too; however, assigns[:hash] creates a member > variable @hash that is made available to the view. Maybe that's the > problem? Modify your view to use @hash instead. http://rspec.rubyforge.org/documentation/rails/writing/views.html > > On Sep 12, 2007, at 5:20 AM, Shaker wrote: > > > > > Hello everyone: > > I am quit new to View test using rspec. I want to write spec for a > > partial, which is rendered by a controller. However, the controller > > does not > > pass data to the partial using instance variables, it uses symbol > > variable > > instead. I read the example of view spec provided in the website. > > But the > > example is using instance variable. So I am looking for a way of > > assigning > > my test data to the partial to be tested. I would like to show an > > my code > > below: > > class MyController > > def index > > hash = {...#data provided here} > > render :partial=>'index', :layout=>false, :locals=>{:hash=>hash} > > end > > end > > > > _index.rhtml > > ......#unrelated code omitted > > > > > > In my spec, I used assigns[:hash] = my_own_data, but an error > > occurred, > > saying that "undefined local variable or method 'hash' ". > > How can I assign my own data to hash in my view spec? > > Thank you! > > > > -- > > View this message in context: http://www.nabble.com/Can-not-% > > 27assigns%27-value-in-View-test-tf4428018.html#a12631788 > > Sent from the rspec-users mailing list archive at Nabble.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 lists-rspec at shopwatch.org Wed Sep 12 18:13:55 2007 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Wed, 12 Sep 2007 18:13:55 -0400 Subject: [rspec-users] Philosophical questions In-Reply-To: <977ACF0A-3D96-403F-A1F5-6E0132AFA438@tiggerpalace.com> References: <977ACF0A-3D96-403F-A1F5-6E0132AFA438@tiggerpalace.com> Message-ID: <46E864A3.1030106@shopwatch.org> On 9/12/2007 3:55 PM, Evan David Light wrote: > Disclaimer: The following are observations by a relatively new user > (couple of weeks) of RSpec and not intended as RSpec trollbait. Also, > forgive me if similar topics have been discussed elsewhere on the > mailing list. I at least did the due diligence of a quick search. > > That said... > > I've been positively thrilled with RSpec for use outside of Rails. It > has been in my attempts to use it within Rails that I have begun to > question whether and how it can buy me much more than Test::Unit. > > I recently began using RSpec to drive the design, in BDD fashion, of a > Rails app. Believing that behavior is best measured from the user's > experience, I started by writing a View spec. I considered this a > top-down approach. Were I still using Test::Unit, I likely would have > started in the same place that I usually do out of habit: the Model. > > However, the more googling that I've done, the more that I noticed that > most RSpec articles, where they addressed Rails, were primarily focused > on the Model. I began to wonder, "are people using RSpec much like > people were using Test::Unit?" I've seen that some people eschew View > Specs . > However, in lieu of that, how does one spec the interface that should, > in theory, drive the design of the application? > > Ultimately, I'm left with similar perspective to Jordan's: View specs > will be brittle. They'll span multiple Behaviors as there will be at > least one per action -- leading me to wonder if BDD, or at least RSpec, > is necessarily the best way to try to spec the View. However, > Controllers and Models seem as though they would work reasonably well. > > Can anyone recommend some approaches for tackling BDD starting from the > View down? I think it's really hard right now for exactly the reasons you mention. I think Story Runner will make it much, much easier. Jay From dchelimsky at gmail.com Wed Sep 12 18:15:43 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 12 Sep 2007 17:15:43 -0500 Subject: [rspec-users] Philosophical questions In-Reply-To: <977ACF0A-3D96-403F-A1F5-6E0132AFA438@tiggerpalace.com> References: <977ACF0A-3D96-403F-A1F5-6E0132AFA438@tiggerpalace.com> Message-ID: <57c63afe0709121515l314f40e3l33846197d6fe6e10@mail.gmail.com> On 9/12/07, Evan David Light wrote: > Disclaimer: The following are observations by a relatively new user (couple > of weeks) of RSpec and not intended as RSpec trollbait. Also, forgive me if > similar topics have been discussed elsewhere on the mailing list. I at > least did the due diligence of a quick search. > > That said... > > I've been positively thrilled with RSpec for use outside of Rails. It has > been in my attempts to use it within Rails that I have begun to question > whether and how it can buy me much more than Test::Unit. > > I recently began using RSpec to drive the design, in BDD fashion, of a > Rails app. Believing that behavior is best measured from the user's > experience, I started by writing a View spec. I considered this a top-down > approach. Were I still using Test::Unit, I likely would have started in the > same place that I usually do out of habit: the Model. > > However, the more googling that I've done, the more that I noticed that > most RSpec articles, where they addressed Rails, were primarily focused on > the Model. I began to wonder, "are people using RSpec much like people were > using Test::Unit?" I've seen that some people eschew View Specs. However, > in lieu of that, how does one spec the interface that should, in theory, > drive the design of the application? > > Ultimately, I'm left with similar perspective to Jordan's: View specs will > be brittle. They'll span multiple Behaviors as there will be at least one > per action -- leading me to wonder if BDD, or at least RSpec, is necessarily > the best way to try to spec the View. However, Controllers and Models seem > as though they would work reasonably well. I like to start w/ integration tests before anything exists at all. You can do that w/ Rails' Integration Tests or Story Runner (if you're using RSpec's trunk). Next, I hit a view. View specs DO get brittle fast, and such warnings are useful advice, however that does not mean you shouldn't do them. If you change a view template and a loose an important form element then the form doesn't work. That's broken software, brittle specs or not. If you don't want broken software, then spec the views - but ONLY the stuff that actually has business value. Once the view is sufficiently spec'd and the specs are passing, I know what the controller needs to supply, so I start spec'ing the controller. And on down to models. I think the reason there's so much posted about spec'ing models is because there's so much controversy over "the right way" to do it. The sad fact is that spec'ing models sucks if you're trying to keep "pure BDD" (can someone explain what that means?) because it means you end up either testing stuff that's already tested by Rails (a TDD no-no) or you're hitting the database (another TDD no-no). On the flip side, if you're trying to get things to go fast and keep things isolated, then you end up violating BDD sensibilities, which also sucks. The thing is that most of the debate has been about aesthetics and hypotheticals. We'll learn a lot more over time as people who espouse different approaches write about how the different approaches effect the long term. The whole reason we started the BDD discussion was because ppl were trying TDD and not getting stuff done because they kept over-engineering themselves down rat holes! In the end, that's the most important measure: Does your approach help you get stuff done? If an approach isn't helping you getting stuff done, then it's just BDC: Bullshit Driven Catastrophe. That's not to say that the philosophy isn't important. I, personally, love talking about philosophy. It helps me to understand why I gravitate towards the things I do. But keep in mind that philosophy/theory is usually there to try to explain natural phenomena. Design patterns just were - they weren't created. They were then recognized, documented, and now instead of solving problems with them people create problems with them by thinking about using them before there's a problem to solve. They were never there to solve problems in advance. They were there to solve problems you were actually having. Same w/ approaches to testing and developing software. Agile isn't all that agile if we're all finding "best practices" and applying them like a bunch of blind followers of some religion. "We have come to value individuals and interactions over processes and tools," yet we're always becoming slave to the next tool rather than becoming its master and sticking it in our tool belt. Wow - that was an unexpected rant. Thanks for prompting it!!! Guess the whole religion thing has been on my mind for a while. Summing up - the series of steps I described above is what I *usually* do because I know it works for me and the way I work. But I don't do that 100% of the time, and I certainly don't feel bad when I break that pattern. It's just a great tool to have lying around. Cheers, David > > Can anyone recommend some approaches for tackling BDD starting from the > View down? > > Thanks, > Evan > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From bret at pettichord.com Wed Sep 12 18:50:53 2007 From: bret at pettichord.com (Bret Pettichord) Date: Wed, 12 Sep 2007 17:50:53 -0500 Subject: [rspec-users] Checking out Rspec Message-ID: I'm getting the following error when i either checkout or update from svn://rubyforge.org/var/svn/rspec/trunk svn: Error processing command 'mv' in 'C:\work\rspec2\RSpec.tmbundle\Preferences' svn: Can't move source to dest svn: Cannot rename file 'C:\work\rspec2\RSpec.tmbundle\Preferences\.svn\tmp\text-base\Symbol List: Behaviour.tmPreferences.svn-base' For what i am doing right now, i was able to workaround this by checking out svn://rubyforge.org/var/svn/rspec/trunk/rspec instead, but i liked having the whole kibboodle, because there is so much cool stuff in there to steal from. Is this a known problem? Is this a bug or just some how how bundles are supposed to be packaged? Bret -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070912/f1386fa7/attachment.html From evan at tiggerpalace.com Wed Sep 12 19:11:59 2007 From: evan at tiggerpalace.com (Evan David Light) Date: Wed, 12 Sep 2007 19:11:59 -0400 Subject: [rspec-users] Philosophical questions In-Reply-To: <57c63afe0709121515l314f40e3l33846197d6fe6e10@mail.gmail.com> References: <977ACF0A-3D96-403F-A1F5-6E0132AFA438@tiggerpalace.com> <57c63afe0709121515l314f40e3l33846197d6fe6e10@mail.gmail.com> Message-ID: Awesome! That's a whole lot more of a response than I had anticipated. Thanks! On Sep 12, 2007, at 6:15 PM, David Chelimsky wrote: > On 9/12/07, Evan David Light wrote: > I like to start w/ integration tests before anything exists at all. > You can do that w/ Rails' Integration Tests or Story Runner (if you're > using RSpec's trunk). > Story Runner is a new one for me. I'll have to look it up. Thanks! (Halfway through writing this, I realized, courtesy of Google, that it's a recently integrated piece of functionality into RSpec-on- Rails. I found this example of yours captured here. ) I see why this could be a good way to start coding. This is exactly what I naturally wanted to do with RSpec but couldn't because RSpec seems oriented toward a lower-level set of issues. I'll have to start playing with the trunk now. This looks nifty. > If you don't want broken software, then spec the views - but ONLY > the stuff that actually has business value. > Seems like sound common sense. I caught myself earlier today writing a spec for a non-functional portion of my view, chided myself for it, ripped out the spec, and then continued. > Once the view is sufficiently spec'd and the specs are passing, I know > what the controller needs to supply, so I start spec'ing the > controller. And on down to models. Good to realize that I'm not thinking that far off the mainstream here. > That's not to say that the philosophy isn't important. I, personally, > love talking about philosophy. It helps me to understand why I > gravitate towards the things I do. Ultimately, this is what I was looking for: not so much "what to do" but the "tao" of it. Starting with the user in mind, from a view level, made some sense but too minutiae driven. I like to dabble with new approaches but always asking "why?" along the way. While a lot of what I have been doing with RSpec could be accomplished with Test::Unit, I'm finding that I prefer the RSpec approach somewhat more. > Same w/ approaches to testing and developing software. Agile isn't all > that agile if we're all finding "best practices" and applying them > like a bunch of blind followers of some religion. Or if we spend so much time on "best practices" that we're not actually accomplishing anything? Welcome to the government. ;-) > "We have come to > value individuals and interactions over processes and tools," yet > we're always becoming slave to the next tool rather than becoming its > master and sticking it in our tool belt. You mean that instead of being Java Juju Zombies that we're becoming Ruby Robots? > Summing up - the series of steps I described above is what I *usually* > do because I know it works for me and the way I work. But I don't do > that 100% of the time, and I certainly don't feel bad when I break > that pattern. It's just a great tool to have lying around. > And, of course, what works for one may not work for all. However, with regard to Rails apps, I'm still finding my way. That said, I know that I would prefer a TDD/BDD approach to writing it, hand testing it, seeing it mostly work, fix something (and perhaps breaking something else!), rinsing and repeating. Thanks for the brain dump! Evan IMs (all): sleight42 http://evan.tiggerpalace.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070912/b75e7fb6/attachment-0001.html From mailing_lists at railsnewbie.com Wed Sep 12 19:27:53 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 12 Sep 2007 19:27:53 -0400 Subject: [rspec-users] Checking out Rspec In-Reply-To: References: Message-ID: <623C2C88-866E-4B62-B9DA-86C0F26488CA@railsnewbie.com> I have been having connection problems with rspec's rubyforge repository for a long time. I'm running my own mirror if you want the subversion link (although the revision numbers are a little bit off). Generally, though, if you are having problems with this sort of thing on rubyforge, you should try contacting them directly (Rubyforge has it's own tracker). They would know more about this stuff than the rspec project admins. Scott On Sep 12, 2007, at 6:50 PM, Bret Pettichord wrote: > I'm getting the following error when i either checkout or update > from svn://rubyforge.org/var/svn/rspec/trunk > > svn: Error processing command 'mv' in 'C:\work\rspec2\RSpec.tmbundle > \Preferences' > svn: Can't move source to dest > svn: Cannot rename file 'C:\work\rspec2\RSpec.tmbundle\Preferences > \.svn\tmp\text-base\Symbol List: Behaviour.tmPreferences.svn-base' > > For what i am doing right now, i was able to workaround this by > checking out svn://rubyforge.org/var/svn/rspec/trunk/rspec instead, > but i liked having the whole kibboodle, because there is so much > cool stuff in there to steal from. > > Is this a known problem? Is this a bug or just some how how bundles > are supposed to be packaged? > > Bret > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Wed Sep 12 19:35:08 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 12 Sep 2007 18:35:08 -0500 Subject: [rspec-users] Philosophical questions In-Reply-To: References: <977ACF0A-3D96-403F-A1F5-6E0132AFA438@tiggerpalace.com> <57c63afe0709121515l314f40e3l33846197d6fe6e10@mail.gmail.com> Message-ID: <57c63afe0709121635o1c6e9867wbbdb6cef0939d288@mail.gmail.com> On 9/12/07, Evan David Light wrote: > Awesome! That's a whole lot more of a response than I had anticipated. Me too. > Thanks! > > On Sep 12, 2007, at 6:15 PM, David Chelimsky wrote: > > On 9/12/07, Evan David Light wrote: > I like to start w/ integration tests before anything exists at all. > You can do that w/ Rails' Integration Tests or Story Runner (if you're > using RSpec's trunk). > > > Story Runner is a new one for me. I'll have to look it up. Thanks! > > (Halfway through writing this, I realized, courtesy of Google, that it's a > recently integrated piece of functionality into RSpec-on-Rails. I found > this example of yours captured here. ) Not specific to Rails at all. Just happens to support Rails. > > I see why this could be a good way to start coding. This is exactly what I > naturally wanted to do with RSpec but couldn't because RSpec seems oriented > toward a lower-level set of issues. I'll have to start playing with the > trunk now. This looks nifty. > > > If you don't want broken software, then spec the views - but ONLY > the stuff that actually has business value. > > Seems like sound common sense. I caught myself earlier today writing a spec > for a non-functional portion of my view, chided myself for it, ripped out > the spec, and then continued. Careful here. Business value is not always measured in terms of things "functional". Sometimes it's the company logo showing up in the right place on the page after spending thousands of marketing dollars figuring out where that spot is. > Once the view is sufficiently spec'd and the specs are passing, I know > what the controller needs to supply, so I start spec'ing the > controller. And on down to models. > > Good to realize that I'm not thinking that far off the mainstream here. Eeeek. You're not thinking far off from ME. That in no way makes it main stream. > That's not to say that the philosophy isn't important. I, personally, > love talking about philosophy. It helps me to understand why I > gravitate towards the things I do. > > Ultimately, this is what I was looking for: not so much "what to do" but the > "tao" of it. Starting with the user in mind, from a view level, made some > sense but too minutiae driven. I like to dabble with new approaches but > always asking "why?" along the way. While a lot of what I have been doing > with RSpec could be accomplished with Test::Unit, I'm finding that I prefer > the RSpec approach somewhat more. > > > Same w/ approaches to testing and developing software. Agile isn't all > that agile if we're all finding "best practices" and applying them > like a bunch of blind followers of some religion. > > Or if we spend so much time on "best practices" that we're not actually > accomplishing anything? Welcome to the government. ;-) > > "We have come to > value individuals and interactions over processes and tools," yet > we're always becoming slave to the next tool rather than becoming its > master and sticking it in our tool belt. > > You mean that instead of being Java Juju Zombies that we're > becoming Ruby Robots? > > Summing up - the series of steps I described above is what I *usually* > do because I know it works for me and the way I work. But I don't do > that 100% of the time, and I certainly don't feel bad when I break > that pattern. It's just a great tool to have lying around. > > > And, of course, what works for one may not work for all. However, with > regard to Rails apps, I'm still finding my way. That said, I know that I > would prefer a TDD/BDD approach to writing it, hand testing it, seeing it > mostly work, fix something (and perhaps breaking something else!), rinsing > and repeating. > > Thanks for the brain dump! Thanks for cleaning it up!!! Cheers, David From geoffrey.wiseman at gmail.com Wed Sep 12 19:45:11 2007 From: geoffrey.wiseman at gmail.com (Geoffrey Wiseman) Date: Wed, 12 Sep 2007 19:45:11 -0400 Subject: [rspec-users] Philosophical questions In-Reply-To: <57c63afe0709121515l314f40e3l33846197d6fe6e10@mail.gmail.com> References: <977ACF0A-3D96-403F-A1F5-6E0132AFA438@tiggerpalace.com> <57c63afe0709121515l314f40e3l33846197d6fe6e10@mail.gmail.com> Message-ID: <835d522e0709121645g1f24fcfak9a7cce18265118e8@mail.gmail.com> On 9/12/07, David Chelimsky wrote: > > I like to start w/ integration tests before anything exists at all. > You can do that w/ Rails' Integration Tests or Story Runner (if you're > using RSpec's trunk). > > Next, I hit a view. ... Despite the time involved, I'd love to see a written tutorial or screencast that walks this whole gamut in order if someone ever has time to do one. - Geoffrey -- Geoffrey Wiseman -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070912/5cff2d61/attachment.html From dchelimsky at gmail.com Wed Sep 12 19:48:12 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 12 Sep 2007 18:48:12 -0500 Subject: [rspec-users] Philosophical questions In-Reply-To: <835d522e0709121645g1f24fcfak9a7cce18265118e8@mail.gmail.com> References: <977ACF0A-3D96-403F-A1F5-6E0132AFA438@tiggerpalace.com> <57c63afe0709121515l314f40e3l33846197d6fe6e10@mail.gmail.com> <835d522e0709121645g1f24fcfak9a7cce18265118e8@mail.gmail.com> Message-ID: <57c63afe0709121648m1313b08au7afd7ca76c960df1@mail.gmail.com> On 9/12/07, Geoffrey Wiseman wrote: > On 9/12/07, David Chelimsky wrote: > > I like to start w/ integration tests before anything exists at all. > > You can do that w/ Rails' Integration Tests or Story Runner (if you're > > using RSpec's trunk). > > > > Next, I hit a view. > > ... > > Despite the time involved, I'd love to see a written tutorial or screencast > that walks this whole gamut in order if someone ever has time to do one. Me too! > - Geoffrey > -- > Geoffrey Wiseman > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From evan at tiggerpalace.com Wed Sep 12 19:59:12 2007 From: evan at tiggerpalace.com (Evan David Light) Date: Wed, 12 Sep 2007 19:59:12 -0400 Subject: [rspec-users] Philosophical questions In-Reply-To: <57c63afe0709121635o1c6e9867wbbdb6cef0939d288@mail.gmail.com> References: <977ACF0A-3D96-403F-A1F5-6E0132AFA438@tiggerpalace.com> <57c63afe0709121515l314f40e3l33846197d6fe6e10@mail.gmail.com> <57c63afe0709121635o1c6e9867wbbdb6cef0939d288@mail.gmail.com> Message-ID: <4BC4EED8-2619-4B11-A2B6-FCDA40E0B86B@tiggerpalace.com> On Sep 12, 2007, at 7:35 PM, David Chelimsky wrote: >> Story Runner is a new one for me. I'll have to look it up. Thanks! >> >> (Halfway through writing this, I realized, courtesy of Google, >> that it's a >> recently integrated piece of functionality into RSpec-on-Rails. I >> found >> this example of yours captured here. ) > > Not specific to Rails at all. Just happens to support Rails. > Gotcha. Tomorrow I'll be checking out from trunk. Although it behooves me to ask if the RSpec (and integration tests/story runner) in trunk all pass. >> Seems like sound common sense. I caught myself earlier today >> writing a spec >> for a non-functional portion of my view, chided myself for it, >> ripped out >> the spec, and then continued. > > Careful here. Business value is not always measured in terms of things > "functional". Sometimes it's the company logo showing up in the right > place on the page after spending thousands of marketing dollars > figuring out where that spot is. > Granted. Anything that is a customer requirement should be captured at some level. That said, the Rails app that I'm writing at the moment is a tool to support an R&D effort so none of that sort of thing there. >> Good to realize that I'm not thinking that far off the mainstream >> here. > > Eeeek. You're not thinking far off from ME. That in no way makes it > main stream. > Hehe. Ok, I'm thinking like a guy who has prolific dialogues about how to build better software. I could do worse. ;-) Evan From flyeminent at hotmail.com Wed Sep 12 20:07:35 2007 From: flyeminent at hotmail.com (Shaker) Date: Wed, 12 Sep 2007 17:07:35 -0700 (PDT) Subject: [rspec-users] Can not 'assigns' value in View test In-Reply-To: <57c63afe0709121436g6de8dc71teb80fc38bf7c9deb@mail.gmail.com> References: <12631788.post@talk.nabble.com> <061C5749-5D23-4929-AB09-6FB9B1F42A73@tiggerpalace.com> <57c63afe0709121436g6de8dc71teb80fc38bf7c9deb@mail.gmail.com> Message-ID: <12646459.post@talk.nabble.com> Unfortunately, I am not supposed to change the code inside the partial. That's why I posted this message. I am trying to find a way of tackling this problem. Because I am going to test tens of hundreds of partials, most of which are using the symbols rather than instance variable. David Chelimsky-2 wrote: > > On 9/12/07, Evan David Light wrote: >> Granted that I'm new too; however, assigns[:hash] creates a >> member >> variable @hash that is made available to the view. Maybe that's the >> problem? Modify your view to use @hash instead. > > http://rspec.rubyforge.org/documentation/rails/writing/views.html > >> >> On Sep 12, 2007, at 5:20 AM, Shaker wrote: >> >> > >> > Hello everyone: >> > I am quit new to View test using rspec. I want to write spec for a >> > partial, which is rendered by a controller. However, the controller >> > does not >> > pass data to the partial using instance variables, it uses symbol >> > variable >> > instead. I read the example of view spec provided in the website. >> > But the >> > example is using instance variable. So I am looking for a way of >> > assigning >> > my test data to the partial to be tested. I would like to show an >> > my code >> > below: >> > class MyController >> > def index >> > hash = {...#data provided here} >> > render :partial=>'index', :layout=>false, :locals=>{:hash=>hash} >> > end >> > end >> > >> > _index.rhtml >> > ......#unrelated code omitted >> > >> > >> > In my spec, I used assigns[:hash] = my_own_data, but an error >> > occurred, >> > saying that "undefined local variable or method 'hash' ". >> > How can I assign my own data to hash in my view spec? >> > Thank you! >> > >> > -- >> > View this message in context: http://www.nabble.com/Can-not-% >> > 27assigns%27-value-in-View-test-tf4428018.html#a12631788 >> > Sent from the rspec-users mailing list archive at Nabble.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 >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > -- View this message in context: http://www.nabble.com/Can-not-%27assigns%27-value-in-View-test-tf4428018.html#a12646459 Sent from the rspec-users mailing list archive at Nabble.com. From dchelimsky at gmail.com Wed Sep 12 20:11:54 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 12 Sep 2007 19:11:54 -0500 Subject: [rspec-users] Philosophical questions In-Reply-To: <4BC4EED8-2619-4B11-A2B6-FCDA40E0B86B@tiggerpalace.com> References: <977ACF0A-3D96-403F-A1F5-6E0132AFA438@tiggerpalace.com> <57c63afe0709121515l314f40e3l33846197d6fe6e10@mail.gmail.com> <57c63afe0709121635o1c6e9867wbbdb6cef0939d288@mail.gmail.com> <4BC4EED8-2619-4B11-A2B6-FCDA40E0B86B@tiggerpalace.com> Message-ID: <57c63afe0709121711n3423ebc7x40f9eeed850856eb@mail.gmail.com> On 9/12/07, Evan David Light wrote: > > On Sep 12, 2007, at 7:35 PM, David Chelimsky wrote: > > >> Story Runner is a new one for me. I'll have to look it up. Thanks! > >> > >> (Halfway through writing this, I realized, courtesy of Google, > >> that it's a > >> recently integrated piece of functionality into RSpec-on-Rails. I > >> found > >> this example of yours captured here. ) > > > > Not specific to Rails at all. Just happens to support Rails. > > > > Gotcha. Tomorrow I'll be checking out from trunk. Although it > behooves me to ask if the RSpec (and integration tests/story runner) > in trunk all pass. Pass? Pass? Puh-lease!!!!!! We don't commit to trunk w/ out 100% coverage in core (not there yet for the rails plugin) and all rails plugin specs passing against 1.2.1, .1.2.2 and .1.2.3. We also run them against edge rails, but we just use that to keep issues on the radar - passing against edge is not a pre-condition for committing. > >> Seems like sound common sense. I caught myself earlier today > >> writing a spec > >> for a non-functional portion of my view, chided myself for it, > >> ripped out > >> the spec, and then continued. > > > > Careful here. Business value is not always measured in terms of things > > "functional". Sometimes it's the company logo showing up in the right > > place on the page after spending thousands of marketing dollars > > figuring out where that spot is. > > > > Granted. Anything that is a customer requirement should be captured > at some level. That said, the Rails app that I'm writing at the > moment is a tool to support an R&D effort so none of that sort of > thing there. > > >> Good to realize that I'm not thinking that far off the mainstream > >> here. > > > > Eeeek. You're not thinking far off from ME. That in no way makes it > > main stream. > > > > Hehe. Ok, I'm thinking like a guy who has prolific dialogues about > how to build better software. I could do worse. ;-) Well - my earlier post was more like a monologue than dialog, but thanks! Cheers, David > > Evan > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Sep 12 20:13:46 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 12 Sep 2007 19:13:46 -0500 Subject: [rspec-users] Can not 'assigns' value in View test In-Reply-To: <12646459.post@talk.nabble.com> References: <12631788.post@talk.nabble.com> <061C5749-5D23-4929-AB09-6FB9B1F42A73@tiggerpalace.com> <57c63afe0709121436g6de8dc71teb80fc38bf7c9deb@mail.gmail.com> <12646459.post@talk.nabble.com> Message-ID: <57c63afe0709121713g46aa8aacm7f8c273810a3482@mail.gmail.com> On 9/12/07, Shaker wrote: > > Unfortunately, I am not supposed to change the code inside the partial. > That's why I posted this message. I am trying to find a way of tackling this > problem. Because I am going to test tens of hundreds of partials, most of > which are using the symbols rather than instance variable. Huh? Symbols in the partials that are supposed to magically transform to some value? I don't get it. What am I missing? > > David Chelimsky-2 wrote: > > > > On 9/12/07, Evan David Light wrote: > >> Granted that I'm new too; however, assigns[:hash] creates a > >> member > >> variable @hash that is made available to the view. Maybe that's the > >> problem? Modify your view to use @hash instead. > > > > http://rspec.rubyforge.org/documentation/rails/writing/views.html > > > >> > >> On Sep 12, 2007, at 5:20 AM, Shaker wrote: > >> > >> > > >> > Hello everyone: > >> > I am quit new to View test using rspec. I want to write spec for a > >> > partial, which is rendered by a controller. However, the controller > >> > does not > >> > pass data to the partial using instance variables, it uses symbol > >> > variable > >> > instead. I read the example of view spec provided in the website. > >> > But the > >> > example is using instance variable. So I am looking for a way of > >> > assigning > >> > my test data to the partial to be tested. I would like to show an > >> > my code > >> > below: > >> > class MyController > >> > def index > >> > hash = {...#data provided here} > >> > render :partial=>'index', :layout=>false, :locals=>{:hash=>hash} > >> > end > >> > end > >> > > >> > _index.rhtml > >> > ......#unrelated code omitted > >> > > >> > > >> > In my spec, I used assigns[:hash] = my_own_data, but an error > >> > occurred, > >> > saying that "undefined local variable or method 'hash' ". > >> > How can I assign my own data to hash in my view spec? > >> > Thank you! > >> > > >> > -- > >> > View this message in context: http://www.nabble.com/Can-not-% > >> > 27assigns%27-value-in-View-test-tf4428018.html#a12631788 > >> > Sent from the rspec-users mailing list archive at Nabble.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 > >> > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > View this message in context: http://www.nabble.com/Can-not-%27assigns%27-value-in-View-test-tf4428018.html#a12646459 > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From flyeminent at hotmail.com Wed Sep 12 20:47:09 2007 From: flyeminent at hotmail.com (Shaker) Date: Wed, 12 Sep 2007 17:47:09 -0700 (PDT) Subject: [rspec-users] Can not 'assigns' value in View test In-Reply-To: <57c63afe0709121713g46aa8aacm7f8c273810a3482@mail.gmail.com> References: <12631788.post@talk.nabble.com> <061C5749-5D23-4929-AB09-6FB9B1F42A73@tiggerpalace.com> <57c63afe0709121436g6de8dc71teb80fc38bf7c9deb@mail.gmail.com> <12646459.post@talk.nabble.com> <57c63afe0709121713g46aa8aacm7f8c273810a3482@mail.gmail.com> Message-ID: <12646774.post@talk.nabble.com> I also feel puzzled. But that's what my colleagues do, and it works. The thing is they use render :partial=>'index', :locals=>{:hash=>hash} in the controller to pass the hash data to the partial it will render(index in this case). And later they simply use <%= hash %> to get the hash data passed from the controller. Maybe the :locals does some magical work here. I am quite familiar with rspec and ruby. So I am reading more documentation now. Hopefully we could figure it out shortly. David Chelimsky-2 wrote: > > On 9/12/07, Shaker wrote: >> >> Unfortunately, I am not supposed to change the code inside the partial. >> That's why I posted this message. I am trying to find a way of tackling >> this >> problem. Because I am going to test tens of hundreds of partials, most of >> which are using the symbols rather than instance variable. > > Huh? Symbols in the partials that are supposed to magically transform > to some value? I don't get it. What am I missing? > >> >> David Chelimsky-2 wrote: >> > >> > On 9/12/07, Evan David Light wrote: >> >> Granted that I'm new too; however, assigns[:hash] creates a >> >> member >> >> variable @hash that is made available to the view. Maybe that's the >> >> problem? Modify your view to use @hash instead. >> > >> > http://rspec.rubyforge.org/documentation/rails/writing/views.html >> > >> >> >> >> On Sep 12, 2007, at 5:20 AM, Shaker wrote: >> >> >> >> > >> >> > Hello everyone: >> >> > I am quit new to View test using rspec. I want to write spec for a >> >> > partial, which is rendered by a controller. However, the controller >> >> > does not >> >> > pass data to the partial using instance variables, it uses symbol >> >> > variable >> >> > instead. I read the example of view spec provided in the website. >> >> > But the >> >> > example is using instance variable. So I am looking for a way of >> >> > assigning >> >> > my test data to the partial to be tested. I would like to show an >> >> > my code >> >> > below: >> >> > class MyController >> >> > def index >> >> > hash = {...#data provided here} >> >> > render :partial=>'index', :layout=>false, :locals=>{:hash=>hash} >> >> > end >> >> > end >> >> > >> >> > _index.rhtml >> >> > ......#unrelated code omitted >> >> > >> >> > >> >> > In my spec, I used assigns[:hash] = my_own_data, but an error >> >> > occurred, >> >> > saying that "undefined local variable or method 'hash' ". >> >> > How can I assign my own data to hash in my view spec? >> >> > Thank you! >> >> > >> >> > -- >> >> > View this message in context: http://www.nabble.com/Can-not-% >> >> > 27assigns%27-value-in-View-test-tf4428018.html#a12631788 >> >> > Sent from the rspec-users mailing list archive at Nabble.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 >> >> >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/Can-not-%27assigns%27-value-in-View-test-tf4428018.html#a12646459 >> Sent from the rspec-users mailing list archive at Nabble.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 > > -- View this message in context: http://www.nabble.com/Can-not-%27assigns%27-value-in-View-test-tf4428018.html#a12646774 Sent from the rspec-users mailing list archive at Nabble.com. From dchelimsky at gmail.com Wed Sep 12 20:53:44 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 12 Sep 2007 19:53:44 -0500 Subject: [rspec-users] Can not 'assigns' value in View test In-Reply-To: <12646774.post@talk.nabble.com> References: <12631788.post@talk.nabble.com> <061C5749-5D23-4929-AB09-6FB9B1F42A73@tiggerpalace.com> <57c63afe0709121436g6de8dc71teb80fc38bf7c9deb@mail.gmail.com> <12646459.post@talk.nabble.com> <57c63afe0709121713g46aa8aacm7f8c273810a3482@mail.gmail.com> <12646774.post@talk.nabble.com> Message-ID: <57c63afe0709121753n542ddbb0ob40c9e0022c5eb59@mail.gmail.com> On 9/12/07, Shaker wrote: > > I also feel puzzled. But that's what my colleagues do, and it works. The > thing is they use > render :partial=>'index', :locals=>{:hash=>hash} > in the controller to pass the hash data to the partial it will render(index > in this case). And later they simply use <%= hash %> to get the hash data > passed from the controller. Now THAT is a horse of a different color. OK - first: render :partial=>'index', :locals=>{:hash=>hash} Here, the symbol :hash is just a key - it is not the object that's been passed around. Second: <%= hash %> I'm assuming that's in the partial named index (a partial named index???????, now THAT's not at all confusing). In this case, the :locals => {:hash=>hash} in the calling template assigns the hash object (in the calling template's scope) as the return value of a method in the partial named .... (drum roll, please) .... hash. Like hash(). So - what you want to do is to stub the hash method on the template: template.stub!(:hash).and_return(the_hash_I_want_to_stick_in_the_template) That all make sense? Good luck! > Maybe the :locals does some magical work here. I > am quite familiar with rspec and ruby. So I am reading more documentation > now. > Hopefully we could figure it out shortly. > > David Chelimsky-2 wrote: > > > > On 9/12/07, Shaker wrote: > >> > >> Unfortunately, I am not supposed to change the code inside the partial. > >> That's why I posted this message. I am trying to find a way of tackling > >> this > >> problem. Because I am going to test tens of hundreds of partials, most of > >> which are using the symbols rather than instance variable. > > > > Huh? Symbols in the partials that are supposed to magically transform > > to some value? I don't get it. What am I missing? > > > >> > >> David Chelimsky-2 wrote: > >> > > >> > On 9/12/07, Evan David Light wrote: > >> >> Granted that I'm new too; however, assigns[:hash] creates a > >> >> member > >> >> variable @hash that is made available to the view. Maybe that's the > >> >> problem? Modify your view to use @hash instead. > >> > > >> > http://rspec.rubyforge.org/documentation/rails/writing/views.html > >> > > >> >> > >> >> On Sep 12, 2007, at 5:20 AM, Shaker wrote: > >> >> > >> >> > > >> >> > Hello everyone: > >> >> > I am quit new to View test using rspec. I want to write spec for a > >> >> > partial, which is rendered by a controller. However, the controller > >> >> > does not > >> >> > pass data to the partial using instance variables, it uses symbol > >> >> > variable > >> >> > instead. I read the example of view spec provided in the website. > >> >> > But the > >> >> > example is using instance variable. So I am looking for a way of > >> >> > assigning > >> >> > my test data to the partial to be tested. I would like to show an > >> >> > my code > >> >> > below: > >> >> > class MyController > >> >> > def index > >> >> > hash = {...#data provided here} > >> >> > render :partial=>'index', :layout=>false, :locals=>{:hash=>hash} > >> >> > end > >> >> > end > >> >> > > >> >> > _index.rhtml > >> >> > ......#unrelated code omitted > >> >> > > >> >> > > >> >> > In my spec, I used assigns[:hash] = my_own_data, but an error > >> >> > occurred, > >> >> > saying that "undefined local variable or method 'hash' ". > >> >> > How can I assign my own data to hash in my view spec? > >> >> > Thank you! > >> >> > > >> >> > -- > >> >> > View this message in context: http://www.nabble.com/Can-not-% > >> >> > 27assigns%27-value-in-View-test-tf4428018.html#a12631788 > >> >> > Sent from the rspec-users mailing list archive at Nabble.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 > >> >> > >> > _______________________________________________ > >> > rspec-users mailing list > >> > rspec-users at rubyforge.org > >> > http://rubyforge.org/mailman/listinfo/rspec-users > >> > > >> > > >> > >> -- > >> View this message in context: > >> http://www.nabble.com/Can-not-%27assigns%27-value-in-View-test-tf4428018.html#a12646459 > >> Sent from the rspec-users mailing list archive at Nabble.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 > > > > > > -- > View this message in context: http://www.nabble.com/Can-not-%27assigns%27-value-in-View-test-tf4428018.html#a12646774 > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From flyeminent at hotmail.com Wed Sep 12 21:08:53 2007 From: flyeminent at hotmail.com (Shaker) Date: Wed, 12 Sep 2007 18:08:53 -0700 (PDT) Subject: [rspec-users] Can not 'assigns' value in View test In-Reply-To: <57c63afe0709121753n542ddbb0ob40c9e0022c5eb59@mail.gmail.com> References: <12631788.post@talk.nabble.com> <061C5749-5D23-4929-AB09-6FB9B1F42A73@tiggerpalace.com> <57c63afe0709121436g6de8dc71teb80fc38bf7c9deb@mail.gmail.com> <12646459.post@talk.nabble.com> <57c63afe0709121713g46aa8aacm7f8c273810a3482@mail.gmail.com> <12646774.post@talk.nabble.com> <57c63afe0709121753n542ddbb0ob40c9e0022c5eb59@mail.gmail.com> Message-ID: <12646978.post@talk.nabble.com> Hello, David: Thank you very much for your help. Now it works! I would like to recall a message posted several days ago regarding the "paginate". How to test "paginate" in controller spec? One simple example may be like this: hash[:accounts_pages], hash[:accounts] = paginate :accounts(the table), #order and conditions follows How should I test this code in controller spec? Or can I mock this line, like should_receive(:paginate).and_return(...)? But the problem is 'paginate' returns two values. :( Thanks for investigating this question. David Chelimsky-2 wrote: > > On 9/12/07, Shaker wrote: >> >> I also feel puzzled. But that's what my colleagues do, and it works. The >> thing is they use >> render :partial=>'index', :locals=>{:hash=>hash} >> in the controller to pass the hash data to the partial it will >> render(index >> in this case). And later they simply use <%= hash %> to get the hash data >> passed from the controller. > > Now THAT is a horse of a different color. OK - first: > > render :partial=>'index', :locals=>{:hash=>hash} > > Here, the symbol :hash is just a key - it is not the object that's > been passed around. > > Second: > > <%= hash %> > > I'm assuming that's in the partial named index (a partial named > index???????, now THAT's not at all confusing). In this case, the > :locals => {:hash=>hash} in the calling template assigns the hash > object (in the calling template's scope) as the return value of a > method in the partial named .... (drum roll, please) .... hash. Like > hash(). > > So - what you want to do is to stub the hash method on the template: > > > template.stub!(:hash).and_return(the_hash_I_want_to_stick_in_the_template) > > That all make sense? > > Good luck! > >> Maybe the :locals does some magical work here. I >> am quite familiar with rspec and ruby. So I am reading more documentation >> now. >> Hopefully we could figure it out shortly. >> >> David Chelimsky-2 wrote: >> > >> > On 9/12/07, Shaker wrote: >> >> >> >> Unfortunately, I am not supposed to change the code inside the >> partial. >> >> That's why I posted this message. I am trying to find a way of >> tackling >> >> this >> >> problem. Because I am going to test tens of hundreds of partials, most >> of >> >> which are using the symbols rather than instance variable. >> > >> > Huh? Symbols in the partials that are supposed to magically transform >> > to some value? I don't get it. What am I missing? >> > >> >> >> >> David Chelimsky-2 wrote: >> >> > >> >> > On 9/12/07, Evan David Light wrote: >> >> >> Granted that I'm new too; however, assigns[:hash] creates a >> >> >> member >> >> >> variable @hash that is made available to the view. Maybe that's >> the >> >> >> problem? Modify your view to use @hash instead. >> >> > >> >> > http://rspec.rubyforge.org/documentation/rails/writing/views.html >> >> > >> >> >> >> >> >> On Sep 12, 2007, at 5:20 AM, Shaker wrote: >> >> >> >> >> >> > >> >> >> > Hello everyone: >> >> >> > I am quit new to View test using rspec. I want to write spec >> for a >> >> >> > partial, which is rendered by a controller. However, the >> controller >> >> >> > does not >> >> >> > pass data to the partial using instance variables, it uses symbol >> >> >> > variable >> >> >> > instead. I read the example of view spec provided in the website. >> >> >> > But the >> >> >> > example is using instance variable. So I am looking for a way of >> >> >> > assigning >> >> >> > my test data to the partial to be tested. I would like to show an >> >> >> > my code >> >> >> > below: >> >> >> > class MyController >> >> >> > def index >> >> >> > hash = {...#data provided here} >> >> >> > render :partial=>'index', :layout=>false, >> :locals=>{:hash=>hash} >> >> >> > end >> >> >> > end >> >> >> > >> >> >> > _index.rhtml >> >> >> > ......#unrelated code omitted >> >> >> > >> >> >> > >> >> >> > In my spec, I used assigns[:hash] = my_own_data, but an error >> >> >> > occurred, >> >> >> > saying that "undefined local variable or method 'hash' ". >> >> >> > How can I assign my own data to hash in my view spec? >> >> >> > Thank you! >> >> >> > >> >> >> > -- >> >> >> > View this message in context: http://www.nabble.com/Can-not-% >> >> >> > 27assigns%27-value-in-View-test-tf4428018.html#a12631788 >> >> >> > Sent from the rspec-users mailing list archive at Nabble.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 >> >> >> >> >> > _______________________________________________ >> >> > rspec-users mailing list >> >> > rspec-users at rubyforge.org >> >> > http://rubyforge.org/mailman/listinfo/rspec-users >> >> > >> >> > >> >> >> >> -- >> >> View this message in context: >> >> >> http://www.nabble.com/Can-not-%27assigns%27-value-in-View-test-tf4428018.html#a12646459 >> >> Sent from the rspec-users mailing list archive at Nabble.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 >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/Can-not-%27assigns%27-value-in-View-test-tf4428018.html#a12646774 >> Sent from the rspec-users mailing list archive at Nabble.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 > > -- View this message in context: http://www.nabble.com/Can-not-%27assigns%27-value-in-View-test-tf4428018.html#a12646978 Sent from the rspec-users mailing list archive at Nabble.com. From dchelimsky at gmail.com Wed Sep 12 21:14:05 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 12 Sep 2007 20:14:05 -0500 Subject: [rspec-users] Can not 'assigns' value in View test In-Reply-To: <12646978.post@talk.nabble.com> References: <12631788.post@talk.nabble.com> <061C5749-5D23-4929-AB09-6FB9B1F42A73@tiggerpalace.com> <57c63afe0709121436g6de8dc71teb80fc38bf7c9deb@mail.gmail.com> <12646459.post@talk.nabble.com> <57c63afe0709121713g46aa8aacm7f8c273810a3482@mail.gmail.com> <12646774.post@talk.nabble.com> <57c63afe0709121753n542ddbb0ob40c9e0022c5eb59@mail.gmail.com> <12646978.post@talk.nabble.com> Message-ID: <57c63afe0709121814v6dce568chbb4eb2b434e07000@mail.gmail.com> On 9/12/07, Shaker wrote: > > Hello, David: > Thank you very much for your help. Now it works! > I would like to recall a message posted several days ago regarding the > "paginate". How to test "paginate" in controller spec? One simple example > may be like this: > hash[:accounts_pages], hash[:accounts] = paginate :accounts(the table), > #order and conditions follows > How should I test this code in controller spec? Or can I mock this line, > like should_receive(:paginate).and_return(...)? But the problem is > 'paginate' returns two values. :( When a method returns 2 values it is really returning an array, so ... and_return([val1, val2]) See if that works. > Thanks for investigating this question. > > David Chelimsky-2 wrote: > > > > On 9/12/07, Shaker wrote: > >> > >> I also feel puzzled. But that's what my colleagues do, and it works. The > >> thing is they use > >> render :partial=>'index', :locals=>{:hash=>hash} > >> in the controller to pass the hash data to the partial it will > >> render(index > >> in this case). And later they simply use <%= hash %> to get the hash data > >> passed from the controller. > > > > Now THAT is a horse of a different color. OK - first: > > > > render :partial=>'index', :locals=>{:hash=>hash} > > > > Here, the symbol :hash is just a key - it is not the object that's > > been passed around. > > > > Second: > > > > <%= hash %> > > > > I'm assuming that's in the partial named index (a partial named > > index???????, now THAT's not at all confusing). In this case, the > > :locals => {:hash=>hash} in the calling template assigns the hash > > object (in the calling template's scope) as the return value of a > > method in the partial named .... (drum roll, please) .... hash. Like > > hash(). > > > > So - what you want to do is to stub the hash method on the template: > > > > > > template.stub!(:hash).and_return(the_hash_I_want_to_stick_in_the_template) > > > > That all make sense? > > > > Good luck! > > > >> Maybe the :locals does some magical work here. I > >> am quite familiar with rspec and ruby. So I am reading more documentation > >> now. > >> Hopefully we could figure it out shortly. > >> > >> David Chelimsky-2 wrote: > >> > > >> > On 9/12/07, Shaker wrote: > >> >> > >> >> Unfortunately, I am not supposed to change the code inside the > >> partial. > >> >> That's why I posted this message. I am trying to find a way of > >> tackling > >> >> this > >> >> problem. Because I am going to test tens of hundreds of partials, most > >> of > >> >> which are using the symbols rather than instance variable. > >> > > >> > Huh? Symbols in the partials that are supposed to magically transform > >> > to some value? I don't get it. What am I missing? > >> > > >> >> > >> >> David Chelimsky-2 wrote: > >> >> > > >> >> > On 9/12/07, Evan David Light wrote: > >> >> >> Granted that I'm new too; however, assigns[:hash] creates a > >> >> >> member > >> >> >> variable @hash that is made available to the view. Maybe that's > >> the > >> >> >> problem? Modify your view to use @hash instead. > >> >> > > >> >> > http://rspec.rubyforge.org/documentation/rails/writing/views.html > >> >> > > >> >> >> > >> >> >> On Sep 12, 2007, at 5:20 AM, Shaker wrote: > >> >> >> > >> >> >> > > >> >> >> > Hello everyone: > >> >> >> > I am quit new to View test using rspec. I want to write spec > >> for a > >> >> >> > partial, which is rendered by a controller. However, the > >> controller > >> >> >> > does not > >> >> >> > pass data to the partial using instance variables, it uses symbol > >> >> >> > variable > >> >> >> > instead. I read the example of view spec provided in the website. > >> >> >> > But the > >> >> >> > example is using instance variable. So I am looking for a way of > >> >> >> > assigning > >> >> >> > my test data to the partial to be tested. I would like to show an > >> >> >> > my code > >> >> >> > below: > >> >> >> > class MyController > >> >> >> > def index > >> >> >> > hash = {...#data provided here} > >> >> >> > render :partial=>'index', :layout=>false, > >> :locals=>{:hash=>hash} > >> >> >> > end > >> >> >> > end > >> >> >> > > >> >> >> > _index.rhtml > >> >> >> > ......#unrelated code omitted > >> >> >> > > >> >> >> > > >> >> >> > In my spec, I used assigns[:hash] = my_own_data, but an error > >> >> >> > occurred, > >> >> >> > saying that "undefined local variable or method 'hash' ". > >> >> >> > How can I assign my own data to hash in my view spec? > >> >> >> > Thank you! > >> >> >> > > >> >> >> > -- > >> >> >> > View this message in context: http://www.nabble.com/Can-not-% > >> >> >> > 27assigns%27-value-in-View-test-tf4428018.html#a12631788 > >> >> >> > Sent from the rspec-users mailing list archive at Nabble.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 > >> >> >> > >> >> > _______________________________________________ > >> >> > rspec-users mailing list > >> >> > rspec-users at rubyforge.org > >> >> > http://rubyforge.org/mailman/listinfo/rspec-users > >> >> > > >> >> > > >> >> > >> >> -- > >> >> View this message in context: > >> >> > >> http://www.nabble.com/Can-not-%27assigns%27-value-in-View-test-tf4428018.html#a12646459 > >> >> Sent from the rspec-users mailing list archive at Nabble.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 > >> > > >> > > >> > >> -- > >> View this message in context: > >> http://www.nabble.com/Can-not-%27assigns%27-value-in-View-test-tf4428018.html#a12646774 > >> Sent from the rspec-users mailing list archive at Nabble.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 > > > > > > -- > View this message in context: http://www.nabble.com/Can-not-%27assigns%27-value-in-View-test-tf4428018.html#a12646978 > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mvyver at gmail.com Thu Sep 13 01:49:19 2007 From: mvyver at gmail.com (Mark Van De Vyver) Date: Thu, 13 Sep 2007 15:49:19 +1000 Subject: [rspec-users] A puzzling spec failure in a shared describe In-Reply-To: <79a30c430709121323l17095e74xc0c15ed55b93f41a@mail.gmail.com> References: <389c43e40709112002q78f7b21fy5f66acad11ffd726@mail.gmail.com> <79a30c430709121323l17095e74xc0c15ed55b93f41a@mail.gmail.com> Message-ID: <389c43e40709122249j6af2cdadsff6a21f9070cf8c5@mail.gmail.com> Hi, On 9/13/07, Christopher D. Pratt wrote: > I'm not really sure about your error, so hopefully someone more skilled than > me can help you with that. OK, turns out this problem was due to 'bad dehavior' in another part of the code base... Spec'ing exposed it but it'll take me some time to get used to debugging this way - more reasons to spec from the outset.... > As far as the "mock issue" goes, I don't think that was anything more than a > suggestion. I don't foresee RSpec removing it's built in mocking. If you > want/need to use another mocking framework, I know that Mocha and RSpec play > well. Not sure about FlexMock. Thanks Chris that is good to know. Regards Mark > > Chris Pratt > > > > On 9/11/07, Mark Van De Vyver wrote: > > > > Hi, > > Thanks for all the effort that has gone into making RSpec available. > > I'm not a professional developer and I've found the approach > > articulated has helped me a lot in writing my code, and understanding > > that of others. > > > > To cut my teeth, I'm trying to write an db adapter for the og project. > > > > I've being iterating with RSpec and it's exposed some unexpected > > behavior in OG, and helped me to understand some of OGs behavior, but > > I've hit a snag..... > > Perhaps someone will be kind enough to point out why I see the 4 > > failures listed in the > > attached log when I run the attached spec file, and even kinder to > > suggest how I might get this working :) > > > > Specifically, I'm puzzled by the following failure: > > > > 1) > > 'A default (DbiAdapter) connection to a new Og store should refer to > > the default database in its 'name' attribute.' FAILED > > expected: :memory, > > got: "test" (using ==) > > /usr/src/nitro-repo/og/test/og/adapter/dbi.rb:242: > > /usr/src/nitro-repo/og/test/og/adapter/dbi.rb:318: > > > > The text refers to the description of a set of expectatons far away > > from the lines references, in fact those line numbers refer to > > different describe section altogether. The 'got "test"' suggest it > > was running a spec around the line numbers cited, but the describe > > 'text' is out of sync. > > > > I suspect I'm don't understand the scope and contexts of the rspec > > components, or I may just be doing things back to front - I've read > > the simple tutorials, but have found and more advanced "how to" just > > yet - I'd greatly appreciate any pointers/hints someone can offer. > > > > There do seem to be some issues, such as 'you can't use an objects > > method twice in a describe block', but I may be misunderstand > > something I've seen? > > > > Anyway, hopefully it is not necessary, but if you need to run the spec > > file I can try help you get OG to that point, but that could be tricky > > - not all changes I've made have been > > submitted or accepted yet. > > > > Hopefully you can just see my error from a glance at the spec file? > > > > Perhaps you can comment on what should be done differently to be > > closer to rspec best-practice. > > I think this is the first adapter spec file so can probably be used as > > a template for others in the project? > > > > As I said, I suspect I'm missing something about how rspec works... one > issue > > that isn't clear from the rspec site is the scope of variables in a > > spec file... > > > > Final Q: > > Has there been a resolution of the Mock issue, i.e will it rspec > > implementation stay in rspec or not. > > Which of mocha and flexmock are most compatible (i.e. work) with > > rspec, or is there a 'better' mock project to use with rspec. > > > > Appreciate any help or insight you can offer. > > > > Regards > > Mark > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > From galeal_lists at ideaforge.org Thu Sep 13 08:25:21 2007 From: galeal_lists at ideaforge.org (Luke Galea) Date: Thu, 13 Sep 2007 08:25:21 -0400 Subject: [rspec-users] Authenticating before tests Message-ID: Hi all, I'm using Goldberg, an engine that provides roles based access control for my app. I need to login before I can do controller tests, but I can't find any examples of people doing this. Could someone point me in the right direction? I thought the simplest way would be to either call the login action from my other tests before(:all), but I can't seem to find how to call another controller from within the spec for a different controller. (Results in @controller is nil). I've also tried setting session[:user] in before(:all), but session is nil at that point! Any help would be greatly appreciated. Thanks, Luke From jarkko at jlaine.net Thu Sep 13 08:42:59 2007 From: jarkko at jlaine.net (Jarkko Laine) Date: Thu, 13 Sep 2007 15:42:59 +0300 Subject: [rspec-users] Authenticating before tests In-Reply-To: References: Message-ID: <4DF65DCD-689C-4D2B-9178-D595C339053D@jlaine.net> On 13.9.2007, at 15.25, Luke Galea wrote: > Hi all, > > I'm using Goldberg, an engine that provides roles based access > control for my app. I need to login before I can do controller tests, > but I can't find any examples of people doing this. > > Could someone point me in the right direction? This is what we do: in spec_helper.rb: include AuthenticatedTestHelper def login_as(user) controller.send :current_user=, user end Then, in a before(:all) block, I can say login_as(@user) with a user object. This assumes you're using restful_authentication (and should work with acts_as_authenticated as well). > > I thought the simplest way would be to either call the login action > from my other tests before(:all), but I can't seem to find how to > call another controller from within the spec for a different > controller. (Results in @controller is nil). You can't and shouldn't do that. Just find out how your particular authentication system determines the login and create a helper method like login_as above to simulate the login. -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070913/2ce6788f/attachment.bin From bret at pettichord.com Thu Sep 13 09:43:27 2007 From: bret at pettichord.com (Bret Pettichord) Date: Thu, 13 Sep 2007 08:43:27 -0500 Subject: [rspec-users] Checking out Rspec In-Reply-To: <623C2C88-866E-4B62-B9DA-86C0F26488CA@railsnewbie.com> References: <623C2C88-866E-4B62-B9DA-86C0F26488CA@railsnewbie.com> Message-ID: On 9/12/07, Scott Taylor wrote: > I have been having connection problems with rspec's rubyforge > repository for a long time. I'm running my own mirror if you want > the subversion link (although the revision numbers are a little bit > off). > > Generally, though, if you are having problems with this sort of thing > on rubyforge, you should try contacting them directly (Rubyforge has > it's own tracker). They would know more about this stuff than the > rspec project admins. Thanks for your help. I have several projects hosted at Rubyforge (and have contacted Tom for help on many occassions) but my first impression was that this particular error was not a connection problem, but rather something specific about the way the code was checked in. Apparently others are not having this problem, so my next guess is that this is something specific to Subclipse. I will install TortoisseSVN next and see what happens with that. I would appreciate it if you could send me a link to your SVN mirror. If, however, there was something specific about the error message that made you think it really was a connection, let me know and I'll talk to Tom about it. I ran into the same problem with the same file in three different attempts to checkout or update. Bret -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070913/b7defd6c/attachment.html From lists-rspec at shopwatch.org Thu Sep 13 10:21:02 2007 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Thu, 13 Sep 2007 10:21:02 -0400 Subject: [rspec-users] Checking out Rspec In-Reply-To: References: <623C2C88-866E-4B62-B9DA-86C0F26488CA@railsnewbie.com> Message-ID: <46E9474E.1020402@shopwatch.org> On 9/13/2007 9:43 AM, Bret Pettichord wrote: > On 9/12/07, *Scott Taylor* > wrote: > > I have been having connection problems with rspec's rubyforge > repository for a long time. I'm running my own mirror if you want > the subversion link (although the revision numbers are a little bit > off). > > Generally, though, if you are having problems with this sort of thing > on rubyforge, you should try contacting them directly (Rubyforge has > it's own tracker). They would know more about this stuff than the > rspec project admins. > > > Thanks for your help. I have several projects hosted at Rubyforge (and > have contacted Tom for help on many occassions) but my first impression > was that this particular error was not a connection problem, but rather > something specific about the way the code was checked in. Apparently > others are not having this problem, so my next guess is that this is > something specific to Subclipse. I will install TortoisseSVN next and > see what happens with that. I would appreciate it if you could send me a > link to your SVN mirror. Hmm, I just checked out RSpec on Subclipse last week w/no problems. What platform are you on, which SVN adapter, etc.? I was using Mac OS X 10.4.10, Eclipse 3.3, Subclipse 1.2.4, SVNKit. Jay > > If, however, there was something specific about the error message that > made you think it really was a connection, let me know and I'll talk to > Tom about it. I ran into the same problem with the same file in three > different attempts to checkout or update. > > Bret > > > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From rspec.user at gmail.com Thu Sep 13 12:52:05 2007 From: rspec.user at gmail.com (sinclair bain) Date: Thu, 13 Sep 2007 12:52:05 -0400 Subject: [rspec-users] Authenticating before tests In-Reply-To: References: Message-ID: <2ca660dd0709130952v7d1f9981k584fdf0a98fe756b@mail.gmail.com> Hi! Have you considered mocking / stubbing to test in isolation if that is appropriate ? sinclair On 9/13/07, Luke Galea wrote: > > Hi all, > > I'm using Goldberg, an engine that provides roles based access > control for my app. I need to login before I can do controller tests, > but I can't find any examples of people doing this. > > Could someone point me in the right direction? > > I thought the simplest way would be to either call the login action > from my other tests before(:all), but I can't seem to find how to > call another controller from within the spec for a different > controller. (Results in @controller is nil). > > I've also tried setting session[:user] in before(:all), but session > is nil at that point! > > Any help would be greatly appreciated. > > Thanks, > Luke > _______________________________________________ > 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/20070913/0e67634b/attachment.html From jarkko at jlaine.net Thu Sep 13 13:22:18 2007 From: jarkko at jlaine.net (Jarkko Laine) Date: Thu, 13 Sep 2007 20:22:18 +0300 Subject: [rspec-users] Failing to raise an exception in a stub Message-ID: <97F6CF1D-7D62-4473-94D7-8A82F79284D9@jlaine.net> I've come across rather strange behaviour when trying to raise an exception in a stubbed method. I'm speccing the behaviour of a Rails create action, where I'm using save! to catch failed saves. In the case of working save, I'm using the following stub: @client.stub!(:save!).and_return(true) which works fine. However, in the negative case, @client.stub!(:save!).and_raise(ActiveRecord::RecordInvalid) The save! call in the controller doesn't seem to work. I get the following error: ArgumentError in 'ClientsController POST /clients with invalid parameters should show new form again' wrong number of arguments (0 for 1) /Users/jarkko/Sites/koulutusweb/app/controllers/clients_controller.rb: 41:in `create' The line #41 consists only of @client.save! I'm at a loss seeing where the wrong number of arguments is really happening because save! certainly shouldn't assume any args. Moreover, both cases work fine in the real app, so it seems to me something funky is happening when stubbing the method. Anyone else stumbled upon anything similar? Cheers, //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070913/a7dcc021/attachment-0001.bin From bret at pettichord.com Thu Sep 13 13:28:55 2007 From: bret at pettichord.com (Bret Pettichord) Date: Thu, 13 Sep 2007 12:28:55 -0500 Subject: [rspec-users] Checking out Rspec In-Reply-To: <46E9474E.1020402@shopwatch.org> References: <623C2C88-866E-4B62-B9DA-86C0F26488CA@railsnewbie.com> <46E9474E.1020402@shopwatch.org> Message-ID: > > Hmm, I just checked out RSpec on Subclipse last week w/no problems. > What platform are you on, which SVN adapter, etc.? I was using Mac OS X > 10.4.10, Eclipse 3.3, Subclipse 1.2.4, SVNKit. I'm using Eclipse 3.3 on windows with Subclipse 1.2.3. I also reproduced the problem using TortoisseSVN 1.4.5. I've reproduced it on two different machines. Just to clarify, are you all also checking out from svn://rubyforge.org/var/svn/rspec/trunk and not from a subdirectory? Bret -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070913/cd9ac574/attachment.html From jarkko at jlaine.net Thu Sep 13 13:25:39 2007 From: jarkko at jlaine.net (Jarkko Laine) Date: Thu, 13 Sep 2007 20:25:39 +0300 Subject: [rspec-users] Authenticating before tests In-Reply-To: <2ca660dd0709130952v7d1f9981k584fdf0a98fe756b@mail.gmail.com> References: <2ca660dd0709130952v7d1f9981k584fdf0a98fe756b@mail.gmail.com> Message-ID: <41192E91-F1EF-4D45-8D62-E7C470FD4EAF@jlaine.net> On 13.9.2007, at 19.52, sinclair bain wrote: > Hi! > > Have you considered mocking / stubbing to test in isolation if that > is appropriate ? Right, my example was also assuming that you are using mocks for users. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070913/f465bb7b/attachment.bin From aslak.hellesoy at gmail.com Thu Sep 13 16:29:42 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 13 Sep 2007 22:29:42 +0200 Subject: [rspec-users] Failing to raise an exception in a stub In-Reply-To: <97F6CF1D-7D62-4473-94D7-8A82F79284D9@jlaine.net> References: <97F6CF1D-7D62-4473-94D7-8A82F79284D9@jlaine.net> Message-ID: <8d961d900709131329v2ace8d7bsc05f98ad74c0c8fe@mail.gmail.com> On 9/13/07, Jarkko Laine wrote: > I've come across rather strange behaviour when trying to raise an > exception in a stubbed method. > > I'm speccing the behaviour of a Rails create action, where I'm using > save! to catch failed saves. In the case of working save, I'm using > the following stub: > > @client.stub!(:save!).and_return(true) > > which works fine. > > However, in the negative case, > > @client.stub!(:save!).and_raise(ActiveRecord::RecordInvalid) > Passing a class only works if the new method takes 0 args. Otherwise you have to pass an exception instance. ActiveRecord::RecordInvalid takes one. @client.stub!(:save!).and_raise(ActiveRecord::RecordInvalid.new(@client)) > The save! call in the controller doesn't seem to work. I get the > following error: > > ArgumentError in 'ClientsController POST /clients with invalid > parameters should show new form again' > wrong number of arguments (0 for 1) > /Users/jarkko/Sites/koulutusweb/app/controllers/clients_controller.rb: > 41:in `create' > > The line #41 consists only of > > @client.save! > > I'm at a loss seeing where the wrong number of arguments is really > happening because save! certainly shouldn't assume any args. > Moreover, both cases work fine in the real app, so it seems to me > something funky is happening when stubbing the method. > > Anyone else stumbled upon anything similar? > > Cheers, > //jarkko > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From pergesu at gmail.com Thu Sep 13 18:10:52 2007 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 13 Sep 2007 15:10:52 -0700 Subject: [rspec-users] Philosophical questions In-Reply-To: <977ACF0A-3D96-403F-A1F5-6E0132AFA438@tiggerpalace.com> References: <977ACF0A-3D96-403F-A1F5-6E0132AFA438@tiggerpalace.com> Message-ID: <810a540e0709131510v55ff00cq77f21bbe1c80ae1d@mail.gmail.com> On 9/12/07, Evan David Light wrote: > Disclaimer: The following are observations by a relatively new user (couple > of weeks) of RSpec and not intended as RSpec trollbait. Also, forgive me if > similar topics have been discussed elsewhere on the mailing list. I at > least did the due diligence of a quick search. > > That said... > > I've been positively thrilled with RSpec for use outside of Rails. It has > been in my attempts to use it within Rails that I have begun to question > whether and how it can buy me much more than Test::Unit. > > I recently began using RSpec to drive the design, in BDD fashion, of a > Rails app. Believing that behavior is best measured from the user's > experience, I started by writing a View spec. I considered this a top-down > approach. Were I still using Test::Unit, I likely would have started in the > same place that I usually do out of habit: the Model. > > However, the more googling that I've done, the more that I noticed that > most RSpec articles, where they addressed Rails, were primarily focused on > the Model. I began to wonder, "are people using RSpec much like people were > using Test::Unit?" I've seen that some people eschew View Specs. However, > in lieu of that, how does one spec the interface that should, in theory, > drive the design of the application? > > Ultimately, I'm left with similar perspective to Jordan's: View specs will > be brittle. They'll span multiple Behaviors as there will be at least one > per action -- leading me to wonder if BDD, or at least RSpec, is necessarily > the best way to try to spec the View. However, Controllers and Models seem > as though they would work reasonably well. > > Can anyone recommend some approaches for tackling BDD starting from the > View down? > > Thanks, > Evan > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Hi Evan, I think you have the right idea about approaching specification from the user's viewpoint (or more appropriately, as David C said, business value). It just seems like you're not completely familiar with the tools that RSpec provides. Nothing wrong with that, because one of the most important tools still hasn't been officially released! View specs are for unit testing your view, not for exercising functionality. In fact they shouldn't do very much at all. They should be pretty simple...make sure that certain attributes from an object are being displayed, perhaps how some of the markup is structured, etc. That can be brittle, and will become painfully so if you specify too much. You'll want to specify the bare minimum it takes to get the job done. Others have mentioned Story Runner, which is a new feature of RSpec. I'm pretty jazzed about it, because it's a very lightweight tool for acceptance tests. The structure is clean, it just makes sense to me. I wrote an introduction which you can find at http://evang.eli.st/blog/2007/9/1/user-stories-with-rspec-s-story-runner. It also has links to some of Dan North's articles which are a great resource for really getting BDD. As far as tackling BDD from the top down...for me, it all starts with a Story. This can be a bit tough if you don't write user stories to define features, and instead just get told "hey we should add this." However I've found that writing an initial user story forces me to really clarify what a feature means to our product. Also Story Runner makes it incredibly easy to share the stories with others. If one of our customers tells me something doesn't work right, but I think it does, I can show him the story I wrote. We've already resolved an issue like this...I showed him the story, he said that he was making different assumptions. I coded those up into the story and off we went. I hope you check out Story Runner, it's a really cool tool. If your development philosophy is about creating business value, then it should totally vibe with you. From there you use the finer-grained aspects of RSpec to achieve that business value with code that doesn't drive you insane :) Pat From evan at tiggerpalace.com Thu Sep 13 18:38:50 2007 From: evan at tiggerpalace.com (Evan David Light) Date: Thu, 13 Sep 2007 18:38:50 -0400 Subject: [rspec-users] Philosophical questions In-Reply-To: <810a540e0709131510v55ff00cq77f21bbe1c80ae1d@mail.gmail.com> References: <977ACF0A-3D96-403F-A1F5-6E0132AFA438@tiggerpalace.com> <810a540e0709131510v55ff00cq77f21bbe1c80ae1d@mail.gmail.com> Message-ID: <280E1160-7C13-4579-9796-76E3FFC138F7@tiggerpalace.com> On Sep 13, 2007, at 6:10 PM, Pat Maddox wrote: > On 9/12/07, Evan David Light wrote: >> ... (Evan's RSpec n00bish ramblings) ... >> Thanks, >> Evan >> >> > > Hi Evan, > > I think you have the right idea about approaching specification from > the user's viewpoint (or more appropriately, as David C said, business > value). It just seems like you're not completely familiar with the > tools that RSpec provides. Nothing wrong with that, because one of > the most important tools still hasn't been officially released! > Quite so. Certainly not with RSpec-on-Rails at least. I have been milling around the RDoc. in my spare moments and have written a few specs for a statistical analysis tool that I wrote recently. Work has been dragging me away from coding too much lately. Fortunately, I've had this afternoon and have all of tomorrow to get my hands dirty. > View specs are for unit testing your view, not for exercising > functionality. In fact they shouldn't do very much at all. They > should be pretty simple...make sure that certain attributes from an > object are being displayed, perhaps how some of the markup is > structured, etc. That can be brittle, and will become painfully so if > you specify too much. You'll want to specify the bare minimum it > takes to get the job done. > Understood. Admittedly, I had not even seen a Rails Integration Test until I after I read a few posts on this list and did some googling. I've been fortunate to be able to pick Ruby for my current project but I haven't had an excuse to develop a production Rails app until a few days ago. I've only done a lot of tinkering at home for which I now wish that I had used TDD or BDD. That said... > Others have mentioned Story Runner, which is a new feature of RSpec. > I'm pretty jazzed about it, because it's a very lightweight tool for > acceptance tests. The structure is clean, it just makes sense to me. > I wrote an introduction which you can find at > http://evang.eli.st/blog/2007/9/1/user-stories-with-rspec-s-story- > runner. > It also has links to some of Dan North's articles which are a great > resource for really getting BDD. > I know! I saw them both! After reading David's messages from yesterday, I was inspired to checkout from trunk this afternoon, plowed through some of the spec for Story Runner, and then some of the examples. I love what I see. My immediate impression was Story == Use Case. That seems to be bear out the more that I looked at the RSpec for Story Runner and at the code samples. In fact, I was just getting ready to dig into writing my first Story when I decided to pop over to the mailing list for a second. Who needs to read an RDoc? ;-) > As far as tackling BDD from the top down...for me, it all starts with > a Story. I can totally see that. Use cases tend to proceed lower level requirements in the waterfall process (not that many of us are using this one anymore...). > This can be a bit tough if you don't write user stories to > define features, and instead just get told "hey we should add this." Not necessarily. Just as you say below, the Story lets you put meat on that skeleton of an idea. > We've already resolved an > issue like this...I showed him the story, he said that he was making > different assumptions. I coded those up into the story and off we > went. > Very cool. > I hope you check out Story Runner, it's a really cool tool. If your > development philosophy is about creating business value, then it > should totally vibe with you. From there you use the finer-grained > aspects of RSpec to achieve that business value with code that doesn't > drive you insane :) Seriously, this is exactly the kind of thing that I was looking for when I mistakenly began playing with View specs. Now I'm also going to have to "Storify" my personal Rails project when I get some spare time! Thanks guys. This looks like it will be very useful. More as I dig in. Evan Light IMs (all): sleight42 http://evan.tiggerpalace.com From dchelimsky at gmail.com Thu Sep 13 18:52:03 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 13 Sep 2007 17:52:03 -0500 Subject: [rspec-users] Philosophical questions In-Reply-To: <280E1160-7C13-4579-9796-76E3FFC138F7@tiggerpalace.com> References: <977ACF0A-3D96-403F-A1F5-6E0132AFA438@tiggerpalace.com> <810a540e0709131510v55ff00cq77f21bbe1c80ae1d@mail.gmail.com> <280E1160-7C13-4579-9796-76E3FFC138F7@tiggerpalace.com> Message-ID: <57c63afe0709131552h47cbf92bj24bd7e62c1fef2f@mail.gmail.com> On 9/13/07, Evan David Light wrote: > My immediate impression was Story == Use Case. Story == User Story User Stories are not the same thing as Use Cases. You may want to google around for some writing on that. Cheers. From flyeminent at hotmail.com Thu Sep 13 22:25:56 2007 From: flyeminent at hotmail.com (Shaker) Date: Thu, 13 Sep 2007 19:25:56 -0700 (PDT) Subject: [rspec-users] Need help in View Spec Message-ID: <12667395.post@talk.nabble.com> Hello everyone: I am kind of puzzled in writing spec on view partials. I can not find much information about the "should have_tag" syntax in Rspec. Can rspec test a particular attribute of a tag (e.g. input tag)? Let me put an example here: #../view/group/_index
        I want to test the "onclick" attribute in the input tag, which ensure that clicking the button will call the correct Javascript method. How should I do? Great thanks for any help. -- View this message in context: http://www.nabble.com/Need-help-in-View-Spec-tf4439760.html#a12667395 Sent from the rspec-users mailing list archive at Nabble.com. From dchelimsky at gmail.com Thu Sep 13 22:40:31 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 13 Sep 2007 21:40:31 -0500 Subject: [rspec-users] Need help in View Spec In-Reply-To: <12667395.post@talk.nabble.com> References: <12667395.post@talk.nabble.com> Message-ID: <57c63afe0709131940r325e99c9i62acd8f96e75d303@mail.gmail.com> On 9/13/07, Shaker wrote: > I can not find much > information about the "should have_tag" syntax in Rspec. http://rspec.rubyforge.org/rdoc-rails/classes/Spec/Rails/Matchers.html#M000011 From flyeminent at hotmail.com Thu Sep 13 22:49:38 2007 From: flyeminent at hotmail.com (Shaker) Date: Thu, 13 Sep 2007 19:49:38 -0700 (PDT) Subject: [rspec-users] Need help in View Spec In-Reply-To: <57c63afe0709131940r325e99c9i62acd8f96e75d303@mail.gmail.com> References: <12667395.post@talk.nabble.com> <57c63afe0709131940r325e99c9i62acd8f96e75d303@mail.gmail.com> Message-ID: <12667582.post@talk.nabble.com> Yes, I have gone through the documentation before, and I read the reference of 'assert_select' as well. But I still can not figure out a way of testing attributes in a tag. What I know is we can use: should have_tag("tag#id") or should have_tag("tag.class") to select a tag, whereas I don't know how to select an attribute and test it! Another problem is the tag does not have id or class sometimes, does it mean that is no way of selecting it? David Chelimsky-2 wrote: > > On 9/13/07, Shaker wrote: >> I can not find much >> information about the "should have_tag" syntax in Rspec. > > http://rspec.rubyforge.org/rdoc-rails/classes/Spec/Rails/Matchers.html#M000011 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > -- View this message in context: http://www.nabble.com/Need-help-in-View-Spec-tf4439760.html#a12667582 Sent from the rspec-users mailing list archive at Nabble.com. From dchelimsky at gmail.com Thu Sep 13 22:54:59 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 13 Sep 2007 21:54:59 -0500 Subject: [rspec-users] Need help in View Spec In-Reply-To: <12667582.post@talk.nabble.com> References: <12667395.post@talk.nabble.com> <57c63afe0709131940r325e99c9i62acd8f96e75d303@mail.gmail.com> <12667582.post@talk.nabble.com> Message-ID: <57c63afe0709131954o57ee58b7p5882fd074d9e28e4@mail.gmail.com> On 9/13/07, Shaker wrote: > > Yes, I have gone through the documentation before, and I read the reference > of 'assert_select' as well. But I still can not figure out a way of testing > attributes in a tag. What I know is we can use: > should have_tag("tag#id") or should have_tag("tag.class") > to select a tag, whereas I don't know how to select an attribute and test > it! That's all covered in the assert_select docs. Here's a cheat sheet you might find useful. http://labnotes.org/svn/public/ruby/rails_plugins/assert_select/cheat/assert_select.html so you can do this: response.should have_tag("form[action=?][method=post]", foo_path(@foo)) HTH > Another problem is the tag does not have id or class sometimes, does it mean > that is no way of selecting it? > > David Chelimsky-2 wrote: > > > > On 9/13/07, Shaker wrote: > >> I can not find much > >> information about the "should have_tag" syntax in Rspec. > > > > http://rspec.rubyforge.org/rdoc-rails/classes/Spec/Rails/Matchers.html#M000011 > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > View this message in context: http://www.nabble.com/Need-help-in-View-Spec-tf4439760.html#a12667582 > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From flyeminent at hotmail.com Thu Sep 13 23:09:52 2007 From: flyeminent at hotmail.com (Shaker) Date: Thu, 13 Sep 2007 20:09:52 -0700 (PDT) Subject: [rspec-users] Need help in View Spec In-Reply-To: <57c63afe0709131954o57ee58b7p5882fd074d9e28e4@mail.gmail.com> References: <12667395.post@talk.nabble.com> <57c63afe0709131940r325e99c9i62acd8f96e75d303@mail.gmail.com> <12667582.post@talk.nabble.com> <57c63afe0709131954o57ee58b7p5882fd074d9e28e4@mail.gmail.com> Message-ID: <12667709.post@talk.nabble.com> Hello To spec the example I mentioned before, I wrote the spec as what you suggested #../view/group/index_spec.rb describe "/group/_index_spec" do it "should call JS function when click the button" do render '/group/_index' response.should have_tag("input[onclick=?]", "update()") end end However, it generated an error "Expecting a selector as the first argument". What is wrong? David Chelimsky-2 wrote: > > On 9/13/07, Shaker wrote: >> >> Yes, I have gone through the documentation before, and I read the >> reference >> of 'assert_select' as well. But I still can not figure out a way of >> testing >> attributes in a tag. What I know is we can use: >> should have_tag("tag#id") or should have_tag("tag.class") >> to select a tag, whereas I don't know how to select an attribute and test >> it! > > That's all covered in the assert_select docs. Here's a cheat sheet you > might find useful. > > http://labnotes.org/svn/public/ruby/rails_plugins/assert_select/cheat/assert_select.html > > so you can do this: > > response.should have_tag("form[action=?][method=post]", foo_path(@foo)) > > HTH > > > > > >> Another problem is the tag does not have id or class sometimes, does it >> mean >> that is no way of selecting it? >> >> David Chelimsky-2 wrote: >> > >> > On 9/13/07, Shaker wrote: >> >> I can not find much >> >> information about the "should have_tag" syntax in Rspec. >> > >> > >> http://rspec.rubyforge.org/rdoc-rails/classes/Spec/Rails/Matchers.html#M000011 >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/Need-help-in-View-Spec-tf4439760.html#a12667582 >> Sent from the rspec-users mailing list archive at Nabble.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 > > -- View this message in context: http://www.nabble.com/Need-help-in-View-Spec-tf4439760.html#a12667709 Sent from the rspec-users mailing list archive at Nabble.com. From flyeminent at hotmail.com Thu Sep 13 23:12:46 2007 From: flyeminent at hotmail.com (Shaker) Date: Thu, 13 Sep 2007 20:12:46 -0700 (PDT) Subject: [rspec-users] Need help in View Spec In-Reply-To: <12667709.post@talk.nabble.com> References: <12667395.post@talk.nabble.com> <57c63afe0709131940r325e99c9i62acd8f96e75d303@mail.gmail.com> <12667582.post@talk.nabble.com> <57c63afe0709131954o57ee58b7p5882fd074d9e28e4@mail.gmail.com> <12667709.post@talk.nabble.com> Message-ID: <12667734.post@talk.nabble.com> Sorry, that's another spec caused the error. It is working. Thank you very much Shaker wrote: > > Hello > To spec the example I mentioned before, I wrote the spec as what you > suggested > #../view/group/index_spec.rb > describe "/group/_index_spec" do > it "should call JS function when click the button" do > render '/group/_index' > response.should have_tag("input[onclick=?]", "update()") > end > end > However, it generated an error "Expecting a selector as the first > argument". What is wrong? > > David Chelimsky-2 wrote: >> >> On 9/13/07, Shaker wrote: >>> >>> Yes, I have gone through the documentation before, and I read the >>> reference >>> of 'assert_select' as well. But I still can not figure out a way of >>> testing >>> attributes in a tag. What I know is we can use: >>> should have_tag("tag#id") or should have_tag("tag.class") >>> to select a tag, whereas I don't know how to select an attribute and >>> test >>> it! >> >> That's all covered in the assert_select docs. Here's a cheat sheet you >> might find useful. >> >> http://labnotes.org/svn/public/ruby/rails_plugins/assert_select/cheat/assert_select.html >> >> so you can do this: >> >> response.should have_tag("form[action=?][method=post]", foo_path(@foo)) >> >> HTH >> >> >> >> >> >>> Another problem is the tag does not have id or class sometimes, does it >>> mean >>> that is no way of selecting it? >>> >>> David Chelimsky-2 wrote: >>> > >>> > On 9/13/07, Shaker wrote: >>> >> I can not find much >>> >> information about the "should have_tag" syntax in Rspec. >>> > >>> > >>> http://rspec.rubyforge.org/rdoc-rails/classes/Spec/Rails/Matchers.html#M000011 >>> > _______________________________________________ >>> > rspec-users mailing list >>> > rspec-users at rubyforge.org >>> > http://rubyforge.org/mailman/listinfo/rspec-users >>> > >>> > >>> >>> -- >>> View this message in context: >>> http://www.nabble.com/Need-help-in-View-Spec-tf4439760.html#a12667582 >>> Sent from the rspec-users mailing list archive at Nabble.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 >> >> > > -- View this message in context: http://www.nabble.com/Need-help-in-View-Spec-tf4439760.html#a12667734 Sent from the rspec-users mailing list archive at Nabble.com. From dchelimsky at gmail.com Thu Sep 13 23:13:35 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 13 Sep 2007 22:13:35 -0500 Subject: [rspec-users] Need help in View Spec In-Reply-To: <12667734.post@talk.nabble.com> References: <12667395.post@talk.nabble.com> <57c63afe0709131940r325e99c9i62acd8f96e75d303@mail.gmail.com> <12667582.post@talk.nabble.com> <57c63afe0709131954o57ee58b7p5882fd074d9e28e4@mail.gmail.com> <12667709.post@talk.nabble.com> <12667734.post@talk.nabble.com> Message-ID: <57c63afe0709132013s3c4fb88dw3dc6110a7240d87b@mail.gmail.com> On 9/13/07, Shaker wrote: > > Sorry, that's another spec caused the error. It is working. Thank you very > much Glad you got it worked out. Cheers, David > > Shaker wrote: > > > > Hello > > To spec the example I mentioned before, I wrote the spec as what you > > suggested > > #../view/group/index_spec.rb > > describe "/group/_index_spec" do > > it "should call JS function when click the button" do > > render '/group/_index' > > response.should have_tag("input[onclick=?]", "update()") > > end > > end > > However, it generated an error "Expecting a selector as the first > > argument". What is wrong? > > > > David Chelimsky-2 wrote: > >> > >> On 9/13/07, Shaker wrote: > >>> > >>> Yes, I have gone through the documentation before, and I read the > >>> reference > >>> of 'assert_select' as well. But I still can not figure out a way of > >>> testing > >>> attributes in a tag. What I know is we can use: > >>> should have_tag("tag#id") or should have_tag("tag.class") > >>> to select a tag, whereas I don't know how to select an attribute and > >>> test > >>> it! > >> > >> That's all covered in the assert_select docs. Here's a cheat sheet you > >> might find useful. > >> > >> http://labnotes.org/svn/public/ruby/rails_plugins/assert_select/cheat/assert_select.html > >> > >> so you can do this: > >> > >> response.should have_tag("form[action=?][method=post]", foo_path(@foo)) > >> > >> HTH > >> > >> > >> > >> > >> > >>> Another problem is the tag does not have id or class sometimes, does it > >>> mean > >>> that is no way of selecting it? > >>> > >>> David Chelimsky-2 wrote: > >>> > > >>> > On 9/13/07, Shaker wrote: > >>> >> I can not find much > >>> >> information about the "should have_tag" syntax in Rspec. > >>> > > >>> > > >>> http://rspec.rubyforge.org/rdoc-rails/classes/Spec/Rails/Matchers.html#M000011 > >>> > _______________________________________________ > >>> > rspec-users mailing list > >>> > rspec-users at rubyforge.org > >>> > http://rubyforge.org/mailman/listinfo/rspec-users > >>> > > >>> > > >>> > >>> -- > >>> View this message in context: > >>> http://www.nabble.com/Need-help-in-View-Spec-tf4439760.html#a12667582 > >>> Sent from the rspec-users mailing list archive at Nabble.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 > >> > >> > > > > > > -- > View this message in context: http://www.nabble.com/Need-help-in-View-Spec-tf4439760.html#a12667734 > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jarkko at jlaine.net Fri Sep 14 02:03:55 2007 From: jarkko at jlaine.net (Jarkko Laine) Date: Fri, 14 Sep 2007 09:03:55 +0300 Subject: [rspec-users] Failing to raise an exception in a stub In-Reply-To: <8d961d900709131329v2ace8d7bsc05f98ad74c0c8fe@mail.gmail.com> References: <97F6CF1D-7D62-4473-94D7-8A82F79284D9@jlaine.net> <8d961d900709131329v2ace8d7bsc05f98ad74c0c8fe@mail.gmail.com> Message-ID: <1C4E7122-D741-4C62-91FE-E2D865D45DB4@jlaine.net> On 13.9.2007, at 23.29, aslak hellesoy wrote: > On 9/13/07, Jarkko Laine wrote: >> I've come across rather strange behaviour when trying to raise an >> exception in a stubbed method. >> >> I'm speccing the behaviour of a Rails create action, where I'm using >> save! to catch failed saves. In the case of working save, I'm using >> the following stub: >> >> @client.stub!(:save!).and_return(true) >> >> which works fine. >> >> However, in the negative case, >> >> @client.stub!(:save!).and_raise(ActiveRecord::RecordInvalid) >> > > Passing a class only works if the new method takes 0 args. Otherwise > you have to pass an exception instance. ActiveRecord::RecordInvalid > takes one. > > @client.stub!(:save!).and_raise(ActiveRecord::RecordInvalid.new > (@client)) Cheers, that was it! //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070914/3cfd2a61/attachment.bin From jarkko at jlaine.net Fri Sep 14 02:15:57 2007 From: jarkko at jlaine.net (Jarkko Laine) Date: Fri, 14 Sep 2007 09:15:57 +0300 Subject: [rspec-users] Philosophical questions In-Reply-To: <810a540e0709131510v55ff00cq77f21bbe1c80ae1d@mail.gmail.com> References: <977ACF0A-3D96-403F-A1F5-6E0132AFA438@tiggerpalace.com> <810a540e0709131510v55ff00cq77f21bbe1c80ae1d@mail.gmail.com> Message-ID: <1744D851-2741-479B-9FDB-90ECC1C6F506@jlaine.net> On 14.9.2007, at 1.10, Pat Maddox wrote: > Others have mentioned Story Runner, which is a new feature of RSpec. > I'm pretty jazzed about it, because it's a very lightweight tool for > acceptance tests. The structure is clean, it just makes sense to me. > I wrote an introduction which you can find at > http://evang.eli.st/blog/2007/9/1/user-stories-with-rspec-s-story- > runner. > It also has links to some of Dan North's articles which are a great > resource for really getting BDD. +1 for Story Runner. I just installed it on a project for a client that were using controller specs heavily for end-to-end stuff. Even on an app running on Rails 1.2, the rspec trunk installed flawlessly with some minimal changes to the existing spec code. From what I learned, Story Runner is already highly usable even though it's not officially out. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070914/8ebb7a81/attachment-0001.bin From rubyphunk at googlemail.com Fri Sep 14 05:02:08 2007 From: rubyphunk at googlemail.com (Andreas Wolff) Date: Fri, 14 Sep 2007 11:02:08 +0200 Subject: [rspec-users] Testing a nested controller Message-ID: <526df6040709140202v4ca1c126ue958fb3e2ef151b3@mail.gmail.com> Hey everyone. I really stuck on testing a nested controller. I'm trying to make a request using get and afterwards checking the response by response.should ... My routes.rb looks like this: map.resources :writers do |writers| writers.resources :notes end In my notes_controller_spec.rb def do_get writer_id = 1 note_id = 1 get note_path(writer_id, note_id) end it "should show a note" do do_get response.should be_success end But this always ends in an error message: You have a nil object when you didn't expect it! The error occurred while evaluating nil.rewrite Can anybody help here?? -- by(e) Andreas Wolff From rubyphunk at googlemail.com Fri Sep 14 05:15:22 2007 From: rubyphunk at googlemail.com (Andreas Wolff) Date: Fri, 14 Sep 2007 11:15:22 +0200 Subject: [rspec-users] Testing a nested controller In-Reply-To: <526df6040709140202v4ca1c126ue958fb3e2ef151b3@mail.gmail.com> References: <526df6040709140202v4ca1c126ue958fb3e2ef151b3@mail.gmail.com> Message-ID: <526df6040709140215h76a6dfd5oac2646937157f91d@mail.gmail.com> Ok. this was stupid :) I found the answer two minutes later: You cannot use the url helper here, but if you provide the writers id in the request everything works fine: testing the route: route_for(:controller => "notes", :action => "show", :id => 1, :writer_id => 1) testing the request by: get :show, :id => 1, :writer_id => 1 bye On 9/14/07, Andreas Wolff wrote: > Hey everyone. > I really stuck on testing a nested controller. I'm trying to make a > request using get and afterwards checking the response by > response.should ... > > My routes.rb looks like this: > > map.resources :writers do |writers| > writers.resources :notes > end > > > In my notes_controller_spec.rb > > def do_get > writer_id = 1 > note_id = 1 > get note_path(writer_id, note_id) > end > > it "should show a note" do > do_get > response.should be_success > end > > > But this always ends in an error message: > You have a nil object when you didn't expect it! > The error occurred while evaluating nil.rewrite > > Can anybody help here?? > > -- > by(e) > Andreas Wolff > -- by(e) Andreas Wolff http://rubyblog.de | http://activerails.de From jarkko at jlaine.net Fri Sep 14 05:28:33 2007 From: jarkko at jlaine.net (Jarkko Laine) Date: Fri, 14 Sep 2007 12:28:33 +0300 Subject: [rspec-users] Testing a nested controller In-Reply-To: <526df6040709140202v4ca1c126ue958fb3e2ef151b3@mail.gmail.com> References: <526df6040709140202v4ca1c126ue958fb3e2ef151b3@mail.gmail.com> Message-ID: On 14.9.2007, at 12.02, Andreas Wolff wrote: > Hey everyone. > I really stuck on testing a nested controller. I'm trying to make a > request using get and afterwards checking the response by > response.should ... > > My routes.rb looks like this: > > map.resources :writers do |writers| > writers.resources :notes > end > > > In my notes_controller_spec.rb > > def do_get > writer_id = 1 > note_id = 1 > get note_path(writer_id, note_id) > end > > it "should show a note" do > do_get > response.should be_success > end > > > But this always ends in an error message: > You have a nil object when you didn't expect it! > The error occurred while evaluating nil.rewrite > > Can anybody help here?? You shouldn't test the routing stack in controller tests. Just say get :show, :id => 1, :writer_id => 1 It will automatically use the correct controller, given that you have either used "describe NotesController" or use the controller helper to identify the controller. I think the former way is now considered best practice. If you want to test routes, do it separately. IIRC generating an rspec_scaffold will create you examples of how to do that. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070914/46f61372/attachment.bin From tom at experthuman.com Fri Sep 14 15:38:11 2007 From: tom at experthuman.com (Tom Stuart) Date: Fri, 14 Sep 2007 20:38:11 +0100 Subject: [rspec-users] using #include in shared behaviours Message-ID: Hi folks, Is there any way I can call #include from within a shared behaviour without it blowing up?: > vendor/plugins/rspec/lib/spec/dsl/shared_behaviour.rb:48:in > `included': private method `include' called for # > (NoMethodError) More detail: I have a spec/concerns directory which contains specs corresponding to mixins in app/concerns (cf Jamis Buck), so each spec/ concerns/*_spec.rb really just contains a shared behaviour which is used in the appropriate specs in spec/models (i.e. of those models whose app/models counterpart mixes in that concern). Each such model says require File.dirname(__FILE__) + '/../concerns/ animal_spec' and describe Dog do before(:each) do @animal = Dog.new end; it_should_behave_like 'all animals' end, which works fine. Some of the concern specs need helpers from modules in spec_helper, but any attempt to include those modules within the shared behaviour blows up as above, so at the moment I'm including the helper modules in the model specs themselves. That also works fine, but leaves an unpleasant taste since the model spec itself doesn't (syntactically) refer to any of the helper methods, so I'd really rather leave the #including to the shared behaviour if possible. Any thoughts? Cheers, -Tom From evan at tiggerpalace.com Fri Sep 14 17:19:23 2007 From: evan at tiggerpalace.com (Evan David Light) Date: Fri, 14 Sep 2007 17:19:23 -0400 Subject: [rspec-users] Posted this in "dev" last night but I'm not sure that anyone reads it Message-ID: I've been using RSpec in anger for perhaps a total of a few days and just started playing with Story Runner. Love it. I also started working on a patch, which ought to be simple, to allow for Scenarios without supplied blocks to be treated as pending -- much like "it" in Spec::DSL::ExampleAPI. That said, I noticed something that seemed odd and chatted with Rein Henrichs a little about it on #rspec. ScenarioRunner#run treats "pending" scenarios as an error case. We both believed this to be a little odd as we both thought that pending would just be a branch and not an error. That said, I thought that there may be a reasonable explanation. Evan Light IMs (all): sleight42 Twitter: elight http://evan.tiggerpalace.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070914/3aa25dc4/attachment.html From port001 at gmail.com Fri Sep 14 17:54:10 2007 From: port001 at gmail.com (Ian Leitch) Date: Fri, 14 Sep 2007 22:54:10 +0100 Subject: [rspec-users] ProfileFormatter (Top 10 slowest examples) Message-ID: Hey list, The time it takes for my specs to run is starting to get a little long (~45 seconds), and annoying enough for me to do something about it. I've written a simple formatter that prints out the top 10 slowest examples in an attempt to identify any low hanging fruit amongst a spec suite. http://rubyforge.org/tracker/index.php?func=detail&aid=13943&group_id=797&atid=3151 Just for fun... here's my Top 10: (I haven't tried speeding any of these up yet, by the way.) 0.4318470 /users/new.html.erb should render new form 0.4248100 /users/edit.html.erb should not dipslay the brand admin checkbox if the current user is also the target user and a brand admin 0.4230980 /users/edit.html.erb should have a new user heading 0.4189370 /users/edit.html.erb should not display the brand admin checkbox if the current user is not a brand admin 0.2828910 <> Sorry, this one gave away some business details -- we're a start-up still in stealth mode. 0.2748610 /users/edit.html.erb should display the brand admin checkbox if the current user is a brand admin 0.2747120 /users/edit.html.erb should not dipslay the brand admin checkbox if the current user is also the target user but not a brand admin 0.2699700 /users/edit.html.erb should render edit form 0.2692280 /users/new.html.erb should have a new user heading 0.2124850 GiftsController handling GET /active.js should construct the Gift::GiftActiveBrandQuery Cheers Ian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070914/de1f14fe/attachment.html From rspec.user at gmail.com Fri Sep 14 17:51:19 2007 From: rspec.user at gmail.com (sinclair bain) Date: Fri, 14 Sep 2007 17:51:19 -0400 Subject: [rspec-users] controller.expect_render has me beat! Message-ID: <2ca660dd0709141451xf23d8b0s2635ffa7d8469407@mail.gmail.com> Hi, A controller has a method with the following def update ... if @config.update_attributes( params[:new_config] ) redirect_to :action => :index else * render :action => :edit, :id => params[:id] # this line here* end ... end The example has the following it 'should render the "edit" config url on an unsuccessful save' do @config.should_receive(:update_attributes).once.and_return(false) c*ontroller.expect_render( :action => :edit, :id => 1 ).once # my prob* do_update end This fails with Mock 'expect_render_mock_proxy' expected :render with ({:action=>:edit, :id=>1}) once, but received it 0 times I have tried controller.expect_render( :action => :edit ).once Am I using #expect_render correctly? Thanks for all and any helpv Cheers! sinclair -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070914/acd6d8e6/attachment.html From pergesu at gmail.com Fri Sep 14 19:10:15 2007 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 14 Sep 2007 16:10:15 -0700 Subject: [rspec-users] Posted this in "dev" last night but I'm not sure that anyone reads it In-Reply-To: References: Message-ID: <810a540e0709141610p37e87824r6cbd14917d0efb06@mail.gmail.com> On 9/14/07, Evan David Light wrote: > > I've been using RSpec in anger for perhaps a total of a few days and just > started playing with Story Runner. Love it. > > I also started working on a patch, which ought to be simple, to allow for > Scenarios without supplied blocks to be treated as pending -- much like "it" > in Spec::DSL::ExampleAPI. > > That said, I noticed something that seemed odd and chatted with Rein > Henrichs a little about it on #rspec. ScenarioRunner#run treats "pending" > scenarios as an error case. We both believed this to be a little odd as we > both thought that pending would just be a branch and not an error. That > said, I thought that there may be a reasonable explanation. > > Evan Light > IMs (all): sleight42 > Twitter: elight > http://evan.tiggerpalace.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Hrm...I added And "this should be pending" do pending "need something else" end to the end of one of my stories and got: And this should be pending P 4 scenarios: 3 succeeded, 0 failed, 1 pending I agree that it would be nice if story runner treats an empty Given/When/Then as pending. But what do you mean it treats pending as an error case? Pat From hughes.james at gmail.com Fri Sep 14 19:44:35 2007 From: hughes.james at gmail.com (James Hughes) Date: Fri, 14 Sep 2007 16:44:35 -0700 Subject: [rspec-users] Mocks in StoryRunner Message-ID: <765a2c230709141644w3b07bf73yc838df01f13b82ba@mail.gmail.com> Hi, I'm trying to get up and running with StoryRunner. I have a story that looks something like the following, but the call to mock_model produces the exception listed below. Am I just misunderstanding the concept? Are mocks not meant to be used in stories like this? Or is this a bug? Changing @user to be an actual AR object makes things run without error. ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'spec' require 'spec/rails' require 'spec/rails/story_adapter' Story 'Something happens', %{ As a user I want to do something So that something will happen. }, :type => RailsStory do Scenario 'User doing something for first time' do Given 'a user' do @user = mock_model(User) end When 'the user makes a request' do end Then 'something should happen' do end end end Here's the stack trace: 1 scenarios: 0 succeeded, 1 failed, 0 pending FAILURES: 1) Something happens (User doing something for first time) FAILED NoMethodError: You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.each /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/integration.rb:519:in `open_session' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/integration.rb:490:in `reset!' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/integration.rb:546:in `method_missing' /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/matchers.rb:146:in `method_missing' stories/use_case_story.rb:38:in `a logged-in user' /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/simple_step.rb:13:in `__send__' /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/simple_step.rb:13:in `perform' /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/world.rb:58:in `store_and_call' /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/world.rb:68:in `Given' stories/use_case_story.rb:36 /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb:13:in `instance_eval' /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb:13:in `run' /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:48:in `run_stories' /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:43:in `each' /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:43:in `run_stories' /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:39:in `each' /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:39:in `run_stories' /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner.rb:36:in `register_exit_hook' stories/use_case_story.rb:29 From pergesu at gmail.com Fri Sep 14 20:46:42 2007 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 14 Sep 2007 17:46:42 -0700 Subject: [rspec-users] Mocks in StoryRunner In-Reply-To: <765a2c230709141644w3b07bf73yc838df01f13b82ba@mail.gmail.com> References: <765a2c230709141644w3b07bf73yc838df01f13b82ba@mail.gmail.com> Message-ID: <810a540e0709141746w7c3be345na67a22a832be31a2@mail.gmail.com> On 9/14/07, James Hughes wrote: > Hi, > > I'm trying to get up and running with StoryRunner. I have a story that > looks something like the following, but the call to mock_model > produces the exception listed below. Am I just misunderstanding the > concept? Are mocks not meant to be used in stories like this? Or is > this a bug? Changing @user to be an actual AR object makes things run > without error. > > ENV["RAILS_ENV"] = "test" > require File.expand_path(File.dirname(__FILE__) + "/../config/environment") > require 'spec' > require 'spec/rails' > require 'spec/rails/story_adapter' > > Story 'Something happens', %{ > As a user > I want to do something > So that something will happen. > }, :type => RailsStory do > > Scenario 'User doing something for first time' do > Given 'a user' do > @user = mock_model(User) > end > When 'the user makes a request' do > end > Then 'something should happen' do > end > end > end > > > Here's the stack trace: > > 1 scenarios: 0 succeeded, 1 failed, 0 pending > > FAILURES: > 1) Something happens (User doing something for first time) FAILED > NoMethodError: You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.each > /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/integration.rb:519:in > `open_session' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/integration.rb:490:in > `reset!' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/integration.rb:546:in > `method_missing' > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/matchers.rb:146:in > `method_missing' > stories/use_case_story.rb:38:in `a logged-in user' > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/simple_step.rb:13:in > `__send__' > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/simple_step.rb:13:in > `perform' > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/world.rb:58:in > `store_and_call' > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/world.rb:68:in > `Given' > stories/use_case_story.rb:36 > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb:13:in > `instance_eval' > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb:13:in > `run' > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:48:in > `run_stories' > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:43:in > `each' > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:43:in > `run_stories' > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:39:in > `each' > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:39:in > `run_stories' > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner.rb:36:in > `register_exit_hook' > stories/use_case_story.rb:29 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > No, you shouldn't be calling mock_model in Story Runner. The whole point of stories is to exercise the full functionality of your app. Pat From hughes.james at gmail.com Fri Sep 14 21:09:18 2007 From: hughes.james at gmail.com (James Hughes) Date: Fri, 14 Sep 2007 18:09:18 -0700 Subject: [rspec-users] Mocks in StoryRunner In-Reply-To: <810a540e0709141746w7c3be345na67a22a832be31a2@mail.gmail.com> References: <765a2c230709141644w3b07bf73yc838df01f13b82ba@mail.gmail.com> <810a540e0709141746w7c3be345na67a22a832be31a2@mail.gmail.com> Message-ID: <765a2c230709141809w4de4bd75mc8be4e641f85bc01@mail.gmail.com> On 9/14/07, Pat Maddox wrote: > On 9/14/07, James Hughes wrote: > > Hi, > > > > I'm trying to get up and running with StoryRunner. I have a story that > > looks something like the following, but the call to mock_model > > produces the exception listed below. Am I just misunderstanding the > > concept? Are mocks not meant to be used in stories like this? Or is > > this a bug? Changing @user to be an actual AR object makes things run > > without error. > > > > ENV["RAILS_ENV"] = "test" > > require File.expand_path(File.dirname(__FILE__) + "/../config/environment") > > require 'spec' > > require 'spec/rails' > > require 'spec/rails/story_adapter' > > > > Story 'Something happens', %{ > > As a user > > I want to do something > > So that something will happen. > > }, :type => RailsStory do > > > > Scenario 'User doing something for first time' do > > Given 'a user' do > > @user = mock_model(User) > > end > > When 'the user makes a request' do > > end > > Then 'something should happen' do > > end > > end > > end > > > > > > Here's the stack trace: > > > > 1 scenarios: 0 succeeded, 1 failed, 0 pending > > > > FAILURES: > > 1) Something happens (User doing something for first time) FAILED > > NoMethodError: You have a nil object when you didn't expect it! > > You might have expected an instance of Array. > > The error occurred while evaluating nil.each > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/integration.rb:519:in > > `open_session' > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/integration.rb:490:in > > `reset!' > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/integration.rb:546:in > > `method_missing' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/matchers.rb:146:in > > `method_missing' > > stories/use_case_story.rb:38:in `a logged-in user' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/simple_step.rb:13:in > > `__send__' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/simple_step.rb:13:in > > `perform' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/world.rb:58:in > > `store_and_call' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/world.rb:68:in > > `Given' > > stories/use_case_story.rb:36 > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb:13:in > > `instance_eval' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb:13:in > > `run' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:48:in > > `run_stories' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:43:in > > `each' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:43:in > > `run_stories' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:39:in > > `each' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:39:in > > `run_stories' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner.rb:36:in > > `register_exit_hook' > > stories/use_case_story.rb:29 > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > No, you shouldn't be calling mock_model in Story Runner. The whole > point of stories is to exercise the full functionality of your app. > > Pat Right, get it now, thanks. jh From evan at tiggerpalace.com Fri Sep 14 21:21:37 2007 From: evan at tiggerpalace.com (Evan David Light) Date: Fri, 14 Sep 2007 21:21:37 -0400 Subject: [rspec-users] Posted this in "dev" last night but I'm not sure that anyone reads it In-Reply-To: <810a540e0709141610p37e87824r6cbd14917d0efb06@mail.gmail.com> References: <810a540e0709141610p37e87824r6cbd14917d0efb06@mail.gmail.com> Message-ID: <41EE185C-C605-4C94-BAFD-A90DE0304507@tiggerpalace.com> On Sep 14, 2007, at 7:10 PM, Pat Maddox wrote: > I agree that it would be nice if story runner treats an empty > Given/When/Then as pending. But what do you mean it treats pending as > an error case? The actual implementation of how a Scenario is defined as pending. The implementation raises a particular type of Error (name eludes me as I'm not steeped in code at the moment, sorry) which the ScenarioRunner rescues and, based on that, then processes the Scenario as pending. Typically, this would simply be a conditional branch in the code and, frankly, seems like an abuse of error handling. Incidentally, I submitted the patch last night to allow Scenarios without blocks to default to pending. Hopefully, Dan (North) likes it. It makes sense that the expectation metaphors through RSpec (and now Story Runner) would behave consistently. This just makes Scenario behave like "it". I have yet to look closely at the implementations of Given/Then/When/ And (forgot about that one, thanks!). Maybe if I get some time this weekend. Unfortunately, I'm spending the rest of tonight and most of tomorrow doing some work for the office... The deeper I get into it, the more that I love this tool.... Evan From rspec.user at gmail.com Fri Sep 14 22:35:48 2007 From: rspec.user at gmail.com (sinclair bain) Date: Fri, 14 Sep 2007 22:35:48 -0400 Subject: [rspec-users] controller.expect_render has me beat! Message-ID: <2ca660dd0709141935x1966a7c3j389f56a073ef07c3@mail.gmail.com> Hi, A controller has a method with the following def update ... if @config.update_attributes ( params[:new_config] ) redirect_to :action => :index else * render :action => :edit, :id => params[:id] # this line here* end ... end The example has the following it 'should render the "edit" config url on an unsuccessful save' do @config.should_receive(:update_attributes).once.and_return(false) c*ontroller.expect_render( :action => :edit, :id => 1 ).once # my prob* do_update end This fails with ... Mock 'expect_render_mock_proxy' expected :render with ({:action=>:edit, :id=>1}) once, but received it 0 times I have tried controller.expect_render( :action => :edit ).once Am I using #expect_render correctly? Thanks for all and any help! Cheers! sinclair -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070914/ab198e3f/attachment.html From evan at tiggerpalace.com Fri Sep 14 23:06:25 2007 From: evan at tiggerpalace.com (Evan David Light) Date: Fri, 14 Sep 2007 23:06:25 -0400 Subject: [rspec-users] Posted this in "dev" last night but I'm not sure that anyone reads it In-Reply-To: <810a540e0709141610p37e87824r6cbd14917d0efb06@mail.gmail.com> References: <810a540e0709141610p37e87824r6cbd14917d0efb06@mail.gmail.com> Message-ID: On Sep 14, 2007, at 7:10 PM, Pat Maddox wrote: > I agree that it would be nice if story runner treats an empty > Given/When/Then as pending. But what do you mean it treats pending as > an error case? > Resending. Believe that my re-reponse, sent a couple of hours ago, was eaten. ;-) The actual implementation of how a Scenario is defined as pending. The implementation raises a particular type of Error (name eludes me as I'm not steeped in code at the moment, sorry) which the ScenarioRunner rescues and, based on that, then processes the Scenario as pending. Typically, this would simply be a conditional branch in the code and, frankly, seems like an abuse of error handling. Incidentally, I submitted the patch last night to allow Scenarios without blocks to default to pending. Hopefully, Dan (North) likes it. It makes sense that the expectation metaphors through RSpec (and now Story Runner) would behave consistently. This just makes Scenario behave like "it". I have yet to look closely at the implementations of Given/Then/When/ And (forgot about that one, thanks!). Maybe if I get some time this weekend. Unfortunately, I'm spending the rest of tonight and most of tomorrow doing some work for the office... The deeper I get into it, the more that I love this tool.... Evan From cwdinfo at gmail.com Sat Sep 15 01:44:58 2007 From: cwdinfo at gmail.com (s.ross) Date: Fri, 14 Sep 2007 22:44:58 -0700 Subject: [rspec-users] controller.expect_render has me beat! In-Reply-To: <2ca660dd0709141935x1966a7c3j389f56a073ef07c3@mail.gmail.com> References: <2ca660dd0709141935x1966a7c3j389f56a073ef07c3@mail.gmail.com> Message-ID: Look at your test.log and you can see exactly what was rendered. That should explain why the example is failing. This works best if you can silence the logs for all examples other than the one you are testing. On Sep 14, 2007, at 7:35 PM, sinclair bain wrote: > Hi, > > > A controller has a method with the following > > > def update > ... > if @config.update_attributes ( params[:new_config] ) > redirect_to :action => :index > else > render :action => :edit, :id => params[:id] # this line > here > end > ... > end > > > The example has the following > > > it 'should render the "edit" config url on an unsuccessful save' do > @config.should_receive(:update_attributes).once.and_return(false) > controller.expect_render ( :action => :edit, :id => > 1 ).once # my prob > do_update > end > > > This fails with > ... > Mock 'expect_render_mock_proxy' expected :render with > ({:action=>:edit, :id=>1}) once, but received it 0 times > > > I have tried > controller.expect_render( :action => :edit ).once > > > Am I using #expect_render correctly? > > > Thanks for all and any help! > > > Cheers! > sinclair > _______________________________________________ > 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/20070914/8999f848/attachment-0001.html From luislavena at gmail.com Sat Sep 15 01:55:11 2007 From: luislavena at gmail.com (Luis Lavena) Date: Sat, 15 Sep 2007 02:55:11 -0300 Subject: [rspec-users] controller.expect_render has me beat! In-Reply-To: References: <2ca660dd0709141935x1966a7c3j389f56a073ef07c3@mail.gmail.com> Message-ID: <71166b3b0709142255kb5061b7n5b1969daa48f30d5@mail.gmail.com> On 9/15/07, s.ross wrote: > Look at your test.log and you can see exactly what was rendered. That should > explain why the example is failing. This works best if you can silence the > logs for all examples other than the one you are testing. > Better if you run just that example: spec spec\controllers\my_controller_spec.rb -e "My failing example name" -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From davidj503 at gmail.com Sat Sep 15 09:05:20 2007 From: davidj503 at gmail.com (David James) Date: Sat, 15 Sep 2007 09:05:20 -0400 Subject: [rspec-users] How to write a plugin that uses rspec internally? Message-ID: <59b5d4330709150605o4587f66cof56068ecd7abe457@mail.gmail.com> My team is working on a plugin and we want to use RSpec internally for the plugin's tests. (a) What are some different ways to go about this? Should we rely on the RSpec gem? Should we expect that the "host" Rails application has installed the RSpec plugins? Are there other options? (b) Which approach from (a) would you recommend? (c) Would you recommend any particular plugins to study along these lines? Thanks, David -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070915/ed2970b6/attachment.html From pergesu at gmail.com Sat Sep 15 12:37:37 2007 From: pergesu at gmail.com (Pat Maddox) Date: Sat, 15 Sep 2007 09:37:37 -0700 Subject: [rspec-users] How to write a plugin that uses rspec internally? In-Reply-To: <59b5d4330709150605o4587f66cof56068ecd7abe457@mail.gmail.com> References: <59b5d4330709150605o4587f66cof56068ecd7abe457@mail.gmail.com> Message-ID: <810a540e0709150937q2252354emfa15b250183a1a25@mail.gmail.com> On 9/15/07, David James wrote: > My team is working on a plugin and we want to use RSpec internally for the > plugin's tests. > > (a) What are some different ways to go about this? Should we rely on the > RSpec gem? Should we expect that the "host" Rails application has installed > the RSpec plugins? Are there other options? > > (b) Which approach from (a) would you recommend? > > (c) Would you recommend any particular plugins to study along these lines? > > Thanks, > David > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Hey David, I wrote a plugin generator that uses RSpec instead of Test::Unit. Another little improvement is that it'll create and hook up a schema.rb file so that you can use a separate db for your specs. Check it out at http://evang.eli.st/blog/2007/4/4/rspec_plugin-generator Users will need rspec if they want to run the specs. If they just want the plugin though and don't care about running the specs, there's no dependency on rspec. Pat From davidj503 at gmail.com Sat Sep 15 22:23:36 2007 From: davidj503 at gmail.com (David James) Date: Sat, 15 Sep 2007 22:23:36 -0400 Subject: [rspec-users] How to write a plugin that uses rspec internally? In-Reply-To: <810a540e0709150937q2252354emfa15b250183a1a25@mail.gmail.com> References: <59b5d4330709150605o4587f66cof56068ecd7abe457@mail.gmail.com> <810a540e0709150937q2252354emfa15b250183a1a25@mail.gmail.com> Message-ID: <59b5d4330709151923k3dce47b6x5259412af2a85d78@mail.gmail.com> Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070915/2650accc/attachment.html From davidj503 at gmail.com Sun Sep 16 01:12:43 2007 From: davidj503 at gmail.com (David James) Date: Sun, 16 Sep 2007 01:12:43 -0400 Subject: [rspec-users] #add method? Message-ID: <59b5d4330709152212p4051733cu16a2618962c89145@mail.gmail.com> I've seen reference to an 'add' method, as in Model.add. When and why would I want to use it? Is it related to Model.collection.build? Thanks, David -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070916/b9e5c97a/attachment.html From davidj503 at gmail.com Sun Sep 16 01:20:21 2007 From: davidj503 at gmail.com (David James) Date: Sun, 16 Sep 2007 01:20:21 -0400 Subject: [rspec-users] How far to go with ActiveRecord unit tests without hitting the database? Message-ID: <59b5d4330709152220t2283ed90wc7354bacbe921a76@mail.gmail.com> I'm currently try to push my limits a little bit with some of my unit testing -- trying to avoid saving ActiveRecord objects to the database and take advantage of mock/stub objects. How far should I expect to get in this direction? From what I can tell, ActiveRecord seems to fight me when it comes to associations. In other words, many associations seem to require database queries. Have others had success in mocking/stubbing associations? In particular, have you had luck with has_many :through? -David -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070916/bf84a106/attachment.html From pergesu at gmail.com Sun Sep 16 01:43:05 2007 From: pergesu at gmail.com (Pat Maddox) Date: Sat, 15 Sep 2007 22:43:05 -0700 Subject: [rspec-users] How far to go with ActiveRecord unit tests without hitting the database? In-Reply-To: <59b5d4330709152220t2283ed90wc7354bacbe921a76@mail.gmail.com> References: <59b5d4330709152220t2283ed90wc7354bacbe921a76@mail.gmail.com> Message-ID: <810a540e0709152243w5c2ef523n45a66e7a8c03a4a5@mail.gmail.com> On 9/15/07, David James wrote: > I'm currently try to push my limits a little bit with some of my unit > testing -- trying to avoid saving ActiveRecord objects to the database and > take advantage of mock/stub objects. > > How far should I expect to get in this direction? From what I can tell, > ActiveRecord seems to fight me when it comes to associations. In other > words, many associations seem to require database queries. > > Have others had success in mocking/stubbing associations? In particular, > have you had luck with has_many :through? > > -David > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > You can't assign mock objects to associations. You have to do stuff like @employee = Employee.new :name => "Pat" @mock_company = mock_model(Company, :name => "BigCo") @employee.stub!(:company).and_return @mock_company As far as has_many through, again you just mock out the association proxy. So if you've got class User < ActiveRecord::Base has_many :rentals has_many :videos, :through => :rentals end and you want to do some testing with videos, you'd have @videos_proxy = mock("videos proxy") @user.stub!(:videos).and_return @videos_proxy You don't deal with the fact that rentals plays in anywhere, at least if you're trying to isolate from the database. Pat From dchelimsky at gmail.com Sun Sep 16 03:23:16 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 16 Sep 2007 09:23:16 +0200 Subject: [rspec-users] #add method? In-Reply-To: <59b5d4330709152212p4051733cu16a2618962c89145@mail.gmail.com> References: <59b5d4330709152212p4051733cu16a2618962c89145@mail.gmail.com> Message-ID: <57c63afe0709160023x11ebfff0x4a452c1a932af979@mail.gmail.com> Can you be more specific? Where have you seen such references? What did they say? Is this even an rspec question? If it's about Rails models, try the rails list. But if you do, be more specific :) On 9/16/07, David James wrote: > I've seen reference to an 'add' method, as in Model.add. When and why would > I want to use it? Is it related to Model.collection.build? > > Thanks, > David > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tom at experthuman.com Sun Sep 16 03:59:24 2007 From: tom at experthuman.com (Tom Stuart) Date: Sun, 16 Sep 2007 08:59:24 +0100 Subject: [rspec-users] #add method? In-Reply-To: <59b5d4330709152212p4051733cu16a2618962c89145@mail.gmail.com> References: <59b5d4330709152212p4051733cu16a2618962c89145@mail.gmail.com> Message-ID: <6C35405A-7832-4001-A40E-A9EF467CE2E7@experthuman.com> On 16 Sep 2007, at 06:12, David James wrote: > I've seen reference to an 'add' method, as in Model.add. When and > why would I want to use it? Is it related to Model.collection.build? Perhaps you're thinking of http://api.rubyonrails.org/classes/ ActiveRecord/Errors.html#M000960. You can use it to explicitly add a validation error to an attribute of an ActiveRecord instance. Cheers, -Tom From tom at experthuman.com Sun Sep 16 04:05:31 2007 From: tom at experthuman.com (Tom Stuart) Date: Sun, 16 Sep 2007 09:05:31 +0100 Subject: [rspec-users] How far to go with ActiveRecord unit tests without hitting the database? In-Reply-To: <810a540e0709152243w5c2ef523n45a66e7a8c03a4a5@mail.gmail.com> References: <59b5d4330709152220t2283ed90wc7354bacbe921a76@mail.gmail.com> <810a540e0709152243w5c2ef523n45a66e7a8c03a4a5@mail.gmail.com> Message-ID: On 16 Sep 2007, at 06:43, Pat Maddox wrote: > You can't assign mock objects to associations. Actually I haven't had any trouble with e.g. @company = Company.new :name => 'BigCo' @mock_employee = mock_model(Employee, :name => 'Pat', :[]= => true, :save => true) @company.employees << @mock_employee (To be followed by, for example, @mock_employee.should_receive (:destroy); @company.destroy.) Is that unacceptable? Cheers, -Tom From chrisdpratt at gmail.com Sun Sep 16 05:19:39 2007 From: chrisdpratt at gmail.com (Christopher D. Pratt) Date: Sun, 16 Sep 2007 04:19:39 -0500 Subject: [rspec-users] "rake spec:doc" returns NO NAME (due to --dry-run) for each specify block Message-ID: <79a30c430709160219t4716b81s7b05c1e77faaccb5@mail.gmail.com> I went ahead and moved to the trunk versions of RSpec and Spec:Rails because I wanted to try out the new Story Runner feature. However, when I tried to do "rake spec:doc", I got the following: AccountController - NO NAME (Because of --dry-run) AccountHelper - NO NAME (Because of --dry-run) User (in general) - NO NAME (Because of --dry-run) - NO NAME (Because of --dry-run) - NO NAME (Because of --dry-run) - NO NAME (Because of --dry-run) - NO NAME (Because of --dry-run) - NO NAME (Because of --dry-run) I emptied everything out of my spec.opts file just to make sure it wasn't some setting there causing problems, but that still had no effect. I haven't submitted this as a bug yet because I'm still holding out the possibility that I'm simply doing something wrong. Thanks, Chris Pratt -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070916/dee445a0/attachment.html From dchelimsky at gmail.com Sun Sep 16 06:48:58 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 16 Sep 2007 12:48:58 +0200 Subject: [rspec-users] "rake spec:doc" returns NO NAME (due to --dry-run) for each specify block In-Reply-To: <79a30c430709160219t4716b81s7b05c1e77faaccb5@mail.gmail.com> References: <79a30c430709160219t4716b81s7b05c1e77faaccb5@mail.gmail.com> Message-ID: <57c63afe0709160348q3aaada87k4f988fc3422c9118@mail.gmail.com> When you use spec:doc, it does a dry-run, in which case the blocks are never executed, in which case you get this message for every block relying on auto-generated names: describe 5 do it { 5.should == 5} end If you mean to use the specdoc format (i.e. it really runs everything and you get the output from all the strings passed to describe and it), do this: rake spec --format specdoc or rake spec -fs Cheers, David On 9/16/07, Christopher D. Pratt wrote: > I went ahead and moved to the trunk versions of RSpec and Spec:Rails because > I wanted to try out the new Story Runner feature. However, when I tried to > do "rake spec:doc", I got the following: > > AccountController > - NO NAME (Because of --dry-run) > > AccountHelper > - NO NAME (Because of --dry-run) > > User (in general) > - NO NAME (Because of --dry-run) > - NO NAME (Because of --dry-run) > - NO NAME (Because of --dry-run) > - NO NAME (Because of --dry-run) > - NO NAME (Because of --dry-run) > - NO NAME (Because of --dry-run) > > I emptied everything out of my spec.opts file just to make sure it wasn't > some setting there causing problems, but that still had no effect. I haven't > submitted this as a bug yet because I'm still holding out the possibility > that I'm simply doing something wrong. > > Thanks, > > Chris Pratt > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Sun Sep 16 06:52:04 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 16 Sep 2007 12:52:04 +0200 Subject: [rspec-users] "rake spec:doc" returns NO NAME (due to --dry-run) for each specify block In-Reply-To: <79a30c430709160219t4716b81s7b05c1e77faaccb5@mail.gmail.com> References: <79a30c430709160219t4716b81s7b05c1e77faaccb5@mail.gmail.com> Message-ID: <8d961d900709160352u6b859901sfd925dcc3e352cea@mail.gmail.com> This happens if you have it blocks with no name. RSpec tries to generate names based on the code inside, but with dry run it isn't executed, so it can't. But maybe you don't have empty it blocks? I'm just guessing here... Aslak On 9/16/07, Christopher D. Pratt wrote: > I went ahead and moved to the trunk versions of RSpec and Spec:Rails because > I wanted to try out the new Story Runner feature. However, when I tried to > do "rake spec:doc", I got the following: > > AccountController > - NO NAME (Because of --dry-run) > > AccountHelper > - NO NAME (Because of --dry-run) > > User (in general) > - NO NAME (Because of --dry-run) > - NO NAME (Because of --dry-run) > - NO NAME (Because of --dry-run) > - NO NAME (Because of --dry-run) > - NO NAME (Because of --dry-run) > - NO NAME (Because of --dry-run) > > I emptied everything out of my spec.opts file just to make sure it wasn't > some setting there causing problems, but that still had no effect. I haven't > submitted this as a bug yet because I'm still holding out the possibility > that I'm simply doing something wrong. > > Thanks, > > Chris Pratt > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists-rspec at shopwatch.org Sun Sep 16 09:38:50 2007 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Sun, 16 Sep 2007 09:38:50 -0400 Subject: [rspec-users] I lost the RSpec fight Message-ID: <46ED31EA.9000203@shopwatch.org> I've been working on a Rails project with one other developer; he was using Test::Unit, and I was using RSpec. That works OK for a while, but obviously it starts causing pain when you have to check in two places to see if a piece of code is properly tested/spec'd, you can't use TextMate shortcuts to switch back and forth between code and test, you have to duplicate shared behaviors/test helpers, etc. So when we brought in a consulting team to add some manpower, we realized we had to switch to a single framework. This is a team that's fairly experienced with Rails and active in the Rails community, but was quite opposed to choosing RSpec. Here are the arguments I heard against unifying on RSpec: * Test::Unit is ubiquitous. Everyone knows it. This is hard to counter; it comes with Rails and is the default. Same reason many people use Prototype even though JQuery/dojo might suit them better. * For that reason, it's a lot easier to find examples of "how to do something" in Test::Unit than in RSpec. That's true; several times I've had a bit of code that didn't fall nicely into the MVC hierarchy, and I wasn't sure how to build up the right context to test it in. If I were using Test::Unit, I could just copy the equivalent tests from Rails core, but using RSpec I had to roll my own. * RSpec is BDD (hand-waving new different troublesome); we do TDD. We've covered that ground on this list many times; BDD is an extension and interpretation of TDD, not some newfangled crackpot theory. But people don't know that. * The team had in fact investigated RSpec a few months ago, and decided they didn't like it. Some of what they didn't like has been fixed in 1.0, but of course people aren't going to come running to re-examine each release, so the bitter taste remained: * #context was defined on Kernel. Not sure if that's still true for #describe. * Not compatible with tools that expect Test::Unit output. This would(could) be fixed with the runner integration that's been discussed. * Wasn't compatible with mocha/FlexMock. Fixed now. But again, it came back to ubiquity, which is a pretty hard problem to overcome. Seems to me that the best way to get RSpec adopted is to find some more visible, prolific plugin programmers and evangelize them to start using RSpec, so it's not some "neat fringe thing", but a solid, respectable alternative to Test::Unit. Jay Levitt From kevwil at gmail.com Sun Sep 16 10:18:52 2007 From: kevwil at gmail.com (Kevin Williams) Date: Sun, 16 Sep 2007 08:18:52 -0600 Subject: [rspec-users] I lost the RSpec fight In-Reply-To: <46ED31EA.9000203@shopwatch.org> References: <46ED31EA.9000203@shopwatch.org> Message-ID: <683a886f0709160718p5dad961i32fd5cd0e81e031@mail.gmail.com> By all means, they should not ever try anything new. The people of Earth should not have ever adopted the use of the electric light bulb or the radio or the automobile or the airplane or the microwave or the telephone or ... the Internet. No, don't adopt anything new, just stick to the old ways of doing things. It's impossible for anyone to improve on anything, right? Bah! Humbug! Obviously, I wouldn't win that argument either, but that's because I'm dumbfounded by those who fear change. Change happens whether you fear it or not, so why stress everyone out? BDD is a better, clearer expression of making sure the code meets the client's needs, why choose an old, clunky interface? They choose the expressiveness of Ruby but fear the expressiveness of RSpec? That doesn't make sense to me. I suppose they insist on using MySQL and erb templates too, right? Sheesh! (Fans of MySQL and erb, fret not - I'm just trying to make the point that breaking from tradition is not to be feared or laughed at - it's OK, really, lean back and let RSpec catch you. :) Ubiquitous is not a permanent tag. Rotary phones used to be ubiquitous. Internet Exploder used to be ubiquitous. Horse-and-buggy transportation used to be ubiquitous. Rails is now a large framework with a huge following. They can't switch everything around overnight every time something better comes along. Luckily it is flexible enough to allow us to use 'something better' when it does come along. New templates, new test frameworks, new javascript frameworks, new ideas on caching and concurrency, new ORM layers - just because Rails defaults to one thing doesn't mean that's the only way to do something and certainly doesn't mean that's the best way to do something. Sorry for rambling on. I make a crappy argument here, but it's hard to express that 'slaps my forehead and says "are you kidding me?!?"' feeling. I hope I won't be flamed for being pro- new stuff and pro-rspec in the rspec-users list. :) On 9/16/07, Jay Levitt wrote: > I've been working on a Rails project with one other developer; he was > using Test::Unit, and I was using RSpec. That works OK for a while, but > obviously it starts causing pain when you have to check in two places to > see if a piece of code is properly tested/spec'd, you can't use TextMate > shortcuts to switch back and forth between code and test, you have to > duplicate shared behaviors/test helpers, etc. > > So when we brought in a consulting team to add some manpower, we > realized we had to switch to a single framework. This is a team that's > fairly experienced with Rails and active in the Rails community, but was > quite opposed to choosing RSpec. > > Here are the arguments I heard against unifying on RSpec: > > * Test::Unit is ubiquitous. Everyone knows it. This is hard to > counter; it comes with Rails and is the default. Same reason many > people use Prototype even though JQuery/dojo might suit them better. > > * For that reason, it's a lot easier to find examples of "how to do > something" in Test::Unit than in RSpec. That's true; several times I've > had a bit of code that didn't fall nicely into the MVC hierarchy, and I > wasn't sure how to build up the right context to test it in. If I were > using Test::Unit, I could just copy the equivalent tests from Rails > core, but using RSpec I had to roll my own. > > * RSpec is BDD (hand-waving new different troublesome); we do TDD. > We've covered that ground on this list many times; BDD is an extension > and interpretation of TDD, not some newfangled crackpot theory. But > people don't know that. > > * The team had in fact investigated RSpec a few months ago, and decided > they didn't like it. Some of what they didn't like has been fixed in > 1.0, but of course people aren't going to come running to re-examine > each release, so the bitter taste remained: > > * #context was defined on Kernel. Not sure if that's still true for > #describe. > > * Not compatible with tools that expect Test::Unit output. This > would(could) be fixed with the runner integration that's been discussed. > > * Wasn't compatible with mocha/FlexMock. Fixed now. > > But again, it came back to ubiquity, which is a pretty hard problem to > overcome. > > Seems to me that the best way to get RSpec adopted is to find some more > visible, prolific plugin programmers and evangelize them to start using > RSpec, so it's not some "neat fringe thing", but a solid, respectable > alternative to Test::Unit. > > Jay Levitt > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Cheers, Kevin Williams http://kevwil.com/ http://www.almostserio.us/ http://kevwil.jaiku.com/ From win at wincent.com Sun Sep 16 10:36:04 2007 From: win at wincent.com (Wincent Colaiuta) Date: Sun, 16 Sep 2007 16:36:04 +0200 Subject: [rspec-users] I lost the RSpec fight In-Reply-To: <46ED31EA.9000203@shopwatch.org> References: <46ED31EA.9000203@shopwatch.org> Message-ID: <0A4D9D7C-1469-40A4-A43D-1C39FC137AE3@wincent.com> El 16/9/2007, a las 15:38, Jay Levitt escribi?: > * Test::Unit is ubiquitous. Everyone knows it. This is hard to > counter; it comes with Rails and is the default. Sorry to hear that you lost the fight. And that "better" doesn't always win. For me "better" beats "ubiquitous" any time. Ah well, in time RSpec will gain a bigger and bigger share. It's inevitable. > * RSpec is BDD (hand-waving new different troublesome); we do TDD. > We've covered that ground on this list many times; BDD is an extension > and interpretation of TDD, not some newfangled crackpot theory. Sigh. For me BDD *is* TDD, just with a vocabulary and a set of tools that subtly steer you towards doing it well rather than half-baked. Wincent From davidj503 at gmail.com Sun Sep 16 10:39:00 2007 From: davidj503 at gmail.com (David James) Date: Sun, 16 Sep 2007 10:39:00 -0400 Subject: [rspec-users] #add method? In-Reply-To: <57c63afe0709160023x11ebfff0x4a452c1a932af979@mail.gmail.com> References: <59b5d4330709152212p4051733cu16a2618962c89145@mail.gmail.com> <57c63afe0709160023x11ebfff0x4a452c1a932af979@mail.gmail.com> Message-ID: <59b5d4330709160739j3e2dfec3odd066f4ce88c9ff3@mail.gmail.com> I wish I was more specific, indeed. :) While scouring the Web for examples of mocking ActiveRecord associations (see other thread), I saw the add method -- but couldn't figure out what it did. That made me wonder if it was perhaps some special construct in RSpec (perhaps for helping with associations, I didn't really know). To investigate, I did a code search in the rspec on rails plugin... and saw reference to an add method there (but I wasn't clear what it did). At that point, I was confused, (obviously!) so just wanted to rule out some possibilities. Your reply helped me put me on the right path. Thanks! -David On 9/16/07, David Chelimsky wrote: > > Can you be more specific? Where have you seen such references? What > did they say? Is this even an rspec question? If it's about Rails > models, try the rails list. But if you do, be more specific :) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070916/7e823401/attachment.html From lists-rspec at shopwatch.org Sun Sep 16 10:44:19 2007 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Sun, 16 Sep 2007 10:44:19 -0400 Subject: [rspec-users] I lost the RSpec fight In-Reply-To: <683a886f0709160718p5dad961i32fd5cd0e81e031@mail.gmail.com> References: <46ED31EA.9000203@shopwatch.org> <683a886f0709160718p5dad961i32fd5cd0e81e031@mail.gmail.com> Message-ID: <46ED4143.2080609@shopwatch.org> On 9/16/2007 10:18 AM, Kevin Williams wrote: > By all means, they should not ever try anything new. The people of > Earth should not have ever adopted the use of the electric light bulb > or the radio or the automobile or the airplane or the microwave or the > telephone or ... the Internet. No, don't adopt anything new, just > stick to the old ways of doing things. It's impossible for anyone to > improve on anything, right? Bah! Humbug! Obviously, I'm with you on that - but I wanted to make the point that, to make inroads in the greater community, "change is good" is not a good enough mantra! One of the problems is that, like templates (and yes, they're still on erb, if you mean as opposed to HAML), you can't really use RSpec for part of a project. There are no technical barriers; rspec and Test::Unit sit side-by-side quite nicely. But procedurally, organizationally, it's a pain. And I don't think there's a way to ease that pain. A few more impressions from that meeting: * RSpec might be nice, but Test::Unit is the "least common denominator". We all know it, it works with everything, it's there out of the box. RSpec doesn't have enough compelling reasons to change to it. (Maybe an updated feature comparison would be good here, once 1.1 launches w/StoryRunner and perhaps these HTML Formatter changes.) * I mentioned how Test::Unit development had stagnated, and they took a different view of it: Test::Unit is "complete". It's done, it works, it provides a base level of functionality that doesn't need any more updating. Jay From davidj503 at gmail.com Sun Sep 16 10:53:08 2007 From: davidj503 at gmail.com (David James) Date: Sun, 16 Sep 2007 10:53:08 -0400 Subject: [rspec-users] I lost the RSpec fight In-Reply-To: <46ED31EA.9000203@shopwatch.org> References: <46ED31EA.9000203@shopwatch.org> Message-ID: <59b5d4330709160753v3a956982ndd743fd0d1312c46@mail.gmail.com> In case it helps those who want to make it a little easier to try both at the same time (i.e. a bridge), ReinH has got a script that helps use autotest growl with both Test::Unit and RSpec: http://reinh.com/2007/9/12/the-autotest-rosetta-stone -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070916/29a37e9b/attachment.html From omen.king at gmail.com Sun Sep 16 11:17:36 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 16 Sep 2007 11:17:36 -0400 Subject: [rspec-users] I lost the RSpec fight In-Reply-To: <59b5d4330709160753v3a956982ndd743fd0d1312c46@mail.gmail.com> References: <46ED31EA.9000203@shopwatch.org> <59b5d4330709160753v3a956982ndd743fd0d1312c46@mail.gmail.com> Message-ID: I honestly didn't understand what I was testing for when I was using TDD. I can't imagine starting a project without using rspec. Rspec reads much clearly and keeps me in scope. The same reason I can't imagine starting a project without ruby. Freedom is Slavery! On 9/16/07, David James wrote: > > In case it helps those who want to make it a little easier to try both at > the same time (i.e. a bridge), ReinH has got a script that helps use > autotest growl with both Test::Unit and RSpec: > http://reinh.com/2007/9/12/the-autotest-rosetta-stone > > _______________________________________________ > 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/20070916/ead920e6/attachment-0001.html From omen.king at gmail.com Sun Sep 16 11:36:38 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 16 Sep 2007 11:36:38 -0400 Subject: [rspec-users] I lost the RSpec fight In-Reply-To: References: <46ED31EA.9000203@shopwatch.org> <59b5d4330709160753v3a956982ndd743fd0d1312c46@mail.gmail.com> Message-ID: You may have lost the fight, but you didn't lose the war. On 9/16/07, Andrew WC Brown wrote: > > I honestly didn't understand what I was testing for when I was using TDD. > I can't imagine starting a project without using rspec. > Rspec reads much clearly and keeps me in scope. > The same reason I can't imagine starting a project without ruby. > > Freedom is Slavery! > > On 9/16/07, David James wrote: > > > > In case it helps those who want to make it a little easier to try both > > at the same time (i.e. a bridge), ReinH has got a script that helps use > > autotest growl with both Test::Unit and RSpec: > > http://reinh.com/2007/9/12/the-autotest-rosetta-stone > > > > _______________________________________________ > > 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/20070916/fe928057/attachment.html From pergesu at gmail.com Sun Sep 16 11:44:42 2007 From: pergesu at gmail.com (Pat Maddox) Date: Sun, 16 Sep 2007 08:44:42 -0700 Subject: [rspec-users] I lost the RSpec fight In-Reply-To: <46ED31EA.9000203@shopwatch.org> References: <46ED31EA.9000203@shopwatch.org> Message-ID: <810a540e0709160844j43e74c0dmc98335fe49b19cb2@mail.gmail.com> On 9/16/07, Jay Levitt wrote: > I've been working on a Rails project with one other developer; he was > using Test::Unit, and I was using RSpec. That works OK for a while, but > obviously it starts causing pain when you have to check in two places to > see if a piece of code is properly tested/spec'd, you can't use TextMate > shortcuts to switch back and forth between code and test, you have to > duplicate shared behaviors/test helpers, etc. > > So when we brought in a consulting team to add some manpower, we > realized we had to switch to a single framework. This is a team that's > fairly experienced with Rails and active in the Rails community, but was > quite opposed to choosing RSpec. > > Here are the arguments I heard against unifying on RSpec: > > * Test::Unit is ubiquitous. Everyone knows it. This is hard to > counter; it comes with Rails and is the default. Same reason many > people use Prototype even though JQuery/dojo might suit them better. > > * For that reason, it's a lot easier to find examples of "how to do > something" in Test::Unit than in RSpec. That's true; several times I've > had a bit of code that didn't fall nicely into the MVC hierarchy, and I > wasn't sure how to build up the right context to test it in. If I were > using Test::Unit, I could just copy the equivalent tests from Rails > core, but using RSpec I had to roll my own. > > * RSpec is BDD (hand-waving new different troublesome); we do TDD. > We've covered that ground on this list many times; BDD is an extension > and interpretation of TDD, not some newfangled crackpot theory. But > people don't know that. > > * The team had in fact investigated RSpec a few months ago, and decided > they didn't like it. Some of what they didn't like has been fixed in > 1.0, but of course people aren't going to come running to re-examine > each release, so the bitter taste remained: > > * #context was defined on Kernel. Not sure if that's still true for > #describe. > > * Not compatible with tools that expect Test::Unit output. This > would(could) be fixed with the runner integration that's been discussed. > > * Wasn't compatible with mocha/FlexMock. Fixed now. > > But again, it came back to ubiquity, which is a pretty hard problem to > overcome. > > Seems to me that the best way to get RSpec adopted is to find some more > visible, prolific plugin programmers and evangelize them to start using > RSpec, so it's not some "neat fringe thing", but a solid, respectable > alternative to Test::Unit. > > Jay Levitt > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Bummer. Since you've been doing TDD the right way this whole time, hopefully you'll be able to maintain (and teach) what you've learned. It might be uncomfortable or painful at first but I'm sure you can do it. I'm interested to know how your Test::Unit style might have changed after using RSpec for a while. I'm also interested to know if you "slip" back to your older, different style (if there was one). Pat From mailing_lists at railsnewbie.com Sun Sep 16 13:59:25 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 16 Sep 2007 13:59:25 -0400 Subject: [rspec-users] How far to go with ActiveRecord unit tests without hitting the database? In-Reply-To: <59b5d4330709152220t2283ed90wc7354bacbe921a76@mail.gmail.com> References: <59b5d4330709152220t2283ed90wc7354bacbe921a76@mail.gmail.com> Message-ID: <4DBFAF1F-50F0-4CFC-8BCB-81CA2B628D0C@railsnewbie.com> On Sep 16, 2007, at 1:20 AM, David James wrote: > I'm currently try to push my limits a little bit with some of my > unit testing -- trying to avoid saving ActiveRecord objects to the > database and take advantage of mock/stub objects. > > How far should I expect to get in this direction? From what I can > tell, ActiveRecord seems to fight me when it comes to > associations. In other words, many associations seem to require > database queries. > > Have others had success in mocking/stubbing associations? In > particular, have you had luck with has_many :through? > I would highly suggest taking a look at Jay Fields blog. The examples use Test::Unit, but that shouldn't discourage you :). In one of his posts he stubs/mocks out the class used for a database column in ActiveRecord (ActiveRecord::ConnectionAdapter::Column). I, personally, though, prefer to go the opposite way. Integration Testing and Unit Testing are on a continuum, and in my opinion, the only advantage of going the Jay Field's way (that is, the traditional mocks/stubs approach - this is the one end of the continuum) is speed. The truth is that Rails was not developed by a BDD'er, and the coupling is too tight. When you test rails the way you would test anything else, you'll soon realize how tight this coupling is, because you will spend more time debugging rails then debugging your own app. Just as an example, the other day I had a method call in an ActiveRecord class which did something like this: Tag.find_or_create_by_name("Summer") and I had the following expectation: Tag.should_receive(:create).with(:name => "Summer") So where was my test failing? It wasn't in the logic of *my* code. It was in how ActiveRecord dealt with this dynamic finder. The docs say this: Tag.find_or_create_by_name("Summer") # equal to Tag.create(:name => "Summer") So I ran my debugger. Guess what! The call was to Tag.create("name" => "Summer"), not Tag.create(:name => "Summer"). (The difference was that "name" was a string, not a symbol). So - if you can afford to spend time debugging the internals of rails (or if you know rails inside and out) , then yes - go right ahead and have incredibly speedy unit tests. But otherwise, what exactly are you testing? Sorry for the rant, Scott Taylor From mailing_lists at railsnewbie.com Sun Sep 16 14:16:24 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 16 Sep 2007 14:16:24 -0400 Subject: [rspec-users] How I won the RSpec fight In-Reply-To: <46ED31EA.9000203@shopwatch.org> References: <46ED31EA.9000203@shopwatch.org> Message-ID: <633323DB-D4F2-4FE0-B868-4EDA086C0E94@railsnewbie.com> On Sep 16, 2007, at 9:38 AM, Jay Levitt wrote: > I've been working on a Rails project with one other developer; he was > using Test::Unit, and I was using RSpec. That works OK for a > while, but > obviously it starts causing pain when you have to check in two > places to > see if a piece of code is properly tested/spec'd, you can't use > TextMate > shortcuts to switch back and forth between code and test, you have to > duplicate shared behaviors/test helpers, etc. There are two developers currently on the project I'm working on. I was lucky enough to win it for two reasons: 1. I had written 100 specs before the other developer came on. There were 60 Test::Unit tests, and half of them were failing. 2. The docs are the real winner. Generate the HTML specdoc report for a buisness user who understands the details of the app. He will appreciate it, understand what *has* been tested, what has not *yet* been tested (or, better yet, what *has* been built, and what is still TODO, or pending). Test::Unit cannot show that, so when you say to the client "I want to spend some time testing," it doesn't translate into anything tangible for him. Plus, the specdoc is pretty! Scott From omen.king at gmail.com Sun Sep 16 14:33:36 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 16 Sep 2007 14:33:36 -0400 Subject: [rspec-users] "Not Implemented" doesn't show Message-ID: I'm going through Peepcode's Rspec Basics for an overview. He's just doing a simple spec: class PeepCode end describe PeepCode do it "should be awsome" do end end So running spec spec/simple_spec.rb should produce according to his screen cast: 1 example, 0 failures, 1 not implemented but I only recieve: 1 example, 0 failures Also spec spec/simple_spec.rb --format will fail /usr/local/lib/ruby/1.8/optparse.rb:451:in `parse': missing argument: --format (OptionParser::MissingArgument) RSpec 1.0.8 ZenTest 3.6.1 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070916/7a5765c4/attachment.html From cwdinfo at gmail.com Sun Sep 16 14:45:20 2007 From: cwdinfo at gmail.com (s.ross) Date: Sun, 16 Sep 2007 11:45:20 -0700 Subject: [rspec-users] [ANN] rspec_todo -- spec'ing backwards Message-ID: <69A0385A-ACEB-438D-9553-90F26F3C919B@gmail.com> While the spirit of BDD is to spec first and code second, many of us have legacy code. Worse, some of us have legacy code without very good coverage. Recognizing that *I* have such code, I created a script that grinds through your .rb files and creates placeholder specs for each public method. While it is more sensible to spec behavior of code function than of individual methods, this tool can help jump start a transition to that wonderful place. Comments welcome (and please be kind about the code -- I know it needs refactoring :). svn: http://svn.calicowebdev.com/rspec_todo/trunk Excerpt from the readme: Usage is: ruby spec_todo.rb Options are: -m -- Wrap each file's spec in a module -u -- Use "it" with a block and a pending method rather than a "it" So, for example, I might use it as follows: ruby spec_todo.rb app/models/* app/controllers/* Here is a brief example of the output of this tool: #------------------------------------------------------------ # File: app/controllers/contact_controller_spec.rb #------------------------------------------------------------ require File.dirname(__FILE__) + '/../spec_helper' describe "A ContactController" do it "should do something sensible with index." it "should do something sensible with thank_you." end From dchelimsky at gmail.com Sun Sep 16 14:53:52 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 16 Sep 2007 20:53:52 +0200 Subject: [rspec-users] "Not Implemented" doesn't show In-Reply-To: References: Message-ID: <57c63afe0709161153t2524330g9ec6fa287796819@mail.gmail.com> On 9/16/07, Andrew WC Brown wrote: > I'm going through Peepcode's Rspec Basics for an overview. > > He's just doing a simple spec: > > class PeepCode > end > > describe PeepCode do > it "should be awsome" do > end > end > > So running spec spec/simple_spec.rb should produce according to his screen > cast: > 1 example, 0 failures, 1 not implemented I'm pretty sure that I saw the peep code and it showed the right thing here - but I don't have time to go through it right this minute to verify. That said, if that IS what the screencast says then the screencast is wrong. You can get "Not implemented" with no block: describe PeepCode do it "should be awesome" # no block passed to the #it method end or by using the pending method inside the block: describe PeepCode do it "should be awesome" do pending("for some reason") ... end end or describe PeepCode do it "should be awesome" do pending("for some reason") do ... end ... end end but an empty block (as in your example) just passes. HTH, David > > but I only recieve: > 1 example, 0 failures > > Also spec spec/simple_spec.rb --format will fail > /usr/local/lib/ruby/1.8/optparse.rb:451:in `parse': missing > argument: --format (OptionParser::MissingArgument) > > RSpec 1.0.8 > ZenTest 3.6.1 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Sun Sep 16 15:04:16 2007 From: pergesu at gmail.com (Pat Maddox) Date: Sun, 16 Sep 2007 12:04:16 -0700 Subject: [rspec-users] [ANN] rspec_todo -- spec'ing backwards In-Reply-To: <69A0385A-ACEB-438D-9553-90F26F3C919B@gmail.com> References: <69A0385A-ACEB-438D-9553-90F26F3C919B@gmail.com> Message-ID: <810a540e0709161204q7d52c907w8699f4a811f93d4d@mail.gmail.com> On 9/16/07, s.ross wrote: > While the spirit of BDD is to spec first and code second, many of us > have legacy code. Worse, some of us have legacy code without very > good coverage. Recognizing that *I* have such code, I created a > script that grinds through your .rb files and creates placeholder > specs for each public method. > > While it is more sensible to spec behavior of code function than of > individual methods, this tool can help jump start a transition to > that wonderful place. Comments welcome (and please be kind about the > code -- I know it needs refactoring :). > > svn: > > http://svn.calicowebdev.com/rspec_todo/trunk > > Excerpt from the readme: > > Usage is: > > ruby spec_todo.rb > > Options are: > > -m -- Wrap each file's spec in a module > > -u -- Use "it" with a block and a pending method rather than a "it" > > > So, for example, I might use it as follows: > > ruby spec_todo.rb app/models/* app/controllers/* > > Here is a brief example of the output of this tool: > > > #------------------------------------------------------------ > # File: app/controllers/contact_controller_spec.rb > #------------------------------------------------------------ > > require File.dirname(__FILE__) + '/../spec_helper' > > describe "A ContactController" do > it "should do something sensible with index." > it "should do something sensible with thank_you." > end > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Jim Weirich has a great article where he uses a technique to retrofit legacy code with specs. http://onestepback.org/index.cgi/Tech/Ruby/FlexMockAndFluidDynamics.red Pat From dchelimsky at gmail.com Sun Sep 16 15:04:30 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 16 Sep 2007 21:04:30 +0200 Subject: [rspec-users] [ANN] rspec_todo -- spec'ing backwards In-Reply-To: <69A0385A-ACEB-438D-9553-90F26F3C919B@gmail.com> References: <69A0385A-ACEB-438D-9553-90F26F3C919B@gmail.com> Message-ID: <57c63afe0709161204q42fd12adsd02ee15d6d540740@mail.gmail.com> On 9/16/07, s.ross wrote: > While the spirit of BDD is to spec first and code second, many of us > have legacy code. Worse, some of us have legacy code without very > good coverage. Recognizing that *I* have such code, I created a > script that grinds through your .rb files and creates placeholder > specs for each public method. > > While it is more sensible to spec behavior of code function than of > individual methods, this tool can help jump start a transition to > that wonderful place. Hi Steve, There are tools that will do this for you on java projects and in nearly every case that I've seen them used, the result has been 100 line test methods, one per object method, that take the object through multiple states, become impossible to understand, and often just get commented out. Worse, even though you sell it as a tool for dealing with legacy code (code without tests), it will end up becoming the tool people use and, even worse than that, they'll think it's BDD because it creates specs and not tests. I beg you (I'm on my knees as I'm writing this) to throw this manuscript in the fire now! FWIW, David > Comments welcome (and please be kind about the > code -- I know it needs refactoring :). > > svn: > > http://svn.calicowebdev.com/rspec_todo/trunk > > Excerpt from the readme: > > Usage is: > > ruby spec_todo.rb > > Options are: > > -m -- Wrap each file's spec in a module > > -u -- Use "it" with a block and a pending method rather than a "it" > > > So, for example, I might use it as follows: > > ruby spec_todo.rb app/models/* app/controllers/* > > Here is a brief example of the output of this tool: > > > #------------------------------------------------------------ > # File: app/controllers/contact_controller_spec.rb > #------------------------------------------------------------ > > require File.dirname(__FILE__) + '/../spec_helper' > > describe "A ContactController" do > it "should do something sensible with index." > it "should do something sensible with thank_you." > end > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From omen.king at gmail.com Sun Sep 16 15:20:28 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 16 Sep 2007 15:20:28 -0400 Subject: [rspec-users] "Not Implemented" doesn't show In-Reply-To: <57c63afe0709161153t2524330g9ec6fa287796819@mail.gmail.com> References: <57c63afe0709161153t2524330g9ec6fa287796819@mail.gmail.com> Message-ID: Oh, he removed the block. describe PeepCode do it "should be awsome" do end end describe PeepCode do it "should be awsome" end I'm still haven't solved --format with specing. On 9/16/07, David Chelimsky wrote: > > On 9/16/07, Andrew WC Brown wrote: > > I'm going through Peepcode's Rspec Basics for an overview. > > > > He's just doing a simple spec: > > > > class PeepCode > > end > > > > describe PeepCode do > > it "should be awsome" do > > end > > end > > > > So running spec spec/simple_spec.rb should produce according to his > screen > > cast: > > 1 example, 0 failures, 1 not implemented > > I'm pretty sure that I saw the peep code and it showed the right thing > here - but I don't have time to go through it right this minute to > verify. That said, if that IS what the screencast says then the > screencast is wrong. You can get "Not implemented" with no block: > > describe PeepCode do > it "should be awesome" # no block passed to the #it method > end > > or by using the pending method inside the block: > > describe PeepCode do > it "should be awesome" do > pending("for some reason") > ... > end > end > > or > > describe PeepCode do > it "should be awesome" do > pending("for some reason") do > ... > end > ... > end > end > > but an empty block (as in your example) just passes. > > HTH, > David > > > > > but I only recieve: > > 1 example, 0 failures > > > > Also spec spec/simple_spec.rb --format will fail > > /usr/local/lib/ruby/1.8/optparse.rb:451:in `parse': missing > > argument: --format (OptionParser::MissingArgument) > > > > RSpec 1.0.8 > > ZenTest 3.6.1 > > > > _______________________________________________ > > 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 > -- Monsterbox Productions putting small businesses on-line 1319 Victoria Avenue East Thunder Bay, Ontario P7C 1C3 Canada Andrew WC Brown web-developer and owner andrew at monsterboxpro.com P: 807-626-9009 F: 807-624-2705 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070916/789bf9a4/attachment.html From omen.king at gmail.com Sun Sep 16 15:21:40 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 16 Sep 2007 15:21:40 -0400 Subject: [rspec-users] "Not Implemented" doesn't show In-Reply-To: References: <57c63afe0709161153t2524330g9ec6fa287796819@mail.gmail.com> Message-ID: Both Solved, User Error =P On 9/16/07, Andrew WC Brown wrote: > > Oh, he removed the block. > > describe PeepCode do > it "should be awsome" do > end > end > > describe PeepCode do > it "should be awsome" > end > > I'm still haven't solved --format with specing. > > On 9/16/07, David Chelimsky wrote: > > > > On 9/16/07, Andrew WC Brown < omen.king at gmail.com> wrote: > > > I'm going through Peepcode's Rspec Basics for an overview. > > > > > > He's just doing a simple spec: > > > > > > class PeepCode > > > end > > > > > > describe PeepCode do > > > it "should be awsome" do > > > end > > > end > > > > > > So running spec spec/simple_spec.rb should produce according to his > > screen > > > cast: > > > 1 example, 0 failures, 1 not implemented > > > > I'm pretty sure that I saw the peep code and it showed the right thing > > here - but I don't have time to go through it right this minute to > > verify. That said, if that IS what the screencast says then the > > screencast is wrong. You can get "Not implemented" with no block: > > > > describe PeepCode do > > it "should be awesome" # no block passed to the #it method > > end > > > > or by using the pending method inside the block: > > > > describe PeepCode do > > it "should be awesome" do > > pending("for some reason") > > ... > > end > > end > > > > or > > > > describe PeepCode do > > it "should be awesome" do > > pending("for some reason") do > > ... > > end > > ... > > end > > end > > > > but an empty block (as in your example) just passes. > > > > HTH, > > David > > > > > > > > but I only recieve: > > > 1 example, 0 failures > > > > > > Also spec spec/simple_spec.rb --format will fail > > > /usr/local/lib/ruby/1.8/optparse.rb:451:in `parse': missing > > > argument: --format (OptionParser::MissingArgument) > > > > > > RSpec 1.0.8 > > > ZenTest 3.6.1 > > > > > > _______________________________________________ > > > 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 > > > > > > -- > Monsterbox Productions > putting small businesses on-line > > 1319 Victoria Avenue East > Thunder Bay, Ontario P7C 1C3 > Canada > > Andrew WC Brown > web-developer and owner > andrew at monsterboxpro.com > P: 807-626-9009 > F: 807-624-2705 -- Monsterbox Productions putting small businesses on-line 1319 Victoria Avenue East Thunder Bay, Ontario P7C 1C3 Canada Andrew WC Brown web-developer and owner andrew at monsterboxpro.com P: 807-626-9009 F: 807-624-2705 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070916/2644d53e/attachment.html From mailing_lists at railsnewbie.com Sun Sep 16 15:34:56 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 16 Sep 2007 15:34:56 -0400 Subject: [rspec-users] [ANN] rspec_todo -- spec'ing backwards In-Reply-To: <57c63afe0709161204q42fd12adsd02ee15d6d540740@mail.gmail.com> References: <69A0385A-ACEB-438D-9553-90F26F3C919B@gmail.com> <57c63afe0709161204q42fd12adsd02ee15d6d540740@mail.gmail.com> Message-ID: <1C0B01B2-0E91-4DA6-BC05-CB91A458F504@railsnewbie.com> On Sep 16, 2007, at 3:04 PM, David Chelimsky wrote: > On 9/16/07, s.ross wrote: >> While the spirit of BDD is to spec first and code second, many of us >> have legacy code. Worse, some of us have legacy code without very >> good coverage. Recognizing that *I* have such code, I created a >> script that grinds through your .rb files and creates placeholder >> specs for each public method. >> >> While it is more sensible to spec behavior of code function than of >> individual methods, this tool can help jump start a transition to >> that wonderful place. > > Hi Steve, > > There are tools that will do this for you on java projects and in > nearly every case that I've seen them used, the result has been 100 > line test methods, one per object method, that take the object through > multiple states, become impossible to understand, and often just get > commented out. > > Worse, even though you sell it as a tool for dealing with legacy code > (code without tests), it will end up becoming the tool people use and, > even worse than that, they'll think it's BDD because it creates specs > and not tests. > > I beg you (I'm on my knees as I'm writing this) to throw this > manuscript in the fire now! I agree with David (you can also look at the ZenTest suite, which has a similar tool). I haven't looked at the tool, but how about modifying it to create comments in the specs, somthing like this: # You haven't specified the behaviour of User#method1! # You haven't specified the behaviour of User#method2! Scott From pergesu at gmail.com Sun Sep 16 15:38:42 2007 From: pergesu at gmail.com (Pat Maddox) Date: Sun, 16 Sep 2007 12:38:42 -0700 Subject: [rspec-users] [ANN] rspec_todo -- spec'ing backwards In-Reply-To: <1C0B01B2-0E91-4DA6-BC05-CB91A458F504@railsnewbie.com> References: <69A0385A-ACEB-438D-9553-90F26F3C919B@gmail.com> <57c63afe0709161204q42fd12adsd02ee15d6d540740@mail.gmail.com> <1C0B01B2-0E91-4DA6-BC05-CB91A458F504@railsnewbie.com> Message-ID: <810a540e0709161238x556d05a0rac05c3a2d332b656@mail.gmail.com> On 9/16/07, Scott Taylor wrote: > > On Sep 16, 2007, at 3:04 PM, David Chelimsky wrote: > > > On 9/16/07, s.ross wrote: > >> While the spirit of BDD is to spec first and code second, many of us > >> have legacy code. Worse, some of us have legacy code without very > >> good coverage. Recognizing that *I* have such code, I created a > >> script that grinds through your .rb files and creates placeholder > >> specs for each public method. > >> > >> While it is more sensible to spec behavior of code function than of > >> individual methods, this tool can help jump start a transition to > >> that wonderful place. > > > > Hi Steve, > > > > There are tools that will do this for you on java projects and in > > nearly every case that I've seen them used, the result has been 100 > > line test methods, one per object method, that take the object through > > multiple states, become impossible to understand, and often just get > > commented out. > > > > Worse, even though you sell it as a tool for dealing with legacy code > > (code without tests), it will end up becoming the tool people use and, > > even worse than that, they'll think it's BDD because it creates specs > > and not tests. > > > > I beg you (I'm on my knees as I'm writing this) to throw this > > manuscript in the fire now! > > > I agree with David (you can also look at the ZenTest suite, which has > a similar tool). I haven't looked at the tool, but how about > modifying it to create comments in the specs, somthing like this: > > # You haven't specified the behaviour of User#method1! > # You haven't specified the behaviour of User#method2! > > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Why not use RCov? Seeing a bunch of red is a much bigger motivator than a lame comment. Pat From mailing_lists at railsnewbie.com Sun Sep 16 15:45:34 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 16 Sep 2007 15:45:34 -0400 Subject: [rspec-users] [ANN] rspec_todo -- spec'ing backwards In-Reply-To: <810a540e0709161238x556d05a0rac05c3a2d332b656@mail.gmail.com> References: <69A0385A-ACEB-438D-9553-90F26F3C919B@gmail.com> <57c63afe0709161204q42fd12adsd02ee15d6d540740@mail.gmail.com> <1C0B01B2-0E91-4DA6-BC05-CB91A458F504@railsnewbie.com> <810a540e0709161238x556d05a0rac05c3a2d332b656@mail.gmail.com> Message-ID: >> >> >> I agree with David (you can also look at the ZenTest suite, which has >> a similar tool). I haven't looked at the tool, but how about >> modifying it to create comments in the specs, somthing like this: >> >> # You haven't specified the behaviour of User#method1! >> # You haven't specified the behaviour of User#method2! >> >> Scott >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > Why not use RCov? Seeing a bunch of red is a much bigger motivator > than a lame comment. Good point. Just out of curiosity - Have you noticed that rcov won't pick up all of the files in a Rails project unless there is an explicit spec file for it (or the class/model isn't called) ? Scott From eivindu at ifi.uio.no Sun Sep 16 16:36:56 2007 From: eivindu at ifi.uio.no (Eivind Uggedal) Date: Sun, 16 Sep 2007 22:36:56 +0200 Subject: [rspec-users] How to write a plugin that uses rspec internally? In-Reply-To: <59b5d4330709150605o4587f66cof56068ecd7abe457@mail.gmail.com> References: <59b5d4330709150605o4587f66cof56068ecd7abe457@mail.gmail.com> Message-ID: <824b51d00709161336i165e54e1jda8a41d9e37c94cd@mail.gmail.com> On 9/15/07, David James wrote: > (c) Would you recommend any particular plugins to study along these lines? I recently (a few minutes ago) released a plugin using RSpec to test it's code: http://acts-as-authentable.googlecode.com/ -- Cheers, Eivind Uggedal Engineer, Faculty of Social Science, MSc Computer Science, University of Oslo From cwdinfo at gmail.com Sun Sep 16 18:44:19 2007 From: cwdinfo at gmail.com (s.ross) Date: Sun, 16 Sep 2007 15:44:19 -0700 Subject: [rspec-users] [ANN] rspec_todo -- spec'ing backwards In-Reply-To: <57c63afe0709161204q42fd12adsd02ee15d6d540740@mail.gmail.com> References: <69A0385A-ACEB-438D-9553-90F26F3C919B@gmail.com> <57c63afe0709161204q42fd12adsd02ee15d6d540740@mail.gmail.com> Message-ID: <97F9A22A-87C8-4974-87D3-F3D85E5DA125@gmail.com> As with all development tools, caveat programmer. The art is in recognizing the behaviors and not just exercising the methods meaninglessly. I personally believe that having the method tests in spec form allows me to think about what the methods are *doing* and then write the real behavior I expect. This is not -- for me -- a "let's get 100% coverage" exercise. Just another tool that might be of use. By the way, do you find that typing when on your knees helps your posture? I thought about that for a while but found I prefer sitting in a chair as I write :) --steve On Sep 16, 2007, at 12:04 PM, David Chelimsky wrote: > On 9/16/07, s.ross wrote: >> While the spirit of BDD is to spec first and code second, many of us >> have legacy code. Worse, some of us have legacy code without very >> good coverage. Recognizing that *I* have such code, I created a >> script that grinds through your .rb files and creates placeholder >> specs for each public method. >> >> While it is more sensible to spec behavior of code function than of >> individual methods, this tool can help jump start a transition to >> that wonderful place. > > Hi Steve, > > There are tools that will do this for you on java projects and in > nearly every case that I've seen them used, the result has been 100 > line test methods, one per object method, that take the object through > multiple states, become impossible to understand, and often just get > commented out. > > Worse, even though you sell it as a tool for dealing with legacy code > (code without tests), it will end up becoming the tool people use and, > even worse than that, they'll think it's BDD because it creates specs > and not tests. > > I beg you (I'm on my knees as I'm writing this) to throw this > manuscript in the fire now! > > FWIW, > David > >> Comments welcome (and please be kind about the >> code -- I know it needs refactoring :). >> >> svn: >> >> http://svn.calicowebdev.com/rspec_todo/trunk >> >> Excerpt from the readme: >> >> Usage is: >> >> ruby spec_todo.rb >> >> Options are: >> >> -m -- Wrap each file's spec in a module >> >> -u -- Use "it" with a block and a pending method rather than a >> "it" >> >> >> So, for example, I might use it as follows: >> >> ruby spec_todo.rb app/models/* app/controllers/* >> >> Here is a brief example of the output of this tool: >> >> >> #------------------------------------------------------------ >> # File: app/controllers/contact_controller_spec.rb >> #------------------------------------------------------------ >> >> require File.dirname(__FILE__) + '/../spec_helper' >> >> describe "A ContactController" do >> it "should do something sensible with index." >> it "should do something sensible with thank_you." >> end >> >> _______________________________________________ >> 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 omen.king at gmail.com Sun Sep 16 21:43:13 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 16 Sep 2007 21:43:13 -0400 Subject: [rspec-users] how do I get the beautiful html rspec results in textmate? Message-ID: I'm going through PeepCode RSpec Basics and he gets a beautiful rspec results page in html when he presses a hotkey in TextMate. I would guess it's along the lines of Apple + R but I don't get the same results and I'm using the same bundle. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070916/1c1089c0/attachment.html From chrisdpratt at gmail.com Sun Sep 16 22:18:26 2007 From: chrisdpratt at gmail.com (Christopher D. Pratt) Date: Sun, 16 Sep 2007 21:18:26 -0500 Subject: [rspec-users] "rake spec:doc" returns NO NAME (due to --dry-run) for each specify block In-Reply-To: <8d961d900709160352u6b859901sfd925dcc3e352cea@mail.gmail.com> References: <79a30c430709160219t4716b81s7b05c1e77faaccb5@mail.gmail.com> <8d961d900709160352u6b859901sfd925dcc3e352cea@mail.gmail.com> Message-ID: <79a30c430709161918k123cfb5am3c8a85e15ce5ba69@mail.gmail.com> Thanks for all the responses. Unfortunately, I apparently just like being difficult. Tom: I installed the new version of rspec on a fresh app, so the first run of script/generate rspec was from the trunk version ... good idea though, because it sounds like something I would have done ----- David: all of my specify blocks have the string names on them, so that doesn't seem like the problem. I also tried running the two commands you provided but both returned the following errors: $ rake spec --format specdoc rake aborted! No Rakefile found (looking for: ormat) /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1934:in `raw_load_rakefile' (See full trace by running task with --trace) $ rake spec -fs rake aborted! No Rakefile found (looking for: s) /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1934:in `raw_load_rakefile' (See full trace by running task with --trace) Is there some way I can turn off dry run for spec:doc? -------- Aslak: I'm not relying on auto-generated names. Although I definitely agree that spec:doc is acting as if I were ------- Any other ideas? ;) Thanks, Chris Pratt On 9/16/07, aslak hellesoy wrote: > > This happens if you have it blocks with no name. RSpec tries to > generate names based on the code inside, but with dry run it isn't > executed, so it can't. > > But maybe you don't have empty it blocks? I'm just guessing here... > > Aslak > > On 9/16/07, Christopher D. Pratt wrote: > > I went ahead and moved to the trunk versions of RSpec and Spec:Rails > because > > I wanted to try out the new Story Runner feature. However, when I tried > to > > do "rake spec:doc", I got the following: > > > > AccountController > > - NO NAME (Because of --dry-run) > > > > AccountHelper > > - NO NAME (Because of --dry-run) > > > > User (in general) > > - NO NAME (Because of --dry-run) > > - NO NAME (Because of --dry-run) > > - NO NAME (Because of --dry-run) > > - NO NAME (Because of --dry-run) > > - NO NAME (Because of --dry-run) > > - NO NAME (Because of --dry-run) > > > > I emptied everything out of my spec.opts file just to make sure it > wasn't > > some setting there causing problems, but that still had no effect. I > haven't > > submitted this as a bug yet because I'm still holding out the > possibility > > that I'm simply doing something wrong. > > > > Thanks, > > > > Chris Pratt > > > > _______________________________________________ > > 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/20070916/4a13d302/attachment.html From mailing_lists at railsnewbie.com Sun Sep 16 22:38:30 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 16 Sep 2007 22:38:30 -0400 Subject: [rspec-users] how do I get the beautiful html rspec results in textmate? In-Reply-To: References: Message-ID: <5C3F9157-D46D-402F-BC71-845332395304@railsnewbie.com> On Sep 16, 2007, at 9:43 PM, Andrew WC Brown wrote: > I'm going through PeepCode RSpec Basics and he gets a beautiful > rspec results page in html when he presses a hotkey in TextMate. > I would guess it's along the lines of Apple + R but I don't get the > same results and I'm using the same bundle. > > Works for me - through Bundles => RSpec => "Run Behaviour Descriptions in Selected Files", although I'm using the rspec Bundle checked out from trunk/. The bundle has been going through some modifications, as of late, though. Here is a document that shows how to use a bundle checked out from subversion (if you care - it's section 5.7.3): http://macromates.com/textmate/manual/bundles Scott From court3nay at gmail.com Mon Sep 17 00:13:50 2007 From: court3nay at gmail.com (court3nay) Date: Sun, 16 Sep 2007 21:13:50 -0700 Subject: [rspec-users] I lost the RSpec fight In-Reply-To: <810a540e0709160844j43e74c0dmc98335fe49b19cb2@mail.gmail.com> References: <46ED31EA.9000203@shopwatch.org> <810a540e0709160844j43e74c0dmc98335fe49b19cb2@mail.gmail.com> Message-ID: <86E6C42E-9F16-43F7-845A-38F2909A52FD@gmail.com> Test/spec + mocha On Sep 16, 2007, at 8:44 AM, "Pat Maddox" wrote: > On 9/16/07, Jay Levitt wrote: >> I've been working on a Rails project with one other developer; he was >> using Test::Unit, and I was using RSpec. That works OK for a >> while, but >> obviously it starts causing pain when you have to check in two >> places to >> see if a piece of code is properly tested/spec'd, you can't use >> TextMate >> shortcuts to switch back and forth between code and test, you have to >> duplicate shared behaviors/test helpers, etc. >> >> So when we brought in a consulting team to add some manpower, we >> realized we had to switch to a single framework. This is a team >> that's >> fairly experienced with Rails and active in the Rails community, >> but was >> quite opposed to choosing RSpec. >> >> Here are the arguments I heard against unifying on RSpec: >> >> * Test::Unit is ubiquitous. Everyone knows it. This is hard to >> counter; it comes with Rails and is the default. Same reason many >> people use Prototype even though JQuery/dojo might suit them better. >> >> * For that reason, it's a lot easier to find examples of "how to do >> something" in Test::Unit than in RSpec. That's true; several times >> I've >> had a bit of code that didn't fall nicely into the MVC hierarchy, >> and I >> wasn't sure how to build up the right context to test it in. If I >> were >> using Test::Unit, I could just copy the equivalent tests from Rails >> core, but using RSpec I had to roll my own. >> >> * RSpec is BDD (hand-waving new different troublesome); we do TDD. >> We've covered that ground on this list many times; BDD is an >> extension >> and interpretation of TDD, not some newfangled crackpot theory. But >> people don't know that. >> >> * The team had in fact investigated RSpec a few months ago, and >> decided >> they didn't like it. Some of what they didn't like has been fixed in >> 1.0, but of course people aren't going to come running to re-examine >> each release, so the bitter taste remained: >> >> * #context was defined on Kernel. Not sure if that's still true for >> #describe. >> >> * Not compatible with tools that expect Test::Unit output. This >> would(could) be fixed with the runner integration that's been >> discussed. >> >> * Wasn't compatible with mocha/FlexMock. Fixed now. >> >> But again, it came back to ubiquity, which is a pretty hard problem >> to >> overcome. >> >> Seems to me that the best way to get RSpec adopted is to find some >> more >> visible, prolific plugin programmers and evangelize them to start >> using >> RSpec, so it's not some "neat fringe thing", but a solid, respectable >> alternative to Test::Unit. >> >> Jay Levitt >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > Bummer. > > Since you've been doing TDD the right way this whole time, hopefully > you'll be able to maintain (and teach) what you've learned. It might > be uncomfortable or painful at first but I'm sure you can do it. > > I'm interested to know how your Test::Unit style might have changed > after using RSpec for a while. I'm also interested to know if you > "slip" back to your older, different style (if there was one). > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lancecarlson at gmail.com Mon Sep 17 00:14:24 2007 From: lancecarlson at gmail.com (lancecarlson at gmail.com) Date: Mon, 17 Sep 2007 04:14:24 +0000 Subject: [rspec-users] [ANN] rspec_todo -- spec'ing backwards In-Reply-To: References: <69A0385A-ACEB-438D-9553-90F26F3C919B@gmail.com><57c63afe0709161204q42fd12adsd02ee15d6d540740@mail.gmail.com><1C0B01B2-0E91-4DA6-BC05-CB91A458F504@railsnewbie.com><810a540e0709161238x556d05a0rac05c3a2d332b656@mail.gmail.com> Message-ID: <1583257461-1190002560-cardhu_decombobulator_blackberry.rim.net-768709304-@bxe126.bisx.prod.on.blackberry> Yes that is nice because you know what files aren't really being used. That is asiming you tested everything that is being used! Sent via BlackBerry from T-Mobile -----Original Message----- From: Scott Taylor Date: Sun, 16 Sep 2007 15:45:34 To:rspec-users Subject: Re: [rspec-users] [ANN] rspec_todo -- spec'ing backwards >> >> >> I agree with David (you can also look at the ZenTest suite, which has >> a similar tool). I haven't looked at the tool, but how about >> modifying it to create comments in the specs, somthing like this: >> >> # You haven't specified the behaviour of User#method1! >> # You haven't specified the behaviour of User#method2! >> >> Scott >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > Why not use RCov? Seeing a bunch of red is a much bigger motivator > than a lame comment. Good point. Just out of curiosity - Have you noticed that rcov won't pick up all of the files in a Rails project unless there is an explicit spec file for it (or the class/model isn't called) ? Scott _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users From mvyver at gmail.com Mon Sep 17 02:30:31 2007 From: mvyver at gmail.com (Mark Van De Vyver) Date: Mon, 17 Sep 2007 16:30:31 +1000 Subject: [rspec-users] [ANN] rspec_todo -- spec'ing backwards In-Reply-To: <57c63afe0709161204q42fd12adsd02ee15d6d540740@mail.gmail.com> References: <69A0385A-ACEB-438D-9553-90F26F3C919B@gmail.com> <57c63afe0709161204q42fd12adsd02ee15d6d540740@mail.gmail.com> Message-ID: <389c43e40709162330w4e6fd5b1x2008522b9749ca3@mail.gmail.com> Hi, On 9/17/07, David Chelimsky wrote: > On 9/16/07, s.ross wrote: > > While the spirit of BDD is to spec first and code second, many of us > > have legacy code. Worse, some of us have legacy code without very > > good coverage. Recognizing that *I* have such code, I created a > > script that grinds through your .rb files and creates placeholder > > specs for each public method. > > > > While it is more sensible to spec behavior of code function than of > > individual methods, this tool can help jump start a transition to > > that wonderful place. > > Hi Steve, > > There are tools that will do this for you on java projects and in > nearly every case that I've seen them used, the result has been 100 > line test methods, one per object method, that take the object through > multiple states, become impossible to understand, and often just get > commented out. > > Worse, even though you sell it as a tool for dealing with legacy code > (code without tests), it will end up becoming the tool people use and, > even worse than that, they'll think it's BDD because it creates specs > and not tests. > > I beg you (I'm on my knees as I'm writing this) to throw this > manuscript in the fire now! Hmm, I've never heard of this approach (burning stuff) ending in joy... Perhaps what you'd like is a one line comment to be prepended to each spec file pointing to spec best/good practice? I'd nominate someone's(;) ) 'One expectation per example' page: http://rubyurl.com/2jw For example: # Visit the following page for an excellent illustration of how to specify code: # http://rubyurl.com/2jw Or, you might prefer that any newbie sees that for each method there are multiple 'it's' prepared? Or maybe the template pending text should read: "should specify one expectation per example" Given these are just clutter things for some expert who is extending existing code using a BDD approach, and they just want a skeleton of 'what's in there', you might ask for an '-e'xpert switch that turns these defaults off. Would that advance anything? My 2c. > FWIW, > David > > > Comments welcome (and please be kind about the > > code -- I know it needs refactoring :). > > > > svn: > > > > http://svn.calicowebdev.com/rspec_todo/trunk > > > > Excerpt from the readme: > > > > Usage is: > > > > ruby spec_todo.rb > > > > Options are: > > > > -m -- Wrap each file's spec in a module > > > > -u -- Use "it" with a block and a pending method rather than a "it" > > > > > > So, for example, I might use it as follows: > > > > ruby spec_todo.rb app/models/* app/controllers/* > > > > Here is a brief example of the output of this tool: > > > > > > #------------------------------------------------------------ > > # File: app/controllers/contact_controller_spec.rb > > #------------------------------------------------------------ > > > > require File.dirname(__FILE__) + '/../spec_helper' > > > > describe "A ContactController" do > > it "should do something sensible with index." > > it "should do something sensible with thank_you." > > end > > > > _______________________________________________ > > 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 farleyknight at gmail.com Mon Sep 17 02:55:30 2007 From: farleyknight at gmail.com (Farley Knight) Date: Sun, 16 Sep 2007 23:55:30 -0700 Subject: [rspec-users] [ANN] rspec_todo -- spec'ing backwards In-Reply-To: <389c43e40709162330w4e6fd5b1x2008522b9749ca3@mail.gmail.com> References: <69A0385A-ACEB-438D-9553-90F26F3C919B@gmail.com> <57c63afe0709161204q42fd12adsd02ee15d6d540740@mail.gmail.com> <389c43e40709162330w4e6fd5b1x2008522b9749ca3@mail.gmail.com> Message-ID: On 9/16/07, Mark Van De Vyver wrote: > > Hi, > On 9/17/07, David Chelimsky wrote: > > On 9/16/07, s.ross wrote: > > > While the spirit of BDD is to spec first and code second, many of us > > > have legacy code. Worse, some of us have legacy code without very > > > good coverage. Recognizing that *I* have such code, I created a > > > script that grinds through your .rb files and creates placeholder > > > specs for each public method. > > > > > > While it is more sensible to spec behavior of code function than of > > > individual methods, this tool can help jump start a transition to > > > that wonderful place. > > > > Hi Steve, > > > > There are tools that will do this for you on java projects and in > > nearly every case that I've seen them used, the result has been 100 > > line test methods, one per object method, that take the object through > > multiple states, become impossible to understand, and often just get > > commented out. > > > > Worse, even though you sell it as a tool for dealing with legacy code > > (code without tests), it will end up becoming the tool people use and, > > even worse than that, they'll think it's BDD because it creates specs > > and not tests. > > > > I beg you (I'm on my knees as I'm writing this) to throw this > > manuscript in the fire now! > > Hmm, I've never heard of this approach (burning stuff) ending in joy... > Perhaps what you'd like is a one line comment to be prepended to each > spec file pointing to spec best/good practice? > I'd nominate someone's(;) ) 'One expectation per example' page: > http://rubyurl.com/2jw > For example: > # Visit the following page for an excellent illustration of how to specify > code: > # http://rubyurl.com/2jw > > Or, you might prefer that any newbie sees that for each method there > are multiple 'it's' prepared? Or maybe the template pending text > should read: > "should specify one expectation per example" > > Given these are just clutter things for some expert who is extending > existing code using a BDD approach, and they just want a skeleton of > 'what's in there', you might ask for an '-e'xpert switch that turns > these defaults off. > > Would that advance anything? > > My 2c. Hey, Just joined the list less than an hour ago, but I've been using RSpec consistently since May. This looks like an interesting topic, and thought I'd chime in. I'm currently working with a crapload of legacy code. But it's not in Ruby. It's in Visual Basic. Not quite the same issue, but similar in some ways. For the most part, I'm completely ignoring all the old code. The business logic, the part of the code that actually matters, is what I try to fish out, and run tests against. If that legacy code is just presentation/controller/database logic, don't loose sleep over it. But don't take my word for it. Here's a few other opinions: http://www.slideshare.net/rabble/testing-legacy-rails-apps/ Not sure who this guy is, but I guess this was presented at RailsConf '07. He suggests just testing when bugs are found, or when refactoring needs to be done. Otherwise, you might waste your time. http://gilesbowkett.blogspot.com/2007/08/getting-legacy-code-under-test.html My boy Giles Bowkett has a completed opposite take: Do a manual "heckle" on all that legacy code, and find out what's necessary and what's not. I probably wouldn't bother doing this by hand, but if you want something more solid that just fishing out bugs, I'd suppose this would work. -Rob > FWIW, > > David > > > > > Comments welcome (and please be kind about the > > > code -- I know it needs refactoring :). > > > > > > svn: > > > > > > http://svn.calicowebdev.com/rspec_todo/trunk > > > > > > Excerpt from the readme: > > > > > > Usage is: > > > > > > ruby spec_todo.rb > > > > > > Options are: > > > > > > -m -- Wrap each file's spec in a module > > > > > > -u -- Use "it" with a block and a pending method rather than a "it" > > > > > > > > > So, for example, I might use it as follows: > > > > > > ruby spec_todo.rb app/models/* app/controllers/* > > > > > > Here is a brief example of the output of this tool: > > > > > > > > > #------------------------------------------------------------ > > > # File: app/controllers/contact_controller_spec.rb > > > #------------------------------------------------------------ > > > > > > require File.dirname(__FILE__) + '/../spec_helper' > > > > > > describe "A ContactController" do > > > it "should do something sensible with index." > > > it "should do something sensible with thank_you." > > > end > > > > > > _______________________________________________ > > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070916/44d95c8a/attachment-0001.html From bryan at osesm.com Mon Sep 17 06:05:49 2007 From: bryan at osesm.com (Bryan Liles) Date: Mon, 17 Sep 2007 06:05:49 -0400 Subject: [rspec-users] how do I get the beautiful html rspec results in textmate? In-Reply-To: References: Message-ID: <1190023549.12239.0.camel@haiserver.Belkin> On Sun, 2007-09-16 at 21:43 -0400, Andrew WC Brown wrote: > I'm going through PeepCode RSpec Basics and he gets a beautiful rspec > results page in html when he presses a hotkey in TextMate. > I would guess it's along the lines of Apple + R but I don't get the > same results and I'm using the same bundle. If you are using the bundle from trunk, you won't get this unless you set the model to RSpec. The behaviour has chanaged recently. From lehrgole at gmail.com Mon Sep 17 10:28:43 2007 From: lehrgole at gmail.com (Sascha Lehrgole) Date: Mon, 17 Sep 2007 16:28:43 +0200 Subject: [rspec-users] how do I get the beautiful html rspec results in textmate? In-Reply-To: <5C3F9157-D46D-402F-BC71-845332395304@railsnewbie.com> References: <5C3F9157-D46D-402F-BC71-845332395304@railsnewbie.com> Message-ID: <68f658150709170728p11afc4e1v8bbccde67544d714@mail.gmail.com> On 9/17/07, Scott Taylor wrote: > Works for me - through Bundles => RSpec => "Run Behaviour > Descriptions in Selected Files", although I'm using the rspec Bundle > checked out from trunk/. I use command+D (Run Behaviour Description). This works even if no file is selected in the Project Drawer. But i don't know if I'm using the latest trunk version (perhaps one week old). Sascha From peter.boling at gmail.com Mon Sep 17 10:45:59 2007 From: peter.boling at gmail.com (peter.boling) Date: Mon, 17 Sep 2007 07:45:59 -0700 (PDT) Subject: [rspec-users] Authenticating before tests In-Reply-To: References: Message-ID: <12737465.post@talk.nabble.com> Luke Galea-4 wrote: > > Could someone point me in the right direction? > > I thought the simplest way would be to either call the login action > from my other tests before(:all), but I can't seem to find how to > call another controller from within the spec for a different > controller. (Results in @controller is nil). > This is what we do. I realize that according to the another poster this is the wrong way, but it is the best way we've found for use with Goldberg. def goldbergAuthAdmin() get 'goldberg/auth/login' #Goldberg::AuthController.set_user(session, Goldberg::User.find_by_name(:first, "admin").id) #Our Admin user has id 2. Goldberg::AuthController.set_user(session,2) end BTW, another important step is bootstrapping goldberg into your test database... To facilitate this we added two methods to the GoldbergMigration model: def self.clear_for_class(klass, dest) filename = "#{dest}/#{klass.to_s.sub(/^Goldberg::/, '')}.yml" records = klass.delete_all end def self.clear_bootstrap self.goldberg_classes.each do |klass| self.clear_for_class klass, "#{File.dirname(__FILE__)}/../db" end end Then add this to spec_helper.rb, or your own included spec_helper def goldbergReload() GoldbergMigration.clear_bootstrap GoldbergMigration.load_bootstrap end Then call this from a before(:all) in the first describe of each rspec needing goldberg. Of course you have to have dumped your goldberg bootstrap from dev/production first (You do this in the console: "GoldbergMigration.dump_bootstrap" to save all goldberg settings, controller/action perms, users roles, etc to some yaml files). Hope that helps! Peter Boling Sagebit, LLC -- View this message in context: http://www.nabble.com/Authenticating-before-tests-tf4435346.html#a12737465 Sent from the rspec-users mailing list archive at Nabble.com. From cwdinfo at gmail.com Mon Sep 17 13:12:02 2007 From: cwdinfo at gmail.com (s.ross) Date: Mon, 17 Sep 2007 10:12:02 -0700 Subject: [rspec-users] [ANN] rspec_todo -- spec'ing backwards In-Reply-To: References: <69A0385A-ACEB-438D-9553-90F26F3C919B@gmail.com> <57c63afe0709161204q42fd12adsd02ee15d6d540740@mail.gmail.com> <389c43e40709162330w4e6fd5b1x2008522b9749ca3@mail.gmail.com> Message-ID: <9319A6BF-61E8-48B4-9EA0-C8D804B27A56@gmail.com> David-- > Worse, even though you sell it as a tool for dealing with legacy code > > (code without tests), it will end up becoming the tool people use I think this is the part that is of the most concern. That people will substitute a tool for good judgment. That should not reflect poorly on BDD or rSpec. It just is what it is. ZenTest has an analogous facility and I don't think it does a particularly better job of pulling out stuff to test, nor does it (IMO) decrease the value or legitimacy of TDD or ZenTest. Whoever wants to use it does, and others ignore it. Reading the posts on this list, it seems to me that most posters have grokked the BDD idea and would be writing their examples first and describing behaviors. Most, if not all, will spot where their specs don't align with methods, but rather with a combination of method invocations. Rcov is, of course, an invaluable tool for discovering which lines of code simply haven't been run. But, as with all tools, Rcov only gives you the feedback on whether the code was run, not whether your example made sense or whether multiple branches were exercised. My goal -- and it's worked for me -- was to find a way to break the inertia of having no specs (clients with legacy code that appears to work aren't always keen to pay for writing specs) and make me puzzle out which things make sense to spec as behaviors and which are really only helpers (and thus candidates to move into private visibility). I'm not planning to dump much more time into this tool unless there is a compelling reason to do so, but it's another arrow (perhaps a bent one :) in the quiver. --steve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070917/731294b8/attachment.html From areed at relocationcentral.com Mon Sep 17 15:14:20 2007 From: areed at relocationcentral.com (Adam Reed) Date: Mon, 17 Sep 2007 14:14:20 -0500 Subject: [rspec-users] Specifying spec and output format inline? Message-ID: <36B5DBA88E027F47812ED877C6A978D801372F26@rc-mail.relocationcentral.com> Howdy from Austin, TX. I'm new to rspec, and am currently using it with the Watir testing library for web testing. I'm moving along at an ok pace so far, but I had a question. I just realized I could require 'spec' and forego running scripts from the command line. However, this limits me in my output formats. Is there a way that I can specify which format to use and where to save it inside the script? I've included the full script below. Thanks, Adam $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__ #set the local dir path require 'watir' require 'spec' describe "Project name" do before(:all) do @browser = Watir::IE.new @browser.goto "http://localhost:8080/admin_frnPkg_add.html " end #begin ## Basic page validation it "should have the logo" do @browser.image(:src, /cp_logo.gif/).should_not be_nil end #logo it "should have login/logout text" do login = @browser.table(:index, 1)[2][1].text login.should =~ (/Log/) end #login/logout after(:all) do @browser.close end #after end #Project name -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070917/a4e9ec95/attachment.html From aslak.hellesoy at gmail.com Mon Sep 17 17:02:13 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 17 Sep 2007 23:02:13 +0200 Subject: [rspec-users] "rake spec:doc" returns NO NAME (due to --dry-run) for each specify block In-Reply-To: <79a30c430709161918k123cfb5am3c8a85e15ce5ba69@mail.gmail.com> References: <79a30c430709160219t4716b81s7b05c1e77faaccb5@mail.gmail.com> <8d961d900709160352u6b859901sfd925dcc3e352cea@mail.gmail.com> <79a30c430709161918k123cfb5am3c8a85e15ce5ba69@mail.gmail.com> Message-ID: <8d961d900709171402m65fac814jcfad685e2719edbb@mail.gmail.com> On 9/17/07, Christopher D. Pratt wrote: > Thanks for all the responses. Unfortunately, I apparently just like being > difficult. > > Tom: I installed the new version of rspec on a fresh app, so the first run > of script/generate rspec was from the trunk version ... good idea though, > because it sounds like something I would have done > > ----- > > David: all of my specify blocks have the string names on them, so that > doesn't seem like the problem. I also tried running the two commands you > provided but both returned the following errors: > > $ rake spec --format specdoc > rake aborted! > No Rakefile found (looking for: ormat) > /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1934:in > `raw_load_rakefile' > (See full trace by running task with --trace) > > $ rake spec -fs > rake aborted! > No Rakefile found (looking for: s) > /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1934:in > `raw_load_rakefile' > (See full trace by running task with --trace) > > Is there some way I can turn off dry run for spec:doc? > > -------- > > Aslak: I'm not relying on auto-generated names. Although I definitely agree > that spec:doc is acting as if I were > > ------- > > Any other ideas? ;) > Help us reproduce what you see > Thanks, > > Chris Pratt > > > > > On 9/16/07, aslak hellesoy wrote: > > This happens if you have it blocks with no name. RSpec tries to > > generate names based on the code inside, but with dry run it isn't > > executed, so it can't. > > > > But maybe you don't have empty it blocks? I'm just guessing here... > > > > Aslak > > > > On 9/16/07, Christopher D. Pratt wrote: > > > I went ahead and moved to the trunk versions of RSpec and Spec:Rails > because > > > I wanted to try out the new Story Runner feature. However, when I tried > to > > > do "rake spec:doc", I got the following: > > > > > > AccountController > > > - NO NAME (Because of --dry-run) > > > > > > AccountHelper > > > - NO NAME (Because of --dry-run) > > > > > > User (in general) > > > - NO NAME (Because of --dry-run) > > > - NO NAME (Because of --dry-run) > > > - NO NAME (Because of --dry-run) > > > - NO NAME (Because of --dry-run) > > > - NO NAME (Because of --dry-run) > > > - NO NAME (Because of --dry-run) > > > > > > I emptied everything out of my spec.opts file just to make sure it > wasn't > > > some setting there causing problems, but that still had no effect. I > haven't > > > submitted this as a bug yet because I'm still holding out the > possibility > > > that I'm simply doing something wrong. > > > > > > Thanks, > > > > > > Chris Pratt > > > > > > _______________________________________________ > > > 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 > From dchelimsky at gmail.com Tue Sep 18 05:32:54 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 18 Sep 2007 11:32:54 +0200 Subject: [rspec-users] "rake spec:doc" returns NO NAME (due to --dry-run) for each specify block In-Reply-To: <79a30c430709161918k123cfb5am3c8a85e15ce5ba69@mail.gmail.com> References: <79a30c430709160219t4716b81s7b05c1e77faaccb5@mail.gmail.com> <8d961d900709160352u6b859901sfd925dcc3e352cea@mail.gmail.com> <79a30c430709161918k123cfb5am3c8a85e15ce5ba69@mail.gmail.com> Message-ID: <57c63afe0709180232q24a69049n3fc4b2935f5095e4@mail.gmail.com> On 9/17/07, Christopher D. Pratt wrote: > Thanks for all the responses. Unfortunately, I apparently just like being > difficult. > > Tom: I installed the new version of rspec on a fresh app, so the first run > of script/generate rspec was from the trunk version ... good idea though, > because it sounds like something I would have done > > ----- > > David: all of my specify blocks have the string names on them, so that > doesn't seem like the problem. I also tried running the two commands you > provided but both returned the following errors: > > $ rake spec --format specdoc > rake aborted! > No Rakefile found (looking for: ormat) > /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1934:in > `raw_load_rakefile' > (See full trace by running task with --trace) > > $ rake spec -fs > rake aborted! > No Rakefile found (looking for: s) > /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1934:in > `raw_load_rakefile' > (See full trace by running task with --trace) Sorry - wrong commands. Try this (assumes a rails app): script/spec spec -fs > Is there some way I can turn off dry run for spec:doc? spec:doc == dry run So probably not :) Cheers, David > > -------- > > Aslak: I'm not relying on auto-generated names. Although I definitely agree > that spec:doc is acting as if I were > > ------- > > Any other ideas? ;) > > Thanks, > > Chris Pratt > > > > > On 9/16/07, aslak hellesoy wrote: > > This happens if you have it blocks with no name. RSpec tries to > > generate names based on the code inside, but with dry run it isn't > > executed, so it can't. > > > > But maybe you don't have empty it blocks? I'm just guessing here... > > > > Aslak > > > > On 9/16/07, Christopher D. Pratt wrote: > > > I went ahead and moved to the trunk versions of RSpec and Spec:Rails > because > > > I wanted to try out the new Story Runner feature. However, when I tried > to > > > do "rake spec:doc", I got the following: > > > > > > AccountController > > > - NO NAME (Because of --dry-run) > > > > > > AccountHelper > > > - NO NAME (Because of --dry-run) > > > > > > User (in general) > > > - NO NAME (Because of --dry-run) > > > - NO NAME (Because of --dry-run) > > > - NO NAME (Because of --dry-run) > > > - NO NAME (Because of --dry-run) > > > - NO NAME (Because of --dry-run) > > > - NO NAME (Because of --dry-run) > > > > > > I emptied everything out of my spec.opts file just to make sure it > wasn't > > > some setting there causing problems, but that still had no effect. I > haven't > > > submitted this as a bug yet because I'm still holding out the > possibility > > > that I'm simply doing something wrong. > > > > > > Thanks, > > > > > > Chris Pratt > > > > > > _______________________________________________ > > > 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 > From dchelimsky at gmail.com Tue Sep 18 05:41:30 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 18 Sep 2007 11:41:30 +0200 Subject: [rspec-users] [ANN] rspec_todo -- spec'ing backwards In-Reply-To: <9319A6BF-61E8-48B4-9EA0-C8D804B27A56@gmail.com> References: <69A0385A-ACEB-438D-9553-90F26F3C919B@gmail.com> <57c63afe0709161204q42fd12adsd02ee15d6d540740@mail.gmail.com> <389c43e40709162330w4e6fd5b1x2008522b9749ca3@mail.gmail.com> <9319A6BF-61E8-48B4-9EA0-C8D804B27A56@gmail.com> Message-ID: <57c63afe0709180241ibe2bf9cmfec38c84c6dc76c8@mail.gmail.com> On 9/17/07, s.ross wrote: > David-- > > Worse, even though you sell it as a tool for dealing with legacy code > > (code without tests), it will end up becoming the tool people use > I think this is the part that is of the most concern. That people will > substitute a tool for good judgment. That should not reflect poorly on BDD > or rSpec. It just is what it is. ZenTest has an analogous facility and I > don't think it does a particularly better job of pulling out stuff to test, > nor does it (IMO) decrease the value or legitimacy of TDD or ZenTest. > Whoever wants to use it does, and others ignore it. > > Reading the posts on this list, it seems to me that most posters have > grokked the BDD idea and would be writing their examples first and > describing behaviors. Most, if not all, will spot where their specs don't > align with methods, but rather with a combination of method invocations. > Rcov is, of course, an invaluable tool for discovering which lines of code > simply haven't been run. But, as with all tools, Rcov only gives you the > feedback on whether the code was run, not whether your example made sense or > whether multiple branches were exercised. > > My goal -- and it's worked for me -- was to find a way to break the inertia > of having no specs (clients with legacy code that appears to work aren't > always keen to pay for writing specs) and make me puzzle out which things > make sense to spec as behaviors and which are really only helpers (and thus > candidates to move into private visibility). I tend to approach the whole legacy thing (any code w/ no tests) from the view espoused by Michael Feathers in his book Working Effectively with Legacy Code: when you want to add a feature or change behaviour, you discover where you want to make the change, analyze the parts of the code it will impact, and add characterization tests for those areas only. This way you're always working on stuff that has immediate value and , little by little, you move towards a very well covered system. As you suggest, no client wants to pay for testing stuff that they see as already working - but certainly they don't you want you to break that stuff either. Cheers, David > I'm not planning to dump much more time into this tool unless there is a > compelling reason to do so, but it's another arrow (perhaps a bent one :) in > the quiver. > > --steve > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From davidj503 at gmail.com Tue Sep 18 09:23:31 2007 From: davidj503 at gmail.com (David James) Date: Tue, 18 Sep 2007 09:23:31 -0400 Subject: [rspec-users] How far to go with ActiveRecord unit tests without hitting the database? In-Reply-To: <4DBFAF1F-50F0-4CFC-8BCB-81CA2B628D0C@railsnewbie.com> References: <59b5d4330709152220t2283ed90wc7354bacbe921a76@mail.gmail.com> <4DBFAF1F-50F0-4CFC-8BCB-81CA2B628D0C@railsnewbie.com> Message-ID: <59b5d4330709180623i6eeb6165lf5d33c7c63d0886c@mail.gmail.com> > > "But otherwise, what exactly are you testing?" > That's a great point. I don't want to be specing Rails if it is not easily separable for testing already. In theory, I would like to have true unit tests for my models. However, in practice, some of my models are coupled to some degree. Generally speaking, I prefer not to mock/stub Rails internals to test my app. I don't find mocking/stubbing *my* code -- that is fine with me. But the internals of Rails are *not* what I'm trying to test. In particular, I found that mocking/stubbing with has_many :through was far from simple. I fired up ruby-debug (highly recommended!) and everything, but realized it was too much effort and too little time. In this sense, my experience is probably similar to Scott's (above post). My Goal model, for example, checks to see how many Contributions it has. It uses a has_many :through (hmt) association. Despite the helpful words of some posters in this thread, I couldn't find a way to effectively spec the hmt association. By the time I had stubbed out enough to make it a true unit test, I was no longer testing what I wanted to test -- namely, that the association itself. Maybe this was a wake up call that there was not point in trying to test that at a unit level? In any case, I've got some conditional logic that connects with the association, so I definitely need to test that, at least. In the end, I just tested the "interaction" between models. In this folder, I test how models in my app work together. I didn't think these specs fit under 'model' because they are testing more than one model. So I put them in a new directory called 'model_integration' folder under the 'spec' directory. I came up with this name on my own intuition, and I can't blame anyone else if this is a bad idea. I wasn't sure if 'model_interaction' would have been a better name, but from what I gather, 'interaction' is a special term when it comes to testing. Suggestions? -DJ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070918/43513278/attachment.html From areed at relocationcentral.com Tue Sep 18 11:20:15 2007 From: areed at relocationcentral.com (Adam Reed) Date: Tue, 18 Sep 2007 10:20:15 -0500 Subject: [rspec-users] FW: Specifying spec and output format inline? Message-ID: <36B5DBA88E027F47812ED877C6A978D801372F29@rc-mail.relocationcentral.com> Anyone have any advice on this one? Thanks, Adam ________________________________ From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Adam Reed Sent: Monday, September 17, 2007 2:14 PM To: rspec-users at rubyforge.org Subject: [rspec-users] Specifying spec and output format inline? Howdy from Austin, TX. I'm new to rspec, and am currently using it with the Watir testing library for web testing. I'm moving along at an ok pace so far, but I had a question. I just realized I could require 'spec' and forego running scripts from the command line. However, this limits me in my output formats. Is there a way that I can specify which format to use and where to save it inside the script? I've included the full script below. Thanks, Adam $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__ #set the local dir path require 'watir' require 'spec' describe "Project name" do before(:all) do @browser = Watir::IE.new @browser.goto "http://localhost:8080/admin_frnPkg_add.html " end #begin ## Basic page validation it "should have the logo" do @browser.image(:src, /cp_logo.gif/).should_not be_nil end #logo it "should have login/logout text" do login = @browser.table(:index, 1)[2][1].text login.should =~ (/Log/) end #login/logout after(:all) do @browser.close end #after end #Project name -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070918/413e4fd4/attachment.html -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ATT2470971.txt Url: http://rubyforge.org/pipermail/rspec-users/attachments/20070918/413e4fd4/attachment.txt From dchelimsky at gmail.com Tue Sep 18 11:33:55 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 18 Sep 2007 17:33:55 +0200 Subject: [rspec-users] FW: Specifying spec and output format inline? In-Reply-To: <36B5DBA88E027F47812ED877C6A978D801372F29@rc-mail.relocationcentral.com> References: <36B5DBA88E027F47812ED877C6A978D801372F29@rc-mail.relocationcentral.com> Message-ID: <57c63afe0709180833v27bbe675h2a9e4ea06b2e41fa@mail.gmail.com> On 9/18/07, Adam Reed wrote: > > > Anyone have any advice on this one? > > Thanks, > Adam > > ________________________________ > From: rspec-users-bounces at rubyforge.org > [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of > Adam Reed > Sent: Monday, September 17, 2007 2:14 PM > To: rspec-users at rubyforge.org > Subject: [rspec-users] Specifying spec and output format inline? > > > > Howdy from Austin, TX. > > I'm new to rspec, and am currently using it with the Watir testing library > for web testing. I'm moving along at an ok pace so far, but I had a > question. > > I just realized I could require 'spec' and forego running scripts from the > command line. However, this limits me in my output formats. Is there a way > that I can specify which format to use and where to save it inside the > script? It sort of depends - how do you plan to run them? > > I've included the full script below. > > Thanks, > Adam > > $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__ > #set the local dir path > > require 'watir' > require 'spec' > > describe "Project name" do > before(:all) do > @browser = Watir::IE.new > @browser.goto > "http://localhost:8080/admin_frnPkg_add.html" > end #begin > > ## Basic page validation > it "should have the logo" do > @browser.image(:src, /cp_logo.gif/).should_not be_nil > end #logo > > it "should have login/logout text" do > login = @browser.table(:index, 1)[2][1].text > login.should =~ (/Log/) > end #login/logout > > after(:all) do > @browser.close > end #after > end #Project name > _______________________________________________ > 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 areed at relocationcentral.com Tue Sep 18 14:21:23 2007 From: areed at relocationcentral.com (Adam Reed) Date: Tue, 18 Sep 2007 13:21:23 -0500 Subject: [rspec-users] FW: Specifying spec and output format inline? In-Reply-To: <57c63afe0709180833v27bbe675h2a9e4ea06b2e41fa@mail.gmail.com> References: <36B5DBA88E027F47812ED877C6A978D801372F29@rc-mail.relocationcentral.com> <57c63afe0709180833v27bbe675h2a9e4ea06b2e41fa@mail.gmail.com> Message-ID: <36B5DBA88E027F47812ED877C6A978D801372F2A@rc-mail.relocationcentral.com> I run my scripts from a windows environment and execute them manually in SciTE with F5. I also have a Rails app that runs them from the web via a batch file on the server, but I can easily change this batch to include the parameters. So, I'm looking for some declaration that can be included in the spec file itself, sort of like the require 'spec' statement. Thanks, Adam -----Original Message----- From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of David Chelimsky Sent: Tuesday, September 18, 2007 10:34 AM To: rspec-users Subject: Re: [rspec-users] FW: Specifying spec and output format inline? On 9/18/07, Adam Reed wrote: > > > Anyone have any advice on this one? > > Thanks, > Adam > > ________________________________ > From: rspec-users-bounces at rubyforge.org > [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Adam Reed > Sent: Monday, September 17, 2007 2:14 PM > To: rspec-users at rubyforge.org > Subject: [rspec-users] Specifying spec and output format inline? > > > > Howdy from Austin, TX. > > I'm new to rspec, and am currently using it with the Watir testing > library for web testing. I'm moving along at an ok pace so far, but I > had a question. > > I just realized I could require 'spec' and forego running scripts from > the command line. However, this limits me in my output formats. Is > there a way that I can specify which format to use and where to save > it inside the script? It sort of depends - how do you plan to run them? > > I've included the full script below. > > Thanks, > Adam > > $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__ > #set the local dir path > > require 'watir' > require 'spec' > > describe "Project name" do > before(:all) do > @browser = Watir::IE.new > @browser.goto > "http://localhost:8080/admin_frnPkg_add.html" > end #begin > > ## Basic page validation > it "should have the logo" do > @browser.image(:src, /cp_logo.gif/).should_not be_nil > end #logo > > it "should have login/logout text" do > login = @browser.table(:index, 1)[2][1].text > login.should =~ (/Log/) > end #login/logout > > after(:all) do > @browser.close > end #after > end #Project name > _______________________________________________ > 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 From mailing_lists at railsnewbie.com Wed Sep 19 10:39:51 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 19 Sep 2007 10:39:51 -0400 Subject: [rspec-users] [ANN] rspec_todo -- spec'ing backwards In-Reply-To: <57c63afe0709180241ibe2bf9cmfec38c84c6dc76c8@mail.gmail.com> References: <69A0385A-ACEB-438D-9553-90F26F3C919B@gmail.com> <57c63afe0709161204q42fd12adsd02ee15d6d540740@mail.gmail.com> <389c43e40709162330w4e6fd5b1x2008522b9749ca3@mail.gmail.com> <9319A6BF-61E8-48B4-9EA0-C8D804B27A56@gmail.com> <57c63afe0709180241ibe2bf9cmfec38c84c6dc76c8@mail.gmail.com> Message-ID: <17BF6C98-C21F-4D3D-95EF-A91A49CF7C0E@railsnewbie.com> > > I tend to approach the whole legacy thing (any code w/ no tests) from > the view espoused by Michael Feathers in his book Working Effectively > with Legacy Code: when you want to add a feature or change behaviour, > you discover where you want to make the change, analyze the parts of > the code it will impact, and add characterization tests for those > areas only. This way you're always working on stuff that has immediate > value and , little by little, you move towards a very well covered > system. > > As you suggest, no client wants to pay for testing stuff that they see > as already working - but certainly they don't you want you to break > that stuff either. > > Cheers, > David +1 => This is exactly how I've been approaching it with a 10,000 line rails app with virtually no tests. Scott From jim at freeze.org Wed Sep 19 11:54:11 2007 From: jim at freeze.org (Jim Freeze) Date: Wed, 19 Sep 2007 10:54:11 -0500 Subject: [rspec-users] Zentest and rspec Message-ID: <5cd596d60709190854o5ae00558t45bc563abd723c18@mail.gmail.com> Hi guys I'm new to rspec and was wondering if there is a quick setup to get it to work with autotest, sans rails. Thanks -- Jim Freeze -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070919/f7eecd9e/attachment.html From lancecarlson at gmail.com Wed Sep 19 11:55:28 2007 From: lancecarlson at gmail.com (Lance Carlson) Date: Wed, 19 Sep 2007 11:55:28 -0400 Subject: [rspec-users] Zentest and rspec In-Reply-To: <5cd596d60709190854o5ae00558t45bc563abd723c18@mail.gmail.com> References: <5cd596d60709190854o5ae00558t45bc563abd723c18@mail.gmail.com> Message-ID: <49f64a900709190855o16d459cas17d4eefb52916b25@mail.gmail.com> http://grasprubyonrails.com/2007/9/17/rspec-and-autotest read the comment I posted too. Comment on it if you have any problems. On 9/19/07, Jim Freeze wrote: > Hi guys > > I'm new to rspec and was wondering if there is a quick setup to get it to > work with autotest, sans rails. > > Thanks > > > -- > Jim Freeze > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jeff at jwhitmire.com Wed Sep 19 12:51:41 2007 From: jeff at jwhitmire.com (Jeff Whitmire) Date: Wed, 19 Sep 2007 12:51:41 -0400 Subject: [rspec-users] Zentest and rspec In-Reply-To: <49f64a900709190855o16d459cas17d4eefb52916b25@mail.gmail.com> References: <5cd596d60709190854o5ae00558t45bc563abd723c18@mail.gmail.com> <49f64a900709190855o16d459cas17d4eefb52916b25@mail.gmail.com> Message-ID: <45c4ccc30709190951y6d61ed86p7fd6909e03ce2413@mail.gmail.com> It's pretty easy to get set up. The reference Lance gave is good. If you want something a little more indepth, I would recommend Geoffrey Grossenbach's rSpec series he has available at http://www.peepcode.com. On 9/19/07, Lance Carlson wrote: > > http://grasprubyonrails.com/2007/9/17/rspec-and-autotest > > read the comment I posted too. Comment on it if you have any problems. > > On 9/19/07, Jim Freeze wrote: > > Hi guys > > > > I'm new to rspec and was wondering if there is a quick setup to get it > to > > work with autotest, sans rails. > > > > Thanks > > > > > > -- > > Jim Freeze > > _______________________________________________ > > 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 > -- Jeff Whitmire Ruby Hackinator Grockit http://grockit.com Think. Learn. Be. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070919/a66f1a98/attachment.html From jim at freeze.org Wed Sep 19 13:13:21 2007 From: jim at freeze.org (Jim Freeze) Date: Wed, 19 Sep 2007 12:13:21 -0500 Subject: [rspec-users] Zentest and rspec In-Reply-To: <49f64a900709190855o16d459cas17d4eefb52916b25@mail.gmail.com> References: <5cd596d60709190854o5ae00558t45bc563abd723c18@mail.gmail.com> <49f64a900709190855o16d459cas17d4eefb52916b25@mail.gmail.com> Message-ID: <5cd596d60709191013t384e0c61h4e1e0b038d279ea6@mail.gmail.com> On 9/19/07, Lance Carlson wrote: > > http://grasprubyonrails.com/2007/9/17/rspec-and-autotest Thanks Lance, but the link seems to be about rspec + autotest + rails. I need sans rails, i.e., rspec + autotest + ruby. Jim read the comment I posted too. Comment on it if you have any problems. > > On 9/19/07, Jim Freeze wrote: > > Hi guys > > > > I'm new to rspec and was wondering if there is a quick setup to get it > to > > work with autotest, sans rails. > > > > Thanks > > > > > > -- > > Jim Freeze > > _______________________________________________ > > 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 > -- Jim Freeze -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070919/eb7cc35f/attachment.html From hughes.james at gmail.com Wed Sep 19 14:14:28 2007 From: hughes.james at gmail.com (James Hughes) Date: Wed, 19 Sep 2007 11:14:28 -0700 Subject: [rspec-users] Strange error in StoryRunner (was: Mocks in StoryRunner) Message-ID: <765a2c230709191114x571d99b1j7c6f7d8ae6d9fa98@mail.gmail.com> Hi, I'm posting this stack trace again because it keeps popping up, seemingly as the 'default error' when something is wrong with my story code; for instance, I got it when I referenced a variable in my 'Given' that I had forgotten to pass into the block. Now I'm getting it when I attempt to post to a login action: And 'user is logged in as', 'jhughes' do |login| post '/login', :login => login, :password => 'secret' end #post calls reset!, leading to the errors on the top of the stack below. This is still happening after updating to the latest rspec trunk about 5 minutes ago. Rails version is 1.2.3. I'm sure this is something wrong with my code/setup, but I thought I'd bring it up again as it seems that StoryRunner should probably die with a more informative error when something's wrong. thanks, James On 9/14/07, Pat Maddox wrote: > On 9/14/07, James Hughes wrote: > > Hi, > > > > I'm trying to get up and running with StoryRunner. I have a story that > > looks something like the following, but the call to mock_model > > produces the exception listed below. Am I just misunderstanding the > > concept? Are mocks not meant to be used in stories like this? Or is > > this a bug? Changing @user to be an actual AR object makes things run > > without error. > > > > ENV["RAILS_ENV"] = "test" > > require File.expand_path(File.dirname(__FILE__) + "/../config/environment") > > require 'spec' > > require 'spec/rails' > > require 'spec/rails/story_adapter' > > > > Story 'Something happens', %{ > > As a user > > I want to do something > > So that something will happen. > > }, :type => RailsStory do > > > > Scenario 'User doing something for first time' do > > Given 'a user' do > > @user = mock_model(User) > > end > > When 'the user makes a request' do > > end > > Then 'something should happen' do > > end > > end > > end > > > > > > Here's the stack trace: > > > > 1 scenarios: 0 succeeded, 1 failed, 0 pending > > > > FAILURES: > > 1) Something happens (User doing something for first time) FAILED > > NoMethodError: You have a nil object when you didn't expect it! > > You might have expected an instance of Array. > > The error occurred while evaluating nil.each > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/integration.rb:519:in > > `open_session' > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/integration.rb:490:in > > `reset!' > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/integration.rb:546:in > > `method_missing' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/matchers.rb:146:in > > `method_missing' > > stories/use_case_story.rb:38:in `a logged-in user' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/simple_step.rb:13:in > > `__send__' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/simple_step.rb:13:in > > `perform' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/world.rb:58:in > > `store_and_call' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/world.rb:68:in > > `Given' > > stories/use_case_story.rb:36 > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb:13:in > > `instance_eval' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb:13:in > > `run' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:48:in > > `run_stories' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:43:in > > `each' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:43:in > > `run_stories' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:39:in > > `each' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:39:in > > `run_stories' > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner.rb:36:in > > `register_exit_hook' > > stories/use_case_story.rb:29 > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > No, you shouldn't be calling mock_model in Story Runner. The whole > point of stories is to exercise the full functionality of your app. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Sep 19 18:49:12 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 20 Sep 2007 00:49:12 +0200 Subject: [rspec-users] Zentest and rspec In-Reply-To: <5cd596d60709191013t384e0c61h4e1e0b038d279ea6@mail.gmail.com> References: <5cd596d60709190854o5ae00558t45bc563abd723c18@mail.gmail.com> <49f64a900709190855o16d459cas17d4eefb52916b25@mail.gmail.com> <5cd596d60709191013t384e0c61h4e1e0b038d279ea6@mail.gmail.com> Message-ID: <57c63afe0709191549n484ba741ud0cbbb967299358a@mail.gmail.com> On 9/19/07, Jim Freeze wrote: > On 9/19/07, Lance Carlson wrote: > > http://grasprubyonrails.com/2007/9/17/rspec-and-autotest > > > Thanks Lance, but the link seems to be about rspec + autotest + rails. > I need sans rails, i.e., rspec + autotest + ruby. Install the rspec and ZenTest gems, create parallel lib and spec directories in your project root and type: autotest In this case, autotest will map files in your lib and spec directories as follows: lib/path/to/some/file.rb spec/path/to/some/file_spec.rb Let us know if you have any other questions. Cheers, David > > Jim > > > > read the comment I posted too. Comment on it if you have any problems. > > > > On 9/19/07, Jim Freeze wrote: > > > Hi guys > > > > > > I'm new to rspec and was wondering if there is a quick setup to get it > to > > > work with autotest, sans rails. > > > > > > Thanks > > > > > > > > > -- > > > Jim Freeze > > > _______________________________________________ > > > 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 > > > > > > -- > Jim Freeze > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From seminlee at gmail.com Sun Sep 16 14:52:25 2007 From: seminlee at gmail.com (Semin Lee) Date: Sun, 16 Sep 2007 19:52:25 +0100 Subject: [rspec-users] "Not Implemented" doesn't show In-Reply-To: References: Message-ID: <46ED7B69.2010907@kaist.ac.kr> Andrew WC Brown wrote: > I'm going through Peepcode's Rspec Basics for an overview. > > He's just doing a simple spec: > > class PeepCode > end > > describe PeepCode do > it "should be awsome" do > end > end > > So running spec spec/simple_spec.rb should produce according to his > screen cast: > 1 example, 0 failures, 1 not implemented > > but I only recieve: > 1 example, 0 failures > > Also spec spec/simple_spec.rb --format will fail > /usr/local/lib/ruby/1.8/optparse.rb:451:in `parse': missing argument: > --format (OptionParser::MissingArgument) > > RSpec 1.0.8 > ZenTest 3.6.1 Don't you have to omit the block, 'do'...'end' when you want them to be not implemented? Or, you can use 'pending' method in the block like this. describe PeepCode do it "should be awesome" end or describe PeepCode do it "should be awesome" do pending("supposed to be pending") end end Cheers, Semin From thinkdiv at googlemail.com Fri Sep 14 04:57:55 2007 From: thinkdiv at googlemail.com (Andreas Wolff) Date: Fri, 14 Sep 2007 10:57:55 +0200 Subject: [rspec-users] Testing nested controller Message-ID: <526df6040709140157s3bcd06f5u43178b13612c05c0@mail.gmail.com> Hey everyone. I really stuck on testing a nested controller. I'm trying to make a request using get and afterwards checking the response by response.should ... My routes.rb looks like this: map.resources :writers do |writers| writers.resources :notes end In my notes_controller_spec.rb def do_get writer_id = 1 note_id = 1 get note_path(writer_id, note_id) end it "should show a note" do do_get response.should be_success end But this always ends in an error message: You have a nil object when you didn't expect it! The error occurred while evaluating nil.rewrite Can anybody help here?? -- by(e) Andreas Wolff From jed.hurt at gmail.com Wed Sep 19 22:17:24 2007 From: jed.hurt at gmail.com (Jed Hurt) Date: Wed, 19 Sep 2007 20:17:24 -0600 Subject: [rspec-users] alias :calling :lambda Message-ID: Sprinkling my examples with 'lambda' has always seemed like a bit of a wart to me. I've gotten into the habit of adding 'alias :calling :lambda' to my spec suites. My examples then look like: calling { Foo }.should raise_error calling { Bar }.should_not raise_error Is there a reason that RSpec core has chosen not to make exception expectations more sugary? From pergesu at gmail.com Wed Sep 19 22:55:49 2007 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 19 Sep 2007 19:55:49 -0700 Subject: [rspec-users] alias :calling :lambda In-Reply-To: References: Message-ID: <810a540e0709191955g19c4100dyba2739e78863d18e@mail.gmail.com> On 9/19/07, Jed Hurt wrote: > Sprinkling my examples with 'lambda' has always seemed like a bit of a > wart to me. I've gotten into the habit of adding 'alias :calling > :lambda' to my spec suites. My examples then look like: > > calling { Foo }.should raise_error > calling { Bar }.should_not raise_error > > Is there a reason that RSpec core has chosen not to make exception > expectations more sugary? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > There's actually a ticket that aliases it to running, I believe. So specs would look like running { Foo }.should raise_error Pat From mailing_lists at railsnewbie.com Wed Sep 19 23:04:52 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 19 Sep 2007 23:04:52 -0400 Subject: [rspec-users] alias :calling :lambda In-Reply-To: References: Message-ID: On Sep 19, 2007, at 10:17 PM, Jed Hurt wrote: > Sprinkling my examples with 'lambda' has always seemed like a bit of a > wart to me. I've gotten into the habit of adding 'alias :calling > :lambda' to my spec suites. My examples then look like: > > calling { Foo }.should raise_error > calling { Bar }.should_not raise_error > > Is there a reason that RSpec core has chosen not to make exception > expectations more sugary? There was a long discussion of this in the tracker + mailing list. Did you not see it (It almost seems coincidental that you ask this question at the current time). Scott From lists-rspec at shopwatch.org Wed Sep 19 23:30:14 2007 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Wed, 19 Sep 2007 23:30:14 -0400 Subject: [rspec-users] alias :calling :lambda In-Reply-To: References: Message-ID: <46F1E946.1070104@shopwatch.org> On 9/19/2007 11:04 PM, Scott Taylor wrote: > On Sep 19, 2007, at 10:17 PM, Jed Hurt wrote: > >> Sprinkling my examples with 'lambda' has always seemed like a bit of a >> wart to me. I've gotten into the habit of adding 'alias :calling >> :lambda' to my spec suites. My examples then look like: >> >> calling { Foo }.should raise_error >> calling { Bar }.should_not raise_error >> >> Is there a reason that RSpec core has chosen not to make exception >> expectations more sugary? > > There was a long discussion of this in the tracker + mailing list. > Did you not see it (It almost seems coincidental that you ask this > question at the current time). Yes, that is *quite* a coincidence, Mr. Jed Hurt - IF that is your real name... Seriously, check out http://rubyforge.org/tracker/index.php?func=detail&aid=13837&group_id=797&atid=3152 Jay From omen.king at gmail.com Thu Sep 20 03:23:01 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Thu, 20 Sep 2007 03:23:01 -0400 Subject: [rspec-users] Getting Started with Story Runner Message-ID: I haven't found any How To's to use story runner and I'm not sure how to get started. Should I be looking for resources on how to use rbehave? How do I generate my first Story? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070920/07a80bc7/attachment.html From ben at benmabey.com Thu Sep 20 03:37:52 2007 From: ben at benmabey.com (Ben Mabey) Date: Thu, 20 Sep 2007 01:37:52 -0600 Subject: [rspec-users] Getting Started with Story Runner In-Reply-To: References: Message-ID: <46F22350.6060209@benmabey.com> Andrew WC Brown wrote: > I haven't found any How To's to use story runner and I'm not sure how > to get started. > Should I be looking for resources on how to use rbehave? > How do I generate my first Story? > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Pat wrote up an awesome tutorial/example: http://evang.eli.st/blog/2007/9/1/user-stories-with-rspec-s-story-runner That should get you started. -Ben From hughes.james at gmail.com Thu Sep 20 09:25:40 2007 From: hughes.james at gmail.com (James Hughes) Date: Thu, 20 Sep 2007 06:25:40 -0700 Subject: [rspec-users] Getting Started with Story Runner In-Reply-To: <46F22350.6060209@benmabey.com> References: <46F22350.6060209@benmabey.com> Message-ID: <765a2c230709200625w43d36a30q7532a3dbf9de75d4@mail.gmail.com> On 9/20/07, Ben Mabey wrote: > Andrew WC Brown wrote: > > I haven't found any How To's to use story runner and I'm not sure how > > to get started. > > Should I be looking for resources on how to use rbehave? > > How do I generate my first Story? > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > Pat wrote up an awesome tutorial/example: > > http://evang.eli.st/blog/2007/9/1/user-stories-with-rspec-s-story-runner > > That should get you started. > This pastie may be of use as well: http://pastie.caboo.se/92472 James From areed at relocationcentral.com Thu Sep 20 09:28:18 2007 From: areed at relocationcentral.com (Adam Reed) Date: Thu, 20 Sep 2007 08:28:18 -0500 Subject: [rspec-users] FW: FW: Specifying spec and output format inline? Message-ID: <36B5DBA88E027F47812ED877C6A978D801372F2E@rc-mail.relocationcentral.com> One more try? I just want the script to save the rspec output to an html file when the script is run. In this case, the script will be run from SciTE using F5, rather than by command line. Is there a way to specify this within the ruby script? ________________________________ From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Adam Reed Sent: Tuesday, September 18, 2007 10:20 AM To: rspec-users at rubyforge.org Subject: [rspec-users] FW: Specifying spec and output format inline? Anyone have any advice on this one? Thanks, Adam ________________________________ From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Adam Reed Sent: Monday, September 17, 2007 2:14 PM To: rspec-users at rubyforge.org Subject: [rspec-users] Specifying spec and output format inline? Howdy from Austin, TX. I'm new to rspec, and am currently using it with the Watir testing library for web testing. I'm moving along at an ok pace so far, but I had a question. I just realized I could require 'spec' and forego running scripts from the command line. However, this limits me in my output formats. Is there a way that I can specify which format to use and where to save it inside the script? I've included the full script below. Thanks, Adam $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__ #set the local dir path require 'watir' require 'spec' describe "Project name" do before(:all) do @browser = Watir::IE.new @browser.goto "http://localhost:8080/admin_frnPkg_add.html " end #begin ## Basic page validation it "should have the logo" do @browser.image(:src, /cp_logo.gif/).should_not be_nil end #logo it "should have login/logout text" do login = @browser.table(:index, 1)[2][1].text login.should =~ (/Log/) end #login/logout after(:all) do @browser.close end #after end #Project name -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070920/6e121174/attachment.html -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ATT2470971.txt Url: http://rubyforge.org/pipermail/rspec-users/attachments/20070920/6e121174/attachment.txt -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ATT03136.txt Url: http://rubyforge.org/pipermail/rspec-users/attachments/20070920/6e121174/attachment-0001.txt From cody at skidmore.us Thu Sep 20 09:49:31 2007 From: cody at skidmore.us (Cody P. Skidmore) Date: Thu, 20 Sep 2007 06:49:31 -0700 (PDT) Subject: [rspec-users] FW: FW: Specifying spec and output format inline? In-Reply-To: <36B5DBA88E027F47812ED877C6A978D801372F2E@rc-mail.relocationcentral.co m> References: <36B5DBA88E027F47812ED877C6A978D801372F2E@rc-mail.relocationcentral.com> Message-ID: <4526.216.167.174.73.1190296171.squirrel@webmail.skidmore.us> Adam Reed wrote: > I just want the script to save the rspec output to an html file when the > script is run. In this case, the script will be run from SciTE using Adam, I don't know what O/S you're using, but I actually output my results to a HTML file stored in the public folder of my sandbox. I don't have my notebook booted up at the moment, but I'll send you a batch script (Windows XP) that shows how I do it. Cody Skidmore From omen.king at gmail.com Thu Sep 20 10:13:47 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Thu, 20 Sep 2007 10:13:47 -0400 Subject: [rspec-users] Getting Started with Story Runner In-Reply-To: <765a2c230709200625w43d36a30q7532a3dbf9de75d4@mail.gmail.com> References: <46F22350.6060209@benmabey.com> <765a2c230709200625w43d36a30q7532a3dbf9de75d4@mail.gmail.com> Message-ID: I'm guessing their isn't a generator for stories yet? ./script/generate story add_person On 9/20/07, James Hughes wrote: > > On 9/20/07, Ben Mabey wrote: > > Andrew WC Brown wrote: > > > I haven't found any How To's to use story runner and I'm not sure how > > > to get started. > > > Should I be looking for resources on how to use rbehave? > > > How do I generate my first Story? > > > > ------------------------------------------------------------------------ > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > Pat wrote up an awesome tutorial/example: > > > > http://evang.eli.st/blog/2007/9/1/user-stories-with-rspec-s-story-runner > > > > That should get you started. > > > > This pastie may be of use as well: > > http://pastie.caboo.se/92472 > > James > _______________________________________________ > 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/20070920/f2ed4363/attachment-0001.html From areed at relocationcentral.com Thu Sep 20 10:18:57 2007 From: areed at relocationcentral.com (Adam Reed) Date: Thu, 20 Sep 2007 09:18:57 -0500 Subject: [rspec-users] FW: FW: Specifying spec and output format inline? In-Reply-To: <4526.216.167.174.73.1190296171.squirrel@webmail.skidmore.us> References: <36B5DBA88E027F47812ED877C6A978D801372F2E@rc-mail.relocationcentral.com> <4526.216.167.174.73.1190296171.squirrel@webmail.skidmore.us> Message-ID: <36B5DBA88E027F47812ED877C6A978D801372F30@rc-mail.relocationcentral.com> Thanks, I appreciate it! I'm using Windows XP. These test scripts will eventually be scheduled to be run automatically through a batch, where I assume I'll be able to use the normal command line functions to direct output, I just wanted to see if there was a way to do that from inside the script itself so I can continue to use SciTE during development, rather than switching to command line each time I want output. Of course, typing that "out loud", it sounds pretty lazy. The command line won't be that much of a hassle... -----Original Message----- From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Cody P. Skidmore Sent: Thursday, September 20, 2007 8:50 AM To: rspec-users Subject: Re: [rspec-users] FW: FW: Specifying spec and output format inline? Adam Reed wrote: > I just want the script to save the rspec output to an html file when > the script is run. In this case, the script will be run from SciTE > using Adam, I don't know what O/S you're using, but I actually output my results to a HTML file stored in the public folder of my sandbox. I don't have my notebook booted up at the moment, but I'll send you a batch script (Windows XP) that shows how I do it. Cody Skidmore _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users From jed.hurt at gmail.com Thu Sep 20 11:49:58 2007 From: jed.hurt at gmail.com (Jed Hurt) Date: Thu, 20 Sep 2007 09:49:58 -0600 Subject: [rspec-users] alias :calling :lambda In-Reply-To: <46F1E946.1070104@shopwatch.org> References: <46F1E946.1070104@shopwatch.org> Message-ID: I missed that one. I had a feeling that such a discussion must have already taken place, so I sent this suggestion with some trepidation. Having read the tracker comments, I empathize with David's and Aslak's sentiments. On 9/19/07, Jay Levitt wrote: > On 9/19/2007 11:04 PM, Scott Taylor wrote: > > On Sep 19, 2007, at 10:17 PM, Jed Hurt wrote: > > > >> Sprinkling my examples with 'lambda' has always seemed like a bit of a > >> wart to me. I've gotten into the habit of adding 'alias :calling > >> :lambda' to my spec suites. My examples then look like: > >> > >> calling { Foo }.should raise_error > >> calling { Bar }.should_not raise_error > >> > >> Is there a reason that RSpec core has chosen not to make exception > >> expectations more sugary? > > > > There was a long discussion of this in the tracker + mailing list. > > Did you not see it (It almost seems coincidental that you ask this > > question at the current time). > > Yes, that is *quite* a coincidence, Mr. Jed Hurt - IF that is your real > name... > > Seriously, check out > > http://rubyforge.org/tracker/index.php?func=detail&aid=13837&group_id=797&atid=3152 > > Jay > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Thu Sep 20 12:09:38 2007 From: ben at benmabey.com (Ben Mabey) Date: Thu, 20 Sep 2007 10:09:38 -0600 Subject: [rspec-users] Getting Started with Story Runner In-Reply-To: References: <46F22350.6060209@benmabey.com> <765a2c230709200625w43d36a30q7532a3dbf9de75d4@mail.gmail.com> Message-ID: <46F29B42.1060407@benmabey.com> Looking in the trunk I couldn't see any generators, for it. Looks like you found yourself a project ;) There is a simple new Story snippet in the textmate bundle in rspec's trunk however. -Ben Andrew WC Brown wrote: > I'm guessing their isn't a generator for stories yet? > > ./script/generate story add_person > > On 9/20/07, *James Hughes* < hughes.james at gmail.com > > wrote: > > On 9/20/07, Ben Mabey < ben at benmabey.com > > wrote: > > Andrew WC Brown wrote: > > > I haven't found any How To's to use story runner and I'm not > sure how > > > to get started. > > > Should I be looking for resources on how to use rbehave? > > > How do I generate my first Story? > > > > ------------------------------------------------------------------------ > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > Pat wrote up an awesome tutorial/example: > > > > > http://evang.eli.st/blog/2007/9/1/user-stories-with-rspec-s-story-runner > > > > That should get you started. > > > > This pastie may be of use as well: > > http://pastie.caboo.se/92472 > > James > _______________________________________________ > 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 hughes.james at gmail.com Thu Sep 20 13:09:07 2007 From: hughes.james at gmail.com (James Hughes) Date: Thu, 20 Sep 2007 10:09:07 -0700 Subject: [rspec-users] Strange error in StoryRunner (was: Mocks in StoryRunner) In-Reply-To: <765a2c230709191114x571d99b1j7c6f7d8ae6d9fa98@mail.gmail.com> References: <765a2c230709191114x571d99b1j7c6f7d8ae6d9fa98@mail.gmail.com> Message-ID: <765a2c230709201009s397ba8cfo3086a2b1483af180@mail.gmail.com> On 9/19/07, James Hughes wrote: > Hi, > I'm posting this stack trace again because it keeps popping up, > seemingly as the 'default error' when something is wrong with my story > code; for instance, I got it when I referenced a variable in my > 'Given' that I had forgotten to pass into the block. > > Now I'm getting it when I attempt to post to a login action: > > And 'user is logged in as', 'jhughes' do |login| > post '/login', :login => login, :password => 'secret' > end > #post calls reset!, leading to the errors on the top of the stack below. > > This is still happening after updating to the latest rspec trunk about > 5 minutes ago. Rails version is 1.2.3. > > I'm sure this is something wrong with my code/setup, but I thought I'd > bring it up again as it seems that StoryRunner should probably die > with a more informative error when something's wrong. > > thanks, > James > > > > On 9/14/07, Pat Maddox wrote: > > On 9/14/07, James Hughes wrote: > > > Hi, > > > > > > I'm trying to get up and running with StoryRunner. I have a story that > > > looks something like the following, but the call to mock_model > > > produces the exception listed below. Am I just misunderstanding the > > > concept? Are mocks not meant to be used in stories like this? Or is > > > this a bug? Changing @user to be an actual AR object makes things run > > > without error. > > > > > > ENV["RAILS_ENV"] = "test" > > > require File.expand_path(File.dirname(__FILE__) + "/../config/environment") > > > require 'spec' > > > require 'spec/rails' > > > require 'spec/rails/story_adapter' > > > > > > Story 'Something happens', %{ > > > As a user > > > I want to do something > > > So that something will happen. > > > }, :type => RailsStory do > > > > > > Scenario 'User doing something for first time' do > > > Given 'a user' do > > > @user = mock_model(User) > > > end > > > When 'the user makes a request' do > > > end > > > Then 'something should happen' do > > > end > > > end > > > end > > > > > > > > > Here's the stack trace: > > > > > > 1 scenarios: 0 succeeded, 1 failed, 0 pending > > > > > > FAILURES: > > > 1) Something happens (User doing something for first time) FAILED > > > NoMethodError: You have a nil object when you didn't expect it! > > > You might have expected an instance of Array. > > > The error occurred while evaluating nil.each > > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/integration.rb:519:in > > > `open_session' > > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/integration.rb:490:in > > > `reset!' > > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/integration.rb:546:in > > > `method_missing' > > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/matchers.rb:146:in > > > `method_missing' > > > stories/use_case_story.rb:38:in `a logged-in user' > > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/simple_step.rb:13:in > > > `__send__' > > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/simple_step.rb:13:in > > > `perform' > > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/world.rb:58:in > > > `store_and_call' > > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/world.rb:68:in > > > `Given' > > > stories/use_case_story.rb:36 > > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb:13:in > > > `instance_eval' > > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb:13:in > > > `run' > > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:48:in > > > `run_stories' > > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:43:in > > > `each' > > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:43:in > > > `run_stories' > > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:39:in > > > `each' > > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:39:in > > > `run_stories' > > > /home/jhughes/dev/rj/csite/config/../vendor/plugins/rspec/lib/spec/story/runner.rb:36:in > > > `register_exit_hook' > > > stories/use_case_story.rb:29 I looked into this a bit more and I think the problem is caused by running the story when there are no fixtures present. If anyone else runs into this, adding "self.fixture_table_names = []" to rspec_on_rails/lib/spec/rails/story_adapter.rb (after the "self.use_transactional_fixtures = true" line) seems to fix the problem. James From jarkko at jlaine.net Thu Sep 20 13:11:48 2007 From: jarkko at jlaine.net (Jarkko Laine) Date: Thu, 20 Sep 2007 20:11:48 +0300 Subject: [rspec-users] Getting Started with Story Runner In-Reply-To: <46F29B42.1060407@benmabey.com> References: <46F22350.6060209@benmabey.com> <765a2c230709200625w43d36a30q7532a3dbf9de75d4@mail.gmail.com> <46F29B42.1060407@benmabey.com> Message-ID: <4679B8B1-599C-48F2-AA07-6F867D35BB14@jlaine.net> On 20.9.2007, at 19.09, Ben Mabey wrote: > Looking in the trunk I couldn't see any generators, for it. Looks > like > you found yourself a project ;) > There is a simple new Story snippet in the textmate bundle in rspec's > trunk however. I just talked about this in Berlin with David. Heading out for dinner and beers now but I might take a stab at it tomorrow. -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi From omen.king at gmail.com Thu Sep 20 14:19:04 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Thu, 20 Sep 2007 14:19:04 -0400 Subject: [rspec-users] Getting Started with Story Runner In-Reply-To: <4679B8B1-599C-48F2-AA07-6F867D35BB14@jlaine.net> References: <46F22350.6060209@benmabey.com> <765a2c230709200625w43d36a30q7532a3dbf9de75d4@mail.gmail.com> <46F29B42.1060407@benmabey.com> <4679B8B1-599C-48F2-AA07-6F867D35BB14@jlaine.net> Message-ID: I wouldn't mind in on that On 9/20/07, Jarkko Laine wrote: > > > On 20.9.2007, at 19.09, Ben Mabey wrote: > > > Looking in the trunk I couldn't see any generators, for it. Looks > > like > > you found yourself a project ;) > > There is a simple new Story snippet in the textmate bundle in rspec's > > trunk however. > > I just talked about this in Berlin with David. Heading out for dinner > and beers now but I might take a stab at it tomorrow. > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Monsterbox Productions putting small businesses on-line 1319 Victoria Avenue East Thunder Bay, Ontario P7C 1C3 Canada Andrew WC Brown web-developer and owner andrew at monsterboxpro.com P: 807-626-9009 F: 807-624-2705 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070920/9a1c0a67/attachment.html From matt at mattmargolis.net Thu Sep 20 22:29:57 2007 From: matt at mattmargolis.net (Matt Margolis) Date: Thu, 20 Sep 2007 21:29:57 -0500 Subject: [rspec-users] Standardize environment between specs containing class defs Message-ID: <46F32CA5.9060607@mattmargolis.net> I have some specs that involve the use of eval and class definitions to test code generation. I want to always start with a clean slate so none of my tests fail or succeed incorrectly due to artifacts left over from previous specs. Example of my situation Spec 1 defines class Fish class Cod < Fish Spec 2 defines class Animal class Cod < Animal In this situation the second spec will fail since Cod was previously defined to be a subclass of Fish and you can not change the superclass of a subclass in ruby without causing an exception. I want the resetting to be as automatic as possible since calling remove_constant on every class my code defines after each spec is a real pain since this situation is going to crop up in lots of different specs and describe blocks. Thank you, Matt Margolis From evan at tiggerpalace.com Fri Sep 21 00:21:26 2007 From: evan at tiggerpalace.com (Evan David Light) Date: Fri, 21 Sep 2007 00:21:26 -0400 Subject: [rspec-users] Getting Started with Story Runner In-Reply-To: References: <46F22350.6060209@benmabey.com> <765a2c230709200625w43d36a30q7532a3dbf9de75d4@mail.gmail.com> Message-ID: There are also a couple of examples buried in the trunk under examples/story/game-of-life/behaviour/stories On Sep 20, 2007, at 10:13 AM, Andrew WC Brown wrote: > I'm guessing their isn't a generator for stories yet? > > ./script/generate story add_person > > On 9/20/07, James Hughes < hughes.james at gmail.com> wrote: > On 9/20/07, Ben Mabey < ben at benmabey.com> wrote: > > Andrew WC Brown wrote: > > > I haven't found any How To's to use story runner and I'm not > sure how > > > to get started. > > > Should I be looking for resources on how to use rbehave? > > > How do I generate my first Story? > > > > ---------------------------------------------------------------------- > -- > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > Pat wrote up an awesome tutorial/example: > > > > http://evang.eli.st/blog/2007/9/1/user-stories-with-rspec-s-story- > runner > > > > That should get you started. > > > > This pastie may be of use as well: > > http://pastie.caboo.se/92472 > > James > _______________________________________________ > 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/20070921/9869bc30/attachment-0001.html From aslak.hellesoy at gmail.com Fri Sep 21 02:53:32 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 21 Sep 2007 08:53:32 +0200 Subject: [rspec-users] Standardize environment between specs containing class defs In-Reply-To: <46F32CA5.9060607@mattmargolis.net> References: <46F32CA5.9060607@mattmargolis.net> Message-ID: <8d961d900709202353k58eb5ex6db6e5cebaaf484a@mail.gmail.com> You can have a global after block in your spec_helper.rb that undefines all such constants. Then you just have to remember to add these constants to some global array whenever you define them. a On 9/21/07, Matt Margolis wrote: > I have some specs that involve the use of eval and class definitions to > test code generation. I want to always start with a clean slate so none > of my tests fail or succeed incorrectly due to artifacts left over from > previous specs. > > Example of my situation > Spec 1 defines > class Fish > class Cod < Fish > Spec 2 defines > class Animal > class Cod < Animal > > In this situation the second spec will fail since Cod was previously > defined to be a subclass of Fish and you can not change the superclass > of a subclass in ruby without causing an exception. > > I want the resetting to be as automatic as possible since calling > remove_constant on every class my code defines after each spec is a real > pain since this situation is going to crop up in lots of different specs > and describe blocks. > > Thank you, > Matt Margolis > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dan at tastapod.com Fri Sep 21 05:42:28 2007 From: dan at tastapod.com (Dan North) Date: Fri, 21 Sep 2007 11:42:28 +0200 Subject: [rspec-users] Standardize environment between specs containing class defs In-Reply-To: <8d961d900709202353k58eb5ex6db6e5cebaaf484a@mail.gmail.com> References: <46F32CA5.9060607@mattmargolis.net> <8d961d900709202353k58eb5ex6db6e5cebaaf484a@mail.gmail.com> Message-ID: <46F39204.5030308@tastapod.com> Although it would be nice (and not too difficult) to have the example runner intercept any class creation (and perhaps other global/constant definitions) and undef them after each example. It certainly seems reasonable to have any defined classes go away after an example. aslak hellesoy wrote: > You can have a global after block in your spec_helper.rb that > undefines all such constants. Then you just have to remember to add > these constants to some global array whenever you define them. > > a > > On 9/21/07, Matt Margolis wrote: > >> I have some specs that involve the use of eval and class definitions to >> test code generation. I want to always start with a clean slate so none >> of my tests fail or succeed incorrectly due to artifacts left over from >> previous specs. >> >> Example of my situation >> Spec 1 defines >> class Fish >> class Cod < Fish >> Spec 2 defines >> class Animal >> class Cod < Animal >> >> In this situation the second spec will fail since Cod was previously >> defined to be a subclass of Fish and you can not change the superclass >> of a subclass in ruby without causing an exception. >> >> I want the resetting to be as automatic as possible since calling >> remove_constant on every class my code defines after each spec is a real >> pain since this situation is going to crop up in lots of different specs >> and describe blocks. >> >> Thank you, >> Matt Margolis >> _______________________________________________ >> 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/20070921/7f9674b4/attachment.html From yrashk at gmail.com Fri Sep 21 09:31:17 2007 From: yrashk at gmail.com (Yurii Rashkovskii) Date: Fri, 21 Sep 2007 16:31:17 +0300 Subject: [rspec-users] given_it Message-ID: Hello, Just decided to check whether I am doing something that makes sense or not. I was thinking about how cool would it be to re-use examples (just like we reuse story scenarios with GivenScenario). I was not sure if this possibility already exists in rspec (and, honestly, was lazy to check), so I have created this helper: def given_it(name) example_definition = behaviour.example_definitions.find{|i| i.description == name } instance_eval(&example_definition.example_block) end so it is possible to write things like it "should do something after another action" do given_it "should successfully do another action" do_something.should be_fine end Is there anything already in rspec that allows me to do the same stuff? Or was it a bad idea at all? Yurii. From lancecarlson at gmail.com Fri Sep 21 14:02:08 2007 From: lancecarlson at gmail.com (Lance Carlson) Date: Fri, 21 Sep 2007 14:02:08 -0400 Subject: [rspec-users] RSpec view spec writing problem (unable to generate url_for in RESTful resource link_to) In-Reply-To: <4f34789a0709100913g3b6c2463hf03f541c58c36eff@mail.gmail.com> References: <4f34789a0709100744h28fbd6dcmedb1dd59747241ed@mail.gmail.com> <57c63afe0709100801x72760bbg61223b36274b6a55@mail.gmail.com> <4f34789a0709100913g3b6c2463hf03f541c58c36eff@mail.gmail.com> Message-ID: <49f64a900709211102p67186b0fn457804700b087538@mail.gmail.com> BTW I know this is old, but did you know you can do this? iink_to a.name, [@customer, @project],,{:class=>"show",:title=>"Show > actor details"} ? I'm having trouble mocking this my view specs right now as it is giving me errors, but it works fine in rails edge. I will report on my discoveries if anyone has figured out how to deal with this new way to call polymorphic path helpers. any takers? My error is as follows: 1) ActionView::TemplateError in 'Label Page should have a link to add a new artist' edit_label_url failed to generate from {:action=>"edit", :controller=>"labels", :id=>#}, expected: {:controller=>"labels", :action=>"edit"}, diff: {:id=>#} On line #3 of app/views/labels/show.rhtml 3: <%= link_to 'Edit', [ @label, :edit ] %>
        On 9/10/07, Scott Sehlhorst wrote: > Thanks very much. I feel like a bit of a fool, now, for the odd error. > > Changing from: > <%= > link_to(a.name,actor_path(@customer, at project),{:class=>"show",:title=>"Show > actor details"}) -%> > To > <%= > link_to(a.name,actor_path(@customer, at project,a),{:class=>"show",:title=>"Show > actor details"}) -%> > > Caused everything to work like a champ. And uncovered an interesting bug. > When not specifying the actor 'a', the link is generated (in the page), but > with id=1. No idea if/when I would have caught that. > > Thanks again David, and all the RSpec'ers out there. > > Also, thanks for the multi-nesting pointer. > > Scott > > > > On 9/10/07, David Chelimsky wrote: > > On 9/10/07, Scott Sehlhorst < scott at tynerblain.com> wrote: > > > Thanks, first, to everyone who's asked and answered questions on this > list, > > > and to the creators of RSpec - it is all very helpful. I've searched > the > > > mailing list, and had a couple 2hr googling sessions that didn't help me > > > find an answer. > > > > > > I've run into a problem getting my first non-trivial view spec to run. > I > > > get an error when trying to generate a link_to() to another resource. > Here > > > is an overview of the situation, then the code: > > > > > > > > > I'm using a restful design > > > I'm using nested (multiply nested) resources > > > I am trying to test a show.rhtml view, that includes links (link_to) to > > > resources managed by another controller > > > The use_case model has a many-to-may through relationship with actors, > and > > > I'm displaying links to the associated actors on the use_case page > > > I can't get the links to generate when running rspec (but it works great > in > > > the app) > > > I am in the early stages of the project, and want to move forward BDD, > but I > > > have some existing code that I need to test before I can start moving > > > forward again. > > > My theories: I need to stub the controller (for the other resource), or > I > > > need to stub something else. > > > > > > Here's the command I'm running to drive RSpec > > > > > > ruby script/spec -f s spec/views > > > > > > Here's the error that I get > > > > > > 1) > > > ActionView::TemplateError in 'UseCase showing a use case should display > the > > > use case identifier' > > > actor_url failed to generate from {:customer_id=>"1", > > > :controller=>"actors", :action=>"show", :project_id=>"1"}, expecte > > > d: {:controller=>"actors", :action=>"show"}, diff: {:customer_id=>"1", > > > :project_id=>"1"} > > > On line #22 of app/views/use_cases/show.rhtml > > > > > > 19:
          > > > 20: <% @primary_actors.each do |a| %> > > > 21:
        • > > > 22: <%= > > > > link_to(a.name,actor_path(@customer, at project),{:class=>"show",:title=>"Show > > > actor details"}) -%> > > > 23: <%= link_to("Remove > > > > assignment",participation_path(@customer, at project, at use_case.participations.find_by > > > _actor_id(a)),{:class=>"delete",:title=>"Remove the > > > assignment of this actor to this use case", :confirm => 'Are you sur > > > e you want to remove this assignment?', :method => :delete})-%> > > > 24:
        • > > > 25: <% end %> > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1273:in > > > `raise_named_route_error' > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1245:in > > > `generate' > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:104:in > > > `rewrite_path' > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:69:in > > > `rewrite' > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:522:in > > > `url_for' > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:27:in > > > `url_for' > > > (eval):19:in `actor_path' > > > #{RAILS_ROOT}/app/views/use_cases/show.rhtml:22:in > > > `_run_rhtml_47app47views47use_cases47show46rhtml' > > > #{RAILS_ROOT}/app/views/use_cases/show.rhtml:20:in > > > `_run_rhtml_47app47views47use_cases47show46rhtml' > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:326:in > > > `compile_and_render_template' > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:301:in > > > `render_template' > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:260:in > > > `render_file' > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:806:in > > > `render_file' > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:741:in > > > `render_with_no_layout' > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/layout.rb:256:in > > > `render_without_benchmark' > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in > > > `render' > > > c:/dev/ruby/lib/ruby/1.8/benchmark.rb:293:in > `measure' > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in > > > `render' > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/view.rb:55:in > > > `render' > > > spec/views/use_cases/show_view_spec.rb:40 > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/composite_proc_builder.rb:17:in > > > `proc' > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/composite_proc_builder.rb:12:in > > > `proc' > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:71:in > > > `before_example' > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:25:in > > > `run' > > > c:/dev/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout' > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:24:in > > > `run' > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:81:in > > > `run' > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:75:in > > > `run' > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:58:in > > > `run_behaviours' > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:57:in > > > `run_behaviours' > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:21:in > > > `run' > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > > `run' > > > script/spec:4 > > > > > > Here's part of my routes.rb, showing the nested resources > > > > > > map.resources :customers do |customers| > > > customers.resources :projects do |projects| > > > projects.resources :actors > > > projects.resources :use_cases > > > > > > > > > Here's some of the stubbing that I am using to set up the spec > > > > > > @customer = mock_model(Customer, > > > :id => 1, > > > :to_param => "1" > > > ) > > > > > > @project = mock_model(Project, > > > :id => 1, > > > :customer_id => 1, > > > :to_param => "1" > > > ) > > > > > > I've also stubbed objects to create the following :assigns > > > > > > assigns[:customer] = @customer > > > assigns[:project] = @project > > > assigns[:use_case] = @use_case > > > assigns[:primary_actors] = @primary_actors > > > > > > I suspect that there is something else that needs to be stubbed - actors > > > controller, maybe? I really don't know. If anyone can point me in the > > > right direction, or tell me where in the error message to dig deeper, > that > > > would be awesome. > > > > > > If I left out any important information, please let me know! And a huge > > > thanks in advance to anyone who can help me out, or explain why this > isn't > > > supported, or point me towards any docs or articles that address this > issue > > > (because I will have it a zillion times, as almost all views in my app > > > display content and links from more than one model). > > > > I don't think it's related to rspec. Note that the top of the error stack > says: > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1273:in > > `raise_named_route_error' > > > > So the error is likely related to this bit: > > > > actor_path(@customer, at project) > > > > Given the nesting that you're doing multi-level nesting (which is not > > recommended btw - read > > http://weblog.jamisbuck.org/2007/2/5/nesting-resources), > I believe > > that the path should be either: > > > > customer_project_actor_path(@customer, @project, @actor) > > > > or > > > > customer_project_actors_path(@customer, @project) > > > > HTH, > > David > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > Scott Sehlhorst, President Tyner Blain LLC > http://tynerblain.com/blog > http://tynerblain.com/nexus > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lancecarlson at gmail.com Fri Sep 21 14:04:14 2007 From: lancecarlson at gmail.com (Lance Carlson) Date: Fri, 21 Sep 2007 14:04:14 -0400 Subject: [rspec-users] RSpec view spec writing problem (unable to generate url_for in RESTful resource link_to) In-Reply-To: <49f64a900709211102p67186b0fn457804700b087538@mail.gmail.com> References: <4f34789a0709100744h28fbd6dcmedb1dd59747241ed@mail.gmail.com> <57c63afe0709100801x72760bbg61223b36274b6a55@mail.gmail.com> <4f34789a0709100913g3b6c2463hf03f541c58c36eff@mail.gmail.com> <49f64a900709211102p67186b0fn457804700b087538@mail.gmail.com> Message-ID: <49f64a900709211104j61aaf5e3yb1340fdc0e0d045a@mail.gmail.com> BTW I also tried this: template.stub!(:edit_label_url).and_return('') but the same error continues to persist On 9/21/07, Lance Carlson wrote: > BTW I know this is old, but did you know you can do this? > > iink_to a.name, [@customer, @project],,{:class=>"show",:title=>"Show > > actor details"} ? > > I'm having trouble mocking this my view specs right now as it is > giving me errors, but it works fine in rails edge. I will report on my > discoveries if anyone has figured out how to deal with this new way to > call polymorphic path helpers. any takers? My error is as follows: > > > 1) > ActionView::TemplateError in 'Label Page should have a link to add a new artist' > edit_label_url failed to generate from {:action=>"edit", > :controller=>"labels", :id=># @name="Label_1000">}, expected: {:controller=>"labels", > :action=>"edit"}, diff: {:id=># @name="Label_1000">} > On line #3 of app/views/labels/show.rhtml > > 3: <%= link_to 'Edit', [ @label, :edit ] %>
          > > On 9/10/07, Scott Sehlhorst wrote: > > Thanks very much. I feel like a bit of a fool, now, for the odd error. > > > > Changing from: > > <%= > > link_to(a.name,actor_path(@customer, at project),{:class=>"show",:title=>"Show > > actor details"}) -%> > > To > > <%= > > link_to(a.name,actor_path(@customer, at project,a),{:class=>"show",:title=>"Show > > actor details"}) -%> > > > > Caused everything to work like a champ. And uncovered an interesting bug. > > When not specifying the actor 'a', the link is generated (in the page), but > > with id=1. No idea if/when I would have caught that. > > > > Thanks again David, and all the RSpec'ers out there. > > > > Also, thanks for the multi-nesting pointer. > > > > Scott > > > > > > > > On 9/10/07, David Chelimsky wrote: > > > On 9/10/07, Scott Sehlhorst < scott at tynerblain.com> wrote: > > > > Thanks, first, to everyone who's asked and answered questions on this > > list, > > > > and to the creators of RSpec - it is all very helpful. I've searched > > the > > > > mailing list, and had a couple 2hr googling sessions that didn't help me > > > > find an answer. > > > > > > > > I've run into a problem getting my first non-trivial view spec to run. > > I > > > > get an error when trying to generate a link_to() to another resource. > > Here > > > > is an overview of the situation, then the code: > > > > > > > > > > > > I'm using a restful design > > > > I'm using nested (multiply nested) resources > > > > I am trying to test a show.rhtml view, that includes links (link_to) to > > > > resources managed by another controller > > > > The use_case model has a many-to-may through relationship with actors, > > and > > > > I'm displaying links to the associated actors on the use_case page > > > > I can't get the links to generate when running rspec (but it works great > > in > > > > the app) > > > > I am in the early stages of the project, and want to move forward BDD, > > but I > > > > have some existing code that I need to test before I can start moving > > > > forward again. > > > > My theories: I need to stub the controller (for the other resource), or > > I > > > > need to stub something else. > > > > > > > > Here's the command I'm running to drive RSpec > > > > > > > > ruby script/spec -f s spec/views > > > > > > > > Here's the error that I get > > > > > > > > 1) > > > > ActionView::TemplateError in 'UseCase showing a use case should display > > the > > > > use case identifier' > > > > actor_url failed to generate from {:customer_id=>"1", > > > > :controller=>"actors", :action=>"show", :project_id=>"1"}, expecte > > > > d: {:controller=>"actors", :action=>"show"}, diff: {:customer_id=>"1", > > > > :project_id=>"1"} > > > > On line #22 of app/views/use_cases/show.rhtml > > > > > > > > 19:
            > > > > 20: <% @primary_actors.each do |a| %> > > > > 21:
          • > > > > 22: <%= > > > > > > link_to(a.name,actor_path(@customer, at project),{:class=>"show",:title=>"Show > > > > actor details"}) -%> > > > > 23: <%= link_to("Remove > > > > > > assignment",participation_path(@customer, at project, at use_case.participations.find_by > > > > _actor_id(a)),{:class=>"delete",:title=>"Remove the > > > > assignment of this actor to this use case", :confirm => 'Are you sur > > > > e you want to remove this assignment?', :method => :delete})-%> > > > > 24:
          • > > > > 25: <% end %> > > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1273:in > > > > `raise_named_route_error' > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1245:in > > > > `generate' > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:104:in > > > > `rewrite_path' > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:69:in > > > > `rewrite' > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:522:in > > > > `url_for' > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:27:in > > > > `url_for' > > > > (eval):19:in `actor_path' > > > > #{RAILS_ROOT}/app/views/use_cases/show.rhtml:22:in > > > > `_run_rhtml_47app47views47use_cases47show46rhtml' > > > > #{RAILS_ROOT}/app/views/use_cases/show.rhtml:20:in > > > > `_run_rhtml_47app47views47use_cases47show46rhtml' > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:326:in > > > > `compile_and_render_template' > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:301:in > > > > `render_template' > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:260:in > > > > `render_file' > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:806:in > > > > `render_file' > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:741:in > > > > `render_with_no_layout' > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/layout.rb:256:in > > > > `render_without_benchmark' > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in > > > > `render' > > > > c:/dev/ruby/lib/ruby/1.8/benchmark.rb:293:in > > `measure' > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in > > > > `render' > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/view.rb:55:in > > > > `render' > > > > spec/views/use_cases/show_view_spec.rb:40 > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/composite_proc_builder.rb:17:in > > > > `proc' > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/composite_proc_builder.rb:12:in > > > > `proc' > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:71:in > > > > `before_example' > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:25:in > > > > `run' > > > > c:/dev/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout' > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:24:in > > > > `run' > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:81:in > > > > `run' > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:75:in > > > > `run' > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:58:in > > > > `run_behaviours' > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:57:in > > > > `run_behaviours' > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:21:in > > > > `run' > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > > > `run' > > > > script/spec:4 > > > > > > > > Here's part of my routes.rb, showing the nested resources > > > > > > > > map.resources :customers do |customers| > > > > customers.resources :projects do |projects| > > > > projects.resources :actors > > > > projects.resources :use_cases > > > > > > > > > > > > Here's some of the stubbing that I am using to set up the spec > > > > > > > > @customer = mock_model(Customer, > > > > :id => 1, > > > > :to_param => "1" > > > > ) > > > > > > > > @project = mock_model(Project, > > > > :id => 1, > > > > :customer_id => 1, > > > > :to_param => "1" > > > > ) > > > > > > > > I've also stubbed objects to create the following :assigns > > > > > > > > assigns[:customer] = @customer > > > > assigns[:project] = @project > > > > assigns[:use_case] = @use_case > > > > assigns[:primary_actors] = @primary_actors > > > > > > > > I suspect that there is something else that needs to be stubbed - actors > > > > controller, maybe? I really don't know. If anyone can point me in the > > > > right direction, or tell me where in the error message to dig deeper, > > that > > > > would be awesome. > > > > > > > > If I left out any important information, please let me know! And a huge > > > > thanks in advance to anyone who can help me out, or explain why this > > isn't > > > > supported, or point me towards any docs or articles that address this > > issue > > > > (because I will have it a zillion times, as almost all views in my app > > > > display content and links from more than one model). > > > > > > I don't think it's related to rspec. Note that the top of the error stack > > says: > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1273:in > > > `raise_named_route_error' > > > > > > So the error is likely related to this bit: > > > > > > actor_path(@customer, at project) > > > > > > Given the nesting that you're doing multi-level nesting (which is not > > > recommended btw - read > > > http://weblog.jamisbuck.org/2007/2/5/nesting-resources), > > I believe > > > that the path should be either: > > > > > > customer_project_actor_path(@customer, @project, @actor) > > > > > > or > > > > > > customer_project_actors_path(@customer, @project) > > > > > > HTH, > > > David > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > -- > > Scott Sehlhorst, President Tyner Blain LLC > > http://tynerblain.com/blog > > http://tynerblain.com/nexus > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > From lancecarlson at gmail.com Fri Sep 21 14:07:27 2007 From: lancecarlson at gmail.com (Lance Carlson) Date: Fri, 21 Sep 2007 14:07:27 -0400 Subject: [rspec-users] RSpec view spec writing problem (unable to generate url_for in RESTful resource link_to) In-Reply-To: <49f64a900709211104j61aaf5e3yb1340fdc0e0d045a@mail.gmail.com> References: <4f34789a0709100744h28fbd6dcmedb1dd59747241ed@mail.gmail.com> <57c63afe0709100801x72760bbg61223b36274b6a55@mail.gmail.com> <4f34789a0709100913g3b6c2463hf03f541c58c36eff@mail.gmail.com> <49f64a900709211102p67186b0fn457804700b087538@mail.gmail.com> <49f64a900709211104j61aaf5e3yb1340fdc0e0d045a@mail.gmail.com> Message-ID: <49f64a900709211107v4e38b076i2d286fb2c1aa178c@mail.gmail.com> Wait I think the problem stemmed from the fact that I started to prefix all of my urls with :subdomain. Could this be a possibility? If so, how to get around this? On 9/21/07, Lance Carlson wrote: > BTW I also tried this: > > template.stub!(:edit_label_url).and_return('') > > but the same error continues to persist > > On 9/21/07, Lance Carlson wrote: > > BTW I know this is old, but did you know you can do this? > > > > iink_to a.name, [@customer, @project],,{:class=>"show",:title=>"Show > > > actor details"} ? > > > > I'm having trouble mocking this my view specs right now as it is > > giving me errors, but it works fine in rails edge. I will report on my > > discoveries if anyone has figured out how to deal with this new way to > > call polymorphic path helpers. any takers? My error is as follows: > > > > > > 1) > > ActionView::TemplateError in 'Label Page should have a link to add a new artist' > > edit_label_url failed to generate from {:action=>"edit", > > :controller=>"labels", :id=># > @name="Label_1000">}, expected: {:controller=>"labels", > > :action=>"edit"}, diff: {:id=># > @name="Label_1000">} > > On line #3 of app/views/labels/show.rhtml > > > > 3: <%= link_to 'Edit', [ @label, :edit ] %>
            > > > > On 9/10/07, Scott Sehlhorst wrote: > > > Thanks very much. I feel like a bit of a fool, now, for the odd error. > > > > > > Changing from: > > > <%= > > > link_to(a.name,actor_path(@customer, at project),{:class=>"show",:title=>"Show > > > actor details"}) -%> > > > To > > > <%= > > > link_to(a.name,actor_path(@customer, at project,a),{:class=>"show",:title=>"Show > > > actor details"}) -%> > > > > > > Caused everything to work like a champ. And uncovered an interesting bug. > > > When not specifying the actor 'a', the link is generated (in the page), but > > > with id=1. No idea if/when I would have caught that. > > > > > > Thanks again David, and all the RSpec'ers out there. > > > > > > Also, thanks for the multi-nesting pointer. > > > > > > Scott > > > > > > > > > > > > On 9/10/07, David Chelimsky wrote: > > > > On 9/10/07, Scott Sehlhorst < scott at tynerblain.com> wrote: > > > > > Thanks, first, to everyone who's asked and answered questions on this > > > list, > > > > > and to the creators of RSpec - it is all very helpful. I've searched > > > the > > > > > mailing list, and had a couple 2hr googling sessions that didn't help me > > > > > find an answer. > > > > > > > > > > I've run into a problem getting my first non-trivial view spec to run. > > > I > > > > > get an error when trying to generate a link_to() to another resource. > > > Here > > > > > is an overview of the situation, then the code: > > > > > > > > > > > > > > > I'm using a restful design > > > > > I'm using nested (multiply nested) resources > > > > > I am trying to test a show.rhtml view, that includes links (link_to) to > > > > > resources managed by another controller > > > > > The use_case model has a many-to-may through relationship with actors, > > > and > > > > > I'm displaying links to the associated actors on the use_case page > > > > > I can't get the links to generate when running rspec (but it works great > > > in > > > > > the app) > > > > > I am in the early stages of the project, and want to move forward BDD, > > > but I > > > > > have some existing code that I need to test before I can start moving > > > > > forward again. > > > > > My theories: I need to stub the controller (for the other resource), or > > > I > > > > > need to stub something else. > > > > > > > > > > Here's the command I'm running to drive RSpec > > > > > > > > > > ruby script/spec -f s spec/views > > > > > > > > > > Here's the error that I get > > > > > > > > > > 1) > > > > > ActionView::TemplateError in 'UseCase showing a use case should display > > > the > > > > > use case identifier' > > > > > actor_url failed to generate from {:customer_id=>"1", > > > > > :controller=>"actors", :action=>"show", :project_id=>"1"}, expecte > > > > > d: {:controller=>"actors", :action=>"show"}, diff: {:customer_id=>"1", > > > > > :project_id=>"1"} > > > > > On line #22 of app/views/use_cases/show.rhtml > > > > > > > > > > 19:
              > > > > > 20: <% @primary_actors.each do |a| %> > > > > > 21:
            • > > > > > 22: <%= > > > > > > > > link_to(a.name,actor_path(@customer, at project),{:class=>"show",:title=>"Show > > > > > actor details"}) -%> > > > > > 23: <%= link_to("Remove > > > > > > > > assignment",participation_path(@customer, at project, at use_case.participations.find_by > > > > > _actor_id(a)),{:class=>"delete",:title=>"Remove the > > > > > assignment of this actor to this use case", :confirm => 'Are you sur > > > > > e you want to remove this assignment?', :method => :delete})-%> > > > > > 24:
            • > > > > > 25: <% end %> > > > > > > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1273:in > > > > > `raise_named_route_error' > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1245:in > > > > > `generate' > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:104:in > > > > > `rewrite_path' > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:69:in > > > > > `rewrite' > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:522:in > > > > > `url_for' > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:27:in > > > > > `url_for' > > > > > (eval):19:in `actor_path' > > > > > #{RAILS_ROOT}/app/views/use_cases/show.rhtml:22:in > > > > > `_run_rhtml_47app47views47use_cases47show46rhtml' > > > > > #{RAILS_ROOT}/app/views/use_cases/show.rhtml:20:in > > > > > `_run_rhtml_47app47views47use_cases47show46rhtml' > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:326:in > > > > > `compile_and_render_template' > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:301:in > > > > > `render_template' > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:260:in > > > > > `render_file' > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:806:in > > > > > `render_file' > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:741:in > > > > > `render_with_no_layout' > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/layout.rb:256:in > > > > > `render_without_benchmark' > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in > > > > > `render' > > > > > c:/dev/ruby/lib/ruby/1.8/benchmark.rb:293:in > > > `measure' > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in > > > > > `render' > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/view.rb:55:in > > > > > `render' > > > > > spec/views/use_cases/show_view_spec.rb:40 > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/composite_proc_builder.rb:17:in > > > > > `proc' > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/composite_proc_builder.rb:12:in > > > > > `proc' > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:71:in > > > > > `before_example' > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:25:in > > > > > `run' > > > > > c:/dev/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout' > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:24:in > > > > > `run' > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:81:in > > > > > `run' > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:75:in > > > > > `run' > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:58:in > > > > > `run_behaviours' > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:57:in > > > > > `run_behaviours' > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:21:in > > > > > `run' > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > > > > `run' > > > > > script/spec:4 > > > > > > > > > > Here's part of my routes.rb, showing the nested resources > > > > > > > > > > map.resources :customers do |customers| > > > > > customers.resources :projects do |projects| > > > > > projects.resources :actors > > > > > projects.resources :use_cases > > > > > > > > > > > > > > > Here's some of the stubbing that I am using to set up the spec > > > > > > > > > > @customer = mock_model(Customer, > > > > > :id => 1, > > > > > :to_param => "1" > > > > > ) > > > > > > > > > > @project = mock_model(Project, > > > > > :id => 1, > > > > > :customer_id => 1, > > > > > :to_param => "1" > > > > > ) > > > > > > > > > > I've also stubbed objects to create the following :assigns > > > > > > > > > > assigns[:customer] = @customer > > > > > assigns[:project] = @project > > > > > assigns[:use_case] = @use_case > > > > > assigns[:primary_actors] = @primary_actors > > > > > > > > > > I suspect that there is something else that needs to be stubbed - actors > > > > > controller, maybe? I really don't know. If anyone can point me in the > > > > > right direction, or tell me where in the error message to dig deeper, > > > that > > > > > would be awesome. > > > > > > > > > > If I left out any important information, please let me know! And a huge > > > > > thanks in advance to anyone who can help me out, or explain why this > > > isn't > > > > > supported, or point me towards any docs or articles that address this > > > issue > > > > > (because I will have it a zillion times, as almost all views in my app > > > > > display content and links from more than one model). > > > > > > > > I don't think it's related to rspec. Note that the top of the error stack > > > says: > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1273:in > > > > `raise_named_route_error' > > > > > > > > So the error is likely related to this bit: > > > > > > > > actor_path(@customer, at project) > > > > > > > > Given the nesting that you're doing multi-level nesting (which is not > > > > recommended btw - read > > > > http://weblog.jamisbuck.org/2007/2/5/nesting-resources), > > > I believe > > > > that the path should be either: > > > > > > > > customer_project_actor_path(@customer, @project, @actor) > > > > > > > > or > > > > > > > > customer_project_actors_path(@customer, @project) > > > > > > > > HTH, > > > > David > > > > _______________________________________________ > > > > rspec-users mailing list > > > > rspec-users at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > > > > > > -- > > > Scott Sehlhorst, President Tyner Blain LLC > > > http://tynerblain.com/blog > > > http://tynerblain.com/nexus > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > From trevor at protocool.com Fri Sep 21 14:07:34 2007 From: trevor at protocool.com (Trevor Squires) Date: Fri, 21 Sep 2007 11:07:34 -0700 Subject: [rspec-users] TextMate Bundle and exception when switching to alternate file. Message-ID: Hey, sorry if this is something better suited to another list. I've encountered a strange problem with the RSpec.tmbundle in trunk - namely that it was raising an exception when pressing ctrl-shift-downarrow (switch between spec and source - "Alternate File"). I tracked down the issue to be handling of the file_type in switch_command.rb#content_for() - the code expected the type string to be just 'spec' when it can be 'view spec' or 'model spec' etc. Unfortunately I don't know whether this is just an issue with my local textmate install or if it is, in fact, a bug. Here is a diff showing how I solved the problem for myself - if it's valid across-the-board it would be great if it could be applied to trunk. Index: RSpec.tmbundle/Support/lib/spec/mate/switch_command.rb =================================================================== --- RSpec.tmbundle/Support/lib/spec/mate/switch_command.rb (revision 2607) +++ RSpec.tmbundle/Support/lib/spec/mate/switch_command.rb (working copy) @@ -63,7 +63,7 @@ def content_for(file_type, relative_path) case file_type - when 'spec' then + when /spec$/ then spec(relative_path) else klass(relative_path) Thanks for your attention, Trevor -- -- Trevor Squires http://somethinglearned.com From lancecarlson at gmail.com Fri Sep 21 14:08:42 2007 From: lancecarlson at gmail.com (Lance Carlson) Date: Fri, 21 Sep 2007 14:08:42 -0400 Subject: [rspec-users] RSpec view spec writing problem (unable to generate url_for in RESTful resource link_to) In-Reply-To: <49f64a900709211107v4e38b076i2d286fb2c1aa178c@mail.gmail.com> References: <4f34789a0709100744h28fbd6dcmedb1dd59747241ed@mail.gmail.com> <57c63afe0709100801x72760bbg61223b36274b6a55@mail.gmail.com> <4f34789a0709100913g3b6c2463hf03f541c58c36eff@mail.gmail.com> <49f64a900709211102p67186b0fn457804700b087538@mail.gmail.com> <49f64a900709211104j61aaf5e3yb1340fdc0e0d045a@mail.gmail.com> <49f64a900709211107v4e38b076i2d286fb2c1aa178c@mail.gmail.com> Message-ID: <49f64a900709211108m3b79440agff1bc560c9fae103@mail.gmail.com> wow nevermind :) assigns[:subdomain] = 'test' On 9/21/07, Lance Carlson wrote: > Wait I think the problem stemmed from the fact that I started to > prefix all of my urls with :subdomain. Could this be a possibility? If > so, how to get around this? > > On 9/21/07, Lance Carlson wrote: > > BTW I also tried this: > > > > template.stub!(:edit_label_url).and_return('') > > > > but the same error continues to persist > > > > On 9/21/07, Lance Carlson wrote: > > > BTW I know this is old, but did you know you can do this? > > > > > > iink_to a.name, [@customer, @project],,{:class=>"show",:title=>"Show > > > > actor details"} ? > > > > > > I'm having trouble mocking this my view specs right now as it is > > > giving me errors, but it works fine in rails edge. I will report on my > > > discoveries if anyone has figured out how to deal with this new way to > > > call polymorphic path helpers. any takers? My error is as follows: > > > > > > > > > 1) > > > ActionView::TemplateError in 'Label Page should have a link to add a new artist' > > > edit_label_url failed to generate from {:action=>"edit", > > > :controller=>"labels", :id=># > > @name="Label_1000">}, expected: {:controller=>"labels", > > > :action=>"edit"}, diff: {:id=># > > @name="Label_1000">} > > > On line #3 of app/views/labels/show.rhtml > > > > > > 3: <%= link_to 'Edit', [ @label, :edit ] %>
              > > > > > > On 9/10/07, Scott Sehlhorst wrote: > > > > Thanks very much. I feel like a bit of a fool, now, for the odd error. > > > > > > > > Changing from: > > > > <%= > > > > link_to(a.name,actor_path(@customer, at project),{:class=>"show",:title=>"Show > > > > actor details"}) -%> > > > > To > > > > <%= > > > > link_to(a.name,actor_path(@customer, at project,a),{:class=>"show",:title=>"Show > > > > actor details"}) -%> > > > > > > > > Caused everything to work like a champ. And uncovered an interesting bug. > > > > When not specifying the actor 'a', the link is generated (in the page), but > > > > with id=1. No idea if/when I would have caught that. > > > > > > > > Thanks again David, and all the RSpec'ers out there. > > > > > > > > Also, thanks for the multi-nesting pointer. > > > > > > > > Scott > > > > > > > > > > > > > > > > On 9/10/07, David Chelimsky wrote: > > > > > On 9/10/07, Scott Sehlhorst < scott at tynerblain.com> wrote: > > > > > > Thanks, first, to everyone who's asked and answered questions on this > > > > list, > > > > > > and to the creators of RSpec - it is all very helpful. I've searched > > > > the > > > > > > mailing list, and had a couple 2hr googling sessions that didn't help me > > > > > > find an answer. > > > > > > > > > > > > I've run into a problem getting my first non-trivial view spec to run. > > > > I > > > > > > get an error when trying to generate a link_to() to another resource. > > > > Here > > > > > > is an overview of the situation, then the code: > > > > > > > > > > > > > > > > > > I'm using a restful design > > > > > > I'm using nested (multiply nested) resources > > > > > > I am trying to test a show.rhtml view, that includes links (link_to) to > > > > > > resources managed by another controller > > > > > > The use_case model has a many-to-may through relationship with actors, > > > > and > > > > > > I'm displaying links to the associated actors on the use_case page > > > > > > I can't get the links to generate when running rspec (but it works great > > > > in > > > > > > the app) > > > > > > I am in the early stages of the project, and want to move forward BDD, > > > > but I > > > > > > have some existing code that I need to test before I can start moving > > > > > > forward again. > > > > > > My theories: I need to stub the controller (for the other resource), or > > > > I > > > > > > need to stub something else. > > > > > > > > > > > > Here's the command I'm running to drive RSpec > > > > > > > > > > > > ruby script/spec -f s spec/views > > > > > > > > > > > > Here's the error that I get > > > > > > > > > > > > 1) > > > > > > ActionView::TemplateError in 'UseCase showing a use case should display > > > > the > > > > > > use case identifier' > > > > > > actor_url failed to generate from {:customer_id=>"1", > > > > > > :controller=>"actors", :action=>"show", :project_id=>"1"}, expecte > > > > > > d: {:controller=>"actors", :action=>"show"}, diff: {:customer_id=>"1", > > > > > > :project_id=>"1"} > > > > > > On line #22 of app/views/use_cases/show.rhtml > > > > > > > > > > > > 19:
                > > > > > > 20: <% @primary_actors.each do |a| %> > > > > > > 21:
              • > > > > > > 22: <%= > > > > > > > > > > link_to(a.name,actor_path(@customer, at project),{:class=>"show",:title=>"Show > > > > > > actor details"}) -%> > > > > > > 23: <%= link_to("Remove > > > > > > > > > > assignment",participation_path(@customer, at project, at use_case.participations.find_by > > > > > > _actor_id(a)),{:class=>"delete",:title=>"Remove the > > > > > > assignment of this actor to this use case", :confirm => 'Are you sur > > > > > > e you want to remove this assignment?', :method => :delete})-%> > > > > > > 24:
              • > > > > > > 25: <% end %> > > > > > > > > > > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1273:in > > > > > > `raise_named_route_error' > > > > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1245:in > > > > > > `generate' > > > > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:104:in > > > > > > `rewrite_path' > > > > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:69:in > > > > > > `rewrite' > > > > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:522:in > > > > > > `url_for' > > > > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:27:in > > > > > > `url_for' > > > > > > (eval):19:in `actor_path' > > > > > > #{RAILS_ROOT}/app/views/use_cases/show.rhtml:22:in > > > > > > `_run_rhtml_47app47views47use_cases47show46rhtml' > > > > > > #{RAILS_ROOT}/app/views/use_cases/show.rhtml:20:in > > > > > > `_run_rhtml_47app47views47use_cases47show46rhtml' > > > > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:326:in > > > > > > `compile_and_render_template' > > > > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:301:in > > > > > > `render_template' > > > > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:260:in > > > > > > `render_file' > > > > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:806:in > > > > > > `render_file' > > > > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:741:in > > > > > > `render_with_no_layout' > > > > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/layout.rb:256:in > > > > > > `render_without_benchmark' > > > > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in > > > > > > `render' > > > > > > c:/dev/ruby/lib/ruby/1.8/benchmark.rb:293:in > > > > `measure' > > > > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in > > > > > > `render' > > > > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/view.rb:55:in > > > > > > `render' > > > > > > spec/views/use_cases/show_view_spec.rb:40 > > > > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/composite_proc_builder.rb:17:in > > > > > > `proc' > > > > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/composite_proc_builder.rb:12:in > > > > > > `proc' > > > > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:71:in > > > > > > `before_example' > > > > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:25:in > > > > > > `run' > > > > > > c:/dev/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout' > > > > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:24:in > > > > > > `run' > > > > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:81:in > > > > > > `run' > > > > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:75:in > > > > > > `run' > > > > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:58:in > > > > > > `run_behaviours' > > > > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:57:in > > > > > > `run_behaviours' > > > > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:21:in > > > > > > `run' > > > > > > > > > > > > > > > > C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > > > > > `run' > > > > > > script/spec:4 > > > > > > > > > > > > Here's part of my routes.rb, showing the nested resources > > > > > > > > > > > > map.resources :customers do |customers| > > > > > > customers.resources :projects do |projects| > > > > > > projects.resources :actors > > > > > > projects.resources :use_cases > > > > > > > > > > > > > > > > > > Here's some of the stubbing that I am using to set up the spec > > > > > > > > > > > > @customer = mock_model(Customer, > > > > > > :id => 1, > > > > > > :to_param => "1" > > > > > > ) > > > > > > > > > > > > @project = mock_model(Project, > > > > > > :id => 1, > > > > > > :customer_id => 1, > > > > > > :to_param => "1" > > > > > > ) > > > > > > > > > > > > I've also stubbed objects to create the following :assigns > > > > > > > > > > > > assigns[:customer] = @customer > > > > > > assigns[:project] = @project > > > > > > assigns[:use_case] = @use_case > > > > > > assigns[:primary_actors] = @primary_actors > > > > > > > > > > > > I suspect that there is something else that needs to be stubbed - actors > > > > > > controller, maybe? I really don't know. If anyone can point me in the > > > > > > right direction, or tell me where in the error message to dig deeper, > > > > that > > > > > > would be awesome. > > > > > > > > > > > > If I left out any important information, please let me know! And a huge > > > > > > thanks in advance to anyone who can help me out, or explain why this > > > > isn't > > > > > > supported, or point me towards any docs or articles that address this > > > > issue > > > > > > (because I will have it a zillion times, as almost all views in my app > > > > > > display content and links from more than one model). > > > > > > > > > > I don't think it's related to rspec. Note that the top of the error stack > > > > says: > > > > > > > > > > > > > > #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1273:in > > > > > `raise_named_route_error' > > > > > > > > > > So the error is likely related to this bit: > > > > > > > > > > actor_path(@customer, at project) > > > > > > > > > > Given the nesting that you're doing multi-level nesting (which is not > > > > > recommended btw - read > > > > > http://weblog.jamisbuck.org/2007/2/5/nesting-resources), > > > > I believe > > > > > that the path should be either: > > > > > > > > > > customer_project_actor_path(@customer, @project, @actor) > > > > > > > > > > or > > > > > > > > > > customer_project_actors_path(@customer, @project) > > > > > > > > > > HTH, > > > > > David > > > > > _______________________________________________ > > > > > rspec-users mailing list > > > > > rspec-users at rubyforge.org > > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > > > > > > > > > > > -- > > > > Scott Sehlhorst, President Tyner Blain LLC > > > > http://tynerblain.com/blog > > > > http://tynerblain.com/nexus > > > > _______________________________________________ > > > > rspec-users mailing list > > > > rspec-users at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > From dchelimsky at gmail.com Fri Sep 21 15:49:51 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 21 Sep 2007 21:49:51 +0200 Subject: [rspec-users] given_it In-Reply-To: References: Message-ID: <57c63afe0709211249i384488ebt420d49bf3cad2b7c@mail.gmail.com> Have you seen shared behaviours? On 9/21/07, Yurii Rashkovskii wrote: > Hello, > > Just decided to check whether I am doing something that makes sense > or not. I was thinking about how cool would it be to re-use examples > (just like we reuse story scenarios with GivenScenario). I was not > sure if this possibility already exists in rspec (and, honestly, was > lazy to check), so I have created this helper: > > def given_it(name) > example_definition = behaviour.example_definitions.find{|i| > i.description == name } > instance_eval(&example_definition.example_block) > end > > so it is possible to write things like > > it "should do something after another action" do > given_it "should successfully do another action" > do_something.should be_fine > end > > Is there anything already in rspec that allows me to do the same > stuff? Or was it a bad idea at all? > > Yurii. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri Sep 21 15:55:02 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 21 Sep 2007 21:55:02 +0200 Subject: [rspec-users] TextMate Bundle and exception when switching to alternate file. In-Reply-To: References: Message-ID: <57c63afe0709211255q7e3f7f30ub5d13ca7e930078f@mail.gmail.com> Please submit this to the tracker as a patch. http://rubyforge.org/tracker/index.php?group_id=797 Thanks, David On 9/21/07, Trevor Squires wrote: > Hey, > > sorry if this is something better suited to another list. > > I've encountered a strange problem with the RSpec.tmbundle in trunk - > namely that it was raising an exception when pressing > ctrl-shift-downarrow (switch between spec and source - "Alternate > File"). > > I tracked down the issue to be handling of the file_type in > switch_command.rb#content_for() - the code expected the type string to > be just 'spec' when it can be 'view spec' or 'model spec' etc. > > Unfortunately I don't know whether this is just an issue with my local > textmate install or if it is, in fact, a bug. > > Here is a diff showing how I solved the problem for myself - if it's > valid across-the-board it would be great if it could be applied to > trunk. > > Index: RSpec.tmbundle/Support/lib/spec/mate/switch_command.rb > =================================================================== > --- RSpec.tmbundle/Support/lib/spec/mate/switch_command.rb (revision 2607) > +++ RSpec.tmbundle/Support/lib/spec/mate/switch_command.rb (working copy) > @@ -63,7 +63,7 @@ > > def content_for(file_type, relative_path) > case file_type > - when 'spec' then > + when /spec$/ then > spec(relative_path) > else > klass(relative_path) > > Thanks for your attention, > Trevor > > -- > -- > Trevor Squires > http://somethinglearned.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From yrashk at gmail.com Fri Sep 21 16:01:06 2007 From: yrashk at gmail.com (Yurii Rashkovskii) Date: Fri, 21 Sep 2007 23:01:06 +0300 Subject: [rspec-users] given_it In-Reply-To: <57c63afe0709211249i384488ebt420d49bf3cad2b7c@mail.gmail.com> References: <57c63afe0709211249i384488ebt420d49bf3cad2b7c@mail.gmail.com> Message-ID: <173572E5-0046-45AC-AAF4-BE52852484B9@gmail.com> Sure! But they are not the same stuff. What I was looking for is it "should do #1" do ... end it "should do X after #1" do given_it "should do #1" should do_x end it "should do Y after #1" do given_it "should do #1" should do_y end it "should do Z after #1 Y" do given_it "should do Y after #1" should do_z end Or am I missing somethiing? On Sep 21, 2007, at 10:49 PM, David Chelimsky wrote: > Have you seen shared behaviours? > > On 9/21/07, Yurii Rashkovskii wrote: >> Hello, >> >> Just decided to check whether I am doing something that makes sense >> or not. I was thinking about how cool would it be to re-use examples >> (just like we reuse story scenarios with GivenScenario). I was not >> sure if this possibility already exists in rspec (and, honestly, was >> lazy to check), so I have created this helper: >> >> def given_it(name) >> example_definition = behaviour.example_definitions.find{|i| >> i.description == name } >> instance_eval(&example_definition.example_block) >> end >> >> so it is possible to write things like >> >> it "should do something after another action" do >> given_it "should successfully do another action" >> do_something.should be_fine >> end >> >> Is there anything already in rspec that allows me to do the same >> stuff? Or was it a bad idea at all? >> >> Yurii. >> _______________________________________________ >> 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 dchelimsky at gmail.com Fri Sep 21 16:03:30 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 21 Sep 2007 22:03:30 +0200 Subject: [rspec-users] given_it In-Reply-To: <173572E5-0046-45AC-AAF4-BE52852484B9@gmail.com> References: <57c63afe0709211249i384488ebt420d49bf3cad2b7c@mail.gmail.com> <173572E5-0046-45AC-AAF4-BE52852484B9@gmail.com> Message-ID: <57c63afe0709211303p4592f42ci3a7b94058d84657e@mail.gmail.com> On 9/21/07, Yurii Rashkovskii wrote: > Sure! But they are not the same stuff. What I was looking for is > > it "should do #1" do > ... > end > it "should do X after #1" do > given_it "should do #1" > should do_x > end > it "should do Y after #1" do > given_it "should do #1" > should do_y > end > it "should do Z after #1 Y" do > given_it "should do Y after #1" > should do_z > end Sorry mate - that just seems like endless confusion - the examples should never rely on each other that way - different animal from scenarios that involve steps. > > Or am I missing somethiing? > > > On Sep 21, 2007, at 10:49 PM, David Chelimsky wrote: > > > Have you seen shared behaviours? > > > > On 9/21/07, Yurii Rashkovskii wrote: > >> Hello, > >> > >> Just decided to check whether I am doing something that makes sense > >> or not. I was thinking about how cool would it be to re-use examples > >> (just like we reuse story scenarios with GivenScenario). I was not > >> sure if this possibility already exists in rspec (and, honestly, was > >> lazy to check), so I have created this helper: > >> > >> def given_it(name) > >> example_definition = behaviour.example_definitions.find{|i| > >> i.description == name } > >> instance_eval(&example_definition.example_block) > >> end > >> > >> so it is possible to write things like > >> > >> it "should do something after another action" do > >> given_it "should successfully do another action" > >> do_something.should be_fine > >> end > >> > >> Is there anything already in rspec that allows me to do the same > >> stuff? Or was it a bad idea at all? > >> > >> Yurii. > >> _______________________________________________ > >> 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 > From yrashk at gmail.com Fri Sep 21 16:12:50 2007 From: yrashk at gmail.com (Yurii Rashkovskii) Date: Fri, 21 Sep 2007 23:12:50 +0300 Subject: [rspec-users] given_it In-Reply-To: <57c63afe0709211303p4592f42ci3a7b94058d84657e@mail.gmail.com> References: <57c63afe0709211249i384488ebt420d49bf3cad2b7c@mail.gmail.com> <173572E5-0046-45AC-AAF4-BE52852484B9@gmail.com> <57c63afe0709211303p4592f42ci3a7b94058d84657e@mail.gmail.com> Message-ID: <0F254CF5-A6A9-4642-A4A0-32960A675EA9@gmail.com> >> Sure! But they are not the same stuff. What I was looking for is >> >> it "should do #1" do >> ... >> end >> it "should do X after #1" do >> given_it "should do #1" >> should do_x >> end >> it "should do Y after #1" do >> given_it "should do #1" >> should do_y >> end >> it "should do Z after #1 Y" do >> given_it "should do Y after #1" >> should do_z >> end > > Sorry mate - that just seems like endless confusion - the examples > should never rely on each other that way - different animal from > scenarios that involve steps. I agree that they should not rely on each other _indirectly_. But why they should not _reuse_ each other? I find it very useful for testing, say, different aspects of, say, controller's behavior. I simply do not want to put all checks into one example, like it should do this, this and this and in result we should have this, this and that. How do you propose to test different aspects of single actions in a nice way? From lancecarlson at gmail.com Fri Sep 21 16:11:45 2007 From: lancecarlson at gmail.com (lancecarlson at gmail.com) Date: Fri, 21 Sep 2007 20:11:45 +0000 Subject: [rspec-users] given_it In-Reply-To: <57c63afe0709211303p4592f42ci3a7b94058d84657e@mail.gmail.com> References: <57c63afe0709211249i384488ebt420d49bf3cad2b7c@mail.gmail.com><173572E5-0046-45AC-AAF4-BE52852484B9@gmail.com><57c63afe0709211303p4592f42ci3a7b94058d84657e@mail.gmail.com> Message-ID: <5306998-1190405603-cardhu_decombobulator_blackberry.rim.net-1390044676-@bxe126.bisx.prod.on.blackberry> This concept violates oo if you want to test whether or not r method calls another method you would do that in the test and label it occordingly. What you are defining is such a narrow use case I think it would be abused Sent via BlackBerry from T-Mobile -----Original Message----- From: "David Chelimsky" Date: Fri, 21 Sep 2007 22:03:30 To:rspec-users Subject: Re: [rspec-users] given_it On 9/21/07, Yurii Rashkovskii wrote: > Sure! But they are not the same stuff. What I was looking for is > > it "should do #1" do > ... > end > it "should do X after #1" do > given_it "should do #1" > should do_x > end > it "should do Y after #1" do > given_it "should do #1" > should do_y > end > it "should do Z after #1 Y" do > given_it "should do Y after #1" > should do_z > end Sorry mate - that just seems like endless confusion - the examples should never rely on each other that way - different animal from scenarios that involve steps. > > Or am I missing somethiing? > > > On Sep 21, 2007, at 10:49 PM, David Chelimsky wrote: > > > Have you seen shared behaviours? > > > > On 9/21/07, Yurii Rashkovskii wrote: > >> Hello, > >> > >> Just decided to check whether I am doing something that makes sense > >> or not. I was thinking about how cool would it be to re-use examples > >> (just like we reuse story scenarios with GivenScenario). I was not > >> sure if this possibility already exists in rspec (and, honestly, was > >> lazy to check), so I have created this helper: > >> > >> def given_it(name) > >> example_definition = behaviour.example_definitions.find{|i| > >> i.description == name } > >> instance_eval(&example_definition.example_block) > >> end > >> > >> so it is possible to write things like > >> > >> it "should do something after another action" do > >> given_it "should successfully do another action" > >> do_something.should be_fine > >> end > >> > >> Is there anything already in rspec that allows me to do the same > >> stuff? Or was it a bad idea at all? > >> > >> Yurii. > >> _______________________________________________ > >> 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 > _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users From lancecarlson at gmail.com Fri Sep 21 16:14:22 2007 From: lancecarlson at gmail.com (lancecarlson at gmail.com) Date: Fri, 21 Sep 2007 20:14:22 +0000 Subject: [rspec-users] given_it In-Reply-To: <0F254CF5-A6A9-4642-A4A0-32960A675EA9@gmail.com> References: <57c63afe0709211249i384488ebt420d49bf3cad2b7c@mail.gmail.com><173572E5-0046-45AC-AAF4-BE52852484B9@gmail.com><57c63afe0709211303p4592f42ci3a7b94058d84657e@mail.gmail.com><0F254CF5-A6A9-4642-A4A0-32960A675EA9@gmail.com> Message-ID: <1616032354-1190405761-cardhu_decombobulator_blackberry.rim.net-1371178950-@bxe126.bisx.prod.on.blackberry> If you want to reuse stuff in your tests put those test methods in a separate module and include them into you specs Sent via BlackBerry from T-Mobile -----Original Message----- From: Yurii Rashkovskii Date: Fri, 21 Sep 2007 23:12:50 To:rspec-users Subject: Re: [rspec-users] given_it >> Sure! But they are not the same stuff. What I was looking for is >> >> it "should do #1" do >> ... >> end >> it "should do X after #1" do >> given_it "should do #1" >> should do_x >> end >> it "should do Y after #1" do >> given_it "should do #1" >> should do_y >> end >> it "should do Z after #1 Y" do >> given_it "should do Y after #1" >> should do_z >> end > > Sorry mate - that just seems like endless confusion - the examples > should never rely on each other that way - different animal from > scenarios that involve steps. I agree that they should not rely on each other _indirectly_. But why they should not _reuse_ each other? I find it very useful for testing, say, different aspects of, say, controller's behavior. I simply do not want to put all checks into one example, like it should do this, this and this and in result we should have this, this and that. How do you propose to test different aspects of single actions in a nice way? _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users From yrashk at gmail.com Fri Sep 21 16:17:00 2007 From: yrashk at gmail.com (Yurii Rashkovskii) Date: Fri, 21 Sep 2007 23:17:00 +0300 Subject: [rspec-users] given_it In-Reply-To: <1616032354-1190405761-cardhu_decombobulator_blackberry.rim.net-1371178950-@bxe126.bisx.prod.on.blackberry> References: <57c63afe0709211249i384488ebt420d49bf3cad2b7c@mail.gmail.com><173572E5-0046-45AC-AAF4-BE52852484B9@gmail.com><57c63afe0709211303p4592f42ci3a7b94058d84657e@mail.gmail.com><0F254CF5-A6A9-4642-A4A0-32960A675EA9@gmail.com> <1616032354-1190405761-cardhu_decombobulator_blackberry.rim.net-1371178950-@bxe126.bisx.prod.on.blackberry> Message-ID: <8E1CD663-0675-46BD-BD7A-830FFB41552F@gmail.com> Then I will have tens of methods that in fact has nothing really different from reused examples On Sep 21, 2007, at 11:14 PM, lancecarlson at gmail.com wrote: > If you want to reuse stuff in your tests put those test methods in > a separate module and include them into you specs > Sent via BlackBerry from T-Mobile > From dchelimsky at gmail.com Fri Sep 21 16:19:49 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 21 Sep 2007 22:19:49 +0200 Subject: [rspec-users] given_it In-Reply-To: <8E1CD663-0675-46BD-BD7A-830FFB41552F@gmail.com> References: <57c63afe0709211249i384488ebt420d49bf3cad2b7c@mail.gmail.com> <173572E5-0046-45AC-AAF4-BE52852484B9@gmail.com> <57c63afe0709211303p4592f42ci3a7b94058d84657e@mail.gmail.com> <0F254CF5-A6A9-4642-A4A0-32960A675EA9@gmail.com> <1616032354-1190405761-cardhu_decombobulator_blackberry.rim.net-1371178950-@bxe126.bisx.prod.on.blackberry> <8E1CD663-0675-46BD-BD7A-830FFB41552F@gmail.com> Message-ID: <57c63afe0709211319k4fd43e5g9a4b0ad8d8be934c@mail.gmail.com> On 9/21/07, Yurii Rashkovskii wrote: > Then I will have tens of methods that in fact has nothing really > different from reused examples But, as methods, they are more clearly differentiated for reuse. The problem is that if I reuse an example, and then decide to change that example, I may accidentally change the meaning of other examples. This is possible w/ helper methods too, but I think it is less likely. You can keep pursuing this if you like, but I can tell you right now that it is very likely not going to happen. We already have a few different ways to deal w/ reuse and this one seems more confusing to me than helpful. FWIW, David > > On Sep 21, 2007, at 11:14 PM, lancecarlson at gmail.com wrote: > > > If you want to reuse stuff in your tests put those test methods in > > a separate module and include them into you specs > > Sent via BlackBerry from T-Mobile > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From yrashk at gmail.com Fri Sep 21 16:26:55 2007 From: yrashk at gmail.com (Yurii Rashkovskii) Date: Fri, 21 Sep 2007 23:26:55 +0300 Subject: [rspec-users] given_it In-Reply-To: <5306998-1190405603-cardhu_decombobulator_blackberry.rim.net-1390044676-@bxe126.bisx.prod.on.blackberry> References: <57c63afe0709211249i384488ebt420d49bf3cad2b7c@mail.gmail.com><173572E5-0046-45AC-AAF4-BE52852484B9@gmail.com><57c63afe0709211303p4592f42ci3a7b94058d84657e@mail.gmail.com> <5306998-1190405603-cardhu_decombobulator_blackberry.rim.net-1390044676-@bxe126.bisx.prod.on.blackberry> Message-ID: <714E56DC-13A3-48E3-89F7-08EEAC184E16@gmail.com> Ok, let me try to explain. I have some controllers that are doing some kind of "main" action and some additional ones. These actions are belong to different aspects of logic and thus I'd prefer to test them separately to have clean and nice code that can be easily modified. Then, what's better to read? it "should do main action" do do_main_action end it "should set some value in session if there was no another specific value in session before" do session[:a] = 1 do_main_action session[:b].should == b end def do_main_action post :create, ... end or it "should do main action" do post :create, ... end it "should set some value in session if there was no another specific value in session before" do session[:a] = 1 given_it "should do main action" session[:b].should == b end I personally like second one. P.S. Examples above are surely artificial. On Sep 21, 2007, at 11:11 PM, lancecarlson at gmail.com wrote: > This concept violates oo if you want to test whether or not r > method calls another method you would do that in the test and label > it occordingly. What you are defining is such a narrow use case I > think it would be abused > Sent via BlackBerry from T-Mobile > > -----Original Message----- > From: "David Chelimsky" > > Date: Fri, 21 Sep 2007 22:03:30 > To:rspec-users > Subject: Re: [rspec-users] given_it > > > On 9/21/07, Yurii Rashkovskii wrote: >> Sure! But they are not the same stuff. What I was looking for is >> >> it "should do #1" do >> ... >> end >> it "should do X after #1" do >> given_it "should do #1" >> should do_x >> end >> it "should do Y after #1" do >> given_it "should do #1" >> should do_y >> end >> it "should do Z after #1 Y" do >> given_it "should do Y after #1" >> should do_z >> end > > Sorry mate - that just seems like endless confusion - the examples > should never rely on each other that way - different animal from > scenarios that involve steps. > >> >> Or am I missing somethiing? >> >> >> On Sep 21, 2007, at 10:49 PM, David Chelimsky wrote: >> >>> Have you seen shared behaviours? >>> >>> On 9/21/07, Yurii Rashkovskii wrote: >>>> Hello, >>>> >>>> Just decided to check whether I am doing something that makes sense >>>> or not. I was thinking about how cool would it be to re-use >>>> examples >>>> (just like we reuse story scenarios with GivenScenario). I was not >>>> sure if this possibility already exists in rspec (and, honestly, >>>> was >>>> lazy to check), so I have created this helper: >>>> >>>> def given_it(name) >>>> example_definition = behaviour.example_definitions.find{|i| >>>> i.description == name } >>>> instance_eval(&example_definition.example_block) >>>> end >>>> >>>> so it is possible to write things like >>>> >>>> it "should do something after another action" do >>>> given_it "should successfully do another action" >>>> do_something.should be_fine >>>> end >>>> >>>> Is there anything already in rspec that allows me to do the same >>>> stuff? Or was it a bad idea at all? >>>> >>>> Yurii. >>>> _______________________________________________ >>>> 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 >> > _______________________________________________ > 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 yrashk at gmail.com Fri Sep 21 16:30:18 2007 From: yrashk at gmail.com (Yurii Rashkovskii) Date: Fri, 21 Sep 2007 23:30:18 +0300 Subject: [rspec-users] given_it In-Reply-To: <57c63afe0709211319k4fd43e5g9a4b0ad8d8be934c@mail.gmail.com> References: <57c63afe0709211249i384488ebt420d49bf3cad2b7c@mail.gmail.com> <173572E5-0046-45AC-AAF4-BE52852484B9@gmail.com> <57c63afe0709211303p4592f42ci3a7b94058d84657e@mail.gmail.com> <0F254CF5-A6A9-4642-A4A0-32960A675EA9@gmail.com> <1616032354-1190405761-cardhu_decombobulator_blackberry.rim.net-1371178950-@bxe126.bisx.prod.on.blackberry> <8E1CD663-0675-46BD-BD7A-830FFB41552F@gmail.com> <57c63afe0709211319k4fd43e5g9a4b0ad8d8be934c@mail.gmail.com> Message-ID: <0F63D6AE-082F-4FC5-A5D2-14F94DE6100B@gmail.com> David, On Sep 21, 2007, at 11:19 PM, David Chelimsky wrote: > On 9/21/07, Yurii Rashkovskii wrote: >> Then I will have tens of methods that in fact has nothing really >> different from reused examples > > But, as methods, they are more clearly differentiated for reuse. > > The problem is that if I reuse an example, and then decide to change > that example, I may accidentally change the meaning of other examples. > This is possible w/ helper methods too, but I think it is less likely. I see no difference, really. You can break anything, either helper or example. But when using helpers, you'd likely to have worse code (just IMHO) > > You can keep pursuing this if you like, but I can tell you right now > that it is very likely not going to happen. We already have a few > different ways to deal w/ reuse and this one seems more confusing to > me than helpful. > I am not going to change anything, that's simply not my intention. My intention was to check what people think about this approach. I just found it very convenient for my coding experience. I do not need spend time extracting helpers, I do not need to keep single line examples that call helpers. I just write down pieces of logic, that's it. Anyway, thank you for your feedback. Yurii. From dan at tastapod.com Fri Sep 21 16:32:50 2007 From: dan at tastapod.com (Dan North) Date: Fri, 21 Sep 2007 22:32:50 +0200 Subject: [rspec-users] given_it In-Reply-To: <57c63afe0709211303p4592f42ci3a7b94058d84657e@mail.gmail.com> References: <57c63afe0709211249i384488ebt420d49bf3cad2b7c@mail.gmail.com> <173572E5-0046-45AC-AAF4-BE52852484B9@gmail.com> <57c63afe0709211303p4592f42ci3a7b94058d84657e@mail.gmail.com> Message-ID: <46F42A72.70908@tastapod.com> I have to agree with David. (It's in the contract ;) Scenarios are reusable as steps in order to chain multiple scenarios together (to describe the various coarse-grained stages of a workflow, state machine or wizard, for example). At an example level it is just confusing. I've noticed that if I find myself wanting to do that, it's an indication that the objects are too tightly coupled or dependent on one another. There is usually a cleaner abstraction in there waiting to be discovered that will mean you don't need to chain examples in this way. fwiw GivenScenario was introduced into JBehave to work around the constraint that scenarios were only allowed to be of the form Given/When/Then in the early days. Then we relaxed scenarios to allow mixing up steps in any order (given.. when.. then.. when.. then..) which made them read much more naturally. GivenScenarios aren't used much now other than in the specific situations I described above (state machines, etc). Cheers, Dan David Chelimsky wrote: > On 9/21/07, Yurii Rashkovskii wrote: > >> Sure! But they are not the same stuff. What I was looking for is >> >> it "should do #1" do >> ... >> end >> it "should do X after #1" do >> given_it "should do #1" >> should do_x >> end >> it "should do Y after #1" do >> given_it "should do #1" >> should do_y >> end >> it "should do Z after #1 Y" do >> given_it "should do Y after #1" >> should do_z >> end >> > > Sorry mate - that just seems like endless confusion - the examples > should never rely on each other that way - different animal from > scenarios that involve steps. > > >> Or am I missing somethiing? >> >> >> On Sep 21, 2007, at 10:49 PM, David Chelimsky wrote: >> >> >>> Have you seen shared behaviours? >>> >>> On 9/21/07, Yurii Rashkovskii wrote: >>> >>>> Hello, >>>> >>>> Just decided to check whether I am doing something that makes sense >>>> or not. I was thinking about how cool would it be to re-use examples >>>> (just like we reuse story scenarios with GivenScenario). I was not >>>> sure if this possibility already exists in rspec (and, honestly, was >>>> lazy to check), so I have created this helper: >>>> >>>> def given_it(name) >>>> example_definition = behaviour.example_definitions.find{|i| >>>> i.description == name } >>>> instance_eval(&example_definition.example_block) >>>> end >>>> >>>> so it is possible to write things like >>>> >>>> it "should do something after another action" do >>>> given_it "should successfully do another action" >>>> do_something.should be_fine >>>> end >>>> >>>> Is there anything already in rspec that allows me to do the same >>>> stuff? Or was it a bad idea at all? >>>> >>>> Yurii. >>>> _______________________________________________ >>>> 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 >> >> > _______________________________________________ > 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/20070921/120f9874/attachment.html From mailing_lists at railsnewbie.com Fri Sep 21 17:44:17 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 21 Sep 2007 17:44:17 -0400 Subject: [rspec-users] TextMate Bundle and exception when switching to alternate file. In-Reply-To: <57c63afe0709211255q7e3f7f30ub5d13ca7e930078f@mail.gmail.com> References: <57c63afe0709211255q7e3f7f30ub5d13ca7e930078f@mail.gmail.com> Message-ID: <7820B654-587F-4D5B-B59E-080CCD254E42@railsnewbie.com> >> >> sorry if this is something better suited to another list. >> >> I've encountered a strange problem with the RSpec.tmbundle in trunk - >> namely that it was raising an exception when pressing >> ctrl-shift-downarrow (switch between spec and source - "Alternate >> File"). >> >> I tracked down the issue to be handling of the file_type in >> switch_command.rb#content_for() - the code expected the type >> string to >> be just 'spec' when it can be 'view spec' or 'model spec' etc. >> >> Unfortunately I don't know whether this is just an issue with my >> local >> textmate install or if it is, in fact, a bug. Nope - it's a bug. I've experienced the same thing too. Scott From omen.king at gmail.com Fri Sep 21 19:14:30 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Fri, 21 Sep 2007 19:14:30 -0400 Subject: [rspec-users] Getting Started with Story Runner In-Reply-To: References: <46F22350.6060209@benmabey.com> <765a2c230709200625w43d36a30q7532a3dbf9de75d4@mail.gmail.com> Message-ID: I'm trying to generate stories based on Dan North's example. I'm not sure how to do this. require File.join(File.dirname(__FILE__), "helper") Story "Account Holder withdraws cash", %{ As an Account Holder I want to withdraw cash from an ATM So that I can get money when the bank is closed }, :type => RailsStory do Scenario "Account has sufficient funds" do Given "the account balance is $", 100 do |amount| @account = Account.new(:balance => 100) end And "the card is valid" do @account.should_not have.error_on(:balance) end And "the machine contains enough money" do @account.sufficient_funds? end When "the Account Holder requests $", 20 do |amount| @account.withdraw(amount) end Then "the ATM should dispense $", 20 do |amount| post "/account/show", :account => {:amount => amount} #show the receipt end And "the account balance should be $", 80 do @account.balance.should be_eql(80) end And "the card should be returned" do post "account/index" end end Scenario "Account has insufficient funds" do; end Scenario "Card has been disabled" do; end Scenario "The ATM has insufficient funds" do; end end Scenario: Account has sufficient funds Given the account balance is $ 100 F Scenario: Account has insufficient funds . Scenario: Card has been disabled . Scenario: The ATM has insufficient funds . 4 scenarios: 3 succeeded, 1 failed, 0 pending FAILURES: 1) Account Holder withdraws cash (Account has sufficient funds) FAILED NameError: uninitialized constant Account /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:266:in `load_missing_constant' When a failure occurs in a story does it always print out a heapstack or is my code incorrect? On 9/21/07, Evan David Light wrote: > > There are also a couple of examples buried in the trunk > under examples/story/game-of-life/behaviour/stories > On Sep 20, 2007, at 10:13 AM, Andrew WC Brown wrote: > > I'm guessing their isn't a generator for stories yet? > > ./script/generate story add_person > > On 9/20/07, James Hughes < hughes.james at gmail.com> wrote: > > > > On 9/20/07, Ben Mabey < ben at benmabey.com> wrote: > > > Andrew WC Brown wrote: > > > > I haven't found any How To's to use story runner and I'm not sure > > how > > > > to get started. > > > > Should I be looking for resources on how to use rbehave? > > > > How do I generate my first Story? > > > > > > ------------------------------------------------------------------------ > > > > > > > > _______________________________________________ > > > > rspec-users mailing list > > > > rspec-users at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > Pat wrote up an awesome tutorial/example: > > > > > > > > http://evang.eli.st/blog/2007/9/1/user-stories-with-rspec-s-story-runner > > > > > > That should get you started. > > > > > > > This pastie may be of use as well: > > > > http://pastie.caboo.se/92472 > > > > James > > _______________________________________________ > > 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 > -- Monsterbox Productions putting small businesses on-line 1319 Victoria Avenue East Thunder Bay, Ontario P7C 1C3 Canada Andrew WC Brown web-developer and owner andrew at monsterboxpro.com P: 807-626-9009 F: 807-624-2705 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070921/1ecc340d/attachment-0001.html From trevor at protocool.com Fri Sep 21 19:29:29 2007 From: trevor at protocool.com (Trevor Squires) Date: Fri, 21 Sep 2007 16:29:29 -0700 Subject: [rspec-users] TextMate Bundle and exception when switching to alternate file. In-Reply-To: <7820B654-587F-4D5B-B59E-080CCD254E42@railsnewbie.com> References: <57c63afe0709211255q7e3f7f30ub5d13ca7e930078f@mail.gmail.com> <7820B654-587F-4D5B-B59E-080CCD254E42@railsnewbie.com> Message-ID: Yeah, I've filed a patch for it - #14140 Regards, Trevor On 9/21/07, Scott Taylor wrote: > > Nope - it's a bug. I've experienced the same thing too. > > Scott -- -- Trevor Squires http://somethinglearned.com From mlangenberg at gmail.com Sat Sep 22 09:22:53 2007 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Sat, 22 Sep 2007 15:22:53 +0200 Subject: [rspec-users] How to DRY up controller action spec with different params. Message-ID: <27c0ac6d0709220622j6f29f5d8xa4f9e116ca73f6d7@mail.gmail.com> I tend to write a fresh description block for every change in the parameters for that specific action, because I hate conditionals in the example describtion, e.g.: describe SomeController, "handling GET /path/with/param/3" do it "should do this" it "should not do this if" it "should still do that in both cases" end Seperate description blocks keep things clean, however, there is a big amount of duplication between the two blocks, I do love clarity over cryptic DRY-ed up code (certainly in the examples), but those long blocks make the controller spec file tedious. Take for instance the code from the following pastie ( http://pastie.caboo.se/99683 ). The only difference between the two examples is that, in the first example a cart is retreived using the cart_id from the session, and in the second a new cart is created. Both then find an item and add this item to the cart. How would you guys rewrite the examples in the provided pastie? (and don't hesitate to tell me if you have any comments about the way I wrote these examples) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070922/c1684655/attachment.html From galeal_lists at ideaforge.org Sat Sep 22 11:15:29 2007 From: galeal_lists at ideaforge.org (Luke Galea) Date: Sat, 22 Sep 2007 11:15:29 -0400 Subject: [rspec-users] Authenticating before tests In-Reply-To: <12737465.post@talk.nabble.com> References: <12737465.post@talk.nabble.com> Message-ID: <9D8A4A5C-37AA-46FD-9F0B-DD2CFD8737FD@ideaforge.org> Hi Peter, I ended up settling on having a "ensure_goldberg_loaded" helper in spec_helper and a login_as that "spoofs" the session in the way that set_user would do but without relying on Goldberg. This should make it less coupled with Goldberg and let you test your code without testing goldberg at the same time. It really just involves creating a goldberg session object with the user_id and a blank menu_history. Here's the revelant bits of my spec_helper: def ensure_goldberg_loaded if Goldberg::User.find(:all).empty? GoldbergMigration.load_bootstrap end end def login_as( user = 'admin' ) request.session[:goldberg] = { :user_id => Goldberg::User.find (:first, :conditions => "name=\"#{user}\"").id, :menu_history => {} } end Then I use it in my specs: before(:all) do ensure_goldberg_loaded end before(:each) do login_as :galeal end Thanks for your help! -- Luke On 17-Sep-07, at 10:45 AM, peter.boling wrote: > > > Luke Galea-4 wrote: >> >> Could someone point me in the right direction? >> >> I thought the simplest way would be to either call the login action >> from my other tests before(:all), but I can't seem to find how to >> call another controller from within the spec for a different >> controller. (Results in @controller is nil). >> > > This is what we do. I realize that according to the another poster > this is > the wrong way, but it is the best way we've found for use with > Goldberg. > > def goldbergAuthAdmin() > get 'goldberg/auth/login' > #Goldberg::AuthController.set_user(session, > Goldberg::User.find_by_name(:first, "admin").id) > #Our Admin user has id 2. > Goldberg::AuthController.set_user(session,2) > end > > BTW, another important step is bootstrapping goldberg into your test > database... > > To facilitate this we added two methods to the GoldbergMigration > model: > def self.clear_for_class(klass, dest) > filename = "#{dest}/#{klass.to_s.sub(/^Goldberg::/, '')}.yml" > records = klass.delete_all > end > def self.clear_bootstrap > self.goldberg_classes.each do |klass| > self.clear_for_class klass, "#{File.dirname(__FILE__)}/../db" > end > end > > Then add this to spec_helper.rb, or your own included spec_helper > def goldbergReload() > GoldbergMigration.clear_bootstrap > GoldbergMigration.load_bootstrap > end > > Then call this from a before(:all) in the first describe of each rspec > needing goldberg. Of course you have to have dumped your goldberg > bootstrap > from dev/production first (You do this in the console: > "GoldbergMigration.dump_bootstrap" to save all goldberg settings, > controller/action perms, users roles, etc to some yaml files). > > Hope that helps! > > Peter Boling > Sagebit, LLC > -- > View this message in context: http://www.nabble.com/Authenticating- > before-tests-tf4435346.html#a12737465 > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From galeal_lists at ideaforge.org Sat Sep 22 11:17:58 2007 From: galeal_lists at ideaforge.org (Luke Galea) Date: Sat, 22 Sep 2007 11:17:58 -0400 Subject: [rspec-users] Odd response.body behavior Message-ID: <8D40E82A-EAB5-477D-A470-F1424A0978EC@ideaforge.org> Hi all, I'm having very odd behavior, but only with a few of my specs. I'm checking the value of response.body and in most cases finding it to be the content of the body... but in some cases it's the name of the template rendered!! There's no rhyme or reason I can see, but obviously my tests fail for no reason when I expect the body to contain the content. Any idea what is happening? Thanks in advance! Luke From hughes.james at gmail.com Sat Sep 22 11:57:16 2007 From: hughes.james at gmail.com (James Hughes) Date: Sat, 22 Sep 2007 08:57:16 -0700 Subject: [rspec-users] Getting Started with Story Runner In-Reply-To: References: <46F22350.6060209@benmabey.com> <765a2c230709200625w43d36a30q7532a3dbf9de75d4@mail.gmail.com> Message-ID: <765a2c230709220857pd101c2diea3d392e880072a8@mail.gmail.com> On 9/21/07, Andrew WC Brown wrote: > I'm trying to generate stories based on Dan North's example. > I'm not sure how to do this. > > require File.join(File.dirname(__FILE__), "helper") > > Story "Account Holder withdraws cash", %{ > As an Account Holder > I want to withdraw cash from an ATM > So that I can get money when the bank is closed > }, :type => RailsStory do > > Scenario "Account has sufficient funds" do > > Given "the account balance is $", 100 do |amount| > @account = Account.new(:balance => 100) > end > And "the card is valid" do > @account.should_not have.error_on(:balance) > end > And "the machine contains enough money" do > @account.sufficient_funds? > end > When "the Account Holder requests $", 20 do |amount| > @account.withdraw(amount) > end > Then "the ATM should dispense $", 20 do |amount| > post "/account/show", :account => {:amount => amount} #show the receipt > end > And "the account balance should be $", 80 do > @account.balance.should be_eql(80) > end > And "the card should be returned" do > post "account/index" > end > end > Scenario "Account has insufficient funds" do; end > Scenario "Card has been disabled" do; end > Scenario "The ATM has insufficient funds" do; end > > end > Scenario: Account has sufficient funds > > Given the account balance is $ 100 > F > Scenario: Account has insufficient funds > . > Scenario: Card has been disabled > . > Scenario: The ATM has insufficient funds > . > > > > 4 scenarios: 3 succeeded, 1 failed, 0 pending > > > FAILURES: > 1) Account Holder withdraws cash (Account has sufficient funds) FAILED > NameError: uninitialized constant Account > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:266:in > `load_missing_constant' > > > When a failure occurs in a story does it always print out a heapstack or is > my code incorrect? > Your code looks correct. My interpretation of the workflow that derives from this tool is that you write a high level story like you have here, run it, and let it tell you what to do next. The stack trace is telling you that you need an Account class. So now you would drop down to the object level and write a spec for Account (this is a Rails Story, so you'd write a model spec). Once you have that passing, you might come back up to the story level and re-run it, at which point it might tell you that it doesn't know about the balance() method on your account object; this would depend on how detailed you got in your model spec. I'm a total noob with this tool as well, so others on this list might have different insights; I'd be interested in hearing other perspectives on how detailed you'd get the first time you drill down to the object level: would you spec out the object completely as specified at the high level and then verify that it satisfies the story, or would you keep ping-ponging back and forth between the two levels? James > > On 9/21/07, Evan David Light wrote: > > > > There are also a couple of examples buried in the trunk under > examples/story/game-of-life/behaviour/stories > > > > > > > > > > On Sep 20, 2007, at 10:13 AM, Andrew WC Brown wrote: > > > > I'm guessing their isn't a generator for stories yet? > > > > ./script/generate story add_person > > > > > > On 9/20/07, James Hughes < hughes.james at gmail.com> wrote: > > > On 9/20/07, Ben Mabey < ben at benmabey.com> wrote: > > > > Andrew WC Brown wrote: > > > > > I haven't found any How To's to use story runner and I'm not sure > how > > > > > to get started. > > > > > Should I be looking for resources on how to use rbehave? > > > > > How do I generate my first Story? > > > > > > ------------------------------------------------------------------------ > > > > > > > > > > _______________________________________________ > > > > > rspec-users mailing list > > > > > rspec-users at rubyforge.org > > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > Pat wrote up an awesome tutorial/example: > > > > > > > > > http://evang.eli.st/blog/2007/9/1/user-stories-with-rspec-s-story-runner > > > > > > > > That should get you started. > > > > > > > > > > This pastie may be of use as well: > > > > > > http://pastie.caboo.se/92472 > > > > > > James > > > _______________________________________________ > > > 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 > > > > > > -- > Monsterbox Productions > putting small businesses on-line > > 1319 Victoria Avenue East > Thunder Bay, Ontario P7C 1C3 > Canada > > Andrew WC Brown > web-developer and owner > andrew at monsterboxpro.com > P: 807-626-9009 > F: 807-624-2705 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From robertrevans at gmail.com Sat Sep 22 16:23:25 2007 From: robertrevans at gmail.com (Robert Evans) Date: Sat, 22 Sep 2007 13:23:25 -0700 Subject: [rspec-users] I lost the RSpec fight In-Reply-To: <46ED4143.2080609@shopwatch.org> References: <46ED31EA.9000203@shopwatch.org> <683a886f0709160718p5dad961i32fd5cd0e81e031@mail.gmail.com> <46ED4143.2080609@shopwatch.org> Message-ID: <90a9a2160709221323q4880daa9wa20852e09d42019e@mail.gmail.com> > * I mentioned how Test::Unit development had stagnated, and they took a > different view of it: Test::Unit is "complete". It's done, it works, > it provides a base level of functionality that doesn't need any more > updating. That's quite troubling in my opinion for a developer(s) to say that something is complete and doesn't need any more updating. That would be a red flag for me in how this team may operate. -- - Robert http://robertrevans.com http://rubysnips.com From douglasdoright at gmail.com Sat Sep 22 17:25:29 2007 From: douglasdoright at gmail.com (Doug Wright) Date: Sat, 22 Sep 2007 14:25:29 -0700 Subject: [rspec-users] Cannot build trunk Message-ID: <5c25cb210709221425u791e3072qf432002a53b9bd61@mail.gmail.com> I apologize if this is a very dumb newbie issue, but I really want to experiment with the new "Story Runner" functionality in rspec and I'm having trouble using the trunk. I've tried in both windows and linux environments and have different problems on each. On linux, I execute svn co svn://rubyforge.org/var/svn/rspec/trunk to check out the trunk. This completes successfully, so I try to build the gem. The readme on building says: "check out source from svn://rubyforge.org/var/svn/rspec/trunk. Then do the following: rake gem gem install pkg/rspec-0.x.x.gem (you may have to sudo)" This doesn't work in trunk, so I cd into trunk/rspec and execute rake gem. This fails with: dwright at hendrix:~/trunk/rspec$ rake gem (in /home/dwright/trunk/rspec) mkdir pkg rm -rf pkg/rspec_on_rails mkdir pkg rm -rf pkg/RSpec.tmbundle rake aborted! No such file or directory - ../spec_ui /home/dwright/trunk/rspec/Rakefile:227:in `chdir' (See full trace by running task with --trace) On windows (vista), I can't seem to successfully check out the project. When I execute: svn co svn://rubyforge.org/var/svn/rspec/trunk I get the following error part-way through the checkout: svn: In directory 'trunk\RSpec.tmbundle\Preferences' svn: Can't move 'trunk\RSpec.tmbundle\Preferences\.svn\tmp\Symbol List: Behaviour.tmPreferences.tmp.tmp' to 'trunk\RSpec.tmbundle\Preferences\.svn\tmp\Symbol List: Behaviour.tmPreferences.tmp': The parameter is incorrect. I can't proceed in this case because the checkout won't complete. This may be an svn setup problem on my part and, if so, sorry to bring it here. Overall, I'm assuming that when I get the gem built and installed, I will need to get the "edge" version of the rspec and rspec_on_rails plugins in my rails project in order to play with Story Runner. I tried just getting the latest versions of the plugins, but without updating my gem, these (understandably) don't work. If anyone has the recipe for setting this up so that I can play with Story Runner, I'd greatly appreciate it. Again, I apologize if these are overly newbie questions. I'm not very experienced with subversion and relatively new to rails - but absolutely loving rspec! Thanks! -Doug Wright -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070922/d40b8899/attachment-0001.html From dchelimsky at gmail.com Sat Sep 22 17:37:54 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 22 Sep 2007 23:37:54 +0200 Subject: [rspec-users] Cannot build trunk In-Reply-To: <5c25cb210709221425u791e3072qf432002a53b9bd61@mail.gmail.com> References: <5c25cb210709221425u791e3072qf432002a53b9bd61@mail.gmail.com> Message-ID: <57c63afe0709221437l38b3a938j5cda27bb8b7ff51d@mail.gmail.com> On 9/22/07, Doug Wright wrote: > I apologize if this is a very dumb newbie issue, but I really want to > experiment with the new "Story Runner" functionality in rspec and I'm having > trouble using the trunk. > > I've tried in both windows and linux environments and have different > problems on each. > > On linux, I execute svn co > svn://rubyforge.org/var/svn/rspec/trunk to check out the > trunk. This completes successfully, so I try to build the gem. The readme > on building says: > > "check out source from > svn://rubyforge.org/var/svn/rspec/trunk. Then do the > following: > rake gem > gem install pkg/rspec-0.x.x.gem (you may have to sudo)" > This doesn't work in trunk, so I cd into trunk/rspec and execute rake gem. > This fails with: > > dwright at hendrix:~/trunk/rspec$ rake gem > (in /home/dwright/trunk/rspec) > mkdir pkg > rm -rf pkg/rspec_on_rails > mkdir pkg > rm -rf pkg/RSpec.tmbundle > rake aborted! > No such file or directory - ../spec_ui > /home/dwright/trunk/rspec/Rakefile:227:in `chdir' > (See full trace by running task with --trace) This is a bug. Please report bugs to the rspec tracker: http://rubyforge.org/tracker/?group_id=797 > > > > On windows (vista), I can't seem to successfully check out the project. > When I execute: > > svn co svn://rubyforge.org/var/svn/rspec/trunk > > I get the following error part-way through the checkout: > > svn: In directory 'trunk\RSpec.tmbundle\Preferences' > svn: Can't move > 'trunk\RSpec.tmbundle\Preferences\.svn\tmp\Symbol List: > Behaviour.tmPreferences.tmp.tmp' to > 'trunk\RSpec.tmbundle\Preferences\.svn\tmp\Symbol List: > Behaviour.tmPreferences.tmp': The parameter is incorrect. > > I can't proceed in this case because the checkout won't complete. This may > be an svn setup problem on my part and, if so, sorry to bring it here. > > Overall, I'm assuming that when I get the gem built and installed, I will > need to get the "edge" version of the rspec and rspec_on_rails plugins in my > rails project in order to play with Story Runner. I tried just getting the > latest versions of the plugins, but without updating my gem, these > (understandably) don't work. > > If anyone has the recipe for setting this up so that I can play with Story > Runner, I'd greatly appreciate it. Again, I apologize if these are overly > newbie questions. I'm not very experienced with subversion and relatively > new to rails - but absolutely loving rspec! > > Thanks! > > -Doug Wright > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Sat Sep 22 19:51:52 2007 From: ben at benmabey.com (Ben Mabey) Date: Sat, 22 Sep 2007 17:51:52 -0600 Subject: [rspec-users] Testing RESTful routes Message-ID: <46F5AA98.7020609@benmabey.com> Hi all, The app I am making right now uses restful routing entirely. I want to prevent people from accessing my actions without the proper HTTP verb so I commented out the :controller/:action/:id catch all routes that were used in pre-RESTful Rails apps. Like so: #map.connect ':controller/:action/:id.:format' #map.connect ':controller/:action/:id' When I did this however all of my routing specs broke. I have been testing my routes like the rspec-scaffold generator tests them: it "{ :controller => 'users', :action => 'new' } to /users/new" do route_for(:controller => "users", :action => "new").should == "/users/new" end To get around this the easiest thing I could think of was to add this to my routes.rb: if RAILS_ENV=="test" map.connect ':controller/:action/:id.:format' map.connect ':controller/:action/:id' end Are there better solutions? This is a workaround for the problem, but I'm wondering if there is a better way to test restful routes without relying on the old routing convention of controller/action/id. Ideally, the routing specs should also verify the HTTP verb as well. Is there any way to do this? Thanks, Ben From dchelimsky at gmail.com Sat Sep 22 23:45:05 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 23 Sep 2007 05:45:05 +0200 Subject: [rspec-users] Testing nested controller In-Reply-To: <526df6040709140157s3bcd06f5u43178b13612c05c0@mail.gmail.com> References: <526df6040709140157s3bcd06f5u43178b13612c05c0@mail.gmail.com> Message-ID: <57c63afe0709222045k67fc3f87w8c245114cd3a8dc6@mail.gmail.com> Controller specs are similar to Rails functional tests, except that they don't render views (unless you tell them to). So rather than saying: get notes_path(1,1) you want to say: get :show, :writer_id => "1", :note_id => "1" Give that a shot and let us know if it works out. Cheers, David On 9/14/07, Andreas Wolff wrote: > Hey everyone. > I really stuck on testing a nested controller. I'm trying to make a > request using get and afterwards checking the response by > response.should ... > > My routes.rb looks like this: > > map.resources :writers do |writers| > writers.resources :notes > end > > > In my notes_controller_spec.rb > > def do_get > writer_id = 1 > note_id = 1 > get note_path(writer_id, note_id) > end > > it "should show a note" do > do_get > response.should be_success > end > > > But this always ends in an error message: > You have a nil object when you didn't expect it! > The error occurred while evaluating nil.rewrite > > Can anybody help here?? > > -- > by(e) > Andreas Wolff > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From omen.king at gmail.com Sun Sep 23 00:08:36 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 23 Sep 2007 00:08:36 -0400 Subject: [rspec-users] Testing RESTful routes In-Reply-To: <46F5AA98.7020609@benmabey.com> References: <46F5AA98.7020609@benmabey.com> Message-ID: I'm currently in a simliar situation as you. I have an application that doesn't use the default routing. When I try to write my stories. ex. And "user logged in successfully" do post "/session/create", :login => "Jon", :password => "your_momma" response.should redirect_to(home_path) end The post fails unless I include this back into my routes file map.connect ':controller/:action/:id.:format' > map.connect ':controller/:action/:id' and even then when I add them back in they'll conflict with my other routes and I have to comment out all my other routes. But then it will pass. On 9/22/07, Ben Mabey wrote: > > Hi all, > The app I am making right now uses restful routing entirely. I want to > prevent people from accessing my actions without the proper HTTP verb so > I commented out the :controller/:action/:id catch all routes that were > used in pre-RESTful Rails apps. Like so: > #map.connect ':controller/:action/:id.:format' > #map.connect ':controller/:action/:id' > When I did this however all of my routing specs broke. I have been > testing my routes like the rspec-scaffold generator tests them: > it "{ :controller => 'users', :action => 'new' } to /users/new" do > route_for(:controller => "users", :action => "new").should == > "/users/new" > end > > To get around this the easiest thing I could think of was to add this to > my routes.rb: > if RAILS_ENV=="test" > map.connect ':controller/:action/:id.:format' > map.connect ':controller/:action/:id' > end > > Are there better solutions? > This is a workaround for the problem, but I'm wondering if there is a > better way to test restful routes without relying on the old routing > convention of controller/action/id. Ideally, the routing specs should > also verify the HTTP verb as well. Is there any way to do this? > > Thanks, > Ben > _______________________________________________ > 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/20070923/4de370f1/attachment.html From omen.king at gmail.com Sun Sep 23 01:38:00 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 23 Sep 2007 01:38:00 -0400 Subject: [rspec-users] Story Runner, autoincrementing Message-ID: I've written a story and I run into a snag. I've written the create_forum method and told it to set the id to 1 but when it creates the forum the id is autoincremented. My forums table is empty but the id keeps incrementing the newest record on creation. When I run the story it comes out as something like 59 which fails my story because I'm asking it to look at /forums/1 I thought of using my named routes instead of specifying the path as a string. That worked up until the point when I reached: When "creating a new topic titled", "Nicks Mom" do |title| post topics(@forum, ??? ), :topic => { :title => title, :body => "She is teh hotZ!" } end The problem was since its a nested routed I couldn't complete the post request without specifying the topic_id. But since the topic hasn't been created yet their is no way (that I know of) to pass the id since I don't know what it will be. I would think the better practice is to state the paths as strings instead of using the nested routes. require File.join(File.dirname(__FILE__), "helper") Story "User creates a new topic", %{ As a user I want to create a new topic So that I can dicuss Nick's Mom }, :type => RailsStory do Scenario "Successfully create a new topic in the 'General' forum" do Given "a user named", "Jon" do |login| @user = create_user login end Given "a forum named", "General" do |name| @forum = create_forum name puts @forum.id end And "user logged in successfully and was redirect to", "/" do |path| post "/session/create", :login => "Jon", :password => "your_momma" response.should redirect_to("/") end And "user is looking at", "/forums/1" do |path| get path response.should be_success end When "creating a new topic titled", "Nicks Mom" do |title| post "/forums/1/topics/1/create", :topic => { :id => 1, :title => title, :body => "She is teh hotZ!" } end Then "user should be redirected to", "/forums/1/topics/1" do |path| get path response.should be_success end end Scenario "Failed creating a new topic due to blank fields" do; end Scenario "Sticky a new thread" do; end Scenario "Annoucment as a new thread" do; end end def create_user(login) user = User.create!( :login => login, :email => "your at momma.com", :password => "your_momma", :password_confirmation => "your_momma", :display_name => "Jon") user end def create_forum(name) forum = Forum.create!( :id => 1, :name => name, :description => "Everything from the latest gossip to the coolest youtube videos.") forum end How do I stop the incrementing? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070923/f565628c/attachment.html From pergesu at gmail.com Sun Sep 23 02:16:31 2007 From: pergesu at gmail.com (Pat Maddox) Date: Sat, 22 Sep 2007 23:16:31 -0700 Subject: [rspec-users] Story Runner, autoincrementing In-Reply-To: References: Message-ID: <810a540e0709222316u2eb53a38y4df688e474bcecc1@mail.gmail.com> On 9/22/07, Andrew WC Brown wrote: > I've written a story and I run into a snag. > I've written the create_forum method and told it to set the id to 1 > but when it creates the forum the id is autoincremented. > My forums table is empty but the id keeps incrementing the newest record on > creation. > When I run the story it comes out as something like 59 which fails my story > because I'm asking it to look at /forums/1 > > I thought of using my named routes instead of specifying the path as a > string. > That worked up until the point when I reached: > > When "creating a new topic titled", "Nicks Mom" do |title| > post topics(@forum, ??? ), :topic => { :title => title, :body => "She is > teh hotZ!" } > end > > The problem was since its a nested routed I couldn't complete the post > request without specifying the topic_id. > But since the topic hasn't been created yet their is no way (that I know of) > to pass the id since I don't know what it will be. > > I would think the better practice is to state the paths as strings instead > of using the nested routes. > > > > require File.join(File.dirname(__FILE__), "helper") > > Story "User creates a new topic", %{ > As a user > I want to create a new topic > So that I can dicuss Nick's Mom > }, :type => RailsStory do > > Scenario "Successfully create a new topic in the 'General' forum" do > > Given "a user named", "Jon" do |login| > @user = create_user login > end > Given "a forum named", "General" do |name| > @forum = create_forum name > puts @forum.id > end > > And "user logged in successfully and was redirect to", "/" do |path| > post "/session/create", :login => "Jon", :password => "your_momma" > response.should redirect_to("/") > end > > And "user is looking at", "/forums/1" do |path| > get path > response.should be_success > end > > When "creating a new topic titled", "Nicks Mom" do |title| > post "/forums/1/topics/1/create", :topic => { :id => 1, :title => > title, :body => "She is teh hotZ!" } > end > > Then "user should be redirected to", "/forums/1/topics/1" do |path| > get path > response.should be_success > end > > end > > Scenario "Failed creating a new topic due to blank fields" do; end > Scenario "Sticky a new thread" do; end > Scenario "Annoucment as a new thread" do; end > end > > def create_user(login) > user = User.create!( > :login => login, > :email => " your at momma.com", > :password => "your_momma", > :password_confirmation => "your_momma", > :display_name => "Jon") > user > end > > def create_forum(name) > forum = Forum.create!( > :id => 1, > :name => name, > :description => "Everything from the latest gossip to the coolest > youtube videos.") > forum > end > > > How do I stop the incrementing? > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > You don't stop the incrementing (at least afaik). That's a db thing. You'd have to drop and recreate the db between runs. The good news is that the instance variables that you created are available everywhere within the Scenario. I wrote a story that is very similar to yours. I only rebuilt the bits that were relevant to the test: require File.join(File.dirname(__FILE__), "helper") Story "User creates a new topic", %{ As a user I want to create a new topic So that I can dicuss Nick's Mom }, :type => RailsStory do Scenario "Successfully create a new topic in the 'General' forum" do Given "a user named", "Jon" do |login| @user = create_user login end Given "a forum named", "General" do |name| @forum = create_forum name end When "creating a new topic titled", "Nicks Mom" do |title| post_via_redirect "/forums/#{@forum.to_param}/topics", :topic => { :title => title } end Then "user should see", "topics/show" do |template| response.should render_template(template) end And "page should show", "Nicks Mom" do |title| response.should have_text(/Title: #{title}/) end end end def create_user(name) user = User.create! :name => name user end def create_forum(name) forum = Forum.create!( :name => name, :description => "Everything from the latest gossip to the coolest youtube videos.") forum end You can see I did a couple things differently: * Use the forum ID in the url * Use post_via_redirect * Specify the template and some text that should be shown The first item solves the problem of the autoincrementing ID, at least for the forum_id part of the URL. Your story is actually a bit broken, imo. You POST the new topic and then GET a url. But how does the user know what that URL is? More likely you're redirecting them to the right URL. You should use post_via_redirect because the user makes a post and then follows the redirect. You'll have a controller spec that specifies what the redirect url should be. Brief example it "should redirect to the topic's show page" do do_post response.should redirect_to(topic_url(@mock_topic)) end The story allows you to specify the external behavior, which is that the user POSTs to a url and then gets redirected to a page showing the topic. The controller spec lets you specify the internal behavior, which includes the correct redirect url. hth Pat From dan at tastapod.com Sun Sep 23 05:32:39 2007 From: dan at tastapod.com (Dan North) Date: Sun, 23 Sep 2007 10:32:39 +0100 Subject: [rspec-users] Getting Started with Story Runner In-Reply-To: <765a2c230709220857pd101c2diea3d392e880072a8@mail.gmail.com> References: <46F22350.6060209@benmabey.com> <765a2c230709200625w43d36a30q7532a3dbf9de75d4@mail.gmail.com> <765a2c230709220857pd101c2diea3d392e880072a8@mail.gmail.com> Message-ID: <46F632B7.70906@tastapod.com> Hi James. James Hughes wrote: > > Your code looks correct. > My interpretation of the workflow that derives from this tool is that > you write a high level story like you have here, run it, and let it > tell you what to do next. The stack trace is telling you that you need > an Account class. So now you would drop down to the object level and > write a spec for Account (this is a Rails Story, so you'd write a > model spec). Once you have that passing, you might come back up to the > story level and re-run it, at which point it might tell you that it > doesn't know about the balance() method on your account object; this > would depend on how detailed you got in your model spec. > > I'm a total noob with this tool as well, so others on this list might > have different insights; For a total noob you're right on the money! The reason there isn't a story "generator" is that the story and scenarios should evolve as the output of a conversation between the tester/analyst and developer. You start with a (failing) scenario which identifies your "outermost" objects - in this case an Account. Then you drop into "traditional" TDD mode - or what we have started calling coding-by-example - to drive out the behaviour of the Account. Doing this you will probably discover other domain objects or services - say an AccountHolder or a BalanceTransferService - that you initially mock out to describe the behaviour of the Account. Then you implement the AccountHolder and BalanceTransferService in the same way, discovering other objects as you go, until you have concrete versions of each of the players in the scenario. Once these are all done, your scenario will work, and you're ready to move onto the next scenario. This is what I mean by outside-in, which is different from both top-down (a module-wise breakdown of functionality) and bottom-up (start adding behaviour to objects and worry about tying them together later on). Right now, the story runner is less helpful than it could be (which is an ongoing conversation I'm having with David Chelimsky - short version, he's right). The story runner /should/ visit every step in each scenario. When the first step fails, it should carry on to all the subsequent steps and at least tell you what they are even if it doesn't execute them. That way you get the immediate feedback of failing fast, but you still see all the other steps in the scenario so you get a sense of context. Right now, it fails fast on the first failing step (which is correct) but it doesn't then carry on to tell you about the subsequent steps (which is wrong). > I'd be interested in hearing other > perspectives on how detailed you'd get the first time you drill down > to the object level: would you spec out the object completely as > specified at the high level and then verify that it satisfies the > story, or would you keep ping-ponging back and forth between the two > levels? > You ping-pong at the granularity of a scenario. In other words, you get the scenario failing and then work inwards until you have all the moving parts to make the scenario work (and no more). Then you ping-pong up to the next scenario and work inwards again. It's more like a pulse than a ping-pong. In reality, I find I run the scenarios quite often anyway to remind myself where I am and what the next unimplemented thing is. > James > Cheers, Dan >> On 9/21/07, Evan David Light wrote: >> >>> There are also a couple of examples buried in the trunk under >>> >> examples/story/game-of-life/behaviour/stories >> >>> >>> >>> On Sep 20, 2007, at 10:13 AM, Andrew WC Brown wrote: >>> >>> I'm guessing their isn't a generator for stories yet? >>> >>> ./script/generate story add_person >>> >>> >>> On 9/20/07, James Hughes < hughes.james at gmail.com> wrote: >>> >>>> On 9/20/07, Ben Mabey < ben at benmabey.com> wrote: >>>> >>>>> Andrew WC Brown wrote: >>>>> >>>>>> I haven't found any How To's to use story runner and I'm not sure >>>>>> >> how >> >>>>>> to get started. >>>>>> Should I be looking for resources on how to use rbehave? >>>>>> How do I generate my first Story? >>>>>> >>>>>> >> ------------------------------------------------------------------------ >> >>>>>> _______________________________________________ >>>>>> rspec-users mailing list >>>>>> rspec-users at rubyforge.org >>>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>>> >>>>> Pat wrote up an awesome tutorial/example: >>>>> >>>>> >>>>> >> http://evang.eli.st/blog/2007/9/1/user-stories-with-rspec-s-story-runner >> >>>>> That should get you started. >>>>> >>>>> >>>> This pastie may be of use as well: >>>> >>>> http://pastie.caboo.se/92472 >>>> >>>> James >>>> _______________________________________________ >>>> 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 >>> >>> >> >> -- >> Monsterbox Productions >> putting small businesses on-line >> >> 1319 Victoria Avenue East >> Thunder Bay, Ontario P7C 1C3 >> Canada >> >> Andrew WC Brown >> web-developer and owner >> andrew at monsterboxpro.com >> P: 807-626-9009 >> F: 807-624-2705 >> _______________________________________________ >> 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/20070923/9fe42583/attachment.html From omen.king at gmail.com Sun Sep 23 10:13:59 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 23 Sep 2007 10:13:59 -0400 Subject: [rspec-users] Story Runner, autoincrementing In-Reply-To: <810a540e0709222316u2eb53a38y4df688e474bcecc1@mail.gmail.com> References: <810a540e0709222316u2eb53a38y4df688e474bcecc1@mail.gmail.com> Message-ID: That''s much more clear I noticed you omitted And "user logged in successfully" do |path| post_via_redirect "/session", :login => "Jon", :password => "your_momma" end My user is required to be login so without this story the test will fail. Now should this be in my story because I'm not testing the if login works. Anyway to share it with all my stories or should I move this line into my create_user function? On 9/23/07, Pat Maddox wrote: > > On 9/22/07, Andrew WC Brown wrote: > > I've written a story and I run into a snag. > > I've written the create_forum method and told it to set the id to 1 > > but when it creates the forum the id is autoincremented. > > My forums table is empty but the id keeps incrementing the newest record > on > > creation. > > When I run the story it comes out as something like 59 which fails my > story > > because I'm asking it to look at /forums/1 > > > > I thought of using my named routes instead of specifying the path as a > > string. > > That worked up until the point when I reached: > > > > When "creating a new topic titled", "Nicks Mom" do |title| > > post topics(@forum, ??? ), :topic => { :title => title, :body => "She > is > > teh hotZ!" } > > end > > > > The problem was since its a nested routed I couldn't complete the post > > request without specifying the topic_id. > > But since the topic hasn't been created yet their is no way (that I know > of) > > to pass the id since I don't know what it will be. > > > > I would think the better practice is to state the paths as strings > instead > > of using the nested routes. > > > > > > > > require File.join(File.dirname(__FILE__), "helper") > > > > Story "User creates a new topic", %{ > > As a user > > I want to create a new topic > > So that I can dicuss Nick's Mom > > }, :type => RailsStory do > > > > Scenario "Successfully create a new topic in the 'General' forum" do > > > > Given "a user named", "Jon" do |login| > > @user = create_user login > > end > > Given "a forum named", "General" do |name| > > @forum = create_forum name > > puts @forum.id > > end > > > > And "user logged in successfully and was redirect to", "/" do |path| > > post "/session/create", :login => "Jon", :password => "your_momma" > > > response.should redirect_to("/") > > end > > > > And "user is looking at", "/forums/1" do |path| > > get path > > response.should be_success > > end > > > > When "creating a new topic titled", "Nicks Mom" do |title| > > post "/forums/1/topics/1/create", :topic => { :id => 1, :title => > > title, :body => "She is teh hotZ!" } > > end > > > > Then "user should be redirected to", "/forums/1/topics/1" do |path| > > get path > > response.should be_success > > end > > > > end > > > > Scenario "Failed creating a new topic due to blank fields" do; end > > Scenario "Sticky a new thread" do; end > > Scenario "Annoucment as a new thread" do; end > > end > > > > def create_user(login) > > user = User.create!( > > :login => login, > > :email => " your at momma.com", > > :password => "your_momma", > > :password_confirmation => "your_momma", > > :display_name => "Jon") > > user > > end > > > > def create_forum(name) > > forum = Forum.create!( > > :id => 1, > > :name => name, > > :description => "Everything from the latest gossip to the coolest > > youtube videos.") > > forum > > end > > > > > > How do I stop the incrementing? > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > You don't stop the incrementing (at least afaik). That's a db thing. > You'd have to drop and recreate the db between runs. The good news is > that the instance variables that you created are available everywhere > within the Scenario. > > I wrote a story that is very similar to yours. I only rebuilt the > bits that were relevant to the test: > > require File.join(File.dirname(__FILE__), "helper") > > Story "User creates a new topic", %{ > As a user > I want to create a new topic > So that I can dicuss Nick's Mom > }, :type => RailsStory do > > Scenario "Successfully create a new topic in the 'General' forum" do > > Given "a user named", "Jon" do |login| > @user = create_user login > end > Given "a forum named", "General" do |name| > @forum = create_forum name > end > > When "creating a new topic titled", "Nicks Mom" do |title| > post_via_redirect "/forums/#{@forum.to_param}/topics", :topic => > { :title => title } > end > > Then "user should see", "topics/show" do |template| > response.should render_template(template) > end > > And "page should show", "Nicks Mom" do |title| > response.should have_text(/Title: #{title}/) > end > end > end > > def create_user(name) > user = User.create! :name => name > user > end > > def create_forum(name) > forum = Forum.create! ( > :name => name, > :description => "Everything from the latest gossip to the coolest > youtube videos.") > forum > end > > You can see I did a couple things differently: > > * Use the forum ID in the url > * Use post_via_redirect > * Specify the template and some text that should be shown > > The first item solves the problem of the autoincrementing ID, at least > for the forum_id part of the URL. > > Your story is actually a bit broken, imo. You POST the new topic and > then GET a url. But how does the user know what that URL is? More > likely you're redirecting them to the right URL. You should use > post_via_redirect because the user makes a post and then follows the > redirect. > > You'll have a controller spec that specifies what the redirect url > should be. Brief example > > it "should redirect to the topic's show page" do > do_post > response.should redirect_to(topic_url(@mock_topic)) > end > > The story allows you to specify the external behavior, which is that > the user POSTs to a url and then gets redirected to a page showing the > topic. The controller spec lets you specify the internal behavior, > which includes the correct redirect url. > > hth > > Pat > _______________________________________________ > 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/20070923/4d47d523/attachment-0001.html From james.deville at gmail.com Sun Sep 23 10:26:20 2007 From: james.deville at gmail.com (Jim Deville) Date: Sun, 23 Sep 2007 10:26:20 -0400 Subject: [rspec-users] Zentest and rspec In-Reply-To: <5cd596d60709191013t384e0c61h4e1e0b038d279ea6@mail.gmail.com> References: <5cd596d60709190854o5ae00558t45bc563abd723c18@mail.gmail.com> <49f64a900709190855o16d459cas17d4eefb52916b25@mail.gmail.com> <5cd596d60709191013t384e0c61h4e1e0b038d279ea6@mail.gmail.com> Message-ID: <9BA03C4C-1E54-44DF-8429-07EEEC52898A@gmail.com> If you're on Mac and a fan of Growl, you can also check out an article I wrote/updated at http://devillecompanies.org/2007/08/14/ growl-autotest-and-rspec-108 Enjoy. Jim Deville On Sep 19, 2007, at 1:13 PM, Jim Freeze wrote: > On 9/19/07, Lance Carlson wrote: > http://grasprubyonrails.com/2007/9/17/rspec-and-autotest > > > Thanks Lance, but the link seems to be about rspec + autotest + > rails. > I need sans rails, i.e., rspec + autotest + ruby. > > Jim > > > read the comment I posted too. Comment on it if you have any problems. > > On 9/19/07, Jim Freeze wrote: > > Hi guys > > > > I'm new to rspec and was wondering if there is a quick setup to > get it to > > work with autotest, sans rails. > > > > Thanks > > > > > > -- > > Jim Freeze > > _______________________________________________ > > 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 > > > > -- > Jim Freeze > _______________________________________________ > 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/20070923/8882e7fd/attachment.html From omen.king at gmail.com Sun Sep 23 11:01:34 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 23 Sep 2007 11:01:34 -0400 Subject: [rspec-users] Story Runner, autoincrementing In-Reply-To: References: <810a540e0709222316u2eb53a38y4df688e474bcecc1@mail.gmail.com> Message-ID: I didn't notice that when you create a second story you'd just omit the blocks that were run in the previous scenario This is my second scenario Scenario "Failed creating a new topic due to error" do Given "a user named", "Jon" Given "a forum named", "General" And "user logged in successfully" When "creating a new topic titled", "Nicks Mom" do |title| post_via_redirect "/forums/#{@forum.to_param}/topics", :topic => { :title => nil, :body => nil } end Then "user should see", "topics/new" do |template| response.should render_template(template) end And "page should show", "Error" do |title| response.should have_text(/#{title}/) end end Is there a better way to test for errors or would this be the appropriate way? On 9/23/07, Andrew WC Brown wrote: > > That''s much more clear > > I noticed you omitted > And "user logged in successfully" do |path| > post_via_redirect "/session", :login => "Jon", :password => > "your_momma" > end > > My user is required to be login so without this story the test will fail. > Now should this be in my story because I'm not testing the if login works. > Anyway to share it with all my stories or should I move this line into my > create_user function? > > On 9/23/07, Pat Maddox wrote: > > > > On 9/22/07, Andrew WC Brown wrote: > > > I've written a story and I run into a snag. > > > I've written the create_forum method and told it to set the id to 1 > > > but when it creates the forum the id is autoincremented. > > > My forums table is empty but the id keeps incrementing the newest > > record on > > > creation. > > > When I run the story it comes out as something like 59 which fails my > > story > > > because I'm asking it to look at /forums/1 > > > > > > I thought of using my named routes instead of specifying the path as a > > > string. > > > That worked up until the point when I reached: > > > > > > When "creating a new topic titled", "Nicks Mom" do |title| > > > post topics(@forum, ??? ), :topic => { :title => title, :body => > > "She is > > > teh hotZ!" } > > > end > > > > > > The problem was since its a nested routed I couldn't complete the post > > > request without specifying the topic_id. > > > But since the topic hasn't been created yet their is no way (that I > > know of) > > > to pass the id since I don't know what it will be. > > > > > > I would think the better practice is to state the paths as strings > > instead > > > of using the nested routes. > > > > > > > > > > > > require File.join(File.dirname(__FILE__), "helper") > > > > > > Story "User creates a new topic", %{ > > > As a user > > > I want to create a new topic > > > So that I can dicuss Nick's Mom > > > }, :type => RailsStory do > > > > > > Scenario "Successfully create a new topic in the 'General' forum" do > > > > > > Given "a user named", "Jon" do |login| > > > @user = create_user login > > > end > > > Given "a forum named", "General" do |name| > > > @forum = create_forum name > > > puts @ forum.id > > > end > > > > > > And "user logged in successfully and was redirect to", "/" do > > |path| > > > post "/session/create", :login => "Jon", :password => > > "your_momma" > > > response.should redirect_to("/") > > > end > > > > > > And "user is looking at", "/forums/1" do |path| > > > get path > > > response.should be_success > > > end > > > > > > When "creating a new topic titled", "Nicks Mom" do |title| > > > post "/forums/1/topics/1/create", :topic => { :id => 1, :title > > => > > > title, :body => "She is teh hotZ!" } > > > end > > > > > > Then "user should be redirected to", "/forums/1/topics/1" do > > |path| > > > get path > > > response.should be_success > > > end > > > > > > end > > > > > > Scenario "Failed creating a new topic due to blank fields" do; end > > > Scenario "Sticky a new thread" do; end > > > Scenario "Annoucment as a new thread" do; end > > > end > > > > > > def create_user(login) > > > user = User.create!( > > > :login => login, > > > :email => " your at momma.com", > > > :password => "your_momma", > > > :password_confirmation => "your_momma", > > > :display_name => "Jon") > > > user > > > end > > > > > > def create_forum(name) > > > forum = Forum.create!( > > > :id => 1, > > > :name => name, > > > :description => "Everything from the latest gossip to the coolest > > > youtube videos.") > > > forum > > > end > > > > > > > > > How do I stop the incrementing? > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > You don't stop the incrementing (at least afaik). That's a db thing. > > You'd have to drop and recreate the db between runs. The good news is > > that the instance variables that you created are available everywhere > > within the Scenario. > > > > I wrote a story that is very similar to yours. I only rebuilt the > > bits that were relevant to the test: > > > > require File.join(File.dirname(__FILE__), "helper") > > > > Story "User creates a new topic", %{ > > As a user > > I want to create a new topic > > So that I can dicuss Nick's Mom > > }, :type => RailsStory do > > > > Scenario "Successfully create a new topic in the 'General' forum" do > > > > Given "a user named", "Jon" do |login| > > @user = create_user login > > end > > Given "a forum named", "General" do |name| > > @forum = create_forum name > > end > > > > When "creating a new topic titled", "Nicks Mom" do |title| > > post_via_redirect "/forums/#{@forum.to_param}/topics", :topic => > > { :title => title } > > end > > > > Then "user should see", "topics/show" do |template| > > response.should render_template(template) > > end > > > > And "page should show", "Nicks Mom" do |title| > > response.should have_text(/Title: #{title}/) > > end > > end > > end > > > > def create_user(name) > > user = User.create! :name => name > > user > > end > > > > def create_forum(name) > > forum = Forum.create ! ( > > :name => name, > > :description => "Everything from the latest gossip to the coolest > > youtube videos.") > > forum > > end > > > > You can see I did a couple things differently: > > > > * Use the forum ID in the url > > * Use post_via_redirect > > * Specify the template and some text that should be shown > > > > The first item solves the problem of the autoincrementing ID, at least > > for the forum_id part of the URL. > > > > Your story is actually a bit broken, imo. You POST the new topic and > > then GET a url. But how does the user know what that URL is? More > > likely you're redirecting them to the right URL. You should use > > post_via_redirect because the user makes a post and then follows the > > redirect. > > > > You'll have a controller spec that specifies what the redirect url > > should be. Brief example > > > > it "should redirect to the topic's show page" do > > do_post > > response.should redirect_to(topic_url(@mock_topic)) > > end > > > > The story allows you to specify the external behavior, which is that > > the user POSTs to a url and then gets redirected to a page showing the > > topic. The controller spec lets you specify the internal behavior, > > which includes the correct redirect url. > > > > hth > > > > Pat > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > -- Monsterbox Productions putting small businesses on-line 1319 Victoria Avenue East Thunder Bay, Ontario P7C 1C3 Canada Andrew WC Brown web-developer and owner andrew at monsterboxpro.com P: 807-626-9009 F: 807-624-2705 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070923/30376772/attachment.html From jarkster at gmail.com Sun Sep 23 01:57:10 2007 From: jarkster at gmail.com (Jarkko Laine) Date: Sun, 23 Sep 2007 08:57:10 +0300 Subject: [rspec-users] Story Runner, autoincrementing In-Reply-To: References: Message-ID: <909400ef0709222257qca0b8b4m7e27dadf544a778@mail.gmail.com> Sorry for top posting, this is all I get from the mobile gmail. You don't specify the id of the post when you create one. This is the same for all restful create actions. In case of nested routes, you give the parent resource as a param, with normal routes nothing: post forum_posts_path(@forum) Or post "/forums/1/posts/" That said, can't you also save the id when you create the object in a given block? //jarkko On 9/23/07, Andrew WC Brown wrote: > I've written a story and I run into a snag. > I've written the create_forum method and told it to set the id to 1 > but when it creates the forum the id is autoincremented. > My forums table is empty but the id keeps incrementing the newest record on > creation. > When I run the story it comes out as something like 59 which fails my story > because I'm asking it to look at /forums/1 > > I thought of using my named routes instead of specifying the path as a > string. > That worked up until the point when I reached: > > When "creating a new topic titled", "Nicks Mom" do |title| > post topics(@forum, ??? ), :topic => { :title => title, :body => "She is > teh hotZ!" } > end > > The problem was since its a nested routed I couldn't complete the post > request without specifying the topic_id. > But since the topic hasn't been created yet their is no way (that I know of) > to pass the id since I don't know what it will be. > > I would think the better practice is to state the paths as strings instead > of using the nested routes. > > > > require File.join(File.dirname(__FILE__), "helper") > > Story "User creates a new topic", %{ > As a user > I want to create a new topic > So that I can dicuss Nick's Mom > }, :type => RailsStory do > > Scenario "Successfully create a new topic in the 'General' forum" do > > Given "a user named", "Jon" do |login| > @user = create_user login > end > Given "a forum named", "General" do |name| > @forum = create_forum name > puts @forum.id > end > > And "user logged in successfully and was redirect to", "/" do |path| > post "/session/create", :login => "Jon", :password => "your_momma" > response.should redirect_to("/") > end > > And "user is looking at", "/forums/1" do |path| > get path > response.should be_success > end > > When "creating a new topic titled", "Nicks Mom" do |title| > post "/forums/1/topics/1/create", :topic => { :id => 1, :title => > title, :body => "She is teh hotZ!" } > end > > Then "user should be redirected to", "/forums/1/topics/1" do |path| > get path > response.should be_success > end > > end > > Scenario "Failed creating a new topic due to blank fields" do; end > Scenario "Sticky a new thread" do; end > Scenario "Annoucment as a new thread" do; end > end > > def create_user(login) > user = User.create!( > :login => login, > :email => "your at momma.com", > :password => "your_momma", > :password_confirmation => "your_momma", > :display_name => "Jon") > user > end > > def create_forum(name) > forum = Forum.create!( > :id => 1, > :name => name, > :description => "Everything from the latest gossip to the coolest > youtube videos.") > forum > end > > > How do I stop the incrementing? > -- -- Jarkko Laine http://jlaine.net http://odesign.fi From flyeminent at hotmail.com Sun Sep 23 23:43:30 2007 From: flyeminent at hotmail.com (Shaker) Date: Sun, 23 Sep 2007 20:43:30 -0700 (PDT) Subject: [rspec-users] Is Rcov working with Jruby now? Message-ID: <12853457.post@talk.nabble.com> Hello everyone: I am currently assigned to test a big project which uses JRuby to build a web application. The reason of using JRuby is the web application is communicating with Java Service. I am writing test cases using Rspec and looking for a code coverage tool. Rcov is no doubt a nice code coverage tool. However, it is said that Rcov is not compatible with JRuby so far. Sigh....I can not find any other code coverage tools for JRuby. Some developers are working on this problem. So I am wondering whether there are any progresses so far? Or are there any alternative code coverage tools for JRuby? -- View this message in context: http://www.nabble.com/Is-Rcov-working-with-Jruby-now--tf4506880.html#a12853457 Sent from the rspec-users mailing list archive at Nabble.com. From aslak.hellesoy at gmail.com Mon Sep 24 03:48:28 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 24 Sep 2007 09:48:28 +0200 Subject: [rspec-users] Is Rcov working with Jruby now? In-Reply-To: <12853457.post@talk.nabble.com> References: <12853457.post@talk.nabble.com> Message-ID: <8d961d900709240048k3aae794fx8a0305f7da466ea1@mail.gmail.com> On 9/24/07, Shaker wrote: > > Hello everyone: > I am currently assigned to test a big project which uses JRuby to build a > web application. The reason of using JRuby is the web application is > communicating with Java Service. I am writing test cases using Rspec and > looking for a code coverage tool. Rcov is no doubt a nice code coverage > tool. However, it is said that Rcov is not compatible with JRuby so far. > Sigh....I can not find any other code coverage tools for JRuby. Some > developers are working on this problem. So I am wondering whether there are > any progresses so far? Or are there any alternative code coverage tools for > JRuby? I think you're on the wrong mailing list. I would ask on the JRuby list or contact the RCov creator. But no, I don't think RCov (C code) has been implemented for JRuby. > -- > View this message in context: http://www.nabble.com/Is-Rcov-working-with-Jruby-now--tf4506880.html#a12853457 > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From geoffrey.wiseman at gmail.com Mon Sep 24 07:56:31 2007 From: geoffrey.wiseman at gmail.com (Geoffrey Wiseman) Date: Mon, 24 Sep 2007 07:56:31 -0400 Subject: [rspec-users] Is Rcov working with Jruby now? In-Reply-To: <8d961d900709240048k3aae794fx8a0305f7da466ea1@mail.gmail.com> References: <12853457.post@talk.nabble.com> <8d961d900709240048k3aae794fx8a0305f7da466ea1@mail.gmail.com> Message-ID: <835d522e0709240456g60527d69i3609cf9de76e7c7a@mail.gmail.com> On 9/24/07, aslak hellesoy wrote: > > I think you're on the wrong mailing list. > > I would ask on the JRuby list or contact the RCov creator. But no, I > don't think RCov (C code) has been implemented for JRuby. Someone was working on a JRuby port of RCov, but do ask on the JRuby list. - Geoffrey -- Geoffrey Wiseman -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070924/b1530699/attachment.html From bkeepers at gmail.com Mon Sep 24 18:01:31 2007 From: bkeepers at gmail.com (Brandon Keepers) Date: Mon, 24 Sep 2007 18:01:31 -0400 Subject: [rspec-users] rcov including ruby lib Message-ID: <319F343F-0B0C-4A2C-A379-60F2D7015515@gmail.com> When I run spec:rcov on my continuous integration server, the rcov report is including many other libraries in the report, including some from standard lib and gems. Has anyone else had this problem or have any ideas for how to limit it just to coverage of code in app/ and lib/? Thanks, Brandon -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 186 bytes Desc: This is a digitally signed message part Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070924/ae43959f/attachment.bin From brandon at collectiveidea.com Mon Sep 24 17:27:18 2007 From: brandon at collectiveidea.com (Brandon Keepers) Date: Mon, 24 Sep 2007 17:27:18 -0400 Subject: [rspec-users] rcov including ruby lib Message-ID: When I run spec:rcov on my continuous integration server, the rcov report is including many other libraries in the report, including some from standard lib and gems. Has anyone else had this problem or have any ideas for how to limit it just to coverage of code in app/ and lib/? Thanks, Brandon -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 186 bytes Desc: This is a digitally signed message part Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070924/9958215a/attachment.bin From aslak.hellesoy at gmail.com Tue Sep 25 01:25:31 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 25 Sep 2007 07:25:31 +0200 Subject: [rspec-users] rcov including ruby lib In-Reply-To: References: Message-ID: <8d961d900709242225x4fff1638i9138910f75a3b023@mail.gmail.com> On 9/24/07, Brandon Keepers wrote: > When I run spec:rcov on my continuous integration server, the rcov > report is including many other libraries in the report, including > some from standard lib and gems. Has anyone else had this problem or > have any ideas for how to limit it just to coverage of code in app/ > and lib/? > Read the RCov manual and pass command line options to it via the RSpec rake task's rcov_opts attribute. Aslak > Thanks, > Brandon > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From eivindu at ifi.uio.no Tue Sep 25 05:06:35 2007 From: eivindu at ifi.uio.no (Eivind Uggedal) Date: Tue, 25 Sep 2007 11:06:35 +0200 Subject: [rspec-users] rcov including ruby lib In-Reply-To: <319F343F-0B0C-4A2C-A379-60F2D7015515@gmail.com> References: <319F343F-0B0C-4A2C-A379-60F2D7015515@gmail.com> Message-ID: <824b51d00709250206u273d2629tcc20ac86bc0167b5@mail.gmail.com> On 9/25/07, Brandon Keepers wrote: > When I run spec:rcov on my continuous integration server, the rcov > report is including many other libraries in the report, including > some from standard lib and gems. Has anyone else had this problem or > have any ideas for how to limit it just to coverage of code in app/ > and lib/? > Make a custom rake task in lib/tasks (or run rcov manually) with one or several --exclude statements: % rcov | grep -A 1 exclude -x, --exclude PATTERNS Don't generate info for files matching a pattern (comma-separated regexp list) --exclude-only PATTERNS Skip info only for files matching the given patterns. Here's an example of such a rake task from my latest project: http://pastie.caboo.se/100531 -- Cheers, Eivind Uggedal Engineer, Faculty of Social Science, MSc Computer Science, University of Oslo From smingins at elctech.com Tue Sep 25 06:16:18 2007 From: smingins at elctech.com (Shane Mingins) Date: Tue, 25 Sep 2007 22:16:18 +1200 Subject: [rspec-users] Autotest with RSpec Rails and Engines Message-ID: <508B84A5-9262-454F-82FB-882D5A3B5856@elctech.com> Hi We have a Rails project using an engine which I want to run autotest with rspec against. So the project specific specs are in the specs directory but the common specs are in the specs directory of the engine plugin (e.g. vendor/plugin/engine/specs) Just wondering where I would be looking to change configuration so that autotest will also look for the specs in the engine directory? is there some way of configuring using a .autotest file? The tests_for_file method did not seem to be what I wanted in that it determines the spec to run for a file where I want to determine the files themselves? It would seem that the initialize method of the class Autotest::RailsRspec sets up where it is finding the tests, yes? And is it here that I should be looking to change? And pointers would be appreciated. Cheers Shane -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070925/8bb00e81/attachment.html From galeal_lists at ideaforge.org Tue Sep 25 08:15:24 2007 From: galeal_lists at ideaforge.org (Luke Galea) Date: Tue, 25 Sep 2007 08:15:24 -0400 Subject: [rspec-users] Odd response.body behavior In-Reply-To: <8D40E82A-EAB5-477D-A470-F1424A0978EC@ideaforge.org> References: <8D40E82A-EAB5-477D-A470-F1424A0978EC@ideaforge.org> Message-ID: <518DBBB1-9B23-4994-8338-A4E6CAFBB770@ideaforge.org> Sorry to bump myself here: But this behavior is really messing my tests up. If anyone has any insight I'd really appreciate it. Even in a debugger, the value of response.body is the name of the template rather than the content, but only in the test and only in a few cases. Works fine in dev. Perhaps it's a rails issue rather than an rspec issue? -- Luke On 22-Sep-07, at 11:17 AM, Luke Galea wrote: > Hi all, > > I'm having very odd behavior, but only with a few of my specs. > > I'm checking the value of response.body and in most cases finding it > to be the content of the body... but in some cases it's the name of > the template rendered!! There's no rhyme or reason I can see, but > obviously my tests fail for no reason when I expect the body to > contain the content. > > Any idea what is happening? > > Thanks in advance! > > Luke > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Tue Sep 25 08:24:08 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 25 Sep 2007 07:24:08 -0500 Subject: [rspec-users] Odd response.body behavior In-Reply-To: <518DBBB1-9B23-4994-8338-A4E6CAFBB770@ideaforge.org> References: <8D40E82A-EAB5-477D-A470-F1424A0978EC@ideaforge.org> <518DBBB1-9B23-4994-8338-A4E6CAFBB770@ideaforge.org> Message-ID: <57c63afe0709250524l462edc63r827eac7dacb5c68e@mail.gmail.com> On 9/25/07, Luke Galea wrote: > Sorry to bump myself here: But this behavior is really messing my > tests up. If anyone has any insight I'd really appreciate it. > > Even in a debugger, the value of response.body is the name of the > template rather than the content, but only in the test and only in a > few cases. Works fine in dev. > > Perhaps it's a rails issue rather than an rspec issue? I'm fairly certain this is a rails issue. When you see a response object, it is the one provided by the Rails testing framework. In fairness, there is some extension of response in rspec, but nothing that changes the nature of response.body. So I'd check w/ the rails list. > > -- Luke > > On 22-Sep-07, at 11:17 AM, Luke Galea wrote: > > > Hi all, > > > > I'm having very odd behavior, but only with a few of my specs. > > > > I'm checking the value of response.body and in most cases finding it > > to be the content of the body... but in some cases it's the name of > > the template rendered!! There's no rhyme or reason I can see, but > > obviously my tests fail for no reason when I expect the body to > > contain the content. > > > > Any idea what is happening? > > > > Thanks in advance! > > > > Luke > > _______________________________________________ > > 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 matt-lists at reprocessed.org Tue Sep 25 10:43:58 2007 From: matt-lists at reprocessed.org (Matt Patterson) Date: Tue, 25 Sep 2007 15:43:58 +0100 Subject: [rspec-users] Problems with expect_render Message-ID: <4EAEFE2F-49B7-449E-83B5-3774A78A8316@reprocessed.org> Hi there, I've been working with RSpec for about a week now, and the process of moving from a Test::Unit + Mocha setup to an RSpec + Mocha environment has been pretty straightforward. Except, I'm having problems with using template.expect_render. I have Mocha enabled with: > config.mock_with :mocha in spec_helper. And then I have a view spec which looks like this: > it "should explode messily because I have made this partial name > up" do > template.expect_render(:partial => 'does_not_exist', :object => > "hello") > render "/a/real/template" > end If I run this spec, it passes, which it really shouldn't. If I comment out the config.mock_with :mocha line and re-run the spec, it fails with: > Mock 'expect_render_mock_proxy' expected :render with > ({:partial=>"does_not_exist", :object=>"hello"}) once, but received > it 0 times Which is much better. So, to me, this looks like a bug in rspec_on_rails. Explanations of why I'm just doing it wrong gratefully received ;-) Matt -- Matt Patterson | Design & Code | http://www.reprocessed.org/ From dchelimsky at gmail.com Tue Sep 25 11:06:19 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 25 Sep 2007 10:06:19 -0500 Subject: [rspec-users] Problems with expect_render In-Reply-To: <4EAEFE2F-49B7-449E-83B5-3774A78A8316@reprocessed.org> References: <4EAEFE2F-49B7-449E-83B5-3774A78A8316@reprocessed.org> Message-ID: <57c63afe0709250806h47dcb0f8s9b8398e7b05a259b@mail.gmail.com> On 9/25/07, Matt Patterson wrote: > Hi there, > > I've been working with RSpec for about a week now, and the process of > moving from a Test::Unit + Mocha setup to an RSpec + Mocha > environment has been pretty straightforward. > > Except, I'm having problems with using template.expect_render. > > I have Mocha enabled with: It is not documented as such, but expect_render does not work with mocha. It uses rspec's underlying mock framework. Please feel free to submit a feature request for this. Cheers, David > > > config.mock_with :mocha > > in spec_helper. And then I have a view spec which looks like this: > > > it "should explode messily because I have made this partial name > > up" do > > template.expect_render(:partial => 'does_not_exist', :object => > > "hello") > > render "/a/real/template" > > end > > If I run this spec, it passes, which it really shouldn't. If I > comment out the config.mock_with :mocha line and re-run the spec, it > fails with: > > > Mock 'expect_render_mock_proxy' expected :render with > > ({:partial=>"does_not_exist", :object=>"hello"}) once, but received > > it 0 times > > Which is much better. > > So, to me, this looks like a bug in rspec_on_rails. > > Explanations of why I'm just doing it wrong gratefully received ;-) > > Matt > > -- > Matt Patterson | Design & Code > | http://www.reprocessed.org/ > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From davidj503 at gmail.com Tue Sep 25 11:20:45 2007 From: davidj503 at gmail.com (David James) Date: Tue, 25 Sep 2007 11:20:45 -0400 Subject: [rspec-users] Testing for particular CSS (i.e. display: none) Message-ID: <59b5d4330709250820i75bd93dx38c53674ac0305a2@mail.gmail.com> I have a page that hides elements using CSS display: none. I don't expect RSpec to test any changes made by Javascript; I just want to test how the page loads initially: what is visible and what is not. Can I test this in RSpec? Or do I need to use something like Selenium? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070925/8245f14b/attachment.html From dchelimsky at gmail.com Tue Sep 25 11:27:53 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 25 Sep 2007 10:27:53 -0500 Subject: [rspec-users] Testing for particular CSS (i.e. display: none) In-Reply-To: <59b5d4330709250820i75bd93dx38c53674ac0305a2@mail.gmail.com> References: <59b5d4330709250820i75bd93dx38c53674ac0305a2@mail.gmail.com> Message-ID: <57c63afe0709250827s422344e2q9509f343f9aa6902@mail.gmail.com> On 9/25/07, David James wrote: > I have a page that hides elements using CSS display: none. > > I don't expect RSpec to test any changes made by Javascript; I just want to > test how the page loads initially: what is visible and what is not. If the css is expressed in-line in the html, then you can do it like so (example assumes a div with id foo that should be hidden): response.should have_tag('div#foo[style=?]', /display:\s*none/) have_tag wraps asset_select, so have a look at the assert_select docs for more info Cheers, David > > Can I test this in RSpec? Or do I need to use something like Selenium? > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From davidj503 at gmail.com Tue Sep 25 11:56:26 2007 From: davidj503 at gmail.com (David James) Date: Tue, 25 Sep 2007 11:56:26 -0400 Subject: [rspec-users] Testing for particular CSS (i.e. display: none) In-Reply-To: <57c63afe0709250827s422344e2q9509f343f9aa6902@mail.gmail.com> References: <59b5d4330709250820i75bd93dx38c53674ac0305a2@mail.gmail.com> <57c63afe0709250827s422344e2q9509f343f9aa6902@mail.gmail.com> Message-ID: <59b5d4330709250856u7623a2d8v59fb27a97720d220@mail.gmail.com> Perfect. That's really nifty. I'm also reading the comments in selector_assertions.rb in actionpack. On 9/25/07, David Chelimsky wrote: > > On 9/25/07, David James wrote: > > I have a page that hides elements using CSS display: none. > > > > I don't expect RSpec to test any changes made by Javascript; I just want > to > > test how the page loads initially: what is visible and what is not. > > If the css is expressed in-line in the html, then you can do it like > so (example assumes a div with id foo that should be hidden): > > response.should have_tag('div#foo[style=?]', /display:\s*none/) > > have_tag wraps asset_select, so have a look at the assert_select docs > for more info -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070925/8d8f5a87/attachment.html From matt-lists at reprocessed.org Tue Sep 25 11:57:10 2007 From: matt-lists at reprocessed.org (Matt Patterson) Date: Tue, 25 Sep 2007 16:57:10 +0100 Subject: [rspec-users] Problems with expect_render In-Reply-To: <57c63afe0709250806h47dcb0f8s9b8398e7b05a259b@mail.gmail.com> References: <4EAEFE2F-49B7-449E-83B5-3774A78A8316@reprocessed.org> <57c63afe0709250806h47dcb0f8s9b8398e7b05a259b@mail.gmail.com> Message-ID: <76BABC62-85E4-40F9-B067-1AEE0950104C@reprocessed.org> On 25 Sep 2007, at 16:06, David Chelimsky wrote: > On 9/25/07, Matt Patterson wrote: >> Hi there, >> >> I've been working with RSpec for about a week now, and the process of >> moving from a Test::Unit + Mocha setup to an RSpec + Mocha >> environment has been pretty straightforward. >> >> Except, I'm having problems with using template.expect_render. >> >> I have Mocha enabled with: > > It is not documented as such, but expect_render does not work with > mocha. It uses rspec's underlying mock framework. Yes, I knew about that, but the rdoc in lib/spec/rails/dsl/behaviour/ render_observer.rb made it sound like it should still work: # Also, +expect_render+ uses parts of RSpec's mock expectation framework. Because # it wraps only a subset of the framework, using this will create no conflict with # other mock frameworks if you choose to use them. Additionally, the object returned # by expect_render is an RSpec mock object, which means that you can call any of the # chained methods available in RSpec's mocks. > Please feel free to submit a feature request for this. I'd be happy to have a look and see whether I could patch it myself, but I've been having a few problems running all the specs cleanly. Currently rake pre_commit is bailing after the first spec run with complaints from rcov (both in 1.0.8 and trunk). Can you give me some pointers on getting the tests to run cleanly? Thanks, Matt -- Matt Patterson | Design & Code | http://www.reprocessed.org/ From dchelimsky at gmail.com Tue Sep 25 12:00:17 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 25 Sep 2007 11:00:17 -0500 Subject: [rspec-users] Problems with expect_render In-Reply-To: <76BABC62-85E4-40F9-B067-1AEE0950104C@reprocessed.org> References: <4EAEFE2F-49B7-449E-83B5-3774A78A8316@reprocessed.org> <57c63afe0709250806h47dcb0f8s9b8398e7b05a259b@mail.gmail.com> <76BABC62-85E4-40F9-B067-1AEE0950104C@reprocessed.org> Message-ID: <57c63afe0709250900k329743d2taf89cdde1a0dd6a9@mail.gmail.com> On 9/25/07, Matt Patterson wrote: > On 25 Sep 2007, at 16:06, David Chelimsky wrote: > > > On 9/25/07, Matt Patterson wrote: > >> Hi there, > >> > >> I've been working with RSpec for about a week now, and the process of > >> moving from a Test::Unit + Mocha setup to an RSpec + Mocha > >> environment has been pretty straightforward. > >> > >> Except, I'm having problems with using template.expect_render. > >> > >> I have Mocha enabled with: > > > > It is not documented as such, but expect_render does not work with > > mocha. It uses rspec's underlying mock framework. > > Yes, I knew about that, but the rdoc in lib/spec/rails/dsl/behaviour/ > render_observer.rb made it sound like it should still work: > > # Also, +expect_render+ uses parts of RSpec's mock > expectation framework. Because > # it wraps only a subset of the framework, using this will > create no conflict with > # other mock frameworks if you choose to use them. > Additionally, the object returned > # by expect_render is an RSpec mock object, which means that > you can call any of the > # chained methods available in RSpec's mocks. Oh - I forgot about that - it actually should work :) > > > Please feel free to submit a feature request for this. > > I'd be happy to have a look and see whether I could patch it myself, > but I've been having a few problems running all the specs cleanly. > Currently rake pre_commit is bailing after the first spec run with > complaints from rcov (both in 1.0.8 and trunk). > > Can you give me some pointers on getting the tests to run cleanly? What platform are you on? > > Thanks, > > Matt > > > -- > Matt Patterson | Design & Code > | http://www.reprocessed.org/ > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt-lists at reprocessed.org Tue Sep 25 12:02:26 2007 From: matt-lists at reprocessed.org (Matt Patterson) Date: Tue, 25 Sep 2007 17:02:26 +0100 Subject: [rspec-users] Problems with expect_render In-Reply-To: <76BABC62-85E4-40F9-B067-1AEE0950104C@reprocessed.org> References: <4EAEFE2F-49B7-449E-83B5-3774A78A8316@reprocessed.org> <57c63afe0709250806h47dcb0f8s9b8398e7b05a259b@mail.gmail.com> <76BABC62-85E4-40F9-B067-1AEE0950104C@reprocessed.org> Message-ID: <04DAB787-E210-4EB0-A10D-D7EE8425DCD0@reprocessed.org> On 25 Sep 2007, at 16:57, Matt Patterson wrote: > On 25 Sep 2007, at 16:06, David Chelimsky wrote: >> >> It is not documented as such, but expect_render does not work with >> mocha. It uses rspec's underlying mock framework. > > Yes, I knew about that, but the rdoc in lib/spec/rails/dsl/behaviour/ > render_observer.rb made it sound like it should still work: Sorry, that sounded a bit snippy - it wasn't meant to. And I forgot to say thanks for the prompt response. Thanks! Matt -- Matt Patterson | Design & Code | http://www.reprocessed.org/ From matt-lists at reprocessed.org Tue Sep 25 12:06:06 2007 From: matt-lists at reprocessed.org (Matt Patterson) Date: Tue, 25 Sep 2007 17:06:06 +0100 Subject: [rspec-users] Problems with expect_render In-Reply-To: <57c63afe0709250900k329743d2taf89cdde1a0dd6a9@mail.gmail.com> References: <4EAEFE2F-49B7-449E-83B5-3774A78A8316@reprocessed.org> <57c63afe0709250806h47dcb0f8s9b8398e7b05a259b@mail.gmail.com> <76BABC62-85E4-40F9-B067-1AEE0950104C@reprocessed.org> <57c63afe0709250900k329743d2taf89cdde1a0dd6a9@mail.gmail.com> Message-ID: <85D415A2-85B4-4750-8DF1-B751886DB090@reprocessed.org> On 25 Sep 2007, at 17:00, David Chelimsky wrote: > Oh - I forgot about that - it actually should work :) Heh. >> Can you give me some pointers on getting the tests to run cleanly? > > What platform are you on? OS X, with Ruby 1.8.6 Matt -- Matt Patterson | Design & Code | http://www.reprocessed.org/ From dchelimsky at gmail.com Tue Sep 25 12:12:20 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 25 Sep 2007 11:12:20 -0500 Subject: [rspec-users] Problems with expect_render In-Reply-To: <85D415A2-85B4-4750-8DF1-B751886DB090@reprocessed.org> References: <4EAEFE2F-49B7-449E-83B5-3774A78A8316@reprocessed.org> <57c63afe0709250806h47dcb0f8s9b8398e7b05a259b@mail.gmail.com> <76BABC62-85E4-40F9-B067-1AEE0950104C@reprocessed.org> <57c63afe0709250900k329743d2taf89cdde1a0dd6a9@mail.gmail.com> <85D415A2-85B4-4750-8DF1-B751886DB090@reprocessed.org> Message-ID: <57c63afe0709250912k56ce3bbbjad6746b13c3f52f@mail.gmail.com> On 9/25/07, Matt Patterson wrote: > On 25 Sep 2007, at 17:00, David Chelimsky wrote: > > > Oh - I forgot about that - it actually should work :) > > Heh. > > >> Can you give me some pointers on getting the tests to run cleanly? > > > > What platform are you on? > > OS X, with Ruby 1.8.6 Me too and I get 100% coverage. Are you just getting a coverage problem, or is it something else? Can you post the output you're getting? > > Matt > > -- > Matt Patterson | Design & Code > | http://www.reprocessed.org/ > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt-lists at reprocessed.org Tue Sep 25 12:30:30 2007 From: matt-lists at reprocessed.org (Matt Patterson) Date: Tue, 25 Sep 2007 17:30:30 +0100 Subject: [rspec-users] Problems with expect_render In-Reply-To: <57c63afe0709250912k56ce3bbbjad6746b13c3f52f@mail.gmail.com> References: <4EAEFE2F-49B7-449E-83B5-3774A78A8316@reprocessed.org> <57c63afe0709250806h47dcb0f8s9b8398e7b05a259b@mail.gmail.com> <76BABC62-85E4-40F9-B067-1AEE0950104C@reprocessed.org> <57c63afe0709250900k329743d2taf89cdde1a0dd6a9@mail.gmail.com> <85D415A2-85B4-4750-8DF1-B751886DB090@reprocessed.org> <57c63afe0709250912k56ce3bbbjad6746b13c3f52f@mail.gmail.com> Message-ID: <969FCA65-9681-49E9-83AE-11E295DC95B6@reprocessed.org> On 25 Sep 2007, at 17:12, David Chelimsky wrote: >> OS X, with Ruby 1.8.6 > > Me too and I get 100% coverage. I'm running the mysql.com MySQL 5.0.45 mac intel build, and the native mysql gem (2.7), if that helps > Are you just getting a coverage problem, or is it something else? Can > you post the output you're getting? pasted below. Also, when running rake examples_with_rcov in the rspec dir of my checkout I get the headline figure: Name | Total lines | Lines of code | Total coverage | Code coverage TOTAL | 5548 | 3800 | 71.1% | 59.7% Do you want to zip up rspec/coverage and send that too? Matt ---- [~/sandbox/rspec-1.0.8] matt$ rake pre_commit (in /Users/matt/sandbox/rspec-1.0.8) (in /Users/matt/sandbox/rspec-1.0.8/rspec) ** Invoke pre_commit (first_time) ** Execute pre_commit ** Invoke verify_rcov (first_time) ** Invoke spec (first_time) ** Invoke clobber_spec (first_time) ** Execute clobber_spec ** Execute spec ........................................................................ ........................................................................ ........................................................................ ..............................................................The :any_a rgs constraint is deprecated. Use any_args() instead. .The :string constraint is deprecated. Use an_instance_of(String) instead. .The :anything constraint is deprecated. Use anything() instead. .The :numeric constraint is deprecated. Use an_instance_of(Numeric) instead. .The :numeric constraint is deprecated. Use an_instance_of(Numeric) instead. .The :boolean constraint is deprecated. Use boolean() instead. .The :boolean constraint is deprecated. Use boolean() instead. ..................................The :no_args constraint is deprecated. Use no_args() instead. .The :no_args constraint is deprecated. Use no_args() instead. .........................................................The :string constraint is deprecated. Use an_instance_of(String) instead. .The :numeric constraint is deprecated. Use an_instance_of(Numeric) instead. .The :boolean constraint is deprecated. Use boolean() instead. ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ................ Finished in 5.021135 seconds 898 examples, 0 failures ** Execute verify_rcov Coverage: 98.9% (threshold: 100.0%) rake aborted! Coverage must be at least 100.0% but was 98.9% ./lib/spec/rake/verify_rcov.rb:47:in `define' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `synchronize' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke' /Users/matt/sandbox/rspec-1.0.8/pre_commit/lib/pre_commit/ pre_commit.rb:9:in `rake_invoke' /Users/matt/sandbox/rspec-1.0.8/pre_commit/lib/pre_commit/core.rb: 11:in `website' /Users/matt/sandbox/rspec-1.0.8/pre_commit/lib/pre_commit/core.rb: 3:in `pre_commit' /Users/matt/sandbox/rspec-1.0.8/rspec/rakefile:175 /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `synchronize' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `each' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in `run' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in `run' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 /usr/local/bin/rake:16:in `load' /usr/local/bin/rake:16 rake aborted! RSpec Core pre_commit failed /Users/matt/sandbox/rspec-1.0.8/rakefile:9 -- Matt Patterson | Design & Code | http://www.reprocessed.org/ From dchelimsky at gmail.com Tue Sep 25 12:35:53 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 25 Sep 2007 11:35:53 -0500 Subject: [rspec-users] Problems with expect_render In-Reply-To: <969FCA65-9681-49E9-83AE-11E295DC95B6@reprocessed.org> References: <4EAEFE2F-49B7-449E-83B5-3774A78A8316@reprocessed.org> <57c63afe0709250806h47dcb0f8s9b8398e7b05a259b@mail.gmail.com> <76BABC62-85E4-40F9-B067-1AEE0950104C@reprocessed.org> <57c63afe0709250900k329743d2taf89cdde1a0dd6a9@mail.gmail.com> <85D415A2-85B4-4750-8DF1-B751886DB090@reprocessed.org> <57c63afe0709250912k56ce3bbbjad6746b13c3f52f@mail.gmail.com> <969FCA65-9681-49E9-83AE-11E295DC95B6@reprocessed.org> Message-ID: <57c63afe0709250935o3dc9c267sb9f87335b14e3398@mail.gmail.com> On 9/25/07, Matt Patterson wrote: > > On 25 Sep 2007, at 17:12, David Chelimsky wrote: > > >> OS X, with Ruby 1.8.6 > > > > Me too and I get 100% coverage. > > I'm running the mysql.com MySQL 5.0.45 mac intel build, and the > native mysql gem (2.7), if that helps > > > Are you just getting a coverage problem, or is it something else? Can > > you post the output you're getting? > > pasted below. Two things: 1. If you're patching you should be working w/ trunk, not the release. 2. Do you have the latest version of rcov (0.8)? > > Also, when running rake examples_with_rcov in the rspec dir of my > checkout I get the headline figure: > Name | Total lines | Lines of code | Total coverage | Code coverage > TOTAL | 5548 | 3800 | 71.1% | 59.7% > > Do you want to zip up rspec/coverage and send that too? > > Matt > > ---- > > [~/sandbox/rspec-1.0.8] matt$ rake pre_commit > (in /Users/matt/sandbox/rspec-1.0.8) > (in /Users/matt/sandbox/rspec-1.0.8/rspec) > ** Invoke pre_commit (first_time) > ** Execute pre_commit > ** Invoke verify_rcov (first_time) > ** Invoke spec (first_time) > ** Invoke clobber_spec (first_time) > ** Execute clobber_spec > ** Execute spec > ........................................................................ > ........................................................................ > ........................................................................ > ..............................................................The :any_a > rgs constraint is deprecated. Use any_args() instead. > .The :string constraint is deprecated. Use an_instance_of(String) > instead. > .The :anything constraint is deprecated. Use anything() instead. > .The :numeric constraint is deprecated. Use an_instance_of(Numeric) > instead. > .The :numeric constraint is deprecated. Use an_instance_of(Numeric) > instead. > .The :boolean constraint is deprecated. Use boolean() instead. > .The :boolean constraint is deprecated. Use boolean() instead. > ..................................The :no_args constraint is > deprecated. Use no_args() instead. > .The :no_args constraint is deprecated. Use no_args() instead. > .........................................................The :string > constraint is deprecated. Use an_instance_of(String) instead. > .The :numeric constraint is deprecated. Use an_instance_of(Numeric) > instead. > .The :boolean constraint is deprecated. Use boolean() instead. > ........................................................................ > ........................................................................ > ........................................................................ > ........................................................................ > ........................................................................ > ........................................................................ > ........................................................................ > ................ > > Finished in 5.021135 seconds > > 898 examples, 0 failures > ** Execute verify_rcov > Coverage: 98.9% (threshold: 100.0%) > rake aborted! > Coverage must be at least 100.0% but was 98.9% > ./lib/spec/rake/verify_rcov.rb:47:in `define' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in > `synchronize' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke' > /Users/matt/sandbox/rspec-1.0.8/pre_commit/lib/pre_commit/ > pre_commit.rb:9:in `rake_invoke' > /Users/matt/sandbox/rspec-1.0.8/pre_commit/lib/pre_commit/core.rb: > 11:in `website' > /Users/matt/sandbox/rspec-1.0.8/pre_commit/lib/pre_commit/core.rb: > 3:in `pre_commit' > /Users/matt/sandbox/rspec-1.0.8/rspec/rakefile:175 > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in > `synchronize' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in > `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in > `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in > `standard_exception_handling' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in > `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in > `standard_exception_handling' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 > /usr/local/bin/rake:16:in `load' > /usr/local/bin/rake:16 > rake aborted! > RSpec Core pre_commit failed > /Users/matt/sandbox/rspec-1.0.8/rakefile:9 > > > > -- > Matt Patterson | Design & Code > | http://www.reprocessed.org/ > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt-lists at reprocessed.org Tue Sep 25 14:07:54 2007 From: matt-lists at reprocessed.org (Matt Patterson) Date: Tue, 25 Sep 2007 19:07:54 +0100 Subject: [rspec-users] Problems with expect_render In-Reply-To: <57c63afe0709250935o3dc9c267sb9f87335b14e3398@mail.gmail.com> References: <4EAEFE2F-49B7-449E-83B5-3774A78A8316@reprocessed.org> <57c63afe0709250806h47dcb0f8s9b8398e7b05a259b@mail.gmail.com> <76BABC62-85E4-40F9-B067-1AEE0950104C@reprocessed.org> <57c63afe0709250900k329743d2taf89cdde1a0dd6a9@mail.gmail.com> <85D415A2-85B4-4750-8DF1-B751886DB090@reprocessed.org> <57c63afe0709250912k56ce3bbbjad6746b13c3f52f@mail.gmail.com> <969FCA65-9681-49E9-83AE-11E295DC95B6@reprocessed.org> <57c63afe0709250935o3dc9c267sb9f87335b14e3398@mail.gmail.com> Message-ID: <43A46614-C2BE-4927-9E50-FA2D4A5DF6B0@reprocessed.org> On 25 Sep 2007, at 17:35, David Chelimsky wrote: > On 9/25/07, Matt Patterson wrote: >> > Two things: > > 1. If you're patching you should be working w/ trunk, not the release. Yeah, I got the same problem with trunk so I thought I'd see if I could figure out what was going on with the latest release in case it was just a trunk thing (although, judging by rake pre_commit, you guys are pretty strict :-). > 2. Do you have the latest version of rcov (0.8)? I do: 0.8.0.2. Headlines from running rake pre_commit against trunk: > Finished in 0.028033 seconds > > 92 examples, 0 failures, 3 pending > Finished in 5.320475 seconds > > 1024 examples, 0 failures, 4 pending > ** Execute verify_rcov > Coverage: 99.0% (threshold: 100.0%) > rake aborted! > Coverage must be at least 100.0% but was 99.0% I can send you the rcov HTML products if you want... Matt -- Matt Patterson | Design & Code | http://www.reprocessed.org/ From dchelimsky at gmail.com Tue Sep 25 14:09:12 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 25 Sep 2007 13:09:12 -0500 Subject: [rspec-users] Problems with expect_render In-Reply-To: <43A46614-C2BE-4927-9E50-FA2D4A5DF6B0@reprocessed.org> References: <4EAEFE2F-49B7-449E-83B5-3774A78A8316@reprocessed.org> <57c63afe0709250806h47dcb0f8s9b8398e7b05a259b@mail.gmail.com> <76BABC62-85E4-40F9-B067-1AEE0950104C@reprocessed.org> <57c63afe0709250900k329743d2taf89cdde1a0dd6a9@mail.gmail.com> <85D415A2-85B4-4750-8DF1-B751886DB090@reprocessed.org> <57c63afe0709250912k56ce3bbbjad6746b13c3f52f@mail.gmail.com> <969FCA65-9681-49E9-83AE-11E295DC95B6@reprocessed.org> <57c63afe0709250935o3dc9c267sb9f87335b14e3398@mail.gmail.com> <43A46614-C2BE-4927-9E50-FA2D4A5DF6B0@reprocessed.org> Message-ID: <57c63afe0709251109g4aeb9f97l3eb5353d9edf2d32@mail.gmail.com> On 9/25/07, Matt Patterson wrote: > On 25 Sep 2007, at 17:35, David Chelimsky wrote: > > > On 9/25/07, Matt Patterson wrote: > >> > > Two things: > > > > 1. If you're patching you should be working w/ trunk, not the release. > > Yeah, I got the same problem with trunk so I thought I'd see if I > could figure out what was going on with the latest release in case it > was just a trunk thing (although, judging by rake pre_commit, you > guys are pretty strict :-). > > > 2. Do you have the latest version of rcov (0.8)? > > I do: 0.8.0.2. > > Headlines from running rake pre_commit against trunk: > > > Finished in 0.028033 seconds > > > > 92 examples, 0 failures, 3 pending > > > Finished in 5.320475 seconds > > > > 1024 examples, 0 failures, 4 pending > > > ** Execute verify_rcov > > Coverage: 99.0% (threshold: 100.0%) > > rake aborted! > > Coverage must be at least 100.0% but was 99.0% > > > I can send you the rcov HTML products if you want... Zip it up! > > Matt > > -- > Matt Patterson | Design & Code > | http://www.reprocessed.org/ > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt-lists at reprocessed.org Tue Sep 25 14:31:38 2007 From: matt-lists at reprocessed.org (Matt Patterson) Date: Tue, 25 Sep 2007 19:31:38 +0100 Subject: [rspec-users] Problems with expect_render In-Reply-To: <57c63afe0709251109g4aeb9f97l3eb5353d9edf2d32@mail.gmail.com> References: <4EAEFE2F-49B7-449E-83B5-3774A78A8316@reprocessed.org> <57c63afe0709250806h47dcb0f8s9b8398e7b05a259b@mail.gmail.com> <76BABC62-85E4-40F9-B067-1AEE0950104C@reprocessed.org> <57c63afe0709250900k329743d2taf89cdde1a0dd6a9@mail.gmail.com> <85D415A2-85B4-4750-8DF1-B751886DB090@reprocessed.org> <57c63afe0709250912k56ce3bbbjad6746b13c3f52f@mail.gmail.com> <969FCA65-9681-49E9-83AE-11E295DC95B6@reprocessed.org> <57c63afe0709250935o3dc9c267sb9f87335b14e3398@mail.gmail.com> <43A46614-C2BE-4927-9E50-FA2D4A5DF6B0@reprocessed.org> <57c63afe0709251109g4aeb9f97l3eb5353d9edf2d32@mail.gmail.com> Message-ID: <0B61899A-1C43-4AB1-AE0C-43239204D94F@reprocessed.org> On 25 Sep 2007, at 19:09, David Chelimsky wrote: >> I can send you the rcov HTML products if you want... > > Zip it up! I finally looked at the Rakefile to see where the rcov output was, had a look and... found the problem: Name | Total lines | Lines of code | Total coverage | Code coverage /Users/matt/.autotest | 133 | 103 | 48.9% | 37.9% I've sent the zip (direct to you) anyway, but there's your problem... rake verify_rcov is running rcov on my ~/.autotest file for some reason... Matt -- Matt Patterson | Design & Code | http://www.reprocessed.org/ From dchelimsky at gmail.com Tue Sep 25 14:38:32 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 25 Sep 2007 13:38:32 -0500 Subject: [rspec-users] Problems with expect_render In-Reply-To: <0B61899A-1C43-4AB1-AE0C-43239204D94F@reprocessed.org> References: <4EAEFE2F-49B7-449E-83B5-3774A78A8316@reprocessed.org> <76BABC62-85E4-40F9-B067-1AEE0950104C@reprocessed.org> <57c63afe0709250900k329743d2taf89cdde1a0dd6a9@mail.gmail.com> <85D415A2-85B4-4750-8DF1-B751886DB090@reprocessed.org> <57c63afe0709250912k56ce3bbbjad6746b13c3f52f@mail.gmail.com> <969FCA65-9681-49E9-83AE-11E295DC95B6@reprocessed.org> <57c63afe0709250935o3dc9c267sb9f87335b14e3398@mail.gmail.com> <43A46614-C2BE-4927-9E50-FA2D4A5DF6B0@reprocessed.org> <57c63afe0709251109g4aeb9f97l3eb5353d9edf2d32@mail.gmail.com> <0B61899A-1C43-4AB1-AE0C-43239204D94F@reprocessed.org> Message-ID: <57c63afe0709251138u5b8e9901ya86d40b6e5149de2@mail.gmail.com> On 9/25/07, Matt Patterson wrote: > On 25 Sep 2007, at 19:09, David Chelimsky wrote: > > >> I can send you the rcov HTML products if you want... > > > > Zip it up! > > I finally looked at the Rakefile to see where the rcov output was, > had a look and... found the problem: > > Name | Total lines | Lines of code | Total coverage > | Code coverage > /Users/matt/.autotest | 133 | 103 | 48.9% > | 37.9% D'oh!!!! > > I've sent the zip (direct to you) anyway, but there's your problem... > rake verify_rcov is running rcov on my ~/.autotest file for some > reason... > > Matt > > -- > Matt Patterson | Design & Code > | http://www.reprocessed.org/ > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From hans at degraaff.org Tue Sep 25 14:54:54 2007 From: hans at degraaff.org (Hans de Graaff) Date: Tue, 25 Sep 2007 20:54:54 +0200 Subject: [rspec-users] controller.expect_render has me beat! In-Reply-To: <2ca660dd0709141451xf23d8b0s2635ffa7d8469407@mail.gmail.com> References: <2ca660dd0709141451xf23d8b0s2635ffa7d8469407@mail.gmail.com> Message-ID: <1190746494.19966.3.camel@ip6-localhost> On Fri, 2007-09-14 at 17:51 -0400, sinclair bain wrote: > > def update > ... > if @config.update_attributes ( params[:new_config] ) > redirect_to :action => :index > else > render :action => :edit, :id => params[:id] # this line > here > end > ... > end > it 'should render the "edit" config url on an unsuccessful save' do > @config.should_receive(:update_attributes).once.and_return(false) > controller.expect_render( :action => :edit, :id => 1 ).once > # my prob > do_update > end I'm not sure what do_update is doing? I assume it is doing a post? In any case params are normally strings, so doing controller.expect_render(:action => :edit, :id => '1').once will most likely work. Kind regards, Hans -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070925/0bb90090/attachment-0001.bin From jonathan at parkerhill.com Tue Sep 25 17:51:20 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 25 Sep 2007 17:51:20 -0400 Subject: [rspec-users] simple story, extract link Message-ID: <88E55648-6529-458F-834B-96C73FB4F03B@parkerhill.com> hi, I just started fooling around with story runner, thought I'd start with a dead simple scenario: The first thing I do when describing a site to someone is go to the home page, and begin exploring public pages from there. So, that seems like a good first story to spec out. And I'd really like to extract the actual link from the rendered page (rather than just "assuming" in the spec), but I'm not sure how to do that Something like: # alink = find tag 'div#home-banner-links a ' where content=="About" # url = extract the href attribute from alink get url Here's the story so far: http://pastie.caboo.se/100810 I'd appreciate suggestions as this seems like something I'd like to do alot. Thanks linoj From dchelimsky at gmail.com Tue Sep 25 18:05:02 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 25 Sep 2007 17:05:02 -0500 Subject: [rspec-users] simple story, extract link In-Reply-To: <88E55648-6529-458F-834B-96C73FB4F03B@parkerhill.com> References: <88E55648-6529-458F-834B-96C73FB4F03B@parkerhill.com> Message-ID: <57c63afe0709251505v1998555dm392e76d31542a653@mail.gmail.com> On 9/25/07, Jonathan Linowes wrote: > hi, > > I just started fooling around with story runner, thought I'd start > with a dead simple scenario: > The first thing I do when describing a site to someone is go to the > home page, and begin exploring public pages from there. > So, that seems like a good first story to spec out. > > And I'd really like to extract the actual link from the rendered page > (rather than just "assuming" in the spec), but I'm not sure how to do > that > Something like: > > # alink = find tag 'div#home-banner-links a ' where > content=="About" > # url = extract the href attribute from alink > get url > > Here's the story so far: http://pastie.caboo.se/100810 Some comments: The second scenario seems more like the right level of abstraction than the first. Using "should render_template" in a Story seems too low level to me. What's interesting is what is being displayed, not what template is being used to display it. The second scenario does a nicer job of that. One thing is that you won't be able to use the full URL. RailsStory wraps rails integration tests, which provide access to routing, but as paths, not URLs. So for href="http://0.0.0.0:3000/site_pages/about", you'd need to extract the "/site_pages/about" part and get that. Thoughts? > > I'd appreciate suggestions as this seems like something I'd like to > do alot. Thanks > > linoj > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From omen.king at gmail.com Tue Sep 25 18:32:56 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Tue, 25 Sep 2007 18:32:56 -0400 Subject: [rspec-users] simple story, extract link In-Reply-To: <57c63afe0709251505v1998555dm392e76d31542a653@mail.gmail.com> References: <88E55648-6529-458F-834B-96C73FB4F03B@parkerhill.com> <57c63afe0709251505v1998555dm392e76d31542a653@mail.gmail.com> Message-ID: Hi Jon, I've been having alot of fun with Story Runner this week. I'm trying to find the time this week to do a screencast on story runner. Here's an example of how I might write your story. http://pastie.caboo.se/100835 I didn't use in my example how you'd like to check for the url. I'm unsure or haven't clearly read over your goal. I'll take a look later. On 9/25/07, David Chelimsky wrote: > > On 9/25/07, Jonathan Linowes wrote: > > hi, > > > > I just started fooling around with story runner, thought I'd start > > with a dead simple scenario: > > The first thing I do when describing a site to someone is go to the > > home page, and begin exploring public pages from there. > > So, that seems like a good first story to spec out. > > > > And I'd really like to extract the actual link from the rendered page > > (rather than just "assuming" in the spec), but I'm not sure how to do > > that > > Something like: > > > > # alink = find tag 'div#home-banner-links a ' where > > content=="About" > > # url = extract the href attribute from alink > > get url > > > > Here's the story so far: http://pastie.caboo.se/100810 > > Some comments: > > The second scenario seems more like the right level of abstraction > than the first. Using "should render_template" in a Story seems too > low level to me. What's interesting is what is being displayed, not > what template is being used to display it. > > The second scenario does a nicer job of that. > > One thing is that you won't be able to use the full URL. RailsStory > wraps rails integration tests, which provide access to routing, but as > paths, not URLs. So for href="http://0.0.0.0:3000/site_pages/about", > you'd need to extract the "/site_pages/about" part and get that. > > Thoughts? > > > > > I'd appreciate suggestions as this seems like something I'd like to > > do alot. Thanks > > > > linoj > > > > > > _______________________________________________ > > 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/20070925/11a0ef1a/attachment.html From pergesu at gmail.com Tue Sep 25 18:48:22 2007 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 25 Sep 2007 15:48:22 -0700 Subject: [rspec-users] simple story, extract link In-Reply-To: <57c63afe0709251505v1998555dm392e76d31542a653@mail.gmail.com> References: <88E55648-6529-458F-834B-96C73FB4F03B@parkerhill.com> <57c63afe0709251505v1998555dm392e76d31542a653@mail.gmail.com> Message-ID: <810a540e0709251548i479bca1bt85f11522d9029d2f@mail.gmail.com> On 9/25/07, David Chelimsky wrote: > On 9/25/07, Jonathan Linowes wrote: > > hi, > > > > I just started fooling around with story runner, thought I'd start > > with a dead simple scenario: > > The first thing I do when describing a site to someone is go to the > > home page, and begin exploring public pages from there. > > So, that seems like a good first story to spec out. > > > > And I'd really like to extract the actual link from the rendered page > > (rather than just "assuming" in the spec), but I'm not sure how to do > > that > > Something like: > > > > # alink = find tag 'div#home-banner-links a ' where > > content=="About" > > # url = extract the href attribute from alink > > get url > > > > Here's the story so far: http://pastie.caboo.se/100810 > > Some comments: > > The second scenario seems more like the right level of abstraction > than the first. Using "should render_template" in a Story seems too > low level to me. What's interesting is what is being displayed, not > what template is being used to display it. I see what you're getting at. I've thought about it a bit myself, and have decided that expecting a certain template is a pragmatic way of knowing that the user is on the right page. > The second scenario does a nicer job of that. > > One thing is that you won't be able to use the full URL. RailsStory > wraps rails integration tests, which provide access to routing, but as > paths, not URLs. So for href="http://0.0.0.0:3000/site_pages/about", > you'd need to extract the "/site_pages/about" part and get that. > > Thoughts? I was planning on implementing a click_link "Follow me!" sorta thing in the next couple days. One problem I have is that right now you still need to know too much about the underlying structure (and golly if I didn't just contradict the first part of my reply!). There was a thread a few days ago [1] where I hinted at that. He wanted to go directly to a URL, when he should have been following a redirect. I think there needs to be some mechanism for following links / submitting forms so that you can really follow the path a user takes. That leaves you with something like: Story "Create an auction", %{ As a seller I want to create a new auction So that I can get filthy rich } do Scenario "Successful listing" do Given "A user" do User.create! :login => "pat", :password => "password" end And "user visits the login page" do get "/login" end And "user logs in" do submit_form :login, :login => "pat", :password => "password" end And "user visits new auction page" do click_link "Create an auction" end When "user creates auction" do submit_form :auction, :auction => { :item_name => "Ruby for Rails", :price => 50 } end Then "new auction should be listed" do response.should have_text(/Item successfully created!/) response.should have_text(/Ruby for Rails/) end end end That requires you to know 1. Point of entry 2. IDs of forms and links (or text for links, if you prefer) 3. The fields that a form uses So really all we've gotten away from is dependency on knowing certain URLs, which I'm not positive is a huge benefit...otoh, this is closer to tracing a user's path through the app which is nice. wdyt? Pat [1] http://rubyforge.org/pipermail/rspec-users/2007-September/003344.html From jonathan at parkerhill.com Tue Sep 25 19:12:25 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 25 Sep 2007 19:12:25 -0400 Subject: [rspec-users] simple story, extract link In-Reply-To: <810a540e0709251548i479bca1bt85f11522d9029d2f@mail.gmail.com> References: <88E55648-6529-458F-834B-96C73FB4F03B@parkerhill.com> <57c63afe0709251505v1998555dm392e76d31542a653@mail.gmail.com> <810a540e0709251548i479bca1bt85f11522d9029d2f@mail.gmail.com> Message-ID: <7E1CC640-DCCB-484A-8F24-6308107574DB@parkerhill.com> yep, in my case I'm imagining a next scenario may go something like this: - from home page, click on Contact Us, see contact form, fill out fields, submit form, see thank you page, email sent to admin On Sep 25, 2007, at 6:48 PM, Pat Maddox wrote: > On 9/25/07, David Chelimsky wrote: >> On 9/25/07, Jonathan Linowes wrote: >>> hi, >>> >>> I just started fooling around with story runner, thought I'd start >>> with a dead simple scenario: >>> The first thing I do when describing a site to someone is go to the >>> home page, and begin exploring public pages from there. >>> So, that seems like a good first story to spec out. >>> >>> And I'd really like to extract the actual link from the rendered >>> page >>> (rather than just "assuming" in the spec), but I'm not sure how >>> to do >>> that >>> Something like: >>> >>> # alink = find tag 'div#home-banner-links a ' where >>> content=="About" >>> # url = extract the href attribute from alink >>> get url >>> >>> Here's the story so far: http://pastie.caboo.se/100810 >> >> Some comments: >> >> The second scenario seems more like the right level of abstraction >> than the first. Using "should render_template" in a Story seems too >> low level to me. What's interesting is what is being displayed, not >> what template is being used to display it. > > I see what you're getting at. I've thought about it a bit myself, and > have decided that expecting a certain template is a pragmatic way of > knowing that the user is on the right page. > > >> The second scenario does a nicer job of that. >> >> One thing is that you won't be able to use the full URL. RailsStory >> wraps rails integration tests, which provide access to routing, >> but as >> paths, not URLs. So for href="http://0.0.0.0:3000/site_pages/about", >> you'd need to extract the "/site_pages/about" part and get that. >> >> Thoughts? > > I was planning on implementing a > click_link "Follow me!" > > sorta thing in the next couple days. One problem I have is that right > now you still need to know too much about the underlying structure > (and golly if I didn't just contradict the first part of my reply!). > There was a thread a few days ago [1] where I hinted at that. He > wanted to go directly to a URL, when he should have been following a > redirect. > > I think there needs to be some mechanism for following links / > submitting forms so that you can really follow the path a user takes. > That leaves you with something like: > > Story "Create an auction", %{ > As a seller > I want to create a new auction > So that I can get filthy rich > } do > > Scenario "Successful listing" do > Given "A user" do > User.create! :login => "pat", :password => "password" > end > And "user visits the login page" do > get "/login" > end > And "user logs in" do > submit_form :login, :login => "pat", :password => "password" > end > And "user visits new auction page" do > click_link "Create an auction" > end > When "user creates auction" do > submit_form :auction, :auction => { :item_name => "Ruby for > Rails", :price => 50 } > end > Then "new auction should be listed" do > response.should have_text(/Item successfully created!/) > response.should have_text(/Ruby for Rails/) > end > end > end > > That requires you to know > 1. Point of entry > 2. IDs of forms and links (or text for links, if you prefer) > 3. The fields that a form uses > > So really all we've gotten away from is dependency on knowing certain > URLs, which I'm not positive is a huge benefit...otoh, this is closer > to tracing a user's path through the app which is nice. > > wdyt? > > Pat > > [1] http://rubyforge.org/pipermail/rspec-users/2007-September/ > 003344.html > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From omen.king at gmail.com Tue Sep 25 19:26:19 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Tue, 25 Sep 2007 19:26:19 -0400 Subject: [rspec-users] simple story, extract link In-Reply-To: <810a540e0709251548i479bca1bt85f11522d9029d2f@mail.gmail.com> References: <88E55648-6529-458F-834B-96C73FB4F03B@parkerhill.com> <57c63afe0709251505v1998555dm392e76d31542a653@mail.gmail.com> <810a540e0709251548i479bca1bt85f11522d9029d2f@mail.gmail.com> Message-ID: Oh that was my post a few days ago. I was trying to emulate the following: Jon is logging onto the forum so he can create a new topic. When Jon logs on he is redirected the home page by default. Jon then clicks on the general forum so he go create a topic. This following seemed out of place. I thought it was necessary to emulate a user clicking a link on the home page to the forums/1 I thought thats the path the user takes. And "user is looking at", "/forums/1" do |path| get path response.should be_success end It just seemed that I was suppose to include the user going to that page before creating the topic. On 9/25/07, Pat Maddox wrote: > > On 9/25/07, David Chelimsky wrote: > > On 9/25/07, Jonathan Linowes wrote: > > > hi, > > > > > > I just started fooling around with story runner, thought I'd start > > > with a dead simple scenario: > > > The first thing I do when describing a site to someone is go to the > > > home page, and begin exploring public pages from there. > > > So, that seems like a good first story to spec out. > > > > > > And I'd really like to extract the actual link from the rendered page > > > (rather than just "assuming" in the spec), but I'm not sure how to do > > > that > > > Something like: > > > > > > # alink = find tag 'div#home-banner-links a ' where > > > content=="About" > > > # url = extract the href attribute from alink > > > get url > > > > > > Here's the story so far: http://pastie.caboo.se/100810 > > > > Some comments: > > > > The second scenario seems more like the right level of abstraction > > than the first. Using "should render_template" in a Story seems too > > low level to me. What's interesting is what is being displayed, not > > what template is being used to display it. > > I see what you're getting at. I've thought about it a bit myself, and > have decided that expecting a certain template is a pragmatic way of > knowing that the user is on the right page. > > > > The second scenario does a nicer job of that. > > > > One thing is that you won't be able to use the full URL. RailsStory > > wraps rails integration tests, which provide access to routing, but as > > paths, not URLs. So for href="http://0.0.0.0:3000/site_pages/about", > > you'd need to extract the "/site_pages/about" part and get that. > > > > Thoughts? > > I was planning on implementing a > click_link "Follow me!" > > sorta thing in the next couple days. One problem I have is that right > now you still need to know too much about the underlying structure > (and golly if I didn't just contradict the first part of my reply!). > There was a thread a few days ago [1] where I hinted at that. He > wanted to go directly to a URL, when he should have been following a > redirect. > > I think there needs to be some mechanism for following links / > submitting forms so that you can really follow the path a user takes. > That leaves you with something like: > > Story "Create an auction", %{ > As a seller > I want to create a new auction > So that I can get filthy rich > } do > > Scenario "Successful listing" do > Given "A user" do > User.create! :login => "pat", :password => "password" > end > And "user visits the login page" do > get "/login" > end > And "user logs in" do > submit_form :login, :login => "pat", :password => "password" > end > And "user visits new auction page" do > click_link "Create an auction" > end > When "user creates auction" do > submit_form :auction, :auction => { :item_name => "Ruby for > Rails", :price => 50 } > end > Then "new auction should be listed" do > response.should have_text(/Item successfully created!/) > response.should have_text(/Ruby for Rails/) > end > end > end > > That requires you to know > 1. Point of entry > 2. IDs of forms and links (or text for links, if you prefer) > 3. The fields that a form uses > > So really all we've gotten away from is dependency on knowing certain > URLs, which I'm not positive is a huge benefit...otoh, this is closer > to tracing a user's path through the app which is nice. > > wdyt? > > Pat > > [1] http://rubyforge.org/pipermail/rspec-users/2007-September/003344.html > _______________________________________________ > 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/20070925/84dc7ca5/attachment-0001.html From keith.tom at gmail.com Tue Sep 25 23:50:51 2007 From: keith.tom at gmail.com (Keith Tom) Date: Tue, 25 Sep 2007 23:50:51 -0400 Subject: [rspec-users] Testing record creation independently of implementation Message-ID: <46F9D71B.3060907@gmail.com> Hi guys, I just had a question on testing a method whose behaviour includes creating a record in the database. How would one go about doing this? At first, it seems okay to cheat and just make sure that create() or new() is called with the correct parameters. So, @model.should_receive(:create).with(params) or, @model.should_receive(:new).with(params) But if I wanted to have it be implementation independent, then the only thing I can think of is to check the database at the end for the record I'm expecting, like, @model = Model.find_last_created @model.attributes.should be == params There are some assumptions here, but at least it is focussed on the end result of the record, and not so much how it was created. Any suggestions are really appreciated. Thanks in advance! Keith From omen.king at gmail.com Wed Sep 26 15:14:26 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Wed, 26 Sep 2007 15:14:26 -0400 Subject: [rspec-users] [Story] passing a file using post Message-ID: I'm trying to run a story for sample caboose that I created. I haven't changed any of the sample application code. When I try to do the following: When "creating a new asset named", File.open('/Users/multimedia/desktop/sample/assets/bridge.jpg') do |path| post_via_redirect "/users/#{@user.login}/assets", :asset => { :uploaded_data => path } end Processing UserAssetsController#create (for 127.0.0.1 at 2007-09-26 14:49:10) [POST] Session ID: d7b173a79b7f1382dc3b037c73608233 Parameters: {"action"=>"create", "controller"=>"user_assets", "user_id"=>"Andrew", "asset"=>{"uploaded_data"=>"#"}} User Load (1) (0.002464) SELECT * FROM users WHERE (users.`id` = 20) LIMIT 1 User Load (1) (0.002417) SELECT * FROM users WHERE (users.`login` = 'Andrew') LIMIT 1 Asset Columns (12) (0.004395) SHOW FIELDS FROM assets Processing UserAssetsController#create (for 127.0.0.1 at 2007-09-26 14:49:11) [POST] Session ID: d7b173a79b7f1382dc3b037c73608233 Parameters: {"action"=>"create", "controller"=>"user_assets", "user_id"=>"Andrew", "asset"=>{"uploaded_data"=>"#"}} undefined method `content_type' for "#":String If I launch the console and try the following line: app.post "users/admin/assets", :asset => { :uploaded_data => File.open('/Users/multimedia/desktop/sample/assets/bridge.jpg') } I get: Processing UserAssetsController#create (for 127.0.0.1 at 2007-09-25 23:47:36) [POST] Session ID: e23542c4871504f64044a25d8d49871b Parameters: {"action"=>"create", "controller"=>"user_assets", "user_id"=>"admin", "asset"=>{"uploaded_data"=>"#"}} ArgumentError (A copy of AuthenticatedSystem has been removed from the module tree but is still active!): Any ideas? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070926/5d2e93da/attachment.html From rspec.user at gmail.com Wed Sep 26 16:19:44 2007 From: rspec.user at gmail.com (sinclair bain) Date: Wed, 26 Sep 2007 16:19:44 -0400 Subject: [rspec-users] Testing nested controller In-Reply-To: <57c63afe0709222045k67fc3f87w8c245114cd3a8dc6@mail.gmail.com> References: <526df6040709140157s3bcd06f5u43178b13612c05c0@mail.gmail.com> <57c63afe0709222045k67fc3f87w8c245114cd3a8dc6@mail.gmail.com> Message-ID: <2ca660dd0709261319h475209b0rfd68227488c8d4b7@mail.gmail.com> get :show, :writer_id => "1", :note_id => "1" This may also get :show, :writer_id => "1", :id => "1" On 9/22/07, David Chelimsky wrote: > > Controller specs are similar to Rails functional tests, except that > they don't render views (unless you tell them to). So rather than > saying: > > get notes_path(1,1) > > you want to say: > > get :show, :writer_id => "1", :note_id => "1" > > Give that a shot and let us know if it works out. > > Cheers, > David > > On 9/14/07, Andreas Wolff wrote: > > Hey everyone. > > I really stuck on testing a nested controller. I'm trying to make a > > request using get and afterwards checking the response by > > response.should ... > > > > My routes.rb looks like this: > > > > map.resources :writers do |writers| > > writers.resources :notes > > end > > > > > > In my notes_controller_spec.rb > > > > def do_get > > writer_id = 1 > > note_id = 1 > > get note_path(writer_id, note_id) > > end > > > > it "should show a note" do > > do_get > > response.should be_success > > end > > > > > > But this always ends in an error message: > > You have a nil object when you didn't expect it! > > The error occurred while evaluating nil.rewrite > > > > Can anybody help here?? > > > > -- > > by(e) > > Andreas Wolff > > _______________________________________________ > > 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/20070926/07229ae2/attachment.html From korny at sietsma.com Thu Sep 27 05:39:02 2007 From: korny at sietsma.com (Korny Sietsma) Date: Thu, 27 Sep 2007 19:39:02 +1000 Subject: [rspec-users] using @variables in an 'it' block Message-ID: <8e15872b0709270239r4f7b1167wfe2b8e7d9b1cac45@mail.gmail.com> Hi folks, I'm somewhat new to the current RSpec release - at work we are still using 0.8.something, with "context 'blah' do ... specify 'should thing' ..." We have some helper code to automatically mix-in selenium: module SeleniumHelper include SpecHelper ... def initialize(arg) @selenium = SeleniumHelper.selenium end (selenium.rb also adds some method-missing magic so we don't need to say '@selenium.open(foo)' we can just say 'open(foo)', but that's not particularly relevant to my question) My problem is, at home in rspec 1.0.8, including this module doesn't work: describe ThingController do include SeleniumHelper it "should list all known things" do @selenium.open "/thing/list" # ==> fails with "nil.open" error SeleniumHelper.selenium.open "/thing/list" # ==> succeeds! open "/thing/list" # ==>fails with "nil.open" error end end The first line fails - @selenium seems to be nil, I get an exception. The second line passes. The third line fails also, for the same reason as the first. Any thoughts? Any hints on getting @selenium initialised? It seems that the method-missing magic is (probably) working, as the third line fails in the same way as the first line - but I'd like to know how to get @selenium to exist. (addendum - if I add to my startup code: config.before(:all) { @selenium = SeleniumHelper.selenium } it seems to work! But I'm still interested in why it doesn't get set in "initialize"...) - Korny -- Kornelis Sietsma korny at my surname dot com From ben at benmabey.com Thu Sep 27 11:40:09 2007 From: ben at benmabey.com (Ben Mabey) Date: Thu, 27 Sep 2007 09:40:09 -0600 Subject: [rspec-users] using @variables in an 'it' block In-Reply-To: <8e15872b0709270239r4f7b1167wfe2b8e7d9b1cac45@mail.gmail.com> References: <8e15872b0709270239r4f7b1167wfe2b8e7d9b1cac45@mail.gmail.com> Message-ID: <46FBCED9.3020609@benmabey.com> Have you tried just turning @selenium into a method for lazy initialization? So, you could have: def selenium @selenium ||= SeleniumHelper.selenium end The in your spec just use the method call as opposed to the instance variable. That is probably what I would do. I have never used initialize in a module so I don't have any ideas along those lines. -Ben Korny Sietsma wrote: > Hi folks, > > I'm somewhat new to the current RSpec release - at work we are still > using 0.8.something, with "context 'blah' do ... specify 'should > thing' ..." > > We have some helper code to automatically mix-in selenium: > module SeleniumHelper > include SpecHelper > ... > def initialize(arg) > @selenium = SeleniumHelper.selenium > end > (selenium.rb also adds some method-missing magic so we don't need to > say '@selenium.open(foo)' we can just say 'open(foo)', but that's not > particularly relevant to my question) > > My problem is, at home in rspec 1.0.8, including this module doesn't work: > > describe ThingController do > include SeleniumHelper > > it "should list all known things" do > @selenium.open "/thing/list" # ==> fails with "nil.open" error > SeleniumHelper.selenium.open "/thing/list" # ==> succeeds! > open "/thing/list" # ==>fails with "nil.open" error > end > end > > The first line fails - @selenium seems to be nil, I get an exception. > The second line passes. > The third line fails also, for the same reason as the first. > > Any thoughts? Any hints on getting @selenium initialised? It seems > that the method-missing magic is (probably) working, as the third line > fails in the same way as the first line - but I'd like to know how to > get @selenium to exist. > > (addendum - if I add to my startup code: > config.before(:all) { @selenium = SeleniumHelper.selenium } > it seems to work! But I'm still interested in why it doesn't get set > in "initialize"...) > > - Korny > > From david.smalley.lists at googlemail.com Thu Sep 27 13:07:48 2007 From: david.smalley.lists at googlemail.com (David Smalley) Date: Thu, 27 Sep 2007 18:07:48 +0100 Subject: [rspec-users] fixture_scenarios in trunk Message-ID: <5F85E23D-A6A4-4C43-8DE7-EF36BFB29873@googlemail.com> Hi, I saw a previous post from David answering someones question about fixture_scenarios with rspec. Following that I upgraded my rspec and rspec_on_rails to the trunk versions and then installed the fixture scenario plugin. Now whenever I run my (previously passing rspecs) I get the following error for all tests... ... 148) NoMethodError in 'Cart should show a sub_total_amount' You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.each ../vendor/plugins/fixture_scenarios/lib/fixture_scenarios.rb:37:in `create_fixtures' ../vendor/plugins/fixture_scenarios/lib/fixture_scenarios.rb:33:in `create_fixtures' ../vendor/plugins/fixture_scenarios/lib/fixture_scenarios.rb:26:in `create_fixtures' ../vendor/plugins/fixture_scenarios/lib/fixture_scenarios.rb:257:in `load_fixtures' ../vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/ rails_example.rb:27:in `before_eval' At the moment I am only using global fixtures for one model, I have tried removing this line and its still the same error. config.global_fixtures = :sites and I have added the trailing slash to my fixture path config.fixture_path = RAILS_ROOT + '/spec/fixtures/' Anyone got any pointers on getting this running? This particular application uses railsengines (both rails and engines are gem versions of 1.2 (rails 1.2.3)) Thanks, David From cnantais at gmail.com Thu Sep 27 14:47:58 2007 From: cnantais at gmail.com (cnantais) Date: Thu, 27 Sep 2007 11:47:58 -0700 (PDT) Subject: [rspec-users] rspec_on_rails: controller method not getting called Message-ID: <12927783.post@talk.nabble.com> In my rspec_on_rails controlle rspec, I have this: require File.dirname(__FILE__) + '/../spec_helper' describe FooController, "with a foo" do it "should be false" do get 'index' assigns[:foo].should be_false end end In my controller I have this: class FooController < ApplicationController def index @foo = FALSE end end But the result of running the spec is: 1) 'FooController should be false' FAILED expected false, got nil It seems I can give any argument to `get`in the description and it won't complain that the method is missing, so I suppose this means that the `get` in the description is not calling my 'index' method. Any advice? I'm using the latest RSpec and rspec_on_rails, ruby 1.8.6, Rails 1.2.3. Thanks, Chad -- View this message in context: http://www.nabble.com/rspec_on_rails%3A-controller-method-not-getting-called-tf4530269.html#a12927783 Sent from the rspec-users mailing list archive at Nabble.com. From simon at mintsource.org Wed Sep 26 18:54:46 2007 From: simon at mintsource.org (Simon Peter Nicholls) Date: Wed, 26 Sep 2007 23:54:46 +0100 Subject: [rspec-users] How do I best setup data for Story Runner? Message-ID: <48E9B5AD-5C90-4E75-B50A-EA3626A4BF32@mintsource.org> Just started looking at the Story Runner integration, and am converting a few Rails integration tests to get a feel for it. My integration tests relied on fixtures, and since my models have a significant amount of validation (and hence need valid data unless I save without validation), this has made setup easy. With stories however, I'm wondering what the recommended approach is. Mocks are out I assume, since the point is testing the stack, but are fixtures out too? Should we be meeting our more complex or repetitive setup needs by treating it as plain ruby code that needs refactoring via regular Ruby/OO techniques (Object Mother et al)? A typical scenario for me might involve a couple of users with different roles, plus a collection of other collaborating objects. Thanks -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2423 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070926/28797084/attachment-0001.bin From cnantais at gmail.com Thu Sep 27 15:29:20 2007 From: cnantais at gmail.com (cnantais) Date: Thu, 27 Sep 2007 12:29:20 -0700 (PDT) Subject: [rspec-users] rspec_on_rails: controller method not getting called In-Reply-To: <12927783.post@talk.nabble.com> References: <12927783.post@talk.nabble.com> Message-ID: <12928446.post@talk.nabble.com> I figured it out. By doing this session sanity check in the spec (as recommended by dchelimsky): sess = session get 'index' sess.should equal(session) I was able to see that a 'Please log in' redirect was preventing index from getting called. Chad cnantais wrote: > > In my rspec_on_rails controlle rspec, I have this: > > require File.dirname(__FILE__) + '/../spec_helper' > > describe FooController, "with a foo" do > it "should be false" do > get 'index' > assigns[:foo].should be_false > end > end > > In my controller I have this: > > class FooController < ApplicationController > def index > @foo = FALSE > end > end > > But the result of running the spec is: > 1) > 'FooController should be false' FAILED > expected false, got nil > > It seems I can give any argument to `get`in the description and it won't > complain that the method is missing, so I suppose this means that the > `get` in the description is not calling my 'index' method. Any advice? > > I'm using the latest RSpec and rspec_on_rails, ruby 1.8.6, Rails 1.2.3. > > Thanks, > > Chad > > -- View this message in context: http://www.nabble.com/rspec_on_rails%3A-controller-method-not-getting-called-tf4530269.html#a12928446 Sent from the rspec-users mailing list archive at Nabble.com. From pergesu at gmail.com Thu Sep 27 15:41:33 2007 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 27 Sep 2007 12:41:33 -0700 Subject: [rspec-users] How do I best setup data for Story Runner? In-Reply-To: <48E9B5AD-5C90-4E75-B50A-EA3626A4BF32@mintsource.org> References: <48E9B5AD-5C90-4E75-B50A-EA3626A4BF32@mintsource.org> Message-ID: <810a540e0709271241t7b56847di9726f255dfdd582d@mail.gmail.com> On 9/26/07, Simon Peter Nicholls wrote: > Just started looking at the Story Runner integration, and am > converting a few Rails integration tests to get a feel for it. > > My integration tests relied on fixtures, and since my models have a > significant amount of validation (and hence need valid data unless I > save without validation), this has made setup easy. > > With stories however, I'm wondering what the recommended approach is. > Mocks are out I assume, since the point is testing the stack, but are > fixtures out too? Should we be meeting our more complex or repetitive > setup needs by treating it as plain ruby code that needs refactoring > via regular Ruby/OO techniques (Object Mother et al)? > > A typical scenario for me might involve a couple of users with > different roles, plus a collection of other collaborating objects. > > Thanks > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > I don't use fixtures (the yaml type, anyway) in story runner stories. I construct objects in the given blocks. I find that that does two things for me. First, it clearly expresses what a given really means. So when I say Given "an activated user," I don't have to go dig around some YAML files. If I need to understand it I can just look at the code and see u = User.create! :login => "pat" u.activate Secondly, constructing your object graph instead of using fixtures means you're actually exercising your code. With fixtures you just instantiate some objects and fill them with data, which may not necessarily be valid (they require maintenance). Also if you're using stuff like before/after create hooks to create child objects, using fixtures bypasses that. I look at fixtures as a weird kind of mock. You're not using the full implementation, so what's the point really? I'd rather use a real object or a proper mock object. In stories I don't use mocks at all, so obviously I'll go for the full implementation. Pat From barjunk at attglobal.net Thu Sep 27 15:53:44 2007 From: barjunk at attglobal.net (barsalou) Date: Thu, 27 Sep 2007 11:53:44 -0800 Subject: [rspec-users] 1.0.8 tarball problem. Message-ID: <20070927115344.9od9wynocgkw8gg8@lcgalaska.com> When I untar 1.0.8 after having downloaded it from rubyforge, I get these errors: rspec-1.0.8/spec/spec/runner/spec_parser_spec.rb rspec-1.0.8/spec/spec/spec_classes.rb gzip: stdin: decompression OK, trailing garbage ignored rspec-1.0.8/spec/spec/translator_spec.rb rspec-1.0.8/spec/spec_helper.rb rspec-1.0.8/UPGRADE tar: Child returned status 2 tar: Error exit delayed from previous errors And for rspec_on_rails: rspec_on_rails-1.0.8/spec_resources/views/ rspec_on_rails-1.0.8/spec_resources/views/controller_spec/ gzip: stdin: decompression OK, trailing garbage ignored rspec_on_rails-1.0.8/spec_resources/views/controller_spec/_partial.rhtml rspec_on_rails-1.0.8/spec_resources/views/controller_spec/action_setting_flash_after_session_reset.rhtml rspec_on_rails-1.0.8/tasks/ rspec_on_rails-1.0.8/tasks/rspec.rake tar: Child returned status 2 tar: Error exit delayed from previous errors I'm using this command on Linux: tar -zxvf rspec_on_rails-1.0.8.tgz Is that a broken tarball or is it the command I'm using? Mike B. ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. From edgargonzalez at gmail.com Thu Sep 27 16:07:50 2007 From: edgargonzalez at gmail.com (Edgar Gonzalez) Date: Thu, 27 Sep 2007 16:07:50 -0400 Subject: [rspec-users] There is a easy way to valid markup? Message-ID: Do I have to create a custom Expectation Matcher? or there is a way to integrate assert_valid_asset plugin? thx -- Edgar Gonz?lez Gonz?lez -- From pergesu at gmail.com Thu Sep 27 16:23:03 2007 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 27 Sep 2007 13:23:03 -0700 Subject: [rspec-users] There is a easy way to valid markup? In-Reply-To: References: Message-ID: <810a540e0709271323o28aea865o37d7972dd7daa01d@mail.gmail.com> On 9/27/07, Edgar Gonzalez wrote: > Do I have to create a custom Expectation Matcher? > > or there is a way to integrate assert_valid_asset plugin? > > thx > -- > Edgar Gonz?lez Gonz?lez > -- > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > I'm sure you could hook into some kind of validator. I jumped on RubyForge and found http://rubyforge.org/projects/feedvalidator/. It kind of sucks because you'd depend on a web service for this...there have to be validators that you can run locally though, right? Pat From simon at mintsource.org Thu Sep 27 18:05:44 2007 From: simon at mintsource.org (Simon Peter Nicholls) Date: Thu, 27 Sep 2007 23:05:44 +0100 Subject: [rspec-users] How do I best setup data for Story Runner? Message-ID: Thanks Pat! I find your arguments fairly compelling. From badcarl at gmail.com Thu Sep 27 18:11:57 2007 From: badcarl at gmail.com (Carl Porth) Date: Thu, 27 Sep 2007 15:11:57 -0700 Subject: [rspec-users] How do I best setup data for Story Runner? In-Reply-To: <810a540e0709271241t7b56847di9726f255dfdd582d@mail.gmail.com> References: <48E9B5AD-5C90-4E75-B50A-EA3626A4BF32@mintsource.org> <810a540e0709271241t7b56847di9726f255dfdd582d@mail.gmail.com> Message-ID: <05A19FC9-1867-4814-AC9B-FA58C33A0A02@gmail.com> On Sep 27, 2007, at 12:41 PM, Pat Maddox wrote: > On 9/26/07, Simon Peter Nicholls wrote: >> Just started looking at the Story Runner integration, and am >> converting a few Rails integration tests to get a feel for it. >> >> My integration tests relied on fixtures, and since my models have a >> significant amount of validation (and hence need valid data unless I >> save without validation), this has made setup easy. >> >> With stories however, I'm wondering what the recommended approach is. >> Mocks are out I assume, since the point is testing the stack, but are >> fixtures out too? Should we be meeting our more complex or repetitive >> setup needs by treating it as plain ruby code that needs refactoring >> via regular Ruby/OO techniques (Object Mother et al)? >> >> A typical scenario for me might involve a couple of users with >> different roles, plus a collection of other collaborating objects. >> >> Thanks >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > > I don't use fixtures (the yaml type, anyway) in story runner stories. > I construct objects in the given blocks. I find that that does two > things for me. First, it clearly expresses what a given really means. > So when I say Given "an activated user," I don't have to go dig > around some YAML files. If I need to understand it I can just look at > the code and see > u = User.create! :login => "pat" > u.activate > > Secondly, constructing your object graph instead of using fixtures > means you're actually exercising your code. With fixtures you just > instantiate some objects and fill them with data, which may not > necessarily be valid (they require maintenance). Also if you're using > stuff like before/after create hooks to create child objects, using > fixtures bypasses that. > > I look at fixtures as a weird kind of mock. You're not using the full > implementation, so what's the point really? I'd rather use a real > object or a proper mock object. In stories I don't use mocks at all, > so obviously I'll go for the full implementation. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users +1 I've adopted a factory pattern for organizing my tests inspired by: http://www.dcmanges.com/blog/38 Carl From chrisdpratt at gmail.com Thu Sep 27 20:48:18 2007 From: chrisdpratt at gmail.com (Christopher D. Pratt) Date: Thu, 27 Sep 2007 19:48:18 -0500 Subject: [rspec-users] RSpec + EdgeRails on Windows Message-ID: <79a30c430709271748l34c7bb06s90403ec8b5fb383e@mail.gmail.com> I recently post on my blog about setting up a Rails environment with RSpec in Windows, and someone left a comment saying that it doesn't work in EdgeRails. I so I played around with it a bit and was able to confirm that none RSpec appears broken on EdgeRails. I'll post the various error messages I received below. I'm not expecting any sort of patch or something for this since it is EdgeRails, but I'm hoping someone might understand the errors better than I do and know a workaround. When running generators, including the main rspec generator: /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_requi re': no such file to load -- active_resource (MissingSourceFile) from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `requi re' from /cygdrive/c/Documents and Settings/Christopher D. Pratt/test/vendor /rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:4 96:in `require' from /cygdrive/c/Documents and Settings/Christopher D. Pratt/test/vendor /rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:3 42:in `new_constants_in' from /cygdrive/c/Documents and Settings/Christopher D. Pratt/test/vendor /rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:4 96:in `require' from ./script/../config/../vendor/rails/railties/lib/initializer.rb:154: in `require_frameworks' from ./script/../config/../vendor/rails/railties/lib/initializer.rb:154: in `each' from ./script/../config/../vendor/rails/railties/lib/initializer.rb:154: in `require_frameworks' from ./script/../config/../vendor/rails/railties/lib/initializer.rb:87:i n `process' ... 8 levels... from /cygdrive/c/Documents and Settings/Christopher D. Pratt/test/vendor /rails/railties/lib/commands/generate.rb:1 from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `gem_o riginal_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `requi re' from script/generate:3 When running autotest (hangs afterward): loading autotest/rails_rspec /usr/bin/ruby -S script/spec -O spec/spec.opts spec/models/user_spec.rb /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_requi re': no such file to load -- active_resource (MissingSourceFile) from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `requi re' from /cygdrive/c/Documents and Settings/Christopher D. Pratt/test/vendor /rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:4 96:in `require' from /cygdrive/c/Documents and Settings/Christopher D. Pratt/test/vendor /rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:3 42:in `new_constants_in' from /cygdrive/c/Documents and Settings/Christopher D. Pratt/test/vendor /rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:4 96:in `require' from /cygdrive/c/Documents and Settings/Christopher D. Pratt/test/config /../vendor/rails/railties/lib/initializer.rb:154:in `require_frameworks' from /cygdrive/c/Documents and Settings/Christopher D. Pratt/test/config /../vendor/rails/railties/lib/initializer.rb:154:in `each' from /cygdrive/c/Documents and Settings/Christopher D. Pratt/test/config /../vendor/rails/railties/lib/initializer.rb:154:in `require_frameworks' from /cygdrive/c/Documents and Settings/Christopher D. Pratt/test/config /../vendor/rails/railties/lib/initializer.rb:87:in `process' ... 25 levels... from /cygdrive/c/Documents and Settings/Christopher D. Pratt/test/vendor /plugins/rspec/lib/spec/runner/option_parser.rb:155:in `parse' from /cygdrive/c/Documents and Settings/Christopher D. Pratt/test/vendor /plugins/rspec/lib/spec/runner/option_parser.rb:88:in `create_behaviour_runner' from /cygdrive/c/Documents and Settings/Christopher D. Pratt/test/vendor /plugins/rspec/lib/spec/runner/command_line.rb:14:in `run' from script/spec:4 Running rake spec: (in /cygdrive/c/Documents and Settings/Christopher D. Pratt/test) rake aborted! no such file to load -- active_resource That last one is a little more obvious, but I'm not sure how to go about fixing it. Thanks, Chris Pratt -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070927/98fb8842/attachment-0001.html From luislavena at gmail.com Thu Sep 27 20:59:30 2007 From: luislavena at gmail.com (Luis Lavena) Date: Thu, 27 Sep 2007 21:59:30 -0300 Subject: [rspec-users] RSpec + EdgeRails on Windows In-Reply-To: <79a30c430709271748l34c7bb06s90403ec8b5fb383e@mail.gmail.com> References: <79a30c430709271748l34c7bb06s90403ec8b5fb383e@mail.gmail.com> Message-ID: <71166b3b0709271759i2b791feehdfc42b3606bc81ea@mail.gmail.com> On 9/27/07, Christopher D. Pratt wrote: > I recently post on my blog about setting up a Rails environment with RSpec > in Windows, and someone left a comment saying that it doesn't work in > EdgeRails. I so I played around with it a bit and was able to confirm that > none RSpec appears broken on EdgeRails. I'll post the various error messages > I received below. I'm not expecting any sort of patch or something for this > since it is EdgeRails, but I'm hoping someone might understand the errors > better than I do and know a workaround. > > When running generators, including the main rspec generator: > > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_requi > re': no such file to load -- active_resource (MissingSourceFile) > from Thanks because edge_rails requires ActiveResource, and the rake freeze:edge:rails don't checkout it. Your options: A) Use Piston to checkout Rails Edge: piston import http://svn.rubyonrails.org/rails/trunk/ vendor/rails (your code should be under version control) B) Manually checkout it the missing part svn co http://svn.rubyonrails.org/rails/trunk/activeresource vendor/rails HTH, -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From dchelimsky at gmail.com Thu Sep 27 20:59:36 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 27 Sep 2007 19:59:36 -0500 Subject: [rspec-users] RSpec + EdgeRails on Windows In-Reply-To: <79a30c430709271748l34c7bb06s90403ec8b5fb383e@mail.gmail.com> References: <79a30c430709271748l34c7bb06s90403ec8b5fb383e@mail.gmail.com> Message-ID: <57c63afe0709271759i1d8690a8x24a13eeb52fcc6df@mail.gmail.com> On 9/27/07, Christopher D. Pratt wrote: > I recently post on my blog about setting up a Rails environment with RSpec > in Windows, and someone left a comment saying that it doesn't work in > EdgeRails. I so I played around with it a bit and was able to confirm that > none RSpec appears broken on EdgeRails. I'll post the various error messages > I received below. I'm not expecting any sort of patch or something for this > since it is EdgeRails, but I'm hoping someone might understand the errors > better than I do and know a workaround. > > When running generators, including the main rspec generator: > > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_requi > re': no such file to load -- active_resource (MissingSourceFile) I've seen this problem before after updating edge rails. I can't remember how I fixed it - I think I just updated rails a second time. But this wasn't an rspec problem when I experienced it - I couldn't run the app either. Anybody else? > from > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > `requi > re' > from /cygdrive/c/Documents and Settings/Christopher D. > Pratt/test/vendor > /rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:4 > 96:in `require' > from /cygdrive/c/Documents and Settings/Christopher D. > Pratt/test/vendor > /rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:3 > 42:in `new_constants_in' > from /cygdrive/c/Documents and Settings/Christopher D. > Pratt/test/vendor > /rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:4 > 96:in `require' > from > ./script/../config/../vendor/rails/railties/lib/initializer.rb:154: > in `require_frameworks' > from > ./script/../config/../vendor/rails/railties/lib/initializer.rb:154: > in `each' > from > ./script/../config/../vendor/rails/railties/lib/initializer.rb:154: > in `require_frameworks' > from > ./script/../config/../vendor/rails/railties/lib/initializer.rb:87:i > n `process' > ... 8 levels... > from /cygdrive/c/Documents and Settings/Christopher D. > Pratt/test/vendor > /rails/railties/lib/commands/generate.rb:1 > from > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in > `gem_o > riginal_require' > from > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in > `requi > re' > from script/generate:3 > > When running autotest (hangs afterward): > > loading autotest/rails_rspec > /usr/bin/ruby -S script/spec -O spec/spec.opts spec/models/user_spec.rb > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_requi > re': no such file to load -- active_resource (MissingSourceFile) > from > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > `requi > re' > from /cygdrive/c/Documents and Settings/Christopher D. > Pratt/test/vendor > /rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:4 > 96:in `require' > from /cygdrive/c/Documents and Settings/Christopher D. > Pratt/test/vendor > /rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:3 > 42:in `new_constants_in' > from /cygdrive/c/Documents and Settings/Christopher D. > Pratt/test/vendor > /rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:4 > 96:in `require' > from /cygdrive/c/Documents and Settings/Christopher D. > Pratt/test/config > /../vendor/rails/railties/lib/initializer.rb:154:in > `require_frameworks' > from /cygdrive/c/Documents and Settings/Christopher D. > Pratt/test/config > /../vendor/rails/railties/lib/initializer.rb:154:in `each' > from /cygdrive/c/Documents and Settings/Christopher D. > Pratt/test/config > /../vendor/rails/railties/lib/initializer.rb:154:in > `require_frameworks' > from /cygdrive/c/Documents and Settings/Christopher D. > Pratt/test/config > /../vendor/rails/railties/lib/initializer.rb:87:in > `process' > ... 25 levels... > from /cygdrive/c/Documents and Settings/Christopher D. > Pratt/test/vendor > /plugins/rspec/lib/spec/runner/option_parser.rb:155:in > `parse' > from /cygdrive/c/Documents and Settings/Christopher D. > Pratt/test/vendor > /plugins/rspec/lib/spec/runner/option_parser.rb:88:in > `create_behaviour_runner' > from /cygdrive/c/Documents and Settings/Christopher D. > Pratt/test/vendor > /plugins/rspec/lib/spec/runner/command_line.rb:14:in `run' > from script/spec:4 > > Running rake spec: > > (in /cygdrive/c/Documents and Settings/Christopher D. Pratt/test) > rake aborted! > no such file to load -- active_resource > > > That last one is a little more obvious, but I'm not sure how to go about > fixing it. > > Thanks, > > Chris Pratt > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Sep 27 21:00:11 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 27 Sep 2007 20:00:11 -0500 Subject: [rspec-users] RSpec + EdgeRails on Windows In-Reply-To: <71166b3b0709271759i2b791feehdfc42b3606bc81ea@mail.gmail.com> References: <79a30c430709271748l34c7bb06s90403ec8b5fb383e@mail.gmail.com> <71166b3b0709271759i2b791feehdfc42b3606bc81ea@mail.gmail.com> Message-ID: <57c63afe0709271800i1e133587rd8c714034ac8d0d5@mail.gmail.com> On 9/27/07, Luis Lavena wrote: > On 9/27/07, Christopher D. Pratt wrote: > > I recently post on my blog about setting up a Rails environment with RSpec > > in Windows, and someone left a comment saying that it doesn't work in > > EdgeRails. I so I played around with it a bit and was able to confirm that > > none RSpec appears broken on EdgeRails. I'll post the various error messages > > I received below. I'm not expecting any sort of patch or something for this > > since it is EdgeRails, but I'm hoping someone might understand the errors > > better than I do and know a workaround. > > > > When running generators, including the main rspec generator: > > > > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > > `gem_original_requi > > re': no such file to load -- active_resource (MissingSourceFile) > > from > > Thanks because edge_rails requires ActiveResource, and the rake > freeze:edge:rails don't checkout it. > > Your options: > > A) Use Piston to checkout Rails Edge: > > piston import http://svn.rubyonrails.org/rails/trunk/ vendor/rails > > (your code should be under version control) > > B) Manually checkout it the missing part > > svn co http://svn.rubyonrails.org/rails/trunk/activeresource vendor/rails Thanks Luis! > > HTH, > > -- > Luis Lavena > Multimedia systems > - > Leaders are made, they are not born. They are made by hard effort, > which is the price which all of us must pay to achieve any goal that > is worthwhile. > Vince Lombardi > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From chrisdpratt at gmail.com Thu Sep 27 21:03:21 2007 From: chrisdpratt at gmail.com (Christopher D. Pratt) Date: Thu, 27 Sep 2007 20:03:21 -0500 Subject: [rspec-users] RSpec + EdgeRails on Windows In-Reply-To: <71166b3b0709271759i2b791feehdfc42b3606bc81ea@mail.gmail.com> References: <79a30c430709271748l34c7bb06s90403ec8b5fb383e@mail.gmail.com> <71166b3b0709271759i2b791feehdfc42b3606bc81ea@mail.gmail.com> Message-ID: <79a30c430709271803j5a889d8eu3224befc42598b9@mail.gmail.com> I second that ;). Thanks Luis. Never ceases to amaze me how quickly people on this list respond. Thanks to all of you for all the support. As for my problem, I'll give what you said a try. It makes sense, so I doubt I'll have any further problems. Thanks again, Chris Pratt On 9/27/07, Luis Lavena wrote: > > On 9/27/07, Christopher D. Pratt wrote: > > I recently post on my blog about setting up a Rails environment with > RSpec > > in Windows, and someone left a comment saying that it doesn't work in > > EdgeRails. I so I played around with it a bit and was able to confirm > that > > none RSpec appears broken on EdgeRails. I'll post the various error > messages > > I received below. I'm not expecting any sort of patch or something for > this > > since it is EdgeRails, but I'm hoping someone might understand the > errors > > better than I do and know a workaround. > > > > When running generators, including the main rspec generator: > > > > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > > `gem_original_requi > > re': no such file to load -- active_resource (MissingSourceFile) > > from > > Thanks because edge_rails requires ActiveResource, and the rake > freeze:edge:rails don't checkout it. > > Your options: > > A) Use Piston to checkout Rails Edge: > > piston import http://svn.rubyonrails.org/rails/trunk/ vendor/rails > > (your code should be under version control) > > B) Manually checkout it the missing part > > svn co http://svn.rubyonrails.org/rails/trunk/activeresource vendor/rails > > HTH, > > -- > Luis Lavena > Multimedia systems > - > Leaders are made, they are not born. They are made by hard effort, > which is the price which all of us must pay to achieve any goal that > is worthwhile. > Vince Lombardi > _______________________________________________ > 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/20070927/5939b028/attachment.html From mailing_lists at railsnewbie.com Thu Sep 27 21:37:02 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Thu, 27 Sep 2007 21:37:02 -0400 Subject: [rspec-users] 1.0.8 tarball problem. In-Reply-To: <20070927115344.9od9wynocgkw8gg8@lcgalaska.com> References: <20070927115344.9od9wynocgkw8gg8@lcgalaska.com> Message-ID: This was a known problem. I believe it should be fixed in the next release (fixed on trunk). Scott On Sep 27, 2007, at 3:53 PM, barsalou wrote: > When I untar 1.0.8 after having downloaded it from rubyforge, I get > these errors: > > > > rspec-1.0.8/spec/spec/runner/spec_parser_spec.rb > rspec-1.0.8/spec/spec/spec_classes.rb > > gzip: stdin: decompression OK, trailing garbage ignored > rspec-1.0.8/spec/spec/translator_spec.rb > rspec-1.0.8/spec/spec_helper.rb > rspec-1.0.8/UPGRADE > tar: Child returned status 2 > tar: Error exit delayed from previous errors > > And for rspec_on_rails: > > > > rspec_on_rails-1.0.8/spec_resources/views/ > rspec_on_rails-1.0.8/spec_resources/views/controller_spec/ > > gzip: stdin: decompression OK, trailing garbage ignored > rspec_on_rails-1.0.8/spec_resources/views/controller_spec/ > _partial.rhtml > rspec_on_rails-1.0.8/spec_resources/views/controller_spec/ > action_setting_flash_after_session_reset.rhtml > > > > rspec_on_rails-1.0.8/tasks/ > rspec_on_rails-1.0.8/tasks/rspec.rake > tar: Child returned status 2 > tar: Error exit delayed from previous errors > > > I'm using this command on Linux: > > tar -zxvf rspec_on_rails-1.0.8.tgz > > Is that a broken tarball or is it the command I'm using? > > Mike B. > > ---------------------------------------------------------------- > This message was sent using IMP, the Internet Messaging Program. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From hans at degraaff.org Fri Sep 28 01:55:11 2007 From: hans at degraaff.org (Hans de Graaff) Date: Fri, 28 Sep 2007 07:55:11 +0200 Subject: [rspec-users] There is a easy way to valid markup? In-Reply-To: References: Message-ID: <1190958911.3383.3.camel@ip6-localhost> On Thu, 2007-09-27 at 16:07 -0400, Edgar Gonzalez wrote: > Do I have to create a custom Expectation Matcher? > > or there is a way to integrate assert_valid_asset plugin? > > thx I'm using this expectation to check for valid XHTML using a locally installed copy of tidy: http://pastie.caboo.se/101660 In my controller tests I'm including something like it 'should be a valid XHTML page' do get :index response.should be_xhtml end Note the :show option also. Tidy outputs its errors with the line numbers which can be a pain to track down. Using bx_xhtml(:show => true) will first show the generated code and then the tidy warnings. Kind regards, Hans -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070928/55f12899/attachment.bin From mailing_lists at railsnewbie.com Fri Sep 28 03:48:15 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 28 Sep 2007 03:48:15 -0400 Subject: [rspec-users] How do I best setup data for Story Runner? In-Reply-To: <05A19FC9-1867-4814-AC9B-FA58C33A0A02@gmail.com> References: <48E9B5AD-5C90-4E75-B50A-EA3626A4BF32@mintsource.org> <810a540e0709271241t7b56847di9726f255dfdd582d@mail.gmail.com> <05A19FC9-1867-4814-AC9B-FA58C33A0A02@gmail.com> Message-ID: <4C392575-9582-41C0-B290-3995818753B7@railsnewbie.com> On Sep 27, 2007, at 6:11 PM, Carl Porth wrote: > On Sep 27, 2007, at 12:41 PM, Pat Maddox wrote: > >> On 9/26/07, Simon Peter Nicholls wrote: >>> Just started looking at the Story Runner integration, and am >>> converting a few Rails integration tests to get a feel for it. >>> >>> My integration tests relied on fixtures, and since my models have a >>> significant amount of validation (and hence need valid data unless I >>> save without validation), this has made setup easy. >>> >>> With stories however, I'm wondering what the recommended approach >>> is. >>> Mocks are out I assume, since the point is testing the stack, but >>> are >>> fixtures out too? Should we be meeting our more complex or >>> repetitive >>> setup needs by treating it as plain ruby code that needs refactoring >>> via regular Ruby/OO techniques (Object Mother et al)? >>> >>> A typical scenario for me might involve a couple of users with >>> different roles, plus a collection of other collaborating objects. >>> >>> Thanks >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> >> >> I don't use fixtures (the yaml type, anyway) in story runner stories. >> I construct objects in the given blocks. I find that that does two >> things for me. First, it clearly expresses what a given really >> means. >> So when I say Given "an activated user," I don't have to go dig >> around some YAML files. If I need to understand it I can just >> look at >> the code and see >> u = User.create! :login => "pat" >> u.activate >> >> Secondly, constructing your object graph instead of using fixtures >> means you're actually exercising your code. With fixtures you just >> instantiate some objects and fill them with data, which may not >> necessarily be valid (they require maintenance). Also if you're >> using >> stuff like before/after create hooks to create child objects, using >> fixtures bypasses that. >> >> I look at fixtures as a weird kind of mock. You're not using the >> full >> implementation, so what's the point really? I'd rather use a real >> object or a proper mock object. In stories I don't use mocks at all, >> so obviously I'll go for the full implementation. >> >> Pat >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > +1 > > I've adopted a factory pattern for organizing my tests inspired by: > http://www.dcmanges.com/blog/38 > Yeah, that post was great, and inspired me to create a plugin, which has been essential to my workflow. Here is a screencast (and a shameless plug) for it: http://railsnewbie.com/files/fixture_replacement_demo.mov I was/am quite tired (it's about 3 AM), so just forward through my stupidity. Regarding Pat's post: fixtures aren't a weird kind of mock, they are real data. The problem is their large overhead in scaling to a project of any size (especially the typical one with lots of associations). Plus, fighting with YAML just sucks. Am I putting in invalid data, or are those tabs instead of spaces? The truth is that they are *PAINFUL* to use, and that's why no one uses them (and why "testing" sucks, and is done after a project instead of before). Personally, I'd love to use mocks in my model specs, but I just can't bring myself to do it. It, too, is painful, because I essentially need to understand the details of how activerecord works. Why spend an hour figuring out that User.find_or_create_by_username 'scott' should be stubbed out as User.find("username" => "scott") and not User.find(:username => "scott")? Have you read Jay Field's blog recently? Stubbing ActiveRecord::Connection::Column ? Give me a break. That's going to break the second you upgrade rails. Mocks are great for external libraries (or objects which you control), but with rails everything is so tightly woven together that mocking/stubbing seems to be more pain then it's worth. The only positive thing the stub approach has going for it is the speed factor. I'd be very interested in hearing how you are using mocks successfully without the overhead of learning tons of plumbing. Scott From pergesu at gmail.com Fri Sep 28 04:35:22 2007 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 28 Sep 2007 01:35:22 -0700 Subject: [rspec-users] How do I best setup data for Story Runner? In-Reply-To: <4C392575-9582-41C0-B290-3995818753B7@railsnewbie.com> References: <48E9B5AD-5C90-4E75-B50A-EA3626A4BF32@mintsource.org> <810a540e0709271241t7b56847di9726f255dfdd582d@mail.gmail.com> <05A19FC9-1867-4814-AC9B-FA58C33A0A02@gmail.com> <4C392575-9582-41C0-B290-3995818753B7@railsnewbie.com> Message-ID: <810a540e0709280135t134d6e93u307b4090f2eae63a@mail.gmail.com> On 9/28/07, Scott Taylor wrote: > > On Sep 27, 2007, at 6:11 PM, Carl Porth wrote: > > > On Sep 27, 2007, at 12:41 PM, Pat Maddox wrote: > > > >> On 9/26/07, Simon Peter Nicholls wrote: > >>> Just started looking at the Story Runner integration, and am > >>> converting a few Rails integration tests to get a feel for it. > >>> > >>> My integration tests relied on fixtures, and since my models have a > >>> significant amount of validation (and hence need valid data unless I > >>> save without validation), this has made setup easy. > >>> > >>> With stories however, I'm wondering what the recommended approach > >>> is. > >>> Mocks are out I assume, since the point is testing the stack, but > >>> are > >>> fixtures out too? Should we be meeting our more complex or > >>> repetitive > >>> setup needs by treating it as plain ruby code that needs refactoring > >>> via regular Ruby/OO techniques (Object Mother et al)? > >>> > >>> A typical scenario for me might involve a couple of users with > >>> different roles, plus a collection of other collaborating objects. > >>> > >>> Thanks > >>> _______________________________________________ > >>> rspec-users mailing list > >>> rspec-users at rubyforge.org > >>> http://rubyforge.org/mailman/listinfo/rspec-users > >>> > >>> > >> > >> I don't use fixtures (the yaml type, anyway) in story runner stories. > >> I construct objects in the given blocks. I find that that does two > >> things for me. First, it clearly expresses what a given really > >> means. > >> So when I say Given "an activated user," I don't have to go dig > >> around some YAML files. If I need to understand it I can just > >> look at > >> the code and see > >> u = User.create! :login => "pat" > >> u.activate > >> > >> Secondly, constructing your object graph instead of using fixtures > >> means you're actually exercising your code. With fixtures you just > >> instantiate some objects and fill them with data, which may not > >> necessarily be valid (they require maintenance). Also if you're > >> using > >> stuff like before/after create hooks to create child objects, using > >> fixtures bypasses that. > >> > >> I look at fixtures as a weird kind of mock. You're not using the > >> full > >> implementation, so what's the point really? I'd rather use a real > >> object or a proper mock object. In stories I don't use mocks at all, > >> so obviously I'll go for the full implementation. > >> > >> Pat > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > +1 > > > > I've adopted a factory pattern for organizing my tests inspired by: > > http://www.dcmanges.com/blog/38 > > > > Yeah, that post was great, and inspired me to create a plugin, which > has been essential to my workflow. Here is a screencast (and a > shameless plug) for it: > > http://railsnewbie.com/files/fixture_replacement_demo.mov > > I was/am quite tired (it's about 3 AM), so just forward through my > stupidity. > > Regarding Pat's post: fixtures aren't a weird kind of mock, they are > real data. I had a feeling that comment would get some attention :) I hoped I had clarified it in my post, but apparently I didn't. When I say it's a weird kind of mock, I mean that you're basically stubbing data without going through the entire business logic. For example, if you have a User model such as class User < ActiveRecord::Base validates_uniqueness_of :login end and a fixture file such as user1: id: 1 login: pat user2: id: 2 login: pat Then the fixtures will still load! Of course that's because there are no unique constraints in the db...but what bothers me is that Rails just loads the fixtures like they're existing records, instead of something like User.create attributes_from_fixture_file So, what I meant was, user stories are intended to exercise the entire application stack. Fixtures don't do this, because even though they preload data, they skip an important part of business logic. In that sense, they return data without executing business logic, which is why I consider them a strange kind of stubbed object. > The problem is their large overhead in scaling to a > project of any size (especially the typical one with lots of > associations). Plus, fighting with YAML just sucks. Am I putting in > invalid data, or are those tabs instead of spaces? The truth is that > they are *PAINFUL* to use, and that's why no one uses them (and why > "testing" sucks, and is done after a project instead of before). > > Personally, I'd love to use mocks in my model specs, but I just > can't bring myself to do it. It, too, is painful, because I > essentially need to understand the details of how activerecord > works. Why spend an hour figuring out that > User.find_or_create_by_username 'scott' should be stubbed out as > User.find("username" => "scott") and not User.find(:username => > "scott")? Have you read Jay Field's blog recently? Stubbing > ActiveRecord::Connection::Column ? Give me a break. That's going to > break the second you upgrade rails. You're right. I'd say this is mostly a consequence of the Active Record pattern. Basically your AR objects have two primary responsibilities - business logic and persistence - and any time your objects have more than one responsibility it becomes difficult to unit test. One example that I see crop up time and again is automatically creating associations using callbacks. Eventually you get to a point where you save an object in a spec, and it blows up because there's a null association. We're saving an object that would normally be created by the parent, because we need to exercise some behavior that occurs when the record is saved. That wouldn't be an issue if we had separate objects handling the persistence and domain logic. When you spec your PROs (plain ruby objects. I thought POROs sucked and I'm really digging PROs) you might initially use mocks and then swap in real implementations. You could do this because (a) your specs will still be super quick because it's all in memory and (b) you won't have stuff blow up because you're trying to save stuff to the db when you didn't really want to. As far as I can tell, there are a couple solutions to this problem: 1. Change the production code to handle errors that only crop up in testing. This sucks for what should be obvious reasons. But it's actually pretty pragmatic when your logic and assocations still aren't very complex. Just be sure to write a comment that says "this sucks but what're ya gonna do" 2. Refactor your code to partially separate domain logic from persistence logic. For example, if you have to create associated objects like we discussed above, move all of that into its own method. If I had code like this: class Company < ActiveRecord::Base has_many :sites after_create :create_sites def create_sites %w(Production Development Testing).each { |n| sites << Site.new(:name => n) } end end I would change it to class Company < ActiveRecord::Base has_many :sites def self.create_company(options = {}) c = create options %w(Production Development Testing).each { |n| c.sites << Site.new(:name => n) } c end end This way you can call Company.create in your model specs and not have it build all the associations. For such a simple example it doesn't really matter much, but once you start getting more complex your specs will get slow and brittle. 3. Refactor your code to completely separate the domain logic from persistence logic. I've never had to do this in the 2.5 years I've been coding Rails on a daily basis. Until very, very recently, that is. I definitely believe in designing code to be testable, but the first two options have made it so that I can stick with AR with a little bit of smelliness. Now that we're using the same business logic on top of two different persistence mechanisms, it's time to make decouple the business logic and make the persistence logic configurable. Story runner gives us one more option now. You can write a story that uses the real objects, and then you can mock out associations in your model specs. You get the benefits of knowing that your objects integrate well and also enjoy speedy, decoupled unit tests. Personally, despite how bright I've made it sound, I'm not a fan of this option. I want my unit tests to exercise the interactions between objects, so I just deal with it. The exception of course is when I'm using objects from a lower layer, such as controllers interacting with the model, in which case I always use mocks. Code from one layer should depend only on the interface of objects in the lower layer. When you're dealing with objects in the same layer, it's useful to use real implementations because it aids refactoring a great deal. > Mocks are great for external libraries (or objects which you > control), but with rails everything is so tightly woven together that > mocking/stubbing seems to be more pain then it's worth. The only > positive thing the stub approach has going for it is the speed factor. So, you're right that mocking can be difficult when it comes to AR associations. As I pointed out, it's a consequence of coupling business and persistence logic. There are some things that you can do to offset that a bit. AR makes it more difficult to write clean specs, but the tradeoff is that the conceptual weight of AR is extremely low. > I'd be very interested in hearing how you are using mocks > successfully without the overhead of learning tons of plumbing. If you could be a bit more specific about what you're interested in, I could perhaps shed some light. I heavily rely on mocks in a way that I would consider successful. Wow that became a lot longer than I expected. I hope there's some value in it instead of it being a steaming pile. Pat From ladislav.martincik at gmail.com Fri Sep 28 05:01:53 2007 From: ladislav.martincik at gmail.com (Ladislav Martincik) Date: Fri, 28 Sep 2007 10:01:53 +0100 Subject: [rspec-users] Testing emails with RSpec 1.0.8. Message-ID: <98ac62f50709280201s1acb0a42t49bc44cf05494741@mail.gmail.com> Anyone is doing email testing with RSpec? Can you post some examples? Thank you, Laco M. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070928/e6e6d5d2/attachment.html From smingins at elctech.com Fri Sep 28 05:04:05 2007 From: smingins at elctech.com (Shane Mingins) Date: Fri, 28 Sep 2007 21:04:05 +1200 Subject: [rspec-users] Testing emails with RSpec 1.0.8. In-Reply-To: <98ac62f50709280201s1acb0a42t49bc44cf05494741@mail.gmail.com> References: <98ac62f50709280201s1acb0a42t49bc44cf05494741@mail.gmail.com> Message-ID: <624075AD-62F1-4727-BE09-C6D72B829500@elctech.com> On 28/09/2007, at 9:01 PM, Ladislav Martincik wrote: > Anyone is doing email testing with RSpec? > Can you post some examples? > Like this? before(:each) do @user1 = mock_model(UserAccount, :email => 'fred at mail.com') @user2 = mock_model(UserAccount, :email => 'bill at mail.com') @user3 = mock_model(UserAccount, :email => 'jane at mail.com') UserAccount.should_receive(:find).with(:all).and_return([@user1, @user2, @user3]) @controller.stub!(:authorize).and_return(true) @emails = ActionMailer::Base.deliveries @emails.clear end it "should send three separate emails" do post :email, :email =>{:body => 'my message', :from => 'admin at fiveacross.com', :subject => 'testing email'} @emails.size.should == 3 email_to_fred = @emails[0] email_to_fred.to.should == ['fred at mail.com'] email_to_fred.subject.should == 'testing email' email_to_fred.body.should match(/my message/) email_to_bill = @emails[1] email_to_bill.to.should == ['bill at mail.com'] email_to_bill.subject.should == 'testing email' email_to_bill.body.should match(/my message/) email_to_jane = @emails[2] email_to_jane.to.should == ['jane at mail.com'] email_to_jane.subject.should == 'testing email' email_to_jane.body.should match(/my message/) end HTH Shane From win at wincent.com Fri Sep 28 08:41:56 2007 From: win at wincent.com (Wincent Colaiuta) Date: Fri, 28 Sep 2007 14:41:56 +0200 Subject: [rspec-users] There is a easy way to valid markup? In-Reply-To: <810a540e0709271323o28aea865o37d7972dd7daa01d@mail.gmail.com> References: <810a540e0709271323o28aea865o37d7972dd7daa01d@mail.gmail.com> Message-ID: <3BDAD2DA-ED18-4B27-987B-F6EDB1352A5C@wincent.com> El 27/9/2007, a las 22:23, Pat Maddox escribi?: > I'm sure you could hook into some kind of validator. I jumped on > RubyForge and found http://rubyforge.org/projects/feedvalidator/. It > kind of sucks because you'd depend on a web service for this...there > have to be validators that you can run locally though, right? Tidy (also known as HTML Tidy) can do many kinds of validation. You may even find it preinstalled on your system: Cheers, Wincent From rspec.user at gmail.com Fri Sep 28 11:37:46 2007 From: rspec.user at gmail.com (sinclair bain) Date: Fri, 28 Sep 2007 11:37:46 -0400 Subject: [rspec-users] form action url example Message-ID: <2ca660dd0709280837i6ee652cel33661d039ed2cd8b@mail.gmail.com> Hi, I have the following example: it 'should have a form with an action attribute' do response.should have_tag( "form[action=?]", '/users/1/machines/1/trouble_tickets') end for a form like so: <% form_for( :trouble_ticket, :url => { :action => 'create', :user_id => @machine.current_owner, :machine_id => @machine } ) do |f| %> ... Now this fails. The way it will pass is to change the url parameters to _explicitly_ call the id method on the parameter values like so: <% form_for( :trouble_ticket, :url => { :action => 'create', *:user_id => @machine.current_owner.id,* *:machine_id => @machine.id* } ) do |f| %> ... (nb. I am stubbing and mock these objects ) My thought is that rails does not require this since it helps by making sure the #id of each object is used in the action url. Is this an error in rspec or just something (mildly inconsistent? ) which I'll have to do in this very limited context ? Cheers! sinclair -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070928/d5a685cf/attachment.html From jonathan at parkerhill.com Fri Sep 28 13:20:35 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Fri, 28 Sep 2007 13:20:35 -0400 Subject: [rspec-users] How do I best setup data for Story Runner? In-Reply-To: <4C392575-9582-41C0-B290-3995818753B7@railsnewbie.com> References: <48E9B5AD-5C90-4E75-B50A-EA3626A4BF32@mintsource.org> <810a540e0709271241t7b56847di9726f255dfdd582d@mail.gmail.com> <05A19FC9-1867-4814-AC9B-FA58C33A0A02@gmail.com> <4C392575-9582-41C0-B290-3995818753B7@railsnewbie.com> Message-ID: <8C3123F4-FDA7-4404-AF6A-DED173276684@parkerhill.com> Scott, Thanks for the plug-in, http://thmadb.com/public_svn/plugins/ fixture_replacement I've started using it, replacing my ad hoc factory methods And I like the idea of putting the factory in db/ btw, for the record, while the Dan Manges blog was posted Aug 07, the first time I saw this technique is as a protected create_user method in the acts_as_authenticated plugin test/user_test.rb (although not to replace fixtures but to test against them :) Regards linoj On Sep 28, 2007, at 3:48 AM, Scott Taylor wrote: > > On Sep 27, 2007, at 6:11 PM, Carl Porth wrote: > >> On Sep 27, 2007, at 12:41 PM, Pat Maddox wrote: >> >>> On 9/26/07, Simon Peter Nicholls wrote: >>>> Just started looking at the Story Runner integration, and am >>>> converting a few Rails integration tests to get a feel for it. >>>> >>>> My integration tests relied on fixtures, and since my models have a >>>> significant amount of validation (and hence need valid data >>>> unless I >>>> save without validation), this has made setup easy. >>>> >>>> With stories however, I'm wondering what the recommended approach >>>> is. >>>> Mocks are out I assume, since the point is testing the stack, but >>>> are >>>> fixtures out too? Should we be meeting our more complex or >>>> repetitive >>>> setup needs by treating it as plain ruby code that needs >>>> refactoring >>>> via regular Ruby/OO techniques (Object Mother et al)? >>>> >>>> A typical scenario for me might involve a couple of users with >>>> different roles, plus a collection of other collaborating objects. >>>> >>>> Thanks >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>>> >>> >>> I don't use fixtures (the yaml type, anyway) in story runner >>> stories. >>> I construct objects in the given blocks. I find that that does two >>> things for me. First, it clearly expresses what a given really >>> means. >>> So when I say Given "an activated user," I don't have to go dig >>> around some YAML files. If I need to understand it I can just >>> look at >>> the code and see >>> u = User.create! :login => "pat" >>> u.activate >>> >>> Secondly, constructing your object graph instead of using fixtures >>> means you're actually exercising your code. With fixtures you just >>> instantiate some objects and fill them with data, which may not >>> necessarily be valid (they require maintenance). Also if you're >>> using >>> stuff like before/after create hooks to create child objects, using >>> fixtures bypasses that. >>> >>> I look at fixtures as a weird kind of mock. You're not using the >>> full >>> implementation, so what's the point really? I'd rather use a real >>> object or a proper mock object. In stories I don't use mocks at >>> all, >>> so obviously I'll go for the full implementation. >>> >>> Pat >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> +1 >> >> I've adopted a factory pattern for organizing my tests inspired by: >> http://www.dcmanges.com/blog/38 >> > > Yeah, that post was great, and inspired me to create a plugin, which > has been essential to my workflow. Here is a screencast (and a > shameless plug) for it: > > http://railsnewbie.com/files/fixture_replacement_demo.mov > > I was/am quite tired (it's about 3 AM), so just forward through my > stupidity. > > Regarding Pat's post: fixtures aren't a weird kind of mock, they are > real data. The problem is their large overhead in scaling to a > project of any size (especially the typical one with lots of > associations). Plus, fighting with YAML just sucks. Am I putting in > invalid data, or are those tabs instead of spaces? The truth is that > they are *PAINFUL* to use, and that's why no one uses them (and why > "testing" sucks, and is done after a project instead of before). > > Personally, I'd love to use mocks in my model specs, but I just > can't bring myself to do it. It, too, is painful, because I > essentially need to understand the details of how activerecord > works. Why spend an hour figuring out that > User.find_or_create_by_username 'scott' should be stubbed out as > User.find("username" => "scott") and not User.find(:username => > "scott")? Have you read Jay Field's blog recently? Stubbing > ActiveRecord::Connection::Column ? Give me a break. That's going to > break the second you upgrade rails. > > Mocks are great for external libraries (or objects which you > control), but with rails everything is so tightly woven together that > mocking/stubbing seems to be more pain then it's worth. The only > positive thing the stub approach has going for it is the speed factor. > > I'd be very interested in hearing how you are using mocks > successfully without the overhead of learning tons of plumbing. > > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From barjunk at attglobal.net Fri Sep 28 15:34:51 2007 From: barjunk at attglobal.net (barsalou) Date: Fri, 28 Sep 2007 11:34:51 -0800 Subject: [rspec-users] 1.0.8 tarball problem. Message-ID: <20070928113451.jortxn9p6ooskkg8@lcgalaska.com> Scott said: This was a known problem. I believe it should be fixed in the next release (fixed on trunk). Scott, Would that mean I have to use svn? I don't have that option at the moment. Thanks for letting me know, though. Mike B. ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. From zach.dennis at gmail.com Fri Sep 28 16:05:18 2007 From: zach.dennis at gmail.com (Zach Dennis) Date: Fri, 28 Sep 2007 16:05:18 -0400 Subject: [rspec-users] How do I best setup data for Story Runner? In-Reply-To: <05A19FC9-1867-4814-AC9B-FA58C33A0A02@gmail.com> References: <48E9B5AD-5C90-4E75-B50A-EA3626A4BF32@mintsource.org> <810a540e0709271241t7b56847di9726f255dfdd582d@mail.gmail.com> <05A19FC9-1867-4814-AC9B-FA58C33A0A02@gmail.com> Message-ID: <85d99afe0709281305lf9f02a0t4fa9226f415d83d1@mail.gmail.com> On 9/27/07, Carl Porth wrote: > > +1 > > I've adopted a factory pattern for organizing my tests inspired by: > http://www.dcmanges.com/blog/38 > +1 We have also started doing this. It is freakishly amazing and maintainable thus far over the course of our app changing, From mailing_lists at railsnewbie.com Fri Sep 28 17:11:04 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 28 Sep 2007 17:11:04 -0400 Subject: [rspec-users] How do I best setup data for Story Runner? In-Reply-To: <8C3123F4-FDA7-4404-AF6A-DED173276684@parkerhill.com> References: <48E9B5AD-5C90-4E75-B50A-EA3626A4BF32@mintsource.org> <810a540e0709271241t7b56847di9726f255dfdd582d@mail.gmail.com> <05A19FC9-1867-4814-AC9B-FA58C33A0A02@gmail.com> <4C392575-9582-41C0-B290-3995818753B7@railsnewbie.com> <8C3123F4-FDA7-4404-AF6A-DED173276684@parkerhill.com> Message-ID: On Sep 28, 2007, at 1:20 PM, Jonathan Linowes wrote: > Scott, > Thanks for the plug-in, http://thmadb.com/public_svn/plugins/ > fixture_replacement > I've started using it, replacing my ad hoc factory methods > And I like the idea of putting the factory in db/ Thanks for trying it out. I'd love to hear any feedback, or anything that you think should be changed. > > btw, for the record, while the Dan Manges blog was posted Aug 07, the > first time I saw this technique is as a protected create_user method > in the acts_as_authenticated plugin test/user_test.rb (although not > to replace fixtures but to test against them :) Yeah, I'm sure I've seen that too - so maybe I stole one of the ideas from there, as well. (Actually, I think I got it from topfunky (the TDD peepcode), who in turn got it from technoweenie - Completely forgot about til' now. It's funny how good ideas can become unconscious like that...) The only really cool thing about the plugin is that it uses lambdas so that extra associations aren't created. Plus, it dries up the .create! and merge() that needs to be repeated over and over again (trust me - this will get tiring if you have something like 30 models). Regarding the lambdas: With the Dan Manges factory, if I do the following, I end up with two posts (not one): def create_comment(hash = {}) Comment.create!( { :post => create_post }.merge(hash) ) end # this yield one associated post (as expected) comment = create_comment # this yields an associated post, with an extra one which I don't care about (and which isn't associated) post = create_post comment = create_comment(:post => post) And this is because Ruby isn't lazily evaluated. So if you end up using the Dan Manges method, beware! Scott > From dchelimsky at gmail.com Fri Sep 28 22:29:03 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 28 Sep 2007 21:29:03 -0500 Subject: [rspec-users] form action url example In-Reply-To: <2ca660dd0709280837i6ee652cel33661d039ed2cd8b@mail.gmail.com> References: <2ca660dd0709280837i6ee652cel33661d039ed2cd8b@mail.gmail.com> Message-ID: <57c63afe0709281929n242b9252j62e14f8092a60750@mail.gmail.com> On 9/28/07, sinclair bain wrote: > Hi, > > I have the following example: > > > it 'should have a form with an action attribute' do > response.should have_tag( "form[action=?]", > '/users/1/machines/1/trouble_tickets') > end > for a form like so: > > > <% form_for( :trouble_ticket, > :url => { :action => 'create', > :user_id => @machine.current_owner, > :machine_id => @machine } ) do |f| %> When you do this (:machine_id => @machine), rails calls @machine.to_param. So as long as you're stubbing the to_param method, it should work. Also, if you use mock_model, this is stubbed for you. Cheers, David > ... > > Now this fails. > > The way it will pass is to change the url parameters to _explicitly_ call > the id method on the > parameter values like so: > > > <% form_for( :trouble_ticket, > :url => { :action => 'create', > :user_id => @ machine.current_owner.id, > :machine_id => @machine.id } ) do |f| %> > ... > > (nb. I am stubbing and mock these objects ) > > My thought is that rails does not require this since it helps by making sure > the #id of each object is used in the action url. > > > Is this an error in rspec or just something (mildly inconsistent? ) which > I'll have to do in this very limited context ? > > Cheers! > sinclair > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jonathan at parkerhill.com Sat Sep 29 00:42:22 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Sat, 29 Sep 2007 00:42:22 -0400 Subject: [rspec-users] How do I best setup data for Story Runner? In-Reply-To: References: <48E9B5AD-5C90-4E75-B50A-EA3626A4BF32@mintsource.org> <810a540e0709271241t7b56847di9726f255dfdd582d@mail.gmail.com> <05A19FC9-1867-4814-AC9B-FA58C33A0A02@gmail.com> <4C392575-9582-41C0-B290-3995818753B7@railsnewbie.com> <8C3123F4-FDA7-4404-AF6A-DED173276684@parkerhill.com> Message-ID: <118E6300-D614-476D-A99A-C0E57B43EDA4@parkerhill.com> yes, i appreciate all the smartness built into it. I wonder if this idea could be extended to generate mocks, eg for my controller specs user = mock_user( :email => "foo at example.com" ) etc not sure how far you could go with this, eg stubbing basic stuff like .find Just a thought On Sep 28, 2007, at 5:11 PM, Scott Taylor wrote: > > On Sep 28, 2007, at 1:20 PM, Jonathan Linowes wrote: > >> Scott, >> Thanks for the plug-in, http://thmadb.com/public_svn/plugins/ >> fixture_replacement >> I've started using it, replacing my ad hoc factory methods >> And I like the idea of putting the factory in db/ > > Thanks for trying it out. I'd love to hear any feedback, or anything > that you think should be changed. > >> >> btw, for the record, while the Dan Manges blog was posted Aug 07, the >> first time I saw this technique is as a protected create_user method >> in the acts_as_authenticated plugin test/user_test.rb (although not >> to replace fixtures but to test against them :) > > Yeah, I'm sure I've seen that too - so maybe I stole one of the ideas > from there, as well. (Actually, I think I got it from topfunky (the > TDD peepcode), who in turn got it from technoweenie - Completely > forgot about til' now. It's funny how good ideas can become > unconscious like that...) > > The only really cool thing about the plugin is that it uses lambdas > so that extra associations aren't created. Plus, it dries up > the .create! and merge() that needs to be repeated over and over > again (trust me - this will get tiring if you have something like 30 > models). > > Regarding the lambdas: With the Dan Manges factory, if I do the > following, I end up with two posts (not one): > > def create_comment(hash = {}) > Comment.create!( > { > :post => create_post > }.merge(hash) > ) > end > > # this yield one associated post (as expected) > comment = create_comment > > # this yields an associated post, with an extra one which I don't > care about (and which isn't associated) > post = create_post > comment = create_comment(:post => post) > > And this is because Ruby isn't lazily evaluated. So if you end up > using the Dan Manges method, beware! > > Scott > >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From omen.king at gmail.com Sat Sep 29 00:56:14 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sat, 29 Sep 2007 00:56:14 -0400 Subject: [rspec-users] mock_model named spaces not working Message-ID: I have a namespace called saltmines The following will fail the spec @player = mock_model(Saltmines::Player) 1) ActionView::TemplateError in '/saltmines/players/index.rhtml should render list of saltmines/players' You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.each On line #9 of app/views/saltmines/players/index.rhtml 6: Player 7: 8: 9: <% for player in @players %> My application works but these specs fail. How do I get them to pass? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070929/12f4cf76/attachment.html From luislavena at gmail.com Sat Sep 29 02:06:49 2007 From: luislavena at gmail.com (Luis Lavena) Date: Sat, 29 Sep 2007 03:06:49 -0300 Subject: [rspec-users] mock_model named spaces not working In-Reply-To: References: Message-ID: <71166b3b0709282306o60a04535vb5fabbc202f22b68@mail.gmail.com> On 9/29/07, Andrew WC Brown wrote: > I have a namespace called saltmines > > The following will fail the spec > > @player = mock_model(Saltmines::Player) > > 1) > ActionView::TemplateError in '/saltmines/players/index.rhtml should render > list of saltmines/players' > You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.each > On line #9 of app/views/saltmines/players/index.rhtml > > 6: Player > 7: > 8: > 9: <% for player in @players %> > > > My application works but these specs fail. How do I get them to pass? > you're mocking @player and not a collection/array of players. maybe: @players = [mock_model(Saltmines::Player), mock_model(Saltmines::Player)] Could work for you? The whole spec will be helpful, since we don't have the setup (before) or the whole context. HTH, -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From mailing_lists at railsnewbie.com Sat Sep 29 11:46:49 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 29 Sep 2007 11:46:49 -0400 Subject: [rspec-users] How do I best setup data for Story Runner? In-Reply-To: <118E6300-D614-476D-A99A-C0E57B43EDA4@parkerhill.com> References: <48E9B5AD-5C90-4E75-B50A-EA3626A4BF32@mintsource.org> <810a540e0709271241t7b56847di9726f255dfdd582d@mail.gmail.com> <05A19FC9-1867-4814-AC9B-FA58C33A0A02@gmail.com> <4C392575-9582-41C0-B290-3995818753B7@railsnewbie.com> <8C3123F4-FDA7-4404-AF6A-DED173276684@parkerhill.com> <118E6300-D614-476D-A99A-C0E57B43EDA4@parkerhill.com> Message-ID: <81694CE0-3A96-47A2-9248-A8D2F1A5EE58@railsnewbie.com> On Sep 29, 2007, at 12:42 AM, Jonathan Linowes wrote: > yes, i appreciate all the smartness built into it. > > I wonder if this idea could be extended to generate mocks, eg for my > controller specs > > user = mock_user( :email => "foo at example.com" ) > etc > > not sure how far you could go with this, eg stubbing basic stuff > like .find > Just a thought Certainly an interesting idea. My guess is that you would need to go a lot lower then stubbing find, Stubbing the connection parts of ActiveRecord. (In my ignorance, it ) Looks like a big project to me. Scott > > > On Sep 28, 2007, at 5:11 PM, Scott Taylor wrote: > >> >> On Sep 28, 2007, at 1:20 PM, Jonathan Linowes wrote: >> >>> Scott, >>> Thanks for the plug-in, http://thmadb.com/public_svn/plugins/ >>> fixture_replacement >>> I've started using it, replacing my ad hoc factory methods >>> And I like the idea of putting the factory in db/ >> >> Thanks for trying it out. I'd love to hear any feedback, or anything >> that you think should be changed. >> >>> >>> btw, for the record, while the Dan Manges blog was posted Aug 07, >>> the >>> first time I saw this technique is as a protected create_user method >>> in the acts_as_authenticated plugin test/user_test.rb (although not >>> to replace fixtures but to test against them :) >> >> Yeah, I'm sure I've seen that too - so maybe I stole one of the ideas >> from there, as well. (Actually, I think I got it from topfunky (the >> TDD peepcode), who in turn got it from technoweenie - Completely >> forgot about til' now. It's funny how good ideas can become >> unconscious like that...) >> >> The only really cool thing about the plugin is that it uses lambdas >> so that extra associations aren't created. Plus, it dries up >> the .create! and merge() that needs to be repeated over and over >> again (trust me - this will get tiring if you have something like 30 >> models). >> >> Regarding the lambdas: With the Dan Manges factory, if I do the >> following, I end up with two posts (not one): >> >> def create_comment(hash = {}) >> Comment.create!( >> { >> :post => create_post >> }.merge(hash) >> ) >> end >> >> # this yield one associated post (as expected) >> comment = create_comment >> >> # this yields an associated post, with an extra one which I don't >> care about (and which isn't associated) >> post = create_post >> comment = create_comment(:post => post) >> >> And this is because Ruby isn't lazily evaluated. So if you end up >> using the Dan Manges method, beware! >> >> Scott >> >>> >> >> _______________________________________________ >> 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 mlangenberg at gmail.com Sat Sep 29 17:43:18 2007 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Sat, 29 Sep 2007 23:43:18 +0200 Subject: [rspec-users] How to write the very first example? Message-ID: <27c0ac6d0709291443i781a4f37t74824fd4263769b0@mail.gmail.com> Many posts on this list are about using RSpec with Rails and that's the way I'm also using RSpec all the time. Unfortunately there isn't that much info about using RSpec for standalone Ruby projects. I must admit I'm really having a hard time writing the very first example(s) for a fresh standalone Ruby project. I haven't really got a clue where to start, how to call the first example and how to describe it. I want to use the outside-in approach, but that suggests the first example you write should specify the workings of the whole project, right? I alway catch myself focusing on dependancies and start from the inside instead of the outside. (if I implement this first, I can use it as a building brick for that feature, and if that feature is implemented I can work on that other feature.) So, where do I actually need to start? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070929/05d13a88/attachment-0001.html From pergesu at gmail.com Sat Sep 29 21:12:53 2007 From: pergesu at gmail.com (Pat Maddox) Date: Sat, 29 Sep 2007 18:12:53 -0700 Subject: [rspec-users] How to write the very first example? In-Reply-To: <27c0ac6d0709291443i781a4f37t74824fd4263769b0@mail.gmail.com> References: <27c0ac6d0709291443i781a4f37t74824fd4263769b0@mail.gmail.com> Message-ID: <810a540e0709291812o58c370b8i2fa1936de7c26554@mail.gmail.com> On 9/29/07, Matthijs Langenberg wrote: > Many posts on this list are about using RSpec with Rails and that's the way > I'm also using RSpec all the time. > Unfortunately there isn't that much info about using RSpec for standalone > Ruby projects. I don't think that matters much, the principles are the same. You write stories for features, and write specs to drive object implementation. In fact I would say that Rails presents some unique challenges for BDDing, and that a "pure" ruby project is easier! > I must admit I'm really having a hard time writing the very first example(s) > for a fresh standalone Ruby project. I haven't really got a clue where to > start, how to call the first example and how to describe it. Begin at the beginning :P There are a couple approaches. First thing I would do is write a story for one feature you want in the system. Having that story means that you stay focused on one particular task and building the infrastructure that will be used. I actually wrote a blog post a while back on what I call "design deep, not wide" [1] On a simpler level, stories represent real progress. When you're done with a story you should have actual value, and that is fulfilling and motivating. Also, you can start with smaller stories and build out from there. In Dan North's article about introducing rbehave [2] he works with simple objects instead of a full application stack like you might in Rails. When I first read it, I thought a standard spec might be more appropriate. Once it hit me though (which was a couple months later), I fell in love with that approach. To give you an idea, here's the starting code: Story "transfer to cash account", %(As a savings account holder I want to transfer money from my savings account So that I can get cash easily from an ATM) do Scenario "savings account is in credit" do Given "my savings account balance is", 100 Given "my cash account balance is", 10 When "I transfer", 20 Then "my savings account balance should be", 80 Then "my cash account balance should be", 30 end Scenario "savings account is overdrawn" do Given "my savings account balance is", -20 Given "my cash account balance is", 10 When "I transfer", 20 Then "my savings account balance should be", -20 Then "my cash account balance should be", 10 end end Eventually he sticks objects in there as he implements them, but at least at the very beginning there's no code to speak of. It's just a user story. The beauty of it is that all you're doing is specifying acceptance criteria - what it means to be "done." One scary part of doing lower level specs is on some level you're designing code without any real sense of direction. You might not necessarily know what objects you need. While specs are excellent for discovering the behavior of objects, as far as what operations they perform and interactions they have, they don't do much to help with the desired behavior of the system. So, basically, writing stories forces you to think about what you want to achieve, and gives you a clear way to measure progress. You know where you want to end, and you know all the steps it takes to get there, and that gives you the knowledge of where to start. > I want to use the outside-in approach, but that suggests the first example > you write should specify the workings of the whole project, right? > I alway catch myself focusing on dependancies and start from the inside > instead of the outside. (if I implement this first, I can use it as a > building brick for that feature, and if that feature is implemented I can > work on that other feature.) This is where mock objects yield their greatest benefits. A lot of people think mock objects are good only for isolating expensive resources, but they're fantastic in allowing you to design well in chunks. For example, something as simple as: customer.place_order some_item, 12 Will require that I have a customer class, a place_order method, an item class, and probably an order class somewhere. I'm adding a little feature, and all of a sudden I have to implement all these classes, at least in bits, and because I'm only handling a little bit of the behavior I don't have any idea how they're going to be used in other parts of the system. It's scary because there's more pressure to get it right the first time. mocks, otoh, allow you to defer all of that until later. When working on a feature, I can concern myself only with that feature and not worry about all the plumbing that it may need. A couple things happen there 1. I tend to end up with a clean, layered architecture. This happens because I'm only working on one layer at a time. When I'm bouncing back and forth between layers, I have to be extra mindful of what I'm dealing with, otherwise stuff that should be in one layer creeps into another and now I've got a muddled, difficult to understand design. 2. My life is easier! With mocks, I can isolate my thinking to a certain level or chunk of the code. Instead of pushing and popping all kinds of stuff on my mental stack, I limit the number of little things I need to think about at one time. I wasn't blessed with unlimited brain space, so that's a huge win for me. It also creates extra room to think about what I'm doing at a higher level and keep everything in perspective. It's interesting, because your questions really boil down to being overwhelmed with what you have to do. It's a feeling I know all too well. Fortunately RSpec provides two tools that do a fantastic job in easing the uncertainty. First you have user stories which help give you direction in the project. You know what you want to get done, have a good measure of progress as you implement it, and finally have a clear understanding of when you've completed it. On a lower level, mock objects help keep your thinking focused instead of running off in all different directions writing the all the infrastructure that it may take to write one line of code. You become less likely to code yourself into a corner, and you keep your mental stack in check. I hope that was helpful. I completely understand sitting at the keyboard wondering just what the hell I should be doing. I've found that RSpec helps me out a great deal both in terms of capturing desired business outcomes and in implementing the code to achieve them. It can take a while to really get it, but you may come to find that once you do you're hooked. Pat [1] http://evang.eli.st/blog/2006/12/18/design-deep-not-wide [2] http://dannorth.net/2007/06/introducing-rbehave From omen.king at gmail.com Sun Sep 30 03:05:37 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 30 Sep 2007 03:05:37 -0400 Subject: [rspec-users] autotest stop working, 1.0.9? Message-ID: My autotest runs but when I make changes to a spec it doesn't reload. I checked another application I was building that had 1.0.9 but it was reloading fine. How would I debug a problem such as autotest not reloading? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070930/6be7160d/attachment.html From mlangenberg at gmail.com Sun Sep 30 05:56:16 2007 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Sun, 30 Sep 2007 11:56:16 +0200 Subject: [rspec-users] How to write the very first example? In-Reply-To: <810a540e0709291812o58c370b8i2fa1936de7c26554@mail.gmail.com> References: <27c0ac6d0709291443i781a4f37t74824fd4263769b0@mail.gmail.com> <810a540e0709291812o58c370b8i2fa1936de7c26554@mail.gmail.com> Message-ID: <27c0ac6d0709300256t1eb2223eoe1a133ac5f34b567@mail.gmail.com> Thanks for clearing things up Pat!I'll give the story stuff I try, I haven't looked at it yet. Does this actually mean I need to start describing some stories, then start with writing the examples/code for the first story by using mock objects for every layer? Do I eventually need to replace all the mocks by real objects? And is it bad to do partially stubbing on objects, or does this indicate an object should provide more information about its state? For instance, take a look at this pastie http://pastie.caboo.se/102174, is this a good way to write an example for a behaviour or am I taking a wrong approach? I feel the need for some small, simple, clean example programs, to take a look through. Maybe, I just need to put my current pet project online and let people shoot at it. - Matthijs On 9/30/07, Pat Maddox wrote: > > On 9/29/07, Matthijs Langenberg wrote: > > Many posts on this list are about using RSpec with Rails and that's the > way > > I'm also using RSpec all the time. > > Unfortunately there isn't that much info about using RSpec for > standalone > > Ruby projects. > > I don't think that matters much, the principles are the same. You > write stories for features, and write specs to drive object > implementation. In fact I would say that Rails presents some unique > challenges for BDDing, and that a "pure" ruby project is easier! > > > I must admit I'm really having a hard time writing the very first > example(s) > > for a fresh standalone Ruby project. I haven't really got a clue where > to > > start, how to call the first example and how to describe it. > > Begin at the beginning :P > > There are a couple approaches. First thing I would do is write a > story for one feature you want in the system. Having that story means > that you stay focused on one particular task and building the > infrastructure that will be used. I actually wrote a blog post a > while back on what I call "design deep, not wide" [1] > > On a simpler level, stories represent real progress. When you're done > with a story you should have actual value, and that is fulfilling and > motivating. > > Also, you can start with smaller stories and build out from there. In > Dan North's article about introducing rbehave [2] he works with simple > objects instead of a full application stack like you might in Rails. > When I first read it, I thought a standard spec might be more > appropriate. Once it hit me though (which was a couple months later), > I fell in love with that approach. > > To give you an idea, here's the starting code: > > Story "transfer to cash account", > %(As a savings account holder > I want to transfer money from my savings account > So that I can get cash easily from an ATM) do > > Scenario "savings account is in credit" do > Given "my savings account balance is", 100 > Given "my cash account balance is", 10 > When "I transfer", 20 > Then "my savings account balance should be", 80 > Then "my cash account balance should be", 30 > end > > Scenario "savings account is overdrawn" do > Given "my savings account balance is", -20 > Given "my cash account balance is", 10 > When "I transfer", 20 > Then "my savings account balance should be", -20 > Then "my cash account balance should be", 10 > end > end > > Eventually he sticks objects in there as he implements them, but at > least at the very beginning there's no code to speak of. It's just a > user story. The beauty of it is that all you're doing is specifying > acceptance criteria - what it means to be "done." One scary part of > doing lower level specs is on some level you're designing code without > any real sense of direction. You might not necessarily know what > objects you need. While specs are excellent for discovering the > behavior of objects, as far as what operations they perform and > interactions they have, they don't do much to help with the desired > behavior of the system. > > So, basically, writing stories forces you to think about what you want > to achieve, and gives you a clear way to measure progress. You know > where you want to end, and you know all the steps it takes to get > there, and that gives you the knowledge of where to start. > > > I want to use the outside-in approach, but that suggests the first > example > > you write should specify the workings of the whole project, right? > > I alway catch myself focusing on dependancies and start from the inside > > instead of the outside. (if I implement this first, I can use it as a > > building brick for that feature, and if that feature is implemented I > can > > work on that other feature.) > > This is where mock objects yield their greatest benefits. A lot of > people think mock objects are good only for isolating expensive > resources, but they're fantastic in allowing you to design well in > chunks. For example, something as simple as: > > customer.place_order some_item, 12 > > Will require that I have a customer class, a place_order method, an > item class, and probably an order class somewhere. I'm adding a > little feature, and all of a sudden I have to implement all these > classes, at least in bits, and because I'm only handling a little bit > of the behavior I don't have any idea how they're going to be used in > other parts of the system. It's scary because there's more pressure > to get it right the first time. > > mocks, otoh, allow you to defer all of that until later. When working > on a feature, I can concern myself only with that feature and not > worry about all the plumbing that it may need. A couple things happen > there > > 1. I tend to end up with a clean, layered architecture. This happens > because I'm only working on one layer at a time. When I'm bouncing > back and forth between layers, I have to be extra mindful of what I'm > dealing with, otherwise stuff that should be in one layer creeps into > another and now I've got a muddled, difficult to understand design. > 2. My life is easier! With mocks, I can isolate my thinking to a > certain level or chunk of the code. Instead of pushing and popping > all kinds of stuff on my mental stack, I limit the number of little > things I need to think about at one time. I wasn't blessed with > unlimited brain space, so that's a huge win for me. It also creates > extra room to think about what I'm doing at a higher level and keep > everything in perspective. > > It's interesting, because your questions really boil down to being > overwhelmed with what you have to do. It's a feeling I know all too > well. Fortunately RSpec provides two tools that do a fantastic job in > easing the uncertainty. First you have user stories which help give > you direction in the project. You know what you want to get done, > have a good measure of progress as you implement it, and finally have > a clear understanding of when you've completed it. On a lower level, > mock objects help keep your thinking focused instead of running off in > all different directions writing the all the infrastructure that it > may take to write one line of code. You become less likely to code > yourself into a corner, and you keep your mental stack in check. > > I hope that was helpful. I completely understand sitting at the > keyboard wondering just what the hell I should be doing. I've found > that RSpec helps me out a great deal both in terms of capturing > desired business outcomes and in implementing the code to achieve > them. It can take a while to really get it, but you may come to find > that once you do you're hooked. > > Pat > > [1] http://evang.eli.st/blog/2006/12/18/design-deep-not-wide > [2] http://dannorth.net/2007/06/introducing-rbehave > _______________________________________________ > 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/20070930/69dbf0cf/attachment-0001.html From dchelimsky at gmail.com Sun Sep 30 09:09:56 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 30 Sep 2007 08:09:56 -0500 Subject: [rspec-users] autotest stop working, 1.0.9? In-Reply-To: References: Message-ID: <57c63afe0709300609wa460c50i34eda84f1c2c57a4@mail.gmail.com> On 9/30/07, Andrew WC Brown wrote: > My autotest runs but when I make changes to a spec it doesn't reload. Reload? Do you mean it doesn't re-run that spec? > I checked another application I was building that had 1.0.9 but it was > reloading fine. > > How would I debug a problem such as autotest not reloading? If you're working on a rails app, look at the mappings in vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb. If it's any other kind of ruby app, then look at lib/autotest/rspec.rb in the rspec gem. Make sure that the path to the spec file is represented in the mappings. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sun Sep 30 10:55:21 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 30 Sep 2007 09:55:21 -0500 Subject: [rspec-users] How to write the very first example? In-Reply-To: <27c0ac6d0709300256t1eb2223eoe1a133ac5f34b567@mail.gmail.com> References: <27c0ac6d0709291443i781a4f37t74824fd4263769b0@mail.gmail.com> <810a540e0709291812o58c370b8i2fa1936de7c26554@mail.gmail.com> <27c0ac6d0709300256t1eb2223eoe1a133ac5f34b567@mail.gmail.com> Message-ID: <57c63afe0709300755r4bfef9a5k6bd3a5b13060020f@mail.gmail.com> On 9/30/07, Matthijs Langenberg wrote: > Thanks for clearing things up Pat! > I'll give the story stuff I try, I haven't looked at it yet. > > Does this actually mean I need to start describing some stories, then start > with writing the examples/code for the first story by using mock objects for > every layer? Here's how I do this. I start with a set of stories and scenarios expressed only in text (no code in the Given/When/Then steps). I pick a scenario to start with and fill in the code, writing the code I wish I could write as I go. This helps me to discover the outermost objects and their APIs. Next, I pick one of the objects from the story and start driving it out with examples. The first examples will often overlap a bit with the stories and this is OK. Even expected. For anything that is needed by the object I'm working on at any given moment, if the code already exists to support it and using it is not expensive (in terms of required setup or processing cycles) I'll use it. If the code is not there yet, or it is expensive to use, I'll introduce a mock. > Do I eventually need to replace all the mocks by real objects? You don't ever *need* to replace the mocks with the real objects, but you certainly can. The reason you don't need to is that the Stories/Scenarios will fail when there is a mismatch between a mocked object and the real object. As to whether you *should* replace them, there are several schools of thought that generally resolve around responsibility and behaviour. For example, if we call foo.validate and that, in turn, calls validator.validate(self), where is the responsibility for validation? Some say it is foo's responsibility, some say it belongs to the validator. That debate is out of scope for this discussion, but there are plenty of other discussions on this list that you can mine for ideas about this. Another factor that comes into play is the level of complexity of the setup. If you have to mock 3 layers deep, then maybe it's better to use the real object. Of course, if you have to mock 3 layers deep, there might be a design problem. > And is it bad to do partially stubbing on objects, or does this indicate an > object should provide more information about its state? Well, it's always better if you can avoid revealing information about state. Tell, Don't Ask. But sometimes it is a necessary (or at least very useful) evil. And even when you're just telling (i.e. no state-exposure necessary) the same question might come up. It really depends on context. I think it's reasonable to ask that question whenever you're using partial mocking/stubbing. Sometimes the answer is going to be that the object should respond to some new message, sometimes not. > For instance, take a look at this pastie http://pastie.caboo.se/102174, is > this a good way to write an example for a behaviour or am I taking a wrong > approach? In the text above the code under development, it says "Read the repositories from a file, notify the user for updates in all repositories," but the example says "should call notify_if_updates on every repository." This is pretty interesting, because the example uses an implementation-specific description, whereas the comment describes behaviour at a higher, more abstract level. So I'd start by changing the example to read "should notify the user if there is an update in any repository", with another example (likely several others) that reads "should not notify the user if there are no updates to any repository". Of course, this starts me thinking that notifying the user is really not Base's responsibility, and that notify_if_updates should accept a notifier, listener, callback, etc. at which point the example is "should provide a callback to each repository to use if the repository has updates." So, the feeling I get from looking at this particular example/code is that it started from the code, not the example. I could be wrong - that's just how it feels to me. > I feel the need for some small, simple, clean example programs, to take a > look through. > Maybe, I just need to put my current pet project online and let people shoot > at it. That would certainly be a powerful learning experience for you if you have the stomach to absorb criticism that is only sometimes constructive. It would probably be so for all of us. One thing to keep in mind if you do this experiment is that BDD is a process, and you'll be showing and getting feedback on a result. There is something to be learned from the result, but the real money is in the process, so you'll have to do some extrapolating from the criticism and apply it back to the process - unless of course you want to turn it into a complete tutorial with step by step explanations of every decision you made along the way. I can tell you from experience that it is a LOT of work ;) Cheers, David > > > - Matthijs > > > On 9/30/07, Pat Maddox wrote: > > On 9/29/07, Matthijs Langenberg wrote: > > > Many posts on this list are about using RSpec with Rails and that's the > way > > > I'm also using RSpec all the time. > > > Unfortunately there isn't that much info about using RSpec for > standalone > > > Ruby projects. > > > > I don't think that matters much, the principles are the same. You > > write stories for features, and write specs to drive object > > implementation. In fact I would say that Rails presents some unique > > challenges for BDDing, and that a "pure" ruby project is easier! > > > > > I must admit I'm really having a hard time writing the very first > example(s) > > > for a fresh standalone Ruby project. I haven't really got a clue where > to > > > start, how to call the first example and how to describe it. > > > > Begin at the beginning :P > > > > There are a couple approaches. First thing I would do is write a > > story for one feature you want in the system. Having that story means > > that you stay focused on one particular task and building the > > infrastructure that will be used. I actually wrote a blog post a > > while back on what I call "design deep, not wide" [1] > > > > On a simpler level, stories represent real progress. When you're done > > with a story you should have actual value, and that is fulfilling and > > motivating. > > > > Also, you can start with smaller stories and build out from there. In > > Dan North's article about introducing rbehave [2] he works with simple > > objects instead of a full application stack like you might in Rails. > > When I first read it, I thought a standard spec might be more > > appropriate. Once it hit me though (which was a couple months later), > > I fell in love with that approach. > > > > To give you an idea, here's the starting code: > > > > Story "transfer to cash account", > > %(As a savings account holder > > I want to transfer money from my savings account > > So that I can get cash easily from an ATM) do > > > > Scenario "savings account is in credit" do > > Given "my savings account balance is", 100 > > Given "my cash account balance is", 10 > > When "I transfer", 20 > > Then "my savings account balance should be", 80 > > Then "my cash account balance should be", 30 > > end > > > > Scenario "savings account is overdrawn" do > > Given "my savings account balance is", -20 > > Given "my cash account balance is", 10 > > When "I transfer", 20 > > Then "my savings account balance should be", -20 > > Then "my cash account balance should be", 10 > > end > > end > > > > Eventually he sticks objects in there as he implements them, but at > > least at the very beginning there's no code to speak of. It's just a > > user story. The beauty of it is that all you're doing is specifying > > acceptance criteria - what it means to be "done." One scary part of > > doing lower level specs is on some level you're designing code without > > any real sense of direction. You might not necessarily know what > > objects you need. While specs are excellent for discovering the > > behavior of objects, as far as what operations they perform and > > interactions they have, they don't do much to help with the desired > > behavior of the system. > > > > So, basically, writing stories forces you to think about what you want > > to achieve, and gives you a clear way to measure progress. You know > > where you want to end, and you know all the steps it takes to get > > there, and that gives you the knowledge of where to start. > > > > > I want to use the outside-in approach, but that suggests the first > example > > > you write should specify the workings of the whole project, right? > > > I alway catch myself focusing on dependancies and start from the inside > > > instead of the outside. (if I implement this first, I can use it as a > > > building brick for that feature, and if that feature is implemented I > can > > > work on that other feature.) > > > > This is where mock objects yield their greatest benefits. A lot of > > people think mock objects are good only for isolating expensive > > resources, but they're fantastic in allowing you to design well in > > chunks. For example, something as simple as: > > > > customer.place_order some_item, 12 > > > > Will require that I have a customer class, a place_order method, an > > item class, and probably an order class somewhere. I'm adding a > > little feature, and all of a sudden I have to implement all these > > classes, at least in bits, and because I'm only handling a little bit > > of the behavior I don't have any idea how they're going to be used in > > other parts of the system. It's scary because there's more pressure > > to get it right the first time. > > > > mocks, otoh, allow you to defer all of that until later. When working > > on a feature, I can concern myself only with that feature and not > > worry about all the plumbing that it may need. A couple things happen > > there > > > > 1. I tend to end up with a clean, layered architecture. This happens > > because I'm only working on one layer at a time. When I'm bouncing > > back and forth between layers, I have to be extra mindful of what I'm > > dealing with, otherwise stuff that should be in one layer creeps into > > another and now I've got a muddled, difficult to understand design. > > 2. My life is easier! With mocks, I can isolate my thinking to a > > certain level or chunk of the code. Instead of pushing and popping > > all kinds of stuff on my mental stack, I limit the number of little > > things I need to think about at one time. I wasn't blessed with > > unlimited brain space, so that's a huge win for me. It also creates > > extra room to think about what I'm doing at a higher level and keep > > everything in perspective. > > > > It's interesting, because your questions really boil down to being > > overwhelmed with what you have to do. It's a feeling I know all too > > well. Fortunately RSpec provides two tools that do a fantastic job in > > easing the uncertainty. First you have user stories which help give > > you direction in the project. You know what you want to get done, > > have a good measure of progress as you implement it, and finally have > > a clear understanding of when you've completed it. On a lower level, > > mock objects help keep your thinking focused instead of running off in > > all different directions writing the all the infrastructure that it > > may take to write one line of code. You become less likely to code > > yourself into a corner, and you keep your mental stack in check. > > > > I hope that was helpful. I completely understand sitting at the > > keyboard wondering just what the hell I should be doing. I've found > > that RSpec helps me out a great deal both in terms of capturing > > desired business outcomes and in implementing the code to achieve > > them. It can take a while to really get it, but you may come to find > > that once you do you're hooked. > > > > Pat > > > > [1] http://evang.eli.st/blog/2006/12/18/design-deep-not-wide > > [2] http://dannorth.net/2007/06/introducing-rbehave > > _______________________________________________ > > 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 mailing_lists at railsnewbie.com Sun Sep 30 12:37:49 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 30 Sep 2007 12:37:49 -0400 Subject: [rspec-users] How to write the very first example? In-Reply-To: <27c0ac6d0709291443i781a4f37t74824fd4263769b0@mail.gmail.com> References: <27c0ac6d0709291443i781a4f37t74824fd4263769b0@mail.gmail.com> Message-ID: <5EAE1B28-A7C8-485D-9B9C-590A7C165B37@railsnewbie.com> On Sep 29, 2007, at 5:43 PM, Matthijs Langenberg wrote: > Many posts on this list are about using RSpec with Rails and that's > the way I'm also using RSpec all the time. > Unfortunately there isn't that much info about using RSpec for > standalone Ruby projects. > > I must admit I'm really having a hard time writing the very first > example(s) for a fresh standalone Ruby project. I haven't really > got a clue where to start, how to call the first example and how to > describe it. > I want to use the outside-in approach, but that suggests the first > example you write should specify the workings of the whole project, > right? > I alway catch myself focusing on dependancies and start from the > inside instead of the outside. (if I implement this first, I can > use it as a building brick for that feature, and if that feature is > implemented I can work on that other feature.) > > So, where do I actually need to start? I sympathize with your position. I imagine it's much easier now that the story/rbehave stuff is around. In the past what I've done is written a prototype (usually a functioning one) - and have done it code-first, with no tests whatsoever. (I'm also thinking of Paul Graham's words - all large programs start as small programs/scripts). Once I have that prototype, I rewrite the code, this time going test first, and making it Object Oriented. If I ever need to refer back to that old code, I can, but, at the same time, now I have written something slightly different, which is architectured better, and has tests to back it up. Just to give you an example of this, a few months ago I wrote a backup system. The core of it was just using rsync - very much like a simple script. But soon I wanted much more - backup deletion which would happen automatically, based on rules specified in a DSL. So I rewrote the core of the system test first, and was then able to layer the rest of the features on top and around that. Going on the 37 signals mantra: What is the most important feature of the system? That's what you should be writing specs for. They may happen to be quite high level - that's what your stories are for. Write one story (or a high level spec which you can mark as "pending"), and drill deeper into that, writing specs for the modules/ classes that it will take to make that initial story going. Hope that helps, Scott From mailing_lists at railsnewbie.com Sun Sep 30 12:39:16 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 30 Sep 2007 12:39:16 -0400 Subject: [rspec-users] autotest stop working, 1.0.9? In-Reply-To: References: Message-ID: <80F2BA2C-7B2F-470C-9136-3655403C219A@railsnewbie.com> On Sep 30, 2007, at 3:05 AM, Andrew WC Brown wrote: > My autotest runs but when I make changes to a spec it doesn't reload. > I checked another application I was building that had 1.0.9 but it > was reloading fine. > > How would I debug a problem such as autotest not reloading? One way would be to run the debugger. escher: which autotest /sw/bin/autotest escher: rdebug /sw/bin/autotest /sw/bin/autotest:9 require 'rubygems' (rdb:1) Scott From powerlauer at gmail.com Sun Sep 30 17:15:05 2007 From: powerlauer at gmail.com (Jesper Laursen) Date: Sun, 30 Sep 2007 23:15:05 +0200 Subject: [rspec-users] Problems with testing nested routes using mocking Message-ID: Hello forum I have there to files #----- virtual_host_controller.rb class VirtualHostsController < ApplicationController before_filter :capture_domain # GET /domain/1/virtual_hosts/1 def show @virtual_host = @domain.virtual_hosts.find(params[:id]) respond_to do |format| format.html # show.rhtml end end private def capture_domain if params[:domain_id].blank? flash[:notice] = 'Need domain.' redirect_to domains_url else @domain = Domain.find(params[:domain_id]) end end end #---- and #----- virtual_host_controller_spec.rb describe VirtualHostsController, "handling GET /domains/1/virtual_hosts/1" do before do @domain = mock_model(Domain) @virtual_hosts = mock("virtual_hosts") @virtual_host = mock("virtual_host") Domain.should_receive(:find).with("1").and_return(@domain) @domain.should_receive(:virtual_hosts).and_return(@virtual_hosts) @virtual_hosts.should_receive(:find).and_return(@virtual_host) login_as :admin end def do_get get :show, :id => "1", :domain_id => "1" end it "should render show template" do do_get response.should render_template('show') end it "should find the virtual_host requested" do # @domain.should_receive(:virtual_hosts).and_return(@virtual_hosts) @virtual_hosts.should_receive(:find).with('1').and_return(@virtual_host) do_get end it "should assign the found virtual_host for the view" do do_get assigns[:virtual_host].should equal(@virtual_host) end #----- I have a problem with these three it should-cases. How can I make them to work. The error is: should find the virtual_host requested Mock 'virtual_hosts' expected :find with ("1") once, but received it 0 times The routes are like this: map.resources :domains do |domains| domains.resources :virtual_hosts end What can I do? From rctucker at u.washington.edu Sun Sep 30 17:48:54 2007 From: rctucker at u.washington.edu (Ryan Tucker) Date: Sun, 30 Sep 2007 14:48:54 -0700 Subject: [rspec-users] Problems with testing nested routes using mocking In-Reply-To: References: Message-ID: <470019C6.6010501@u.washington.edu> Jesper Laursen wrote: > Hello forum > > I have there to files > > #----- virtual_host_controller.rb > class VirtualHostsController < ApplicationController > before_filter :capture_domain > > # GET /domain/1/virtual_hosts/1 > def show > @virtual_host = @domain.virtual_hosts.find(params[:id]) > > respond_to do |format| > format.html # show.rhtml > end > end > > private > > def capture_domain > if params[:domain_id].blank? > flash[:notice] = 'Need domain.' > redirect_to domains_url > else > @domain = Domain.find(params[:domain_id]) > end > end > end > #---- > > and > > > #----- virtual_host_controller_spec.rb > describe VirtualHostsController, "handling GET /domains/1/virtual_hosts/1" do > > before do > @domain = mock_model(Domain) > @virtual_hosts = mock("virtual_hosts") > @virtual_host = mock("virtual_host") > Domain.should_receive(:find).with("1").and_return(@domain) > @domain.should_receive(:virtual_hosts).and_return(@virtual_hosts) > @virtual_hosts.should_receive(:find).and_return(@virtual_host) > login_as :admin > end > > def do_get > get :show, :id => "1", :domain_id => "1" > end > > it "should render show template" do > do_get > response.should render_template('show') > end > > it "should find the virtual_host requested" do > # @domain.should_receive(:virtual_hosts).and_return(@virtual_hosts) > @virtual_hosts.should_receive(:find).with('1').and_return(@virtual_host) > do_get > end > > it "should assign the found virtual_host for the view" do > do_get > assigns[:virtual_host].should equal(@virtual_host) > end > #----- > > I have a problem with these three it should-cases. How can I make them to work. > > The error is: > should find the virtual_host requested > Mock 'virtual_hosts' expected :find with ("1") once, but received it 0 times > > The routes are like this: > map.resources :domains do |domains| > domains.resources :virtual_hosts > end > > What can I do? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Correct me if I am wrong, but in the "before do" @virtual_hosts.should_receive(:find).and_return(@virtual_host) should be VirtualHosts.should_receive(:find).and_return(@virtual_host) Since you are calling find on the class?