From matt at mattwynne.net Thu Oct 1 03:56:18 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 1 Oct 2009 08:56:18 +0100 Subject: [rspec-users] Grabbing the controller name before a new test case In-Reply-To: <43dab9cd-e17c-42ba-ba43-7fb55ffe9940@e12g2000yqi.googlegroups.com> References: <43dab9cd-e17c-42ba-ba43-7fb55ffe9940@e12g2000yqi.googlegroups.com> Message-ID: On 1 Oct 2009, at 00:56, Hates_ wrote: > I currently have: > > describe Publishers::PagesController > > I want to be able to grab the path "publishers/pages/ and use that to > generate a load of tests automatically. Problem is I can't figure out > how to do it outside of my "it" block. > > Any help is greatly appreciated. Can't remember exactly, but it's something like self.described_type cheers, Matt http://mattwynne.net +447974 430184 From richard.e.hart at googlemail.com Thu Oct 1 05:30:12 2009 From: richard.e.hart at googlemail.com (Hates_) Date: Thu, 1 Oct 2009 02:30:12 -0700 (PDT) Subject: [rspec-users] Grabbing the controller name before a new test case In-Reply-To: References: <43dab9cd-e17c-42ba-ba43-7fb55ffe9940@e12g2000yqi.googlegroups.com> Message-ID: <485352bf-d7ec-46c7-b97a-5f2000fc6bb5@v25g2000yqk.googlegroups.com> On Oct 1, 8:56?am, Matt Wynne wrote: > > Can't remember exactly, but it's something like self.described_type > Cheers, that was it exactly! From zach.dennis at gmail.com Thu Oct 1 13:45:31 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 1 Oct 2009 13:45:31 -0400 Subject: [rspec-users] Grabbing the controller name before a new test case In-Reply-To: <43dab9cd-e17c-42ba-ba43-7fb55ffe9940@e12g2000yqi.googlegroups.com> References: <43dab9cd-e17c-42ba-ba43-7fb55ffe9940@e12g2000yqi.googlegroups.com> Message-ID: <85d99afe0910011045p3dfc3a5bnf0e4817bfe52de06@mail.gmail.com> Your name has intrigued me. Do you really hate underscores? :) Zach On Wed, Sep 30, 2009 at 7:56 PM, Hates_ wrote: > I currently have: > > describe Publishers::PagesController > > I want to be able to grab the path "publishers/pages/ and use that to > generate a load of tests automatically. Problem is I can't figure out > how to do it outside of my "it" block. > > Any help is greatly appreciated. > > Richard > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) http://ideafoundry.info/behavior-driven-development (first rate BDD training) @zachdennis (twitter) From sfeley at gmail.com Thu Oct 1 14:27:36 2009 From: sfeley at gmail.com (Stephen Eley) Date: Thu, 1 Oct 2009 14:27:36 -0400 Subject: [rspec-users] Grabbing the controller name before a new test case In-Reply-To: <85d99afe0910011045p3dfc3a5bnf0e4817bfe52de06@mail.gmail.com> References: <43dab9cd-e17c-42ba-ba43-7fb55ffe9940@e12g2000yqi.googlegroups.com> <85d99afe0910011045p3dfc3a5bnf0e4817bfe52de06@mail.gmail.com> Message-ID: <1fb4df0910011127h37da80efy49bc49f8f060a2fd@mail.gmail.com> On Thu, Oct 1, 2009 at 1:45 PM, Zach Dennis wrote: > Your name has intrigued me. Do you really hate underscores? :) Some people are ReallyPassionateAboutCamelCase. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From richard.e.hart at googlemail.com Thu Oct 1 15:33:17 2009 From: richard.e.hart at googlemail.com (Hates_) Date: Thu, 1 Oct 2009 12:33:17 -0700 (PDT) Subject: [rspec-users] Grabbing the controller name before a new test case In-Reply-To: <1fb4df0910011127h37da80efy49bc49f8f060a2fd@mail.gmail.com> References: <43dab9cd-e17c-42ba-ba43-7fb55ffe9940@e12g2000yqi.googlegroups.com> <85d99afe0910011045p3dfc3a5bnf0e4817bfe52de06@mail.gmail.com> <1fb4df0910011127h37da80efy49bc49f8f060a2fd@mail.gmail.com> Message-ID: <6c443036-7a6d-4c3a-9102-2dbccf771fa1@e8g2000yqo.googlegroups.com> On Oct 1, 7:27?pm, Stephen Eley wrote: > On Thu, Oct 1, 2009 at 1:45 PM, Zach Dennis wrote: > > Your name has intrigued me. Do you really hate underscores? :) > > Some people are ReallyPassionateAboutCamelCase. Underscores make me livid! :D From dchelimsky at gmail.com Thu Oct 1 15:34:49 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 1 Oct 2009 14:34:49 -0500 Subject: [rspec-users] Grabbing the controller name before a new test case In-Reply-To: <6c443036-7a6d-4c3a-9102-2dbccf771fa1@e8g2000yqo.googlegroups.com> References: <43dab9cd-e17c-42ba-ba43-7fb55ffe9940@e12g2000yqi.googlegroups.com> <85d99afe0910011045p3dfc3a5bnf0e4817bfe52de06@mail.gmail.com> <1fb4df0910011127h37da80efy49bc49f8f060a2fd@mail.gmail.com> <6c443036-7a6d-4c3a-9102-2dbccf771fa1@e8g2000yqo.googlegroups.com> Message-ID: <57c63afe0910011234p682dc38embfe6ca1efaaa2e88@mail.gmail.com> On Thu, Oct 1, 2009 at 2:33 PM, Hates_ wrote: > > > On Oct 1, 7:27?pm, Stephen Eley wrote: >> On Thu, Oct 1, 2009 at 1:45 PM, Zach Dennis wrote: >> > Your name has intrigued me. Do you really hate underscores? :) >> >> Some people are ReallyPassionateAboutCamelCase. > > Underscores make me livid! :D How.do.you.feel.about.dots? From wwww.mithun at yahoo.com Thu Oct 1 20:27:09 2009 From: wwww.mithun at yahoo.com (mithunperera) Date: Thu, 1 Oct 2009 17:27:09 -0700 (PDT) Subject: [rspec-users] what's wrong with my newbie cucumber test? In-Reply-To: <784d429b97db99d32fe4a538c353340d@ruby-forum.com> References: <784d429b97db99d32fe4a538c353340d@ruby-forum.com> Message-ID: <25708812.post@talk.nabble.com> hi, I did a senario like to u. but i got unswer. go and follow http://jeewanthajtk.blogspot.com cheers, mithun :super::handshake: Mithun Perera wrote: > > forums.feature > = > Feature: Tasks > In order to keep track of tasks > People should be able to > Create a list of tasks > > Scenario: List Tasks > When I go to the homepage > = > > forums_steps.rb > = > When /^I go to the homepage$/ do > visit "/forums" > end > = > > when I run rake features. > == > Scenario: List Tasks # features/forums.feature:6 > When I go to the homepage # features/forums.feature:7 > Ambiguous match of "I go to the homepage": > > features/step_definitions/webrat_steps.rb:10:in `/^I go to (.+)$/' > features/step_definitions/forums_steps.rb:1:in `/^I go to the > homepage$/' > > You can run again with --guess to make Cucumber be more smart > about it > (Cucumber::Ambiguous) > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/step_mother.rb:210:in > `step_match' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/step_invocation.rb:50:in > `find_step_match!' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/step_invocation.rb:27:in > `invoke' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/step_invocation.rb:22:in > `accept' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/visitor.rb:74:in > `visit_step' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/formatter/pretty.rb:124:in > `visit_step' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/step_collection.rb:14:in > `accept' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/step_collection.rb:13:in > `each' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/step_collection.rb:13:in > `accept' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/visitor.rb:70:in > `visit_steps' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/scenario.rb:29:in > `accept' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/step_mother.rb:236:in > `before_and_after' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/scenario.rb:28:in > `accept' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/visitor.rb:45:in > `visit_feature_element' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/formatter/pretty.rb:79:in > `visit_feature_element' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/feature.rb:23:in > `accept' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/feature.rb:22:in > `each' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/feature.rb:22:in > `accept' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/visitor.rb:23:in > `visit_feature' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/formatter/pretty.rb:41:in > `visit_feature' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/features.rb:21:in > `accept' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/features.rb:20:in > `each' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/features.rb:20:in > `accept' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/visitor.rb:19:in > `visit_features' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/formatter/pretty.rb:26:in > `visit_features' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/broadcaster.rb:9:in > `__send__' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/broadcaster.rb:9:in > `method_missing' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/broadcaster.rb:8:in > `map' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/broadcaster.rb:8:in > `method_missing' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/cli/main.rb:41:in > `execute!' > > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/cli/main.rb:20:in > `execute' > /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/cucumber:6 > features/forums.feature:7:in `When I go to the homepage' > > 1 scenario (1 failed) > 1 step (1 failed) > rake aborted! > Command failed with status (1): [/usr/bin/ruby -I > "/home/ning/.gem/ruby/1.8...] > > > > > == > does anyone can tell me what's wrong with my test? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > 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/what%27s-wrong-with-my-newbie-cucumber-test--tp23580449p25708812.html Sent from the rspec-users mailing list archive at Nabble.com. From sfeley at gmail.com Fri Oct 2 09:48:04 2009 From: sfeley at gmail.com (Stephen Eley) Date: Fri, 2 Oct 2009 09:48:04 -0400 Subject: [rspec-users] what's wrong with my newbie cucumber test? In-Reply-To: <1ebf5a4d0910020624n2d51e188i17272d26d64222b8@mail.gmail.com> References: <784d429b97db99d32fe4a538c353340d@ruby-forum.com> <25708812.post@talk.nabble.com> <1ebf5a4d0910020624n2d51e188i17272d26d64222b8@mail.gmail.com> Message-ID: <1fb4df0910020648s398c71d6xd38762303e0a9b3e@mail.gmail.com> On Fri, Oct 2, 2009 at 9:24 AM, Tim Walker wrote: > Try commenting out your step completely or temporarily removing > forums_step.rb. Run and see what step it's matching. I'd imagine it's > matching a webrat step. Also: there's a separate list for Cucumber stuff these days. Check out: http://groups.google.com/group/cukes -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From lists at ruby-forum.com Fri Oct 2 12:16:27 2009 From: lists at ruby-forum.com (Sam Treweek) Date: Fri, 2 Oct 2009 18:16:27 +0200 Subject: [rspec-users] Running a specific row in cucumber example table Message-ID: <55fffb5e4aa63f57668c006fb09ea138@ruby-forum.com> I want to be able to execute only 1 row in an Scenario/Outline Example table. Is there a method already created for me to access. I have certain validation rules for only running 1 row of data coming from an external request to execute cuke. So having something in a step_definition file like: test.rb If $something table.row.skip end Before do pending end etc... -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Fri Oct 2 12:21:19 2009 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 2 Oct 2009 17:21:19 +0100 Subject: [rspec-users] Running a specific row in cucumber example table In-Reply-To: <55fffb5e4aa63f57668c006fb09ea138@ruby-forum.com> References: <55fffb5e4aa63f57668c006fb09ea138@ruby-forum.com> Message-ID: <178772FE-6F26-4B53-81E9-54459C50C428@mattwynne.net> On 2 Oct 2009, at 17:16, Sam Treweek wrote: > I want to be able to execute only 1 row in an Scenario/Outline Example > table. Is there a method already created for me to access. I have > certain validation rules for only running 1 row of data coming from an > external request to execute cuke. > > So having something in a step_definition file like: > > test.rb > > If $something > table.row.skip > end > > Before do > pending > end I have no idea if this will work, but you could try to sense for the table row you want to skip in a Before block, then call skip_invoke! on it: Before(scenario_or_example_row) do if the_one_to_skip?(scenario_or_example_row) scenario_or_example_row.skip_invoke! end end That might work for you, but you should be aware that #skip_invoke! is not part of the public API right now and might be changed without warning. Obviously you'll have to write #the_one_to_skip? method yourself... It would probably be better to be able to tag the example table row, and just filter it out before the feature run. We can't do that right now can we? > > etc... > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users cheers, Matt http://mattwynne.net +447974 430184 From dchelimsky at gmail.com Fri Oct 2 12:27:32 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 2 Oct 2009 11:27:32 -0500 Subject: [rspec-users] Running a specific row in cucumber example table In-Reply-To: <55fffb5e4aa63f57668c006fb09ea138@ruby-forum.com> References: <55fffb5e4aa63f57668c006fb09ea138@ruby-forum.com> Message-ID: <57c63afe0910020927r23f02e56o4138ee7ec27c0216@mail.gmail.com> On Fri, Oct 2, 2009 at 11:16 AM, Sam Treweek wrote: > I want to be able to execute only 1 row in an Scenario/Outline Example > table. Is there a method already created for me to access. I have > certain validation rules for only running 1 row of data coming from an > external request to execute cuke. > > So having something in a step_definition file like: > > test.rb > > If $something > ? table.row.skip > end > > Before do > ?pending > end > > etc... > -- Please direct cucumber questions to http://groups.google.com/group/cukes From ashley.moran at patchspace.co.uk Sat Oct 3 08:35:05 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Sat, 3 Oct 2009 13:35:05 +0100 Subject: [rspec-users] feedback on 1.2.9.rc1 In-Reply-To: <57c63afe0909282036s52bc74eci538981285fe7707@mail.gmail.com> References: <57c63afe0909280022l1f20a681p5d36d13b2b762c05@mail.gmail.com> <7C7A5606-A6F6-43DB-941D-7554D9E954C0@patchspace.co.uk> <57c63afe0909282036s52bc74eci538981285fe7707@mail.gmail.com> Message-ID: On 29 Sep 2009, at 04:36, David Chelimsky wrote: > I ran into some problems using rubygems to uninstall prerelease gems > but I don't remember when that got fixed. If you're feeling bold, I'd > say go for it, and then if you run into trouble you can always > manually remove them from your system gems directories. It might even > work just fine :) Hi David Currently lost so much time with upgrading MacPorts stuff after Snow Leopard, plus finding it broke something mysterious deep in the bowels of my Cucumber/Merb stuff that I'm a little hesitant to update until I can get RubyGems 1.3.5! But if the MacPort is released before RSpec 1.2.9 I'll let you know what I find. I've been quiet here for ages, feel like I should do something useful to make up for my absense :) Ashley -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran http://aviewfromafar.net/ From rick.denatale at gmail.com Sat Oct 3 20:09:27 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sat, 3 Oct 2009 20:09:27 -0400 Subject: [rspec-users] Is there a good (non-judgemental) comparison of Rspec mocking vs Mocha? Message-ID: I've just picked up a project which has been using test/spec and mocha. We're in the process of switching over to rspec for the testing framework, and will probably just continue to use mocha for the mocks, although I'm certainly more fluent in Rspec. I was thinking that there must be a comparison/conversion chart somewhere, like the Test:Unit => RSpec translation guide in the RSpec docs, but my usually awesome google skills seem to be failing me on this. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From dhf0820 at gmail.com Sat Oct 3 20:41:49 2009 From: dhf0820 at gmail.com (Don French) Date: Sat, 3 Oct 2009 17:41:49 -0700 (PDT) Subject: [rspec-users] factory girl rspec and authlogic Message-ID: <23f16b50-f7f2-4ede-a202-368d5de30ff6@g22g2000prf.googlegroups.com> I am trying some simple test using the above items. Using the Factory.create(...) gives Active Record errors and not the failure of the test. Change it to u = Factory.build(...) then u.save, I do not get the Active record error but the proper test failure message. it 'requires email' do lambda do u = Factory.create(:valid_user, {:email => nil}) #u.save u.errors.on(:email).should_not be_nil end.should_not change(User, :count) end returns: ActiveRecord::RecordInvalid in 'User requires email' Validation failed: Email is too short (minimum is 6 characters), Email should look like an email address. ./spec/models/user_spec.rb:34: ./spec/models/user_spec.rb:33: However: it 'requires email' do lambda do u = Factory.build(:valid_user, {:email => nil}) u.save u.errors.on(:email).should be_nil end.should change(User, :count) fails properly with 'User requires email' FAILED expected nil, got ["is too short (minimum is 6 characters)", "should look like an email address."] ./spec/models/user_spec.rb:36: ./spec/models/user_spec.rb:33: It does not matter whether the first test above is above is set up as a failing or passing test I get the same results, ActiveRecord errors instead of Rspec messages. I am not sure if this is a FactoryGirl issue or Rspec issue, or me screwing up. Thanks From sfeley at gmail.com Sat Oct 3 23:51:48 2009 From: sfeley at gmail.com (Stephen Eley) Date: Sat, 3 Oct 2009 23:51:48 -0400 Subject: [rspec-users] Is there a good (non-judgemental) comparison of Rspec mocking vs Mocha? In-Reply-To: References: Message-ID: <1fb4df0910032051q55e8ab22r62383a774e9eb669@mail.gmail.com> On Sat, Oct 3, 2009 at 8:09 PM, Rick DeNatale wrote: > > I was thinking that there must be a comparison/conversion chart > somewhere, like the Test:Unit => RSpec translation guide in the RSpec > docs, but my usually awesome google skills seem to be failing me on > this. Major differences off the top of my head: * RSpec's mocking framework has 'mock_model' and 'stub_model' for Rails testing. There's some controversy about them, but many people find them convenient. * Mocha offers the 'any_instance' class method, which makes it easy to inject mock or stub behavior into objects that aren't created yet. There's some controversy about it, but many people find it convenient. >8-> But personal or "judgmental" preferences aside, I don't think one is head-and-shoulders above the other. Many of the differences are purely on the surface, and no one will call you wrong for using either one. I use Mocha mostly out of an aesthetic preference for its syntax. I don't think it makes me a better human being. (And I try not to mock when I can help it these days anyway.)* As for your current project -- if it's already fairly deeply invested in Mocha, my advice would be to keep it there. I once did convert a project from one to the other for inconsequential reasons. It wasn't _hard_ to do; it was mostly just "start with a passing test suite, and find-and-replace and fix specific lines until it passes again." But I realized at the end that I hadn't really _gained_ anything. It wasn't even a useful refactoring. I could've spent that time adding something to my application instead. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From sfeley at gmail.com Sun Oct 4 00:31:18 2009 From: sfeley at gmail.com (Stephen Eley) Date: Sun, 4 Oct 2009 00:31:18 -0400 Subject: [rspec-users] factory girl rspec and authlogic In-Reply-To: <23f16b50-f7f2-4ede-a202-368d5de30ff6@g22g2000prf.googlegroups.com> References: <23f16b50-f7f2-4ede-a202-368d5de30ff6@g22g2000prf.googlegroups.com> Message-ID: <1fb4df0910032131q76830095xa55518bb0819bdd3@mail.gmail.com> On Sat, Oct 3, 2009 at 8:41 PM, Don French wrote: > I am trying some simple test using the above items. Using the > Factory.create(...) gives Active Record errors and not the failure of > the test. Change it to u = Factory.build(...) then u.save, I do not > get the Active record error but the proper test failure message. I don't think you have a problem with Factory Girl *or* with RSpec. Both are working as intended. Factory Girl's 'create' method is calling 'save!' instead of 'save' -- the difference being that 'save!' throws an exception instead of returning false when validations fail. That's exactly what you're seeing. And it's reasonable, because if you ask it to create a record, it assumes that you *want a record*, and that an inability to make one is unexpected. The 'build' method is intended exactly for things like validation testing. There are a few better ways you can test for this than what you're doing. One is to try 'create' and test for the exception it throws: it 'requires email' do lambda { Factory.create(:valid_user, :email => nil) }.should raise_error(ActiveRecord::RecordInvalid) end ...This would work, but it's clunky. I don't like lambdas if I can avoid them. I would probably do it like this instead: it 'requires email' do u = Factory.build(:valid_user) u.email = nil u.should_not be_valid end Assuming another test where a :valid_user proved to actually *be* valid, this is entire and sufficient. If you consider it important to know what the error messages are well (I generally don't), you could also do: it 'requires email' do u = Factory.build(:valid_user) u.email = nil u.save.should be_false u.should have(2).errors.on("email") u.errors.on("email").should include("is too short (minimum is 6 characters)") u.errors.on("email").should include("should look like an email address.") end In practice, even if I did care about all of that, I'd split them out into separate examples, because I subscribe to the philosophy that a good example should have at most one expectation. Four "shoulds" is three too many. But that's a subtle distinction, and I wanted to be brief here. The one thing I _wouldn't_ do is what you're doing in both code blocks, which is to wrap an expectation inside a lambda and then put _another_ expectation outside it. Checking that the record count did not change is really unnecessary. The save failed. That's sufficient. (By the way, if I screwed up any of the syntax with Factory Girl here, my apologies. I don't use it; I use Machinist. That's another one of those personal preference things, though.) -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From lists at ruby-forum.com Sun Oct 4 06:55:46 2009 From: lists at ruby-forum.com (Paco Guzman) Date: Sun, 4 Oct 2009 12:55:46 +0200 Subject: [rspec-users] Can't run specs after upgrading gems... get 0 tests, 0 assertions... In-Reply-To: <57c63afe0909292049p2aea80c5kfd0818bcff872ef8@mail.gmail.com> References: <128f4f21-00e0-4627-ab9a-71049b10cb80@l13g2000yqb.googlegroups.com> <57c63afe0909292049p2aea80c5kfd0818bcff872ef8@mail.gmail.com> Message-ID: <9ca4aee5d025ac497ed7c172ed7eda4f@ruby-forum.com> David Chelimsky wrote: > On Tue, Sep 29, 2009 at 9:37 PM, ignu wrote: >> ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in >> active_support/dependencies.rb:158:in `require' >> `gem_original_require' >> ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in >> `require' >> ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/ >> active_support/dependencies.rb:158:in `require' >> ? ? ? ?from /Users/ignu/code/surveighor/spec/spec_helper.rb:6 > > What versions of rails, rspec and rspec-rails were you using > successfully before you did this upgrade? Did you run "script/generate > rspec"? Were you seeing test/unit output before the upgrade? I have the same problem I'm using Rails 2.3.4 in vendor/rails Rspec 1.2.8 Rspec-Rails 1.2.7.1 I load the rspec libraries in the test.rb file config.gem "rspec", :version => '1.2.8', :lib => 'spec' config.gem "rspec-rails", :version => '1.2.7.1', :lib => false If I execute: "rake spec" in the console I got: anything If I execute: "RAILS_ENV=test rake spec" in the console I got: Loaded suite /usr/local/bin/rake Started Finished in 0.000149 seconds. 0 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications I added some puts commands in my user_spec.rb file and I've noticed that the rspec "it" blocks aren't executed. Any idea what happens? Thanks -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Sun Oct 4 09:54:47 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 4 Oct 2009 08:54:47 -0500 Subject: [rspec-users] Can't run specs after upgrading gems... get 0 tests, 0 assertions... In-Reply-To: <9ca4aee5d025ac497ed7c172ed7eda4f@ruby-forum.com> References: <128f4f21-00e0-4627-ab9a-71049b10cb80@l13g2000yqb.googlegroups.com> <57c63afe0909292049p2aea80c5kfd0818bcff872ef8@mail.gmail.com> <9ca4aee5d025ac497ed7c172ed7eda4f@ruby-forum.com> Message-ID: <57c63afe0910040654s79984c6fy572fc5b31395ea8d@mail.gmail.com> On Sun, Oct 4, 2009 at 5:55 AM, Paco Guzman wrote: > David Chelimsky wrote: >> On Tue, Sep 29, 2009 at 9:37 PM, ignu wrote: >>> ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in >>> active_support/dependencies.rb:158:in `require' >>> `gem_original_require' >>> ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in >>> `require' >>> ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/ >>> active_support/dependencies.rb:158:in `require' >>> ? ? ? ?from /Users/ignu/code/surveighor/spec/spec_helper.rb:6 >> >> What versions of rails, rspec and rspec-rails were you using >> successfully before you did this upgrade? Did you run "script/generate >> rspec"? Were you seeing test/unit output before the upgrade? > > I have the same problem > > I'm using > ?Rails 2.3.4 in vendor/rails > ?Rspec 1.2.8 > ?Rspec-Rails 1.2.7.1 > > I load the rspec libraries in the test.rb file > ?config.gem "rspec", :version => '1.2.8', :lib => 'spec' Change this to :lib => false. Let us know if that fixes it. > ?config.gem "rspec-rails", :version => '1.2.7.1', :lib => false > > If I execute: "rake spec" in the console I got: > ?anything > If I execute: "RAILS_ENV=test rake spec" in the console I got: > ?Loaded suite /usr/local/bin/rake > ?Started > > > ?Finished in 0.000149 seconds. > > ?0 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, > 0 ?notifications > > I added some puts commands in my user_spec.rb file and I've noticed that > the rspec "it" blocks aren't executed. > > Any idea what happens? > > Thanks > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ignu.smith at gmail.com Sun Oct 4 11:42:26 2009 From: ignu.smith at gmail.com (Len Smith) Date: Sun, 4 Oct 2009 11:42:26 -0400 Subject: [rspec-users] Can't run specs after upgrading gems... get 0 tests, 0 assertions... In-Reply-To: <9ca4aee5d025ac497ed7c172ed7eda4f@ruby-forum.com> References: <128f4f21-00e0-4627-ab9a-71049b10cb80@l13g2000yqb.googlegroups.com> <57c63afe0909292049p2aea80c5kfd0818bcff872ef8@mail.gmail.com> <9ca4aee5d025ac497ed7c172ed7eda4f@ruby-forum.com> Message-ID: Yeah, I figured out it was from upgrading test/unit. Remove the 2.X test/unit gem and you should be fine. On Sun, Oct 4, 2009 at 6:55 AM, Paco Guzman wrote: > David Chelimsky wrote: > > On Tue, Sep 29, 2009 at 9:37 PM, ignu wrote: > >> ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > >> active_support/dependencies.rb:158:in `require' > >> `gem_original_require' > >> ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > >> `require' > >> ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/ > >> active_support/dependencies.rb:158:in `require' > >> ? ? ? ?from /Users/ignu/code/surveighor/spec/spec_helper.rb:6 > > > > What versions of rails, rspec and rspec-rails were you using > > successfully before you did this upgrade? Did you run "script/generate > > rspec"? Were you seeing test/unit output before the upgrade? > > I have the same problem > > I'm using > Rails 2.3.4 in vendor/rails > Rspec 1.2.8 > Rspec-Rails 1.2.7.1 > > I load the rspec libraries in the test.rb file > config.gem "rspec", :version => '1.2.8', :lib => 'spec' > config.gem "rspec-rails", :version => '1.2.7.1', :lib => false > > If I execute: "rake spec" in the console I got: > anything > If I execute: "RAILS_ENV=test rake spec" in the console I got: > Loaded suite /usr/local/bin/rake > Started > > > Finished in 0.000149 seconds. > > 0 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, > 0 notifications > > I added some puts commands in my user_spec.rb file and I've noticed that > the rspec "it" blocks aren't executed. > > Any idea what happens? > > Thanks > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Sun Oct 4 16:15:05 2009 From: lists at ruby-forum.com (Paco Guzman) Date: Sun, 4 Oct 2009 22:15:05 +0200 Subject: [rspec-users] Can't run specs after upgrading gems... get 0 tests, 0 assertions... In-Reply-To: <57c63afe0910040654s79984c6fy572fc5b31395ea8d@mail.gmail.com> References: <128f4f21-00e0-4627-ab9a-71049b10cb80@l13g2000yqb.googlegroups.com> <57c63afe0909292049p2aea80c5kfd0818bcff872ef8@mail.gmail.com> <9ca4aee5d025ac497ed7c172ed7eda4f@ruby-forum.com> <57c63afe0910040654s79984c6fy572fc5b31395ea8d@mail.gmail.com> Message-ID: <1a0e0bbe98277e5014f0fd8b4ac91134@ruby-forum.com> David Chelimsky wrote: > On Sun, Oct 4, 2009 at 5:55 AM, Paco Guzman > wrote: >>> >> >> I load the rspec libraries in the test.rb file >> ?config.gem "rspec", :version => '1.2.8', :lib => 'spec' > > Change this to :lib => false. Let us know if that fixes it. If I change to :lib => false I got the same text in the execution. But If I uninstall test-unit 2.0.3 like Len said the examples executes right. Why the execution of rake spec:model task write "Could not find Test::Unit 2.0, ignoring" now? Thanks David and Len -- Posted via http://www.ruby-forum.com/. From sfeley at gmail.com Sun Oct 4 19:35:44 2009 From: sfeley at gmail.com (Stephen Eley) Date: Sun, 4 Oct 2009 19:35:44 -0400 Subject: [rspec-users] Can't run specs after upgrading gems... get 0 tests, 0 assertions... In-Reply-To: <1a0e0bbe98277e5014f0fd8b4ac91134@ruby-forum.com> References: <128f4f21-00e0-4627-ab9a-71049b10cb80@l13g2000yqb.googlegroups.com> <57c63afe0909292049p2aea80c5kfd0818bcff872ef8@mail.gmail.com> <9ca4aee5d025ac497ed7c172ed7eda4f@ruby-forum.com> <57c63afe0910040654s79984c6fy572fc5b31395ea8d@mail.gmail.com> <1a0e0bbe98277e5014f0fd8b4ac91134@ruby-forum.com> Message-ID: <1fb4df0910041635ma09b27dqcb7d520c09cab0b3@mail.gmail.com> On Sun, Oct 4, 2009 at 4:15 PM, Paco Guzman wrote: > > If I change to :lib => false I got the same text in the execution. But > If I uninstall test-unit 2.0.3 like Len said the examples executes > right. There's a pernicious known bug in RSpec that causes it to fail with newer versions of the test-unit gem. This has a stronger impact on those of us using Ruby 1.9, which doesn't include Test::Unit at all, and is somewhat documented here: http://wiki.github.com/dchelimsky/rspec/ruby-191 I made a brief attempt at one point to figure out what broke with newer Test::Unit versions, but got a bit lost just setting up the RSpec-Dev project to pass all specs. Really troubleshooting RSpec internals is probably beyond me. So I'll be a smartass instead: David, given the broad impact and confusing output of the test-unit dependency problem, would it be a practical short-term solution to simply bundle version 1.2.3 of the Test::Unit gem into RSpec? And then require the bundled Test::Unit directly on its path instead of the gem and Ruby loadpaths? Sure, for stock Ruby 1.8 users this would be redundant, but they wouldn't really lose anything. And everyone on 1.9 or running the Test::Unit gem for other purposes gains reliability and a much easier path to getting RSpec running the first time. It's not an ideal solution but it'd be quick to set up. Is there a reason why this wouldn't work or shouldn't be done? -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From lists at ruby-forum.com Mon Oct 5 04:49:50 2009 From: lists at ruby-forum.com (Zoltan Penzeli) Date: Mon, 5 Oct 2009 10:49:50 +0200 Subject: [rspec-users] Running a specific row in cucumber example table In-Reply-To: <178772FE-6F26-4B53-81E9-54459C50C428@mattwynne.net> References: <55fffb5e4aa63f57668c006fb09ea138@ruby-forum.com> <178772FE-6F26-4B53-81E9-54459C50C428@mattwynne.net> Message-ID: <35de0298a9ca06ca34b86d832a7971ca@ruby-forum.com> > I have no idea if this will work, but you could try to sense for the > table row you want to skip in a Before block, then call skip_invoke! > on it: > > Before(scenario_or_example_row) do > if the_one_to_skip?(scenario_or_example_row) > scenario_or_example_row.skip_invoke! > end > end > Well, this isn't really working (or I might forgot something to define, but from http://wiki.github.com/aslakhellesoy/cucumber/hooks - it seems that 'Before' is operating with tags (and hooks) - see This is in fact be useful, because we are able execute code before each line of the properly tagged Scenario Outline... but... I still don't know the method/variable to access the _current line_ of the example table. So translated into the code, an example: x.feature: ... @tagged Scenario Outline: file reader Given I read Then I want to have Examples: | file | content | | x.txt | Text | | y.txt | Other text | *************************** step_definitions/x.rb Before('@tagged') do # how to access current row??? if row[0] == $external_filename # how to properly skip current line??? row.skip_invoke! end end Given /I read (.+)/ do |fileName| #open and read fileName #fill @file_content end Then /I want to have (.+)/ do |content| #assert 'content' against @file_content end ********************************** So we need something for 'row[0]' and a proper way to skip the current line... I now that this example is not a good real life situation (it would be easier to use multiline step arguments), but we would like to use Cucumber driven by an external source (executing only one line from each example table) AND maintaining the ability to run it independently (all lines) I hope this cleared up the things a bit more... Thanks for your ideas! -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Mon Oct 5 06:32:32 2009 From: lists at ruby-forum.com (Mithun Perera) Date: Mon, 5 Oct 2009 12:32:32 +0200 Subject: [rspec-users] Factory_girl Need help Message-ID: Hi please any body can help me to learn the basics of Factory girl method. If someone know about these please tell me. I want to learn this from the beginning. thanks, Mithun -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Mon Oct 5 07:03:46 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 5 Oct 2009 12:03:46 +0100 Subject: [rspec-users] Running a specific row in cucumber example table In-Reply-To: <35de0298a9ca06ca34b86d832a7971ca@ruby-forum.com> References: <55fffb5e4aa63f57668c006fb09ea138@ruby-forum.com> <178772FE-6F26-4B53-81E9-54459C50C428@mattwynne.net> <35de0298a9ca06ca34b86d832a7971ca@ruby-forum.com> Message-ID: On 5 Oct 2009, at 09:49, Zoltan Penzeli wrote: > >> I have no idea if this will work, but you could try to sense for the >> table row you want to skip in a Before block, then call skip_invoke! >> on it: >> >> Before(scenario_or_example_row) do >> if the_one_to_skip?(scenario_or_example_row) >> scenario_or_example_row.skip_invoke! >> end >> end Sorry, my example is bollocks. Try this instead: Before do |scenario_or_example_row| if the_one_to_skip?(scenario_or_example_row) scenario_or_example_row.skip_invoke! end end So the thing yielded to the Before block is the Scenario object if you're in a Scenario, or the OutlineTable::ExampleRow if you're in an outline table. You can call skip_invoke! on either of those objects to tell them not to invoke their step definition. >> > > Well, this isn't really working (or I might forgot something to > define, > but from http://wiki.github.com/aslakhellesoy/cucumber/hooks - it > seems > that 'Before' is operating with tags (and hooks) - see > > This is in fact be useful, because we are able execute code before > each > line of the properly tagged Scenario Outline... but... I still don't > know the method/variable to access the _current line_ of the example > table. > > So translated into the code, an example: > > x.feature: > ... > @tagged > Scenario Outline: file reader > Given I read > Then I want to have > > Examples: > | file | content | > | x.txt | Text | > | y.txt | Other text | > > *************************** > step_definitions/x.rb > > Before('@tagged') do > # how to access current row??? > if row[0] == $external_filename > # how to properly skip current line??? > row.skip_invoke! > end > end > > Given /I read (.+)/ do |fileName| > #open and read fileName > #fill @file_content > end > > Then /I want to have (.+)/ do |content| > #assert 'content' against @file_content > end > > ********************************** > > So we need something for 'row[0]' and a proper way to skip the current > line... > > I now that this example is not a good real life situation (it would be > easier to use multiline step arguments), but we would like to use > Cucumber driven by an external source (executing only one line from > each > example table) AND maintaining the ability to run it independently > (all > lines) > > I hope this cleared up the things a bit more... > > Thanks for your ideas! > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users cheers, Matt http://mattwynne.net +447974 430184 From dchelimsky at gmail.com Mon Oct 5 07:28:48 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 5 Oct 2009 06:28:48 -0500 Subject: [rspec-users] Factory_girl Need help In-Reply-To: References: Message-ID: <57c63afe0910050428u200c874aq65e08b532456b3fb@mail.gmail.com> On Mon, Oct 5, 2009 at 5:32 AM, Mithun Perera wrote: > Hi > please any body can help me to learn the basics of Factory girl method. > If someone know about these please tell me. > > I want to learn this from the beginning. Try starting with the readme at http://github.com/thoughtbot/factory_girl/. Feel free to ask If there's anything specific you don't understand. Cheers, David > thanks, > Mithun From dchelimsky at gmail.com Tue Oct 6 00:08:26 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 5 Oct 2009 23:08:26 -0500 Subject: [rspec-users] [ANN] rspec 1.2.9 Released Message-ID: <57c63afe0910052108n4c803bcfq78893a33d5b4765c@mail.gmail.com> rspec version 1.2.9 has been released! * * * * * Behaviour Driven Development for Ruby. Changes: ### Version 1.2.9 / 2009-10-05 * enhancements * manage backtrace-ignore patterns with Spec::Runner.configure (Martin Emde). Closes #870. * friendly mock argument expectation failure message (Tim Harper). Closes #868. * added double() as alias for stub() and mock() * failure messages for doubles, mocks and stubs use the right name * add let() method to assign memoized attributes (suggestion from Stuart Halloway). Closes #857. * add its method so you can say: describe Array do its(:length) { should == 0 } (Stephen Touset). Closes #833 * spec command automatically uses spec/spec.opts if it is present (suggestion from Yehuda Katz) * rspec now adds PROJECT_ROOT/lib and PROJECT_ROOT/spec to the load path * determines PROJECT_ROOT by recursing up until it finds a directory that has a ./spec directory (thanks to Scott Taylor) * supports require 'spec_helper' * supports running specs from the PROJECT_ROOT or any directory below it * closes #733 * better handling of determining test names in test/unit/interop mode * Joe Ferris * closes #854 * bug fixes * Fixed problem with colorized output when writing to a file * Corey Ehmke * closes #777 * not really a bug fix or enhancement * temporarily moved heckle feature to features-pending (waiting to see what happens with http://rubyforge.org/tracker/index.php?func=detail&aid=26786&group_id=1513&atid=5921) From dchelimsky at gmail.com Tue Oct 6 00:08:41 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 5 Oct 2009 23:08:41 -0500 Subject: [rspec-users] [ANN] rspec-rails 1.2.9 Released Message-ID: <57c63afe0910052108s6b5609act9c6fb7cb52728f8b@mail.gmail.com> rspec-rails version 1.2.9 has been released! * * * * * Behaviour Driven Development for Ruby on Rails. Changes: ### Version 1.2.9 / 2009-10-05 * enhancements * added route_to and be_routable matchers (Randy Harmon). Closes #843. * Provide better failure message for render_template when redirected (Josh Nichols). Closes #885. * generated specs require 'spec_helper' * bug fixes * pass the correct args to super in controller#render depending on the rails version (Lucas Carlson). Closes #865. * use Rack::Utils.parse_query to convert query strings to hashes. Closes #872. * errors correctly bubble up when a controller spec in isolation mode requests a non-existent action/template * no error if either action or template exist * error if neither exist * Closes #888. * removals * spec_server has been removed in favor of spork. * You can still use the --drb flag, but you've got to install the spork gem. * Windows users who cannot use the spork gem can install the spec_server from http://github.com/dchelimsky/spec_server From lists at ruby-forum.com Tue Oct 6 02:53:14 2009 From: lists at ruby-forum.com (Mithun Perera) Date: Tue, 6 Oct 2009 08:53:14 +0200 Subject: [rspec-users] Factory_girl Need help In-Reply-To: <57c63afe0910050428u200c874aq65e08b532456b3fb@mail.gmail.com> References: <57c63afe0910050428u200c874aq65e08b532456b3fb@mail.gmail.com> Message-ID: David Chelimsky wrote: > On Mon, Oct 5, 2009 at 5:32 AM, Mithun Perera > wrote: >> Hi >> please any body can help me to learn the basics of Factory girl method. >> If someone know about these please tell me. >> >> I want to learn this from the beginning. > > Try starting with the readme at > http://github.com/thoughtbot/factory_girl/. Feel free to ask If > there's anything specific you don't understand. > > Cheers, > David Hi, Thanks David. I'll check it :) cheers mithun -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Tue Oct 6 09:56:36 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 6 Oct 2009 08:56:36 -0500 Subject: [rspec-users] [ANN] rspec-rails 1.2.9 Released In-Reply-To: References: <57c63afe0910052108s6b5609act9c6fb7cb52728f8b@mail.gmail.com> Message-ID: <57c63afe0910060656g530a2453yf7fd99a6e0a3c347@mail.gmail.com> On Tue, Oct 6, 2009 at 8:52 AM, Chris Flipse wrote: > rubyforge seems to have picked up the rspec release, but not the rspec-rails > release -- the web interface (at least) still says that the most recent > rspec-rails is 1.2.7.1 It's actually in the rspec package (with the rspec gem) on http://rspec.rubyforge.org/rspec-rails/1.2.9/. Also, I get this: ================== $ gem q -rn rspec-rails *** REMOTE GEMS *** ... rspec-rails (1.2.9, 1.2.7.1) ... ================== So it's up there, just slightly visually confusing. I'll see what I can do to clean things up. > > > On Tue, Oct 6, 2009 at 12:08 AM, David Chelimsky > wrote: >> >> rspec-rails version 1.2.9 has been released! >> >> * >> * >> * >> * >> * >> >> Behaviour Driven Development for Ruby on Rails. >> >> Changes: >> >> ### Version 1.2.9 / 2009-10-05 >> >> * enhancements >> ?* added route_to and be_routable matchers (Randy Harmon). Closes #843. >> ?* Provide better failure message for render_template when redirected >> (Josh >> ? ?Nichols). Closes #885. >> ?* generated specs require 'spec_helper' >> >> * bug fixes >> ?* pass the correct args to super in controller#render depending on the >> rails >> ? ?version (Lucas Carlson). Closes #865. >> ?* use Rack::Utils.parse_query to convert query strings to hashes. Closes >> #872. >> ?* errors correctly bubble up when a controller spec in isolation mode >> ? ?requests a non-existent action/template >> ? ?* no error if either action or template exist >> ? ?* error if neither exist >> ? ?* Closes #888. >> >> * removals >> ?* spec_server has been removed in favor of spork. >> ? ?* You can still use the --drb flag, but you've got to install the spork >> ? ? ?gem. >> ? ?* Windows users who cannot use the spork gem can install the >> spec_server >> ? ? ?from http://github.com/dchelimsky/spec_server >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > -- > // anything worth taking seriously is worth making fun of > // http://blog.devcaffeine.com/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From sfeley at gmail.com Tue Oct 6 09:57:55 2009 From: sfeley at gmail.com (Stephen Eley) Date: Tue, 6 Oct 2009 09:57:55 -0400 Subject: [rspec-users] [ANN] rspec-rails 1.2.9 Released In-Reply-To: References: <57c63afe0910052108s6b5609act9c6fb7cb52728f8b@mail.gmail.com> Message-ID: <1fb4df0910060657vb3ebd7fsf57c1df55983ed0f@mail.gmail.com> On Tue, Oct 6, 2009 at 9:52 AM, Chris Flipse wrote: > rubyforge seems to have picked up the rspec release, but not the rspec-rails > release -- the web interface (at least) still says that the most recent > rspec-rails is 1.2.7.1 The gems repository is right, though. Running "gem outdated" tells me that both rspec and rspec-rails are at 1.2.9. Except for an RDoc error of "Could not find main page README.rdoc," both installed fine. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From dchelimsky at gmail.com Tue Oct 6 10:31:58 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 6 Oct 2009 09:31:58 -0500 Subject: [rspec-users] Can't run specs after upgrading gems... get 0 tests, 0 assertions... In-Reply-To: <1fb4df0910041635ma09b27dqcb7d520c09cab0b3@mail.gmail.com> References: <128f4f21-00e0-4627-ab9a-71049b10cb80@l13g2000yqb.googlegroups.com> <57c63afe0909292049p2aea80c5kfd0818bcff872ef8@mail.gmail.com> <9ca4aee5d025ac497ed7c172ed7eda4f@ruby-forum.com> <57c63afe0910040654s79984c6fy572fc5b31395ea8d@mail.gmail.com> <1a0e0bbe98277e5014f0fd8b4ac91134@ruby-forum.com> <1fb4df0910041635ma09b27dqcb7d520c09cab0b3@mail.gmail.com> Message-ID: <57c63afe0910060731j6428fa59rc47bea73aa25d581@mail.gmail.com> On Sun, Oct 4, 2009 at 6:35 PM, Stephen Eley wrote: > On Sun, Oct 4, 2009 at 4:15 PM, Paco Guzman wrote: >> >> If I change to :lib => false I got the same text in the execution. But >> If I uninstall test-unit 2.0.3 like Len said the examples executes >> right. > > There's a pernicious known bug in RSpec that causes it to fail with > newer versions of the test-unit gem. ?This has a stronger impact on > those of us using Ruby 1.9, which doesn't include Test::Unit at all, > and is somewhat documented here: > > http://wiki.github.com/dchelimsky/rspec/ruby-191 > > I made a brief attempt at one point to figure out what broke with > newer Test::Unit versions, but got a bit lost just setting up the > RSpec-Dev project to pass all specs. ?Really troubleshooting RSpec > internals is probably beyond me. > > So I'll be a smartass instead: David, given the broad impact and > confusing output of the test-unit dependency problem, would it be a > practical short-term solution to simply bundle version 1.2.3 of the > Test::Unit gem into RSpec? ?And then require the bundled Test::Unit > directly on its path instead of the gem and Ruby loadpaths? > > Sure, for stock Ruby 1.8 users this would be redundant, but they > wouldn't really lose anything. ?And everyone on 1.9 or running the > Test::Unit gem for other purposes gains reliability and a much easier > path to getting RSpec running the first time. ?It's not an ideal > solution but it'd be quick to set up. ?Is there a reason why this > wouldn't work or shouldn't be done? I'll give this some thought, though I'd much rather just solve the problem. For the 1.2.9 release I added a message. When you run specs w/ test/unit interop (which is implicit in rspec-rails) it senses whether t/u 1.2.3 is loaded - if not it raises an error explaining your options. In terms of solving the problem, there are a few paths: 1. Figure out why ruby 1.9 + rubygems + activesupport is allowing two different versions of the same gem to be loaded. 2. Get rspec to play nice w/ test-unit-2.0.3 3. Get rspec to play nice w/ minitest. 4. Some combination of 1, 2, and 3. This probably won't get resolved (by me) until we release rspec-2, work on which has begun but it's waiting for me to get the book off to print before it gets the full love and attention it needs. If anybody out there wants to help w/ any of the above, please fork the repo, get it to work, and if it works well I'll be glad to merge it back in. Cheers, David > > > -- > Have Fun, > ? Steve Eley (sfeley at gmail.com) > ? ESCAPE POD - The Science Fiction Podcast Magazine > ? http://www.escapepod.org > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Tue Oct 6 13:08:03 2009 From: lists at ruby-forum.com (mo fire) Date: Tue, 6 Oct 2009 19:08:03 +0200 Subject: [rspec-users] timeouts with ruby 1.9.1 Message-ID: I find myself in a confused spot. Please note I am running OS X 10.5 ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-darwin9] rspec 1.2.9 rspec-rails 1.2.9 TextMate Version 1.5.8 (1509) I have a user model and a corresponding user_spec.rb.file. When I run user_spec.rb in TextMate all examples pass. All the examples also pass when I run ./script/spec spec/ and ./script/spec spec/models and ./script/spec/models/user_spec.rb. However when I run rake spec it suddenly throws errors. Weird enough, when I run rake spec:models all examples pass. Under pinning all this weird behaviour (WBDD :p) is the timeouts that crop up. Below is a stacktrace (that's as far as it goes) of the timeouts that crop up when I run rake spec. 'User validation should require a name' FAILED expected "is required." got nil (compared using eql?) /Users/liseki/work/wwror/adify/spec/models/user_spec.rb:35:in `block (2 levels) in ' /opt/local/lib/ruby1.9/1.9.1/timeout.rb:44:in `timeout' A similar thing (timeouts) happens for some controllers as seen in the trace below ActiveRecord::RecordInvalid in 'UserSessionsController attempting sign in when already signed in should set flash notice and redirect to the signed-in-user's homepage' Validation failed: /opt/local/lib/ruby1.9/gems/1.9.1/gems/activerecord-2.3.4/lib/active_record/validations.rb:1090:in `save_with_validation!' /opt/local/lib/ruby1.9/gems/1.9.1/gems/activerecord-2.3.4/lib/active_record/dirty.rb:87:in `save_with_dirty!' /opt/local/lib/ruby1.9/gems/1.9.1/gems/activerecord-2.3.4/lib/active_record/transactions.rb:200:in `block (2 levels) in save_with_transactions!' /opt/local/lib/ruby1.9/gems/1.9.1/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction' /opt/local/lib/ruby1.9/gems/1.9.1/gems/activerecord-2.3.4/lib/active_record/transactions.rb:182:in `transaction' /opt/local/lib/ruby1.9/gems/1.9.1/gems/activerecord-2.3.4/lib/active_record/transactions.rb:200:in `block in save_with_transactions!' /opt/local/lib/ruby1.9/gems/1.9.1/gems/activerecord-2.3.4/lib/active_record/transactions.rb:208:in `rollback_active_record_state!' /opt/local/lib/ruby1.9/gems/1.9.1/gems/activerecord-2.3.4/lib/active_record/transactions.rb:200:in `save_with_transactions!' /opt/local/lib/ruby1.9/gems/1.9.1/gems/notahat-machinist-1.0.3/lib/machinist/active_record.rb:54:in `make' /Users/liseki/work/wwror/adify/spec/support/authentication_helper.rb:3:in `sign_in' /Users/liseki/work/wwror/adify/spec/controllers/user_sessions_controller_spec.rb:47:in `block (2 levels) in ' /opt/local/lib/ruby1.9/1.9.1/timeout.rb:44:in `timeout' Any ideas would be appreciated. Thanks. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Oct 6 15:25:39 2009 From: lists at ruby-forum.com (mo fire) Date: Tue, 6 Oct 2009 21:25:39 +0200 Subject: [rspec-users] timeouts with ruby 1.9.1 In-Reply-To: References: Message-ID: <9d15e73333eed08700438d9bc810f015@ruby-forum.com> Sorry, actually those were not the full backtraces. Please see below: Example 1 ================ User validation should require a name' FAILED expected "is required." got nil (compared using eql?) /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/expectations/fail_with.rb:41:in `fail_with' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/expectations/handler.rb:21:in `handle_matcher' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/expectations/extensions/kernel.rb:27:in `should' /Users/liseki/work/wwror/adify/spec/models/user_spec.rb:35:in `block (2 levels) in ' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/example/example_methods.rb:40:in `instance_eval' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/example/example_methods.rb:40:in `block in execute' /opt/local/lib/ruby1.9/1.9.1/timeout.rb:44:in `timeout' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/example/example_methods.rb:37:in `execute' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/example/example_group_methods.rb:214:in `block in run_examples' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/example/example_group_methods.rb:212:in `each' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/example/example_group_methods.rb:212:in `run_examples' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/example/example_group_methods.rb:103:in `run' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/runner/example_group_runner.rb:23:in `block in run' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/runner/example_group_runner.rb:22:in `each' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/runner/example_group_runner.rb:22:in `run' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/runner/options.rb:151:in `run_examples' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/runner/command_line.rb:9:in `run' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/bin/spec:5:in `
' Example 2 =================== ActiveRecord::RecordInvalid in 'UserSessionsController attempting sign in when already signed in should set flash notice and redirect to the signed-in-user's homepage' Validation failed: /opt/local/lib/ruby1.9/gems/1.9.1/gems/activerecord-2.3.4/lib/active_record/validations.rb:1090:in `save_with_validation!' /opt/local/lib/ruby1.9/gems/1.9.1/gems/activerecord-2.3.4/lib/active_record/dirty.rb:87:in `save_with_dirty!' /opt/local/lib/ruby1.9/gems/1.9.1/gems/activerecord-2.3.4/lib/active_record/transactions.rb:200:in `block (2 levels) in save_with_transactions!' /opt/local/lib/ruby1.9/gems/1.9.1/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction' /opt/local/lib/ruby1.9/gems/1.9.1/gems/activerecord-2.3.4/lib/active_record/transactions.rb:182:in `transaction' /opt/local/lib/ruby1.9/gems/1.9.1/gems/activerecord-2.3.4/lib/active_record/transactions.rb:200:in `block in save_with_transactions!' /opt/local/lib/ruby1.9/gems/1.9.1/gems/activerecord-2.3.4/lib/active_record/transactions.rb:208:in `rollback_active_record_state!' /opt/local/lib/ruby1.9/gems/1.9.1/gems/activerecord-2.3.4/lib/active_record/transactions.rb:200:in `save_with_transactions!' /opt/local/lib/ruby1.9/gems/1.9.1/gems/notahat-machinist-1.0.3/lib/machinist/active_record.rb:54:in `make' /Users/liseki/work/wwror/adify/spec/support/authentication_helper.rb:3:in `sign_in' /Users/liseki/work/wwror/adify/spec/controllers/user_sessions_controller_spec.rb:47:in `block (2 levels) in ' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/example/example_methods.rb:70:in `instance_eval' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/example/example_methods.rb:70:in `block in eval_each_fail_fast' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/example/example_methods.rb:70:in `each' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/example/example_methods.rb:70:in `eval_each_fail_fast' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/example/example_group_hierarchy.rb:17:in `run_before_each' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/example/example_methods.rb:103:in `run_before_each' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/example/example_methods.rb:124:in `before_each_example' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/example/example_methods.rb:39:in `block in execute' /opt/local/lib/ruby1.9/1.9.1/timeout.rb:44:in `timeout' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/example/example_methods.rb:37:in `execute' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/example/example_group_methods.rb:214:in `block in run_examples' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/example/example_group_methods.rb:212:in `each' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/example/example_group_methods.rb:212:in `run_examples' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/example/example_group_methods.rb:103:in `run' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/runner/example_group_runner.rb:23:in `block in run' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/runner/example_group_runner.rb:22:in `each' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/runner/example_group_runner.rb:22:in `run' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/runner/options.rb:151:in `run_examples' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/lib/spec/runner/command_line.rb:9:in `run' /opt/local/lib/ruby1.9/gems/1.9.1/gems/rspec-1.2.9/bin/spec:5:in `
' Thanks for any ideas. -- Posted via http://www.ruby-forum.com/. From david.malin at gmail.com Wed Oct 7 11:23:09 2009 From: david.malin at gmail.com (davidm) Date: Wed, 7 Oct 2009 08:23:09 -0700 (PDT) Subject: [rspec-users] rake spec does not run specs -- just writes to spec.opts directory Message-ID: I am having an issue on my integration server currently. When I run rake spec locally my specs run and all is good but when I run rake spec in on my integration box I get the following output Options written to spec/spec.opts. You can now use these options with: spec --options spec/spec.opts When I run spec --options spec.opts I get the same message. script/spec and others all do the same , if I try to target a specific spec file again the same thing This is my setup CentOS release 5.2 (Final) ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-linux] gem version 1.3.5 gem list - http://pastie.org/645449 any thoughts would be much appreciated as this is pretty annoying. thanks. From dchelimsky at gmail.com Wed Oct 7 14:55:05 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 7 Oct 2009 13:55:05 -0500 Subject: [rspec-users] rake spec does not run specs -- just writes to spec.opts directory In-Reply-To: References: Message-ID: <57c63afe0910071155n6a7b8a5h9ee6032160c89b76@mail.gmail.com> On Wed, Oct 7, 2009 at 10:23 AM, davidm wrote: > I am having an issue on my integration server currently. When I run > rake spec locally my specs run and all is good but when I run rake > spec in on my integration box I get the following output > > Options written to spec/spec.opts. You can now use these options with: > spec --options spec/spec.opts > > When I run spec --options spec.opts I get the same message. > script/spec and others all do the same , if I try to target a specific > spec file again the same thing > > This is my setup > > CentOS release 5.2 (Final) > ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-linux] > gem version 1.3.5 > > gem list - http://pastie.org/645449 > > > any thoughts would be much appreciated as this is pretty annoying. > thanks. What's in spec/spec.opts? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Oct 7 17:06:59 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 7 Oct 2009 16:06:59 -0500 Subject: [rspec-users] Need Help In-Reply-To: <8d961d900910071357k3bf417fbyf1b036f346bd2dc@mail.gmail.com> References: <4edfa1d1a36284246d74ad1b254f8541@ruby-forum.com> <98286041539419c67480f06ee7ee4dbb@ruby-forum.com> <43266d4809196c801e9fc4ac97c1e873@ruby-forum.com> <88fd8ddc0910071324l7260a001y175a0215424ebb84@mail.gmail.com> <8d961d900910071357k3bf417fbyf1b036f346bd2dc@mail.gmail.com> Message-ID: <57c63afe0910071406r3e382d52n30abe64e152ed6db@mail.gmail.com> On Wed, Oct 7, 2009 at 3:57 PM, aslak hellesoy wrote: > > > On Wed, Oct 7, 2009 at 10:24 PM, Andrew Premdas wrote: >> >> 2009/9/25 Mithun Perera >>> >>> Mithun Perera wrote: >>> > Mithun Perera wrote: >>> >> Hi all, >>> >> I am an university student and these days i am on training period. So >>> >> i >>> >> want to know about ruby on on rails "cucumber and Rspec". If somebody >>> >> know about these fields please help me. If not please send me an >>> >> tutorials for basic functionality of the cucumber and Rspec. >>> >> Thank you. >>> >> regards, >>> >> Mithun Perera >>> > >>> > Hi all, >>> > I found one tutorial. >>> > >>> > http://www.ultrasaurus.com/sarahblog/2008/12/rails-2-day-3-behavior-driven-development/#setup >>> > >>> > if u found new one please kind enough to send me reply. >>> > >>> > Mithun Perera >>> >>> >>> >>> Hi all, >>> >>> Again i found a blog for tutorials for cucumber >>> http://jeewanthajtk.blogspot.com/ >>> here ther is a subject called Working with Ruby on Rails Cucumber From >>> the Beginning(Part I) >>> >> >> Interesting Mithun that in another post you sign of as?jeewantha >> (https://mail.google.com/mail/#label/rspec_users/1240984e52dd76c5). > > Andrew, are you saying that Mithun and Jeewantha is the same person?? How > did you come to that conclusion? I've come to the same conclusion. Consider these two threads: http://groups.google.com/group/rspec/browse_thread/thread/dfb4112d7605b2d7 http://groups.google.com/group/cukes/browse_thread/thread/7b4023c2da02c577 Similar title, similar reference to the "factory girl method", and similar command of the language. I'm guessing they're either the same person or they're classmates. As for the implications of them being one - I don't have a problem w/ two personae, but I agree that it's a bit odd to be recommending your own blog posts under a pseudonym. We're all free to ping the list and say "hi _I_ wrote a post and I'd love your feedback." Mithun, Jeewantha - care to clear up any confusion here? Cheers, David > BTW, I think you linked to your own gmail mailbox - do you have another > link? > > Aslak > >> If a person were to use these mailing lists collect information to write a >> tutorial and then use another account to recommend their tutorial ... well >> personally I'd think that would be highly unethical and an abuse of the >> goodwill of the people on the cucumber and rspec mailing lists. >> >> >> >>> >>> try this if u need help. >>> -- >>> Posted via http://www.ruby-forum.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 > From dchelimsky at gmail.com Wed Oct 7 17:22:12 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 7 Oct 2009 16:22:12 -0500 Subject: [rspec-users] Need Help In-Reply-To: <88fd8ddc0910071418y7925974ft3740acdc8c5f0441@mail.gmail.com> References: <4edfa1d1a36284246d74ad1b254f8541@ruby-forum.com> <98286041539419c67480f06ee7ee4dbb@ruby-forum.com> <43266d4809196c801e9fc4ac97c1e873@ruby-forum.com> <88fd8ddc0910071324l7260a001y175a0215424ebb84@mail.gmail.com> <8d961d900910071357k3bf417fbyf1b036f346bd2dc@mail.gmail.com> <57c63afe0910071406r3e382d52n30abe64e152ed6db@mail.gmail.com> <88fd8ddc0910071418y7925974ft3740acdc8c5f0441@mail.gmail.com> Message-ID: <57c63afe0910071422y506d7d8cm5f994d0107ef2b0a@mail.gmail.com> On Wed, Oct 7, 2009 at 4:18 PM, Andrew Premdas wrote: > 2009/10/7 David Chelimsky >> >> On Wed, Oct 7, 2009 at 3:57 PM, aslak hellesoy >> wrote: >> > >> > >> > On Wed, Oct 7, 2009 at 10:24 PM, Andrew Premdas >> > wrote: >> >> >> >> 2009/9/25 Mithun Perera >> >>> >> >>> Mithun Perera wrote: >> >>> > Mithun Perera wrote: >> >>> >> Hi all, >> >>> >> I am an university student and these days i am on training period. >> >>> >> So >> >>> >> i >> >>> >> want to know about ruby on on rails "cucumber and Rspec". If >> >>> >> somebody >> >>> >> know about these fields please help me. If not please send me an >> >>> >> tutorials for basic functionality of the cucumber and Rspec. >> >>> >> Thank you. >> >>> >> regards, >> >>> >> Mithun Perera >> >>> > >> >>> > Hi all, >> >>> > I found one tutorial. >> >>> > >> >>> > >> >>> > http://www.ultrasaurus.com/sarahblog/2008/12/rails-2-day-3-behavior-driven-development/#setup >> >>> > >> >>> > if u found new one please kind enough to send me reply. >> >>> > >> >>> > Mithun Perera >> >>> >> >>> >> >>> >> >>> Hi all, >> >>> >> >>> Again i found a blog for tutorials for cucumber >> >>> http://jeewanthajtk.blogspot.com/ >> >>> here ther is a subject called Working with Ruby on Rails Cucumber From >> >>> the Beginning(Part I) >> >>> >> >> >> >> Interesting Mithun that in another post you sign of as?jeewantha >> >> (https://mail.google.com/mail/#label/rspec_users/1240984e52dd76c5). >> > >> > Andrew, are you saying that Mithun and Jeewantha is the same person?? >> > How >> > did you come to that conclusion? >> >> I've come to the same conclusion. Consider these two threads: >> >> http://groups.google.com/group/rspec/browse_thread/thread/dfb4112d7605b2d7 >> http://groups.google.com/group/cukes/browse_thread/thread/7b4023c2da02c577 >> >> Similar title, similar reference to the "factory girl method", and >> similar command of the language. I'm guessing they're either the same >> person or they're classmates. >> >> As for the implications of them being one - I don't have a problem w/ >> two personae, but I agree that it's a bit odd to be recommending your >> own blog posts under a pseudonym. We're all free to ping the list and >> say "hi _I_ wrote a post and I'd love your feedback." >> >> Mithun, Jeewantha - care to clear up any confusion here? >> >> Cheers, >> David >> >> > BTW, I think you linked to your own gmail mailbox - do you have another >> > link? >> > >> > Aslak >> > >> >> If a person were to use these mailing lists collect information to >> >> write a >> >> tutorial and then use another account to recommend their tutorial ... >> >> well >> >> personally I'd think that would be highly unethical and an abuse of the >> >> goodwill of the people on the cucumber and rspec mailing lists. >> >> >> >> >> >> >> >>> >> >>> try this if u need help. >> >>> -- >> >>> Posted via http://www.ruby-forum.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 >> > >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > I think this thread is fairly damning > http://groups.google.com/group/rspec/browse_thread/thread/232d4c26a07423e2# > notice the signature in the 3rd post. That's pretty solid. > By the way David thanks for teaching me how to post links to threads on > google groups :-) :) > Andrew From lists at ruby-forum.com Wed Oct 7 23:09:23 2009 From: lists at ruby-forum.com (Rube Noob) Date: Thu, 8 Oct 2009 05:09:23 +0200 Subject: [rspec-users] autospec cannont find gems Message-ID: I am trying to install rspec for rails and have the following gems install C:\INSTAN~3.0-W\rails_apps\katai>gem list --local *** LOCAL GEMS *** actionmailer (2.3.4, 2.0.2) actionpack (2.3.4, 2.0.2) activerecord (2.3.4, 2.0.2) activeresource (2.3.4, 2.0.2) activesupport (2.3.4, 2.0.2) authlogic (2.1.2) autotest-rails (4.1.0) builder (2.1.2) capistrano (2.5.9, 2.1.0) cgi_multipart_eof_fix (2.5.0) cmdparse (2.0.2) columnize (0.3.1) fastercsv (1.5.0) fxri (0.3.7, 0.3.6) fxruby (1.6.19, 1.6.12) gem_plugin (0.2.3) highline (1.5.1, 1.4.0) hpricot (0.8.1, 0.6) linecache (0.43) log4r (1.1.2, 1.0.5) mocha (0.9.8) mongrel (1.1.5, 1.1.2) mysql (2.8.1, 2.7.3) needle (1.3.0) net-scp (1.0.2) net-sftp (2.0.2, 1.1.0) net-ssh (2.0.15, 1.1.2) net-ssh-gateway (1.0.1) nifty-generators (0.3.0) rack (1.0.0) rails (2.3.4, 2.0.2) rake (0.8.7, 0.8.1, 0.8.0, 0.7.3) rspec (1.2.9) rspec-rails (1.2.9) ruby-debug (0.10.3) ruby-debug-base (0.10.3) rubygems-update (1.3.5, 1.0.1) sources (0.0.1) sqlite3-ruby (1.2.5, 1.2.1) test-unit (2.0.3) win32-api (1.4.5, 1.0.4) win32-clipboard (0.5.2, 0.4.3) win32-dir (0.3.5, 0.3.2) win32-eventlog (0.5.2, 0.4.6) win32-file (0.6.3, 0.5.4) win32-file-stat (1.3.4, 1.2.7) win32-process (0.6.1, 0.5.3) win32-sapi (0.1.5, 0.1.4) win32-sound (0.4.2, 0.4.1) win32console (1.2.0) windows-api (0.3.1, 0.2.0) windows-pr (1.0.8, 0.7.2) ZenTest (4.1.4) When attempting to run autospec, I get the follwing errors about not being able to find installed gems C:\INSTAN~3.0-W\rails_apps\katai>autospec -rails loading autotest/rails_rspec C:\INSTAN~3.0-W\ruby\bin\ruby C:/INSTAN~3.0-W/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.9/bin/spec --autospec spec/models/user_spec.rb -O spec/spec.opts no such file to load -- rspec C:/INSTAN~3.0-W/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' C:/INSTAN~3.0-W/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' C:/INSTAN~3.0-W/rails_apps/katai/vendor/rails/activesupport/lib/active_support/dependencies.rb:158:in `require' C:/INSTAN~3.0-W/rails_apps/katai/config/../vendor/rails/railties/lib/rails/gem_dependency.rb:208:in `load' C:/INSTAN~3.0-W/rails_apps/katai/config/../vendor/rails/railties/lib/initializer.rb:307:in `load_gems' C:/INSTAN~3.0-W/rails_apps/katai/config/../vendor/rails/railties/lib/initializer.rb:307:in `each' C:/INSTAN~3.0-W/rails_apps/katai/config/../vendor/rails/railties/lib/initializer.rb:307:in `load_gems' C:/INSTAN~3.0-W/rails_apps/katai/config/../vendor/rails/railties/lib/initializer.rb:169:in `process' C:/INSTAN~3.0-W/rails_apps/katai/config/../vendor/rails/railties/lib/initializer.rb:113:in `send' C:/INSTAN~3.0-W/rails_apps/katai/config/../vendor/rails/railties/lib/initializer.rb:113:in `run' C:/INSTAN~3.0-W/rails_apps/katai/config/environment.rb:9 C:/INSTAN~3.0-W/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' C:/INSTAN~3.0-W/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' C:/INSTAN~3.0-W/rails_apps/katai/spec/spec_helper.rb:4 C:/INSTAN~3.0-W/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' C:/INSTAN~3.0-W/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' ./spec/models/user_spec.rb:1 C:/INSTAN~3.0-W/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.9/lib/spec/runner/example_group_runner.rb:15:in `load' C:/INSTAN~3.0-W/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.9/lib/spec/runner/example_group_runner.rb:15:in `load_files' C:/INSTAN~3.0-W/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.9/lib/spec/runner/example_group_runner.rb:14:in `each' C:/INSTAN~3.0-W/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.9/lib/spec/runner/example_group_runner.rb:14:in `load_files' C:/INSTAN~3.0-W/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.9/lib/spec/runner/options.rb:132:in `run_examples' C:/INSTAN~3.0-W/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.9/lib/spec/runner/command_line.rb:9:in `run' C:/INSTAN~3.0-W/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.9/bin/spec:5 no such file to load -- rspec-rails C:/INSTAN~3.0-W/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' C:/INSTAN~3.0-W/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' C:/INSTAN~3.0-W/rails_apps/katai/vendor/rails/activesupport/lib/active_support/dependencies.rb:158:in `require' C:/INSTAN~3.0-W/rails_apps/katai/config/../vendor/rails/railties/lib/rails/gem_dependency.rb:208:in `load' C:/INSTAN~3.0-W/rails_apps/katai/config/../vendor/rails/railties/lib/initializer.rb:307:in `load_gems' C:/INSTAN~3.0-W/rails_apps/katai/config/../vendor/rails/railties/lib/initializer.rb:307:in `each' C:/INSTAN~3.0-W/rails_apps/katai/config/../vendor/rails/railties/lib/initializer.rb:307:in `load_gems' C:/INSTAN~3.0-W/rails_apps/katai/config/../vendor/rails/railties/lib/initializer.rb:169:in `process' C:/INSTAN~3.0-W/rails_apps/katai/config/../vendor/rails/railties/lib/initializer.rb:113:in `send' C:/INSTAN~3.0-W/rails_apps/katai/config/../vendor/rails/railties/lib/initializer.rb:113:in `run' C:/INSTAN~3.0-W/rails_apps/katai/config/environment.rb:9 C:/INSTAN~3.0-W/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' C:/INSTAN~3.0-W/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' C:/INSTAN~3.0-W/rails_apps/katai/spec/spec_helper.rb:4 C:/INSTAN~3.0-W/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' C:/INSTAN~3.0-W/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' ./spec/models/user_spec.rb:1 C:/INSTAN~3.0-W/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.9/lib/spec/runner/example_group_runner.rb:15:in `load' C:/INSTAN~3.0-W/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.9/lib/spec/runner/example_group_runner.rb:15:in `load_files' C:/INSTAN~3.0-W/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.9/lib/spec/runner/example_group_runner.rb:14:in `each' C:/INSTAN~3.0-W/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.9/lib/spec/runner/example_group_runner.rb:14:in `load_files' C:/INSTAN~3.0-W/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.9/lib/spec/runner/options.rb:132:in `run_examples' C:/INSTAN~3.0-W/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.9/lib/spec/runner/command_line.rb:9:in `run' C:/INSTAN~3.0-W/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.9/bin/spec:5 Missing these required gems: rspec-rails You're running: ruby 1.8.6.111 at C:/INSTAN~3.0-W/ruby/bin/ruby.exe rubygems 1.3.5 at ./.gem/ruby/1.8, C:/INSTAN~3.0-W/ruby/lib/ruby/gems/1.8 Run `rake gems:install` to install the missing gems. ________________________________ Does anyone know why this might be happening? Thanks! -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sat Oct 10 13:22:01 2009 From: lists at ruby-forum.com (George Mauer) Date: Sat, 10 Oct 2009 19:22:01 +0200 Subject: [rspec-users] bmabey-fakefs Not Found Error when installing rspec 1.2. In-Reply-To: References: Message-ID: <5d855afc2835bfeab8d9e7ad11c1c9ee@ruby-forum.com> DanS wrote: > I'm trying to install rspec so I can work with the new book chapter. > This what the console shows after running "rake install_gem" > > Successfully built RubyGem > Name: rspec > Version: 1.2.9.rc1 > File: rspec-1.2.9.rc1.gem > mv rspec-1.2.9.rc1.gem pkg/rspec-1.2.9.rc1.gem > sudo gem install bmabey-fakefs --version '>=0.1.1' > ERROR: could not find gem bmabey-fakefs locally or in a repository Just ran into this problem and none of the posted answers helped. Here is the solution: Going to http://gems.github.com/ I noticed that it RubyGems 1.2.0 or higher is required for working with github. PS C:\code\RubyPlayground> gem -v 0.9.4 PS C:\code\RubyPlayground> gem update --system PS C:\code\RubyPlayground> gem install rspec -- Posted via http://www.ruby-forum.com/. From shot at hot.pl Sat Oct 10 16:54:04 2009 From: shot at hot.pl (Shot (Piotr Szotkowski)) Date: Sat, 10 Oct 2009 22:54:04 +0200 Subject: [rspec-users] Problems with Set after upgrade to RSpec 1.2.9 Message-ID: <20091010205404.GA12281@devielle> It seems RSpec 1.2.9 is be breaking my specs in an interesting way (both under Ruby 1.8.7 and 1.9.1). The problem may very well be in my non-standard approach to monkey-patching core/stdlib classes, but my approach does work with RSpec 1.2.8 and prior, as well as in different Ruby implementations? If you checkout my art-decomp project from http://github.com/Chastell/art-decomp and you ?rake spec? the master branch under Ruby 1.9.1 or the ruby-1.8-compat branch under Ruby 1.8.7 the result should be a short, happily green run of 114 tests ? and it is if you use RSpec 1.2.8. Unfortunately, with RSpec 1.2.9 I get the two following results (first Ruby 1.9.1 on master, then Ruby 1.8.7 on the ruby-1.8-compat branch): shot at devielle:~/PhD/art-decomp$ rake spec (in /home/shot/PhD/art-decomp) /home/shot/PhD/art-decomp/lib/set.rb:5:in `': undefined method `[]' for Set:Class (NoMethodError) from /home/shot/PhD/art-decomp/lib/set.rb:1:in `' from /home/shot/PhD/art-decomp/lib/art-decomp.rb:18:in `require' from /home/shot/PhD/art-decomp/lib/art-decomp.rb:18:in `' from /home/shot/PhD/art-decomp/spec/spec_helper.rb:4:in `require' from /home/shot/PhD/art-decomp/spec/spec_helper.rb:4:in `' from /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:149:in `require' from /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:149:in `block in invoke_requires' from /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:148:in `each' from /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:148:in `invoke_requires' from /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:104:in `block in initialize' from /home/shot/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/optparse.rb:1271:in `call' from /home/shot/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/optparse.rb:1271:in `block in parse_in_order' from /home/shot/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/optparse.rb:1258:in `catch' from /home/shot/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/optparse.rb:1258:in `parse_in_order' from /home/shot/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/optparse.rb:1252:in `order!' from /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:132:in `order!' from /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner.rb:51:in `options' from /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/command_line.rb:6:in `run' from /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/bin/spec:5:in `
' rake aborted! Command /home/shot/.rvm/ruby-1.9.1-p243/bin/ruby -I"lib" "/home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/bin/spec" "spec/set_spec.rb" "spec/string_spec.rb" "spec/enumerable_spec.rb" "spec/file_spec.rb" "spec/art-decomp/graph_spec.rb" "spec/art-decomp/logging_spec.rb" "spec/art-decomp/arch_spec.rb" "spec/art-decomp/fsm_spec.rb" "spec/art-decomp/sep_spec.rb" "spec/art-decomp/bipainter_spec.rb" "spec/art-decomp/blanket_spec.rb" "spec/art-decomp/kiss_spec.rb" "spec/art-decomp/qv_generator/graph_colouring_spec.rb" "spec/art-decomp/qv_generator/bipainting_spec.rb" "spec/art-decomp/qv_generator/graph_merging_spec.rb" "spec/art-decomp/executable_spec.rb" "spec/art-decomp/decomposer_spec.rb" "spec/art-decomp/qu_generator/edge_labels_spec.rb" "spec/art-decomp/qu_generator/block_table_spec.rb" "spec/art-decomp/uv_generator/relevance_spec.rb" "spec/art-decomp/uv_generator/braindead_spec.rb" "spec/art-decomp/decomposition_spec.rb" "spec/art-decomp/b_spec.rb" "spec/integer_spec.rb" --options spec/spec.opts failed (See full trace by running task with --trace) shot at devielle:~/PhD/art-decomp$ shot at devielle:~/PhD/art-decomp$ rake spec (in /home/shot/PhD/art-decomp) ./lib/set.rb:5: undefined method `[]' for Set:Class (NoMethodError) from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from ./lib/art-decomp.rb:39 from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from ./spec/spec_helper.rb:4 from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:149:in `invoke_requires' from /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:148:in `each' from /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:148:in `invoke_requires' from /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:104:in `initialize' from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/1.8/optparse.rb:1267:in `call' from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/1.8/optparse.rb:1267:in `parse_in_order' from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/1.8/optparse.rb:1254:in `catch' from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/1.8/optparse.rb:1254:in `parse_in_order' from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/1.8/optparse.rb:1248:in `order!' from /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:132:in `order!' from /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner.rb:51:in `options' from /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner/command_line.rb:6:in `run' from /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/bin/spec:5 rake aborted! Command /home/shot/.rvm/ruby-1.8.7-p174/bin/ruby -I"lib" "/home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/bin/spec" "spec/set_spec.rb" "spec/string_spec.rb" "spec/enumerable_spec.rb" "spec/file_spec.rb" "spec/art-decomp/graph_spec.rb" "spec/art-decomp/logging_spec.rb" "spec/art-decomp/arch_spec.rb" "spec/art-decomp/fsm_spec.rb" "spec/art-decomp/sep_spec.rb" "spec/art-decomp/bipainter_spec.rb" "spec/art-decomp/blanket_spec.rb" "spec/art-decomp/kiss_spec.rb" "spec/art-decomp/qv_generator/graph_colouring_spec.rb" "spec/art-decomp/qv_generator/bipainting_spec.rb" "spec/art-decomp/qv_generator/graph_merging_spec.rb" "spec/art-decomp/executable_spec.rb" "spec/art-decomp/decomposer_spec.rb" "spec/art-decomp/qu_generator/edge_labels_spec.rb" "spec/art-decomp/qu_generator/block_table_spec.rb" "spec/art-decomp/uv_generator/relevance_spec.rb" "spec/art-decomp/uv_generator/braindead_spec.rb" "spec/art-decomp/decomposition_spec.rb" "spec/art-decomp/b_spec.rb" "spec/integer_spec.rb" --options spec/spec.opts failed (See full trace by running task with --trace) shot at devielle:~/PhD/art-decomp$ I guess the problem is my way of monkey-patching the Set class; I first ?require 'set'? to get the stdlib?s Set, and then ?require_relative 'lib/set'? to get my patches. But this approach works in RSpec 1.2.8 and in all other applications of my code? Any insight on whether I should fix my code or is this a bug in RSpec would be most appreciated. ? Shot, who?s back to RSpec 1.2.8 for now -- Content-type: lies/all-lies Content-disposition: blatant [Nick Moffitt] -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Digital signature URL: From dchelimsky at gmail.com Sat Oct 10 21:16:39 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 10 Oct 2009 22:16:39 -0300 Subject: [rspec-users] Problems with Set after upgrade to RSpec 1.2.9 In-Reply-To: <20091010205404.GA12281@devielle> References: <20091010205404.GA12281@devielle> Message-ID: <5969DD51-69A5-4024-8FC6-FFB834687479@gmail.com> On Oct 10, 2009, at 5:54 PM, Shot (Piotr Szotkowski) wrote: > It seems RSpec 1.2.9 is be breaking my specs in an interesting way > (both under Ruby 1.8.7 and 1.9.1). The problem may very well be in > my non-standard approach to monkey-patching core/stdlib classes, > but my approach does work with RSpec 1.2.8 and prior, as well as > in different Ruby implementations? > > If you checkout my art-decomp project from > http://github.com/Chastell/art-decomp and you > ?rake spec? the master branch under Ruby 1.9.1 > or the ruby-1.8-compat branch under Ruby 1.8.7 > the result should be a short, happily green run > of 114 tests ? and it is if you use RSpec 1.2.8. > > Unfortunately, with RSpec 1.2.9 I get the two following results (first > Ruby 1.9.1 on master, then Ruby 1.8.7 on the ruby-1.8-compat branch): > > > shot at devielle:~/PhD/art-decomp$ rake spec > (in /home/shot/PhD/art-decomp) > /home/shot/PhD/art-decomp/lib/set.rb:5:in `': undefined > method `[]' for Set:Class (NoMethodError) > from /home/shot/PhD/art-decomp/lib/set.rb:1:in `' > from /home/shot/PhD/art-decomp/lib/art-decomp.rb:18:in `require' > from /home/shot/PhD/art-decomp/lib/art-decomp.rb:18:in ` (required)>' > from /home/shot/PhD/art-decomp/spec/spec_helper.rb:4:in `require' > from /home/shot/PhD/art-decomp/spec/spec_helper.rb:4:in ` (required)>' > from /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/ > option_parser.rb:149:in `require' > from /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/ > option_parser.rb:149:in `block in invoke_requires' > from /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/ > option_parser.rb:148:in `each' > from /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/ > option_parser.rb:148:in `invoke_requires' > from /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/ > option_parser.rb:104:in `block in initialize' > from /home/shot/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/optparse.rb: > 1271:in `call' > from /home/shot/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/optparse.rb: > 1271:in `block in parse_in_order' > from /home/shot/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/optparse.rb: > 1258:in `catch' > from /home/shot/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/optparse.rb: > 1258:in `parse_in_order' > from /home/shot/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/optparse.rb: > 1252:in `order!' > from /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/ > option_parser.rb:132:in `order!' > from /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner.rb: > 51:in `options' > from /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/ > command_line.rb:6:in `run' > from /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/bin/spec:5:in > `
' > rake aborted! > Command /home/shot/.rvm/ruby-1.9.1-p243/bin/ruby -I"lib" "/home/ > shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/bin/spec" "spec/set_spec.rb" > "spec/string_spec.rb" "spec/enumerable_spec.rb" "spec/file_spec.rb" > "spec/art-decomp/graph_spec.rb" "spec/art-decomp/logging_spec.rb" > "spec/art-decomp/arch_spec.rb" "spec/art-decomp/fsm_spec.rb" "spec/ > art-decomp/sep_spec.rb" "spec/art-decomp/bipainter_spec.rb" "spec/ > art-decomp/blanket_spec.rb" "spec/art-decomp/kiss_spec.rb" "spec/art- > decomp/qv_generator/graph_colouring_spec.rb" "spec/art-decomp/ > qv_generator/bipainting_spec.rb" "spec/art-decomp/qv_generator/ > graph_merging_spec.rb" "spec/art-decomp/executable_spec.rb" "spec/ > art-decomp/decomposer_spec.rb" "spec/art-decomp/qu_generator/ > edge_labels_spec.rb" "spec/art-decomp/qu_generator/ > block_table_spec.rb" "spec/art-decomp/uv_generator/ > relevance_spec.rb" "spec/art-decomp/uv_generator/braindead_spec.rb" > "spec/art-decomp/decomposition_spec.rb" "spec/art-decomp/b_spec.rb" > "spec/integer_spec.rb" --options spec/spec.opts failed > > (See full trace by running task with --trace) > shot at devielle:~/PhD/art-decomp$ > > > shot at devielle:~/PhD/art-decomp$ rake spec > (in /home/shot/PhD/art-decomp) > ./lib/set.rb:5: undefined method `[]' for Set:Class (NoMethodError) > from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/site_ruby/1.8/ > rubygems/custom_require.rb:31:in `gem_original_require' > from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/site_ruby/1.8/ > rubygems/custom_require.rb:31:in `require' > from ./lib/art-decomp.rb:39 > from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/site_ruby/1.8/ > rubygems/custom_require.rb:31:in `gem_original_require' > from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/site_ruby/1.8/ > rubygems/custom_require.rb:31:in `require' > from ./spec/spec_helper.rb:4 > from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/site_ruby/1.8/ > rubygems/custom_require.rb:31:in `gem_original_require' > from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/site_ruby/1.8/ > rubygems/custom_require.rb:31:in `require' > from /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner/ > option_parser.rb:149:in `invoke_requires' > from /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner/ > option_parser.rb:148:in `each' > from /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner/ > option_parser.rb:148:in `invoke_requires' > from /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner/ > option_parser.rb:104:in `initialize' > from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/1.8/optparse.rb: > 1267:in `call' > from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/1.8/optparse.rb: > 1267:in `parse_in_order' > from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/1.8/optparse.rb: > 1254:in `catch' > from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/1.8/optparse.rb: > 1254:in `parse_in_order' > from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/1.8/optparse.rb: > 1248:in `order!' > from /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner/ > option_parser.rb:132:in `order!' > from /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner.rb: > 51:in `options' > from /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner/ > command_line.rb:6:in `run' > from /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/bin/spec:5 > rake aborted! > Command /home/shot/.rvm/ruby-1.8.7-p174/bin/ruby -I"lib" "/home/ > shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/bin/spec" "spec/set_spec.rb" > "spec/string_spec.rb" "spec/enumerable_spec.rb" "spec/file_spec.rb" > "spec/art-decomp/graph_spec.rb" "spec/art-decomp/logging_spec.rb" > "spec/art-decomp/arch_spec.rb" "spec/art-decomp/fsm_spec.rb" "spec/ > art-decomp/sep_spec.rb" "spec/art-decomp/bipainter_spec.rb" "spec/ > art-decomp/blanket_spec.rb" "spec/art-decomp/kiss_spec.rb" "spec/art- > decomp/qv_generator/graph_colouring_spec.rb" "spec/art-decomp/ > qv_generator/bipainting_spec.rb" "spec/art-decomp/qv_generator/ > graph_merging_spec.rb" "spec/art-decomp/executable_spec.rb" "spec/ > art-decomp/decomposer_spec.rb" "spec/art-decomp/qu_generator/ > edge_labels_spec.rb" "spec/art-decomp/qu_generator/ > block_table_spec.rb" "spec/art-decomp/uv_generator/ > relevance_spec.rb" "spec/art-decomp/uv_generator/braindead_spec.rb" > "spec/art-decomp/decomposition_spec.rb" "spec/art-decomp/b_spec.rb" > "spec/integer_spec.rb" --options spec/spec.opts failed > > (See full trace by running task with --trace) > shot at devielle:~/PhD/art-decomp$ > > > I guess the problem is my way of monkey-patching the Set class; > I first ?require 'set'? to get the stdlib?s Set, and then > ?require_relative 'lib/set'? to get my patches. But this approach > works in RSpec 1.2.8 and in all other applications of my code? > > Any insight on whether I should fix my code or > is this a bug in RSpec would be most appreciated. Hey Shot - RSpec 1.2.9 adds ./lib and ./spec (from the project root) to the load path. So it sounds it's loading your custom 'set' before the one in stdlib. I've run into load order problems like this before, and found that the safest bet is to have the extension at a different path than that of the core lib. So in this case, I'd recommend putting the 'set' extensions in ./lib/extensions/set (or something similar - anything other than ./lib/set), and then require 'set' _from that file_. WDYT? David > > ? Shot, who?s back to RSpec 1.2.8 for now > -- > Content-type: lies/all-lies > Content-disposition: blatant > [Nick Moffitt] > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sat Oct 10 22:26:25 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 10 Oct 2009 23:26:25 -0300 Subject: [rspec-users] Problems with Set after upgrade to RSpec 1.2.9 In-Reply-To: <5969DD51-69A5-4024-8FC6-FFB834687479@gmail.com> References: <20091010205404.GA12281@devielle> <5969DD51-69A5-4024-8FC6-FFB834687479@gmail.com> Message-ID: <57c63afe0910101926g24f02356w1f4f95ef8fc8bf84@mail.gmail.com> On Sat, Oct 10, 2009 at 10:16 PM, David Chelimsky wrote: > On Oct 10, 2009, at 5:54 PM, Shot (Piotr Szotkowski) wrote: > >> It seems RSpec 1.2.9 is be breaking my specs in an interesting way >> (both under Ruby 1.8.7 and 1.9.1). The problem may very well be in >> my non-standard approach to monkey-patching core/stdlib classes, >> but my approach does work with RSpec 1.2.8 and prior, as well as >> in different Ruby implementations? >> >> If you checkout my art-decomp project from >> http://github.com/Chastell/art-decomp and you >> ?rake spec? the master branch under Ruby 1.9.1 >> or the ruby-1.8-compat branch under Ruby 1.8.7 >> the result should be a short, happily green run >> of 114 tests ? and it is if you use RSpec 1.2.8. >> >> Unfortunately, with RSpec 1.2.9 I get the two following results (first >> Ruby 1.9.1 on master, then Ruby 1.8.7 on the ruby-1.8-compat branch): >> >> >> shot at devielle:~/PhD/art-decomp$ rake spec >> (in /home/shot/PhD/art-decomp) >> /home/shot/PhD/art-decomp/lib/set.rb:5:in `': undefined method >> `[]' for Set:Class (NoMethodError) >> ?from /home/shot/PhD/art-decomp/lib/set.rb:1:in `' >> ?from /home/shot/PhD/art-decomp/lib/art-decomp.rb:18:in `require' >> ?from /home/shot/PhD/art-decomp/lib/art-decomp.rb:18:in `' >> ?from /home/shot/PhD/art-decomp/spec/spec_helper.rb:4:in `require' >> ?from /home/shot/PhD/art-decomp/spec/spec_helper.rb:4:in `> (required)>' >> ?from >> /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:149:in >> `require' >> ?from >> /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:149:in >> `block in invoke_requires' >> ?from >> /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:148:in >> `each' >> ?from >> /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:148:in >> `invoke_requires' >> ?from >> /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:104:in >> `block in initialize' >> ?from /home/shot/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/optparse.rb:1271:in >> `call' >> ?from /home/shot/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/optparse.rb:1271:in >> `block in parse_in_order' >> ?from /home/shot/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/optparse.rb:1258:in >> `catch' >> ?from /home/shot/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/optparse.rb:1258:in >> `parse_in_order' >> ?from /home/shot/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/optparse.rb:1252:in >> `order!' >> ?from >> /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:132:in >> `order!' >> ?from /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner.rb:51:in >> `options' >> ?from >> /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/lib/spec/runner/command_line.rb:6:in >> `run' >> ?from /home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/bin/spec:5:in `
' >> rake aborted! >> Command /home/shot/.rvm/ruby-1.9.1-p243/bin/ruby -I"lib" >> ?"/home/shot/.gem/ruby/1.9.1/gems/rspec-1.2.9/bin/spec" "spec/set_spec.rb" >> "spec/string_spec.rb" "spec/enumerable_spec.rb" "spec/file_spec.rb" >> "spec/art-decomp/graph_spec.rb" "spec/art-decomp/logging_spec.rb" >> "spec/art-decomp/arch_spec.rb" "spec/art-decomp/fsm_spec.rb" >> "spec/art-decomp/sep_spec.rb" "spec/art-decomp/bipainter_spec.rb" >> "spec/art-decomp/blanket_spec.rb" "spec/art-decomp/kiss_spec.rb" >> "spec/art-decomp/qv_generator/graph_colouring_spec.rb" >> "spec/art-decomp/qv_generator/bipainting_spec.rb" >> "spec/art-decomp/qv_generator/graph_merging_spec.rb" >> "spec/art-decomp/executable_spec.rb" "spec/art-decomp/decomposer_spec.rb" >> "spec/art-decomp/qu_generator/edge_labels_spec.rb" >> "spec/art-decomp/qu_generator/block_table_spec.rb" >> "spec/art-decomp/uv_generator/relevance_spec.rb" >> "spec/art-decomp/uv_generator/braindead_spec.rb" >> "spec/art-decomp/decomposition_spec.rb" "spec/art-decomp/b_spec.rb" >> "spec/integer_spec.rb" --options spec/spec.opts failed >> >> (See full trace by running task with --trace) >> shot at devielle:~/PhD/art-decomp$ >> >> >> shot at devielle:~/PhD/art-decomp$ rake spec >> (in /home/shot/PhD/art-decomp) >> ./lib/set.rb:5: undefined method `[]' for Set:Class (NoMethodError) >> ?from >> /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> `gem_original_require' >> ?from >> /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> `require' >> ?from ./lib/art-decomp.rb:39 >> ?from >> /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> `gem_original_require' >> ?from >> /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> `require' >> ?from ./spec/spec_helper.rb:4 >> ?from >> /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> `gem_original_require' >> ?from >> /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> `require' >> ?from >> /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:149:in >> `invoke_requires' >> ?from >> /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:148:in >> `each' >> ?from >> /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:148:in >> `invoke_requires' >> ?from >> /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:104:in >> `initialize' >> ?from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/1.8/optparse.rb:1267:in >> `call' >> ?from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/1.8/optparse.rb:1267:in >> `parse_in_order' >> ?from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/1.8/optparse.rb:1254:in >> `catch' >> ?from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/1.8/optparse.rb:1254:in >> `parse_in_order' >> ?from /home/shot/.rvm/ruby-1.8.7-p174/lib/ruby/1.8/optparse.rb:1248:in >> `order!' >> ?from >> /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb:132:in >> `order!' >> ?from /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner.rb:51:in >> `options' >> ?from >> /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/lib/spec/runner/command_line.rb:6:in >> `run' >> ?from /home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/bin/spec:5 >> rake aborted! >> Command /home/shot/.rvm/ruby-1.8.7-p174/bin/ruby -I"lib" >> ?"/home/shot/.gem/ruby/1.8.7/gems/rspec-1.2.9/bin/spec" "spec/set_spec.rb" >> "spec/string_spec.rb" "spec/enumerable_spec.rb" "spec/file_spec.rb" >> "spec/art-decomp/graph_spec.rb" "spec/art-decomp/logging_spec.rb" >> "spec/art-decomp/arch_spec.rb" "spec/art-decomp/fsm_spec.rb" >> "spec/art-decomp/sep_spec.rb" "spec/art-decomp/bipainter_spec.rb" >> "spec/art-decomp/blanket_spec.rb" "spec/art-decomp/kiss_spec.rb" >> "spec/art-decomp/qv_generator/graph_colouring_spec.rb" >> "spec/art-decomp/qv_generator/bipainting_spec.rb" >> "spec/art-decomp/qv_generator/graph_merging_spec.rb" >> "spec/art-decomp/executable_spec.rb" "spec/art-decomp/decomposer_spec.rb" >> "spec/art-decomp/qu_generator/edge_labels_spec.rb" >> "spec/art-decomp/qu_generator/block_table_spec.rb" >> "spec/art-decomp/uv_generator/relevance_spec.rb" >> "spec/art-decomp/uv_generator/braindead_spec.rb" >> "spec/art-decomp/decomposition_spec.rb" "spec/art-decomp/b_spec.rb" >> "spec/integer_spec.rb" --options spec/spec.opts failed >> >> (See full trace by running task with --trace) >> shot at devielle:~/PhD/art-decomp$ >> >> >> I guess the problem is my way of monkey-patching the Set class; >> I first ?require 'set'? to get the stdlib?s Set, and then >> ?require_relative 'lib/set'? to get my patches. But this approach >> works in RSpec 1.2.8 and in all other applications of my code? >> >> Any insight on whether I should fix my code or >> is this a bug in RSpec would be most appreciated. > > Hey Shot - > > RSpec 1.2.9 adds ./lib and ./spec (from the project root) to the load path. > So it sounds it's loading your custom 'set' before the one in stdlib. > > I've run into load order problems like this before, and found that the > safest bet is to have the extension at a different path than that of the > core lib. So in this case, I'd recommend putting the 'set' extensions in > ./lib/extensions/set (or something similar - anything other than ./lib/set), > and then require 'set' _from that file_. > > WDYT? FYI - from http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices: It may seem harmless to call files whatever you?d like in your package because you are ?namespaced? in your own package. But if lib/ is prepended to $LOAD_PATH it will clobber Ruby?s built in erb and set libs. require 'erb' would no longer require Ruby?s builtin erb library, but this package?s version of it. The safe (and correct) way would be to namespace your files under another directory. Its conventional to create a folder within lib with the same name as your gem. Then we would put all our dependency files under lib/foo/ instead of at lib/ root. I agree, and I think this applies to extensions to stdlib and core classes as I mentioned in my previous post. > > David > >> >> ? Shot, who?s back to RSpec 1.2.8 for now >> -- >> Content-type: lies/all-lies >> Content-disposition: blatant >> ? ? ? ? ? ? [Nick Moffitt] >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > From jona.hunt777 at gmail.com Sun Oct 11 02:00:40 2009 From: jona.hunt777 at gmail.com (Hunt Jon) Date: Sun, 11 Oct 2009 15:00:40 +0900 Subject: [rspec-users] What argument should I pass for mock(), stub() and double() Message-ID: <5e1f1f1f0910102300r4d21aa23qa6e5da750043a6f8@mail.gmail.com> Hi - I'm reading the RSpec book. I see an example like: customer = double('customer') What is the customer that is in the argument for? How is this different from: customer = double() ? Can anybody explain to me? - Jon From lee.hambley at gmail.com Sun Oct 11 05:21:59 2009 From: lee.hambley at gmail.com (Lee Hambley) Date: Sun, 11 Oct 2009 11:21:59 +0200 Subject: [rspec-users] What argument should I pass for mock(), stub() and double() In-Reply-To: <5e1f1f1f0910102300r4d21aa23qa6e5da750043a6f8@mail.gmail.com> References: <5e1f1f1f0910102300r4d21aa23qa6e5da750043a6f8@mail.gmail.com> Message-ID: John, I may well be wrong, but I believe it's just a `tag` or name, so when you print out - you see <#Double customer> rather tahn something inexplicable, that is at least how it appears to work using Mocha - Lee -------------- next part -------------- An HTML attachment was scrubbed... URL: From shot at hot.pl Sun Oct 11 07:25:01 2009 From: shot at hot.pl (Shot (Piotr Szotkowski)) Date: Sun, 11 Oct 2009 13:25:01 +0200 Subject: [rspec-users] Problems with Set after upgrade to RSpec 1.2.9 In-Reply-To: <57c63afe0910101926g24f02356w1f4f95ef8fc8bf84@mail.gmail.com> References: <20091010205404.GA12281@devielle> <5969DD51-69A5-4024-8FC6-FFB834687479@gmail.com> <57c63afe0910101926g24f02356w1f4f95ef8fc8bf84@mail.gmail.com> Message-ID: <20091011112501.GA5286@devielle> David Chelimsky: >> RSpec 1.2.9 adds ./lib and ./spec (from the project root) to the load >> path. So it sounds it's loading your custom 'set' before the one in >> stdlib. That would explain that backtrace. Thanks for the clarification! >> I've run into load order problems like this before, and found that >> the safest bet is to have the extension at a different path than that >> of the core lib. So in this case, I'd recommend putting the 'set' >> extensions in ./lib/extensions/set (or something similar - anything >> other than ./lib/set), and then require 'set' _from that file_. I was waiting a bit to see whether there emerges any common naming of the directory carrying patches for core/stdlib classes (core? base? core-ext? stdlib?) before breaking my ?file path maps 1:1 to class name? rule. But you?re right that having ?require 'set'? and ?require_relative 'set'? next to each other and actually *wanting* them to load two different files does not feel like following the path of least surprise. > FYI - from http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices: > > It may seem harmless to call files whatever you?d like in your package > because you are ?namespaced? in your own package. But if lib/ is > prepended to $LOAD_PATH it will clobber Ruby?s built in erb and > set libs. require 'erb' would no longer require Ruby?s builtin erb > library, but this package?s version of it. > The safe (and correct) way would be to namespace your files under > another directory. Its conventional to create a folder within lib > with the same name as your gem. Then we would put all our dependency > files under lib/foo/ instead of at lib/ root. > > I agree, and I think this applies to extensions to stdlib > and core classes as I mentioned in my previous post. Ah, right ? I actually remembered reading this somewhere, but forgot the source. Thanks! ? Shot -- When I die, I want my last words to be some harsh call that will haunt some poor bastard forever. Like, just say to the doctor ?your shirt is terrible; one of us will have to go?, then die. [bossan] -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Digital signature URL: From dchelimsky at gmail.com Sun Oct 11 08:20:17 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 11 Oct 2009 09:20:17 -0300 Subject: [rspec-users] What argument should I pass for mock(), stub() and double() In-Reply-To: References: <5e1f1f1f0910102300r4d21aa23qa6e5da750043a6f8@mail.gmail.com> Message-ID: <5EAFA812-E9C0-400D-A2C2-EDE7B2E00287@gmail.com> On Oct 11, 2009, at 6:21 AM, Lee Hambley wrote: > John, > > I may well be wrong, but I believe it's just a `tag` or name, so > when you print out - you see <#Double customer> rather > tahn something inexplicable, that is at least how it appears to work > using Mocha Not so much when _you_ print it out, but when there is a failure and rspec prints out a failure message for you. This is actually explained in the book - on page 207 if you've got beta 10: To create a double, just use the double( ) method, like this: thingamajig_double = double('thing-a-ma-jig') The string argument is optional, but highly recommended as it is used in failure messages. > - Lee > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From wmene at stanford.edu Mon Oct 12 14:33:41 2009 From: wmene at stanford.edu (Willy Mene) Date: Mon, 12 Oct 2009 11:33:41 -0700 Subject: [rspec-users] should and != operator Message-ID: <4D2FE013-9120-4318-A4C4-ECB286B7B351@stanford.edu> I've tried searching around for something describing how the #should method works with the != operator, but couldn't find anything conclusive. Can someone please explain while the following lines will pass if placed into an rspec example? it "should fail but passes" do [].should != [] 'some string'.should != 'some string' end Thanks! Willy From lee.hambley at gmail.com Mon Oct 12 15:08:50 2009 From: lee.hambley at gmail.com (Lee Hambley) Date: Mon, 12 Oct 2009 21:08:50 +0200 Subject: [rspec-users] should and != operator In-Reply-To: <4D2FE013-9120-4318-A4C4-ECB286B7B351@stanford.edu> References: <4D2FE013-9120-4318-A4C4-ECB286B7B351@stanford.edu> Message-ID: Willy... Should you not use .should_not ? -- Lee -------------- next part -------------- An HTML attachment was scrubbed... URL: From wmene at stanford.edu Mon Oct 12 15:21:07 2009 From: wmene at stanford.edu (Willy Mene) Date: Mon, 12 Oct 2009 12:21:07 -0700 Subject: [rspec-users] should and != operator In-Reply-To: References: <4D2FE013-9120-4318-A4C4-ECB286B7B351@stanford.edu> Message-ID: Yes, I do know about .should_not, and the example should be written that way. So the following [].should_not == [] 'string'.should_not == 'string' do fail. But I'm trying to understand why they pass with .should != Willy On Oct 12, 2009, at 12:08 PM, Lee Hambley wrote: > Willy... > > Should you not use .should_not ? > > -- Lee > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From tero at tilus.net Mon Oct 12 15:18:56 2009 From: tero at tilus.net (Tero Tilus) Date: Mon, 12 Oct 2009 22:18:56 +0300 Subject: [rspec-users] should and != operator In-Reply-To: <4D2FE013-9120-4318-A4C4-ECB286B7B351@stanford.edu> References: <4D2FE013-9120-4318-A4C4-ECB286B7B351@stanford.edu> Message-ID: <20091012191856.GB31379@tilus.net> 2009-10-12 11:33, Willy Mene: > I've tried searching around for something describing how the #should > method works with the != operator Afaik it doesn't. I have led to believe this is because there is no method '!='. Expression x!=y is instead just syntactic sugar for !(x==y). > it "should fail but passes" do > [].should != [] > 'some string'.should != 'some string' > end How about it "fails now" do [].should_not == [] 'some string'.should_not == 'some string' end -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From bret at pettichord.com Mon Oct 12 15:11:07 2009 From: bret at pettichord.com (Bret Pettichord) Date: Mon, 12 Oct 2009 14:11:07 -0500 Subject: [rspec-users] should and != operator In-Reply-To: <4D2FE013-9120-4318-A4C4-ECB286B7B351@stanford.edu> References: <4D2FE013-9120-4318-A4C4-ECB286B7B351@stanford.edu> Message-ID: <4AD37F4B.1080907@pettichord.com> Looks like an rspec bug to me. Bret Willy Mene wrote: > I've tried searching around for something describing how the #should > method works with the != operator, but couldn't find anything > conclusive. Can someone please explain while the following lines will > pass if placed into an rspec example? > > it "should fail but passes" do > [].should != [] > 'some string'.should != 'some string' > end > > Thanks! > Willy > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cwdinfo at gmail.com Mon Oct 12 15:32:08 2009 From: cwdinfo at gmail.com (s.ross) Date: Mon, 12 Oct 2009 12:32:08 -0700 Subject: [rspec-users] should and != operator In-Reply-To: References: <4D2FE013-9120-4318-A4C4-ECB286B7B351@stanford.edu> Message-ID: <30BD29C4-2747-4A22-A4FE-FA5F640B1F30@gmail.com> Afaik, != is one of the few operators that is intrinsic. I believe there is no !=() method defined in Ruby. Hunted and pecked from my iPhone On Oct 12, 2009, at 12:21 PM, Willy Mene wrote: > Yes, I do know about .should_not, and the example should be written > that way. So the following > > [].should_not == [] > 'string'.should_not == 'string' > > do fail. But I'm trying to understand why they pass with .should != > > Willy > > On Oct 12, 2009, at 12:08 PM, Lee Hambley wrote: > >> Willy... >> >> Should you not use .should_not ? >> >> -- Lee >> _______________________________________________ >> 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 tero at tilus.net Mon Oct 12 16:19:11 2009 From: tero at tilus.net (Tero Tilus) Date: Mon, 12 Oct 2009 23:19:11 +0300 Subject: [rspec-users] should and != operator In-Reply-To: <20091012191856.GB31379@tilus.net> References: <4D2FE013-9120-4318-A4C4-ECB286B7B351@stanford.edu> <20091012191856.GB31379@tilus.net> Message-ID: <20091012201911.GC31379@tilus.net> 2009-10-12 22:18, Tero Tilus: > Expression x!=y is instead just syntactic sugar for !(x==y). To illustrate how this affects #should, think of 'some string'.should != 'some string' Now Ruby internals kick in and desugar this (before anything is even executed) to !('some string'.should == 'some string') Which obviously does not fail. -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From aslak.hellesoy at gmail.com Mon Oct 12 16:18:20 2009 From: aslak.hellesoy at gmail.com (=?utf-8?Q?Aslak_Helles=C3=B8y?=) Date: Mon, 12 Oct 2009 22:18:20 +0200 Subject: [rspec-users] should and != operator In-Reply-To: <4AD37F4B.1080907@pettichord.com> References: <4D2FE013-9120-4318-A4C4-ECB286B7B351@stanford.edu> <4AD37F4B.1080907@pettichord.com> Message-ID: Den 12. okt. 2009 kl. 21.11 skrev Bret Pettichord : > Looks like an rspec bug to me. > It's not an rspec bug. != is not a method, and therefore can't be treated by rspec. It's a limitation of ruby. Aslak > Bret > > Willy Mene wrote: >> I've tried searching around for something describing how the >> #should method works with the != operator, but couldn't find >> anything conclusive. Can someone please explain while the >> following lines will pass if placed into an rspec example? >> >> it "should fail but passes" do >> [].should != [] >> 'some string'.should != 'some string' >> end >> >> Thanks! >> Willy >> >> _______________________________________________ >> 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 cwdinfo at gmail.com Mon Oct 12 16:25:28 2009 From: cwdinfo at gmail.com (s.ross) Date: Mon, 12 Oct 2009 13:25:28 -0700 Subject: [rspec-users] should and != operator In-Reply-To: <4AD37F4B.1080907@pettichord.com> References: <4D2FE013-9120-4318-A4C4-ECB286B7B351@stanford.edu> <4AD37F4B.1080907@pettichord.com> Message-ID: <9A0F7A6A-87F9-4D73-AD8D-50D811E11AE8@gmail.com> It's not a bug. Consider: "abc".should eql("abc") <= pass "abc".should_not eql("def") <= pass But eql() is a Ruby method. In Pickaxe, you'll see that other comparators such as != >= etc. Are not implemented as overridable methods. Hope this clarifies. Hunted and pecked from my iPhone On Oct 12, 2009, at 12:11 PM, Bret Pettichord wrote: > Looks like an rspec bug to me. > > Bret > > Willy Mene wrote: >> I've tried searching around for something describing how the >> #should method works with the != operator, but couldn't find >> anything conclusive. Can someone please explain while the >> following lines will pass if placed into an rspec example? >> >> it "should fail but passes" do >> [].should != [] >> 'some string'.should != 'some string' >> end >> >> Thanks! >> Willy >> >> _______________________________________________ >> 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 ashley.moran at patchspace.co.uk Mon Oct 12 17:03:06 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Mon, 12 Oct 2009 22:03:06 +0100 Subject: [rspec-users] should and != operator In-Reply-To: <4D2FE013-9120-4318-A4C4-ECB286B7B351@stanford.edu> References: <4D2FE013-9120-4318-A4C4-ECB286B7B351@stanford.edu> Message-ID: On 12 Oct 2009, at 19:33, Willy Mene wrote: > it "should fail but passes" do > [].should != [] > 'some string'.should != 'some string' > end This is a common mistake, and one I made for a long while even after being familiar with RSpec. I wonder if there is justification for an AST pass over spec files to catch this (among possibly other issues)? Just one of my usual idle thoughts... Ashley -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran http://aviewfromafar.net/ From bret at pettichord.com Mon Oct 12 17:20:22 2009 From: bret at pettichord.com (Bret Pettichord) Date: Mon, 12 Oct 2009 16:20:22 -0500 Subject: [rspec-users] should and != operator In-Reply-To: References: <4D2FE013-9120-4318-A4C4-ECB286B7B351@stanford.edu> <4AD37F4B.1080907@pettichord.com> Message-ID: <4AD39D96.4090702@pettichord.com> Aslak Helles?y wrote: > > Den 12. okt. 2009 kl. 21.11 skrev Bret Pettichord : > >> Looks like an rspec bug to me. >> > It's not an rspec bug. != is not a method, and therefore can't be > treated by rspec. It's a limitation of ruby. OK. I get it. Bret From lists at ruby-forum.com Mon Oct 12 20:37:55 2009 From: lists at ruby-forum.com (Sam Woodard) Date: Tue, 13 Oct 2009 02:37:55 +0200 Subject: [rspec-users] stub! and stubs Message-ID: <2cd94577b66f87912307a404ef9c06b1@ruby-forum.com> I have an interesting setup: I am using rspec for mocking but I have mocha installed which give me access to any_instance, expects, etc. The problem that I am having is that I want to stub out a method for the duration of a single example, throughout that example but only for that example. If I do, Goal.any_instance.stub!(:valid?).and_return(true) this is not sufficient because valid is called more than once If I do, Goal.any_instance.stubs(:valid?).returns(true) then my tests are not independent but dependent on one another. Can anyone help? Thanks in advance, Sam -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Mon Oct 12 21:14:37 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 12 Oct 2009 22:14:37 -0300 Subject: [rspec-users] stub! and stubs In-Reply-To: <2cd94577b66f87912307a404ef9c06b1@ruby-forum.com> References: <2cd94577b66f87912307a404ef9c06b1@ruby-forum.com> Message-ID: On Oct 12, 2009, at 9:37 PM, Sam Woodard wrote: > I have an interesting setup: I am using rspec for mocking but I have > mocha installed which give me access to any_instance, expects, etc. > The > problem that I am having is that I want to stub out a method for the > duration of a single example, throughout that example but only for > that > example. > > If I do, > > Goal.any_instance.stub!(:valid?).and_return(true) > > this is not sufficient because valid is called more than once > > If I do, > > Goal.any_instance.stubs(:valid?).returns(true) then my tests are not > independent but dependent on one another. > > Can anyone help? While mocha and rspec's mocks might be compatible for you in some cases, it is purely accidental. I'd strongly recommend you choose one or the other. If any_instance is important to you, I'd choose mocha. If not, choose whichever makes you happier. Cheers, David > > Thanks in advance, > Sam > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From scott at railsnewbie.com Mon Oct 12 21:26:38 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Mon, 12 Oct 2009 21:26:38 -0400 Subject: [rspec-users] stub! and stubs In-Reply-To: References: <2cd94577b66f87912307a404ef9c06b1@ruby-forum.com> Message-ID: <7B3473EE-CE31-4F17-8504-CBA03C8BE4C8@railsnewbie.com> On Oct 12, 2009, at 9:14 PM, David Chelimsky wrote: > On Oct 12, 2009, at 9:37 PM, Sam Woodard wrote: > >> I have an interesting setup: I am using rspec for mocking but I have >> mocha installed which give me access to any_instance, expects, >> etc. The >> problem that I am having is that I want to stub out a method for the >> duration of a single example, throughout that example but only for >> that >> example. >> >> If I do, >> >> Goal.any_instance.stub!(:valid?).and_return(true) >> >> this is not sufficient because valid is called more than once >> >> If I do, >> >> Goal.any_instance.stubs(:valid?).returns(true) then my tests are not >> independent but dependent on one another. >> >> Can anyone help? > > While mocha and rspec's mocks might be compatible for you in some > cases, it is purely accidental. I'd strongly recommend you choose > one or the other. If any_instance is important to you, I'd choose > mocha. If not, choose whichever makes you happier. Unless I'm incorrect, this is still a feature request on the lighthouse tracker. I don't see why we couldn't use something like this code: http://github.com/smtlaissezfaire/mix_master to implement the mixin/mixout feature that we'd need to support different frameworks per-example group. Scott > > Cheers, > David > >> >> Thanks in advance, >> Sam >> -- >> Posted via http://www.ruby-forum.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 dchelimsky at gmail.com Mon Oct 12 21:41:10 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 12 Oct 2009 22:41:10 -0300 Subject: [rspec-users] stub! and stubs In-Reply-To: <7B3473EE-CE31-4F17-8504-CBA03C8BE4C8@railsnewbie.com> References: <2cd94577b66f87912307a404ef9c06b1@ruby-forum.com> <7B3473EE-CE31-4F17-8504-CBA03C8BE4C8@railsnewbie.com> Message-ID: <94AEB722-0559-4333-84E4-D893C07EEF01@gmail.com> On Oct 12, 2009, at 10:26 PM, Scott Taylor wrote: > > On Oct 12, 2009, at 9:14 PM, David Chelimsky wrote: > >> On Oct 12, 2009, at 9:37 PM, Sam Woodard wrote: >> >>> I have an interesting setup: I am using rspec for mocking but I >>> have >>> mocha installed which give me access to any_instance, expects, >>> etc. The >>> problem that I am having is that I want to stub out a method for the >>> duration of a single example, throughout that example but only for >>> that >>> example. >>> >>> If I do, >>> >>> Goal.any_instance.stub!(:valid?).and_return(true) >>> >>> this is not sufficient because valid is called more than once >>> >>> If I do, >>> >>> Goal.any_instance.stubs(:valid?).returns(true) then my tests are not >>> independent but dependent on one another. >>> >>> Can anyone help? >> >> While mocha and rspec's mocks might be compatible for you in some >> cases, it is purely accidental. I'd strongly recommend you choose >> one or the other. If any_instance is important to you, I'd choose >> mocha. If not, choose whichever makes you happier. > > Unless I'm incorrect, this is still a feature request on the > lighthouse tracker. > > I don't see why we couldn't use something like this code: > > http://github.com/smtlaissezfaire/mix_master > > to implement the mixin/mixout feature that we'd need to support > different frameworks per-example group. Hey Scott - I haven't looked into mixmaster yet, but supporting multiple mock frameworks is definitely something I want to do/support in rspec-2. Just been busy trying to get the book done and on paper before I focus on the next version of rspec. I think this is a separate issue, however. Sam is looking to mix frameworks in a single statement. FWIW, David > > Scott > > >> >> Cheers, >> David >> >>> >>> Thanks in advance, >>> Sam >>> -- >>> Posted via http://www.ruby-forum.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 From lists at ruby-forum.com Tue Oct 13 10:01:09 2009 From: lists at ruby-forum.com (Sam Woodard) Date: Tue, 13 Oct 2009 16:01:09 +0200 Subject: [rspec-users] stub! and stubs In-Reply-To: <94AEB722-0559-4333-84E4-D893C07EEF01@gmail.com> References: <2cd94577b66f87912307a404ef9c06b1@ruby-forum.com> <7B3473EE-CE31-4F17-8504-CBA03C8BE4C8@railsnewbie.com> <94AEB722-0559-4333-84E4-D893C07EEF01@gmail.com> Message-ID: Things seem to be working better now that I am using just Mocha, however, I am still having problems with Foo.any_instance.stubs(:valid?).returns(false). I later tests, valid is still stubbed out to be false. How to I stub something for exactly the duration of one example? Thanks, Sam -- Posted via http://www.ruby-forum.com/. From ctm at devctm.com Tue Oct 13 10:27:41 2009 From: ctm at devctm.com (Clifford T. Matthews) Date: Tue, 13 Oct 2009 08:27:41 -0600 Subject: [rspec-users] route_to for ambiguous generation? Message-ID: I like the new route_to matcher, but I can't use it for my root route, since the route that is generated isn't the route that I pass in. Specifically, my routes.rb has: ... map.resources :skills, :only => [:index, :show] ... map.root :controller => :skills, :action => :index, :conditions => { :method => :get } ... So, '/' routes to SkillsController#index, but { :controller => :skills, :action => :index } generates '/skills', an acceptable synonym. So instead of being able to write: { :get, '/' }.should route_to(:controller => 'skills', :action => 'index') I had to write the old style params_from(:get, '/').should == { :controller => 'skills', :action => 'index' } That works, but is inelegant. I think I can code things up so that I could write: { :get, '/' }.should route_to(:controller => 'skills', :action => 'index').which_generates('/skills') If I understand how things work, I'd just need to add a #which_generates method Spec::Rails::Matchers::RouteTo, and have it set up an ivar that is used in the @example.assert_routing invocation. I'm having some trouble accessing GitHub right now. Once it's back, I'll try doing what I've described. Anyone see a better solution that I'm overlooking? -- Cliff Matthews From lee.hambley at gmail.com Tue Oct 13 10:33:44 2009 From: lee.hambley at gmail.com (Lee Hambley) Date: Tue, 13 Oct 2009 16:33:44 +0200 Subject: [rspec-users] stub! and stubs In-Reply-To: References: <2cd94577b66f87912307a404ef9c06b1@ruby-forum.com> <7B3473EE-CE31-4F17-8504-CBA03C8BE4C8@railsnewbie.com> <94AEB722-0559-4333-84E4-D893C07EEF01@gmail.com> Message-ID: Sam, As the .any_instance call suggests, anything ever again for the duration of the test will stub that value, the alternative is this: Foo.any_instance.stubs(:valid?).returns(false) replace with this foo = Foo.new foo.stubs(:valid?).returns(false) HTH - Lee -------------- next part -------------- An HTML attachment was scrubbed... URL: From rjharmon0316 at yahoo.com Tue Oct 13 10:52:43 2009 From: rjharmon0316 at yahoo.com (Randy Harmon) Date: Tue, 13 Oct 2009 07:52:43 -0700 Subject: [rspec-users] route_to for ambiguous generation? In-Reply-To: References: Message-ID: <4AD4943B.2000107@yahoo.com> Hi Cliff, Hey, that's a good use case - one I hadn't considered. Just goes to show you, the real world has a way of intruding on happy theories. :) It's nice to hear feedback about the matcher. which_generates() as a method on the route_to() matcher seems like it should work to me, once it's written. I don't generally wish to have two separate paths to the same content for publicly-accessible sites, because it's not as good for SEO, but there are certainly cases I can think of where that's irrelevant. I've had difficulty with my rspec-rails testing environment lately so it'd be difficult for me to quickly make the adjustment, but it does seem like it would be a simple change for someone who had strong motivation or easy access. Randy On 10/13/09 7:27 AM, Clifford T. Matthews wrote: > I like the new route_to matcher, but I can't use it for my root route, > since the route that is generated isn't the route that I pass in. > Specifically, my routes.rb has: > > ... > map.resources :skills, :only => [:index, :show] > ... > map.root :controller => :skills, :action => :index, :conditions => { :method => :get } > ... > > So, '/' routes to SkillsController#index, > but { :controller => :skills, :action => :index } > generates '/skills', an acceptable synonym. > > So instead of being able to write: > > { :get, '/' }.should route_to(:controller => 'skills', :action => 'index') > > I had to write the old style > > params_from(:get, '/').should == { :controller => 'skills', :action => 'index' } > > That works, but is inelegant. > > I think I can code things up so that I could write: > > { :get, '/' }.should route_to(:controller => 'skills', :action => 'index').which_generates('/skills') > > If I understand how things work, I'd just need to add a > #which_generates method Spec::Rails::Matchers::RouteTo, and have it > set up an ivar that is used in the @example.assert_routing invocation. > I'm having some trouble accessing GitHub right now. Once it's back, I'll > try doing what I've described. > > Anyone see a better solution that I'm overlooking? > From r_j_h_box-sf at yahoo.com Tue Oct 13 10:54:05 2009 From: r_j_h_box-sf at yahoo.com (Randy Harmon) Date: Tue, 13 Oct 2009 07:54:05 -0700 Subject: [rspec-users] route_to for ambiguous generation? In-Reply-To: References: Message-ID: <4AD4948D.3070101@yahoo.com> Hi Cliff, Hey, that's a good use case - one I hadn't considered. Just goes to show you, the real world has a way of intruding on happy theories. :) It's nice to hear feedback about the matcher. which_generates() as a method on the route_to() matcher seems like it should work to me, once it's written. I don't generally wish to have two separate paths to the same content for publicly-accessible sites, because it's not as good for SEO, but there are certainly cases I can think of where that's irrelevant. I've had difficulty with my rspec-rails testing environment lately so it'd be difficult for me to quickly make the adjustment, but it does seem like it would be a simple change for someone who had strong motivation or easy access. Randy On 10/13/09 7:27 AM, Clifford T. Matthews wrote: > I like the new route_to matcher, but I can't use it for my root route, > since the route that is generated isn't the route that I pass in. > Specifically, my routes.rb has: > > ... > map.resources :skills, :only => [:index, :show] > ... > map.root :controller => :skills, :action => :index, :conditions => { :method => :get } > ... > > So, '/' routes to SkillsController#index, > but { :controller => :skills, :action => :index } > generates '/skills', an acceptable synonym. > > So instead of being able to write: > > { :get, '/' }.should route_to(:controller => 'skills', :action => 'index') > > I had to write the old style > > params_from(:get, '/').should == { :controller => 'skills', :action => 'index' } > > That works, but is inelegant. > > I think I can code things up so that I could write: > > { :get, '/' }.should route_to(:controller => 'skills', :action => 'index').which_generates('/skills') > > If I understand how things work, I'd just need to add a > #which_generates method Spec::Rails::Matchers::RouteTo, and have it > set up an ivar that is used in the @example.assert_routing invocation. > I'm having some trouble accessing GitHub right now. Once it's back, I'll > try doing what I've described. > > Anyone see a better solution that I'm overlooking? > From ctm at devctm.com Tue Oct 13 11:35:11 2009 From: ctm at devctm.com (Clifford T. Matthews) Date: Tue, 13 Oct 2009 09:35:11 -0600 Subject: [rspec-users] route_to for ambiguous generation? In-Reply-To: <4AD4948D.3070101@yahoo.com> (Randy Harmon's message of "Tue, 13 Oct 2009 07:54:05 -0700") References: <4AD4948D.3070101@yahoo.com> Message-ID: >>>>> "Randy" == Randy Harmon writes: Randy> Hi Cliff, Hey, that's a good use case - one I hadn't Randy> considered. Just goes to show you, the real world has a Randy> way of intruding on happy theories. :) It's nice to hear Randy> feedback about the matcher. It's so good that it makes my params_from hack too ugly! Randy> which_generates() as a method on the route_to() matcher Randy> seems like it should work to me, once it's written. I Randy> don't generally wish to have two separate paths to the same Randy> content for publicly-accessible sites, because it's not as Randy> good for SEO, but there are certainly cases I can think of Randy> where that's irrelevant. I thought about making it so that the only path to SkillsController#index was through my root path, but that just struck me as a bad compromise. As for SEO, I try to do things the way I think they should be done architecturally and then I just cross my fingers and hope the search engine folks agree with me (eventually). Randy> I've had difficulty with my rspec-rails testing environment Randy> lately so it'd be difficult for me to quickly make the Randy> adjustment, but it does seem like it would be a simple Randy> change for someone who had strong motivation or easy Randy> access. I added a which_generates call to my current test, cloned Rspec-rails, added support for which_generates and pushed my results as a proof-of-concept. Unfortunately, the RSpec-rails testing isn't working for me either right now and I have a huge queue of other things to do before I can look at it. I don't mind coming back and making sure that I have a test for my new code, but it won't be for a several hours at minimum and maybe a couple of days. -- Cliff Matthews From mguterl at gmail.com Tue Oct 13 19:32:56 2009 From: mguterl at gmail.com (Michael Guterl) Date: Tue, 13 Oct 2009 19:32:56 -0400 Subject: [rspec-users] should and != operator In-Reply-To: <20091012191856.GB31379@tilus.net> References: <4D2FE013-9120-4318-A4C4-ECB286B7B351@stanford.edu> <20091012191856.GB31379@tilus.net> Message-ID: <944a03770910131632g50777c33i42d5cc13a85d0b4d@mail.gmail.com> On Mon, Oct 12, 2009 at 3:18 PM, Tero Tilus wrote: > 2009-10-12 11:33, Willy Mene: >> I've tried searching around for something describing how the #should >> method works with the != operator > > Afaik it doesn't. ?I have led to believe this is because there is no > method '!='. ?Expression x!=y is instead just syntactic sugar for > !(x==y). > This is not true in Ruby 1.9. You can define != separate from ==. Best, Michael Guterl From sfeley at gmail.com Tue Oct 13 21:25:00 2009 From: sfeley at gmail.com (Stephen Eley) Date: Tue, 13 Oct 2009 21:25:00 -0400 Subject: [rspec-users] should and != operator In-Reply-To: References: <4D2FE013-9120-4318-A4C4-ECB286B7B351@stanford.edu> Message-ID: <1fb4df0910131825y2fc87979n19b1cd7317abd436@mail.gmail.com> On Mon, Oct 12, 2009 at 5:03 PM, Ashley Moran wrote: > > This is a common mistake, and one I made for a long while even after being > familiar with RSpec. ?I wonder if there is justification for an AST pass > over spec files to catch this (among possibly other issues)? The AST pass over the spec files already exists. It's what Ruby does when you run the specs, and these quirks are caught when your specs pass and you haven't done anything to make them pass yet. >8-> (You _do_ always start with failing specs, and then do the work to make them pass, right?) -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From ashley.moran at patchspace.co.uk Wed Oct 14 04:34:47 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Wed, 14 Oct 2009 09:34:47 +0100 Subject: [rspec-users] should and != operator In-Reply-To: <1fb4df0910131825y2fc87979n19b1cd7317abd436@mail.gmail.com> References: <4D2FE013-9120-4318-A4C4-ECB286B7B351@stanford.edu> <1fb4df0910131825y2fc87979n19b1cd7317abd436@mail.gmail.com> Message-ID: <98DDB12D-E85F-40CD-8118-B5465C9264D0@patchspace.co.uk> On 14 Oct 2009, at 02:25, Stephen Eley wrote: > The AST pass over the spec files already exists. It's what Ruby does > when you run the specs, and these quirks are caught when your specs > pass and you haven't done anything to make them pass yet. >8-> Really? I just tried `1.should != 2' and got no warnings. > (You _do_ always start with failing specs, and then do the work to > make them pass, right?) Only when I care if the code does something useful =) Ashley -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran http://aviewfromafar.net/ From dchelimsky at gmail.com Wed Oct 14 08:51:15 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 14 Oct 2009 09:51:15 -0300 Subject: [rspec-users] Resources on using RSpec with Sinatra In-Reply-To: <50873a360910140414p3fe08a19mb1c6ca818b120af9@mail.gmail.com> References: <50873a360910140414p3fe08a19mb1c6ca818b120af9@mail.gmail.com> Message-ID: <57c63afe0910140551p491e7279na3400052eacc845f@mail.gmail.com> On Wed, Oct 14, 2009 at 8:14 AM, doug livesey wrote: > Could anybody post resources on using RSpec with Sinatra? There's no official resource that I'm aware of, but google says there are over 2 million to choose from :) If anybody has specific resources they'd like to put focus on, feel free to create a page on http://wiki.github.com/dchelimsky/rspec. Cheers, David > Thanks, > ?? Doug. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From sfeley at gmail.com Wed Oct 14 12:01:04 2009 From: sfeley at gmail.com (Stephen Eley) Date: Wed, 14 Oct 2009 12:01:04 -0400 Subject: [rspec-users] should and != operator In-Reply-To: <98DDB12D-E85F-40CD-8118-B5465C9264D0@patchspace.co.uk> References: <4D2FE013-9120-4318-A4C4-ECB286B7B351@stanford.edu> <1fb4df0910131825y2fc87979n19b1cd7317abd436@mail.gmail.com> <98DDB12D-E85F-40CD-8118-B5465C9264D0@patchspace.co.uk> Message-ID: <1fb4df0910140901p7f783642obcdc71b21db05e59@mail.gmail.com> On Wed, Oct 14, 2009 at 4:34 AM, Ashley Moran wrote: > On 14 Oct 2009, at 02:25, Stephen Eley wrote: > >> [...] these quirks are caught when your specs >> pass and you haven't done anything to make them pass yet. ?>8-> > > Really? ?I just tried `1.should != 2' and got no warnings. Did your brain try to warn you? You're part of the system, you know. >8-> >> (You _do_ always start with failing specs, and then do the work to >> make them pass, right?) > > Only when I care if the code does something useful =) If you don't care whether the code is useful, I'm baffled as to why you might care whether the tests are useful. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From elliot.winkler at gmail.com Wed Oct 14 14:01:23 2009 From: elliot.winkler at gmail.com (Elliot Winkler) Date: Wed, 14 Oct 2009 13:01:23 -0500 Subject: [rspec-users] Model specs and ActiveRecord::TestCase Message-ID: <4AD611F3.1040102@gmail.com> Is there any reason why the ModelExampleGroup in rspec-rails inherits from ActiveSupport::TestCase and not ActiveRecord::TestCase? I noticed this because I tried to use assert_queries in one of my specs and obviously it told me it didn't know what that was. Not a huge problem, I can always add assert_queries (or an equivalent) manually, I was just curious. -- Elliot From ashley.moran at patchspace.co.uk Wed Oct 14 14:12:00 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Wed, 14 Oct 2009 19:12:00 +0100 Subject: [rspec-users] should and != operator In-Reply-To: <1fb4df0910140901p7f783642obcdc71b21db05e59@mail.gmail.com> References: <4D2FE013-9120-4318-A4C4-ECB286B7B351@stanford.edu> <1fb4df0910131825y2fc87979n19b1cd7317abd436@mail.gmail.com> <98DDB12D-E85F-40CD-8118-B5465C9264D0@patchspace.co.uk> <1fb4df0910140901p7f783642obcdc71b21db05e59@mail.gmail.com> Message-ID: On 14 Oct 2009, at 17:01, Stephen Eley wrote: > Did your brain try to warn you? You're part of the system, you > know. >8-> Well I already know not to do `should !=`, so I don't do it. But I was suggesting that RSpec could make an AST pass over the specs to pick up this, which is undetectable otherwise - at least under Ruby <1.9, apparently. (It would be something like mini RSpecLint, I guess.) != caught me out quite a few times when I was first learning RSpec. I misinterpreted your comment to mean that something like this was already in RSpec. > If you don't care whether the code is useful, I'm baffled as to why > you might care whether the tests are useful. Lol, I was joking! The implication was I always write specs* because I always care if the code is useful. Ashley * Actually, that's a lie. I have support code in my Cucumber features that has no specs, and yes, we've found bugs in them. But all my non- false-positive features prove that they work =) So maybe I should say, "I always write specs except when I don't, and I always regret it when I don't". -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran http://aviewfromafar.net/ From dchelimsky at gmail.com Wed Oct 14 14:18:25 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 14 Oct 2009 15:18:25 -0300 Subject: [rspec-users] Model specs and ActiveRecord::TestCase In-Reply-To: <4AD611F3.1040102@gmail.com> References: <4AD611F3.1040102@gmail.com> Message-ID: <57c63afe0910141118v14a28ef9g925df440d8c6d267@mail.gmail.com> On Wed, Oct 14, 2009 at 3:01 PM, Elliot Winkler wrote: > Is there any reason why the ModelExampleGroup in rspec-rails inherits from > ActiveSupport::TestCase and not ActiveRecord::TestCase? I noticed this > because I tried to use assert_queries in one of my specs and obviously it > told me it didn't know what that was. Not a huge problem, I can always add > assert_queries (or an equivalent) manually, I was just curious. Pure oversight. Wanna submit a patch? https://rspec.lighthouseapp.com/projects/5645-rspec/overview > > -- Elliot > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From elliot.winkler at gmail.com Wed Oct 14 15:19:55 2009 From: elliot.winkler at gmail.com (Elliot Winkler) Date: Wed, 14 Oct 2009 14:19:55 -0500 Subject: [rspec-users] Model specs and ActiveRecord::TestCase In-Reply-To: <57c63afe0910141118v14a28ef9g925df440d8c6d267@mail.gmail.com> References: <4AD611F3.1040102@gmail.com> <57c63afe0910141118v14a28ef9g925df440d8c6d267@mail.gmail.com> Message-ID: <4AD6245B.4060703@gmail.com> Actually it seems someone read my mind... just tried out the patch in #896 and it seems to work great. So, problem solved ;) -- Elliot On 10/14/09 1:18 PM, David Chelimsky wrote: > On Wed, Oct 14, 2009 at 3:01 PM, Elliot Winkler > wrote: > >> Is there any reason why the ModelExampleGroup in rspec-rails inherits from >> ActiveSupport::TestCase and not ActiveRecord::TestCase? I noticed this >> because I tried to use assert_queries in one of my specs and obviously it >> told me it didn't know what that was. Not a huge problem, I can always add >> assert_queries (or an equivalent) manually, I was just curious. >> > Pure oversight. Wanna submit a patch? > https://rspec.lighthouseapp.com/projects/5645-rspec/overview > > >> -- Elliot >> _______________________________________________ >> 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 godfoca at gmail.com Wed Oct 14 16:24:45 2009 From: godfoca at gmail.com (=?ISO-8859-1?Q?Nicol=E1s_Sanguinetti?=) Date: Wed, 14 Oct 2009 18:24:45 -0200 Subject: [rspec-users] spec-ing private methods? In-Reply-To: <333A6CFB-2CD4-4C28-83BB-0253D6B2A602@railsnewbie.com> References: <8277b7f40910141236w5803d640h5281a88adb649776@mail.gmail.com> <333A6CFB-2CD4-4C28-83BB-0253D6B2A602@railsnewbie.com> Message-ID: On Wed, Oct 14, 2009 at 5:49 PM, Scott Taylor wrote: > > On Oct 14, 2009, at 3:36 PM, Joaquin Rivera Padron wrote: > > hello there, > how do you tipically spec private methods? The thing is ? have something > like this: > > def some_method > ?? complex_method + other_complex_methods > end > > private > def complex_method... > def?other_complex_methods ... > > and the two complex methods can get really tricky to get right, I would like > to be able to write specs for them, how do you do that? I mean I cannot do: > > object.some_private_method > > You have a few options: > 1. Make the method public in the object you are testing > 2. Make the method public in the test case > 3. Don't test the method > 4. Use __send__ or (send) to call it. > 5. Refactor private methods to a new object, and make the methods public in > that object. > Most of those options suck (esp. 1, 2, 3, & 4) - usually it represents a > design flaw (you are doing too much in your class). > Scott 3 is ok. A "private" method just means it's an implementation detail that is outside of your API. If you are aiming to test the behavior of your API, then you don't care about implementation details. -foca > > am I? > > thanks in advance, > joaquin > > -- > www.least-significant-bit.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 sfeley at gmail.com Wed Oct 14 16:31:00 2009 From: sfeley at gmail.com (Stephen Eley) Date: Wed, 14 Oct 2009 16:31:00 -0400 Subject: [rspec-users] spec-ing private methods? In-Reply-To: <333A6CFB-2CD4-4C28-83BB-0253D6B2A602@railsnewbie.com> References: <8277b7f40910141236w5803d640h5281a88adb649776@mail.gmail.com> <333A6CFB-2CD4-4C28-83BB-0253D6B2A602@railsnewbie.com> Message-ID: <1fb4df0910141331k5c6c681em1664657da72486a0@mail.gmail.com> On Wed, Oct 14, 2009 at 3:49 PM, Scott Taylor wrote: > > Most of those options suck (esp. 1, 2, 3, & 4) - usually it represents a > design flaw (you are doing too much in your class). I disagree that the simple existence of private methods is a sign of a design flaw. There are plenty of use cases for which private methods are the simplest and most practical approach. I use them all the time to help me deconstruct complicated multi-step actions into shorter, more atomic chunks of logic. They're also how callbacks and filters are usually implemented in Rails. That said, though: I usually don't bother testing them. I use RSpec for unit testing, and when I'm doing that I care about the _external behavior_ of the unit. I want to know what the object will do when I poke it from another object. Private methods are an implementation detail, not a "What does it do?" but rather "How does it do that?" -- and that's not any other class's business. They're also not usually that complex or brittle. I'll know they work because the public or protected methods that call them work; and I don't need tests to understand them. In the exceptional cases where they _might_ be complex (e.g., some ActiveRecord callbacks or authentication filters) you're right -- putting them into a module and testing that module makes sense. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From ashley.moran at patchspace.co.uk Wed Oct 14 16:32:43 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Wed, 14 Oct 2009 21:32:43 +0100 Subject: [rspec-users] spec-ing private methods? In-Reply-To: <333A6CFB-2CD4-4C28-83BB-0253D6B2A602@railsnewbie.com> References: <8277b7f40910141236w5803d640h5281a88adb649776@mail.gmail.com> <333A6CFB-2CD4-4C28-83BB-0253D6B2A602@railsnewbie.com> Message-ID: <6A65C952-6B72-4DCE-A398-A2AE770BCAA3@patchspace.co.uk> On 14 Oct 2009, at 20:49, Scott Taylor wrote: > On Oct 14, 2009, at 3:36 PM, Joaquin Rivera Padron wrote: > >> private >> def complex_method... >> def other_complex_methods ... >> >> and the two complex methods can get really tricky to get right, I >> would like to be able to write specs for them, how do you do that? >> I mean I cannot do: >> >> object.some_private_method > > You have a few options: > > 1. Make the method public in the object you are testing > 2. Make the method public in the test case > 3. Don't test the method > 4. Use __send__ or (send) to call it. > 5. Refactor private methods to a new object, and make the methods > public in that object. > > Most of those options suck (esp. 1, 2, 3, & 4) - usually it > represents a design flaw (you are doing too much in your class). I'm with Scott, this usually indicates a design flaw, and 5 is usually the solution. The clue is in the names you gave them - you shouldn't have complex methods, especially private ones. Can you post any of the code so we can see where the complexity/ problem is? Ashley -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran http://aviewfromafar.net/ From scott at railsnewbie.com Wed Oct 14 16:34:40 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Wed, 14 Oct 2009 16:34:40 -0400 Subject: [rspec-users] spec-ing private methods? In-Reply-To: References: <8277b7f40910141236w5803d640h5281a88adb649776@mail.gmail.com> <333A6CFB-2CD4-4C28-83BB-0253D6B2A602@railsnewbie.com> Message-ID: On Oct 14, 2009, at 4:24 PM, Nicol?s Sanguinetti wrote: > On Wed, Oct 14, 2009 at 5:49 PM, Scott Taylor > wrote: >> >> On Oct 14, 2009, at 3:36 PM, Joaquin Rivera Padron wrote: >> >> hello there, >> how do you tipically spec private methods? The thing is ? have >> something >> like this: >> >> def some_method >> complex_method + other_complex_methods >> end >> >> private >> def complex_method... >> def other_complex_methods ... >> >> and the two complex methods can get really tricky to get right, I >> would like >> to be able to write specs for them, how do you do that? I mean I >> cannot do: >> >> object.some_private_method >> >> You have a few options: >> 1. Make the method public in the object you are testing >> 2. Make the method public in the test case >> 3. Don't test the method >> 4. Use __send__ or (send) to call it. >> 5. Refactor private methods to a new object, and make the methods >> public in >> that object. >> Most of those options suck (esp. 1, 2, 3, & 4) - usually it >> represents a >> design flaw (you are doing too much in your class). >> Scott > > 3 is ok. Yeah, 3 is OK, although ideally you *are* testing the method, albeit indirectly through the public interface. Scott > > A "private" method just means it's an implementation detail that is > outside of your API. If you are aiming to test the behavior of your > API, then you don't care about implementation details. > > -foca > >> >> am I? >> >> thanks in advance, >> joaquin >> >> -- >> www.least-significant-bit.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 From ashley.moran at patchspace.co.uk Wed Oct 14 16:47:10 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Wed, 14 Oct 2009 21:47:10 +0100 Subject: [rspec-users] spec-ing private methods? In-Reply-To: <1fb4df0910141331k5c6c681em1664657da72486a0@mail.gmail.com> References: <8277b7f40910141236w5803d640h5281a88adb649776@mail.gmail.com> <333A6CFB-2CD4-4C28-83BB-0253D6B2A602@railsnewbie.com> <1fb4df0910141331k5c6c681em1664657da72486a0@mail.gmail.com> Message-ID: <896BB8AB-463B-4A3F-AA17-D3E2051A1CE2@patchspace.co.uk> On 14 Oct 2009, at 21:31, Stephen Eley wrote: > I disagree that the simple existence of private methods is a sign of a > design flaw. There are plenty of use cases for which private methods > are the simplest and most practical approach. I use them all the time > to help me deconstruct complicated multi-step actions into shorter, > more atomic chunks of logic. > > > > They're also not usually that complex or brittle. I don't think Scott meant to imply that private methods are bad, only that complex ones private methods are. I use private methods for the same reason you describe above, to break complex actions down into more understandable chunks. When it takes 30 private methods before I can understand the code, that usually indicates there's a problem, and that a new class needs to emerge. (There are usually other signs of this too, though.) Ashley -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran http://aviewfromafar.net/ From matt at mattwynne.net Wed Oct 14 17:33:44 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 14 Oct 2009 22:33:44 +0100 Subject: [rspec-users] spec-ing private methods? In-Reply-To: <333A6CFB-2CD4-4C28-83BB-0253D6B2A602@railsnewbie.com> References: <8277b7f40910141236w5803d640h5281a88adb649776@mail.gmail.com> <333A6CFB-2CD4-4C28-83BB-0253D6B2A602@railsnewbie.com> Message-ID: <0816DDE1-FC41-4898-9440-C45CBAFCD24F@mattwynne.net> On 14 Oct 2009, at 20:49, Scott Taylor wrote: > On Oct 14, 2009, at 3:36 PM, Joaquin Rivera Padron wrote: > >> hello there, >> how do you tipically spec private methods? The thing is ? have >> something like this: > > You have a few options: > > 1. Make the method public in the object you are testing > 2. Make the method public in the test case > 3. Don't test the method > 4. Use __send__ or (send) to call it. > 5. Refactor private methods to a new object, and make the methods > public in that object. > > Most of those options suck (esp. 1, 2, 3, & 4) - usually it > represents a design flaw (you are doing too much in your class). Yup. Sprout class[1] works for me, every single time. [1]http://xunitpatterns.com/Sprout%20Class.html cheers, Matt +447974 430184 matt at mattwynne.net http://mattwynne.net From matt at mattwynne.net Wed Oct 14 17:48:35 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 14 Oct 2009 22:48:35 +0100 Subject: [rspec-users] spec-ing private methods? In-Reply-To: <0816DDE1-FC41-4898-9440-C45CBAFCD24F@mattwynne.net> References: <8277b7f40910141236w5803d640h5281a88adb649776@mail.gmail.com> <333A6CFB-2CD4-4C28-83BB-0253D6B2A602@railsnewbie.com> <0816DDE1-FC41-4898-9440-C45CBAFCD24F@mattwynne.net> Message-ID: <53B3F1DD-95DB-4503-84D2-1EB1ED55288B@mattwynne.net> On 14 Oct 2009, at 22:33, Matt Wynne wrote: > > On 14 Oct 2009, at 20:49, Scott Taylor wrote: > >> On Oct 14, 2009, at 3:36 PM, Joaquin Rivera Padron wrote: >> >>> hello there, >>> how do you tipically spec private methods? The thing is ? have >>> something like this: >> >> You have a few options: >> >> 1. Make the method public in the object you are testing >> 2. Make the method public in the test case >> 3. Don't test the method >> 4. Use __send__ or (send) to call it. >> 5. Refactor private methods to a new object, and make the methods >> public in that object. >> >> Most of those options suck (esp. 1, 2, 3, & 4) - usually it >> represents a design flaw (you are doing too much in your class). > > Yup. Sprout class[1] works for me, every single time. > > [1]http://xunitpatterns.com/Sprout%20Class.html By the way, Sprout Class comes from 'Working Effectively with Legacy Code' (Feathers), which is probably the best book I've read on TDD (Admittedly I've yet to read The RSpec Book). Highly recommended. > cheers, > Matt > > +447974 430184 > matt at mattwynne.net > http://mattwynne.net > cheers, Matt +447974 430184 matt at mattwynne.net http://mattwynne.net From ashley.moran at patchspace.co.uk Wed Oct 14 19:07:25 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Thu, 15 Oct 2009 00:07:25 +0100 Subject: [rspec-users] spec-ing private methods? In-Reply-To: <53B3F1DD-95DB-4503-84D2-1EB1ED55288B@mattwynne.net> References: <8277b7f40910141236w5803d640h5281a88adb649776@mail.gmail.com> <333A6CFB-2CD4-4C28-83BB-0253D6B2A602@railsnewbie.com> <0816DDE1-FC41-4898-9440-C45CBAFCD24F@mattwynne.net> <53B3F1DD-95DB-4503-84D2-1EB1ED55288B@mattwynne.net> Message-ID: On 14 Oct 2009, at 22:48, Matt Wynne wrote: > By the way, Sprout Class comes from 'Working Effectively with Legacy > Code' (Feathers), which is probably the best book I've read on TDD > (Admittedly I've yet to read The RSpec Book). Highly recommended. I've heard good things about this book too. Do you also recommend xUnit Patterns? Bizarrely, I'm including xUnit patterns as a reference in a presentation on mocks I'm giving tomorrow[1], despite never having read it. (Only because I know it contains some mocking definitions I refer to...) Incidentally, the mocking section of the RSpec Book is very good. Which is to say I agree with what it says :) Ashley [1] http://nwrug.org/events/october09/ -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran http://aviewfromafar.net/ From zach.dennis at gmail.com Wed Oct 14 20:06:58 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 14 Oct 2009 20:06:58 -0400 Subject: [rspec-users] spec-ing private methods? In-Reply-To: References: <8277b7f40910141236w5803d640h5281a88adb649776@mail.gmail.com> <333A6CFB-2CD4-4C28-83BB-0253D6B2A602@railsnewbie.com> <0816DDE1-FC41-4898-9440-C45CBAFCD24F@mattwynne.net> <53B3F1DD-95DB-4503-84D2-1EB1ED55288B@mattwynne.net> Message-ID: <85d99afe0910141706gfd88915w681e827e583e6307@mail.gmail.com> On Wed, Oct 14, 2009 at 7:07 PM, Ashley Moran wrote: > > On 14 Oct 2009, at 22:48, Matt Wynne wrote: > >> By the way, Sprout Class comes from 'Working Effectively with Legacy Code' >> (Feathers), which is probably the best book I've read on TDD (Admittedly >> I've yet to read The RSpec Book). Highly recommended. > > > I've heard good things about this book too. ?Do you also recommend xUnit > Patterns? It's been a while since I've read that book. From what I remember it had a lot of great information, but there were many sections I don't find applicable for my coding practices. I think a lot of the typical xUnit styles of testing are heavily influenced from heavier weight languages (like Java for instance). I think that is reflected in much of the material in the book. I did enjoy reading it over a few month period because of the wealth of information, but I would consider many of the techniques dated given where the current state of tools (RSpec and Cucumber), the flexibility of our ruby, and the philosophy of BDD have put us. So if you're looking to read it for immediately applicable techniques I would say don't bother, but if you're an information-whore and want to gain a wealth of knowledge, and want to see a lot of thinking and techniques that have influenced a lot of today's tools and thinking, then read it, for sure, but don't expect to read it in a weekened or even a week... that would be information overload -- your brain would explode. Zach > > Bizarrely, I'm including xUnit patterns as a reference in a presentation on > mocks I'm giving tomorrow[1], despite never having read it. ?(Only because I > know it contains some mocking definitions I refer to...) > > Incidentally, the mocking section of the RSpec Book is very good. ?Which is > to say I agree with what it says :) > > Ashley > > [1] http://nwrug.org/events/october09/ > > -- > http://www.patchspace.co.uk/ > http://www.linkedin.com/in/ashleymoran > http://aviewfromafar.net/ > > > > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) http://ideafoundry.info/behavior-driven-development (first rate BDD training) @zachdennis (twitter) From sfeley at gmail.com Thu Oct 15 11:03:59 2009 From: sfeley at gmail.com (Stephen Eley) Date: Thu, 15 Oct 2009 11:03:59 -0400 Subject: [rspec-users] spec-ing private methods? In-Reply-To: <896BB8AB-463B-4A3F-AA17-D3E2051A1CE2@patchspace.co.uk> References: <8277b7f40910141236w5803d640h5281a88adb649776@mail.gmail.com> <333A6CFB-2CD4-4C28-83BB-0253D6B2A602@railsnewbie.com> <1fb4df0910141331k5c6c681em1664657da72486a0@mail.gmail.com> <896BB8AB-463B-4A3F-AA17-D3E2051A1CE2@patchspace.co.uk> Message-ID: <1fb4df0910150803s147e82a6wff194e9ba9586b0a@mail.gmail.com> On Wed, Oct 14, 2009 at 4:47 PM, Ashley Moran wrote: > > I don't think Scott meant to imply that private methods are bad, only that > complex ones private methods are. This is a good point. I was overgeneralizing the response, despite the question being somewhat more specific. My bad. (It's a worthwhile discussion, though.) -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From sfeley at gmail.com Thu Oct 15 11:06:55 2009 From: sfeley at gmail.com (Stephen Eley) Date: Thu, 15 Oct 2009 11:06:55 -0400 Subject: [rspec-users] spec-ing private methods? In-Reply-To: <88fd8ddc0910150059o61409b44hb619bc40d358800b@mail.gmail.com> References: <8277b7f40910141236w5803d640h5281a88adb649776@mail.gmail.com> <88fd8ddc0910150059o61409b44hb619bc40d358800b@mail.gmail.com> Message-ID: <1fb4df0910150806t7f3743a3p40ddcf7f4bf3a6d0@mail.gmail.com> On Thu, Oct 15, 2009 at 3:59 AM, Andrew Premdas wrote: > > You can take this further and state that no public method should ever do > anything, it should just contain calls to private methods which document how > the public method works. I expect most would consider that going to far ... > sigh Once complexity has been managed, what's the value of that strategy? -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From bcardarella at gmail.com Thu Oct 15 11:25:42 2009 From: bcardarella at gmail.com (Brian Cardarella) Date: Thu, 15 Oct 2009 08:25:42 -0700 (PDT) Subject: [rspec-users] rspec-rails question In-Reply-To: <57c63afe0909280020t34d50869i51051697cb7308f4@mail.gmail.com> References: <860e329d-d1fe-45d2-84b7-a4313408faba@m20g2000vbp.googlegroups.com> <57c63afe0909272005q2644e533vf3dec4ee3a7d24de@mail.gmail.com> <57c63afe0909280020t34d50869i51051697cb7308f4@mail.gmail.com> Message-ID: <0dfa11db-0035-49d8-8a82-11b2b4d6ca09@w19g2000yqk.googlegroups.com> Hey Dave, Sorry I didn't see your last post here until now. I've been using 1.2.9.rc1 for over a month now and it is working great. I haven't noticed any quirks. - Brian On Sep 28, 3:20?am, David Chelimsky wrote: > Glad to hear it. Please let me know how the 1.2.9.rc1 gems are working > otherwise for you. I've gotten zero feedback, positive or negative, on > these release candidate gems and I'd like to do the release sometime > this week. > > Cheers, > David > > On Sun, Sep 27, 2009 at 11:36 PM, BrianCardarella > > > > wrote: > > Excellent, that did the trick. Thanks Dave! > > > On Sep 27, 11:05?pm, David Chelimsky wrote: > >> On Sun, Sep 27, 2009 at 9:10 PM, BrianCardarella wrote: > >> > I have this controller test:http://pastie.org/632880?And the show > >> > method has not been written for the HomeController yet. However, the > >> > test still passes. Why? > > >> Hey Brian, > > >> This is due to a bug that has already been fixed: > > >>https://rspec.lighthouseapp.com/projects/5645/tickets/888 > > >> It is fixed in the 1.2.9.rc1 gems, so if you grab those you should be good: > > >> [sudo] gem install rspec-rails --prerelease > > >> Cheers, > >> David > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From jbrainsberger at gmail.com Thu Oct 15 17:30:37 2009 From: jbrainsberger at gmail.com (J. B. Rainsberger) Date: Thu, 15 Oct 2009 17:30:37 -0400 Subject: [rspec-users] spec-ing private methods? In-Reply-To: <8277b7f40910141236w5803d640h5281a88adb649776@mail.gmail.com> References: <8277b7f40910141236w5803d640h5281a88adb649776@mail.gmail.com> Message-ID: On Wed, Oct 14, 2009 at 15:36, Joaquin Rivera Padron wrote: > hello there, > how do you tipically spec private methods? The thing is ? have something > like this: > > def some_method > ?? complex_method + other_complex_methods > end > > private > def complex_method... > def?other_complex_methods ... > > and the two complex methods can get really tricky to get right, I would like > to be able to write specs for them, how do you do that? I mean I cannot do: > > object.some_private_method > > am I? Hello, Joaquin. I typically make these methods public, then test them. I use the guideline "if it's important enough to test, then it's useful enough to use somewhere else". I usually end up using the method -- or something like it -- somewhere else in my code base, then make it public at that point, anyway. I have also trusted, for a long time, the idea that if I want to test it, but it's private, then I really have a small object trying to grow out of a larger object. I find this especially true when I have three private methods, all related to each other, in the same class. In that case I see the clear signal that a smaller object is getting out, so I let that happen. Of course, not everyone feels comfortable with so many small objects, and not everyone feels comfortable making those methods public. If you don't feel comfortable to do that, then you should look for tricks in Ruby to let you invoke that private method another way. I think someone else suggested using __send__() for that. I strongly prefer not to do that, and when I do, I generally only do it as a first step towards refactoring the code I'm testing. Only you can decide what to do, but if you can't decide, then I highly recommend making the method public, then testing it. If that makes you dislike the design, then create a new class for the method and move it there, making it public. I hope this helps you. -- J. B. (Joe) Rainsberger :: http://www.jbrains.ca :: http://blog.thecodewhisperer.com Diaspar Software Services :: http://www.diasparsoftware.com Author, JUnit Recipes 2005 Gordon Pask Award for contribution to Agile practice :: Agile 2010: Learn. Practice. Explore. From zach.dennis at gmail.com Thu Oct 15 22:42:20 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 15 Oct 2009 22:42:20 -0400 Subject: [rspec-users] spec-ing private methods? In-Reply-To: <8277b7f40910141422i6cfcb13fwa46f121e0bbb4a00@mail.gmail.com> References: <8277b7f40910141236w5803d640h5281a88adb649776@mail.gmail.com> <333A6CFB-2CD4-4C28-83BB-0253D6B2A602@railsnewbie.com> <6A65C952-6B72-4DCE-A398-A2AE770BCAA3@patchspace.co.uk> <8277b7f40910141422i6cfcb13fwa46f121e0bbb4a00@mail.gmail.com> Message-ID: <85d99afe0910151942h3399f610n993e99a587d6259d@mail.gmail.com> Hello Joaquin, On Wed, Oct 14, 2009 at 5:22 PM, Joaquin Rivera Padron wrote: > hello > > 2009/10/14 Ashley Moran >> >> On 14 Oct 2009, at 20:49, Scott Taylor wrote: >>> >>> On Oct 14, 2009, at 3:36 PM, Joaquin Rivera Padron wrote: >>> >>>> private >>>> def complex_method... >>>> def other_complex_methods ... >>>> >>>> and the two complex methods can get really tricky to get right, I would >>>> like to be able to write specs for them, how do you do that? I mean I cannot >>>> do: >>>> >>>> object.some_private_method >>> >>> You have a few options: >>> >>> 1. Make the method public in the object you are testing >>> 2. Make the method public in the test case >>> 3. Don't test the method >>> 4. Use __send__ or (send) to call it. >>> 5. Refactor private methods to a new object, and make the methods public >>> in that object. >>> >>> Most of those options suck (esp. 1, 2, 3, & 4) - usually it represents a >>> design flaw (you are doing too much in your class). >> >> I'm with Scott, this usually indicates a design flaw, and 5 is usually the >> solution. The clue is in the names you gave them - you shouldn't have >> complex methods, especially private ones. >> >> Can you post any of the code so we can see where the complexity/problem >> is? > > hey ashley, > the code itself is not very interesting, it's some fast hacking I'm doing > dumping chess positions into a string, and then the methods given the > character index on that string should translate it to two-dimensional > vectors in the board, boring: mainly math calculations multiplying columns > by some number and adding row numbers and such, and during the spec-ing of > the public method the question arose... I might shift my focus from whether or not these methods should be made public or moved to another class and first make sure I had written examples that focused on the behaviour I was interested in. I have found that having those tend to be a good help when thinking about making private methods public. Even if you find you don't need these methods to be public you will find the examples afford you a great deal of freedom to refactor that code in a number of ways or by simply leaving them as private methods all while leaving the examples intact. > > and yeah, I think 5 it my favorite at the moment, > they don't have to be > private anyway, also IMHO testing private methods through the public API > it's not in general applicable (only thinking here, no code sample)... > > but anyway I wanted to hear what you guys think about it Behaviour first. That will help you identify if you're dealing with different responsibilities which might push you to extract a new object, or if you're dealing with logic that goes together (in which you might keep well-named private methods), or if you want to pull out some of the dry and boring math calculations out into a method on some utility class. If you put good examples in place you'll be able to change your mind later without having to maintain *brittle* specs while having a great deal of freedom for re-organizing the implementation in a number of imaginable ways. -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) http://ideafoundry.info/behavior-driven-development (first rate BDD training) @zachdennis (twitter) From elza.morelli at tagview.com.br Fri Oct 16 00:25:46 2009 From: elza.morelli at tagview.com.br (Elza) Date: Thu, 15 Oct 2009 21:25:46 -0700 (PDT) Subject: [rspec-users] Help me with Controllers spec Message-ID: <25919605.post@talk.nabble.com> I am starting with Rspec and I am having some errors in the Get/index Can someone help me with this? describe BrandsController, 'GET /index' do ############################################################## should_require_login :get, :index ############################################################## describe "authenticated user" do ############################################################## before do login_as_user @brands = mock_model(Brand) @brands.stub!(:paginate).and_return(@brands) end ############################################################## def do_get get :index end ############################################################## it 'should load the brands' do @brands.should_receive(:paginate).with( :conditions => {:active => 'true'}, :order =>'brands.name' ).and_return(@brands) do_get assigns[:brands].should == @brands end end end ************************************ My controller is def index # Build the SQL conditions object based on the parameters received. conditions = Sql::Conditions.new conditions.and('name LIKE ?', "%#{get_param(:name)}%") if get_param(:name) conditions.and('active = ?', true) if !get_param(:include_inactive, :boolean) @brands = Brand.paginate( :conditions => conditions.to_sql, :order => build_sort_conditions(:name, true), :page => get_param(:page, :integer), :per_page => 10 ) end ************************************************ The error is 'BrandsController GET /index authenticated user should load the brands' FAILED expected: #, got: [] (using ==) -- View this message in context: http://www.nabble.com/Help-me-with-Controllers-spec-tp25919605p25919605.html Sent from the rspec-users mailing list archive at Nabble.com. From matt at mattwynne.net Fri Oct 16 03:42:29 2009 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 16 Oct 2009 08:42:29 +0100 Subject: [rspec-users] Help me with Controllers spec In-Reply-To: <25919605.post@talk.nabble.com> References: <25919605.post@talk.nabble.com> Message-ID: <5396527B-285C-4E77-9FB7-E0DABD3E4FE8@mattwynne.net> You're getting mixed up between stubbing the methods on the class (Brand) and the instance (Brand.new) Try the corrections below: On 16 Oct 2009, at 05:25, Elza wrote: > > I am starting with Rspec and I am having some errors in the Get/index > Can someone help me with this? > > describe BrandsController, 'GET /index' do > ############################################################## > should_require_login :get, :index > ############################################################## > describe "authenticated user" do > ############################################################## > before do > login_as_user > @brands = mock_model(Brand) @brand = mock_model(Brand) @brands = [@brand] > @brands.stub!(:paginate).and_return(@brands) Brand.stub!(:paginate).and_return(@brands) > end > ############################################################## > def do_get > get :index > end > > ############################################################## > it 'should load the brands' do > @brands.should_receive(:paginate).with( Brand.should_receive(:paginate).with( > :conditions => {:active => 'true'}, > :order =>'brands.name' > ).and_return(@brands) > > do_get > > assigns[:brands].should == @brands > end > end > end > ************************************ > My controller is > def index > # Build the SQL conditions object based on the parameters received. > conditions = Sql::Conditions.new > conditions.and('name LIKE ?', "%#{get_param(:name)}%") if > get_param(:name) > conditions.and('active = ?', true) > if !get_param(:include_inactive, :boolean) > > @brands = > Brand.paginate( > :conditions => conditions.to_sql, > :order => build_sort_conditions(:name, true), > :page => get_param(:page, :integer), > :per_page => 10 > ) > end > ************************************************ > > The error is > > 'BrandsController GET /index authenticated user should load the > brands' > FAILED > expected: #, > got: [] (using ==) > -- > View this message in context: http://www.nabble.com/Help-me-with-Controllers-spec-tp25919605p25919605.html > Sent from the rspec-users mailing list archive at Nabble.com. By the way, a more general comment if you don't mind me offering it, is that building SQL like this in a controller is considered a bit of an anti-pattern. You would be better off (and, funnily enough, find the mocks a lot easier to write) if you dreamed up a new method on Brand, something like Brand.paginage_for_name and pushed the logic that builds the SQL conditions down into the model. cheers, Matt +447974 430184 matt at mattwynne.net http://mattwynne.net From lists at ruby-forum.com Fri Oct 16 08:21:10 2009 From: lists at ruby-forum.com (Sergey Rogachev) Date: Fri, 16 Oct 2009 14:21:10 +0200 Subject: [rspec-users] How to write a correct RSpec for Polymorphic Association Message-ID: <440d15776238db3cba7cb50579d495aa@ruby-forum.com> I don't know what is need to set in the variable ADDRESSES: Organization.stub!(:find_by_id).with("100").and_return(mock_organization(:id => "100", :addresses => ??? )) Somebody help me. Any ideas? I tried to find the solution of problem but I can't. --- rspec - controllers def mock_organization(stubs={}) @parent_object ||= mock_model(Organization, stubs) end it "assigns a newly created address as @address" do Organization.stub!(:find_by_id).with("100").and_return( mock_organization(:id => "100", :addresses => ??? )) <