From lists at ruby-forum.com Thu Jan 1 06:31:17 2009 From: lists at ruby-forum.com (Jesse Crockett) Date: Thu, 1 Jan 2009 12:31:17 +0100 Subject: [rspec-users] My first tests, backwards. Please help In-Reply-To: References: <1ebf5a4d0812301643t356fb558rcc1ab2385b621797@mail.gmail.com> <57c63afe0812310718t2b4c85bx310e517be4bf1e54@mail.gmail.com> Message-ID: Jesse Crockett wrote: > I hope to be on my feet after a few more basic questions.. I'm sorry, but this is beginning to feel like kicking myself in the head. === here is what I'm working with http://github.com/fudgestudios/bort/tree/master === Errors FF 1) NoMethodError in 'bidding on an item should be allowed with a credit' You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.new_record? spec/controllers/auction_controller_spec.rb:23: spec/controllers/auction_controller_spec.rb:6: 2) NoMethodError in 'bidding on an item should require a credit' You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.new_record? spec/controllers/auction_controller_spec.rb:17: spec/controllers/auction_controller_spec.rb:6: Finished in 0.074996 seconds 2 examples, 2 failures === here is my controller action def bid @bid = Bid.new(params[:bid]) @bid.save end === here is my test require File.dirname(__FILE__) + '/../spec_helper' include ApplicationHelper include UsersHelper include AuthenticatedTestHelper describe "bidding on an item" do controller_name :items before(:each) do @user = mock_user stub!(:current_user).and_return(@user) end it "should require a credit" do @user.stub!(:credits).and_return(0) post 'bid', :bid => { :auction_id => 1, :user_id => @user.id, :point => 1 } assigns[:bid].should_not be_new_record end it "should be allowed with a credit" do @user.stub!(:credits).and_return(1) post 'bid', :bid => { :auction_id => 1, :user_id => @user.id, :point => 1 } assigns[:bid].should be_new_record end end === spec_helper http://github.com/fudgestudios/bort/tree/master/spec/spec_helper.rb It's very disheartening to wake for work at 3 a.m. and accomplish nothing for the day. Please understand. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu Jan 1 12:24:27 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 1 Jan 2009 11:24:27 -0600 Subject: [rspec-users] My first tests, backwards. Please help In-Reply-To: References: <1ebf5a4d0812301643t356fb558rcc1ab2385b621797@mail.gmail.com> <57c63afe0812310718t2b4c85bx310e517be4bf1e54@mail.gmail.com> Message-ID: <57c63afe0901010924y106590b4v34395ee8fe285083@mail.gmail.com> On Thu, Jan 1, 2009 at 5:31 AM, Jesse Crockett wrote: > Jesse Crockett wrote: >> I hope to be on my feet after a few more basic questions.. > > I'm sorry, but this is beginning to feel like kicking myself in the > head. > > === here is what I'm working with > http://github.com/fudgestudios/bort/tree/master > > === Errors > FF > > 1) > NoMethodError in 'bidding on an item should be allowed with a credit' > You have a nil object when you didn't expect it! > You might have expected an instance of ActiveRecord::Base. > The error occurred while evaluating nil.new_record? > spec/controllers/auction_controller_spec.rb:23: > spec/controllers/auction_controller_spec.rb:6: > > 2) > NoMethodError in 'bidding on an item should require a credit' > You have a nil object when you didn't expect it! > You might have expected an instance of ActiveRecord::Base. > The error occurred while evaluating nil.new_record? > spec/controllers/auction_controller_spec.rb:17: > spec/controllers/auction_controller_spec.rb:6: > > Finished in 0.074996 seconds > > 2 examples, 2 failures > > > === here is my controller action > > def bid > > @bid = Bid.new(params[:bid]) > @bid.save > > end > > === here is my test > > require File.dirname(__FILE__) + '/../spec_helper' > include ApplicationHelper > include UsersHelper > include AuthenticatedTestHelper > > describe "bidding on an item" do > controller_name :items > > before(:each) do > @user = mock_user > stub!(:current_user).and_return(@user) Calling stub! with no receiver means it's being called on the example itself. Assuming you're using RestfulAuth, you'll want this to be on the controller itself: controller.stub!(:current_user).and_return(@user) Although, looking at the 'bid' action, it doesn't appear to be doing anything with the user yet, so I'm not sure why this is here at this point. > end > > it "should require a credit" do > @user.stub!(:credits).and_return(0) > post 'bid', :bid => { :auction_id => 1, :user_id => @user.id, :point > => 1 } If you're using the mock_user, which uses mock_model (I'm assuming here, since you're not posting complete files), > assigns[:bid].should_not be_new_record I'm guessing this is line 17 and the "assigns[:bid] line below is 23. What this means is that assigns[:bid] is nil, which means that somehow the action is failing to generate the bit object. I'm at a bit of a loss as to why that might be, but that's what is indicated. HTH, David > end > > it "should be allowed with a credit" do > @user.stub!(:credits).and_return(1) > post 'bid', :bid => { :auction_id => 1, :user_id => @user.id, :point > => 1 } > assigns[:bid].should be_new_record > end > > end > > === spec_helper > http://github.com/fudgestudios/bort/tree/master/spec/spec_helper.rb > > It's very disheartening to wake for work at 3 a.m. and accomplish > nothing for the day. Please understand. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Thu Jan 1 12:32:30 2009 From: lists at ruby-forum.com (Jesse Crockett) Date: Thu, 1 Jan 2009 18:32:30 +0100 Subject: [rspec-users] My first tests, backwards. Please help In-Reply-To: <57c63afe0901010924y106590b4v34395ee8fe285083@mail.gmail.com> References: <1ebf5a4d0812301643t356fb558rcc1ab2385b621797@mail.gmail.com> <57c63afe0812310718t2b4c85bx310e517be4bf1e54@mail.gmail.com> <57c63afe0901010924y106590b4v34395ee8fe285083@mail.gmail.com> Message-ID: I've finally made some progress thanks to Otto at stackoverflow. I'm very exited. Thanks so much for trying to help. If you've got a minute, please browse my question and Otto's answer, and correct me if I seem to be going in the wrong direction. http://stackoverflow.com/questions/404887 Yee haw, my first passing spec! -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu Jan 1 12:48:22 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 1 Jan 2009 11:48:22 -0600 Subject: [rspec-users] My first tests, backwards. Please help In-Reply-To: References: <1ebf5a4d0812301643t356fb558rcc1ab2385b621797@mail.gmail.com> <57c63afe0812310718t2b4c85bx310e517be4bf1e54@mail.gmail.com> <57c63afe0901010924y106590b4v34395ee8fe285083@mail.gmail.com> Message-ID: <57c63afe0901010948s4f0d551fl1a735a6abbcfba82@mail.gmail.com> On Thu, Jan 1, 2009 at 11:32 AM, Jesse Crockett wrote: > I've finally made some progress thanks to Otto at stackoverflow. I'm > very exited. Thanks so much for trying to help. If you've got a > minute, please browse my question and Otto's answer, and correct me if I > seem to be going in the wrong direction. > > http://stackoverflow.com/questions/404887 I responded there to keep things in context. Cheers, David > > Yee haw, my first passing spec! > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mark at markrichman.com Thu Jan 1 14:40:34 2009 From: mark at markrichman.com (Mark A. Richman) Date: Thu, 1 Jan 2009 14:40:34 -0500 Subject: [rspec-users] MockExpectationError with restful-authentication In-Reply-To: <810a540e0812311143u174d6526t7b36fae9e47fb369@mail.gmail.com> References: <810a540e0812311143u174d6526t7b36fae9e47fb369@mail.gmail.com> Message-ID: Thanks that helped! Now I'm getting these errors...any ideas? Looks like something cookie related? http://pastie.org/350148 On Wed, Dec 31, 2008 at 2:43 PM, Pat Maddox wrote: > You didn't tell your mock object about the enabled? method. You need > to stub it out (prob set it to true) > > Pat > > > On 12/31/08, Mark A. Richman wrote: > > Hi there...this is my first time using rspec and rspec-rails. When I run > > `rake spec`, I get this type of error over and over...what does it mean, > and > > how can I correct it? > > > > Thanks, > > Mark > > > > 9) > > Spec::Mocks::MockExpectationError in 'SessionController on successful > login, > > my request cookie token is valid, and ask not to be remembered sets an > auth > > cookie' > > Mock 'User_1' received unexpected message :enabled? with (no args) > > > /Users/mark/rails_apps/ExamRoom/app/controllers/session_controller.rb:14:in > > `create' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in > > `send' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in > > `perform_action_without_filters' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in > > `call_filters' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in > > `perform_action_without_benchmark' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in > > `perform_action_without_rescue' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in > > `perform_action_without_rescue' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/rescue.rb:136:in > > `perform_action_without_caching' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:13:in > > `perform_action' > > > /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in > > `cache' > > > /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/query_cache.rb:8:in > > `cache' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:12:in > > `perform_action' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in > > `send' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in > > `process_without_filters' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:606:in > > `process_without_session_management_support' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/session_management.rb:134:in > > `process_without_test' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:18:in > > `process' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:407:in > > `process' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:376:in > > `post' > > ./spec/controllers/session_controller_spec.rb:15:in `do_create' > > ./spec/controllers/session_controller_spec.rb:55: > > > _______________________________________________ > 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 dchelimsky at gmail.com Fri Jan 2 05:00:52 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 2 Jan 2009 04:00:52 -0600 Subject: [rspec-users] MockExpectationError with restful-authentication In-Reply-To: References: <810a540e0812311143u174d6526t7b36fae9e47fb369@mail.gmail.com> Message-ID: <57c63afe0901020200m2602cf0fm27a661bf27ecf6d1@mail.gmail.com> On Thu, Jan 1, 2009 at 1:40 PM, Mark A. Richman wrote: > Thanks that helped! Now I'm getting these errors...any ideas? Looks like > something cookie related? > > http://pastie.org/350148 Only the first 2 look cookie related to me. The rest seem like typos - either things that you changed after generating the restful auth material (like redirecting to "/dashboard" instead of "/") or perhaps there are typos in the generated specs ("session" vs "sessions"). In most of these cases, you should be able to see from the failure messages what the discrepancies are and you just need to choose whether the specs are correct or the code is correct and adjust appropriately. HTH, David > > On Wed, Dec 31, 2008 at 2:43 PM, Pat Maddox wrote: >> >> You didn't tell your mock object about the enabled? method. You need >> to stub it out (prob set it to true) >> >> Pat >> >> >> On 12/31/08, Mark A. Richman wrote: >> > Hi there...this is my first time using rspec and rspec-rails. When I run >> > `rake spec`, I get this type of error over and over...what does it mean, >> > and >> > how can I correct it? >> > >> > Thanks, >> > Mark >> > >> > 9) >> > Spec::Mocks::MockExpectationError in 'SessionController on successful >> > login, >> > my request cookie token is valid, and ask not to be remembered sets an >> > auth >> > cookie' >> > Mock 'User_1' received unexpected message :enabled? with (no args) >> > >> > /Users/mark/rails_apps/ExamRoom/app/controllers/session_controller.rb:14:in >> > `create' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in >> > `send' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in >> > `perform_action_without_filters' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in >> > `call_filters' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in >> > `perform_action_without_benchmark' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in >> > `perform_action_without_rescue' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in >> > `perform_action_without_rescue' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/rescue.rb:136:in >> > `perform_action_without_caching' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:13:in >> > `perform_action' >> > >> > /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in >> > `cache' >> > >> > /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/query_cache.rb:8:in >> > `cache' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:12:in >> > `perform_action' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in >> > `send' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in >> > `process_without_filters' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:606:in >> > `process_without_session_management_support' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/session_management.rb:134:in >> > `process_without_test' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:18:in >> > `process' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:407:in >> > `process' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:376:in >> > `post' >> > ./spec/controllers/session_controller_spec.rb:15:in `do_create' >> > ./spec/controllers/session_controller_spec.rb:55: >> > >> _______________________________________________ >> 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 mark at markrichman.com Fri Jan 2 06:52:20 2009 From: mark at markrichman.com (Mark A. Richman) Date: Fri, 2 Jan 2009 06:52:20 -0500 Subject: [rspec-users] MockExpectationError with restful-authentication In-Reply-To: <57c63afe0901020200m2602cf0fm27a661bf27ecf6d1@mail.gmail.com> References: <810a540e0812311143u174d6526t7b36fae9e47fb369@mail.gmail.com> <57c63afe0901020200m2602cf0fm27a661bf27ecf6d1@mail.gmail.com> Message-ID: Thanks! That seems to have knocked out all but 4 errors. I'll keep banging away...this is fun! :) Best, Mark On Fri, Jan 2, 2009 at 5:00 AM, David Chelimsky wrote: > On Thu, Jan 1, 2009 at 1:40 PM, Mark A. Richman > wrote: > > Thanks that helped! Now I'm getting these errors...any ideas? Looks like > > something cookie related? > > > > http://pastie.org/350148 > > Only the first 2 look cookie related to me. The rest seem like typos - > either things that you changed after generating the restful auth > material (like redirecting to "/dashboard" instead of "/") or perhaps > there are typos in the generated specs ("session" vs "sessions"). > > In most of these cases, you should be able to see from the failure > messages what the discrepancies are and you just need to choose > whether the specs are correct or the code is correct and adjust > appropriately. > > HTH, > David > > > > > On Wed, Dec 31, 2008 at 2:43 PM, Pat Maddox wrote: > >> > >> You didn't tell your mock object about the enabled? method. You need > >> to stub it out (prob set it to true) > >> > >> Pat > >> > >> > >> On 12/31/08, Mark A. Richman wrote: > >> > Hi there...this is my first time using rspec and rspec-rails. When I > run > >> > `rake spec`, I get this type of error over and over...what does it > mean, > >> > and > >> > how can I correct it? > >> > > >> > Thanks, > >> > Mark > >> > > >> > 9) > >> > Spec::Mocks::MockExpectationError in 'SessionController on successful > >> > login, > >> > my request cookie token is valid, and ask not to be remembered sets an > >> > auth > >> > cookie' > >> > Mock 'User_1' received unexpected message :enabled? with (no args) > >> > > >> > > /Users/mark/rails_apps/ExamRoom/app/controllers/session_controller.rb:14:in > >> > `create' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in > >> > `send' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in > >> > `perform_action_without_filters' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in > >> > `call_filters' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in > >> > `perform_action_without_benchmark' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in > >> > `perform_action_without_rescue' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in > >> > `perform_action_without_rescue' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/rescue.rb:136:in > >> > `perform_action_without_caching' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:13:in > >> > `perform_action' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in > >> > `cache' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/query_cache.rb:8:in > >> > `cache' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:12:in > >> > `perform_action' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in > >> > `send' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in > >> > `process_without_filters' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:606:in > >> > `process_without_session_management_support' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/session_management.rb:134:in > >> > `process_without_test' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:18:in > >> > `process' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:407:in > >> > `process' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:376:in > >> > `post' > >> > ./spec/controllers/session_controller_spec.rb:15:in `do_create' > >> > ./spec/controllers/session_controller_spec.rb:55: > >> > > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rubyphunk at googlemail.com Fri Jan 2 09:54:06 2009 From: rubyphunk at googlemail.com (rubyphunk) Date: Fri, 2 Jan 2009 06:54:06 -0800 (PST) Subject: [rspec-users] [ANN] RSpactor 1.0.1 Message-ID: <122b3d65-2454-4139-81db-30e2b9eabb9d@u18g2000pro.googlegroups.com> Hi all, I'm happy to announce the first public RSpactor release 1.0.1. RSpactor is an autotest/autospec like Mac OS X 10.5 gui application that takes care of your rspec examples. It watches for changes and runs these files. You can download 1.0.1 here: http://rspactorapp.com/assets/downloads/rspactor-1_0_1.dmg Read the blog post for more information: http://rubyphunk.com/articles/2009/01/02/happy-new-year-rspactor-1-0-1 lg // andreas From nas35_in at yahoo.com Fri Jan 2 11:01:29 2009 From: nas35_in at yahoo.com (Nasir Jamal) Date: Fri, 2 Jan 2009 08:01:29 -0800 (PST) Subject: [rspec-users] How to spec a controller method that involves an rjs redirect Message-ID: <190728.50003.qm@web38004.mail.mud.yahoo.com> Hi everyone, What is the best way to spec a controller method that involves an rjs redirect? Something like this def index ? url_to = @parent ? auction_bids_path(@parent)? : auctions_path ? render :update do |page| ??? page.redirect_to(url_to) ? end end I tried ?response.should have_rjs for the redirect but it didnt work. Any help would be appreciated. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From cougar2149 at gmail.com Fri Jan 2 12:54:11 2009 From: cougar2149 at gmail.com (waseem ahmad) Date: Fri, 2 Jan 2009 23:24:11 +0530 Subject: [rspec-users] How to write specs for already written parts of an application? Message-ID: Hi, What should be my approach to write specs for the parts of an applications which are already written? How should I start writing tests for those models, controllers which were not generated using rspec_controller or rspec_model? Would you please point me to some tutorials for writing RSpec tests? Is there any IRC channel for RSpec users? -- Waseem RwrWrwRwrWrwRwrWrwRwrWrwRwwwwwwww............ Blog: http://babygnu.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Fri Jan 2 13:02:57 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 2 Jan 2009 12:02:57 -0600 Subject: [rspec-users] How to write specs for already written parts of an application? In-Reply-To: References: Message-ID: <57c63afe0901021002p62db2450w411c13b2ddf542a5@mail.gmail.com> On Fri, Jan 2, 2009 at 11:54 AM, waseem ahmad wrote: > Hi, > What should be my approach to write specs for the parts of an applications > which are already written? How should I start writing tests for those > models, controllers which were not generated using rspec_controller or > rspec_model? Would you please point me to some tutorials for writing RSpec > tests? Is there any IRC channel for RSpec users? #rspec on freenode Check out Michael Feathers' Working Effectively with Legacy Code for learning how to get untested apps under test. General idea is to do it gradually over time. When you have a new requirement, figure out what code needs to change to add that requirement, and write characterization tests (high level tests using a tool like Cucumber) that characterize what the application already does. The WELC book provides strategies for determining which tests to add, but the idea is to add the least number of tests to cover the code you want to change, so when you start changing it you have confidence you're not breaking things. Once you have the characterization tests in place, then you drive out the new code using TDD. HTH, David > > -- > Waseem > RwrWrwRwrWrwRwrWrwRwrWrwRwwwwwwww............ > Blog: http://babygnu.blogspot.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From seatmanu at gmail.com Fri Jan 2 13:20:12 2009 From: seatmanu at gmail.com (Emmanuel Pinault) Date: Fri, 2 Jan 2009 10:20:12 -0800 Subject: [rspec-users] Cucumber namespace problem Message-ID: <3A058CB2-78FF-438A-9BBA-FD01376E118F@gmail.com> Hi I am having an issue with Cucumber where I am writing in one files some steps where rspec matcher do not seem to be accessible. So I have a file with my steps written like this require 'steputils' Given "some step description 1 " do SomeClass.post(args) end Given "some step description 2 that is slighty different for better readability " do SomeClass.post(args) end and in steputils I have class Steputils def self.post(args) args.should_not be_empty end end But the code breaks when trying to run args.should_not be_empty that are valid rspec matchers.. Seems like it is not recognizing it. I tried to include Cucumber and Spec as part of my class but still not working. Any idea what I need to do to make it work? This will help refactoring some of the steps that may have similar code Also, is there a way to see all the existing step using the cucumber methods? because when you have a lot it would be nice to have a way to describe them for documentation purpose (like Rake does for task) Thanks Emmanuel From aslak.hellesoy at gmail.com Fri Jan 2 13:34:58 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 2 Jan 2009 19:34:58 +0100 Subject: [rspec-users] Cucumber namespace problem In-Reply-To: <3A058CB2-78FF-438A-9BBA-FD01376E118F@gmail.com> References: <3A058CB2-78FF-438A-9BBA-FD01376E118F@gmail.com> Message-ID: <8d961d900901021034i377970cdp68e7ed619749fd02@mail.gmail.com> On Fri, Jan 2, 2009 at 7:20 PM, Emmanuel Pinault wrote: > Hi > > I am having an issue with Cucumber where I am writing in one files some > steps where rspec matcher do not seem to be accessible. > > So I have a file with my steps written like this > > require 'steputils' > > Given "some step description 1 " do > SomeClass.post(args) > end > > Given "some step description 2 that is slighty different for better > readability " do > SomeClass.post(args) > end > > > and in steputils I have > > class Steputils > > def self.post(args) > args.should_not be_empty > end > end > > > But the code breaks when trying to run args.should_not be_empty that are > valid rspec matchers.. Seems like it is not recognizing it. I tried to > include Cucumber and Spec as part of my class Please post the full error message and backtrace. Did you require 'spec' in your support/env.rb file? Aslak > > but still not working. Any idea what I need to do to make it work? This > will help refactoring some of the steps that may have similar code > > Also, is there a way to see all the existing step using the cucumber > methods? because when you have a lot it would be nice to have a way to > describe them for documentation purpose (like Rake does for task) > > Thanks > > Emmanuel > > > > > > _______________________________________________ > 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 peter.a.jaros at gmail.com Fri Jan 2 13:45:28 2009 From: peter.a.jaros at gmail.com (Peter Jaros) Date: Fri, 2 Jan 2009 13:45:28 -0500 Subject: [rspec-users] Cucumber namespace problem In-Reply-To: <3A058CB2-78FF-438A-9BBA-FD01376E118F@gmail.com> References: <3A058CB2-78FF-438A-9BBA-FD01376E118F@gmail.com> Message-ID: <937d9d810901021045h1ebe10c4i9925ff7215975917@mail.gmail.com> On Fri, Jan 2, 2009 at 1:20 PM, Emmanuel Pinault wrote: > So I have a file with my steps written like this > > require 'steputils' > > Given "some step description 1 " do > SomeClass.post(args) > end > > Given "some step description 2 that is slighty different for better > readability " do > SomeClass.post(args) > end > > > and in steputils I have > > class Steputils > > def self.post(args) > args.should_not be_empty > end > end Is that code right? It looks to me like Steputils.post is never getting called. You're calling SomeClass.post instead. Peter From seatmanu at gmail.com Fri Jan 2 14:01:21 2009 From: seatmanu at gmail.com (Emmanuel Pinault) Date: Fri, 2 Jan 2009 11:01:21 -0800 Subject: [rspec-users] Cucumber namespace problem In-Reply-To: <8d961d900901021034i377970cdp68e7ed619749fd02@mail.gmail.com> References: <3A058CB2-78FF-438A-9BBA-FD01376E118F@gmail.com> <8d961d900901021034i377970cdp68e7ed619749fd02@mail.gmail.com> Message-ID: <6816A2A0-8387-4209-93C4-0A54D44F2AD1@gmail.com> I think I found a solution to my problem. in the Steputils class, instead of including, I perform an extend on Spec::Matcher so my class look like > > class Steputils > extend Spec::Matchers > def self.post(args) > args.should_not be_empty > end > end Now all the Matcher are visible in my class and tests are running fine again Thanks Emmanuel On Jan 2, 2009, at 10:34 AM, aslak hellesoy wrote: > > > On Fri, Jan 2, 2009 at 7:20 PM, Emmanuel Pinault > wrote: > Hi > > I am having an issue with Cucumber where I am writing in one files > some steps where rspec matcher do not seem to be accessible. > > So I have a file with my steps written like this > > require 'steputils' > > Given "some step description 1 " do > SomeClass.post(args) > end > > Given "some step description 2 that is slighty different for better > readability " do > SomeClass.post(args) > end > > > and in steputils I have > > class Steputils > > def self.post(args) > args.should_not be_empty > end > end > > > But the code breaks when trying to run args.should_not be_empty that > are valid rspec matchers.. Seems like it is not recognizing it. I > tried to include Cucumber and Spec as part of my class > > Please post the full error message and backtrace. > > Did you require 'spec' in your support/env.rb file? > > Aslak > > > but still not working. Any idea what I need to do to make it work? > This will help refactoring some of the steps that may have similar > code > > Also, is there a way to see all the existing step using the cucumber > methods? because when you have a lot it would be nice to have a way > to describe them for documentation purpose (like Rake does for task) > > Thanks > > Emmanuel > > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From seatmanu at gmail.com Fri Jan 2 14:03:03 2009 From: seatmanu at gmail.com (Emmanuel Pinault) Date: Fri, 2 Jan 2009 11:03:03 -0800 Subject: [rspec-users] Cucumber namespace problem In-Reply-To: <937d9d810901021045h1ebe10c4i9925ff7215975917@mail.gmail.com> References: <3A058CB2-78FF-438A-9BBA-FD01376E118F@gmail.com> <937d9d810901021045h1ebe10c4i9925ff7215975917@mail.gmail.com> Message-ID: Sorry, I made up the example to explain my problem but yes, it should be Steputils. post in each of the steps. But the problem was calling a spec matcher within that class. My solution to get it i to work is to extend my class with Spec::Matcher Thanks Emmanuel On Jan 2, 2009, at 10:45 AM, Peter Jaros wrote: > On Fri, Jan 2, 2009 at 1:20 PM, Emmanuel Pinault > wrote: > >> So I have a file with my steps written like this >> >> require 'steputils' >> >> Given "some step description 1 " do >> SomeClass.post(args) >> end >> >> Given "some step description 2 that is slighty different for better >> readability " do >> SomeClass.post(args) >> end >> >> >> and in steputils I have >> >> class Steputils >> >> def self.post(args) >> args.should_not be_empty >> end >> end > > Is that code right? It looks to me like Steputils.post is never > getting called. You're calling SomeClass.post instead. > > Peter > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From wycats at gmail.com Fri Jan 2 14:29:04 2009 From: wycats at gmail.com (Yehuda Katz) Date: Fri, 2 Jan 2009 11:29:04 -0800 (PST) Subject: [rspec-users] Testing Framework Survey Message-ID: <1b4105b6-5a3c-4879-80f0-f3efc8546c03@r37g2000prr.googlegroups.com> In the interest of collecting some demographic information on the Rails community, Matt (Aimonetti, Rails evangelist) put together a poll of testing framework usage. Please vote at http://twtpoll.com/zhh2fm. Thanks! From aidy.lewis at googlemail.com Fri Jan 2 15:04:57 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Fri, 2 Jan 2009 20:04:57 +0000 Subject: [rspec-users] Cucumber namespace problem In-Reply-To: <8d961d900901021034i377970cdp68e7ed619749fd02@mail.gmail.com> References: <3A058CB2-78FF-438A-9BBA-FD01376E118F@gmail.com> <8d961d900901021034i377970cdp68e7ed619749fd02@mail.gmail.com> Message-ID: <7ac2300c0901021204k567b9ab2gb2fa150e5e6f97ca@mail.gmail.com> Hi Aslak, 2009/1/2 aslak hellesoy : > Did you require 'spec' in your support/env.rb file? Is it now a standard to put the env.rb in the 'support' folder? Mine is in the 'steps' folder? Regards Aidy From dchelimsky at gmail.com Fri Jan 2 15:11:23 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 2 Jan 2009 14:11:23 -0600 Subject: [rspec-users] Cucumber namespace problem In-Reply-To: <7ac2300c0901021204k567b9ab2gb2fa150e5e6f97ca@mail.gmail.com> References: <3A058CB2-78FF-438A-9BBA-FD01376E118F@gmail.com> <8d961d900901021034i377970cdp68e7ed619749fd02@mail.gmail.com> <7ac2300c0901021204k567b9ab2gb2fa150e5e6f97ca@mail.gmail.com> Message-ID: <57c63afe0901021211q248a0047ua121db3cd6da3f19@mail.gmail.com> On Fri, Jan 2, 2009 at 2:04 PM, aidy lewis wrote: > Hi Aslak, > > 2009/1/2 aslak hellesoy : > >> Did you require 'spec' in your support/env.rb file? > > Is it now a standard to put the env.rb in the 'support' folder? Mine > is in the 'steps' folder? That's the direction, yes. features/step_definitions #for step definitions features/support #for everything else > > Regards > > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Fri Jan 2 15:19:18 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 2 Jan 2009 21:19:18 +0100 Subject: [rspec-users] Cucumber namespace problem In-Reply-To: <57c63afe0901021211q248a0047ua121db3cd6da3f19@mail.gmail.com> References: <3A058CB2-78FF-438A-9BBA-FD01376E118F@gmail.com> <8d961d900901021034i377970cdp68e7ed619749fd02@mail.gmail.com> <7ac2300c0901021204k567b9ab2gb2fa150e5e6f97ca@mail.gmail.com> <57c63afe0901021211q248a0047ua121db3cd6da3f19@mail.gmail.com> Message-ID: <8d961d900901021219x122c3898rabc6b1797905c233@mail.gmail.com> On Fri, Jan 2, 2009 at 9:11 PM, David Chelimsky wrote: > On Fri, Jan 2, 2009 at 2:04 PM, aidy lewis > wrote: > > Hi Aslak, > > > > 2009/1/2 aslak hellesoy : > > > >> Did you require 'spec' in your support/env.rb file? > > > > Is it now a standard to put the env.rb in the 'support' folder? Mine > > is in the 'steps' folder? > You can keep it wherever you want, but a recent new feature is that ruby files in the support dir get loaded before any other dir. This is needed in some cases. See History.txt on GitHub. > > That's the direction, yes. > > features/step_definitions #for step definitions > features/support #for everything else > > > > > > > Regards > > > > Aidy > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Sat Jan 3 02:07:45 2009 From: lists at ruby-forum.com (Sebastian W.) Date: Sat, 3 Jan 2009 08:07:45 +0100 Subject: [rspec-users] Getting heckled by Heckle? Message-ID: <4837fa5000068804cbdea858f10b6af5@ruby-forum.com> Hello RSpec folks, I'm not sure if I'm doing something wrong with the Heckle integration in RSpec? I go to heckle my spec, and everything seems to start out okay. But then something weird happens: 3 mutations remaining... 2 mutations remaining... 1 mutations remaining... 1 mutations remaining... 1 mutations remaining... 1 mutations remaining... 1 mutations remaining... 1 mutations remaining... 1 mutations remaining... #repeat the above line forever... I've tried waiting to see if I just need to be patient, but Heckle never seems to exit. FWIW, I'm running my spec in the following manner: spec --heckle Seeker seeker_spec.rb And as you may guess, the name of my class is "Seeker". Any thoughts? -- Posted via http://www.ruby-forum.com/. From wycats at gmail.com Sat Jan 3 03:31:20 2009 From: wycats at gmail.com (Yehuda Katz) Date: Sat, 3 Jan 2009 00:31:20 -0800 Subject: [rspec-users] Getting heckled by Heckle? In-Reply-To: <4837fa5000068804cbdea858f10b6af5@ruby-forum.com> References: <4837fa5000068804cbdea858f10b6af5@ruby-forum.com> Message-ID: <245fb4700901030031o5ffdae18i8aeea59590bf41b@mail.gmail.com> There is more than 1 bug in Heckle that can produce this behavior. Tim Carey Smith (halorgium) has been working on a much saner replacement with effectively the same feature set called boo_hiss, but I'm not sure if it's quite ready yet. I've used it a bit but last I checked the user interface (not GUI, just command-line interface) was rough around the edges. -- Yehuda On Fri, Jan 2, 2009 at 11:07 PM, Sebastian W. wrote: > Hello RSpec folks, > I'm not sure if I'm doing something wrong with the Heckle integration in > RSpec? > > I go to heckle my spec, and everything seems to start out okay. But then > something weird happens: > > 3 mutations remaining... > 2 mutations remaining... > 1 mutations remaining... > 1 mutations remaining... > 1 mutations remaining... > 1 mutations remaining... > 1 mutations remaining... > 1 mutations remaining... > 1 mutations remaining... > #repeat the above line forever... > > I've tried waiting to see if I just need to be patient, but Heckle never > seems to exit. > > FWIW, I'm running my spec in the following manner: > > spec --heckle Seeker seeker_spec.rb > > And as you may guess, the name of my class is "Seeker". Any thoughts? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Yehuda Katz Developer | Engine Yard (ph) 718.877.1325 -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Sat Jan 3 07:25:24 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sat, 3 Jan 2009 12:25:24 +0000 Subject: [rspec-users] newbie: need help to write the spec for helper In-Reply-To: <8d961d900812310811k7d4a0b74s89a6e84e81338ec9@mail.gmail.com> References: <460644.22468.qm@web38001.mail.mud.yahoo.com> <57c63afe0812310721o4a65a879v55b7e4f586f50f46@mail.gmail.com> <8d961d900812310749g5a4a3b5lf15722da3670547a@mail.gmail.com> <57c63afe0812310802h3f0cf030l1bf7a2626a492193@mail.gmail.com> <8d961d900812310811k7d4a0b74s89a6e84e81338ec9@mail.gmail.com> Message-ID: <01C25EB5-DD78-4B48-9DCA-2DA8BD72B76F@mattwynne.net> On 31 Dec 2008, at 16:11, aslak hellesoy wrote: > On Wed, Dec 31, 2008 at 5:02 PM, David Chelimsky > wrote: > > So do you recommend never doing helper specs? > > I never said never :-) Here is my manifesto styled take on this: > > "I favour testing directly accessible APIs over indirectly > accessible ones." > > In Rails, I usually try to write a spec against a controller or view > before I resort to a helper spec. > > Aslak Interesting. I've ended up going in the other direction. I started out writing tests for UI code at the view level, treating helper methods as implementation details, just as you're describing. This seemed to result in view specs that were fragile, with lots of mocks to set up, and duplicated spec logic where helper code was re-used in different views. I now prefer to put all the interesting stuff in the helpers, unit test that, use Cucumber to make sure the view doesn't blow up, and do very little testing of the view itself. I guess in the context of your little manifesto, I've started to think of the methods you put in helpers as being the API that's used by the designer who hacks on the views. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From matt at mattwynne.net Sat Jan 3 08:19:50 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sat, 3 Jan 2009 13:19:50 +0000 Subject: [rspec-users] Do people write specs for the code in their steps? How? In-Reply-To: References: Message-ID: On 30 Dec 2008, at 04:17, Erik Pukinskis wrote: >> The approach I like to take is to follow the guidance of the system >> (cucumber + rspec) every step of the way. Right now there are no >> passing steps, so I'd write the code for the 1st pending step, run >> the >> features and find the first thing that is missing or failing. > > This is one thing I don't get. I just started implementing steps, but > I feel like THAT code is all completely untested. I don't know if my > regular expression is correct, I don't know if it does what I think it > should do. What I really want to do is write something like this: > > describe "steps for withdrawing money" > > describe "Given user has a balance" > > before :each > cucumber "Given user has $50 dollars" > end > > it "should match a particular step" > > it "should create an account" > > it "should set the account balance to $50" > > end > > end > > > But is there such a "cucumber" method? And how do you check that your > regular expressions are going to the right place? > > Maybe the best thing to do is write your cucumber steps like this: > > user_has_a_balance = /user has $(.*) dollars/ > Given user_has_a_balance do |balance| > ... > end > > And then in your spec you can do: > > user_has_a_balance.match("user has $20 dollars").should_not == nil > > How do people write specs for their cucumber steps? And if you don't > write specs, how do you live with the uncertainty? > > Erik It seems like at least part of the uncertainty you're talking about is that the step matcher in your step definition ruby code won't match all the steps defined in your features files that you intended it to. I have also worried about this, particularly after refactoring steps in a codebase with a large number of features. A while back, I suggested a feature for cucumber, which would allow you to run it in a 'strict' mode, where the build would fail if any of the steps in features were not matched to a ruby step definition. I'm not sure whether this ticket has been implemented or not - I had a feeling it was, but I can't see anything in the help for 0.1.13, and the ticket hasn't been updated. Plus it's Christmas and my brain is pickled. Anyway, take a look at the ticket: http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/52-unmatched-steps-should-less-tolerable-than-pending-steps#ticket-52-23 cheers, Matt Wynne http://blog.mattwynne.net http://www.songkick.com From dchelimsky at gmail.com Sat Jan 3 15:31:38 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 3 Jan 2009 14:31:38 -0600 Subject: [rspec-users] How to spec a controller method that involves an rjs redirect In-Reply-To: <190728.50003.qm@web38004.mail.mud.yahoo.com> References: <190728.50003.qm@web38004.mail.mud.yahoo.com> Message-ID: <57c63afe0901031231u7e5de199i4738cda8e1c95d37@mail.gmail.com> On Fri, Jan 2, 2009 at 10:01 AM, Nasir Jamal wrote: > Hi everyone, > > What is the best way to spec a controller method that involves an rjs > redirect? Something like this > > def index > url_to = @parent ? auction_bids_path(@parent) : auctions_path > render :update do |page| > page.redirect_to(url_to) > end > end > > I tried > response.should have_rjs > for the redirect but it didnt work. Any help would be appreciated. Please be more specific when you say "it didn't work." What precisely was the code in the spec and what precisely was the error you got. From luke at lukemelia.com Sat Jan 3 20:41:41 2009 From: luke at lukemelia.com (Luke Melia) Date: Sat, 3 Jan 2009 20:41:41 -0500 Subject: [rspec-users] Cucumber speed tips In-Reply-To: References: Message-ID: <8E28160D-A681-48DE-A983-E9D36007027C@lukemelia.com> On Dec 27, 2008, at 3:08 AM, Mischa Fierer wrote: > You only need to test login for each login case, not for each time > you are testing some sort of logged in functionality. > In most cases you can just post to sessions/create rather than > filling in a login form. I also wanted to speed up the "Given I am a logged in user" type of thing, as you suggested, but took a different, faster approach which may also work for you. I set a cookie to auto-login the user on the next request. Implementation as a gist http://gist.github.com/42973 and below. -Luke features/steps/users_steps.rb: Given "I'm a logged in member" do @me = create_adult logged_in_as @me end features/support/env.rb: class Cucumber::Rails::World ... def logged_in_as(user) cookies['integration_test_user'] = user.id.to_s end ,,, end app/controllers/application.rb class ApplicationController < ActionController::Base ... before_filter :login_integration_test_user, :if => lambda { Rails.env == 'test' } ... def login_integration_test_user return true if cookies['integration_test_user'].blank? integration_test_user_id = cookies['integration_test_user'].to_i if integration_test_user_id != current_user.id reset_session self.current_user = User.find(integration_test_user_id) end cookies['integration_test_user'] = nil end -- Luke Melia luke at lukemelia.com http://www.lukemelia.com/ From luke at lukemelia.com Sat Jan 3 20:51:32 2009 From: luke at lukemelia.com (Luke Melia) Date: Sat, 3 Jan 2009 20:51:32 -0500 Subject: [rspec-users] Cucumber speed tips In-Reply-To: References: <49566B61.9020201@benmabey.com> Message-ID: On Dec 28, 2008, at 11:30 AM, Josh Knowles wrote: > 4) Distribute your scenarios across multiple processes using TestJour > (http://github.com/brynary/testjour) To provide a little more info (Josh and I work with Bryan, who created testjour): we have a cucumber suite currently consisting of 5835 steps that takes a bit under 20 minutes to run without testjour. Running it via testjour with 2 local slaves and 6 remote slaves (2 mac minis and a Mac Pro), the run completes in about 4 minutes. testjour is still a little raw, but I already would not want to work on a large product without it. Luke -- Luke Melia luke at lukemelia.com http://www.lukemelia.com/ From ben at benmabey.com Sat Jan 3 21:12:32 2009 From: ben at benmabey.com (Ben Mabey) Date: Sat, 03 Jan 2009 19:12:32 -0700 Subject: [rspec-users] Cucumber speed tips In-Reply-To: <8E28160D-A681-48DE-A983-E9D36007027C@lukemelia.com> References: <8E28160D-A681-48DE-A983-E9D36007027C@lukemelia.com> Message-ID: <49601B10.8020902@benmabey.com> On 1/3/09 6:41 PM, Luke Melia wrote: > On Dec 27, 2008, at 3:08 AM, Mischa Fierer wrote: > >> You only need to test login for each login case, not for each time >> you are testing some sort of logged in functionality. >> In most cases you can just post to sessions/create rather than >> filling in a login form. > > I also wanted to speed up the "Given I am a logged in user" type of > thing, as you suggested, but took a different, faster approach which > may also work for you. I set a cookie to auto-login the user on the > next request. Implementation as a gist http://gist.github.com/42973 > and below. -Luke > > features/steps/users_steps.rb: > > Given "I'm a logged in member" do > @me = create_adult > logged_in_as @me > end > > features/support/env.rb: > > class Cucumber::Rails::World > ... > def logged_in_as(user) > cookies['integration_test_user'] = user.id.to_s > end > ,,, > end > > app/controllers/application.rb > > class ApplicationController < ActionController::Base > ... > before_filter :login_integration_test_user, :if => lambda { > Rails.env == 'test' } > ... > def login_integration_test_user > return true if cookies['integration_test_user'].blank? > integration_test_user_id = cookies['integration_test_user'].to_i > > if integration_test_user_id != current_user.id > reset_session > self.current_user = User.find(integration_test_user_id) > end > > cookies['integration_test_user'] = nil > end The downside with this approach is that it only works with the rails webrat adapter. One solution which I have been meaning to do is to create a UsersSessionManager. The manager would be responsible for logging in all the various roles you use in your app with different webrat sessions (and then caching them.) You could then swap out which session you would be using in your steps... So you could then do something like: logged_in_as 'Admin' do |session| session.click_link 'Foo' ... end Or.. Given /^I am logged in as an '(.+)'$/ |role| login_as role end The 'login_as' would swap out the session that the World object uses so the next steps would be using the appropriate session. WDYT? -Ben -Ben From reza.primardiansyah at gmail.com Sat Jan 3 21:58:26 2009 From: reza.primardiansyah at gmail.com (Reza Primardiansyah) Date: Sun, 4 Jan 2009 09:58:26 +0700 Subject: [rspec-users] Rspec Rails high overhead Message-ID: Greetings, I found out that running RSpec on Rails takes too much overhead. It takes more than 16s per run although the specs only take less than 6s, like seen below. That means almost 11s overhead. I can't find the bottleneck. I use latest rspec, and rails 2.2 on Debian. $ time rake spec > (in /home/reza/system) > > .................................................................................................................................................................................................................................................................................................................................................... > > Finished in 5.493595 seconds > > 340 examples, 0 failures > > real 0m16.497s > user 0m14.059s > sys 0m2.266s > I know that Debian's ruby is slow. So I tried using enterprise ruby. Not much difference $ time /opt/ruby-enterprise/bin/ruby /var/lib/gems/1.8/bin/rake spec > (in /home/reza/system) > > .................................................................................................................................................................................................................................................................................................................................................... > > Finished in 3.170093 seconds > > 340 examples, 0 failures > > real 0m12.033s > user 0m9.948s > sys 0m1.735s > The overhead is also felt when using autospec. Even using sqlite's in-memory-db doesn't change much. Can anyone give me hint about what happens and what to do to overcome it? Thanks all. -------------- next part -------------- An HTML attachment was scrubbed... URL: From luke at lukemelia.com Sat Jan 3 22:36:54 2009 From: luke at lukemelia.com (Luke Melia) Date: Sat, 3 Jan 2009 22:36:54 -0500 Subject: [rspec-users] Cucumber speed tips In-Reply-To: <49601B10.8020902@benmabey.com> References: <8E28160D-A681-48DE-A983-E9D36007027C@lukemelia.com> <49601B10.8020902@benmabey.com> Message-ID: <2F917216-123A-467B-A35E-1FA5BF8CBC79@lukemelia.com> On Jan 3, 2009, at 9:12 PM, Ben Mabey wrote: > The downside with this approach is that it only works with the rails > webrat adapter. One solution which I have been meaning to do is to > create a UsersSessionManager. The manager would be responsible for > logging in all the various roles you use in your app with different > webrat sessions (and then caching them.) You could then swap out > which session you would be using in your steps... > > So you could then do something like: > > logged_in_as 'Admin' do |session| > session.click_link 'Foo' > ... > end > > Or.. > > Given /^I am logged in as an '(.+)'$/ |role| > login_as role > end > > The 'login_as' would swap out the session that the World object uses > so the next steps would be using the appropriate session. > > WDYT? In general I like the idea, Ben. At weplay, we use webrat to drive rails and selenium, and logged_in_as method has the following implementation in the Selenium world: def logged_in_as(user) visit login_for_test_path(user) end where login_for_test_path is is a named route defined only for the selenium environment that provides a "quick" login of a given user. Would the solution you're thinking of help with this? I'm not sure how you would "cache" a selenium session. -- Luke Melia luke at lukemelia.com http://www.lukemelia.com/ From sfeley at gmail.com Sat Jan 3 23:15:50 2009 From: sfeley at gmail.com (Stephen Eley) Date: Sat, 3 Jan 2009 23:15:50 -0500 Subject: [rspec-users] How to spec a controller method that involves an rjs redirect In-Reply-To: <190728.50003.qm@web38004.mail.mud.yahoo.com> References: <190728.50003.qm@web38004.mail.mud.yahoo.com> Message-ID: <1fb4df0901032015s32af4727udfc1ab76bc8fbd42@mail.gmail.com> On Fri, Jan 2, 2009 at 11:01 AM, Nasir Jamal wrote: > > What is the best way to spec a controller method that involves an rjs > redirect? Something like this Consider: response.should =~ /window\.location\.href = '(whatever your expected path is)';/ I didn't confirm that regex, obviously. But the concept is pretty simple: if you know how the RJS redirect works and what Javascript is supposed to be generated, then test for its presence in the response. If it's there, your controller logic worked. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From mark at mwilden.com Sat Jan 3 23:17:12 2009 From: mark at mwilden.com (Mark Wilden) Date: Sat, 3 Jan 2009 20:17:12 -0800 Subject: [rspec-users] Rspec Rails high overhead In-Reply-To: References: Message-ID: <3c30da400901032017u62e0a063hfaa5ca8e7bbbb97d@mail.gmail.com> On Sat, Jan 3, 2009 at 6:58 PM, Reza Primardiansyah < reza.primardiansyah at gmail.com> wrote: > I found out that running RSpec on Rails takes too much overhead. It takes > more than 16s per run although the specs only take less than 6s, like seen > below. The killer is the time it takes to load environment.rb, which loads Rails, runs initializers, etc. The rake spec task also tears down and recreates the test database, but that's not as significant. The solution to the first situation is spec_server, which loads the environment once, then stays in memory as a DRb process. By passing --drb to the spec command, RSpec will have that process run specs. The solution to the second situation is to not run rake spec, but instead use spec or autospec. All that said, I haven't had as much joy from spec_server as I have in the past. Too often it seems to not load changed models. But this might be related to a patch I had to apply to even get it to run. Things seemed to have changed with Rails 2.2.2 and/or RSpec 1.1.11. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Sun Jan 4 01:01:42 2009 From: lists at ruby-forum.com (Sebastian W.) Date: Sun, 4 Jan 2009 07:01:42 +0100 Subject: [rspec-users] Getting heckled by Heckle? In-Reply-To: <245fb4700901030031o5ffdae18i8aeea59590bf41b@mail.gmail.com> References: <4837fa5000068804cbdea858f10b6af5@ruby-forum.com> <245fb4700901030031o5ffdae18i8aeea59590bf41b@mail.gmail.com> Message-ID: Yehuda Katz wrote: > There is more than 1 bug in Heckle that can produce this behavior. Tim > Carey > Smith (halorgium) has been working on a much saner replacement with > effectively the same feature set called boo_hiss, but I'm not sure if > it's > quite ready yet. I've used it a bit but last I checked the user > interface > (not GUI, just command-line interface) was rough around the edges. > -- Yehuda Cool, thanks Yehuda! I'll hold on tight and wait for that. :) -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Sun Jan 4 09:43:52 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 4 Jan 2009 15:43:52 +0100 Subject: [rspec-users] Rspec Rails high overhead In-Reply-To: References: Message-ID: <8d961d900901040643k6d8e2967je6ec475bbc0db9ac@mail.gmail.com> On Sun, Jan 4, 2009 at 3:58 AM, Reza Primardiansyah < reza.primardiansyah at gmail.com> wrote: > Greetings, > I found out that running RSpec on Rails takes too much overhead. It takes > more than 16s per run although the specs only take less than 6s, like seen > below. That means almost 11s overhead. > I can't find the bottleneck. I use latest rspec, and rails 2.2 on Debian. > > $ time rake spec >> (in /home/reza/system) >> >> .................................................................................................................................................................................................................................................................................................................................................... >> >> Finished in 5.493595 seconds >> >> 340 examples, 0 failures >> >> real 0m16.497s >> user 0m14.059s >> sys 0m2.266s >> > > I know that Debian's ruby is slow. So I tried using enterprise ruby. Not > much difference > > $ time /opt/ruby-enterprise/bin/ruby /var/lib/gems/1.8/bin/rake spec >> (in /home/reza/system) >> >> .................................................................................................................................................................................................................................................................................................................................................... >> >> Finished in 3.170093 seconds >> >> 340 examples, 0 failures >> >> real 0m12.033s >> user 0m9.948s >> sys 0m1.735s >> > > The overhead is also felt when using autospec. Even using sqlite's > in-memory-db doesn't change much. > > Can anyone give me hint about what happens and what to do to overcome it? > How long does ruby script/server take before the server is up? Aslak > > Thanks all. > > _______________________________________________ > 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 nick at deadorange.com Sun Jan 4 09:57:47 2009 From: nick at deadorange.com (Nick Hoffman) Date: Sun, 4 Jan 2009 09:57:47 -0500 Subject: [rspec-users] Rspec Rails high overhead In-Reply-To: <3c30da400901032017u62e0a063hfaa5ca8e7bbbb97d@mail.gmail.com> References: <3c30da400901032017u62e0a063hfaa5ca8e7bbbb97d@mail.gmail.com> Message-ID: On 2009-01-03, at 23:17, Mark Wilden wrote: >> On Sat, Jan 3, 2009 at 6:58 PM, Reza Primardiansyah > > wrote: >> >> I found out that running RSpec on Rails takes too much overhead. It >> takes more than 16s per run although the specs only take less than >> 6s, like seen below. > > The killer is the time it takes to load environment.rb, which loads > Rails, runs initializers, etc. The rake spec task also tears down > and recreates the test database, but that's not as significant. > > The solution to the first situation is spec_server, which loads the > environment once, then stays in memory as a DRb process. By passing > --drb to the spec command, RSpec will have that process run specs. > The solution to the second situation is to not run rake spec, but > instead use spec or autospec. > > All that said, I haven't had as much joy from spec_server as I have > in the past. Too often it seems to not load changed models. But this > might be related to a patch I had to apply to even get it to run. > Things seemed to have changed with Rails 2.2.2 and/or RSpec 1.1.11. > > ///ark Mark, would you mind explicitly telling us/me how you get the ``spec'' command to run within DRb, please? This is what happens I try [and fail] to do so: http://gist.github.com/43070 Cheers, Nick From dchelimsky at gmail.com Sun Jan 4 11:41:21 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 4 Jan 2009 10:41:21 -0600 Subject: [rspec-users] [ANN] RSpec-1.1.12 - RC1 Message-ID: <57c63afe0901040841m655f4eb2i835833d5ee581778@mail.gmail.com> Hey all, I'm getting ready to do a 1.1.12 release of rspec and rspec-rails. Given the history of release-related compatibility problems, I offer you release candidate gems, which you can acquire thusly: [sudo] gem install dchelimsky-rspec -v 1.1.11.5 --source http://gems.github.com [sudo] gem install dchelimsky-rspec-rails -v 1.1.11.5 --source http://gems.github.com Release notes can be seen under Maintenance at: http://github.com/dchelimsky/rspec/tree/master/History.txt http://github.com/dchelimsky/rspec-rails/tree/master/History.txt NOTE: This will be the last release of rspec-rails that supports rails < 2.0 If you are so inclined, please grab these gems, use them, and let me know if everything is AOK. Cheers, David From dchelimsky at gmail.com Sun Jan 4 13:22:42 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 4 Jan 2009 12:22:42 -0600 Subject: [rspec-users] [ANN] RSpec-1.1.12 - RC1 In-Reply-To: <57c63afe0901040841m655f4eb2i835833d5ee581778@mail.gmail.com> References: <57c63afe0901040841m655f4eb2i835833d5ee581778@mail.gmail.com> Message-ID: <57c63afe0901041022m7f1c324fm7049b93bf6f20210@mail.gmail.com> On Sun, Jan 4, 2009 at 10:41 AM, David Chelimsky wrote: > Hey all, > > I'm getting ready to do a 1.1.12 release of rspec and rspec-rails. > Given the history of release-related compatibility problems, I offer > you release candidate gems, which you can acquire thusly: > > [sudo] gem install dchelimsky-rspec -v 1.1.11.5 --source http://gems.github.com > [sudo] gem install dchelimsky-rspec-rails -v 1.1.11.5 --source > http://gems.github.com Fixed gem dependency issue related to github-generated gems (prefixed w/ usernames). Try 1.1.11.6 instead: gem sources -a http://gems.github.com gem install dchelimsky-rspec -v 1.1.11.6 gem install dchelimsky-rspec-rails -v 1.1.11.6 Cheers, David > > Release notes can be seen under Maintenance at: > > http://github.com/dchelimsky/rspec/tree/master/History.txt > http://github.com/dchelimsky/rspec-rails/tree/master/History.txt > > NOTE: This will be the last release of rspec-rails that supports rails < 2.0 > > If you are so inclined, please grab these gems, use them, and let me > know if everything is AOK. > > Cheers, > David > From joahking at gmail.com Sun Jan 4 13:31:30 2009 From: joahking at gmail.com (Joaquin Rivera Padron) Date: Sun, 4 Jan 2009 19:31:30 +0100 Subject: [rspec-users] rack app to browse specs Message-ID: <8277b7f40901041031l3a1fe8d4v6c6150bfee3cb944@mail.gmail.com> hello there, Sometimes I find easier to browse my specs directly on the browser to have an overall idea of the logic. To do it I have put up a simple rack app to: - browse the contents of /spec directory on rails root - run each spec and view the html formatted output (it does spec FILE -f h) It is only a .rb file to put on spec/ directory. If you will like to give it a try: http://gist.github.com/43149 I hope it helps somebody ;-) joaquin -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Sun Jan 4 13:50:11 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 4 Jan 2009 19:50:11 +0100 Subject: [rspec-users] [ANN] Cucumber 0.1.14 Message-ID: <8d961d900901041050pd052a6dgd0d4c671d130bc66@mail.gmail.com> Now with Ruby 1.9 support! Full changelog: http://github.com/aslakhellesoy/cucumber/tree/v0.1.14/History.txt The gem will be available in an hour or two. Aslak -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sun Jan 4 13:55:06 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 4 Jan 2009 12:55:06 -0600 Subject: [rspec-users] [rspec-devel] [ANN] Cucumber 0.1.14 In-Reply-To: <8d961d900901041050pd052a6dgd0d4c671d130bc66@mail.gmail.com> References: <8d961d900901041050pd052a6dgd0d4c671d130bc66@mail.gmail.com> Message-ID: <57c63afe0901041055s4ac8b36fpebe3c299541e3be9@mail.gmail.com> Rock on!!!!! Thanks for this this. It's going to make getting rspec ruby 1.9 compliant much easier (since now I'll be able to run rspec's features!). Cheers, David On Sun, Jan 4, 2009 at 12:50 PM, aslak hellesoy wrote: > Now with Ruby 1.9 support! > > Full changelog: > http://github.com/aslakhellesoy/cucumber/tree/v0.1.14/History.txt > > The gem will be available in an hour or two. > > Aslak > > _______________________________________________ > rspec-devel mailing list > rspec-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-devel > From lists at ruby-forum.com Sun Jan 4 14:13:57 2009 From: lists at ruby-forum.com (Hubert Lepicki) Date: Sun, 4 Jan 2009 20:13:57 +0100 Subject: [rspec-users] Cucumber model expectations fail to find newly created users Message-ID: <9fed933fb90eda32e8d056bb16460a98@ruby-forum.com> Hi guys, I have strange problem with getting model expectations to work with Cucumber. My setup is that I use Cucumber + Webrat (Selenium backend). Story I test is registering user on site. Cucumber runs story perfectly fine, and I see it fills in form, sends it, I even see proper "You have successfully registered" message at the end. However, as a last element of story I want to make sure the user was really created in database - and this fails. I have definition of following step: Then /^should exist exactly "(.*)" users$/ do |cnt, state| User.count.should == cnt.to_i end However, it always complains that there are 0 users, when expected X. What is even more stranger, when I log into console, and do User.count, I get proper number of users - they were actually created during running a story! Any ideas? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sun Jan 4 14:15:43 2009 From: lists at ruby-forum.com (Hubert Lepicki) Date: Sun, 4 Jan 2009 20:15:43 +0100 Subject: [rspec-users] Cucumber model expectations fail to find newly created users In-Reply-To: <9fed933fb90eda32e8d056bb16460a98@ruby-forum.com> References: <9fed933fb90eda32e8d056bb16460a98@ruby-forum.com> Message-ID: <70166be6233dc4d4aac84e049a46acae@ruby-forum.com> The step definition is actually: Then /^should exist exactly "(.*)" users$/ do |cnt| User.count.should == cnt.to_i end but that doesn't change anything, please help! -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Sun Jan 4 14:46:54 2009 From: ben at benmabey.com (Ben Mabey) Date: Sun, 04 Jan 2009 12:46:54 -0700 Subject: [rspec-users] Cucumber model expectations fail to find newly created users In-Reply-To: <9fed933fb90eda32e8d056bb16460a98@ruby-forum.com> References: <9fed933fb90eda32e8d056bb16460a98@ruby-forum.com> Message-ID: <4961122E.2090607@benmabey.com> On 1/4/09 12:13 PM, Hubert Lepicki wrote: > Hi guys, > > I have strange problem with getting model expectations to work with > Cucumber. My setup is that I use Cucumber + Webrat (Selenium backend). > My guess is that you are using Selenium in conjuction with rails transactional fixtures turned on. In your env.rb file do you have the following? Cucumber::Rails.use_transactional_fixtures If so that is your problem. What is happending is that you two separate processes and two separate DB connections going. One is running the server for selenium, and the other is for your features. With transactional_fixtures turned on all of your DB calls for each scenario are wrapped in into a transaction that is rolled back at the end. Be default MySQL, and most other DBs I would imagine, don't let the data in a transaction appear to any other queries until that transaction is actually committed. That is why you can see the correct count in the process running the features but not the selenium process. How do you get around this? You could change your settings on MySQL, but I wouldn't suggest that. What I do is turn off transactional_fixtures and then manage the DB cleanup myself in After blocks. The quick and dirty way to do this is to truncate your tables.. There have been some threads on this list explaining how to do this. There are some other ways to accomplish this without resorting to truncating everytime too, but I will let you google and find those threads. This problem seems to come up quite a bit.. we should probably add this to the Troubleshooting page on Cucumber's wiki.... Anyways, I hope that helps. -Ben > Story I test is registering user on site. Cucumber runs story perfectly > fine, and I see it fills in form, sends it, I even see proper "You have > successfully registered" message at the end. However, as a last element > of story I want to make sure the user was really created in database - > and this fails. > > I have definition of following step: > > Then /^should exist exactly "(.*)" users$/ do |cnt, state| > User.count.should == cnt.to_i > end > > However, it always complains that there are 0 users, when expected X. > > What is even more stranger, when I log into console, and do User.count, > I get proper number of users - they were actually created during running > a story! > > Any ideas? > From lists at ruby-forum.com Sun Jan 4 15:16:00 2009 From: lists at ruby-forum.com (Hubert Lepicki) Date: Sun, 4 Jan 2009 21:16:00 +0100 Subject: [rspec-users] Cucumber model expectations fail to find newly created users In-Reply-To: <4961122E.2090607@benmabey.com> References: <9fed933fb90eda32e8d056bb16460a98@ruby-forum.com> <4961122E.2090607@benmabey.com> Message-ID: <95e80809d0a68fab3c1a666a74d93295@ruby-forum.com> Ben Mabey wrote: > My guess is that you are using Selenium in conjuction with rails > transactional fixtures turned on. In your env.rb file do you have the > following? > Cucumber::Rails.use_transactional_fixtures That was a perfect guess! Thank you, Ben, a lot! I have updated Troubleshooting page in Github wiki like you suggested so that other people might find solution quicker than me :). One more time - thanks! -- Posted via http://www.ruby-forum.com/. From mark at mwilden.com Sun Jan 4 15:52:59 2009 From: mark at mwilden.com (Mark Wilden) Date: Sun, 4 Jan 2009 12:52:59 -0800 Subject: [rspec-users] Rspec Rails high overhead In-Reply-To: References: <3c30da400901032017u62e0a063hfaa5ca8e7bbbb97d@mail.gmail.com> Message-ID: <3c30da400901041252n42d8aebeuaaeed800aca9dae0@mail.gmail.com> On Sun, Jan 4, 2009 at 6:57 AM, Nick Hoffman wrote: > > Mark, would you mind explicitly telling us/me how you get the ``spec'' > command to run within DRb, please? > I use spec rather than script/spec to run specs. script/spec runs my specs twice. I also use rake spec:server:start rather than script/spec_server, but both commands do work for me. The problem now is that if I change a model or lib file, it's not reloaded by spec_server. I have to stop and restart spec_server for the change to be picked up. This means I can't really use it. (To the powers that be, I apologize for not filing a proper bug report.) This is what happens I try [and fail] to do so: > http://gist.github.com/43070 > That sequence "works for me," I'm afraid. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sun Jan 4 16:03:38 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 4 Jan 2009 15:03:38 -0600 Subject: [rspec-users] Rspec Rails high overhead In-Reply-To: <3c30da400901041252n42d8aebeuaaeed800aca9dae0@mail.gmail.com> References: <3c30da400901032017u62e0a063hfaa5ca8e7bbbb97d@mail.gmail.com> <3c30da400901041252n42d8aebeuaaeed800aca9dae0@mail.gmail.com> Message-ID: <57c63afe0901041303uacc7b41sb589cd48289740e8@mail.gmail.com> On Sun, Jan 4, 2009 at 2:52 PM, Mark Wilden wrote: > On Sun, Jan 4, 2009 at 6:57 AM, Nick Hoffman wrote: >> >> Mark, would you mind explicitly telling us/me how you get the ``spec'' >> command to run within DRb, please? > > I use spec rather than script/spec to run specs. script/spec runs my specs > twice. That's fixed, so I'm guessing you've got a mixture of old and new generated files. > I also use rake spec:server:start rather than script/spec_server, but > both commands do work for me. > > The problem now is that if I change a model or lib file, it's not reloaded > by spec_server. I have to stop and restart spec_server for the change to be > picked up. This means I can't really use it. (To the powers that be, I > apologize for not filing a proper bug report.) Apology accepted as soon as you do :) > >> This is what happens I try [and fail] to do so: >> http://gist.github.com/43070 > > That sequence "works for me," I'm afraid. > > ///ark From mark at mwilden.com Sun Jan 4 16:19:45 2009 From: mark at mwilden.com (Mark Wilden) Date: Sun, 4 Jan 2009 13:19:45 -0800 Subject: [rspec-users] Rspec Rails high overhead In-Reply-To: <57c63afe0901041303uacc7b41sb589cd48289740e8@mail.gmail.com> References: <3c30da400901032017u62e0a063hfaa5ca8e7bbbb97d@mail.gmail.com> <3c30da400901041252n42d8aebeuaaeed800aca9dae0@mail.gmail.com> <57c63afe0901041303uacc7b41sb589cd48289740e8@mail.gmail.com> Message-ID: <3c30da400901041319k1f475266nc0d643edbfeae7d5@mail.gmail.com> On Sun, Jan 4, 2009 at 1:03 PM, David Chelimsky wrote: > > I use spec rather than script/spec to run specs. script/spec runs my > specs > > twice. > > That's fixed, so I'm guessing you've got a mixture of old and new > generated files. > I did re-gen with .16, but still got that result. > The problem now is that if I change a model or lib file, it's not reloaded > > by spec_server. I have to stop and restart spec_server for the change to > be > > picked up. This means I can't really use it. (To the powers that be, I > > apologize for not filing a proper bug report.) > > Apology accepted as soon as you do :) > The problem, of course, is the "proper" part. But I will try to get at it - I love spec_server! ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Sun Jan 4 19:08:27 2009 From: ben at benmabey.com (Ben Mabey) Date: Sun, 04 Jan 2009 17:08:27 -0700 Subject: [rspec-users] Cucumber speed tips In-Reply-To: <2F917216-123A-467B-A35E-1FA5BF8CBC79@lukemelia.com> References: <8E28160D-A681-48DE-A983-E9D36007027C@lukemelia.com> <49601B10.8020902@benmabey.com> <2F917216-123A-467B-A35E-1FA5BF8CBC79@lukemelia.com> Message-ID: <49614F7B.4010803@benmabey.com> On 1/3/09 8:36 PM, Luke Melia wrote: > On Jan 3, 2009, at 9:12 PM, Ben Mabey wrote: > >> The downside with this approach is that it only works with the rails >> webrat adapter. One solution which I have been meaning to do is to >> create a UsersSessionManager. The manager would be responsible for >> logging in all the various roles you use in your app with different >> webrat sessions (and then caching them.) You could then swap out >> which session you would be using in your steps... >> >> So you could then do something like: >> >> logged_in_as 'Admin' do |session| >> session.click_link 'Foo' >> ... >> end >> >> Or.. >> >> Given /^I am logged in as an '(.+)'$/ |role| >> login_as role >> end >> >> The 'login_as' would swap out the session that the World object uses >> so the next steps would be using the appropriate session. >> >> WDYT? > > In general I like the idea, Ben. At weplay, we use webrat to drive > rails and selenium, and logged_in_as method has the following > implementation in the Selenium world: > > def logged_in_as(user) > visit login_for_test_path(user) > end > > where login_for_test_path is is a named route defined only for the > selenium environment that provides a "quick" login of a given user. > > Would the solution you're thinking of help with this? I'm not sure how > you would "cache" a selenium session. I'm by no means a Selenium expert so I may be making some incorrect assumptions. I thought that it was possible with Selenium to have different sessions open concurrently for the same selenium server. (i.e. have more than one SeleniumDriver/browser instance running against the same server but with different session ids.) Is that not possible? -Ben > > -- > Luke Melia > luke at lukemelia.com > http://www.lukemelia.com/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Sun Jan 4 20:55:40 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 5 Jan 2009 02:55:40 +0100 Subject: [rspec-users] [rspec-devel] [ANN] RSpec-1.1.12 - RC1 In-Reply-To: <57c63afe0901041022m7f1c324fm7049b93bf6f20210@mail.gmail.com> References: <57c63afe0901040841m655f4eb2i835833d5ee581778@mail.gmail.com> <57c63afe0901041022m7f1c324fm7049b93bf6f20210@mail.gmail.com> Message-ID: <8d961d900901041755g699aa0bcx71110493511005ef@mail.gmail.com> On Sun, Jan 4, 2009 at 7:22 PM, David Chelimsky wrote: > On Sun, Jan 4, 2009 at 10:41 AM, David Chelimsky > wrote: > > Hey all, > > > > I'm getting ready to do a 1.1.12 release of rspec and rspec-rails. > > Given the history of release-related compatibility problems, I offer > > you release candidate gems, which you can acquire thusly: > > > > [sudo] gem install dchelimsky-rspec -v 1.1.11.5 --source > http://gems.github.com > > [sudo] gem install dchelimsky-rspec-rails -v 1.1.11.5 --source > > http://gems.github.com > > Fixed gem dependency issue related to github-generated gems (prefixed > w/ usernames). Try 1.1.11.6 instead: > > gem sources -a http://gems.github.com > gem install dchelimsky-rspec -v 1.1.11.6 > gem install dchelimsky-rspec-rails -v 1.1.11.6 > Awesome - now get that 1.9 baby rolling! Aslak > > Cheers, > David > > > > > Release notes can be seen under Maintenance at: > > > > http://github.com/dchelimsky/rspec/tree/master/History.txt > > http://github.com/dchelimsky/rspec-rails/tree/master/History.txt > > > > NOTE: This will be the last release of rspec-rails that supports rails < > 2.0 > > > > If you are so inclined, please grab these gems, use them, and let me > > know if everything is AOK. > > > > Cheers, > > David > > > _______________________________________________ > rspec-devel mailing list > rspec-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Sun Jan 4 20:58:26 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 5 Jan 2009 02:58:26 +0100 Subject: [rspec-users] Voted for Cucumber logo yet? Message-ID: <8d961d900901041758o18fd4a44s10a0e4093d7f851e@mail.gmail.com> If not - please do! http://cukes.info Announcing winner tomorrow. No rallying friends please. Just vote for the best one. Aslak -------------- next part -------------- An HTML attachment was scrubbed... URL: From aidy.lewis at googlemail.com Mon Jan 5 08:33:53 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Mon, 5 Jan 2009 13:33:53 +0000 Subject: [rspec-users] [Cucumber] after feature hook? Message-ID: <7ac2300c0901050533v362261d3r56f3087fd7e883d@mail.gmail.com> Hi, Is there a hook or a method to execute some code after a whole feature has run or will I need to embed that in a 'Then'? Regards Aidy From aslak.hellesoy at gmail.com Mon Jan 5 08:49:48 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 5 Jan 2009 14:49:48 +0100 Subject: [rspec-users] [Cucumber] after feature hook? In-Reply-To: <7ac2300c0901050533v362261d3r56f3087fd7e883d@mail.gmail.com> References: <7ac2300c0901050533v362261d3r56f3087fd7e883d@mail.gmail.com> Message-ID: <8d961d900901050549t732f2e59k3dd1cd336497bb6d@mail.gmail.com> On Mon, Jan 5, 2009 at 2:33 PM, aidy lewis wrote: > Hi, > > Is there a hook or a method to execute some code after a whole feature > has run or will I need to embed that in a 'Then'? > May I ask what you're planning to use it for? Aslak > > Regards > > Aidy > _______________________________________________ > 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 aidy.lewis at googlemail.com Mon Jan 5 09:12:24 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Mon, 5 Jan 2009 14:12:24 +0000 Subject: [rspec-users] [Cucumber] after feature hook? In-Reply-To: <8d961d900901050549t732f2e59k3dd1cd336497bb6d@mail.gmail.com> References: <7ac2300c0901050533v362261d3r56f3087fd7e883d@mail.gmail.com> <8d961d900901050549t732f2e59k3dd1cd336497bb6d@mail.gmail.com> Message-ID: <7ac2300c0901050612g5329a6a0tadedf7c9917ba82c@mail.gmail.com> Hi Alsak, I am finding it difficult to separate my Acceptance Tests unless I have lengthy scenarios. One scenario would be one sequence of action etc - until a goal is reached. At the end of the feature, I would like the browser to close: If the browser closes on each scenario - they I have to get back to the previous state. This is expensive with browser based tests. Aidy On 05/01/2009, aslak hellesoy wrote: > > > > On Mon, Jan 5, 2009 at 2:33 PM, aidy lewis > wrote: > > Hi, > > > > Is there a hook or a method to execute some code after a whole feature > > has run or will I need to embed that in a 'Then'? > > > > May I ask what you're planning to use it for? > > Aslak > > > > Regards > > > > Aidy > > _______________________________________________ > > 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 joe at josephwilk.net Mon Jan 5 09:15:27 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Mon, 05 Jan 2009 14:15:27 +0000 Subject: [rspec-users] [Cucumber] after feature hook? In-Reply-To: <7ac2300c0901050533v362261d3r56f3087fd7e883d@mail.gmail.com> References: <7ac2300c0901050533v362261d3r56f3087fd7e883d@mail.gmail.com> Message-ID: <496215FF.9090901@josephwilk.net> aidy lewis wrote: > Hi, > > Is there a hook or a method to execute some code after a whole feature > has run or will I need to embed that in a 'Then'? > > There are currently no before/after feature hooks. http://github.com/aslakhellesoy/cucumber/wikis/hooks Also if you want something to happen before/after everything you can use World and at_exit respectively. -- Joseph Wilk http://blog.josephwilk.net > Regards > > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From aslak.hellesoy at gmail.com Mon Jan 5 10:09:08 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 5 Jan 2009 16:09:08 +0100 Subject: [rspec-users] [Cucumber] after feature hook? In-Reply-To: <7ac2300c0901050612g5329a6a0tadedf7c9917ba82c@mail.gmail.com> References: <7ac2300c0901050533v362261d3r56f3087fd7e883d@mail.gmail.com> <8d961d900901050549t732f2e59k3dd1cd336497bb6d@mail.gmail.com> <7ac2300c0901050612g5329a6a0tadedf7c9917ba82c@mail.gmail.com> Message-ID: <8d961d900901050709lcd2ff11r11055d18c3ee39b2@mail.gmail.com> On Mon, Jan 5, 2009 at 3:12 PM, aidy lewis wrote: > Hi Alsak, > > I am finding it difficult to separate my Acceptance Tests unless I > have lengthy scenarios. > > One scenario would be one sequence of action etc - until a goal is reached. > > At the end of the feature, I would like the browser to close: If the > browser closes on each scenario - they I have to get back to the > previous state. This is expensive with browser based tests. > And only closing the browser after all the features (at_exit) does not work? Aslak > > Aidy > > > > On 05/01/2009, aslak hellesoy wrote: > > > > > > > > On Mon, Jan 5, 2009 at 2:33 PM, aidy lewis > > wrote: > > > Hi, > > > > > > Is there a hook or a method to execute some code after a whole feature > > > has run or will I need to embed that in a 'Then'? > > > > > > > May I ask what you're planning to use it for? > > > > Aslak > > > > > > Regards > > > > > > Aidy > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joe at josephwilk.net Mon Jan 5 10:13:24 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Mon, 05 Jan 2009 15:13:24 +0000 Subject: [rspec-users] [Cucumber] after feature hook? In-Reply-To: <7ac2300c0901050612g5329a6a0tadedf7c9917ba82c@mail.gmail.com> References: <7ac2300c0901050533v362261d3r56f3087fd7e883d@mail.gmail.com> <8d961d900901050549t732f2e59k3dd1cd336497bb6d@mail.gmail.com> <7ac2300c0901050612g5329a6a0tadedf7c9917ba82c@mail.gmail.com> Message-ID: <49622394.9070409@josephwilk.net> aidy lewis wrote: > Hi Alsak, > > I am finding it difficult to separate my Acceptance Tests unless I > have lengthy scenarios. > > One scenario would be one sequence of action etc - until a goal is reached. > > At the end of the feature, I would like the browser to close: So you are using scenarios to get the browser into a certain state and then the next scenario relies on continuing work on that state? I guess this must mean one scenario failing breaks all following scenarios in the feature? > If the > browser closes on each scenario - they I have to get back to the > previous state. This is expensive with browser based tests. > > Aidy > > A bit of a side note but can I ask why you need the browser to close after a scenario or feature? In Selenium (not sure if Watir is the same) the time expense of starting a new browser instances per scenario or per feature is too high (It can take 7/8 seconds for selenium to start a browser). So rather than closing and opening new browsers we use a single browser instance open throughout the test run. We terminate the session before each scenario (By accessing logout). @@@ruby World do ... browser.open '/logout' ... end @@@ -- Joseph Wilk http://blog.josephwilk.net > > On 05/01/2009, aslak hellesoy wrote: > >> >> On Mon, Jan 5, 2009 at 2:33 PM, aidy lewis >> wrote: >> >>> Hi, >>> >>> Is there a hook or a method to execute some code after a whole feature >>> has run or will I need to embed that in a 'Then'? >>> >>> >> May I ask what you're planning to use it for? >> >> Aslak >> >>> Regards >>> >>> Aidy >>> _______________________________________________ >>> 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 aidy.lewis at googlemail.com Mon Jan 5 11:08:03 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Mon, 5 Jan 2009 16:08:03 +0000 Subject: [rspec-users] [Cucumber] after feature hook? In-Reply-To: <49622394.9070409@josephwilk.net> References: <7ac2300c0901050533v362261d3r56f3087fd7e883d@mail.gmail.com> <8d961d900901050549t732f2e59k3dd1cd336497bb6d@mail.gmail.com> <7ac2300c0901050612g5329a6a0tadedf7c9917ba82c@mail.gmail.com> <49622394.9070409@josephwilk.net> Message-ID: <7ac2300c0901050808h2b169bceoe7e5ee5c81e9c973@mail.gmail.com> Hi Joe, Aslak 2009/1/5 Joseph Wilk : > aidy lewis wrote: >> >> Hi Alsak, >> >> I am finding it difficult to separate my Acceptance Tests unless I >> have lengthy scenarios. >> >> One scenario would be one sequence of action etc - until a goal is >> reached. >> >> At the end of the feature, I would like the browser to close: > > So you are using scenarios to get the browser into a certain state and then > the next scenario relies on continuing work on that state? > I guess this must mean one scenario failing breaks all following scenarios > in the feature? >> >> If the >> browser closes on each scenario - they I have to get back to the >> previous state. This is expensive with browser based tests. >> >> Aidy >> >> > > A bit of a side note but can I ask why you need the browser to close after a > scenario or feature? > > In Selenium (not sure if Watir is the same) the time expense of starting a > new browser instances per scenario or per feature is too high (It can take > 7/8 seconds for selenium to start a browser). So rather than closing and > opening new browsers we use a single browser instance open throughout the > test run. We terminate the session before each scenario (By accessing > logout). > > @@@ruby > World do > ... > browser.open '/logout' > ... > end > @@@ > at_exit {browser.close} works fine and I should have thought of that. Thanks Maybe Selenium RC is slow on starting the browser by going through the HTTP proxy - but I am not sure. Watir\Firewatir does not take that long. I am closing the browser because if the test or A-U-T totally bombs; I can get rid of that session and run the next test. So if one test fails, all my tests don't. Aidy From lists at ruby-forum.com Mon Jan 5 16:18:20 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 5 Jan 2009 22:18:20 +0100 Subject: [rspec-users] cucumber, finding a row in a table Message-ID: <84f730e41b1773b44b0fd8a6dfd49cf8@ruby-forum.com> I generate the following html on the page in question Just An Entity CORP 000001 Show Entity Edit Entity Destroy Entity I have this step definition: When /I delete the "(.*)" entity/ do |row| visits entities_url my_entity = Entity.find_by_entity_name( "my entity number #{row.hll_words_to_i}") within("table > tr#entity_id_" + my_entity.id.to_s) do puts "table > tr#entity_id_" + my_entity.id.to_s click_link "Destroy Entity" end end The puts statement displays this: table > tr#entity_id_1 after wich I see this: When I delete the "first" entity # features/app/models/entities #/step_definitions/entity_steps.rb:128 You have a nil object when you didn't expect it! The error occurred while evaluating nil.to_html (NoMethodError) /usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/scope.rb:176:in `scoped_dom' ... The table entries exist. The find_by_name returns a valid instance. I do not know what the nil object is. Can someone point out to me what I am missing? -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Mon Jan 5 18:07:13 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 5 Jan 2009 18:07:13 -0500 Subject: [rspec-users] cucumber, finding a row in a table In-Reply-To: <84f730e41b1773b44b0fd8a6dfd49cf8@ruby-forum.com> References: <84f730e41b1773b44b0fd8a6dfd49cf8@ruby-forum.com> Message-ID: <85d99afe0901051507pd187422w2bf618459f0bf597@mail.gmail.com> On Mon, Jan 5, 2009 at 4:18 PM, James Byrne wrote: > I generate the following html on the page in question > > > Just An Entity > > CORP > 000001 > Show Entity > Edit Entity > Destroy Entity > > > > I have this step definition: > > When /I delete the "(.*)" entity/ do |row| > visits entities_url > my_entity = Entity.find_by_entity_name( > "my entity number #{row.hll_words_to_i}") > within("table > tr#entity_id_" + my_entity.id.to_s) do > puts "table > tr#entity_id_" + my_entity.id.to_s > click_link "Destroy Entity" > end > end > > The puts statement displays this: > > table > tr#entity_id_1 > > after wich I see this: > > When I delete the "first" entity # features/app/models/entities > #/step_definitions/entity_steps.rb:128 > You have a nil object when you didn't expect it! > The error occurred while evaluating nil.to_html (NoMethodError) > /usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/scope.rb:176:in > `scoped_dom' > ... > > The table entries exist. The find_by_name returns a valid instance. I > do not know what the nil object is. Can someone point out to me what I > am missing? Does your outputted HTML properly include a tbody in the table? If so the selector you are using won't work. You would need to make match any descendant rather than any direct child, ie: "table tr#entity_id_1" On a related note (although not specific your problem at hand) to generate an id on an ActiveRecord model you can use the dom_id helper method provided by Rails. ie: "dom_id(entity)". You can use this both in your template and your steps/specs. And rather than hardcoding "table tr" CSS selectors why not just give your table an id like "entities" and then use dom_id to give your rows ids? Should you change the display to a ul or ol you wouldn't have to go back and change your CSS selectors, -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From reza.primardiansyah at gmail.com Mon Jan 5 22:29:46 2009 From: reza.primardiansyah at gmail.com (Reza Primardiansyah) Date: Tue, 6 Jan 2009 10:29:46 +0700 Subject: [rspec-users] Rspec Rails high overhead In-Reply-To: <8d961d900901040643k6d8e2967je6ec475bbc0db9ac@mail.gmail.com> References: <8d961d900901040643k6d8e2967je6ec475bbc0db9ac@mail.gmail.com> Message-ID: Aslak, The best time I get is 6.3 seconds. I'm using "time script/server" command and hitting Ctrl-C immediately after I see "** Use CTRL-C to stop." On Sun, Jan 4, 2009 at 9:43 PM, aslak hellesoy wrote: > > > On Sun, Jan 4, 2009 at 3:58 AM, Reza Primardiansyah < > reza.primardiansyah at gmail.com> wrote: > >> Greetings, >> I found out that running RSpec on Rails takes too much overhead. It takes >> more than 16s per run although the specs only take less than 6s, like seen >> below. That means almost 11s overhead. >> I can't find the bottleneck. I use latest rspec, and rails 2.2 on Debian. >> >> $ time rake spec >>> (in /home/reza/system) >>> >>> .................................................................................................................................................................................................................................................................................................................................................... >>> >>> Finished in 5.493595 seconds >>> >>> 340 examples, 0 failures >>> >>> real 0m16.497s >>> user 0m14.059s >>> sys 0m2.266s >>> >> >> I know that Debian's ruby is slow. So I tried using enterprise ruby. Not >> much difference >> >> $ time /opt/ruby-enterprise/bin/ruby /var/lib/gems/1.8/bin/rake spec >>> (in /home/reza/system) >>> >>> .................................................................................................................................................................................................................................................................................................................................................... >>> >>> Finished in 3.170093 seconds >>> >>> 340 examples, 0 failures >>> >>> real 0m12.033s >>> user 0m9.948s >>> sys 0m1.735s >>> >> >> The overhead is also felt when using autospec. Even using sqlite's >> in-memory-db doesn't change much. >> >> Can anyone give me hint about what happens and what to do to overcome it? >> > > How long does ruby script/server take before the server is up? > > Aslak > > >> >> Thanks all. >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From luke at lukemelia.com Mon Jan 5 23:38:01 2009 From: luke at lukemelia.com (Luke Melia) Date: Mon, 5 Jan 2009 23:38:01 -0500 Subject: [rspec-users] Cucumber speed tips In-Reply-To: <49614F7B.4010803@benmabey.com> References: <8E28160D-A681-48DE-A983-E9D36007027C@lukemelia.com> <49601B10.8020902@benmabey.com> <2F917216-123A-467B-A35E-1FA5BF8CBC79@lukemelia.com> <49614F7B.4010803@benmabey.com> Message-ID: On Jan 4, 2009, at 7:08 PM, Ben Mabey wrote: > I'm by no means a Selenium expert so I may be making some incorrect > assumptions. I thought that it was possible with Selenium to have > different sessions open concurrently for the same selenium server. > (i.e. have more than one SeleniumDriver/browser instance running > against the same server but with different session ids.) Is that > not possible? Not that I know of, but now that you mention it, seems like it would be pretty cool. Anyone else on the list done this? -- Luke Melia luke at lukemelia.com http://www.lukemelia.com/ From f.mischa at gmail.com Tue Jan 6 01:24:35 2009 From: f.mischa at gmail.com (Mischa Fierer) Date: Tue, 6 Jan 2009 00:24:35 -0600 Subject: [rspec-users] Cucumber speed tips In-Reply-To: References: <8E28160D-A681-48DE-A983-E9D36007027C@lukemelia.com> <49601B10.8020902@benmabey.com> <2F917216-123A-467B-A35E-1FA5BF8CBC79@lukemelia.com> <49614F7B.4010803@benmabey.com> Message-ID: Josh, Ben & Luke -- This is great stuff, thanks a bunch. Over at CaptainU we are probably going to get into the thousands in the next few weeks or so, so speed is a serious issue. I'm going to work on a longer blog post about this, will let you guys know when finished. Best, M On Mon, Jan 5, 2009 at 10:38 PM, Luke Melia wrote: > On Jan 4, 2009, at 7:08 PM, Ben Mabey wrote: > > I'm by no means a Selenium expert so I may be making some incorrect >> assumptions. I thought that it was possible with Selenium to have different >> sessions open concurrently for the same selenium server. (i.e. have more >> than one SeleniumDriver/browser instance running against the same server but >> with different session ids.) Is that not possible? >> > > > Not that I know of, but now that you mention it, seems like it would be > pretty cool. Anyone else on the list done this? > -- > > Luke Melia > luke at lukemelia.com > http://www.lukemelia.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 ivorpaul at gmail.com Tue Jan 6 03:47:45 2009 From: ivorpaul at gmail.com (Ivor Paul) Date: Tue, 6 Jan 2009 10:47:45 +0200 Subject: [rspec-users] options:229 error Message-ID: Hi Guys I am really having incredible issues with this error ivor at TheLuggage:~/workspace/talkies$ rake db:migrate (in /home/ivor/workspace/talkies) /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:229:in `files_to_load': File or directory not found: db:migrate (RuntimeError) from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in `each' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in `files_to_load' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in `run_examples' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec.rb:21:in `run' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:191:in `register_at_exit_hook' from /usr/bin/rake:19 Is there a reliable fix, what is causing the issue and, is anyone else getting this? The comments, questions and related posts seem to have dried up. The problem seems to be very intermittent in my case. I was wondering if there is a failsafe solution. One thing that strikes me as odd is that we have rspec and rspec-rails in vendor/gems yet this error is being thrown in my /usr/lib... gems directory. Also, if I gem uninstall rspec I get an error saying that spec cannot be found. Any pointers would be appreciated. Regards Ivor -------------- next part -------------- An HTML attachment was scrubbed... URL: From scott at railsnewbie.com Tue Jan 6 04:05:34 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Tue, 06 Jan 2009 04:05:34 -0500 Subject: [rspec-users] options:229 error In-Reply-To: References: Message-ID: <49631EDE.3050908@railsnewbie.com> Ivor Paul wrote: > Hi Guys > > I am really having incredible issues with this error > > ivor at TheLuggage:~/workspace/talkies$ rake db:migrate > (in /home/ivor/workspace/talkies) > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:229:in > `files_to_load': File or directory not found: db:migrate (RuntimeError) > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in > `each' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in > `files_to_load' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in > `run_examples' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec.rb:21:in `run' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:191:in > `register_at_exit_hook' > from /usr/bin/rake:19 > > Is there a reliable fix, what is causing the issue and, is anyone else > getting this? The comments, questions and related posts seem to have > dried up. > > The problem seems to be very intermittent in my case. I was wondering > if there is a failsafe solution. > One thing that strikes me as odd is that we have rspec and rspec-rails > in vendor/gems yet this error is being thrown in my /usr/lib... gems > directory. Also, if I gem uninstall rspec I get an error saying that > spec cannot be found. > > Any pointers would be appreciated. > > Regards > Ivor Here's a pointer: Don't use rails' broken gem system. Use the tried and true method of putting rspec & rspec on rails in vendor/plugins. Scott From scott at railsnewbie.com Tue Jan 6 04:06:14 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Tue, 06 Jan 2009 04:06:14 -0500 Subject: [rspec-users] options:229 error In-Reply-To: References: Message-ID: <49631F06.8020300@railsnewbie.com> Ivor Paul wrote: > Hi Guys > > I am really having incredible issues with this error > > ivor at TheLuggage:~/workspace/talkies$ rake db:migrate > (in /home/ivor/workspace/talkies) > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:229:in > `files_to_load': File or directory not found: db:migrate (RuntimeError) > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in > `each' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in > `files_to_load' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in > `run_examples' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec.rb:21:in `run' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:191:in > `register_at_exit_hook' > from /usr/bin/rake:19 > > Is there a reliable fix, what is causing the issue and, is anyone else > getting this? The comments, questions and related posts seem to have > dried up. > > The problem seems to be very intermittent in my case. I was wondering > if there is a failsafe solution. > One thing that strikes me as odd is that we have rspec and rspec-rails > in vendor/gems yet this error is being thrown in my /usr/lib... gems > directory. Also, if I gem uninstall rspec I get an error saying that > spec cannot be found. I guess you don't have the gem unpacked? Scott From dchelimsky at gmail.com Tue Jan 6 07:43:23 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 6 Jan 2009 06:43:23 -0600 Subject: [rspec-users] options:229 error In-Reply-To: References: Message-ID: <57c63afe0901060443q28e75e68x1bac84b2f97b06ad@mail.gmail.com> On Tue, Jan 6, 2009 at 2:47 AM, Ivor Paul wrote: > Hi Guys > > I am really having incredible issues with this error > > ivor at TheLuggage:~/workspace/talkies$ rake db:migrate > (in /home/ivor/workspace/talkies) > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:229:in > `files_to_load': File or directory not found: db:migrate (RuntimeError) > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in > `each' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in > `files_to_load' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in > `run_examples' > from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec.rb:21:in > `run' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:191:in > `register_at_exit_hook' > from /usr/bin/rake:19 > > Is there a reliable fix, what is causing the issue and, is anyone else > getting this? The comments, questions and related posts seem to have dried > up. If you've got rspec and rspec-rails configured as gems, try moving that configuration to config/environments/test.rb. > > The problem seems to be very intermittent in my case. I was wondering if > there is a failsafe solution. > One thing that strikes me as odd is that we have rspec and rspec-rails in > vendor/gems yet this error is being thrown in my /usr/lib... gems directory. > Also, if I gem uninstall rspec I get an error saying that spec cannot be > found. > > Any pointers would be appreciated. > > Regards > Ivor > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Tue Jan 6 08:02:02 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 6 Jan 2009 14:02:02 +0100 Subject: [rspec-users] Rspec Rails high overhead In-Reply-To: References: <8d961d900901040643k6d8e2967je6ec475bbc0db9ac@mail.gmail.com> Message-ID: <8d961d900901060502k347747b4if7f8a4e5f2382d33@mail.gmail.com> On Tue, Jan 6, 2009 at 4:29 AM, Reza Primardiansyah < reza.primardiansyah at gmail.com> wrote: > Aslak, > The best time I get is 6.3 seconds. I'm using "time script/server" command > and hitting Ctrl-C immediately after I see "** Use CTRL-C to stop." > Ok, so you have 5 seconds of additional overhead. I'm guessing that RSpec takes maybe 0.5-1 seconds of the remaining 6 seconds overhead, and that plugins, gems and other code the rest. Maybe you'll find out more with http://ruby-prof.rubyforge.org/ Aslak > > > On Sun, Jan 4, 2009 at 9:43 PM, aslak hellesoy wrote: > >> >> >> On Sun, Jan 4, 2009 at 3:58 AM, Reza Primardiansyah < >> reza.primardiansyah at gmail.com> wrote: >> >>> Greetings, >>> I found out that running RSpec on Rails takes too much overhead. It takes >>> more than 16s per run although the specs only take less than 6s, like seen >>> below. That means almost 11s overhead. >>> I can't find the bottleneck. I use latest rspec, and rails 2.2 on Debian. >>> >>> $ time rake spec >>>> (in /home/reza/system) >>>> >>>> .................................................................................................................................................................................................................................................................................................................................................... >>>> >>>> Finished in 5.493595 seconds >>>> >>>> 340 examples, 0 failures >>>> >>>> real 0m16.497s >>>> user 0m14.059s >>>> sys 0m2.266s >>>> >>> >>> I know that Debian's ruby is slow. So I tried using enterprise ruby. Not >>> much difference >>> >>> $ time /opt/ruby-enterprise/bin/ruby /var/lib/gems/1.8/bin/rake spec >>>> (in /home/reza/system) >>>> >>>> .................................................................................................................................................................................................................................................................................................................................................... >>>> >>>> Finished in 3.170093 seconds >>>> >>>> 340 examples, 0 failures >>>> >>>> real 0m12.033s >>>> user 0m9.948s >>>> sys 0m1.735s >>>> >>> >>> The overhead is also felt when using autospec. Even using sqlite's >>> in-memory-db doesn't change much. >>> >>> Can anyone give me hint about what happens and what to do to overcome it? >>> >> >> How long does ruby script/server take before the server is up? >> >> Aslak >> >> >>> >>> Thanks all. >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Tue Jan 6 08:52:31 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 6 Jan 2009 13:52:31 +0000 Subject: [rspec-users] Rspec Rails high overhead In-Reply-To: <8d961d900901060502k347747b4if7f8a4e5f2382d33@mail.gmail.com> References: <8d961d900901040643k6d8e2967je6ec475bbc0db9ac@mail.gmail.com> <8d961d900901060502k347747b4if7f8a4e5f2382d33@mail.gmail.com> Message-ID: On 6 Jan 2009, at 13:02, aslak hellesoy wrote: > > > On Tue, Jan 6, 2009 at 4:29 AM, Reza Primardiansyah > wrote: > Aslak, > The best time I get is 6.3 seconds. I'm using "time script/server" > command and hitting Ctrl-C immediately after I see "** Use CTRL-C to > stop." > > Ok, so you have 5 seconds of additional overhead. I'm guessing that > RSpec takes maybe 0.5-1 seconds of the remaining 6 seconds overhead, > and that plugins, gems and other code the rest. Maybe you'll find > out more with http://ruby-prof.rubyforge.org/ > > Aslak Worth mentioning that I went down a huge rabbit hole with a similar problem (slow load of rails environment) a few weeks ago, and it turned out that all I needed was a reboot. (Mac OSX Leopard). Boy, did I feel like a chump! > > > > > > On Sun, Jan 4, 2009 at 9:43 PM, aslak hellesoy > wrote: > > > On Sun, Jan 4, 2009 at 3:58 AM, Reza Primardiansyah > wrote: > Greetings, > I found out that running RSpec on Rails takes too much overhead. It > takes more than 16s per run although the specs only take less than > 6s, like seen below. That means almost 11s overhead. > I can't find the bottleneck. I use latest rspec, and rails 2.2 on > Debian. > > $ time rake spec > (in /home/reza/system) > .................................................................................................................................................................................................................................................................................................................................................... > > Finished in 5.493595 seconds > > 340 examples, 0 failures > > real 0m16.497s > user 0m14.059s > sys 0m2.266s > > I know that Debian's ruby is slow. So I tried using enterprise ruby. > Not much difference > > $ time /opt/ruby-enterprise/bin/ruby /var/lib/gems/1.8/bin/rake spec > (in /home/reza/system) > .................................................................................................................................................................................................................................................................................................................................................... > > Finished in 3.170093 seconds > > 340 examples, 0 failures > > real 0m12.033s > user 0m9.948s > sys 0m1.735s > > The overhead is also felt when using autospec. Even using sqlite's > in-memory-db doesn't change much. > > Can anyone give me hint about what happens and what to do to > overcome it? > > How long does ruby script/server take before the server is up? > > Aslak > > > Thanks all. > > _______________________________________________ > 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 Matt Wynne http://blog.mattwynne.net http://www.songkick.com From matt at matt-darby.com Tue Jan 6 10:53:12 2009 From: matt at matt-darby.com (Matt Darby) Date: Tue, 6 Jan 2009 10:53:12 -0500 Subject: [rspec-users] Help with controller spec? Message-ID: I'm stumped. How would I go about specing the "update_sandbox" method? # bids_controller: def new @bid = Bid.new respond_to do |wants| wants.html { redirect_to job_bids_path(@job) } wants.js { update_sandbox do render_to_string :partial => 'new', :locals => {:bid => @bid, :job => @job} end } end end Here is my 4789th stab at it: # bids_controller_spec.rb it "should render new template" do sandbox = mock("Sandbox") controller.stub!(:update_sandbox).and_return(sandbox) sandbox.stub!(:render_to_string).with(:partial => 'new', :locals => {:bid => @bid, :job => @job}) sandbox.should_receive(:render_to_string).with(:partial => 'new', :locals => {:bid => @bid, :job => @job}) controller.should_receive(:update_sandbox) xhr :get, :new end # => Mock 'Sandbox' expected :render_to_string with ({:partial=>"new", :locals=>{:job=>#, :bid=>#}}) once, but received it 0 times Any pointers would be greatly appreciated! Thanks! Matt Darby, M.S. Rails | PHP | Linux | MySQL | IT Email: matt /\at/\ matt-darby.com Skype: matt-darby Web: http://blog.matt-darby.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Tue Jan 6 11:27:42 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 6 Jan 2009 10:27:42 -0600 Subject: [rspec-users] Help with controller spec? In-Reply-To: References: Message-ID: <57c63afe0901060827u123ae68do2bb993ae901584f5@mail.gmail.com> On Tue, Jan 6, 2009 at 9:53 AM, Matt Darby wrote: > I'm stumped. How would I go about specing the "update_sandbox" method? > # bids_controller: > def new > @bid = Bid.new > > respond_to do |wants| > wants.html { redirect_to job_bids_path(@job) } > wants.js { > update_sandbox do > render_to_string :partial => 'new', :locals => {:bid => @bid, :job > => @job} > end > } > end > end > > Here is my 4789th stab at it: > # bids_controller_spec.rb > it "should render new template" do > sandbox = mock("Sandbox") > controller.stub!(:update_sandbox).and_return(sandbox) > sandbox.stub!(:render_to_string).with(:partial => 'new', :locals => > {:bid => @bid, :job => @job}) > > sandbox.should_receive(:render_to_string).with(:partial => 'new', > :locals => {:bid => @bid, :job => @job}) > controller.should_receive(:update_sandbox) I'm just guessing here, because I don't know what #update_sandbox does, but you probably want this to yield the sandbox: controller.should_receive(:update_sandbox).and_yield(sandbox) Let us know if that works. Cheers, David > > xhr :get, :new > end > # => Mock 'Sandbox' expected :render_to_string with ({:partial=>"new", > :locals=>{:job=>#, :bid=># @name="Bid_1015">}}) once, but received it 0 times > Any pointers would be greatly appreciated! > > > Thanks! > Matt Darby, M.S. > Rails | PHP | Linux | MySQL | IT > Email: matt /\at/\ matt-darby.com > Skype: matt-darby > Web: http://blog.matt-darby.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at matt-darby.com Tue Jan 6 11:41:48 2009 From: matt at matt-darby.com (Matt Darby) Date: Tue, 6 Jan 2009 11:41:48 -0500 Subject: [rspec-users] Help with controller spec? In-Reply-To: <57c63afe0901060827u123ae68do2bb993ae901584f5@mail.gmail.com> References: <57c63afe0901060827u123ae68do2bb993ae901584f5@mail.gmail.com> Message-ID: <46EAD556-8462-4FFD-A3AB-CF7F62F5082D@matt-darby.com> On Jan 6, 2009, at 11:27 AM, David Chelimsky wrote: > On Tue, Jan 6, 2009 at 9:53 AM, Matt Darby > wrote: >> I'm stumped. How would I go about specing the "update_sandbox" >> method? >> # bids_controller: >> def new >> @bid = Bid.new >> >> respond_to do |wants| >> wants.html { redirect_to job_bids_path(@job) } >> wants.js { >> update_sandbox do >> render_to_string :partial => 'new', :locals => {:bid => >> @bid, :job >> => @job} >> end >> } >> end >> end >> >> Here is my 4789th stab at it: >> # bids_controller_spec.rb >> it "should render new template" do >> sandbox = mock("Sandbox") >> controller.stub!(:update_sandbox).and_return(sandbox) >> sandbox.stub!(:render_to_string).with(:partial => >> 'new', :locals => >> {:bid => @bid, :job => @job}) >> >> sandbox.should_receive(:render_to_string).with(:partial => >> 'new', >> :locals => {:bid => @bid, :job => @job}) >> controller.should_receive(:update_sandbox) > > I'm just guessing here, because I don't know what #update_sandbox > does, but you probably want this to yield the sandbox: > > controller.should_receive(:update_sandbox).and_yield(sandbox) > > Let us know if that works. > > Cheers, > David > Unfortunately, I get the same result. Here is the #update_sandbox method: # application.rb # RJS method to show new / edit partials def update_sandbox(obj = nil, &block) highlight_this_div = obj ? dom_id(obj) : :sandbox render :update do |page| page[:error_div].hide page.replace_html :sandbox, capture(&block) page.visual_effect :scroll_to, :sandbox page.visual_effect :highlight, highlight_this_div end end Thanks for your help David! >> >> xhr :get, :new >> end >> # => Mock 'Sandbox' expected :render_to_string with >> ({:partial=>"new", >> :locals=>{:job=>#, :bid=>#> 0x2b46f0c >> @name="Bid_1015">}}) once, but received it 0 times >> Any pointers would be greatly appreciated! >> >> >> Thanks! >> Matt Darby, M.S. >> Rails | PHP | Linux | MySQL | IT >> Email: matt /\at/\ matt-darby.com >> Skype: matt-darby >> Web: http://blog.matt-darby.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 joahking at gmail.com Tue Jan 6 11:47:23 2009 From: joahking at gmail.com (Joaquin Rivera Padron) Date: Tue, 6 Jan 2009 17:47:23 +0100 Subject: [rspec-users] rack app to browse specs In-Reply-To: <8277b7f40901041031l3a1fe8d4v6c6150bfee3cb944@mail.gmail.com> References: <8277b7f40901041031l3a1fe8d4v6c6150bfee3cb944@mail.gmail.com> Message-ID: <8277b7f40901060847n6d04b656w7ee4dd5069318357@mail.gmail.com> hello there, I've added support to browse/run cucumber features to the app, check it out in gist: http://gist.github.com/43149 right now you can: browse your spec/ and features/ directory run specs and feature files living there. it is only a .rb script to put into spec (or features) directory I've also moved the gists to a normal repo at: http://github.com/joahking/rack-rspec-html/tree/master I hope it helps somebody ;-) joaquin -- www.least-significant-bit.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Tue Jan 6 11:48:08 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 6 Jan 2009 10:48:08 -0600 Subject: [rspec-users] Help with controller spec? In-Reply-To: <46EAD556-8462-4FFD-A3AB-CF7F62F5082D@matt-darby.com> References: <57c63afe0901060827u123ae68do2bb993ae901584f5@mail.gmail.com> <46EAD556-8462-4FFD-A3AB-CF7F62F5082D@matt-darby.com> Message-ID: <57c63afe0901060848l2a373acbi40cdc15a4cddb219@mail.gmail.com> On Tue, Jan 6, 2009 at 10:41 AM, Matt Darby wrote: > On Jan 6, 2009, at 11:27 AM, David Chelimsky wrote: > >> On Tue, Jan 6, 2009 at 9:53 AM, Matt Darby wrote: >>> >>> I'm stumped. How would I go about specing the "update_sandbox" method? >>> # bids_controller: >>> def new >>> @bid = Bid.new >>> >>> respond_to do |wants| >>> wants.html { redirect_to job_bids_path(@job) } >>> wants.js { >>> update_sandbox do >>> render_to_string :partial => 'new', :locals => {:bid => @bid, >>> :job >>> => @job} >>> end >>> } >>> end >>> end >>> >>> Here is my 4789th stab at it: >>> # bids_controller_spec.rb >>> it "should render new template" do >>> sandbox = mock("Sandbox") >>> controller.stub!(:update_sandbox).and_return(sandbox) >>> sandbox.stub!(:render_to_string).with(:partial => 'new', :locals => >>> {:bid => @bid, :job => @job}) >>> >>> sandbox.should_receive(:render_to_string).with(:partial => 'new', >>> :locals => {:bid => @bid, :job => @job}) >>> controller.should_receive(:update_sandbox) >> >> I'm just guessing here, because I don't know what #update_sandbox >> does, but you probably want this to yield the sandbox: >> >> controller.should_receive(:update_sandbox).and_yield(sandbox) >> >> Let us know if that works. >> >> Cheers, >> David >> > > Unfortunately, I get the same result. Here is the #update_sandbox method: > > # application.rb > # RJS method to show new / edit partials > def update_sandbox(obj = nil, &block) > highlight_this_div = obj ? dom_id(obj) : :sandbox > > render :update do |page| > page[:error_div].hide > page.replace_html :sandbox, capture(&block) This call to capture(&block) is what's going to result in eval'ing the block w/ render_to_string in it. Since update_sandbox is being stubbed, it is never actually called, so it makes perfect sense that this call to capture which evals the &block is never called. I'd go for a higher level expectation here instead of specifying the internal behaviour of update_sandbox. Something like setting an expectation that specific stuff shows up in the output. HTH, David > page.visual_effect :scroll_to, :sandbox > page.visual_effect :highlight, highlight_this_div > end > end > > > Thanks for your help David! > > > >>> >>> xhr :get, :new >>> end >>> # => Mock 'Sandbox' expected :render_to_string with ({:partial=>"new", >>> :locals=>{:job=>#, :bid=>#>> @name="Bid_1015">}}) once, but received it 0 times >>> Any pointers would be greatly appreciated! >>> >>> >>> Thanks! >>> Matt Darby, M.S. >>> Rails | PHP | Linux | MySQL | IT >>> Email: matt /\at/\ matt-darby.com >>> Skype: matt-darby >>> Web: http://blog.matt-darby.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 sfeley at gmail.com Tue Jan 6 13:16:08 2009 From: sfeley at gmail.com (Stephen Eley) Date: Tue, 6 Jan 2009 13:16:08 -0500 Subject: [rspec-users] Help with controller spec? In-Reply-To: References: Message-ID: <1fb4df0901061016k68cb32aar79e1a46e2d77fae6@mail.gmail.com> On Tue, Jan 6, 2009 at 10:53 AM, Matt Darby wrote: > I'm stumped. How would I go about specing the "update_sandbox" method? I couldn't hope to compete with David's answer when it comes to specifics, but more generally, it occurs to me that your question is a little imprecise and that could point to part of the cognitive disconnect. You ask how to spec the method, but you're NOT specing the "update_sandbox" method in the example you posted. You're specing a controller's "new" action. Creating a stub or mock for a method isn't the same as specing it. A spec tests something to see if it does what it's supposed to. Mocking or stubbing is the opposite: instead of testing the method, you're pretending the method doesn't exist and replacing it with a cardboard cutout. Other things I noticed: 1.) There's really no point in putting identical stub!() and should_receive() declarations in the same example. should_receive() does everything stub!() does and slightly more. It replaces the method AND says "Complain if this doesn't get called." When you see them used in the same spec file, what you're usually seeing is stub!() in the "before" blocks just to replace external interfaces and make sure nothing breaks, and then should_receive() in multiple individual examples to prove that things called when they should. 2.) On that note, it's becoming more and more the accepted practice to have only one "should" per example. (Including "should_receives" or other mocks.) That way, if one of the expectations breaks, you'll know which one from the "it should..." text and won't have to look at individual lines. 3.) You _could_ probably make this spec work as it stands by changing the "update_sandbox" call to expect a Proc with the "render_to_string ..." block included; that's what actually happens when you call a method with a "do" block, you're passing it an anonymous Proc as a parameter. Tweak it enough and I'll bet you could get this to work. 4.) BUT, I agree with David, there's probably no point. At this level your spec becomes sort of trivial; you're not even testing behavior any more, you're testing for the existence of certain lines of code. Think big picture: WHY are you testing? What is it you want to prove? Your users don't care whether render_to_string() ever gets called with certain parameters, and tomorrow you won't care either. You DO care whether the controller's "new" method responds with an appropriate block of Javascript when accessed via AJAX. You can find that out by making the request and checking the response, but if you stub out the part that actually generates the Javascript, all you'll learn is "the controller get called and it responded." If that's all you want to know, you could mock update_sandbox to return "neener neener" and test for THAT. (And make sure to spec the update_sandbox() method thoroughly elsewhere.) 5.) OR... You might gain some good food for thought by going to the MerbCamp videos (http://merbcamp.com/video) and watching Yehuda Katz's video on testing (http://merbcamp.com/video/katz1.mp4). Don't worry about the Merb stuff; what he's describing is a general approach and it's just as applicable to Rails. The philosophy is somewhat contrary to the "unit test everything in isolation" philosophy that many others espouse, but it doesn't hurt to learn both and decide which style suits you best. I personally found Yehuda's approach to be a slap of cold water and then a breath of fresh air; since I started it, I've almost entirely stopped mocking things, and I no longer have the frustrating feeling that I'm spending 10x longer on tests (and testing my tests, and debugging my tests) than I am on my application features. But again: think for yourself, and decide what suits your goals and learning path. -- 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 Jan 6 13:24:02 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 6 Jan 2009 12:24:02 -0600 Subject: [rspec-users] Help with controller spec? In-Reply-To: <1fb4df0901061016k68cb32aar79e1a46e2d77fae6@mail.gmail.com> References: <1fb4df0901061016k68cb32aar79e1a46e2d77fae6@mail.gmail.com> Message-ID: <57c63afe0901061024n744d92f1h72ad696c23239fec@mail.gmail.com> On Tue, Jan 6, 2009 at 12:16 PM, Stephen Eley wrote: > On Tue, Jan 6, 2009 at 10:53 AM, Matt Darby wrote: >> I'm stumped. How would I go about specing the "update_sandbox" method? > > I couldn't hope to compete with David's answer when it comes to > specifics, but more generally, it occurs to me that your question is a > little imprecise and that could point to part of the cognitive > disconnect. You ask how to spec the method, but you're NOT specing > the "update_sandbox" method in the example you posted. You're specing > a controller's "new" action. Creating a stub or mock for a method > isn't the same as specing it. A spec tests something to see if it > does what it's supposed to. Mocking or stubbing is the opposite: > instead of testing the method, you're pretending the method doesn't > exist and replacing it with a cardboard cutout. > > Other things I noticed: > > 1.) There's really no point in putting identical stub!() and > should_receive() declarations in the same example. should_receive() > does everything stub!() does and slightly more. It replaces the > method AND says "Complain if this doesn't get called." When you see > them used in the same spec file, what you're usually seeing is stub!() > in the "before" blocks just to replace external interfaces and make > sure nothing breaks, and then should_receive() in multiple individual > examples to prove that things called when they should. > > 2.) On that note, it's becoming more and more the accepted practice to > have only one "should" per example. (Including "should_receives" or > other mocks.) That way, if one of the expectations breaks, you'll > know which one from the "it should..." text and won't have to look at > individual lines. > > 3.) You _could_ probably make this spec work as it stands by changing > the "update_sandbox" call to expect a Proc with the "render_to_string > ..." block included; that's what actually happens when you call a > method with a "do" block, you're passing it an anonymous Proc as a > parameter. Tweak it enough and I'll bet you could get this to work. > > 4.) BUT, I agree with David, there's probably no point. At this level > your spec becomes sort of trivial; you're not even testing behavior > any more, you're testing for the existence of certain lines of code. > Think big picture: WHY are you testing? What is it you want to prove? > Your users don't care whether render_to_string() ever gets called > with certain parameters, and tomorrow you won't care either. You DO > care whether the controller's "new" method responds with an > appropriate block of Javascript when accessed via AJAX. You can find > that out by making the request and checking the response, but if you > stub out the part that actually generates the Javascript, all you'll > learn is "the controller get called and it responded." If that's all > you want to know, you could mock update_sandbox to return "neener > neener" and test for THAT. (And make sure to spec the > update_sandbox() method thoroughly elsewhere.) > > 5.) OR... You might gain some good food for thought by going to the > MerbCamp videos (http://merbcamp.com/video) and watching Yehuda Katz's > video on testing (http://merbcamp.com/video/katz1.mp4). Don't worry > about the Merb stuff; what he's describing is a general approach and > it's just as applicable to Rails. The philosophy is somewhat contrary > to the "unit test everything in isolation" philosophy that many others > espouse, but it doesn't hurt to learn both and decide which style > suits you best. I'd refine that a bit: learn both and decide *when to apply each*. Choosing one style over the other limits your toolbox and consequently your ability to operate in different contexts. FWiW, David > > I personally found Yehuda's approach to be a slap of cold water and > then a breath of fresh air; since I started it, I've almost entirely > stopped mocking things, and I no longer have the frustrating feeling > that I'm spending 10x longer on tests (and testing my tests, and > debugging my tests) than I am on my application features. But again: > think for yourself, and decide what suits your goals and learning > path. > > > -- > 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 sfeley at gmail.com Tue Jan 6 13:50:28 2009 From: sfeley at gmail.com (Stephen Eley) Date: Tue, 6 Jan 2009 13:50:28 -0500 Subject: [rspec-users] Help with controller spec? In-Reply-To: <57c63afe0901061024n744d92f1h72ad696c23239fec@mail.gmail.com> References: <1fb4df0901061016k68cb32aar79e1a46e2d77fae6@mail.gmail.com> <57c63afe0901061024n744d92f1h72ad696c23239fec@mail.gmail.com> Message-ID: <1fb4df0901061050v56b4c7d1xc399d39307449ad6@mail.gmail.com> On Tue, Jan 6, 2009 at 1:24 PM, David Chelimsky wrote: > > I'd refine that a bit: learn both and decide *when to apply each*. > > Choosing one style over the other limits your toolbox and consequently > your ability to operate in different contexts. True, and good point. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From matt at matt-darby.com Tue Jan 6 13:53:28 2009 From: matt at matt-darby.com (Matt Darby) Date: Tue, 6 Jan 2009 13:53:28 -0500 Subject: [rspec-users] Help with controller spec? In-Reply-To: <1fb4df0901061016k68cb32aar79e1a46e2d77fae6@mail.gmail.com> References: <1fb4df0901061016k68cb32aar79e1a46e2d77fae6@mail.gmail.com> Message-ID: <3ECF52E4-93DE-47A1-BA0A-02992E0294C4@matt-darby.com> On Jan 6, 2009, at 1:16 PM, Stephen Eley wrote: > On Tue, Jan 6, 2009 at 10:53 AM, Matt Darby > wrote: >> I'm stumped. How would I go about specing the "update_sandbox" >> method? > > I couldn't hope to compete with David's answer when it comes to > specifics, but more generally, it occurs to me that your question is a > little imprecise and that could point to part of the cognitive > disconnect. You ask how to spec the method, but you're NOT specing > the "update_sandbox" method in the example you posted. You're specing > a controller's "new" action. Creating a stub or mock for a method > isn't the same as specing it. A spec tests something to see if it > does what it's supposed to. Mocking or stubbing is the opposite: > instead of testing the method, you're pretending the method doesn't > exist and replacing it with a cardboard cutout. > Hi Stephen! My aim is to spec the Bid::new action; all it really does is call the #update_sandbox method with a particular block. If I am to test strictly the behavior of the action, I would really just be testing the View as it's based on RJS. The View is spec'd, but I need to simulate the actual updating of the View via the returned Javascript. > Other things I noticed: > > 1.) There's really no point in putting identical stub!() and > should_receive() declarations in the same example. should_receive() > does everything stub!() does and slightly more. It replaces the > method AND says "Complain if this doesn't get called." When you see > them used in the same spec file, what you're usually seeing is stub!() > in the "before" blocks just to replace external interfaces and make > sure nothing breaks, and then should_receive() in multiple individual > examples to prove that things called when they should. > Good to know! That will really clean up my specs (and save me a ton of typing!) > 2.) On that note, it's becoming more and more the accepted practice to > have only one "should" per example. (Including "should_receives" or > other mocks.) That way, if one of the expectations breaks, you'll > know which one from the "it should..." text and won't have to look at > individual lines. > Agreed, however, I wasn't sure how to approach this case as I'm testing a method and a block at the same time. By the time I'd arrived at the spec I originally posted I was well into the "Grasping At Straws" phase. > 3.) You _could_ probably make this spec work as it stands by changing > the "update_sandbox" call to expect a Proc with the "render_to_string > ..." block included; that's what actually happens when you call a > method with a "do" block, you're passing it an anonymous Proc as a > parameter. Tweak it enough and I'll bet you could get this to work. > Duly noted. > 4.) BUT, I agree with David, there's probably no point. At this level > your spec becomes sort of trivial; you're not even testing behavior > any more, you're testing for the existence of certain lines of code. > Think big picture: WHY are you testing? What is it you want to prove? > Your users don't care whether render_to_string() ever gets called > with certain parameters, and tomorrow you won't care either. You DO > care whether the controller's "new" method responds with an > appropriate block of Javascript when accessed via AJAX. You can find > that out by making the request and checking the response, but if you > stub out the part that actually generates the Javascript, all you'll > learn is "the controller get called and it responded." If that's all > you want to know, you could mock update_sandbox to return "neener > neener" and test for THAT. (And make sure to spec the > update_sandbox() method thoroughly elsewhere.) > I don't necessarily care what #update_sandbox actually produces, I just want to make sure that it is called with the expected "render_to_string" call. Can you clarify "making the request and checking the response"? Is it possible to just check the "xhr :get, :index" call for a standard hunk of Javascript? If so, problem solved -- again, I don't yet have a super firm grip on controller specing when AJAX/RJS is concerned. I'm eagerly awaiting David's book! > 5.) OR... You might gain some good food for thought by going to the > MerbCamp videos (http://merbcamp.com/video) and watching Yehuda Katz's > video on testing (http://merbcamp.com/video/katz1.mp4). Don't worry > about the Merb stuff; what he's describing is a general approach and > it's just as applicable to Rails. The philosophy is somewhat contrary > to the "unit test everything in isolation" philosophy that many others > espouse, but it doesn't hurt to learn both and decide which style > suits you best. > I shall, thanks for the pointer. > I personally found Yehuda's approach to be a slap of cold water and > then a breath of fresh air; since I started it, I've almost entirely > stopped mocking things, and I no longer have the frustrating feeling > that I'm spending 10x longer on tests (and testing my tests, and > debugging my tests) than I am on my application features. But again: > think for yourself, and decide what suits your goals and learning > path. > Thank you for your reply, it was really very insightful and I'm sure others will learn from it as well! > > -- > 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 Jan 6 16:08:33 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 6 Jan 2009 22:08:33 +0100 Subject: [rspec-users] cucumber, finding a row in a table In-Reply-To: <85d99afe0901051507pd187422w2bf618459f0bf597@mail.gmail.com> References: <84f730e41b1773b44b0fd8a6dfd49cf8@ruby-forum.com> <85d99afe0901051507pd187422w2bf618459f0bf597@mail.gmail.com> Message-ID: <1e43aeb33748c276ad770eb033cf1fb7@ruby-forum.com> Zach Dennis wrote: > > Does your outputted HTML properly include a tbody in the table? If so > the selector you are using won't work. You would need to make match > any descendant rather than any direct child, ie: "table > tr#entity_id_1" > I cannot find one if there is. > On a related note (although not specific your problem at hand) to > generate an id on an ActiveRecord model you can use the dom_id helper > method provided by Rails. ie: "dom_id(entity)". You can use this both > in your template and your steps/specs. And rather than hardcoding > "table tr" CSS selectors why not just give your table an id like > "entities" and then use dom_id to give your rows ids? Should you > change the display to a ul or ol you wouldn't have to go back and > change your CSS selectors, Could you provide a reference to an example of how this is done? I am afraid that the API was insufficient to clarify this for me. Thank you for your help. -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Tue Jan 6 18:08:11 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 6 Jan 2009 23:08:11 +0000 Subject: [rspec-users] Cucumber: acceptance testing OAuth Message-ID: Hi, We're adding OAuth support for our API, and I paired with the guy who's spiked it today to try and write some features to drive out the behaviour we need. It ended up getting quite tricky, so if you don't mind I'd like to bounce my ideas of this list and see what you think. The spike uses the OAuth Provider plugin[1] which is what we're planning to integrate. This adds a ClientApplication model to your database. A ClientApplication represents, for example, the flickr uploader application that I've downlaoded. One User has many ClientApplications. A ClientApplication instance has a #key and a #secret which are stored on the server, and also known by the application on the client side which it represents. Anyway, so back to my Cucumber scenario. In the Given step, I create a User and a ClientApplication. Now I have to pretend to be the actual API client making a request to my rails app. At this point, I need to make some special magic OAuth parameters for the HTTP request, called 'signature' and 'signature_method'. These signify some magic munging of the key and secret for the ClientApplication which will (hopefully) be understood and processed by the SUT. In the real world, you would delegate the work of talking to an OAuth provider like this to the oauth gem[2]. I had a crack, for an hour or so, to use the gem in my When step, injecting a fake replacement for the Net::HTTP which it uses and instead forwarding calls to rails IntegrationSession post / get methods. This wasn't easy. Net::HTTPResponse objects don't look much like ActionController::CgiResponse objects, for example, so you have to do a lot of bridging. So I feel like it's time to pull back and have a re-think. Has anyone else tried to do something similar, and has some code to bridge from Net::HTTP objects to the ones used by Rails' Test::IntegrationSession? Am we barking up the wrong tree? Should we perhaps just spin up a web server for the test session and just go ahead and call the app through the gem? Any other ideas? Am I missing anything else obvious? All thoughts greatly appreciated guys! cheers, Matt Wynne http://blog.mattwynne.net http://www.songkick.com [1] http://github.com/pelle/oauth-plugin/tree/master [2] http://github.com/pelle/oauth/tree/master From ben at benmabey.com Tue Jan 6 18:29:53 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 06 Jan 2009 16:29:53 -0700 Subject: [rspec-users] Cucumber: acceptance testing OAuth In-Reply-To: References: Message-ID: <4963E971.2050507@benmabey.com> On 1/6/09 4:08 PM, Matt Wynne wrote: > Hi, > > We're adding OAuth support for our API, and I paired with the guy > who's spiked it today to try and write some features to drive out the > behaviour we need. > > It ended up getting quite tricky, so if you don't mind I'd like to > bounce my ideas of this list and see what you think. > > The spike uses the OAuth Provider plugin[1] which is what we're > planning to integrate. This adds a ClientApplication model to your > database. A ClientApplication represents, for example, the flickr > uploader application that I've downlaoded. One User has many > ClientApplications. > > A ClientApplication instance has a #key and a #secret which are stored > on the server, and also known by the application on the client side > which it represents. > > > Anyway, so back to my Cucumber scenario. > > In the Given step, I create a User and a ClientApplication. Now I have > to pretend to be the actual API client making a request to my rails app. > > At this point, I need to make some special magic OAuth parameters for > the HTTP request, called 'signature' and 'signature_method'. These > signify some magic munging of the key and secret for the > ClientApplication which will (hopefully) be understood and processed > by the SUT. > > In the real world, you would delegate the work of talking to an OAuth > provider like this to the oauth gem[2]. I had a crack, for an hour or > so, to use the gem in my When step, injecting a fake replacement for > the Net::HTTP which it uses and instead forwarding calls to rails > IntegrationSession post / get methods. > > This wasn't easy. Net::HTTPResponse objects don't look much like > ActionController::CgiResponse objects, for example, so you have to do > a lot of bridging. > > > So I feel like it's time to pull back and have a re-think. Has anyone > else tried to do something similar, and has some code to bridge from > Net::HTTP objects to the ones used by Rails' Test::IntegrationSession? > > Am we barking up the wrong tree? Should we perhaps just spin up a web > server for the test session and just go ahead and call the app through > the gem? > > Any other ideas? Am I missing anything else obvious? > > All thoughts greatly appreciated guys! > > cheers, > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > [1] http://github.com/pelle/oauth-plugin/tree/master > [2] http://github.com/pelle/oauth/tree/master > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Hey Matt, I don't know the first thing about OAuth and what integrating it into an app entails. Is it too much of a simplification in saying that it is a third-party webservice that you need to stub out the Net::HTTP requests for? If not, then this post may give you some ideas: http://technicalpickles.com/posts/stop-net-http-dead-in-its-tracks-with-fakeweb Sorry if this wasn't too much help.. I guess I don't understand what sort of "bridge from Net::HTTP objects to the ones used by Rails' Test::IntegrationSession" really means. -Ben From matt at mattwynne.net Tue Jan 6 19:33:20 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 7 Jan 2009 00:33:20 +0000 Subject: [rspec-users] Cucumber: acceptance testing OAuth In-Reply-To: <4963E971.2050507@benmabey.com> References: <4963E971.2050507@benmabey.com> Message-ID: <29787CC6-FAB9-4A95-B6D6-B30F4DF46B69@mattwynne.net> On 6 Jan 2009, at 23:29, Ben Mabey wrote: > On 1/6/09 4:08 PM, Matt Wynne wrote: >> Hi, >> >> We're adding OAuth support for our API, and I paired with the guy >> who's spiked it today to try and write some features to drive out >> the behaviour we need. >> >> It ended up getting quite tricky, so if you don't mind I'd like to >> bounce my ideas of this list and see what you think. >> >> The spike uses the OAuth Provider plugin[1] which is what we're >> planning to integrate. This adds a ClientApplication model to your >> database. A ClientApplication represents, for example, the flickr >> uploader application that I've downlaoded. One User has many >> ClientApplications. >> >> A ClientApplication instance has a #key and a #secret which are >> stored on the server, and also known by the application on the >> client side which it represents. >> >> >> Anyway, so back to my Cucumber scenario. >> >> In the Given step, I create a User and a ClientApplication. Now I >> have to pretend to be the actual API client making a request to my >> rails app. >> >> At this point, I need to make some special magic OAuth parameters >> for the HTTP request, called 'signature' and 'signature_method'. >> These signify some magic munging of the key and secret for the >> ClientApplication which will (hopefully) be understood and >> processed by the SUT. >> >> In the real world, you would delegate the work of talking to an >> OAuth provider like this to the oauth gem[2]. I had a crack, for an >> hour or so, to use the gem in my When step, injecting a fake >> replacement for the Net::HTTP which it uses and instead forwarding >> calls to rails IntegrationSession post / get methods. >> >> This wasn't easy. Net::HTTPResponse objects don't look much like >> ActionController::CgiResponse objects, for example, so you have to >> do a lot of bridging. >> >> >> So I feel like it's time to pull back and have a re-think. Has >> anyone else tried to do something similar, and has some code to >> bridge from Net::HTTP objects to the ones used by Rails' >> Test::IntegrationSession? >> >> Am we barking up the wrong tree? Should we perhaps just spin up a >> web server for the test session and just go ahead and call the app >> through the gem? >> >> Any other ideas? Am I missing anything else obvious? >> >> All thoughts greatly appreciated guys! >> >> cheers, >> >> Matt Wynne >> http://blog.mattwynne.net >> http://www.songkick.com >> >> [1] http://github.com/pelle/oauth-plugin/tree/master >> [2] http://github.com/pelle/oauth/tree/master >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > Hey Matt, > I don't know the first thing about OAuth and what integrating it > into an app entails. Is it too much of a simplification in saying > that it is a third-party webservice that you need to stub out the > Net::HTTP requests for? If not, then this post may give you some > ideas: > http://technicalpickles.com/posts/stop-net-http-dead-in-its-tracks-with-fakeweb > > Sorry if this wasn't too much help.. I guess I don't understand what > sort of "bridge from Net::HTTP objects to the ones used by Rails' > Test::IntegrationSession" really means. Yeah I know that was pretty rambling. Let me have another go at explaining what I'm trying to do, for the benefit of anyone else who might be wondering what I'm on about. Real world: API Client -> OAuth Gem -> Net::HTTP -> (The Internet) -> My Rails App So in order to acceptance-test my Rails app's OAuth features, I need to make requests that look a lot like the ones made by the OAuth gem when the API client asks it to call my Rails app and authenticate itself. So it's not so much that Net::HTTP is a dependency I want to stub out, as it's a test-driver I want to leverage. I had figured I might be able to do something like this: Cucumber Steps -> OAuth Gem -> Patched Net::HTTP -> Test::IntegrationSession -> My Rails App The 'bridge' I'm talking about is something that looks enough like Net::HTTP for the OAuth gem to be happy to talk to it, but that will actually pass on it's calls to the Rails Test::IntegrationSession get / post methods, and pass back the response. Does that make any more sense? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From zach.dennis at gmail.com Tue Jan 6 19:53:55 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Tue, 6 Jan 2009 19:53:55 -0500 Subject: [rspec-users] cucumber, finding a row in a table In-Reply-To: <1e43aeb33748c276ad770eb033cf1fb7@ruby-forum.com> References: <84f730e41b1773b44b0fd8a6dfd49cf8@ruby-forum.com> <85d99afe0901051507pd187422w2bf618459f0bf597@mail.gmail.com> <1e43aeb33748c276ad770eb033cf1fb7@ruby-forum.com> Message-ID: <85d99afe0901061653m3ffdbb77ma1d36aebf64ef59f@mail.gmail.com> On Tue, Jan 6, 2009 at 4:08 PM, James Byrne wrote: > Zach Dennis wrote: >> >> Does your outputted HTML properly include a tbody in the table? If so >> the selector you are using won't work. You would need to make match >> any descendant rather than any direct child, ie: "table >> tr#entity_id_1" >> > > I cannot find one if there is. > >> On a related note (although not specific your problem at hand) to >> generate an id on an ActiveRecord model you can use the dom_id helper >> method provided by Rails. ie: "dom_id(entity)". You can use this both >> in your template and your steps/specs. And rather than hardcoding >> "table tr" CSS selectors why not just give your table an id like >> "entities" and then use dom_id to give your rows ids? Should you >> change the display to a ul or ol you wouldn't have to go back and >> change your CSS selectors, > > Could you provide a reference to an example of how this is done? I am > afraid that the API was insufficient to clarify this for me. > When constructing HTML ids you can avoid concatenating strings, ie: "entity_id_" + my_entity.to_s Instead you can use this: dom_id(entity) You can also pass in additional identifiers: dom_id(entity, "show") If you use this in your steps and in your views themselves it cleans generating html ids up. In my cucumber env.rb I have added so the dom helpers are available throughout my steps Cucumber::Rails::World.class_eval do include ActionView::Helpers::RecordIdentificationHelper end Hope this helps, -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From mark at markrichman.com Tue Jan 6 20:25:09 2009 From: mark at markrichman.com (Mark A. Richman) Date: Tue, 6 Jan 2009 20:25:09 -0500 Subject: [rspec-users] Fixing "expected success? to return true, got false" Message-ID: I am trying to get the following test to pass, and get this error. Since I'm only on day 4 of rspec, I'm sure I'm missing something simple. Any ideas? ## rake spec 'PatientsController GET 'new' should be successful' FAILED expected success? to return true, got false ./spec/controllers/patients_controller_spec.rb:27: ## patients_controller_spec.rb require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe PatientsController do integrate_views fixtures :all before(:each) do @user = mock_user @login_params = { :login => 'quentin', :password => 'monkey' } User.stub!(:authenticate).with(@login_params[:login], @login_params[:password]).and_return(@user) @user.stub!(:enabled?).and_return(true) @user.stub!(:account_id).and_return(1) @user.stub!(:time_zone).and_return('Eastern Time (US & Canada)') @user.stub!(:role).and_return('Normal') controller_bypass_authentication(@user) end #Delete these examples and add some real ones it "should use PatientsController" do controller.should be_an_instance_of(PatientsController) end describe "GET 'new'" do it "should be successful" do get 'new' response.should be_success # this is the offending line 27 end end end # Allows a spec to bypass auth for controllers that filter for logged_in user def controller_bypass_authentication(user=nil) controller.stub!(:logged_in).and_return(true) controller.stub!(:authorized?).and_return(true) controller.stub!(:current_user).and_return(user) end ## patients_controller.rb ... def new @patient = Patient.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @patient } end end ... http://www.pastie.org/354313 -------------- next part -------------- An HTML attachment was scrubbed... URL: From cougar2149 at gmail.com Wed Jan 7 01:29:50 2009 From: cougar2149 at gmail.com (waseem ahmad) Date: Wed, 7 Jan 2009 11:59:50 +0530 Subject: [rspec-users] Error: undefined method `use_transactional_fixtures Message-ID: Hi, I get this error when I do $spec /spec/any_spec /home/waseem/app/spec/spec_helper.rb:14: undefined method `use_transactional_fixtures=' for # (NoMethodError) from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:184:in `configure' from /home/waseem/app/spec/spec_helper.rb:10 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from ./spec/controllers/user_sessions_controller_spec.rb:1 from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:14:in `load' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:14:in `load_files' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:13:in `each' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:13:in `load_files' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in `run_examples' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/command_line.rb:10:in `run' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/bin/spec:4 from /usr/bin/spec:19:in `load' from /usr/bin/spec:19 I googled it and got http://ryandaigle.com/articles/2008/11/19/what-s-new-in-edge-rails-application-rb-duality-is-no-moresee Maxim's comment What could be possibly wrong? -- Waseem RwrWrwRwrWrwRwrWrwRwrWrwRwwwwwwww............ Blog: http://babygnu.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From f.mischa at gmail.com Wed Jan 7 02:23:42 2009 From: f.mischa at gmail.com (Mischa Fierer) Date: Wed, 7 Jan 2009 01:23:42 -0600 Subject: [rspec-users] Error: undefined method `use_transactional_fixtures In-Reply-To: References: Message-ID: this may help: http://themomorohoax.com/2008/12/17/rails-2-3-tests On Wed, Jan 7, 2009 at 12:29 AM, waseem ahmad wrote: > Hi, > > I get this error when I do > > $spec /spec/any_spec > > /home/waseem/app/spec/spec_helper.rb:14: undefined method > `use_transactional_fixtures=' for # > (NoMethodError) > from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:184:in > `configure' > from /home/waseem/app/spec/spec_helper.rb:10 > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require' > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in > `require' > from ./spec/controllers/user_sessions_controller_spec.rb:1 > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:14:in > `load' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:14:in > `load_files' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:13:in > `each' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:13:in > `load_files' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in > `run_examples' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/command_line.rb:10:in > `run' > from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/bin/spec:4 > from /usr/bin/spec:19:in `load' > from /usr/bin/spec:19 > > I googled it and got > http://ryandaigle.com/articles/2008/11/19/what-s-new-in-edge-rails-application-rb-duality-is-no-moresee Maxim's comment > > What could be possibly wrong? > -- > Waseem > RwrWrwRwrWrwRwrWrwRwrWrwRwwwwwwww............ > Blog: http://babygnu.blogspot.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 dchelimsky at gmail.com Wed Jan 7 04:25:57 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 7 Jan 2009 03:25:57 -0600 Subject: [rspec-users] Error: undefined method `use_transactional_fixtures In-Reply-To: References: Message-ID: <57c63afe0901070125o5d8f2e73wcca3dfc63ae7728c@mail.gmail.com> On Wed, Jan 7, 2009 at 12:29 AM, waseem ahmad wrote: > Hi, > > I get this error when I do > > $spec /spec/any_spec > > /home/waseem/app/spec/spec_helper.rb:14: undefined method > `use_transactional_fixtures=' for # > (NoMethodError) > from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:184:in > `configure' > from /home/waseem/app/spec/spec_helper.rb:10 > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require' > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in > `require' > from ./spec/controllers/user_sessions_controller_spec.rb:1 > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:14:in > `load' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:14:in > `load_files' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:13:in > `each' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:13:in > `load_files' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in > `run_examples' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/command_line.rb:10:in > `run' > from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/bin/spec:4 > from /usr/bin/spec:19:in `load' > from /usr/bin/spec:19 > > I googled it and got > http://ryandaigle.com/articles/2008/11/19/what-s-new-in-edge-rails-application-rb-duality-is-no-more > see Maxim's comment > > What could be possibly wrong? Seems like it's not loading up rspec-rails' Configuration object. In order for that to happen implicitly, the specs need to be in any of spec/models, spec/controllers, spec/views, spec/helpers. Is your file in one of those? > -- > Waseem > RwrWrwRwrWrwRwrWrwRwrWrwRwwwwwwww............ > Blog: http://babygnu.blogspot.com From colinjack at hotmail.com Wed Jan 7 04:31:46 2009 From: colinjack at hotmail.com (Colin Jack) Date: Wed, 7 Jan 2009 09:31:46 +0000 Subject: [rspec-users] Cucumber - Performance Message-ID: Hi, Small question on performance. I've just run the CS example provided with Cucumber and it took about 45-50 seconds before the first output appeared in the console, but once this first output had appeared the tests completed quickly. I'm wondering whether this is the expected performance or whether the plan is to optimize it at some time in the future? Ta, Colin _________________________________________________________________ Are you a PC?? Upload your PC story and show the world http://clk.atdmt.com/UKM/go/122465942/direct/01/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From cougar2149 at gmail.com Wed Jan 7 04:49:27 2009 From: cougar2149 at gmail.com (waseem ahmad) Date: Wed, 7 Jan 2009 15:19:27 +0530 Subject: [rspec-users] Error: undefined method `use_transactional_fixtures In-Reply-To: <57c63afe0901070125o5d8f2e73wcca3dfc63ae7728c@mail.gmail.com> References: <57c63afe0901070125o5d8f2e73wcca3dfc63ae7728c@mail.gmail.com> Message-ID: On Wed, Jan 7, 2009 at 2:55 PM, David Chelimsky wrote: > Seems like it's not loading up rspec-rails' Configuration object. In > order for that to happen implicitly, the specs need to be in any of > spec/models, spec/controllers, spec/views, spec/helpers. Is your file > in one of those? > > Yeah the file is spec/controllers/user_sessions_controller.rb @Mischa: The pointer you gave talks about rails edge. Right now I am on rails 2.1 -- Waseem RwrWrwRwrWrwRwrWrwRwrWrwRwwwwwwww............ Blog: http://babygnu.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Wed Jan 7 06:36:45 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 7 Jan 2009 11:36:45 +0000 Subject: [rspec-users] Fixing "expected success? to return true, got false" In-Reply-To: References: Message-ID: <79185472-8D9D-4759-9820-49641E9D58F2@mattwynne.net> On 7 Jan 2009, at 01:25, Mark A. Richman wrote: > I am trying to get the following test to pass, and get this error. > Since I'm only on day 4 of rspec, I'm sure I'm missing something > simple. Any ideas? > ## rake spec > > 'PatientsController GET 'new' should be successful' FAILED > > expected success? to return true, got false > ./spec/controllers/patients_controller_spec.rb:27: > > ## patients_controller_spec.rb > > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > > > describe PatientsController do > > integrate_views > fixtures :all > > before(:each) do > @user = mock_user > @login_params = { :login => 'quentin', :password => 'monkey' } > > User.stub!(:authenticate).with(@login_params[:login], > @login_params[:password]).and_return(@user) > @user.stub!(:enabled?).and_return(true) > @user.stub!(:account_id).and_return(1) > @user.stub!(:time_zone).and_return('Eastern Time (US & Canada)') > > @user.stub!(:role).and_return('Normal') > controller_bypass_authentication(@user) > end > > #Delete these examples and add some real ones > it "should use PatientsController" do > > controller.should be_an_instance_of(PatientsController) > end > > describe "GET 'new'" do > it "should be successful" do > get 'new' > response.should be_success # this is the offending line 27 > > end > end > end > > # Allows a spec to bypass auth for controllers that filter for > logged_in user > def controller_bypass_authentication(user=nil) > controller.stub!(:logged_in).and_return(true) > controller.stub!(:authorized?).and_return(true) > > controller.stub!(:current_user).and_return(user) > end > > ## patients_controller.rb > > ... > def new > @patient = Patient.new > > respond_to do |format| > format.html # new.html.erb > format.xml { render :xml => @patient } > > end > end > ... > http://www.pastie.org/354313 I don't think there's enough to go on here. We need to know why the request failed, and it could be for any number of reasons. You've shown us a load of test setup code for stubbing out your authentication mechanism, but you haven't shown us the actual authentication mechanism in your controller, so we have no way of knowing whether your stubs are good. I would start your debugging by adding a puts statement between lines 26 and 27 to show more of the (unexpected) response. Looking at response.code or response.body should give you some clues. By the way, did you know you can pass hashes of stubs to the mock() method? You could clean up your setup code quite a bit by doing this: @user = mock(User, :enabled? => true, :account_id => 1, :time_zone => 'Eastern Time (US & Canada)', :role => 'Normal') HTH, Matt Wynne http://blog.mattwynne.net http://www.songkick.com From aslak.hellesoy at gmail.com Wed Jan 7 06:46:14 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 7 Jan 2009 12:46:14 +0100 Subject: [rspec-users] Cucumber - Performance In-Reply-To: References: Message-ID: <8d961d900901070346k4e452dcfva2edd0123e2ef7c0@mail.gmail.com> On Wed, Jan 7, 2009 at 10:31 AM, Colin Jack wrote: > Hi, > > Small question on performance. I've just run the CS example provided with > Cucumber and it took about 45-50 seconds before the first output appeared in > the console, but once this first output had appeared the tests completed > quickly. > > I'm wondering whether this is the expected performance or whether the plan > is to optimize it at some time in the future? > > The reason it's so slow is that IronRuby is slow. That's where the optimisation will have to happen. It runs "fast" on JRuby, MRI and YARV. Aslak > > Ta, > > Colin > > ------------------------------ > Are you a PC? Upload your PC story and show the world > > _______________________________________________ > 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 matt at mattwynne.net Wed Jan 7 06:52:11 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 7 Jan 2009 11:52:11 +0000 Subject: [rspec-users] Cucumber - Performance In-Reply-To: References: Message-ID: <2A03B818-5EF1-42F6-A7FD-9FE8D176AC6F@mattwynne.net> On 7 Jan 2009, at 09:31, Colin Jack wrote: > Hi, > > Small question on performance. I've just run the CS example provided > with Cucumber and it took about 45-50 seconds before the first > output appeared in the console, but once this first output had > appeared the tests completed quickly. > > I'm wondering whether this is the expected performance or whether > the plan is to optimize it at some time in the future? I normally just use MRI to run Cucumber, but I have tried JRuby a couple of times and noticed that was a bit slower to start up. I'd guess it's something similar with IronRuby - .NET apps are often slow to start up the first time in my experience, as the JIT compilation kicks in or whatever magic it is these days. Have you tried running any other Ruby tools through IronRuby? How do they perform? If you think it's a bug in Cucumber (even if one specific to running on the IronRuby platform) please raise a ticket at lighthouse[1]. Obviously the more you can do to diagnose the fault, the faster it's likely to be fixed. [1]http://rspec.lighthouseapp.com/projects/16211-cucumber/overview Matt Wynne http://blog.mattwynne.net http://www.songkick.com From matt at mattwynne.net Wed Jan 7 06:55:27 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 7 Jan 2009 11:55:27 +0000 Subject: [rspec-users] Cucumber - Performance In-Reply-To: <8d961d900901070346k4e452dcfva2edd0123e2ef7c0@mail.gmail.com> References: <8d961d900901070346k4e452dcfva2edd0123e2ef7c0@mail.gmail.com> Message-ID: <22FA105F-8A20-4CDB-B4EA-22C1BF506397@mattwynne.net> On 7 Jan 2009, at 11:46, aslak hellesoy wrote: > > > On Wed, Jan 7, 2009 at 10:31 AM, Colin Jack > wrote: > Hi, > > Small question on performance. I've just run the CS example provided > with Cucumber and it took about 45-50 seconds before the first > output appeared in the console, but once this first output had > appeared the tests completed quickly. > > I'm wondering whether this is the expected performance or whether > the plan is to optimize it at some time in the future? > > > The reason it's so slow is that IronRuby is slow. That's where the > optimisation will have to happen. It runs "fast" on JRuby, MRI and > YARV. My guess is that it's the initial start-up that's slow. This is a great reason to use something like autotest, which will keep the process loaded up. I wonder how that hell you could make that work with C# code though! Watch the DLLs?! Matt Wynne http://blog.mattwynne.net http://www.songkick.com From mark at markrichman.com Wed Jan 7 07:55:38 2009 From: mark at markrichman.com (Mark A. Richman) Date: Wed, 7 Jan 2009 07:55:38 -0500 Subject: [rspec-users] Fixing "expected success? to return true, got false" In-Reply-To: <79185472-8D9D-4759-9820-49641E9D58F2@mattwynne.net> References: <79185472-8D9D-4759-9820-49641E9D58F2@mattwynne.net> Message-ID: Matt, Thank you very much. It turns out that a pair of authentication/authorization before_filters were interfering with the test. I got past it now by doing this: before(:each) do @user = mock_user @login_params = { :login => 'quentin', :password => 'monkey' } User.stub!(:authenticate).with(@login_params[:login], @login_params[:password]).and_return(@user) @user.stub!(:enabled?).and_return(true) @user.stub!(:account_id).and_return(1) @user.stub!(:time_zone).and_return('Eastern Time (US & Canada)') @user.stub!(:role).and_return('normal') User.stub!(:in_role?).with('limited').and_return(false) controller_bypass_authentication(@user) end I've got 3 roles in my app (admin, normal, and limited), in case you were curious about that. I didn't know about the hash trick. Thanks! - Mark On Wed, Jan 7, 2009 at 6:36 AM, Matt Wynne wrote: > On 7 Jan 2009, at 01:25, Mark A. Richman wrote: > > I am trying to get the following test to pass, and get this error. Since >> I'm only on day 4 of rspec, I'm sure I'm missing something simple. Any >> ideas? >> ## rake spec >> >> 'PatientsController GET 'new' should be successful' FAILED >> >> expected success? to return true, got false >> ./spec/controllers/patients_controller_spec.rb:27: >> >> ## patients_controller_spec.rb >> >> require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') >> >> >> describe PatientsController do >> >> integrate_views >> fixtures :all >> >> before(:each) do >> @user = mock_user >> @login_params = { :login => 'quentin', :password => 'monkey' } >> >> User.stub!(:authenticate).with(@login_params[:login], >> @login_params[:password]).and_return(@user) >> @user.stub!(:enabled?).and_return(true) >> @user.stub!(:account_id).and_return(1) >> @user.stub!(:time_zone).and_return('Eastern Time (US & Canada)') >> >> @user.stub!(:role).and_return('Normal') >> controller_bypass_authentication(@user) >> end >> >> #Delete these examples and add some real ones >> it "should use PatientsController" do >> >> controller.should be_an_instance_of(PatientsController) >> end >> >> describe "GET 'new'" do >> it "should be successful" do >> get 'new' >> response.should be_success # this is the offending line 27 >> >> end >> end >> end >> >> # Allows a spec to bypass auth for controllers that filter for logged_in >> user >> def controller_bypass_authentication(user=nil) >> controller.stub!(:logged_in).and_return(true) >> controller.stub!(:authorized?).and_return(true) >> >> controller.stub!(:current_user).and_return(user) >> end >> >> ## patients_controller.rb >> >> ... >> def new >> @patient = Patient.new >> >> respond_to do |format| >> format.html # new.html.erb >> format.xml { render :xml => @patient } >> >> end >> end >> ... >> http://www.pastie.org/354313 >> > > I don't think there's enough to go on here. We need to know why the request > failed, and it could be for any number of reasons. You've shown us a load of > test setup code for stubbing out your authentication mechanism, but you > haven't shown us the actual authentication mechanism in your controller, so > we have no way of knowing whether your stubs are good. > > I would start your debugging by adding a puts statement between lines 26 > and 27 to show more of the (unexpected) response. Looking at response.code > or response.body should give you some clues. > > By the way, did you know you can pass hashes of stubs to the mock() method? > > You could clean up your setup code quite a bit by doing this: > > @user = mock(User, > :enabled? => true, > :account_id => 1, > :time_zone => 'Eastern Time (US & Canada)', > :role => 'Normal') > > HTH, > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.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 tero at tilus.net Wed Jan 7 09:11:48 2009 From: tero at tilus.net (Tero Tilus) Date: Wed, 7 Jan 2009 16:11:48 +0200 Subject: [rspec-users] Examples not getting rolled back... Message-ID: <20090107141148.GA15510@uivelo.tilus.net> I assume there's now something I'm totally missing here. I'm creating stuff in examples, just plain Foo.create, and the results aren't getting rolled back. I'm keep getting the following kind of pattern in my logs ... log from example starts here ... SQL (0.0ms) BEGIN SQL (0.0ms) BEGIN ClassFoo Create (0.2ms) INSERT ... Group Load (0.4ms) SELECT ... Contains Create (0.2ms) INSERT ... ... other stuff from example, no transaction stuff ... SQL (1.9ms) COMMIT SQL (0.1ms) ROLLBACK ... log from example ends here ... all examples of the following form produce it describe ClassFoo do ... it "plim-ploms" do foo = ClassFoo.create ... end ... end I'm just wondering if this is caused by those nested transactions. MySQL (which I happen to use) doesn't support nested transactions and is documented to just silently commit open transaction on new BEGIN. Taken that I'd expect last ROLLBACK not to have any effect. Where do those transactions come from? I'd guess outer transaction to be from RSpec and inner from ActiveRecord (oh, I'm on Rails). And of course, what can I do about this... A bit more stuff in pastie http://pastie.org/354521 -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From scott at railsnewbie.com Wed Jan 7 10:19:37 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Wed, 07 Jan 2009 10:19:37 -0500 Subject: [rspec-users] Cucumber - Performance In-Reply-To: <22FA105F-8A20-4CDB-B4EA-22C1BF506397@mattwynne.net> References: <8d961d900901070346k4e452dcfva2edd0123e2ef7c0@mail.gmail.com> <22FA105F-8A20-4CDB-B4EA-22C1BF506397@mattwynne.net> Message-ID: <4964C809.1020604@railsnewbie.com> Matt Wynne wrote: > > On 7 Jan 2009, at 11:46, aslak hellesoy wrote: > >> >> >> On Wed, Jan 7, 2009 at 10:31 AM, Colin Jack >> wrote: >> Hi, >> >> Small question on performance. I've just run the CS example provided >> with Cucumber and it took about 45-50 seconds before the first output >> appeared in the console, but once this first output had appeared the >> tests completed quickly. >> >> I'm wondering whether this is the expected performance or whether the >> plan is to optimize it at some time in the future? >> >> >> The reason it's so slow is that IronRuby is slow. That's where the >> optimisation will have to happen. It runs "fast" on JRuby, MRI and YARV. > > My guess is that it's the initial start-up that's slow. This is a > great reason to use something like autotest, which will keep the > process loaded up. I wonder how that hell you could make that work > with C# code though! Watch the DLLs?! Autotest doesn't keep the process running - it invokes a new process by shelling out (Kernel#`) Scott From stevemolitor at gmail.com Wed Jan 7 12:23:17 2009 From: stevemolitor at gmail.com (Steve Molitor) Date: Wed, 7 Jan 2009 11:23:17 -0600 Subject: [rspec-users] Constraints / Global requirements Message-ID: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> I have two related questions: What is the best way to express global requirements, and how does one do it in Cucumber. The first question is the one I'm most interested in right now. By a global requirement I'm talking about requirements like 'all emails must be formatted like this...' Some people call them constraints, but I'm focusing on UI or business rules, not technical things. I can think of two approaches: put the global constraints in one place and reference these features in other features. The other point of view is that no, we want to see these rules in every feature that uses them, so we (customers, BAs, developers, testers) can see everything in one place. For example I can reference the different valid and invalid email scenarios in both the 'add new patient' and the 'add new doctor' features. Or I can copy and paste the email scenarios directly into the 'add new patient' and the 'add new doctor' features. As a DRY infected developer I prefer the first approach. However I have not found a simple way to have one cucumber feature reference or 'include' another, and have both features get executed. Perhaps partially for that reason, other people on my project want to use the second approach as it seems more straight forward. I realize I can reuse steps. But I want to reference the actual feature in another. To pick a more important example, in my past life I worked on a big leasing application with lots of formulas: to compute the cost of a lease, the cost of fuel cards, the cost of different levels of insurance, etc. I'm going to simply a lot, but say the formula for computing the sales tax is 'subtotal + subtotal * 0.5'. Calculating the sales tax is one feature. Two other features are 'compute lease cost' and 'compute fuel card cost'. They both need to add sales tax. This was before cumber and stories, but some of us preferred the specifications to look like this: LEASE COST FORMULA: a + b + sales tax. Others, especially the testers, preferred: a + b + (a + b * 0.5) In real life the sales (and use) tax calculation was quite complex and changed. When it changed this broke many manual test plan and invalidated many use cases. If we were using cucumber with the second approach it would break many features. Sorry for rambling on so long but I've found this is a hard question to articulate. Steve -------------- next part -------------- An HTML attachment was scrubbed... URL: From sfeley at gmail.com Wed Jan 7 12:40:12 2009 From: sfeley at gmail.com (Stephen Eley) Date: Wed, 7 Jan 2009 12:40:12 -0500 Subject: [rspec-users] Fixing "expected success? to return true, got false" In-Reply-To: <79185472-8D9D-4759-9820-49641E9D58F2@mattwynne.net> References: <79185472-8D9D-4759-9820-49641E9D58F2@mattwynne.net> Message-ID: <1fb4df0901070940s46d8eedfu3273039271769ac8@mail.gmail.com> On Wed, Jan 7, 2009 at 6:36 AM, Matt Wynne wrote: > > I would start your debugging by adding a puts statement between lines 26 and > 27 to show more of the (unexpected) response. Looking at response.code or > response.body should give you some clues. You can also check the logfiles. I often keep two terminals running in the background whenever I'm doing BDD coding; one's running autospec, and the other one has 'tail -f log/test.log'. I don't have to look at that all the time, but when something breaks and I can't figure out why it's a huge time saver. I also found this post of Ben Mabey's to be very useful for figuring out which chunk of log goes with which spec: http://www.benmabey.com/2008/07/04/global-setup-in-rspec-or-how-to-add-logging-for-specs/ -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From sfeley at gmail.com Wed Jan 7 13:04:52 2009 From: sfeley at gmail.com (Stephen Eley) Date: Wed, 7 Jan 2009 13:04:52 -0500 Subject: [rspec-users] Examples not getting rolled back... In-Reply-To: <20090107141148.GA15510@uivelo.tilus.net> References: <20090107141148.GA15510@uivelo.tilus.net> Message-ID: <1fb4df0901071004v6e0b5f99y44096ba412829b46@mail.gmail.com> On Wed, Jan 7, 2009 at 9:11 AM, Tero Tilus wrote: > > I'm creating stuff in examples, just plain Foo.create, and the results > aren't getting rolled back. I'm keep getting the following kind of > pattern in my logs You probably thought about this already, but did you check the setting of config.use_transactional_fixtures in config.spec_helper.rb? -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From mark at markrichman.com Wed Jan 7 13:05:56 2009 From: mark at markrichman.com (Mark A. Richman) Date: Wed, 7 Jan 2009 13:05:56 -0500 Subject: [rspec-users] Fixing "expected success? to return true, got false" In-Reply-To: <1fb4df0901070940s46d8eedfu3273039271769ac8@mail.gmail.com> References: <79185472-8D9D-4759-9820-49641E9D58F2@mattwynne.net> <1fb4df0901070940s46d8eedfu3273039271769ac8@mail.gmail.com> Message-ID: Steve, That's really useful! Thank you. - Mark On Wed, Jan 7, 2009 at 12:40 PM, Stephen Eley wrote: > On Wed, Jan 7, 2009 at 6:36 AM, Matt Wynne wrote: > > > > I would start your debugging by adding a puts statement between lines 26 > and > > 27 to show more of the (unexpected) response. Looking at response.code or > > response.body should give you some clues. > > You can also check the logfiles. I often keep two terminals running > in the background whenever I'm doing BDD coding; one's running > autospec, and the other one has 'tail -f log/test.log'. I don't have > to look at that all the time, but when something breaks and I can't > figure out why it's a huge time saver. I also found this post of Ben > Mabey's to be very useful for figuring out which chunk of log goes > with which spec: > > > http://www.benmabey.com/2008/07/04/global-setup-in-rspec-or-how-to-add-logging-for-specs/ > > > > -- > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at mwilden.com Wed Jan 7 13:20:25 2009 From: mark at mwilden.com (Mark Wilden) Date: Wed, 7 Jan 2009 10:20:25 -0800 Subject: [rspec-users] Error: undefined method `use_transactional_fixtures In-Reply-To: References: <57c63afe0901070125o5d8f2e73wcca3dfc63ae7728c@mail.gmail.com> Message-ID: <3c30da400901071020v50e39a00kab08b608ac4400d7@mail.gmail.com> FWIW, I was getting this error yesterday. I completely uninstalled rspec and rspec-rails (including David's code from GitHub) and reinstalled, and it "went away." ///ark On Wed, Jan 7, 2009 at 1:49 AM, waseem ahmad wrote: > > > On Wed, Jan 7, 2009 at 2:55 PM, David Chelimsky wrote: > >> Seems like it's not loading up rspec-rails' Configuration object. In >> order for that to happen implicitly, the specs need to be in any of >> spec/models, spec/controllers, spec/views, spec/helpers. Is your file >> in one of those? >> >> > Yeah the file is spec/controllers/user_sessions_controller.rb > > @Mischa: The pointer you gave talks about rails edge. Right now I am on > rails 2.1 > > -- > Waseem > RwrWrwRwrWrwRwrWrwRwrWrwRwwwwwwww............ > Blog: http://babygnu.blogspot.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 dchelimsky at gmail.com Wed Jan 7 13:26:32 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 7 Jan 2009 12:26:32 -0600 Subject: [rspec-users] Error: undefined method `use_transactional_fixtures In-Reply-To: <3c30da400901071020v50e39a00kab08b608ac4400d7@mail.gmail.com> References: <57c63afe0901070125o5d8f2e73wcca3dfc63ae7728c@mail.gmail.com> <3c30da400901071020v50e39a00kab08b608ac4400d7@mail.gmail.com> Message-ID: <57c63afe0901071026n2207e5e9h630b996639070431@mail.gmail.com> On Wed, Jan 7, 2009 at 12:20 PM, Mark Wilden wrote: > FWIW, I was getting this error yesterday. I completely uninstalled rspec and > rspec-rails (including David's code from GitHub) and reinstalled, and it > "went away." Which version did you install after removing everything? > > ///ark > > On Wed, Jan 7, 2009 at 1:49 AM, waseem ahmad wrote: >> >> >> On Wed, Jan 7, 2009 at 2:55 PM, David Chelimsky >> wrote: >>> >>> Seems like it's not loading up rspec-rails' Configuration object. In >>> order for that to happen implicitly, the specs need to be in any of >>> spec/models, spec/controllers, spec/views, spec/helpers. Is your file >>> in one of those? >>> >> >> Yeah the file is spec/controllers/user_sessions_controller.rb >> >> @Mischa: The pointer you gave talks about rails edge. Right now I am on >> rails 2.1 >> >> -- >> Waseem >> RwrWrwRwrWrwRwrWrwRwrWrwRwwwwwwww............ >> Blog: http://babygnu.blogspot.com >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tero at tilus.net Wed Jan 7 13:26:44 2009 From: tero at tilus.net (Tero Tilus) Date: Wed, 7 Jan 2009 20:26:44 +0200 Subject: [rspec-users] Examples not getting rolled back... In-Reply-To: <1fb4df0901071004v6e0b5f99y44096ba412829b46@mail.gmail.com> References: <20090107141148.GA15510@uivelo.tilus.net> <1fb4df0901071004v6e0b5f99y44096ba412829b46@mail.gmail.com> Message-ID: <20090107182644.GA5784@uivelo.tilus.net> 2009-01-07 13:04, Stephen Eley: > config.use_transactional_fixtures in config.spec_helper.rb? Tried true, false and commenting out. I could not see any difference. -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From dchelimsky at gmail.com Wed Jan 7 14:08:44 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 7 Jan 2009 13:08:44 -0600 Subject: [rspec-users] Examples not getting rolled back... In-Reply-To: <20090107141148.GA15510@uivelo.tilus.net> References: <20090107141148.GA15510@uivelo.tilus.net> Message-ID: <57c63afe0901071108p1e217f7ah3d2f4dd0a94cf7dc@mail.gmail.com> On Wed, Jan 7, 2009 at 8:11 AM, Tero Tilus wrote: > I assume there's now something I'm totally missing here. > > I'm creating stuff in examples, just plain Foo.create, and the results > aren't getting rolled back. I'm keep getting the following kind of > pattern in my logs > > ... log from example starts here ... > SQL (0.0ms) BEGIN > SQL (0.0ms) BEGIN > ClassFoo Create (0.2ms) INSERT ... > Group Load (0.4ms) SELECT ... > Contains Create (0.2ms) INSERT ... > ... other stuff from example, no transaction stuff ... > SQL (1.9ms) COMMIT > SQL (0.1ms) ROLLBACK > ... log from example ends here ... > > all examples of the following form produce it > > describe ClassFoo do > ... > it "plim-ploms" do > foo = ClassFoo.create > ... > end > ... > end > > I'm just wondering if this is caused by those nested transactions. > MySQL (which I happen to use) doesn't support nested transactions and > is documented to just silently commit open transaction on new BEGIN. > Taken that I'd expect last ROLLBACK not to have any effect. > > Where do those transactions come from? I'd guess outer transaction > to be from RSpec and inner from ActiveRecord (oh, I'm on Rails). Is the app code opening transactions? > > And of course, what can I do about this... > > A bit more stuff in pastie http://pastie.org/354521 > > -- > Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mark at mwilden.com Wed Jan 7 14:00:22 2009 From: mark at mwilden.com (Mark Wilden) Date: Wed, 7 Jan 2009 11:00:22 -0800 Subject: [rspec-users] Error: undefined method `use_transactional_fixtures In-Reply-To: <57c63afe0901071026n2207e5e9h630b996639070431@mail.gmail.com> References: <57c63afe0901070125o5d8f2e73wcca3dfc63ae7728c@mail.gmail.com> <3c30da400901071020v50e39a00kab08b608ac4400d7@mail.gmail.com> <57c63afe0901071026n2207e5e9h630b996639070431@mail.gmail.com> Message-ID: <3c30da400901071100xbaf83e1mbc7f4abed35086bd@mail.gmail.com> On Wed, Jan 7, 2009 at 10:26 AM, David Chelimsky wrote: > On Wed, Jan 7, 2009 at 12:20 PM, Mark Wilden wrote: > > FWIW, I was getting this error yesterday. I completely uninstalled rspec > and > > rspec-rails (including David's code from GitHub) and reinstalled, and it > > "went away." > > Which version did you install after removing everything? > > 1.1.16, of course. Kidding - 1.1.11. :) ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From pergesu at gmail.com Wed Jan 7 14:57:29 2009 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 7 Jan 2009 11:57:29 -0800 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> Message-ID: <810a540e0901071157i3b8df25arcf77972e7b8b6818@mail.gmail.com> On Wed, Jan 7, 2009 at 9:23 AM, Steve Molitor wrote: > I have two related questions: What is the best way to express global > requirements, and how does one do it in Cucumber. The first question is the > one I'm most interested in right now. > By a global requirement I'm talking about requirements like 'all emails must > be formatted like this...' Some people call them constraints, but I'm > focusing on UI or business rules, not technical things. My take on this situation is at http://rubyforge.org/pipermail/rspec-users/2008-December/011033.html Pat From matt at mattwynne.net Wed Jan 7 15:46:59 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 7 Jan 2009 20:46:59 +0000 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> Message-ID: <09CEC587-8C1D-4F19-A04E-24C37AF73165@mattwynne.net> On 7 Jan 2009, at 17:23, Steve Molitor wrote: > I have two related questions: What is the best way to express > global requirements, and how does one do it in Cucumber. The first > question is the one I'm most interested in right now. > > By a global requirement I'm talking about requirements like 'all > emails must be formatted like this...' Some people call them > constraints, but I'm focusing on UI or business rules, not technical > things. I can think of two approaches: put the global constraints > in one place and reference these features in other features. The > other point of view is that no, we want to see these rules in every > feature that uses them, so we (customers, BAs, developers, testers) > can see everything in one place. For example I can reference the > different valid and invalid email scenarios in both the 'add new > patient' and the 'add new doctor' features. Or I can copy and paste > the email scenarios directly into the 'add new patient' and the 'add > new doctor' features. > > As a DRY infected developer I prefer the first approach. However I > have not found a simple way to have one cucumber feature reference > or 'include' another, and have both features get executed. Perhaps > partially for that reason, other people on my project want to use > the second approach as it seems more straight forward. > > I realize I can reuse steps. But I want to reference the actual > feature in another. To pick a more important example, in my past > life I worked on a big leasing application with lots of formulas: > to compute the cost of a lease, the cost of fuel cards, the cost of > different levels of insurance, etc. I'm going to simply a lot, but > say the formula for computing the sales tax is 'subtotal + subtotal > * 0.5'. Calculating the sales tax is one feature. Two other > features are 'compute lease cost' and 'compute fuel card cost'. > They both need to add sales tax. This was before cumber and > stories, but some of us preferred the specifications to look like > this: > > LEASE COST FORMULA: > a + b + sales tax. > > Others, especially the testers, preferred: > > a + b + (a + b * 0.5) > > In real life the sales (and use) tax calculation was quite complex > and changed. When it changed this broke many manual test plan and > invalidated many use cases. If we were using cucumber with the > second approach it would break many features. > > Sorry for rambling on so long but I've found this is a hard question > to articulate. > > Steve I think you might need to try and let go of the idea that your Cucumber acceptance tests should be a *complete specification* and instead focus on making sure that there is *just enough* specification so that you can be sure to be alerted by the tests if something is wrong. Any more is likely to do more harm than good. I noticed you called yourself a 'DRY infected developer'. Duplication is undoubtedly the root of all evil in production code, but there are times when it pays to allow a little slack in. Check out this article from Dan North: http://dannorth.net/index.php?s=examples+flow Matt Wynne http://blog.mattwynne.net http://www.songkick.com From tero at tilus.net Wed Jan 7 16:23:37 2009 From: tero at tilus.net (Tero Tilus) Date: Wed, 7 Jan 2009 23:23:37 +0200 Subject: [rspec-users] Examples not getting rolled back... In-Reply-To: <57c63afe0901071108p1e217f7ah3d2f4dd0a94cf7dc@mail.gmail.com> References: <20090107141148.GA15510@uivelo.tilus.net> <57c63afe0901071108p1e217f7ah3d2f4dd0a94cf7dc@mail.gmail.com> Message-ID: <20090107212336.GC5784@uivelo.tilus.net> 2009-01-07 13:08, David Chelimsky: > Is the app code opening transactions? Yes, but only one spot (iirc) which is not anywhere near the model whose test is failing here. I'll verify tomorrow that the failing test really doesn't run the app code in question. -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From sfeley at gmail.com Wed Jan 7 17:22:25 2009 From: sfeley at gmail.com (Stephen Eley) Date: Wed, 7 Jan 2009 17:22:25 -0500 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> Message-ID: <1fb4df0901071422u34d9e1b9ld83dcb81fc64262e@mail.gmail.com> On Wed, Jan 7, 2009 at 12:23 PM, Steve Molitor wrote: > By a global requirement I'm talking about requirements like 'all emails must > be formatted like this...' Some people call them constraints, but I'm > focusing on UI or business rules, not technical things. You say "must." That's a programmer's synonym for "should." And to me that feels like a level of detail better handled with RSpec examples, where "should" is central to the domain language, than Cucumber features (which are more about stimulus and response). I know you said "business rules" and that tends to imply Cucumber in a lot of minds, but a SpecDoc formatted output that lists all the "it should" text works pretty well for business process description too. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From stevemolitor at gmail.com Wed Jan 7 17:24:09 2009 From: stevemolitor at gmail.com (Steve Molitor) Date: Wed, 7 Jan 2009 16:24:09 -0600 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <810a540e0901071157i3b8df25arcf77972e7b8b6818@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <810a540e0901071157i3b8df25arcf77972e7b8b6818@mail.gmail.com> Message-ID: <3e21ad60901071424m9f271b5r4c2113d63b7c4b2f@mail.gmail.com> Pat, Thanks -- I misunderstood your original response you sent below. For some reason I read it as 'use rspec specs to validate the date logic' and missed the bit in the second paragraph where you suggested creating an explicit date feature. Doh! Sorry for not reading carefully. This sounds like a good approach. We would have to trust that the developer did indeed call the date validator object. On a large project developers might not read / remember all the feature docs so this could happen. Or the customer might have forgotten about the date validation feature, and this could be an exception where the standard date validation should not apply for some reason. But this is probably fixable via a '# see date_validation.feature' comment. >From a testing perspective it would be nice if cucumber could actually run the date validation feature everywhere it applies. But there are technical issues as then the date feature would have to be parameterized by uri, or whatever varies. More important perhaps this is putting too much emphasis on using cucumber as a testing tool when it is primarily a communication tool. But still if it could be done in a way that was easy to read it might be nice. Anyway you've showed me a very workable approach. Thanks! Steve P.S. Date validation really isn't that important in my application; that's just an example. A real example would be the sales tax calculation in the leasing app I worked on. That was very important, it was a global requirement with some important exceptions. But I think your approach would have worked there as well. On Wed, Jan 7, 2009 at 1:57 PM, Pat Maddox wrote: > On Wed, Jan 7, 2009 at 9:23 AM, Steve Molitor > wrote: > > I have two related questions: What is the best way to express global > > requirements, and how does one do it in Cucumber. The first question is > the > > one I'm most interested in right now. > > By a global requirement I'm talking about requirements like 'all emails > must > > be formatted like this...' Some people call them constraints, but I'm > > focusing on UI or business rules, not technical things. > > My take on this situation is at > http://rubyforge.org/pipermail/rspec-users/2008-December/011033.html > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stevemolitor at gmail.com Wed Jan 7 17:37:00 2009 From: stevemolitor at gmail.com (Steve Molitor) Date: Wed, 7 Jan 2009 16:37:00 -0600 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <09CEC587-8C1D-4F19-A04E-24C37AF73165@mattwynne.net> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <09CEC587-8C1D-4F19-A04E-24C37AF73165@mattwynne.net> Message-ID: <3e21ad60901071437v373c0b3bu9c14aef59df10935@mail.gmail.com> Thanks Matt I think you're right. Ironically on a past project customers wanted a little drying up in the use cases because that helped their flow, and QA wanted more inline expansion because that helped their testing flow. The customers wanted to read about the new features, and didn't care to see a regurgitation of all the previously explained features that applied. A reference or reminder note was just fine. But anyway, yes focus on clarity and flow for the reader. Sometimes that will mean getting a little DRYer, in other cases it would me getting a little moister. Thanks! Steve On Wed, Jan 7, 2009 at 2:46 PM, Matt Wynne wrote: > > On 7 Jan 2009, at 17:23, Steve Molitor wrote: > > I have two related questions: What is the best way to express global >> requirements, and how does one do it in Cucumber. The first question is the >> one I'm most interested in right now. >> >> By a global requirement I'm talking about requirements like 'all emails >> must be formatted like this...' Some people call them constraints, but I'm >> focusing on UI or business rules, not technical things. I can think of two >> approaches: put the global constraints in one place and reference these >> features in other features. The other point of view is that no, we want to >> see these rules in every feature that uses them, so we (customers, BAs, >> developers, testers) can see everything in one place. For example I can >> reference the different valid and invalid email scenarios in both the 'add >> new patient' and the 'add new doctor' features. Or I can copy and paste the >> email scenarios directly into the 'add new patient' and the 'add new doctor' >> features. >> >> As a DRY infected developer I prefer the first approach. However I have >> not found a simple way to have one cucumber feature reference or 'include' >> another, and have both features get executed. Perhaps partially for that >> reason, other people on my project want to use the second approach as it >> seems more straight forward. >> >> I realize I can reuse steps. But I want to reference the actual feature >> in another. To pick a more important example, in my past life I worked on a >> big leasing application with lots of formulas: to compute the cost of a >> lease, the cost of fuel cards, the cost of different levels of insurance, >> etc. I'm going to simply a lot, but say the formula for computing the sales >> tax is 'subtotal + subtotal * 0.5'. Calculating the sales tax is one >> feature. Two other features are 'compute lease cost' and 'compute fuel card >> cost'. They both need to add sales tax. This was before cumber and >> stories, but some of us preferred the specifications to look like this: >> >> LEASE COST FORMULA: >> a + b + sales tax. >> >> Others, especially the testers, preferred: >> >> a + b + (a + b * 0.5) >> >> In real life the sales (and use) tax calculation was quite complex and >> changed. When it changed this broke many manual test plan and invalidated >> many use cases. If we were using cucumber with the second approach it would >> break many features. >> >> Sorry for rambling on so long but I've found this is a hard question to >> articulate. >> >> Steve >> > > I think you might need to try and let go of the idea that your Cucumber > acceptance tests should be a *complete specification* and instead focus on > making sure that there is *just enough* specification so that you can be > sure to be alerted by the tests if something is wrong. Any more is likely to > do more harm than good. > > I noticed you called yourself a 'DRY infected developer'. Duplication is > undoubtedly the root of all evil in production code, but there are times > when it pays to allow a little slack in. Check out this article from Dan > North: > > http://dannorth.net/index.php?s=examples+flow > > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.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 stevemolitor at gmail.com Wed Jan 7 19:00:18 2009 From: stevemolitor at gmail.com (Steve Molitor) Date: Wed, 7 Jan 2009 18:00:18 -0600 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <1fb4df0901071422u34d9e1b9ld83dcb81fc64262e@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <1fb4df0901071422u34d9e1b9ld83dcb81fc64262e@mail.gmail.com> Message-ID: <3e21ad60901071600l6bf80c36g8f4a42121e5e58df@mail.gmail.com> Perhaps. But I'm not sure then what the difference is between requirements that should (no pun intended) be expressed via RSpec examples versus features. Lots of features use the word "should" in their then clauses. Take this example from the 'Feature Introduction' of the cucumber wiki: Scenario: Buy last coffee Given there are 1 coffees left in the machine And I have deposited 1$ When I press the coffee button Then I should be served a coffee Should this be an rspec example instead? It certainly could be, but I don't think an rspec example would communicate as well with the customer as the feature would. And that's the primary goal here (as Pat and Matt have reminded me!). Which is not to say that the developers wouldn't get benefit out of a spec example as well -- you could do both -- just that at least in this case a feature is clearer to the customer than a spec example. Steve On Wed, Jan 7, 2009 at 4:22 PM, Stephen Eley wrote: > On Wed, Jan 7, 2009 at 12:23 PM, Steve Molitor > wrote: > > By a global requirement I'm talking about requirements like 'all emails > must > > be formatted like this...' Some people call them constraints, but I'm > > focusing on UI or business rules, not technical things. > > You say "must." That's a programmer's synonym for "should." And to > me that feels like a level of detail better handled with RSpec > examples, where "should" is central to the domain language, than > Cucumber features (which are more about stimulus and response). I > know you said "business rules" and that tends to imply Cucumber in a > lot of minds, but a SpecDoc formatted output that lists all the "it > should" text works pretty well for business process description too. > > > -- > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pergesu at gmail.com Wed Jan 7 20:26:25 2009 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 7 Jan 2009 17:26:25 -0800 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <3e21ad60901071424m9f271b5r4c2113d63b7c4b2f@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <810a540e0901071157i3b8df25arcf77972e7b8b6818@mail.gmail.com> <3e21ad60901071424m9f271b5r4c2113d63b7c4b2f@mail.gmail.com> Message-ID: <810a540e0901071726u103038e4r3b560995d0b0435@mail.gmail.com> > From a testing perspective it would be nice if cucumber could actually run > the date validation feature everywhere it applies. Sure, and you can have a step like Given birth date is valid Given /(.*) date is valid/ do |field| TestData.valid_dates.each do |date| @it.send "#{field}_date=", date @it.should be_valid end TestData.invalid_dates.each do |date| @it.send "#{field}_date=", date @it.should_not be_valid end end That gets you technical validation everywhere you need it. Then you have another individual feature file that describes date formats. > P.S. Date validation really isn't that important in my application; that's > just an example. A real example would be the sales tax calculation in the > leasing app I worked on. That was very important, it was a global > requirement with some important exceptions. But I think your approach would > have worked there as well. Same ideas apply. Pat p.s. I didn't realize you were also the author of the other thread I linked to :) From stevemolitor at gmail.com Wed Jan 7 20:58:25 2009 From: stevemolitor at gmail.com (Steve Molitor) Date: Wed, 7 Jan 2009 19:58:25 -0600 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <810a540e0901071726u103038e4r3b560995d0b0435@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <810a540e0901071157i3b8df25arcf77972e7b8b6818@mail.gmail.com> <3e21ad60901071424m9f271b5r4c2113d63b7c4b2f@mail.gmail.com> <810a540e0901071726u103038e4r3b560995d0b0435@mail.gmail.com> Message-ID: <3e21ad60901071758i21469d47ne0acb0b2689b6ae4@mail.gmail.com> Yeah I thought of something like that. Actually we do something like that in one step now that I think about it. But I really wanted to execute the same exact date feature (for example) doc that the user verified to make sure nothing got lost in translation. Which I could do if I programmatically ran the date feature file inside the Given /(.*) date is vaild/ step. But all those results would clutter up the report output. I like your approach best: simple and doesn't require a funky technical solution. Steve On Wed, Jan 7, 2009 at 7:26 PM, Pat Maddox wrote: > > From a testing perspective it would be nice if cucumber could actually > run > > the date validation feature everywhere it applies. > > Sure, and you can have a step like > > Given birth date is valid > > Given /(.*) date is valid/ do |field| > TestData.valid_dates.each do |date| > @it.send "#{field}_date=", date > @it.should be_valid > end > > TestData.invalid_dates.each do |date| > @it.send "#{field}_date=", date > @it.should_not be_valid > end > end > > That gets you technical validation everywhere you need it. Then you > have another individual feature file that describes date formats. > > > > P.S. Date validation really isn't that important in my application; > that's > > just an example. A real example would be the sales tax calculation in > the > > leasing app I worked on. That was very important, it was a global > > requirement with some important exceptions. But I think your approach > would > > have worked there as well. > > Same ideas apply. > > Pat > > p.s. I didn't realize you were also the author of the other thread I > linked to :) > _______________________________________________ > 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 pergesu at gmail.com Wed Jan 7 21:09:02 2009 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 7 Jan 2009 18:09:02 -0800 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <3e21ad60901071758i21469d47ne0acb0b2689b6ae4@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <810a540e0901071157i3b8df25arcf77972e7b8b6818@mail.gmail.com> <3e21ad60901071424m9f271b5r4c2113d63b7c4b2f@mail.gmail.com> <810a540e0901071726u103038e4r3b560995d0b0435@mail.gmail.com> <3e21ad60901071758i21469d47ne0acb0b2689b6ae4@mail.gmail.com> Message-ID: <810a540e0901071809ibaf3472k96d05e12dcf8d246@mail.gmail.com> Another idea I had is to potentially introduce a ValidatedDate class, and then your "should be a valid date" step checks that the field is an instance of ValidatedDate. That has the affect of ensuring that people use your validation code in those spots where you want them to. How does that sound? Pat On Wed, Jan 7, 2009 at 5:58 PM, Steve Molitor wrote: > Yeah I thought of something like that. Actually we do something like that > in one step now that I think about it. But I really wanted to execute the > same exact date feature (for example) doc that the user verified to make > sure nothing got lost in translation. Which I could do if I > programmatically ran the date feature file inside the Given /(.*) date is > vaild/ step. But all those results would clutter up the report output. I > like your approach best: simple and doesn't require a funky technical > solution. > Steve > > On Wed, Jan 7, 2009 at 7:26 PM, Pat Maddox wrote: >> >> > From a testing perspective it would be nice if cucumber could actually >> > run >> > the date validation feature everywhere it applies. >> >> Sure, and you can have a step like >> >> Given birth date is valid >> >> Given /(.*) date is valid/ do |field| >> TestData.valid_dates.each do |date| >> @it.send "#{field}_date=", date >> @it.should be_valid >> end >> >> TestData.invalid_dates.each do |date| >> @it.send "#{field}_date=", date >> @it.should_not be_valid >> end >> end >> >> That gets you technical validation everywhere you need it. Then you >> have another individual feature file that describes date formats. >> >> >> > P.S. Date validation really isn't that important in my application; >> > that's >> > just an example. A real example would be the sales tax calculation in >> > the >> > leasing app I worked on. That was very important, it was a global >> > requirement with some important exceptions. But I think your approach >> > would >> > have worked there as well. >> >> Same ideas apply. >> >> Pat >> >> p.s. I didn't realize you were also the author of the other thread I >> linked to :) >> _______________________________________________ >> 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 Jan 7 21:22:26 2009 From: sfeley at gmail.com (Stephen Eley) Date: Wed, 7 Jan 2009 21:22:26 -0500 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <3e21ad60901071600l6bf80c36g8f4a42121e5e58df@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <1fb4df0901071422u34d9e1b9ld83dcb81fc64262e@mail.gmail.com> <3e21ad60901071600l6bf80c36g8f4a42121e5e58df@mail.gmail.com> Message-ID: <1fb4df0901071822g1bdfdce2q9949a4e494d8b2b6@mail.gmail.com> On Wed, Jan 7, 2009 at 7:00 PM, Steve Molitor wrote: > Lots of features use the word "should" in their then clauses. > Take this example from the 'Feature Introduction' of the cucumber wiki: > > Scenario: Buy last coffee > Given there are 1 coffees left in the machine > And I have deposited 1$ > When I press the coffee button > Then I should be served a coffee Maybe I'm overly audacious, but I'd call that imprecise wording. A better clause would be "Then I am served a coffee." (Actually, that feature has more than one thing wrong with it. The "depositing $1" part really ought to be a When, not a Given, since it's an action integral to the scenario rather than a starting state. Unfortunately, this often happens when people make up theoretical examples instead of presenting real tests for real code. I'll be this feature was never actually part of designing a coffee machine...) > Should this be an rspec example instead? It certainly could be, but I don't > think an rspec example would communicate as well with the customer as the > feature would. And that's the primary goal here (as Pat and Matt have > reminded me!). I agree. This is a flawed feature, but it really ought to be a feature: it describes a stimulus (an action) and a response. But this example doesn't have much in common with your original e-mail validation example. In that case, what's the action and what's the response? And is a feature clearer to the customer to explain e-mail validation than a spec? -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From pergesu at gmail.com Wed Jan 7 22:00:49 2009 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 7 Jan 2009 19:00:49 -0800 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <1fb4df0901071822g1bdfdce2q9949a4e494d8b2b6@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <1fb4df0901071422u34d9e1b9ld83dcb81fc64262e@mail.gmail.com> <3e21ad60901071600l6bf80c36g8f4a42121e5e58df@mail.gmail.com> <1fb4df0901071822g1bdfdce2q9949a4e494d8b2b6@mail.gmail.com> Message-ID: <810a540e0901071900q56f95aefo571e0c290dd98131@mail.gmail.com> On Wed, Jan 7, 2009 at 6:22 PM, Stephen Eley wrote: > On Wed, Jan 7, 2009 at 7:00 PM, Steve Molitor wrote: >> Lots of features use the word "should" in their then clauses. >> Take this example from the 'Feature Introduction' of the cucumber wiki: >> >> Scenario: Buy last coffee >> Given there are 1 coffees left in the machine >> And I have deposited 1$ >> When I press the coffee button >> Then I should be served a coffee > > Maybe I'm overly audacious, but I'd call that imprecise wording. A > better clause would be "Then I am served a coffee." meh. I use "should" all over the place in my features. >> Should this be an rspec example instead? It certainly could be, but I don't >> think an rspec example would communicate as well with the customer as the >> feature would. And that's the primary goal here (as Pat and Matt have >> reminded me!). > > I agree. This is a flawed feature, but it really ought to be a > feature: it describes a stimulus (an action) and a response. But this > example doesn't have much in common with your original e-mail > validation example. In that case, what's the action and what's the > response? And is a feature clearer to the customer to explain e-mail > validation than a spec? hrm... "pat.maddox at gmail.com".should be_valid_email "pat.maddox+foo at gmail.com".should be_valid_email "pat.maddox at gmail".should_not be_valid_email Seems pretty clear to me. Email validation and the lease cost formula are examples of acceptance tests that are probably best handled with FIT. I know that cucumber has FIT-inspired tables, but those are still coupled to scenarios, aren't they? Actually, I'd still prefer to write these tests with prose. But it'd be super simple: pat.maddox at gmail.com is a valid email address pat.maddox at gmail is an invalid email address You can achieve this with cucumber already... Then pat.maddox at gmail.com is a valid email address Then pat.maddox at gmail is an invalid email address but it looks stupid. Pat From zach.dennis at gmail.com Wed Jan 7 22:41:37 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 7 Jan 2009 22:41:37 -0500 Subject: [rspec-users] newbie: need help to write the spec for helper In-Reply-To: <8d961d900812310811k7d4a0b74s89a6e84e81338ec9@mail.gmail.com> References: <460644.22468.qm@web38001.mail.mud.yahoo.com> <57c63afe0812310721o4a65a879v55b7e4f586f50f46@mail.gmail.com> <8d961d900812310749g5a4a3b5lf15722da3670547a@mail.gmail.com> <57c63afe0812310802h3f0cf030l1bf7a2626a492193@mail.gmail.com> <8d961d900812310811k7d4a0b74s89a6e84e81338ec9@mail.gmail.com> Message-ID: <85d99afe0901071941i3d2dee1bj3ae3726ff97276da@mail.gmail.com> On Wed, Dec 31, 2008 at 11:11 AM, aslak hellesoy wrote: > > > On Wed, Dec 31, 2008 at 5:02 PM, David Chelimsky > wrote: >> >> On Wed, Dec 31, 2008 at 9:49 AM, aslak hellesoy >> wrote: >> > >> > >> > On Wed, Dec 31, 2008 at 4:21 PM, David Chelimsky >> > wrote: >> >> >> >> On Wed, Dec 31, 2008 at 8:00 AM, Nasir Jamal >> >> wrote: >> >> > Hi, >> >> > >> >> > I am a rspec newbie, can anyone guide me on how to write a spec for >> >> > the >> >> > below helper. >> >> > >> >> > module MyHelper >> >> > def test >> >> > link_to('MyLink', resources_path) if @categories || >> >> > @sub_categories >> >> > end >> >> > end >> >> > >> >> > @categories is an instance of Category model >> >> > @sub_categories is an instance of SubCategory model >> >> >> >> Take a look at >> >> http://rspec.info/documentation/rails/writing/helpers.html. >> >> You can use assigns[:categories] and assigns[:sub_categories] to make >> >> the necessary data available to the helper. >> > >> > Technically you can do it that way, but personally I don't recommend >> > that >> > approach in most cases. Testing modules is similar to testing private >> > methods, and the general advice is: Don't do it. >> > >> > Instead, test module methods and private methods indirectly via the >> > class/object that uses them. For modules this means: Write a spec for a >> > class that includes the module (in Rails this is a controller or view). >> >> So do you recommend never doing helper specs? > > I never said never :-) Here is my manifesto styled take on this: > > "I favour testing directly accessible APIs over indirectly accessible ones." > > In Rails, I usually try to write a spec against a controller or view before > I resort to a helper spec. Keeping inappropriate logic out of the view helpers goes a long way to allow for this IMO. My personal rule of thumb of Rails view helpers is that they should only be concerned with what is built, and not with the how or why. Relying on instance variables is a no-no. When conditional checks come into play there is usually something that can be abstracted. This is where presenters excel. Granted, not everything is always so black and white. When in doubt there tend to be three ways to categorize presentation logic IMO: 1. Is it site-wide? (ie: rounded_button_helper, date_format, money_format) 2. Is it resource specific? (ie: order, line_item) 3. Is it UI component/widget specific? (ie: scoreboard which is compromised of multiple resources/models) Site-wide things should go in Rails helper modules so they are easily accessible. For the most part you can write implement these through requirements imposed by scenarios and view specs. In other cases it makes sense to write helper specs. Logic that is resource specific or UI component/widget specific should go inside of presenters. Rather than having (@category || @subcategory) conditionals floating around disorganized view helpers you should be posing that question to something that cares. This makes adding, extending, changing the logic surrounding the concept in question easier because there is a concrete representation that is organized and exists in a single spot -- the presenter. When you find you have multiple concepts sharing logic (but it's not site-wide) than extract out modules and include them in each presenter. I don't want to go to far off-topic from this thread, but needing to directly test view helpers is much less frequent when you are putting presentation logic where it belongs and writing examples for an appropriate object and its public interface. BTW, I agree with Aslak's manifesto on this. :) -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From cougar2149 at gmail.com Thu Jan 8 00:26:13 2009 From: cougar2149 at gmail.com (waseem ahmad) Date: Thu, 8 Jan 2009 10:56:13 +0530 Subject: [rspec-users] Error: undefined method `use_transactional_fixtures In-Reply-To: <3c30da400901071100xbaf83e1mbc7f4abed35086bd@mail.gmail.com> References: <57c63afe0901070125o5d8f2e73wcca3dfc63ae7728c@mail.gmail.com> <3c30da400901071020v50e39a00kab08b608ac4400d7@mail.gmail.com> <57c63afe0901071026n2207e5e9h630b996639070431@mail.gmail.com> <3c30da400901071100xbaf83e1mbc7f4abed35086bd@mail.gmail.com> Message-ID: I have both the rspec 1.1.11 and rspec-rails 1.1.11 as gems. I had them plugged in my application too. When I removed them from my application the problem was solved. The version of both the gems and plugins are same. Why did this happen? -- Waseem RwrWrwRwrWrwRwrWrwRwrWrwRwwwwwwww............ Blog: http://babygnu.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From tero at tilus.net Thu Jan 8 04:56:12 2009 From: tero at tilus.net (Tero Tilus) Date: Thu, 8 Jan 2009 11:56:12 +0200 Subject: [rspec-users] Examples not getting rolled back... In-Reply-To: <20090107141148.GA15510@uivelo.tilus.net> References: <20090107141148.GA15510@uivelo.tilus.net> Message-ID: <20090108095611.GA8340@uivelo.tilus.net> Forgot to mention before. I'm on Rails 2.2.2 and RSpec 1.1.4. Inspired by older discussion touching this issue (see http://www.nabble.com/Database-clearing-td19572270.html) I've now got Spec::Runner.configure do |config| config.use_transactional_fixtures = false ... tables_to_truncate = ActiveRecord::Base.connection.tables - ["schema_migrations"] config.before(:all) do tables_to_truncate.each do |table_name| ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table_name};") end end ... end And if I run rake spec all specs pass. But if I run script/spec spec/models/class_foo_spec.rb then it "finds no ghost foos" do ClassFoo.should have(:no).records end fails. That is the first example of describe ClassFoo. Looks like script/spec runs examples (see pastie http://pastie.org/354521) in the order they are defined and rake spec in reverse order. And that of course makes ClassFoo.should have(:no).records fail when run _after_ examples that create ClassFoo instances (befause ive got transactions off and the db state "bleeds" within one describe. 2009-01-07 16:11, Tero Tilus: > I'm keep getting the following kind of pattern in my logs > > ... log from example starts here ... > SQL (0.0ms) BEGIN > SQL (0.0ms) BEGIN > ClassFoo Create (0.2ms) INSERT ... > Group Load (0.4ms) SELECT ... > Contains Create (0.2ms) INSERT ... > ... other stuff from example, no transaction stuff ... > SQL (1.9ms) COMMIT > SQL (0.1ms) ROLLBACK > ... log from example ends here ... If I turn use_transactional_fixtures off, the outer transaction is gone. -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From tero at tilus.net Thu Jan 8 05:00:19 2009 From: tero at tilus.net (Tero Tilus) Date: Thu, 8 Jan 2009 12:00:19 +0200 Subject: [rspec-users] Examples not getting rolled back... In-Reply-To: <20090107212336.GC5784@uivelo.tilus.net> References: <20090107141148.GA15510@uivelo.tilus.net> <57c63afe0901071108p1e217f7ah3d2f4dd0a94cf7dc@mail.gmail.com> <20090107212336.GC5784@uivelo.tilus.net> Message-ID: <20090108100019.GB8340@uivelo.tilus.net> 2009-01-07 23:23, Tero Tilus: > 2009-01-07 13:08, David Chelimsky: > > Is the app code opening transactions? > > Yes, but only one spot (iirc) which is not anywhere near the model > whose test is failing here. I'll verify tomorrow that the failing > test really doesn't run the app code in question. Verified, and it didn't. Transactions I see on the log when running the spec in question come from ActiveRecord (and RSpec if I have use_transactional_fixtures = true). -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From dchelimsky at gmail.com Thu Jan 8 08:31:58 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 8 Jan 2009 07:31:58 -0600 Subject: [rspec-users] Error: undefined method `use_transactional_fixtures In-Reply-To: References: <57c63afe0901070125o5d8f2e73wcca3dfc63ae7728c@mail.gmail.com> <3c30da400901071020v50e39a00kab08b608ac4400d7@mail.gmail.com> <57c63afe0901071026n2207e5e9h630b996639070431@mail.gmail.com> <3c30da400901071100xbaf83e1mbc7f4abed35086bd@mail.gmail.com> Message-ID: <57c63afe0901080531k32975914y653ce877e056a71@mail.gmail.com> On Wed, Jan 7, 2009 at 11:26 PM, waseem ahmad wrote: > I have both the rspec 1.1.11 and rspec-rails 1.1.11 as gems. I had them > plugged in my application too. When I removed them from my application the > problem was solved. The version of both the gems and plugins are same. > > Why did this happen? I haven't seen the problem of use_transactional_fixtures before, but there were some problems with installing rspec/rspec-rails as gems w/ 1.1.11. This will be fixed in the 1.1.12 release coming shortly. Cheers, David > -- > Waseem > RwrWrwRwrWrwRwrWrwRwrWrwRwwwwwwww............ > Blog: http://babygnu.blogspot.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Jan 8 08:37:38 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 8 Jan 2009 07:37:38 -0600 Subject: [rspec-users] Examples not getting rolled back... In-Reply-To: <20090108095611.GA8340@uivelo.tilus.net> References: <20090107141148.GA15510@uivelo.tilus.net> <20090108095611.GA8340@uivelo.tilus.net> Message-ID: <57c63afe0901080537k62110ed7h26b1461f75f84b13@mail.gmail.com> On Thu, Jan 8, 2009 at 3:56 AM, Tero Tilus wrote: > Forgot to mention before. I'm on Rails 2.2.2 and RSpec 1.1.4. Aha! There's the problem. RSpec-1.1.4 was released in May and Rails 2.2.2 was released AFTER in November. I'd grab the 1.1.12 release candidates from github: gem sources -a http://gems.github.com [sudo] gem install dchelimsky-rspec [sudo] gem install dchelimsky-rspec-rails Cheers, David > > Inspired by older discussion touching this issue (see > http://www.nabble.com/Database-clearing-td19572270.html) I've now got > > Spec::Runner.configure do |config| > config.use_transactional_fixtures = false > ... > tables_to_truncate = > ActiveRecord::Base.connection.tables - ["schema_migrations"] > config.before(:all) do > tables_to_truncate.each do |table_name| > ActiveRecord::Base.connection.execute("TRUNCATE TABLE > #{table_name};") > end > end > ... > end > > And if I run rake spec all specs pass. But if I run script/spec > spec/models/class_foo_spec.rb then > > it "finds no ghost foos" do > ClassFoo.should have(:no).records > end > > fails. That is the first example of describe ClassFoo. Looks like > script/spec runs examples (see pastie http://pastie.org/354521) in the > order they are defined and rake spec in reverse order. And that of > course makes ClassFoo.should have(:no).records fail when run _after_ > examples that create ClassFoo instances (befause ive got transactions > off and the db state "bleeds" within one describe. > > 2009-01-07 16:11, Tero Tilus: >> I'm keep getting the following kind of pattern in my logs >> >> ... log from example starts here ... >> SQL (0.0ms) BEGIN >> SQL (0.0ms) BEGIN >> ClassFoo Create (0.2ms) INSERT ... >> Group Load (0.4ms) SELECT ... >> Contains Create (0.2ms) INSERT ... >> ... other stuff from example, no transaction stuff ... >> SQL (1.9ms) COMMIT >> SQL (0.1ms) ROLLBACK >> ... log from example ends here ... > > If I turn use_transactional_fixtures off, the outer transaction is > gone. > > -- > Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From stevemolitor at gmail.com Thu Jan 8 09:56:36 2009 From: stevemolitor at gmail.com (Steve Molitor) Date: Thu, 8 Jan 2009 08:56:36 -0600 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <810a540e0901071900q56f95aefo571e0c290dd98131@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <1fb4df0901071422u34d9e1b9ld83dcb81fc64262e@mail.gmail.com> <3e21ad60901071600l6bf80c36g8f4a42121e5e58df@mail.gmail.com> <1fb4df0901071822g1bdfdce2q9949a4e494d8b2b6@mail.gmail.com> <810a540e0901071900q56f95aefo571e0c290dd98131@mail.gmail.com> Message-ID: <3e21ad60901080656s1496e77aw3db1ced35282418c@mail.gmail.com> For a more realistic example lets take the leasing application I worked on. There were lots of rules and formulas, and exceptions to those rules and formulas, and the different pieces were (sometimes) part of larger calculations. We specified the requirements in the normal declarative fashion On Wed, Jan 7, 2009 at 9:00 PM, Pat Maddox wrote: > On Wed, Jan 7, 2009 at 6:22 PM, Stephen Eley wrote: > > On Wed, Jan 7, 2009 at 7:00 PM, Steve Molitor > wrote: > >> Lots of features use the word "should" in their then clauses. > >> Take this example from the 'Feature Introduction' of the cucumber wiki: > >> > >> Scenario: Buy last coffee > >> Given there are 1 coffees left in the machine > >> And I have deposited 1$ > >> When I press the coffee button > >> Then I should be served a coffee > > > > Maybe I'm overly audacious, but I'd call that imprecise wording. A > > better clause would be "Then I am served a coffee." > > meh. I use "should" all over the place in my features. > > > >> Should this be an rspec example instead? It certainly could be, but I > don't > >> think an rspec example would communicate as well with the customer as > the > >> feature would. And that's the primary goal here (as Pat and Matt have > >> reminded me!). > > > > I agree. This is a flawed feature, but it really ought to be a > > feature: it describes a stimulus (an action) and a response. But this > > example doesn't have much in common with your original e-mail > > validation example. In that case, what's the action and what's the > > response? And is a feature clearer to the customer to explain e-mail > > validation than a spec? > > hrm... > "pat.maddox at gmail.com".should be_valid_email > "pat.maddox+foo at gmail.com ".should > be_valid_email > "pat.maddox at gmail".should_not be_valid_email > > Seems pretty clear to me. > > Email validation and the lease cost formula are examples of acceptance > tests that are probably best handled with FIT. I know that cucumber > has FIT-inspired tables, but those are still coupled to scenarios, > aren't they? > > Actually, I'd still prefer to write these tests with prose. But it'd > be super simple: > > pat.maddox at gmail.com is a valid email address > pat.maddox at gmail is an invalid email address > > You can achieve this with cucumber already... > Then pat.maddox at gmail.com is a valid email address > Then pat.maddox at gmail is an invalid email address > > but it looks stupid. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stevemolitor at gmail.com Thu Jan 8 11:32:52 2009 From: stevemolitor at gmail.com (Steve Molitor) Date: Thu, 8 Jan 2009 10:32:52 -0600 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <810a540e0901071809ibaf3472k96d05e12dcf8d246@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <810a540e0901071157i3b8df25arcf77972e7b8b6818@mail.gmail.com> <3e21ad60901071424m9f271b5r4c2113d63b7c4b2f@mail.gmail.com> <810a540e0901071726u103038e4r3b560995d0b0435@mail.gmail.com> <3e21ad60901071758i21469d47ne0acb0b2689b6ae4@mail.gmail.com> <810a540e0901071809ibaf3472k96d05e12dcf8d246@mail.gmail.com> Message-ID: <3e21ad60901080832h19f1883ey80ab4d23751a58de@mail.gmail.com> I guess that would work. But a method would probably work too, if I'm understanding correctly (often a bad assumption!). I.e. /"(.*)" should be a valid date/ would call valid_date?(date), or something. Anyway, yes that sounds promising. Steve On Wed, Jan 7, 2009 at 8:09 PM, Pat Maddox wrote: > Another idea I had is to potentially introduce a ValidatedDate class, > and then your "should be a valid date" step checks that the field is > an instance of ValidatedDate. That has the affect of ensuring that > people use your validation code in those spots where you want them to. > How does that sound? > > Pat > > On Wed, Jan 7, 2009 at 5:58 PM, Steve Molitor > wrote: > > Yeah I thought of something like that. Actually we do something like > that > > in one step now that I think about it. But I really wanted to execute > the > > same exact date feature (for example) doc that the user verified to make > > sure nothing got lost in translation. Which I could do if I > > programmatically ran the date feature file inside the Given /(.*) date is > > vaild/ step. But all those results would clutter up the report output. > I > > like your approach best: simple and doesn't require a funky technical > > solution. > > Steve > > > > On Wed, Jan 7, 2009 at 7:26 PM, Pat Maddox wrote: > >> > >> > From a testing perspective it would be nice if cucumber could actually > >> > run > >> > the date validation feature everywhere it applies. > >> > >> Sure, and you can have a step like > >> > >> Given birth date is valid > >> > >> Given /(.*) date is valid/ do |field| > >> TestData.valid_dates.each do |date| > >> @it.send "#{field}_date=", date > >> @it.should be_valid > >> end > >> > >> TestData.invalid_dates.each do |date| > >> @it.send "#{field}_date=", date > >> @it.should_not be_valid > >> end > >> end > >> > >> That gets you technical validation everywhere you need it. Then you > >> have another individual feature file that describes date formats. > >> > >> > >> > P.S. Date validation really isn't that important in my application; > >> > that's > >> > just an example. A real example would be the sales tax calculation in > >> > the > >> > leasing app I worked on. That was very important, it was a global > >> > requirement with some important exceptions. But I think your approach > >> > would > >> > have worked there as well. > >> > >> Same ideas apply. > >> > >> Pat > >> > >> p.s. I didn't realize you were also the author of the other thread I > >> linked to :) > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stevemolitor at gmail.com Thu Jan 8 11:45:58 2009 From: stevemolitor at gmail.com (Steve Molitor) Date: Thu, 8 Jan 2009 10:45:58 -0600 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <810a540e0901071900q56f95aefo571e0c290dd98131@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <1fb4df0901071422u34d9e1b9ld83dcb81fc64262e@mail.gmail.com> <3e21ad60901071600l6bf80c36g8f4a42121e5e58df@mail.gmail.com> <1fb4df0901071822g1bdfdce2q9949a4e494d8b2b6@mail.gmail.com> <810a540e0901071900q56f95aefo571e0c290dd98131@mail.gmail.com> Message-ID: <3e21ad60901080845v6f4171d8p7ad0fa18a393ffa8@mail.gmail.com> I hid send to early on a previous email; please ignore it. I think you could do this with cucumber: Then should be a email address | date | result | | "sam at foo.com | valid | | "tom@" | invalid | Or: Then should be a valid email address | email | | sam at foo.com | | tom at bar.com | Then should be an invalid email address | email | | sam@ | | @bar.com | I don't think you need all three steps. Instead of the tables you could And them all together if you prefer. OK, "Then" is a little awkward. Perhaps you could monkey patch cucumber with your own step name. I may have picked bad examples, but fundamentally I don't think this is an rspec vs. cucumber issue. In the leasing app I worked on we had lots of testing scenarios like 'setup the lease with values x, y, z..., then press the calculate button. The result should be xxx'. Obviously these translate directly into cucumber scenarios. And then some tests would include other tests, as caculcations were often composites of other calculations. I could see where sometimes inlining would make sense, other times where that would be too much noise and you want a reference. Steve Steve I don't think you need all 3 steps. OK. "Then" is awkward On Wed, Jan 7, 2009 at 9:00 PM, Pat Maddox wrote: > On Wed, Jan 7, 2009 at 6:22 PM, Stephen Eley wrote: > > On Wed, Jan 7, 2009 at 7:00 PM, Steve Molitor > wrote: > >> Lots of features use the word "should" in their then clauses. > >> Take this example from the 'Feature Introduction' of the cucumber wiki: > >> > >> Scenario: Buy last coffee > >> Given there are 1 coffees left in the machine > >> And I have deposited 1$ > >> When I press the coffee button > >> Then I should be served a coffee > > > > Maybe I'm overly audacious, but I'd call that imprecise wording. A > > better clause would be "Then I am served a coffee." > > meh. I use "should" all over the place in my features. > > > >> Should this be an rspec example instead? It certainly could be, but I > don't > >> think an rspec example would communicate as well with the customer as > the > >> feature would. And that's the primary goal here (as Pat and Matt have > >> reminded me!). > > > > I agree. This is a flawed feature, but it really ought to be a > > feature: it describes a stimulus (an action) and a response. But this > > example doesn't have much in common with your original e-mail > > validation example. In that case, what's the action and what's the > > response? And is a feature clearer to the customer to explain e-mail > > validation than a spec? > > hrm... > "pat.maddox at gmail.com".should be_valid_email > "pat.maddox+foo at gmail.com ".should > be_valid_email > "pat.maddox at gmail".should_not be_valid_email > > Seems pretty clear to me. > > Email validation and the lease cost formula are examples of acceptance > tests that are probably best handled with FIT. I know that cucumber > has FIT-inspired tables, but those are still coupled to scenarios, > aren't they? > > Actually, I'd still prefer to write these tests with prose. But it'd > be super simple: > > pat.maddox at gmail.com is a valid email address > pat.maddox at gmail is an invalid email address > > You can achieve this with cucumber already... > Then pat.maddox at gmail.com is a valid email address > Then pat.maddox at gmail is an invalid email address > > but it looks stupid. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stevemolitor at gmail.com Thu Jan 8 12:05:40 2009 From: stevemolitor at gmail.com (Steve Molitor) Date: Thu, 8 Jan 2009 11:05:40 -0600 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <3e21ad60901080832h19f1883ey80ab4d23751a58de@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <810a540e0901071157i3b8df25arcf77972e7b8b6818@mail.gmail.com> <3e21ad60901071424m9f271b5r4c2113d63b7c4b2f@mail.gmail.com> <810a540e0901071726u103038e4r3b560995d0b0435@mail.gmail.com> <3e21ad60901071758i21469d47ne0acb0b2689b6ae4@mail.gmail.com> <810a540e0901071809ibaf3472k96d05e12dcf8d246@mail.gmail.com> <3e21ad60901080832h19f1883ey80ab4d23751a58de@mail.gmail.com> Message-ID: <3e21ad60901080905m306da5e8lb07e45e31e629be5@mail.gmail.com> Whoops I misunderstood again. You'd validate that it was an instance ValidDate to make sure the date validation code was executed. Got it now. Maybe you could mock out the date validation part of the code and set an expectation that it should be called: mock_date_validator.should_receive?(:validate).with(the_date).return(true) You're completely mocking out the date validation result, but you're testing that the date validation routine was indeed called, and if you've tested that routine elsewhere you should be good. Or something like that. Good ideas, thanks. Steve On Thu, Jan 8, 2009 at 10:32 AM, Steve Molitor wrote: > I guess that would work. But a method would probably work too, if I'm > understanding correctly (often a bad assumption!). I.e. /"(.*)" should be > a valid date/ would call valid_date?(date), or something. Anyway, yes that > sounds promising. > Steve > > > > On Wed, Jan 7, 2009 at 8:09 PM, Pat Maddox wrote: > >> Another idea I had is to potentially introduce a ValidatedDate class, >> and then your "should be a valid date" step checks that the field is >> an instance of ValidatedDate. That has the affect of ensuring that >> people use your validation code in those spots where you want them to. >> How does that sound? >> >> Pat >> >> On Wed, Jan 7, 2009 at 5:58 PM, Steve Molitor >> wrote: >> > Yeah I thought of something like that. Actually we do something like >> that >> > in one step now that I think about it. But I really wanted to execute >> the >> > same exact date feature (for example) doc that the user verified to make >> > sure nothing got lost in translation. Which I could do if I >> > programmatically ran the date feature file inside the Given /(.*) date >> is >> > vaild/ step. But all those results would clutter up the report output. >> I >> > like your approach best: simple and doesn't require a funky technical >> > solution. >> > Steve >> > >> > On Wed, Jan 7, 2009 at 7:26 PM, Pat Maddox wrote: >> >> >> >> > From a testing perspective it would be nice if cucumber could >> actually >> >> > run >> >> > the date validation feature everywhere it applies. >> >> >> >> Sure, and you can have a step like >> >> >> >> Given birth date is valid >> >> >> >> Given /(.*) date is valid/ do |field| >> >> TestData.valid_dates.each do |date| >> >> @it.send "#{field}_date=", date >> >> @it.should be_valid >> >> end >> >> >> >> TestData.invalid_dates.each do |date| >> >> @it.send "#{field}_date=", date >> >> @it.should_not be_valid >> >> end >> >> end >> >> >> >> That gets you technical validation everywhere you need it. Then you >> >> have another individual feature file that describes date formats. >> >> >> >> >> >> > P.S. Date validation really isn't that important in my application; >> >> > that's >> >> > just an example. A real example would be the sales tax calculation >> in >> >> > the >> >> > leasing app I worked on. That was very important, it was a global >> >> > requirement with some important exceptions. But I think your >> approach >> >> > would >> >> > have worked there as well. >> >> >> >> Same ideas apply. >> >> >> >> Pat >> >> >> >> p.s. I didn't realize you were also the author of the other thread I >> >> linked to :) >> >> _______________________________________________ >> >> rspec-users mailing list >> >> rspec-users at rubyforge.org >> >> http://rubyforge.org/mailman/listinfo/rspec-users >> > >> > >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Thu Jan 8 13:13:54 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 8 Jan 2009 19:13:54 +0100 Subject: [rspec-users] cucumber, finding a row in a table In-Reply-To: <85d99afe0901061653m3ffdbb77ma1d36aebf64ef59f@mail.gmail.com> References: <84f730e41b1773b44b0fd8a6dfd49cf8@ruby-forum.com> <85d99afe0901051507pd187422w2bf618459f0bf597@mail.gmail.com> <1e43aeb33748c276ad770eb033cf1fb7@ruby-forum.com> <85d99afe0901061653m3ffdbb77ma1d36aebf64ef59f@mail.gmail.com> Message-ID: <1176ad0c77805270cb1c4e71bbb230ac@ruby-forum.com> I am still not getting this to work. Here is what I have done: In index.html.erb ... ... <% for entity in @entities %> ... ... In the step definition file: When /I delete the "(.*)" entity/ do |row| visits entities_url puts entities_url my_entity = Entity.find_by_entity_name( "my entity number #{row.hll_words_to_i}") puts "selector found" if have_selector( "table > tbody > tr#" + dom_id(my_entity) + " > td > a") within("table > tbody > tr#" + dom_id(my_entity) + " > td > a") do click_link "Destroy Entity" end end The results: Scenario: Delete entity # features/app/models/entities/entity.feature:32 Given I have "4" valid entities # features/app/models/entities/step_definitions/entity_steps.rb:115 http://www.example.com/entities selector found When I delete the "first" entity # features/app/models/entities/step_definitions/entity_steps.rb:128 You have a nil object when you didn't expect it! The error occurred while evaluating nil.to_html (NoMethodError) /usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/scope.rb:176:in `scoped_dom' The selector is found so what is my error? I have backed off the selector element by element to "table > tbody > tr#" + dom_id(myentity) with no change in the result. I always get a nil object error. -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Thu Jan 8 13:52:00 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 8 Jan 2009 13:52:00 -0500 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <3e21ad60901080832h19f1883ey80ab4d23751a58de@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <810a540e0901071157i3b8df25arcf77972e7b8b6818@mail.gmail.com> <3e21ad60901071424m9f271b5r4c2113d63b7c4b2f@mail.gmail.com> <810a540e0901071726u103038e4r3b560995d0b0435@mail.gmail.com> <3e21ad60901071758i21469d47ne0acb0b2689b6ae4@mail.gmail.com> <810a540e0901071809ibaf3472k96d05e12dcf8d246@mail.gmail.com> <3e21ad60901080832h19f1883ey80ab4d23751a58de@mail.gmail.com> Message-ID: <85d99afe0901081052h2f0a685fye78121736a9843f0@mail.gmail.com> On Thu, Jan 8, 2009 at 11:32 AM, Steve Molitor wrote: > I guess that would work. What would work? You top-posted, any way you can inline post to the spot you're responding to? Sorry to be an email nazi, but you're making me do all of the work for wanting to hopefully participate in this thread, Zach > But a method would probably work too, if I'm > understanding correctly (often a bad assumption!). I.e. /"(.*)" should be > a valid date/ would call valid_date?(date), or something. Anyway, yes that > sounds promising. > Steve > > > On Wed, Jan 7, 2009 at 8:09 PM, Pat Maddox wrote: >> >> Another idea I had is to potentially introduce a ValidatedDate class, >> and then your "should be a valid date" step checks that the field is >> an instance of ValidatedDate. That has the affect of ensuring that >> people use your validation code in those spots where you want them to. >> How does that sound? >> >> Pat >> >> On Wed, Jan 7, 2009 at 5:58 PM, Steve Molitor >> wrote: >> > Yeah I thought of something like that. Actually we do something like >> > that >> > in one step now that I think about it. But I really wanted to execute >> > the >> > same exact date feature (for example) doc that the user verified to make >> > sure nothing got lost in translation. Which I could do if I >> > programmatically ran the date feature file inside the Given /(.*) date >> > is >> > vaild/ step. But all those results would clutter up the report output. >> > I >> > like your approach best: simple and doesn't require a funky technical >> > solution. >> > Steve >> > >> > On Wed, Jan 7, 2009 at 7:26 PM, Pat Maddox wrote: >> >> >> >> > From a testing perspective it would be nice if cucumber could >> >> > actually >> >> > run >> >> > the date validation feature everywhere it applies. >> >> >> >> Sure, and you can have a step like >> >> >> >> Given birth date is valid >> >> >> >> Given /(.*) date is valid/ do |field| >> >> TestData.valid_dates.each do |date| >> >> @it.send "#{field}_date=", date >> >> @it.should be_valid >> >> end >> >> >> >> TestData.invalid_dates.each do |date| >> >> @it.send "#{field}_date=", date >> >> @it.should_not be_valid >> >> end >> >> end >> >> >> >> That gets you technical validation everywhere you need it. Then you >> >> have another individual feature file that describes date formats. >> >> >> >> >> >> > P.S. Date validation really isn't that important in my application; >> >> > that's >> >> > just an example. A real example would be the sales tax calculation >> >> > in >> >> > the >> >> > leasing app I worked on. That was very important, it was a global >> >> > requirement with some important exceptions. But I think your >> >> > approach >> >> > would >> >> > have worked there as well. >> >> >> >> Same ideas apply. >> >> >> >> Pat >> >> >> >> p.s. I didn't realize you were also the author of the other thread I >> >> linked to :) >> >> _______________________________________________ >> >> 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 > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From walketim at gmail.com Thu Jan 8 14:51:52 2009 From: walketim at gmail.com (Tim Walker) Date: Thu, 8 Jan 2009 12:51:52 -0700 Subject: [rspec-users] any eta on the rspec book? Message-ID: <1ebf5a4d0901081151s31e662d8q129f5413ec032db2@mail.gmail.com> Subject says it all... Thanks in advance, T From lists at ruby-forum.com Thu Jan 8 14:55:25 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 8 Jan 2009 20:55:25 +0100 Subject: [rspec-users] cucumber, finding a row in a table In-Reply-To: <1176ad0c77805270cb1c4e71bbb230ac@ruby-forum.com> References: <84f730e41b1773b44b0fd8a6dfd49cf8@ruby-forum.com> <85d99afe0901051507pd187422w2bf618459f0bf597@mail.gmail.com> <1e43aeb33748c276ad770eb033cf1fb7@ruby-forum.com> <85d99afe0901061653m3ffdbb77ma1d36aebf64ef59f@mail.gmail.com> <1176ad0c77805270cb1c4e71bbb230ac@ruby-forum.com> Message-ID: <07b430446d480d1655cacdb2ea08a79b@ruby-forum.com> I have tried to simplify this as much as possible. To the best of my ability to determine when one selects an html element via id then one obtains the entire element contents to the termination tag. So, I did this: Now, when I check for either of the selector ids using webrat's within method they both work. within("tr#"+dom_id(my_entity, :list)) do puts "within method executed for tr#dom_id selector" end within("td#"+dom_id(my_entity, :delete)) do puts "within method executed for td#dom_id selector" end produces: within method executed for tr#dom_id selector within method executed for td#dom_id selector But, any call to the click_link("Destroy Entity") method from a successful within match gives a nil object exception. So, what is happening here? -- Posted via http://www.ruby-forum.com/. From stevemolitor at gmail.com Thu Jan 8 15:15:23 2009 From: stevemolitor at gmail.com (Steve Molitor) Date: Thu, 8 Jan 2009 14:15:23 -0600 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <85d99afe0901081052h2f0a685fye78121736a9843f0@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <810a540e0901071157i3b8df25arcf77972e7b8b6818@mail.gmail.com> <3e21ad60901071424m9f271b5r4c2113d63b7c4b2f@mail.gmail.com> <810a540e0901071726u103038e4r3b560995d0b0435@mail.gmail.com> <3e21ad60901071758i21469d47ne0acb0b2689b6ae4@mail.gmail.com> <810a540e0901071809ibaf3472k96d05e12dcf8d246@mail.gmail.com> <3e21ad60901080832h19f1883ey80ab4d23751a58de@mail.gmail.com> <85d99afe0901081052h2f0a685fye78121736a9843f0@mail.gmail.com> Message-ID: <3e21ad60901081215h962e8aetf36ddfbf8fe3b525@mail.gmail.com> Sorry. I was responding to this from Pat Maddox: >> Another idea I had is to potentially introduce a ValidatedDate class, >> and then your "should be a valid date" step checks that the field is >> an instance of ValidatedDate. That has the affect of ensuring that >> people use your validation code in those spots where you want them to. >> How does that sound? Steve On Thu, Jan 8, 2009 at 12:52 PM, Zach Dennis wrote: > On Thu, Jan 8, 2009 at 11:32 AM, Steve Molitor > wrote: > > I guess that would work. > > What would work? You top-posted, any way you can inline post to the > spot you're responding to? Sorry to be an email nazi, but you're > making me do all of the work for wanting to hopefully participate in > this thread, > > Zach > > > But a method would probably work too, if I'm > > understanding correctly (often a bad assumption!). I.e. /"(.*)" should > be > > a valid date/ would call valid_date?(date), or something. Anyway, yes > that > > sounds promising. > > Steve > > > > > > On Wed, Jan 7, 2009 at 8:09 PM, Pat Maddox wrote: > >> > >> Another idea I had is to potentially introduce a ValidatedDate class, > >> and then your "should be a valid date" step checks that the field is > >> an instance of ValidatedDate. That has the affect of ensuring that > >> people use your validation code in those spots where you want them to. > >> How does that sound? > >> > >> Pat > >> > >> On Wed, Jan 7, 2009 at 5:58 PM, Steve Molitor > >> wrote: > >> > Yeah I thought of something like that. Actually we do something like > >> > that > >> > in one step now that I think about it. But I really wanted to execute > >> > the > >> > same exact date feature (for example) doc that the user verified to > make > >> > sure nothing got lost in translation. Which I could do if I > >> > programmatically ran the date feature file inside the Given /(.*) date > >> > is > >> > vaild/ step. But all those results would clutter up the report > output. > >> > I > >> > like your approach best: simple and doesn't require a funky technical > >> > solution. > >> > Steve > >> > > >> > On Wed, Jan 7, 2009 at 7:26 PM, Pat Maddox wrote: > >> >> > >> >> > From a testing perspective it would be nice if cucumber could > >> >> > actually > >> >> > run > >> >> > the date validation feature everywhere it applies. > >> >> > >> >> Sure, and you can have a step like > >> >> > >> >> Given birth date is valid > >> >> > >> >> Given /(.*) date is valid/ do |field| > >> >> TestData.valid_dates.each do |date| > >> >> @it.send "#{field}_date=", date > >> >> @it.should be_valid > >> >> end > >> >> > >> >> TestData.invalid_dates.each do |date| > >> >> @it.send "#{field}_date=", date > >> >> @it.should_not be_valid > >> >> end > >> >> end > >> >> > >> >> That gets you technical validation everywhere you need it. Then you > >> >> have another individual feature file that describes date formats. > >> >> > >> >> > >> >> > P.S. Date validation really isn't that important in my application; > >> >> > that's > >> >> > just an example. A real example would be the sales tax calculation > >> >> > in > >> >> > the > >> >> > leasing app I worked on. That was very important, it was a global > >> >> > requirement with some important exceptions. But I think your > >> >> > approach > >> >> > would > >> >> > have worked there as well. > >> >> > >> >> Same ideas apply. > >> >> > >> >> Pat > >> >> > >> >> p.s. I didn't realize you were also the author of the other thread I > >> >> linked to :) > >> >> _______________________________________________ > >> >> 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 > > > > > > -- > Zach Dennis > http://www.continuousthinking.com > http://www.mutuallyhuman.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 cdemyanovich at gmail.com Thu Jan 8 16:27:58 2009 From: cdemyanovich at gmail.com (Craig Demyanovich) Date: Thu, 8 Jan 2009 16:27:58 -0500 Subject: [rspec-users] any eta on the rspec book? In-Reply-To: <1ebf5a4d0901081151s31e662d8q129f5413ec032db2@mail.gmail.com> References: <1ebf5a4d0901081151s31e662d8q129f5413ec032db2@mail.gmail.com> Message-ID: <61c885db0901081327i668fe895qb466dc7f26c4d3b4@mail.gmail.com> Information on the book is always available here: http://pragprog.com/titles/achbd/the-rspec-book Currently, the ETA is April 2009. I'm sure that the authors will let us know if anything changes. Regards, Craig -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Thu Jan 8 16:30:09 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 8 Jan 2009 15:30:09 -0600 Subject: [rspec-users] any eta on the rspec book? In-Reply-To: <1ebf5a4d0901081151s31e662d8q129f5413ec032db2@mail.gmail.com> References: <1ebf5a4d0901081151s31e662d8q129f5413ec032db2@mail.gmail.com> Message-ID: <57c63afe0901081330h5b0a45fco8de3f851e6e096ef@mail.gmail.com> On Thu, Jan 8, 2009 at 1:51 PM, Tim Walker wrote: > Subject says it all... > > Thanks in advance, We've got a lot of momentum now. We had planned to do the beta release in December, but with holiday schedules (planned and otherwise) getting in everybody's way, that just couldn't happen. My hope is that we'll have the beta out on either the 21st or 28th of January (prag beta's typically come out on Wednesdays, and I'm quite sure that it won't be the 14th), and as soon as I have something concrete I'll post about it. Thanks for the continued interest! Cheers, David From dchelimsky at gmail.com Thu Jan 8 16:51:45 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 8 Jan 2009 15:51:45 -0600 Subject: [rspec-users] any eta on the rspec book? In-Reply-To: <61c885db0901081327i668fe895qb466dc7f26c4d3b4@mail.gmail.com> References: <1ebf5a4d0901081151s31e662d8q129f5413ec032db2@mail.gmail.com> <61c885db0901081327i668fe895qb466dc7f26c4d3b4@mail.gmail.com> Message-ID: <57c63afe0901081351n217169eay76036740f03fe1fc@mail.gmail.com> On Thu, Jan 8, 2009 at 3:27 PM, Craig Demyanovich wrote: > Information on the book is always available here: > > http://pragprog.com/titles/achbd/the-rspec-book > > Currently, the ETA is April 2009. I'm sure that the authors will let us know > if anything changes. To be clear: that's for the print book. Beta will be very soon. > > Regards, > Craig > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tero at tilus.net Fri Jan 9 07:37:29 2009 From: tero at tilus.net (Tero Tilus) Date: Fri, 9 Jan 2009 14:37:29 +0200 Subject: [rspec-users] Examples not getting rolled back... In-Reply-To: <57c63afe0901080537k62110ed7h26b1461f75f84b13@mail.gmail.com> References: <20090107141148.GA15510@uivelo.tilus.net> <20090108095611.GA8340@uivelo.tilus.net> <57c63afe0901080537k62110ed7h26b1461f75f84b13@mail.gmail.com> Message-ID: <20090109123729.GB12671@uivelo.tilus.net> 2009-01-08 07:37, David Chelimsky: > I'd grab the 1.1.12 release candidates from github: > > gem sources -a http://gems.github.com > [sudo] gem install dchelimsky-rspec > [sudo] gem install dchelimsky-rspec-rails It gives me 1.1.11.6. Is that a "1.1.12 release candidate"? Could I git clone 1.1.12 somewhere? I'd love to do that. -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From dchelimsky at gmail.com Fri Jan 9 09:14:26 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 9 Jan 2009 08:14:26 -0600 Subject: [rspec-users] Examples not getting rolled back... In-Reply-To: <20090109123729.GB12671@uivelo.tilus.net> References: <20090107141148.GA15510@uivelo.tilus.net> <20090108095611.GA8340@uivelo.tilus.net> <57c63afe0901080537k62110ed7h26b1461f75f84b13@mail.gmail.com> <20090109123729.GB12671@uivelo.tilus.net> Message-ID: <57c63afe0901090614s5461984fwb1c24e3630e588a5@mail.gmail.com> On Fri, Jan 9, 2009 at 6:37 AM, Tero Tilus wrote: > 2009-01-08 07:37, David Chelimsky: >> I'd grab the 1.1.12 release candidates from github: >> >> gem sources -a http://gems.github.com >> [sudo] gem install dchelimsky-rspec >> [sudo] gem install dchelimsky-rspec-rails > > It gives me 1.1.11.6. Is that a "1.1.12 release candidate"? > Could I git clone 1.1.12 somewhere? I'd love to do that. Sure. Take a look at http://github.com/dchelimsky/rspec/wikis > > -- > Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Fri Jan 9 11:08:11 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 9 Jan 2009 17:08:11 +0100 Subject: [rspec-users] Is there a problem with webrat? Message-ID: webrat (0.3.4) I have this in the view:
<\div> I have this in my test: my_entity = Entity.find_by_entity_name( "my entity number #{row.hll_words_to_i}") within("div#" + dom_id(my_entity, :list)) do puts "within method executed for div" end within("div#" + dom_id(my_entity, :list)) do click_link "Destroy Entity" end The first within method prints the trace message The second within method call blows up with: within method executed for div When I delete the "first" entity # features/app/models/entities/step_definitions/entity_steps.rb:128 You have a nil object when you didn't expect it! The error occurred while evaluating nil.to_html (NoMethodError) /usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/scope.rb:176:in `scoped_dom' /usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/scope.rb:158:in `dom' /usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/scope.rb:194:in `links' /usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/locators.rb:80:in `find_link' /usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/scope.rb:134:in `click_link' /usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/rails.rb:88:in `send' /usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/rails.rb:88:in `method_missing' Now, I am reasonably sure that the div selector is working as expected. It is the click_link method that is failing for some reason. Is this failure caused by something I have done or is it some problem with webrat? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Jan 9 11:34:06 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 9 Jan 2009 17:34:06 +0100 Subject: [rspec-users] Is there a problem with webrat? In-Reply-To: References: Message-ID: <5c91da003de4e50dafc7e4431d2a2fe5@ruby-forum.com> James Byrne wrote: > webrat (0.3.4) > > Now, I am reasonably sure that the div selector is working as expected. > It is the click_link method that is failing for some reason. Is this > failure caused by something I have done or is it some problem with > webrat? It was something I did that was very, very wrong.... -- Posted via http://www.ruby-forum.com/. From mark.thomson at ieee.org Sat Jan 10 18:44:32 2009 From: mark.thomson at ieee.org (MarkMT) Date: Sat, 10 Jan 2009 15:44:32 -0800 (PST) Subject: [rspec-users] Is the Fit Table documentation correct? Message-ID: I've been looking at the authentication feature example contained in merb_cucumber and not having used features with tabulated input before I had to go and look for an explanation of the syntax. However when I looked at the wiki page on github that deals with this - http://wiki.github.com/aslakhellesoy/cucumber/using-fit-tables-in-a-feature I had some difficulty mapping the description there into what I was seeing in the example, which is shown here - http://github.com/david/merb_cucumber/tree/master/lib/generators/cucumber/templates/features/authentication/login.feature After some searching I found a discussion on lighthouse that seems to bear on this issue - http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/57-scenario-templates-to-allow-for-terse-scenario-tables This describes a syntax change that (if I understand correctly) involves putting variable placeholders in angle brackets and matching these to the column headings in the table. This seems to be consistent with the merb-cucumber example. However if I'm understanding this correctly, it looks like the change has not yet been reflected in the github documentation. Can someone confirm for me that this is the case, because it's possible that I'm just plain confused. Also, does the approach currently shown in the documentation still work? And is the idea there that table columns map sequentially onto the strings that correspond to the regexp match groups in the step definitions? Are the column headings then essentially redundant in that case? Mark. From matt at mattwynne.net Sat Jan 10 19:08:09 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 11 Jan 2009 00:08:09 +0000 Subject: [rspec-users] Is the Fit Table documentation correct? In-Reply-To: References: Message-ID: <0216EBFF-686E-4085-AB3A-8D972F19E0FA@mattwynne.net> On 10 Jan 2009, at 23:44, MarkMT wrote: > I've been looking at the authentication feature example contained in > merb_cucumber and not having used features with tabulated input before > I had to go and look for an explanation of the syntax. However when I > looked at the wiki page on github that deals with this - > > http://wiki.github.com/aslakhellesoy/cucumber/using-fit-tables-in-a-feature > > I had some difficulty mapping the description there into what I was > seeing in the example, which is shown here - > > http://github.com/david/merb_cucumber/tree/master/lib/generators/cucumber/templates/features/authentication/login.feature > > After some searching I found a discussion on lighthouse that seems to > bear on this issue - > > http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/57-scenario-templates-to-allow-for-terse-scenario-tables > > This describes a syntax change that (if I understand correctly) > involves putting variable placeholders in angle brackets and matching > these to the column headings in the table. This seems to be consistent > with the merb-cucumber example. > > However if I'm understanding this correctly, it looks like the change > has not yet been reflected in the github documentation. Can someone > confirm for me that this is the case, because it's possible that I'm > just plain confused. > > Also, does the approach currently shown in the documentation still > work? And is the idea there that table columns map sequentially onto > the strings that correspond to the regexp match groups in the step > definitions? Are the column headings then essentially redundant in > that case? > > Mark. Hi Mark, I can't check the github wiki right now, because GH is down, but I'm sure I saw Scenario Outline documented on there today. There are three ways of doing tabulated data in Cucumber, and as far as I know they're all still supported. The basic way, shown on the homepage for cucumber, works in Given and Then steps (but not When), and looks like Then there should be the following people: | name | age | | Matt | 33 | | Anna | 31 | The next way extends a single Scenario with a More Examples table. The third, and newest way uses a Scenario Outline to define a template, followed by an Examples table to define the value substitutions to make the scenario actually run. HTH, Matt Wynne http://blog.mattwynne.net http://www.songkick.com From mark.thomson at ieee.org Sat Jan 10 20:22:17 2009 From: mark.thomson at ieee.org (MarkMT) Date: Sat, 10 Jan 2009 17:22:17 -0800 (PST) Subject: [rspec-users] Is the Fit Table documentation correct? In-Reply-To: <0216EBFF-686E-4085-AB3A-8D972F19E0FA@mattwynne.net> References: <0216EBFF-686E-4085-AB3A-8D972F19E0FA@mattwynne.net> Message-ID: <9a447563-6e33-4710-8392-1c0e48c8f9c7@f40g2000pri.googlegroups.com> Thanks Matt. I have now found the page that deals with scenario outlines (GH is back up) - http://wiki.github.com/aslakhellesoy/cucumber/scenario-outlines so that is now pretty clear. Might be worth a note in the fit table page referring to that. On Jan 10, 6:08?pm, Matt Wynne wrote: > On 10 Jan 2009, at 23:44, MarkMT wrote: > > > > > I've been looking at the authentication feature example contained in > > merb_cucumber and not having used features with tabulated input before > > I had to go and look for an explanation of the syntax. However when I > > looked at the wiki page on github that deals with this - > > >http://wiki.github.com/aslakhellesoy/cucumber/using-fit-tables-in-a-f... > > > I had some difficulty mapping the description there into what I was > > seeing in the example, which is shown here - > > >http://github.com/david/merb_cucumber/tree/master/lib/generators/cucu... > > > After some searching I found a discussion on lighthouse that seems to > > bear on this issue - > > >http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/57-sce... > > > This describes a syntax change that (if I understand correctly) > > involves putting variable placeholders in angle brackets and matching > > these to the column headings in the table. This seems to be consistent > > with the merb-cucumber example. > > > However if I'm understanding this correctly, it looks like the change > > has not yet been reflected in the github documentation. Can someone > > confirm for me that this is the case, because it's possible that I'm > > just plain confused. > > > Also, does the approach currently shown in the documentation still > > work? And is the idea there that table columns map sequentially onto > > the strings that correspond to the regexp match groups in the step > > definitions? Are the column headings then essentially redundant in > > that case? > > > Mark. > > Hi Mark, > > I can't check the github wiki right now, because GH is down, but I'm ? > sure I saw Scenario Outline documented on there today. > > There are three ways of doing tabulated data in Cucumber, and as far ? > as I know they're all still supported. > > The basic way, shown on the homepage for cucumber, works in Given and ? > Then steps (but not When), and looks like > > ? ? ?Then there should be the following people: > ? ? ? ?| name ?| age | > ? ? ? ?| Matt ?| 33 ?| > ? ? ? ?| Anna ?| 31 ?| > > The next way extends a single Scenario with a More Examples table. > > The third, and newest way uses a Scenario Outline to define a ? > template, followed by an Examples table to define the value ? > substitutions to make the scenario actually run. > > HTH, > > Matt Wynnehttp://blog.mattwynne.nethttp://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From greg.hauptmann.ruby at gmail.com Sun Jan 11 03:17:15 2009 From: greg.hauptmann.ruby at gmail.com (Greg Hauptmann) Date: Sun, 11 Jan 2009 18:17:15 +1000 Subject: [rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this??? Message-ID: Hi, Any suggestions on how to write an rspec expectation for equality when you get a BigDecimal back. I see that "big_decimal_variable.should == 123.23" doesn't work as the ruby BigDecimal comparison (via ==) to the same Float value gives false (not true as you'd expect). For background / as an example see below: ?> bd => # >> f => -323.03 >> f.class => Float >> bd.should == f Spec::Expectations::ExpectationNotMetError: expected: -323.03, got: # (using ==) from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/expectations.rb:52:in `fail_with' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/matchers/operator_matcher.rb:46:in `fail_with_message' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/matchers/operator_matcher.rb:61:in `__delegate_method_missing_to_given' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/matchers/operator_matcher.rb:12:in `==' from (irb):73 >> bd == f => false >> f == bd => false thanks Greg -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at mwilden.com Sun Jan 11 04:23:02 2009 From: mark at mwilden.com (Mark Wilden) Date: Sun, 11 Jan 2009 01:23:02 -0800 Subject: [rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this??? In-Reply-To: References: Message-ID: <3c30da400901110123p2669f2e4xbda03ca27daa6a20@mail.gmail.com> On Sun, Jan 11, 2009 at 12:17 AM, Greg Hauptmann < greg.hauptmann.ruby at gmail.com> wrote: > > Any suggestions on how to write an rspec expectation for equality when you > get a BigDecimal back. I see that "big_decimal_variable.should == 123.23" > doesn't work as the ruby BigDecimal comparison (via ==) to the same Float > value gives false (not true as you'd expect). > How about bd.to_s.should == 123.23.to_s ? ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.hauptmann.ruby at gmail.com Sun Jan 11 05:05:36 2009 From: greg.hauptmann.ruby at gmail.com (Greg Hauptmann) Date: Sun, 11 Jan 2009 20:05:36 +1000 Subject: [rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this??? In-Reply-To: <3c30da400901110123p2669f2e4xbda03ca27daa6a20@mail.gmail.com> References: <3c30da400901110123p2669f2e4xbda03ca27daa6a20@mail.gmail.com> Message-ID: I've gone with the following ai.amount.should == BigDecimal('-323.03') However I'm still a bit surprised that Ruby itself does allow a good "==" test between a Float and a BigDecimal. Perhaps there's a reason that I'm missing? On Sun, Jan 11, 2009 at 7:23 PM, Mark Wilden wrote: > On Sun, Jan 11, 2009 at 12:17 AM, Greg Hauptmann < > greg.hauptmann.ruby at gmail.com> wrote: > >> >> Any suggestions on how to write an rspec expectation for equality when you >> get a BigDecimal back. I see that "big_decimal_variable.should == 123.23" >> doesn't work as the ruby BigDecimal comparison (via ==) to the same Float >> value gives false (not true as you'd expect). >> > > How about bd.to_s.should == 123.23.to_s ? > > ///ark > > _______________________________________________ > 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 tomcloyd at comcast.net Sun Jan 11 07:26:04 2009 From: tomcloyd at comcast.net (Tom Cloyd) Date: Sun, 11 Jan 2009 04:26:04 -0800 Subject: [rspec-users] getting started - very much a beginner Message-ID: <4969E55C.3000004@comcast.net> A hope my ignorance is acceptable here. I have, to this point, programmed in Ruby mostly using my awareness of procedural programming; I've written a small number of very useful programs for myself. I'm starting to use classes now - just starting. I have a small project I'm working on - setting up a database based on the directed acyclic graph (DAG) model (using Ruby only). I'm been studying test-directed development, which led me to BDD, at which point I got really excited. I truly want to go forward with learning cucumber, and rspec. So here I am trying to started using cucumber, and I'm having a little trouble. The documentation in the cucumber wiki isn't, to my poverty stricken perception, at all procedural, although individual pages seem quite lucid and accessible. After reading and rereading (I've looked at every page, and most several times), it appears that the "start" page is "Cucumber Backgrounder". The problem is that this assumes you are working with Rails, about which I know little and desire to know less. I get stuck, on that page, at the phrase... ==When you run "script/generate cucumber" == Huh? Is this something you do in Rails? Then there's this -- ----- Running script/generate cucumber adds this layout to the existing structure: ||-- features | |-- step_definitions | | `-- webrat_steps.rb | `-- support | `-- env.rb | We are now ready to begin testing with cucumber. ----- Well, maybe for some people...but not for me. I simply cannot see what to do first. Do I manually create some kind of directory structure and fill it with...well, with what? Feature description files? And then what do I do? I'm guessing that this is covered by the "Running features" page. Am I right? Is there documentation somewhere that talks about using cucumber to launch BDD using a non-Rails Ruby program? I think that's what I really need. I cannot quite get past this stuck place, so any help at all would be much appreciated. I'm sorry to bother folks with this - I'm sure it's all quite obvious to you; I wish it were to me, and hope that it soon will be. Hopefully, Tom -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist Bellingham, Washington, U.S.A: (360) 920-1226 << tc at tomcloyd.com >> (email) << TomCloyd.com >> (website) << sleightmind.wordpress.com >> (mental health weblog) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From tomcloyd at comcast.net Sun Jan 11 07:56:35 2009 From: tomcloyd at comcast.net (Tom Cloyd) Date: Sun, 11 Jan 2009 04:56:35 -0800 Subject: [rspec-users] maybe I 'get it' after all Message-ID: <4969EC83.8070708@comcast.net> I hope I'm not the only one in the world who posts to a discussion list only to (maybe) get the answer to a question moments after hitting posting. Sigh. Looking again, in the cucumber wiki page "Running Features", I had a sense that I maybe I DID know what to do, went to /examples/dos_line_endings in the cucumber gems installation on my machine, and entered to the CLI - ~$ cucumber features/dos_line_endings.feature After I stopped laughing at the feature description text (I too love Linux), I have to admit that this output simply works for me. Whew. So...my sense of "what to do" now, is to write *.feature files, with corresponding step definition files, then...well, there's lots of what-to-do info very lucidly written in the wiki. I much enjoy reading it - although I wish the Rails stuff was factored out, because it's of no use if you're not doing Rails, and I think I'm going to have to try to translate some of it, and will likely do it badly... If someone wants to redirect me in any way, I'll give very close attention to their advice. Meanwhile, I'm feeling like I can go forward with this and I'll be learning a great deal. This sure looks like fun...and very very useful, in the long run. I'm endlessly grateful for the hard work of others in the Ruby world, from which I benefit so much. t. -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist Bellingham, Washington, U.S.A: (360) 920-1226 << tc at tomcloyd.com >> (email) << TomCloyd.com >> (website) << sleightmind.wordpress.com >> (mental health weblog) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From aslak.hellesoy at gmail.com Sun Jan 11 08:09:03 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 11 Jan 2009 14:09:03 +0100 Subject: [rspec-users] getting started - very much a beginner In-Reply-To: <4969E55C.3000004@comcast.net> References: <4969E55C.3000004@comcast.net> Message-ID: <8d961d900901110509y4c2c95c0l97f929ef984ed4c@mail.gmail.com> On Sun, Jan 11, 2009 at 1:26 PM, Tom Cloyd wrote: > A hope my ignorance is acceptable here. I have, to this point, > programmed in Ruby mostly using my awareness of procedural programming; > I've written a small number of very useful programs for myself. I'm starting > to use classes now - just starting. > > I have a small project I'm working on - setting up a database based on the > directed acyclic graph (DAG) model (using Ruby only). I'm been studying > test-directed development, which led me to BDD, at which point I got really > excited. I truly want to go forward with learning cucumber, and rspec. > > So here I am trying to started using cucumber, and I'm having a little > trouble. The documentation in the cucumber wiki isn't, to my poverty > stricken perception, at all procedural, although individual pages seem > quite lucid and accessible. After reading and rereading (I've looked at > every page, and most several times), it appears that the "start" page is > "Cucumber Backgrounder". The problem is that this assumes you are working > with Rails, about which I know little and desire to know less. I get stuck, > on that page, at the phrase... > > ==When you run "script/generate cucumber" == > > Huh? Is this something you do in Rails? > Yes, this is Rails only. I recommend you take a look at the examples/i18n folder. You'll find some really simplistic Cucumber code that is simple Ruby. No Rails or other complex material. Aslak > Then there's this -- > > ----- > > Running script/generate cucumber adds this layout to the existing > structure: > > ||-- features > | |-- step_definitions > | | `-- webrat_steps.rb > | `-- support > | `-- env.rb > | > > We are now ready to begin testing with cucumber. > > ----- > > Well, maybe for some people...but not for me. > > I simply cannot see what to do first. Do I manually create some kind of > directory structure and fill it with...well, with what? Feature > description files? And then what do I do? I'm guessing that this is > covered by the "Running features" page. Am I right? > > Is there documentation somewhere that talks about using cucumber to > launch BDD using a non-Rails Ruby program? I think that's what I really > need. I cannot quite get past this stuck place, so any help at all would > be much appreciated. I'm sorry to bother folks with this - I'm sure it's > all quite obvious to you; I wish it were to me, and hope that it soon > will be. > > Hopefully, > > Tom > > -- > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist > Bellingham, Washington, U.S.A: (360) 920-1226 > << tc at tomcloyd.com >> (email) > << TomCloyd.com >> (website) > << sleightmind.wordpress.com >> (mental health weblog) > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > _______________________________________________ > 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 aslak.hellesoy at gmail.com Sun Jan 11 08:12:46 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 11 Jan 2009 14:12:46 +0100 Subject: [rspec-users] maybe I 'get it' after all In-Reply-To: <4969EC83.8070708@comcast.net> References: <4969EC83.8070708@comcast.net> Message-ID: <8d961d900901110512m7d6cffc6qbd5d01418b1be0ee@mail.gmail.com> On Sun, Jan 11, 2009 at 1:56 PM, Tom Cloyd wrote: > I hope I'm not the only one in the world who posts to a discussion list > only to (maybe) get the answer to a question moments after hitting > posting. Sigh. > > Looking again, in the cucumber wiki page "Running Features", I had a > sense that I maybe I DID know what to do, went to > /examples/dos_line_endings in the cucumber gems installation on my > machine, and entered to the CLI - > > ~$ cucumber features/dos_line_endings.feature > > After I stopped laughing at the feature description text (I too love > Linux), I have to admit that this output simply works for me. Whew. > > So...my sense of "what to do" now, is to write *.feature files, with > corresponding step definition files, then...well, there's lots of > what-to-do info very lucidly written in the wiki. I much enjoy reading > it - although I wish the Rails stuff was factored out, because it's of > no use if you're not doing Rails, and I think I'm going to have to try > to translate some of it, and will likely do it badly... > Good point. Keeping Rails-related content apart from the more general Cucumber docs has been my goal since I started. However, several contributors to the Wiki are using Rails and it seems they often think that everybody is using Rails. Or maybe they are so ingrained in the Rails way of doing things that it's hard to describe non-Rails environments. Keep this in mind folks! Aslak > > If someone wants to redirect me in any way, I'll give very close > attention to their advice. Meanwhile, I'm feeling like I can go > forward with this and I'll be learning a great deal. This sure looks > like fun...and very very useful, in the long run. > > I'm endlessly grateful for the hard work of others in the Ruby world, > from which I benefit so much. > > t. > > -- > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist > Bellingham, Washington, U.S.A: (360) 920-1226 > << tc at tomcloyd.com >> (email) > << TomCloyd.com >> (website) > << sleightmind.wordpress.com >> (mental health weblog) > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > _______________________________________________ > 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 biot023 at gmail.com Sun Jan 11 08:16:06 2009 From: biot023 at gmail.com (doug livesey) Date: Sun, 11 Jan 2009 13:16:06 +0000 Subject: [rspec-users] maybe I 'get it' after all In-Reply-To: <4969EC83.8070708@comcast.net> References: <4969EC83.8070708@comcast.net> Message-ID: <50873a360901110516o778a10es864e1e6e9f20759e@mail.gmail.com> > I hope I'm not the only one in the world who posts to a discussion list > only to (maybe) get the answer to a question moments after hitting > posting. Sigh. Hey, that's my trick! Get your own! 2009/1/11 Tom Cloyd > I hope I'm not the only one in the world who posts to a discussion list > only to (maybe) get the answer to a question moments after hitting > posting. Sigh. > > Looking again, in the cucumber wiki page "Running Features", I had a > sense that I maybe I DID know what to do, went to > /examples/dos_line_endings in the cucumber gems installation on my > machine, and entered to the CLI - > > ~$ cucumber features/dos_line_endings.feature > > After I stopped laughing at the feature description text (I too love > Linux), I have to admit that this output simply works for me. Whew. > > So...my sense of "what to do" now, is to write *.feature files, with > corresponding step definition files, then...well, there's lots of > what-to-do info very lucidly written in the wiki. I much enjoy reading > it - although I wish the Rails stuff was factored out, because it's of > no use if you're not doing Rails, and I think I'm going to have to try > to translate some of it, and will likely do it badly... > > If someone wants to redirect me in any way, I'll give very close > attention to their advice. Meanwhile, I'm feeling like I can go > forward with this and I'll be learning a great deal. This sure looks > like fun...and very very useful, in the long run. > > I'm endlessly grateful for the hard work of others in the Ruby world, > from which I benefit so much. > > t. > > -- > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist > Bellingham, Washington, U.S.A: (360) 920-1226 > << tc at tomcloyd.com >> (email) > << TomCloyd.com >> (website) > << sleightmind.wordpress.com >> (mental health weblog) > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > _______________________________________________ > 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 dchelimsky at gmail.com Sun Jan 11 09:21:07 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 11 Jan 2009 08:21:07 -0600 Subject: [rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this??? In-Reply-To: References: <3c30da400901110123p2669f2e4xbda03ca27daa6a20@mail.gmail.com> Message-ID: <57c63afe0901110621p774a15dp86e78028e79cef92@mail.gmail.com> On Sun, Jan 11, 2009 at 4:05 AM, Greg Hauptmann wrote: > I've gone with the following > ai.amount.should == BigDecimal('-323.03') > However I'm still a bit surprised that Ruby itself does allow a good "==" > test between a Float and a BigDecimal. Perhaps there's a reason that I'm > missing? Very telling is this: >> require 'bigdecimal' => true >> BigDecimal.new(3333333.0) == 3333333.0 TypeError: can't convert Float into String from (irb):4:in `new' from (irb):4 As for why, I think you'll get some good insights if you post the ruby-lang mailing list, but I can take shot. BigDecimal has explicit precision. Float does not. Imagine the developer at the bank explaining that the thousands of dollars discrepancy last year was due to an average miscalculation of 0.00005 per transaction because sometimes the code used BigDecimal, and sometimes it used Float. Personally, I think this seeming annoyance is actually a good thing. FWIW, David > > On Sun, Jan 11, 2009 at 7:23 PM, Mark Wilden wrote: >> >> On Sun, Jan 11, 2009 at 12:17 AM, Greg Hauptmann >> wrote: >>> >>> Any suggestions on how to write an rspec expectation for equality when >>> you get a BigDecimal back. I see that "big_decimal_variable.should == >>> 123.23" doesn't work as the ruby BigDecimal comparison (via ==) to the same >>> Float value gives false (not true as you'd expect). >> >> How about bd.to_s.should == 123.23.to_s ? >> >> ///ark From matt at mattwynne.net Sun Jan 11 09:28:29 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 11 Jan 2009 14:28:29 +0000 Subject: [rspec-users] Is the Fit Table documentation correct? In-Reply-To: <9a447563-6e33-4710-8392-1c0e48c8f9c7@f40g2000pri.googlegroups.com> References: <0216EBFF-686E-4085-AB3A-8D972F19E0FA@mattwynne.net> <9a447563-6e33-4710-8392-1c0e48c8f9c7@f40g2000pri.googlegroups.com> Message-ID: <232C8D95-A694-47E9-9EB9-B385184BA514@mattwynne.net> On 11 Jan 2009, at 01:22, MarkMT wrote: > Thanks Matt. I have now found the page that deals with scenario > outlines (GH is back up) - > > http://wiki.github.com/aslakhellesoy/cucumber/scenario-outlines > > so that is now pretty clear. Might be worth a note in the fit table > page referring to that. The wiki is open to all... be our guest! Seriously it's terrific if first-timers can polish these pages, as they're often written by those of us who are quite immersed in the product and consequently find it harder to put on the 'newbie hat' to proof-read documentation. cheers, Matt Wynne http://blog.mattwynne.net http://www.songkick.com From rick.denatale at gmail.com Sun Jan 11 13:53:05 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sun, 11 Jan 2009 13:53:05 -0500 Subject: [rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this??? In-Reply-To: <57c63afe0901110621p774a15dp86e78028e79cef92@mail.gmail.com> References: <3c30da400901110123p2669f2e4xbda03ca27daa6a20@mail.gmail.com> <57c63afe0901110621p774a15dp86e78028e79cef92@mail.gmail.com> Message-ID: On Sun, Jan 11, 2009 at 9:21 AM, David Chelimsky wrote: > On Sun, Jan 11, 2009 at 4:05 AM, Greg Hauptmann > wrote: > > I've gone with the following > > ai.amount.should == BigDecimal('-323.03') > > However I'm still a bit surprised that Ruby itself does allow a good "==" > > test between a Float and a BigDecimal. Perhaps there's a reason that I'm > > missing? > > Very telling is this: > > >> require 'bigdecimal' > => true > >> BigDecimal.new(3333333.0) == 3333333.0 > TypeError: can't convert Float into String > from (irb):4:in `new' > from (irb):4 > > As for why, I think you'll get some good insights if you post the > ruby-lang mailing list, but I can take shot. > > BigDecimal has explicit precision. Float does not. Imagine the > developer at the bank explaining that the thousands of dollars > discrepancy last year was due to an average miscalculation of 0.00005 > per transaction because sometimes the code used BigDecimal, and > sometimes it used Float. > Even more telling is this: irb(main):001:0> 1.0 / 3.0 => 0.333333333333333 irb(main):002:0> (1.0 / 3.00) == 0.333333333333333 => false This has little to do with rspec or Ruby, and everything to do with floats. Floats are approximations, it's a mistake to thing of them as equivalent to the mathematical concept of real numbers, or even rational numbers. There are several issues here including 1. Floats are not infinite precision, they have a fixed number of bits or digits, this means that in-between any two consecutive real number which CAN be represented by a float, there are an infinite number of reals which cannot. 2. As is the case in decimal fractions, where some rational numbers such as 1/3 cannot be represented without an infinite number of decimal digits, there are similar values dependent on the base used for the float representation. There's a whole branch of computer science, Numerical Analysis, comprised in large part of understanding how Floats differ from the mathematical ideal. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.hauptmann.ruby at gmail.com Sun Jan 11 15:33:34 2009 From: greg.hauptmann.ruby at gmail.com (Greg Hauptmann) Date: Mon, 12 Jan 2009 06:33:34 +1000 Subject: [rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this??? In-Reply-To: References: <3c30da400901110123p2669f2e4xbda03ca27daa6a20@mail.gmail.com> <57c63afe0901110621p774a15dp86e78028e79cef92@mail.gmail.com> Message-ID: it would be nice in one's project if you could basically say "use BigDecimal wherever you normally would have used a float", just to get the benefit but maintain ease of coding/readability etc - anyone know if this is possible? Would it be enough to override Float's initializer and return a BigDecimal instead? On Mon, Jan 12, 2009 at 4:53 AM, Rick DeNatale wrote: > On Sun, Jan 11, 2009 at 9:21 AM, David Chelimsky wrote: > >> On Sun, Jan 11, 2009 at 4:05 AM, Greg Hauptmann >> wrote: >> > I've gone with the following >> > ai.amount.should == BigDecimal('-323.03') >> > However I'm still a bit surprised that Ruby itself does allow a good >> "==" >> > test between a Float and a BigDecimal. Perhaps there's a reason that >> I'm >> > missing? >> >> Very telling is this: >> >> >> require 'bigdecimal' >> => true >> >> BigDecimal.new(3333333.0) == 3333333.0 >> TypeError: can't convert Float into String >> from (irb):4:in `new' >> from (irb):4 >> >> As for why, I think you'll get some good insights if you post the >> ruby-lang mailing list, but I can take shot. >> >> BigDecimal has explicit precision. Float does not. Imagine the >> developer at the bank explaining that the thousands of dollars >> discrepancy last year was due to an average miscalculation of 0.00005 >> per transaction because sometimes the code used BigDecimal, and >> sometimes it used Float. >> > > Even more telling is this: > irb(main):001:0> 1.0 / 3.0 > => 0.333333333333333 > irb(main):002:0> (1.0 / 3.00) == 0.333333333333333 > => false > > This has little to do with rspec or Ruby, and everything to do with floats. > > Floats are approximations, it's a mistake to thing of them as equivalent to > the mathematical concept of real numbers, or even rational numbers. There > are several issues here including > > 1. Floats are not infinite precision, they have a fixed number of bits or > digits, this means that in-between any two consecutive real number which CAN > be represented by a float, there are an infinite number of reals which > cannot. > > 2. As is the case in decimal fractions, where some rational numbers such as > 1/3 cannot be represented without an infinite number of decimal digits, > there are similar values dependent on the base used for the float > representation. > > There's a whole branch of computer science, Numerical Analysis, comprised > in large part of understanding how Floats differ from the mathematical > ideal. > > > -- > Rick DeNatale > > Blog: http://talklikeaduck.denhaven2.com/ > Twitter: http://twitter.com/RickDeNatale > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Greg http://blog.gregnet.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From mauricio.linhares at gmail.com Sun Jan 11 15:45:28 2009 From: mauricio.linhares at gmail.com (=?ISO-8859-1?Q?Maur=EDcio_Linhares?=) Date: Sun, 11 Jan 2009 18:45:28 -0200 Subject: [rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this??? In-Reply-To: References: <3c30da400901110123p2669f2e4xbda03ca27daa6a20@mail.gmail.com> <57c63afe0901110621p774a15dp86e78028e79cef92@mail.gmail.com> Message-ID: This is a very bad idea, as you can break the whole runtime by doing this, as many internal classes use floating point math. You would also slow the world down, as operations using BigDecimals are some order of magnitude slower than pure floating point math. - Maur?cio Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Sun, Jan 11, 2009 at 6:33 PM, Greg Hauptmann wrote: > it would be nice in one's project if you could basically say "use > BigDecimal wherever you normally would have used a float", just to get the > benefit but maintain ease of coding/readability etc - anyone know if this is > possible? Would it be enough to override Float's initializer and return a > BigDecimal instead? > > > On Mon, Jan 12, 2009 at 4:53 AM, Rick DeNatale > wrote: >> >> On Sun, Jan 11, 2009 at 9:21 AM, David Chelimsky >> wrote: >>> >>> On Sun, Jan 11, 2009 at 4:05 AM, Greg Hauptmann >>> wrote: >>> > I've gone with the following >>> > ai.amount.should == BigDecimal('-323.03') >>> > However I'm still a bit surprised that Ruby itself does allow a good >>> > "==" >>> > test between a Float and a BigDecimal. Perhaps there's a reason that >>> > I'm >>> > missing? >>> >>> Very telling is this: >>> >>> >> require 'bigdecimal' >>> => true >>> >> BigDecimal.new(3333333.0) == 3333333.0 >>> TypeError: can't convert Float into String >>> from (irb):4:in `new' >>> from (irb):4 >>> >>> As for why, I think you'll get some good insights if you post the >>> ruby-lang mailing list, but I can take shot. >>> >>> BigDecimal has explicit precision. Float does not. Imagine the >>> developer at the bank explaining that the thousands of dollars >>> discrepancy last year was due to an average miscalculation of 0.00005 >>> per transaction because sometimes the code used BigDecimal, and >>> sometimes it used Float. >> >> Even more telling is this: >> irb(main):001:0> 1.0 / 3.0 >> => 0.333333333333333 >> irb(main):002:0> (1.0 / 3.00) == 0.333333333333333 >> => false >> >> This has little to do with rspec or Ruby, and everything to do with >> floats. >> >> Floats are approximations, it's a mistake to thing of them as equivalent >> to the mathematical concept of real numbers, or even rational numbers. There >> are several issues here including >> >> 1. Floats are not infinite precision, they have a fixed number of bits or >> digits, this means that in-between any two consecutive real number which CAN >> be represented by a float, there are an infinite number of reals which >> cannot. >> >> 2. As is the case in decimal fractions, where some rational numbers such >> as 1/3 cannot be represented without an infinite number of decimal digits, >> there are similar values dependent on the base used for the float >> representation. >> >> There's a whole branch of computer science, Numerical Analysis, comprised >> in large part of understanding how Floats differ from the mathematical >> ideal. >> >> >> -- >> Rick DeNatale >> >> Blog: http://talklikeaduck.denhaven2.com/ >> Twitter: http://twitter.com/RickDeNatale >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > -- > Greg > http://blog.gregnet.org/ > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tero at tilus.net Sun Jan 11 16:31:20 2009 From: tero at tilus.net (Tero Tilus) Date: Sun, 11 Jan 2009 23:31:20 +0200 Subject: [rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this??? In-Reply-To: References: Message-ID: <20090111213119.GE18105@uivelo.tilus.net> 2009-01-11 18:17, Greg Hauptmann: > Any suggestions on how to write an rspec expectation for equality when you > get a BigDecimal back. I see that "big_decimal_variable.should == > 123.23" If you register keywords "comparison" and "float", you should train yourself to cry out "delta" without even thinking. ;) Would this work for you? big_decimal_variable.should be_close(123.23, 0.005) -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From mark at mwilden.com Sun Jan 11 17:06:42 2009 From: mark at mwilden.com (Mark Wilden) Date: Sun, 11 Jan 2009 14:06:42 -0800 Subject: [rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this??? In-Reply-To: References: Message-ID: <3c30da400901111406v1c652585x79a63f86cadd531e@mail.gmail.com> On Sun, Jan 11, 2009 at 12:17 AM, Greg Hauptmann < greg.hauptmann.ruby at gmail.com> wrote: > Any suggestions on how to write an rspec expectation for equality when you > get a BigDecimal back. I see that "big_decimal_variable.should == 123.23" > doesn't work as the ruby BigDecimal comparison (via ==) to the same Float > value gives false (not true as you'd expect). > Noting there are two decimal places in your data, I might suggest using the Money plugin. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.hauptmann.ruby at gmail.com Sun Jan 11 17:36:42 2009 From: greg.hauptmann.ruby at gmail.com (Greg Hauptmann) Date: Mon, 12 Jan 2009 08:36:42 +1000 Subject: [rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this??? In-Reply-To: References: <3c30da400901110123p2669f2e4xbda03ca27daa6a20@mail.gmail.com> <57c63afe0901110621p774a15dp86e78028e79cef92@mail.gmail.com> Message-ID: ok - thanks - seems like if one remembers to use "BigDecimal('10.1')", then instead of 10.1 in your code you should be ok then. On Mon, Jan 12, 2009 at 6:45 AM, Maur?cio Linhares < mauricio.linhares at gmail.com> wrote: > This is a very bad idea, as you can break the whole runtime by doing > this, as many internal classes use floating point math. You would also > slow the world down, as operations using BigDecimals are some order of > magnitude slower than pure floating point math. > > - > Maur?cio Linhares > http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) > > > > On Sun, Jan 11, 2009 at 6:33 PM, Greg Hauptmann > wrote: > > it would be nice in one's project if you could basically say "use > > BigDecimal wherever you normally would have used a float", just to get > the > > benefit but maintain ease of coding/readability etc - anyone know if this > is > > possible? Would it be enough to override Float's initializer and return > a > > BigDecimal instead? > > > > > > On Mon, Jan 12, 2009 at 4:53 AM, Rick DeNatale > > wrote: > >> > >> On Sun, Jan 11, 2009 at 9:21 AM, David Chelimsky > >> wrote: > >>> > >>> On Sun, Jan 11, 2009 at 4:05 AM, Greg Hauptmann > >>> wrote: > >>> > I've gone with the following > >>> > ai.amount.should == BigDecimal('-323.03') > >>> > However I'm still a bit surprised that Ruby itself does allow a good > >>> > "==" > >>> > test between a Float and a BigDecimal. Perhaps there's a reason that > >>> > I'm > >>> > missing? > >>> > >>> Very telling is this: > >>> > >>> >> require 'bigdecimal' > >>> => true > >>> >> BigDecimal.new(3333333.0) == 3333333.0 > >>> TypeError: can't convert Float into String > >>> from (irb):4:in `new' > >>> from (irb):4 > >>> > >>> As for why, I think you'll get some good insights if you post the > >>> ruby-lang mailing list, but I can take shot. > >>> > >>> BigDecimal has explicit precision. Float does not. Imagine the > >>> developer at the bank explaining that the thousands of dollars > >>> discrepancy last year was due to an average miscalculation of 0.00005 > >>> per transaction because sometimes the code used BigDecimal, and > >>> sometimes it used Float. > >> > >> Even more telling is this: > >> irb(main):001:0> 1.0 / 3.0 > >> => 0.333333333333333 > >> irb(main):002:0> (1.0 / 3.00) == 0.333333333333333 > >> => false > >> > >> This has little to do with rspec or Ruby, and everything to do with > >> floats. > >> > >> Floats are approximations, it's a mistake to thing of them as equivalent > >> to the mathematical concept of real numbers, or even rational numbers. > There > >> are several issues here including > >> > >> 1. Floats are not infinite precision, they have a fixed number of bits > or > >> digits, this means that in-between any two consecutive real number which > CAN > >> be represented by a float, there are an infinite number of reals which > >> cannot. > >> > >> 2. As is the case in decimal fractions, where some rational numbers such > >> as 1/3 cannot be represented without an infinite number of decimal > digits, > >> there are similar values dependent on the base used for the float > >> representation. > >> > >> There's a whole branch of computer science, Numerical Analysis, > comprised > >> in large part of understanding how Floats differ from the mathematical > >> ideal. > >> > >> > >> -- > >> Rick DeNatale > >> > >> Blog: http://talklikeaduck.denhaven2.com/ > >> Twitter: http://twitter.com/RickDeNatale > >> > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > -- > > Greg > > http://blog.gregnet.org/ > > > > > > > > _______________________________________________ > > 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 > -- Greg http://blog.gregnet.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Mon Jan 12 09:09:33 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 12 Jan 2009 14:09:33 +0000 Subject: [rspec-users] NullDb makes rake spec take (much) longer Message-ID: <3CF2B3E2-176F-4F69-B613-580D4ADBD277@mattwynne.net> Hi all, We did a spike last week to de-couple our view and controller tests from the database, using NullDb. It didn't go too well. I realise that this plugin isn't part of RSpec, but I thought others on this list might have experiences to share. Here's a summary of my colleague's investigations: > I installed the plugin from http://github.com/jakehow/nulldb/tree/master > > Changed spec/spec_helper to set > "ActiveRecord::Base.establish_connection(:adapter => :nulldb)" by > default. > > The specs that complained of the lack of db, I included a before(all) > that changed the connection to the test database (include > NeedsDatabase - copied from Ben Mabey's Functional module) > By default, I also included the db for all models (config.include > NeedsDatabase, :type => :model) > > Running spec spec/views with or without nulldb takes about the same > time (a couple of seconds less with nulldb). However, running "rake > spec" with nulldb takes 10 times longer!! > > Another weird thing was that three tests failed in the controllers > (venues and concerts) in a very strange way, even when I included the > NeedsDatabase in the tests that needed it. The weird bit is, when I > run: "spec spec/controllers/venues_controller_spec.rb" it doesn't > fail. But when I run: "spec spec/controllers/users_controller_spec.rb > spec/controllers/venues_controller_spec.rb" It does fail... That is, > the user_controller test is influencing the results of the > venue_controller test! > The same weird behaviour happens in lib/sk/find > > This made me had to include NeedsDatabase for all lib and controllers > tests as well. The barrier for us was the shockingly poor performance of 'rake spec' on the view specs - it really means we just can't use it, and actually only barely improved the performance of the specs at all. I was disappointed that the view specs didn't get any faster. My guess is that stub_model is the problem - as it has to do quite a bit of work to set up the attributes on the models. So, can anyone tell us what we might have been doing wrong? Or did I just have unrealistic expectations of how this might help? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From lists at ruby-forum.com Mon Jan 12 10:20:35 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 12 Jan 2009 16:20:35 +0100 Subject: [rspec-users] getting started - very much a beginner In-Reply-To: <4969E55C.3000004@comcast.net> References: <4969E55C.3000004@comcast.net> Message-ID: <66a39943877200ba3e6bb3ac5ff4d898@ruby-forum.com> Tom Cloyd wrote: > > The problem is that this assumes you are working with Rails, about > which I know little and desire to know less. I get stuck, on that page, > at the phrase... > > ==When you run "script/generate cucumber" == > > Huh? Is this something you do in Rails? > > Then there's this -- > > ----- > > Running script/generate cucumber adds this layout to the existing > structure: > > ||-- features > | |-- step_definitions > | | `-- webrat_steps.rb > | `-- support > | `-- env.rb > | > > We are now ready to begin testing with cucumber. > > ----- > > Well, maybe for some people...but not for me. > > I simply cannot see what to do first. First, let me a assure you that ignorance, or at least the admission to it, is a de facto requirement here. If we all knew everything then there would be precious little to write about. Second, as the author of the Cucumber Backgrounder, I apologize for my evident bias in creating a solely Rails Centric guide. This article was, in fact, my first attempt at such a thing and I completely overlooked that others might not approach testing with cucumber from outside the Rails Framework. Over the next little while I will endeavour to correct that defect. Third, that article was intended as a guide on how to get cucumber working inside a Rails project rather than a guide on how to actually construct tests/features. In other words, it deals primarily with the mechanics of setting up the environment rather than with exercising the capabilities. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Mon Jan 12 11:45:07 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 12 Jan 2009 17:45:07 +0100 Subject: [rspec-users] Persisting Logins and Sessions across scenarios Message-ID: I have an authentication filter on my application controller. I have the following feature statements: Scenario: I should be logged in to do any of this Given we have a user named "myuser" And the user named "myuser" logs in When they visit the "entities" page Then they should see the "entities" page Scenario: Entity should have essential identification information Given I do not have any entities And I am on the add a new entity page When I enter "My Business Relation" in the "Common Name" field And I enter "My B.R. Legal Name" in the "Legal Name" field And I choose "Corporation" as the "Legal Form" And I press "Create" Then I should save the entity information successfully In scenario 1, the user is logged in successfully and the response body after the 'see the "entities" page' is indeed the entities/index page. When /should see the "(entities)" page/ do |resource| response.body.should =~ /All Entities/m end When /on the add a new entity page/ do visits new_entity_path response.body.should =~ /Add a New Entity/m end However, in Scenario 2, I am assuming that a.) the same user (myuser) and their associated login session is employed. Since the response body from this is the login page then evidently this assumption is wrong and something else is going on. Can some inform me as to how test logins are managed/maintained/reused within cucumber/webrat? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Mon Jan 12 12:21:49 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 12 Jan 2009 11:21:49 -0600 Subject: [rspec-users] Persisting Logins and Sessions across scenarios In-Reply-To: References: Message-ID: <57c63afe0901120921j71a49306i2d7af4509357589e@mail.gmail.com> On Mon, Jan 12, 2009 at 10:45 AM, James Byrne wrote: > I have an authentication filter on my application controller. I have the > following feature statements: > > > Scenario: I should be logged in to do any of this > Given we have a user named "myuser" > And the user named "myuser" logs in > When they visit the "entities" page > Then they should see the "entities" page > > > Scenario: Entity should have essential identification information > > Given I do not have any entities > And I am on the add a new entity page > When I enter "My Business Relation" in the "Common Name" field > And I enter "My B.R. Legal Name" in the "Legal Name" field > And I choose "Corporation" as the "Legal Form" > And I press "Create" > Then I should save the entity information successfully > > In scenario 1, the user is logged in successfully and the response body > after the 'see the "entities" page' is indeed the entities/index page. > > When /should see the "(entities)" page/ do |resource| > response.body.should =~ /All Entities/m > end > > When /on the add a new entity page/ do > visits new_entity_path > response.body.should =~ /Add a New Entity/m > end > > > However, in Scenario 2, I am assuming that a.) the same user (myuser) > and their associated login session is employed. Since the response body > from this is the login page then evidently this assumption is wrong and > something else is going on. Can some inform me as to how test logins > are managed/maintained/reused within cucumber/webrat? Each scenario operates in a new session. I usually have a step that aggregates the login process: Given /^I am logged in as "(.*)"/ do |role| #create a user whose name and role are based on the role #log in that user end This lets me say: Given I am logged in as "admin" When I visit the super-secret page Then I see it and learn about all its mystery HTH, David From ben at benmabey.com Mon Jan 12 12:36:16 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 12 Jan 2009 10:36:16 -0700 Subject: [rspec-users] NullDb makes rake spec take (much) longer In-Reply-To: <3CF2B3E2-176F-4F69-B613-580D4ADBD277@mattwynne.net> References: <3CF2B3E2-176F-4F69-B613-580D4ADBD277@mattwynne.net> Message-ID: <496B7F90.3040007@benmabey.com> On 1/12/09 7:09 AM, Matt Wynne wrote: > Hi all, > > We did a spike last week to de-couple our view and controller tests > from the database, using NullDb. It didn't go too well. I realise that > this plugin isn't part of RSpec, but I thought others on this list > might have experiences to share. > > Here's a summary of my colleague's investigations: > >> I installed the plugin from http://github.com/jakehow/nulldb/tree/master >> >> Changed spec/spec_helper to set >> "ActiveRecord::Base.establish_connection(:adapter => :nulldb)" by >> default. >> >> The specs that complained of the lack of db, I included a before(all) >> that changed the connection to the test database (include >> NeedsDatabase - copied from Ben Mabey's Functional module) >> By default, I also included the db for all models (config.include >> NeedsDatabase, :type => :model) >> >> Running spec spec/views with or without nulldb takes about the same >> time (a couple of seconds less with nulldb). However, running "rake >> spec" with nulldb takes 10 times longer!! >> >> Another weird thing was that three tests failed in the controllers >> (venues and concerts) in a very strange way, even when I included the >> NeedsDatabase in the tests that needed it. The weird bit is, when I >> run: "spec spec/controllers/venues_controller_spec.rb" it doesn't >> fail. But when I run: "spec spec/controllers/users_controller_spec.rb >> spec/controllers/venues_controller_spec.rb" It does fail... That is, >> the user_controller test is influencing the results of the >> venue_controller test! >> The same weird behaviour happens in lib/sk/find >> >> This made me had to include NeedsDatabase for all lib and controllers >> tests as well. > > The barrier for us was the shockingly poor performance of 'rake spec' > on the view specs - it really means we just can't use it, and actually > only barely improved the performance of the specs at all. > > I was disappointed that the view specs didn't get any faster. My guess > is that stub_model is the problem - as it has to do quite a bit of > work to set up the attributes on the models. > > So, can anyone tell us what we might have been doing wrong? Or did I > just have unrealistic expectations of how this might help? > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Hey Matt, I had similar experiences when I started using NullDB. I think that the reason why the overall spec suite runs slow is AR is switching from one adapter to another, and in the case of the mysql one it probably is relatively expensive to set up a new connection. Switching over to using NullDB on an existing project of any sizable size is going to be large task IMO. On my last project we started using NullDB by default and the result has been very worthwhile and noticeable. In this project DB connectivity was the exception, not the norm (even on our model specs) and so that is why I created a module that would turn on the DB temporarily. In your case the opposite approach may be needed. Going back to the problem at hand... Based on the email you are using a module like this: unless Object.const_defined?(:NeedsDatabase) share_as :NeedsDatabase do before :all do ActiveRecord::Base.establish_connection(:test) end after :all do ActiveRecord::Base.establish_connection(:adapter => :nulldb) end end end Since you are including this on all of your model specs (and more) you are incurring the setup and teardown cost of the DB connection repeatedly. Like I said, you may want to adopt the opposite policy of turning it off temporarily... You could also make the the changing smarter by only changing it when you need to.. something like: share_as :NeedsDatabase do before :all do ActiveRecord::Base.establish_connection(:test) if ActiveRecord::Base.connection.class.to_s =~ /NullDB/ end end share_as :DontNeedDatabase do before :all do ActiveRecord::Base.establish_connection(:adapter => :nulldb) unless ActiveRecord::Base.connection.class.to_s =~ /NullDB/ end end With this approach you would need to specify whether or not to use the DB for each example group... just a thought. Of course, an even better solution would be to somehow modify AR to maintain an active connection to the real DB even when it isn't the active adapter. re: the view specs I wouldn't expect to see too much gain here. The big win for nullDB is in models IMO. Of course, having it on the view and controller specs helps prevent accidental DB calls. re: the random controller spec failures I only guess is that you are somehow relying on the DB in your controller specs. I did this too in my controllers when I called class methods on models that would get a list from the DB... I can't really help without seeing any specs though. I hope this helps and you can find a suitable policy on how to manage the connections/adapters. Just ask if you have any other questions. -Ben From lists at ruby-forum.com Mon Jan 12 12:46:23 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 12 Jan 2009 18:46:23 +0100 Subject: [rspec-users] Persisting Logins and Sessions across scenarios In-Reply-To: <57c63afe0901120921j71a49306i2d7af4509357589e@mail.gmail.com> References: <57c63afe0901120921j71a49306i2d7af4509357589e@mail.gmail.com> Message-ID: David Chelimsky wrote: > > Each scenario operates in a new session. > > I usually have a step that aggregates the login process: > > Given /^I am logged in as "(.*)"/ do |role| > #create a user whose name and role are based on the role > #log in that user > end > > This lets me say: > > Given I am logged in as "admin" > When I visit the super-secret page > Then I see it and learn about all its mystery > > HTH, > David Thanks David, I have something like that: When /user named "(.*)" logs in/ do |name| # assumes that the user given exists of course visits root_path UserSession.find.destroy if UserSession.find Then "enter the username \"#{name}\"" Then "enter the password \"#{name}-password\"" Then "press the login button" Then "welcome message" end But this seems needlessly expensive given that the entire application is secured. Is there no way of preserving a login session for any arbitrary period across both features and scenario? Is there a technical or philosophical reason why this is not so? -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Mon Jan 12 13:10:14 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 12 Jan 2009 19:10:14 +0100 Subject: [rspec-users] Persisting Logins and Sessions across scenarios In-Reply-To: <57c63afe0901120921j71a49306i2d7af4509357589e@mail.gmail.com> References: <57c63afe0901120921j71a49306i2d7af4509357589e@mail.gmail.com> Message-ID: <8d961d900901121010k7805ce6fg602a111280477407@mail.gmail.com> On Mon, Jan 12, 2009 at 6:21 PM, David Chelimsky wrote: > On Mon, Jan 12, 2009 at 10:45 AM, James Byrne > wrote: > > I have an authentication filter on my application controller. I have the > > following feature statements: > > > > > > Scenario: I should be logged in to do any of this > > Given we have a user named "myuser" > > And the user named "myuser" logs in > > When they visit the "entities" page > > Then they should see the "entities" page > > > > > > Scenario: Entity should have essential identification information > > > > Given I do not have any entities > > And I am on the add a new entity page > > When I enter "My Business Relation" in the "Common Name" field > > And I enter "My B.R. Legal Name" in the "Legal Name" field > > And I choose "Corporation" as the "Legal Form" > > And I press "Create" > > Then I should save the entity information successfully > > > > In scenario 1, the user is logged in successfully and the response body > > after the 'see the "entities" page' is indeed the entities/index page. > > > > When /should see the "(entities)" page/ do |resource| > > response.body.should =~ /All Entities/m > > end > > > > When /on the add a new entity page/ do > > visits new_entity_path > > response.body.should =~ /Add a New Entity/m > > end > > > > > > However, in Scenario 2, I am assuming that a.) the same user (myuser) > > and their associated login session is employed. Since the response body > > from this is the login page then evidently this assumption is wrong and > > something else is going on. Can some inform me as to how test logins > > are managed/maintained/reused within cucumber/webrat? > > Each scenario operates in a new session. > And coupling scenarios (or any kind of automated test - regardless of framework) is a very bad idea. Aslak > > I usually have a step that aggregates the login process: > > Given /^I am logged in as "(.*)"/ do |role| > #create a user whose name and role are based on the role > #log in that user > end > > This lets me say: > > Given I am logged in as "admin" > When I visit the super-secret page > Then I see it and learn about all its mystery > > HTH, > David > _______________________________________________ > 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 Mon Jan 12 13:47:07 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 12 Jan 2009 19:47:07 +0100 Subject: [rspec-users] Persisting Logins and Sessions across scenarios In-Reply-To: <8d961d900901121010k7805ce6fg602a111280477407@mail.gmail.com> References: <57c63afe0901120921j71a49306i2d7af4509357589e@mail.gmail.com> <8d961d900901121010k7805ce6fg602a111280477407@mail.gmail.com> Message-ID: Aslak Helles?y wrote: > On Mon, Jan 12, 2009 at 6:21 PM, David Chelimsky > wrote: > >> > Then they should see the "entities" page >> > Then I should save the entity information successfully >> > response.body.should =~ /Add a New Entity/m >> > And coupling scenarios (or any kind of automated test - regardless of > framework) is a very bad idea. > > Aslak I do not have a problem with putting : Given I am logged in as "myuser" At the start of every scenario, but is there no way of performing the actual log in once, place the session info into an instance variable and then use that rather than actually starting up a new session each and every time? -- Posted via http://www.ruby-forum.com/. From sfeley at gmail.com Mon Jan 12 14:29:55 2009 From: sfeley at gmail.com (Stephen Eley) Date: Mon, 12 Jan 2009 14:29:55 -0500 Subject: [rspec-users] Persisting Logins and Sessions across scenarios In-Reply-To: References: <57c63afe0901120921j71a49306i2d7af4509357589e@mail.gmail.com> <8d961d900901121010k7805ce6fg602a111280477407@mail.gmail.com> Message-ID: <1fb4df0901121129p5e634d05v48e290781abdec6a@mail.gmail.com> On Mon, Jan 12, 2009 at 1:47 PM, James Byrne wrote: > > At the start of every scenario, but is there no way of performing the > actual log in once, place the session info into an instance variable and > then use that rather than actually starting up a new session each and > every time? Sure. You could mock out your session or deserialize a saved session object in a Cucumber Before block on every feature except the one that tests login. Or put the "Given" call that does the real session initiation inside a Before so you don't have to look at it every time. If you want it to happen _everywhere_, you can also have a Before in the env.rb file. You can't chain the results from one scenario to another, however, because the order scenarios run in (or whether they run at all) is not guaranteed. So you'd have to put it in your setup code. On acceptance testing, I'd favor going through the actual session creation logic instead of mocking it, even if you don't put an explicit "Given" every time. Yeah, it's slower. But acceptance tests aren't _supposed_ to be fast; they're supposed to demonstrate real usage, and be the last line of defense between your app and the big bad world. They're going to be slow with or without login each time. And if there is some unseen routing or filtering bug in some controller's session access that doesn't show up in your test because you skipped past all that, and you lose a day and some hair trying to figure it out, you're going to wonder whether the seconds you saved were worth it. -- 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 Jan 12 14:49:23 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 12 Jan 2009 20:49:23 +0100 Subject: [rspec-users] Persisting Logins and Sessions across scenarios In-Reply-To: <1fb4df0901121129p5e634d05v48e290781abdec6a@mail.gmail.com> References: <57c63afe0901120921j71a49306i2d7af4509357589e@mail.gmail.com> <8d961d900901121010k7805ce6fg602a111280477407@mail.gmail.com> <1fb4df0901121129p5e634d05v48e290781abdec6a@mail.gmail.com> Message-ID: <72115b99c30008ef9d8237d9fbd48db9@ruby-forum.com> Stephen Eley wrote: > > On acceptance testing, I'd favor going through the actual session > creation logic instead of mocking it, even if you don't put an > explicit "Given" every time. Yeah, it's slower. But acceptance tests > aren't _supposed_ to be fast; they're supposed to demonstrate real > usage, and be the last line of defense between your app and the big > bad world. They're going to be slow with or without login each time. > And if there is some unseen routing or filtering bug in some > controller's session access that doesn't show up in your test because > you skipped past all that, and you lose a day and some hair trying to > figure it out, you're going to wonder whether the seconds you saved > were worth it. Ok, Ok, Ok... It is no big deal to login in every time. If that is the way it should be done in general then I have learned enough these past weeks that I will go with the flow and save myself some headaches. Thanks for the pointers and the explanations. I feel much more comfortable about doing the login in each scenario now that I understand the reasons. -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Mon Jan 12 15:05:28 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 12 Jan 2009 20:05:28 +0000 Subject: [rspec-users] NullDb makes rake spec take (much) longer In-Reply-To: <496B7F90.3040007@benmabey.com> References: <3CF2B3E2-176F-4F69-B613-580D4ADBD277@mattwynne.net> <496B7F90.3040007@benmabey.com> Message-ID: <616BACD6-0EB0-4A92-8937-8D9C34B6E743@mattwynne.net> On 12 Jan 2009, at 17:36, Ben Mabey wrote: > On 1/12/09 7:09 AM, Matt Wynne wrote: >> Hi all, >> >> We did a spike last week to de-couple our view and controller tests >> from the database, using NullDb. It didn't go too well. I realise >> that this plugin isn't part of RSpec, but I thought others on this >> list might have experiences to share. >> >> Here's a summary of my colleague's investigations: >> >>> I installed the plugin from http://github.com/jakehow/nulldb/tree/master >>> >>> Changed spec/spec_helper to set >>> "ActiveRecord::Base.establish_connection(:adapter => :nulldb)" by >>> default. >>> >>> The specs that complained of the lack of db, I included a >>> before(all) >>> that changed the connection to the test database (include >>> NeedsDatabase - copied from Ben Mabey's Functional module) >>> By default, I also included the db for all models (config.include >>> NeedsDatabase, :type => :model) >>> >>> Running spec spec/views with or without nulldb takes about the same >>> time (a couple of seconds less with nulldb). However, running "rake >>> spec" with nulldb takes 10 times longer!! >>> >>> Another weird thing was that three tests failed in the controllers >>> (venues and concerts) in a very strange way, even when I included >>> the >>> NeedsDatabase in the tests that needed it. The weird bit is, when I >>> run: "spec spec/controllers/venues_controller_spec.rb" it doesn't >>> fail. But when I run: "spec spec/controllers/ >>> users_controller_spec.rb >>> spec/controllers/venues_controller_spec.rb" It does fail... That is, >>> the user_controller test is influencing the results of the >>> venue_controller test! >>> The same weird behaviour happens in lib/sk/find >>> >>> This made me had to include NeedsDatabase for all lib and >>> controllers >>> tests as well. >> >> The barrier for us was the shockingly poor performance of 'rake >> spec' on the view specs - it really means we just can't use it, and >> actually only barely improved the performance of the specs at all. >> >> I was disappointed that the view specs didn't get any faster. My >> guess is that stub_model is the problem - as it has to do quite a >> bit of work to set up the attributes on the models. >> >> So, can anyone tell us what we might have been doing wrong? Or did >> I just have unrealistic expectations of how this might help? >> >> Matt Wynne >> http://blog.mattwynne.net >> http://www.songkick.com >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > Hey Matt, > I had similar experiences when I started using NullDB. I think that > the reason why the overall spec suite runs slow is AR is switching > from one adapter to another, and in the case of the mysql one it > probably is relatively expensive to set up a new connection. > Switching over to using NullDB on an existing project of any sizable > size is going to be large task IMO. On my last project we started > using NullDB by default and the result has been very worthwhile and > noticeable. In this project DB connectivity was the exception, not > the norm (even on our model specs) and so that is why I created a > module that would turn on the DB temporarily. In your case the > opposite approach may be needed. > > Going back to the problem at hand... Based on the email you are > using a module like this: > unless Object.const_defined?(:NeedsDatabase) > share_as :NeedsDatabase do > > before :all do > ActiveRecord::Base.establish_connection(:test) > end > > after :all do > ActiveRecord::Base.establish_connection(:adapter => :nulldb) > end > end > end > > Since you are including this on all of your model specs (and more) > you are incurring the setup and teardown cost of the DB connection > repeatedly. Like I said, you may want to adopt the opposite policy > of turning it off temporarily... You could also make the the > changing smarter by only changing it when you need to.. something > like: > > share_as :NeedsDatabase do > before :all do > ActiveRecord::Base.establish_connection(:test) if > ActiveRecord::Base.connection.class.to_s =~ /NullDB/ > end > end > share_as :DontNeedDatabase do > before :all do > ActiveRecord::Base.establish_connection(:adapter => :nulldb) > unless ActiveRecord::Base.connection.class.to_s =~ /NullDB/ > end > end > > With this approach you would need to specify whether or not to use > the DB for each example group... just a thought. Of course, an even > better solution would be to somehow modify AR to maintain an active > connection to the real DB even when it isn't the active adapter. > > re: the view specs > I wouldn't expect to see too much gain here. The big win for > nullDB is in models IMO. Of course, having it on the view and > controller specs helps prevent accidental DB calls. > > re: the random controller spec failures > I only guess is that you are somehow relying on the DB in your > controller specs. I did this too in my controllers when I called > class methods on models that would get a list from the DB... I can't > really help without seeing any specs though. > > I hope this helps and you can find a suitable policy on how to > manage the connections/adapters. Just ask if you have any other > questions. > > -Ben Thanks Ben. I had a brief look at the AR code and it did appear to be caching the adapters so I'd assumed the changeover wasn't expensive, but it did feel like something like that, so that's probably it. Ho hum. No quick wins for speeding up our specs then! Matt Wynne http://blog.mattwynne.net http://www.songkick.com From ben at benmabey.com Mon Jan 12 16:07:19 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 12 Jan 2009 14:07:19 -0700 Subject: [rspec-users] NullDb makes rake spec take (much) longer In-Reply-To: <616BACD6-0EB0-4A92-8937-8D9C34B6E743@mattwynne.net> References: <3CF2B3E2-176F-4F69-B613-580D4ADBD277@mattwynne.net> <496B7F90.3040007@benmabey.com> <616BACD6-0EB0-4A92-8937-8D9C34B6E743@mattwynne.net> Message-ID: <496BB107.2000604@benmabey.com> On 1/12/09 1:05 PM, Matt Wynne wrote: > > On 12 Jan 2009, at 17:36, Ben Mabey wrote: > >> On 1/12/09 7:09 AM, Matt Wynne wrote: >>> Hi all, >>> >>> We did a spike last week to de-couple our view and controller tests >>> from the database, using NullDb. It didn't go too well. I realise >>> that this plugin isn't part of RSpec, but I thought others on this >>> list might have experiences to share. >>> >>> Here's a summary of my colleague's investigations: >>> >>>> I installed the plugin from >>>> http://github.com/jakehow/nulldb/tree/master >>>> >>>> Changed spec/spec_helper to set >>>> "ActiveRecord::Base.establish_connection(:adapter => :nulldb)" by >>>> default. >>>> >>>> The specs that complained of the lack of db, I included a before(all) >>>> that changed the connection to the test database (include >>>> NeedsDatabase - copied from Ben Mabey's Functional module) >>>> By default, I also included the db for all models (config.include >>>> NeedsDatabase, :type => :model) >>>> >>>> Running spec spec/views with or without nulldb takes about the same >>>> time (a couple of seconds less with nulldb). However, running "rake >>>> spec" with nulldb takes 10 times longer!! >>>> >>>> Another weird thing was that three tests failed in the controllers >>>> (venues and concerts) in a very strange way, even when I included the >>>> NeedsDatabase in the tests that needed it. The weird bit is, when I >>>> run: "spec spec/controllers/venues_controller_spec.rb" it doesn't >>>> fail. But when I run: "spec spec/controllers/users_controller_spec.rb >>>> spec/controllers/venues_controller_spec.rb" It does fail... That is, >>>> the user_controller test is influencing the results of the >>>> venue_controller test! >>>> The same weird behaviour happens in lib/sk/find >>>> >>>> This made me had to include NeedsDatabase for all lib and controllers >>>> tests as well. >>> >>> The barrier for us was the shockingly poor performance of 'rake >>> spec' on the view specs - it really means we just can't use it, and >>> actually only barely improved the performance of the specs at all. >>> >>> I was disappointed that the view specs didn't get any faster. My >>> guess is that stub_model is the problem - as it has to do quite a >>> bit of work to set up the attributes on the models. >>> >>> So, can anyone tell us what we might have been doing wrong? Or did I >>> just have unrealistic expectations of how this might help? >>> >>> Matt Wynne >>> http://blog.mattwynne.net >>> http://www.songkick.com >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> Hey Matt, >> I had similar experiences when I started using NullDB. I think that >> the reason why the overall spec suite runs slow is AR is switching >> from one adapter to another, and in the case of the mysql one it >> probably is relatively expensive to set up a new connection. >> Switching over to using NullDB on an existing project of any sizable >> size is going to be large task IMO. On my last project we started >> using NullDB by default and the result has been very worthwhile and >> noticeable. In this project DB connectivity was the exception, not >> the norm (even on our model specs) and so that is why I created a >> module that would turn on the DB temporarily. In your case the >> opposite approach may be needed. >> >> Going back to the problem at hand... Based on the email you are using >> a module like this: >> unless Object.const_defined?(:NeedsDatabase) >> share_as :NeedsDatabase do >> >> before :all do >> ActiveRecord::Base.establish_connection(:test) >> end >> >> after :all do >> ActiveRecord::Base.establish_connection(:adapter => :nulldb) >> end >> end >> end >> >> Since you are including this on all of your model specs (and more) >> you are incurring the setup and teardown cost of the DB connection >> repeatedly. Like I said, you may want to adopt the opposite policy >> of turning it off temporarily... You could also make the the changing >> smarter by only changing it when you need to.. something like: >> >> share_as :NeedsDatabase do >> before :all do >> ActiveRecord::Base.establish_connection(:test) if >> ActiveRecord::Base.connection.class.to_s =~ /NullDB/ >> end >> end >> share_as :DontNeedDatabase do >> before :all do >> ActiveRecord::Base.establish_connection(:adapter => :nulldb) >> unless ActiveRecord::Base.connection.class.to_s =~ /NullDB/ >> end >> end >> >> With this approach you would need to specify whether or not to use >> the DB for each example group... just a thought. Of course, an even >> better solution would be to somehow modify AR to maintain an active >> connection to the real DB even when it isn't the active adapter. >> >> re: the view specs >> I wouldn't expect to see too much gain here. The big win for nullDB >> is in models IMO. Of course, having it on the view and controller >> specs helps prevent accidental DB calls. >> >> re: the random controller spec failures >> I only guess is that you are somehow relying on the DB in your >> controller specs. I did this too in my controllers when I called >> class methods on models that would get a list from the DB... I can't >> really help without seeing any specs though. >> >> I hope this helps and you can find a suitable policy on how to manage >> the connections/adapters. Just ask if you have any other questions. >> >> -Ben > > Thanks Ben. I had a brief look at the AR code and it did appear to be > caching the adapters so I'd assumed the changeover wasn't expensive, > but it did feel like something like that, so that's probably it. Oh really? Hmm.. well, I never did any real testing to verify my assumption about the the changeover. I just noticed that suites that had to switch adapters a lot ran very slowly. > > Ho hum. No quick wins for speeding up our specs then! Unfortunately not. :( > > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Mon Jan 12 16:50:49 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 12 Jan 2009 22:50:49 +0100 Subject: [rspec-users] Help with regexp in matcher Message-ID: This is giving me an error: When /?:(log|sign)?:(i|o)n success message/ do Then "welcome message" end To the effect that: /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': ./features/components/login/step_definitions/login_steps.rb:21: invalid regular expression; there's no previous pattern, to which '?' would define cardinality at 1: /?:(am|is) not ?:(logg|sign)ed ?:(i|o)n/ (SyntaxError) ./features/components/login/step_definitions/login_steps.rb:25: invalid regular expression; there's no previous pattern, to which '?' would define cardinality at 1: /?:(log|sign) ??:(i|o)n request message/ ./features/components/login/step_definitions/login_steps.rb:41: invalid regular expression; there's no previous pattern, to which '?' would define cardinality at 1: /?:(log|sign)?:(i|o)n success message/ from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' I would appreciate it very much if someone could tell me what i am doing wrong here. -- Posted via http://www.ruby-forum.com/. From tim at pivotib.com Mon Jan 12 17:35:51 2009 From: tim at pivotib.com (Tim Glen) Date: Mon, 12 Jan 2009 17:35:51 -0500 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: References: Message-ID: > > This is giving me an error: > > When /?:(log|sign)?:(i|o)n success message/ do > Then "welcome message" > end I could be wrong, but I believe you're looking for this instead? When /(?:log|sign)(?:i|o)n success message/ do hope that helps, timg From ben at benmabey.com Mon Jan 12 18:00:16 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 12 Jan 2009 16:00:16 -0700 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: References: Message-ID: <496BCB80.1030008@benmabey.com> On 1/12/09 2:50 PM, James Byrne wrote: > This is giving me an error: > > When /?:(log|sign)?:(i|o)n success message/ do > Then "welcome message" > end > The ?: needs to be inside your group if you don't want to capture it... so: When /(?:log|sign)(?:i|o)n success message/ do FWIW, I have found http://www.rubular.com an excellent resource when creating my steps. -Ben > To the effect that: > > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require': > ./features/components/login/step_definitions/login_steps.rb:21: invalid > regular expression; there's no previous pattern, to which '?' would > define cardinality at 1: /?:(am|is) not ?:(logg|sign)ed ?:(i|o)n/ > (SyntaxError) > ./features/components/login/step_definitions/login_steps.rb:25: invalid > regular expression; there's no previous pattern, to which '?' would > define cardinality at 1: /?:(log|sign) ??:(i|o)n request message/ > ./features/components/login/step_definitions/login_steps.rb:41: invalid > regular expression; there's no previous pattern, to which '?' would > define cardinality at 1: /?:(log|sign)?:(i|o)n success message/ from > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' > > > I would appreciate it very much if someone could tell me what i am doing > wrong here. > From sfeley at gmail.com Mon Jan 12 18:00:33 2009 From: sfeley at gmail.com (Stephen Eley) Date: Mon, 12 Jan 2009 18:00:33 -0500 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: References: Message-ID: <1fb4df0901121500y60862f22h3b31a71352c53329@mail.gmail.com> On Mon, Jan 12, 2009 at 4:50 PM, James Byrne wrote: > > When /?:(log|sign)?:(i|o)n success message/ do > Then "welcome message" > end It's a syntax error on that first question mark, the one right after the slash. A ? in a regex signifies that whatever came just before it may appear 0 or 1 times. Just like a + signifies that whatever came before it _must_ appear 1 or more times, and a * signifies that whatever came before it can appear any number of times. There are a few other things a ? can mean (non-greedy matching, etc.) but they all come *after* something. Not at the beginning of your expression. That's the bug. Beyond that, what you're trying to do with the regex itself seems just a little too clever; do your features or your app messages really vary randomly between the terms "login," "logon," "signin" and "signon," all meaning the same thing? If so, jumping hoops to account for it in the tests might be a hint to change your app language just for clarity. But if you have to have them all, just writing /(login|logon|signin|signon) success message/ would be a lot easier to read and understand. (Final nit, because I'm a smellfungus: what is this step supposed to do, anyway? Do you really have scenarios that include the line "When login success message?" 'When' steps imply action taken by the imaginary user. What's the action here? What's the verb?) -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From aslak.hellesoy at gmail.com Mon Jan 12 18:13:22 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 13 Jan 2009 00:13:22 +0100 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: References: Message-ID: <8d961d900901121513j53c9fde6y543b67da15461551@mail.gmail.com> On Mon, Jan 12, 2009 at 11:35 PM, Tim Glen wrote: > >> This is giving me an error: >> >> When /?:(log|sign)?:(i|o)n success message/ do >> Then "welcome message" >> end >> > > > I could be wrong, but I believe you're looking for this instead? > When /(?:log|sign)(?:i|o)n success message/ do > Actually - it should be: /(?:log|sign) (?:i|o)n success message/ (a space was missing too) http://www.rubular.com Aslak > hope that helps, > timg > > _______________________________________________ > 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 avdi at avdi.org Mon Jan 12 18:20:16 2009 From: avdi at avdi.org (Avdi Grimm) Date: Mon, 12 Jan 2009 18:20:16 -0500 Subject: [rspec-users] Who is using NullDB? Message-ID: I gather from some recent posts that some people are actually using NullDB in their projects. As the creator of NullDB, I'm pleased and a little surprised to hear this. Since NullDB is has received exactly zero attention from me since it's initial release, I'm curious how it's working out for people. Do you use NullDB? If so, do you use my baseline version (http://svn.avdi.org/nulldb/trunk), or are you using a fork? If a fork, which fork, and why? Are there any bugs or feature requests you'd like to see addressed? Thanks, -- Avdi Home: http://avdi.org Developer Blog: http://avdi.org/devblog/ Twitter: http://twitter.com/avdi Journal: http://avdi.livejournal.com From ben at benmabey.com Mon Jan 12 19:22:29 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 12 Jan 2009 17:22:29 -0700 Subject: [rspec-users] Who is using NullDB? In-Reply-To: References: Message-ID: <496BDEC5.6010700@benmabey.com> On 1/12/09 4:20 PM, Avdi Grimm wrote: > I gather from some recent posts that some people are actually using > NullDB in their projects. As the creator of NullDB, I'm pleased and a > little surprised to hear this. > > Since NullDB is has received exactly zero attention from me since > it's initial release, I'm curious how it's working out for people. > > Do you use NullDB? > > If so, do you use my baseline version > (http://svn.avdi.org/nulldb/trunk), or are you using a fork? > > If a fork, which fork, and why? > > Are there any bugs or feature requests you'd like to see addressed? > > Thanks, > > Hey Avdi, I love nullDB, so thank you very much for making it! After looking into the various libs that disconnect AR from the DB I decided on nullDB due to it's design decisions. I have been using your SVN version I believe. Although, I may of grabbed it off of github a couple of times since that is easier for me. So my first request would be for you to add it to github so your fork can be the official one. :) GitHub has an import from SVN feature which is really nice and makes it painless to convert a SVN repo. If you do that I would be much more likely to fork it and submit patches. There is one bug I have found that is quite annoying but I haven't looked into fixing it yet. If I remember correctly the bug is something like this: class Band < AR::Base has_many :members end #with nulldb: band = Band.create!(:name => "Foo") bar = Member.create!(:name => "Mr. Bar") band.members << bar band.members # => [] I understand the limitations of nullDB so I don't expect the above call to update the member's band_id. I do however, expect the newly added member to appear in the AR association. What I have found is that for some reason the above will not work when that is the first time the association is being used, but it will otherwise. For example, this workaround works: band = Band.create!(:name => "Foo") bar = Member.create!(:name => "Mr. Bar") band.members.inspect # workaround for odd nullDB bug band.members << bar band.members # => [bar] Does that make sense? Other than that bug, and the problem with the adapter changing slowing things down nullDB has been great. We are getting a lot of benefit from it on our current project. So once again, thanks! -Ben From pergesu at gmail.com Mon Jan 12 19:48:26 2009 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 12 Jan 2009 16:48:26 -0800 Subject: [rspec-users] Persisting Logins and Sessions across scenarios In-Reply-To: <72115b99c30008ef9d8237d9fbd48db9@ruby-forum.com> References: <57c63afe0901120921j71a49306i2d7af4509357589e@mail.gmail.com> <8d961d900901121010k7805ce6fg602a111280477407@mail.gmail.com> <1fb4df0901121129p5e634d05v48e290781abdec6a@mail.gmail.com> <72115b99c30008ef9d8237d9fbd48db9@ruby-forum.com> Message-ID: <810a540e0901121648k5e612b8ar7b56f20a0caeb0c5@mail.gmail.com> On Mon, Jan 12, 2009 at 11:49 AM, James Byrne wrote: > Stephen Eley wrote: > >> >> On acceptance testing, I'd favor going through the actual session >> creation logic instead of mocking it, even if you don't put an >> explicit "Given" every time. Yeah, it's slower. But acceptance tests >> aren't _supposed_ to be fast; they're supposed to demonstrate real >> usage, and be the last line of defense between your app and the big >> bad world. They're going to be slow with or without login each time. >> And if there is some unseen routing or filtering bug in some >> controller's session access that doesn't show up in your test because >> you skipped past all that, and you lose a day and some hair trying to >> figure it out, you're going to wonder whether the seconds you saved >> were worth it. > > Ok, Ok, Ok... It is no big deal to login in every time. If that is the > way it should be done in general then I have learned enough these past > weeks that I will go with the flow and save myself some headaches. > > Thanks for the pointers and the explanations. I feel much more > comfortable about doing the login in each scenario now that I understand > the reasons. Well you can inject it right into the session instead of doing the full webrat thing. That'll definitely cut down on the time it takes. btw, I know it seems like you want this stuff to persist between scenarios, but you really don't. You want to ensure that the world is in a known state before the test run, so that your tests are repeatable and reliable. Getting it into a known state requires two steps, basically (1) get to a base state that works for EVERY SINGLE TEST. This basically means an empty database, potentially populated with some seed data (like if you store references to zip codes in the db) (2) at the beginning of each test, modify the state to suit that test. You should be changing only the state that you need to write an expressive test, and no more If you need to reuse logic, take advantage of one of the existing reuse patterns. In cucumber's case, that means extracting code to a step and calling that in the scenarios. With RSpec, you've got a bit more stuff like nested groups with a before block (which imo is NOT a good idea for cucumber, nesting scenarios would be insane). What you're asking about is implicit coupling, and that's not an effective reuse pattern :) Pat From pergesu at gmail.com Mon Jan 12 19:52:33 2009 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 12 Jan 2009 16:52:33 -0800 Subject: [rspec-users] Who is using NullDB? In-Reply-To: References: Message-ID: <810a540e0901121652o3dec150doc1cea9650a024332@mail.gmail.com> On Mon, Jan 12, 2009 at 3:20 PM, Avdi Grimm wrote: > I gather from some recent posts that some people are actually using > NullDB in their projects. As the creator of NullDB, I'm pleased and a > little surprised to hear this. > > Since NullDB is has received exactly zero attention from me since > it's initial release, I'm curious how it's working out for people. > > Do you use NullDB? > > If so, do you use my baseline version > (http://svn.avdi.org/nulldb/trunk), or are you using a fork? > > If a fork, which fork, and why? > > Are there any bugs or feature requests you'd like to see addressed? Out of curiosity, how much faster is nulldb than using sqlite in-memory? Pat From lists at ruby-forum.com Tue Jan 13 10:41:47 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 13 Jan 2009 16:41:47 +0100 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: <8d961d900901121513j53c9fde6y543b67da15461551@mail.gmail.com> References: <8d961d900901121513j53c9fde6y543b67da15461551@mail.gmail.com> Message-ID: Thanks for all the advise and corrections. I ended up with this: When /\bsee a (?:log|sign)(?: ?)[io]n success message/ do # login | log in | logon | log on | signin ... Then "see the login ok message" end As to the issue of whether this is being too clever by half: Perhaps. I have to consider though, that various people are going to be working on features relating to this project under a wide range of circumstances and that features will develop over a long period of time. While it might appear attractive to simply insist that a session is always a login the fact is that language is not so precise; login, logon, log in, log on, signin, signon, sign in and sign on are all common synonyms for the same action. Internally, the action is just login. Logins are a pervasive feature of this application and so, rather than waste effort on policing the feature syntax, I thought it best just to accommodate the likely variations from the start. Admittedly, I also availed myself of this opportunity to gain additional knowledge regarding regexp and so this example is perhaps overwrought for the actual purpose at hand. Finally, thank you Ben very much for the reference to http://www.rubular.com -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Jan 13 11:58:57 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Tue, 13 Jan 2009 17:58:57 +0100 Subject: [rspec-users] Cucumber newbie gets Webrat::Se ssion (LoadError) Message-ID: <8e9d69e10a4689bf4f4145ef2eeeeb41@ruby-forum.com> Just trying to get cucumber/webrat going and so after following the installation process here http://wiki.github.com/aslakhellesoy/cucumber/ruby-on-rails i wrote a quick feature and when I rake features, I get the following in the console: c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/acti ve_support/dependencies.rb:262:in `load_missing_constant': Expected c:/projects/ classroomparent/vendor/plugins/webrat/lib/webrat/session.rb to define Webrat::Se ssion (LoadError) Failed to load features/support/env.rb from c:/InstantRails-2.0-win/ruby/lib/ru by/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:468:in ` const_missing' from c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/aslakhellesoy-w ebrat-0.3.2.2/lib/webrat/rails.rb:7 I have the following related gems installed: aslakhellesoy-webrat (0.3.2.2) cucumber (0.1.14) webrat (0.3.4) Any advice you can give would be greatly appreciated. Tom -- Posted via http://www.ruby-forum.com/. From mark at mwilden.com Tue Jan 13 12:14:48 2009 From: mark at mwilden.com (Mark Wilden) Date: Tue, 13 Jan 2009 09:14:48 -0800 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: References: <8d961d900901121513j53c9fde6y543b67da15461551@mail.gmail.com> Message-ID: <3c30da400901130914j2cad5037v4ba20a4ce63c45e@mail.gmail.com> On Tue, Jan 13, 2009 at 7:41 AM, James Byrne wrote: > > Logins are a pervasive feature of this application and so, rather than > waste effort on policing the feature syntax, I thought it best just to > accommodate the likely variations from the start. Premature flexibility is one of the roots of all evil. :) Seriously, your code has two types of users. Yes, you should make writing features easier for biz, but you should also make reading steps easier for dev. Given that, I like the suggestion of explicitly enumerating the choices of verbiage. A clear pointer toward that choice is the comment. A comment is an apology for unclear code. All unclear code should be commented, but unclear code should be avoided whenever possible. All IMO, of course. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Tue Jan 13 12:22:36 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 13 Jan 2009 18:22:36 +0100 Subject: [rspec-users] Cucumber newbie gets Webrat::Se ssion (LoadError) In-Reply-To: <8e9d69e10a4689bf4f4145ef2eeeeb41@ruby-forum.com> References: <8e9d69e10a4689bf4f4145ef2eeeeb41@ruby-forum.com> Message-ID: <11c89e4023b965fe962259bcf89fd64e@ruby-forum.com> Tom Hoen wrote: > > Any advice you can give would be greatly appreciated. > > Tom What are the contents of features/support/env.rb? Do you have something like this in there? # If webrat is a gem then uncomment this require 'webrat' if !defined?(Webrat) # If webrat is a plugin then uncomment this #require 'webrat/rails' -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Jan 13 12:36:46 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Tue, 13 Jan 2009 18:36:46 +0100 Subject: [rspec-users] Cucumber newbie gets Webrat::Se ssion (LoadError) In-Reply-To: <11c89e4023b965fe962259bcf89fd64e@ruby-forum.com> References: <8e9d69e10a4689bf4f4145ef2eeeeb41@ruby-forum.com> <11c89e4023b965fe962259bcf89fd64e@ruby-forum.com> Message-ID: James Byrne wrote: > > What are the contents of features/support/env.rb? Do you have something > like this in there? > > # If webrat is a gem then uncomment this > require 'webrat' if !defined?(Webrat) > > # If webrat is a plugin then uncomment this > #require 'webrat/rails' Though there isn't the comment, I do have the line: require 'webrat/rails' I changed it to the other require statement and now I get 0 scenarios. So I am getting closer. Thanks for your help. Tom -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Tue Jan 13 12:55:07 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 13 Jan 2009 17:55:07 +0000 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: <3c30da400901130914j2cad5037v4ba20a4ce63c45e@mail.gmail.com> References: <8d961d900901121513j53c9fde6y543b67da15461551@mail.gmail.com> <3c30da400901130914j2cad5037v4ba20a4ce63c45e@mail.gmail.com> Message-ID: <334671B0-6515-40A1-BF05-50216FCFFC80@mattwynne.net> On 13 Jan 2009, at 17:14, Mark Wilden wrote: > On Tue, Jan 13, 2009 at 7:41 AM, James Byrne > wrote: > > Logins are a pervasive feature of this application and so, rather than > waste effort on policing the feature syntax, I thought it best just to > accommodate the likely variations from the start. > > Premature flexibility is one of the roots of all evil. :) > > Seriously, your code has two types of users. Yes, you should make > writing features easier for biz, but you should also make reading > steps easier for dev. Given that, I like the suggestion of > explicitly enumerating the choices of verbiage. A clear pointer > toward that choice is the comment. A comment is an apology for > unclear code. All unclear code should be commented, but unclear code > should be avoided whenever possible. > > All IMO, of course. +1 to all that. I feel like you get lectured quite a bit by this list James, but you'd do well to heed the advice of some battle-hardened journeymen, IMO. Read Eric Evans' excellent book 'Domain Driven Design', which actually inspired a lot of this BDD stuff you're using, to hear how keeping faithful to a 'Ubiquitous Language' can make a big difference to the success or failure of a project. You're not just policing syntax when you encourage people to use the same words for things, you're actually protecting the integrity of your system by reducing the opportunities for misunderstanding. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From aslak.hellesoy at gmail.com Tue Jan 13 12:57:03 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 13 Jan 2009 18:57:03 +0100 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: <3c30da400901130914j2cad5037v4ba20a4ce63c45e@mail.gmail.com> References: <8d961d900901121513j53c9fde6y543b67da15461551@mail.gmail.com> <3c30da400901130914j2cad5037v4ba20a4ce63c45e@mail.gmail.com> Message-ID: <8d961d900901130957t507d260dm4821ebd09565dd12@mail.gmail.com> On Tue, Jan 13, 2009 at 6:14 PM, Mark Wilden wrote: > On Tue, Jan 13, 2009 at 7:41 AM, James Byrne wrote: > >> >> Logins are a pervasive feature of this application and so, rather than >> waste effort on policing the feature syntax, I thought it best just to >> accommodate the likely variations from the start. > > > Premature flexibility is one of the roots of all evil. :) > > Seriously, your code has two types of users. Yes, you should make writing > features easier for biz, but you should also make reading steps easier for > dev. Given that, I like the suggestion of explicitly enumerating the choices > of verbiage. A clear pointer toward that choice is the comment. A comment is > an apology for unclear code. All unclear code should be commented, but > unclear code should be avoided whenever possible. > Another principle that calls for a more rigid Regex: http://domaindrivendesign.org/discussion/messageboardarchive/UbiquitousLanguage.html. Everybody should speak the same language and know what it means. Having 4 different ways of saying the same thing will just add to confusion. Aslak > > All IMO, of course. > > ///ark > > > > _______________________________________________ > 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 aidy.lewis at googlemail.com Tue Jan 13 13:02:45 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Tue, 13 Jan 2009 18:02:45 +0000 Subject: [rspec-users] [Cucumber] - default rake task Message-ID: <7ac2300c0901131002r48a77635nf5daababc7e77415@mail.gmail.com> Hi, I have a Rake problem. I would like the default task to run after :features. Curently it doesn't when :features fails. Could you please help? require 'cucumber/rake/task' def send_dcs_email_report(path_to_story_results) ### end Cucumber::Rake::Task.new("features", "All features in IE") do |t| t.cucumber_opts = "--format html --out story-results.html" end task :default => :features do path_to_story_results = File.expand_path(File.dirname(".")).gsub("/", "\\") + "\\story-results.html" send_dcs_email_report(path_to_story_results) end Thanks Aidy From matt at mattwynne.net Tue Jan 13 13:09:37 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 13 Jan 2009 18:09:37 +0000 Subject: [rspec-users] [Cucumber] - default rake task In-Reply-To: <7ac2300c0901131002r48a77635nf5daababc7e77415@mail.gmail.com> References: <7ac2300c0901131002r48a77635nf5daababc7e77415@mail.gmail.com> Message-ID: <4AFD416C-6ED7-4A24-9272-9915D5FE7A11@mattwynne.net> On 13 Jan 2009, at 18:02, aidy lewis wrote: > Hi, > > I have a Rake problem. > > I would like the default task to run after :features. > > Curently it doesn't when :features fails. Could you please help? > > > > require 'cucumber/rake/task' > > def send_dcs_email_report(path_to_story_results) > ### > end > > Cucumber::Rake::Task.new("features", "All features in IE") do |t| > t.cucumber_opts = "--format html --out story-results.html" > end > > task :default => :features do > path_to_story_results = > File.expand_path(File.dirname(".")).gsub("/", "\\") + > "\\story-results.html" > send_dcs_email_report(path_to_story_results) > end > > > Thanks > > Aidy You could do something like this: task :default do begin Rake::Task[:features].invoke ensure path_to_story_results = File.expand_path(File.dirname(".")).gsub("/", "\\") + "\\story- results.html" send_dcs_email_report(path_to_story_results) end end does that work? > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Matt Wynne http://blog.mattwynne.net http://www.songkick.com From sfeley at gmail.com Tue Jan 13 13:18:13 2009 From: sfeley at gmail.com (Stephen Eley) Date: Tue, 13 Jan 2009 13:18:13 -0500 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: References: <8d961d900901121513j53c9fde6y543b67da15461551@mail.gmail.com> Message-ID: <1fb4df0901131018y75c8e0b0gd14022ce0c35f295@mail.gmail.com> On Tue, Jan 13, 2009 at 10:41 AM, James Byrne wrote: > > Logins are a pervasive feature of this application Which is exactly why you should standardize. If you try to be accommodating toward unclear communication, you're just going to create confusion when people need to get things done. Someone won't remember whether the action is named "login" or "signin" or "sign_on" and will waste time looking for the wrong thing -- or worse, write the same function over again under a different name. That's not the fault of the feature, but it doesn't _help._ This step doesn't do as much as it could to accurately document your application. > and so, rather than > waste effort on policing the feature syntax, I thought it best just to > accommodate the likely variations from the start. Well, first, if that was _really_ your goal you're not going nearly far enough. If a teammate isn't going to take the trouble to review existing steps, he's probably more likely to screw up the "success message" part than the "login" part. How many variations on the concept of "success message" do you think you can fit in a regex? ("acknowledgement" and "acceptance" both start with "ac," so I guess you could start your conditional branching logic there... Just remember that the number of e's in "acknowledgment" can vary...) Beyond that, though... It's really not a problem. Issues like this tend to be self-correcting. Most developers (well, most competent and properly lazy ones) will read the existing features before writing their own. They'll know that if they saw a clause already that does something they want, they should use it again. And if they misremember and type something else, they'll get a failure and think, "Whathuh? James got his features to work yesterday and HE needs to log in!" And *then* they'll think to look back at the step code, see one called 'When "I see a success message"," and figure out what they really ought to say. In looking it up, they'll come to understand the existing functionality better. And they'd certainly be able to look it up in less time than it takes to figure out all the regexes. (Or me to be a smartass about them. Hmm.) -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From aslak.hellesoy at gmail.com Tue Jan 13 13:28:44 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 13 Jan 2009 19:28:44 +0100 Subject: [rspec-users] [Cucumber] - default rake task In-Reply-To: <7ac2300c0901131002r48a77635nf5daababc7e77415@mail.gmail.com> References: <7ac2300c0901131002r48a77635nf5daababc7e77415@mail.gmail.com> Message-ID: <8d961d900901131028u42526c3t138ac1625bddb69f@mail.gmail.com> On Tue, Jan 13, 2009 at 7:02 PM, aidy lewis wrote: > Hi, > > I have a Rake problem. > > I would like the default task to run after :features. > > Curently it doesn't when :features fails. Could you please help? > > > > require 'cucumber/rake/task' > > def send_dcs_email_report(path_to_story_results) > ### > end > > Cucumber::Rake::Task.new("features", "All features in IE") do |t| > t.cucumber_opts = "--format html --out story-results.html" > end > > task :default => :features do > path_to_story_results = > File.expand_path(File.dirname(".")).gsub("/", "\\") + > "\\story-results.html" > send_dcs_email_report(path_to_story_results) > end > > Rake immediately stops when a task fails. I'm assuming you're using some sort of CI since you're sending emails. I'd make the CI send email instead of Rake. Aslak > Thanks > > Aidy > _______________________________________________ > 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 aidy.lewis at googlemail.com Tue Jan 13 13:43:50 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Tue, 13 Jan 2009 18:43:50 +0000 Subject: [rspec-users] [Cucumber] - default rake task In-Reply-To: <4AFD416C-6ED7-4A24-9272-9915D5FE7A11@mattwynne.net> References: <7ac2300c0901131002r48a77635nf5daababc7e77415@mail.gmail.com> <4AFD416C-6ED7-4A24-9272-9915D5FE7A11@mattwynne.net> Message-ID: <7ac2300c0901131043v49d20fd8idef238d92103766@mail.gmail.com> On 13/01/2009, Matt Wynne wrote: > > On 13 Jan 2009, at 18:02, aidy lewis wrote: > > > > Hi, > > > > I have a Rake problem. > > > > I would like the default task to run after :features. > > > > Curently it doesn't when :features fails. Could you please help? > > > > > > > > require 'cucumber/rake/task' > > > > def send_dcs_email_report(path_to_story_results) > > ### > > end > > > > Cucumber::Rake::Task.new("features", "All features in > IE") do |t| > > t.cucumber_opts = "--format html --out story-results.html" > > end > > > > task :default => :features do > > path_to_story_results = > > File.expand_path(File.dirname(".")).gsub("/", "\\") + > > "\\story-results.html" > > send_dcs_email_report(path_to_story_results) > > end > > > > > > Thanks > > > > Aidy > > > > You could do something like this: > > task :default do > begin > Rake::Task[:features].invoke > ensure > path_to_story_results = > File.expand_path(File.dirname(".")).gsub("/", "\\") + > "\\story-results.html" > send_dcs_email_report(path_to_story_results) > end > end > > does that work? > Like a dream Matt. Thanks Aidy From zach.dennis at gmail.com Tue Jan 13 14:57:33 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Tue, 13 Jan 2009 14:57:33 -0500 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: <334671B0-6515-40A1-BF05-50216FCFFC80@mattwynne.net> References: <8d961d900901121513j53c9fde6y543b67da15461551@mail.gmail.com> <3c30da400901130914j2cad5037v4ba20a4ce63c45e@mail.gmail.com> <334671B0-6515-40A1-BF05-50216FCFFC80@mattwynne.net> Message-ID: <85d99afe0901131157l3972a2dfsdd019dbf8f4caa05@mail.gmail.com> On Tue, Jan 13, 2009 at 12:55 PM, Matt Wynne wrote: > > On 13 Jan 2009, at 17:14, Mark Wilden wrote: > >> On Tue, Jan 13, 2009 at 7:41 AM, James Byrne wrote: >> >> Logins are a pervasive feature of this application and so, rather than >> waste effort on policing the feature syntax, I thought it best just to >> accommodate the likely variations from the start. >> >> Premature flexibility is one of the roots of all evil. :) >> >> Seriously, your code has two types of users. Yes, you should make writing >> features easier for biz, but you should also make reading steps easier for >> dev. Given that, I like the suggestion of explicitly enumerating the choices >> of verbiage. A clear pointer toward that choice is the comment. A comment is >> an apology for unclear code. All unclear code should be commented, but >> unclear code should be avoided whenever possible. >> >> All IMO, of course. > > +1 to all that. I feel like you get lectured quite a bit by this list James, > but you'd do well to heed the advice of some battle-hardened journeymen, > IMO. > > Read Eric Evans' excellent book 'Domain Driven Design', which actually > inspired a lot of this BDD stuff you're using, to hear how keeping faithful > to a 'Ubiquitous Language' can make a big difference to the success or > failure of a project. > > You're not just policing syntax when you encourage people to use the same > words for things, you're actually protecting the integrity of your system by > reducing the opportunities for misunderstanding. This last paragraph was beautifully said Matt. I am going to steal it (and give you credit of course). :) -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From lists at ruby-forum.com Tue Jan 13 15:10:38 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 13 Jan 2009 21:10:38 +0100 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: <1fb4df0901131018y75c8e0b0gd14022ce0c35f295@mail.gmail.com> References: <8d961d900901121513j53c9fde6y543b67da15461551@mail.gmail.com> <1fb4df0901131018y75c8e0b0gd14022ce0c35f295@mail.gmail.com> Message-ID: <52d4f64441439d3a88eabb5f3097a72a@ruby-forum.com> Stephen Eley wrote: > On Tue, Jan 13, 2009 at 10:41 AM, James Byrne > wrote: >> >> Logins are a pervasive feature of this application > > Which is exactly why you should standardize. If you try to be > accommodating toward unclear communication, you're just going to > create confusion when people need to get things done. I appreciate the advice and accept the wisdom that it contains. I have no intention of handling with a regexp every situation where there might be more than one English expression available to express a concept. Nor do I intend to otherwise permit multiplicities of expression to exist. However, on the matter of log in versus log on and its common variations, I think I will stick with my initial instinct. Initially I provided the different variants of login matchers along the lines shown below: When /see a login success message/ do have_selector("#login_current") end When /see a log in success message/ do Then "see a login success message" end When /see a sign on success message/ do ... The revised regexp version simply puts all of these together in one place for me. As for forcing people to remember that it is login and not logon; well this project does not exist in a vacuum. The people involved deal with at least three different operating systems every day, each one of which has its own dialect with respect to what constitutes an authenticated user. I will accept a little flexibility of expression here in the service of user comfort. In any case the term login, in the context of a web application environment, seems a bit of a misnomer from the outset. I cannot get too worked up over the idea of unclear communication when one is dealing with as muddy a concept as that represented by login. Really, what I should be saying is: Given user "myuser" has a current authenticated session And I see the session authenticated message When I terminate my current session Then the current session is destroyed And I should see the user authentication request message However, current authenticated session tends to be a little unwieldy in casual speech. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Jan 13 15:14:59 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 13 Jan 2009 21:14:59 +0100 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: <334671B0-6515-40A1-BF05-50216FCFFC80@mattwynne.net> References: <8d961d900901121513j53c9fde6y543b67da15461551@mail.gmail.com> <3c30da400901130914j2cad5037v4ba20a4ce63c45e@mail.gmail.com> <334671B0-6515-40A1-BF05-50216FCFFC80@mattwynne.net> Message-ID: <28a4671751bfc33aa81ce945dd1cbb6e@ruby-forum.com> Matt Wynne wrote: . > > +1 to all that. I feel like you get lectured quite a bit by this list > James, but you'd do well to heed the advice of some battle-hardened > journeymen, IMO. > > I do hope that I do not give the impression that I resent anything that anyone has written in response to my many inquiries. I have been enlightened on a number of things that I was either unaware of or only dimly perceived. I am transitioning from a completely different environment and need all the help and guidance I can obtain. I value this and the ruby-on-rails list very much for that reason. Regards, -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Jan 13 16:11:32 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 13 Jan 2009 22:11:32 +0100 Subject: [rspec-users] Using has_selector to identify responses. Message-ID: <658ff9594560a0d5fa8526b54b024da5@ruby-forum.com> This is more of a "best practices" question. Earlier, when I was trying to understand what it was I was supposed to be testing with cucumber, I was advised that I should test for text elements contained in the response body of the expected output. Now, what I am wondering is how one accounts for multilingual implementation. I have hit upon the idea of simply adding special css id selectors to the templates that identify their use. So, for example, instead of looking for the word "Registration" I would look for a css selector id=user_registration. I know that this will work but, is there another, preferred, way of handling this situation? Regards, -- Posted via http://www.ruby-forum.com/. From pergesu at gmail.com Tue Jan 13 16:50:10 2009 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 13 Jan 2009 13:50:10 -0800 Subject: [rspec-users] Using has_selector to identify responses. In-Reply-To: <658ff9594560a0d5fa8526b54b024da5@ruby-forum.com> References: <658ff9594560a0d5fa8526b54b024da5@ruby-forum.com> Message-ID: <810a540e0901131350i762e6519o10f11a063aa7684e@mail.gmail.com> On Tue, Jan 13, 2009 at 1:11 PM, James Byrne wrote: > This is more of a "best practices" question. > > Earlier, when I was trying to understand what it was I was supposed to > be testing with cucumber, I was advised that I should test for text > elements contained in the response body of the expected output. Now, > what I am wondering is how one accounts for multilingual implementation. > > I have hit upon the idea of simply adding special css id selectors to > the templates that identify their use. So, for example, instead of > looking for the word "Registration" I would look for a css selector > id=user_registration. > > I know that this will work but, is there another, preferred, way of > handling this situation? > > Regards, > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > semantic markup ftw (so, yes, your way :) From aslak.hellesoy at gmail.com Tue Jan 13 16:58:15 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 13 Jan 2009 22:58:15 +0100 Subject: [rspec-users] Using has_selector to identify responses. In-Reply-To: <658ff9594560a0d5fa8526b54b024da5@ruby-forum.com> References: <658ff9594560a0d5fa8526b54b024da5@ruby-forum.com> Message-ID: <8d961d900901131358r3ac7ef6fya4b79e8f76b37dbf@mail.gmail.com> On Tue, Jan 13, 2009 at 10:11 PM, James Byrne wrote: > This is more of a "best practices" question. > I'll describe a practice that has worked well for me. (I stopped believing in best practices several years ago :-)) > Earlier, when I was trying to understand what it was I was supposed to > be testing with cucumber, I was advised that I should test for text > elements contained in the response body of the expected output. Now, > what I am wondering is how one accounts for multilingual implementation. > > I have hit upon the idea of simply adding special css id selectors to > the templates that identify their use. So, for example, instead of > looking for the word "Registration" I would look for a css selector > id=user_registration. > > I know that this will work but, is there another, preferred, way of > handling this situation? > I'm developing a multilingual app now. Based on the user's preferences it will display UI elements (text, links etc) in either Norwegian, Nynorsk (Neo Norwegian) or** S?mi (the 3 official languages in Norway). We use Webrat, and for the Cucumber Scenarios we have chosen one arbitrary language - Norwegian. (Actually, it's not that arbitrary - it's what all the developers speak and write). In order to make the scenarios readable for the stakeholders we prefer to refer to use the visible text instead of the DOM id or names. (This also verifies that the
Short Name
<%=h entity.entity_name.titlecase -%><%= "%06d" % entity.id -%> <%= link_to 'Show Entity', entity -%> <%= link_to 'Edit Entity', edit_entity_path(entity) -%> <%= link_to 'Destroy Entity', entity, :confirm => 'Are you sure?', :method => :delete -%>
<%=h entity.entity_name.titlecase -%> <%=h entity.entity_legal_form -%> <%= "%06d" % entity.id -%> <%= link_to 'Show Entity', entity -%> <%= link_to 'Edit Entity', edit_entity_path(entity) -%> <%= link_to 'Destroy Entity', entity, :confirm => 'Are you sure?', :method => :delete -%>
Just An Entity 000001 Show Entity Edit Entity Destroy Entity
This Is a Bare Entity
\n\n
\n\n
New user\n\n\n\r\n\r\n ... So, I am nonplussed by the report that it did not find what was present. -- Posted via http://www.ruby-forum.com/. From jim at saturnflyer.com Mon Jan 19 14:22:32 2009 From: jim at saturnflyer.com (Jim Gay) Date: Mon, 19 Jan 2009 14:22:32 -0500 Subject: [rspec-users] [RSpec] matcher for href In-Reply-To: References: Message-ID: <9D008F8E-6B3F-40C8-9A84-B8E3A2DB4ACD@saturnflyer.com> On Jan 19, 2009, at 2:11 PM, James Byrne wrote: > Of the several ways available to test for this, what would be the > preferred way to see if the following is present in an html document > WITHOUT actually following the link? > > response.should have_tag('a[href=?]','/users/new') > I tried this: > > response.body.should have_text('href="/users/new"') Or response.should include_text('href="/users/new"') have_text should be used "when you want to match the whole string or whole body" include_text should be used "when you either don?t know or don?t care where on the page this text appears." http://rspec.rubyforge.org/rspec-rails/1.1.12/ > > > But this test fails, even though the rake features report is this: > > expected "href=\"/users/new\"", got ... > > ... \n\n\n\n
\n\n
New > user\n\n\n\r\n\r\n ... > > So, I am nonplussed by the report that it did not find what was > present. From jarkko at jlaine.net Mon Jan 19 14:26:51 2009 From: jarkko at jlaine.net (Jarkko Laine) Date: Mon, 19 Jan 2009 21:26:51 +0200 Subject: [rspec-users] [RSpec] matcher for href In-Reply-To: References: Message-ID: <126B70EA-9ADE-4B47-BB02-58C13E721FE0@jlaine.net> On 19.1.2009, at 21.11, James Byrne wrote: > Of the several ways available to test for this, what would be the > preferred way to see if the following is present in an html document > WITHOUT actually following the link? > > > > I tried this: > > response.body.should have_text('href="/users/new"') response.should have_tag("a[href=/users/new]") http://rspec.rubyforge.org/rspec-rails/1.1.12/classes/Spec/Rails/Matchers.html#M000071 //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://odesign.fi Check out my latest book, Unobtrusive Prototype, fresh off the Peepcode oven: http://peepcode.com/products/unobtrusive-prototype-js From matt at mattwynne.net Mon Jan 19 14:45:07 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 19 Jan 2009 19:45:07 +0000 Subject: [rspec-users] [Rails, RSpec] The config.gem rake task chicken and egg thing Message-ID: <4C6D6798-DB86-46AD-90EB-E4A8D17777F0@mattwynne.net> Sorry folks, because I know this has been asked before but I don't remember anyone giving enough detail for me to sort this out the way I want to. How do I change my rake tasks to silently fail if they can't require rspec? I can do this: begin require 'spec/rake/spectask' ... the whole Rake task ... rescue LoadError puts "Unable to load RSpec - do you need to install the gem?" end ... but that seems insane to have to indent all the code inside that big begin / rescue block. I'm sure there's a way to exit the script without causing the whole rake loading chain to fail, but what is it? I tried 'exit 0' but that seems to exit the whole process. So I guess this is more a Ruby question than an RSpec question really, but I'm sure a good answer will help a few other people out too. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From lists at ruby-forum.com Mon Jan 19 14:46:12 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 19 Jan 2009 20:46:12 +0100 Subject: [rspec-users] [RSpec] matcher for href In-Reply-To: References: Message-ID: James Byrne wrote: > Of the several ways available to test for this, what would be the > preferred way to see if the following is present in an html document > WITHOUT actually following the link? Apparently this is the correct form: response.body.should have_tag("a[href=/users/new]") -- Posted via http://www.ruby-forum.com/. From scott at railsnewbie.com Mon Jan 19 15:03:06 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Mon, 19 Jan 2009 15:03:06 -0500 Subject: [rspec-users] [Rails, RSpec] The config.gem rake task chicken and egg thing In-Reply-To: <4C6D6798-DB86-46AD-90EB-E4A8D17777F0@mattwynne.net> References: <4C6D6798-DB86-46AD-90EB-E4A8D17777F0@mattwynne.net> Message-ID: <4974DC7A.20406@railsnewbie.com> Matt Wynne wrote: > Sorry folks, because I know this has been asked before but I don't > remember anyone giving enough detail for me to sort this out the way I > want to. > > How do I change my rake tasks to silently fail if they can't require > rspec? > > I can do this: > > begin > require 'spec/rake/spectask' > > ... the whole Rake task ... > > rescue LoadError > puts "Unable to load RSpec - do you need to install the gem?" > end > > > ... but that seems insane to have to indent all the code inside that > big begin / rescue block. I'm sure there's a way to exit the script > without causing the whole rake loading chain to fail, but what is it? > I tried 'exit 0' but that seems to exit the whole process. > > So I guess this is more a Ruby question than an RSpec question really, > but I'm sure a good answer will help a few other people out too. > I suppose you could override describe: begin require 'spec/rake/spectask' rescue LoadError Kernel.warn "Unable to load RSpec - do you need to install the gem?" class << self def describe(*args) # do nothing end end end Scott From scott at railsnewbie.com Mon Jan 19 15:05:14 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Mon, 19 Jan 2009 15:05:14 -0500 Subject: [rspec-users] gem installation issues Message-ID: <4974DCFA.1020606@railsnewbie.com> I'm getting the following error when trying to install rspec: scott-taylors-macbook-pro:dl_forms(specs) smt$ sudo gem install rspec Password: ERROR: Error installing rspec: invalid gem format for /usr/local/ruby_versions/1_8_6/lib/ruby/gems/1.8/cache/rspec-1.1.12.gem Are the gems no longer hosted at rubyforge? Scott From matt at mattwynne.net Mon Jan 19 15:38:16 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 19 Jan 2009 20:38:16 +0000 Subject: [rspec-users] Rake features:rcov question In-Reply-To: <36f9f6ee64f54277dc64efd8926857de@ruby-forum.com> References: <36f9f6ee64f54277dc64efd8926857de@ruby-forum.com> Message-ID: On 19 Jan 2009, at 15:49, James Byrne wrote: > I have reached a point where I thought that it might be useful to see > how must test coverage I have for the code I have written. However, > running rake features:rcov produces some unexpected output. I see > this > in the index file: > > > /usr/lib/ruby/1.8/base64.rb ... > /usr/lib/ruby/1.8/benchmark.rb ... > ... > /usr/lib/ruby/1.8/uri/mailto.rb > > Then my files are reported > > app/controllers/application_controller.rb > app/controllers/clients_controller.rb > ... > and so forth. Now, I have checked the spec and test directory trees > and there does not seem to be anything in there that I recognize as > having anything to do with the ruby libraries. My questions are: 1. > Is > this normal behaviour for rcov? 2. If not, then what might I have done > to cause this? > > Regards, > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Take a look at the --exclude option for rcov - that's what you need to do. Otherwise by default it will tell you about coverage for every ruby file that was touched during the test run, including things that the testing framework called, and the things they called, etc. I would have assumed this was in the default rake task that was generated, but anyway you should be able to figure it out if you look at rcov's options. Running rcov yourself really isn't such a black art - from the command line you can get coverage from a single feature using this: rcov --exclude 'gems/*.rb' /usr/local/bin/cucumber -- path/to/ the.feature Matt Wynne http://blog.mattwynne.net http://www.songkick.com From lists at ruby-forum.com Mon Jan 19 15:38:27 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 19 Jan 2009 21:38:27 +0100 Subject: [rspec-users] [Cucumber] code stats Message-ID: Rspec provides a stats task for rake. However, it does not reference cucumber step definitions, possibly because these are not easily categorized into the MVC etc. test classifications that the rspec task uses. Is extending the rake stats task to encompass cucumber step definitions possible? If so, is it worth doing? -- Posted via http://www.ruby-forum.com/. From apremdas at gmail.com Mon Jan 19 16:31:13 2009 From: apremdas at gmail.com (Andrew Premdas) Date: Mon, 19 Jan 2009 21:31:13 +0000 Subject: [rspec-users] [Cucumber] Scenario Outlines Output Insufficient In-Reply-To: <8b05c7eb1196f3a832b1da5c95bc9e5f@ruby-forum.com> References: <88fd8ddc0901162008r2f89997co1844f258c52bb5fe@mail.gmail.com> <8d961d900901170520y3d8e2913r2e96a35781fe96f6@mail.gmail.com> <88fd8ddc0901180801k1612eb48m1cb77894530494fe@mail.gmail.com> <49736E96.40408@josephwilk.net> <88fd8ddc0901181136t55509a31mbbecab481676b9cc@mail.gmail.com> <8b05c7eb1196f3a832b1da5c95bc9e5f@ruby-forum.com> Message-ID: <88fd8ddc0901191331h45bdc64dr53ab25d2adac058a@mail.gmail.com> Comments below 2009/1/19 Joseph Wilk > Andrew Premdas wrote: > > You misunderstood I bit of my post, I've nested a comment. Its towards > > the > > end of the post. > > > > 2009/1/18 Joseph Wilk > > > >> Scenario Outline: viewing resources # > >> features/admin/poop.feature:11 > >> > >> -- > >> features/step_definitions/general.rb:1 > >> When I follow resource # > >> |product | > >> > http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/163-hidden-pending-status-with-output-when-using-scenario-outlines > >> And there are 4 > >> > >> > >> keen on this solution as I would like to preserve the way the scenarios > are > >> defined (in the feature file) with the way that they are outputted. > >> > >> > >> > >> And there are 4 category # > >> features/admin/poop.feature:8 > >> And there are 4 product # > >> features/step_definitions/product.rb:1 > >> > > > > No you've misunderstood me. I meant the outline step is colored with the > > worst result. Then the details of each run of the step are nested inside > > the > > outline step showing the output for each resource (entry in the table) > > Would you expect to still see the scenario table with status colours? > Yes it feels that the table would still be useful in this situation to guide you back to the nested output to look for things > Do you think it might become difficult to workout which steps are for > which run? > i.e the 5th indented Step broke so lets read through and find each 5th > step to see what the run did. > Hopefully because the nested output contains the expanded template variable the navigation will be OK. The idea was that the nesting would only happen when there was variation i.e. a different matcher in the first example or a different result in the second. If you showed the nesting for every step regardless then yes I think things could get pretty confusing. I haven't really thought about what happens with errors yet. For example if you have five things in your table and they all fail generating a massive output stack. Would you really want to see five output stacks? > It does sound like an interesting idea. Would you mind adding the full > output you would expect with this indentation in the ticket please? (If > you want colour as a html attachment). > I will do this, but let me think about it a little more > > Thanks, > Your welcome > -- > Joseph Wilk > http://blog.josephwilk.net > > -- > 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 aslak.hellesoy at gmail.com Mon Jan 19 16:31:44 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 19 Jan 2009 22:31:44 +0100 Subject: [rspec-users] [Cucumber] code stats In-Reply-To: References: Message-ID: <8d961d900901191331j1411f8bem23a17fa9665ca081@mail.gmail.com> On Mon, Jan 19, 2009 at 9:38 PM, James Byrne wrote: > Rspec provides a stats task for rake. However, it does not reference > cucumber step definitions, possibly because these are not easily > categorized into the MVC etc. test classifications that the rspec task > uses. > > Is extending the rake stats task to encompass cucumber step definitions > possible? If so, is it worth doing? I haven't thought about it. I can't think of any valuable knowledge I'd get from that. Aslak > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at deadorange.com Mon Jan 19 17:14:18 2009 From: nick at deadorange.com (Nick Hoffman) Date: Mon, 19 Jan 2009 17:14:18 -0500 Subject: [rspec-users] [RSpec] Message expectations and #dup / #clone Message-ID: <3B5C2E75-64E9-4A45-A5A7-2657A460E645@deadorange.com> Can anyone confirm that message expectations are not copied/duplicated to the new object when using Object#dup or #clone ? Thanks! Nick From zuperinfinite at gmail.com Tue Jan 20 08:44:02 2009 From: zuperinfinite at gmail.com (Bart Zonneveld) Date: Tue, 20 Jan 2009 14:44:02 +0100 Subject: [rspec-users] [rspec] Stubbing partials in view specs Message-ID: <71C878F7-574B-4287-8D5B-FAD56FD8AFB5@gmail.com> Hey list, As a good BDDer I want to test my views in isolation. And as a good rails programmer, I separate views into partials when needed. So, when testing my views, I want to stub out rendering of partials in my views. I'm working on upgrading an app from rails 2.1.2 to 2.2.2, using the latest rspec and rspec-rails. I used to throw template.stub!(:render) in a before(:each) block and be done with it, but that doesn't work anymore. I can understand why, but now I have to do something like template.stub!(:render).with (hash_including(:partial => anything)). Except for when I'm testing a partial, then I need to replace the anything with every partial I'm rendering in my partial. Is this the correct way, or is there perhaps something like template.stub_partials :only => [], :except => [] ? thanks, bartz From dchelimsky at gmail.com Tue Jan 20 09:29:53 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 20 Jan 2009 08:29:53 -0600 Subject: [rspec-users] [rspec] Stubbing partials in view specs In-Reply-To: <71C878F7-574B-4287-8D5B-FAD56FD8AFB5@gmail.com> References: <71C878F7-574B-4287-8D5B-FAD56FD8AFB5@gmail.com> Message-ID: <57c63afe0901200629y1bb6b1e8vf0acaf2f2c7d5a2@mail.gmail.com> On Tue, Jan 20, 2009 at 7:44 AM, Bart Zonneveld wrote: > Hey list, > > As a good BDDer I want to test my views in isolation. Sort of. A *good* BDDer wants to *specify* views in isolation. Testing is for testers :) > And as a good rails > programmer, I separate views into partials when needed. So, when testing my > views, I want to stub out rendering of partials in my views. I'm working on > upgrading an app from rails 2.1.2 to 2.2.2, using the latest rspec and > rspec-rails. > > I used to throw template.stub!(:render) in a before(:each) block and be done > with it That sounds kinda risky because you could be ignoring partials that get rendered that you don't want to be rendered. >, but that doesn't work anymore. I can understand why, but now I have > to do something like template.stub!(:render).with(hash_including(:partial => > anything)). Except for when I'm testing a partial, then I need to replace > the anything with every partial I'm rendering in my partial. > > Is this the correct way, Seems like the only way at the moment. Wouldn't call it correct or incorrect. > or is there perhaps something like > template.stub_partials :only => [], :except => [] ? Nothing like this exists. Seems like a reasonable idea. Feel free to submit a feature request, or better yet, a patch to http://rspec.lighthouseapp.com Cheers, David > > thanks, > bartz > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From daniel.vartanov at gmail.com Tue Jan 20 09:45:14 2009 From: daniel.vartanov at gmail.com (Daniel Vartanov) Date: Tue, 20 Jan 2009 14:45:14 +0000 Subject: [rspec-users] [Cucumber, Merb, Webrat] undefined method 'response' for Merb::Test::World::Webrat Message-ID: Hello! I get the following error everytime I try to check the result of previous step (by the way, I use default result_steps.rb): undefined local variable or method `response' for # (NameError) ./features/steps/result_steps.rb:14:in ` /^the (.*) ?request should fail/' features/authentication/login.feature:17:in `/^the (.*) ?request should fail/' It is raised even in a freshly generated merb application (merb-gen app) and freshly generated cucumber files (merb-gen cucumber --session-type webrat). Here are the versions of the installed gems: cucumber (0.1.15) merb (1.0.8) webrat (0.4.0) david-merb_cucumber (0.5.1.2) Where should I search for the source of the problem? -------------- next part -------------- An HTML attachment was scrubbed... URL: From zuperinfinite at gmail.com Tue Jan 20 11:35:15 2009 From: zuperinfinite at gmail.com (Bart Zonneveld) Date: Tue, 20 Jan 2009 17:35:15 +0100 Subject: [rspec-users] [rspec] Stubbing partials in view specs In-Reply-To: <57c63afe0901200629y1bb6b1e8vf0acaf2f2c7d5a2@mail.gmail.com> References: <71C878F7-574B-4287-8D5B-FAD56FD8AFB5@gmail.com> <57c63afe0901200629y1bb6b1e8vf0acaf2f2c7d5a2@mail.gmail.com> Message-ID: <6E3760F3-15A0-4E25-9E70-7DF948A4C8B2@gmail.com> On 20-jan-2009, at 15:29, David Chelimsky wrote: > On Tue, Jan 20, 2009 at 7:44 AM, Bart Zonneveld > wrote: >> Hey list, >> >> As a good BDDer I want to test my views in isolation. > > Sort of. A *good* BDDer wants to *specify* views in isolation. Testing > is for testers :) You're right! I tend to talk a lot to non-programmers, and they get that glaze-in-the-distance look in their eyes, whenever I mention specifiy, spec'ing, or what have you :). >> And as a good rails >> programmer, I separate views into partials when needed. So, when >> testing my >> views, I want to stub out rendering of partials in my views. I'm >> working on >> upgrading an app from rails 2.1.2 to 2.2.2, using the latest rspec >> and >> rspec-rails. >> >> I used to throw template.stub!(:render) in a before(:each) block >> and be done >> with it > > That sounds kinda risky because you could be ignoring partials that > get rendered that you don't want to be rendered. It is, most definately. >> , but that doesn't work anymore. I can understand why, but now I have >> to do something like template.stub!(:render).with(hash_including >> (:partial => >> anything)). Except for when I'm testing a partial, then I need to >> replace >> the anything with every partial I'm rendering in my partial. >> >> Is this the correct way, > > Seems like the only way at the moment. Wouldn't call it correct or > incorrect. I would call it ugly :). Not only do I have to remember the hash_including part, but also the anything (and not :anything). Conceptually, I like the template.stub!(:render). I render a template, on which I stub all the renders. Whether that's risky or not is a different discussion. >> or is there perhaps something like >> template.stub_partials :only => [], :except => [] ? > > Nothing like this exists. Seems like a reasonable idea. Feel free to > submit a feature request, or better yet, a patch to > http://rspec.lighthouseapp.com Will do! cheers, bartz From lists at ruby-forum.com Wed Jan 21 02:57:14 2009 From: lists at ruby-forum.com (Giuseppe Bertini) Date: Wed, 21 Jan 2009 08:57:14 +0100 Subject: [rspec-users] fixture_scenarios problem Message-ID: Hello there, is anyone still using fixture_scenarios with RSpec these days? They don't seem to coexist peacefully anymore. I just created a new rails (2.2.2) app, generated an rspec_scaffold (with v. 1.1.12), and verified that all specs pass. But if I then install the fixture_scenarios plugin: script/plugin install http://fixture-scenarios.googlecode.com/svn/trunk/fixture_scenarios all specs break, with the first error line being: /Users/giuseppe/trails/witest/vendor/plugins/fixture_scenarios/lib/fixture_scenarios.rb:37 :in `create_fixtures' (more details upon request) On the other hand, the same plugin used to work with RSpec 1.1.4 Has anyone encountered/solved this problem? Thanks in advance, Giuseppe -- Posted via http://www.ruby-forum.com/. From scott at railsnewbie.com Wed Jan 21 03:09:32 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Wed, 21 Jan 2009 03:09:32 -0500 Subject: [rspec-users] fixture_scenarios problem In-Reply-To: References: Message-ID: <4976D83C.9080306@railsnewbie.com> Giuseppe Bertini wrote: > Hello there, > > is anyone still using fixture_scenarios with RSpec these days? They > don't seem to coexist peacefully anymore. > > I just created a new rails (2.2.2) app, generated an rspec_scaffold > (with v. 1.1.12), and verified that all specs pass. > > But if I then install the fixture_scenarios plugin: > > script/plugin install > http://fixture-scenarios.googlecode.com/svn/trunk/fixture_scenarios > > all specs break, with the first error line being: > > /Users/giuseppe/trails/witest/vendor/plugins/fixture_scenarios/lib/fixture_scenarios.rb:37 > :in `create_fixtures' > > (more details upon request) > Is the git tree any different than the svn one? http://github.com/mojombo/fixture-scenarios/tree/master Scott From lists at ruby-forum.com Wed Jan 21 07:49:18 2009 From: lists at ruby-forum.com (Juanma Cervera) Date: Wed, 21 Jan 2009 13:49:18 +0100 Subject: [rspec-users] =?utf-8?q?=5Bcucumber=5D_Features_with_multiple_use?= =?utf-8?q?r_iterations_=C2=BF=3F?= Message-ID: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> I am specing a feature, maybe at more high level of what it should be, and this makes scenarios that involves more that one rails controller. Is it possible or convenient? I have scenarios like this (although it's only an unreal example): Feature: Making a reservation for a service. Scenario: Making the reservation Given I want to make a reservation for a service When I choose the service Then I see the page 'service1/1/options' When I select option 1 And I click on "submit" Then I will be asked for a confirmation When I answer 'Yes' Then I see "Ok" And I go to "/services/1" Is this ok or I should define the features with only one single iteration? Juanma Cervera. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed Jan 21 08:40:05 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 21 Jan 2009 07:40:05 -0600 Subject: [rspec-users] =?iso-8859-1?q?=5Bcucumber=5D_Features_with_multipl?= =?iso-8859-1?q?e_user_iterations_=BF=3F?= In-Reply-To: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> References: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> Message-ID: <57c63afe0901210540x4f8141eah1eeb89aac34f1f3f@mail.gmail.com> On Wed, Jan 21, 2009 at 6:49 AM, Juanma Cervera wrote: > I am specing a feature, maybe at more high level of what it should be, > and this makes scenarios that involves more that one rails controller. > > Is it possible or convenient? > > I have scenarios like this (although it's only an unreal example): > > Feature: Making a reservation for a service. > Scenario: Making the reservation > Given I want to make a reservation for a service > When I choose the service > Then I see the page 'service1/1/options' > When I select option 1 > And I click on "submit" > Then I will be asked for a confirmation > When I answer 'Yes' > Then I see "Ok" > And I go to "/services/1" > > > Is this ok or I should define the features with only one single > iteration? It's OK to have more than one series of When/Then as long as they make for a cohesive scenario, which you've done here. I'd recommend avoiding URLs in the steps though. For example (I don't know what service and option mean in your case, but this should give you an idea): Scenario: Make a new reservation Given a 'Foo' service And the 'Foo' service includes a 'Bar' option When I choose the 'Foo' service Then I see the 'Foo Service' detail When I select the 'Bar' option And I submit my request Then I am be asked for a confirmation When I answer 'Yes' Then I see 'OK' And I see the 'Foo' service in the 'My Services' Note the lack of references to URLS and even pages. I might have taken it too far, depending on your situation. For example, "And I submit my request" instead of "And I click 'submit'" - If there is particular text on the button that is deemed to have business value, then you might say "And I click 'Request Service'" - but if you're referencing DOM IDs or HTML element names like 'submit', I'd hide those. HTH, David > > Juanma Cervera. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aidy.lewis at googlemail.com Wed Jan 21 08:57:14 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Wed, 21 Jan 2009 13:57:14 +0000 Subject: [rspec-users] 'Then' after a 'When' and then a 'Then'? Message-ID: <7ac2300c0901210557u62a632e6vd5f5b91c872ebaa2@mail.gmail.com> Hi, Is it bad form to use a 'Then' after a 'When' and then a 'Then'? When the CiP ingest checkbox is clicked Then '1 Spool(s) in Cart' should appear When the Add button is clicked Then an ingest user is on the BBC Cart page Or should I create a new scenario and use a 'Given'? Or can I have a Given after a 'Then' in the same scenario? Or should each scenerio follow 'Given'...'When'...'Then'? Cheers Aidy From aidy.lewis at googlemail.com Wed Jan 21 09:16:24 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Wed, 21 Jan 2009 14:16:24 +0000 Subject: [rspec-users] 'Then' after a 'When' and then a 'Then'? In-Reply-To: <7ac2300c0901210557u62a632e6vd5f5b91c872ebaa2@mail.gmail.com> References: <7ac2300c0901210557u62a632e6vd5f5b91c872ebaa2@mail.gmail.com> Message-ID: <7ac2300c0901210616x3e3401edi609c44acff7a5baa@mail.gmail.com> Hi, Apologies only just read the last post re: multiple iterations: please ignore. Aidy On 21/01/2009, aidy lewis wrote: > Hi, > > Is it bad form to use a 'Then' after a 'When' and then a 'Then'? > > When the CiP ingest checkbox is clicked > Then '1 Spool(s) in Cart' should appear > When the Add button is clicked > Then an ingest user is on the BBC Cart page > > Or should I create a new scenario and use a 'Given'? > > Or can I have a Given after a 'Then' in the same scenario? > > Or should each scenerio follow 'Given'...'When'...'Then'? > > Cheers > > > Aidy > From lists at ruby-forum.com Wed Jan 21 09:34:57 2009 From: lists at ruby-forum.com (Juanma Cervera) Date: Wed, 21 Jan 2009 15:34:57 +0100 Subject: [rspec-users] =?utf-8?q?=5Bcucumber=5D_Features_with_multipl_e_us?= =?utf-8?q?er_iterations_=C2=BF=3F?= In-Reply-To: <57c63afe0901210540x4f8141eah1eeb89aac34f1f3f@mail.gmail.com> References: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> <57c63afe0901210540x4f8141eah1eeb89aac34f1f3f@mail.gmail.com> Message-ID: <417a9b024aa6a81656f67791e9cb513f@ruby-forum.com> Thank you David. All make a lot of sense. With the urls I only was trying to clarify that the scenario spans across multiple controllers, but I am making the specs as you recommend. Juanma -- Posted via http://www.ruby-forum.com/. From joe at josephwilk.net Wed Jan 21 09:35:47 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Wed, 21 Jan 2009 14:35:47 +0000 Subject: [rspec-users] =?iso-8859-1?q?=5Bcucumber=5D_Features_with_multipl?= =?iso-8859-1?q?e_user_iterations_=BF=3F?= In-Reply-To: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> References: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> Message-ID: <497732C3.3000401@josephwilk.net> Juanma Cervera wrote: > I am specing a feature, maybe at more high level of what it should be, > and this makes scenarios that involves more that one rails controller. > > Is it possible or convenient? > > I do not think its a problem touching multiple controllers if that's what is required for the user to achieve some specific value from the system. The value is king. > I have scenarios like this (although it's only an unreal example): > > Feature: Making a reservation for a service. > Scenario: Making the reservation > Given I want to make a reservation for a service > When I choose the service > Then I see the page 'service1/1/options' > When I select option 1 > And I click on "submit" > Then I will be asked for a confirmation > When I answer 'Yes' > Then I see "Ok" > And I go to "/services/1" > > > Is this ok or I should define the features with only one single > iteration? > > I find deviating from the ordering of Given/When/Then can sometimes produce scenarios that are hard to read and conceptualise. So I personally avoid multiple iterations in a single scenario. This however does not mean you should not touch multiple controllers. I would suggest perhaps something like this for your example scenario: -- Scenario: Making a successful reservation for massage service Given I have gone to the reservation page And I selected the service "massage" When I choose the option "extra oil" And I press the "make reservation" button And I confirm my reservation Then I will see "Ok, your reservation has been made for blah. Thanks!" And I will see the total price And I will be redirected to the service. Scenario: Making a reservation but cancelling at confirmation -- My scenario would still fail based on the 'thens' you mention. For example if I don't see the page 'service1/1/options' then I can never click the option for extra oil. So your thens have become implied. They are part of the journey, the destination (and value) is seeing I've made a reservation. Looking at your initial steps this one jumps out at me: Given I want to make a reservation for a service While it gives intent and a goal it does not explain the start state so I would question its usefulness. It feels more like the scenario name. -- Joseph Wilk http://blog.josephwilk.net > Juanma Cervera. > From zach.dennis at gmail.com Wed Jan 21 09:57:17 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 21 Jan 2009 09:57:17 -0500 Subject: [rspec-users] =?iso-8859-1?q?=5Bcucumber=5D_Features_with_multipl?= =?iso-8859-1?q?e_user_iterations_=BF=3F?= In-Reply-To: <497732C3.3000401@josephwilk.net> References: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> <497732C3.3000401@josephwilk.net> Message-ID: <85d99afe0901210657n277f3fc0s9f7fe0e86e9fb796@mail.gmail.com> On Wed, Jan 21, 2009 at 9:35 AM, Joseph Wilk wrote: > Juanma Cervera wrote: >> >> I am specing a feature, maybe at more high level of what it should be, >> and this makes scenarios that involves more that one rails controller. >> >> Is it possible or convenient? >> >> > > I do not think its a problem touching multiple controllers if that's what is > required for the user to achieve some specific value from the system. The > value is king. To add this Joseph's comment, a general rule of thumb I follow is that I don't think about what controllers (if any) my scenarios are going to use. Since the scenario communicates value and behaviour provided by the app it's up to me as the developer to determine a good implementation. This may involve multiple controllers, one controller, or no controllers. This doesn't mean that I don't have a general idea of how I'm going to implement something because I usually do. But that's just because I'm a developer and as soon as I see a behaviour wanting implementation my brain goes in problem solving mode and starts to determining possible paths to a solution. The trick is to not to let this influence how you write (or encourage customers if you're working with them) scenarios. Here's a quick example. Let's say that you start by thinking one controller will suffice so you write your scenario for one controller. As you implement the scenario you may determine you really want to have two controllers because it helps keep your controller implementations clean. At this point you shouldn't have to change your scenario because you didn't change what the app is doing -- you just changed how it is doing it. So, changes should be limited to step definitions and actual implementation and not the scenario text itself. > >> I have scenarios like this (although it's only an unreal example): >> >> Feature: Making a reservation for a service. >> Scenario: Making the reservation >> Given I want to make a reservation for a service >> When I choose the service >> Then I see the page 'service1/1/options' >> When I select option 1 >> And I click on "submit" >> Then I will be asked for a confirmation >> When I answer 'Yes' >> Then I see "Ok" >> And I go to "/services/1" >> >> Is this ok or I should define the features with only one single >> iteration? >> >> > > I find deviating from the ordering of Given/When/Then can sometimes produce > scenarios that are hard to read and conceptualise. So I personally avoid > multiple iterations in a single scenario. This however does not mean you > should not touch multiple controllers. > > I would suggest perhaps something like this for your example scenario: > > -- > Scenario: Making a successful reservation for massage service > Given I have gone to the reservation page > And I selected the service "massage" > When I choose the option "extra oil" > And I press the "make reservation" button > And I confirm my reservation > Then I will see "Ok, your reservation has been made for blah. Thanks!" > And I will see the total price > And I will be redirected to the service. > Scenario: Making a reservation but cancelling at confirmation > > -- > My scenario would still fail based on the 'thens' you mention. For example > if I don't see the page 'service1/1/options' then I can never click the > option for extra oil. So your thens have become implied. They are part of > the journey, the destination (and value) is seeing I've made a reservation. > > > Looking at your initial steps this one jumps out at me: > > Given I want to make a reservation for a service > > While it gives intent and a goal it does not explain the start state so I > would question its usefulness. It feels more like the scenario name. > > > -- > Joseph Wilk > http://blog.josephwilk.net >> >> Juanma Cervera. >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From aidy.lewis at googlemail.com Wed Jan 21 10:27:54 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Wed, 21 Jan 2009 15:27:54 +0000 Subject: [rspec-users] =?iso-8859-1?q?=5Bcucumber=5D_Features_with_multipl?= =?iso-8859-1?q?e_user_iterations_=BF=3F?= In-Reply-To: <57c63afe0901210540x4f8141eah1eeb89aac34f1f3f@mail.gmail.com> References: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> <57c63afe0901210540x4f8141eah1eeb89aac34f1f3f@mail.gmail.com> Message-ID: <7ac2300c0901210727x8072331nc3612517f3cc1de0@mail.gmail.com> Hi David, On 21/01/2009, David Chelimsky wrote: > text on the button that is deemed to have business value, then you > might say "And I click 'Request Service'" - but if you're referencing > DOM IDs or HTML element names like 'submit', I'd hide those. However we could get a lot of re-use in the user steps if we have step definitions like these: When /^clicks '(+)' link$/ do |text| browser.link(:text, Regexp.new(value)).click end When /^clicks '(+)' button$/ do |text| browser.button(:value, Regexp.new(value)).click end When clicks 'Submit' link When clicks 'Submit' button When clicks 'New' link When clicks 'New' button I personally don't think it is a crime for the tester to change the acceptance steps as long as the 'user' can easily follow the narrative. A lot of the other user-steps could be wrapped-up in a more 'declarative' fashion. Aidy From dchelimsky at gmail.com Wed Jan 21 10:50:50 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 21 Jan 2009 09:50:50 -0600 Subject: [rspec-users] =?iso-8859-1?q?=5Bcucumber=5D_Features_with_multipl?= =?iso-8859-1?q?e_user_iterations_=BF=3F?= In-Reply-To: <7ac2300c0901210727x8072331nc3612517f3cc1de0@mail.gmail.com> References: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> <57c63afe0901210540x4f8141eah1eeb89aac34f1f3f@mail.gmail.com> <7ac2300c0901210727x8072331nc3612517f3cc1de0@mail.gmail.com> Message-ID: <57c63afe0901210750t7e4038b1h8d306ecc9df9dcaa@mail.gmail.com> On Wed, Jan 21, 2009 at 9:27 AM, aidy lewis wrote: > Hi David, > On 21/01/2009, David Chelimsky wrote: > >> text on the button that is deemed to have business value, then you >> might say "And I click 'Request Service'" - but if you're referencing >> DOM IDs or HTML element names like 'submit', I'd hide those. > > However we could get a lot of re-use in the user steps if we have > step definitions like these: > > When /^clicks '(+)' link$/ do |text| > browser.link(:text, Regexp.new(value)).click > end > > When /^clicks '(+)' button$/ do |text| > browser.button(:value, Regexp.new(value)).click > end > > > When clicks 'Submit' link > When clicks 'Submit' button > When clicks 'New' link > When clicks 'New' button The important part of what I was saying was to avoid hidden elements (DOM IDs and element names). If the label that is visible in the browser says "Submit", then this is OK IMO. > I personally don't think it is a crime for the tester to change the > acceptance steps as long as the 'user' can easily follow the > narrative. Don't worry, you're not under arrest. At least not for this transgression :) > A lot of the other user-steps could be wrapped-up in a more > 'declarative' fashion. > > Aidy From apremdas at gmail.com Thu Jan 22 00:06:50 2009 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 22 Jan 2009 05:06:50 +0000 Subject: [rspec-users] =?iso-8859-1?q?=5Bcucumber=5D_Features_with_multipl?= =?iso-8859-1?q?e_user_iterations_=BF=3F?= In-Reply-To: <57c63afe0901210750t7e4038b1h8d306ecc9df9dcaa@mail.gmail.com> References: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> <57c63afe0901210540x4f8141eah1eeb89aac34f1f3f@mail.gmail.com> <7ac2300c0901210727x8072331nc3612517f3cc1de0@mail.gmail.com> <57c63afe0901210750t7e4038b1h8d306ecc9df9dcaa@mail.gmail.com> Message-ID: <88fd8ddc0901212106u41f5da00mf7ce21478a46cc70@mail.gmail.com> Assuming that your steps are focused on using DOM Id's what sort of convention would you use to translate from the narrative of the step to the DOM id. Would you avoid the brittleness that "clicks submit link|button" has over "I submit". Thats me arguing that whether its a link or a button, and whether the user submits by clicking, pressing enter or barking is not relevant to the scenario. 2009/1/21 David Chelimsky > On Wed, Jan 21, 2009 at 9:27 AM, aidy lewis > wrote: > > Hi David, > > On 21/01/2009, David Chelimsky wrote: > > > >> text on the button that is deemed to have business value, then you > >> might say "And I click 'Request Service'" - but if you're referencing > >> DOM IDs or HTML element names like 'submit', I'd hide those. > > > > However we could get a lot of re-use in the user steps if we have > > step definitions like these: > > > > When /^clicks '(+)' link$/ do |text| > > browser.link(:text, Regexp.new(value)).click > > end > > > > When /^clicks '(+)' button$/ do |text| > > browser.button(:value, Regexp.new(value)).click > > end > > > > > > When clicks 'Submit' link > > When clicks 'Submit' button > > When clicks 'New' link > > When clicks 'New' button > > The important part of what I was saying was to avoid hidden elements > (DOM IDs and element names). If the label that is visible in the > browser says "Submit", then this is OK IMO. > > > I personally don't think it is a crime for the tester to change the > > acceptance steps as long as the 'user' can easily follow the > > narrative. > > Don't worry, you're not under arrest. At least not for this transgression > :) > > > A lot of the other user-steps could be wrapped-up in a more > > 'declarative' fashion. > > > > Aidy > _______________________________________________ > 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 joshuachisholm at gmail.com Thu Jan 22 05:41:21 2009 From: joshuachisholm at gmail.com (Josh Chisholm) Date: Thu, 22 Jan 2009 10:41:21 +0000 Subject: [rspec-users] =?iso-8859-1?q?=5Bcucumber=5D_Features_with_multipl?= =?iso-8859-1?q?e_user_iterations_=BF=3F?= In-Reply-To: <88fd8ddc0901212106u41f5da00mf7ce21478a46cc70@mail.gmail.com> References: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> <57c63afe0901210540x4f8141eah1eeb89aac34f1f3f@mail.gmail.com> <7ac2300c0901210727x8072331nc3612517f3cc1de0@mail.gmail.com> <57c63afe0901210750t7e4038b1h8d306ecc9df9dcaa@mail.gmail.com> <88fd8ddc0901212106u41f5da00mf7ce21478a46cc70@mail.gmail.com> Message-ID: <1126d7ae0901220241l2825b12bq505c190ac68e2488@mail.gmail.com> > Would you avoid the brittleness that "clicks submit link|button" has over "I submit". There are often many ways of submitting on the same page. So to avoid tying "I submit" to a particular scenario, I tend to use "I click 'submit'", which doesn't correspond to a link or button specifically, but to "a link, button, or label with the text 'submit' -- and raise an error if it's ambiguous". Is that too vague? As a human, if I were told to "click 'submit'" I think I would apply the same reasoning. On Thu, Jan 22, 2009 at 5:06 AM, Andrew Premdas wrote: > Assuming that your steps are focused on using DOM Id's what sort of > convention would you use to translate from the narrative of the step to the > DOM id. > > Would you avoid the brittleness that "clicks submit link|button" has over "I > submit". Thats me arguing that whether its a link or a button, and whether > the user submits by clicking, pressing enter or barking is not relevant to > the scenario. > > 2009/1/21 David Chelimsky >> >> On Wed, Jan 21, 2009 at 9:27 AM, aidy lewis >> wrote: >> > Hi David, >> > On 21/01/2009, David Chelimsky wrote: >> > >> >> text on the button that is deemed to have business value, then you >> >> might say "And I click 'Request Service'" - but if you're referencing >> >> DOM IDs or HTML element names like 'submit', I'd hide those. >> > >> > However we could get a lot of re-use in the user steps if we have >> > step definitions like these: >> > >> > When /^clicks '(+)' link$/ do |text| >> > browser.link(:text, Regexp.new(value)).click >> > end >> > >> > When /^clicks '(+)' button$/ do |text| >> > browser.button(:value, Regexp.new(value)).click >> > end >> > >> > >> > When clicks 'Submit' link >> > When clicks 'Submit' button >> > When clicks 'New' link >> > When clicks 'New' button >> >> The important part of what I was saying was to avoid hidden elements >> (DOM IDs and element names). If the label that is visible in the >> browser says "Submit", then this is OK IMO. >> >> > I personally don't think it is a crime for the tester to change the >> > acceptance steps as long as the 'user' can easily follow the >> > narrative. >> >> Don't worry, you're not under arrest. At least not for this transgression >> :) >> >> > A lot of the other user-steps could be wrapped-up in a more >> > 'declarative' fashion. >> > >> > Aidy >> _______________________________________________ >> 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 Thu Jan 22 06:32:46 2009 From: lists at ruby-forum.com (Zac Zheng) Date: Thu, 22 Jan 2009 12:32:46 +0100 Subject: [rspec-users] How best to write repetitive specs Message-ID: I wanted to test that my mailer models all had the correct headers: subject, to and from fields. I had done this by creating this in my spec_helper.rb: module TestMailerHelpers module ClassMethods def test_basic_headers it "subject" do @email.subject.should_not be_blank end it "to email address(es)" do @email.to.should_not be_blank end it "from email address(es)" do @email.from.should_not be_blank end end end def self.included(receiver) receiver.extend ClassMethods receiver.fixtures :users receiver.fixtures :roles receiver.fixtures :roles_users receiver.fixtures :ports end end I included the above in all my mailer specs, for which there are four, and called the method 'test_basic_headers'. This used to work, even though it looks terribly unDRY. An example of a mailer spec: require File.dirname(__FILE__) + '/../spec_helper' describe UserMailer do include TestMailerHelpers before(:each) do @user = users(:normal) @port = ports(:Alexandria) end describe "activation" do before(:each) do @email = UserMailer.create_activation(@user) end test_basic_headers end # ... end I have two problems. One, I am now receiving 'test_basic_headers' method not found error after upgrading rspec to 1.1.12. UserMailer is not including TestMailerHelpers correctly. Can anyone see why? Problem number two is that I have realised this is do doubt in inefficient way of doing what I want. Can anyone recommend a better way? Much thanks, Zac -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Jan 22 06:40:24 2009 From: lists at ruby-forum.com (Zac Zheng) Date: Thu, 22 Jan 2009 12:40:24 +0100 Subject: [rspec-users] How best to write repetitive specs In-Reply-To: References: Message-ID: <71b330722d83695a04a2911bdb058a0b@ruby-forum.com> How stupid of me! I was looking at the wrong spec file. My 1st problem with no method found has now been solved. If anyone can still recommend a better way of spec'ing these tests, that'd be great. Zac Zheng wrote: > One, I am now receiving 'test_basic_headers' method not found error > after upgrading rspec to 1.1.12. UserMailer is not including > TestMailerHelpers correctly. Can anyone see why? -- Posted via http://www.ruby-forum.com/. From aidy.lewis at googlemail.com Thu Jan 22 06:40:39 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Thu, 22 Jan 2009 11:40:39 +0000 Subject: [rspec-users] =?iso-8859-1?q?=5Bcucumber=5D_Features_with_multipl?= =?iso-8859-1?q?e_user_iterations_=BF=3F?= In-Reply-To: <1126d7ae0901220241l2825b12bq505c190ac68e2488@mail.gmail.com> References: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> <57c63afe0901210540x4f8141eah1eeb89aac34f1f3f@mail.gmail.com> <7ac2300c0901210727x8072331nc3612517f3cc1de0@mail.gmail.com> <57c63afe0901210750t7e4038b1h8d306ecc9df9dcaa@mail.gmail.com> <88fd8ddc0901212106u41f5da00mf7ce21478a46cc70@mail.gmail.com> <1126d7ae0901220241l2825b12bq505c190ac68e2488@mail.gmail.com> Message-ID: <7ac2300c0901220340t53899608kbf8eb7037d16af76@mail.gmail.com> Josh, On 22/01/2009, Josh Chisholm wrote: > > Would you avoid the brittleness that "clicks submit link|button" has over "I submit". > > There are often many ways of submitting on the same page. So to avoid > tying "I submit" to a particular scenario, I tend to use "I click > 'submit'", which doesn't correspond to a link or button specifically, > but to "a link, button, or label with the text 'submit' -- and raise > an error if it's ambiguous". Is that too vague? As a human, if I were > told to "click 'submit'" I think I would apply the same reasoning. > Yes, and in a lot of cases we do choose 'I click submit' with the step implementation searching for a button value or text link: however, the user may specify a link; so I would write 'I click the 'submit' link'. Aidy From zach.dennis at gmail.com Thu Jan 22 07:47:44 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 22 Jan 2009 07:47:44 -0500 Subject: [rspec-users] How best to write repetitive specs In-Reply-To: References: Message-ID: <85d99afe0901220447m7e535c68h273283b424a46db0@mail.gmail.com> On Thu, Jan 22, 2009 at 6:32 AM, Zac Zheng wrote: > I wanted to test that my mailer models all had the correct headers: > subject, to and from fields. > > I had done this by creating this in my spec_helper.rb: > > module TestMailerHelpers > module ClassMethods > def test_basic_headers > it "subject" do > @email.subject.should_not be_blank > end > > it "to email address(es)" do > @email.to.should_not be_blank > end > > it "from email address(es)" do > @email.from.should_not be_blank > end > end > end > > def self.included(receiver) > receiver.extend ClassMethods > receiver.fixtures :users > receiver.fixtures :roles > receiver.fixtures :roles_users > receiver.fixtures :ports > end > end > Check out shared_examples_for: http://rspec.rubyforge.org/rspec/1.1.12/classes/Spec/DSL/Main.html#M000505 shared_examples_for "a standard mailer model" do # ... end I usually put my shared examples in spec/shared_examples/ and then in your actual mailer models you'd add the below line... describe YourMailerModel do it_should_behave_like "a standard mailer model" end > > I included the above in all my mailer specs, for which there are four, > and called the method 'test_basic_headers'. This used to work, even > though it looks terribly unDRY. > > An example of a mailer spec: > > require File.dirname(__FILE__) + '/../spec_helper' > describe UserMailer do > include TestMailerHelpers > > before(:each) do > @user = users(:normal) > @port = ports(:Alexandria) > end > > describe "activation" do > before(:each) do > @email = UserMailer.create_activation(@user) > end > > test_basic_headers > end > # ... > end > > I have two problems. > > One, I am now receiving 'test_basic_headers' method not found error > after upgrading rspec to 1.1.12. UserMailer is not including > TestMailerHelpers correctly. Can anyone see why? > > Problem number two is that I have realised this is do doubt in > inefficient way of doing what I want. Can anyone recommend a better way? > > Much thanks, > Zac > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From lists at ruby-forum.com Thu Jan 22 08:37:33 2009 From: lists at ruby-forum.com (Zac Zheng) Date: Thu, 22 Jan 2009 14:37:33 +0100 Subject: [rspec-users] How best to write repetitive specs In-Reply-To: <85d99afe0901220447m7e535c68h273283b424a46db0@mail.gmail.com> References: <85d99afe0901220447m7e535c68h273283b424a46db0@mail.gmail.com> Message-ID: <9c21c3b72ef00fb795e7a69598bf1b9e@ruby-forum.com> Thanks Zach(great name btw)! I am using it now and it works great. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Jan 22 10:38:31 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 22 Jan 2009 16:38:31 +0100 Subject: [rspec-users] Cucumber ENV setting in env.rb Message-ID: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> I develop in a heterogeneous environment. When I am working with Ruby on Rails on my laptop then I am inside the bash shell of cygwin running under MS-WinXPpro. I also happen to favour a light green on dark green default terminal display. This renders portions of cucumber's output, under its default colour scheme, invisible on both Linux and cygwin. So, I have set up a custom ENV setting in support/env.rb. Thus: ENV["CUCUMBER_COLORS"] = 'passed=white,bold:passed_param=white,bold,underscore' When I run rake features this works exactly as I intended under Linux, but seems to have no effect whatsoever under cygwin. I am working around this by manually setting the session environment variable and I could make this solution permanent by altering my .bashrc script. I nonetheless would like to know why this Ruby setting does not seem to work in all cases. Is there a special syntax for cygwin/windows? Have I missed a step and the fact that Linux turns out as expected simply a coincidence? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Jan 22 14:21:59 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 22 Jan 2009 20:21:59 +0100 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> Message-ID: <735bd5aa60c4e5cae8af6ba0c48abe28@ruby-forum.com> James Byrne wrote: > > When I run rake features this works exactly as I intended under Linux, Evidently not. Setting the ENV inside env.rb does not influence the rake task display at all. It seems that I must set it externally to cucumber to have effect. -- Posted via http://www.ruby-forum.com/. From luislavena at gmail.com Thu Jan 22 14:29:02 2009 From: luislavena at gmail.com (Luis Lavena) Date: Thu, 22 Jan 2009 17:29:02 -0200 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> Message-ID: <71166b3b0901221129jbc91935n2e4c0d08a445b4bd@mail.gmail.com> On Thu, Jan 22, 2009 at 1:38 PM, James Byrne wrote: > I develop in a heterogeneous environment. When I am working with Ruby > on Rails on my laptop then I am inside the bash shell of cygwin running > under MS-WinXPpro. > > I also happen to favour a light green on dark green default terminal > display. This renders portions of cucumber's output, under its default > colour scheme, invisible on both Linux and cygwin. So, I have set up a > custom ENV setting in support/env.rb. Thus: > > ENV["CUCUMBER_COLORS"] = > 'passed=white,bold:passed_param=white,bold,underscore' > > When I run rake features this works exactly as I intended under Linux, > but seems to have no effect whatsoever under cygwin. I am working > around this by manually setting the session environment variable and I > could make this solution permanent by altering my .bashrc script. I > nonetheless would like to know why this Ruby setting does not seem to > work in all cases. Is there a special syntax for cygwin/windows? Have > I missed a step and the fact that Linux turns out as expected simply a > coincidence? Cucumber is already initialized when support/env.rb is loaded. On Windows, cucumber uses win32console to output colors. I cannot comment on cygwin since I'm not a user of the environment. You're mixing cygwin ruby or is native ruby? -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-Exup?ry From apremdas at gmail.com Thu Jan 22 15:09:47 2009 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 22 Jan 2009 20:09:47 +0000 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> Message-ID: <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> I never could get Cygwin to display terminal colors in a consistent way. You'd probably find it easier to install OSX on your laptop! One thing you could do is try and run an XTerm in cygwin perhaps using a minimal window manager like ratpoison. This was the best I was able to manage in getting a decent terminal on windows (Cygwin Ratpoison and Screen), but in the end I gave up it was just to hard :) and inconsistent. 2009/1/22 James Byrne > I develop in a heterogeneous environment. When I am working with Ruby > on Rails on my laptop then I am inside the bash shell of cygwin running > under MS-WinXPpro. > > I also happen to favour a light green on dark green default terminal > display. This renders portions of cucumber's output, under its default > colour scheme, invisible on both Linux and cygwin. So, I have set up a > custom ENV setting in support/env.rb. Thus: > > ENV["CUCUMBER_COLORS"] = > 'passed=white,bold:passed_param=white,bold,underscore' > > When I run rake features this works exactly as I intended under Linux, > but seems to have no effect whatsoever under cygwin. I am working > around this by manually setting the session environment variable and I > could make this solution permanent by altering my .bashrc script. I > nonetheless would like to know why this Ruby setting does not seem to > work in all cases. Is there a special syntax for cygwin/windows? Have > I missed a step and the fact that Linux turns out as expected simply a > coincidence? > -- > 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 luislavena at gmail.com Thu Jan 22 15:34:16 2009 From: luislavena at gmail.com (Luis Lavena) Date: Thu, 22 Jan 2009 18:34:16 -0200 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> Message-ID: <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> On Thu, Jan 22, 2009 at 6:09 PM, Andrew Premdas wrote: > I never could get Cygwin to display terminal colors in a consistent way. > You'd probably find it easier to install OSX on your laptop! > http://rubyonwindows.blogspot.com/2009/01/amen-brother.html > One thing you could do is try and run an XTerm in cygwin perhaps using a > minimal window manager like ratpoison. This was the best I was able to > manage in getting a decent terminal on windows (Cygwin Ratpoison and > Screen), but in the end I gave up it was just to hard :) and inconsistent. > That needs to run a x server to be able to use Xterm... that is way more complicated... James: can you tell us if you're using cygwin ruby or native one? -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-Exup?ry From lists at ruby-forum.com Thu Jan 22 16:15:17 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 22 Jan 2009 22:15:17 +0100 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> Message-ID: <31423f0b48c8520950af4a95957cdf1e@ruby-forum.com> Luis Lavena wrote: > > James: can you tell us if you're using cygwin ruby or native one? > I am not sure. I installed cygwin after I had Ruby on that box. -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Thu Jan 22 17:06:47 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 22 Jan 2009 23:06:47 +0100 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <31423f0b48c8520950af4a95957cdf1e@ruby-forum.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> <31423f0b48c8520950af4a95957cdf1e@ruby-forum.com> Message-ID: <8d961d900901221406m199c24c3q7a622f223279011c@mail.gmail.com> On Thu, Jan 22, 2009 at 10:15 PM, James Byrne wrote: > Luis Lavena wrote: > > > > > James: can you tell us if you're using cygwin ruby or native one? > > > > I am not sure. I installed cygwin after I had Ruby on that box. > Than you have a native one. Run ruby --version to be sure. What does it say? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) -------------- next part -------------- An HTML attachment was scrubbed... URL: From cwdinfo at gmail.com Thu Jan 22 17:51:31 2009 From: cwdinfo at gmail.com (s.ross) Date: Thu, 22 Jan 2009 14:51:31 -0800 Subject: [rspec-users] [Cucumber] Directory Layout Message-ID: <0BBB1863-0228-4D93-BEB5-76E48942744E@gmail.com> I had a relatively flat layout and wanted to group like features together so I made it more hierarchical: features/ messaging/ main_screen.feature message_page.feature steps/ main_screen.rb messaging_steps.rb This may be just my boneheadedness, but when I do: cucumber features/messaging -r features/support/env.rb These run, but none of the steps are matched. It seems the step matchers are not expected to be where I put them. Questions: - Is there a more sensible layout? - Is there an easier way than -r features/support/env.rb to get the machinist plugin to load? Thanks From dchelimsky at gmail.com Thu Jan 22 18:38:25 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 22 Jan 2009 17:38:25 -0600 Subject: [rspec-users] [Cucumber] Directory Layout In-Reply-To: <0BBB1863-0228-4D93-BEB5-76E48942744E@gmail.com> References: <0BBB1863-0228-4D93-BEB5-76E48942744E@gmail.com> Message-ID: <57c63afe0901221538v6e9ff352wae84ca3a18bb7beb@mail.gmail.com> On Thu, Jan 22, 2009 at 4:51 PM, s.ross wrote: > I had a relatively flat layout and wanted to group like features together so > I made it more hierarchical: > > features/ > messaging/ > main_screen.feature > message_page.feature > steps/ > main_screen.rb > messaging_steps.rb > > This may be just my boneheadedness, but when I do: > > cucumber features/messaging -r features/support/env.rb That ONLY loads features/support/env.rb and not any of the step definition files. Try this: cucumber features/messaging -r features > > These run, but none of the steps are matched. It seems the step matchers are > not expected to be where I put them. > > Questions: > > - Is there a more sensible layout? > - Is there an easier way than -r features/support/env.rb to get the > machinist plugin to load? > > Thanks > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cwdinfo at gmail.com Thu Jan 22 19:05:43 2009 From: cwdinfo at gmail.com (s.ross) Date: Thu, 22 Jan 2009 16:05:43 -0800 Subject: [rspec-users] [Cucumber] Directory Layout In-Reply-To: <57c63afe0901221538v6e9ff352wae84ca3a18bb7beb@mail.gmail.com> References: <0BBB1863-0228-4D93-BEB5-76E48942744E@gmail.com> <57c63afe0901221538v6e9ff352wae84ca3a18bb7beb@mail.gmail.com> Message-ID: <8861DEAC-8E67-4861-8D59-34AE89409DE2@gmail.com> On Jan 22, 2009, at 3:38 PM, David Chelimsky wrote: > On Thu, Jan 22, 2009 at 4:51 PM, s.ross wrote: >> I had a relatively flat layout and wanted to group like features >> together so >> I made it more hierarchical: >> >> features/ >> messaging/ >> main_screen.feature >> message_page.feature >> steps/ >> main_screen.rb >> messaging_steps.rb >> >> This may be just my boneheadedness, but when I do: >> >> cucumber features/messaging -r features/support/env.rb > > That ONLY loads features/support/env.rb and not any of the step > definition files. Try this: > > cucumber features/messaging -r features > >> >> These run, but none of the steps are matched. It seems the step >> matchers are >> not expected to be where I put them. >> >> Questions: >> >> - Is there a more sensible layout? >> - Is there an easier way than -r features/support/env.rb to get the >> machinist plugin to load? >> >> Thanks >> Yup. That was it. Thanks! From aslak.hellesoy at gmail.com Thu Jan 22 19:57:54 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 23 Jan 2009 01:57:54 +0100 Subject: [rspec-users] [Cucumber] Directory Layout In-Reply-To: <8861DEAC-8E67-4861-8D59-34AE89409DE2@gmail.com> References: <0BBB1863-0228-4D93-BEB5-76E48942744E@gmail.com> <57c63afe0901221538v6e9ff352wae84ca3a18bb7beb@mail.gmail.com> <8861DEAC-8E67-4861-8D59-34AE89409DE2@gmail.com> Message-ID: <8d961d900901221657q1724aef3h931b3a0c0978700f@mail.gmail.com> On Fri, Jan 23, 2009 at 1:05 AM, s.ross wrote: > On Jan 22, 2009, at 3:38 PM, David Chelimsky wrote: > > On Thu, Jan 22, 2009 at 4:51 PM, s.ross wrote: >> >>> I had a relatively flat layout and wanted to group like features together >>> so >>> I made it more hierarchical: >>> >>> features/ >>> messaging/ >>> main_screen.feature >>> message_page.feature >>> steps/ >>> main_screen.rb >>> messaging_steps.rb >>> >>> This may be just my boneheadedness, but when I do: >>> >>> cucumber features/messaging -r features/support/env.rb >>> >> >> That ONLY loads features/support/env.rb and not any of the step >> definition files. Try this: >> >> cucumber features/messaging -r features >> >> >>> These run, but none of the steps are matched. It seems the step matchers >>> are >>> not expected to be where I put them. >>> >>> Questions: >>> >>> - Is there a more sensible layout? >>> - Is there an easier way than -r features/support/env.rb to get the >>> machinist plugin to load? >>> >>> Thanks >>> >>> > Yup. That was it. Thanks! > Just to clarify.. If you pass *no* --require switches to cucumber, it will guess where to find .rb files to load If you pass one or more it will stop guessing Aslak > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) -------------- next part -------------- An HTML attachment was scrubbed... URL: From joe at pinkpucker.net Thu Jan 22 21:46:27 2009 From: joe at pinkpucker.net (Joe Van Dyk) Date: Thu, 22 Jan 2009 18:46:27 -0800 Subject: [rspec-users] testing javascript-heavy websites Message-ID: We're starting to work on some javascript-heavy websites, and even some flash/flex based ones as well. What's the current hotness in automatically testing those types of websites? Does cucumber hook up to selenium now? I thought I saw that webrat did. Any recommended resources? Joe From ben at benmabey.com Thu Jan 22 22:06:40 2009 From: ben at benmabey.com (Ben Mabey) Date: Thu, 22 Jan 2009 20:06:40 -0700 Subject: [rspec-users] testing javascript-heavy websites In-Reply-To: References: Message-ID: <49793440.8040400@benmabey.com> On 1/22/09 7:46 PM, Joe Van Dyk wrote: > We're starting to work on some javascript-heavy websites, and even > some flash/flex based ones as well. > For flex see: http://wiki.github.com/aslakhellesoy/cucumber/funfx-and-flex > What's the current hotness in automatically testing those types of > websites? Does cucumber hook up to selenium now? I thought I saw > that webrat did. > For JS you can use webrat with Cucumber to drive selenium. See the webrat docs for more info. You can use Watir or Celerity with Cucumber. There is a screencast on using Cucumber with Watir on cukes.info. HTH, Ben From pergesu at gmail.com Thu Jan 22 22:19:23 2009 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 22 Jan 2009 19:19:23 -0800 Subject: [rspec-users] testing javascript-heavy websites In-Reply-To: References: Message-ID: <810a540e0901221919t5e2f8f04heffd217ee4f668c5@mail.gmail.com> On Thu, Jan 22, 2009 at 6:46 PM, Joe Van Dyk wrote: > We're starting to work on some javascript-heavy websites, and even > some flash/flex based ones as well. > > What's the current hotness in automatically testing those types of > websites? Does cucumber hook up to selenium now? I thought I saw > that webrat did. > > Any recommended resources? Yes you can use cucumber/webrat/selenium. I have had some trouble with ajax-heavy stuff but never took the time to sort it out. For testing JS directly, I use Screw.Unit Pat From lists at ruby-forum.com Thu Jan 22 22:26:46 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 23 Jan 2009 04:26:46 +0100 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <8d961d900901221406m199c24c3q7a622f223279011c@mail.gmail.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> <31423f0b48c8520950af4a95957cdf1e@ruby-forum.com> <8d961d900901221406m199c24c3q7a622f223279011c@mail.gmail.com> Message-ID: <587af765943665bd9ef26b1ae67dede6@ruby-forum.com> Aslak Helles?y wrote: > On Thu, Jan 22, 2009 at 10:15 PM, > >> Luis Lavena wrote: >> >> > >> > James: can you tell us if you're using cygwin ruby or native one? >> > >> >> I am not sure. I installed cygwin after I had Ruby on that box. >> > > Than you have a native one. Run ruby --version to be sure. What does it > say? byrnejb at HAL-M13 ~ $ruby --version ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin] Sorry for the delay in my reply. JBB -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Fri Jan 23 03:49:05 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 23 Jan 2009 09:49:05 +0100 Subject: [rspec-users] Reorganize documentation for Cucumber at Github In-Reply-To: <8d961d900901171724w5f339fedn110f9431bb6dc722@mail.gmail.com> References: <4972493F.5000408@comcast.net> <8d961d900901171634s5500e7f5oec8347a4816e432d@mail.gmail.com> <8d961d900901171724w5f339fedn110f9431bb6dc722@mail.gmail.com> Message-ID: <8d961d900901230049m1a33e159m17b0e3c33449fb5@mail.gmail.com> On Sun, Jan 18, 2009 at 2:24 AM, aslak hellesoy wrote: > > > On Sun, Jan 18, 2009 at 1:34 AM, aslak hellesoy wrote: > >> >> >> On Sat, Jan 17, 2009 at 10:10 PM, Tom Cloyd wrote: >> >>> Fernando Perez wrote: >>> >>>> Hi, >>>> >>>> I actually just noticed that Cucumber has plenty good documentation on >>>> its wiki at github. But the problems are: >>>> >>>> - The homepage is badly designed as it doesn't really outline an order >>>> to read other pages >>>> - It is impossible to make the difference between internal links to the >>>> wiki and links that will bring us some where else unless we hover over >>>> the link >>>> - Pages don't link to each other such as: read next page or previous >>>> page, or related pages >>>> - Pages are just sorted alphabetically which is not a proper way of >>>> sorting >>>> >>>> Would it be possible to at least number the pages in the order in which >>>> we should read as if we were reading a book about cucumber? >>>> >>>> The documentation seems excellent but is definitely not well marketed >>>> for new comers :) >>>> >>>> >>> Oh, I totally agree. Add in the fact that the Rails stuff is just a mess >>> for non-Rails people to read, and we really have two problems to solve. >>> That's how I, at least, have been experiencing it. >>> >>> My own solution is to build my own procedural outline. I'm working on it >>> today, in fact - sort of a "Cucumber for dummies" document. In my >>> conception, liberal use will be made of links to existing pages, or to >>> sections thereof, as there's no need to attempt to redo what the experts >>> have already done well. I figure if I write what I wish I'd encountered when >>> I went to the wiki, and then see if I can get it there, it might help other >>> folks. >>> >>> Your final sentence says it all - great documentation, but not for >>> newbies. Where's the starting point? Etc. >>> >> >> Where is the starting point! There is none! Haha. And the GitHub Wiki Home >> page is probably the worst page in the whole Wiki. >> >> Honestly - I think what's needed is: >> >> 1) Move a lot of the random stuff from Home to separate pages >> 2) Make the Home page really short - with links to a few new pages: >> >> * General Five Minute Introduction (Pure Cucumber/Ruby stuff - no Rails) - >> Narrative, sequential style, link to other specific pages - ideally most of >> them. >> * Rails-specific Five Minute Introduction (to be read after the other 5 >> minute one). Cucumber Backgrounder is a very good start for this, but I >> think it's a little rambling :-) >> >> I'd like to write these intros myself, so please don't start doing massive >> edits. Instead, I'd love to get input of an outline for these Introduction >> pages. >> >> How does that sound? >> > > Ok, I'll give a stab at what a 5 minute introduction might contain. Please > comment. > > 1) Who should use Cucumber, and what benefits can you get from it? > 2) How Cucumber works (high level explanation without getting too > technical). > 3) Learn the nomenclature - features, scenarios, steps (step definitions > later). Some style guidlines. > 4) What does a Cucumber feature look like (plain - no outlines or tables). > Learn how to write one in a simple text editor. > 5) How to install and run Cucumber (using the one from 3 as example. No > Rake yet - just the cucumber command) > 6) What does the output from Cucumber mean? (Learn to read the deafault > console output. Colours and error messages. Mention other formatters) > 7) Learn to write step definitions (they are similar to defining methods in > most imperative languages like Ruby, Java, C, Pascal....). Mention Regexps, > Rubular.com. > 8) How to implement the body of a step definition. Learn about RSpec's > #should and #should_not - and matchers > 9) How to fix a failing (red) step definition by writing some code (in lib > for now since we're not doing any Rails) > 10) Mention DTSTTCPW and refactoring - with some external links. TDD > basics. > 11) Learn how to use Rake (useful when you have more than one feature > file). Mention RCov. > 12) Learn about the various command-line switches > 13) Learn about more advanced Gherkin (Cucumber language) features such as > Tables, PyString, Scenario Outlines and Background (coming soon) > 13.5) Learn about how to substitute in steps and multiline args (table, pystring) from examples tables. > > 14) Learn about hooks (Before, After etc) > 15) Various other features (CUCUMBER_COLORS, AutoTest, cucumber.yml > (profiles) > 16) IDE support > 17) How to use other assertion tools like Test::Unit, Shoulda, etc. > 18) How to use Cukes with non-Ruby platforms (Watir family, JRuby, > IronRuby, FunFX/Flex) > 18.5) Pure Java via JBehave > > The reader will gradually learn about the recommended file layout > structure. > > Maybe this is more like a 10-15 minute intro. I'll try to keep it as short > as possible without skipping important concepts. > > What's missing? What's in the wrong order? What should I remove? > > Aslak > > >> Aslak >> >> >>> I'm working on this thing right now, and maybe it'll be far enough along >>> for some kind of review this weekend. Or...I could put it up, say on a >>> Google Sites wiki, and several of us could work on it. Any thoughts? I >>> actually prefer to work in a group, but have already started on my own. >>> >>> Yeah, I like that idea - a temporary Google Sites wiki. >>> >>> Tom >>> >>> >>> >>> >>> -- >>> >>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist >>> Bellingham, Washington, U.S.A: (360) 920-1226 >>> << tc at tomcloyd.com >> (email) >>> << TomCloyd.com >> (website) << sleightmind.wordpress.com >> (mental >>> health weblog) >>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> >> >> -- >> Aslak (::) >> > > > > -- > Aslak (::) > -- Aslak (::) -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Fri Jan 23 05:47:15 2009 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 23 Jan 2009 10:47:15 +0000 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> Message-ID: <88fd8ddc0901230247p2fe65beh3a5805094a6bad@mail.gmail.com> Luis Not quite sure that your criticism is of my post is justified. At no point did I say that James should give up on Windows nor give up on Cygwin, only that it is very difficult to get the terminal colors to work exactly how you want in that environment. This is based on considerable experience trying to do precisely this. Nor am I saying that people should not use Windows for Rails or that you cannot have an effective Rails setup with Windows. What I am saying is that having an effective Unix command prompt in Windows that you can control with as much precision as in linux or OSX is very difficult under Windows. If you want to do this (and I really did want to do this) then the XTerm approach was more effective at trying to control terminal colors consistently in comparison to manipulating the standard cygwin terminal. But whatever you do you will probably have to compromise somewhat your terminal experience in comparison to a proper nix. Andrew 2009/1/22 Luis Lavena > On Thu, Jan 22, 2009 at 6:09 PM, Andrew Premdas > wrote: > > I never could get Cygwin to display terminal colors in a consistent way. > > You'd probably find it easier to install OSX on your laptop! > > > > http://rubyonwindows.blogspot.com/2009/01/amen-brother.html > > > One thing you could do is try and run an XTerm in cygwin perhaps using a > > minimal window manager like ratpoison. This was the best I was able to > > manage in getting a decent terminal on windows (Cygwin Ratpoison and > > Screen), but in the end I gave up it was just to hard :) and > inconsistent. > > > > That needs to run a x server to be able to use Xterm... that is way > more complicated... > > James: can you tell us if you're using cygwin ruby or native one? > > -- > Luis Lavena > AREA 17 > - > Perfection in design is achieved not when there is nothing more to add, > but rather when there is nothing more to take away. > Antoine de Saint-Exup?ry > _______________________________________________ > 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 aidy.lewis at googlemail.com Fri Jan 23 06:14:11 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Fri, 23 Jan 2009 11:14:11 +0000 Subject: [rspec-users] Reorganize documentation for Cucumber at Github In-Reply-To: <8d961d900901230049m1a33e159m17b0e3c33449fb5@mail.gmail.com> References: <4972493F.5000408@comcast.net> <8d961d900901171634s5500e7f5oec8347a4816e432d@mail.gmail.com> <8d961d900901171724w5f339fedn110f9431bb6dc722@mail.gmail.com> <8d961d900901230049m1a33e159m17b0e3c33449fb5@mail.gmail.com> Message-ID: <7ac2300c0901230314l61b5d3far1f05067a74787939@mail.gmail.com> Hi On 23/01/2009, aslak hellesoy wrote: > > 18) How to use Cukes with non-Ruby platforms (Watir family, .... I will gladly put something together on Cucumber and Watir. Aidy From aslak.hellesoy at gmail.com Fri Jan 23 06:23:50 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 23 Jan 2009 12:23:50 +0100 Subject: [rspec-users] Reorganize documentation for Cucumber at Github In-Reply-To: <7ac2300c0901230314l61b5d3far1f05067a74787939@mail.gmail.com> References: <4972493F.5000408@comcast.net> <8d961d900901171634s5500e7f5oec8347a4816e432d@mail.gmail.com> <8d961d900901171724w5f339fedn110f9431bb6dc722@mail.gmail.com> <8d961d900901230049m1a33e159m17b0e3c33449fb5@mail.gmail.com> <7ac2300c0901230314l61b5d3far1f05067a74787939@mail.gmail.com> Message-ID: <8d961d900901230323w22552e90y3970960be1362fc6@mail.gmail.com> On Fri, Jan 23, 2009 at 12:14 PM, aidy lewis wrote: > Hi > On 23/01/2009, aslak hellesoy wrote: > > > > 18) How to use Cukes with non-Ruby platforms (Watir family, .... > > I will gladly put something together on Cucumber and Watir. > Be my guest! Please also link to the Watir examples in the sources at GitHub Aslak > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) -------------- next part -------------- An HTML attachment was scrubbed... URL: From joshuachisholm at gmail.com Fri Jan 23 08:55:27 2009 From: joshuachisholm at gmail.com (Josh Chisholm) Date: Fri, 23 Jan 2009 13:55:27 +0000 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <735bd5aa60c4e5cae8af6ba0c48abe28@ruby-forum.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <735bd5aa60c4e5cae8af6ba0c48abe28@ruby-forum.com> Message-ID: <1126d7ae0901230555u5b3fd639q7b5edd4634874631@mail.gmail.com> We are setting environment variables in our Rakefile. We have various tasks that set up environment variables, then call the cucumber task. That's working for us under windows. On Thu, Jan 22, 2009 at 7:21 PM, James Byrne wrote: > James Byrne wrote: > >> >> When I run rake features this works exactly as I intended under Linux, > > Evidently not. Setting the ENV inside env.rb does not influence the > rake task display at all. It seems that I must set it externally to > cucumber to have effect. > > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Fri Jan 23 09:20:42 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 23 Jan 2009 15:20:42 +0100 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <587af765943665bd9ef26b1ae67dede6@ruby-forum.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> <31423f0b48c8520950af4a95957cdf1e@ruby-forum.com> <8d961d900901221406m199c24c3q7a622f223279011c@mail.gmail.com> <587af765943665bd9ef26b1ae67dede6@ruby-forum.com> Message-ID: <6c08411215424ef9a2fd442c66a5ebe9@ruby-forum.com> My original observation wrt this problem was inaccurate. The same behaviour is evidenced in both my Linux and cygwin environments. Setting the environment variable "CUCUMBER_COLORS" in support/env.rb run does not alter the behaviour of that run. As one expects, any environment variable set within a process will not persist after that process terminates. I lack the experience in either OS to say whether or not doing so should affect the setting process itself or only those processes spawned by that parent after the setting of the variable. I gathered from the cucumber documentation that the writer expected that setting the environment in env.rb SHOULD have some effect. However, I cannot say if that expectation was valid or not. I am not experiencing any problems with displaying colours or text enhancements (within the limited ANSI palette) in either environment. -- Posted via http://www.ruby-forum.com/. From luislavena at gmail.com Fri Jan 23 09:25:14 2009 From: luislavena at gmail.com (Luis Lavena) Date: Fri, 23 Jan 2009 12:25:14 -0200 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <88fd8ddc0901230247p2fe65beh3a5805094a6bad@mail.gmail.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> <88fd8ddc0901230247p2fe65beh3a5805094a6bad@mail.gmail.com> Message-ID: <71166b3b0901230625s48954f40l837e28b19ada5539@mail.gmail.com> On Fri, Jan 23, 2009 at 8:47 AM, Andrew Premdas wrote: > Luis > > Not quite sure that your criticism is of my post is justified. At no point > did I say that James should give up on Windows nor give up on Cygwin, only > that it is very difficult to get the terminal colors to work exactly how you > want in that environment. This is based on considerable experience trying to > do precisely this. Nor am I saying that people should not use Windows for > Rails or that you cannot have an effective Rails setup with Windows. You forgot to put a smiley icon along your statement that install OSX ;-) > What I am saying is that having an effective Unix command prompt in Windows > that you can control with as much precision as in linux or OSX is very > difficult under Windows. If you want to do this (and I really did want to do > this) then the XTerm approach was more effective at trying to control > terminal colors consistently in comparison to manipulating the standard > cygwin terminal. But whatever you do you will probably have to compromise > somewhat your terminal experience in comparison to a proper nix. I cannot comment too much on cygwin experince, since only used it for short amount of time and with rxvt. In my experience, I've only used bash directly which provided syntax coloring without issues. Now, the thing is that I'm talking about MSYS bash, no cygwin, so dunno how that will work. XTerm, while it provided a workaround to the problem, and worked as solution, imposes another requirement for users to use it (you need to adapt to something different can also not work with other tools). The nature of console in Windows is far from ideal, but that applies to native Ruby on Windows Cygwin Ruby should behave much like *nix, with ansi colors and all that. As other users commented, setting environment variables is not a problem on native Windows (I use and abuse of that in a daily basis). But again, dunno what happens in cygwin island. > > Andrew > > > > > 2009/1/22 Luis Lavena >> >> On Thu, Jan 22, 2009 at 6:09 PM, Andrew Premdas >> wrote: >> > I never could get Cygwin to display terminal colors in a consistent way. >> > You'd probably find it easier to install OSX on your laptop! >> > >> >> http://rubyonwindows.blogspot.com/2009/01/amen-brother.html >> >> > One thing you could do is try and run an XTerm in cygwin perhaps using a >> > minimal window manager like ratpoison. This was the best I was able to >> > manage in getting a decent terminal on windows (Cygwin Ratpoison and >> > Screen), but in the end I gave up it was just to hard :) and >> > inconsistent. >> > >> >> That needs to run a x server to be able to use Xterm... that is way >> more complicated... >> >> James: can you tell us if you're using cygwin ruby or native one? >> >> -- >> Luis Lavena >> AREA 17 >> - >> Perfection in design is achieved not when there is nothing more to add, >> but rather when there is nothing more to take away. >> Antoine de Saint-Exup?ry >> _______________________________________________ >> 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 > -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-Exup?ry From aslak.hellesoy at gmail.com Fri Jan 23 09:34:08 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 23 Jan 2009 15:34:08 +0100 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <6c08411215424ef9a2fd442c66a5ebe9@ruby-forum.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> <31423f0b48c8520950af4a95957cdf1e@ruby-forum.com> <8d961d900901221406m199c24c3q7a622f223279011c@mail.gmail.com> <587af765943665bd9ef26b1ae67dede6@ruby-forum.com> <6c08411215424ef9a2fd442c66a5ebe9@ruby-forum.com> Message-ID: <8d961d900901230634o5a862be4u1577c4a1313265a7@mail.gmail.com> On Fri, Jan 23, 2009 at 3:20 PM, James Byrne wrote: > My original observation wrt this problem was inaccurate. The same > behaviour is evidenced in both my Linux and cygwin environments. > Setting the environment variable "CUCUMBER_COLORS" in support/env.rb run > does not alter the behaviour of that run. > Updated docs: http://wiki.github.com/aslakhellesoy/cucumber/console-colours > > As one expects, any environment variable set within a process will not > persist after that process terminates. I lack the experience in either > OS to say whether or not doing so should affect the setting process > itself or only those processes spawned by that parent after the setting > of the variable. > > I gathered from the cucumber documentation that the writer expected that > setting the environment in env.rb SHOULD have some effect. However, I > cannot say if that expectation was valid or not. > > I am not experiencing any problems with displaying colours or text > enhancements (within the limited ANSI palette) in either environment. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Fri Jan 23 09:40:27 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 23 Jan 2009 15:40:27 +0100 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <1126d7ae0901230555u5b3fd639q7b5edd4634874631@mail.gmail.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <735bd5aa60c4e5cae8af6ba0c48abe28@ruby-forum.com> <1126d7ae0901230555u5b3fd639q7b5edd4634874631@mail.gmail.com> Message-ID: <7d868051da352d18aab23041949143c9@ruby-forum.com> Josh Chisholm wrote: > We are setting environment variables in our Rakefile. We have various > tasks that set up environment variables, then call the cucumber task. > That's working for us under windows. Yes that makes sense. Referring to the Pickaxe book one reads that: "A Ruby program may write to the ENV object, which on most systems changes the values of the corresponding environment variables. However, this change is local to the process that makes it and to any subsequently spawned child processes. This inheritance of environment variables is illustrated in the code that follows. A subprocess changes an environment variable and this change is seen in a process that it then starts. However, the change is not visible to the original parent. (This just goes to prove that parents never really know what their children are doing.)" This does seem to indicate that the ENV setting made in in env.rb is visible to the cucumber process. The inference that I draw from this is that env.rb is processed after the ENV setting for "CUCUMBER_COLORS" has already been used by cucumber and thus has no further effect on its behaviour. -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Fri Jan 23 10:16:18 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 23 Jan 2009 16:16:18 +0100 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <7d868051da352d18aab23041949143c9@ruby-forum.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <735bd5aa60c4e5cae8af6ba0c48abe28@ruby-forum.com> <1126d7ae0901230555u5b3fd639q7b5edd4634874631@mail.gmail.com> <7d868051da352d18aab23041949143c9@ruby-forum.com> Message-ID: <8d961d900901230716x1b9e4f3br225468a5e33c9a2c@mail.gmail.com> On Fri, Jan 23, 2009 at 3:40 PM, James Byrne wrote: > Josh Chisholm wrote: > > We are setting environment variables in our Rakefile. We have various > > tasks that set up environment variables, then call the cucumber task. > > That's working for us under windows. > > Yes that makes sense. Referring to the Pickaxe book one reads that: > > "A Ruby program may write to the ENV object, which on most systems > changes the values of the corresponding environment variables. However, > this change is local to the process that makes it and to any > subsequently spawned child processes. This inheritance of environment > variables is illustrated in the code that follows. A subprocess changes > an environment variable and this change is seen in a process that it > then starts. However, the change is not visible to the original parent. > (This just goes to prove that parents never really know what their > children are doing.)" > > This does seem to indicate that the ENV setting made in in env.rb is > visible to the cucumber process. The inference that I draw from this is > that env.rb is processed after the ENV setting for "CUCUMBER_COLORS" has > already been used by cucumber and thus has no further effect on its > behaviour. That is correct: http://github.com/aslakhellesoy/cucumber/blob/cee08ca63fd2d234aacc231d5be342bb6fba06bc/lib/cucumber/formatters/ansicolor.rb (BTW, this is the ugliest code in Cucumber) Aslak > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Fri Jan 23 12:04:16 2009 From: ben at benmabey.com (Ben Mabey) Date: Fri, 23 Jan 2009 10:04:16 -0700 Subject: [rspec-users] [Cucumber, BDD] When not to use Cucumber? Message-ID: <4979F890.8000608@benmabey.com> Hi all, Just wanted to get some feedback and opinions on something... I have been using Cucumber/Story Runner since plaintext support was introduced. (So, since October/November of 2007.) Throughout this time I have used it on various projects. Some projects had customer involvement in help writing the scenarios, some I mostly wrote the scenarios after gathering requirements and then got verification from the customer, and others involved no customer at all (i.e. I was the customer). In all three cases I have gotten a lot of benefit from the upfront analysis that writing the feature forces you to do and the outside-in development that follows. That said, the business analysis and outside-in development can be accomplished with any tool (i.e. rspec with webrat for webapps). In the past I have always defaulted on using the GWT (Given, When, Then) syntax for most of my acceptance tests, but that may be because I am so accustomed to that workflow by now. So... I'm curious what people's thoughts are. When writing acceptance tests how do you choose which tool is best for the job? I often hear people complaining about the GWT syntax and they see no benefit of it over the frameworks that provide contexts (i.e rspec, shoulda, etc).[1] In what cases, if any, do you think the GWT gets in the way and how? In particular, if you are writing an app or lib whose customers/users are all developers do you still think there is value in the GWT syntax that Cucumber provides? I have my own thoughts on the matter, but in playing devil's advocate I want to get other people's thoughts before I skew you with mine. :) Thanks, Ben [1] http://www.dcmanges.com/blog/practicality-of-the-rspec-story-runner From lists at ruby-forum.com Fri Jan 23 12:15:49 2009 From: lists at ruby-forum.com (Pau Cor) Date: Fri, 23 Jan 2009 18:15:49 +0100 Subject: [rspec-users] testing javascript-heavy websites In-Reply-To: <810a540e0901221919t5e2f8f04heffd217ee4f668c5@mail.gmail.com> References: <810a540e0901221919t5e2f8f04heffd217ee4f668c5@mail.gmail.com> Message-ID: <080ecafd6e56311809ba500097bb4717@ruby-forum.com> > I have had some trouble > with ajax-heavy stuff but never took the time to sort it out. I had some trouble too at first. Some things that seem like they _should_ work just don't. But I seem to have gotten past it. If anyone has a specific problem post here, and I'll give it a try :) Or you can email me directly: paul (at) thoughtless --I hate spam-- (dot) ca -- Posted via http://www.ruby-forum.com/. From apremdas at gmail.com Fri Jan 23 13:29:26 2009 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 23 Jan 2009 18:29:26 +0000 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <6c08411215424ef9a2fd442c66a5ebe9@ruby-forum.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> <31423f0b48c8520950af4a95957cdf1e@ruby-forum.com> <8d961d900901221406m199c24c3q7a622f223279011c@mail.gmail.com> <587af765943665bd9ef26b1ae67dede6@ruby-forum.com> <6c08411215424ef9a2fd442c66a5ebe9@ruby-forum.com> Message-ID: <88fd8ddc0901231029k41f535cv89b877fa77d28901@mail.gmail.com> Have you tried setting the CUCUMBER_COLORS environment variable in your bash config on cygwin? 2009/1/23 James Byrne > My original observation wrt this problem was inaccurate. The same > behaviour is evidenced in both my Linux and cygwin environments. > Setting the environment variable "CUCUMBER_COLORS" in support/env.rb run > does not alter the behaviour of that run. > > As one expects, any environment variable set within a process will not > persist after that process terminates. I lack the experience in either > OS to say whether or not doing so should affect the setting process > itself or only those processes spawned by that parent after the setting > of the variable. > > I gathered from the cucumber documentation that the writer expected that > setting the environment in env.rb SHOULD have some effect. However, I > cannot say if that expectation was valid or not. > > I am not experiencing any problems with displaying colours or text > enhancements (within the limited ANSI palette) in either environment. > -- > 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 Fri Jan 23 15:07:20 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 23 Jan 2009 21:07:20 +0100 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <88fd8ddc0901231029k41f535cv89b877fa77d28901@mail.gmail.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> <31423f0b48c8520950af4a95957cdf1e@ruby-forum.com> <8d961d900901221406m199c24c3q7a622f223279011c@mail.gmail.com> <587af765943665bd9ef26b1ae67dede6@ruby-forum.com> <6c08411215424ef9a2fd442c66a5ebe9@ruby-forum.com> <88fd8ddc0901231029k41f535cv89b877fa77d28901@mail.gmail.com> Message-ID: <1644b8bcb8fc26a52c3afec443b2e039@ruby-forum.com> Andrew Premdas wrote: > Have you tried setting the CUCUMBER_COLORS environment variable in your > bash config on cygwin? James Byrne wrote: > I am working around this by manually setting the session environment > variable and I could make this solution permanent by altering > my .bashrc script. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Jan 23 15:46:05 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 23 Jan 2009 21:46:05 +0100 Subject: [rspec-users] [Cucumber, BDD] When not to use Cucumber? In-Reply-To: <4979F890.8000608@benmabey.com> References: <4979F890.8000608@benmabey.com> Message-ID: <6f81634f599b13345ced41074daceaa9@ruby-forum.com> Ben Mabey wrote: > > So... I'm curious what people's thoughts are. When writing acceptance > tests how do you choose which tool is best for the job? I often hear > people complaining about the GWT syntax and they see no benefit of it > over the frameworks that provide contexts (i.e rspec, shoulda, etc).[1] > In what cases, if any, do you think the GWT gets in the way and how? In > particular, if you are writing an app or lib whose customers/users are > all developers do you still think there is value in the GWT syntax that > Cucumber provides? > My own experience is quite limited, but I did start out trying to get what I desired done through TestUnit, then RSpec, then RSpec Story Runner and finally Cucumber. In the end it was Cucumber that clarified my approach for me, mainly by clearing away all (or at least most) of the nitty gritty details of configuring and using the tool itself. I found that, coming from a non OO programming background, that the degree of mastery required of the other tools mentioned, together with the effort I had to make to get the tool to behave as I wished (desires that were often malformed by lack of understanding in any case), distracted considerably from the task at hand, programming the application. I have progressed on my current project far, far more since discovering Cucumber this past November than in all the time before. The bifurcation between what and how seems far more natural to me with the Cucumber features/step definitions file split than with the unified expectation method/test steps of RSpec and the test method/assert statements of TestUnit. Cucumber feature files just seem to permit one to concentrate solely on "what" in the one case and then, with the separate step definitions file, deal with the "how" in the other, without crossing the line between the two. Given, When and Then seemed contrived and far too stiff to me to begin with. However, I discovered that much of my initial discomfort arose from too vague a conception of what is was that was desired. The benefit of GWT stylistic conventions is that it really does make one consider deeply where one is starting from, what one is actually trying to accomplish, and how, exactly, does one tell if it has been accomplished. If this sort of self-analysis is so ingrained that one need not think of it then GWT probably does not provide a measurable benefit. So, perhaps deeply experienced developers and programmers might not get as much from it as I have. On the other hand, I have frequently discovered in myself a lamentable tendency to believe that I understood what a problem was simply because I wanted to believe and not because of any demonstrable evidence to that effect. Sitting down and writing out what you believe to be the truth often reveals the flaws in ones assumptions. The GWT litany seems to provide a very useful, if formulaic, examination of exactly what one is setting out to accomplish thereby sometimes raising the question of why it needs to be done at all. I find that it thereby clears away much that is irrelevant to the question at hand. I also hold to the opinion that when writing an end user application the only testing that can be consider definitive is what is described as integration or acceptance testing. I accept that there are pragmatic reasons why, because of limited time and equipment resources, unit and functional tests are viewed as attractive alternatives. But, that should not blind one the the fact that they really are alternatives, chosen because of environmental considerations and not because of inherent superiority. The only test that means anything to an end user is one that shows the application works as intended in the environment it is deployed to. Libraries and utilities have a different audience and their testing is perhaps better handled solely in unit and functional tests, but I cannot say so with any conviction. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Jan 23 17:24:49 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Fri, 23 Jan 2009 23:24:49 +0100 Subject: [rspec-users] [Cucumber, BDD] When not to use Cucumber? In-Reply-To: <6f81634f599b13345ced41074daceaa9@ruby-forum.com> References: <4979F890.8000608@benmabey.com> <6f81634f599b13345ced41074daceaa9@ruby-forum.com> Message-ID: <85d749698fd100ede5b31391ecf43be7@ruby-forum.com> > My own experience is quite limited, [...] Hi James, are you saying that you only use Cucumber and not RSpec at all? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Jan 23 17:45:23 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 23 Jan 2009 23:45:23 +0100 Subject: [rspec-users] [Cucumber, BDD] When not to use Cucumber? In-Reply-To: <85d749698fd100ede5b31391ecf43be7@ruby-forum.com> References: <4979F890.8000608@benmabey.com> <6f81634f599b13345ced41074daceaa9@ruby-forum.com> <85d749698fd100ede5b31391ecf43be7@ruby-forum.com> Message-ID: <0e4dc8620551b0e11d50ef1cbb18827b@ruby-forum.com> Fernando Perez wrote: >> My own experience is quite limited, [...] > > Hi James, are you saying that you only use Cucumber and not RSpec at > all? No, I do use RSpec and TestUnit for that matter, but not to any extent at the present time. I find that cucumber features are much more conducive to driving out the design than RSpec expectations. Once the essence of the application is laid out and working then, if necessary, I will consider adding more technical type expectations via RSpec. Frankly, at the moment, I do not see a compelling case to move from step definitions into formal RSpec expectations. Again, my experience in these matters is limited and perhaps as it grows my appreciations will change as well. I do note however, that once one finds a tool that suits ones needs then it is somewhat inefficient to use another without some compelling advantage to be gained. What advantage does formal RSpec constructions provide over cucumber step definitions using RSpec and RSpec-Rails methods? -- Posted via http://www.ruby-forum.com/. From nick at deadorange.com Fri Jan 23 18:03:12 2009 From: nick at deadorange.com (Nick Hoffman) Date: Fri, 23 Jan 2009 18:03:12 -0500 Subject: [rspec-users] [Cucumber, BDD] When not to use Cucumber? In-Reply-To: <4979F890.8000608@benmabey.com> References: <4979F890.8000608@benmabey.com> Message-ID: <8373493B-A693-4797-8F71-6F75A9B6F419@deadorange.com> On 23/01/2009, at 12:04 PM, Ben Mabey wrote: > So... I'm curious what people's thoughts are. When writing > acceptance tests how do you choose which tool is best for the job? > I often hear people complaining about the GWT syntax and they see no > benefit of it over the frameworks that provide contexts (i.e rspec, > shoulda, etc).[1] In what cases, if any, do you think the GWT gets > in the way and how? In particular, if you are writing an app or lib > whose customers/users are all developers do you still think there is > value in the GWT syntax that Cucumber provides? I've been using RSpec since July, and love it. For the last few months, I've been reading most of the Cucumber posts on this list. Last week, I thought I'd give Cucumber a try. It feels like a really fantastic tool for determining business requirements, functionality, etc. From what I can tell though, there seems to be a lot of overlap between RSpec specs, and Cucumber features and stories. For that reason, I haven't delved much further into Cucumber, because I don't want to be repeating myself, and having to update two sets of files whenever I make a change. However, if that's not the case, please correct me! Nick From brent at fuglylogic.com Sat Jan 24 00:04:00 2009 From: brent at fuglylogic.com (Brent Snook) Date: Sat, 24 Jan 2009 16:04:00 +1100 Subject: [rspec-users] [Cucumber, BDD] When not to use Cucumber? In-Reply-To: <4979F890.8000608@benmabey.com> References: <4979F890.8000608@benmabey.com> Message-ID: <1e177fd10901232104q4f417e67gb8125d2cac3b24cf@mail.gmail.com> I've been using story runner for the first time over the past 4 months or so and I've found the invaluable part to be the plain text support. Having a shared artifact that can be used by the customer, developers and testers is a huge boost towards achieving ubiquitous language. We use the story kickoff discussion to refine the language used in each scenario together, ensuring that the language makes sense to everyone and is consistent with other stories. In the sense that we want a way to store the feature/story in an executable format that we can all understand, a tool that supports plain text stories is the best choice for us. You can implement a scenario just as easily using plain rspec but then it becomes less accessible to other people in the team. If I was choosing a testing approach for a project that had technical people as customers I would still use the GWT format. I think it helps you continually focus on what you are really trying to achieve, otherwise it can be too easy to burrow down into the technical details and lose sight of that. No matter what the nature of project, every thing that you do is driven by the goal of adding some sort of value. Continually keeping that goal in mind helps you make better choices along the way. I agree with James that having that separation between the "what" and "how" is very useful. This approach is amenable to a more black box style of testing appropriate for acceptance tests. You should theoretically be able to completely change how your system works without touching the story/feature text. Your mileage would of course vary with this depending on whether or not you use a more declarative or imperative approach (as Ben describes in http://www.benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories/ ). My current recipe for testing spread is to automate the acceptance scenarios using a tool like story runner/cucumber and then use specs for targeted integration and unit level testing. The automated acceptance scenarios cover the main scenarios that the customer cares about while more specialised cases (or more technical aspects) are covered at the spec level. The specs will typically gravitate towards the white box end of the scale (describing the internals in more detail). - Brent -------------- next part -------------- An HTML attachment was scrubbed... URL: From jonathan at parkerhill.com Sat Jan 24 00:05:40 2009 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Sat, 24 Jan 2009 00:05:40 -0500 Subject: [rspec-users] nokogiri selector help Message-ID: <51054F01-B154-4D21-9B11-96AEF17F7B15@parkerhill.com> hiya, i want the selector that would return a of a table if any td contains some text, so i can use it in click_link_within e.g. When I click the "show" link within the row containing "user at example.com" When /^I click the "(.+)" link within the row containing "(.+)"$/ do | link, text| selector = ?? click_link_within selector, link end ----------- and lets say the response contains ...
......
show foo bar user at example.com baz
... From voodoorai2000 at gmail.com Sat Jan 24 07:02:33 2009 From: voodoorai2000 at gmail.com (voodoorai2000) Date: Sat, 24 Jan 2009 04:02:33 -0800 (PST) Subject: [rspec-users] [Cucumber, BDD] When not to use Cucumber? In-Reply-To: <1e177fd10901232104q4f417e67gb8125d2cac3b24cf@mail.gmail.com> References: <4979F890.8000608@benmabey.com> <1e177fd10901232104q4f417e67gb8125d2cac3b24cf@mail.gmail.com> Message-ID: <21639914.post@talk.nabble.com> Brent Snook wrote: > > My current recipe for testing spread is to automate the acceptance > scenarios > using a tool like story runner/cucumber and then use specs for targeted > integration and unit level testing. The automated acceptance scenarios > cover > the main scenarios that the customer cares about while more specialised > cases (or more technical aspects) are covered at the spec level. The specs > will typically gravitate towards the white box end of the scale > (describing > the internals in more detail). > Hi, I think this is the most used approach nowadays, high level testing with features and more specific testing, that end users don't care about at the spec level. However, I prefer the distinction between, declarative stories and imperative stories, which I think can be applied to these two levels also. For example, the end user or the business person, most probably gets bored of reading a very long imperative story of clicking links and filling out forms, plus other setup steps that might seem unnecessary to him, but are needed sometimes due to a not fully correct design. Whilst a developer will appreciate an imperative story as it tells him/her exactly what to do. In my opinion, even at the spec level we can use the philosophy behind steps (re-usability) to reduce the redundancies inherent to spec definitions. Trivial cases of you should see this in the page (view specs), or this object should have this attribute set to true (model specs), happen all the time, and seem like a great place to use variables inside step definitions. Other cases are more complex and the use of regular expressions to encapsulate them all, can certainly be very difficult, maybe the type of an attribute is a datetime and needs to be parsed, thus not being completely re-usable to say a boolean field. Still we could account for this variations by checking the type of the attribute, at the expense of increasing the complexity of the step. This is where the argument continues, people support the view of writing repetitive specs considering that they are clearer. I still have doubts about this. In my opinion this will certainly be a complex problem to solve, but once we tackle it a number of times, it will become trivial, we'll figure out an elegant step_helper to deal with this situations, and move on to the next hard problem. The hardest problem seems to be agreeing on a language to write the stories including minimal variations in the syntax and grammar of our steps, to be able to come up with a re-usable set of step definitions out-of-the-box, a set of steps that will allow us to write stories and jump straight to the failing nature of a step, due to it not being implemented, once its implemented the step will be passing, without further need to write trivial step definitions. This would be a great time saver and allow us to concentrate on harder problems very specific to our application that are not accounted for in the general step definitions. In conclusion, when not to use cucumber? never. Always use cucumber, everyone always use cucumber, lets find this hard problems to re-use steps and tackle them together, find a solution and move on to the next road-blocker. Use Rspec but as the underlying language to make cucumber work, not to divide your application into model view controller specs, separate your tests into user and developer features/steps. Distributed testing is a must to use cucumber effectively, and the use of mocks is also unrefutable[1], but only as an alternative to an inability to test something in a classical way[2] Rai [1]http://rubyconf2008.confreaks.com/testing-heresies.html [2]http://martinfowler.com/articles/mocksArentStubs.html -- View this message in context: http://www.nabble.com/-Cucumber%2C-BDD--When-not-to-use-Cucumber--tp21628693p21639914.html Sent from the rspec-users mailing list archive at Nabble.com. From ben at benmabey.com Sat Jan 24 12:12:20 2009 From: ben at benmabey.com (Ben Mabey) Date: Sat, 24 Jan 2009 10:12:20 -0700 Subject: [rspec-users] [Cucumber, BDD] When not to use Cucumber? In-Reply-To: <6f81634f599b13345ced41074daceaa9@ruby-forum.com> References: <4979F890.8000608@benmabey.com> <6f81634f599b13345ced41074daceaa9@ruby-forum.com> Message-ID: <497B4BF4.9020109@benmabey.com> See comments inline... On 1/23/09 1:46 PM, James Byrne wrote: > Ben Mabey wrote: > > >> So... I'm curious what people's thoughts are. When writing acceptance >> tests how do you choose which tool is best for the job? I often hear >> people complaining about the GWT syntax and they see no benefit of it >> over the frameworks that provide contexts (i.e rspec, shoulda, etc).[1] >> In what cases, if any, do you think the GWT gets in the way and how? In >> particular, if you are writing an app or lib whose customers/users are >> all developers do you still think there is value in the GWT syntax that >> Cucumber provides? >> >> > > My own experience is quite limited, but I did start out trying to get > what I desired done through TestUnit, then RSpec, then RSpec Story > Runner and finally Cucumber. In the end it was Cucumber that clarified > my approach for me, mainly by clearing away all (or at least most) of > the nitty gritty details of configuring and using the tool itself. I > found that, coming from a non OO programming background, that the degree > of mastery required of the other tools mentioned, together with the > effort I had to make to get the tool to behave as I wished (desires that > were often malformed by lack of understanding in any case), distracted > considerably from the task at hand, programming the application. > Interesting, thanks for sharing what your background is. I have seen other developers who don't have a strong OO background struggle with the concepts of isolation have a really hard time understanding how and why to use rspec. However, they seem to love Cucumber and it makes total sense to them. > I have progressed on my current project far, far more since discovering > Cucumber this past November than in all the time before. The > bifurcation between what and how seems far more natural to me with the > Cucumber features/step definitions file split than with the unified > expectation method/test steps of RSpec and the test method/assert > statements of TestUnit. Cucumber feature files just seem to permit one > to concentrate solely on "what" in the one case and then, with the > separate step definitions file, deal with the "how" in the other, > without crossing the line between the two. > Ahh.. that is a very good observation. When I write examples in rspec I start out with the example description first (obviously) but then I like to jump straight to my expectation. Meaning, I will say something like "dog.should be_happy" before I have even created the dog object. I like to do this for the same reason- I first write what I want and then I go a line above and create the how/given. A lot of people complain about the separation of code form story in plaintext features, but as you have pointed out that separation can be a very good thing. > Given, When and Then seemed contrived and far too stiff to me to begin > with. However, I discovered that much of my initial discomfort arose > from too vague a conception of what is was that was desired. The > benefit of GWT stylistic conventions is that it really does make one > consider deeply where one is starting from, what one is actually trying > to accomplish, and how, exactly, does one tell if it has been > accomplished. > > If this sort of self-analysis is so ingrained that one need not think of > it then GWT probably does not provide a measurable benefit. So, perhaps > deeply experienced developers and programmers might not get as much from > it as I have. > > On the other hand, I have frequently discovered in myself a lamentable > tendency to believe that I understood what a problem was simply because > I wanted to believe and not because of any demonstrable evidence to that > effect. Sitting down and writing out what you believe to be the truth > often reveals the flaws in ones assumptions. The GWT litany seems to > provide a very useful, if formulaic, examination of exactly what one is > setting out to accomplish thereby sometimes raising the question of why > it needs to be done at all. I find that it thereby clears away much > that is irrelevant to the question at hand. > +1. I totally agree with this. When it is difficult for me to write scenarios I find that the reason is that I fail to really understand what I am trying to accomplish. By flushing the acceptance criteria out in the GWT language I come out with a much better understanding of the problem and know exactly where to begin. > I also hold to the opinion that when writing an end user application the > only testing that can be consider definitive is what is described as > integration or acceptance testing. I accept that there are pragmatic > reasons why, because of limited time and equipment resources, unit and > functional tests are viewed as attractive alternatives. But, that > should not blind one the the fact that they really are alternatives, > chosen because of environmental considerations and not because of > inherent superiority. The only test that means anything to an end user > is one that shows the application works as intended in the environment > it is deployed to. > So here is where I disagree with you. :) I do agree that all the user cares about in the end is that the desired outcome is reached and the business value is provided. So with that mindset features are the only kind of tests a customer really cares about. Unit tests however are more for the developer. They aid in design and provide much more detailed documentation than the customer testes (acceptance tests). I don't think that cucumber features help me design my objects that much better unless I have focused object level examples telling me where the pain points are in my design. Eventually the customer will be greatful that you have unit tests (even if they don't know about them) because they will help lower the maintenace of the project by encouraging better design and providing tighter and more focused feedback on the smaller parts of the system. IMHO, of course. Thanks for the feedback, Ben From ben at benmabey.com Sat Jan 24 12:27:57 2009 From: ben at benmabey.com (Ben Mabey) Date: Sat, 24 Jan 2009 10:27:57 -0700 Subject: [rspec-users] [Cucumber, BDD] When not to use Cucumber? In-Reply-To: <1e177fd10901232104q4f417e67gb8125d2cac3b24cf@mail.gmail.com> References: <4979F890.8000608@benmabey.com> <1e177fd10901232104q4f417e67gb8125d2cac3b24cf@mail.gmail.com> Message-ID: <497B4F9D.4090609@benmabey.com> On 1/23/09 10:04 PM, Brent Snook wrote: *snip* > > If I was choosing a testing approach for a project that had technical > people as customers I would still use the GWT format. I think it helps > you continually focus on what you are really trying to achieve, > otherwise it can be too easy to burrow down into the technical details > and lose sight of that. No matter what the nature of project, every > thing that you do is driven by the goal of adding some sort of value. > Continually keeping that goal in mind helps you make better choices > along the way. This is at the herat of what I was asking. Even if every "customer" of the project is fluent in ruby would you still bother with the plaintext GWT features of Cucumber? I think you have nailed it.. Or at least, have confirmed my thoughts on the matter. :) Business value is business value no matter who is the customer. While other tools can be used to automate acceptance criteria Cucumber provides the huge advantage of helping you focus and analyze on what the desired business value is. I have talked to other people who have claimed that the GWT gets in the way though, so YMMV. So, I wouldn't be surprised that in some technical domains the overhead of adding features just doesn't make sense. Thanks for your thoughts, Ben From jonathan at parkerhill.com Sat Jan 24 12:44:17 2009 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Sat, 24 Jan 2009 12:44:17 -0500 Subject: [rspec-users] [Cucumber, BDD] When not to use Cucumber? In-Reply-To: <21639914.post@talk.nabble.com> References: <4979F890.8000608@benmabey.com> <1e177fd10901232104q4f417e67gb8125d2cac3b24cf@mail.gmail.com> <21639914.post@talk.nabble.com> Message-ID: Hi, I've been using cucumber, and story runner before that since plain text stories were introduced 1.5 years ago. I also use rspec for model and controller specing/testing. I'll answer the opposite question: when do I use cucumber? I am a team of one, and I am my own client, so the way I use cucumber may be different than other people's experience. As outlined in my recent presentation (http://www.slideshare.net/linoj/cucumber-how-i- slice-it-presentation-924254 ) I've found myself using cucumber for: * Talking to myself (planning) * Keeping track of what I'm working on (outlining) * Automating my manual testing (scripting) * View specs * Regression testing (confidence) Plain text stories let me plan out my app from the end-user point of view. When I'm my own client, Given/When/Then helps me structure conversations with myself. Scenarios let me explore variations. However, I do not shoot for full coverage or many edge cases, I leave that for the controller and model specs. These tend to be short atomic G/W/T scenarios. When taking the BDD approach (which TBH is sometimes), it can take days to implement a single scenario, drilling down from feature to controller spec to model spec, etc, at which point the story provides a valuable context for what to work on next as i "pop the to-do stack" and work my way through the steps. However, in reality, sometimes I jump in and implement stuff first, and test it as I go by clicking in the browser (oh my!). At a certain point I'm repeating the same set of clicks so I write a cucumber story to more easily script the scenario. In this case there may be a high level Given step(s), and a sequence of multiple When's, with a few Then's inbetween (to validate where I landed, flash messages, or whatever). I've also started using cucumber in place of view specs. These scenarios will often be a simple Give/When with a whole bunch of Then's that validate elements on the page. By the way, I've written utility steps for viewing the response in a browser (http://www.vaporbase.com/postings/Show_me_the_response ), and I often use rdebug to work through my code. Finally, I love to run my suite of scenarios as regression tests, especially at stabilization points in my development, to make sure everything is still operational. I even have a "cap deploy:features" to run them on my staging server. linoj -------------------------------------- wtf <=> ftw -------------------------------------- From ben at benmabey.com Sat Jan 24 12:57:39 2009 From: ben at benmabey.com (Ben Mabey) Date: Sat, 24 Jan 2009 10:57:39 -0700 Subject: [rspec-users] [Cucumber, BDD] When not to use Cucumber? In-Reply-To: <21639914.post@talk.nabble.com> References: <4979F890.8000608@benmabey.com> <1e177fd10901232104q4f417e67gb8125d2cac3b24cf@mail.gmail.com> <21639914.post@talk.nabble.com> Message-ID: <497B5693.5020906@benmabey.com> On 1/24/09 5:02 AM, voodoorai2000 wrote: > In conclusion, when not to use cucumber? never. Always use cucumber, > everyone always use cucumber, lets find this hard problems to re-use steps > and tackle them together, find a solution and move on to the next > road-blocker. Use Rspec but as the underlying language to make cucumber > work, not to divide your application into model view controller specs, > separate your tests into user and developer features/steps. > Distributed testing is a must to use cucumber effectively, and the use of > mocks is also unrefutable[1], but only as an alternative to an inability to > test something in a classical way[2] > > Rai > > [1]http://rubyconf2008.confreaks.com/testing-heresies.html > [2]http://martinfowler.com/articles/mocksArentStubs.html > > > Well, I have learned never to say never. ;) As far as the mocking goes... I always use real objects in features unless I need to make an external network call to another system (i.e. a web services call, in which case I like to use fakeweb[1]). That said, one of the things I really like about having features is that it allows me to use mock objects in my object level examples without any fear of integration point failures. I find it very hard to test objects under total isolation without using mocks to remove dependencies and I gain a lot of design benefit from using mocks. I really don't want to get into the whole classic vs mockist debate though as it was just beat to death on the TDD mailing list.[2] :) -Ben [1] http://github.com/chrisk/fakeweb/tree/master [2] http://tech.groups.yahoo.com/group/testdrivendevelopment/message/29674 From lists at ruby-forum.com Sat Jan 24 21:13:21 2009 From: lists at ruby-forum.com (Justin Smestad) Date: Sun, 25 Jan 2009 03:13:21 +0100 Subject: [rspec-users] [Cucumber, Merb, Webrat] undefined method 'response' for In-Reply-To: References: Message-ID: <7bfeb788238eb4753e075ed48ee4e498@ruby-forum.com> Daniel, I have fixed this in my fork: http://github.com/jsmestad/merb_cucumber/tree/master Daniel Vartanov wrote: > undefined local variable or method `response' for > # (NameError) > ./features/steps/result_steps.rb:14:in ` /^the (.*) ?request should > fail/' > features/authentication/login.feature:17:in `/^the (.*) ?request should > fail/' > Here are the versions of the installed gems: > cucumber (0.1.15) > merb (1.0.8) > webrat (0.4.0) > david-merb_cucumber (0.5.1.2) -- Posted via http://www.ruby-forum.com/. From mark at mwilden.com Sat Jan 24 21:39:01 2009 From: mark at mwilden.com (Mark Wilden) Date: Sat, 24 Jan 2009 18:39:01 -0800 Subject: [rspec-users] [Cucumber] Long backtrace Message-ID: <3c30da400901241839s76e9a3f4m3f8e59776b84b8c4@mail.gmail.com> I'm getting a humongous backtrace when I have an error in a Cucumber feature. Is there a way to quiet it down a bit? ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Sat Jan 24 22:02:02 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 25 Jan 2009 04:02:02 +0100 Subject: [rspec-users] [Cucumber] Long backtrace In-Reply-To: <3c30da400901241839s76e9a3f4m3f8e59776b84b8c4@mail.gmail.com> References: <3c30da400901241839s76e9a3f4m3f8e59776b84b8c4@mail.gmail.com> Message-ID: <8d961d900901241902s78dc3a34v6d00d04a924d418b@mail.gmail.com> On Sun, Jan 25, 2009 at 3:39 AM, Mark Wilden wrote: > I'm getting a humongous backtrace when I have an error in a Cucumber > feature. Is there a way to quiet it down a bit? > It's filtering by default. -b gives you a full backtrace. If you get a long one by default it's a bug. Please advise how to reproduce. Cucumber version, Ruby version etc. Aslak > > ///ark > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at mwilden.com Sat Jan 24 22:41:46 2009 From: mark at mwilden.com (Mark Wilden) Date: Sat, 24 Jan 2009 19:41:46 -0800 Subject: [rspec-users] [Cucumber] Long backtrace In-Reply-To: <8d961d900901241902s78dc3a34v6d00d04a924d418b@mail.gmail.com> References: <3c30da400901241839s76e9a3f4m3f8e59776b84b8c4@mail.gmail.com> <8d961d900901241902s78dc3a34v6d00d04a924d418b@mail.gmail.com> Message-ID: <3c30da400901241941p35f82004t4dc547ef7da15a8a@mail.gmail.com> On Sat, Jan 24, 2009 at 7:02 PM, aslak hellesoy wrote: > > > On Sun, Jan 25, 2009 at 3:39 AM, Mark Wilden wrote: > >> I'm getting a humongous backtrace when I have an error in a Cucumber >> feature. Is there a way to quiet it down a bit? >> > > It's filtering by default. -b gives you a full backtrace. If you get a long > one by default it's a bug. Please advise how to reproduce. Cucumber version, > Ruby version etc. > I filed a ticket on Lighthouse. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Sun Jan 25 10:53:19 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 25 Jan 2009 16:53:19 +0100 Subject: [rspec-users] [ANN] Cucumber 0.2 alpha Message-ID: <8d961d900901250753i26b2c416h855c78a8539b2a4@mail.gmail.com> Hi folks, I'm pretty excited about the next release - 0.2. Please try out the prereleases (0.1.99): gem sources -a http://gems.github.com gem install aslakhellesoy-cucumber We need updated translations! To see what needs updating, do this: cucumber --lang help # To see what languages are incomplete cucumber --lang es help # To see what's incomplete in Spanish Stuff that users should care about: * New --tags option and @tag keyword in the Gherkin language * Automatic aliasing of keywords so you can use Given/When/Then in your language in step definitions * New --strict option to fail on undefined and pending steps * New --autoformat option to format your feature sources (useful especially for tables) * Make the current scenario available to step definitions * Multiline tables and strings in steps get printed * New --help for all the supported languages * Much faster installation of gem * Pure Java support via JBehave Stuff that contributors should care about * A new design based on an abstract syntax tree with better separation of concerns. * Self tests - Cucumber features for Cucumber * No need to compile language specific parsers There are a few features of 0.1 that haven't been ported yet: * HTML formatter * Any number of things that I have overseen Some parts of the Gherkin language have also changed: * "GivenScenario" is gone. Instead you can call steps from step definitions, or wait for "Background (#153)" * "More Examples" is gone. "Scenario" + "More Examples" is no longer supported. Use "Scenario Outline" + "Examples" instead. And finally, pure Ruby features are no longer supported. The code for the 0.1.x series lives on the v0.1.x branch. From now on there will only be minor bugfixes on 0.1.x. Big thanks to Joseph Wilk who has helped out a lot during the redesign. Please be patient about any bugs you find in this release and help us iron out any wrinkles. Full (pre)release notes here: http://github.com/aslakhellesoy/cucumber/blob/dc114aeca49bdaaeec757089790ac14fca75a62b/History.txt (::) Aslak (::) -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.dennis at gmail.com Sun Jan 25 11:58:18 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Sun, 25 Jan 2009 11:58:18 -0500 Subject: [rspec-users] nokogiri selector help In-Reply-To: <51054F01-B154-4D21-9B11-96AEF17F7B15@parkerhill.com> References: <51054F01-B154-4D21-9B11-96AEF17F7B15@parkerhill.com> Message-ID: <85d99afe0901250858we266949l2473e4da56b8d1ed@mail.gmail.com> On Sat, Jan 24, 2009 at 12:05 AM, Jonathan Linowes wrote: > hiya, > > i want the selector that would return a of a table if any td contains > some text, so i can use it in click_link_within > > e.g. When I click the "show" link within the row containing > "user at example.com" > > > When /^I click the "(.+)" link within the row containing "(.+)"$/ do |link, > text| > selector = ?? > click_link_within selector, link > end You can use an XPath selector to find the parent. Try: selector = "//table//tr//td[contains(.,'user at example.com')]//.." > > > ----------- > and lets say the response contains > > ... >
> > > ... > > > > > > > > ... > >
showfoobaruser at example.combaz
>
> ... > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From walketim at gmail.com Sun Jan 25 13:32:10 2009 From: walketim at gmail.com (Tim Walker) Date: Sun, 25 Jan 2009 11:32:10 -0700 Subject: [rspec-users] [ANN] Cucumber 0.2 alpha In-Reply-To: <1ebf5a4d0901251030n49d5f76dj75abf60f911b513@mail.gmail.com> References: <8d961d900901250753i26b2c416h855c78a8539b2a4@mail.gmail.com> <1ebf5a4d0901251030n49d5f76dj75abf60f911b513@mail.gmail.com> Message-ID: <1ebf5a4d0901251032q76be91ffg38f0e3743fe268c6@mail.gmail.com> On behalf of a very grateful community: Thank you. Tim On Jan 25, 2009 9:16 AM, "aslak hellesoy" wrote: Hi folks, I'm pretty excited about the next release - 0.2. Please try out the prereleases (0.1.99): gem sources -a http://gems.github.com gem install aslakhellesoy-cucumber We need updated translations! To see what needs updating, do this: cucumber --lang help # To see what languages are incomplete cucumber --lang es help # To see what's incomplete in Spanish Stuff that users should care about: * New --tags option and @tag keyword in the Gherkin language * Automatic aliasing of keywords so you can use Given/When/Then in your language in step definitions * New --strict option to fail on undefined and pending steps * New --autoformat option to format your feature sources (useful especially for tables) * Make the current scenario available to step definitions * Multiline tables and strings in steps get printed * New --help for all the supported languages * Much faster installation of gem * Pure Java support via JBehave Stuff that contributors should care about * A new design based on an abstract syntax tree with better separation of concerns. * Self tests - Cucumber features for Cucumber * No need to compile language specific parsers There are a few features of 0.1 that haven't been ported yet: * HTML formatter * Any number of things that I have overseen Some parts of the Gherkin language have also changed: * "GivenScenario" is gone. Instead you can call steps from step definitions, or wait for "Background (#153)" * "More Examples" is gone. "Scenario" + "More Examples" is no longer supported. Use "Scenario Outline" + "Examples" instead. And finally, pure Ruby features are no longer supported. The code for the 0.1.x series lives on the v0.1.x branch. From now on there will only be minor bugfixes on 0.1.x. Big thanks to Joseph Wilk who has helped out a lot during the redesign. Please be patient about any bugs you find in this release and help us iron out any wrinkles. Full (pre)release notes here: http://github.com/aslakhellesoy/cucumber/blob/dc114aeca49bdaaeec757089790ac14fca75a62b/History.txt (::) Aslak (::) _______________________________________________ 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 joe at pinkpucker.net Sun Jan 25 22:35:18 2009 From: joe at pinkpucker.net (Joe Van Dyk) Date: Sun, 25 Jan 2009 19:35:18 -0800 Subject: [rspec-users] testing javascript-heavy websites In-Reply-To: References: Message-ID: How does http://celerity.rubyforge.org/ compare to the options mentioned? On Thu, Jan 22, 2009 at 6:46 PM, Joe Van Dyk wrote: > We're starting to work on some javascript-heavy websites, and even > some flash/flex based ones as well. > > What's the current hotness in automatically testing those types of > websites? Does cucumber hook up to selenium now? I thought I saw > that webrat did. > > Any recommended resources? > > Joe > From stuart.hungerford at anu.edu.au Sun Jan 25 21:56:19 2009 From: stuart.hungerford at anu.edu.au (Stuart Hungerford) Date: Mon, 26 Jan 2009 13:56:19 +1100 Subject: [rspec-users] Best way to spec nested modules?... Message-ID: <4C77F01C-1235-4083-BF8C-61DFAE726C18@anu.edu.au> Hi, I've got a set of classes in nested Ruby modules which I'm using rspec to specify: module Foo module Baz class C1 ... end class C2 ... end end end To specify C2 behaviour I need to create a bunch of C1 instances: describe Foo::Baz::C2 do before(:each) do @c1a = Foo::Baz::C1.new(...) @c1b = Foo::Baz::C1.new(...) @c1c = Foo::Baz::C1.new(...) @c2 = Foo::Baz::C2.new(@c1a, @c1b, @c1c) end describe "some behaviour" do # ... end end After a while the many Foo::Baz:: module prefixes become pretty tedious and not particularly DRY. Can someone suggest a better way to manage using nested modules in rspec? Thanks, Stu -- Stuart Hungerford ANU Supercomputer Facility From pergesu at gmail.com Sun Jan 25 22:56:27 2009 From: pergesu at gmail.com (Pat Maddox) Date: Sun, 25 Jan 2009 19:56:27 -0800 Subject: [rspec-users] Best way to spec nested modules?... In-Reply-To: <4C77F01C-1235-4083-BF8C-61DFAE726C18@anu.edu.au> References: <4C77F01C-1235-4083-BF8C-61DFAE726C18@anu.edu.au> Message-ID: <810a540e0901251956q774dc875jf7f86f9eb758b3fe@mail.gmail.com> Put the describe in the module, and take advantage of Ruby's lookup semantics: module Foo module Baz describe Class1 do ... Pat On 1/25/09, Stuart Hungerford wrote: > Hi, > > I've got a set of classes in nested Ruby modules which I'm using rspec > to specify: > > module Foo > > module Baz > > class C1 ... end > > class C2 ... end > end > end > > To specify C2 behaviour I need to create a bunch of C1 instances: > > describe Foo::Baz::C2 do > > before(:each) do > @c1a = Foo::Baz::C1.new(...) > @c1b = Foo::Baz::C1.new(...) > @c1c = Foo::Baz::C1.new(...) > > @c2 = Foo::Baz::C2.new(@c1a, @c1b, @c1c) > end > > describe "some behaviour" do > # ... > end > end > > After a while the many Foo::Baz:: module prefixes become pretty > tedious and > not particularly DRY. > > Can someone suggest a better way to manage using nested modules in > rspec? > > Thanks, > > Stu > > -- > Stuart Hungerford > ANU Supercomputer Facility > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mvidaurr at acm.org Mon Jan 26 00:13:29 2009 From: mvidaurr at acm.org (Manuel Vidaurre) Date: Sun, 25 Jan 2009 23:13:29 -0600 Subject: [rspec-users] [ANN] Cucumber 0.2 alpha In-Reply-To: <8d961d900901250753i26b2c416h855c78a8539b2a4@mail.gmail.com> References: <8d961d900901250753i26b2c416h855c78a8539b2a4@mail.gmail.com> Message-ID: Aslak, For Spanish: "es": name: Spanish native: espa?ol encoding: UTF-8 background: Antecedentes feature: Caracter?stica scenario: Escenario scenario_outline: Esquema del escenario examples: Ejemplos given: Dado when: Cuando then: Entonces and: Y but: Pero Regards Manuel On Sun, Jan 25, 2009 at 9:53 AM, aslak hellesoy wrote: > Hi folks, > > I'm pretty excited about the next release - 0.2. Please try out the > prereleases (0.1.99): > > gem sources -a http://gems.github.com > gem install aslakhellesoy-cucumber > > We need updated translations! To see what needs updating, do this: > > cucumber --lang help # To see what languages are incomplete > cucumber --lang es help # To see what's incomplete in Spanish > > Stuff that users should care about: > * New --tags option and @tag keyword in the Gherkin language > * Automatic aliasing of keywords so you can use Given/When/Then in your > language in step definitions > * New --strict option to fail on undefined and pending steps > * New --autoformat option to format your feature sources (useful especially > for tables) > * Make the current scenario available to step definitions > * Multiline tables and strings in steps get printed > * New --help for all the supported languages > * Much faster installation of gem > * Pure Java support via JBehave > > Stuff that contributors should care about > * A new design based on an abstract syntax tree with better separation of > concerns. > * Self tests - Cucumber features for Cucumber > * No need to compile language specific parsers > > There are a few features of 0.1 that haven't been ported yet: > * HTML formatter > * Any number of things that I have overseen > > Some parts of the Gherkin language have also changed: > * "GivenScenario" is gone. Instead you can call steps from step > definitions, or wait for "Background (#153)" > * "More Examples" is gone. "Scenario" + "More Examples" is no longer > supported. Use "Scenario Outline" + "Examples" instead. > > And finally, pure Ruby features are no longer supported. > > The code for the 0.1.x series lives on the v0.1.x branch. From now on there > will only be minor bugfixes on 0.1.x. > > Big thanks to Joseph Wilk who has helped out a lot during the redesign. > Please be patient about any bugs you find in this release and help us iron > out any wrinkles. > > Full (pre)release notes here: > http://github.com/aslakhellesoy/cucumber/blob/dc114aeca49bdaaeec757089790ac14fca75a62b/History.txt > > (::) Aslak (::) > > _______________________________________________ > 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 Mon Jan 26 01:56:41 2009 From: lists at ruby-forum.com (Giuseppe Bertini) Date: Mon, 26 Jan 2009 07:56:41 +0100 Subject: [rspec-users] fixture_scenarios problem In-Reply-To: <4976D83C.9080306@railsnewbie.com> References: <4976D83C.9080306@railsnewbie.com> Message-ID: > Is the git tree any different than the svn one? > http://github.com/mojombo/fixture-scenarios/tree/master > Scott Hi Scott, I checked, and the two trees are actually identical. It seems that while fixture_scenarios has not changed since around April 2007, changes in rspec since v.1.1.4 have created (or revealed) an incompatibility. Thanks in advance for any advice on this problem. Giuseppe -- Posted via http://www.ruby-forum.com/. From pelle at stakeventures.com Mon Jan 26 02:41:57 2009 From: pelle at stakeventures.com (Pelle Braendgaard) Date: Sun, 25 Jan 2009 23:41:57 -0800 Subject: [rspec-users] fixture_scenarios problem In-Reply-To: References: <4976D83C.9080306@railsnewbie.com> Message-ID: It was this change included in rspec 1.1.12 that caused the problem: http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/620-fixture_path-moved-from-testunittestcase-to-activesupporttestcase Basically rspec extends ActiveSupport::TestCase instead of Test::Unit:TestCase. I have made a fix to fixture scenarios which fixes that particular problem. I've made it available here: http://github.com/pelle/fixture-scenarios/tree/master All it does is change fixture scenarios to use ActiveSupport::TestCase as well and it works for me. P On Sun, Jan 25, 2009 at 10:56 PM, Giuseppe Bertini wrote: >> Is the git tree any different than the svn one? >> http://github.com/mojombo/fixture-scenarios/tree/master >> Scott > > Hi Scott, I checked, and the two trees are actually identical. > > It seems that while fixture_scenarios has not changed since around April > 2007, changes in rspec since v.1.1.4 have created (or revealed) an > incompatibility. > > Thanks in advance for any advice on this problem. > > Giuseppe > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- http://agree2.com - Reach Agreement! http://extraeagle.com - Solutions for the electronic Extra Legal world http://stakeventures.com - Bootstrapping blog From lists at ruby-forum.com Mon Jan 26 10:23:20 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 26 Jan 2009 16:23:20 +0100 Subject: [rspec-users] Mocking/Stubbing ActiveRecord.config.default_timezone Message-ID: In tracking down a bug in AuthLogic I realized that I had made the same error in one of my libraries. Knowing what the error was made creating a test to expose it (using cucumber) rather trivial. However, it has occurred to me that this sort of issue is far more subtle than I first appreciated. So, I am looking for some opinions on how to test for this sort of thing in a more general sense. At issue is the setting of config values in environment.rb files and their influence on user code. In the specific case I encountered this code demonstrates the essence of the situation: def active_row? time_now = DateTime.now return true if (effective_from <= time_now and (not superseded_after or superseded_after >= time_now )) return false end The error is that the time_now assignment is not testing whether or not the default AR time is utc. The correct code is: def active_row? if self.class.default_timezone == :utc time_now = DateTime.now.utc else time_now = DateTime.now end return true if (effective_from <= time_now and (not superseded_after or superseded_after >= time_now )) return false end My question is: How does one vary the config.default_timezone, or any configuration value for that matter, in a cucumber step definition or RSpec test? -- Posted via http://www.ruby-forum.com/. From mark at mwilden.com Mon Jan 26 10:57:52 2009 From: mark at mwilden.com (Mark Wilden) Date: Mon, 26 Jan 2009 07:57:52 -0800 Subject: [rspec-users] Mocking/Stubbing ActiveRecord.config.default_timezone In-Reply-To: References: Message-ID: <3c30da400901260757y55c74a9fr68e269ff50d4f7e5@mail.gmail.com> On Mon, Jan 26, 2009 at 7:23 AM, James Byrne wrote: > return true if (effective_from <= time_now and > (not superseded_after or superseded_after >= time_now > )) > return false > This has nothing to do with your question - just a style suggestion: effective_from <= time_now and (superseded_after.nil? or superseded_after >= time_now) No need to use 'return'. And you don't want to check if superseded_after is false - just nil (if it's false, there's a bug that would be hidden by 'not superseded'). Carry on. :) ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Mon Jan 26 12:06:24 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 26 Jan 2009 18:06:24 +0100 Subject: [rspec-users] Mocking/Stubbing ActiveRecord.config.default_timezone In-Reply-To: <3c30da400901260757y55c74a9fr68e269ff50d4f7e5@mail.gmail.com> References: <3c30da400901260757y55c74a9fr68e269ff50d4f7e5@mail.gmail.com> Message-ID: <3f6306357aff6d903317beeee51d9ee6@ruby-forum.com> Mark Wilden wrote: > On Mon, Jan 26, 2009 at 7:23 AM, James Byrne > wrote: > > This has nothing to do with your question - just a style suggestion: > > effective_from <= time_now and (superseded_after.nil? or > superseded_after = time_now) > > No need to use 'return'. And you don't want to check if superseded_after > is false - just nil (if it's false, there's a bug that would be hidden by > 'not superseded'). > I prefer the style of explicit returns. It makes intent unambiguous. Your point wrt nil? is well taken and I have modified the code to use this idiom. -- Posted via http://www.ruby-forum.com/. From mark at mwilden.com Mon Jan 26 12:57:06 2009 From: mark at mwilden.com (Mark Wilden) Date: Mon, 26 Jan 2009 09:57:06 -0800 Subject: [rspec-users] Mocking/Stubbing ActiveRecord.config.default_timezone In-Reply-To: <3f6306357aff6d903317beeee51d9ee6@ruby-forum.com> References: <3c30da400901260757y55c74a9fr68e269ff50d4f7e5@mail.gmail.com> <3f6306357aff6d903317beeee51d9ee6@ruby-forum.com> Message-ID: <3c30da400901260957g9a46878hb5123dd6963cd8d6@mail.gmail.com> On Mon, Jan 26, 2009 at 9:06 AM, James Byrne wrote: > > I prefer the style of explicit returns. It makes intent unambiguous. > The thing is that the Ruby idiom is to avoid unnecessary returns. Because of this, using them actually makes code harder to read, because you have to read it more carefully to see if they're being used for a legitimate reason. Just one opinion. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at deadorange.com Mon Jan 26 13:02:46 2009 From: nick at deadorange.com (Nick Hoffman) Date: Mon, 26 Jan 2009 13:02:46 -0500 Subject: [rspec-users] Best way to spec nested modules?... In-Reply-To: <4C77F01C-1235-4083-BF8C-61DFAE726C18@anu.edu.au> References: <4C77F01C-1235-4083-BF8C-61DFAE726C18@anu.edu.au> Message-ID: On 25/01/2009, at 9:56 PM, Stuart Hungerford wrote: > Hi, > > I've got a set of classes in nested Ruby modules which I'm using > rspec to specify: > > module Foo > > module Baz > > class C1 ... end > > class C2 ... end > end > end > > To specify C2 behaviour I need to create a bunch of C1 instances: > > describe Foo::Baz::C2 do > > before(:each) do > @c1a = Foo::Baz::C1.new(...) > @c1b = Foo::Baz::C1.new(...) > @c1c = Foo::Baz::C1.new(...) > > @c2 = Foo::Baz::C2.new(@c1a, @c1b, @c1c) > end > > describe "some behaviour" do > # ... > end > end > > After a while the many Foo::Baz:: module prefixes become pretty > tedious and > not particularly DRY. > > Can someone suggest a better way to manage using nested modules in > rspec? > > Thanks, > > Stu > > -- > Stuart Hungerford > ANU Supercomputer Facility Hey Stuart. You should also consider using mocks and stubs. Eg: module Foo module Baz before :each do @c1a = mock_model C1, ... @c1b = mock_model C1, ... @c1c = mock_model C1, ... @c2 = C2.new @c1a, @c1b, @c1c end end end That way, your specs for class C2 aren't tied to C1's implementation. One other suggestion I'd make is to use more descriptive variable names, though "c1a" might simply be for example's sake, since we're talking about Foo::Baz::C1, etc. Cheers, Nick From lists at ruby-forum.com Mon Jan 26 15:08:37 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 26 Jan 2009 21:08:37 +0100 Subject: [rspec-users] Mocking/Stubbing ActiveRecord.config.default_timezone In-Reply-To: <3c30da400901260957g9a46878hb5123dd6963cd8d6@mail.gmail.com> References: <3c30da400901260757y55c74a9fr68e269ff50d4f7e5@mail.gmail.com> <3f6306357aff6d903317beeee51d9ee6@ruby-forum.com> <3c30da400901260957g9a46878hb5123dd6963cd8d6@mail.gmail.com> Message-ID: <048c5b9a72126dfca6e874e1183c78b6@ruby-forum.com> Mark Wilden wrote: > > > The thing is that the Ruby idiom is to avoid unnecessary returns. > Because of this, using them actually makes code harder to read, > because you have to read it more carefully to see if they're being > used for a legitimate reason. If the method is short, the code simply falls through, and I am not doing anything particularly subtle with the result, then I follow the convention of no explicit return. If a method requires at least one explicit return then I code all possible outcomes as returns. In such a case, one _should_ be reading the code more carefully, particularly if one is writing it. But, we digress. I am still looking for suggestions on recommended approaches to testing application code that is dependent upon environment.rb config values. -- Posted via http://www.ruby-forum.com/. From stuart.hungerford at anu.edu.au Mon Jan 26 15:59:19 2009 From: stuart.hungerford at anu.edu.au (Stuart Hungerford) Date: Tue, 27 Jan 2009 07:59:19 +1100 Subject: [rspec-users] Best way to spec nested modules? In-Reply-To: References: Message-ID: On 27/01/2009, at 4:06 AM, rspec-users-request at rubyforge.org wrote: Pat: > > Put the describe in the module, and take advantage of Ruby's lookup > semantics: > > module Foo > module Baz > describe Class1 do > > ... Thanks for that beautifully simple suggestion! Thanks also to Nick Hoffman for the reminder about mocks and stubs. The overly concise variable names I used in my example are for example purposes only, the real ones are more readable and subject-specific. Thanks, Stu -- Stuart Hungerford ANU Supercomputer Facility From lists at ruby-forum.com Mon Jan 26 18:00:12 2009 From: lists at ruby-forum.com (Giuseppe Bertini) Date: Tue, 27 Jan 2009 00:00:12 +0100 Subject: [rspec-users] fixture_scenarios problem In-Reply-To: References: <4976D83C.9080306@railsnewbie.com> Message-ID: Pelle Braendgaard wrote: > I have made a fix to fixture scenarios which fixes that particular > problem. I've made it available here: > > http://github.com/pelle/fixture-scenarios/tree/master It works! Thank you very, very much, Pelle. Giuseppe -- Posted via http://www.ruby-forum.com/. From scott at railsnewbie.com Mon Jan 26 22:31:46 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Mon, 26 Jan 2009 22:31:46 -0500 Subject: [rspec-users] testing capistrano tasks Message-ID: <497E8022.60300@railsnewbie.com> Does anyone have any insight into testing capistrano tasks? More specifically, I'm looking to add regression tests to this package, which adds database backup tasks to capistrano: http://github.com/smtlaissezfaire/cap_db_dump/tree/master Scott From matt at mattwynne.net Tue Jan 27 04:15:54 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 27 Jan 2009 09:15:54 +0000 Subject: [rspec-users] testing capistrano tasks In-Reply-To: <497E8022.60300@railsnewbie.com> References: <497E8022.60300@railsnewbie.com> Message-ID: <12E02DC8-3624-4C9F-9B40-6D5A14F39CF5@mattwynne.net> Not done it, but Cucumber acceptance tests would surely be a good fit here: Given there is a database "foo" When I run the script Then there should be a backup no more than 10 minutes old And the backup should restore OK And the restored database should contain the same records as the original database On 27 Jan 2009, at 03:31, Scott Taylor wrote: > > Does anyone have any insight into testing capistrano tasks? More > specifically, I'm looking to add regression tests to this package, > which adds database backup tasks to capistrano: > > http://github.com/smtlaissezfaire/cap_db_dump/tree/master > > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Matt Wynne http://blog.mattwynne.net http://www.songkick.com From nick at deadorange.com Tue Jan 27 11:03:53 2009 From: nick at deadorange.com (Nick Hoffman) Date: Tue, 27 Jan 2009 11:03:53 -0500 Subject: [rspec-users] [RSpec] Error when returning multiple values from a stub Message-ID: Hey guys. I've just found some odd behaviour within RSpec 1.1.12 , and would like to know whether this is a bug, or I'm doing something wrong. When I give multiple return values to a stub, like this: SubtitleFile.stub!(:new).and_return @sf1, @sf2 RSpec complains: Mock 'SubtitleFile_1001' received unexpected message :size with (no args) However, if I break that into two stubs, like this: SubtitleFile.stub!(:new).and_return @sf1 SubtitleFile.stub!(:new).and_return @sf2 the spec passes. I've posted a more concrete example here: http://gist.github.com/53389 In code pane #2, if I comment line 13 and uncomment lines 14 and 15, the spec passes. Any idea what's going on? Thanks for your help, Nick From nick at deadorange.com Tue Jan 27 11:10:36 2009 From: nick at deadorange.com (Nick Hoffman) Date: Tue, 27 Jan 2009 11:10:36 -0500 Subject: [rspec-users] [RSpec] Error when returning multiple values from a stub In-Reply-To: References: Message-ID: <36BCDAA0-8FFC-4DE9-A944-F2DCFE4D76BC@deadorange.com> On 27/01/2009, at 11:03 AM, Nick Hoffman wrote: > Hey guys. I've just found some odd behaviour within RSpec 1.1.12 , > and would like to know whether this is a bug, or I'm doing something > wrong. > > When I give multiple return values to a stub, like this: > SubtitleFile.stub!(:new).and_return @sf1, @sf2 > RSpec complains: > Mock 'SubtitleFile_1001' received unexpected message :size with (no > args) > > However, if I break that into two stubs, like this: > SubtitleFile.stub!(:new).and_return @sf1 > SubtitleFile.stub!(:new).and_return @sf2 > the spec passes. > > I've posted a more concrete example here: > http://gist.github.com/53389 > > In code pane #2, if I comment line 13 and uncomment lines 14 and 15, > the spec passes. > > Any idea what's going on? Thanks for your help, > Nick I just realised that breaking SubtitleFile.stub!(:new).and_return @sf1, @sf2 into two stubs causes the second call to #stub! to override the first, which obviously causes problems, and thus doesn't provide an interim solution. -Nick From lists at ruby-forum.com Tue Jan 27 12:05:08 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 27 Jan 2009 18:05:08 +0100 Subject: [rspec-users] rake features does not seem to run rake db:test:prepare Message-ID: <4a18139fae7c1dee40905547bbe811a2@ruby-forum.com> This may be misunderstanding on my part but I thought that running rake features would automatically run rake db:test:prepare. However, this does not seem to be the case. Am I mistaken or is this a bug? The rake task I am using is this: #in ./lib/tasks/cucumber.rake desc "Exercise cucumber features" task :features => 'db:test:prepare' task :features => "features:all" #task :features => 'db:test:prepare' require 'cucumber/rake/task' #I have to add this -mischa namespace :features do Cucumber::Rake::Task.new(:all) do |t| t.cucumber_opts = "--format pretty" end Cucumber::Rake::Task.new(:cruise) do |t| t.cucumber_opts = "--format pretty --out=#{ENV['CC_BUILD_ARTIFACTS']}/features.txt --format html --out=#{ENV['CC_BUILD_ARTIFACTS']}/features.html" t.rcov = true t.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/} t.rcov_opts << %[-o "#{ENV['CC_BUILD_ARTIFACTS']}/code_coverage/features"] end Cucumber::Rake::Task.new(:rcov) do |t| t.rcov = true t.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/} t.rcov_opts << %[-o "code_coverage/features"] end end I moved the task :features => 'db:test:prepare' statement from after task :features => "features:all" to before it, but this does not influence the observed behaviour. This issue came to my attention when I discovered that changes to the migrations were not showing up in the test database unless I manually did rake db:test:prepare. -- Posted via http://www.ruby-forum.com/. From brian.takita at gmail.com Tue Jan 27 12:08:28 2009 From: brian.takita at gmail.com (Brian Takita) Date: Tue, 27 Jan 2009 12:08:28 -0500 Subject: [rspec-users] testing capistrano tasks In-Reply-To: <12E02DC8-3624-4C9F-9B40-6D5A14F39CF5@mattwynne.net> References: <497E8022.60300@railsnewbie.com> <12E02DC8-3624-4C9F-9B40-6D5A14F39CF5@mattwynne.net> Message-ID: <1d7ddd110901270908i3a9f9c2ai7c7723dd872c0349@mail.gmail.com> On Tue, Jan 27, 2009 at 4:15 AM, Matt Wynne wrote: > Not done it, but Cucumber acceptance tests would surely be a good fit here: > > Given there is a database "foo" > When I run the script > Then there should be a backup no more than 10 minutes old > And the backup should restore OK > And the restored database should contain the same records as the > original database > > On 27 Jan 2009, at 03:31, Scott Taylor wrote: > >> >> Does anyone have any insight into testing capistrano tasks? More >> specifically, I'm looking to add regression tests to this package, which >> adds database backup tasks to capistrano: Yes, I have experience testing capistrano. My experience with unit testing Capistrano has been less than positive. Capistrano is difficult to test. Basically you have to mock out the shell/run/file transfer commands to do unit tests. The big problem is how do you know the shell commands are correct? There is some benefit though. You do get to see a list of the shell commands that are run in one place. However, there can be many permutations of logic inside of a deploy, so its often difficult to capture every situation. I realize that this sounds terrible, and perhaps there is a better way to go about this, but this has been my experience. IMO, the best way to test Capistrano is to have a staging environment that simulates your production environment where you deploy to and make sure things work. I can't recall a situation where I had non-obvious issues that would have been prevented with unit tests. Often times, non-obvious issues are related to properly restarting processes because the monit + shell script interactions had issues. This is testable, of course. You can also do an integration test by deploying to localhost or to a test box. You can then ensure that the actual db dump exists and properly restores. I'm sorry about the rambling infoflood/rant. I hope it is useful. :-) Brian >> >> http://github.com/smtlaissezfaire/cap_db_dump/tree/master >> >> Scott >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Tue Jan 27 12:13:57 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 27 Jan 2009 18:13:57 +0100 Subject: [rspec-users] rake features does not seem to run rake db:test:prepare In-Reply-To: <4a18139fae7c1dee40905547bbe811a2@ruby-forum.com> References: <4a18139fae7c1dee40905547bbe811a2@ruby-forum.com> Message-ID: James Byrne wrote: > > I moved the task :features => 'db:test:prepare' statement from after > task :features => "features:all" to before it, but this does not > influence the observed behaviour. > I lied. Evidently moving the the db:test:prepare statement did resolve the problem after all. -- Posted via http://www.ruby-forum.com/. From walketim at gmail.com Tue Jan 27 12:33:50 2009 From: walketim at gmail.com (Tim Walker) Date: Tue, 27 Jan 2009 10:33:50 -0700 Subject: [rspec-users] (Cucumber) Non-default folder hierarchy in Cucumber Textmate bundle Message-ID: <1ebf5a4d0901270933w2bc46da0oa864966a3c88aba4@mail.gmail.com> Hi Guys, I refactored my folder hierarchy organizing my cucumber features in sub-folders of features such as model, control, listeners, etc. When I run from the command line now I use the -r features prior to specifying the folder name, all is good. From textmate, APPLE-R, how do I specify the -r? Many TIA, Tim From mark at mwilden.com Tue Jan 27 12:43:37 2009 From: mark at mwilden.com (Mark Wilden) Date: Tue, 27 Jan 2009 09:43:37 -0800 Subject: [rspec-users] rake features does not seem to run rake db:test:prepare In-Reply-To: References: <4a18139fae7c1dee40905547bbe811a2@ruby-forum.com> Message-ID: <3c30da400901270943q1c1eb550q6d454c16f6570aa1@mail.gmail.com> On Tue, Jan 27, 2009 at 9:13 AM, James Byrne wrote: > James Byrne wrote: > > > > > I moved the task :features => 'db:test:prepare' statement from after > > task :features => "features:all" to before it, but this does not > > influence the observed behaviour. > > > > I lied. Evidently moving the the db:test:prepare statement did resolve > the problem after all. > When in doubt, run rake with --trace, and you'll see 1) which tasks are considered as prequisites, and 2) which of these are actually run. For example, I tend to do 'rake db:migrate:redo' when I'm writing a migration, in order to make sure the migration is downable as well as upable. However, I found that it was leaving schema.rb in the 'down' state. Running rake with --trace showed me that the task of writing schema.rb was a prerequisite for both the down and the up - but the dependency had been satisifed by the first invovation, hence it didn't write schema.rb again after the up. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Tue Jan 27 13:00:16 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 27 Jan 2009 11:00:16 -0700 Subject: [rspec-users] (Cucumber) Non-default folder hierarchy in Cucumber Textmate bundle In-Reply-To: <1ebf5a4d0901270933w2bc46da0oa864966a3c88aba4@mail.gmail.com> References: <1ebf5a4d0901270933w2bc46da0oa864966a3c88aba4@mail.gmail.com> Message-ID: <497F4BB0.2070103@benmabey.com> On 1/27/09 10:33 AM, Tim Walker wrote: > Hi Guys, > > I refactored my folder hierarchy organizing my cucumber features in > sub-folders of features such as model, control, listeners, etc. > > When I run from the command line now I use the -r features prior to > specifying the folder name, all is good. From textmate, APPLE-R, how > do I specify the -r? > > Many TIA, > > Tim > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Go to preferences.. Click on Advanced. Click on Shell Variables. Enter new one: Variable: TM_CUCUMBER_OPTS Value: --format=html -r features -Ben From walketim at gmail.com Tue Jan 27 13:10:49 2009 From: walketim at gmail.com (Tim Walker) Date: Tue, 27 Jan 2009 11:10:49 -0700 Subject: [rspec-users] (Cucumber) Non-default folder hierarchy in Cucumber Textmate bundle In-Reply-To: <497F4BB0.2070103@benmabey.com> References: <1ebf5a4d0901270933w2bc46da0oa864966a3c88aba4@mail.gmail.com> <497F4BB0.2070103@benmabey.com> Message-ID: <1ebf5a4d0901271010s1774bc5dlf7dc4ff364cb212a@mail.gmail.com> Sweet. Thank you Ben. Tim On Tue, Jan 27, 2009 at 11:00 AM, Ben Mabey wrote: > On 1/27/09 10:33 AM, Tim Walker wrote: >> >> Hi Guys, >> >> I refactored my folder hierarchy organizing my cucumber features in >> sub-folders of features such as model, control, listeners, etc. >> >> When I run from the command line now I use the -r features prior to >> specifying the folder name, all is good. From textmate, APPLE-R, how >> do I specify the -r? >> >> Many TIA, >> >> Tim >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > Go to preferences.. > Click on Advanced. > Click on Shell Variables. > Enter new one: > > Variable: TM_CUCUMBER_OPTS > Value: --format=html -r features > > -Ben > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cwdinfo at gmail.com Tue Jan 27 14:14:22 2009 From: cwdinfo at gmail.com (s.ross) Date: Tue, 27 Jan 2009 11:14:22 -0800 Subject: [rspec-users] [ANN, Cucumber] Textile Formatter Message-ID: <74375641-A85A-4C7C-8FAF-947C50FB70B3@gmail.com> Sheepishly, I am announcing that I created a textile formatter for Cuke. It was unabashedly ripped out of the HTML formatter, so there is almost certainly a better way to do it. The incentive behind this was my desire to get stories posted on Github. Like, real fast. If only Github let me post automatically... I'm hoping this is of some use and that you won't brutalize me too much for the lack of specs :) --s From nick at deadorange.com Tue Jan 27 14:48:31 2009 From: nick at deadorange.com (Nick Hoffman) Date: Tue, 27 Jan 2009 14:48:31 -0500 Subject: [rspec-users] [RSpec] Cloning objects and leaking state Message-ID: G'day folks. I've been beating my head on this one problem for a couple of hours, and have managed to figure out what's causing it. However, I don't understand why it's happening, nor do I know how to solve or get around it. One of my methods clones an arg, and it seems that doing so causes state to leak out. I discovered this because changing this: new_subtitle = subtitle.clone to this: new_subtitle = subtitle causes the problem to disappear. Before we get into the code snippets, are there any known caveats, warnings, or problems with writing specs that cover the cloning or duplication of objects? Here's the code, specs, and spec output: http://gist.github.com/53482 As you can see, in the "should clone ..." example, the expectation on line 24 succeeds, but the same expectation on line 28 fails. After that, the same expectation fails in the "should not leak state" example. Any idea what's going on? I'd appreciate any help at all. Thanks, Nick From aslak.hellesoy at gmail.com Tue Jan 27 15:09:37 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 27 Jan 2009 21:09:37 +0100 Subject: [rspec-users] [ANN, Cucumber] Textile Formatter In-Reply-To: <74375641-A85A-4C7C-8FAF-947C50FB70B3@gmail.com> References: <74375641-A85A-4C7C-8FAF-947C50FB70B3@gmail.com> Message-ID: <8d961d900901271209i20f12eb3h37d1a3e08093bdd7@mail.gmail.com> On Tue, Jan 27, 2009 at 8:14 PM, s.ross wrote: > Sheepishly, I am announcing that I created a textile formatter for Cuke. It > was unabashedly ripped out of the HTML formatter, so there is almost > certainly a better way to do it. The incentive behind this was my desire to > get stories posted on Github. Like, real fast. If only Github let me post > automatically... > What a great idea! > > I'm hoping this is of some use and that you won't brutalize me too much for > the lack of specs :) > As long as I don't have to maintain untested code I don't care ;-) Unfortunately though - 0.2 is soon out and the formatter API has changed dramatically (and should be pretty stable from now on). I suggest you check out the latest GitHub code (recently merged to master) and refactor your formatter. You'll also find some awesome cucumber features for cucumber. We use this to verify that cucumber's output is as expected. I suggest you do the same with your Textile formatter. If you write features for it I'm happy to include it into Cucumber. Aslak > > --s > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) -------------- next part -------------- An HTML attachment was scrubbed... URL: From sfeley at gmail.com Tue Jan 27 15:23:45 2009 From: sfeley at gmail.com (Stephen Eley) Date: Tue, 27 Jan 2009 15:23:45 -0500 Subject: [rspec-users] testing capistrano tasks In-Reply-To: <1d7ddd110901270908i3a9f9c2ai7c7723dd872c0349@mail.gmail.com> References: <497E8022.60300@railsnewbie.com> <12E02DC8-3624-4C9F-9B40-6D5A14F39CF5@mattwynne.net> <1d7ddd110901270908i3a9f9c2ai7c7723dd872c0349@mail.gmail.com> Message-ID: <1fb4df0901271223p788a9caet4f78dbbcb68f93f2@mail.gmail.com> On Tue, Jan 27, 2009 at 12:08 PM, Brian Takita wrote: > > Yes, I have experience testing capistrano. My experience with unit > testing Capistrano has been less than positive. Capistrano is > difficult to test. Basically you have to mock out the shell/run/file > transfer commands to do unit tests. The big problem is how do you know > the shell commands are correct? Well, you could test them separately in their own unit tests. Write a spec, run it, look for expected output. But the bigger question to me is, unless you're *developing* Capistrano or writing fundamental new tasks for it, why unit test it? To me that's a bit like taking apart my car to test the pieces; I find it more sensible to assume (correctly or not) that they've already been tested at the factory. Integration testing seems a lot more appropriate for a typical deployment, even a complex one. I don't really care what shell commands get run; I care that the end result puts the expected stuff in the expected locations for the inputs I intend to give it, and executes the expected commands. Either way, though, I'd think it would be pretty easy to test in RSpec *or* Cucumber. You could even use Webrat to help. Set up a staging URL, write a stupid little Rails or Sinatra app with a single controller that spits out different known values before and after deployment, run your cap recipe inside your spec, and hit the URL to see if it changed. Add wrinkles as necessary for whatever special thing you're testing that's important to your situation. (If you care about file contents or locations, your Rails controller could show grep results or checksums. If you care about DB migrations, write simple migrations to change DB values and return those. Etc. The micro-app doesn't have to be elegant or proper. It's not the thing being tested.) Does that make sense? I haven't bothered with this sort of thing much because my deployments are never the weird part of my applications, but it seems straightforward. One thing we tend to forget if we're too MVC-Web-focused is that RSpec can test *anything* you can express in Ruby. And you can use Ruby to do anything you can do in the OS. So it's a lot more flexible than just hitting models and controllers. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From scott at railsnewbie.com Tue Jan 27 15:32:40 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Tue, 27 Jan 2009 15:32:40 -0500 Subject: [rspec-users] testing capistrano tasks In-Reply-To: <1d7ddd110901270908i3a9f9c2ai7c7723dd872c0349@mail.gmail.com> References: <497E8022.60300@railsnewbie.com> <12E02DC8-3624-4C9F-9B40-6D5A14F39CF5@mattwynne.net> <1d7ddd110901270908i3a9f9c2ai7c7723dd872c0349@mail.gmail.com> Message-ID: <66E0ACE6-CCD6-426B-9462-7E81B5340983@railsnewbie.com> On Jan 27, 2009, at 12:08 PM, Brian Takita wrote: > On Tue, Jan 27, 2009 at 4:15 AM, Matt Wynne > wrote: >> Not done it, but Cucumber acceptance tests would surely be a good >> fit here: >> >> Given there is a database "foo" >> When I run the script >> Then there should be a backup no more than 10 minutes old >> And the backup should restore OK >> And the restored database should contain the same records as >> the >> original database >> >> On 27 Jan 2009, at 03:31, Scott Taylor wrote: >> >>> >>> Does anyone have any insight into testing capistrano tasks? More >>> specifically, I'm looking to add regression tests to this package, >>> which >>> adds database backup tasks to capistrano: > Yes, I have experience testing capistrano. My experience with unit > testing Capistrano has been less than positive. Capistrano is > difficult to test. Basically you have to mock out the shell/run/file > transfer commands to do unit tests. The big problem is how do you know > the shell commands are correct? > There is some benefit though. You do get to see a list of the shell > commands that are run in one place. However, there can be many > permutations of logic inside of a deploy, so its often difficult to > capture every situation. > > I realize that this sounds terrible, and perhaps there is a better way > to go about this, but this has been my experience. > > IMO, the best way to test Capistrano is to have a staging environment > that simulates your production environment where you deploy to and > make sure things work. > I can't recall a situation where I had non-obvious issues that would > have been prevented with unit tests. Often times, non-obvious issues > are related to properly restarting processes because the monit + shell > script interactions had issues. This is testable, of course. > > You can also do an integration test by deploying to localhost or to a > test box. You can then ensure that the actual db dump exists and > properly restores. > > I'm sorry about the rambling infoflood/rant. I hope it is useful. :-) It's is useful - thanks Brian. Unfortunately the bug involves the listing which comes out of an "ls" command, and a subsequent rm -rf of an old backup file, so it looks like I'll have to do some sort of local deploy strategy. Thanks for the info, Scott From cwdinfo at gmail.com Tue Jan 27 18:55:42 2009 From: cwdinfo at gmail.com (s.ross) Date: Tue, 27 Jan 2009 15:55:42 -0800 Subject: [rspec-users] [ANN, Cucumber] Textile Formatter In-Reply-To: <8d961d900901271209i20f12eb3h37d1a3e08093bdd7@mail.gmail.com> References: <74375641-A85A-4C7C-8FAF-947C50FB70B3@gmail.com> <8d961d900901271209i20f12eb3h37d1a3e08093bdd7@mail.gmail.com> Message-ID: Ok, I created stories http://github.com/sxross/cucumber_textile_formatter/tree/master :) On Jan 27, 2009, at 12:09 PM, aslak hellesoy wrote: > > > On Tue, Jan 27, 2009 at 8:14 PM, s.ross wrote: > Sheepishly, I am announcing that I created a textile formatter for > Cuke. It was unabashedly ripped out of the HTML formatter, so there > is almost certainly a better way to do it. The incentive behind this > was my desire to get stories posted on Github. Like, real fast. If > only Github let me post automatically... > > What a great idea! > > > I'm hoping this is of some use and that you won't brutalize me too > much for the lack of specs :) > > As long as I don't have to maintain untested code I don't care ;-) > > Unfortunately though - 0.2 is soon out and the formatter API has > changed dramatically (and should be pretty stable from now on). I > suggest you check out the latest GitHub code (recently merged to > master) and refactor your formatter. > > You'll also find some awesome cucumber features for cucumber. We use > this to verify that cucumber's output is as expected. I suggest you > do the same with your Textile formatter. If you write features for > it I'm happy to include it into Cucumber. > > Aslak > > > --s > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > > -- > Aslak (::) > _______________________________________________ > 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 dchelimsky at gmail.com Tue Jan 27 19:44:07 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 27 Jan 2009 18:44:07 -0600 Subject: [rspec-users] [RSpec] Cloning objects and leaking state In-Reply-To: References: Message-ID: <57c63afe0901271644s2b13215dmf7fc2aeabadd0bcf@mail.gmail.com> On Tue, Jan 27, 2009 at 1:48 PM, Nick Hoffman wrote: > G'day folks. I've been beating my head on this one problem for a couple of > hours, and have managed to figure out what's causing it. However, I don't > understand why it's happening, nor do I know how to solve or get around it. > > One of my methods clones an arg, and it seems that doing so causes state to > leak out. I discovered this because changing this: > new_subtitle = subtitle.clone > to this: > new_subtitle = subtitle > causes the problem to disappear. > > Before we get into the code snippets, are there any known caveats, warnings, > or problems with writing specs that cover the cloning or duplication of > objects? > > Here's the code, specs, and spec output: > http://gist.github.com/53482 > > As you can see, in the "should clone ..." example, the expectation on line > 24 succeeds, but the same expectation on line 28 fails. After that, the same > expectation fails in the "should not leak state" example. Would you please try doing the same thing without using the clone method specifically. i.e. change the method name in the spec to :copy and then call that in the subject code as well and see if you come up w/ different results. I want to make sure this is really about the clone method itself. > > Any idea what's going on? I'd appreciate any help at all. Thanks, > Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Tue Jan 27 20:31:32 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 28 Jan 2009 02:31:32 +0100 Subject: [rspec-users] [ANN, Cucumber] Textile Formatter In-Reply-To: References: <74375641-A85A-4C7C-8FAF-947C50FB70B3@gmail.com> <8d961d900901271209i20f12eb3h37d1a3e08093bdd7@mail.gmail.com> Message-ID: <8d961d900901271731i65ac4ad1qefd58a62c2b95795@mail.gmail.com> On Wed, Jan 28, 2009 at 12:55 AM, s.ross wrote: > > Ok, I created stories > http://github.com/sxross/cucumber_textile_formatter/tree/master > :) > On Jan 27, 2009, at 12:09 PM, aslak hellesoy wrote: > I'm inviting EVERYBODY to help design a new HTML format for Cucumber 0.2's new HTML formatter. ---> http://tinyurl.com/cuke-html <--- Aslak > > On Tue, Jan 27, 2009 at 8:14 PM, s.ross wrote: >> >> Sheepishly, I am announcing that I created a textile formatter for Cuke. It was unabashedly ripped out of the HTML formatter, so there is almost certainly a better way to do it. The incentive behind this was my desire to get stories posted on Github. Like, real fast. If only Github let me post automatically... > > What a great idea! > >> >> I'm hoping this is of some use and that you won't brutalize me too much for the lack of specs :) > > As long as I don't have to maintain untested code I don't care ;-) > > Unfortunately though - 0.2 is soon out and the formatter API has changed dramatically (and should be pretty stable from now on). I suggest you check out the latest GitHub code (recently merged to master) and refactor your formatter. > > You'll also find some awesome cucumber features for cucumber. We use this to verify that cucumber's output is as expected. I suggest you do the same with your Textile formatter. If you write features for it I'm happy to include it into Cucumber. > > Aslak > >> >> --s >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > -- > Aslak (::) > _______________________________________________ > 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 -- Aslak (::) From nick at deadorange.com Tue Jan 27 22:52:09 2009 From: nick at deadorange.com (Nick Hoffman) Date: Tue, 27 Jan 2009 22:52:09 -0500 Subject: [rspec-users] [RSpec] Cloning objects and leaking state In-Reply-To: <57c63afe0901271644s2b13215dmf7fc2aeabadd0bcf@mail.gmail.com> References: <57c63afe0901271644s2b13215dmf7fc2aeabadd0bcf@mail.gmail.com> Message-ID: On 27/01/2009, at 7:44 PM, David Chelimsky wrote: > On Tue, Jan 27, 2009 at 1:48 PM, Nick Hoffman > wrote: >> G'day folks. I've been beating my head on this one problem for a >> couple of >> hours, and have managed to figure out what's causing it. However, I >> don't >> understand why it's happening, nor do I know how to solve or get >> around it. >> >> One of my methods clones an arg, and it seems that doing so causes >> state to >> leak out. I discovered this because changing this: >> new_subtitle = subtitle.clone >> to this: >> new_subtitle = subtitle >> causes the problem to disappear. >> >> Before we get into the code snippets, are there any known caveats, >> warnings, >> or problems with writing specs that cover the cloning or >> duplication of >> objects? >> >> Here's the code, specs, and spec output: >> http://gist.github.com/53482 >> >> As you can see, in the "should clone ..." example, the expectation >> on line >> 24 succeeds, but the same expectation on line 28 fails. After that, >> the same >> expectation fails in the "should not leak state" example. > > Would you please try doing the same thing without using the clone > method specifically. i.e. change the method name in the spec to :copy > and then call that in the subject code as well and see if you come up > w/ different results. I want to make sure this is really about the > clone method itself. I removed the call to #clone from the instance method, and lo and behold, the problem persists: http://tinyurl.com/cl8rvy I don't know why, because when I posted the first email in this thread, this seemed to resolve it. I also tried replacing #clone with #dup, and the problem still occurs: http://tinyurl.com/dzuvrd Now I'm even more flummoxed. If the #clone isn't causing this problem, what is? Can I do anything else to help others help me with this? Thanks, guys! Nick From matt at mattwynne.net Wed Jan 28 05:39:56 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 28 Jan 2009 10:39:56 +0000 Subject: [rspec-users] testing capistrano tasks In-Reply-To: <1d7ddd110901270908i3a9f9c2ai7c7723dd872c0349@mail.gmail.com> References: <497E8022.60300@railsnewbie.com> <12E02DC8-3624-4C9F-9B40-6D5A14F39CF5@mattwynne.net> <1d7ddd110901270908i3a9f9c2ai7c7723dd872c0349@mail.gmail.com> Message-ID: On 27 Jan 2009, at 17:08, Brian Takita wrote: > On Tue, Jan 27, 2009 at 4:15 AM, Matt Wynne > wrote: >> Not done it, but Cucumber acceptance tests would surely be a good >> fit here: >> >> Given there is a database "foo" >> When I run the script >> Then there should be a backup no more than 10 minutes old >> And the backup should restore OK >> And the restored database should contain the same records as >> the >> original database >> >> On 27 Jan 2009, at 03:31, Scott Taylor wrote: >> >>> >>> Does anyone have any insight into testing capistrano tasks? More >>> specifically, I'm looking to add regression tests to this package, >>> which >>> adds database backup tasks to capistrano: > Yes, I have experience testing capistrano. My experience with unit > testing Capistrano has been less than positive. Capistrano is > difficult to test. Basically you have to mock out the shell/run/file > transfer commands to do unit tests. The big problem is how do you know > the shell commands are correct? > There is some benefit though. You do get to see a list of the shell > commands that are run in one place. However, there can be many > permutations of logic inside of a deploy, so its often difficult to > capture every situation. > > I realize that this sounds terrible, and perhaps there is a better way > to go about this, but this has been my experience. > > IMO, the best way to test Capistrano is to have a staging environment > that simulates your production environment where you deploy to and > make sure things work. > I can't recall a situation where I had non-obvious issues that would > have been prevented with unit tests. Often times, non-obvious issues > are related to properly restarting processes because the monit + shell > script interactions had issues. This is testable, of course. That's why I suggested *acceptance tests* in Cucumber. I don't think mocking / unit testing is going to get you much value here - what you need is something that feeds back whether the whole thing works. So yeah you'll need a sandbox / staging environment for that. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From matt at mattwynne.net Wed Jan 28 05:43:22 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 28 Jan 2009 10:43:22 +0000 Subject: [rspec-users] (Cucumber) Non-default folder hierarchy in Cucumber Textmate bundle In-Reply-To: <1ebf5a4d0901270933w2bc46da0oa864966a3c88aba4@mail.gmail.com> References: <1ebf5a4d0901270933w2bc46da0oa864966a3c88aba4@mail.gmail.com> Message-ID: On 27 Jan 2009, at 17:33, Tim Walker wrote: > I refactored my folder hierarchy organizing my cucumber features in > sub-folders of features such as model, control, listeners, etc. Wow - are you using Cucumber to write unit tests? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From zach.dennis at gmail.com Wed Jan 28 07:50:21 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 28 Jan 2009 07:50:21 -0500 Subject: [rspec-users] [RSpec] Cloning objects and leaking state In-Reply-To: References: Message-ID: <85d99afe0901280450i4de7df4w2701248e3e9bad78@mail.gmail.com> On Tue, Jan 27, 2009 at 2:48 PM, Nick Hoffman wrote: > G'day folks. I've been beating my head on this one problem for a couple of > hours, and have managed to figure out what's causing it. However, I don't > understand why it's happening, nor do I know how to solve or get around it. > > One of my methods clones an arg, and it seems that doing so causes state to > leak out. I discovered this because changing this: > new_subtitle = subtitle.clone > to this: > new_subtitle = subtitle > causes the problem to disappear. > > Before we get into the code snippets, are there any known caveats, warnings, > or problems with writing specs that cover the cloning or duplication of > objects? > > Here's the code, specs, and spec output: > http://gist.github.com/53482 > > As you can see, in the "should clone ..." example, the expectation on line > 24 succeeds, but the same expectation on line 28 fails. After that, the same > expectation fails in the "should not leak state" example. What does your full SubtitleFile class look like? It looks like there is an issue with how the #subtitles method is storing information. Since you're using ActiveRecord::BaseWithoutTable there are probably not going to be any unique primary keys amongst your SubtitleFiles to help differentiate them. So if #subtitles is a has_many, every call to SubtitleFile#subtitles may lookup Subtitles in the exact same way w/o any unique key to use to differentiate which subtitles belong to which subtitle files which would produce the results you are seeing. Is Subtitle a ActiveRecord::BaseWithoutTable or a real ActiveRecord::Base model? > > Any idea what's going on? I'd appreciate any help at all. Thanks, > Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From lists at ruby-forum.com Wed Jan 28 09:32:42 2009 From: lists at ruby-forum.com (Juanma Cervera) Date: Wed, 28 Jan 2009 15:32:42 +0100 Subject: [rspec-users] Testing Sub-domains with Cucumber In-Reply-To: <111BD9CD-9A21-45FD-9DC1-64D6F8B727D0@parkerhill.com> References: <29b759687200a33844962fe1866bccb3@ruby-forum.com> <248944FF-31A5-4219-8B30-159E4225E2A6@parkerhill.com> <111BD9CD-9A21-45FD-9DC1-64D6F8B727D0@parkerhill.com> Message-ID: <98e88ac33c25b3f17fd1d0431ffc51b6@ruby-forum.com> Jonathan Linowes wrote: > On Jan 14, 2009, at 11:39 AM, Tom Hoen wrote: > >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > for example, > > Given /^a "(.+)" account$/ do |name| > account = Account.create( :name => name ) > host! "#{account.to_param}.example.com" > end Can somebody point me to the documentation of host!, or explain what is it. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Jan 28 10:15:39 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Wed, 28 Jan 2009 16:15:39 +0100 Subject: [rspec-users] webrat methods are undefined Message-ID: <897488b954d8536cb88314d26c128d13@ruby-forum.com> I am sure it is just a configuration issue, but when I use any of the steps in the webrat_steps.rb file, I get messages like: undefined method `click_link' I have the webrat gem installed (0.3.4). I have the aslakhellesoy-webrat (0.3.2.2) gem installed, and I have the webrat plugin installed. In my cucumber env.rb file I have the following. require 'webrat' if !defined?(Webrat) # Comment out the next two lines if you're not using RSpec's matchers (should should_not) in your steps. require 'cucumber/rails/rspec' #require 'webrat/rspec-rails' So I am sure I have munged the setup. Any advice would be appreciated. Not withstanding, cucumber works, just not the webrat steps Best, Tom -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed Jan 28 10:53:09 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 28 Jan 2009 09:53:09 -0600 Subject: [rspec-users] webrat methods are undefined In-Reply-To: <897488b954d8536cb88314d26c128d13@ruby-forum.com> References: <897488b954d8536cb88314d26c128d13@ruby-forum.com> Message-ID: <57c63afe0901280753g45607037nafff0ea84ae67858@mail.gmail.com> On Wed, Jan 28, 2009 at 9:15 AM, Tom Hoen wrote: > I am sure it is just a configuration issue, but when I use any of the > steps in the webrat_steps.rb file, I get messages like: > > undefined method `click_link' > > I have the webrat gem installed (0.3.4). I have the aslakhellesoy-webrat > (0.3.2.2) gem installed, and I have the webrat plugin installed. I had this problem and upgraded to webrat-0.4.0 and it went away. I think that the aslakhellesoy-webrat gem was a temporary solution to incompatibilities and is out of date at this point. HTH, David > > In my cucumber env.rb file I have the following. > require 'webrat' if !defined?(Webrat) > > # Comment out the next two lines if you're not using RSpec's matchers > (should should_not) in your steps. > require 'cucumber/rails/rspec' > #require 'webrat/rspec-rails' > > So I am sure I have munged the setup. Any advice would be appreciated. > > Not withstanding, cucumber works, just not the webrat steps > > Best, > Tom > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Wed Jan 28 10:55:30 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 28 Jan 2009 15:55:30 +0000 Subject: [rspec-users] webrat methods are undefined In-Reply-To: <897488b954d8536cb88314d26c128d13@ruby-forum.com> References: <897488b954d8536cb88314d26c128d13@ruby-forum.com> Message-ID: On 28 Jan 2009, at 15:15, Tom Hoen wrote: > I am sure it is just a configuration issue, but when I use any of the > steps in the webrat_steps.rb file, I get messages like: > > undefined method `click_link' > > I have the webrat gem installed (0.3.4). I have the aslakhellesoy- > webrat > (0.3.2.2) gem installed, and I have the webrat plugin installed. > > In my cucumber env.rb file I have the following. > require 'webrat' if !defined?(Webrat) > > # Comment out the next two lines if you're not using RSpec's matchers > (should should_not) in your steps. > require 'cucumber/rails/rspec' > #require 'webrat/rspec-rails' > > So I am sure I have munged the setup. Any advice would be appreciated. Hi Tom, I should update to the new version of webrat (0.4) and cucumber (can't remember) as this stuff has gone through some churn but stabilised following that 0.4 release. Check the webrat docs, but (with that new version) I think you need to do something like Webrat.configure do |config| config.mode = :rails end You won't need the aslakhellesoy gem anymore either I don't think. Please let us know if you were misguided by any out-of-date documentation. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From matt at mattwynne.net Wed Jan 28 10:58:55 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 28 Jan 2009 15:58:55 +0000 Subject: [rspec-users] Testing Sub-domains with Cucumber In-Reply-To: <98e88ac33c25b3f17fd1d0431ffc51b6@ruby-forum.com> References: <29b759687200a33844962fe1866bccb3@ruby-forum.com> <248944FF-31A5-4219-8B30-159E4225E2A6@parkerhill.com> <111BD9CD-9A21-45FD-9DC1-64D6F8B727D0@parkerhill.com> <98e88ac33c25b3f17fd1d0431ffc51b6@ruby-forum.com> Message-ID: <31175DF3-E57F-4E62-B30C-6A8FA1D2EEBB@mattwynne.net> On 28 Jan 2009, at 14:32, Juanma Cervera wrote: > Jonathan Linowes wrote: >> On Jan 14, 2009, at 11:39 AM, Tom Hoen wrote: >> for example, >> >> Given /^a "(.+)" account$/ do |name| >> account = Account.create( :name => name ) >> host! "#{account.to_param}.example.com" >> end > > Can somebody point me to the documentation of host!, or explain what > is > it. http://apidock.com/rails/ActionController/Integration/Session/host! Matt Wynne http://blog.mattwynne.net http://www.songkick.com From mr.gaffo at gmail.com Wed Jan 28 10:01:53 2009 From: mr.gaffo at gmail.com (Mike Gaffney) Date: Wed, 28 Jan 2009 09:01:53 -0600 Subject: [rspec-users] testing capistrano tasks In-Reply-To: References: <497E8022.60300@railsnewbie.com> <12E02DC8-3624-4C9F-9B40-6D5A14F39CF5@mattwynne.net> <1d7ddd110901270908i3a9f9c2ai7c7723dd872c0349@mail.gmail.com> Message-ID: <49807361.2010004@gmail.com> We actually have a machine that is a perfect clone of the production machine. The only difference is the passwords. We test all deployments to it first. We call it staging. Having a staging has 2 benefits: 1) We can test our deployment scripts, migrations, etc on as close as we can get to production. 2) If the production box dies, we have one that can take it's place very quickly (change the database passwords/pointers and go). We also have a demo box that is updated via capistrano whenever the build passes. Testing configuration / deployment is hard because you can assert that the config is what you think it is, but that in no way proves that it's actually working. It's like using mocks to build up functionality against a mock library. At some point you actually have to test against the real thing or you're just guessing. -Mike Matt Wynne wrote: > > On 27 Jan 2009, at 17:08, Brian Takita wrote: > >> On Tue, Jan 27, 2009 at 4:15 AM, Matt Wynne wrote: >>> Not done it, but Cucumber acceptance tests would surely be a good >>> fit here: >>> >>> Given there is a database "foo" >>> When I run the script >>> Then there should be a backup no more than 10 minutes old >>> And the backup should restore OK >>> And the restored database should contain the same records as the >>> original database >>> >>> On 27 Jan 2009, at 03:31, Scott Taylor wrote: >>> >>>> >>>> Does anyone have any insight into testing capistrano tasks? More >>>> specifically, I'm looking to add regression tests to this package, >>>> which >>>> adds database backup tasks to capistrano: >> Yes, I have experience testing capistrano. My experience with unit >> testing Capistrano has been less than positive. Capistrano is >> difficult to test. Basically you have to mock out the shell/run/file >> transfer commands to do unit tests. The big problem is how do you know >> the shell commands are correct? >> There is some benefit though. You do get to see a list of the shell >> commands that are run in one place. However, there can be many >> permutations of logic inside of a deploy, so its often difficult to >> capture every situation. >> >> I realize that this sounds terrible, and perhaps there is a better way >> to go about this, but this has been my experience. >> >> IMO, the best way to test Capistrano is to have a staging environment >> that simulates your production environment where you deploy to and >> make sure things work. >> I can't recall a situation where I had non-obvious issues that would >> have been prevented with unit tests. Often times, non-obvious issues >> are related to properly restarting processes because the monit + shell >> script interactions had issues. This is testable, of course. > > That's why I suggested *acceptance tests* in Cucumber. I don't think > mocking / unit testing is going to get you much value here - what you > need is something that feeds back whether the whole thing works. So > yeah you'll need a sandbox / staging environment for that. > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Wed Jan 28 11:29:30 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Wed, 28 Jan 2009 17:29:30 +0100 Subject: [rspec-users] webrat methods are undefined In-Reply-To: References: <897488b954d8536cb88314d26c128d13@ruby-forum.com> Message-ID: Hey Matt - > I should update to the new version of webrat (0.4) and cucumber (can't > remember) as this stuff has gone through some churn but stabilised > following that 0.4 release. > > Check the webrat docs, but (with that new version) I think you need to > do something like > > Webrat.configure do |config| > config.mode = :rails > end > > You won't need the aslakhellesoy gem anymore either I don't think. > > Please let us know if you were misguided by any out-of-date > documentation. > I uninstalled the aslakhellesoy gem and installed/updated the webrat gem to 0.4 I changed the env.rb file to match the docs Now I get `load_missing_constant': Expected /mnt/hgfs/projects/classroomparent/vendor/plugins/webrat/lib/webrat.rb to define Webrat (LoadError) Do I need to have the gem and the plugin both installed? The documentation I read was here http://wiki.github.com/aslakhellesoy/cucumber/ruby-on-rails, but it looks like it has been updated, though it doesn't include the instructions on configuring webrat. I really appreciate your help. Tom -- Posted via http://www.ruby-forum.com/. From nick at deadorange.com Wed Jan 28 11:30:07 2009 From: nick at deadorange.com (Nick Hoffman) Date: Wed, 28 Jan 2009 11:30:07 -0500 Subject: [rspec-users] [RSpec] Cloning objects and leaking state In-Reply-To: <85d99afe0901280450i4de7df4w2701248e3e9bad78@mail.gmail.com> References: <85d99afe0901280450i4de7df4w2701248e3e9bad78@mail.gmail.com> Message-ID: <0EE1BC5C-05C4-46E5-B90B-DA7A524C65E9@deadorange.com> On 28/01/2009, at 7:50 AM, Zach Dennis wrote: > On Tue, Jan 27, 2009 at 2:48 PM, Nick Hoffman > wrote: >> G'day folks. I've been beating my head on this one problem for a >> couple of >> hours, and have managed to figure out what's causing it. However, I >> don't >> understand why it's happening, nor do I know how to solve or get >> around it. >> >> One of my methods clones an arg, and it seems that doing so causes >> state to >> leak out. I discovered this because changing this: >> new_subtitle = subtitle.clone >> to this: >> new_subtitle = subtitle >> causes the problem to disappear. >> >> Before we get into the code snippets, are there any known caveats, >> warnings, >> or problems with writing specs that cover the cloning or >> duplication of >> objects? >> >> Here's the code, specs, and spec output: >> http://gist.github.com/53482 >> >> As you can see, in the "should clone ..." example, the expectation >> on line >> 24 succeeds, but the same expectation on line 28 fails. After that, >> the same >> expectation fails in the "should not leak state" example. > > What does your full SubtitleFile class look like? It looks like there > is an issue with how the #subtitles method is storing information. > > Since you're using ActiveRecord::BaseWithoutTable there are probably > not going to be any unique primary keys amongst your SubtitleFiles to > help differentiate them. So if #subtitles is a has_many, every call to > SubtitleFile#subtitles may lookup Subtitles in the exact same way w/o > any unique key to use to differentiate which subtitles belong to which > subtitle files which would produce the results you are seeing. > > Is Subtitle a ActiveRecord::BaseWithoutTable or a real > ActiveRecord::Base model? Hi Zach. Subtitle is an ActiveRecord::BaseWithoutTable model; it does not inherit from ActiveRecord::Base . The SubtitleFile "subtitles" attribute is actually just an Array. I didn't bother to setup a has_many relationship with Subtitle. SubtitleFile#subtitles is a standard getter method that ActiveRecord sets up for me. In my app's console, I tested out a has_many relationship between two ActiveRecord::BaseWithoutTable models, and there weren't any mixups after creating associations between different model instances. Here's the source for the SubtitleFile model. The #add_subtitle! in question starts on line 74: http://gist.github.com/54028 Thanks, mate. Nick From lists at ruby-forum.com Wed Jan 28 11:32:34 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Wed, 28 Jan 2009 17:32:34 +0100 Subject: [rspec-users] webrat methods are undefined In-Reply-To: References: <897488b954d8536cb88314d26c128d13@ruby-forum.com> Message-ID: Appears that I did not fully remove the webrat plugin, and this was causing the problem. Thanks again for your help. -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Wed Jan 28 11:54:47 2009 From: ben at benmabey.com (Ben Mabey) Date: Wed, 28 Jan 2009 09:54:47 -0700 Subject: [rspec-users] [Cucumber, TextMate Bundle] Call for help Message-ID: <49808DD7.9030100@benmabey.com> Hey all, As some of you may know I created the Cucumber TextMate bundle: http://github.com/bmabey/cucumber-tmbundle/tree/master What most of you probably don't know is that I stopped using TextMate (in favor of Vim) several months ago. Since then the Cucumber bundle has been somewhat neglected by me and I've mostly pulled in patches and regenerated the syntax for new languages. I think there are a lot of cool things that could still be done with the bundle (see the TODO list in the README), but I just don't see myself doing a lot of them without the motivation I once had. Is there anyone on the list with the motivation to take the lead on this project and start adding new features to it? There is a little bit of cruft from the old rspec story runner bundle but all in all the code is reasonably clean with specs behind it. I'm still happy to help out, but I don't see myself moving too fast without other contributors. :) Thanks in advance, Ben From lists at ruby-forum.com Wed Jan 28 11:55:49 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Wed, 28 Jan 2009 17:55:49 +0100 Subject: [rspec-users] webrat methods are undefined In-Reply-To: References: <897488b954d8536cb88314d26c128d13@ruby-forum.com> Message-ID: <27253a92e9ba59a23181303eb39111d6@ruby-forum.com> Tom Hoen wrote: > Appears that I did not fully remove the webrat plugin, and this was > causing the problem. > > Thanks again for your help. Perhaps I should request this in a new topic, but it could be another simple mistake I am making. I have the following scenario Scenario: Login Given I am using the "rpems" domain Given I am logged in as an admin user Then I should see "Classrooms" And I should see "School Year: 2008-2009" And I should see "Users" What ends up happening is after the admin login, instead of seeing the Classrooms page, the next bit of html delivered is "You are being
redirected. Is there something special I should be doing to handle redirects. After reading this (http://www.nabble.com/Cucumber,-Webrat-and-http-basic-auth-td20598510.html) my impression was that redirects are handled internally to webrat and cucumber and don't need to be explicitly handled in the scenarios. Your thoughts are greatly appreciated. Best, Tom -- Posted via http://www.ruby-forum.com/. From pergesu at gmail.com Wed Jan 28 12:12:28 2009 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 28 Jan 2009 09:12:28 -0800 Subject: [rspec-users] [RSpec] Cloning objects and leaking state In-Reply-To: <0EE1BC5C-05C4-46E5-B90B-DA7A524C65E9@deadorange.com> References: <85d99afe0901280450i4de7df4w2701248e3e9bad78@mail.gmail.com> <0EE1BC5C-05C4-46E5-B90B-DA7A524C65E9@deadorange.com> Message-ID: <810a540e0901280912v6d1b63by27cf4055cb4f405a@mail.gmail.com> On Wed, Jan 28, 2009 at 8:30 AM, Nick Hoffman wrote: > On 28/01/2009, at 7:50 AM, Zach Dennis wrote: >> >> On Tue, Jan 27, 2009 at 2:48 PM, Nick Hoffman wrote: >>> >>> G'day folks. I've been beating my head on this one problem for a couple >>> of >>> hours, and have managed to figure out what's causing it. However, I don't >>> understand why it's happening, nor do I know how to solve or get around >>> it. >>> >>> One of my methods clones an arg, and it seems that doing so causes state >>> to >>> leak out. I discovered this because changing this: >>> new_subtitle = subtitle.clone >>> to this: >>> new_subtitle = subtitle >>> causes the problem to disappear. >>> >>> Before we get into the code snippets, are there any known caveats, >>> warnings, >>> or problems with writing specs that cover the cloning or duplication of >>> objects? >>> >>> Here's the code, specs, and spec output: >>> http://gist.github.com/53482 >>> >>> As you can see, in the "should clone ..." example, the expectation on >>> line >>> 24 succeeds, but the same expectation on line 28 fails. After that, the >>> same >>> expectation fails in the "should not leak state" example. >> >> What does your full SubtitleFile class look like? It looks like there >> is an issue with how the #subtitles method is storing information. >> >> Since you're using ActiveRecord::BaseWithoutTable there are probably >> not going to be any unique primary keys amongst your SubtitleFiles to >> help differentiate them. So if #subtitles is a has_many, every call to >> SubtitleFile#subtitles may lookup Subtitles in the exact same way w/o >> any unique key to use to differentiate which subtitles belong to which >> subtitle files which would produce the results you are seeing. >> >> Is Subtitle a ActiveRecord::BaseWithoutTable or a real ActiveRecord::Base >> model? > > Hi Zach. Subtitle is an ActiveRecord::BaseWithoutTable model; it does not > inherit from ActiveRecord::Base . > > The SubtitleFile "subtitles" attribute is actually just an Array. I didn't > bother to setup a has_many relationship with Subtitle. > SubtitleFile#subtitles is a standard getter method that ActiveRecord sets up > for me. > > In my app's console, I tested out a has_many relationship between two > ActiveRecord::BaseWithoutTable models, and there weren't any mixups after > creating associations between different model instances. > > Here's the source for the SubtitleFile model. The #add_subtitle! in question > starts on line 74: > http://gist.github.com/54028 I'm not familiar with this library, so I can't say for sure, but the line default :subtitles => [] looks very suspicious to me. The underlying library code would have to do a .clone of that default value, otherwise all instances will share the same array (meaning if you push a value onto it, the next instance will have that array with one element). If it doesn't automatically clone (it may, I don't know), it probably should provide a lambda syntax so you can do: default :subtitles => lambda { [] } Pat From pergesu at gmail.com Wed Jan 28 12:16:23 2009 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 28 Jan 2009 09:16:23 -0800 Subject: [rspec-users] [RSpec] Cloning objects and leaking state In-Reply-To: <810a540e0901280912v6d1b63by27cf4055cb4f405a@mail.gmail.com> References: <85d99afe0901280450i4de7df4w2701248e3e9bad78@mail.gmail.com> <0EE1BC5C-05C4-46E5-B90B-DA7A524C65E9@deadorange.com> <810a540e0901280912v6d1b63by27cf4055cb4f405a@mail.gmail.com> Message-ID: <810a540e0901280916o6ef0c960o8cf172699acdc650@mail.gmail.com> > If it doesn't automatically clone (it may, I don't know), it probably > should provide a lambda syntax so you can do: > default :subtitles => lambda { [] } Yeah, I just looked at the code for ARD and this is the problem. You can pass in immutable objects and they don't get affected for obvious reasons. But with a mutable object like an array, you need to pass it a lambda so that it's creating a new instance each time. Pat From zach.dennis at gmail.com Wed Jan 28 12:33:14 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 28 Jan 2009 12:33:14 -0500 Subject: [rspec-users] webrat methods are undefined In-Reply-To: <27253a92e9ba59a23181303eb39111d6@ruby-forum.com> References: <897488b954d8536cb88314d26c128d13@ruby-forum.com> <27253a92e9ba59a23181303eb39111d6@ruby-forum.com> Message-ID: <85d99afe0901280933y532204eew37ae49b58f430f70@mail.gmail.com> On Wed, Jan 28, 2009 at 11:55 AM, Tom Hoen wrote: > Tom Hoen wrote: >> Appears that I did not fully remove the webrat plugin, and this was >> causing the problem. >> >> Thanks again for your help. > > Perhaps I should request this in a new topic, but it could be another > simple mistake I am making. > > I have the following scenario > > Scenario: Login > Given I am using the "rpems" domain > Given I am logged in as an admin user > Then I should see "Classrooms" > And I should see "School Year: 2008-2009" > And I should see "Users" > > > What ends up happening is after the admin login, instead of seeing the > Classrooms page, the next bit of html delivered is > > "You are being href=\"http://rpems.test/classrooms\">redirected. > > Is there something special I should be doing to handle redirects. After > reading this > (http://www.nabble.com/Cucumber,-Webrat-and-http-basic-auth-td20598510.html) > my impression was that redirects are handled internally to webrat and > cucumber and don't need to be explicitly handled in the scenarios. > > Your thoughts are greatly appreciated. There are a number of fixes for redirects and subdomain related functionality which are currently tagged for the 0.4.1 release. I had this problem after upgrading to 0.4.0, and have since updated to edge until 0.4.1 is out. http://webrat.lighthouseapp.com/projects/10503-webrat/tickets?q=redirect&filter= -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From nick at deadorange.com Wed Jan 28 12:41:54 2009 From: nick at deadorange.com (Nick Hoffman) Date: Wed, 28 Jan 2009 12:41:54 -0500 Subject: [rspec-users] [RSpec] Cloning objects and leaking state In-Reply-To: <810a540e0901280912v6d1b63by27cf4055cb4f405a@mail.gmail.com> References: <85d99afe0901280450i4de7df4w2701248e3e9bad78@mail.gmail.com> <0EE1BC5C-05C4-46E5-B90B-DA7A524C65E9@deadorange.com> <810a540e0901280912v6d1b63by27cf4055cb4f405a@mail.gmail.com> Message-ID: On 28/01/2009, at 12:12 PM, Pat Maddox wrote: > On Wed, Jan 28, 2009 at 8:30 AM, Nick Hoffman > wrote: >> On 28/01/2009, at 7:50 AM, Zach Dennis wrote: >>> >>> On Tue, Jan 27, 2009 at 2:48 PM, Nick Hoffman >>> wrote: >>>> >>>> G'day folks. I've been beating my head on this one problem for a >>>> couple >>>> of >>>> hours, and have managed to figure out what's causing it. However, >>>> I don't >>>> understand why it's happening, nor do I know how to solve or get >>>> around >>>> it. >>>> >>>> One of my methods clones an arg, and it seems that doing so >>>> causes state >>>> to >>>> leak out. I discovered this because changing this: >>>> new_subtitle = subtitle.clone >>>> to this: >>>> new_subtitle = subtitle >>>> causes the problem to disappear. >>>> >>>> Before we get into the code snippets, are there any known caveats, >>>> warnings, >>>> or problems with writing specs that cover the cloning or >>>> duplication of >>>> objects? >>>> >>>> Here's the code, specs, and spec output: >>>> http://gist.github.com/53482 >>>> >>>> As you can see, in the "should clone ..." example, the >>>> expectation on >>>> line >>>> 24 succeeds, but the same expectation on line 28 fails. After >>>> that, the >>>> same >>>> expectation fails in the "should not leak state" example. >>> >>> What does your full SubtitleFile class look like? It looks like >>> there >>> is an issue with how the #subtitles method is storing information. >>> >>> Since you're using ActiveRecord::BaseWithoutTable there are probably >>> not going to be any unique primary keys amongst your SubtitleFiles >>> to >>> help differentiate them. So if #subtitles is a has_many, every >>> call to >>> SubtitleFile#subtitles may lookup Subtitles in the exact same way >>> w/o >>> any unique key to use to differentiate which subtitles belong to >>> which >>> subtitle files which would produce the results you are seeing. >>> >>> Is Subtitle a ActiveRecord::BaseWithoutTable or a real >>> ActiveRecord::Base >>> model? >> >> Hi Zach. Subtitle is an ActiveRecord::BaseWithoutTable model; it >> does not >> inherit from ActiveRecord::Base . >> >> The SubtitleFile "subtitles" attribute is actually just an Array. I >> didn't >> bother to setup a has_many relationship with Subtitle. >> SubtitleFile#subtitles is a standard getter method that >> ActiveRecord sets up >> for me. >> >> In my app's console, I tested out a has_many relationship between two >> ActiveRecord::BaseWithoutTable models, and there weren't any mixups >> after >> creating associations between different model instances. >> >> Here's the source for the SubtitleFile model. The #add_subtitle! in >> question >> starts on line 74: >> http://gist.github.com/54028 > > I'm not familiar with this library, so I can't say for sure, but the > line > default :subtitles => [] > looks very suspicious to me. > > The underlying library code would have to do a .clone of that default > value, otherwise all instances will share the same array (meaning if > you push a value onto it, the next instance will have that array with > one element). > > If it doesn't automatically clone (it may, I don't know), it probably > should provide a lambda syntax so you can do: > default :subtitles => lambda { [] } > > Pat Pat, the lambda fixed the problem. That's a keen spidey sense you have there! To spell this out in more detail, having defaults :subtitles => [] causes the SubtitleFile class to initialise an Array when the class is defined. From then on, the "subtitles" attribute of all SubtitleFile instances will refer to that one specific array. Thanks for your help with this, mate. It's much appreciated. Nick From nick at deadorange.com Wed Jan 28 12:49:39 2009 From: nick at deadorange.com (Nick Hoffman) Date: Wed, 28 Jan 2009 12:49:39 -0500 Subject: [rspec-users] [RSpec] Cloning objects and leaking state In-Reply-To: <810a540e0901280916o6ef0c960o8cf172699acdc650@mail.gmail.com> References: <85d99afe0901280450i4de7df4w2701248e3e9bad78@mail.gmail.com> <0EE1BC5C-05C4-46E5-B90B-DA7A524C65E9@deadorange.com> <810a540e0901280912v6d1b63by27cf4055cb4f405a@mail.gmail.com> <810a540e0901280916o6ef0c960o8cf172699acdc650@mail.gmail.com> Message-ID: <9A3E43AC-C904-4986-86E8-F0CCF197FF01@deadorange.com> On 28/01/2009, at 12:16 PM, Pat Maddox wrote: >> If it doesn't automatically clone (it may, I don't know), it probably >> should provide a lambda syntax so you can do: >> default :subtitles => lambda { [] } > > Yeah, I just looked at the code for ARD and this is the problem. You > can pass in immutable objects and they don't get affected for obvious > reasons. But with a mutable object like an array, you need to pass it > a lambda so that it's creating a new instance each time. > > Pat That makes a lot of sense. The active_record_defaults README[1] shows strings being used for default values. The problem that I experienced in this thread will plague the README's example if a non-assignment operation is performed on the attribute. [1] http://svn.viney.net.nz/things/rails/plugins/active_record_defaults/README Thanks again, Pat, David, and Zach! Nick From nick at deadorange.com Wed Jan 28 13:29:41 2009 From: nick at deadorange.com (Nick Hoffman) Date: Wed, 28 Jan 2009 13:29:41 -0500 Subject: [rspec-users] [RSpec] Error when returning multiple values from a stub In-Reply-To: References: Message-ID: <39CA56D1-7984-487F-A611-5E281E22398E@deadorange.com> On 27/01/2009, at 11:03 AM, Nick Hoffman wrote: > Hey guys. I've just found some odd behaviour within RSpec 1.1.12 , > and would like to know whether this is a bug, or I'm doing something > wrong. > > When I give multiple return values to a stub, like this: > SubtitleFile.stub!(:new).and_return @sf1, @sf2 > RSpec complains: > Mock 'SubtitleFile_1001' received unexpected message :size with (no > args) > > However, if I break that into two stubs, like this: > SubtitleFile.stub!(:new).and_return @sf1 > SubtitleFile.stub!(:new).and_return @sf2 > the spec passes. > > I've posted a more concrete example here: > http://gist.github.com/53389 > > In code pane #2, if I comment line 13 and uncomment lines 14 and 15, > the spec passes. > > Any idea what's going on? Thanks for your help, > Nick I've managed to cut even more code from the controller and specs while continuing to reproduce the problem: http://gist.github.com/53389 If I change this line: SubtitleFile.stub!(:new).and_return @sf1, @sf2 to this: SubtitleFile.stub!(:new).and_return @sf1 then the problem disappears. Why does providing a second argument to #and_return cause #size to be called on the "@sf1" mock? Thanks in advance for any help with this, guys. Nick From lists at ruby-forum.com Wed Jan 28 13:37:18 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Wed, 28 Jan 2009 19:37:18 +0100 Subject: [rspec-users] webrat methods are undefined In-Reply-To: <85d99afe0901280933y532204eew37ae49b58f430f70@mail.gmail.com> References: <897488b954d8536cb88314d26c128d13@ruby-forum.com> <27253a92e9ba59a23181303eb39111d6@ruby-forum.com> <85d99afe0901280933y532204eew37ae49b58f430f70@mail.gmail.com> Message-ID: > > There are a number of fixes for redirects and subdomain related > functionality which are currently tagged for the 0.4.1 release. I had > this problem after upgrading to 0.4.0, and have since updated to edge > until 0.4.1 is out. > Thanks Zach I installed the edge code (at least I believe I have) by doing a "git clone" into the vendor/plugins/webrat folder and changing the env.rb file to no longer require the gem. However, I am still getting the error. When I attempt to login to my app, the page that is returned after successful login is You are being redirected. instead of the contents of the redirected page. What generates this message? Is it mongrel? Rails? I just have to believe that I have something set up incorrectly. Wouldn't everyone that is using 4.0 and has redirects in their code be facing the same problem? Any other ideas? Thanks Tom -- Posted via http://www.ruby-forum.com/. From scott at railsnewbie.com Wed Jan 28 13:44:54 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Wed, 28 Jan 2009 13:44:54 -0500 Subject: [rspec-users] testing capistrano tasks In-Reply-To: <49807361.2010004@gmail.com> References: <497E8022.60300@railsnewbie.com> <12E02DC8-3624-4C9F-9B40-6D5A14F39CF5@mattwynne.net> <1d7ddd110901270908i3a9f9c2ai7c7723dd872c0349@mail.gmail.com> <49807361.2010004@gmail.com> Message-ID: <8F914776-1087-450D-9873-58E04E762F33@railsnewbie.com> On Jan 28, 2009, at 10:01 AM, Mike Gaffney wrote: > We actually have a machine that is a perfect clone of the production > machine. The only difference is the passwords. We test all > deployments to it first. We call it staging. Having a staging has 2 > benefits: > 1) We can test our deployment scripts, migrations, etc on as close > as we can get to production. > 2) If the production box dies, we have one that can take it's place > very quickly (change the database passwords/pointers and go). > > We also have a demo box that is updated via capistrano whenever the > build passes. > > Testing configuration / deployment is hard because you can assert > that the config is what you think it is, but that in no way proves > that it's actually working. It's like using mocks to build up > functionality against a mock library. At some point you actually > have to test against the real thing or you're just guessing. Well, it's actually even trickier than that, because I'm not only deploying one app to one machine, but am writing a library, which could be used for any number of apps to any number of machines (which certain assumptions - i.e. a unix machine with mysql, etc.) I've tested it locally (and by that I mean, on a staging slice), but when I fix a bug in the library without writing a test, there is absolutely no regression ability going forward. Looks like establishing the test harness will the most tricky thing. As usual, writing the first test is the hardest. Scott From joshknowles at gmail.com Wed Jan 28 13:47:17 2009 From: joshknowles at gmail.com (Josh Knowles) Date: Wed, 28 Jan 2009 13:47:17 -0500 Subject: [rspec-users] webrat methods are undefined In-Reply-To: References: <897488b954d8536cb88314d26c128d13@ruby-forum.com> <27253a92e9ba59a23181303eb39111d6@ruby-forum.com> <85d99afe0901280933y532204eew37ae49b58f430f70@mail.gmail.com> Message-ID: On Wed, Jan 28, 2009 at 1:37 PM, Tom Hoen wrote: > I installed the edge code (at least I believe I have) by doing a "git > clone" into the vendor/plugins/webrat folder and changing the env.rb > file to no longer require the gem. > > However, I am still getting the error. When I attempt to login to my > app, the page that is returned after successful login is > > You are being href=\"http://rpems.test/classrooms\">redirected. > Hey Tom, As Zack pointed out I heavily refactored the redirect logic in 0.4, but missed a few cases which will be included in 0.4.1. What repo did you clone from when you installed the plugin? Assuming it was brynary or myself then everything should be fine. If however you are still seeing problems please give me a little more context as to what URLs are being request, where they are being redirected to, etc. so that I can try and track it down. Thanks. Josh -- Josh Knowles phone: 509-979-1593 email: joshknowles at gmail.com web: http://joshknowles.com From lists at ruby-forum.com Wed Jan 28 14:29:51 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Wed, 28 Jan 2009 20:29:51 +0100 Subject: [rspec-users] webrat methods are undefined In-Reply-To: References: <897488b954d8536cb88314d26c128d13@ruby-forum.com> <27253a92e9ba59a23181303eb39111d6@ruby-forum.com> <85d99afe0901280933y532204eew37ae49b58f430f70@mail.gmail.com> Message-ID: Josh - I used "git clone git://github.com/brynary/webrat.git". Should I have used a different repo? First, I set up the host with my subdomain host! "rpems.test" Then the steps for the admin login: visit "/login" fill_in("login", :with => "admin") fill_in("password", :with => "test") click_button("Log in") Then i check what is returned, looking for the word "Classroom" to indicate that the user is on the Classrooms page. So the steps should go http://rpems.test/ http://rpems.test/login Then the Log In submit, which, if the login is successful (which it appears to be), redirects to http://rpems.test/classrooms What else could I give you to help track down the issue (if I have indeed installed the correct repo). Thanks Tom -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Wed Jan 28 14:43:54 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 28 Jan 2009 19:43:54 +0000 Subject: [rspec-users] [Cucumber, TextMate Bundle] Call for help In-Reply-To: <49808DD7.9030100@benmabey.com> References: <49808DD7.9030100@benmabey.com> Message-ID: On 28 Jan 2009, at 16:54, Ben Mabey wrote: > Hey all, > As some of you may know I created the Cucumber TextMate bundle: > http://github.com/bmabey/cucumber-tmbundle/tree/master > > What most of you probably don't know is that I stopped using > TextMate (in favor of Vim) several months ago. Since then the > Cucumber bundle has been somewhat neglected by me and I've mostly > pulled in patches and regenerated the syntax for new languages. I > think there are a lot of cool things that could still be done with > the bundle (see the TODO list in the README), but I just don't see > myself doing a lot of them without the motivation I once had. > > Is there anyone on the list with the motivation to take the lead on > this project and start adding new features to it? There is a little > bit of cruft from the old rspec story runner bundle but all in all > the code is reasonably clean with specs behind it. I'm still happy > to help out, but I don't see myself moving too fast without other > contributors. :) > > Thanks in advance, > Ben I'd probably be willing - I use it every day so I'd like to give something back. What does this involve? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From zach.dennis at gmail.com Wed Jan 28 14:49:05 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 28 Jan 2009 14:49:05 -0500 Subject: [rspec-users] webrat methods are undefined In-Reply-To: References: <897488b954d8536cb88314d26c128d13@ruby-forum.com> <27253a92e9ba59a23181303eb39111d6@ruby-forum.com> <85d99afe0901280933y532204eew37ae49b58f430f70@mail.gmail.com> Message-ID: <85d99afe0901281149q139df019nf8148310e6fb7707@mail.gmail.com> On Wed, Jan 28, 2009 at 2:29 PM, Tom Hoen wrote: > Josh - > > I used "git clone git://github.com/brynary/webrat.git". Should I have > used a different repo? > > First, I set up the host with my subdomain > > host! "rpems.test" > > Then the steps for the admin login: > > visit "/login" > fill_in("login", :with => "admin") > fill_in("password", :with => "test") > click_button("Log in") > Try kicking things off with: visit login_url(:host =>" rpems.test") host! is a Rails method, and outside-of the knowledge of Webrat. Webrat only knows about the URLs and paths that you actually have it go through. I think this may produce the results you want because Webrat will be aware from the get-go that you're on as subdomain. This will probably still break in webrat HEAD, I am using this branch right now which includes a fix that is not in HEAD (it's waiting to be merged, or for another solution to take effect): http://github.com/zdennis/webrat/tree/make_current_url_fully_qualified This ensures that webrat respects subdomains while navigating through the app. You may want to check it out until one (or al) of the following tickets are closed: http://webrat.lighthouseapp.com/projects/10503/tickets/140-current_url-should-be-fully-qualified http://webrat.lighthouseapp.com/projects/10503/tickets/147-linkabsolute_href-is-broken http://webrat.lighthouseapp.com/projects/10503/tickets/146-click_button-does-not-expand-relative-action-urls With the aforementioned branch we haven't hit any new issues using subdomains in our app's feature suite. > Then i check what is returned, looking for the word "Classroom" to > indicate that the user is on the Classrooms page. > > So the steps should go > http://rpems.test/ > http://rpems.test/login > > Then the Log In submit, which, if the login is successful (which it > appears to be), redirects to > http://rpems.test/classrooms > > What else could I give you to help track down the issue (if I have > indeed installed the correct repo). > > Thanks > Tom > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From jeremy.lightsmith at gmail.com Wed Jan 28 15:21:25 2009 From: jeremy.lightsmith at gmail.com (Jeremy Lightsmith) Date: Wed, 28 Jan 2009 12:21:25 -0800 Subject: [rspec-users] specs run faster separately than together Message-ID: <648eacf20901281221t33729447v9ba0bece508f02d7@mail.gmail.com> So this is weird. on my current project I've been working on speeding up specs, and I just found that time rake spec => 4m 0s whereas time rake spec:controllers spec:models spec:helpers spec:lib => 2m 32s (we don't have any view specs) any idea why this might be true? I compared numbers of tests and got the same number both ways, just running everything together seems to make it take almost twice as long... Is anyone else seeing this? If it matters, we have 1183 tests spread more or less evenly across each of controllers, models, helpers, and lib. Jeremy -------------- next part -------------- An HTML attachment was scrubbed... URL: From scott at railsnewbie.com Wed Jan 28 15:34:15 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Wed, 28 Jan 2009 15:34:15 -0500 Subject: [rspec-users] specs run faster separately than together In-Reply-To: <648eacf20901281221t33729447v9ba0bece508f02d7@mail.gmail.com> References: <648eacf20901281221t33729447v9ba0bece508f02d7@mail.gmail.com> Message-ID: <00F4A6C9-0E79-4CB3-8504-47E22F419746@railsnewbie.com> On Jan 28, 2009, at 3:21 PM, Jeremy Lightsmith wrote: > So this is weird. > > on my current project I've been working on speeding up specs, and I > just found that > > time rake spec => 4m 0s > > whereas > > time rake spec:controllers spec:models spec:helpers spec:lib => 2m 32s Do those rake tasks run rake db:test:prepare, and other dependencies of rake spec? How are you getting those numbers? Scott > > > (we don't have any view specs) any idea why this might be true? I > compared numbers of tests and got the same number both ways, just > running everything together seems to make it take almost twice as > long... Is anyone else seeing this? > > If it matters, we have 1183 tests spread more or less evenly across > each of controllers, models, helpers, and lib. > > Jeremy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From jeremy.lightsmith at gmail.com Wed Jan 28 16:05:32 2009 From: jeremy.lightsmith at gmail.com (Jeremy Lightsmith) Date: Wed, 28 Jan 2009 13:05:32 -0800 Subject: [rspec-users] specs run faster separately than together In-Reply-To: <00F4A6C9-0E79-4CB3-8504-47E22F419746@railsnewbie.com> References: <648eacf20901281221t33729447v9ba0bece508f02d7@mail.gmail.com> <00F4A6C9-0E79-4CB3-8504-47E22F419746@railsnewbie.com> Message-ID: <648eacf20901281305j6c1e75a8m63129706ca3ad1eb@mail.gmail.com> On Wed, Jan 28, 2009 at 12:34 PM, Scott Taylor wrote: > > On Jan 28, 2009, at 3:21 PM, Jeremy Lightsmith wrote: > > So this is weird. >> >> on my current project I've been working on speeding up specs, and I just >> found that >> >> time rake spec => 4m 0s >> >> whereas >> >> time rake spec:controllers spec:models spec:helpers spec:lib => 2m 32s >> > > Do those rake tasks run rake db:test:prepare, and other dependencies of > rake spec? > > How are you getting those numbers? > > Scott > Each of those rake tasks are the default generated ones : Spec::Rake::SpecTask.new(sub => spec_prereq) do |t| t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"] end So, yes db:test:prepare is a prereq for each of those, which means in both cases it gets run exactly once. As for those numbers, I'm using the time command, I actually run "time rake spec" and after the spec it gives me something that looks like : real 4m16.242s user 3m54.037s sys 0m9.008s -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Wed Jan 28 16:26:48 2009 From: ben at benmabey.com (Ben Mabey) Date: Wed, 28 Jan 2009 14:26:48 -0700 Subject: [rspec-users] [Cucumber, TextMate Bundle] Call for help In-Reply-To: References: <49808DD7.9030100@benmabey.com> Message-ID: <4980CD98.6040107@benmabey.com> On 1/28/09 12:43 PM, Matt Wynne wrote: > > On 28 Jan 2009, at 16:54, Ben Mabey wrote: > >> Hey all, >> As some of you may know I created the Cucumber TextMate bundle: >> http://github.com/bmabey/cucumber-tmbundle/tree/master >> >> What most of you probably don't know is that I stopped using TextMate >> (in favor of Vim) several months ago. Since then the Cucumber bundle >> has been somewhat neglected by me and I've mostly pulled in patches >> and regenerated the syntax for new languages. I think there are a >> lot of cool things that could still be done with the bundle (see the >> TODO list in the README), but I just don't see myself doing a lot of >> them without the motivation I once had. >> >> Is there anyone on the list with the motivation to take the lead on >> this project and start adding new features to it? There is a little >> bit of cruft from the old rspec story runner bundle but all in all >> the code is reasonably clean with specs behind it. I'm still happy >> to help out, but I don't see myself moving too fast without other >> contributors. :) >> >> Thanks in advance, >> Ben > > I'd probably be willing - I use it every day so I'd like to give > something back. What does this involve? Thanks Matt. Doesn't involve much.. just fork the repo on github and start adding any features that you think would be cool to have. :) (I'll continue to take pull requests and do little tweaks here and there.) I updated the TODO section on the readme for all the things I think should/could be done. For example, I began implementing a "Goto Step" command but I never actually implemented the StepDetector class to do all the work. So seeing how that hooks up and implementing the class might be a good starting point. Feel free to make any design decisions you want to. -Ben > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Wed Jan 28 16:49:58 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Wed, 28 Jan 2009 22:49:58 +0100 Subject: [rspec-users] webrat methods are undefined In-Reply-To: <85d99afe0901281149q139df019nf8148310e6fb7707@mail.gmail.com> References: <897488b954d8536cb88314d26c128d13@ruby-forum.com> <27253a92e9ba59a23181303eb39111d6@ruby-forum.com> <85d99afe0901280933y532204eew37ae49b58f430f70@mail.gmail.com> <85d99afe0901281149q139df019nf8148310e6fb7707@mail.gmail.com> Message-ID: Zach Dennis wrote: > > This will probably still break in webrat HEAD, I am using this branch > right now which includes a fix that is not in HEAD (it's waiting to be > merged, or for another solution to take effect): > http://github.com/zdennis/webrat/tree/make_current_url_fully_qualified I apologize for my newbieness to git, but i have tried several different ways of trying to checkout the code in your repo and, alas, I have failed. if I want to git clone it, what statement should I use? Thanks again for your help! -- Posted via http://www.ruby-forum.com/. From scott at railsnewbie.com Wed Jan 28 16:57:39 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Wed, 28 Jan 2009 16:57:39 -0500 Subject: [rspec-users] webrat methods are undefined In-Reply-To: References: <897488b954d8536cb88314d26c128d13@ruby-forum.com> <27253a92e9ba59a23181303eb39111d6@ruby-forum.com> <85d99afe0901280933y532204eew37ae49b58f430f70@mail.gmail.com> <85d99afe0901281149q139df019nf8148310e6fb7707@mail.gmail.com> Message-ID: On Jan 28, 2009, at 4:49 PM, Tom Hoen wrote: > Zach Dennis wrote: > >> >> This will probably still break in webrat HEAD, I am using this branch >> right now which includes a fix that is not in HEAD (it's waiting to >> be >> merged, or for another solution to take effect): >> http://github.com/zdennis/webrat/tree/make_current_url_fully_qualified > > > I apologize for my newbieness to git, but i have tried several > different > ways of trying to checkout the code in your repo and, alas, I have > failed. > > if I want to git clone it, what statement should I use? git clone git://github.com/zdennis/webrat.git > > > Thanks again for your help! > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Wed Jan 28 16:58:32 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 28 Jan 2009 15:58:32 -0600 Subject: [rspec-users] webrat methods are undefined In-Reply-To: References: <897488b954d8536cb88314d26c128d13@ruby-forum.com> <27253a92e9ba59a23181303eb39111d6@ruby-forum.com> <85d99afe0901280933y532204eew37ae49b58f430f70@mail.gmail.com> <85d99afe0901281149q139df019nf8148310e6fb7707@mail.gmail.com> Message-ID: <57c63afe0901281358w2b66eb6cw7c640605db2d7994@mail.gmail.com> On Wed, Jan 28, 2009 at 3:57 PM, Scott Taylor wrote: > > On Jan 28, 2009, at 4:49 PM, Tom Hoen wrote: > >> Zach Dennis wrote: >> >>> >>> This will probably still break in webrat HEAD, I am using this branch >>> right now which includes a fix that is not in HEAD (it's waiting to be >>> merged, or for another solution to take effect): >>> http://github.com/zdennis/webrat/tree/make_current_url_fully_qualified >> >> >> I apologize for my newbieness to git, but i have tried several different >> ways of trying to checkout the code in your repo and, alas, I have >> failed. >> >> if I want to git clone it, what statement should I use? > > git clone git://github.com/zdennis/webrat.git You can get this if you click on the Public Clone URL: git://github.com/zdennis/webrat.git on http://github.com/zdennis/webrat/tree/make_current_url_fully_qualified > >> >> >> Thanks again for your 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 > From lists at ruby-forum.com Wed Jan 28 18:50:21 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Thu, 29 Jan 2009 00:50:21 +0100 Subject: [rspec-users] webrat methods are undefined In-Reply-To: References: <897488b954d8536cb88314d26c128d13@ruby-forum.com> <27253a92e9ba59a23181303eb39111d6@ruby-forum.com> <85d99afe0901280933y532204eew37ae49b58f430f70@mail.gmail.com> <85d99afe0901281149q139df019nf8148310e6fb7707@mail.gmail.com> Message-ID: <57449cb6b55e765c1db8f544595cf206@ruby-forum.com> Scott Taylor wrote: > > git clone git://github.com/zdennis/webrat.git I am sorry to be a pain, but i get the following error. Initialize webrat/.git Initialized empty Git repository in c:/projects/pospaw/vendor/plugins/webrat/.git/ fatal: read error (Invalid argument) Tom -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Jan 29 03:47:06 2009 From: lists at ruby-forum.com (Juanma Cervera) Date: Thu, 29 Jan 2009 09:47:06 +0100 Subject: [rspec-users] [Cucumber] Tabular data in steps Message-ID: <36034273393cf888ee2c72826ad2aa25@ruby-forum.com> Is it possible to mix a normal parameter argument for a step, with tabular data? Something like this: Given there is a country "Spain" with the cities: |name | |Madrid | |Barcelona | |Valencia | And this step_definition Given /^there is a country "Spain" with the cities:$/ do |country_name, cities_table| ... end Thanks Juanma -- Posted via http://www.ruby-forum.com/. From erikpukinskis at gmail.com Thu Jan 29 04:37:29 2009 From: erikpukinskis at gmail.com (Erik Pukinskis) Date: Thu, 29 Jan 2009 01:37:29 -0800 Subject: [rspec-users] [Cucumber] Tabular data in steps In-Reply-To: <36034273393cf888ee2c72826ad2aa25@ruby-forum.com> References: <36034273393cf888ee2c72826ad2aa25@ruby-forum.com> Message-ID: Yes, that should work. But you'd have to do Given /^there is a country "(.*)" with the cities:$/ do |country_name, cities_table| ... end Erik On Thu, Jan 29, 2009 at 12:47 AM, Juanma Cervera wrote: > Is it possible to mix a normal parameter argument for a step, with > tabular data? > > Something like this: > > Given there is a country "Spain" with the cities: > |name | > |Madrid | > |Barcelona | > |Valencia | > > And this step_definition > > Given /^there is a country "Spain" with the cities:$/ do |country_name, > cities_table| > ... > end > > Thanks > Juanma > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Thu Jan 29 06:29:36 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 29 Jan 2009 12:29:36 +0100 Subject: [rspec-users] [Cucumber] Tabular data in steps In-Reply-To: References: <36034273393cf888ee2c72826ad2aa25@ruby-forum.com> Message-ID: <8d961d900901290329t10cf1875rcb7e28225b86e200@mail.gmail.com> On Thu, Jan 29, 2009 at 10:37 AM, Erik Pukinskis wrote: > Yes, that should work. But you'd have to do > > Given /^there is a country "(.*)" with the cities:$/ do |country_name, > cities_table| > ... > end > Correct. And it's documented in the Wiki: http://wiki.github.com/aslakhellesoy/cucumber/calling-steps-from-step-definitions Aslak > Erik > > On Thu, Jan 29, 2009 at 12:47 AM, Juanma Cervera wrote: >> Is it possible to mix a normal parameter argument for a step, with >> tabular data? >> >> Something like this: >> >> Given there is a country "Spain" with the cities: >> |name | >> |Madrid | >> |Barcelona | >> |Valencia | >> >> And this step_definition >> >> Given /^there is a country "Spain" with the cities:$/ do |country_name, >> cities_table| >> ... >> end >> >> Thanks >> Juanma >> -- >> 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 > -- Aslak (::) From aslak.hellesoy at gmail.com Thu Jan 29 06:36:31 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 29 Jan 2009 12:36:31 +0100 Subject: [rspec-users] [Cucumber] Tabular data in steps In-Reply-To: <8d961d900901290329t10cf1875rcb7e28225b86e200@mail.gmail.com> References: <36034273393cf888ee2c72826ad2aa25@ruby-forum.com> <8d961d900901290329t10cf1875rcb7e28225b86e200@mail.gmail.com> Message-ID: <8d961d900901290336o2b5c3d58ue23136ac22b47613@mail.gmail.com> On Thu, Jan 29, 2009 at 12:29 PM, aslak hellesoy wrote: > On Thu, Jan 29, 2009 at 10:37 AM, Erik Pukinskis > wrote: >> Yes, that should work. But you'd have to do >> >> Given /^there is a country "(.*)" with the cities:$/ do |country_name, >> cities_table| >> ... >> end >> > > Correct. And it's documented in the Wiki: > http://wiki.github.com/aslakhellesoy/cucumber/calling-steps-from-step-definitions > Actually - this is more relevant in your case: http://wiki.github.com/aslakhellesoy/cucumber/using-tabular-data-in-features Aslak > Aslak > >> Erik >> >> On Thu, Jan 29, 2009 at 12:47 AM, Juanma Cervera wrote: >>> Is it possible to mix a normal parameter argument for a step, with >>> tabular data? >>> >>> Something like this: >>> >>> Given there is a country "Spain" with the cities: >>> |name | >>> |Madrid | >>> |Barcelona | >>> |Valencia | >>> >>> And this step_definition >>> >>> Given /^there is a country "Spain" with the cities:$/ do |country_name, >>> cities_table| >>> ... >>> end >>> >>> Thanks >>> Juanma >>> -- >>> 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 >> > > > > -- > Aslak (::) > -- Aslak (::) From lists at ruby-forum.com Thu Jan 29 07:17:10 2009 From: lists at ruby-forum.com (Juanma Cervera) Date: Thu, 29 Jan 2009 13:17:10 +0100 Subject: [rspec-users] [Cucumber] Tabular data in steps In-Reply-To: <8d961d900901290336o2b5c3d58ue23136ac22b47613@mail.gmail.com> References: <36034273393cf888ee2c72826ad2aa25@ruby-forum.com> <8d961d900901290329t10cf1875rcb7e28225b86e200@mail.gmail.com> <8d961d900901290336o2b5c3d58ue23136ac22b47613@mail.gmail.com> Message-ID: <22193ac0de5039051cc64bd4c7012f0e@ruby-forum.com> Aslak The documentation in this wiki is the best I have ever seen, and it's constantly being improved. Very good job and thanks. Juanma -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Jan 29 07:27:28 2009 From: lists at ruby-forum.com (Juanma Cervera) Date: Thu, 29 Jan 2009 13:27:28 +0100 Subject: [rspec-users] [Cucumber] cucumber command does not work in db transaction Message-ID: <527eba206a82aee86fb27c81bc8fc019@ruby-forum.com> I am working in an scenario and it's still failing. I have not yet finished it. And I am running it constantly with the cucumber command, not with rake. The problem is that it's not working with the database in a transaction, and I have to run 'rake db:test:prepare' manually between two sequential runs of cucumber. rake features, make db:test:prepare automatically. But cucumber no. Isn't it a bug or it's correct? and I have to delete my data each time when using cucumber command. Juanma Cervera -- Posted via http://www.ruby-forum.com/. From joe at josephwilk.net Thu Jan 29 07:50:48 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Thu, 29 Jan 2009 12:50:48 +0000 Subject: [rspec-users] [Cucumber] cucumber command does not work in db transaction In-Reply-To: <527eba206a82aee86fb27c81bc8fc019@ruby-forum.com> References: <527eba206a82aee86fb27c81bc8fc019@ruby-forum.com> Message-ID: <4981A628.4000201@josephwilk.net> Juanma Cervera wrote: > I am working in an scenario and it's still failing. I have not yet > finished it. > > And I am running it constantly with the cucumber command, not with rake. > The problem is that it's not working with the database in a transaction, > and I have to run 'rake db:test:prepare' manually between two sequential > runs of cucumber. > > rake features, make db:test:prepare automatically. > But cucumber no. > Isn't it a bug or it's correct? and I have to delete my data each time > when using cucumber command. > > Juanma Cervera > Do you have: @@@ Cucumber::Rails.use_transactional_fixtures = true @@@ In your env.rb? If you are using a browser based testing tool such as Selenium or Watir you have to deal with the clean-up yourself (using Cucumber's hooks: http://wiki.github.com/aslakhellesoy/cucumber/hooks). -- Joseph Wilk http://blog.josephwilk.net From joe at josephwilk.net Thu Jan 29 07:52:29 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Thu, 29 Jan 2009 12:52:29 +0000 Subject: [rspec-users] [Cucumber] cucumber command does not work in db transaction In-Reply-To: <4981A628.4000201@josephwilk.net> References: <527eba206a82aee86fb27c81bc8fc019@ruby-forum.com> <4981A628.4000201@josephwilk.net> Message-ID: <4981A68D.9070405@josephwilk.net> Woops, sorry I meant: @@@ Cucumber::Rails.use_transactional_fixtures @@@ Joseph Wilk wrote: > Juanma Cervera wrote: >> I am working in an scenario and it's still failing. I have not yet >> finished it. >> >> And I am running it constantly with the cucumber command, not with rake. >> The problem is that it's not working with the database in a transaction, >> and I have to run 'rake db:test:prepare' manually between two sequential >> runs of cucumber. >> >> rake features, make db:test:prepare automatically. >> But cucumber no. >> Isn't it a bug or it's correct? and I have to delete my data each time >> when using cucumber command. >> >> Juanma Cervera >> > Do you have: > > @@@ > Cucumber::Rails.use_transactional_fixtures = true > @@@ > > In your env.rb? > > If you are using a browser based testing tool such as Selenium or > Watir you have to deal with the clean-up yourself (using Cucumber's > hooks: http://wiki.github.com/aslakhellesoy/cucumber/hooks). > > -- > Joseph Wilk > http://blog.josephwilk.net > > From lists at ruby-forum.com Thu Jan 29 09:54:22 2009 From: lists at ruby-forum.com (Juanma Cervera) Date: Thu, 29 Jan 2009 15:54:22 +0100 Subject: [rspec-users] [Cucumber] cucumber command does not work in db transaction In-Reply-To: <4981A68D.9070405@josephwilk.net> References: <527eba206a82aee86fb27c81bc8fc019@ruby-forum.com> <4981A628.4000201@josephwilk.net> <4981A68D.9070405@josephwilk.net> Message-ID: <9a33212835472bb90bcadbc871d93cb3@ruby-forum.com> Joseph Wilk wrote: > Woops, sorry I meant: > > @@@ > Cucumber::Rails.use_transactional_fixtures > @@@ Joseph, thanks for the reply. I do have Cucumber::Rails.use_transactional_fixtures in env.rb I have verified it failing when setting the database in the new background section of the feature. In that case I have to call manually db:test:prepare to clean up the database. But it works like expected when I move the setup to the Scenario. Juanma Cervera -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Jan 29 09:58:25 2009 From: lists at ruby-forum.com (Juanma Cervera) Date: Thu, 29 Jan 2009 15:58:25 +0100 Subject: [rspec-users] [Cucumber] cucumber command does not work in db transaction In-Reply-To: <9a33212835472bb90bcadbc871d93cb3@ruby-forum.com> References: <527eba206a82aee86fb27c81bc8fc019@ruby-forum.com> <4981A628.4000201@josephwilk.net> <4981A68D.9070405@josephwilk.net> <9a33212835472bb90bcadbc871d93cb3@ruby-forum.com> Message-ID: For now I am running this command (together) rake db:test:prepare && cucumber -r features -l es features/reservas/creacion_reserva.feature Juanma -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Thu Jan 29 10:05:29 2009 From: ben at benmabey.com (Ben Mabey) Date: Thu, 29 Jan 2009 08:05:29 -0700 Subject: [rspec-users] [Cucumber] cucumber command does not work in db transaction In-Reply-To: <9a33212835472bb90bcadbc871d93cb3@ruby-forum.com> References: <527eba206a82aee86fb27c81bc8fc019@ruby-forum.com> <4981A628.4000201@josephwilk.net> <4981A68D.9070405@josephwilk.net> <9a33212835472bb90bcadbc871d93cb3@ruby-forum.com> Message-ID: <4981C5B9.1080303@benmabey.com> Juanma Cervera wrote: > Joseph Wilk wrote: > >> Woops, sorry I meant: >> >> @@@ >> Cucumber::Rails.use_transactional_fixtures >> @@@ >> > > > Joseph, thanks for the reply. > I do have Cucumber::Rails.use_transactional_fixtures in env.rb > > I have verified it failing when setting the database in the new > background section of the feature. > In that case I have to call manually db:test:prepare to clean up the > database. > But it works like expected when I move the setup to the Scenario. > > Juanma Cervera > > The transactions are setup to start and be rolled back for each scenario.. Depending on how the Background section was implemented its setup may not be included in this transaction... So it sounds like it may be a bug with the new feature. WDYT Joeseph? -Ben From lists at ruby-forum.com Thu Jan 29 10:10:13 2009 From: lists at ruby-forum.com (Juanma Cervera) Date: Thu, 29 Jan 2009 16:10:13 +0100 Subject: [rspec-users] [ANN] At last, the book Message-ID: I have just gone to "Pragmatic Programmers" and spent my money in the book I have dreaming for six months. :) Maybe I'm the first :) -- Posted via http://www.ruby-forum.com/. From joe at josephwilk.net Thu Jan 29 10:21:10 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Thu, 29 Jan 2009 15:21:10 +0000 Subject: [rspec-users] [Cucumber] cucumber command does not work in db transaction In-Reply-To: <4981C5B9.1080303@benmabey.com> References: <527eba206a82aee86fb27c81bc8fc019@ruby-forum.com> <4981A628.4000201@josephwilk.net> <4981A68D.9070405@josephwilk.net> <9a33212835472bb90bcadbc871d93cb3@ruby-forum.com> <4981C5B9.1080303@benmabey.com> Message-ID: <4981C966.7050607@josephwilk.net> Ben Mabey wrote: > Juanma Cervera wrote: >> Joseph Wilk wrote: >> >>> Woops, sorry I meant: >>> >>> @@@ >>> Cucumber::Rails.use_transactional_fixtures >>> @@@ >>> >> >> >> Joseph, thanks for the reply. >> I do have Cucumber::Rails.use_transactional_fixtures in env.rb >> >> I have verified it failing when setting the database in the new >> background section of the feature. >> In that case I have to call manually db:test:prepare to clean up the >> database. >> But it works like expected when I move the setup to the Scenario. >> >> Juanma Cervera >> >> > The transactions are setup to start and be rolled back for each > scenario.. Depending on how the Background section was implemented its > setup may not be included in this transaction... So it sounds like it > may be a bug with the new feature. > WDYT Joeseph? > *lightbulb* Yes this was me thinking it was really clever to run Background before any of you're 'Before's. Which would scupper transactions. Will look at this ASAP. Thanks for spotting this. You can track the ticket here: http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/181-background-runs-outside-of-transactions -- Joseph Wilk http://blog.josephwilk.net/ > -Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Jan 29 10:36:03 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 29 Jan 2009 09:36:03 -0600 Subject: [rspec-users] [ANN] The RSpec Book is now in beta Message-ID: <68A01C2A-2808-493D-B212-C16617AFB9A6@gmail.com> I?m pleased to announce the beta release of the Pragmatic Bookshelf?s The RSpec Book: Behaviour Driven Development with RSpec, Cucumber and Friends! It?s been a long time coming, and there?s still a lot of work to do to get to print. The beta release has 9 of the 22 chapters we have planned. Most of what remains is almost done, but not quite ready to release yet. As with all of the Pragmatic beta books, we?ll do regular updates every few weeks as we wrap up the remaining chapters and incorporate your feedback. And please do provide feedback. We want this book to serve you well! There are six authors involved: Dave Astels, Zach Dennis, Aslak Hellesoy, Bryan Helmkamp, Dan North, and me. I'm honored to be in such good company here, with the guys who brought us BDD, to the developers and maintainers of RSpec, Cucumber and Webrat. You can read more (and buy the book!) at http://www.pragprog.com/titles/achbd/the-rspec-book On behalf of all the authors, I'd like to extend a special thank you to all of you who have contributed to the software and the conversation around RSpec, Cucumber, and BDD in general. RSpec would be nothing without the community that has evolved around it, so thank you, thank you, thank you. Again, THANK YOU! David Chelimsky From mauricio.linhares at gmail.com Thu Jan 29 10:45:15 2009 From: mauricio.linhares at gmail.com (=?ISO-8859-1?Q?Maur=EDcio_Linhares?=) Date: Thu, 29 Jan 2009 12:45:15 -0300 Subject: [rspec-users] [ANN] At last, the book In-Reply-To: References: Message-ID: No, you're not ;P Hope it's really launched in April \o/ - Maur?cio Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Thu, Jan 29, 2009 at 12:10 PM, Juanma Cervera wrote: > I have just gone to "Pragmatic Programmers" and spent my money in the > book I have dreaming for six months. :) > > Maybe I'm the first :) > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From nick at deadorange.com Thu Jan 29 10:55:31 2009 From: nick at deadorange.com (Nick Hoffman) Date: Thu, 29 Jan 2009 10:55:31 -0500 Subject: [rspec-users] [ANN] The RSpec Book is now in beta In-Reply-To: <68A01C2A-2808-493D-B212-C16617AFB9A6@gmail.com> References: <68A01C2A-2808-493D-B212-C16617AFB9A6@gmail.com> Message-ID: On 29/01/2009, at 10:36 AM, David Chelimsky wrote: > I?m pleased to announce the beta release of the Pragmatic > Bookshelf?s The RSpec Book: Behaviour Driven Development with RSpec, > Cucumber and Friends! > > It?s been a long time coming, and there?s still a lot of work to do > to get to print. The beta release has 9 of the 22 chapters we have > planned. Most of what remains is almost done, but not quite ready to > release yet. As with all of the Pragmatic beta books, we?ll do > regular updates every few weeks as we wrap up the remaining chapters > and incorporate your feedback. And please do provide feedback. We > want this book to serve you well! > > There are six authors involved: Dave Astels, Zach Dennis, Aslak > Hellesoy, Bryan Helmkamp, Dan North, and me. I'm honored to be in > such good company here, with the guys who brought us BDD, to the > developers and maintainers of RSpec, Cucumber and Webrat. > > You can read more (and buy the book!) at http://www.pragprog.com/titles/achbd/the-rspec-book > > On behalf of all the authors, I'd like to extend a special thank you > to all of you who have contributed to the software and the > conversation around RSpec, Cucumber, and BDD in general. RSpec would > be nothing without the community that has evolved around it, so > thank you, thank you, thank you. > > Again, THANK YOU! > David Chelimsky Congrats David, Dave, Zach, Aslak, Bryan and Dan! We've all really been looking forward to this. Expect lots of feedback, support, and thanks. Cheers, Nick From erik at solidcode.net Thu Jan 29 10:35:39 2009 From: erik at solidcode.net (Erik Terpstra) Date: Thu, 29 Jan 2009 16:35:39 +0100 Subject: [rspec-users] [ANN] At last, the book In-Reply-To: References: Message-ID: <4981CCCB.3060109@solidcode.net> Just did the same :) Juanma Cervera wrote: > I have just gone to "Pragmatic Programmers" and spent my money in the > book I have dreaming for six months. :) > > Maybe I'm the first :) > From dchelimsky at gmail.com Thu Jan 29 11:04:31 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 29 Jan 2009 10:04:31 -0600 Subject: [rspec-users] [ANN] The RSpec Book is now in beta In-Reply-To: References: <68A01C2A-2808-493D-B212-C16617AFB9A6@gmail.com> Message-ID: <57c63afe0901290804q1314d209k1f68ed295084bc99@mail.gmail.com> On Thu, Jan 29, 2009 at 9:55 AM, Nick Hoffman wrote: > On 29/01/2009, at 10:36 AM, David Chelimsky wrote: >> >> I'm pleased to announce the beta release of the Pragmatic Bookshelf's The >> RSpec Book: Behaviour Driven Development with RSpec, Cucumber and Friends! >> >> It's been a long time coming, and there's still a lot of work to do to get >> to print. The beta release has 9 of the 22 chapters we have planned. Most of >> what remains is almost done, but not quite ready to release yet. As with all >> of the Pragmatic beta books, we'll do regular updates every few weeks as we >> wrap up the remaining chapters and incorporate your feedback. And please do >> provide feedback. We want this book to serve you well! >> >> There are six authors involved: Dave Astels, Zach Dennis, Aslak Hellesoy, >> Bryan Helmkamp, Dan North, and me. I'm honored to be in such good company >> here, with the guys who brought us BDD, to the developers and maintainers of >> RSpec, Cucumber and Webrat. >> >> You can read more (and buy the book!) at >> http://www.pragprog.com/titles/achbd/the-rspec-book >> >> On behalf of all the authors, I'd like to extend a special thank you to >> all of you who have contributed to the software and the conversation around >> RSpec, Cucumber, and BDD in general. RSpec would be nothing without the >> community that has evolved around it, so thank you, thank you, thank you. >> >> Again, THANK YOU! >> David Chelimsky > > Congrats David, Dave, Zach, Aslak, Bryan and Dan! We've all really been > looking forward to this. Expect lots of feedback, support, and thanks. Thank you Nick. That's exactly why we're doing a beta book. Looking forward to your input. Cheers, David > > Cheers, > Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From walketim at gmail.com Thu Jan 29 11:21:26 2009 From: walketim at gmail.com (Tim Walker) Date: Thu, 29 Jan 2009 09:21:26 -0700 Subject: [rspec-users] [ANN] At last, the book In-Reply-To: <4981CCCB.3060109@solidcode.net> References: <4981CCCB.3060109@solidcode.net> Message-ID: <1ebf5a4d0901290821w3b01542frae3462b18c5c593a@mail.gmail.com> Dang, I tried to create a spiffy new application and ended up with a strangely shaped farm implement instead. 8) Nice work guys. Sincerely, T On Thu, Jan 29, 2009 at 8:35 AM, Erik Terpstra wrote: > Just did the same :) > > Juanma Cervera wrote: >> >> I have just gone to "Pragmatic Programmers" and spent my money in the >> book I have dreaming for six months. :) >> >> Maybe I'm the first :) >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From biot023 at gmail.com Thu Jan 29 11:28:14 2009 From: biot023 at gmail.com (doug livesey) Date: Thu, 29 Jan 2009 16:28:14 +0000 Subject: [rspec-users] [ANN] The RSpec Book is now in beta In-Reply-To: <57c63afe0901290804q1314d209k1f68ed295084bc99@mail.gmail.com> References: <68A01C2A-2808-493D-B212-C16617AFB9A6@gmail.com> <57c63afe0901290804q1314d209k1f68ed295084bc99@mail.gmail.com> Message-ID: <50873a360901290828u2c926a4crad52a33c764032aa@mail.gmail.com> Just bought it -- been looking forwards to this! 2009/1/29 David Chelimsky > On Thu, Jan 29, 2009 at 9:55 AM, Nick Hoffman wrote: > > On 29/01/2009, at 10:36 AM, David Chelimsky wrote: > >> > >> I'm pleased to announce the beta release of the Pragmatic Bookshelf's > The > >> RSpec Book: Behaviour Driven Development with RSpec, Cucumber and > Friends! > >> > >> It's been a long time coming, and there's still a lot of work to do to > get > >> to print. The beta release has 9 of the 22 chapters we have planned. > Most of > >> what remains is almost done, but not quite ready to release yet. As with > all > >> of the Pragmatic beta books, we'll do regular updates every few weeks as > we > >> wrap up the remaining chapters and incorporate your feedback. And please > do > >> provide feedback. We want this book to serve you well! > >> > >> There are six authors involved: Dave Astels, Zach Dennis, Aslak > Hellesoy, > >> Bryan Helmkamp, Dan North, and me. I'm honored to be in such good > company > >> here, with the guys who brought us BDD, to the developers and > maintainers of > >> RSpec, Cucumber and Webrat. > >> > >> You can read more (and buy the book!) at > >> http://www.pragprog.com/titles/achbd/the-rspec-book > >> > >> On behalf of all the authors, I'd like to extend a special thank you to > >> all of you who have contributed to the software and the conversation > around > >> RSpec, Cucumber, and BDD in general. RSpec would be nothing without the > >> community that has evolved around it, so thank you, thank you, thank > you. > >> > >> Again, THANK YOU! > >> David Chelimsky > > > > Congrats David, Dave, Zach, Aslak, Bryan and Dan! We've all really been > > looking forward to this. Expect lots of feedback, support, and thanks. > > Thank you Nick. That's exactly why we're doing a beta book. Looking > forward to your input. > > Cheers, > David > > > > > Cheers, > > Nick > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From r_j_h_box-sf at yahoo.com Thu Jan 29 13:00:40 2009 From: r_j_h_box-sf at yahoo.com (r_j_h_box-sf at yahoo.com) Date: Thu, 29 Jan 2009 10:00:40 -0800 (PST) Subject: [rspec-users] simple == with prettier error messages + good documentation Message-ID: <167563.64595.qm@web31805.mail.mud.yahoo.com> Hi all, I've found myself writing a thing I think is less than optimal, looking for suggestions. The context is, I'm testing a result, and as a part of that test, I might verify two or three things, which are individually relevant but not really discrete results (?). Here's my thinking process, using a toy example: foo.should == bar (or foo.should_not be_nil) > expected not to be nil, but was (hm, not very informative) if( foo == nil ) "failure to setup foo".should == "foo should be set to the thing that will be rendered" end > expected "foo should be set to the thing that will be rendered", > got "failure to setup foo" (using ==) I've used this, by example, for a test on a dependency (imagemagick), where if the dependency isn't found, I show a decent message with info the tester can use to resolve it. And, as I mentioned, I've used it for revealing more details in cases where the it "" + the generic error aren't informative. I'm satisfied using this method for things like detecting a failure to use a test-helper correctly - works fine, doesn't get in my way as part of the documentation. Which brings me to the problem I'm concerned about: With this method, nothing come out in the generated spec-docs to represent the thing I'm conditionally requiring. I guess I could get more fine-grained with my it()'s, but I've been preferring a more general statement for it(), that gives the sense without the detail. Any suggestions? Thanks, Randy -------------- next part -------------- An HTML attachment was scrubbed... URL: From todd at snappl.co.uk Thu Jan 29 13:08:15 2009 From: todd at snappl.co.uk (tatyree) Date: Thu, 29 Jan 2009 10:08:15 -0800 (PST) Subject: [rspec-users] Strange message expectation behaviour with Time.now in a find condition Message-ID: <1dcfd34b-4559-4c01-82b6-c0828f6851ca@y1g2000pra.googlegroups.com> Even if this is a bug, it's a pretty obscure one. It was frustrating the hell out of me until I found a workaround, so I thought I'd just post the details: Given a find like this: def self.find_old User.all(:conditions => ['updated_at <= ?',Time.now - 1.day) ... Trying to set a message expectation will always fail: it "should find users" do User.should_receive(:all).with({:conditions => ['updated_at <= ?',Time.now - 1.day]}) User.find_old ... with the error: Mock 'Class' expected :all with ({:conditions=>["updated_at <= ?", Wed Jan 28 17:59:02 +0000 2009]}) but received it with ({:conditions=> ["updated_at <= ?", Wed Jan 28 17:59:02 +0000 2009]}) Expected and received here are identical. The only workaround I've found (the example here is simplified, but the datetime in the model where I discovered the bug is critical and so needs to be spec'd) is to wrap the Time call and the expectation in another format: User.all(:conditions => ['updated_at <= ?',(Time.now - 1.day).xmlschema]) and it "should find users" do User.should_receive(:all).with({:conditions => ['updated_at <= ?', (Time.now - 1.day).xmlschema]}) I'm on rspec 1.1.12 on rails 2.1.0 and I'm guessing the + in the formatted datetime is playing hell with a regexp somewhere. Unfortunately, I don't have time to dig in to it myself right now. I was seeing the same behaviour when I tried hash_including (:conditions => ['updated_at <= ?',Time.now - 1.day]) as part of the expectation. Thanks, Todd From dchelimsky at gmail.com Thu Jan 29 13:25:04 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 29 Jan 2009 12:25:04 -0600 Subject: [rspec-users] simple == with prettier error messages + good documentation In-Reply-To: <167563.64595.qm@web31805.mail.mud.yahoo.com> References: <167563.64595.qm@web31805.mail.mud.yahoo.com> Message-ID: <57c63afe0901291025i1b1a18dah17b76a4650af60d1@mail.gmail.com> On Thu, Jan 29, 2009 at 12:00 PM, wrote: > Hi all, > > I've found myself writing a thing I think is less than optimal, looking for > suggestions. The context is, I'm testing a result, and as a part of that > test, I might verify two or three things, which are individually relevant > but not really discrete results (?). > > Here's my thinking process, using a toy example: > > foo.should == bar (or foo.should_not be_nil) > > > expected not to be nil, but was > > (hm, not very informative) > > if( foo == nil ) > "failure to setup foo".should == "foo should be set to the thing that > will be rendered" > end > > > expected "foo should be set to the thing that will be rendered", > > got "failure to setup foo" (using ==) > > I've used this, by example, for a test on a dependency (imagemagick), where > if the dependency isn't found, I show a decent message with info the tester > can use to resolve it. And, as I mentioned, I've used it for revealing more > details in cases where the it "" + the generic error aren't informative. > > I'm satisfied using this method for things like detecting a failure to use > a test-helper correctly - works fine, doesn't get in my way as part of the > documentation. Which brings me to the problem I'm concerned about: > > With this method, nothing come out in the generated spec-docs to represent > the thing I'm conditionally requiring. > > I guess I could get more fine-grained with my it()'s, but I've been > preferring a more general statement for it(), that gives the sense without > the detail. > > Any suggestions? > I can't think of anything that wouldn't result in something that requires more writing as of now. Maybe we need a new construct like: it "does something" do with_message "this is a more specific message" do foo.should == bar end end WDYT? > > > Thanks, > > Randy > > > _______________________________________________ > 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 dchelimsky at gmail.com Thu Jan 29 13:41:28 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 29 Jan 2009 12:41:28 -0600 Subject: [rspec-users] Strange message expectation behaviour with Time.now in a find condition In-Reply-To: <1dcfd34b-4559-4c01-82b6-c0828f6851ca@y1g2000pra.googlegroups.com> References: <1dcfd34b-4559-4c01-82b6-c0828f6851ca@y1g2000pra.googlegroups.com> Message-ID: <57c63afe0901291041x7769364eq70940bb01bd21615@mail.gmail.com> On Thu, Jan 29, 2009 at 12:08 PM, tatyree wrote: > Even if this is a bug, it's a pretty obscure one. It was frustrating > the hell out of me until I found a workaround, so I thought I'd just > post the details: > > Given a find like this: > > def self.find_old > User.all(:conditions => ['updated_at <= ?',Time.now - 1.day) > ... > > Trying to set a message expectation will always fail: > > it "should find users" do > User.should_receive(:all).with({:conditions => ['updated_at > <= ?',Time.now - 1.day]}) > User.find_old > ... > > with the error: > Mock 'Class' expected :all with ({:conditions=>["updated_at <= ?", > Wed Jan 28 17:59:02 +0000 2009]}) but received it with ({:conditions=> > ["updated_at <= ?", Wed Jan 28 17:59:02 +0000 2009]}) > > Expected and received here are identical. > > The only workaround I've found (the example here is simplified, but > the datetime in the model where I discovered the bug is critical and > so needs to be spec'd) is to wrap the Time call and the expectation in > another format: > > User.all(:conditions => ['updated_at <= ?',(Time.now - > 1.day).xmlschema]) > > and > > it "should find users" do > User.should_receive(:all).with({:conditions => ['updated_at <= ?', > (Time.now - 1.day).xmlschema]}) > > I'm on rspec 1.1.12 on rails 2.1.0 and I'm guessing the + in the > formatted datetime is playing hell with a regexp somewhere. > Unfortunately, I don't have time to dig in to it myself right now. > > I was seeing the same behaviour when I tried hash_including > (:conditions => ['updated_at <= ?',Time.now - 1.day]) as part of the > expectation. The problem is a display problem - the Time objects are actually different by some milliseconds, but you don't see that in the feedback. Try this: now = Time.now Time.stub!(:now).and_return(now) Then both calls will return the same object. > > > Thanks, > Todd > _______________________________________________ > 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 aslak.hellesoy at gmail.com Thu Jan 29 13:42:51 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 29 Jan 2009 19:42:51 +0100 Subject: [rspec-users] Strange message expectation behaviour with Time.now in a find condition In-Reply-To: <1dcfd34b-4559-4c01-82b6-c0828f6851ca@y1g2000pra.googlegroups.com> References: <1dcfd34b-4559-4c01-82b6-c0828f6851ca@y1g2000pra.googlegroups.com> Message-ID: <8d961d900901291042t17ba04dblfdeca3c7bf36342a@mail.gmail.com> On Thu, Jan 29, 2009 at 7:08 PM, tatyree wrote: > Even if this is a bug, it's a pretty obscure one. It was frustrating > the hell out of me until I found a workaround, so I thought I'd just > post the details: > > Given a find like this: > > def self.find_old > User.all(:conditions => ['updated_at <= ?',Time.now - 1.day) > ... > > Trying to set a message expectation will always fail: > > it "should find users" do > User.should_receive(:all).with({:conditions => ['updated_at > <= ?',Time.now - 1.day]}) > User.find_old > ... > > with the error: > Mock 'Class' expected :all with ({:conditions=>["updated_at <= ?", > Wed Jan 28 17:59:02 +0000 2009]}) but received it with ({:conditions=> > ["updated_at <= ?", Wed Jan 28 17:59:02 +0000 2009]}) > > Expected and received here are identical. > No they are not. They are milliseconds apart. You should *always* stub Time.now in tests. Aslak > The only workaround I've found (the example here is simplified, but > the datetime in the model where I discovered the bug is critical and > so needs to be spec'd) is to wrap the Time call and the expectation in > another format: > > User.all(:conditions => ['updated_at <= ?',(Time.now - > 1.day).xmlschema]) > > and > > it "should find users" do > User.should_receive(:all).with({:conditions => ['updated_at <= ?', > (Time.now - 1.day).xmlschema]}) > > I'm on rspec 1.1.12 on rails 2.1.0 and I'm guessing the + in the > formatted datetime is playing hell with a regexp somewhere. > Unfortunately, I don't have time to dig in to it myself right now. > > I was seeing the same behaviour when I tried hash_including > (:conditions => ['updated_at <= ?',Time.now - 1.day]) as part of the > expectation. > > Thanks, > Todd > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From nick at deadorange.com Thu Jan 29 13:42:59 2009 From: nick at deadorange.com (Nick Hoffman) Date: Thu, 29 Jan 2009 13:42:59 -0500 Subject: [rspec-users] simple == with prettier error messages + good documentation In-Reply-To: <167563.64595.qm@web31805.mail.mud.yahoo.com> References: <167563.64595.qm@web31805.mail.mud.yahoo.com> Message-ID: <9865E722-6341-4D1F-ABAD-D682C31AF990@deadorange.com> On 29/01/2009, at 1:00 PM, r_j_h_box-sf at yahoo.com wrote: > Hi all, > > I've found myself writing a thing I think is less than optimal, > looking for suggestions. The context is, I'm testing a result, and > as a part of that test, I might verify two or three things, which > are individually relevant but not really discrete results (?). > > Here's my thinking process, using a toy example: > > foo.should == bar (or foo.should_not be_nil) > > > expected not to be nil, but was > > (hm, not very informative) > > if( foo == nil ) > "failure to setup foo".should == "foo should be set to the thing > that will be rendered" > end > > > expected "foo should be set to the thing that will be rendered", > > got "failure to setup foo" (using ==) > > I've used this, by example, for a test on a dependency > (imagemagick), where if the dependency isn't found, I show a decent > message with info the tester can use to resolve it. And, as I > mentioned, I've used it for revealing more details in cases where > the it "" + the generic error aren't informative. > > I'm satisfied using this method for things like detecting a failure > to use a test-helper correctly - works fine, doesn't get in my way > as part of the documentation. Which brings me to the problem I'm > concerned about: > > With this method, nothing come out in the generated spec-docs to > represent the thing I'm conditionally requiring. > > I guess I could get more fine-grained with my it()'s, but I've been > preferring a more general statement for it(), that gives the sense > without the detail. > > Any suggestions? > > Thanks, > > Randy Hi Randy. I'm not 100% sure what you're asking. In short, are you wondering how to generate expectation failure messages that are more verbose and contextual? Cheers, Nick From scott at railsnewbie.com Thu Jan 29 13:57:31 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Thu, 29 Jan 2009 13:57:31 -0500 Subject: [rspec-users] session vs. controller.session Message-ID: <51D98BCF-8ADB-4E1C-BEA5-6A1204B0142F@railsnewbie.com> What exactly is the difference between using controller.session and session? I though that session was just a proxy controller.session, but this irb/debug sessions show that it isn't: http://gist.github.com/54673 When I call reset_session in the controller, I'm seeing the controller's session reset, but not the session() provided in the spec. Is this intended behavior? Scott From aslak.hellesoy at gmail.com Thu Jan 29 14:02:52 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 29 Jan 2009 20:02:52 +0100 Subject: [rspec-users] simple == with prettier error messages + good documentation In-Reply-To: <57c63afe0901291025i1b1a18dah17b76a4650af60d1@mail.gmail.com> References: <167563.64595.qm@web31805.mail.mud.yahoo.com> <57c63afe0901291025i1b1a18dah17b76a4650af60d1@mail.gmail.com> Message-ID: <8d961d900901291102l67a1414bq1f4dbfd1951979e4@mail.gmail.com> On Thu, Jan 29, 2009 at 7:25 PM, David Chelimsky wrote: > > > On Thu, Jan 29, 2009 at 12:00 PM, wrote: >> >> Hi all, >> >> I've found myself writing a thing I think is less than optimal, looking >> for suggestions. The context is, I'm testing a result, and as a part of >> that test, I might verify two or three things, which are individually >> relevant but not really discrete results (?). >> >> Here's my thinking process, using a toy example: >> >> foo.should == bar (or foo.should_not be_nil) >> >> > expected not to be nil, but was >> >> (hm, not very informative) >> >> if( foo == nil ) >> "failure to setup foo".should == "foo should be set to the thing that >> will be rendered" >> end >> >> > expected "foo should be set to the thing that will be rendered", >> > got "failure to setup foo" (using ==) >> >> I've used this, by example, for a test on a dependency (imagemagick), >> where if the dependency isn't found, I show a decent message with info the >> tester can use to resolve it. And, as I mentioned, I've used it for >> revealing more details in cases where the it "" + the generic error aren't >> informative. >> >> I'm satisfied using this method for things like detecting a failure to use >> a test-helper correctly - works fine, doesn't get in my way as part of the >> documentation. Which brings me to the problem I'm concerned about: >> >> With this method, nothing come out in the generated spec-docs to represent >> the thing I'm conditionally requiring. >> >> I guess I could get more fine-grained with my it()'s, but I've been >> preferring a more general statement for it(), that gives the sense without >> the detail. >> >> Any suggestions? > > I can't think of anything that wouldn't result in something that requires > more writing as of now. Maybe we need a new construct like: > it "does something" do > with_message "this is a more specific message" do > foo.should == bar > end > end > WDYT? > I think that would be useful. Maybe make it more explicit that it's an error message: on_error "bla" do ... end >> >> Thanks, >> >> Randy >> >> >> _______________________________________________ >> 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 > -- Aslak (::) From nick at deadorange.com Thu Jan 29 14:04:44 2009 From: nick at deadorange.com (Nick Hoffman) Date: Thu, 29 Jan 2009 14:04:44 -0500 Subject: [rspec-users] Strange message expectation behaviour with Time.now in a find condition In-Reply-To: <57c63afe0901291041x7769364eq70940bb01bd21615@mail.gmail.com> References: <1dcfd34b-4559-4c01-82b6-c0828f6851ca@y1g2000pra.googlegroups.com> <57c63afe0901291041x7769364eq70940bb01bd21615@mail.gmail.com> Message-ID: <54D72593-E9B2-486C-BEB8-D3C06C191DCB@deadorange.com> On 29/01/2009, at 1:41 PM, David Chelimsky wrote: > On Thu, Jan 29, 2009 at 12:08 PM, tatyree wrote: > Even if this is a bug, it's a pretty obscure one. It was frustrating > the hell out of me until I found a workaround, so I thought I'd just > post the details: > > Given a find like this: > > def self.find_old > User.all(:conditions => ['updated_at <= ?',Time.now - 1.day) > ... > > Trying to set a message expectation will always fail: > > it "should find users" do > User.should_receive(:all).with({:conditions => ['updated_at > <= ?',Time.now - 1.day]}) > User.find_old > ... > > with the error: > Mock 'Class' expected :all with ({:conditions=>["updated_at <= ?", > Wed Jan 28 17:59:02 +0000 2009]}) but received it with ({:conditions=> > ["updated_at <= ?", Wed Jan 28 17:59:02 +0000 2009]}) > > Expected and received here are identical. > > The only workaround I've found (the example here is simplified, but > the datetime in the model where I discovered the bug is critical and > so needs to be spec'd) is to wrap the Time call and the expectation in > another format: > > User.all(:conditions => ['updated_at <= ?',(Time.now - > 1.day).xmlschema]) > > and > > it "should find users" do > User.should_receive(:all).with({:conditions => ['updated_at <= ?', > (Time.now - 1.day).xmlschema]}) > > I'm on rspec 1.1.12 on rails 2.1.0 and I'm guessing the + in the > formatted datetime is playing hell with a regexp somewhere. > Unfortunately, I don't have time to dig in to it myself right now. > > I was seeing the same behaviour when I tried hash_including > (:conditions => ['updated_at <= ?',Time.now - 1.day]) as part of the > expectation. > > The problem is a display problem - the Time objects are actually > different by some milliseconds, but you don't see that in the > feedback. > > Try this: > > now = Time.now > Time.stub!(:now).and_return(now) > > Then both calls will return the same object. You're too fast, David and Aslak! =P Todd, I fell prey to the same problem a few months ago. As David and Aslak suggested, just stub out Time#now . Eg: it 'should do something' do now = Time.now Time.stub!(:now).and_return now User.should_receive(:all).with(:conditions => ['updated_at <= ?', now - 1.day]) User.all(:conditions => ['updated_at <= ?', Time.now - 1.day]) end Cheers, Nick From dchelimsky at gmail.com Thu Jan 29 14:18:29 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 29 Jan 2009 13:18:29 -0600 Subject: [rspec-users] simple == with prettier error messages + good documentation In-Reply-To: <8d961d900901291102l67a1414bq1f4dbfd1951979e4@mail.gmail.com> References: <167563.64595.qm@web31805.mail.mud.yahoo.com> <57c63afe0901291025i1b1a18dah17b76a4650af60d1@mail.gmail.com> <8d961d900901291102l67a1414bq1f4dbfd1951979e4@mail.gmail.com> Message-ID: <57c63afe0901291118h5e18acafg5cdc57994b5df9ed@mail.gmail.com> On Thu, Jan 29, 2009 at 1:02 PM, aslak hellesoy wrote: > On Thu, Jan 29, 2009 at 7:25 PM, David Chelimsky > wrote: > > > > > > On Thu, Jan 29, 2009 at 12:00 PM, wrote: > >> > >> Hi all, > >> > >> I've found myself writing a thing I think is less than optimal, looking > >> for suggestions. The context is, I'm testing a result, and as a part of > >> that test, I might verify two or three things, which are individually > >> relevant but not really discrete results (?). > >> > >> Here's my thinking process, using a toy example: > >> > >> foo.should == bar (or foo.should_not be_nil) > >> > >> > expected not to be nil, but was > >> > >> (hm, not very informative) > >> > >> if( foo == nil ) > >> "failure to setup foo".should == "foo should be set to the thing > that > >> will be rendered" > >> end > >> > >> > expected "foo should be set to the thing that will be rendered", > >> > got "failure to setup foo" (using ==) > >> > >> I've used this, by example, for a test on a dependency (imagemagick), > >> where if the dependency isn't found, I show a decent message with info > the > >> tester can use to resolve it. And, as I mentioned, I've used it for > >> revealing more details in cases where the it "" + the generic error > aren't > >> informative. > >> > >> I'm satisfied using this method for things like detecting a failure to > use > >> a test-helper correctly - works fine, doesn't get in my way as part of > the > >> documentation. Which brings me to the problem I'm concerned about: > >> > >> With this method, nothing come out in the generated spec-docs to > represent > >> the thing I'm conditionally requiring. > >> > >> I guess I could get more fine-grained with my it()'s, but I've been > >> preferring a more general statement for it(), that gives the sense > without > >> the detail. > >> > >> Any suggestions? > > > > I can't think of anything that wouldn't result in something that requires > > more writing as of now. Maybe we need a new construct like: > > it "does something" do > > with_message "this is a more specific message" do > > foo.should == bar > > end > > end > > WDYT? > > > > I think that would be useful. Maybe make it more explicit that it's an > error message: > > on_error "bla" do > ... > end on_failure "..." do ???? > > > >> > >> Thanks, > >> > >> Randy > >> > >> > >> _______________________________________________ > >> 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 > > > > > > -- > Aslak (::) > _______________________________________________ > 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 aidy.lewis at googlemail.com Thu Jan 29 14:21:26 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Thu, 29 Jan 2009 19:21:26 +0000 Subject: [rspec-users] [Cucumber] two running formats Message-ID: <7ac2300c0901291121k8995711rf0809a51d2b602c3@mail.gmail.com> Hi, Is it possible to run the html and console formatting concurrently in Cucumber? Thanks Aidy From aidy.lewis at googlemail.com Thu Jan 29 14:36:09 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Thu, 29 Jan 2009 19:36:09 +0000 Subject: [rspec-users] Rspec beta book documenting errors Message-ID: <7ac2300c0901291136v4b2f44aye50eda29eaf9daf9@mail.gmail.com> Hi, Where should we be documenting errors in the Rspec beta book? Thanks Aidy From aslak.hellesoy at gmail.com Thu Jan 29 14:51:37 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 29 Jan 2009 20:51:37 +0100 Subject: [rspec-users] [Cucumber] two running formats In-Reply-To: <7ac2300c0901291121k8995711rf0809a51d2b602c3@mail.gmail.com> References: <7ac2300c0901291121k8995711rf0809a51d2b602c3@mail.gmail.com> Message-ID: <8d961d900901291151w4b23cb5dl9f5ae756efa93588@mail.gmail.com> On Thu, Jan 29, 2009 at 8:21 PM, aidy lewis wrote: > Hi, > > Is it possible to run the html and console formatting concurrently in Cucumber? > It should be, yes. Check --help for details. Are you running into any issues? Aslak > Thanks > > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From dchelimsky at gmail.com Thu Jan 29 14:57:43 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 29 Jan 2009 13:57:43 -0600 Subject: [rspec-users] Rspec beta book documenting errors In-Reply-To: <7ac2300c0901291136v4b2f44aye50eda29eaf9daf9@mail.gmail.com> References: <7ac2300c0901291136v4b2f44aye50eda29eaf9daf9@mail.gmail.com> Message-ID: <57c63afe0901291157m69727e8boa2f58982dd8a3ef2@mail.gmail.com> On Thu, Jan 29, 2009 at 1:36 PM, aidy lewis wrote: > Hi, > > Where should we be documenting errors in the Rspec beta book? http://www.pragprog.com/titles/achbd/errata THANKS! > > Thanks > > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Thu Jan 29 14:59:31 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 29 Jan 2009 20:59:31 +0100 Subject: [rspec-users] Rspec beta book documenting errors In-Reply-To: <7ac2300c0901291136v4b2f44aye50eda29eaf9daf9@mail.gmail.com> References: <7ac2300c0901291136v4b2f44aye50eda29eaf9daf9@mail.gmail.com> Message-ID: <8d961d900901291159t18685c44ocb5aabae1d088d1c@mail.gmail.com> On Thu, Jan 29, 2009 at 8:36 PM, aidy lewis wrote: > Hi, > > Where should we be documenting errors in the Rspec beta book? > There is an "Errata" link on the main book page that points here: http://www.pragprog.com/titles/achbd/errata Aslak > Thanks > > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From aslak.hellesoy at gmail.com Thu Jan 29 15:04:34 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 29 Jan 2009 21:04:34 +0100 Subject: [rspec-users] simple == with prettier error messages + good documentation In-Reply-To: <57c63afe0901291118h5e18acafg5cdc57994b5df9ed@mail.gmail.com> References: <167563.64595.qm@web31805.mail.mud.yahoo.com> <57c63afe0901291025i1b1a18dah17b76a4650af60d1@mail.gmail.com> <8d961d900901291102l67a1414bq1f4dbfd1951979e4@mail.gmail.com> <57c63afe0901291118h5e18acafg5cdc57994b5df9ed@mail.gmail.com> Message-ID: <8d961d900901291204y592c20dav51971c93adbc11e7@mail.gmail.com> On Thu, Jan 29, 2009 at 8:18 PM, David Chelimsky wrote: > > > On Thu, Jan 29, 2009 at 1:02 PM, aslak hellesoy > wrote: >> >> On Thu, Jan 29, 2009 at 7:25 PM, David Chelimsky >> wrote: >> > >> > >> > On Thu, Jan 29, 2009 at 12:00 PM, wrote: >> >> >> >> Hi all, >> >> >> >> I've found myself writing a thing I think is less than optimal, looking >> >> for suggestions. The context is, I'm testing a result, and as a part >> >> of >> >> that test, I might verify two or three things, which are individually >> >> relevant but not really discrete results (?). >> >> >> >> Here's my thinking process, using a toy example: >> >> >> >> foo.should == bar (or foo.should_not be_nil) >> >> >> >> > expected not to be nil, but was >> >> >> >> (hm, not very informative) >> >> >> >> if( foo == nil ) >> >> "failure to setup foo".should == "foo should be set to the thing >> >> that >> >> will be rendered" >> >> end >> >> >> >> > expected "foo should be set to the thing that will be rendered", >> >> > got "failure to setup foo" (using ==) >> >> >> >> I've used this, by example, for a test on a dependency (imagemagick), >> >> where if the dependency isn't found, I show a decent message with info >> >> the >> >> tester can use to resolve it. And, as I mentioned, I've used it for >> >> revealing more details in cases where the it "" + the generic error >> >> aren't >> >> informative. >> >> >> >> I'm satisfied using this method for things like detecting a failure to >> >> use >> >> a test-helper correctly - works fine, doesn't get in my way as part of >> >> the >> >> documentation. Which brings me to the problem I'm concerned about: >> >> >> >> With this method, nothing come out in the generated spec-docs to >> >> represent >> >> the thing I'm conditionally requiring. >> >> >> >> I guess I could get more fine-grained with my it()'s, but I've been >> >> preferring a more general statement for it(), that gives the sense >> >> without >> >> the detail. >> >> >> >> Any suggestions? >> > >> > I can't think of anything that wouldn't result in something that >> > requires >> > more writing as of now. Maybe we need a new construct like: >> > it "does something" do >> > with_message "this is a more specific message" do >> > foo.should == bar >> > end >> > end >> > WDYT? >> > >> >> I think that would be useful. Maybe make it more explicit that it's an >> error message: >> >> on_error "bla" do >> ... >> end > > on_failure "..." do ???? > uh crap. strike last remark >> >> >> >> >> Thanks, >> >> >> >> Randy >> >> >> >> >> >> _______________________________________________ >> >> 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 >> > >> >> >> >> -- >> Aslak (::) >> _______________________________________________ >> 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 > -- Aslak (::) From nick at deadorange.com Thu Jan 29 15:38:03 2009 From: nick at deadorange.com (Nick Hoffman) Date: Thu, 29 Jan 2009 15:38:03 -0500 Subject: [rspec-users] simple == with prettier error messages + good documentation In-Reply-To: <57c63afe0901291118h5e18acafg5cdc57994b5df9ed@mail.gmail.com> References: <167563.64595.qm@web31805.mail.mud.yahoo.com> <57c63afe0901291025i1b1a18dah17b76a4650af60d1@mail.gmail.com> <8d961d900901291102l67a1414bq1f4dbfd1951979e4@mail.gmail.com> <57c63afe0901291118h5e18acafg5cdc57994b5df9ed@mail.gmail.com> Message-ID: On 29/01/2009, at 2:18 PM, David Chelimsky wrote: > On Thu, Jan 29, 2009 at 1:02 PM, aslak hellesoy > wrote: > On Thu, Jan 29, 2009 at 7:25 PM, David Chelimsky > wrote: > > > > > > On Thu, Jan 29, 2009 at 12:00 PM, wrote: > >> > >> Hi all, > >> > >> I've found myself writing a thing I think is less than optimal, > looking > >> for suggestions. The context is, I'm testing a result, and as a > part of > >> that test, I might verify two or three things, which are > individually > >> relevant but not really discrete results (?). > >> > >> Here's my thinking process, using a toy example: > >> > >> foo.should == bar (or foo.should_not be_nil) > >> > >> > expected not to be nil, but was > >> > >> (hm, not very informative) > >> > >> if( foo == nil ) > >> "failure to setup foo".should == "foo should be set to the > thing that > >> will be rendered" > >> end > >> > >> > expected "foo should be set to the thing that will be rendered", > >> > got "failure to setup foo" (using ==) > >> > >> I've used this, by example, for a test on a dependency > (imagemagick), > >> where if the dependency isn't found, I show a decent message with > info the > >> tester can use to resolve it. And, as I mentioned, I've used it > for > >> revealing more details in cases where the it "" + the generic > error aren't > >> informative. > >> > >> I'm satisfied using this method for things like detecting a > failure to use > >> a test-helper correctly - works fine, doesn't get in my way as > part of the > >> documentation. Which brings me to the problem I'm concerned about: > >> > >> With this method, nothing come out in the generated spec-docs to > represent > >> the thing I'm conditionally requiring. > >> > >> I guess I could get more fine-grained with my it()'s, but I've been > >> preferring a more general statement for it(), that gives the > sense without > >> the detail. > >> > >> Any suggestions? > > > > I can't think of anything that wouldn't result in something that > requires > > more writing as of now. Maybe we need a new construct like: > > it "does something" do > > with_message "this is a more specific message" do > > foo.should == bar > > end > > end > > WDYT? > > > > I think that would be useful. Maybe make it more explicit that it's an > error message: > > on_error "bla" do > ... > end > > on_failure "..." do ???? I like "on_failure", as it's consistent with RSpec's output. Eg: 31 examples, 0 failures What could be done to make the construct more sentence-like? If used in this manner: it 'should do something' do on_failure "@foo is nil" do @foo.should_not be_nil end end It reads like this to me: If "@foo is nil" fails, execute the block. These are a bit verbose, but what do you think these approaches?: http://gist.github.com/54726 From dchelimsky at gmail.com Thu Jan 29 16:14:54 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 29 Jan 2009 15:14:54 -0600 Subject: [rspec-users] simple == with prettier error messages + good documentation In-Reply-To: References: <167563.64595.qm@web31805.mail.mud.yahoo.com> <57c63afe0901291025i1b1a18dah17b76a4650af60d1@mail.gmail.com> <8d961d900901291102l67a1414bq1f4dbfd1951979e4@mail.gmail.com> <57c63afe0901291118h5e18acafg5cdc57994b5df9ed@mail.gmail.com> Message-ID: <57c63afe0901291314y205a899bj1763d7d713792a81@mail.gmail.com> On Thu, Jan 29, 2009 at 2:38 PM, Nick Hoffman wrote: > On 29/01/2009, at 2:18 PM, David Chelimsky wrote: >> >> On Thu, Jan 29, 2009 at 1:02 PM, aslak hellesoy >> wrote: >> On Thu, Jan 29, 2009 at 7:25 PM, David Chelimsky >> wrote: >> > >> > >> > On Thu, Jan 29, 2009 at 12:00 PM, wrote: >> >> >> >> Hi all, >> >> >> >> I've found myself writing a thing I think is less than optimal, looking >> >> for suggestions. The context is, I'm testing a result, and as a part >> >> of >> >> that test, I might verify two or three things, which are individually >> >> relevant but not really discrete results (?). >> >> >> >> Here's my thinking process, using a toy example: >> >> >> >> foo.should == bar (or foo.should_not be_nil) >> >> >> >> > expected not to be nil, but was >> >> >> >> (hm, not very informative) >> >> >> >> if( foo == nil ) >> >> "failure to setup foo".should == "foo should be set to the thing >> >> that >> >> will be rendered" >> >> end >> >> >> >> > expected "foo should be set to the thing that will be rendered", >> >> > got "failure to setup foo" (using ==) >> >> >> >> I've used this, by example, for a test on a dependency (imagemagick), >> >> where if the dependency isn't found, I show a decent message with info >> >> the >> >> tester can use to resolve it. And, as I mentioned, I've used it for >> >> revealing more details in cases where the it "" + the generic error >> >> aren't >> >> informative. >> >> >> >> I'm satisfied using this method for things like detecting a failure to >> >> use >> >> a test-helper correctly - works fine, doesn't get in my way as part of >> >> the >> >> documentation. Which brings me to the problem I'm concerned about: >> >> >> >> With this method, nothing come out in the generated spec-docs to >> >> represent >> >> the thing I'm conditionally requiring. >> >> >> >> I guess I could get more fine-grained with my it()'s, but I've been >> >> preferring a more general statement for it(), that gives the sense >> >> without >> >> the detail. >> >> >> >> Any suggestions? >> > >> > I can't think of anything that wouldn't result in something that >> > requires >> > more writing as of now. Maybe we need a new construct like: >> > it "does something" do >> > with_message "this is a more specific message" do >> > foo.should == bar >> > end >> > end >> > WDYT? >> > >> >> I think that would be useful. Maybe make it more explicit that it's an >> error message: >> >> on_error "bla" do >> ... >> end >> >> on_failure "..." do ???? > > I like "on_failure", as it's consistent with RSpec's output. Eg: > 31 examples, 0 failures > > What could be done to make the construct more sentence-like? If used in this > manner: > > it 'should do something' do > on_failure "@foo is nil" do > @foo.should_not be_nil > end > end > > It reads like this to me: > If "@foo is nil" fails, execute the block. > > These are a bit verbose, but what do you think these approaches?: > http://gist.github.com/54726 I'll take that gist and raise you one: http://gist.github.com/54750 (Suggestion #3) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Thu Jan 29 16:27:02 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 29 Jan 2009 22:27:02 +0100 Subject: [rspec-users] simple == with prettier error messages + good documentation In-Reply-To: <57c63afe0901291314y205a899bj1763d7d713792a81@mail.gmail.com> References: <167563.64595.qm@web31805.mail.mud.yahoo.com> <57c63afe0901291025i1b1a18dah17b76a4650af60d1@mail.gmail.com> <8d961d900901291102l67a1414bq1f4dbfd1951979e4@mail.gmail.com> <57c63afe0901291118h5e18acafg5cdc57994b5df9ed@mail.gmail.com> <57c63afe0901291314y205a899bj1763d7d713792a81@mail.gmail.com> Message-ID: <8d961d900901291327le97eed7pa9ab234cd5539fe9@mail.gmail.com> On Thu, Jan 29, 2009 at 10:14 PM, David Chelimsky wrote: > On Thu, Jan 29, 2009 at 2:38 PM, Nick Hoffman wrote: >> On 29/01/2009, at 2:18 PM, David Chelimsky wrote: >>> >>> On Thu, Jan 29, 2009 at 1:02 PM, aslak hellesoy >>> wrote: >>> On Thu, Jan 29, 2009 at 7:25 PM, David Chelimsky >>> wrote: >>> > >>> > >>> > On Thu, Jan 29, 2009 at 12:00 PM, wrote: >>> >> >>> >> Hi all, >>> >> >>> >> I've found myself writing a thing I think is less than optimal, looking >>> >> for suggestions. The context is, I'm testing a result, and as a part >>> >> of >>> >> that test, I might verify two or three things, which are individually >>> >> relevant but not really discrete results (?). >>> >> >>> >> Here's my thinking process, using a toy example: >>> >> >>> >> foo.should == bar (or foo.should_not be_nil) >>> >> >>> >> > expected not to be nil, but was >>> >> >>> >> (hm, not very informative) >>> >> >>> >> if( foo == nil ) >>> >> "failure to setup foo".should == "foo should be set to the thing >>> >> that >>> >> will be rendered" >>> >> end >>> >> >>> >> > expected "foo should be set to the thing that will be rendered", >>> >> > got "failure to setup foo" (using ==) >>> >> >>> >> I've used this, by example, for a test on a dependency (imagemagick), >>> >> where if the dependency isn't found, I show a decent message with info >>> >> the >>> >> tester can use to resolve it. And, as I mentioned, I've used it for >>> >> revealing more details in cases where the it "" + the generic error >>> >> aren't >>> >> informative. >>> >> >>> >> I'm satisfied using this method for things like detecting a failure to >>> >> use >>> >> a test-helper correctly - works fine, doesn't get in my way as part of >>> >> the >>> >> documentation. Which brings me to the problem I'm concerned about: >>> >> >>> >> With this method, nothing come out in the generated spec-docs to >>> >> represent >>> >> the thing I'm conditionally requiring. >>> >> >>> >> I guess I could get more fine-grained with my it()'s, but I've been >>> >> preferring a more general statement for it(), that gives the sense >>> >> without >>> >> the detail. >>> >> >>> >> Any suggestions? >>> > >>> > I can't think of anything that wouldn't result in something that >>> > requires >>> > more writing as of now. Maybe we need a new construct like: >>> > it "does something" do >>> > with_message "this is a more specific message" do >>> > foo.should == bar >>> > end >>> > end >>> > WDYT? >>> > >>> >>> I think that would be useful. Maybe make it more explicit that it's an >>> error message: >>> >>> on_error "bla" do >>> ... >>> end >>> >>> on_failure "..." do ???? >> >> I like "on_failure", as it's consistent with RSpec's output. Eg: >> 31 examples, 0 failures >> >> What could be done to make the construct more sentence-like? If used in this >> manner: >> >> it 'should do something' do >> on_failure "@foo is nil" do >> @foo.should_not be_nil >> end >> end >> >> It reads like this to me: >> If "@foo is nil" fails, execute the block. >> >> These are a bit verbose, but what do you think these approaches?: >> http://gist.github.com/54726 > > I'll take that gist and raise you one: > > http://gist.github.com/54750 (Suggestion #3) > Upped: http://gist.github.com/54758 >> _______________________________________________ >> 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 > -- Aslak (::) From dchelimsky at gmail.com Thu Jan 29 16:32:21 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 29 Jan 2009 15:32:21 -0600 Subject: [rspec-users] simple == with prettier error messages + good documentation In-Reply-To: <8d961d900901291327le97eed7pa9ab234cd5539fe9@mail.gmail.com> References: <167563.64595.qm@web31805.mail.mud.yahoo.com> <57c63afe0901291025i1b1a18dah17b76a4650af60d1@mail.gmail.com> <8d961d900901291102l67a1414bq1f4dbfd1951979e4@mail.gmail.com> <57c63afe0901291118h5e18acafg5cdc57994b5df9ed@mail.gmail.com> <57c63afe0901291314y205a899bj1763d7d713792a81@mail.gmail.com> <8d961d900901291327le97eed7pa9ab234cd5539fe9@mail.gmail.com> Message-ID: <57c63afe0901291332k17a5e7fhfed81d51f11eb047@mail.gmail.com> On Thu, Jan 29, 2009 at 3:27 PM, aslak hellesoy wrote: > On Thu, Jan 29, 2009 at 10:14 PM, David Chelimsky wrote: >> On Thu, Jan 29, 2009 at 2:38 PM, Nick Hoffman wrote: >>> On 29/01/2009, at 2:18 PM, David Chelimsky wrote: >>>> >>>> On Thu, Jan 29, 2009 at 1:02 PM, aslak hellesoy >>>> wrote: >>>> On Thu, Jan 29, 2009 at 7:25 PM, David Chelimsky >>>> wrote: >>>> > >>>> > >>>> > On Thu, Jan 29, 2009 at 12:00 PM, wrote: >>>> >> >>>> >> Hi all, >>>> >> >>>> >> I've found myself writing a thing I think is less than optimal, looking >>>> >> for suggestions. The context is, I'm testing a result, and as a part >>>> >> of >>>> >> that test, I might verify two or three things, which are individually >>>> >> relevant but not really discrete results (?). >>>> >> >>>> >> Here's my thinking process, using a toy example: >>>> >> >>>> >> foo.should == bar (or foo.should_not be_nil) >>>> >> >>>> >> > expected not to be nil, but was >>>> >> >>>> >> (hm, not very informative) >>>> >> >>>> >> if( foo == nil ) >>>> >> "failure to setup foo".should == "foo should be set to the thing >>>> >> that >>>> >> will be rendered" >>>> >> end >>>> >> >>>> >> > expected "foo should be set to the thing that will be rendered", >>>> >> > got "failure to setup foo" (using ==) >>>> >> >>>> >> I've used this, by example, for a test on a dependency (imagemagick), >>>> >> where if the dependency isn't found, I show a decent message with info >>>> >> the >>>> >> tester can use to resolve it. And, as I mentioned, I've used it for >>>> >> revealing more details in cases where the it "" + the generic error >>>> >> aren't >>>> >> informative. >>>> >> >>>> >> I'm satisfied using this method for things like detecting a failure to >>>> >> use >>>> >> a test-helper correctly - works fine, doesn't get in my way as part of >>>> >> the >>>> >> documentation. Which brings me to the problem I'm concerned about: >>>> >> >>>> >> With this method, nothing come out in the generated spec-docs to >>>> >> represent >>>> >> the thing I'm conditionally requiring. >>>> >> >>>> >> I guess I could get more fine-grained with my it()'s, but I've been >>>> >> preferring a more general statement for it(), that gives the sense >>>> >> without >>>> >> the detail. >>>> >> >>>> >> Any suggestions? >>>> > >>>> > I can't think of anything that wouldn't result in something that >>>> > requires >>>> > more writing as of now. Maybe we need a new construct like: >>>> > it "does something" do >>>> > with_message "this is a more specific message" do >>>> > foo.should == bar >>>> > end >>>> > end >>>> > WDYT? >>>> > >>>> >>>> I think that would be useful. Maybe make it more explicit that it's an >>>> error message: >>>> >>>> on_error "bla" do >>>> ... >>>> end >>>> >>>> on_failure "..." do ???? >>> >>> I like "on_failure", as it's consistent with RSpec's output. Eg: >>> 31 examples, 0 failures >>> >>> What could be done to make the construct more sentence-like? If used in this >>> manner: >>> >>> it 'should do something' do >>> on_failure "@foo is nil" do >>> @foo.should_not be_nil >>> end >>> end >>> >>> It reads like this to me: >>> If "@foo is nil" fails, execute the block. >>> >>> These are a bit verbose, but what do you think these approaches?: >>> http://gist.github.com/54726 >> >> I'll take that gist and raise you one: >> >> http://gist.github.com/54750 (Suggestion #3) >> > > Upped: > > http://gist.github.com/54758 Somebody move this to a ticket please :) > >>> _______________________________________________ >>> 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 >> > > > > -- > Aslak (::) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From byrnejb at harte-lyne.ca Thu Jan 29 16:24:36 2009 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Thu, 29 Jan 2009 16:24:36 -0500 (EST) Subject: [rspec-users] RSpec - Testing ActiveRecord addins Message-ID: <45017.216.185.71.24.1233264276.squirrel@webmail.harte-lyne.ca> I wish to test a small library that I have written. The module resides in a file in ./lib. It is loaded in the application via a a file in ./config/initializers that contains the following code: > require 'hll_audit_stamps' > ActiveRecord::Base > include ActiveRecord::HLLAuditStamps > end My questions are really procedural in nature. What do I put at the top of my spec file to load an ActiveRecord instance containing the custom module? Or, do I put the code given above into spec_helper.rb? I am really only interested in the actions of the module so I would like to create a test model instance (Mytable) inside the spec rather than create a dummy model in app/models. How do you do this without connecting to an underlying database? I am unfamiliar with mocks, although this seems to be the case for one. Nonetheless, am am uncertain how a mock would inherit the necessary characteristics from the module that I am testing? I would appreciate guidance here. Sincerely, -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From nick at deadorange.com Thu Jan 29 16:46:46 2009 From: nick at deadorange.com (Nick Hoffman) Date: Thu, 29 Jan 2009 16:46:46 -0500 Subject: [rspec-users] simple == with prettier error messages + good documentation In-Reply-To: <8d961d900901291327le97eed7pa9ab234cd5539fe9@mail.gmail.com> References: <167563.64595.qm@web31805.mail.mud.yahoo.com> <57c63afe0901291025i1b1a18dah17b76a4650af60d1@mail.gmail.com> <8d961d900901291102l67a1414bq1f4dbfd1951979e4@mail.gmail.com> <57c63afe0901291118h5e18acafg5cdc57994b5df9ed@mail.gmail.com> <57c63afe0901291314y205a899bj1763d7d713792a81@mail.gmail.com> <8d961d900901291327le97eed7pa9ab234cd5539fe9@mail.gmail.com> Message-ID: On 29/01/2009, at 4:27 PM, aslak hellesoy wrote: > On Thu, Jan 29, 2009 at 10:14 PM, David Chelimsky > wrote: >> On Thu, Jan 29, 2009 at 2:38 PM, Nick Hoffman >> wrote: >>> I like "on_failure", as it's consistent with RSpec's output. Eg: >>> 31 examples, 0 failures >>> >>> What could be done to make the construct more sentence-like? If >>> used in this >>> manner: >>> >>> it 'should do something' do >>> on_failure "@foo is nil" do >>> @foo.should_not be_nil >>> end >>> end >>> >>> It reads like this to me: >>> If "@foo is nil" fails, execute the block. >>> >>> These are a bit verbose, but what do you think these approaches?: >>> http://gist.github.com/54726 >> >> I'll take that gist and raise you one: >> >> http://gist.github.com/54750 (Suggestion #3) > > Upped: > > http://gist.github.com/54758 Putting the message at the end is a great idea! I still think that naming the method (and thus starting the block) with "on_failure" is a bit misleading when read aloud...but maybe that's not a big concern for you guys? What do you think about this modification to #3?: http://gist.github.com/54770 From r_j_h_box-sf at yahoo.com Thu Jan 29 16:50:12 2009 From: r_j_h_box-sf at yahoo.com (r_j_h_box-sf at yahoo.com) Date: Thu, 29 Jan 2009 13:50:12 -0800 (PST) Subject: [rspec-users] simple == with prettier error messages + good documentation References: <167563.64595.qm@web31805.mail.mud.yahoo.com> <57c63afe0901291025i1b1a18dah17b76a4650af60d1@mail.gmail.com> <8d961d900901291102l67a1414bq1f4dbfd1951979e4@mail.gmail.com> <57c63afe0901291118h5e18acafg5cdc57994b5df9ed@mail.gmail.com> <57c63afe0901291314y205a899bj1763d7d713792a81@mail.gmail.com> <8d961d900901291327le97eed7pa9ab234cd5539fe9@mail.gmail.com> Message-ID: <664078.75402.qm@web31813.mail.mud.yahoo.com> I'm starting to wonder if this is a good idea to begin with. I had started to suggest nested it()s: it "..." do it "something more" do end end ... but it's already handled by the existing nested describe(), before(), it() system. I guess if we were shooting for flexibility, we might ask what the simplest way is to the next level of flex? One route might be a detail level on describe() blocks. So, suggestion #5: http://gist.github.com/54764 Then when generating spec docs, you could vary the detail level on what's generated, to generate only up to level-2 documentation, or to generate full-detail documentation if you prefer. Nested it()s could do the same thing, I suppose. Not sure what side effects would come into play. Pretty clearly, a nested it() wouldn't have an embedded transaction or respect the outer before() block, since the outer if() would handle both those things. Randy ________________________________ From: aslak hellesoy To: rspec-users Sent: Thursday, January 29, 2009 1:27:02 PM Subject: Re: [rspec-users] simple == with prettier error messages + good documentation On Thu, Jan 29, 2009 at 10:14 PM, David Chelimsky wrote: > On Thu, Jan 29, 2009 at 2:38 PM, Nick Hoffman wrote: >> On 29/01/2009, at 2:18 PM, David Chelimsky wrote: >>> >>> On Thu, Jan 29, 2009 at 1:02 PM, aslak hellesoy >>> wrote: >>> On Thu, Jan 29, 2009 at 7:25 PM, David Chelimsky >>> wrote: >>> > >>> > >>> > On Thu, Jan 29, 2009 at 12:00 PM, wrote: >>> >> >>> >> Hi all, >>> >> >>> >> I've found myself writing a thing I think is less than optimal, looking >>> >> for suggestions. The context is, I'm testing a result, and as a part >>> >> of >>> >> that test, I might verify two or three things, which are individually >>> >> relevant but not really discrete results (?). >>> >> >>> >> Here's my thinking process, using a toy example: >>> >> >>> >> foo.should == bar (or foo.should_not be_nil) >>> >> >>> >> > expected not to be nil, but was >>> >> >>> >> (hm, not very informative) >>> >> >>> >> if( foo == nil ) >>> >> "failure to setup foo".should == "foo should be set to the thing >>> >> that >>> >> will be rendered" >>> >> end >>> >> >>> >> > expected "foo should be set to the thing that will be rendered", >>> >> > got "failure to setup foo" (using ==) >>> >> >>> >> I've used this, by example, for a test on a dependency (imagemagick), >>> >> where if the dependency isn't found, I show a decent message with info >>> >> the >>> >> tester can use to resolve it. And, as I mentioned, I've used it for >>> >> revealing more details in cases where the it "" + the generic error >>> >> aren't >>> >> informative. >>> >> >>> >> I'm satisfied using this method for things like detecting a failure to >>> >> use >>> >> a test-helper correctly - works fine, doesn't get in my way as part of >>> >> the >>> >> documentation. Which brings me to the problem I'm concerned about: >>> >> >>> >> With this method, nothing come out in the generated spec-docs to >>> >> represent >>> >> the thing I'm conditionally requiring. >>> >> >>> >> I guess I could get more fine-grained with my it()'s, but I've been >>> >> preferring a more general statement for it(), that gives the sense >>> >> without >>> >> the detail. >>> >> >>> >> Any suggestions? >>> > >>> > I can't think of anything that wouldn't result in something that >>> > requires >>> > more writing as of now. Maybe we need a new construct like: >>> > it "does something" do >>> > with_message "this is a more specific message" do >>> > foo.should == bar >>> > end >>> > end >>> > WDYT? >>> > >>> >>> I think that would be useful. Maybe make it more explicit that it's an >>> error message: >>> >>> on_error "bla" do >>> ... >>> end >>> >>> on_failure "..." do ???? >> >> I like "on_failure", as it's consistent with RSpec's output. Eg: >> 31 examples, 0 failures >> >> What could be done to make the construct more sentence-like? If used in this >> manner: >> >> it 'should do something' do >> on_failure "@foo is nil" do >> @foo.should_not be_nil >> end >> end >> >> It reads like this to me: >> If "@foo is nil" fails, execute the block. >> >> These are a bit verbose, but what do you think these approaches?: >> http://gist.github.com/54726 > > I'll take that gist and raise you one: > > http://gist.github.com/54750 (Suggestion #3) > Upped: http://gist.github.com/54758 >> _______________________________________________ >> 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 > -- Aslak (::) _______________________________________________ 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 scott at railsnewbie.com Thu Jan 29 16:50:37 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Thu, 29 Jan 2009 16:50:37 -0500 Subject: [rspec-users] session vs. controller.session In-Reply-To: <51D98BCF-8ADB-4E1C-BEA5-6A1204B0142F@railsnewbie.com> References: <51D98BCF-8ADB-4E1C-BEA5-6A1204B0142F@railsnewbie.com> Message-ID: <12170332-807C-4515-A9C6-3C3DC43862C9@railsnewbie.com> On Jan 29, 2009, at 1:57 PM, Scott Taylor wrote: > > > What exactly is the difference between using controller.session and > session? I though that session was just a proxy controller.session, > but this irb/debug sessions show that it isn't: > > http://gist.github.com/54673 > > When I call reset_session in the controller, I'm seeing the > controller's session reset, but not the session() provided in the > spec. Is this intended behavior? Nevermind. It was a bug in rails HEAD. http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1823-bugpatch-response-and-request-objects-dont-use-the-same-session Scott From r_j_h_box-sf at yahoo.com Thu Jan 29 16:56:31 2009 From: r_j_h_box-sf at yahoo.com (r_j_h_box-sf at yahoo.com) Date: Thu, 29 Jan 2009 13:56:31 -0800 (PST) Subject: [rspec-users] simple == with prettier error messages + good documentation References: <167563.64595.qm@web31805.mail.mud.yahoo.com> <57c63afe0901291025i1b1a18dah17b76a4650af60d1@mail.gmail.com> <8d961d900901291102l67a1414bq1f4dbfd1951979e4@mail.gmail.com> <57c63afe0901291118h5e18acafg5cdc57994b5df9ed@mail.gmail.com> <57c63afe0901291314y205a899bj1763d7d713792a81@mail.gmail.com> <8d961d900901291327le97eed7pa9ab234cd5539fe9@mail.gmail.com> Message-ID: <412371.56469.qm@web31804.mail.mud.yahoo.com> I do like try_to do...end.or_report - much better for the case where I'm not trying to generate documentation. I'm not sure it works so well for the case where I want to generate an extra element of documentation, though this might be just an implementation detail. .or_report .or_document .or_gripe .or_complain One of the first two could generate documentation, and one of the others might generate none. Randy ________________________________ From: Nick Hoffman On 29/01/2009, at 4:27 PM, aslak hellesoy wrote: > http://gist.github.com/54758 Putting the message at the end is a great idea! I still think that naming the method (and thus starting the block) with "on_failure" is a bit misleading when read aloud...but maybe that's not a big concern for you guys? What do you think about this modification to #3?: http://gist.github.com/54770 _______________________________________________ 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 ben at benmabey.com Thu Jan 29 17:06:08 2009 From: ben at benmabey.com (Ben Mabey) Date: Thu, 29 Jan 2009 15:06:08 -0700 Subject: [rspec-users] RSpec - Testing ActiveRecord addins In-Reply-To: <45017.216.185.71.24.1233264276.squirrel@webmail.harte-lyne.ca> References: <45017.216.185.71.24.1233264276.squirrel@webmail.harte-lyne.ca> Message-ID: <49822850.9000902@benmabey.com> James B. Byrne wrote: > I wish to test a small library that I have written. The module > resides in a file in ./lib. It is loaded in the application via a a > file in ./config/initializers that contains the following code: > > >> require 'hll_audit_stamps' >> ActiveRecord::Base >> include ActiveRecord::HLLAuditStamps >> end >> > > My questions are really procedural in nature. What do I put at the > top of my spec file to load an ActiveRecord instance containing the > custom module? Or, do I put the code given above into > spec_helper.rb? > > I am really only interested in the actions of the module so I would > like to create a test model instance (Mytable) inside the spec > rather than create a dummy model in app/models. How do you do this > without connecting to an underlying database? I am unfamiliar with > mocks, although this seems to be the case for one. Nonetheless, am > am uncertain how a mock would inherit the necessary characteristics > from the module that I am testing? > > I would appreciate guidance here. > > Sincerely, > > > > > Hi James, From the looks of it you may want to move your module into a plugin and then have it's own set of specs. Doing this may make your life easier in running specs in the fashion you are wanting to. In the past I have done just this and have used the in-memory sqlite3 adapter with some dummy AR classes, just as you have explained. In your plugin's spec_helper put something like this: ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:") def setup_db ActiveRecord::Schema.define(:version => 1) do create_table :vehicles do |t| t.string :type, :name t.integer :dealership_id end create_table :dealerships do |t| t.string :name end end end def teardown_db ActiveRecord::Base.connection.tables.each do |table| ActiveRecord::Base.connection.drop_table(table) end end setup_db class Vehicle < ActiveRecord::Base ... end class Dealership < ActiveRecord::Base ... end You can then use the dummy AR classes in your specs with an in-memory DB. I hope that helps, Ben From dchelimsky at gmail.com Thu Jan 29 17:20:21 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 29 Jan 2009 16:20:21 -0600 Subject: [rspec-users] simple == with prettier error messages + good documentation In-Reply-To: <664078.75402.qm@web31813.mail.mud.yahoo.com> References: <167563.64595.qm@web31805.mail.mud.yahoo.com> <57c63afe0901291025i1b1a18dah17b76a4650af60d1@mail.gmail.com> <8d961d900901291102l67a1414bq1f4dbfd1951979e4@mail.gmail.com> <57c63afe0901291118h5e18acafg5cdc57994b5df9ed@mail.gmail.com> <57c63afe0901291314y205a899bj1763d7d713792a81@mail.gmail.com> <8d961d900901291327le97eed7pa9ab234cd5539fe9@mail.gmail.com> <664078.75402.qm@web31813.mail.mud.yahoo.com> Message-ID: <57c63afe0901291420o126515bfg5ef0077a6672820a@mail.gmail.com> On Thu, Jan 29, 2009 at 3:50 PM, wrote: > I'm starting to wonder if this is a good idea to begin with. I had started > to suggest nested it()s: > > it "..." do > it "something more" do > end > end > > ... but it's already handled by the existing nested describe(), before(), > it() system. > > I guess if we were shooting for flexibility, we might ask what the simplest > way is to the next level of flex? One route might be a detail level on > describe() blocks. So, suggestion #5: > > http://gist.github.com/54764 > > Then when generating spec docs, you could vary the detail level on what's > generated, to generate only up to level-2 documentation, or to generate > full-detail documentation if you prefer. > > Nested it()s could do the same thing, I suppose. Not sure what side effects > would come into play. Pretty clearly, a nested it() wouldn't have an > embedded transaction or respect the outer before() block, since the outer > if() would handle both those things. For a number of technical reasons, the nested code example (it()) is a non-starter. The idea of having some means of flagging examples so they report differently is possible. Right now, example groups and examples each take a hash in their declarations: describe "an example group", :with => "some, :args => "like this" do it "an example", :with => "some", :other => "args" ... end end Those are accessible to the runner, and are used internally for assorted filtering. As of this moment, they don't make it past the reporters, because the object that goes to formatters is a wrapper w/ limited information instead of the real example. We could add the options to that wrapper though, and then you'd be able to write a custom formatter that would do anything you like based on the configuration of those options. WDYT about that? > > Randy > > > ________________________________ > From: aslak hellesoy > To: rspec-users > Sent: Thursday, January 29, 2009 1:27:02 PM > Subject: Re: [rspec-users] simple == with prettier error messages + good > documentation > > On Thu, Jan 29, 2009 at 10:14 PM, David Chelimsky > wrote: >> On Thu, Jan 29, 2009 at 2:38 PM, Nick Hoffman wrote: >>> On 29/01/2009, at 2:18 PM, David Chelimsky wrote: >>>> >>>> On Thu, Jan 29, 2009 at 1:02 PM, aslak hellesoy >>>> >>>> wrote: >>>> On Thu, Jan 29, 2009 at 7:25 PM, David Chelimsky >>>> wrote: >>>> > >>>> > >>>> > On Thu, Jan 29, 2009 at 12:00 PM, wrote: >>>> >> >>>> >> Hi all, >>>> >> >>>> >> I've found myself writing a thing I think is less than optimal, >>>> >> looking >>>> >> for suggestions. The context is, I'm testing a result, and as a part >>>> >> of >>>> >> that test, I might verify two or three things, which are individually >>>> >> relevant but not really discrete results (?). >>>> >> >>>> >> Here's my thinking process, using a toy example: >>>> >> >>>> >> foo.should == bar (or foo.should_not be_nil) >>>> >> >>>> >> > expected not to be nil, but was >>>> >> >>>> >> (hm, not very informative) >>>> >> >>>> >> if( foo == nil ) >>>> >> "failure to setup foo".should == "foo should be set to the thing >>>> >> that >>>> >> will be rendered" >>>> >> end >>>> >> >>>> >> > expected "foo should be set to the thing that will be rendered", >>>> >> > got "failure to setup foo" (using ==) >>>> >> >>>> >> I've used this, by example, for a test on a dependency (imagemagick), >>>> >> where if the dependency isn't found, I show a decent message with >>>> >> info >>>> >> the >>>> >> tester can use to resolve it. And, as I mentioned, I've used it for >>>> >> revealing more details in cases where the it "" + the generic error >>>> >> aren't >>>> >> informative. >>>> >> >>>> >> I'm satisfied using this method for things like detecting a failure >>>> >> to >>>> >> use >>>> >> a test-helper correctly - works fine, doesn't get in my way as part >>>> >> of >>>> >> the >>>> >> documentation. Which brings me to the problem I'm concerned about: >>>> >> >>>> >> With this method, nothing come out in the generated spec-docs to >>>> >> represent >>>> >> the thing I'm conditionally requiring. >>>> >> >>>> >> I guess I could get more fine-grained with my it()'s, but I've been >>>> >> preferring a more general statement for it(), that gives the sense >>>> >> without >>>> >> the detail. >>>> >> >>>> >> Any suggestions? >>>> > >>>> > I can't think of anything that wouldn't result in something that >>>> > requires >>>> > more writing as of now. Maybe we need a new construct like: >>>> > it "does something" do >>>> > with_message "this is a more specific message" do >>>> > foo.should == bar >>>> > end >>>> > end >>>> > WDYT? >>>> > >>>> >>>> I think that would be useful. Maybe make it more explicit that it's an >>>> error message: >>>> >>>> on_error "bla" do >>>> ... >>>> end >>>> >>>> on_failure "..." do ???? >>> >>> I like "on_failure", as it's consistent with RSpec's output. Eg: >>> 31 examples, 0 failures >>> >>> What could be done to make the construct more sentence-like? If used in >>> this >>> manner: >>> >>> it 'should do something' do >>> on_failure "@foo is nil" do >>> @foo.should_not be_nil >>> end >>> end >>> >>> It reads like this to me: >>> If "@foo is nil" fails, execute the block. >>> >>> These are a bit verbose, but what do you think these approaches?: >>> http://gist.github.com/54726 >> >> I'll take that gist and raise you one: >> >> http://gist.github.com/54750 (Suggestion #3) >> > > Upped: > > http://gist.github.com/54758 > >>> _______________________________________________ >>> 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 >> > > > > -- > Aslak (::) > _______________________________________________ > 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 Thu Jan 29 18:37:56 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 30 Jan 2009 00:37:56 +0100 Subject: [rspec-users] RSpec - Testing ActiveRecord addins In-Reply-To: <49822850.9000902@benmabey.com> References: <45017.216.185.71.24.1233264276.squirrel@webmail.harte-lyne.ca> <49822850.9000902@benmabey.com> Message-ID: <9bfb9a52fdbe0f05bac07fb2b6e3650c@ruby-forum.com> Ben Mabey wrote: > > You can then use the dummy AR classes in your specs with an in-memory > DB. > > I hope that helps, > > Ben Oh, yes. very much. Especially this example. > def setup_db > ActiveRecord::Schema.define(:version => 1) do Have you, or anyone reading this, had any experience with the nulldb gem as an alternative to in memory sqlite3? -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Thu Jan 29 19:07:16 2009 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 30 Jan 2009 00:07:16 +0000 Subject: [rspec-users] simple == with prettier error messages + good documentation In-Reply-To: <57c63afe0901291420o126515bfg5ef0077a6672820a@mail.gmail.com> References: <167563.64595.qm@web31805.mail.mud.yahoo.com> <57c63afe0901291025i1b1a18dah17b76a4650af60d1@mail.gmail.com> <8d961d900901291102l67a1414bq1f4dbfd1951979e4@mail.gmail.com> <57c63afe0901291118h5e18acafg5cdc57994b5df9ed@mail.gmail.com> <57c63afe0901291314y205a899bj1763d7d713792a81@mail.gmail.com> <8d961d900901291327le97eed7pa9ab234cd5539fe9@mail.gmail.com> <664078.75402.qm@web31813.mail.mud.yahoo.com> <57c63afe0901291420o126515bfg5ef0077a6672820a@mail.gmail.com> Message-ID: <818D8494-1F09-465B-9033-EC550DACA523@mattwynne.net> On 29 Jan 2009, at 22:20, David Chelimsky wrote: > On Thu, Jan 29, 2009 at 3:50 PM, wrote: >>>>>> >>>>>> On Thu, Jan 29, 2009 at 12:00 PM, wrote: >>>>>>> >>>>>>> Hi all, >>>>>>> >>>>>>> I've found myself writing a thing I think is less than optimal, >>>>>>> looking >>>>>>> for suggestions. The context is, I'm testing a result, and as >>>>>>> a part >>>>>>> of >>>>>>> that test, I might verify two or three things, which are >>>>>>> individually >>>>>>> relevant but not really discrete results (?). >>>>>>> >>>>>>> Here's my thinking process, using a toy example: >>>>>>> >>>>>>> foo.should == bar (or foo.should_not be_nil) >>>>>>> >>>>>>>> expected not to be nil, but was >>>>>>> >>>>>>> (hm, not very informative) >>>>>>> >>>>>>> if( foo == nil ) >>>>>>> "failure to setup foo".should == "foo should be set to the >>>>>>> thing >>>>>>> that >>>>>>> will be rendered" >>>>>>> end >>>>>>> >>>>>>>> expected "foo should be set to the thing that will be >>>>>>>> rendered", >>>>>>>> got "failure to setup foo" (using ==) >>>>>>> >>>>>>> I've used this, by example, for a test on a dependency >>>>>>> (imagemagick), >>>>>>> where if the dependency isn't found, I show a decent message >>>>>>> with >>>>>>> info >>>>>>> the >>>>>>> tester can use to resolve it. And, as I mentioned, I've used >>>>>>> it for >>>>>>> revealing more details in cases where the it "" + the generic >>>>>>> error >>>>>>> aren't >>>>>>> informative. >>>>>>> >>>>>>> I'm satisfied using this method for things like detecting a >>>>>>> failure >>>>>>> to >>>>>>> use >>>>>>> a test-helper correctly - works fine, doesn't get in my way as >>>>>>> part >>>>>>> of >>>>>>> the >>>>>>> documentation. Which brings me to the problem I'm concerned >>>>>>> about: >>>>>>> >>>>>>> With this method, nothing come out in the generated spec-docs to >>>>>>> represent >>>>>>> the thing I'm conditionally requiring. >>>>>>> >>>>>>> I guess I could get more fine-grained with my it()'s, but I've >>>>>>> been >>>>>>> preferring a more general statement for it(), that gives the >>>>>>> sense >>>>>>> without >>>>>>> the detail. I really do suggest setting up the context in the before() block of a describe (example group), then using each 'it' (example) to hold an assertion. It's a tried and tested way of doing it for me, but it does take some getting used to when you move over from xUnit style tests. >>>>>>> >>>>>>> >>>>>>> Any suggestions? >>>>>> >>>>>> I can't think of anything that wouldn't result in something that >>>>>> requires >>>>>> more writing as of now. Maybe we need a new construct like: >>>>>> it "does something" do >>>>>> with_message "this is a more specific message" do >>>>>> foo.should == bar >>>>>> end >>>>>> end >>>>>> WDYT? >>>>>> >>>>> >>>>> I think that would be useful. Maybe make it more explicit that >>>>> it's an >>>>> error message: >>>>> >>>>> on_error "bla" do >>>>> ... >>>>> end >>>>> >>>>> on_failure "..." do ???? >>>> >>>> I like "on_failure", as it's consistent with RSpec's output. Eg: >>>> 31 examples, 0 failures >>>> >>>> What could be done to make the construct more sentence-like? If >>>> used in >>>> this >>>> manner: >>>> >>>> it 'should do something' do >>>> on_failure "@foo is nil" do >>>> @foo.should_not be_nil >>>> end >>>> end >>>> >>>> It reads like this to me: >>>> If "@foo is nil" fails, execute the block. >>>> >>>> These are a bit verbose, but what do you think these approaches?: >>>> http://gist.github.com/54726 >>> >>> I'll take that gist and raise you one: >>> >>> http://gist.github.com/54750 (Suggestion #3) >>> >> >> Upped: >> >> http://gist.github.com/54758 I do find myself hitting this sometimes, especially when I use rspec assertions in Cucumber steps - I usually stick to one assertion per example in RSpec so it isn't a problem when I'm writing unit tests. However we do have a couple of alternatives already, without extending RSpec any more: (1) just use traditional test/unit assertions instead (works OK in Cucumber steps, though obviously they don't read quite so well) (2) write a custom matcher We could also pretty easily extend the existing matchers, just taking a failure message in the factory method, e.g: http://gist.github.com/54849 I agree this discussion should move to a ticket. But it seems I am to lazy to do it myself ;) Matt Wynne http://blog.mattwynne.net http://www.songkick.com From dchelimsky at gmail.com Thu Jan 29 19:33:43 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 29 Jan 2009 18:33:43 -0600 Subject: [rspec-users] simple == with prettier error messages + good documentation In-Reply-To: <818D8494-1F09-465B-9033-EC550DACA523@mattwynne.net> References: <167563.64595.qm@web31805.mail.mud.yahoo.com> <57c63afe0901291025i1b1a18dah17b76a4650af60d1@mail.gmail.com> <8d961d900901291102l67a1414bq1f4dbfd1951979e4@mail.gmail.com> <57c63afe0901291118h5e18acafg5cdc57994b5df9ed@mail.gmail.com> <57c63afe0901291314y205a899bj1763d7d713792a81@mail.gmail.com> <8d961d900901291327le97eed7pa9ab234cd5539fe9@mail.gmail.com> <664078.75402.qm@web31813.mail.mud.yahoo.com> <57c63afe0901291420o126515bfg5ef0077a6672820a@mail.gmail.com> <818D8494-1F09-465B-9033-EC550DACA523@mattwynne.net> Message-ID: <57c63afe0901291633l719abfa3w73f4b89ea29afb36@mail.gmail.com> On Thu, Jan 29, 2009 at 6:07 PM, Matt Wynne wrote: > > On 29 Jan 2009, at 22:20, David Chelimsky wrote: > >> On Thu, Jan 29, 2009 at 3:50 PM, wrote: >>>>>>> >>>>>>> On Thu, Jan 29, 2009 at 12:00 PM, wrote: >>>>>>>> >>>>>>>> Hi all, >>>>>>>> >>>>>>>> I've found myself writing a thing I think is less than optimal, >>>>>>>> looking >>>>>>>> for suggestions. The context is, I'm testing a result, and as a >>>>>>>> part >>>>>>>> of >>>>>>>> that test, I might verify two or three things, which are >>>>>>>> individually >>>>>>>> relevant but not really discrete results (?). >>>>>>>> >>>>>>>> Here's my thinking process, using a toy example: >>>>>>>> >>>>>>>> foo.should == bar (or foo.should_not be_nil) >>>>>>>> >>>>>>>>> expected not to be nil, but was >>>>>>>> >>>>>>>> (hm, not very informative) >>>>>>>> >>>>>>>> if( foo == nil ) >>>>>>>> "failure to setup foo".should == "foo should be set to the thing >>>>>>>> that >>>>>>>> will be rendered" >>>>>>>> end >>>>>>>> >>>>>>>>> expected "foo should be set to the thing that will be rendered", >>>>>>>>> got "failure to setup foo" (using ==) >>>>>>>> >>>>>>>> I've used this, by example, for a test on a dependency >>>>>>>> (imagemagick), >>>>>>>> where if the dependency isn't found, I show a decent message with >>>>>>>> info >>>>>>>> the >>>>>>>> tester can use to resolve it. And, as I mentioned, I've used it for >>>>>>>> revealing more details in cases where the it "" + the generic error >>>>>>>> aren't >>>>>>>> informative. >>>>>>>> >>>>>>>> I'm satisfied using this method for things like detecting a failure >>>>>>>> to >>>>>>>> use >>>>>>>> a test-helper correctly - works fine, doesn't get in my way as part >>>>>>>> of >>>>>>>> the >>>>>>>> documentation. Which brings me to the problem I'm concerned about: >>>>>>>> >>>>>>>> With this method, nothing come out in the generated spec-docs to >>>>>>>> represent >>>>>>>> the thing I'm conditionally requiring. >>>>>>>> >>>>>>>> I guess I could get more fine-grained with my it()'s, but I've been >>>>>>>> preferring a more general statement for it(), that gives the sense >>>>>>>> without >>>>>>>> the detail. > > I really do suggest setting up the context in the before() block of a > describe (example group), then using each 'it' (example) to hold an > assertion. It's a tried and tested way of doing it for me, but it does take > some getting used to when you move over from xUnit style tests. > >>>>>>>> >>>>>>>> >>>>>>>> Any suggestions? >>>>>>> >>>>>>> I can't think of anything that wouldn't result in something that >>>>>>> requires >>>>>>> more writing as of now. Maybe we need a new construct like: >>>>>>> it "does something" do >>>>>>> with_message "this is a more specific message" do >>>>>>> foo.should == bar >>>>>>> end >>>>>>> end >>>>>>> WDYT? >>>>>>> >>>>>> >>>>>> I think that would be useful. Maybe make it more explicit that it's an >>>>>> error message: >>>>>> >>>>>> on_error "bla" do >>>>>> ... >>>>>> end >>>>>> >>>>>> on_failure "..." do ???? >>>>> >>>>> I like "on_failure", as it's consistent with RSpec's output. Eg: >>>>> 31 examples, 0 failures >>>>> >>>>> What could be done to make the construct more sentence-like? If used in >>>>> this >>>>> manner: >>>>> >>>>> it 'should do something' do >>>>> on_failure "@foo is nil" do >>>>> @foo.should_not be_nil >>>>> end >>>>> end >>>>> >>>>> It reads like this to me: >>>>> If "@foo is nil" fails, execute the block. >>>>> >>>>> These are a bit verbose, but what do you think these approaches?: >>>>> http://gist.github.com/54726 >>>> >>>> I'll take that gist and raise you one: >>>> >>>> http://gist.github.com/54750 (Suggestion #3) >>>> >>> >>> Upped: >>> >>> http://gist.github.com/54758 > > I do find myself hitting this sometimes, especially when I use rspec > assertions in Cucumber steps - I usually stick to one assertion per example > in RSpec so it isn't a problem when I'm writing unit tests. > > However we do have a couple of alternatives already, without extending RSpec > any more: > (1) just use traditional test/unit assertions instead (works OK in Cucumber > steps, though obviously they don't read quite so well) > (2) write a custom matcher > > We could also pretty easily extend the existing matchers, just taking a > failure message in the factory method, e.g: > > http://gist.github.com/54849 > > I agree this discussion should move to a ticket. But it seems I am to lazy > to do it myself ;) http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/669 > > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Thu Jan 29 22:18:12 2009 From: ben at benmabey.com (Ben Mabey) Date: Thu, 29 Jan 2009 20:18:12 -0700 Subject: [rspec-users] RSpec - Testing ActiveRecord addins In-Reply-To: <9bfb9a52fdbe0f05bac07fb2b6e3650c@ruby-forum.com> References: <45017.216.185.71.24.1233264276.squirrel@webmail.harte-lyne.ca> <49822850.9000902@benmabey.com> <9bfb9a52fdbe0f05bac07fb2b6e3650c@ruby-forum.com> Message-ID: <49827174.6040904@benmabey.com> James Byrne wrote: > Ben Mabey wrote: > > >> You can then use the dummy AR classes in your specs with an in-memory >> DB. >> >> I hope that helps, >> >> Ben >> > > Oh, yes. very much. Especially this example. > > >> def setup_db >> ActiveRecord::Schema.define(:version => 1) do >> > > Have you, or anyone reading this, had any experience with the nulldb gem > as an alternative to in memory sqlite3? > I used nulldb on my last project and I had a lot of success with it. Using nulldb comes with tradeoffs though and in this case I would just use sqlite. Unless the project and spec suite is large disconnecting the DB may not be worth the effort. -Ben From pergesu at gmail.com Thu Jan 29 22:32:01 2009 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 29 Jan 2009 19:32:01 -0800 Subject: [rspec-users] Strange message expectation behaviour with Time.now in a find condition In-Reply-To: <57c63afe0901291041x7769364eq70940bb01bd21615@mail.gmail.com> References: <1dcfd34b-4559-4c01-82b6-c0828f6851ca@y1g2000pra.googlegroups.com> <57c63afe0901291041x7769364eq70940bb01bd21615@mail.gmail.com> Message-ID: <810a540e0901291932gd8db8c5g9f043a085975720e@mail.gmail.com> On Thu, Jan 29, 2009 at 10:41 AM, David Chelimsky wrote: > > > On Thu, Jan 29, 2009 at 12:08 PM, tatyree wrote: >> >> Even if this is a bug, it's a pretty obscure one. It was frustrating >> the hell out of me until I found a workaround, so I thought I'd just >> post the details: >> >> Given a find like this: >> >> def self.find_old >> User.all(:conditions => ['updated_at <= ?',Time.now - 1.day) >> ... >> >> Trying to set a message expectation will always fail: >> >> it "should find users" do >> User.should_receive(:all).with({:conditions => ['updated_at >> <= ?',Time.now - 1.day]}) >> User.find_old >> ... >> >> with the error: >> Mock 'Class' expected :all with ({:conditions=>["updated_at <= ?", >> Wed Jan 28 17:59:02 +0000 2009]}) but received it with ({:conditions=> >> ["updated_at <= ?", Wed Jan 28 17:59:02 +0000 2009]}) >> >> Expected and received here are identical. >> >> The only workaround I've found (the example here is simplified, but >> the datetime in the model where I discovered the bug is critical and >> so needs to be spec'd) is to wrap the Time call and the expectation in >> another format: >> >> User.all(:conditions => ['updated_at <= ?',(Time.now - >> 1.day).xmlschema]) >> >> and >> >> it "should find users" do >> User.should_receive(:all).with({:conditions => ['updated_at <= ?', >> (Time.now - 1.day).xmlschema]}) >> >> I'm on rspec 1.1.12 on rails 2.1.0 and I'm guessing the + in the >> formatted datetime is playing hell with a regexp somewhere. >> Unfortunately, I don't have time to dig in to it myself right now. >> >> I was seeing the same behaviour when I tried hash_including >> (:conditions => ['updated_at <= ?',Time.now - 1.day]) as part of the >> expectation. > > The problem is a display problem - the Time objects are actually different > by some milliseconds, but you don't see that in the feedback. > Try this: > now = Time.now > Time.stub!(:now).and_return(now) > Then both calls will return the same object. What David, Aslak & Nick said. btw... ~:$ irb >> Time.now == Time.now => false Pat From patnakajima at gmail.com Fri Jan 30 01:06:42 2009 From: patnakajima at gmail.com (Pat Nakajima) Date: Thu, 29 Jan 2009 22:06:42 -0800 (PST) Subject: [rspec-users] RSpec - Testing ActiveRecord addins In-Reply-To: <49827174.6040904@benmabey.com> References: <45017.216.185.71.24.1233264276.squirrel@webmail.harte-lyne.ca> <49822850.9000902@benmabey.com> <9bfb9a52fdbe0f05bac07fb2b6e3650c@ruby-forum.com> <49827174.6040904@benmabey.com> Message-ID: (Sorry if this is double-posted, I was having trouble with joining the list) If you want an easy way to test ActiveRecord extensions, check out acts_as_fu: http://github.com/nakajima/acts_as_fu. It makes generating ActiveRecord models dead simple. Pat On Jan 29, 10:18?pm, Ben Mabey wrote: > James Byrne wrote: > > Ben Mabey wrote: > > >> You can then use the dummy AR classes in your specs with an in-memory > >> DB. > > >> I hope that helps, > > >> Ben > > > Oh, yes. very much. Especially this example. > > >> def setup_db > >> ? ActiveRecord::Schema.define(:version => 1) do > > > Have you, or anyone reading this, had any experience with the nulldb gem > > as an alternative to in memory sqlite3? > > I used nulldb on my last project and I had a lot of success with it. ? > Using nulldb comes with tradeoffs though and in this case I would just > use sqlite. ?Unless the project and spec suite is large disconnecting > the DB may not be worth the effort. > > -Ben > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From ben at benmabey.com Fri Jan 30 01:25:18 2009 From: ben at benmabey.com (Ben Mabey) Date: Thu, 29 Jan 2009 23:25:18 -0700 Subject: [rspec-users] RSpec - Testing ActiveRecord addins In-Reply-To: References: <45017.216.185.71.24.1233264276.squirrel@webmail.harte-lyne.ca> <49822850.9000902@benmabey.com> <9bfb9a52fdbe0f05bac07fb2b6e3650c@ruby-forum.com> <49827174.6040904@benmabey.com> Message-ID: <49829D4E.9060608@benmabey.com> Pat Nakajima wrote: > (Sorry if this is double-posted, I was having trouble with joining the > list) > > If you want an easy way to test ActiveRecord extensions, check out > acts_as_fu: http://github.com/nakajima/acts_as_fu. It makes generating > ActiveRecord models dead simple. > > Pat > Very slick. I'll be using this next time. :) -Ben > On Jan 29, 10:18 pm, Ben Mabey wrote: > >> James Byrne wrote: >> >>> Ben Mabey wrote: >>> >>>> You can then use the dummy AR classes in your specs with an in-memory >>>> DB. >>>> >>>> I hope that helps, >>>> >>>> Ben >>>> >>> Oh, yes. very much. Especially this example. >>> >>>> def setup_db >>>> ActiveRecord::Schema.define(:version => 1) do >>>> >>> Have you, or anyone reading this, had any experience with the nulldb gem >>> as an alternative to in memory sqlite3? >>> >> I used nulldb on my last project and I had a lot of success with it. >> Using nulldb comes with tradeoffs though and in this case I would just >> use sqlite. Unless the project and spec suite is large disconnecting >> the DB may not be worth the effort. >> >> -Ben >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From todd at snappl.co.uk Fri Jan 30 04:25:14 2009 From: todd at snappl.co.uk (tatyree) Date: Fri, 30 Jan 2009 01:25:14 -0800 (PST) Subject: [rspec-users] Strange message expectation behaviour with Time.now in a find condition In-Reply-To: <810a540e0901291932gd8db8c5g9f043a085975720e@mail.gmail.com> References: <1dcfd34b-4559-4c01-82b6-c0828f6851ca@y1g2000pra.googlegroups.com> <57c63afe0901291041x7769364eq70940bb01bd21615@mail.gmail.com> <810a540e0901291932gd8db8c5g9f043a085975720e@mail.gmail.com> Message-ID: Thanks for that everyone! Henceforth I shall always endeavour to stop the flow of time in all of my specs! From peter.fitzgibbons at gmail.com Fri Jan 30 09:10:34 2009 From: peter.fitzgibbons at gmail.com (Peter Fitzgibbons) Date: Fri, 30 Jan 2009 08:10:34 -0600 Subject: [rspec-users] Cucumber resource routes Message-ID: <670a00380901300610of5b4214y946f5e2bad207c5d@mail.gmail.com> Hi all, I'm missing something basic here. Inside ./features/support/paths.rb I want to use a ActionController::Resources helper for Products as mapped in routes.rb ./routes.rb map.resource :product ./features/support/paths.rb (abbreviated for clarity) def path_to(page_name) case page_name when /Product (\d+)/ project_path(:id => $1) else raise "Can't find mapping from \"#{page_name}\" to a path." end end rake features Given I go to Product 1 page # features/step_definitions/webrat_steps.rb:6 undefined method `project_path' for # (NoMethodError) So, can someone tell me the horribly obvious that I've missed? Peter Fitzgibbons (847) 687-7646 Email: peter.fitzgibbons at gmail.com IM GTalk: peter.fitzgibbons IM Yahoo: pjfitzgibbons IM MSN: pjfitzgibbons at hotmail.com IM AOL: peter.fitzgibbons at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From tomk32 at gmx.de Fri Jan 30 09:19:35 2009 From: tomk32 at gmx.de (Thomas R. Koll) Date: Fri, 30 Jan 2009 15:19:35 +0100 Subject: [rspec-users] Cucumber resource routes In-Reply-To: <670a00380901300610of5b4214y946f5e2bad207c5d@mail.gmail.com> References: <670a00380901300610of5b4214y946f5e2bad207c5d@mail.gmail.com> Message-ID: <5D21F32D-5206-468F-982A-46830E2D4BEB@gmx.de> Hi, uhmmm 'project'.should be('product') Am 30.01.2009 um 15:10 schrieb Peter Fitzgibbons: > Hi all, > > I'm missing something basic here. > > Inside ./features/support/paths.rb I want to use a > ActionController::Resources helper for Products as mapped in routes.rb > > ./routes.rb > map.resource :product > > ./features/support/paths.rb (abbreviated for clarity) > def path_to(page_name) > case page_name > when /Product (\d+)/ > project_path(:id => $1) > else > raise "Can't find mapping from \"#{page_name}\" to a path." > end > end > > rake features > Given I go to Product 1 page # features/step_definitions/ > webrat_steps.rb:6 > undefined method `project_path' for > # (NoMethodError) > > So, can someone tell me the horribly obvious that I've missed? -- Thomas R. "TomK32" Koll <> http://ananasblau.com just a geek trying to change the world http://github.com/TomK32 From lists at ruby-forum.com Fri Jan 30 09:25:46 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 30 Jan 2009 15:25:46 +0100 Subject: [rspec-users] RSpec - Testing ActiveRecord addins In-Reply-To: References: <45017.216.185.71.24.1233264276.squirrel@webmail.harte-lyne.ca> <49822850.9000902@benmabey.com> <9bfb9a52fdbe0f05bac07fb2b6e3650c@ruby-forum.com> <49827174.6040904@benmabey.com> Message-ID: <139722ebf6d673f91316e160aad0cd5d@ruby-forum.com> Pat Nakajima wrote: > (Sorry if this is double-posted, I was having trouble with joining the > list) > > If you want an easy way to test ActiveRecord extensions, check out > acts_as_fu: http://github.com/nakajima/acts_as_fu. It makes generating > ActiveRecord models dead simple. > > Pat This seems to be just what the behaviourist ordered... I am going to try this out for my present situation. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Fri Jan 30 09:26:51 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 30 Jan 2009 08:26:51 -0600 Subject: [rspec-users] Cucumber resource routes In-Reply-To: <670a00380901300610of5b4214y946f5e2bad207c5d@mail.gmail.com> References: <670a00380901300610of5b4214y946f5e2bad207c5d@mail.gmail.com> Message-ID: <57c63afe0901300626w2006f9b9n5e98fb2732b9d8e4@mail.gmail.com> On Fri, Jan 30, 2009 at 8:10 AM, Peter Fitzgibbons wrote: > Hi all, > > I'm missing something basic here. > > Inside ./features/support/paths.rb I want to use a > ActionController::Resources helper for Products as mapped in routes.rb > > ./routes.rb > map.resource :product > > ./features/support/paths.rb (abbreviated for clarity) > def path_to(page_name) > case page_name > when /Product (\d+)/ > project_path(:id => $1) > else > raise "Can't find mapping from \"#{page_name}\" to a path." > end > end > > rake features > Given I go to Product 1 page # > features/step_definitions/webrat_steps.rb:6 > undefined method `project_path' for > # (NoMethodError) > > So, can someone tell me the horribly obvious that I've missed? map.resource :product project_path(:id => $1) product != project > > Peter Fitzgibbons > (847) 687-7646 > Email: peter.fitzgibbons at gmail.com > IM GTalk: peter.fitzgibbons > IM Yahoo: pjfitzgibbons > IM MSN: pjfitzgibbons at hotmail.com > IM AOL: peter.fitzgibbons at gmail.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Fri Jan 30 09:49:46 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 30 Jan 2009 15:49:46 +0100 Subject: [rspec-users] OK... What is ... fu ? Message-ID: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> Pardon my ignorance, but exactly what does _fu mean WRT Ruby plugins, gems and such? I have run across this suffix a number of times in Ruby and Rails, always in connection with some add-on or extension. In the original context that I encountered '_fu' I inferred that it probably stood for file upload. However, its widespread use in other contexts evidently disproves this interpretation. So, does it have a meaning? Does it derive from the foo in foobar? Does it stand for functional update? Or, is it an obscure cultural reference to Ruby's Japanese origins? -- Posted via http://www.ruby-forum.com/. From cflipse at gmail.com Fri Jan 30 10:05:02 2009 From: cflipse at gmail.com (Chris Flipse) Date: Fri, 30 Jan 2009 10:05:02 -0500 Subject: [rspec-users] OK... What is ... fu ? In-Reply-To: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> References: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> Message-ID: Think Kung-Fu It's not an abbreviation, it's a suffix that's supposed to imply a certain level of kick-assery http://catb.org/jargon/html/F/suffix-fu.html On Fri, Jan 30, 2009 at 9:49 AM, James Byrne wrote: > Pardon my ignorance, but exactly what does _fu mean WRT Ruby plugins, > gems and such? > > I have run across this suffix a number of times in Ruby and Rails, > always in connection with some add-on or extension. In the original > context that I encountered '_fu' I inferred that it probably stood for > file upload. However, its widespread use in other contexts evidently > disproves this interpretation. So, does it have a meaning? Does it > derive from the foo in foobar? Does it stand for functional update? Or, > is it an obscure cultural reference to Ruby's Japanese origins? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > 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/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Fri Jan 30 10:07:18 2009 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 30 Jan 2009 15:07:18 +0000 Subject: [rspec-users] OK... What is ... fu ? In-Reply-To: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> References: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> Message-ID: <7EF74B0A-CE73-4FAD-A7BE-75F700857A6B@mattwynne.net> On 30 Jan 2009, at 14:49, James Byrne wrote: > Pardon my ignorance, but exactly what does _fu mean WRT Ruby plugins, > gems and such? > > I have run across this suffix a number of times in Ruby and Rails, > always in connection with some add-on or extension. In the original > context that I encountered '_fu' I inferred that it probably stood for > file upload. However, its widespread use in other contexts evidently > disproves this interpretation. So, does it have a meaning? Does it > derive from the foo in foobar? Does it stand for functional update? > Or, > is it an obscure cultural reference to Ruby's Japanese origins? Think 'Kung Fu' and you're getting there. It's a bit like The Force. Or what Robert M. Pirsig calls 'gumption'. From mark at mwilden.com Fri Jan 30 10:08:19 2009 From: mark at mwilden.com (Mark Wilden) Date: Fri, 30 Jan 2009 07:08:19 -0800 Subject: [rspec-users] OK... What is ... fu ? In-Reply-To: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> References: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> Message-ID: <3c30da400901300708m52b89e6fy8f0e59660ba355ab@mail.gmail.com> On Fri, Jan 30, 2009 at 6:49 AM, James Byrne wrote: > Pardon my ignorance, but exactly what does _fu mean WRT Ruby plugins, > gems and such? > Kung fu. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From sfeley at gmail.com Fri Jan 30 10:09:25 2009 From: sfeley at gmail.com (Stephen Eley) Date: Fri, 30 Jan 2009 10:09:25 -0500 Subject: [rspec-users] OK... What is ... fu ? In-Reply-To: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> References: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> Message-ID: <1fb4df0901300709sb103ef9ha316dafcf5d9e7d4@mail.gmail.com> On Fri, Jan 30, 2009 at 9:49 AM, James Byrne wrote: > Pardon my ignorance, but exactly what does _fu mean WRT Ruby plugins, > gems and such? >From "kung fu." It's a joke. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From nick at deadorange.com Fri Jan 30 10:10:28 2009 From: nick at deadorange.com (Nick Hoffman) Date: Fri, 30 Jan 2009 10:10:28 -0500 Subject: [rspec-users] OK... What is ... fu ? In-Reply-To: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> References: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> Message-ID: On 30/01/2009, at 9:49 AM, James Byrne wrote: > Pardon my ignorance, but exactly what does _fu mean WRT Ruby plugins, > gems and such? > > I have run across this suffix a number of times in Ruby and Rails, > always in connection with some add-on or extension. In the original > context that I encountered '_fu' I inferred that it probably stood for > file upload. However, its widespread use in other contexts evidently > disproves this interpretation. So, does it have a meaning? Does it > derive from the foo in foobar? Does it stand for functional update? > Or, > is it an obscure cultural reference to Ruby's Japanese origins? I figure it means "skill", and originates from "kung-fu". So attachment_fu would be implying "strong attachment skills". Also, I've heard people say things like "My fu is better than yours." At least, that's my interpretation... From dchelimsky at gmail.com Fri Jan 30 10:06:44 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 30 Jan 2009 09:06:44 -0600 Subject: [rspec-users] OK... What is ... fu ? In-Reply-To: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> References: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> Message-ID: <57c63afe0901300706s368870eer3bd8b5949704e78f@mail.gmail.com> On Fri, Jan 30, 2009 at 8:49 AM, James Byrne wrote: > Pardon my ignorance, but exactly what does _fu mean WRT Ruby plugins, > gems and such? > > I have run across this suffix a number of times in Ruby and Rails, > always in connection with some add-on or extension. In the original > context that I encountered '_fu' I inferred that it probably stood for > file upload. However, its widespread use in other contexts evidently > disproves this interpretation. So, does it have a meaning? Does it > derive from the foo in foobar? Does it stand for functional update? Or, > is it an obscure cultural reference to Ruby's Japanese origins? http://english.peopledaily.com.cn/200601/25/eng20060125_238295.html > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Fri Jan 30 10:14:17 2009 From: ben at benmabey.com (Ben Mabey) Date: Fri, 30 Jan 2009 08:14:17 -0700 Subject: [rspec-users] OK... What is ... fu ? In-Reply-To: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> References: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> Message-ID: <49831949.1070202@benmabey.com> James Byrne wrote: > Pardon my ignorance, but exactly what does _fu mean WRT Ruby plugins, > gems and such? > > I have run across this suffix a number of times in Ruby and Rails, > always in connection with some add-on or extension. In the original > context that I encountered '_fu' I inferred that it probably stood for > file upload. However, its widespread use in other contexts evidently > disproves this interpretation. So, does it have a meaning? Does it > derive from the foo in foobar? Does it stand for functional update? Or, > is it an obscure cultural reference to Ruby's Japanese origins? > "I have some mad kung-fu skills!" "Oh, yeah! I have some killer ruby-fu skills!" Does that help? :) -Ben From mark at mwilden.com Fri Jan 30 10:17:54 2009 From: mark at mwilden.com (Mark Wilden) Date: Fri, 30 Jan 2009 07:17:54 -0800 Subject: [rspec-users] Strange message expectation behaviour with Time.now in a find condition In-Reply-To: References: <1dcfd34b-4559-4c01-82b6-c0828f6851ca@y1g2000pra.googlegroups.com> <57c63afe0901291041x7769364eq70940bb01bd21615@mail.gmail.com> <810a540e0901291932gd8db8c5g9f043a085975720e@mail.gmail.com> Message-ID: <3c30da400901300717p4835657dg4c6c6760c1492b77@mail.gmail.com> Avdi Grimm wrote a blog post about why he doesn't stub Time.now and instead always injects a clock into his objects. I disagreed, but I can't seem to find the article now. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From hayafirst at gmail.com Fri Jan 30 10:23:45 2009 From: hayafirst at gmail.com (Yi Wen) Date: Fri, 30 Jan 2009 09:23:45 -0600 Subject: [rspec-users] OK... What is ... fu ? In-Reply-To: <57c63afe0901300706s368870eer3bd8b5949704e78f@mail.gmail.com> References: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> <57c63afe0901300706s368870eer3bd8b5949704e78f@mail.gmail.com> Message-ID: This "Fu" you refer to is actually different than "Fu" as in "Kung-Fu". The fu as in kung-fu by itself, means husband. In Ancient Chinese, it also means wise person, such as confucius(Kong Fu Zi). On Fri, Jan 30, 2009 at 9:06 AM, David Chelimsky wrote: > On Fri, Jan 30, 2009 at 8:49 AM, James Byrne wrote: > > Pardon my ignorance, but exactly what does _fu mean WRT Ruby plugins, > > gems and such? > > > > I have run across this suffix a number of times in Ruby and Rails, > > always in connection with some add-on or extension. In the original > > context that I encountered '_fu' I inferred that it probably stood for > > file upload. However, its widespread use in other contexts evidently > > disproves this interpretation. So, does it have a meaning? Does it > > derive from the foo in foobar? Does it stand for functional update? Or, > > is it an obscure cultural reference to Ruby's Japanese origins? > > http://english.peopledaily.com.cn/200601/25/eng20060125_238295.html > > > -- > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From patnakajima at gmail.com Fri Jan 30 10:31:44 2009 From: patnakajima at gmail.com (Pat Nakajima) Date: Fri, 30 Jan 2009 07:31:44 -0800 (PST) Subject: [rspec-users] OK... What is ... fu ? In-Reply-To: References: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> Message-ID: <5cdad2e7-66da-4d11-b255-79806240233d@40g2000prx.googlegroups.com> Speaking as the author of a "-fu" project, I'll say that I named acts_as_fu that way because it aids the creation of ActiveRecord extensions, which very commonly have names starting with "acts_as" or ending with "fu". This sort of meta-extension of that workflow means that you can look at it in two ways: It lets you write projects that act as "fu", or it increases your "acts_as"-fu. It's also just obnoxious. :) Pat On Jan 30, 10:10?am, Nick Hoffman wrote: > On 30/01/2009, at 9:49 AM, James Byrne wrote: > > > Pardon my ignorance, but exactly what does _fu mean WRT Ruby plugins, > > gems and such? > > > I have run across this suffix a number of times in Ruby and Rails, > > always in connection with some add-on or extension. ?In the original > > context that I encountered '_fu' I inferred that it probably stood for > > file upload. ?However, its widespread use in other contexts evidently > > disproves this interpretation. So, does it have a meaning? ?Does it > > derive from the foo in foobar? Does it stand for functional update? ? > > Or, > > is it an obscure cultural reference to Ruby's Japanese origins? > > I figure it means "skill", and originates from "kung-fu". So ? > attachment_fu would be implying "strong attachment skills". Also, I've ? > heard people say things like "My fu is better than yours." > > At least, that's my interpretation... > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Fri Jan 30 10:38:56 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 30 Jan 2009 09:38:56 -0600 Subject: [rspec-users] Strange message expectation behaviour with Time.now in a find condition In-Reply-To: <3c30da400901300717p4835657dg4c6c6760c1492b77@mail.gmail.com> References: <1dcfd34b-4559-4c01-82b6-c0828f6851ca@y1g2000pra.googlegroups.com> <57c63afe0901291041x7769364eq70940bb01bd21615@mail.gmail.com> <810a540e0901291932gd8db8c5g9f043a085975720e@mail.gmail.com> <3c30da400901300717p4835657dg4c6c6760c1492b77@mail.gmail.com> Message-ID: <57c63afe0901300738g74a1cf83pccd365d450f8f19f@mail.gmail.com> On Fri, Jan 30, 2009 at 9:17 AM, Mark Wilden wrote: > Avdi Grimm wrote a blog post about why he doesn't stub Time.now and instead > always injects a clock into his objects. I disagreed, but I can't seem to > find the article now. http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/297660 > > ///ark > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Fri Jan 30 11:01:17 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 30 Jan 2009 17:01:17 +0100 Subject: [rspec-users] OK... What is ... fu ? In-Reply-To: <3c30da400901300708m52b89e6fy8f0e59660ba355ab@mail.gmail.com> References: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> <3c30da400901300708m52b89e6fy8f0e59660ba355ab@mail.gmail.com> Message-ID: <6c02002d8076ebbfa689c38733a6de23@ruby-forum.com> Mark Wilden wrote: > On Fri, Jan 30, 2009 at 6:49 AM, James Byrne > wrote: > >> Pardon my ignorance, but exactly what does _fu mean WRT Ruby plugins, >> gems and such? >> > > Kung fu. > Ah... Thanks. I understand the reference now. My own martial arts training leans more to FN than FU so I did not make the connection. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Jan 30 11:10:10 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 30 Jan 2009 17:10:10 +0100 Subject: [rspec-users] RSpec - Testing ActiveRecord addins In-Reply-To: References: <45017.216.185.71.24.1233264276.squirrel@webmail.harte-lyne.ca> <49822850.9000902@benmabey.com> <9bfb9a52fdbe0f05bac07fb2b6e3650c@ruby-forum.com> <49827174.6040904@benmabey.com> Message-ID: <3678fd4c32e5f78368ced27b0136ee73@ruby-forum.com> Pat Nakajima wrote: > If you want an easy way to test ActiveRecord extensions, check out > acts_as_fu: http://github.com/nakajima/acts_as_fu. It makes generating > ActiveRecord models dead simple. > This seems to work very well. However, I am causing myself a problem with the logger and I could use some clarification on what is happening so that I can fix it. I created a custom logger to format the log output into syslog style. So, in environment.rb I have this: # Customize logger - 'require "syslog_formatter"' config.logger = RAILS_DEFAULT_LOGGER = Logger.new(config.log_path) config.logger.formatter = SyslogFormatter.new config.logger.level = Logger::INFO # DEBUG, WARN, ERROR, FATAL and lib/syslog_formatter.rb has this: # Configure custom logger used in all environments class SyslogFormatter def call(level, time, program, message) l_time = time.strftime("%b %d %H:%M:%S") l_process = "rails[#{$PID}]" l_host = Socket.gethostname.split('.')[0] l_user = @current_user if defined?(@current_user) l_text = (String === message ? message : message.inspect).gsub(/\n/, '').strip "#{l_time} #{l_host} #{l_process} #{l_text} #{l_user}\n" end end and when I run rake spec I see this: NameError in 'Role should create a new instance given valid attributes' undefined local variable or method `logger' for # /usr/lib64/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:471:in `method_missing' /home/byrnejb/Software/Development/Projects/proforma.git/spec/spec_helper.rb:25: Which is explicitly related to this code in spec_helper.rb: # Custom Logger config.before(:each) do full_example_description = "#{self.class.description} #{@method_name}" logger.info( "\n\n#{full_example_description}\n#{'-' * (full_example_description.length)}") end Do I just comment this out or is there something else I should do, short of disabling my own custom logger, to get this to work? -- Posted via http://www.ruby-forum.com/. From andre.x.pretorius at gmail.com Fri Jan 30 11:20:01 2009 From: andre.x.pretorius at gmail.com (AndreXP) Date: Fri, 30 Jan 2009 08:20:01 -0800 (PST) Subject: [rspec-users] [Cucumber] Passing a variable from rake to steps file Message-ID: <21746008.post@talk.nabble.com> Can anybody tell me how to pass a variable from the rake command to my steps file using cucumber? I have the following in my Rakefile: ## Rakefile Cucumber::Rake::Task.new do |t| profile = ENV['PROFILE'] || 'default' browser_type = ENV['BROWSER'] || '*chrome' t.cucumber_opts = "--profile #{profile}" end I would like to have access to the "browser_type" variable in my "Before do" in my_steps.rb file. ## my_steps.rb Before do $browser = Selenium::SeleniumDriver.new($server_host, $server_port, "browser_type", $root_url, $time_out) end Thanks for the help. -- View this message in context: http://www.nabble.com/-Cucumber--Passing-a-variable-from-rake-to-steps-file-tp21746008p21746008.html Sent from the rspec-users mailing list archive at Nabble.com. From patnakajima at gmail.com Fri Jan 30 11:31:52 2009 From: patnakajima at gmail.com (Pat Nakajima) Date: Fri, 30 Jan 2009 08:31:52 -0800 (PST) Subject: [rspec-users] RSpec - Testing ActiveRecord addins In-Reply-To: <3678fd4c32e5f78368ced27b0136ee73@ruby-forum.com> References: <45017.216.185.71.24.1233264276.squirrel@webmail.harte-lyne.ca> <49822850.9000902@benmabey.com> <9bfb9a52fdbe0f05bac07fb2b6e3650c@ruby-forum.com> <49827174.6040904@benmabey.com> <3678fd4c32e5f78368ced27b0136ee73@ruby-forum.com> Message-ID: <33bb62b8-f528-40b6-a5f2-f093bb0f1bcb@e1g2000pra.googlegroups.com> So, in acts_as_fu, I actually set the ActiveRecord logger to just log to a StringIO that you can inspect by calling ActsAsFu.log. That's not going to fly for your project though, so let me give the ability to set your own. It'll be committed soon. - Pat On Jan 30, 11:10?am, James Byrne wrote: > Pat Nakajima wrote: > > If you want an easy way to test ActiveRecord extensions, check out > > acts_as_fu:http://github.com/nakajima/acts_as_fu. It makes generating > > ActiveRecord models dead simple. > > This seems to work very well. ?However, I am causing myself a problem > with the logger and I could use some clarification on what is happening > so that I can fix it. > > I created a custom logger to format the log output into syslog style. > So, in environment.rb I have this: > > ? # Customize logger - 'require "syslog_formatter"' > ? config.logger = RAILS_DEFAULT_LOGGER = Logger.new(config.log_path) > ? config.logger.formatter = SyslogFormatter.new > ? config.logger.level ? ? = Logger::INFO # DEBUG, WARN, ERROR, FATAL > > and lib/syslog_formatter.rb has this: > > # Configure custom logger used in all environments > > class SyslogFormatter > ? def call(level, time, program, message) > ? ? l_time ? ?= time.strftime("%b %d %H:%M:%S") > ? ? l_process = "rails[#{$PID}]" > ? ? l_host ? ?= Socket.gethostname.split('.')[0] > ? ? l_user ? ?= @current_user if defined?(@current_user) > ? ? l_text ? ?= (String === message ? ?message : > message.inspect).gsub(/\n/, '').strip > ? ? "#{l_time} #{l_host} #{l_process} #{l_text} #{l_user}\n" > ? end > end > > and when I run rake spec I see this: > > NameError in 'Role should create a new instance given valid attributes' > undefined local variable or method `logger' for > # > /usr/lib64/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_p rocess.rb:471:in > `method_missing' > /home/byrnejb/Software/Development/Projects/proforma.git/spec/spec_helper.r b:25: > > Which is explicitly related to this code in spec_helper.rb: > > # Custom Logger > > ? config.before(:each) do > ? ? full_example_description = "#{self.class.description} > #{@method_name}" > ? ? logger.info( > ? ? ? "\n\n#{full_example_description}\n#{'-' * > ? ? ? ? ? (full_example_description.length)}") > ? end > > Do I just comment this out or is there something else I should do, short > of disabling my own custom logger, to get this to work? > > -- > Posted viahttp://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Fri Jan 30 11:32:40 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 30 Jan 2009 17:32:40 +0100 Subject: [rspec-users] RSpec - Testing ActiveRecord addins In-Reply-To: <3678fd4c32e5f78368ced27b0136ee73@ruby-forum.com> References: <45017.216.185.71.24.1233264276.squirrel@webmail.harte-lyne.ca> <49822850.9000902@benmabey.com> <9bfb9a52fdbe0f05bac07fb2b6e3650c@ruby-forum.com> <49827174.6040904@benmabey.com> <3678fd4c32e5f78368ced27b0136ee73@ruby-forum.com> Message-ID: James Byrne wrote: > > and when I run rake spec I see this: > > NameError in 'Role should create a new instance given valid attributes' > undefined local variable or method `logger' for > # > /usr/lib64/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:471:in > `method_missing' > /home/byrnejb/Software/Development/Projects/proforma.git/spec/spec_helper.rb:25: > > Which is explicitly related to this code in spec_helper.rb: > > # Custom Logger > > config.before(:each) do > full_example_description = "#{self.class.description} > #{@method_name}" > logger.info( > "\n\n#{full_example_description}\n#{'-' * > (full_example_description.length)}") > end > If I comment out my own custom logger in environment.rb this error remains nonetheless. I have not run spec before this in this project so I have no baseline to work from. -- Posted via http://www.ruby-forum.com/. From peter.fitzgibbons at gmail.com Fri Jan 30 11:36:51 2009 From: peter.fitzgibbons at gmail.com (Peter Fitzgibbons) Date: Fri, 30 Jan 2009 10:36:51 -0600 Subject: [rspec-users] Cucumber resource routes In-Reply-To: <57c63afe0901300626w2006f9b9n5e98fb2732b9d8e4@mail.gmail.com> References: <670a00380901300610of5b4214y946f5e2bad207c5d@mail.gmail.com> <57c63afe0901300626w2006f9b9n5e98fb2732b9d8e4@mail.gmail.com> Message-ID: <670a00380901300836q2969ce33g53e74d76b83fbe43@mail.gmail.com> See, I told you it was horribly obvious! *blush* Thanks Thomas, David. Peter Fitzgibbons (847) 687-7646 Email: peter.fitzgibbons at gmail.com IM GTalk: peter.fitzgibbons IM Yahoo: pjfitzgibbons IM MSN: pjfitzgibbons at hotmail.com IM AOL: peter.fitzgibbons at gmail.com On Fri, Jan 30, 2009 at 8:26 AM, David Chelimsky wrote: > On Fri, Jan 30, 2009 at 8:10 AM, Peter Fitzgibbons > wrote: > > Hi all, > > > > I'm missing something basic here. > > > > Inside ./features/support/paths.rb I want to use a > > ActionController::Resources helper for Products as mapped in routes.rb > > > > ./routes.rb > > map.resource :product > > > > ./features/support/paths.rb (abbreviated for clarity) > > def path_to(page_name) > > case page_name > > when /Product (\d+)/ > > project_path(:id => $1) > > else > > raise "Can't find mapping from \"#{page_name}\" to a path." > > end > > end > > > > rake features > > Given I go to Product 1 page # > > features/step_definitions/webrat_steps.rb:6 > > undefined method `project_path' for > > # (NoMethodError) > > > > So, can someone tell me the horribly obvious that I've missed? > > map.resource :product > project_path(:id => $1) > > product != project > > > > > Peter Fitzgibbons > > (847) 687-7646 > > Email: peter.fitzgibbons at gmail.com > > IM GTalk: peter.fitzgibbons > > IM Yahoo: pjfitzgibbons > > IM MSN: pjfitzgibbons at hotmail.com > > IM AOL: peter.fitzgibbons at gmail.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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From patnakajima at gmail.com Fri Jan 30 11:46:07 2009 From: patnakajima at gmail.com (Pat Nakajima) Date: Fri, 30 Jan 2009 08:46:07 -0800 (PST) Subject: [rspec-users] RSpec - Testing ActiveRecord addins In-Reply-To: <3678fd4c32e5f78368ced27b0136ee73@ruby-forum.com> References: <45017.216.185.71.24.1233264276.squirrel@webmail.harte-lyne.ca> <49822850.9000902@benmabey.com> <9bfb9a52fdbe0f05bac07fb2b6e3650c@ruby-forum.com> <49827174.6040904@benmabey.com> <3678fd4c32e5f78368ced27b0136ee73@ruby-forum.com> Message-ID: <3f6e65a6-ff4c-481a-b036-1a9c7aa5bf09@m15g2000vbp.googlegroups.com> After taking another look, I think you may be able to do something like this to test your logger: https://gist.github.com/3c55cbec990f283c5399 Let me know if that works. Pat On Jan 30, 11:10?am, James Byrne wrote: > Pat Nakajima wrote: > > If you want an easy way to test ActiveRecord extensions, check out > > acts_as_fu:http://github.com/nakajima/acts_as_fu. It makes generating > > ActiveRecord models dead simple. > > This seems to work very well. ?However, I am causing myself a problem > with the logger and I could use some clarification on what is happening > so that I can fix it. > > I created a custom logger to format the log output into syslog style. > So, in environment.rb I have this: > > ? # Customize logger - 'require "syslog_formatter"' > ? config.logger = RAILS_DEFAULT_LOGGER = Logger.new(config.log_path) > ? config.logger.formatter = SyslogFormatter.new > ? config.logger.level ? ? = Logger::INFO # DEBUG, WARN, ERROR, FATAL > > and lib/syslog_formatter.rb has this: > > # Configure custom logger used in all environments > > class SyslogFormatter > ? def call(level, time, program, message) > ? ? l_time ? ?= time.strftime("%b %d %H:%M:%S") > ? ? l_process = "rails[#{$PID}]" > ? ? l_host ? ?= Socket.gethostname.split('.')[0] > ? ? l_user ? ?= @current_user if defined?(@current_user) > ? ? l_text ? ?= (String === message ? ?message : > message.inspect).gsub(/\n/, '').strip > ? ? "#{l_time} #{l_host} #{l_process} #{l_text} #{l_user}\n" > ? end > end > > and when I run rake spec I see this: > > NameError in 'Role should create a new instance given valid attributes' > undefined local variable or method `logger' for > # > /usr/lib64/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_p rocess.rb:471:in > `method_missing' > /home/byrnejb/Software/Development/Projects/proforma.git/spec/spec_helper.r b:25: > > Which is explicitly related to this code in spec_helper.rb: > > # Custom Logger > > ? config.before(:each) do > ? ? full_example_description = "#{self.class.description} > #{@method_name}" > ? ? logger.info( > ? ? ? "\n\n#{full_example_description}\n#{'-' * > ? ? ? ? ? (full_example_description.length)}") > ? end > > Do I just comment this out or is there something else I should do, short > of disabling my own custom logger, to get this to work? > > -- > Posted viahttp://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Fri Jan 30 11:52:42 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 30 Jan 2009 17:52:42 +0100 Subject: [rspec-users] RSpec - Testing ActiveRecord addins In-Reply-To: References: <45017.216.185.71.24.1233264276.squirrel@webmail.harte-lyne.ca> <49822850.9000902@benmabey.com> <9bfb9a52fdbe0f05bac07fb2b6e3650c@ruby-forum.com> <49827174.6040904@benmabey.com> Message-ID: <1a9dc4cc6a426c536a0d6faaac8e0d11@ruby-forum.com> Pat Nakajima wrote: > If you want an easy way to test ActiveRecord extensions, check out > acts_as_fu: http://github.com/nakajima/acts_as_fu. It makes generating > ActiveRecord models dead simple. Perhaps I misunderstood what this gem is supposed to provide but when I call create! on an object produced by ActsASFu::build_model then I get a method missing error. If I call create instead then I get a private method exception. Since what I am testing is a library that links into the create method this behaviour is problematic. Other than this show stopper (for this situation) the gem seems to be quite user/tester friendly and useful. -- Posted via http://www.ruby-forum.com/. From mark at mwilden.com Fri Jan 30 12:05:42 2009 From: mark at mwilden.com (Mark Wilden) Date: Fri, 30 Jan 2009 09:05:42 -0800 Subject: [rspec-users] Strange message expectation behaviour with Time.now in a find condition In-Reply-To: <57c63afe0901300738g74a1cf83pccd365d450f8f19f@mail.gmail.com> References: <1dcfd34b-4559-4c01-82b6-c0828f6851ca@y1g2000pra.googlegroups.com> <57c63afe0901291041x7769364eq70940bb01bd21615@mail.gmail.com> <810a540e0901291932gd8db8c5g9f043a085975720e@mail.gmail.com> <3c30da400901300717p4835657dg4c6c6760c1492b77@mail.gmail.com> <57c63afe0901300738g74a1cf83pccd365d450f8f19f@mail.gmail.com> Message-ID: <3c30da400901300905p1b04304fid24bb14b105b5b7f@mail.gmail.com> On Fri, Jan 30, 2009 at 7:38 AM, David Chelimsky wrote: > On Fri, Jan 30, 2009 at 9:17 AM, Mark Wilden wrote: > > Avdi Grimm wrote a blog post about why he doesn't stub Time.now and > instead > > always injects a clock into his objects. I disagreed, but I can't seem to > > find the article now. > > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/297660 > Yeah, I saw that, but he laid out his case in greater depth in a blog post (i know because I posted a comment disagreeing with it!). The interesting thing is that Avdi says that stubbing Time.now has broken some of his tests in the past because of other code (like RSpec) that calls it. I can't say I've ever run into that myself, but it bears keeping in mind. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From patnakajima at gmail.com Fri Jan 30 12:17:35 2009 From: patnakajima at gmail.com (Pat Nakajima) Date: Fri, 30 Jan 2009 09:17:35 -0800 (PST) Subject: [rspec-users] RSpec - Testing ActiveRecord addins In-Reply-To: <1a9dc4cc6a426c536a0d6faaac8e0d11@ruby-forum.com> References: <45017.216.185.71.24.1233264276.squirrel@webmail.harte-lyne.ca> <49822850.9000902@benmabey.com> <9bfb9a52fdbe0f05bac07fb2b6e3650c@ruby-forum.com> <49827174.6040904@benmabey.com> <1a9dc4cc6a426c536a0d6faaac8e0d11@ruby-forum.com> Message-ID: <767af1f9-8d7b-4644-925d-1ab154c4bc62@v5g2000prm.googlegroups.com> James, Can you show me how you're trying to use ActsAsFu? Pat On Jan 30, 11:52?am, James Byrne wrote: > Pat Nakajima wrote: > > If you want an easy way to test ActiveRecord extensions, check out > > acts_as_fu:http://github.com/nakajima/acts_as_fu. It makes generating > > ActiveRecord models dead simple. > > Perhaps I misunderstood what this gem is supposed to provide but when I > call create! on an object produced by ActsASFu::build_model then I get a > method missing error. ?If I call create instead then I get a private > method exception. Since what I am testing is a library that links into > the create method this behaviour is problematic. > > Other than this show stopper (for this situation) the gem seems to be > quite user/tester friendly and useful. > -- > Posted viahttp://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From rick.denatale at gmail.com Fri Jan 30 13:00:26 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Fri, 30 Jan 2009 13:00:26 -0500 Subject: [rspec-users] simple == with prettier error messages + good documentation In-Reply-To: <57c63afe0901291633l719abfa3w73f4b89ea29afb36@mail.gmail.com> References: <167563.64595.qm@web31805.mail.mud.yahoo.com> <8d961d900901291102l67a1414bq1f4dbfd1951979e4@mail.gmail.com> <57c63afe0901291118h5e18acafg5cdc57994b5df9ed@mail.gmail.com> <57c63afe0901291314y205a899bj1763d7d713792a81@mail.gmail.com> <8d961d900901291327le97eed7pa9ab234cd5539fe9@mail.gmail.com> <664078.75402.qm@web31813.mail.mud.yahoo.com> <57c63afe0901291420o126515bfg5ef0077a6672820a@mail.gmail.com> <818D8494-1F09-465B-9033-EC550DACA523@mattwynne.net> <57c63afe0901291633l719abfa3w73f4b89ea29afb36@mail.gmail.com> Message-ID: On Thu, Jan 29, 2009 at 7:33 PM, David Chelimsky wrote: > > > I agree this discussion should move to a ticket. But it seems I am to > lazy > > to do it myself ;) > > http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/669 > > Nice to see you step back from the list of suggestions and nicely summarize the problem. I think that using the example docstring works well enough if you are religulous about the 1 expectation per example approach. In general I think what is wanted is to have a string to override what is reported on a failed expectation, which prompted me to make yet another suggestion http://gist.github.com/55165 -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale -------------- next part -------------- An HTML attachment was scrubbed... URL: From pergesu at gmail.com Fri Jan 30 13:00:48 2009 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 30 Jan 2009 10:00:48 -0800 Subject: [rspec-users] Strange message expectation behaviour with Time.now in a find condition In-Reply-To: <3c30da400901300905p1b04304fid24bb14b105b5b7f@mail.gmail.com> References: <1dcfd34b-4559-4c01-82b6-c0828f6851ca@y1g2000pra.googlegroups.com> <57c63afe0901291041x7769364eq70940bb01bd21615@mail.gmail.com> <810a540e0901291932gd8db8c5g9f043a085975720e@mail.gmail.com> <3c30da400901300717p4835657dg4c6c6760c1492b77@mail.gmail.com> <57c63afe0901300738g74a1cf83pccd365d450f8f19f@mail.gmail.com> <3c30da400901300905p1b04304fid24bb14b105b5b7f@mail.gmail.com> Message-ID: <810a540e0901301000t2803f96bhffa89491c6e0dbbe@mail.gmail.com> On Fri, Jan 30, 2009 at 9:05 AM, Mark Wilden wrote: > On Fri, Jan 30, 2009 at 7:38 AM, David Chelimsky > wrote: >> >> On Fri, Jan 30, 2009 at 9:17 AM, Mark Wilden wrote: >> > Avdi Grimm wrote a blog post about why he doesn't stub Time.now and >> > instead >> > always injects a clock into his objects. I disagreed, but I can't seem >> > to >> > find the article now. >> >> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/297660 > > Yeah, I saw that, but he laid out his case in greater depth in a blog post > (i know because I posted a comment disagreeing with it!). > > The interesting thing is that Avdi says that stubbing Time.now has broken > some of his tests in the past because of other code (like RSpec) that calls > it. I can't say I've ever run into that myself, but it bears keeping in > mind. I think that using a custom Clock class can be very useful. However, it can cause confusion in Rails apps, because AR uses Time.now for created_at and updated_at. You'd have to keep specific track of when you meant to use Clock and when you wanted to control Time, and to me it's just not worth it. Pat From rick.denatale at gmail.com Fri Jan 30 13:05:57 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Fri, 30 Jan 2009 13:05:57 -0500 Subject: [rspec-users] OK... What is ... fu ? In-Reply-To: <57c63afe0901300706s368870eer3bd8b5949704e78f@mail.gmail.com> References: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> <57c63afe0901300706s368870eer3bd8b5949704e78f@mail.gmail.com> Message-ID: On Fri, Jan 30, 2009 at 10:06 AM, David Chelimsky wrote: > On Fri, Jan 30, 2009 at 8:49 AM, James Byrne wrote: > > Pardon my ignorance, but exactly what does _fu mean WRT Ruby plugins, > > gems and such? > > > > I have run across this suffix a number of times in Ruby and Rails, > > always in connection with some add-on or extension. In the original > > context that I encountered '_fu' I inferred that it probably stood for > > file upload. However, its widespread use in other contexts evidently > > disproves this interpretation. So, does it have a meaning? Does it > > derive from the foo in foobar? Does it stand for functional update? Or, > > is it an obscure cultural reference to Ruby's Japanese origins? > > http://english.peopledaily.com.cn/200601/25/eng20060125_238295.html > > And of course according to the last meaning of Fu in that article*, the technical meaning of Fu is Fu is having the ability to run Windows applications on Linux or OS X. * "Fu is having wine" -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Fri Jan 30 13:09:20 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 30 Jan 2009 19:09:20 +0100 Subject: [rspec-users] RSpec - Testing ActiveRecord addins In-Reply-To: <767af1f9-8d7b-4644-925d-1ab154c4bc62@v5g2000prm.googlegroups.com> References: <45017.216.185.71.24.1233264276.squirrel@webmail.harte-lyne.ca> <49822850.9000902@benmabey.com> <9bfb9a52fdbe0f05bac07fb2b6e3650c@ruby-forum.com> <49827174.6040904@benmabey.com> <1a9dc4cc6a426c536a0d6faaac8e0d11@ruby-forum.com> <767af1f9-8d7b-4644-925d-1ab154c4bc62@v5g2000prm.googlegroups.com> Message-ID: <1f9ac04d99d789d5e286d377039b5ea8@ruby-forum.com> Pat Nakajima wrote: > James, > > Can you show me how you're trying to use ActsAsFu? > > Pat Not easily, because I removed the code. When I get a moment I will reset it and post here. It will be later today. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Jan 30 13:12:00 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 30 Jan 2009 19:12:00 +0100 Subject: [rspec-users] RSpec - Testing ActiveRecord addins In-Reply-To: <3f6e65a6-ff4c-481a-b036-1a9c7aa5bf09@m15g2000vbp.googlegroups.com> References: <45017.216.185.71.24.1233264276.squirrel@webmail.harte-lyne.ca> <49822850.9000902@benmabey.com> <9bfb9a52fdbe0f05bac07fb2b6e3650c@ruby-forum.com> <49827174.6040904@benmabey.com> <3678fd4c32e5f78368ced27b0136ee73@ruby-forum.com> <3f6e65a6-ff4c-481a-b036-1a9c7aa5bf09@m15g2000vbp.googlegroups.com> Message-ID: <17909deb32f03dca8bd4186ab90a1dd8@ruby-forum.com> Pat Nakajima wrote: > After taking another look, I think you may be able to do something > like this to test your logger: > https://gist.github.com/3c55cbec990f283c5399 I am not trying to test my custom logger. That part has worked for a few weeks now. What is happening is that RSpec is blowing up at its own logger code in the default spec_helper.rb file. This happens whether or not ActAsFu is installed and whether or not my custom logger is commented out in environment.rb -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Fri Jan 30 13:36:47 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 30 Jan 2009 12:36:47 -0600 Subject: [rspec-users] simple == with prettier error messages + good documentation In-Reply-To: References: <167563.64595.qm@web31805.mail.mud.yahoo.com> <57c63afe0901291118h5e18acafg5cdc57994b5df9ed@mail.gmail.com> <57c63afe0901291314y205a899bj1763d7d713792a81@mail.gmail.com> <8d961d900901291327le97eed7pa9ab234cd5539fe9@mail.gmail.com> <664078.75402.qm@web31813.mail.mud.yahoo.com> <57c63afe0901291420o126515bfg5ef0077a6672820a@mail.gmail.com> <818D8494-1F09-465B-9033-EC550DACA523@mattwynne.net> <57c63afe0901291633l719abfa3w73f4b89ea29afb36@mail.gmail.com> Message-ID: <57c63afe0901301036u4176b72brf62c931164f90315@mail.gmail.com> On Fri, Jan 30, 2009 at 12:00 PM, Rick DeNatale wrote: > On Thu, Jan 29, 2009 at 7:33 PM, David Chelimsky > wrote: >> >> > I agree this discussion should move to a ticket. But it seems I am to >> > lazy >> > to do it myself ;) >> >> http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/669 >> > > Nice to see you step back from the list of suggestions and nicely summarize > the problem. > > I think that using the example docstring works well enough if you are > religulous about the 1 expectation per example approach. > > In general I think what is wanted is to have a string to override what is > reported on a failed expectation, which prompted me to make yet another > suggestion > > http://gist.github.com/55165 Now that I've started a ticket, would you kindly put your response in the ticket instead? Thanks > > -- > Rick DeNatale > > Blog: http://talklikeaduck.denhaven2.com/ > Twitter: http://twitter.com/RickDeNatale > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Fri Jan 30 15:24:21 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 30 Jan 2009 21:24:21 +0100 Subject: [rspec-users] RSpec - Testing ActiveRecord addins In-Reply-To: <1f9ac04d99d789d5e286d377039b5ea8@ruby-forum.com> References: <45017.216.185.71.24.1233264276.squirrel@webmail.harte-lyne.ca> <49822850.9000902@benmabey.com> <9bfb9a52fdbe0f05bac07fb2b6e3650c@ruby-forum.com> <49827174.6040904@benmabey.com> <1a9dc4cc6a426c536a0d6faaac8e0d11@ruby-forum.com> <767af1f9-8d7b-4644-925d-1ab154c4bc62@v5g2000prm.googlegroups.com> <1f9ac04d99d789d5e286d377039b5ea8@ruby-forum.com> Message-ID: <92d56ab349e76076ba9f0b9040f4d04f@ruby-forum.com> James Byrne wrote: > Pat Nakajima wrote: >> James, >> >> Can you show me how you're trying to use ActsAsFu? >> >> Pat > > Not easily, because I removed the code. When I get a moment I will > reset it and post here. It will be later today. Here is what I have. FYI once I removed the custom logger from spec_helper.rb everything worked just fine thereafter. # hll_audit_stamps_spec.rb require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "Builds a Model with custom magic columns" do before(:all) do build_model :magiks do string :description # these are Rails' own magic columns datetime :created_at datetime :created_on datetime :updated_at datetime :updated_on # these are our custom magic columns ActiveRecord::Base::HLL_AUDIT_COLUMNS.each do |magic_column| string magic_column if /.*_by\z/.match(magic_column) datetime magic_column if /.*_(at|on)\z/.match(magic_column) end end @my_mage = Magik.new @my_mage.save! end # control - make sure the default behaviour is preserved it "should set Rails created_at" do @my_mage.created_at.should_not be_nil puts @my_mage.created_at end it "should set Rails created_on" do @my_mage.created_on.should_not be_nil puts @my_mage.created_on end ... -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Jan 30 15:45:13 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 30 Jan 2009 21:45:13 +0100 Subject: [rspec-users] RSpec get model attribute values by name Message-ID: This is a request for a programming technique: Given class Mymodel < ActiveRecord::Base end my_instance = Mymodel.new If I am given a string representation of an attribute "xxx" what is the most elegant way of passing that string to my_instance to retrieve its value? This is probably a common idiom, given what Rails does, but I cannot seem to find its code in the rails gem at the moment. So, if anyone knows hoe to do this off the cuff I would appreciate it. An example of the intended use of this is def table_compare(table1, table2, array_of_attributes) do |t1, t2, aon| tint = t1.column_names & t2.column_names tfin = tint & aon tfin.each do |column| return false if t1.column <> t2.column end return tfin #could be nil end I want to convert the string value of the column variable into the attribute name to obtain the value of that attribute. -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Fri Jan 30 16:07:47 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Fri, 30 Jan 2009 16:07:47 -0500 Subject: [rspec-users] RSpec get model attribute values by name In-Reply-To: References: Message-ID: <85d99afe0901301307h66132789k755a6a735e5b376b@mail.gmail.com> On Fri, Jan 30, 2009 at 3:45 PM, James Byrne wrote: > This is a request for a programming technique: > > Given > > class Mymodel < ActiveRecord::Base > end > > my_instance = Mymodel.new > > If I am given a string representation of an attribute "xxx" what is the > most elegant way of passing that string to my_instance to retrieve its > value? This is probably a common idiom, given what Rails does, but I > cannot seem to find its code in the rails gem at the moment. > > So, if anyone knows hoe to do this off the cuff I would appreciate it. > An example of the intended use of this is > > def table_compare(table1, table2, array_of_attributes) do |t1, t2, > aon| > tint = t1.column_names & t2.column_names > tfin = tint & aon > tfin.each do |column| > return false if t1.column <> t2.column > end > return tfin #could be nil > end > > I want to convert the string value of the column variable into the > attribute name to obtain the value of that attribute. I'm assuming you want to treat your model instance like a hash: m = MyModel.new :name => "foo" m["name"] # => "foo" http://www.railsbrain.com/api/rails-2.2.2/doc/index.html?a=M001972&name=[] On a different note, how about some better variable names? -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From patnakajima at gmail.com Fri Jan 30 16:20:06 2009 From: patnakajima at gmail.com (Pat Nakajima) Date: Fri, 30 Jan 2009 13:20:06 -0800 (PST) Subject: [rspec-users] RSpec - Testing ActiveRecord addins In-Reply-To: <92d56ab349e76076ba9f0b9040f4d04f@ruby-forum.com> References: <45017.216.185.71.24.1233264276.squirrel@webmail.harte-lyne.ca> <49822850.9000902@benmabey.com> <9bfb9a52fdbe0f05bac07fb2b6e3650c@ruby-forum.com> <49827174.6040904@benmabey.com> <1a9dc4cc6a426c536a0d6faaac8e0d11@ruby-forum.com> <767af1f9-8d7b-4644-925d-1ab154c4bc62@v5g2000prm.googlegroups.com> <1f9ac04d99d789d5e286d377039b5ea8@ruby-forum.com> <92d56ab349e76076ba9f0b9040f4d04f@ruby-forum.com> Message-ID: Glad it works. Just so you know, you can get created_at and updated_at by calling #timestamps: require 'rubygems' require 'acts_as_fu' require 'spec' describe "timestamps" do before(:each) do build_model(:people) { timestamps } @person = Person.create! end it "adds created_at" do @person.created_at.should_not be_nil end it "adds updated_at" do @person.updated_at.should_not be_nil end end Pat On Jan 30, 3:24?pm, James Byrne wrote: > James Byrne wrote: > > Pat Nakajima wrote: > >> James, > > >> Can you show me how you're trying to use ActsAsFu? > > >> Pat > > > Not easily, because I removed the code. ?When I get a moment I will > > reset it and post here. ?It will be later today. > > Here is what I have. ?FYI once I removed the custom logger from > spec_helper.rb everything worked just fine thereafter. > > # hll_audit_stamps_spec.rb > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > > describe "Builds a Model with custom magic columns" do > ? before(:all) do > ? ? build_model ? :magiks do > ? ? ? string ? ?:description > ? ? # these are Rails' own magic columns > ? ? ? datetime ?:created_at > ? ? ? datetime ?:created_on > ? ? ? datetime ?:updated_at > ? ? ? datetime ?:updated_on > ? ? # these are our custom magic columns > ? ? ? ActiveRecord::Base::HLL_AUDIT_COLUMNS.each do |magic_column| > ? ? ? ? string ? ?magic_column ?if /.*_by\z/.match(magic_column) > ? ? ? ? datetime ?magic_column ?if /.*_(at|on)\z/.match(magic_column) > ? ? ? end > ? ? end > ? ? @my_mage = Magik.new > ? ? @my_mage.save! > ? end > > # control - make sure the default behaviour is preserved > ? it "should set Rails created_at" do > ? ? @my_mage.created_at.should_not be_nil > ? ? puts @my_mage.created_at > ? end > > ? it "should set Rails created_on" do > ? ? @my_mage.created_on.should_not be_nil > ? ? puts @my_mage.created_on > ? end > ... > -- > Posted viahttp://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Fri Jan 30 16:30:05 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 30 Jan 2009 22:30:05 +0100 Subject: [rspec-users] RSpec get model attribute values by name In-Reply-To: References: Message-ID: <0bc249643f94a106f08c0ea0f5ea93e2@ruby-forum.com> James Byrne wrote: > This is a request for a programming technique: Got it... t1.read_attribute(column) -- Posted via http://www.ruby-forum.com/. From rick.denatale at gmail.com Fri Jan 30 16:57:30 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Fri, 30 Jan 2009 16:57:30 -0500 Subject: [rspec-users] simple == with prettier error messages + good documentation In-Reply-To: <57c63afe0901301036u4176b72brf62c931164f90315@mail.gmail.com> References: <167563.64595.qm@web31805.mail.mud.yahoo.com> <57c63afe0901291314y205a899bj1763d7d713792a81@mail.gmail.com> <8d961d900901291327le97eed7pa9ab234cd5539fe9@mail.gmail.com> <664078.75402.qm@web31813.mail.mud.yahoo.com> <57c63afe0901291420o126515bfg5ef0077a6672820a@mail.gmail.com> <818D8494-1F09-465B-9033-EC550DACA523@mattwynne.net> <57c63afe0901291633l719abfa3w73f4b89ea29afb36@mail.gmail.com> <57c63afe0901301036u4176b72brf62c931164f90315@mail.gmail.com> Message-ID: On Fri, Jan 30, 2009 at 1:36 PM, David Chelimsky wrote: > On Fri, Jan 30, 2009 at 12:00 PM, Rick DeNatale > wrote: > > On Thu, Jan 29, 2009 at 7:33 PM, David Chelimsky > > wrote: > >> > >> > I agree this discussion should move to a ticket. But it seems I am to > >> > lazy > >> > to do it myself ;) > >> > >> http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/669 > >> > > > > Nice to see you step back from the list of suggestions and nicely > summarize > > the problem. > > > > I think that using the example docstring works well enough if you are > > religulous about the 1 expectation per example approach. > > > > In general I think what is wanted is to have a string to override what is > > reported on a failed expectation, which prompted me to make yet another > > suggestion > > > > http://gist.github.com/55165 > > Now that I've started a ticket, would you kindly put your response in > the ticket instead? > > Thanks Done -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Fri Jan 30 18:56:30 2009 From: lists at ruby-forum.com (James Byrne) Date: Sat, 31 Jan 2009 00:56:30 +0100 Subject: [rspec-users] RSpec get model attribute values by name In-Reply-To: <85d99afe0901301307h66132789k755a6a735e5b376b@mail.gmail.com> References: <85d99afe0901301307h66132789k755a6a735e5b376b@mail.gmail.com> Message-ID: <9f74f1f67189119503b1b611773c71da@ruby-forum.com> Zach Dennis wrote: > > m = MyModel.new :name => "foo" > m["name"] # => "foo" > > http://www.railsbrain.com/api/rails-2.2.2/doc/index.html?a=M001972&name=[] > > On a different note, how about some better variable names? That code was for demonstration purposes for this question only. -- Posted via http://www.ruby-forum.com/. From jonathan at parkerhill.com Fri Jan 30 21:45:19 2009 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Fri, 30 Jan 2009 21:45:19 -0500 Subject: [rspec-users] nokogiri selector help In-Reply-To: <85d99afe0901250858we266949l2473e4da56b8d1ed@mail.gmail.com> References: <51054F01-B154-4D21-9B11-96AEF17F7B15@parkerhill.com> <85d99afe0901250858we266949l2473e4da56b8d1ed@mail.gmail.com> Message-ID: On Jan 25, 2009, at 11:58 AM, Zach Dennis wrote: > On Sat, Jan 24, 2009 at 12:05 AM, Jonathan Linowes > wrote: >> hiya, >> >> i want the selector that would return a of a table if any td >> contains >> some text, so i can use it in click_link_within >> >> e.g. When I click the "show" link within the row containing >> "user at example.com" >> >> >> When /^I click the "(.+)" link within the row containing "(.+)"$/ >> do |link, >> text| >> selector = ?? >> click_link_within selector, link >> end > > You can use an XPath selector to find the parent. Try: > > selector = "//table//tr//td[contains(.,'user at example.com')]//.." hi Zach, that works as a selector when I do doc = Nokogiri::HTML.parse( response.body ) doc.xpath(selector) returns the correct dom elements but when used with click_link_within I get the error Nokogiri::CSS::SyntaxError Exception: unexpected '//' after '' From pergesu at gmail.com Fri Jan 30 22:00:09 2009 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 30 Jan 2009 19:00:09 -0800 Subject: [rspec-users] RSpec get model attribute values by name In-Reply-To: <9f74f1f67189119503b1b611773c71da@ruby-forum.com> References: <85d99afe0901301307h66132789k755a6a735e5b376b@mail.gmail.com> <9f74f1f67189119503b1b611773c71da@ruby-forum.com> Message-ID: <810a540e0901301900h6b40b6f8hc7adda5c300ba1c4@mail.gmail.com> On Fri, Jan 30, 2009 at 3:56 PM, James Byrne wrote: > Zach Dennis wrote: > >> >> m = MyModel.new :name => "foo" >> m["name"] # => "foo" >> >> http://www.railsbrain.com/api/rails-2.2.2/doc/index.html?a=M001972&name=[] >> >> On a different note, how about some better variable names? > > That code was for demonstration purposes for this question only. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > a = "name" As Zach pointed out, you can access AR instance attributes like a hash: my_instance[a] = "foobar" my_instance[a.to_sym] # => "foobar" the reason you can use either a symbol or a string is because the hash access is done with a HashWithIndifferentAccess. A couple other things you can do... my_instance.send(a) # => "foobar" It's important to view method calls as sending messages to objects in Ruby... send is a method you can use to send a message to an object, where the method name is known only at runtime. eval "my_instance.#{a}" and then of course you can eval strings...so if you have a var containing the name, you can interpolate it into another string and eval that. I realize you didn't ask for all of that but I'm feeling a bit chatty. Pat From biot023 at gmail.com Fri Jan 30 23:27:35 2009 From: biot023 at gmail.com (doug livesey) Date: Sat, 31 Jan 2009 04:27:35 +0000 Subject: [rspec-users] OK... What is ... fu ? In-Reply-To: References: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> <57c63afe0901300706s368870eer3bd8b5949704e78f@mail.gmail.com> Message-ID: <50873a360901302027v1b92bec9u8bfc3f8d655b84fe@mail.gmail.com> And of course the pinnacle of geekdom is to be known as a 'poodle', or one who is skilled in being skilled; a fu-fu.Damn', I appear to be posting drunk again ... 2009/1/30 Rick DeNatale > > > On Fri, Jan 30, 2009 at 10:06 AM, David Chelimsky wrote: > >> On Fri, Jan 30, 2009 at 8:49 AM, James Byrne >> wrote: >> > Pardon my ignorance, but exactly what does _fu mean WRT Ruby plugins, >> > gems and such? >> > >> > I have run across this suffix a number of times in Ruby and Rails, >> > always in connection with some add-on or extension. In the original >> > context that I encountered '_fu' I inferred that it probably stood for >> > file upload. However, its widespread use in other contexts evidently >> > disproves this interpretation. So, does it have a meaning? Does it >> > derive from the foo in foobar? Does it stand for functional update? Or, >> > is it an obscure cultural reference to Ruby's Japanese origins? >> >> http://english.peopledaily.com.cn/200601/25/eng20060125_238295.html >> >> > And of course according to the last meaning of Fu in that article*, the > technical meaning of Fu is > > Fu is having the ability to run Windows applications on Linux or OS X. > > > > * "Fu is having wine" > > -- > Rick DeNatale > > Blog: http://talklikeaduck.denhaven2.com/ > Twitter: http://twitter.com/RickDeNatale > > _______________________________________________ > 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 jonathan at parkerhill.com Sat Jan 31 08:13:03 2009 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Sat, 31 Jan 2009 08:13:03 -0500 Subject: [rspec-users] OK... What is ... fu ? In-Reply-To: <50873a360901302027v1b92bec9u8bfc3f8d655b84fe@mail.gmail.com> References: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> <57c63afe0901300706s368870eer3bd8b5949704e78f@mail.gmail.com> <50873a360901302027v1b92bec9u8bfc3f8d655b84fe@mail.gmail.com> Message-ID: <434F26D2-278C-4365-8FC7-19364B3E32AC@parkerhill.com> And of course, when spelled out, F-U, has a whole different meaning... On Jan 30, 2009, at 11:27 PM, doug livesey wrote: > And of course the pinnacle of geekdom is to be known as a 'poodle', > or one who is skilled in being skilled; a fu-fu. > Damn', I appear to be posting drunk again ... > > 2009/1/30 Rick DeNatale > > > On Fri, Jan 30, 2009 at 10:06 AM, David Chelimsky > wrote: > On Fri, Jan 30, 2009 at 8:49 AM, James Byrne > wrote: > > Pardon my ignorance, but exactly what does _fu mean WRT Ruby > plugins, > > gems and such? > > > > I have run across this suffix a number of times in Ruby and Rails, > > always in connection with some add-on or extension. In the original > > context that I encountered '_fu' I inferred that it probably > stood for > > file upload. However, its widespread use in other contexts > evidently > > disproves this interpretation. So, does it have a meaning? Does it > > derive from the foo in foobar? Does it stand for functional > update? Or, > > is it an obscure cultural reference to Ruby's Japanese origins? > > http://english.peopledaily.com.cn/200601/25/eng20060125_238295.html > > > And of course according to the last meaning of Fu in that article*, > the technical meaning of Fu is > > Fu is having the ability to run Windows applications on Linux or > OS X. > > > * "Fu is having wine" > > -- > Rick DeNatale > > Blog: http://talklikeaduck.denhaven2.com/ > Twitter: http://twitter.com/RickDeNatale > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Sat Jan 31 09:18:09 2009 From: lists at ruby-forum.com (James Byrne) Date: Sat, 31 Jan 2009 15:18:09 +0100 Subject: [rspec-users] RSpec get model attribute values by name In-Reply-To: <810a540e0901301900h6b40b6f8hc7adda5c300ba1c4@mail.gmail.com> References: <85d99afe0901301307h66132789k755a6a735e5b376b@mail.gmail.com> <9f74f1f67189119503b1b611773c71da@ruby-forum.com> <810a540e0901301900h6b40b6f8hc7adda5c300ba1c4@mail.gmail.com> Message-ID: <11aa9b92fe7c0be583fbaeca9cc5ca60@ruby-forum.com> Pat Maddox wrote: > I realize you didn't ask for all of that but I'm feeling a bit chatty. > > Pat The more information the better. I never really did understand exactly what using eval() was supposed to accomplish, now I do. Chat away... I do want to point out that this is what the ActiveRecord::Base api has to say about the [] method: [](attr_name) Returns the value of the attribute identified by attr_name after it has been typecast (for example, "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)). (Alias for the protected read_attribute method). Notice anything wrong about the api call description? Should not this say: [attr_name] Returns the value of the attribute identified by attr_name... The reason that I raised this question to begin with was because I could not get "model_instance[](attr_name)" to work. Which is what the api is telling me to do the way that it is written. I came up with the alternative, write_attribute(attr_name), by looking at the code for []. -- Posted via http://www.ruby-forum.com/. From mark at mwilden.com Sat Jan 31 10:38:01 2009 From: mark at mwilden.com (Mark Wilden) Date: Sat, 31 Jan 2009 07:38:01 -0800 Subject: [rspec-users] OK... What is ... fu ? In-Reply-To: <434F26D2-278C-4365-8FC7-19364B3E32AC@parkerhill.com> References: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> <57c63afe0901300706s368870eer3bd8b5949704e78f@mail.gmail.com> <50873a360901302027v1b92bec9u8bfc3f8d655b84fe@mail.gmail.com> <434F26D2-278C-4365-8FC7-19364B3E32AC@parkerhill.com> Message-ID: <3c30da400901310738qe7f6d61k1a3ecb847c537d57@mail.gmail.com> On Sat, Jan 31, 2009 at 5:13 AM, Jonathan Linowes wrote: > And of course, when spelled out, F-U, has a whole different meaning... > We just had a presentation by the developers of a Mongrel replacement called Fuzed. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From pergesu at gmail.com Sat Jan 31 11:37:08 2009 From: pergesu at gmail.com (Pat Maddox) Date: Sat, 31 Jan 2009 08:37:08 -0800 Subject: [rspec-users] RSpec get model attribute values by name In-Reply-To: <11aa9b92fe7c0be583fbaeca9cc5ca60@ruby-forum.com> References: <85d99afe0901301307h66132789k755a6a735e5b376b@mail.gmail.com> <9f74f1f67189119503b1b611773c71da@ruby-forum.com> <810a540e0901301900h6b40b6f8hc7adda5c300ba1c4@mail.gmail.com> <11aa9b92fe7c0be583fbaeca9cc5ca60@ruby-forum.com> Message-ID: <810a540e0901310837w62756d15x9311caefe7ed7d99@mail.gmail.com> On Sat, Jan 31, 2009 at 6:18 AM, James Byrne wrote: > Pat Maddox wrote: > >> I realize you didn't ask for all of that but I'm feeling a bit chatty. >> >> Pat > > The more information the better. I never really did understand exactly > what using eval() was supposed to accomplish, now I do. Chat away... > > I do want to point out that this is what the ActiveRecord::Base api has > to say about the [] method: > > [](attr_name) > > Returns the value of the attribute identified by attr_name after it has > been typecast (for example, "2004-12-12" in a data column is cast to a > date object, like Date.new(2004, 12, 12)). (Alias for the protected > read_attribute method). > > Notice anything wrong about the api call description? Should not this > say: > > [attr_name] Not quite... You must be looking at the rdoc. RDoc looks at the method definition, and then includes any comments above it. Method definitions in ruby are of the form method_name(param1, param2, *other_params, &block) and [] is just a method call. You can define it on your own objects with def [](element) .... end Note that you can do {:foo => "abc", :bar => "123"}.send :[], :foo I just looked at the RDoc, and yeah you're right that it shows it of the form [](attr_name). That's because RDoc just sticks in the method as it's defined. You would need to know that this is a special case in Ruby where you really call it like blah[:foo] Pat From pergesu at gmail.com Sat Jan 31 11:41:20 2009 From: pergesu at gmail.com (Pat Maddox) Date: Sat, 31 Jan 2009 08:41:20 -0800 Subject: [rspec-users] OK... What is ... fu ? In-Reply-To: <3c30da400901310738qe7f6d61k1a3ecb847c537d57@mail.gmail.com> References: <18334368f4c08b56744c1545be705e9c@ruby-forum.com> <57c63afe0901300706s368870eer3bd8b5949704e78f@mail.gmail.com> <50873a360901302027v1b92bec9u8bfc3f8d655b84fe@mail.gmail.com> <434F26D2-278C-4365-8FC7-19364B3E32AC@parkerhill.com> <3c30da400901310738qe7f6d61k1a3ecb847c537d57@mail.gmail.com> Message-ID: <810a540e0901310841t7603795dh221a8dff534304e5@mail.gmail.com> On Sat, Jan 31, 2009 at 7:38 AM, Mark Wilden wrote: > On Sat, Jan 31, 2009 at 5:13 AM, Jonathan Linowes > wrote: >> >> And of course, when spelled out, F-U, has a whole different meaning... > > We just had a presentation by the developers of a Mongrel replacement called > Fuzed. Which, if you remember "Rails is a Ghetto," Zed did NOT like. Pat From r_j_h_box-sf at yahoo.com Sat Jan 31 13:02:57 2009 From: r_j_h_box-sf at yahoo.com (r_j_h_box-sf at yahoo.com) Date: Sat, 31 Jan 2009 10:02:57 -0800 (PST) Subject: [rspec-users] simple == with prettier error messages + good documentation References: <167563.64595.qm@web31805.mail.mud.yahoo.com> <57c63afe0901291025i1b1a18dah17b76a4650af60d1@mail.gmail.com> <8d961d900901291102l67a1414bq1f4dbfd1951979e4@mail.gmail.com> <57c63afe0901291118h5e18acafg5cdc57994b5df9ed@mail.gmail.com> <57c63afe0901291314y205a899bj1763d7d713792a81@mail.gmail.com> <8d961d900901291327le97eed7pa9ab234cd5539fe9@mail.gmail.com> <664078.75402.qm@web31813.mail.mud.yahoo.com> <57c63afe0901291420o126515bfg5ef0077a6672820a@mail.gmail.com> Message-ID: <338510.91289.qm@web31802.mail.mud.yahoo.com> Passing the it() and describe() args through to the reporting layer sounds like a great idea. I've thought more about the reporting-levels approach. The numeric as I postulated earlier is probably not the most useful thing. As a product manager, I want to be able to flexibly present the appropriate documentation to different audiences, to avoid the need for maintaining multiple docs. describe "an example group", :audience => :execs describe "an example group", :audience => :owner describe "an example group", :audience => :users describe "an example group", :audience => :developers These could be entirely ad-hoc, allowing the developer to select the desired labels for the situation at hand. When generating reports, you'd state which audiences to generate docs for (maybe with a default set coded into a helper?). When generating reports to text, any examples or groups that were skipped would be simply tabulated, and the summary would be displayed at the bottom: Skipped 7 example groups and 27 examples for Users. Skipped 3 example groups and 12 examples for Developers. And when generating reports to HTML, any docs for not-specified roles could simply be folded/hidden by default, allowing the viewer to drill down. Of course, this could be skipped by setting an option for static HTML purposes, and the skipped items could be reported in the same way as the text version. Does this seem like a useful way to treat the various detail levels of documentation we want to present to different audiences? Randy ________________________________ From: David Chelimsky Randy: > http://gist.github.com/54764 > > Then when generating spec docs, you could vary the detail level on what's > generated, to generate only up to level-2 documentation, or to generate > full-detail documentation if you prefer. > > Nested it()s could do the same thing, I suppose. Not sure what side effects > would come into play. Pretty clearly, a nested it() wouldn't have an > embedded transaction or respect the outer before() block, since the outer > if() would handle both those things. For a number of technical reasons, the nested code example (it()) is a non-starter. The idea of having some means of flagging examples so they report differently is possible. Right now, example groups and examples each take a hash in their declarations: describe "an example group", :with => "some, :args => "like this" do it "an example", :with => "some", :other => "args" ... end end Those are accessible to the runner, and are used internally for assorted filtering. As of this moment, they don't make it past the reporters, because the object that goes to formatters is a wrapper w/ limited information instead of the real example. We could add the options to that wrapper though, and then you'd be able to write a custom formatter that would do anything you like based on the configuration of those options. WDYT about that? -------------- next part -------------- An HTML attachment was scrubbed... URL: From r_j_h_box-sf at yahoo.com Sat Jan 31 19:06:39 2009 From: r_j_h_box-sf at yahoo.com (r_j_h_box-sf at yahoo.com) Date: Sat, 31 Jan 2009 16:06:39 -0800 (PST) Subject: [rspec-users] resource urls only work *after* a get() in controller spec Message-ID: <960691.61104.qm@web31811.mail.mud.yahoo.com> I'm encountering an interesting symptom during example execution. I'm making a shared example group that dries up belongs-to-me before_filter testing, and it makes a callback to the example group that says it_should_behave_like that. The callback tells the shared example where to expect a redirect for failure. It seems that prior to executing a get() (etc), the resource-based url functions aren't accessible. Following the get(), topics_url works fine. But before then, it gives an error like this: http://pastie.org/376096 Is this a known issue? Is there a workaround I can use? I haven't stepped through get() to see what its doing that brings in the resource functions, but if it's not well-known, I can do so and followup with the answer. Thanks in advance, Randy From ben at benmabey.com Sat Jan 31 20:41:56 2009 From: ben at benmabey.com (Ben Mabey) Date: Sat, 31 Jan 2009 18:41:56 -0700 Subject: [rspec-users] resource urls only work *after* a get() in controller spec In-Reply-To: <960691.61104.qm@web31811.mail.mud.yahoo.com> References: <960691.61104.qm@web31811.mail.mud.yahoo.com> Message-ID: <4984FDE4.4000903@benmabey.com> r_j_h_box-sf at yahoo.com wrote: > I'm encountering an interesting symptom during example execution. I'm > making a shared example group that dries up belongs-to-me before_filter > testing, and it makes a callback to the example group that says > it_should_behave_like that. The callback tells the shared example > where to expect a redirect for failure. > > It seems that prior to > executing a get() (etc), the resource-based url functions aren't > accessible. Following the get(), topics_url works fine. But before > then, it gives an error like this: > > http://pastie.org/376096 > > Is > this a known issue? Is there a workaround I can use? > For a workaround try doing a "include ActionController::UrlWriter" in your shared example group. -Ben From andre.x.pretorius at gmail.com Fri Jan 30 07:06:36 2009 From: andre.x.pretorius at gmail.com (AndreXP) Date: Fri, 30 Jan 2009 04:06:36 -0800 (PST) Subject: [rspec-users] Pass a variable from rake to steps file in cucumber Message-ID: <21746008.post@talk.nabble.com> Can anybody tell me how to pass a variable from the rake command to my steps file using cucumber? I have the following in my Rakefile: ## Rakefile Cucumber::Rake::Task.new do |t| profile = ENV['PROFILE'] || 'default' browser_type = ENV['BROWSER'] || '*chrome' t.cucumber_opts = "--profile #{profile}" end I would like to have access to the "browser_type" variable in my "Before do" in my_steps.rb file. ## my_steps.rb Before do $browser = Selenium::SeleniumDriver.new($server_host, $server_port, "browser_type", $root_url, $time_out) end Thanks for the help. -- View this message in context: http://www.nabble.com/Pass-a-variable-from-rake-to-steps-file-in-cucumber-tp21746008p21746008.html Sent from the rspec-users mailing list archive at Nabble.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From andre.x.pretorius at gmail.com Fri Jan 30 07:26:20 2009 From: andre.x.pretorius at gmail.com (AndreXP) Date: Fri, 30 Jan 2009 04:26:20 -0800 (PST) Subject: [rspec-users] Pass a variable from rake to steps file in cucumber Message-ID: <21746008.post@talk.nabble.com> Can anybody tell me how to pass a variable from the rake command to my steps file using cucumber? I have the following in my Rakefile: ## Rakefile Cucumber::Rake::Task.new do |t| profile = ENV['PROFILE'] || 'default' browser_type = ENV['BROWSER'] || '*chrome' t.cucumber_opts = "--profile #{profile}" end I would like to have access to the "browser_type" variable in my "Before do" in my_steps.rb file. ## my_steps.rb Before do $browser = Selenium::SeleniumDriver.new($server_host, $server_port, "browser_type", $root_url, $time_out) end Thanks for the help. -- View this message in context: http://www.nabble.com/Pass-a-variable-from-rake-to-steps-file-in-cucumber-tp21746008p21746008.html Sent from the rspec-users mailing list archive at Nabble.com. From jschank at mac.com Sat Jan 31 01:45:56 2009 From: jschank at mac.com (jschank) Date: Fri, 30 Jan 2009 22:45:56 -0800 (PST) Subject: [rspec-users] Problem with refresh_specs Message-ID: Hello, I recently unpacked the latest (1.1.12) rspec and rspec rails in my applicaiton. When I run my specs I get: config.gem: Unpacked gem rspec-1.1.12 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this. config.gem: Unpacked gem rspec-rails-1.1.12 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this. However, when I do what it says, I get this: [jschank at serenity shindg (maps)]$ rake gems:refresh_specs (in /Users/jschank/Projects/Rails/shindg) config.gem: Unpacked gem rspec-1.1.12 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this. config.gem: Unpacked gem rspec-rails-1.1.12 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this. rake aborted! superclass mismatch for class ModelExampleGroup A google search isn't helping me. What can I do to make this warning go away? besides piping it to dev/null Thanks, John Schank From melvin at volcanicmarketing.com Tue Jan 27 21:04:43 2009 From: melvin at volcanicmarketing.com (melvin ram) Date: Tue, 27 Jan 2009 18:04:43 -0800 (PST) Subject: [rspec-users] Rspec fails Message-ID: <08834094-2815-40d5-a37f-1b432521cde8@x16g2000prn.googlegroups.com> >From this code http://pastie.org/372777 I'm getting these errors http://pastie.org/372702 and it's not making any sense... and it's got me a little stuck. Some help pls? From rjharmon0316 at yahoo.com Sat Jan 31 13:41:26 2009 From: rjharmon0316 at yahoo.com (Randy Harmon) Date: Sat, 31 Jan 2009 10:41:26 -0800 (PST) Subject: [rspec-users] (no subject) Message-ID: <374020.38887.qm@web31811.mail.mud.yahoo.com> I'm encountering an interesting symptom during example execution. I'm making a shared example group that dries up belongs-to-me before_filter testing, and it makes a callback to the example group that says it_should_behave_like that. The callback tells the shared example where to expect a redirect for failure. It seems that prior to executing a get() (etc), the resource-based url functions aren't accessible. Following the get(), topics_url works fine. But before then, it gives an error like this: http://pastie.org/376096 Is this a known issue? Is there a workaround I can use? I haven't stepped through get() to see what its doing that brings in the resource functions, but if it's not well-known, I can do so and followup with the answer. Thanks in advance, Randy From robby at planetargon.com Thu Jan 29 10:59:00 2009 From: robby at planetargon.com (Robby Russell) Date: Thu, 29 Jan 2009 07:59:00 -0800 Subject: [rspec-users] [Rails] [ANN] The RSpec Book is now in beta In-Reply-To: <68A01C2A-2808-493D-B212-C16617AFB9A6@gmail.com> References: <68A01C2A-2808-493D-B212-C16617AFB9A6@gmail.com> Message-ID: ...and the crowd roars! On Thu, Jan 29, 2009 at 7:36 AM, David Chelimsky wrote: > > I'm pleased to announce the beta release of the Pragmatic Bookshelf's > The RSpec Book: Behaviour Driven Development with RSpec, Cucumber and > Friends! > > It's been a long time coming, and there's still a lot of work to do to > get to print. The beta release has 9 of the 22 chapters we have > planned. Most of what remains is almost done, but not quite ready to > release yet. As with all of the Pragmatic beta books, we'll do regular > updates every few weeks as we wrap up the remaining chapters and > incorporate your feedback. And please do provide feedback. We want > this book to serve you well! > > There are six authors involved: Dave Astels, Zach Dennis, Aslak > Hellesoy, Bryan Helmkamp, Dan North, and me. I'm honored to be in such > good company here, with the guys who brought us BDD, to the developers > and maintainers of RSpec, Cucumber and Webrat. > > You can read more (and buy the book!) at http://www.pragprog.com/titles/achbd/the-rspec-book > > On behalf of all the authors, I'd like to extend a special thank you > to all of you who have contributed to the software and the > conversation around RSpec, Cucumber, and BDD in general. RSpec would > be nothing without the community that has evolved around it, so thank > you, thank you, thank you. > > Again, THANK YOU! > David Chelimsky > > > --~--~---------~--~----~------------~-------~--~----~ > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk at googlegroups.com > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe at googlegroups.com > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en > -~----------~----~----~----~------~----~------~--~--- > > -- Robby Russell Chief Evangelist, Partner PLANET ARGON, LLC design // development // hosting w/Ruby on Rails http://www.planetargon.com/ http://www.robbyonrails.com/ aim: planetargon +1 503 445 2457 +1 877 55 ARGON [toll free] +1 815 642 4068 [fax]