From bastien.vaucher at gmail.com Fri Aug 1 04:41:08 2008 From: bastien.vaucher at gmail.com (Bastien) Date: Fri, 1 Aug 2008 01:41:08 -0700 (PDT) Subject: [rspec-users] Can't access actions of a singular nested resource In-Reply-To: <8d961d900807310821h1a1a7d6at281434f486e34432@mail.gmail.com> References: <8e78802d-707e-4782-a69c-e5cbf4a92692@m36g2000hse.googlegroups.com> <8d961d900807310821h1a1a7d6at281434f486e34432@mail.gmail.com> Message-ID: <70d5b216-3511-47fb-ba74-d53001f37235@m36g2000hse.googlegroups.com> Thanks for your help Aslak, but I still didn't manage to make it pass >> get :show, :id=>"34" it sends me this error then : No route matches {:action=>"show", :controller=>"surveys/report", :id=>"34"} >> Try rake routes, and also try to spec the routing in the associated >> routing_spec.rb. and this test passes : it "should map { :controller => 'report', :action => 'show', :survey_id => 1} to /survey/1/report" do route_for(:controller => "surveys/report", :action => "show", :survey_id => 1).should == "/surveys/1/report" end also if I try to remove my condition the test passes so the routes must be correct it "should return the survey corresponding to the report" do #Survey.should_receive(:find) get :show, :survey_id=>"34", :controller =>"surveys/report" end Any other idea ? From aslak.hellesoy at gmail.com Fri Aug 1 06:39:52 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 1 Aug 2008 12:39:52 +0200 Subject: [rspec-users] Can't access actions of a singular nested resource In-Reply-To: <70d5b216-3511-47fb-ba74-d53001f37235@m36g2000hse.googlegroups.com> References: <8e78802d-707e-4782-a69c-e5cbf4a92692@m36g2000hse.googlegroups.com> <8d961d900807310821h1a1a7d6at281434f486e34432@mail.gmail.com> <70d5b216-3511-47fb-ba74-d53001f37235@m36g2000hse.googlegroups.com> Message-ID: <8d961d900808010339w7f275b5uafabd7b0435806ff@mail.gmail.com> On Fri, Aug 1, 2008 at 10:41 AM, Bastien wrote: > Thanks for your help Aslak, but I still didn't manage to make it pass > >>> get :show, :id=>"34" > > it sends me this error then : No route matches > {:action=>"show", :controller=>"surveys/report", :id=>"34"} > >>> Try rake routes, and also try to spec the routing in the associated >>> routing_spec.rb. > > and this test passes : > > it "should map { :controller => 'report', :action => > 'show', :survey_id => 1} to /survey/1/report" do > route_for(:controller => "surveys/report", :action => > "show", :survey_id => 1).should == "/surveys/1/report" > end > > also if I try to remove my condition the test passes so the routes > must be correct > it "should return the survey corresponding to the report" do > #Survey.should_receive(:find) > get :show, :survey_id=>"34", :controller =>"surveys/report" > end > Actually, that's a sign that you're *not* hitting the desired #show method. Survey.find("34") will fail with RecordNotFound unless you have a survey with id=34 in your test db (unlikely). > Any other idea ? Maybe you have a filter in your controller that prevents show from being called? I'd resort to some good old puts debugging.. BTW, I just committed some specs based on your code, and they pass: http://github.com/dchelimsky/rspec-dev/commit/9a7ce9ce371b1136380e97e34d33397966734b0f Aslak > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From vertebrate at gmail.com Fri Aug 1 15:19:19 2008 From: vertebrate at gmail.com (Steve) Date: Fri, 01 Aug 2008 14:19:19 -0500 Subject: [rspec-users] Rails views have_tag with html inside Message-ID: Is there a way to use "have_tag" to match tags with HTML content? I want this: response.should have_tag('span#customer_address', '123 Main St.
Anytown, FL 32803') and that is what renders in the view, but it won't match because have_tag ignores the contained '
'. I know that have_tag is based on HTMLSelector, so it's not specifically RSpec, but does anyone know how to work around this? Thanks, Steve From zach.dennis at gmail.com Fri Aug 1 15:26:35 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Fri, 1 Aug 2008 15:26:35 -0400 Subject: [rspec-users] cheat install_rspec_rails -x Message-ID: <85d99afe0808011226l41f70c3x4a55816cf9eb3193@mail.gmail.com> Should this be valuable for anyone else, I've forked cheat (hoping for it to get pulled) to allow cheat to be used for execution. For example: cheat install_rspec_rails --execute OR cheat install_rspec_rails --x http://www.continuousthinking.com/2008/8/1/cheat-execute -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From raasdnil at gmail.com Sat Aug 2 08:10:49 2008 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Sat, 2 Aug 2008 22:10:49 +1000 Subject: [rspec-users] Spec'ing correct use of Timeout Message-ID: <57a815bf0808020510n371f6ae7y2001cec64a32792@mail.gmail.com> Heya all, I have an interesting case that I would like to bounce off the list. I have a separate thread going in ruby-talk about Timeout.timeout still running after the timeout specified. The spec on this has been the classic 'I didn't write it, so I won't spec it' and so using mocks and stubs. But in this case I am getting a failure (it seems) in the Timeout library or in the OCI8 library maybe... I actually don't know. But regardless, how would one go about specing a timeout block?..... _without_ having to wait 2000 seconds? :) Mikel -- http://lindsaar.net/ Rails, RSpec and Life blog.... From zach.dennis at gmail.com Sat Aug 2 10:46:38 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Sat, 2 Aug 2008 10:46:38 -0400 Subject: [rspec-users] Spec'ing correct use of Timeout In-Reply-To: <57a815bf0808020510n371f6ae7y2001cec64a32792@mail.gmail.com> References: <57a815bf0808020510n371f6ae7y2001cec64a32792@mail.gmail.com> Message-ID: <85d99afe0808020746pb495ac2n293782911b943114@mail.gmail.com> On Sat, Aug 2, 2008 at 8:10 AM, Mikel Lindsaar wrote: > Heya all, > > I have an interesting case that I would like to bounce off the list. > > I have a separate thread going in ruby-talk about Timeout.timeout > still running after the timeout specified. The spec on this has been > the classic 'I didn't write it, so I won't spec it' and so using mocks > and stubs. > > But in this case I am getting a failure (it seems) in the Timeout > library or in the OCI8 library maybe... I actually don't know. > > But regardless, how would one go about specing a timeout block?..... > _without_ having to wait 2000 seconds? :) The first thing that comes to mind is to pass in your timeout threshold as a defaulted argument, ie: def do_something(timeout=2000), and then in the example pass in a much lower threshold. This assumes that you want the block you pass to timeout to actually be executed. -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From lists at ruby-forum.com Sat Aug 2 12:22:58 2008 From: lists at ruby-forum.com (Dean Radcliffe) Date: Sat, 2 Aug 2008 18:22:58 +0200 Subject: [rspec-users] Spec Server on Windows - missing fork Message-ID: <5516415a646d6852960d318de8b71b76@ruby-forum.com> Really tired of 30 second startup times to run Test::Unit tests, I would give my left pinky for a solution to running spec_server on windows. Is there some monkey patch that can avoid daemonizing the process altogether (Im fine if it runs as any kind of process at all). TIA. Error below - I have open3 and win32-process already but no dice. Dean > rake spec:server:start (in C:/ChessOnRails/trunk) Starting up spec server. Loading Rails environment Ready script/spec_server:81:in `fork': fork() function is unimplemented on this machine (NotImplementedErr or) from script/spec_server:81:in `daemonize' from script/spec_server:113 > gem list win32 *** LOCAL GEMS *** win32-api (1.2.0, 1.0.4) win32-clipboard (0.4.3) win32-dir (0.3.2) win32-eventlog (0.4.6) win32-file (0.5.4) win32-file-stat (1.2.7) win32-open3 (0.2.6) win32-process (0.5.9, 0.5.3) win32-sapi (0.1.4) win32-sound (0.4.1) -- Posted via http://www.ruby-forum.com/. From luislavena at gmail.com Sat Aug 2 12:38:50 2008 From: luislavena at gmail.com (Luis Lavena) Date: Sat, 2 Aug 2008 18:38:50 +0200 Subject: [rspec-users] Spec Server on Windows - missing fork In-Reply-To: <5516415a646d6852960d318de8b71b76@ruby-forum.com> References: <5516415a646d6852960d318de8b71b76@ruby-forum.com> Message-ID: <71166b3b0808020938h5529fcd4p5f258be57a833659@mail.gmail.com> On Sat, Aug 2, 2008 at 6:22 PM, Dean Radcliffe wrote: > Really tired of 30 second startup times to run Test::Unit tests, I would > give my left pinky for a solution to running spec_server on windows. Is > there some monkey patch that can avoid daemonizing the process > altogether (Im fine if it runs as any kind of process at all). TIA. > Error below - I have open3 and win32-process already but no dice. > > Dean > > > rake spec:server:start > (in C:/ChessOnRails/trunk) > Starting up spec server. > Loading Rails environment > Ready > script/spec_server:81:in `fork': fork() function is unimplemented on > this machine (NotImplementedErr > or) > from script/spec_server:81:in `daemonize' > from script/spec_server:113 > > No fork() love for us Windows users, try putting this into a batch file (like spec_server.bat) @echo off start "spec_server" /min ruby.exe script\spec_server One problem is that spec_server is not trapping Ctrl-C, so you will require to use Ctrl-break to stop the minized spec_server. HTH, -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Sat Aug 2 13:20:09 2008 From: lists at ruby-forum.com (Dean Radcliffe) Date: Sat, 2 Aug 2008 19:20:09 +0200 Subject: [rspec-users] Spec Server on Windows - missing fork In-Reply-To: <71166b3b0808020938h5529fcd4p5f258be57a833659@mail.gmail.com> References: <5516415a646d6852960d318de8b71b76@ruby-forum.com> <71166b3b0808020938h5529fcd4p5f258be57a833659@mail.gmail.com> Message-ID: <18585142bc47db50b792a5c77a166938@ruby-forum.com> Exactly the kind of monkey patch I was looking for - thanks Luis ! I also saw you could edit the spec_server file to make if options[:daemon] into if options[:daemon] and false or something similar, but a no touch solution like yours is nice, and thanks for the Ctrl-Break tip. D Luis Lavena wrote: > > No fork() love for us Windows users, try putting this into a batch file > (like spec_server.bat) > > @echo off > start "spec_server" /min ruby.exe script\spec_server > > One problem is that spec_server is not trapping Ctrl-C, so you will > require > to use Ctrl-break to stop the minized spec_server. -- Posted via http://www.ruby-forum.com/. From mark.wilden at gmail.com Sat Aug 2 15:04:37 2008 From: mark.wilden at gmail.com (Mark Wilden) Date: Sat, 2 Aug 2008 12:04:37 -0700 Subject: [rspec-users] Spec Server on Windows - missing fork In-Reply-To: <3c30da400808021203x36cd3d4eo6e7449ac693ac178@mail.gmail.com> References: <5516415a646d6852960d318de8b71b76@ruby-forum.com> <71166b3b0808020938h5529fcd4p5f258be57a833659@mail.gmail.com> <18585142bc47db50b792a5c77a166938@ruby-forum.com> <3c30da400808021203x36cd3d4eo6e7449ac693ac178@mail.gmail.com> Message-ID: <3c30da400808021204m26c318dau3d3ce63b85286bb4@mail.gmail.com> spec_server is one of the hidden gems of the RSpec world. It's not completely a slam-dunk to use, and I know people who don't use it because of various problems, but it's worth working through those problems, especially if you do T/BDD. I've set up a vim script that runs just the current spec, where "current" is defined as "the last spec the cursor was on" (even if you're editing the model or whatever). Wherever I am, I can just hit Ctrl-X and see the results of the test almost instantly. Beat that, TextMate! ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From luislavena at gmail.com Sat Aug 2 16:43:12 2008 From: luislavena at gmail.com (Luis Lavena) Date: Sat, 2 Aug 2008 22:43:12 +0200 Subject: [rspec-users] Spec Server on Windows - missing fork In-Reply-To: <3c30da400808021204m26c318dau3d3ce63b85286bb4@mail.gmail.com> References: <5516415a646d6852960d318de8b71b76@ruby-forum.com> <71166b3b0808020938h5529fcd4p5f258be57a833659@mail.gmail.com> <18585142bc47db50b792a5c77a166938@ruby-forum.com> <3c30da400808021203x36cd3d4eo6e7449ac693ac178@mail.gmail.com> <3c30da400808021204m26c318dau3d3ce63b85286bb4@mail.gmail.com> Message-ID: <71166b3b0808021343q6c49a662u3b5ae863ac19dca0@mail.gmail.com> On Sat, Aug 2, 2008 at 9:04 PM, Mark Wilden wrote: > spec_server is one of the hidden gems of the RSpec world. It's not > completely a slam-dunk to use, and I know people who don't use it because of > various problems, but it's worth working through those problems, especially > if you do T/BDD. > Yes, is a hidden gem but also have is own glitches. One is the lack of possiblity to actually quit gracefully (they need to trap INT and properly stop the DRb server. Second and trickest one is reloading of the environment. Right now if you change parts that are outside the reload mechanism of Rails, spec_server will fail. Haven't had time to investigate into it, sorry. The other one is related to ANSI escape, at least on Windows. spec_server takes spec/spec.opts and enable ANSI colors if the option is present, but that still confuses script/spec -X and generate garbage. > I've set up a vim script that runs just the current spec, where "current" is > defined as "the last spec the cursor was on" (even if you're editing the > model or whatever). Wherever I am, I can just hit Ctrl-X and see the results > of the test almost instantly. Beat that, TextMate! > I use autotest, I just save the file and it's executed, then I get the total test results without distraction, beat that ;-) Regards, -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams From mark.wilden at gmail.com Sat Aug 2 17:49:07 2008 From: mark.wilden at gmail.com (Mark Wilden) Date: Sat, 2 Aug 2008 14:49:07 -0700 Subject: [rspec-users] Spec Server on Windows - missing fork In-Reply-To: <71166b3b0808021343q6c49a662u3b5ae863ac19dca0@mail.gmail.com> References: <5516415a646d6852960d318de8b71b76@ruby-forum.com> <71166b3b0808020938h5529fcd4p5f258be57a833659@mail.gmail.com> <18585142bc47db50b792a5c77a166938@ruby-forum.com> <3c30da400808021203x36cd3d4eo6e7449ac693ac178@mail.gmail.com> <3c30da400808021204m26c318dau3d3ce63b85286bb4@mail.gmail.com> <71166b3b0808021343q6c49a662u3b5ae863ac19dca0@mail.gmail.com> Message-ID: <3c30da400808021449xaa65bc0y1120bbf1968b47c2@mail.gmail.com> On Sat, Aug 2, 2008 at 1:43 PM, Luis Lavena wrote: > One is the lack of possiblity to actually quit gracefully (they need > to trap INT and properly stop the DRb server. I just do rake spec:server:stop. This is necessary before running rake spec, for instance, since rake spec drops the test database which spec_server keeps open. Second and trickest one is reloading of the environment. Right now if > you change parts that are outside the reload mechanism of Rails, > spec_server will fail. Haven't had time to investigate into it, sorry. > I have a shell script called spec_restart, which just does a rake spec:server:stop followed by rake spec:server:start. I can't say I use it very much, though. > I use autotest, I just save the file and it's executed, then I get the > total test results without distraction, beat that ;-) > I use autotest, too (well, rspactor, which is much the same thing). But it loads the Rails environment every time it's triggered. The whole point of spec_server is that it doesn't have to do that. autotest also runs entire spec file(s). With my little script, only one spec gets run, which helps keep things narrowed down while debugging. With both autotest and spec_server running, you kind of get the best of both worlds - you can T/BDD one spec at a time very quickly but also make sure that any other potentially affected specs are run too. Before you check in, of course, you do a rake spec. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From luislavena at gmail.com Sat Aug 2 19:49:01 2008 From: luislavena at gmail.com (Luis Lavena) Date: Sun, 3 Aug 2008 01:49:01 +0200 Subject: [rspec-users] it_should_behave_like and arguments Message-ID: <71166b3b0808021649q3aa3c2a5g201c9c7e100b0e01@mail.gmail.com> Hello list, I'm trying to setup some shared specs to describe a CRUD controller and want to reuse the logic in it. I'm basing most of the examples in latest David's post about it [1] The thing is that looking at the mailing list I couldn't find a cleaner way to set the model that will be used in the different controller examples. Has anyone experienced DRY without removing readability in this topic? I was looking for something like this: describe Invoices do it_should_behave_like "CRUD", :model => Invoice, ... end where :model is being set as instance variable inside the shared specs. In any case, I can workaround using before(:each) blocks before invoking the shared specs. Thanks in advance for comments, suggestions and pointers. [1] http://blog.davidchelimsky.net/2008/7/1/new-controller-examples -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams From mailing_lists at railsnewbie.com Sat Aug 2 20:51:12 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 2 Aug 2008 20:51:12 -0400 Subject: [rspec-users] Spec Server on Windows - missing fork In-Reply-To: <71166b3b0808021343q6c49a662u3b5ae863ac19dca0@mail.gmail.com> References: <5516415a646d6852960d318de8b71b76@ruby-forum.com> <71166b3b0808020938h5529fcd4p5f258be57a833659@mail.gmail.com> <18585142bc47db50b792a5c77a166938@ruby-forum.com> <3c30da400808021203x36cd3d4eo6e7449ac693ac178@mail.gmail.com> <3c30da400808021204m26c318dau3d3ce63b85286bb4@mail.gmail.com> <71166b3b0808021343q6c49a662u3b5ae863ac19dca0@mail.gmail.com> Message-ID: On Aug 2, 2008, at 4:43 PM, Luis Lavena wrote: > On Sat, Aug 2, 2008 at 9:04 PM, Mark Wilden > wrote: >> spec_server is one of the hidden gems of the RSpec world. It's not >> completely a slam-dunk to use, and I know people who don't use it >> because of >> various problems, but it's worth working through those problems, >> especially >> if you do T/BDD. >> > > Yes, is a hidden gem but also have is own glitches. > > One is the lack of possiblity to actually quit gracefully (they need > to trap INT and properly stop the DRb server. > > Second and trickest one is reloading of the environment. Right now if > you change parts that are outside the reload mechanism of Rails, > spec_server will fail. Haven't had time to investigate into it, sorry. Yeah - this is usually the trickiest. Generally, as long as something is loaded (instead of required) everything should work fine. Also - be advised that if you set cache_classes = true in your test environment, this is doing the same as requiring your files, meaning the spec_server won't work at all. Scott From pergesu at gmail.com Sun Aug 3 11:44:06 2008 From: pergesu at gmail.com (Pat Maddox) Date: Sun, 3 Aug 2008 11:44:06 -0400 Subject: [rspec-users] Can't access actions of a singular nested resource In-Reply-To: <70d5b216-3511-47fb-ba74-d53001f37235@m36g2000hse.googlegroups.com> References: <8e78802d-707e-4782-a69c-e5cbf4a92692@m36g2000hse.googlegroups.com> <8d961d900807310821h1a1a7d6at281434f486e34432@mail.gmail.com> <70d5b216-3511-47fb-ba74-d53001f37235@m36g2000hse.googlegroups.com> Message-ID: <810a540e0808030844l1e8e4058y76ea4ee63560f9c6@mail.gmail.com> On Fri, Aug 1, 2008 at 4:41 AM, Bastien wrote: > Thanks for your help Aslak, but I still didn't manage to make it pass > >>> get :show, :id=>"34" > > it sends me this error then : No route matches > {:action=>"show", :controller=>"surveys/report", :id=>"34"} What's your controller's name? In Rails, all resource controller names are plural, even singleton resources. So your controller should be Surveys::ReportsController. Pat From james2mccarthy at gmail.com Sun Aug 3 15:50:29 2008 From: james2mccarthy at gmail.com (J2M) Date: Sun, 3 Aug 2008 12:50:29 -0700 (PDT) Subject: [rspec-users] Rspec doesn't pickup the status code correctly. Message-ID: I'm setting the status code on a controller action but rspec doesn't seem to be catching it in my spec. It works in the browser. This is the controller method, called via xhr with header Accept: 'application/json' def validate account = Account.new(:login => params[:login]) account.valid? unless (errors = account.errors['login']) url = ['http:','', request.host, params[:login]].join('/') respond_to do |format| format.json { render :json => { :url => url } } end else url = ['http:','', request.host].join('/') respond_to do |format| format.json { render :json => {:errors => errors, :url => url }, :status => 409} end end end And the spec; describe "with errors on login" do before do @account.stub!(:errors).and_return( { "password_confirmation"=>["can't be blank"], "login"=>["is too short (minimum is 3 characters)", "use only letters, numbers, and .-_@ please."], "password"=>["can't be blank", "is too short (minimum is 6 characters)"], "email"=>["can't be blank", "is too short (minimum is 6 characters)", "should look like an email address."] } ) request.env["HTTP_HOST"] = "myhost" controller.use_rails_error_handling! end it "should return conflict 409" do do_post response.response_code.should == 409 end it "should only return the login errors & the url" do expected_json = { "login" => ["is too short (minimum is 3 characters)", "use only letters, numbers, and .-_@ please."], 'url' => 'myhost/mylogin' }.to_json @format.should_receive(:json).and_return(expected_json) do_post end end Any ideas? From pergesu at gmail.com Sun Aug 3 16:19:26 2008 From: pergesu at gmail.com (Pat Maddox) Date: Sun, 3 Aug 2008 16:19:26 -0400 Subject: [rspec-users] Rspec doesn't pickup the status code correctly. In-Reply-To: References: Message-ID: <810a540e0808031319v75126f43jaf421684b9b9ed8d@mail.gmail.com> > it "should return conflict 409" do > do_post > response.response_code.should == 409 > end What is the failure message? Also, it looks like your before block has not set Account.new to return @account, and that @account is nil. Is this a nested describe, and there's some other setup happening elsewhere? Pat From james2mccarthy at gmail.com Sun Aug 3 16:29:08 2008 From: james2mccarthy at gmail.com (J2M) Date: Sun, 3 Aug 2008 13:29:08 -0700 (PDT) Subject: [rspec-users] Rspec doesn't pickup the status code correctly. In-Reply-To: <810a540e0808031319v75126f43jaf421684b9b9ed8d@mail.gmail.com> References: <810a540e0808031319v75126f43jaf421684b9b9ed8d@mail.gmail.com> Message-ID: <3f48e9f6-6141-4e0a-9f81-b4caaa90f0b6@k30g2000hse.googlegroups.com> It is nested and the rest of the setup is here; before(:each) do request.env["HTTP_ACCEPT"] = "application/json" @account = mock_account @account.stub!(:valid?) Account.stub!(:new).and_return(@account) @errors = { 'login' => 'Not available, try another!' } @account.stub!(:errors).and_return( @errors ) @json = {:this => 'that'}.to_json @format = mock("format", :json => @json ) controller.stub!(:respond_to).and_yield(@format) end All the other specs pass the only failure is this being should return conflict 409 expected: 409, got: 200 (using ==) Thanks, James On Aug 3, 9:19?pm, "Pat Maddox" wrote: > > ? ? ?it "should return conflict 409" do > > ? ? ? ?do_post > > ? ? ? ?response.response_code.should == 409 > > ? ? ?end > > What is the failure message? > > Also, it looks like your before block has not set Account.new to > return @account, and that @account is nil. ?Is this a nested describe, > and there's some other setup happening elsewhere? > > Pat > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From james2mccarthy at gmail.com Sun Aug 3 17:41:55 2008 From: james2mccarthy at gmail.com (J2M) Date: Sun, 3 Aug 2008 14:41:55 -0700 (PDT) Subject: [rspec-users] Rspec doesn't pickup the status code correctly. In-Reply-To: <810a540e0808031319v75126f43jaf421684b9b9ed8d@mail.gmail.com> References: <810a540e0808031319v75126f43jaf421684b9b9ed8d@mail.gmail.com> Message-ID: <4d1e5673-d655-40bc-ac6c-6724c33f6c59@2g2000hsn.googlegroups.com> The failure message is; should return conflict 409 expected: 409, got: 200 (using ==) Yes it is nested and the rest of the setup is; before(:each) do request.env["HTTP_ACCEPT"] = "application/json" @account = mock_account @account.stub!(:valid?) Account.stub!(:new).and_return(@account) @errors = { 'login' => 'Not available, try another!' } @account.stub!(:errors).and_return( @errors ) @json = {:this => 'that'}.to_json @format = mock("format", :json => @json ) controller.stub!(:respond_to).and_yield(@format) end Thanks. James On Aug 3, 9:19?pm, "Pat Maddox" wrote: > > ? ? ?it "should return conflict 409" do > > ? ? ? ?do_post > > ? ? ? ?response.response_code.should == 409 > > ? ? ?end > > What is the failure message? > > Also, it looks like your before block has not set Account.new to > return @account, and that @account is nil. ?Is this a nested describe, > and there's some other setup happening elsewhere? > > Pat > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From vertebrate at gmail.com Mon Aug 4 00:16:42 2008 From: vertebrate at gmail.com (Steve) Date: Sun, 03 Aug 2008 23:16:42 -0500 Subject: [rspec-users] Rspec doesn't pickup the status code correctly. In-Reply-To: References: Message-ID: J2M wrote: > I'm setting the status code on a controller action but rspec doesn't > seem to be catching it in my spec. It works in the browser. > > This is the controller method, called via xhr with header Accept: > 'application/json' > > def validate > account = Account.new(:login => params[:login]) > account.valid? > unless (errors = account.errors['login']) > url = ['http:','', request.host, params[:login]].join('/') > respond_to do |format| > format.json { render :json => { :url => url } } > end > else > url = ['http:','', request.host].join('/') > respond_to do |format| > format.json { render :json => {:errors => errors, :url => > url }, :status => 409} > end > end > end I don't know if it's the cause, but your unless statement is an assignment, and not an equality comparison: unless (errors = account.errors['login']) Steve From treas at dynamicdudes.com Mon Aug 4 09:07:49 2008 From: treas at dynamicdudes.com (Andreas Wolff) Date: Mon, 4 Aug 2008 15:07:49 +0200 (CEST) Subject: [rspec-users] Do you remember RSpactor? In-Reply-To: <12630624.181217854952993.JavaMail.andreas@hackmac.local> Message-ID: <12836674.201217855238019.JavaMail.andreas@hackmac.local> It took me a while to get the next release out, but I finally managed to release RSpactor 0.9.16, a Mac OS X RSpec runner. There are no new features but RSpactor should be a lot more stable and responsive now. If you want to have a look and download: http://rubyphunk.com/articles/2008/08/04/now-on-stock-rspactor-0-9-16/. bye -- Andreas Wolff DynamicDudes Lightweight Ruby on Rails application development http://dynamicdudes.com hire: +49 151 58 54 78 50 home: http://rubyphunk.com From zach.dennis at gmail.com Mon Aug 4 10:12:54 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 4 Aug 2008 10:12:54 -0400 Subject: [rspec-users] Can't access actions of a singular nested resource In-Reply-To: <8e78802d-707e-4782-a69c-e5cbf4a92692@m36g2000hse.googlegroups.com> References: <8e78802d-707e-4782-a69c-e5cbf4a92692@m36g2000hse.googlegroups.com> Message-ID: <85d99afe0808040712x43b288e9lfbce7c812a0c1618@mail.gmail.com> Bastien, What version of Rails and rspec are you using? Using a singular resource like you presented works just fine for me, Zach On Thu, Jul 31, 2008 at 10:06 AM, Bastien wrote: > I can't figure out what I do wrong there, I have a nested controller > which is defined as a singular resource, the routing works properly, > but inside my specs the request never goes through the show action. > > I keep on getting this error : > > Spec::Mocks::MockExpectationError in 'Surveys::ReportController should > return the survey corresponding to the report' > Mock 'Class' expected :find with (any args) once, but received it 0 > times > > In my specs : > require File.expand_path(File.dirname(__FILE__) + '/../../ > spec_helper') > describe Surveys::ReportController do > > it "should return the survey corresponding to the report" do > Survey.should_receive(:find) > get :show, :survey_id=>"34" > end > > end > > In route.rb : > map.resources :surveys do |survey| > survey.resource :report, :controller =>'surveys/report' > end > > In controller/surveys/report_controller.rb : > class Surveys::ReportController < ApplicationController > > def show > @survey = Survey.find(params[:survey_id]) > > respond_to do |format| > format.html > format.xml > end > end > > end > _______________________________________________ > 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 james2mccarthy at gmail.com Mon Aug 4 12:59:45 2008 From: james2mccarthy at gmail.com (J2M) Date: Mon, 4 Aug 2008 09:59:45 -0700 (PDT) Subject: [rspec-users] Can't access actions of a singular nested resource In-Reply-To: <85d99afe0808040712x43b288e9lfbce7c812a0c1618@mail.gmail.com> References: <8e78802d-707e-4782-a69c-e5cbf4a92692@m36g2000hse.googlegroups.com> <85d99afe0808040712x43b288e9lfbce7c812a0c1618@mail.gmail.com> Message-ID: <912dc79e-8506-4675-91b5-fa9d791f019e@i76g2000hsf.googlegroups.com> Zach, Rails 2.1 Rspec 1.1.4 What does your spec look like? Thanks, James On Aug 4, 3:12?pm, "Zach Dennis" wrote: > Bastien, > > What version of Rails and rspec are you using? Using a singular > resource like you presented works just fine for me, > > Zach > > > > On Thu, Jul 31, 2008 at 10:06 AM, Bastien wrote: > > I can't figure out what I do wrong there, I have a nested controller > > which is defined as a singular resource, the routing works properly, > > but inside my specs the request never goes through the show action. > > > I keep on getting this error : > > > Spec::Mocks::MockExpectationError in 'Surveys::ReportController should > > return the survey corresponding to the report' > > Mock 'Class' expected :find with (any args) once, but received it 0 > > times > > > In my specs : > > require File.expand_path(File.dirname(__FILE__) + '/../../ > > spec_helper') > > describe Surveys::ReportController do > > > ?it "should return the survey corresponding to the report" do > > ? ?Survey.should_receive(:find) > > ? ?get :show, :survey_id=>"34" > > ?end > > > end > > > In route.rb : > > map.resources :surveys do |survey| > > ? ?survey.resource :report, :controller =>'surveys/report' > > end > > > In controller/surveys/report_controller.rb : > > class Surveys::ReportController < ApplicationController > > > ?def show > > ? ?@survey = Survey.find(params[:survey_id]) > > > ? ?respond_to do |format| > > ? ? ?format.html > > ? ? ?format.xml > > ? ?end > > ?end > > > end > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > -- > Zach Dennishttp://www.continuousthinking.comhttp://www.mutuallyhuman.com > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From zach.dennis at gmail.com Mon Aug 4 13:43:11 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 4 Aug 2008 13:43:11 -0400 Subject: [rspec-users] Can't access actions of a singular nested resource In-Reply-To: <912dc79e-8506-4675-91b5-fa9d791f019e@i76g2000hsf.googlegroups.com> References: <8e78802d-707e-4782-a69c-e5cbf4a92692@m36g2000hse.googlegroups.com> <85d99afe0808040712x43b288e9lfbce7c812a0c1618@mail.gmail.com> <912dc79e-8506-4675-91b5-fa9d791f019e@i76g2000hsf.googlegroups.com> Message-ID: <85d99afe0808041043s6a83661co768b48bde9288585@mail.gmail.com> On Mon, Aug 4, 2008 at 12:59 PM, J2M wrote: > Zach, > > Rails 2.1 > Rspec 1.1.4 > > What does your spec look like? > http://gist.github.com/3651 -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From james2mccarthy at gmail.com Mon Aug 4 11:31:28 2008 From: james2mccarthy at gmail.com (J2M) Date: Mon, 4 Aug 2008 08:31:28 -0700 (PDT) Subject: [rspec-users] Rspec doesn't pickup the status code correctly. In-Reply-To: References: Message-ID: On Aug 4, 5:16?am, Steve wrote: > J2M wrote: > > I'm setting the status code on a controller action but rspec doesn't > > seem to be catching it in my spec. It works in the browser. > > > This is the controller method, called via xhr with header Accept: > > 'application/json' > > > ? def validate > > ? ? account = Account.new(:login => params[:login]) > > ? ? account.valid? > > ? ? unless (errors = account.errors['login']) > > ? ? ? url = ['http:','', request.host, params[:login]].join('/') > > ? ? ? respond_to do |format| > > ? ? ? ? format.json { render :json => { :url => url } } > > ? ? ? end > > ? ? else > > ? ? ? url = ['http:','', request.host].join('/') > > ? ? ? respond_to do |format| > > ? ? ? ? format.json { render :json => {:errors => errors, :url => > > url }, :status => 409} > > ? ? ? end > > ? ? end > > ? end > > I don't know if it's the cause, but your unless statement is an > assignment, and not an equality comparison: > > unless (errors = account.errors['login']) That's just me being lazy I'm assigning errors I could have put that as; errors = account.errors['login'] if account.errors['login'] But it isn't the cause as it works in the wild, it is just the spec that fails. Thanks, James From me at danielfischer.com Mon Aug 4 17:55:06 2008 From: me at danielfischer.com (Fischer, Daniel) Date: Mon, 4 Aug 2008 14:55:06 -0700 Subject: [rspec-users] Keep getting respond_to? errors Message-ID: <7e565b5c0808041455m604fa7b0g4bf541d9be2d9212@mail.gmail.com> Every time I save a model spec I get this: super: no superclass method `respond_to?' And I have to restart autotest to get it to go away. Is there any solution to this? -------------- next part -------------- An HTML attachment was scrubbed... URL: From mailing_lists at railsnewbie.com Mon Aug 4 20:25:01 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Mon, 4 Aug 2008 20:25:01 -0400 Subject: [rspec-users] Keep getting respond_to? errors In-Reply-To: <7e565b5c0808041455m604fa7b0g4bf541d9be2d9212@mail.gmail.com> References: <7e565b5c0808041455m604fa7b0g4bf541d9be2d9212@mail.gmail.com> Message-ID: <4908C456-6054-4384-A77F-EED9A6169AE7@railsnewbie.com> On Aug 4, 2008, at 5:55 PM, Fischer, Daniel wrote: > Every time I save a model spec I get this: > > super: no superclass method `respond_to?' Are you running under drb? Autotest? What version of rspec? rails? I'm almost certain this is a rails loading bug...Are you requiring anywhere? What is the value of config.cache_classes in your test.rb? Scott From dchelimsky at gmail.com Mon Aug 4 20:29:12 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 4 Aug 2008 19:29:12 -0500 Subject: [rspec-users] Capistrano: after_deploy system specs? In-Reply-To: <5b1b5e890807271252g28a6b10emc2fe12d6ff866430@mail.gmail.com> References: <5b1b5e890807271252g28a6b10emc2fe12d6ff866430@mail.gmail.com> Message-ID: <57c63afe0808041729t170e3db5l6cedbca51a6c4254@mail.gmail.com> On Sun, Jul 27, 2008 at 2:52 PM, john wrote: > Hi everyone, > I was curious if anyone out there had any examples or advice for running > specs on system status. > I would like to analyze unix utilities such as ps -aux|grep dispatch, > uptime, top (ruby processes), proper log activity, etc. Write now I > frantically scramble through these on the command to make sure everything's > okay and a rollback isn't in order. > > So far I've only found one writing about the subject: > http://www.vaporbase.com/postings/Running_rspec_after_you_deploy > > This artcle (very cool) has his post deploy rspec results outputted to the > server in question as HTML, so a few minutes after the deploy he just visits > the web page. > > Thanks in advance Hey John - this is something I've never really though of doing myself. This email was a few days ago - have you been experimenting? What have you come up with? Cheers, David From dchelimsky at gmail.com Mon Aug 4 21:45:09 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 4 Aug 2008 20:45:09 -0500 Subject: [rspec-users] Autotest quits when code has errors In-Reply-To: References: Message-ID: <57c63afe0808041845w3c5437b8i8d509b96e2203e97@mail.gmail.com> On Mon, Jul 28, 2008 at 5:10 PM, Evan Dorn wrote: > Sorry, I'd put this in a ZenTest forum (as opposed to RSpec), except > that I can't find one. > > I find it frustrating that autotest keeps running when it finds failing > tests - but it quits back to the command line whenever a test or code > contains *errors*. What do you mean "it quits back to the command line"? > This means I have to constantly (like every 5 minutes) restart autotest > by hand, which kind of defeats the purpose of autotest, and I find it > hard to believe this is the default behavior. > > If I want to do TDD/BDD and call methods before they exist, this causes > autotest to quit, which REALLY defeats the purpose. That would suck, but I haven't had this experience. > Am I doing something wrong, or is there a fix? I'm using ZenTest 3.10 > with RSpec 1.1.5. There has not been a 1.1.5 release, so I'm guessing you're using code from github, right? Can you provide a bit more about what you're doing? Are you using Rails? If so, which version? If not, how are you organizing things? Are you using a gem that you built? Cheers, David > > Thanks! > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Tue Aug 5 04:12:18 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 5 Aug 2008 03:12:18 -0500 Subject: [rspec-users] it_should_behave_like and arguments In-Reply-To: <71166b3b0808021649q3aa3c2a5g201c9c7e100b0e01@mail.gmail.com> References: <71166b3b0808021649q3aa3c2a5g201c9c7e100b0e01@mail.gmail.com> Message-ID: <57c63afe0808050112h143527b5w29687b91b2b4b7b3@mail.gmail.com> On Sat, Aug 2, 2008 at 6:49 PM, Luis Lavena wrote: > Hello list, > > I'm trying to setup some shared specs to describe a CRUD controller > and want to reuse the logic in it. > > I'm basing most of the examples in latest David's post about it [1] > > The thing is that looking at the mailing list I couldn't find a > cleaner way to set the model that will be used in the different > controller examples. > > Has anyone experienced DRY without removing readability in this topic? I think it's ironic that you cite my post about the goodness of being less DRY in your quest for more DRY-ness. ;) > I was looking for something like this: > > describe Invoices do > it_should_behave_like "CRUD", :model => Invoice, ... > end There is an open ticket on this: http://rubyurl.com/7ZsP Please feel free to resurrect the conversation there. Cheers, David > > where :model is being set as instance variable inside the shared specs. > > In any case, I can workaround using before(:each) blocks before > invoking the shared specs. > > Thanks in advance for comments, suggestions and pointers. > > [1] http://blog.davidchelimsky.net/2008/7/1/new-controller-examples > -- > Luis Lavena > AREA 17 > - > Human beings, who are almost unique in having the ability to learn from > the experience of others, are also remarkable for their apparent > disinclination to do so. > Douglas Adams > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From luislavena at gmail.com Tue Aug 5 04:22:02 2008 From: luislavena at gmail.com (Luis Lavena) Date: Tue, 5 Aug 2008 10:22:02 +0200 Subject: [rspec-users] it_should_behave_like and arguments In-Reply-To: <57c63afe0808050112h143527b5w29687b91b2b4b7b3@mail.gmail.com> References: <71166b3b0808021649q3aa3c2a5g201c9c7e100b0e01@mail.gmail.com> <57c63afe0808050112h143527b5w29687b91b2b4b7b3@mail.gmail.com> Message-ID: <71166b3b0808050122i690db75cr36b468ee7d72993a@mail.gmail.com> On Tue, Aug 5, 2008 at 10:12 AM, David Chelimsky wrote: > On Sat, Aug 2, 2008 at 6:49 PM, Luis Lavena wrote: >> Hello list, >> >> I'm trying to setup some shared specs to describe a CRUD controller >> and want to reuse the logic in it. >> >> I'm basing most of the examples in latest David's post about it [1] >> >> The thing is that looking at the mailing list I couldn't find a >> cleaner way to set the model that will be used in the different >> controller examples. >> >> Has anyone experienced DRY without removing readability in this topic? > > I think it's ironic that you cite my post about the goodness of being > less DRY in your quest for more DRY-ness. ;) > Thanks I always give my best :-D >> I was looking for something like this: >> >> describe Invoices do >> it_should_behave_like "CRUD", :model => Invoice, ... >> end > > There is an open ticket on this: http://rubyurl.com/7ZsP > > Please feel free to resurrect the conversation there. > Thanks for the pointer, but after further review of my code (and a complete weekend to think about it) I'll stick to a before :each that set the @model_class. The quest to find balance between DRY and readability is the hardest one. > Cheers, > David > Thanks David for your time answering this email. Regards, -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams From james2mccarthy at gmail.com Tue Aug 5 06:20:11 2008 From: james2mccarthy at gmail.com (J2M) Date: Tue, 5 Aug 2008 03:20:11 -0700 (PDT) Subject: [rspec-users] Rspec doesn't pickup the status code correctly. In-Reply-To: References: Message-ID: <9e4f1100-7669-4a0d-82a5-3b9b607e100f@x35g2000hsb.googlegroups.com> I'm not having much luck posting here, every other reply seems to go astray! So if I double post sorry! I'm using Rails 2.1 Rspec 1.1.4 Any ideas why this isn't giving the correct response in Rspec but is in the wild? On Aug 4, 4:31?pm, J2M wrote: > On Aug 4, 5:16?am, Steve wrote: > > > > > J2M wrote: > > > I'm setting the status code on a controller action but rspec doesn't > > > seem to be catching it in my spec. It works in the browser. > > > > This is the controller method, called via xhr with header Accept: > > > 'application/json' > > > > ? def validate > > > ? ? account = Account.new(:login => params[:login]) > > > ? ? account.valid? > > > ? ? unless (errors = account.errors['login']) > > > ? ? ? url = ['http:','', request.host, params[:login]].join('/') > > > ? ? ? respond_to do |format| > > > ? ? ? ? format.json { render :json => { :url => url } } > > > ? ? ? end > > > ? ? else > > > ? ? ? url = ['http:','', request.host].join('/') > > > ? ? ? respond_to do |format| > > > ? ? ? ? format.json { render :json => {:errors => errors, :url => > > > url }, :status => 409} > > > ? ? ? end > > > ? ? end > > > ? end > > > I don't know if it's the cause, but your unless statement is an > > assignment, and not an equality comparison: > > > unless (errors = account.errors['login']) > > That's just me being lazy I'm assigning errors I could have put that > as; > > errors = account.errors['login'] if account.errors['login'] > > But it isn't the cause as it works in the wild, it is just the spec > that fails. > > Thanks, > James > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From luislavena at gmail.com Tue Aug 5 09:09:15 2008 From: luislavena at gmail.com (Luis Lavena) Date: Tue, 5 Aug 2008 15:09:15 +0200 Subject: [rspec-users] Rails controller specs and private helper methods Message-ID: <71166b3b0808050609r81aa05s8f8050ec7dad10b9@mail.gmail.com> Hello guys, Been a while since last time I worked with Rails so is taking me a while get back to full speed. For a specific scenario I'm facing right now, I required to implement a generic REST controller that accept any kind of resource and provide a @collection or @record to work with. I take from the route requirements the name of the resource (params['resource_name']) and then constantize it. Since I keep doing that for several actions, I found cumbersome and cryptic have this in my actions: def index @collection = params['resource_name'].camelize.constantize.find(...) end You get the idea: something very ugly and something that will break if I don't be careful enough. So I tried to extract it to it's own method (resource_class), but wrapping my brain to spec it is taking me a while. At this point, I don't like the feeling that resource_class is being stubbed or expected in some actions, but not actually executed. This is the pastie: http://pastie.org/247678 Do you guys think that will be best to put the resource_class stub inside the actions and create another context to deal with those internals? Thanks in advance for your suggestions. -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams From lists at ruby-forum.com Tue Aug 5 13:19:47 2008 From: lists at ruby-forum.com (Matt Wynne) Date: Tue, 5 Aug 2008 19:19:47 +0200 Subject: [rspec-users] Autotest Doesn't Run Old Test::Unit Tests After Install Message-ID: Hi, We have a biggish rails app with a bunch of 'legacy' Test::Unit tests, but we're moving over to rspec for all our new work. We're going to be carrying these legacy tests around for a good while though, so they need to play together nicely. Before I installed the rspec plugins, autotest would run the Test::Unit tests in the project if I just called the autotest command from the root of the rails app. Now, when I do the same thing, it just runs the specs... and that's it - the old Test::Unit tests are ignored. I've attached the output FYI. I'd really like autotest to watch / run both rspec and Test::Unit tests in case my changes break either type of test. Obviously I can still use rake to run both, but I'd like to know I'll get the instant feedback. Plus I'm just intrigued about what's going on! I've tried looking at the AutoTest code in the vendor/plugins/rspec* directories but I'm a bit too new to ruby (second week as a pro!) to figure out what's going on in there. Attachments: http://www.ruby-forum.com/attachment/2490/autotest-output.txt -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Aug 5 13:24:53 2008 From: lists at ruby-forum.com (Matt Wynne) Date: Tue, 5 Aug 2008 19:24:53 +0200 Subject: [rspec-users] Autotest quits when code has errors In-Reply-To: <3c30da400807281619k5046e5b3w7a48b4381b6bd947@mail.gmail.com> References: <3c30da400807281619k5046e5b3w7a48b4381b6bd947@mail.gmail.com> Message-ID: <04b2904c4819c6709508cf854b360fff@ruby-forum.com> Mark Wilden wrote: > > It sounds like it might be an RSpec 1.1.5 thing. I've used 1.1.4 with > autotest without seeing the problem you describe. > I get a similar-ish thing: autotest doesn't actually quit, but I get no growl notification when there's a 'compile' error, so it seems like autotest doesn't treat this as a 'fail' per se. I find this slightly annoying, but I'm getting used to just hitting Shift-CTRL-V in TextMate to validate my ruby as I save it. Hope that info helps someone. Matt -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Aug 5 13:42:36 2008 From: lists at ruby-forum.com (Evan Dorn) Date: Tue, 5 Aug 2008 19:42:36 +0200 Subject: [rspec-users] Autotest quits when code has errors In-Reply-To: <57c63afe0808041845w3c5437b8i8d509b96e2203e97@mail.gmail.com> References: <57c63afe0808041845w3c5437b8i8d509b96e2203e97@mail.gmail.com> Message-ID: David Chelimsky wrote: > What do you mean "it quits back to the command line"? Autotest stops running and I get a command prompt again. > There has not been a 1.1.5 release, so I'm guessing you're using code > from github, right? Yes, I'm using a version from github, in a Rails 2.1 project. rspec and rspec-rails are installed in vendor/plugins. (as I understand it, from this post, rspec > 1.1.4 is necessary for Rails 2.1) One of the projects in question is in fact a fork of Insoshi, the project referenced in that blog post I linked, so the copies of rspec I'm using is the same version as in their git repo. The other is a personal project, but the plugins are checked out the same way (from github). I don't get this problem in another project I have, which is a R2.1 project as well but which uses Test::Unit instead of rspec. However, I have seen a similar problem (autotest quitting when errors are encountered) in that project in a similar version. I think the next thing I'll try is changing or erasing my .autotest file. There's very little in there - just some hooks for growl - but it's always possible that's what's different between my setup and that of other folks. -- Posted via http://www.ruby-forum.com/. From steve at deepsalt.com Tue Aug 5 14:26:41 2008 From: steve at deepsalt.com (Steve Eley) Date: Tue, 5 Aug 2008 14:26:41 -0400 Subject: [rspec-users] Rails controller specs and private helper methods In-Reply-To: <71166b3b0808050609r81aa05s8f8050ec7dad10b9@mail.gmail.com> References: <71166b3b0808050609r81aa05s8f8050ec7dad10b9@mail.gmail.com> Message-ID: <74243c220808051126p49b7645pfd8d722b51086695@mail.gmail.com> On Tue, Aug 5, 2008 at 9:09 AM, Luis Lavena wrote: > > Do you guys think that will be best to put the resource_class stub > inside the actions and create another context to deal with those > internals? I would. In fact, if it were really necessary to treat a generic resource as a model, I'd consider wrapping it inside a model class and spec'ing it out as a model. -- Have Fun, Steve Eley Deep Salt Team From dchelimsky at gmail.com Tue Aug 5 19:39:57 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 5 Aug 2008 18:39:57 -0500 Subject: [rspec-users] Autotest Doesn't Run Old Test::Unit Tests After Install In-Reply-To: References: Message-ID: <57c63afe0808051639s21db4c8ehf7e5c4e8a7e07a10@mail.gmail.com> On Tue, Aug 5, 2008 at 12:19 PM, Matt Wynne wrote: > Hi, > > We have a biggish rails app with a bunch of 'legacy' Test::Unit tests, > but we're moving over to rspec for all our new work. > > We're going to be carrying these legacy tests around for a good while > though, so they need to play together nicely. > > Before I installed the rspec plugins, autotest would run the Test::Unit > tests in the project if I just called the autotest command from the root > of the rails app. > > Now, when I do the same thing, it just runs the specs... and that's it - > the old Test::Unit tests are ignored. I've attached the output FYI. > > I'd really like autotest to watch / run both rspec and Test::Unit tests > in case my changes break either type of test. Obviously I can still use > rake to run both, but I'd like to know I'll get the instant feedback. > > Plus I'm just intrigued about what's going on! I've tried looking at the > AutoTest code in the vendor/plugins/rspec* directories but I'm a bit too > new to ruby (second week as a pro!) to figure out what's going on in > there. The latest rspec code in git introduces an autospec command that runs specs, leaving autotest to run the stuff in the test directory. This doesn't solve your problem, but might be useful information. To run both tests and specs you'll have to add a .autotest file and modify the mappings between subject files and the tests and examples that drive them. Check out http://blog.davidchelimsky.net/2008/1/15/rspec-1-1-2-and-zentest-3-8-0 and the ZenTest documentation for pointers on this. Cheers, David > > Attachments: > http://www.ruby-forum.com/attachment/2490/autotest-output.txt > > -- > 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 Tue Aug 5 23:27:00 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 5 Aug 2008 22:27:00 -0500 Subject: [rspec-users] HTML Story Formatter In-Reply-To: <747a4561e23c795b961245c283ea648f@ruby-forum.com> References: <1216902734.7340.14.camel@tybalt> <57c63afe0807240544p5a8adc2keaa21aac0ca1fe0e@mail.gmail.com> <57c63afe0807250611p5a950d51icefc3c36829650f2@mail.gmail.com> <49733.98.202.34.115.1217111915.squirrel@mail.onticweb.com> <488DF668.8070301@benmabey.com> <747a4561e23c795b961245c283ea648f@ruby-forum.com> Message-ID: <57c63afe0808052027p3d816a72l62d5a80d11d37b7@mail.gmail.com> On Tue, Jul 29, 2008 at 2:28 PM, Joseph Wilk wrote: >> Ahh, good to know. Does that mean that the HTML isn't outputted until >> all of the scenario's are ran for a particular story? > > Exactly. It made the html much nicer but did loose that per scenario > output. I added a progress bar formatter so I could still get that > direct scenario feedback, be it just a green dot or red F :) > > David are you happy with this html and dev-html formatter direction? If > so I'll move this issue to lighthouse and start adding my patch. Sorry for the long silence on this - just got back from my first "computer-free" vacation in some years. I recommend it to everyone (though some may wish to prepare themselves for assorted withdrawal symptoms). Anyhow - I'm not convinced one way or the other as to whether two formatters for different audiences is better than a single html formatter w/ some simple js to reveal backtraces. I can tell you from my experience with FitNesse that the backtraces were sometimes life-saving and sometimes simply annoying. Having the option to show it but have it hidden on load would be nice. Anybody else wanna chime in on this? > > > > Ben Mabey wrote: >> Joseph Wilk wrote: >>>> Which brings up the other question.. how do we want to handle the JS? >>>> Due to how the HTML is written out JS is required to change the Story's >>>> and Scenario's styles when a step fails or is pending. I did this with >>>> lowpro for the rspec-story-tmbundle: >>>> >>> >>> The current html formatter in trunk no longer requires js to apply >>> styles for failure or pending. >>> >> >> Ahh, good to know. Does that mean that the HTML isn't outputted until >> all of the scenario's are ran for a particular story? >>> So that moves us along to looking at js to hide/show the backtrace. >>> >>> The idea of showing the backtrace in the html has been something I've >>> been debating for a while. I did come to conclusion that as a developer >>> I have the build log (or terminal stories are run from) as a source for >>> story errors. Hence I felt I was best left leaving my stories clean for >>> the non-developer users of the stories. >>> >> >> This is true for regular development, although having the backtrace can >> also be helpful in the HTML version if you use that as your main >> formatter (i.e. in textmate.) >> The real use for the backtrace, IMO, is for providing a decent build >> artifact for CI. Otherwise you could have to look through your test.log >> file and try to match it up.. which would be no fun. >>> >>> AND >>> advanced/verbose output (profiling each story aswell perhaps?). >>> Potentially Aslak's new interface could move to this dev-formatter(or >>> some other formatter) so that we continue development without disturbing >>> those using the simple default output. >>> >>> What do people think? >>> >> >> I really like that idea, and I agree with you that these two would cover >> most use cases. >> >> -Ben > > -- > 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 Tue Aug 5 23:41:41 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 5 Aug 2008 22:41:41 -0500 Subject: [rspec-users] Writing specs for a plugin module for ActionController In-Reply-To: References: Message-ID: <57c63afe0808052041w6f8fd959u61acaa72593b4d7b@mail.gmail.com> On Thu, Jul 31, 2008 at 2:02 PM, Leslie Freeman wrote: > Hello, > I'm trying to spec a plugin that includes a module that adds functionality > to ActionController below is what I've come up with: > > # vendor/plugins/custom_attribute_fu/spec/active_record_spec.rb > require File.dirname(__FILE__) + '/spec_helper' > > class TestPerson < ActiveRecord::Base > end > > class TestPeopleController < ActionController::Base > #calling defines_custom_attributes should add the > custom_attribute_definitions method, I've defined it explicitly for now to > just get the tests running > #defines_custom_attributes > > def custom_attribute_definitions > end > end > > describe TestPeopleController do > > describe "handling GET /custom_attribute_definitions" do > > before(:each) do > @controller = TestPeopleController.new > @request = ActionController::TestRequest.new > @response = ActionController::TestResponse.new > end > > def do_get > get :custom_attribute_definitions > end > > it "should be successful" do > do_get > response.should be_success > end > > end > end > > When I run the spec I get: > > 1) > ActionView::TemplateError in 'TestPeopleController handling GET > /custom_attribute_definitions should be successful' > undefined method `custom_attribute_definitions' for TestPerson(id: integer, > name: string):Class > > What I don't understand is that why get :custom_attribute_definitions is > trying to call that method on TestPerson rather than TestPersonController. > > I'm sure there's a better way to set this up - any advice would be greatly > appreciated! I get a very different result. Here's what I did: $ rails foo $ cd foo $ script/plugin install git://github.com/dchelimsky/rspec.git $ script/plugin install git://github.com/dchelimsky/rspec-rails.git $ script/generate rspec $ mkdir vendor/plugins/custom_attribute_fu $ mkdir vendor/plugins/custom_attribute_fu/spec $ touch vendor/plugins/custom_attribute_fu/spec/spec_helper.rb $ touch vendor/plugins/custom_attribute_fu/spec/active_record_spec.rb Then I added the text you posted above to active_record_spec.rb and the following to spec_helper.rb: require File.join(File.dirname(__FILE__), *%w[.. .. .. .. spec spec_helper]) Then, from the RAILS_ROOT: $ rake spec:plugins F 1) ActionView::MissingTemplate in 'TestPeopleController handling GET /custom_attribute_definitions should be successful' This is with rails 2.1 and the latest rspec (from git). Am I doing something different from what you did? From dchelimsky at gmail.com Wed Aug 6 00:04:42 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 5 Aug 2008 23:04:42 -0500 Subject: [rspec-users] Spec Server on Windows - missing fork In-Reply-To: <71166b3b0808021343q6c49a662u3b5ae863ac19dca0@mail.gmail.com> References: <5516415a646d6852960d318de8b71b76@ruby-forum.com> <71166b3b0808020938h5529fcd4p5f258be57a833659@mail.gmail.com> <18585142bc47db50b792a5c77a166938@ruby-forum.com> <3c30da400808021203x36cd3d4eo6e7449ac693ac178@mail.gmail.com> <3c30da400808021204m26c318dau3d3ce63b85286bb4@mail.gmail.com> <71166b3b0808021343q6c49a662u3b5ae863ac19dca0@mail.gmail.com> Message-ID: <57c63afe0808052104g6a2b795au5ee0e725f94cd239@mail.gmail.com> On Sat, Aug 2, 2008 at 3:43 PM, Luis Lavena wrote: > On Sat, Aug 2, 2008 at 9:04 PM, Mark Wilden wrote: >> spec_server is one of the hidden gems of the RSpec world. It's not >> completely a slam-dunk to use, and I know people who don't use it because of >> various problems, but it's worth working through those problems, especially >> if you do T/BDD. >> > > Yes, is a hidden gem but also have is own glitches. > > One is the lack of possiblity to actually quit gracefully (they need > to trap INT and properly stop the DRb server. Patches welcome! > > Second and trickest one is reloading of the environment. Right now if > you change parts that are outside the reload mechanism of Rails, > spec_server will fail. Haven't had time to investigate into it, sorry. > > The other one is related to ANSI escape, at least on Windows. > spec_server takes spec/spec.opts and enable ANSI colors if the option > is present, but that still confuses script/spec -X and generate > garbage. > >> I've set up a vim script that runs just the current spec, where "current" is >> defined as "the last spec the cursor was on" (even if you're editing the >> model or whatever). Wherever I am, I can just hit Ctrl-X and see the results >> of the test almost instantly. Beat that, TextMate! > > I use autotest, I just save the file and it's executed, then I get the > total test results without distraction, beat that ;-) > > Regards, > -- > Luis Lavena > AREA 17 > - > Human beings, who are almost unique in having the ability to learn from > the experience of others, are also remarkable for their apparent > disinclination to do so. > Douglas Adams > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jim at saturnflyer.com Wed Aug 6 00:28:54 2008 From: jim at saturnflyer.com (Jim Gay) Date: Wed, 6 Aug 2008 00:28:54 -0400 Subject: [rspec-users] Spec Server on Windows - missing fork In-Reply-To: <57c63afe0808052104g6a2b795au5ee0e725f94cd239@mail.gmail.com> References: <5516415a646d6852960d318de8b71b76@ruby-forum.com> <71166b3b0808020938h5529fcd4p5f258be57a833659@mail.gmail.com> <18585142bc47db50b792a5c77a166938@ruby-forum.com> <3c30da400808021203x36cd3d4eo6e7449ac693ac178@mail.gmail.com> <3c30da400808021204m26c318dau3d3ce63b85286bb4@mail.gmail.com> <71166b3b0808021343q6c49a662u3b5ae863ac19dca0@mail.gmail.com> <57c63afe0808052104g6a2b795au5ee0e725f94cd239@mail.gmail.com> Message-ID: <21235693-CE3A-4DC5-8CDE-CD292FD0F3B1@saturnflyer.com> On Aug 6, 2008, at 12:04 AM, David Chelimsky wrote: > On Sat, Aug 2, 2008 at 3:43 PM, Luis Lavena > wrote: >> On Sat, Aug 2, 2008 at 9:04 PM, Mark Wilden >> wrote: >>> spec_server is one of the hidden gems of the RSpec world. It's not >>> completely a slam-dunk to use, and I know people who don't use it >>> because of >>> various problems, but it's worth working through those problems, >>> especially >>> if you do T/BDD. >>> >> >> Yes, is a hidden gem but also have is own glitches. >> >> One is the lack of possiblity to actually quit gracefully (they need >> to trap INT and properly stop the DRb server. > > Patches welcome! http://www.patchesthecat.com/ I couldn't resist. > > >> >> Second and trickest one is reloading of the environment. Right now if >> you change parts that are outside the reload mechanism of Rails, >> spec_server will fail. Haven't had time to investigate into it, >> sorry. >> >> The other one is related to ANSI escape, at least on Windows. >> spec_server takes spec/spec.opts and enable ANSI colors if the option >> is present, but that still confuses script/spec -X and generate >> garbage. >> >>> I've set up a vim script that runs just the current spec, where >>> "current" is >>> defined as "the last spec the cursor was on" (even if you're >>> editing the >>> model or whatever). Wherever I am, I can just hit Ctrl-X and see >>> the results >>> of the test almost instantly. Beat that, TextMate! >> >> I use autotest, I just save the file and it's executed, then I get >> the >> total test results without distraction, beat that ;-) >> >> Regards, >> -- >> Luis Lavena >> AREA 17 >> - >> Human beings, who are almost unique in having the ability to learn >> from >> the experience of others, are also remarkable for their apparent >> disinclination to do so. >> Douglas Adams >> _______________________________________________ >> 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 undees at gmail.com Wed Aug 6 00:47:33 2008 From: undees at gmail.com (Ian Dees) Date: Tue, 5 Aug 2008 21:47:33 -0700 Subject: [rspec-users] [ANN/ADV] "Scripted GUI Testing With Ruby" book (uses RSpec) Message-ID: Hi, all. The publishers have just thrown the switch to make my new book, "Scripted GUI Testing With Ruby," available for purchase in both PDF and "analog." http://www.pragprog.com/titles/idgtr The book uses RSpec heavily throughout (both example notation and the Story Runner) as it builds up a series of user interface tests for desktop (Win32, Swing, OS X) and Web apps. Couldn't have done it without the beauty of RSpec to look up to as a role model. So thanks, David and crew. Enjoy! --Ian From dchelimsky at gmail.com Wed Aug 6 01:06:33 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 6 Aug 2008 00:06:33 -0500 Subject: [rspec-users] [ANN/ADV] "Scripted GUI Testing With Ruby" book (uses RSpec) In-Reply-To: References: Message-ID: <57c63afe0808052206t676858ecqfad19c65d0c307dd@mail.gmail.com> On Tue, Aug 5, 2008 at 11:47 PM, Ian Dees wrote: > Hi, all. > > The publishers have just thrown the switch to make my new book, > "Scripted GUI Testing With Ruby," available for purchase in both PDF > and "analog." Congratulations Ian! > > http://www.pragprog.com/titles/idgtr > > The book uses RSpec heavily throughout (both example notation and the > Story Runner) as it builds up a series of user interface tests for > desktop (Win32, Swing, OS X) and Web apps. > > Couldn't have done it without the beauty of RSpec to look up to as a > role model. So thanks, David and crew. > > Enjoy! > > --Ian > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Wed Aug 6 03:26:28 2008 From: lists at ruby-forum.com (Matt Wynne) Date: Wed, 6 Aug 2008 09:26:28 +0200 Subject: [rspec-users] Autotest Doesn't Run Old Test::Unit Tests After Install In-Reply-To: <57c63afe0808051639s21db4c8ehf7e5c4e8a7e07a10@mail.gmail.com> References: <57c63afe0808051639s21db4c8ehf7e5c4e8a7e07a10@mail.gmail.com> Message-ID: David Chelimsky wrote: > > The latest rspec code in git introduces an autospec command that runs > specs, leaving autotest to run the stuff in the test directory. This > doesn't solve your problem, but might be useful information. > > To run both tests and specs you'll have to add a .autotest file and > modify the mappings between subject files and the tests and examples > that drive them. Check out > http://blog.davidchelimsky.net/2008/1/15/rspec-1-1-2-and-zentest-3-8-0 > and the ZenTest documentation for pointers on this. > Thanks David, that looks like plenty to go on. I can run autotest and autospec in two different terminals for the time being I guess, and when I gather the gumption I'll blaze into the ~/.autotest stuff. cheers, Matt -- Posted via http://www.ruby-forum.com/. From luislavena at gmail.com Wed Aug 6 04:04:23 2008 From: luislavena at gmail.com (Luis Lavena) Date: Wed, 6 Aug 2008 10:04:23 +0200 Subject: [rspec-users] Spec Server on Windows - missing fork In-Reply-To: <57c63afe0808052104g6a2b795au5ee0e725f94cd239@mail.gmail.com> References: <5516415a646d6852960d318de8b71b76@ruby-forum.com> <71166b3b0808020938h5529fcd4p5f258be57a833659@mail.gmail.com> <18585142bc47db50b792a5c77a166938@ruby-forum.com> <3c30da400808021203x36cd3d4eo6e7449ac693ac178@mail.gmail.com> <3c30da400808021204m26c318dau3d3ce63b85286bb4@mail.gmail.com> <71166b3b0808021343q6c49a662u3b5ae863ac19dca0@mail.gmail.com> <57c63afe0808052104g6a2b795au5ee0e725f94cd239@mail.gmail.com> Message-ID: <71166b3b0808060104u1af539cch7c5086b2ecbc7327@mail.gmail.com> On Wed, Aug 6, 2008 at 6:04 AM, David Chelimsky wrote: > On Sat, Aug 2, 2008 at 3:43 PM, Luis Lavena wrote: >> On Sat, Aug 2, 2008 at 9:04 PM, Mark Wilden wrote: >>> spec_server is one of the hidden gems of the RSpec world. It's not >>> completely a slam-dunk to use, and I know people who don't use it because of >>> various problems, but it's worth working through those problems, especially >>> if you do T/BDD. >>> >> >> Yes, is a hidden gem but also have is own glitches. >> >> One is the lack of possiblity to actually quit gracefully (they need >> to trap INT and properly stop the DRb server. > > Patches welcome! > I will!! I'm not complaining, but giving a warning ;-) I need to find it the time, so maybe around next week will have a few hours to setup the environment and provide a patch for it. -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams From lists at ruby-forum.com Wed Aug 6 06:12:15 2008 From: lists at ruby-forum.com (Matt Wynne) Date: Wed, 6 Aug 2008 12:12:15 +0200 Subject: [rspec-users] Straw Poll: How are you using plain text stories (in rails)? Message-ID: Hi all, I've been using rspec / rails for just over a week now, and I'm loving the specification framework. The way I can group examples together feels really natural, and I'm finding the TDD flow terrific. Thus far I've used the describe / it "should..." syntax to basically do TDD of my controllers, views and models, with splendid isolation using the mocking framework. I've yet to write any 'integrations tests', in fact I'm not yet clear how much value they have. What originally attracted me to rspec was hearing Dan North talk about the plain text stories, and I had some fun in my previous life as a C# programmer using them to drive watir tests of an ASP.NET app. What I'm not sure about is how they're most appropriately used in rails. Are people generally using them, as I was in the .NET world, to drive selenium/watir acceptance tests, or do they have value as replacements to the rails 'integration tests'? How about webrat? or some other glue / tool that I haven't heard of yet? Just a quick answer from anyone out there using these tools would be great in order to get a feel for the current state of the art, and some fresh fuel for my googling! Sorry if this post is a bit rambling... thanks for bearing with me as I scramble up the learning curve! cheers, Matt -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Aug 6 07:13:11 2008 From: lists at ruby-forum.com (Joseph Wilk) Date: Wed, 6 Aug 2008 13:13:11 +0200 Subject: [rspec-users] Straw Poll: How are you using plain text stories (in rails)? In-Reply-To: References: Message-ID: > Are people generally using them, as I was in the .NET world, to drive > selenium/watir acceptance tests, or do they have value as replacements > to the rails 'integration tests'? I'm using stories as acceptance tests and also replacing rails integration tests. I find with stories I generally end up with good coverage of all the things I would do for integration tests. > > How about webrat? or some other glue / tool that I haven't heard of yet? > Webrat's great but you often have to turn to something that handles JavaScript. I ended up using Selenium to handle this ?(Selenium-rc). I find in a big ajaxy web app, webrat accounts for about 10% of my stories. Dealing with the running tests in both Webrat and a browser testing framework requires some separation when running the stories. I've been meaning to make a post on this... Webrat has started to look at how its syntax can be used to drive Selenium/Watir (checkout the latest in git). How useful this is and where it goes I'm unsure but its interesting! If you are using JRuby a nice tool which wraps the Java HtmlUnit is Celerity: http://celerity.rubyforge.org/ At the moment I'm yet to see something like HtmlUnit on the ruby platform. I watch Celerity in envy :) -- Joseph Wilk http://www.joesniff.co.uk -- Posted via http://www.ruby-forum.com/. From jonathan at parkerhill.com Wed Aug 6 08:24:09 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Wed, 6 Aug 2008 08:24:09 -0400 Subject: [rspec-users] [ANN/ADV] "Scripted GUI Testing With Ruby" book (uses RSpec) In-Reply-To: References: Message-ID: Ian, sounds like your espresso machine needs some gui testing... :) On Aug 6, 2008, at 12:47 AM, Ian Dees wrote: > Hi, all. > > The publishers have just thrown the switch to make my new book, > "Scripted GUI Testing With Ruby," available for purchase in both PDF > and "analog." > > http://www.pragprog.com/titles/idgtr > > The book uses RSpec heavily throughout (both example notation and the > Story Runner) as it builds up a series of user interface tests for > desktop (Win32, Swing, OS X) and Web apps. > > Couldn't have done it without the beauty of RSpec to look up to as a > role model. So thanks, David and crew. > > Enjoy! > > --Ian > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Wed Aug 6 08:56:11 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 6 Aug 2008 07:56:11 -0500 Subject: [rspec-users] [ANN/ADV] "Scripted GUI Testing With Ruby" book (uses RSpec) In-Reply-To: References: Message-ID: <57c63afe0808060556j12354147l6e8b79baf4d9d228@mail.gmail.com> On Wed, Aug 6, 2008 at 7:24 AM, Jonathan Linowes wrote: > Ian, sounds like your espresso machine needs some gui testing... Hmmm ... gui espresso? I prefer mine a bit more watiry. > :) > > On Aug 6, 2008, at 12:47 AM, Ian Dees wrote: > >> Hi, all. >> >> The publishers have just thrown the switch to make my new book, >> "Scripted GUI Testing With Ruby," available for purchase in both PDF >> and "analog." >> >> http://www.pragprog.com/titles/idgtr >> >> The book uses RSpec heavily throughout (both example notation and the >> Story Runner) as it builds up a series of user interface tests for >> desktop (Win32, Swing, OS X) and Web apps. >> >> Couldn't have done it without the beauty of RSpec to look up to as a >> role model. So thanks, David and crew. >> >> Enjoy! >> >> --Ian >> _______________________________________________ >> 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 Aug 6 09:13:21 2008 From: lists at ruby-forum.com (Matt Wynne) Date: Wed, 6 Aug 2008 15:13:21 +0200 Subject: [rspec-users] Straw Poll: How are you using plain text stories (in rails)? In-Reply-To: References: Message-ID: Joseph Wilk wrote: > If you are using JRuby a nice tool which wraps the Java HtmlUnit is > Celerity: > http://celerity.rubyforge.org/ > > At the moment I'm yet to see something like HtmlUnit on the ruby > platform. I watch Celerity in envy :) Interesting. On the surface HtmlUnit looks just like webrat - what's the difference? -- Posted via http://www.ruby-forum.com/. From reddvinylene at gmail.com Wed Aug 6 09:57:22 2008 From: reddvinylene at gmail.com (Redd Vinylene) Date: Wed, 6 Aug 2008 15:57:22 +0200 Subject: [rspec-users] How to consolidate old_project/test/* with new_project/spec/*? Message-ID: Hello everybody:) I'm new to this, but how should I go about consolidating old_project/test/* with new_project/spec/*? Here is the contents of my old_project/test/* -- http://pastie.org/248453 Would I have to rewrite everything? Many thanks! -- http://www.home.no/reddvinylene From ben at benmabey.com Wed Aug 6 10:43:17 2008 From: ben at benmabey.com (Ben Mabey) Date: Wed, 06 Aug 2008 08:43:17 -0600 Subject: [rspec-users] Straw Poll: How are you using plain text stories (in rails)? In-Reply-To: References: Message-ID: <4899B885.60909@benmabey.com> Matt Wynne wrote: > Interesting. On the surface HtmlUnit looks just like webrat - what's the > difference? > HtmlUnit is quite different. It is a language/framework agnostic way to test any webapp *including* the app's JS. All of this, even the JS, is in memory and does not require a browser just like webrat. It does the JS by using Rhino, Java's implementation of JS. At the moment, webrat is tied to rails integration testing framework (their are forks that allow merb testing as well that I have used successfully.) As Joseph said their is currently some work to wrap the webrat API around Selenuin, mechanize, etc, that would break it's dependence on the integration testing framework in rails. Having it tied to the integration framework does give you some flexibility though and is most likely faster. To answer your original question on how people are using it... In the past project I did I ended up with 100+ scenarios all using webrat. We decided to make the entire site with UJS (unobtrusive JS) which lent it self to testing it with webrat. The extra JS we added we have not yet wrapped stories around it so we have a manual testing cycle before each major deployment. On the current project I'm on we are going to be using JS heavily and will most likely leverage HtmlUnit (Celerity) in our stories to keep them all in-memory. If your app is not extremely JS dependent then I would recommend the UJS + webrat route. @Joseph > If you are using JRuby a nice tool which wraps the Java HtmlUnit is > Celerity: > http://celerity.rubyforge.org/ > > At the moment I'm yet to see something like HtmlUnit on the ruby > platform. I watch Celerity in envy :) > Have you seen Johnson yet? http://github.com/jbarnette/johnson/tree/master It's goal is to wrap Mozilla's JS engine written in C, SpiderMonkey, in ruby. With this equivalent solution in place like Java's Rhino it will be possible to create an HtmlUnit like testing framwork entirely in Ruby and perhaps just extend webrat to get JS functionality. I have not yet realll played around with it and I haven't been able to find any posts about how to use it.. but it is something to keep your eye on. Johnson seems young so, as I said earlier, we will probably try to use the more mature HtmlUnit (a'la JRuby) to do our in-memory JS testing. -Ben From chris at cobaltedge.com Wed Aug 6 10:47:16 2008 From: chris at cobaltedge.com (Christopher Bailey) Date: Wed, 6 Aug 2008 07:47:16 -0700 Subject: [rspec-users] Straw Poll: How are you using plain text stories (in rails)? In-Reply-To: References: Message-ID: <443c240c0808060747s74619897y704d1d4b744fe52e@mail.gmail.com> I'm using stories with Webrat, and really like it. As mentioned, it doesn't cover the JavaScript bit, but so far that's ok, we don't have enough that I can't just test it manually (dread!). But, yes, since starting to use stories, I'd guess I've written maybe two or three controller tests, and have wound up deleting many of my view tests (and don't use Rails integration tests at all). So, essentially, what it's boiling down to for me, is that I have my examples for models, and then use stories for everything else. There have been a few tricky cases to do with stories, but otherwise I just like it far better, and feel it's a much better and more effective way to test since it's going to emulate what really happens on your site. One of the things that's driven me to using stories so much more is the fragile nature of the other tests, in that it seems like view and controller tests break so much more easily with various changes, whereas stories don't. This likely depends on how much you test the precise text and such on a page. On Wed, Aug 6, 2008 at 3:12 AM, Matt Wynne wrote: > Hi all, > > I've been using rspec / rails for just over a week now, and I'm loving > the specification framework. The way I can group examples together > feels really natural, and I'm finding the TDD flow terrific. > > Thus far I've used the describe / it "should..." syntax to basically do > TDD of my controllers, views and models, with splendid isolation using > the mocking framework. I've yet to write any 'integrations tests', in > fact I'm not yet clear how much value they have. > > What originally attracted me to rspec was hearing Dan North talk about > the plain text stories, and I had some fun in my previous life as a C# > programmer using them to drive watir tests of an ASP.NET app. > > What I'm not sure about is how they're most appropriately used in rails. > > Are people generally using them, as I was in the .NET world, to drive > selenium/watir acceptance tests, or do they have value as replacements > to the rails 'integration tests'? > > How about webrat? or some other glue / tool that I haven't heard of yet? > > Just a quick answer from anyone out there using these tools would be > great in order to get a feel for the current state of the art, and some > fresh fuel for my googling! > > Sorry if this post is a bit rambling... thanks for bearing with me as I > scramble up the learning curve! > > cheers, > Matt > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Christopher Bailey Cobalt Edge LLC http://cobaltedge.com From baz at madeofstone.net Wed Aug 6 11:04:01 2008 From: baz at madeofstone.net (Rahoul Baruah) Date: Wed, 6 Aug 2008 16:04:01 +0100 Subject: [rspec-users] Granularity in stories (was Straw Poll: How are you using plain text stories (in rails)?) In-Reply-To: <443c240c0808060747s74619897y704d1d4b744fe52e@mail.gmail.com> References: <443c240c0808060747s74619897y704d1d4b744fe52e@mail.gmail.com> Message-ID: <7E4C0540-7E33-4C24-B570-48852626BD6F@madeofstone.net> Hi all. On 6 Aug 2008, at 15:47, Christopher Bailey wrote: > But, yes, since starting to use stories, I'd guess I've written maybe > two or three controller tests, and have wound up deleting many of my > view tests (and don't use Rails integration tests at all). So, > essentially, what it's boiling down to for me, is that I have my > examples for models, and then use stories for everything else. There > have been a few tricky cases to do with stories, but otherwise I just > like it far better, and feel it's a much better and more effective way > to test since it's going to emulate what really happens on your site. > I've not used stories in anger yet (although my current personal project is gathering a large selection of text stories as I think of new functionality). The thing that's been holding me back is the granularity. Do you try and write a scenario for every possible case? For example, if my story was about signing up for an account, would you write a sign up story with scenarios for success and scenarios for failure (and let your controller/model specs deal with the individual reasons that the signup may fail) or would you have scenarios for "username is taken", "password and confirmation do not match" etc (effectively making the other tests slightly redundant, as Christopher mentioned)? Cheers, Baz. Rahoul Baruah Web design and development: http://www.3hv.co.uk/ Nottingham Forest: http://www.eighteensixtyfive.co.uk/ Serious Rails Hosting: http://www.brightbox.co.uk/ Lifecast: http://www.madeofstone.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Wed Aug 6 11:18:57 2008 From: lists at ruby-forum.com (Matt Wynne) Date: Wed, 6 Aug 2008 17:18:57 +0200 Subject: [rspec-users] Granularity in stories (was Straw Poll: How are you using plain text stories (in rails)?) In-Reply-To: <7E4C0540-7E33-4C24-B570-48852626BD6F@madeofstone.net> References: <443c240c0808060747s74619897y704d1d4b744fe52e@mail.gmail.com> <7E4C0540-7E33-4C24-B570-48852626BD6F@madeofstone.net> Message-ID: <0033d1c27522b0351b2205ee141aea74@ruby-forum.com> Rahoul Baruah wrote: > > The thing that's been holding me back is the granularity. > > Do you try and write a scenario for every possible case? > It might help to have a look at the thread that starts here: http://www.benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories/ Its a subtlety I'm only just getting my head around, but there's a wealth of useful experience behind these posts. cheers, Matt -- Posted via http://www.ruby-forum.com/. From baz at madeofstone.net Wed Aug 6 11:41:44 2008 From: baz at madeofstone.net (Rahoul Baruah) Date: Wed, 6 Aug 2008 16:41:44 +0100 Subject: [rspec-users] Granularity in stories (was Straw Poll: How are you using plain text stories (in rails)?) In-Reply-To: <0033d1c27522b0351b2205ee141aea74@ruby-forum.com> References: <443c240c0808060747s74619897y704d1d4b744fe52e@mail.gmail.com> <7E4C0540-7E33-4C24-B570-48852626BD6F@madeofstone.net> <0033d1c27522b0351b2205ee141aea74@ruby-forum.com> Message-ID: On 6 Aug 2008, at 16:18, Matt Wynne wrote: > > It might help to have a look at the thread that starts here: > http://www.benmabey.com/2008/05/19/imperative-vs-declarative- > scenarios-in-user-stories/ > > Its a subtlety I'm only just getting my head around, but there's a > wealth of useful experience behind these posts. Thanks Matt (and Ben), that's very helpful. I'm definitely in the "declarative, token for conversation" camp then. So I would write a scenario for success and one for failure and let my models (and/or controllers) deal with what failure actually means. Heh, I like this stuff - it's got me enthused about programming in a way that haven't been since I first came across Rails. B. Rahoul Baruah Web design and development: http://www.3hv.co.uk/ Nottingham Forest: http://www.eighteensixtyfive.co.uk/ Serious Rails Hosting: http://www.brightbox.co.uk/ Lifecast: http://www.madeofstone.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From vertebrate at gmail.com Wed Aug 6 12:22:31 2008 From: vertebrate at gmail.com (Steve) Date: Wed, 06 Aug 2008 11:22:31 -0500 Subject: [rspec-users] hash_excluding/hash_only? Message-ID: I know there is a hash_including, which is quite useful. Are there by chance any matchers for ensuring a hash includes only the specified values, or that it doesn't have certain values? Thanks, Steve From lists at ruby-forum.com Wed Aug 6 12:32:01 2008 From: lists at ruby-forum.com (Matt Wynne) Date: Wed, 6 Aug 2008 18:32:01 +0200 Subject: [rspec-users] Straw Poll: How are you using plain text stories (in rails)? In-Reply-To: References: Message-ID: Note that there's also some existing discussion on this list that I just found (with a search for 'RailsStory'): http://www.ruby-forum.com/topic/156930#new -- Posted via http://www.ruby-forum.com/. From undees at gmail.com Wed Aug 6 12:33:53 2008 From: undees at gmail.com (Ian Dees) Date: Wed, 6 Aug 2008 09:33:53 -0700 Subject: [rspec-users] [ANN/ADV] "Scripted GUI Testing With Ruby" book (uses RSpec) Message-ID: > > Ian, sounds like your espresso machine needs some gui testing... > > Hmmm ... gui espresso? I prefer mine a bit more watiry. What, no Mocha jokes? From mark at mwilden.com Wed Aug 6 12:37:51 2008 From: mark at mwilden.com (Mark Wilden) Date: Wed, 6 Aug 2008 09:37:51 -0700 Subject: [rspec-users] hash_excluding/hash_only? In-Reply-To: References: Message-ID: <3c30da400808060937j6b801c80m960678f72772d578@mail.gmail.com> On Wed, Aug 6, 2008 at 9:22 AM, Steve wrote: > I know there is a hash_including, which is quite useful. Are there by > chance any matchers for ensuring a hash includes only the specified values, > or that it doesn't have certain values? > I'm just on my way out the door, but just wanted to say that if there isn't, writing your own matcher is super easy. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists-rspec at shopwatch.org Wed Aug 6 11:48:57 2008 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Wed, 06 Aug 2008 11:48:57 -0400 Subject: [rspec-users] old plugin points to old docs to explain how to upgrade to new plugin Message-ID: <4899C7E9.2060501@shopwatch.org> I was using Ben Mabey's tutorial, which includes an older RSpec on Rails (20080131122909) plugin, and thus reported that it was incompatible with my 1.1.4 gem. It tries to be helpful, and says: "See http://rspec.rubyforge.org/documentation/rails/install.html for details." But, of course, the details aren't there anymore; they're over at rspec.info. Maybe the old URL should redirect? Jay Levitt From pergesu at gmail.com Wed Aug 6 13:50:27 2008 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 6 Aug 2008 13:50:27 -0400 Subject: [rspec-users] Someone please name this matcher for me Message-ID: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> I've had a matcher in my head for a couple months, that I frequently want but never get around to writing because I can't think of the name for it. Here's how it would look [1, 2, 3, 4, 1].should ... [1, 3, 1, 4, 2] I have a couple ideas for names, but I'll hold off on them so I don't influence anyone's opinion. btw, I realize that .sort works in this case. But that's slightly less clear than I'd like, and it doesn't work for non-Comparable objects (like activerecords). Pat From jonathan at parkerhill.com Wed Aug 6 14:06:19 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Wed, 6 Aug 2008 14:06:19 -0400 Subject: [rspec-users] Someone please name this matcher for me In-Reply-To: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> References: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> Message-ID: <92D02CED-EA1C-4297-A779-9A748424FE07@parkerhill.com> perhaps verbose but how about foo.should equal_in_any_order [1, 3, 1, 4, 2] On Aug 6, 2008, at 1:50 PM, Pat Maddox wrote: > I've had a matcher in my head for a couple months, that I frequently > want but never get around to writing because I can't think of the name > for it. Here's how it would look > > [1, 2, 3, 4, 1].should ... [1, 3, 1, 4, 2] > > I have a couple ideas for names, but I'll hold off on them so I don't > influence anyone's opinion. > > btw, I realize that .sort works in this case. But that's slightly > less clear than I'd like, and it doesn't work for non-Comparable > objects (like activerecords). > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mike at vincent.ws Wed Aug 6 14:11:01 2008 From: mike at vincent.ws (Mike Vincent) Date: Wed, 6 Aug 2008 13:11:01 -0500 Subject: [rspec-users] Someone please name this matcher for me In-Reply-To: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> References: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> Message-ID: <2386bfa00808061111m7970263dt6b902ad3ea4fac4f@mail.gmail.com> On Wed, Aug 6, 2008 at 12:50 PM, Pat Maddox wrote: > I've had a matcher in my head for a couple months, that I frequently > want but never get around to writing because I can't think of the name > for it. Here's how it would look > > [1, 2, 3, 4, 1].should ... [1, 3, 1, 4, 2] [1, 2, 3, 4, 1].should include_all [1, 3, 1, 4, 2] From zach.dennis at gmail.com Wed Aug 6 14:15:05 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 6 Aug 2008 14:15:05 -0400 Subject: [rspec-users] Someone please name this matcher for me In-Reply-To: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> References: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> Message-ID: <85d99afe0808061115te21d16awcf8f4b40b527f0ee@mail.gmail.com> On Wed, Aug 6, 2008 at 1:50 PM, Pat Maddox wrote: > I've had a matcher in my head for a couple months, that I frequently > want but never get around to writing because I can't think of the name > for it. Here's how it would look > > [1, 2, 3, 4, 1].should ... [1, 3, 1, 4, 2] > > I have a couple ideas for names, but I'll hold off on them so I don't > influence anyone's opinion. > > btw, I realize that .sort works in this case. But that's slightly > less clear than I'd like, and it doesn't work for non-Comparable > objects (like activerecords). [1, 2, 3, 4, 1].should consist_of([1, 3, 1, 4, 2]) Since consist means "to be composed or made up of", which matches the usage. To me it reads like, this thing should be made up of these other things. WDYT? -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From steve at fenestra.com Wed Aug 6 14:33:38 2008 From: steve at fenestra.com (Steve Schafer) Date: Wed, 06 Aug 2008 14:33:38 -0400 Subject: [rspec-users] Someone please name this matcher for me In-Reply-To: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> References: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> Message-ID: On Wed, 6 Aug 2008 13:50:27 -0400, you wrote: >I've had a matcher in my head for a couple months, that I frequently >want but never get around to writing because I can't think of the name >for it. Here's how it would look > >[1, 2, 3, 4, 1].should ... [1, 3, 1, 4, 2] An unordered collection with possibly multiple occurrences of its members is known in mathematics as a "multiset," or, informally, a "bag." -Steve From JDCOHEN at stoel.com Wed Aug 6 14:25:48 2008 From: JDCOHEN at stoel.com (Cohen, Joseph) Date: Wed, 6 Aug 2008 11:25:48 -0700 Subject: [rspec-users] Someone please name this matcher for me In-Reply-To: <85d99afe0808061115te21d16awcf8f4b40b527f0ee@mail.gmail.com> References: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> <85d99afe0808061115te21d16awcf8f4b40b527f0ee@mail.gmail.com> Message-ID: Consider: should_have_the_same_members_as -----Original Message----- From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Zach Dennis Sent: Wednesday, August 06, 2008 11:15 AM To: rspec-users Subject: Re: [rspec-users] Someone please name this matcher for me On Wed, Aug 6, 2008 at 1:50 PM, Pat Maddox wrote: > I've had a matcher in my head for a couple months, that I frequently > want but never get around to writing because I can't think of the name > for it. Here's how it would look > > [1, 2, 3, 4, 1].should ... [1, 3, 1, 4, 2] > > I have a couple ideas for names, but I'll hold off on them so I don't > influence anyone's opinion. > > btw, I realize that .sort works in this case. But that's slightly > less clear than I'd like, and it doesn't work for non-Comparable > objects (like activerecords). [1, 2, 3, 4, 1].should consist_of([1, 3, 1, 4, 2]) Since consist means "to be composed or made up of", which matches the usage. To me it reads like, this thing should be made up of these other things. WDYT? -- 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 From lists at ruby-forum.com Wed Aug 6 14:59:34 2008 From: lists at ruby-forum.com (Matt Wynne) Date: Wed, 6 Aug 2008 20:59:34 +0200 Subject: [rspec-users] Someone please name this matcher for me In-Reply-To: <85d99afe0808061115te21d16awcf8f4b40b527f0ee@mail.gmail.com> References: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> <85d99afe0808061115te21d16awcf8f4b40b527f0ee@mail.gmail.com> Message-ID: <623e6bb7c2dbfbe4289e3b6732686957@ruby-forum.com> How about [1, 2, 3, 4, 1].should contain([1, 3, 1, 4, 2]) [1, 2, 3, 4, 1].should contain_only([1, 3, 1, 4, 2]) or (riffing off Zach) [1, 2, 3, 4, 1].should be_composed_from([1, 3, 1, 4, 2]) Matt -- Posted via http://www.ruby-forum.com/. From jonathan at parkerhill.com Wed Aug 6 15:04:07 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Wed, 6 Aug 2008 15:04:07 -0400 Subject: [rspec-users] Someone please name this matcher for me In-Reply-To: References: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> Message-ID: .should be_bag_of( [1, 3, 1, 4, 2] ) On Aug 6, 2008, at 2:33 PM, Steve Schafer wrote: > On Wed, 6 Aug 2008 13:50:27 -0400, you wrote: > >> I've had a matcher in my head for a couple months, that I frequently >> want but never get around to writing because I can't think of the >> name >> for it. Here's how it would look >> >> [1, 2, 3, 4, 1].should ... [1, 3, 1, 4, 2] > > An unordered collection with possibly multiple occurrences of its > members is known in mathematics as a "multiset," or, informally, a > "bag." > > -Steve > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From tero at tilus.net Wed Aug 6 15:08:16 2008 From: tero at tilus.net (Tero Tilus) Date: Wed, 6 Aug 2008 22:08:16 +0300 Subject: [rspec-users] Someone please name this matcher for me In-Reply-To: References: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> Message-ID: <20080806190815.GA6404@uivelo.tilus.net> 2008-08-06 14:33, Steve Schafer: > An unordered collection with possibly multiple occurrences of its > members is known in mathematics as a "multiset," or, informally, a > "bag." I (standing knee-deep in mathematics) was about to offer the following be_multiset_equal_to be_set_equal_to Set equality is slightly (imo not fatally) incorrect, and multiset might be alien to majority of hackers out there. I'd prefer either of these or modifications. -- Tero Tilus ## 050 3635 235 ## http://www.tilus.net/koti/tero/ From tero at tilus.net Wed Aug 6 15:13:54 2008 From: tero at tilus.net (Tero Tilus) Date: Wed, 6 Aug 2008 22:13:54 +0300 Subject: [rspec-users] Someone please name this matcher for me In-Reply-To: <2386bfa00808061111m7970263dt6b902ad3ea4fac4f@mail.gmail.com> References: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> <2386bfa00808061111m7970263dt6b902ad3ea4fac4f@mail.gmail.com> Message-ID: <20080806191354.GB6404@uivelo.tilus.net> 2008-08-06 13:11, Mike Vincent: > > [1, 2, 3, 4, 1].should ... [1, 3, 1, 4, 2] > [1, 2, 3, 4, 1].should include_all [1, 3, 1, 4, 2] I'd then think that [1, 1, 1, 2, 3, 4].should include_all [1, 3, 1, 4, 2] [1, 2, 3, 4, 5, 6].should include_all [1, 3, 1, 4, 2] Which afaik was not what Pat had in mind. Or was it? And include_all_and_nothing_but is a bit verbose. :) -- Tero Tilus ## 050 3635 235 ## http://www.tilus.net/koti/tero/ From vertebrate at gmail.com Wed Aug 6 15:26:41 2008 From: vertebrate at gmail.com (Steve) Date: Wed, 06 Aug 2008 14:26:41 -0500 Subject: [rspec-users] hash_excluding/hash_only? In-Reply-To: <3c30da400808060937j6b801c80m960678f72772d578@mail.gmail.com> References: <3c30da400808060937j6b801c80m960678f72772d578@mail.gmail.com> Message-ID: Mark Wilden wrote: > On Wed, Aug 6, 2008 at 9:22 AM, Steve > > wrote: > > I know there is a hash_including, which is quite useful. Are there > by chance any matchers for ensuring a hash includes only the > specified values, or that it doesn't have certain values? > > > I'm just on my way out the door, but just wanted to say that if there > isn't, writing your own matcher is super easy. > > ///ark > Yeah, I just wanted to make sure the functionality didn't exist before I wrote my own. From dchelimsky at gmail.com Wed Aug 6 19:05:35 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 6 Aug 2008 18:05:35 -0500 Subject: [rspec-users] How to consolidate old_project/test/* with new_project/spec/*? In-Reply-To: References: Message-ID: <57c63afe0808061605s161b4bbesac57d84089e5f545@mail.gmail.com> On Wed, Aug 6, 2008 at 8:57 AM, Redd Vinylene wrote: > Hello everybody:) > > I'm new to this, but how should I go about consolidating > old_project/test/* with new_project/spec/*? > > Here is the contents of my old_project/test/* -- http://pastie.org/248453 > > Would I have to rewrite everything? In your test_helper.rb file, require 'spec' after requiring 'test/unit' and rspec will run your tests for you. Cheers, David > > Many thanks! > > -- > http://www.home.no/reddvinylene > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From grail at goldweb.com.au Wed Aug 6 20:46:02 2008 From: grail at goldweb.com.au (Alex Satrapa) Date: Thu, 7 Aug 2008 10:46:02 +1000 Subject: [rspec-users] Someone please name this matcher for me In-Reply-To: References: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> Message-ID: <7800A195-DE10-4707-9ECC-12E0430B024A@goldweb.com.au> On 07/08/2008, at 05:04 , Jonathan Linowes wrote: > .should be_bag_of( [1, 3, 1, 4, 2] ) FWIW, I am in favour of this naming. Now back to lurking :) From jony at jonysk.net Wed Aug 6 21:47:39 2008 From: jony at jonysk.net (Jony dos Santos Kostetzer) Date: Wed, 06 Aug 2008 22:47:39 -0300 Subject: [rspec-users] hash_excluding/hash_only? In-Reply-To: References: <3c30da400808060937j6b801c80m960678f72772d578@mail.gmail.com> Message-ID: <489A543B.7070906@jonysk.net> Steve wrote: > Mark Wilden wrote: >> On Wed, Aug 6, 2008 at 9:22 AM, Steve > > wrote: >> >> I know there is a hash_including, which is quite useful. Are there >> by chance any matchers for ensuring a hash includes only the >> specified values, or that it doesn't have certain values? >> How about using should_not to ensure it doesn't have these values? Jony >> >> I'm just on my way out the door, but just wanted to say that if there >> isn't, writing your own matcher is super easy. >> >> ///ark >> > > Yeah, I just wanted to make sure the functionality didn't exist before > I wrote my own. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From philodespotos at gmail.com Thu Aug 7 11:17:08 2008 From: philodespotos at gmail.com (Kyle Hargraves) Date: Thu, 7 Aug 2008 10:17:08 -0500 Subject: [rspec-users] Someone please name this matcher for me In-Reply-To: References: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> <85d99afe0808061115te21d16awcf8f4b40b527f0ee@mail.gmail.com> Message-ID: <60f3810c0808070817k56a2f762tbb0fc5d1b1502084@mail.gmail.com> On Wed, Aug 6, 2008 at 1:25 PM, Cohen, Joseph wrote: > > Consider: > should_have_the_same_members_as Similarly, I have a have_same_elements_as(arr) matcher. k From JDCOHEN at stoel.com Thu Aug 7 13:40:46 2008 From: JDCOHEN at stoel.com (Cohen, Joseph) Date: Thu, 7 Aug 2008 10:40:46 -0700 Subject: [rspec-users] Someone please name this matcher for me In-Reply-To: <60f3810c0808070817k56a2f762tbb0fc5d1b1502084@mail.gmail.com> References: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com><85d99afe0808061115te21d16awcf8f4b40b527f0ee@mail.gmail.com> <60f3810c0808070817k56a2f762tbb0fc5d1b1502084@mail.gmail.com> Message-ID: Lots of good, interesting suggestions. If you don't mind its length, for the non-mathematically inclined something like has_same_members_as may be easier to remember and corresponds to Ruby's member? predicate. -----Original Message----- From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Kyle Hargraves Sent: Thursday, August 07, 2008 8:17 AM To: rspec-users Subject: Re: [rspec-users] Someone please name this matcher for me On Wed, Aug 6, 2008 at 1:25 PM, Cohen, Joseph wrote: > > Consider: > should_have_the_same_members_as Similarly, I have a have_same_elements_as(arr) matcher. k _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Thu Aug 7 14:44:27 2008 From: lists at ruby-forum.com (Christian Lescuyer) Date: Thu, 7 Aug 2008 20:44:27 +0200 Subject: [rspec-users] Can't test for page content after a redirect Message-ID: <0671df537cb4aaf2dfecefbedd1be2a4@ruby-forum.com> I'm trying to verify that data entered in a form has been saved in the database. Scenario: User enters a bookmark URL Given a bookmark 'http://www.gotapi.com/rubyrails' When the user adds the bookmark Then should redirect to '/' And the page should contain 'http://www.gotapi.com/rubyrails' The first test (should redirect) passes. The second fails. I understand why: the page that is analysed is a dummy page "You are being redirected." Is it possible to check data in the second page? Cheers Xtian -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Thu Aug 7 14:54:48 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 7 Aug 2008 14:54:48 -0400 Subject: [rspec-users] Can't test for page content after a redirect In-Reply-To: <0671df537cb4aaf2dfecefbedd1be2a4@ruby-forum.com> References: <0671df537cb4aaf2dfecefbedd1be2a4@ruby-forum.com> Message-ID: <85d99afe0808071154v5b039b45u192866efcd949e5f@mail.gmail.com> On Thu, Aug 7, 2008 at 2:44 PM, Christian Lescuyer wrote: > I'm trying to verify that data entered in a form has been saved in the > database. > > Scenario: User enters a bookmark URL > Given a bookmark 'http://www.gotapi.com/rubyrails' > When the user adds the bookmark > Then should redirect to '/' > And the page should contain 'http://www.gotapi.com/rubyrails' > > The first test (should redirect) passes. The second fails. I understand > why: the page that is analysed is a dummy page "You are being > redirected." > > Is it possible to check data in the second page? What about something like: Scenario: User enters a bookmark URL Given I log in as a user When I add 'http://www.gotapi.com/rubyrails' as a bookmark Then I should see that has the 'http://www.gotapi.com/rubyrails' has been added to my bookmarks I'd imagine the steps to look something like: Given "I log in as a user" do # do whatever to login end When I add $url as a bookmark do |url| # fill out the new bookmmark form with the given url # after submitting form handle redirects follow_all_redirects end Then "I should see that has the $url has been added to my bookmarks" do |url| # response should have url somewhere on page end follow_all_redirects looks like: def follow_all_redirects if response.content_type == "text/html" follow_redirect! while response.redirect? elsif response.content_type == "text/javascript" if md=response.body.match(/window.location.href = "([^"]+)"/) get md.captures.first end end true end -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From lists at ruby-forum.com Thu Aug 7 17:07:27 2008 From: lists at ruby-forum.com (Christian Lescuyer) Date: Thu, 7 Aug 2008 23:07:27 +0200 Subject: [rspec-users] Can't test for page content after a redirect In-Reply-To: <85d99afe0808071154v5b039b45u192866efcd949e5f@mail.gmail.com> References: <0671df537cb4aaf2dfecefbedd1be2a4@ruby-forum.com> <85d99afe0808071154v5b039b45u192866efcd949e5f@mail.gmail.com> Message-ID: Thanks! I will try this tomorrow. Xtian -- Posted via http://www.ruby-forum.com/. From aidy.lewis at googlemail.com Fri Aug 8 10:18:28 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Fri, 8 Aug 2008 15:18:28 +0100 Subject: [rspec-users] embedding variable in a regex Message-ID: <7ac2300c0808080718r2687cf2blf4ef6439483dd9e7@mail.gmail.com> Given /a (PROGRAM|PROGRAMMES) title of '$title'/ do |title| .... end Could anyone give me the correct syntax for embedding this variable in a regex? Aidy From lists at ruby-forum.com Fri Aug 8 11:09:12 2008 From: lists at ruby-forum.com (Joseph Wilk) Date: Fri, 8 Aug 2008 17:09:12 +0200 Subject: [rspec-users] HTML Story Formatter In-Reply-To: <57c63afe0808052027p3d816a72l62d5a80d11d37b7@mail.gmail.com> References: <1216902734.7340.14.camel@tybalt> <57c63afe0807240544p5a8adc2keaa21aac0ca1fe0e@mail.gmail.com> <57c63afe0807250611p5a950d51icefc3c36829650f2@mail.gmail.com> <49733.98.202.34.115.1217111915.squirrel@mail.onticweb.com> <488DF668.8070301@benmabey.com> <747a4561e23c795b961245c283ea648f@ruby-forum.com> <57c63afe0808052027p3d816a72l62d5a80d11d37b7@mail.gmail.com> Message-ID: Hello, Hope you had a nice break David. I've been thinking about hidden backtraces in the html stories some more and I think having them carries little to no impact for the non-tech consumers of the stories. I think its similar to how we use Nagios. The business like to look at the nice red and green lights. When things go wrong they don't care why, they care if its red. The QA people of the other hand can use the same interface to see what went wrong. It feels a similar situation to that of the html stories. The key thing for me is that we still try and make the html story reports standalone. Fortunately a simple show hide is not going to require any external js libs. I'm happy to add some JS to my current patch to show/hide the backtrace when there is an error. As for a separate Formatter for developers, with the JS/backtrace dealt with perhaps until something dramatic comes about that swings the discussion we procrastinate? -- Joseph Wilk, http://www.joesniff.co.uk David Chelimsky wrote: > On Tue, Jul 29, 2008 at 2:28 PM, Joseph Wilk > wrote: >>> Ahh, good to know. Does that mean that the HTML isn't outputted until >>> all of the scenario's are ran for a particular story? >> >> Exactly. It made the html much nicer but did loose that per scenario >> output. I added a progress bar formatter so I could still get that >> direct scenario feedback, be it just a green dot or red F :) >> >> David are you happy with this html and dev-html formatter direction? If >> so I'll move this issue to lighthouse and start adding my patch. > > Sorry for the long silence on this - just got back from my first > "computer-free" vacation in some years. I recommend it to everyone > (though some may wish to prepare themselves for assorted withdrawal > symptoms). > > Anyhow - I'm not convinced one way or the other as to whether two > formatters for different audiences is better than a single html > formatter w/ some simple js to reveal backtraces. I can tell you from > my experience with FitNesse that the backtraces were sometimes > life-saving and sometimes simply annoying. Having the option to show > it but have it hidden on load would be nice. > > Anybody else wanna chime in on this? -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Fri Aug 8 11:20:52 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Fri, 8 Aug 2008 11:20:52 -0400 Subject: [rspec-users] embedding variable in a regex In-Reply-To: <7ac2300c0808080718r2687cf2blf4ef6439483dd9e7@mail.gmail.com> References: <7ac2300c0808080718r2687cf2blf4ef6439483dd9e7@mail.gmail.com> Message-ID: <85d99afe0808080820p668e01fcm1a196ca4a5630118@mail.gmail.com> On Fri, Aug 8, 2008 at 10:18 AM, aidy lewis wrote: > Given /a (PROGRAM|PROGRAMMES) title of '$title'/ do |title| > .... > end > > Could anyone give me the correct syntax for embedding this variable in a regex? You'll need to create a sub-expression capturing the title. Sub-expressions are denoted in a regular expression with parenthesizes. You already have one in your with (PROGRAM|PROGRAMMES). If your regex matched a given step the title would be either PROGRAM or PROGRAMMES depending on what the step description looked like. You probably want to use a non-matching sub-expression for PROGRAM|PROGRAMMES so it doesn't get captured (and thus passed in as a block parameter). Try this: Given /a (?:PROGRAM|PROGRAMMES) title of '([^']+)'/ do |title| end Which should match the step with the name Given "a PROGRAM title of 'foo bar baz thingy majoo'" -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From lists-rspec at shopwatch.org Fri Aug 8 11:20:53 2008 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Fri, 08 Aug 2008 11:20:53 -0400 Subject: [rspec-users] Stories run with "ruby", not "spec" Message-ID: <489C6455.5000000@shopwatch.org> Since there's no real documentation for stories yet, and since none of the blog posts about it ever show it being run, I thought some other newbie might find this useful information when they're Googling: You don't run RSpec stories with spec! You run them with ruby. For instance, in Ben Mabey's "animals" tutorial, at: http://www.benmabey.com/2008/02/04/rspec-plain-text-stories-webrat-chunky-bacon/ you run the example stories with ruby stories/animals_without_webrat.rb NOT spec stories/animals_without_webrat.rb I imagine this is in the screencasts, but I'm working with a developer who has no broadband, so I've been reading more than watching... So, yeah. Carry on. From jonathan at parkerhill.com Fri Aug 8 11:38:53 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Fri, 8 Aug 2008 11:38:53 -0400 Subject: [rspec-users] passing a hash in stories Message-ID: <9ED4A0EC-F9CA-4D0F-9134-41AFFC17BB28@parkerhill.com> Hi, Anyone have code you could share that lets you pass a hash in plain text stories, for example Then I fill out form with name: Jon, email: jon at mail.com, age: 9 passes in a hash { 'name' => 'Jon', 'emal' => 'jon at mail.com', 'age' => '9' } From lists-rspec at shopwatch.org Fri Aug 8 11:55:49 2008 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Fri, 08 Aug 2008 11:55:49 -0400 Subject: [rspec-users] RSpactor: Black is the new green? In-Reply-To: <12836674.201217855238019.JavaMail.andreas@hackmac.local> References: <12836674.201217855238019.JavaMail.andreas@hackmac.local> Message-ID: <489C6C85.6090109@shopwatch.org> Andreas Wolff wrote: > It took me a while to get the next release out, but I finally managed to release RSpactor 0.9.16, a Mac OS X RSpec runner. > > There are no new features but RSpactor should be a lot more stable and responsive now. If you want to have a look and download: http://rubyphunk.com/articles/2008/08/04/now-on-stock-rspactor-0-9-16/. Failing specs do show up as red, but passing ones show up as black in the lefthand drawer (though the "bar" is green in the main display pane) - known bug? Jay From lists-rspec at shopwatch.org Fri Aug 8 11:57:00 2008 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Fri, 08 Aug 2008 11:57:00 -0400 Subject: [rspec-users] Straw Poll: How are you using plain text stories (in rails)? In-Reply-To: References: Message-ID: <489C6CCC.5060206@shopwatch.org> Matt Wynne wrote: > Hi all, > > > What originally attracted me to rspec was hearing Dan North talk about > the plain text stories, and I had some fun in my previous life as a C# > programmer using them to drive watir tests of an ASP.NET app. > > What I'm not sure about is how they're most appropriately used in rails. I'm just getting back into RSpec, and stories are new to me. I'm finding a lot of inspiration from Ben Mabey's article/tutorial, which uses RSpec with webrat: http://www.benmabey.com/2008/02/04/rspec-plain-text-stories-webrat-chunky-bacon/ From lists-rspec at shopwatch.org Fri Aug 8 11:57:26 2008 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Fri, 08 Aug 2008 11:57:26 -0400 Subject: [rspec-users] Do you remember RSpactor? In-Reply-To: <12836674.201217855238019.JavaMail.andreas@hackmac.local> References: <12836674.201217855238019.JavaMail.andreas@hackmac.local> Message-ID: <489C6CE6.909@shopwatch.org> Andreas Wolff wrote: > It took me a while to get the next release out, but I finally managed to release RSpactor 0.9.16, a Mac OS X RSpec runner. > > There are no new features but RSpactor should be a lot more stable and responsive now. If you want to have a look and download: http://rubyphunk.com/articles/2008/08/04/now-on-stock-rspactor-0-9-16/. As a freaking idiot I want to see an error message (at least in system.log!) when RSpactor can't find "/usr/bin/spec" So that I can remember I'm a freaking idiot > > > bye > > -- > Andreas Wolff > DynamicDudes > > Lightweight Ruby on Rails application development > http://dynamicdudes.com > hire: +49 151 58 54 78 50 > > home: http://rubyphunk.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mark at mwilden.com Fri Aug 8 12:06:51 2008 From: mark at mwilden.com (Mark Wilden) Date: Fri, 8 Aug 2008 09:06:51 -0700 Subject: [rspec-users] Someone please name this matcher for me In-Reply-To: References: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> <85d99afe0808061115te21d16awcf8f4b40b527f0ee@mail.gmail.com> <60f3810c0808070817k56a2f762tbb0fc5d1b1502084@mail.gmail.com> Message-ID: <3c30da400808080906o424770a6hdb8206f45969d7fc@mail.gmail.com> is_permutation_of would be technically correct, but it doesn't really express equality to me, which is the intent of the match. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From dhruv at infochimps.org Fri Aug 8 12:18:21 2008 From: dhruv at infochimps.org (Dhruv Bansal) Date: Fri, 08 Aug 2008 12:18:21 -0400 Subject: [rspec-users] Someone please name this matcher for me In-Reply-To: <3c30da400808080906o424770a6hdb8206f45969d7fc@mail.gmail.com> (Mark Wilden's message of "Fri\, 8 Aug 2008 09\:06\:51 -0700") References: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> <85d99afe0808061115te21d16awcf8f4b40b527f0ee@mail.gmail.com> <60f3810c0808070817k56a2f762tbb0fc5d1b1502084@mail.gmail.com> <3c30da400808080906o424770a6hdb8206f45969d7fc@mail.gmail.com> Message-ID: <877iar5vle.fsf@silicon.austin.rr.com> i wrote this matcher myself for a project i'm working on and have been calling it `equals_without_regard_to_order'. it's an unwieldy name and i've never really been comfortable with it but i've continued to use it, mostly because i'm dim. very curious to find a winning replacement on this list! -- Dhruv Bansal http://www.infochimps.org || http://www.dhruvbansal.com || dhruv at infochimps.org "Mark Wilden" writes: > is_permutation_of would be technically correct, but it doesn't > really express equality to me, which is the intent of the match. > > ///ark > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mark at mwilden.com Fri Aug 8 13:11:20 2008 From: mark at mwilden.com (Mark Wilden) Date: Fri, 8 Aug 2008 10:11:20 -0700 Subject: [rspec-users] Do you remember RSpactor? In-Reply-To: <489C6CE6.909@shopwatch.org> References: <12836674.201217855238019.JavaMail.andreas@hackmac.local> <489C6CE6.909@shopwatch.org> Message-ID: <3c30da400808081011nda35541lf352072bafeca193@mail.gmail.com> I've been using RSpactor (the gem version, not the GUI) fairly happily for a month or so. However, when trying the GUI version out, it became clear that RSpactor loads things differently than 'rake spec'. Today, using the gem version, I found that I get a MissingSourceFile trying to require json. 'rake spec' works fine. So I'd suggest that RSpactor is not quite ready for primetime, in case anyone's thinking of using it. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Fri Aug 8 13:29:19 2008 From: lists at ruby-forum.com (Christian Lescuyer) Date: Fri, 8 Aug 2008 19:29:19 +0200 Subject: [rspec-users] Can't test for page content after a redirect In-Reply-To: <85d99afe0808071154v5b039b45u192866efcd949e5f@mail.gmail.com> References: <0671df537cb4aaf2dfecefbedd1be2a4@ruby-forum.com> <85d99afe0808071154v5b039b45u192866efcd949e5f@mail.gmail.com> Message-ID: Thanks Zach! It worked like a charm. Finally I used: Scenario: User enters a bookmark URL When the user adds 'http://www.gotapi.com/rubyrails' as a bookmark Then the database should have a bookmark with url 'http://www.gotapi.com/rubyrails' And the page should contain 'http://www.gotapi.com/rubyrails' and in bookmark_steps.rb: When "the user adds '$string' as a bookmark" do |string| post "/bookmarks/create", :bookmark => { :url => string } follow_all_redirects end Then "the database should have a bookmark with url '$url'" do |url| Bookmark.find_by_url(url).should_not be_nil end Then "the page should contain '$stuff'" do |stuff| response.should have_text(/#{stuff}/) end end def follow_all_redirects if response.content_type == "text/html" follow_redirect! while response.redirect? end true end I skipped the Javascript right now, I'll add it when the time comes. Xtian -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Fri Aug 8 13:43:06 2008 From: ben at benmabey.com (Ben Mabey) Date: Fri, 08 Aug 2008 11:43:06 -0600 Subject: [rspec-users] passing a hash in stories In-Reply-To: <9ED4A0EC-F9CA-4D0F-9134-41AFFC17BB28@parkerhill.com> References: <9ED4A0EC-F9CA-4D0F-9134-41AFFC17BB28@parkerhill.com> Message-ID: <489C85AA.7060509@benmabey.com> Jonathan Linowes wrote: > Hi, > Anyone have code you could share that lets you pass a hash in plain > text stories, > for example > > Then I fill out form with name: Jon, email: jon at mail.com, age: 9 > > passes in a hash { 'name' => 'Jon', 'emal' => 'jon at mail.com', 'age' => > '9' } > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Jonathan, You can do this, and I have done it in the past, but I wouldn't recommend it. Their are a couple of reasons why I would discourage it. The first is that by just posting a hash to the form's URL (like you would do in a controller spec) you are not verifying the existence of the form fields and thereby skipping the view layer of the stack. You can get around this by also checking the markup for the form fields like you would in a view spec. However, doing this becomes very tedious. A much better solution exists and that is webrat. Webrat offers a very nice interface that ends up verifying the existence of the form fields and doing the post for you. If you haven't looked into webrat then I would highly recommend it.[1] The other disadvantage of what you are doing is that you might be placing too much information in your stories. The danger of this is that you might end up with ugly stories with a lot of noise that end up drowning out the real 'signal' of the story. Additionally, every time you add a field to the form you will have to change the story. See my post about the different styles of writing styles to see an example of how you might rewrite it. [2] That said, I don't know your exact situation and what you are trying to do may very well be the best approach to it. So, the answer to your real question would be something like: # Pass the params as such: ISBN: '0967539854' and comment: 'I love this book' and rating: '4' # this matcher will post to the resourcese default create action When "$actor submits $a_or_an $resource with $attributes" do |actor, a_or_an, resource, attributes| post_via_redirect "/#{resource.downcase.pluralize}", {resource.downcase => attributes.to_hash_from_story} end class String # Coverts a string found in the steps into a hash. Example: # ISBN: '0967539854' and comment: 'I love this book' and rating: '4' # => {"rating"=>"4", "isbn"=>"0967539854", "comment"=>"I love this book"} def to_hash_from_story self.split(/, and |, /).inject({}){ |hash_so_far, key_value| key, value = key_value.split(":").map{ |v| v.strip.gsub(" ","_")} hash_so_far.merge(key.downcase => value.gsub("'","")) } end end To reiterate, I really do not like the pattern above. I started out doing stories like that ran into many problems with it. In short I think step reuse is overrated. I hope that helps, Ben [1] http://www.benmabey.com/2008/02/04/rspec-plain-text-stories-webrat-chunky-bacon/ [2] http://www.benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories/ From lists-rspec at shopwatch.org Fri Aug 8 16:12:43 2008 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Fri, 08 Aug 2008 16:12:43 -0400 Subject: [rspec-users] Someone please name this matcher for me In-Reply-To: <85d99afe0808061115te21d16awcf8f4b40b527f0ee@mail.gmail.com> References: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> <85d99afe0808061115te21d16awcf8f4b40b527f0ee@mail.gmail.com> Message-ID: <489CA8BB.2020705@shopwatch.org> Zach Dennis wrote: > > [1, 2, 3, 4, 1].should consist_of([1, 3, 1, 4, 2]) +1 From james2mccarthy at gmail.com Fri Aug 8 16:46:09 2008 From: james2mccarthy at gmail.com (J2M) Date: Fri, 8 Aug 2008 13:46:09 -0700 (PDT) Subject: [rspec-users] template.expect_render fails when partial is rendered from a helper Message-ID: My spec; describe 'subnav rendering while logged in' do before do template.stub!(:logged_in?).and_return(true) template.stub! (:current_profile).at_least(:once).and_return(mock_profile) end def do_render render "/homepages/show.html.erb" end it "should render the logged in partial for homepages" do template.expect_render(:partial => 'shared/subnav/home', :locals => {:active => :home}) do_render end end passes if I render the partial directly in the view, render :partial => 'shared/subnav/home', :locals => {:active => :home} but it fails if the partial is rendered by a helper; module ApplicationHelper def subnav(partial, args={}) active = args[:active] || :no_highlight if partial == :home partial = (logged_in? ? 'home' : 'login') end render :partial => "shared/subnav/#{partial}", :locals => {:active => active} end end Is there any way to check whether the helper renders it? From jonathan at parkerhill.com Fri Aug 8 17:36:57 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Fri, 8 Aug 2008 17:36:57 -0400 Subject: [rspec-users] passing a hash in stories In-Reply-To: <489C85AA.7060509@benmabey.com> References: <9ED4A0EC-F9CA-4D0F-9134-41AFFC17BB28@parkerhill.com> <489C85AA.7060509@benmabey.com> Message-ID: <87EDEEDD-64C3-49B6-A6EC-423498B64B71@parkerhill.com> Thanks, I'll give the snippet a try. My intent is not to pass the hash to the post directly, but to fill form fields using webrat. Just i want a resusable step for filling out the form with different values. Similarly I'll use the hash parser for checking row cells in a list view, etc On Aug 8, 2008, at 1:43 PM, Ben Mabey wrote: > Jonathan Linowes wrote: >> Hi, >> Anyone have code you could share that lets you pass a hash in >> plain text stories, >> for example >> >> Then I fill out form with name: Jon, email: jon at mail.com, age: 9 >> >> passes in a hash { 'name' => 'Jon', 'emal' => 'jon at mail.com', >> 'age' => '9' } >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > Jonathan, > You can do this, and I have done it in the past, but I wouldn't > recommend it. Their are a couple of reasons why I would discourage > it. The first is that by just posting a hash to the form's URL > (like you would do in a controller spec) you are not verifying the > existence of the form fields and thereby skipping the view layer of > the stack. You can get around this by also checking the markup for > the form fields like you would in a view spec. However, doing this > becomes very tedious. A much better solution exists and that is > webrat. Webrat offers a very nice interface that ends up verifying > the existence of the form fields and doing the post for you. If > you haven't looked into webrat then I would highly recommend it.[1] > > The other disadvantage of what you are doing is that you might be > placing too much information in your stories. The danger of this > is that you might end up with ugly stories with a lot of noise that > end up drowning out the real 'signal' of the story. Additionally, > every time you add a field to the form you will have to change the > story. See my post about the different styles of writing styles to > see an example of how you might rewrite it. [2] > > That said, I don't know your exact situation and what you are > trying to do may very well be the best approach to it. So, the > answer to your real question would be something like: > > > # Pass the params as such: ISBN: '0967539854' and comment: 'I love > this book' and rating: '4' > # this matcher will post to the resourcese default create action > When "$actor submits $a_or_an $resource with $attributes" do | > actor, a_or_an, resource, attributes| > post_via_redirect "/#{resource.downcase.pluralize}", > {resource.downcase => attributes.to_hash_from_story} > end > > class String > # Coverts a string found in the steps into a hash. Example: > # ISBN: '0967539854' and comment: 'I love this book' and rating: '4' > # => {"rating"=>"4", "isbn"=>"0967539854", "comment"=>"I love > this book"} > def to_hash_from_story > self.split(/, and |, /).inject({}){ |hash_so_far, key_value| > key, value = > key_value.split(":").map{ |v| v.strip.gsub(" ","_")} > hash_so_far.merge > (key.downcase => value.gsub("'","")) > } > end > end > > To reiterate, I really do not like the pattern above. I started > out doing stories like that ran into many problems with it. In > short I think step reuse is overrated. > > I hope that helps, > Ben > > > [1] http://www.benmabey.com/2008/02/04/rspec-plain-text-stories- > webrat-chunky-bacon/ > [2] http://www.benmabey.com/2008/05/19/imperative-vs-declarative- > scenarios-in-user-stories/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Sat Aug 9 11:33:30 2008 From: lists at ruby-forum.com (Jd Roberts) Date: Sat, 9 Aug 2008 17:33:30 +0200 Subject: [rspec-users] Keep getting respond_to? errors In-Reply-To: <4908C456-6054-4384-A77F-EED9A6169AE7@railsnewbie.com> References: <7e565b5c0808041455m604fa7b0g4bf541d9be2d9212@mail.gmail.com> <4908C456-6054-4384-A77F-EED9A6169AE7@railsnewbie.com> Message-ID: <809154ea504d7787b710684e42870014@ruby-forum.com> > Are you running under drb? Autotest? What version of rspec? rails? > > I'm almost certain this is a rails loading bug...Are you requiring > anywhere? What is the value of config.cache_classes in your test.rb? Same prob. Passing tests pass, and the first failing test fails correctly... but ever afterwards the permanent 'respond_to?' error plagues me until I restart autotest Running autotest with Rspec -v 1.1.4 and rails 2.1.0 no special requiring (except spec_helper at the top, of course) and config.cache_classes is true I tried setting config.cache_classes to false, but that didn't change the above countdown to FAIL :/ -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sun Aug 10 12:03:00 2008 From: lists at ruby-forum.com (Jesse Crockett) Date: Sun, 10 Aug 2008 18:03:00 +0200 Subject: [rspec-users] First encounter with RSpec, please help Message-ID: Hello, I'm working on a feature of insoshi to limit daily connection requests, using a boolean and integer value set by the admin. The feature works fine, but causes 11 failures in `rake spec', not to mention the two or three tests for the new variables yet to be written. Here is the existing connection_spec, followed by connections_controller_spec ## require File.dirname(__FILE__) + '/../spec_helper' describe Connection do before(:each) do @emails = ActionMailer::Base.deliveries @emails.clear @global_prefs = Preference.find(:first) @person = people(:quentin) @contact = people(:aaron) end describe "class methods" do it "should create a request" do Connection.request(@person, @contact) status(@person, @contact).should == Connection::PENDING status(@contact, @person).should == Connection::REQUESTED end # abridged ### connections_controller_spec require File.dirname(__FILE__) + '/../spec_helper' describe ConnectionsController do integrate_views before(:each) do @person = login_as(:quentin) @contact = people(:aaron) end it "should protect the create page" do logout post :create response.should redirect_to(login_url) end it "should create a new connection request" do Connection.should_receive(:request).with(@person, @contact). and_return(true) post :create, :person_id => @contact response.should redirect_to(home_url) end # abridged The two vars needed can be accessed in the connection_spec with @global_prefs.limit_requests and @global_prefs.daily_request_limit Please help me clear this problem. The errors from `rake spec' -- 1) Spec::Mocks::MockExpectationError in 'ConnectionsController should create a new connection request' Mock 'Class' expected :request with (I'm Quentin, I'm Aaron) once, but received it 0 times ./spec/controllers/connections_controller_spec.rb:18: 2) 'SearchesController Forum post searches should render with a topic link' FAILED Expected at least 1 element matching "a[href='/forums/953125641/topics/953125641#post_119261968']", found 0. is not true. ./spec/controllers/searches_controller_spec.rb:174: 3) 'SearchesController Forum post searches should render with a post div' FAILED Expected at least 1 element matching "div[class='forum']", found 0. is not true. ./spec/controllers/searches_controller_spec.rb:167: 4) 'SearchesController Forum post searches should search by topic name' FAILED Expected array to include # ./spec/controllers/searches_controller_spec.rb:162: 5) 'SearchesController Forum post searches should search by post body' FAILED Expected array to include # ./spec/controllers/searches_controller_spec.rb:148: 6) 'SearchesController Message searches should search by content' FAILED Expected array to include # ./spec/controllers/searches_controller_spec.rb:123: 7) 'SearchesController Message searches should search by subject' FAILED Expected array to include # ./spec/controllers/searches_controller_spec.rb:118: 8) 'SearchesController Person searches as an admin should return email unverified users' FAILED Expected array to include # ./spec/controllers/searches_controller_spec.rb:104: 9) 'SearchesController Person searches as an admin should return deactivated users' FAILED Expected array to include # ./spec/controllers/searches_controller_spec.rb:96: 10) 'SearchesController Person searches should search by description' FAILED expected: [#], got: [] (using ==) ./spec/controllers/searches_controller_spec.rb:64: 11) 'SearchesController Person searches should search by name' FAILED expected: [#], got: [] (using ==) ./spec/controllers/searches_controller_spec.rb:59: Finished in 11.488971 seconds 366 examples, 11 failures -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Sun Aug 10 18:24:29 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 10 Aug 2008 17:24:29 -0500 Subject: [rspec-users] First encounter with RSpec, please help In-Reply-To: References: Message-ID: <57c63afe0808101524n799bc6f0o4b3fa99b1fb0e856@mail.gmail.com> On Sun, Aug 10, 2008 at 11:03 AM, Jesse Crockett wrote: > Hello, I'm working on a feature of insoshi to limit daily connection > requests, using a boolean and integer value set by the admin. The > feature works fine, but causes 11 failures in `rake spec', not to > mention the two or three tests for the new variables yet to be written. > > Here is the existing connection_spec, followed by > connections_controller_spec > > ## > > require File.dirname(__FILE__) + '/../spec_helper' > > describe Connection do > > before(:each) do > @emails = ActionMailer::Base.deliveries > @emails.clear > @global_prefs = Preference.find(:first) > > @person = people(:quentin) > @contact = people(:aaron) > end > > describe "class methods" do > > it "should create a request" do > Connection.request(@person, @contact) > status(@person, @contact).should == Connection::PENDING > status(@contact, @person).should == Connection::REQUESTED > end > > # abridged > > ### > connections_controller_spec > > require File.dirname(__FILE__) + '/../spec_helper' > > describe ConnectionsController do > integrate_views > > before(:each) do > @person = login_as(:quentin) > @contact = people(:aaron) > end > > it "should protect the create page" do > logout > post :create > response.should redirect_to(login_url) > end > > it "should create a new connection request" do > Connection.should_receive(:request).with(@person, @contact). > and_return(true) > post :create, :person_id => @contact > response.should redirect_to(home_url) > end > > # abridged > > The two vars needed can be accessed in the connection_spec with > @global_prefs.limit_requests and @global_prefs.daily_request_limit > > Please help me clear this problem. Please post the code for Connection and Controller as well. > > The errors from `rake spec' -- > > 1) > Spec::Mocks::MockExpectationError in 'ConnectionsController should > create a new connection request' > Mock 'Class' expected :request with (I'm Quentin, I'm Aaron) once, but > received it 0 times > ./spec/controllers/connections_controller_spec.rb:18: > > 2) > 'SearchesController Forum post searches should render with a topic link' > FAILED > Expected at least 1 element matching > "a[href='/forums/953125641/topics/953125641#post_119261968']", found 0. > is not true. > ./spec/controllers/searches_controller_spec.rb:174: > > 3) > 'SearchesController Forum post searches should render with a post div' > FAILED > Expected at least 1 element matching "div[class='forum']", found 0. > is not true. > ./spec/controllers/searches_controller_spec.rb:167: > > 4) > 'SearchesController Forum post searches should search by topic name' > FAILED > Expected array to include # > ./spec/controllers/searches_controller_spec.rb:162: > > 5) > 'SearchesController Forum post searches should search by post body' > FAILED > Expected array to include # > ./spec/controllers/searches_controller_spec.rb:148: > > 6) > 'SearchesController Message searches should search by content' FAILED > Expected array to include # > ./spec/controllers/searches_controller_spec.rb:123: > > 7) > 'SearchesController Message searches should search by subject' FAILED > Expected array to include # > ./spec/controllers/searches_controller_spec.rb:118: > > 8) > 'SearchesController Person searches as an admin should return email > unverified users' FAILED > Expected array to include # > ./spec/controllers/searches_controller_spec.rb:104: > > 9) > 'SearchesController Person searches as an admin should return > deactivated users' FAILED > Expected array to include # > ./spec/controllers/searches_controller_spec.rb:96: > > 10) > 'SearchesController Person searches should search by description' FAILED > expected: [# "Quentin", remember_token: nil, crypted_password: > "tiM81jP/bSzxdKEpRXyd0osc/N9hXVDPQutJ7ZxsJCyKoXIRuBa...", description: > "I'm Quentin", remember_token_expires_at: nil, last_contacted_at: nil, > last_logged_in_at: "2008-08-10 10:19:06", forum_posts_count: 0, > blog_post_comments_count: 0, wall_comments_count: 0, created_at: > "2008-08-05 10:19:00", updated_at: "2008-08-10 10:19:06", admin: false, > deactivated: false, connection_notifications: true, > message_notifications: true, wall_comment_notifications: true, > blog_comment_notifications: true, email_verified: true>], > got: [] (using ==) > ./spec/controllers/searches_controller_spec.rb:64: > > 11) > 'SearchesController Person searches should search by name' FAILED > expected: [# "Quentin", remember_token: nil, crypted_password: > "tiM81jP/bSzxdKEpRXyd0osc/N9hXVDPQutJ7ZxsJCyKoXIRuBa...", description: > "I'm Quentin", remember_token_expires_at: nil, last_contacted_at: nil, > last_logged_in_at: "2008-08-10 10:19:06", forum_posts_count: 0, > blog_post_comments_count: 0, wall_comments_count: 0, created_at: > "2008-08-05 10:19:00", updated_at: "2008-08-10 10:19:06", admin: false, > deactivated: false, connection_notifications: true, > message_notifications: true, wall_comment_notifications: true, > blog_comment_notifications: true, email_verified: true>], > got: [] (using ==) > ./spec/controllers/searches_controller_spec.rb:59: > > Finished in 11.488971 seconds > > 366 examples, 11 failures From lists at ruby-forum.com Sun Aug 10 19:22:29 2008 From: lists at ruby-forum.com (Jesse Crockett) Date: Mon, 11 Aug 2008 01:22:29 +0200 Subject: [rspec-users] First encounter with RSpec, please help In-Reply-To: <57c63afe0808101524n799bc6f0o4b3fa99b1fb0e856@mail.gmail.com> References: <57c63afe0808101524n799bc6f0o4b3fa99b1fb0e856@mail.gmail.com> Message-ID: Connection # == Schema Information # Schema version: 26 # # Table name: connections # # id :integer(11) not null, primary key # person_id :integer(11) # contact_id :integer(11) # status :integer(11) # accepted_at :datetime # created_at :datetime # updated_at :datetime # class Connection < ActiveRecord::Base extend ActivityLogger extend PreferencesHelper belongs_to :person belongs_to :contact, :class_name => "Person", :foreign_key => "contact_id" has_many :activities, :foreign_key => "item_id", :dependent => :destroy validates_presence_of :person_id, :contact_id # Status codes. ACCEPTED = 0 REQUESTED = 1 PENDING = 2 # Accept a connection request (instance method). # Each connection is really two rows, so delegate this method # to Connection.accept to wrap the whole thing in a transaction. def accept Connection.accept(person_id, contact_id) end def breakup Connection.breakup(person_id, contact_id) end class << self # Return true if the persons are (possibly pending) connections. def exists?(person, contact) not conn(person, contact).nil? end alias exist? exists? # Make a pending connection request. def request(person, contact, send_mail = nil) if send_mail.nil? send_mail = global_prefs.email_notifications? && contact.connection_notifications? end if person == contact or Connection.exists?(person, contact) nil else transaction do create(:person => person, :contact => contact, :status => PENDING) create(:person => contact, :contact => person, :status => REQUESTED) end if send_mail # The order here is important: the mail is sent *to* the contact, # so the connection should be from the contact's point of view. connection = conn(contact, person) PersonMailer.deliver_connection_request(connection) end true end end # Accept a connection request. def accept(person, contact) transaction do accepted_at = Time.now accept_one_side(person, contact, accepted_at) accept_one_side(contact, person, accepted_at) end log_activity(conn(person, contact)) end def connect(person, contact, send_mail = nil) transaction do request(person, contact, send_mail) accept(person, contact) end conn(person, contact) end # Delete a connection or cancel a pending request. def breakup(person, contact) transaction do destroy(conn(person, contact)) destroy(conn(contact, person)) end end # Return a connection based on the person and contact. def conn(person, contact) find_by_person_id_and_contact_id(person, contact) end def accepted?(person, contact) conn(person, contact).status == ACCEPTED end def connected?(person, contact) exist?(person, contact) and accepted?(person, contact) end end private class << self # Update the db with one side of an accepted connection request. def accept_one_side(person, contact, accepted_at) conn = conn(person, contact) conn.update_attributes!(:status => ACCEPTED, :accepted_at => accepted_at) end def log_activity(conn) activity = Activity.create!(:item => conn, :person => conn.person) add_activities(:activity => activity, :person => conn.person) add_activities(:activity => activity, :person => conn.contact) end end end Controller class ConnectionsController < ApplicationController before_filter :login_required, :setup before_filter :authorize_view, :only => :index before_filter :authorize_person, :only => [:edit, :update, :destroy] before_filter :redirect_for_inactive, :only => [:edit, :update] # Show all the contacts for a person. def index @contacts = @person.contacts.paginate(:page => params[:page], :per_page => RASTER_PER_PAGE) end def edit @contact = @connection.contact end def create @contact = Person.find(params[:person_id]) respond_to do |format| if can_request? and Connection.request(current_person, @contact) flash[:notice] = 'Connection request sent!' format.html { redirect_to(home_url) } else # This should only happen when people exceed daily request limit # or something funky like friending themselves. flash[:notice] = "Invalid connection or exceeds daily \ request limit (#{Preference.find(:first).daily_request_limit})." format.html { redirect_to(home_url) } end end end # validate against admin daily connection request limit def can_request? @requests_limited = Preference.find(:first).limit_requests @limit = Preference.find(:first).daily_request_limit if @requests_limited @list = Connection.find_all_by_person_id_and_status(current_person, Connection::PENDING, :order => 'created_at desc') if @limit == 0 false elsif not @list[@limit - 1].nil? @list[@limit - 1].created_at < 1.day.ago else true end end end def update respond_to do |format| contact = @connection.contact name = contact.name case params[:commit] when "Accept" @connection.accept flash[:notice] = %(Accepted connection with #{name}) when "Decline" @connection.breakup flash[:notice] = "Declined connection with #{name}" end format.html { redirect_to(home_url) } end end def destroy @connection.breakup respond_to do |format| flash[:success] = "Ended connection with #{@connection.contact.name}" format.html { redirect_to( person_connections_url(current_person)) } end end private def setup # Connections have same body class as profiles. @body = "profile" end def authorize_view @person = Person.find(params[:person_id]) unless (current_person?(@person) or Connection.connected?(@person, current_person)) redirect_to home_url end end # Make sure the current person is correct for this connection. def authorize_person @connection = Connection.find(params[:id], :include => [:person, :contact]) unless current_person?(@connection.person) flash[:error] = "Invalid connection." redirect_to home_url end rescue ActiveRecord::RecordNotFound flash[:error] = "Invalid or expired connection request" redirect_to home_url end # Redirect if the target person is inactive. # Suppose Alice sends Bob a connection request, but then the admin # deactivates Alice. We don't want Bob to be able to make the connection. def redirect_for_inactive if @connection.contact.deactivated? flash[:error] = "Invalid connection request: person deactivated" redirect_to home_url end end end Error 1) Spec::Mocks::MockExpectationError in 'ConnectionsController should create a new connection request' Mock 'Class' expected :request with (I'm Quentin, I'm Aaron) once, but received it 0 times ./spec/controllers/connections_controller_spec.rb:18: Finished in 10.707133 seconds David Chelimsky wrote: > On Sun, Aug 10, 2008 at 11:03 AM, Jesse Crockett > wrote: >> require File.dirname(__FILE__) + '/../spec_helper' >> end >> >> @contact = people(:aaron) >> and_return(true) >> post :create, :person_id => @contact >> response.should redirect_to(home_url) >> end >> >> # abridged >> >> The two vars needed can be accessed in the connection_spec with >> @global_prefs.limit_requests and @global_prefs.daily_request_limit >> >> Please help me clear this problem. > > Please post the code for Connection and Controller as well. -- Posted via http://www.ruby-forum.com/. From twscannell at gmail.com Mon Aug 11 00:59:25 2008 From: twscannell at gmail.com (Teedub) Date: Sun, 10 Aug 2008 21:59:25 -0700 (PDT) Subject: [rspec-users] Confused about square bracket usage. Message-ID: I ran script/generate rspec_scaffold page title:string body:text and have been reading on the generated code in my spare time in an attempt to fully understand rspec. It mostly makes a lot of sense except for the square brackets in the snippet below. To my best understanding, [mock_page] would be an array containing mock_page. That almost makes sense, buy why wouldn't the variable mock_page simply be an array like @pages. You wouldn't say [@pages]. I can't get my head wrapped around the syntax. Thanks in advance. pages_controller_spec.rb def mock_page(stubs={}) @mock_page ||= mock_model(Page, stubs) end describe "responding to GET index" do it "should expose all pages as @pages" do Page.should_receive(:find).with(:all).and_return([mock_page]) get :index assigns[:pages].should == [mock_page] end From steve at deepsalt.com Mon Aug 11 02:32:18 2008 From: steve at deepsalt.com (Steve Eley) Date: Mon, 11 Aug 2008 02:32:18 -0400 Subject: [rspec-users] Confused about square bracket usage. In-Reply-To: References: Message-ID: <74243c220808102332j3bc50b09w66bd9149555539ef@mail.gmail.com> On Mon, Aug 11, 2008 at 12:59 AM, Teedub wrote: > To my best understanding, > [mock_page] would be an array containing mock_page. That almost makes > sense, buy why wouldn't the variable mock_page simply be an array like > @pages. What you say is completely correct. In the code you give, mock_page is defined as singular. It represents a single mock instance of a Page model. It isn't an array because it isn't defined that way. But you can (and do) *put* it in an array to represent a collection of instances of the Page model. > You wouldn't say [@pages]. No, you usually wouldn't (though you could). But if you had a @page variable that represented just one Page, it would be quite sensible and common to say @pages == [@page]. That's really all that mock_page is doing. -- Have Fun, Steve Eley Deep Salt Team From yura at brainhouse.ru Mon Aug 11 03:05:00 2008 From: yura at brainhouse.ru (Yury Kotlyarov) Date: Mon, 11 Aug 2008 11:05:00 +0400 Subject: [rspec-users] calls with block in views Message-ID: <489FE49C.5030104@brainhouse.ru> Hi! I have a view: <% restrict_to 'admin' do %>
<%= render :partial => 'detail' %>
<% end %> What's the best way to spec view in this case - I just want to yield block in restrict_to call. Thanks in advance, Yury From dchelimsky at gmail.com Mon Aug 11 06:46:22 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 11 Aug 2008 05:46:22 -0500 Subject: [rspec-users] calls with block in views In-Reply-To: <489FE49C.5030104@brainhouse.ru> References: <489FE49C.5030104@brainhouse.ru> Message-ID: <57c63afe0808110346t41ba05faxb7b791689c7d847@mail.gmail.com> On Mon, Aug 11, 2008 at 2:05 AM, Yury Kotlyarov wrote: > Hi! > > I have a view: > > <% restrict_to 'admin' do %> >
> <%= render :partial => 'detail' %> >
> <% end %> > > What's the best way to spec view in this case - I just want to yield block > in restrict_to call. Here's one way: it "should render detail for admin" do template.should_receive(:restrict_to).with('admin').and_yield template.expect_render(:partial => 'detail') render 'path/to/view' end it "should not render detail for non-admin" do template.should_receive(:restrict_to).with('admin') template.expect_render(:partial => 'detail').never render 'path/to/view' end Cheers, David > > Thanks in advance, > Yury > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Mon Aug 11 10:24:09 2008 From: lists at ruby-forum.com (Matt Wynne) Date: Mon, 11 Aug 2008 16:24:09 +0200 Subject: [rspec-users] Someone please name this matcher for me In-Reply-To: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> References: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> Message-ID: <496c5cda671dafee6fde2a4b2808c9b6@ruby-forum.com> Would such a matcher also work in this instance: Car.should_receive(:find).with(bag_of[@ford.id, @fiat.id]) Such that if I don't know (or care) what order the IDs will be passed to the find method, this will pass? Or is there already some other way to achieve that? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Mon Aug 11 14:27:26 2008 From: lists at ruby-forum.com (John Mark) Date: Mon, 11 Aug 2008 20:27:26 +0200 Subject: [rspec-users] find_all_by returning nil Message-ID: The statement products = find_all_by_category_id(category_id) in the Product model is returning nil with rspec. I am expecting it to to return value for the stub that I provided it with. It does not also work with fixtures. Product model def self.find_all_meeting_some_criteria_for_category(category_id) products = find_all_by_category_id(category_id) products.each do |product| .... end end Product spec it "should find products given a category" do product = mock_model(Product, :id => 1, :category_id => 1) Product.stub(!find_all_by_category_id).with(anything()).and_return([product]) Product.should_receive(:find_all_meeting_some_criteria_for_category).with(product.category_id) end -- Posted via http://www.ruby-forum.com/. From cdemyanovich at gmail.com Mon Aug 11 14:31:28 2008 From: cdemyanovich at gmail.com (Craig Demyanovich) Date: Mon, 11 Aug 2008 14:31:28 -0400 Subject: [rspec-users] find_all_by returning nil In-Reply-To: References: Message-ID: <61c885db0808111131g76bc3542h92f86a88f04533fc@mail.gmail.com> Looks like this line Product.stub(!find_all_by_category_id).with(anything()).and_return([product]) might be the culprit. It should be stub!(find... instead of stub(!find.... Regards, Craig -------------- next part -------------- An HTML attachment was scrubbed... URL: From mauricio.linhares at gmail.com Mon Aug 11 14:32:29 2008 From: mauricio.linhares at gmail.com (=?ISO-8859-1?Q?Maur=EDcio_Linhares?=) Date: Mon, 11 Aug 2008 15:32:29 -0300 Subject: [rspec-users] find_all_by returning nil In-Reply-To: <61c885db0808111131g76bc3542h92f86a88f04533fc@mail.gmail.com> References: <61c885db0808111131g76bc3542h92f86a88f04533fc@mail.gmail.com> Message-ID: And i think that stubbed classes or objects can not access the database. On Mon, Aug 11, 2008 at 3:31 PM, Craig Demyanovich wrote: > Looks like this line > > Product.stub(!find_all_by_category_id).with(anything()).and_return([product]) > > might be the culprit. It should be stub!(find... instead of stub(!find.... > > Regards, > Craig -- Maur?cio Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) Jo?o Pessoa, PB, +55 83 8867-7208 From dchelimsky at gmail.com Mon Aug 11 14:30:28 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 11 Aug 2008 13:30:28 -0500 Subject: [rspec-users] find_all_by returning nil In-Reply-To: References: Message-ID: <57c63afe0808111130t29c8e665k78c1214c363d2f23@mail.gmail.com> On Mon, Aug 11, 2008 at 1:27 PM, John Mark wrote: > The statement > products = find_all_by_category_id(category_id) > in the Product model is returning nil with rspec. > I am expecting it to to return value for the stub that I provided it > with. It does > not also work with fixtures. > > > Product model > > def self.find_all_meeting_some_criteria_for_category(category_id) > products = find_all_by_category_id(category_id) > products.each do |product| > .... > end > end > > Product spec > > it "should find products given a category" do > product = mock_model(Product, :id => 1, :category_id => 1) > Product.stub(!find_all_by_category_id).with(anything()).and_return([product]) Try this: Product.stub!(:find_all_by_category_id).with(anything()).and_return([product]) > Product.should_receive(:find_all_meeting_some_criteria_for_category).with(product.category_id) > end > -- > 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 Mon Aug 11 14:32:32 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 11 Aug 2008 13:32:32 -0500 Subject: [rspec-users] find_all_by returning nil In-Reply-To: <61c885db0808111131g76bc3542h92f86a88f04533fc@mail.gmail.com> References: <61c885db0808111131g76bc3542h92f86a88f04533fc@mail.gmail.com> Message-ID: <57c63afe0808111132kef556c8l3b2e7eeb17a61535@mail.gmail.com> On Mon, Aug 11, 2008 at 1:31 PM, Craig Demyanovich wrote: > Looks like this line > > Product.stub(!find_all_by_category_id).with(anything()).and_return([product]) > > might be the culprit. It should be stub!(find... instead of stub(!find.... Actually, stub!(:find.... > > Regards, > Craig > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Mon Aug 11 14:47:31 2008 From: lists at ruby-forum.com (John Mark) Date: Mon, 11 Aug 2008 20:47:31 +0200 Subject: [rspec-users] find_all_by returning nil In-Reply-To: <57c63afe0808111132kef556c8l3b2e7eeb17a61535@mail.gmail.com> References: <61c885db0808111131g76bc3542h92f86a88f04533fc@mail.gmail.com> <57c63afe0808111132kef556c8l3b2e7eeb17a61535@mail.gmail.com> Message-ID: <9b25e3a5006d7fed4dac2544b01f5ca6@ruby-forum.com> David Chelimsky wrote: > On Mon, Aug 11, 2008 at 1:31 PM, Craig Demyanovich > wrote: >> Looks like this line >> >> Product.stub(!find_all_by_category_id).with(anything()).and_return([product]) >> >> might be the culprit. It should be stub!(find... instead of stub(!find.... > > Actually, stub!(:find.... Sorry that was a typo Its actually stub! in my code -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Mon Aug 11 14:51:17 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 11 Aug 2008 13:51:17 -0500 Subject: [rspec-users] find_all_by returning nil In-Reply-To: <9b25e3a5006d7fed4dac2544b01f5ca6@ruby-forum.com> References: <61c885db0808111131g76bc3542h92f86a88f04533fc@mail.gmail.com> <57c63afe0808111132kef556c8l3b2e7eeb17a61535@mail.gmail.com> <9b25e3a5006d7fed4dac2544b01f5ca6@ruby-forum.com> Message-ID: <57c63afe0808111151v62d9707es26b8af9d725c6496@mail.gmail.com> On Mon, Aug 11, 2008 at 1:47 PM, John Mark wrote: > David Chelimsky wrote: >> On Mon, Aug 11, 2008 at 1:31 PM, Craig Demyanovich >> wrote: >>> Looks like this line >>> >>> Product.stub(!find_all_by_category_id).with(anything()).and_return([product]) >>> >>> might be the culprit. It should be stub!(find... instead of stub(!find.... >> >> Actually, stub!(:find.... > > Sorry that was a typo > > Its actually stub! in my code The original example doesn't seem to do anything: it "should find products given a category" do product = mock_model(Product, :id => 1, :category_id => 1) Product.stub(!find_all_by_category_id).with(anything()).and_return([product]) Product.should_receive(:find_all_meeting_some_criteria_for_category).with(product.category_id) end It just sets up some objects but never actually calls an action. What is the error message you're getting? From lists at ruby-forum.com Mon Aug 11 15:23:09 2008 From: lists at ruby-forum.com (Joseph Wilk) Date: Mon, 11 Aug 2008 21:23:09 +0200 Subject: [rspec-users] Someone please name this matcher for me In-Reply-To: <496c5cda671dafee6fde2a4b2808c9b6@ruby-forum.com> References: <810a540e0808061050q47f61590rc8f6eda3a7b80a96@mail.gmail.com> <496c5cda671dafee6fde2a4b2808c9b6@ruby-forum.com> Message-ID: <440e6659879a800ef15aba7d7ad4c020@ruby-forum.com> On 07/08/2008, at 05:04 , Jonathan Linowes wrote: > .should be_bag_of( [1, 3, 1, 4, 2] ) +1 -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Mon Aug 11 15:49:19 2008 From: lists at ruby-forum.com (John Mark) Date: Mon, 11 Aug 2008 21:49:19 +0200 Subject: [rspec-users] find_all_by returning nil In-Reply-To: <57c63afe0808111151v62d9707es26b8af9d725c6496@mail.gmail.com> References: <61c885db0808111131g76bc3542h92f86a88f04533fc@mail.gmail.com> <57c63afe0808111132kef556c8l3b2e7eeb17a61535@mail.gmail.com> <9b25e3a5006d7fed4dac2544b01f5ca6@ruby-forum.com> <57c63afe0808111151v62d9707es26b8af9d725c6496@mail.gmail.com> Message-ID: <554ee0130cbd4798be6f8908fb1d9465@ruby-forum.com> David Chelimsky wrote: > On Mon, Aug 11, 2008 at 1:47 PM, John Mark wrote: >> >> Sorry that was a typo >> >> Its actually stub! in my code > > The original example doesn't seem to do anything: > > it "should find products given a category" do > product = mock_model(Product, :id => 1, :category_id => 1) > Product.stub(!find_all_by_category_id).with(anything()).and_return([product]) > Product.should_receive(:find_all_meeting_some_criteria_for_category).with(product.category_id) > end > > It just sets up some objects but never actually calls an action. What > is the error message you're getting? Sorry again I forgot to add the last statement. Here is how the code should have looked like it "should find products given a category" do product = mock_model(Product, :id => 1, :category_id => 1) Product.stub!(:find_all_by_category_id).with(anything()).and_return([product]) Product.should_receive(:find_all_meeting_some_criteria_for_category).with(product.category_id) Product.find_all_meeting_some_criteria_for_category(product.category_id) end I have created a new application with only the above 2 models and the rspec is working ok. It appears there are some extra information in my real application that is making it not to work properly. I have to investigate further on this. The error I am getting is. "You have a nil object when you didn't expect it! You might have expected an instance of Array. The error ocurred while evaluating nil.each" aand the error line is line 2 below in the Product model 1. products = find_all_by_category_id(category_id) 2. products.each do |product| Perhaps what I need answered for now is what could cause rspec return nil for an activerecord method that is supposed to return an array? Thanks Mark -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Mon Aug 11 16:00:04 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 11 Aug 2008 15:00:04 -0500 Subject: [rspec-users] find_all_by returning nil In-Reply-To: <554ee0130cbd4798be6f8908fb1d9465@ruby-forum.com> References: <61c885db0808111131g76bc3542h92f86a88f04533fc@mail.gmail.com> <57c63afe0808111132kef556c8l3b2e7eeb17a61535@mail.gmail.com> <9b25e3a5006d7fed4dac2544b01f5ca6@ruby-forum.com> <57c63afe0808111151v62d9707es26b8af9d725c6496@mail.gmail.com> <554ee0130cbd4798be6f8908fb1d9465@ruby-forum.com> Message-ID: <57c63afe0808111300u74313334k252d01c954c00a9e@mail.gmail.com> On Mon, Aug 11, 2008 at 2:49 PM, John Mark wrote: > David Chelimsky wrote: >> On Mon, Aug 11, 2008 at 1:47 PM, John Mark wrote: >>> >>> Sorry that was a typo >>> >>> Its actually stub! in my code >> >> The original example doesn't seem to do anything: >> >> it "should find products given a category" do >> product = mock_model(Product, :id => 1, :category_id => 1) >> Product.stub(!find_all_by_category_id).with(anything()).and_return([product]) >> Product.should_receive(:find_all_meeting_some_criteria_for_category).with(product.category_id) >> end >> >> It just sets up some objects but never actually calls an action. What >> is the error message you're getting? > > Sorry again I forgot to add the last statement. Can't really help you if you're submitting code that is different from the code that is causing you trouble. Please be more careful about this. > Here is how the code > should have looked like > it "should find products given a category" do > product = mock_model(Product, :id => 1, :category_id => 1) > Product.stub!(:find_all_by_category_id).with(anything()).and_return([product]) > Product.should_receive(:find_all_meeting_some_criteria_for_category).with(product.category_id) > Product.find_all_meeting_some_criteria_for_category(product.category_id) > end OK - so here, the 2nd to last line sets an expectation that Product should receive : find_all_meeting_some_criteria_for_category with product.category_id, and then the last line makes that exact call. This means that none of your actual code is being executed here. Is that really what you have? > I have created a new application with only the above 2 models and the > rspec is working ok. It appears there are some extra information in my > real application that is making it not to work properly. I have to > investigate further on this. > > The error I am getting is. > "You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error ocurred while evaluating nil.each" > > aand the error line is line 2 below in the Product model > 1. products = find_all_by_category_id(category_id) > 2. products.each do |product| > > > Perhaps what I need answered for now is what could cause rspec return > nil for an activerecord method that is supposed to return an array? > > > Thanks > Mark > > -- > 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 Mon Aug 11 16:24:02 2008 From: lists at ruby-forum.com (John Mark) Date: Mon, 11 Aug 2008 22:24:02 +0200 Subject: [rspec-users] find_all_by returning nil In-Reply-To: <57c63afe0808111300u74313334k252d01c954c00a9e@mail.gmail.com> References: <61c885db0808111131g76bc3542h92f86a88f04533fc@mail.gmail.com> <57c63afe0808111132kef556c8l3b2e7eeb17a61535@mail.gmail.com> <9b25e3a5006d7fed4dac2544b01f5ca6@ruby-forum.com> <57c63afe0808111151v62d9707es26b8af9d725c6496@mail.gmail.com> <554ee0130cbd4798be6f8908fb1d9465@ruby-forum.com> <57c63afe0808111300u74313334k252d01c954c00a9e@mail.gmail.com> Message-ID: David Chelimsky wrote: > On Mon, Aug 11, 2008 at 2:49 PM, John Mark wrote: >>> product = mock_model(Product, :id => 1, :category_id => 1) >>> Product.stub(!find_all_by_category_id).with(anything()).and_return([product]) >>> Product.should_receive(:find_all_meeting_some_criteria_for_category).with(product.category_id) >>> end >>> >>> It just sets up some objects but never actually calls an action. What >>> is the error message you're getting? >> >> Sorry again I forgot to add the last statement. > > Can't really help you if you're submitting code that is different from > the code that is causing you trouble. Please be more careful about > this. > >> Here is how the code >> should have looked like >> it "should find products given a category" do >> product = mock_model(Product, :id => 1, :category_id => 1) >> Product.stub!(:find_all_by_category_id).with(anything()).and_return([product]) >> Product.should_receive(:find_all_meeting_some_criteria_for_category).with(product.category_id) >> Product.find_all_meeting_some_criteria_for_category(product.category_id) >> end > > OK - so here, the 2nd to last line sets an expectation that Product > should receive : find_all_meeting_some_criteria_for_category with > product.category_id, and then the last line makes that exact call. > This means that none of your actual code is being executed here. Is > that really what you have? Thanks David for the effort you are making to address my questions. Next time I will definitely run the examples I am wrting here before I post them Yes the actual code gets called and thats where the nil error is getting generated from. The code works ok for a simple application with only the Product and Category model. The real code has a lot of associations and other complex logic which I did not want to post here as they will hide the problem I am trying to solve. I will investigate it further since now I know the problem could be caused by something else other than rspec. It just looks as if (based on logs) that no database call is made in the real application when I make this call with rspec (although it works ok without rspec) products = find_all_by_category_id(category_id) The error is generated in the statement following the above statement products.each do |product| saying products is nil -- Posted via http://www.ruby-forum.com/. From pergesu at gmail.com Mon Aug 11 16:24:03 2008 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 11 Aug 2008 14:24:03 -0600 Subject: [rspec-users] find_all_by returning nil In-Reply-To: <554ee0130cbd4798be6f8908fb1d9465@ruby-forum.com> References: <61c885db0808111131g76bc3542h92f86a88f04533fc@mail.gmail.com> <57c63afe0808111132kef556c8l3b2e7eeb17a61535@mail.gmail.com> <9b25e3a5006d7fed4dac2544b01f5ca6@ruby-forum.com> <57c63afe0808111151v62d9707es26b8af9d725c6496@mail.gmail.com> <554ee0130cbd4798be6f8908fb1d9465@ruby-forum.com> Message-ID: <810a540e0808111324o11afdd74k9db4e393ca18bdfb@mail.gmail.com> > Sorry again I forgot to add the last statement Could you just copy and paste your code? That would be infinitely more helpful. Pat From lists at ruby-forum.com Mon Aug 11 16:35:16 2008 From: lists at ruby-forum.com (John Mark) Date: Mon, 11 Aug 2008 22:35:16 +0200 Subject: [rspec-users] find_all_by returning nil In-Reply-To: References: <61c885db0808111131g76bc3542h92f86a88f04533fc@mail.gmail.com> <57c63afe0808111132kef556c8l3b2e7eeb17a61535@mail.gmail.com> <9b25e3a5006d7fed4dac2544b01f5ca6@ruby-forum.com> <57c63afe0808111151v62d9707es26b8af9d725c6496@mail.gmail.com> <554ee0130cbd4798be6f8908fb1d9465@ruby-forum.com> <57c63afe0808111300u74313334k252d01c954c00a9e@mail.gmail.com> Message-ID: > It just looks as if (based on logs) that no database call is made in the > real application when I make this call with rspec (although it works ok > without rspec) > products = find_all_by_category_id(category_id) > The error is generated in the statement following the above statement > products.each do |product| > saying products is nil I should not have expected any database call as this is a stub. I will investigate further as there is something else causing the error other than rspec. -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Tue Aug 12 12:45:17 2008 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 12 Aug 2008 17:45:17 +0100 Subject: [rspec-users] Documentation for Plain-Text Stories Message-ID: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> Can I help the project by writing some docs about the plain-text story runner for the rspec.info website? It would surely help me to get it wired in my own mind if I have to write it up for the world. Would this be helpful / appreciated? What format would you want them in? cheers, Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.fyvie at champsoftware.com Tue Aug 12 14:22:40 2008 From: ben.fyvie at champsoftware.com (Ben Fyvie) Date: Tue, 12 Aug 2008 13:22:40 -0500 Subject: [rspec-users] return code question Message-ID: <4411D4B7C89D453797F0178162790289@champ.net> We are trying to automate the running of our rspec tests for our Rails app on a build server using Capistrano. The problem is that Capistrano seems to think that the command called to run the model tests failed when in fact I believe it succeeded. I believe the problem has to do with the return code from the command I am running.. The command I am running is: ruby script/spec spec/models -f html:model_test_results.html The output file seems to be complete as it has both the opening and closing html tags and it has the results of all of our tests. But when I run $? To get the return code of the last command it says it was "1" which I believe signifies that the command was not successful and is what is causing our Capistrano task to abort. We are using RSpec 1.1.4 and in case you're curious the output from Capistrano looks like this: * executing "cd /data/nightingalenotes/releases/20080812160703 && ruby script/ spec spec/models -f html:public/rspec_test_results/model_test_results.html" servers: ["buildnexus.champ.net"] [buildnexus.champ.net] executing command command finished *** [deploy:update_code] rolling back * executing "rm -rf /data/nightingalenotes/releases/20080812160703; true" servers: ["buildnexus.champ.net"] [buildnexus.champ.net] executing command command finished command "cd /data/nightingalenotes/releases/20080812160703 && ruby script/spec s pec/models -f html:public/rspec_test_results/model_test_results.html" failed on buildnexus.champ.net Thanks! Ben Fyvie -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.dennis at gmail.com Tue Aug 12 20:25:45 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Tue, 12 Aug 2008 20:25:45 -0400 Subject: [rspec-users] WDYT, simple, anonymous story listeners? Message-ID: <85d99afe0808121725s7ed3272ejec197885aa0c0f4f@mail.gmail.com> Sometimes I don't have a full need to make a class to do something, yet I want something readable and concise. This is influenced from the joys of JavaScript. Today I made this happen. Love it, like it, hate it, WDYT? Spec::Story::Runner.register_listener FunctionalStruct.new( :run_started => lambda { |*args| Generate.user(:login => "normal user") }, :run_ended => lambda { |*args| User.destroy_all }, :method_missing => lambda { |*a| } ) -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From dchelimsky at gmail.com Tue Aug 12 21:25:25 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 12 Aug 2008 20:25:25 -0500 Subject: [rspec-users] WDYT, simple, anonymous story listeners? In-Reply-To: <85d99afe0808121725s7ed3272ejec197885aa0c0f4f@mail.gmail.com> References: <85d99afe0808121725s7ed3272ejec197885aa0c0f4f@mail.gmail.com> Message-ID: <57c63afe0808121825k5de7bfeasa5b129f610e9fcb2@mail.gmail.com> On Tue, Aug 12, 2008 at 7:25 PM, Zach Dennis wrote: > Sometimes I don't have a full need to make a class to do something, > yet I want something readable and concise. This is influenced from the > joys of JavaScript. > > Today I made this happen. Love it, like it, hate it, WDYT? > > Spec::Story::Runner.register_listener FunctionalStruct.new( > :run_started => lambda { |*args| > Generate.user(:login => "normal user") > }, > :run_ended => lambda { |*args| > User.destroy_all > }, > :method_missing => lambda { |*a| } > ) Love is a bit strong. Like++ From tero at tilus.net Wed Aug 13 00:24:08 2008 From: tero at tilus.net (Tero Tilus) Date: Wed, 13 Aug 2008 07:24:08 +0300 Subject: [rspec-users] WDYT, simple, anonymous story listeners? In-Reply-To: <85d99afe0808121725s7ed3272ejec197885aa0c0f4f@mail.gmail.com> References: <85d99afe0808121725s7ed3272ejec197885aa0c0f4f@mail.gmail.com> Message-ID: <20080813042408.GL24854@uivelo.tilus.net> 2008-08-12 20:25, Zach Dennis: > Sometimes I don't have a full need to make a class to do something, How's that _essentially_ different from making a class or extending an existing class? I am not knowledgeable enough to "just see" it, and becaus I can't understand the motivation, I'm bound to hate it. ;) > This is influenced from the joys of JavaScript. It even looks like JavaScript. :D -- Tero Tilus ## 050 3635 235 ## http://www.tilus.net/koti/tero/ From zach.dennis at gmail.com Wed Aug 13 00:54:51 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 13 Aug 2008 00:54:51 -0400 Subject: [rspec-users] WDYT, simple, anonymous story listeners? In-Reply-To: <20080813042408.GL24854@uivelo.tilus.net> References: <85d99afe0808121725s7ed3272ejec197885aa0c0f4f@mail.gmail.com> <20080813042408.GL24854@uivelo.tilus.net> Message-ID: <85d99afe0808122154v66db016cs1a0ffb0b804bfbd4@mail.gmail.com> On Wed, Aug 13, 2008 at 12:24 AM, Tero Tilus wrote: > 2008-08-12 20:25, Zach Dennis: >> Sometimes I don't have a full need to make a class to do something, > > How's that _essentially_ different from making a class or extending an > existing class? I am not knowledgeable enough to "just see" it, and > becaus I can't understand the motivation, I'm bound to hate it. ;) The biggest difference is that you can pass the whole thing as an argument into the method you're calling (reduce noise, increase clarity). If you used something like OpenStruct you couldn't do it, because in Ruby you can't force invocation of a Proc object (you have to call "call" on it). For example, this wouldn't work using an OpenStruct: Spec::Story::Runner.register_listener OpenStruct.new( :run_started => lambda { |*args| Generate.user(:login => "normal user") }, :run_ended => lambda { |*args| User.destroy_all }, :method_missing => lambda { |*a| } ) In order for this to work we'd have to create a class for our listener, like so: class MyStoryListener def run_started(*args) Generate.user(:login => "normal user") end def run_ended(*args) User.destroy_all end def method_missing(*args) end end # and register it separately Spec::Story::Runner.register_listener MyStoryListener.new There is nothing wrong with this, but there are times when it feels dirty and unnecessary to create yet another class with some methods, just so the thing can be instantiated one time and passed in as an argument. That's why I decided to throw together a little FunctionalStruct, so if Proc objects got passed in they would be invokable. Here's a more specific example of the different between OpenStruct and FunctionalStruct: # openstruct example o = OpenStruct.new :foo => lambda { "foo" } o.foo # => o.foo.call # => "foo" # functionalstruct example f = FunctionalStruct.new :foo => lambda { "foo" } f.foo # => "foo" >> This is influenced from the joys of JavaScript. > > It even looks like JavaScript. :D One thing I miss from JavaScript is that functions are truly first class citizens. The beauty of Ruby is that I can mimic that by writing something like FunctionalStruct. -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From mark at mwilden.com Wed Aug 13 01:29:20 2008 From: mark at mwilden.com (Mark Wilden) Date: Tue, 12 Aug 2008 22:29:20 -0700 Subject: [rspec-users] WDYT, simple, anonymous story listeners? In-Reply-To: <85d99afe0808122154v66db016cs1a0ffb0b804bfbd4@mail.gmail.com> References: <85d99afe0808121725s7ed3272ejec197885aa0c0f4f@mail.gmail.com> <20080813042408.GL24854@uivelo.tilus.net> <85d99afe0808122154v66db016cs1a0ffb0b804bfbd4@mail.gmail.com> Message-ID: <3c30da400808122229p3dfd8191k3509afbf404ece00@mail.gmail.com> On Tue, Aug 12, 2008 at 9:54 PM, Zach Dennis wrote: > There is nothing wrong with this, but there are times when it feels > dirty and unnecessary to create yet another class with some methods The proposed solution looks very nice, but I've never been convinced by the "yet another class" argument. It's not like you're only allowed a certain number. That hasn't always been the case, however. When I worked at Sierra On-Line in the early '90s, I broke the compiler of our proprietary OOP language because I exceeded its maximum class count. Those were the days...:) ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From me at danielfischer.com Wed Aug 13 04:52:33 2008 From: me at danielfischer.com (Fischer, Daniel) Date: Wed, 13 Aug 2008 01:52:33 -0700 Subject: [rspec-users] Keep getting respond_to? errors In-Reply-To: <809154ea504d7787b710684e42870014@ruby-forum.com> References: <7e565b5c0808041455m604fa7b0g4bf541d9be2d9212@mail.gmail.com> <4908C456-6054-4384-A77F-EED9A6169AE7@railsnewbie.com> <809154ea504d7787b710684e42870014@ruby-forum.com> Message-ID: <7e565b5c0808130152x65459e64i9e4aa0a6abe6b9f0@mail.gmail.com> Any fix on this yet? On Sat, Aug 9, 2008 at 8:33 AM, Jd Roberts wrote: > > Are you running under drb? Autotest? What version of rspec? rails? > > > > I'm almost certain this is a rails loading bug...Are you requiring > > anywhere? What is the value of config.cache_classes in your test.rb? > > Same prob. Passing tests pass, and the first failing test fails > correctly... but ever afterwards the permanent 'respond_to?' error > plagues me until I restart autotest > > Running autotest with Rspec -v 1.1.4 and rails 2.1.0 > > no special requiring (except spec_helper at the top, of course) and > config.cache_classes is true > > I tried setting config.cache_classes to false, but that didn't change > the above countdown to FAIL :/ > -- > 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 Wed Aug 13 05:26:09 2008 From: lists at ruby-forum.com (Joseph Wilk) Date: Wed, 13 Aug 2008 11:26:09 +0200 Subject: [rspec-users] WDYT, simple, anonymous story listeners? In-Reply-To: <3c30da400808122229p3dfd8191k3509afbf404ece00@mail.gmail.com> References: <85d99afe0808121725s7ed3272ejec197885aa0c0f4f@mail.gmail.com> <20080813042408.GL24854@uivelo.tilus.net> <85d99afe0808122154v66db016cs1a0ffb0b804bfbd4@mail.gmail.com> <3c30da400808122229p3dfd8191k3509afbf404ece00@mail.gmail.com> Message-ID: <04f4bb2b71ed4c6f45535e44de79b021@ruby-forum.com> It looks like a nice shortcut for those times when you are registering simple one-off listeners. While it does provide a nice shortcut I can see reasons why that shortcut might be bad(in some cases). Separating registering and implementation can be a good thing. *Split the logic. *Organise files/classes nicely *Enable inheritance from the listeners If it was anything that I had to maintain or touch regularly I would be happier with a class. Can/Could you support mixins inside FunctionalStruct? That would help overcome some of those points. I can think of a couple of places that I would be happy using FunctionalStruct. Is the source for 'FunctionalStruct' written/available? -- Joseph Wilk http://www.joesniff.co.uk Mark Wilden wrote: > On Tue, Aug 12, 2008 at 9:54 PM, Zach Dennis > wrote: > > >> There is nothing wrong with this, but there are times when it feels >> dirty and unnecessary to create yet another class with some methods > > > The proposed solution looks very nice, but I've never been convinced by > the > "yet another class" argument. It's not like you're only allowed a > certain > number. > > That hasn't always been the case, however. When I worked at Sierra > On-Line > in the early '90s, I broke the compiler of our proprietary OOP language > because I exceeded its maximum class count. Those were the days...:) > > ///ark -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Wed Aug 13 08:29:11 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 13 Aug 2008 14:29:11 +0200 Subject: [rspec-users] WDYT, simple, anonymous story listeners? In-Reply-To: <85d99afe0808121725s7ed3272ejec197885aa0c0f4f@mail.gmail.com> References: <85d99afe0808121725s7ed3272ejec197885aa0c0f4f@mail.gmail.com> Message-ID: <8d961d900808130529t4384f0cqfa8712fa03a138b3@mail.gmail.com> On Wed, Aug 13, 2008 at 2:25 AM, Zach Dennis wrote: > Sometimes I don't have a full need to make a class to do something, > yet I want something readable and concise. This is influenced from the > joys of JavaScript. > > Today I made this happen. Love it, like it, hate it, WDYT? > As mentioned earlier on the RSpec development list, we're considering replacing the Story runner with a new implementation: http://github.com/aslakhellesoy/cucumber http://gojko.net/2008/08/06/cucumber-next-generation-ruby-bdd-tool/ http://www.nabble.com/-ANN--Cucumber-td18876816.html I'd rather see a similar construct for Cucumber, which already is (IMHO) much better than the Story Runner. Before(:all) do end After(:all) do end (per-scenarion Before/After is already implemented). Aslak > Spec::Story::Runner.register_listener FunctionalStruct.new( > :run_started => lambda { |*args| > Generate.user(:login => "normal user") > }, > :run_ended => lambda { |*args| > User.destroy_all > }, > :method_missing => lambda { |*a| } > ) > > > -- > 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 > From dchelimsky at gmail.com Wed Aug 13 08:35:45 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 13 Aug 2008 07:35:45 -0500 Subject: [rspec-users] return code question In-Reply-To: <4411D4B7C89D453797F0178162790289@champ.net> References: <4411D4B7C89D453797F0178162790289@champ.net> Message-ID: <57c63afe0808130535n5032c37dl9c271f1d95235d19@mail.gmail.com> On Tue, Aug 12, 2008 at 1:22 PM, Ben Fyvie wrote: > We are trying to automate the running of our rspec tests for our Rails app > on a build server using Capistrano. The problem is that Capistrano seems to > think that the command called to run the model tests failed when in fact I > believe it succeeded. I believe the problem has to do with the return code > from the command I am running.. The command I am running is: > > ruby script/spec spec/models -f html:model_test_results.html > > > > The output file seems to be complete as it has both the opening and closing > html tags and it has the results of all of our tests. But when I run $? To > get the return code of the last command it says it was "1" which I believe > signifies that the command was not successful and is what is causing our > Capistrano task to abort. I just did this in a Rakefile: task :models do `ruby script/spec spec/models -f html:model_test_results.html` puts $? end And I get this when I run 'rake models' $ rake models (in /Users/david/projects/ruby/mycastory) 0 I'm using the latest from git (naturally). How are you checking the exit code? > We are using RSpec 1.1.4 and in case you're > curious the output from Capistrano looks like this: > > > > * executing "cd /data/nightingalenotes/releases/20080812160703 && ruby > script/ > > spec spec/models -f html:public/rspec_test_results/model_test_results.html" > > servers: ["buildnexus.champ.net"] > > [buildnexus.champ.net] executing command > > command finished > > *** [deploy:update_code] rolling back > > * executing "rm -rf /data/nightingalenotes/releases/20080812160703; true" > > servers: ["buildnexus.champ.net"] > > [buildnexus.champ.net] executing command > > command finished > > command "cd /data/nightingalenotes/releases/20080812160703 && ruby > script/spec s > > pec/models -f html:public/rspec_test_results/model_test_results.html" failed > on > > buildnexus.champ.net > > > > > > Thanks! > > > > Ben Fyvie > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From zach.dennis at gmail.com Wed Aug 13 10:41:42 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 13 Aug 2008 10:41:42 -0400 Subject: [rspec-users] WDYT, simple, anonymous story listeners? In-Reply-To: <04f4bb2b71ed4c6f45535e44de79b021@ruby-forum.com> References: <85d99afe0808121725s7ed3272ejec197885aa0c0f4f@mail.gmail.com> <20080813042408.GL24854@uivelo.tilus.net> <85d99afe0808122154v66db016cs1a0ffb0b804bfbd4@mail.gmail.com> <3c30da400808122229p3dfd8191k3509afbf404ece00@mail.gmail.com> <04f4bb2b71ed4c6f45535e44de79b021@ruby-forum.com> Message-ID: <85d99afe0808130741t77cea15fm4c4f8e3e93bbde7b@mail.gmail.com> On Wed, Aug 13, 2008 at 5:26 AM, Joseph Wilk wrote: > It looks like a nice shortcut for those times when you are registering > simple one-off listeners. > > While it does provide a nice shortcut I can see reasons why that > shortcut might be bad(in some cases). > > Separating registering and implementation can be a good thing. > *Split the logic. > *Organise files/classes nicely > *Enable inheritance from the listeners > > If it was anything that I had to maintain or touch regularly I would be > happier with a class. > > Can/Could you support mixins inside FunctionalStruct? That would help > overcome some of those points. Yeah you definitely could, perhaps something like: FunctionalStruct.new( SomeModule, :foo => ..., :bar => ..., ) > I can think of a couple of places that I would be happy using > FunctionalStruct. Is the source for 'FunctionalStruct' > written/available? http://github.com/zdennis/functional_struct/tree/master -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From zach.dennis at gmail.com Wed Aug 13 10:50:24 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 13 Aug 2008 10:50:24 -0400 Subject: [rspec-users] WDYT, simple, anonymous story listeners? In-Reply-To: <8d961d900808130529t4384f0cqfa8712fa03a138b3@mail.gmail.com> References: <85d99afe0808121725s7ed3272ejec197885aa0c0f4f@mail.gmail.com> <8d961d900808130529t4384f0cqfa8712fa03a138b3@mail.gmail.com> Message-ID: <85d99afe0808130750n31df3787id61e28ce16daa231@mail.gmail.com> On Wed, Aug 13, 2008 at 8:29 AM, aslak hellesoy wrote: > On Wed, Aug 13, 2008 at 2:25 AM, Zach Dennis wrote: >> Sometimes I don't have a full need to make a class to do something, >> yet I want something readable and concise. This is influenced from the >> joys of JavaScript. >> >> Today I made this happen. Love it, like it, hate it, WDYT? >> > > As mentioned earlier on the RSpec development list, we're considering > replacing the Story runner with a new implementation: > > http://github.com/aslakhellesoy/cucumber > http://gojko.net/2008/08/06/cucumber-next-generation-ruby-bdd-tool/ > http://www.nabble.com/-ANN--Cucumber-td18876816.html > > > I'd rather see a similar construct for Cucumber, which already is > (IMHO) much better than the Story Runner. > > > Before(:all) do > end > > After(:all) do > end > > (per-scenarion Before/After is already implemented). > When you say "rather see a similar construct" -- are you referring to having the Before(:all) and After(:all) capability that you posted, or something similar to what I posted with using a FuncionalStruct as an argument to register a listener on the existing StoryRunner (a clear/concise way to hook-in with those one off listeners) ? -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From aslak.hellesoy at gmail.com Wed Aug 13 11:00:02 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 13 Aug 2008 17:00:02 +0200 Subject: [rspec-users] WDYT, simple, anonymous story listeners? In-Reply-To: <85d99afe0808130750n31df3787id61e28ce16daa231@mail.gmail.com> References: <85d99afe0808121725s7ed3272ejec197885aa0c0f4f@mail.gmail.com> <8d961d900808130529t4384f0cqfa8712fa03a138b3@mail.gmail.com> <85d99afe0808130750n31df3787id61e28ce16daa231@mail.gmail.com> Message-ID: <8d961d900808130800s3c349e57r93a7dc59ab3dd085@mail.gmail.com> On Wed, Aug 13, 2008 at 4:50 PM, Zach Dennis wrote: > On Wed, Aug 13, 2008 at 8:29 AM, aslak hellesoy > wrote: >> On Wed, Aug 13, 2008 at 2:25 AM, Zach Dennis wrote: >>> Sometimes I don't have a full need to make a class to do something, >>> yet I want something readable and concise. This is influenced from the >>> joys of JavaScript. >>> >>> Today I made this happen. Love it, like it, hate it, WDYT? >>> >> >> As mentioned earlier on the RSpec development list, we're considering >> replacing the Story runner with a new implementation: >> >> http://github.com/aslakhellesoy/cucumber >> http://gojko.net/2008/08/06/cucumber-next-generation-ruby-bdd-tool/ >> http://www.nabble.com/-ANN--Cucumber-td18876816.html >> >> >> I'd rather see a similar construct for Cucumber, which already is >> (IMHO) much better than the Story Runner. >> >> >> Before(:all) do >> end >> >> After(:all) do >> end >> >> (per-scenarion Before/After is already implemented). >> > > When you say "rather see a similar construct" -- are you referring to > having the Before(:all) and After(:all) capability that you posted, or > something similar to what I posted with using a FuncionalStruct as an > argument to register a listener on the existing StoryRunner (a > clear/concise way to hook-in with those one off listeners) ? > By "similar construct" I meant something that achievs the same goal (running pieces of code at different times during the run). I suggested Before(:all) and After(:all) because: * It's a familiar concept from RSpec examples * It's much easier to read/write Compare these: # Your suggestion Spec::Story::Runner.register_listener FunctionalStruct.new( :run_started => lambda { |*args| Generate.user(:login => "normal user") } ) # My suggestion: Before(:all) do # We can pass args to the block if we want to Generate.user(:login => "normal user") end Aslak > -- > Zach Dennis > http://www.continuousthinking.com > http://www.mutuallyhuman.com > From zach.dennis at gmail.com Wed Aug 13 11:18:22 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 13 Aug 2008 11:18:22 -0400 Subject: [rspec-users] WDYT, simple, anonymous story listeners? In-Reply-To: <8d961d900808130800s3c349e57r93a7dc59ab3dd085@mail.gmail.com> References: <85d99afe0808121725s7ed3272ejec197885aa0c0f4f@mail.gmail.com> <8d961d900808130529t4384f0cqfa8712fa03a138b3@mail.gmail.com> <85d99afe0808130750n31df3787id61e28ce16daa231@mail.gmail.com> <8d961d900808130800s3c349e57r93a7dc59ab3dd085@mail.gmail.com> Message-ID: <85d99afe0808130818v3a6b6523he066b4688b69e29b@mail.gmail.com> On Wed, Aug 13, 2008 at 11:00 AM, aslak hellesoy wrote: > On Wed, Aug 13, 2008 at 4:50 PM, Zach Dennis wrote: >> On Wed, Aug 13, 2008 at 8:29 AM, aslak hellesoy >> wrote: >>> On Wed, Aug 13, 2008 at 2:25 AM, Zach Dennis wrote: >>>> Sometimes I don't have a full need to make a class to do something, >>>> yet I want something readable and concise. This is influenced from the >>>> joys of JavaScript. >>>> >>>> Today I made this happen. Love it, like it, hate it, WDYT? >>>> >>> >>> As mentioned earlier on the RSpec development list, we're considering >>> replacing the Story runner with a new implementation: >>> >>> http://github.com/aslakhellesoy/cucumber >>> http://gojko.net/2008/08/06/cucumber-next-generation-ruby-bdd-tool/ >>> http://www.nabble.com/-ANN--Cucumber-td18876816.html >>> >>> >>> I'd rather see a similar construct for Cucumber, which already is >>> (IMHO) much better than the Story Runner. >>> >>> >>> Before(:all) do >>> end >>> >>> After(:all) do >>> end >>> >>> (per-scenarion Before/After is already implemented). >>> >> >> When you say "rather see a similar construct" -- are you referring to >> having the Before(:all) and After(:all) capability that you posted, or >> something similar to what I posted with using a FuncionalStruct as an >> argument to register a listener on the existing StoryRunner (a >> clear/concise way to hook-in with those one off listeners) ? >> > > By "similar construct" I meant something that achievs the same goal > (running pieces of code at different times during the run). > > I suggested Before(:all) and After(:all) because: > > * It's a familiar concept from RSpec examples > * It's much easier to read/write > > Compare these: > > # Your suggestion > Spec::Story::Runner.register_listener FunctionalStruct.new( > :run_started => lambda { |*args| > Generate.user(:login => "normal user") > } > ) > > # My suggestion: > Before(:all) do # We can pass args to the block if we want to > Generate.user(:login => "normal user") > end > Before/After is definitely much cleaner, although I'm not a fan of more global namespace pollution, but it may not be a problem in practice (and/or maybe it's scoped in to another namespace like Feature::Before(:all)) Are you thinking of allowing for multiple Before/After(:all) blocks? -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From aslak.hellesoy at gmail.com Wed Aug 13 11:26:53 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 13 Aug 2008 17:26:53 +0200 Subject: [rspec-users] WDYT, simple, anonymous story listeners? In-Reply-To: <85d99afe0808130818v3a6b6523he066b4688b69e29b@mail.gmail.com> References: <85d99afe0808121725s7ed3272ejec197885aa0c0f4f@mail.gmail.com> <8d961d900808130529t4384f0cqfa8712fa03a138b3@mail.gmail.com> <85d99afe0808130750n31df3787id61e28ce16daa231@mail.gmail.com> <8d961d900808130800s3c349e57r93a7dc59ab3dd085@mail.gmail.com> <85d99afe0808130818v3a6b6523he066b4688b69e29b@mail.gmail.com> Message-ID: <8d961d900808130826r173d648cpe550014fc37557d9@mail.gmail.com> On Wed, Aug 13, 2008 at 5:18 PM, Zach Dennis wrote: > On Wed, Aug 13, 2008 at 11:00 AM, aslak hellesoy > wrote: >> On Wed, Aug 13, 2008 at 4:50 PM, Zach Dennis wrote: >>> On Wed, Aug 13, 2008 at 8:29 AM, aslak hellesoy >>> wrote: >>>> On Wed, Aug 13, 2008 at 2:25 AM, Zach Dennis wrote: >>>>> Sometimes I don't have a full need to make a class to do something, >>>>> yet I want something readable and concise. This is influenced from the >>>>> joys of JavaScript. >>>>> >>>>> Today I made this happen. Love it, like it, hate it, WDYT? >>>>> >>>> >>>> As mentioned earlier on the RSpec development list, we're considering >>>> replacing the Story runner with a new implementation: >>>> >>>> http://github.com/aslakhellesoy/cucumber >>>> http://gojko.net/2008/08/06/cucumber-next-generation-ruby-bdd-tool/ >>>> http://www.nabble.com/-ANN--Cucumber-td18876816.html >>>> >>>> >>>> I'd rather see a similar construct for Cucumber, which already is >>>> (IMHO) much better than the Story Runner. >>>> >>>> >>>> Before(:all) do >>>> end >>>> >>>> After(:all) do >>>> end >>>> >>>> (per-scenarion Before/After is already implemented). >>>> >>> >>> When you say "rather see a similar construct" -- are you referring to >>> having the Before(:all) and After(:all) capability that you posted, or >>> something similar to what I posted with using a FuncionalStruct as an >>> argument to register a listener on the existing StoryRunner (a >>> clear/concise way to hook-in with those one off listeners) ? >>> >> >> By "similar construct" I meant something that achievs the same goal >> (running pieces of code at different times during the run). >> >> I suggested Before(:all) and After(:all) because: >> >> * It's a familiar concept from RSpec examples >> * It's much easier to read/write >> >> Compare these: >> >> # Your suggestion >> Spec::Story::Runner.register_listener FunctionalStruct.new( >> :run_started => lambda { |*args| >> Generate.user(:login => "normal user") >> } >> ) >> >> # My suggestion: >> Before(:all) do # We can pass args to the block if we want to >> Generate.user(:login => "normal user") >> end >> > > Before/After is definitely much cleaner, although I'm not a fan of > more global namespace pollution, but it may not be a problem in > practice (and/or maybe it's scoped in to another namespace like > Feature::Before(:all)) > I've thought about that a bit, and decided that I want to keep it global (because it means less typing and looks nicer) until it poses a problem to someone. > Are you thinking of allowing for multiple Before/After(:all) blocks? > Definitely. Before/After (without :all) already supports multiple. Aslak > -- > Zach Dennis > http://www.continuousthinking.com > http://www.mutuallyhuman.com > From ben.fyvie at champsoftware.com Wed Aug 13 12:12:04 2008 From: ben.fyvie at champsoftware.com (Ben Fyvie) Date: Wed, 13 Aug 2008 11:12:04 -0500 Subject: [rspec-users] return code question In-Reply-To: <57c63afe0808130535n5032c37dl9c271f1d95235d19@mail.gmail.com> References: <4411D4B7C89D453797F0178162790289@champ.net> <57c63afe0808130535n5032c37dl9c271f1d95235d19@mail.gmail.com> Message-ID: The command I was running to get the return code was "echo $?" After reading over my email it seems I left out a bit of rather important information. You see we expect the command to return a return code of "0" if the command was successful in it's task which was to generate an html file with the results of running the model tests. In our case the command is successful and it generates the desired output and puts it into the HTML file as expected. However we find that the return code is changed to "1" if any single test fails. To me this seems incorrect because the result of a test should not influence the return code as the return code should be associated with whether or not the command executed successfully or not. Our current situation is a great example of why the return code should only represent the success or failure of the command and not the results of the command. Whenever a test fails the return code of "1" causes our build to break and therefore nobody even knows a test is failing until we notice that the build server is no longer updating on regular intervals. Ben Fyvie -----Original Message----- From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of David Chelimsky Sent: Wednesday, August 13, 2008 7:36 AM To: rspec-users Subject: Re: [rspec-users] return code question On Tue, Aug 12, 2008 at 1:22 PM, Ben Fyvie wrote: > We are trying to automate the running of our rspec tests for our Rails app > on a build server using Capistrano. The problem is that Capistrano seems to > think that the command called to run the model tests failed when in fact I > believe it succeeded. I believe the problem has to do with the return code > from the command I am running.. The command I am running is: > > ruby script/spec spec/models -f html:model_test_results.html > > > > The output file seems to be complete as it has both the opening and closing > html tags and it has the results of all of our tests. But when I run $? To > get the return code of the last command it says it was "1" which I believe > signifies that the command was not successful and is what is causing our > Capistrano task to abort. I just did this in a Rakefile: task :models do `ruby script/spec spec/models -f html:model_test_results.html` puts $? end And I get this when I run 'rake models' $ rake models (in /Users/david/projects/ruby/mycastory) 0 I'm using the latest from git (naturally). How are you checking the exit code? > We are using RSpec 1.1.4 and in case you're > curious the output from Capistrano looks like this: > > > > * executing "cd /data/nightingalenotes/releases/20080812160703 && ruby > script/ > > spec spec/models -f html:public/rspec_test_results/model_test_results.html" > > servers: ["buildnexus.champ.net"] > > [buildnexus.champ.net] executing command > > command finished > > *** [deploy:update_code] rolling back > > * executing "rm -rf /data/nightingalenotes/releases/20080812160703; true" > > servers: ["buildnexus.champ.net"] > > [buildnexus.champ.net] executing command > > command finished > > command "cd /data/nightingalenotes/releases/20080812160703 && ruby > script/spec s > > pec/models -f html:public/rspec_test_results/model_test_results.html" failed > on > > buildnexus.champ.net > > > > > > Thanks! > > > > Ben Fyvie > > > > _______________________________________________ > 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 stefano.crocco at alice.it Wed Aug 13 12:50:50 2008 From: stefano.crocco at alice.it (Stefano Crocco) Date: Wed, 13 Aug 2008 18:50:50 +0200 Subject: [rspec-users] formatter writing output on different files Message-ID: <200808131850.50341.stefano.crocco@alice.it> Hello to every one, I'm writing an application and using rspec to test it. I like very much it's html output, since it allows me to look at it and see how something is supposed to work. The only problem is that the list of example is quickly growing to a size that makes looking for a particular example a bit time- consuming. So I got the idea to split the output into several files. Something like: a_spec.rb -> a_results.html b_spec.rb -> b_results.html Since I put all the specs related to a class in a single spec file, this would allow me to have a clear overview of the class and to be able to locate quickly the example I'm looking for. The only problem is that, as far as I know, rspec doesn't provide similar features. So, I decided to try and write a custom rspec formatter which does what I described above. Before I start coding, however, I'd like to know the answers to some questions: 1) is there any reason my idea is not a good one? 2) has something like this already been implemented? I searched google, this mailing list and the ruby mailing list, but found nothing 3) what's the best way for a formatter to access the name of the file an example comes from? Looking at the RDoc documentation, the only way I found is to use the Spec::Example::ExampleMethods#implementation_backtrace, which contains the filename and line of the example in its first entry. Is this reliable? Is there a better way? Thanks in advance Stefano From tgateau at seethroo.us Wed Aug 13 14:33:46 2008 From: tgateau at seethroo.us (tgateau at seethroo.us) Date: Wed, 13 Aug 2008 11:33:46 -0700 (PDT) Subject: [rspec-users] first try to make a controller test with RSpe Message-ID: <49482.76.79.202.162.1218652426.squirrel@seethroo.us> Hello, I'm trying to create a controller test with RSpec but I get the error when I run > spec login_controller_spec.rb --format specdoc ../../app/controllers/application.rb:4: uninitialized constant ActionController (NameError) from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from ./login_controller_spec.rb:9 from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/example_group_runner.rb:14:in `load' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/example_group_runner.rb:14:in `load_files' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/example_group_runner.rb:13:in `each' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/example_group_runner.rb:13:in `load_files' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/options.rb:98:in `run_examples' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/command_line.rb:19:in `run' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/bin/spec:4 from /usr/bin/spec:19:in `load' from /usr/bin/spec:19 Here is my login_controller_spec : ## require File.dirname(__FILE__) + '/../spec_helper' describe "A LoginController" do before(:each) do @login_controlleur = LoginController.new end it "should be valid" do @login_controlleur.should be_valid end end ## Here is my spec_helper : ## require "rubygems" require "activerecord" require "spec" LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)), *%w[.. app controllers]) ## Until now, I was working with Test::Unit, and all my test were successfull on my login_controller.rb file. The file application.rb exists. I have tried to add the line : require "actioncontroller" in my spec_helper, but I only get the error : /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- ActionController (MissingSourceFile) from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in `new_constants_in' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require' from ./../spec_helper.rb:3 from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from ./login_controller_spec.rb:1 from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/example_group_runner.rb:14:in `load' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/example_group_runner.rb:14:in `load_files' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/example_group_runner.rb:13:in `each' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/example_group_runner.rb:13:in `load_files' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/options.rb:98:in `run_examples' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/command_line.rb:19:in `run' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/bin/spec:4 from /usr/bin/spec:19:in `load' from /usr/bin/spec:19 Could somebody help me find a solution to make my test working ? Thanks Thibault From lists at ruby-forum.com Wed Aug 13 15:18:13 2008 From: lists at ruby-forum.com (Joseph Wilk) Date: Wed, 13 Aug 2008 21:18:13 +0200 Subject: [rspec-users] first try to make a controller test with RSpe In-Reply-To: <49482.76.79.202.162.1218652426.squirrel@seethroo.us> References: <49482.76.79.202.162.1218652426.squirrel@seethroo.us> Message-ID: Hello, Try including your rails config/environment.rb file in your spec_helper: spec_helper.rb ---- ENV["RAILS_ENV"] = "test" require "/../config/environment" ---- -- Joseph Wilk http://www.joesniff.co.uk -- Posted via http://www.ruby-forum.com/. From tgateau at seethroo.us Wed Aug 13 16:16:20 2008 From: tgateau at seethroo.us (tgateau at seethroo.us) Date: Wed, 13 Aug 2008 13:16:20 -0700 (PDT) Subject: [rspec-users] first try to make a controller test with RSpe In-Reply-To: References: <49482.76.79.202.162.1218652426.squirrel@seethroo.us> Message-ID: <49824.76.79.202.162.1218658580.squirrel@seethroo.us> Bug fixed ! thank you very much ! > Hello, > > Try including your rails config/environment.rb file in your spec_helper: > > spec_helper.rb > ---- > ENV["RAILS_ENV"] = "test" > require "/../config/environment" > ---- > > -- > Joseph Wilk > http://www.joesniff.co.uk > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ramos.gaston at gmail.com Wed Aug 13 14:18:14 2008 From: ramos.gaston at gmail.com (Gaston Ramos) Date: Wed, 13 Aug 2008 15:18:14 -0300 Subject: [rspec-users] require StepGroup problem Message-ID: <20080813181813.GA5544@marlasina> Hi guys, I'm trying to run this story http://pastie.org/252361 and I get the following error: http://pastie.org/252367 the helper file is: http://pastie.org/252368 I think that I'm missing a require somewhere, can anybody help me? Any thoughts? Versions: rspec 1.1.4 ruby on rails 2.1 -- "Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." (Larry Wall) +-------------------------------------+ Gast?n Ramos http://gastonramos.wordpress.com/ GNU/Linux Counter user #450312 From pergesu at gmail.com Wed Aug 13 21:11:49 2008 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 13 Aug 2008 19:11:49 -0600 Subject: [rspec-users] require StepGroup problem In-Reply-To: <20080813181813.GA5544@marlasina> References: <20080813181813.GA5544@marlasina> Message-ID: <810a540e0808131811p40114fb1u6df913bc09c5d651@mail.gmail.com> On Wed, Aug 13, 2008 at 12:18 PM, Gaston Ramos wrote: > Hi guys, I'm trying to run this story http://pastie.org/252361 You need to fully-qualify the class name, which is Spec::Story::StepGroup. Although I'm not sure why you're defining the steps this way in the first place. I think you want to use steps_for to define them, and with_steps_for to run them. Pat From lists at ruby-forum.com Thu Aug 14 03:42:45 2008 From: lists at ruby-forum.com (Andy Croll) Date: Thu, 14 Aug 2008 09:42:45 +0200 Subject: [rspec-users] Stubbing calls to the command line Message-ID: <477ba9f2b13cb126d6942e6c27c0413d@ruby-forum.com> I'm using a call to wget to download a large datafile (multiple megabytes) having assumed this will be quicker than using open-uri. How can I spec the behaviour? Ideally I'd also like to not be hitting the internet every time I test! in my_object_spec.rb describe ".get_data" do before(:each) do @my_obj = MyObject.create(@valid_attributes) end it "should download the file" do # behaviour goes here end end in my_object.rb: def get_data `wget --output-document=#{self.filename} #{self.file_uri}` end I'll be massively grateful for any help anyone can give me. -- Posted via http://www.ruby-forum.com/. From mailing_lists at railsnewbie.com Thu Aug 14 03:47:39 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Thu, 14 Aug 2008 03:47:39 -0400 Subject: [rspec-users] Stubbing calls to the command line In-Reply-To: <477ba9f2b13cb126d6942e6c27c0413d@ruby-forum.com> References: <477ba9f2b13cb126d6942e6c27c0413d@ruby-forum.com> Message-ID: <6886D175-2935-49A0-A58F-A4BF67C8D26A@railsnewbie.com> On Aug 14, 2008, at 3:42 AM, Andy Croll wrote: > I'm using a call to wget to download a large datafile (multiple > megabytes) having assumed this will be quicker than using open-uri. > > How can I spec the behaviour? Ideally I'd also like to not be hitting > the internet every time I test! > > in my_object_spec.rb > > describe ".get_data" do > before(:each) do > @my_obj = MyObject.create(@valid_attributes) > end > it "should download the file" do > # behaviour goes here > end > end > > > in my_object.rb: > > def get_data > `wget --output-document=#{self.filename} #{self.file_uri}` > end Use Kernel.stub!(:`, "wget..."), and use Kernel.send(:`, "wget") instead of literal backticks. Scott From lists at ruby-forum.com Thu Aug 14 04:46:21 2008 From: lists at ruby-forum.com (Kaja Mohaideen) Date: Thu, 14 Aug 2008 10:46:21 +0200 Subject: [rspec-users] Multy threading in ruby Message-ID: <88607630606e3325605834fe1cbfc9a1@ruby-forum.com> we people are new team for ruby. we trying to put multithreading in our code. how is it possible? we want to read a message from queue and process that message parellaly and finally insert the message to the DB. Can you give me the Idea please. we want to process 7000 to 10000 message and store it to the Database perminute. we are trying through threads. can you please help me how we do? Regards Kaja Mohaideen.A Trichy -- Posted via http://www.ruby-forum.com/. From jarkko at jlaine.net Thu Aug 14 05:04:14 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Thu, 14 Aug 2008 12:04:14 +0300 Subject: [rspec-users] Multy threading in ruby In-Reply-To: <88607630606e3325605834fe1cbfc9a1@ruby-forum.com> References: <88607630606e3325605834fe1cbfc9a1@ruby-forum.com> Message-ID: On 14.8.2008, at 11.46, Kaja Mohaideen wrote: > we people are new team for ruby. we trying to put multithreading in > our > code. how is it possible? we want to read a message from queue and > process that message parellaly and finally insert the message to the > DB. > Can you give me the Idea please. > > we want to process 7000 to 10000 message and store it to the Database > perminute. we are trying through threads. can you please help me how > we > do? For that volume, you'll probably want something ditributed, like beanstalkd (http://xph.us/software/beanstalkd/) or starfish (http://rufy.com/starfish/doc/ ). //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi From treas at dynamicdudes.com Thu Aug 14 05:26:23 2008 From: treas at dynamicdudes.com (rubyphunk) Date: Thu, 14 Aug 2008 02:26:23 -0700 (PDT) Subject: [rspec-users] Do you remember RSpactor? In-Reply-To: <3c30da400808081011nda35541lf352072bafeca193@mail.gmail.com> References: <12836674.201217855238019.JavaMail.andreas@hackmac.local> <489C6CE6.909@shopwatch.org> <3c30da400808081011nda35541lf352072bafeca193@mail.gmail.com> Message-ID: <7456bc53-dd26-4649-9096-8315e8e54e56@k30g2000hse.googlegroups.com> On 8 Aug., 19:11, "Mark Wilden" wrote: > I've been using RSpactor (the gem version, not the GUI) fairly happily for a > month or so. However, when trying the GUI version out, it became clear that > RSpactor loads things differently than 'rake spec'. Today, using the gem > version, I found that I get a MissingSourceFile trying to require json. > 'rake spec' works fine. RSpactor loads things the same way as 'rake spec' does. The problem comes from the environment RSpactor.app is running in. I haven't figured out yet how to change that.. > So I'd suggest that RSpactor is not quite ready for primetime, in case > anyone's thinking of using it. You're right RSpactor is not a final release, its a first beta. So if you encounter problems please report them to the lighthouse project http://rspactor.lighthouseapp.com or simply fork, fix, commit :) However, you can use RSpactor already for your daily work. I do, and a lot of other people too. From treas at dynamicdudes.com Thu Aug 14 05:36:26 2008 From: treas at dynamicdudes.com (rubyphunk) Date: Thu, 14 Aug 2008 02:36:26 -0700 (PDT) Subject: [rspec-users] RSpactor: Black is the new green? In-Reply-To: <489C6C85.6090109@shopwatch.org> References: <12836674.201217855238019.JavaMail.andreas@hackmac.local> <489C6C85.6090109@shopwatch.org> Message-ID: <5f2502fe-775a-4344-a0a4-0a601db9f2bf@d1g2000hsg.googlegroups.com> On 8 Aug., 17:55, Jay Levitt wrote: > Failing specs do show up as red, but passing ones show up as black in the > lefthand drawer (though the "bar" is green in the main display pane) - known > bug? No its not a bug. The lefthand drawer shows all your spec files. The right, main view shows up the content of a specific file. I don't won't _passing files_ to be shown up as green because its distracting colorful. From aidy.lewis at googlemail.com Thu Aug 14 05:47:40 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Thu, 14 Aug 2008 10:47:40 +0100 Subject: [rspec-users] traditional Rspec HTML reports through Story Runner? Message-ID: <7ac2300c0808140247s55f0ab58k2d0a1d671a9aaead@mail.gmail.com> Hi, I am currently using the story runner HTML ruby aut.rb -fh:"C:\C:\rspec_reports\aut.htm" Is it possible to also produce the traditional Rspec HTML reports through Story Runner as well Aidy From dchelimsky at gmail.com Thu Aug 14 08:25:58 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 14 Aug 2008 07:25:58 -0500 Subject: [rspec-users] traditional Rspec HTML reports through Story Runner? In-Reply-To: <7ac2300c0808140247s55f0ab58k2d0a1d671a9aaead@mail.gmail.com> References: <7ac2300c0808140247s55f0ab58k2d0a1d671a9aaead@mail.gmail.com> Message-ID: <57c63afe0808140525t35580e45ge2ea00407a3a152c@mail.gmail.com> On Thu, Aug 14, 2008 at 4:47 AM, aidy lewis wrote: > Hi, > > I am currently using the story runner HTML > > ruby aut.rb -fh:"C:\C:\rspec_reports\aut.htm" > > Is it possible to also produce the traditional Rspec HTML reports > through Story Runner as well There is no formatter for that, but you could write one. > > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aidy.lewis at googlemail.com Thu Aug 14 08:58:04 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Thu, 14 Aug 2008 13:58:04 +0100 Subject: [rspec-users] traditional Rspec HTML reports through Story Runner? In-Reply-To: <57c63afe0808140525t35580e45ge2ea00407a3a152c@mail.gmail.com> References: <7ac2300c0808140247s55f0ab58k2d0a1d671a9aaead@mail.gmail.com> <57c63afe0808140525t35580e45ge2ea00407a3a152c@mail.gmail.com> Message-ID: <7ac2300c0808140558tb2104b3m471f69aa370d846c@mail.gmail.com> Hi David, 2008/8/14 David Chelimsky : > There is no formatter for that, but you could write one. OK. Initially I think I will look into a simple dashboard that will link to each of the Story HTML files. Aidy From robl at mail.pigdestroyer.co.uk Thu Aug 14 09:53:45 2008 From: robl at mail.pigdestroyer.co.uk (Rob Lacey) Date: Thu, 14 Aug 2008 14:53:45 +0100 Subject: [rspec-users] How do you stub out callbacks? Message-ID: <48A438E9.1040600@mail.pigdestroyer.co.uk> Hi there, I'm trying to write a spec for and existing model. It has an after_create callback which I'd like to stub out. Any quick solution to this? Many thanks Rob Lacey From james2mccarthy at gmail.com Thu Aug 14 10:20:18 2008 From: james2mccarthy at gmail.com (J2M) Date: Thu, 14 Aug 2008 07:20:18 -0700 (PDT) Subject: [rspec-users] template.expect_render fails when partial is rendered from a helper In-Reply-To: References: Message-ID: Is this expected behaviour? On Aug 8, 9:46?pm, J2M wrote: > My spec; > > ? describe 'subnav rendering while logged in' do > > ? ? before do > ? ? ? template.stub!(:logged_in?).and_return(true) > ? ? ? template.stub! > (:current_profile).at_least(:once).and_return(mock_profile) > ? ? end > > ? ? def do_render > ? ? ? render "/homepages/show.html.erb" > ? ? end > > ? ? it "should render the logged in partial for homepages" do > ? ? ? template.expect_render(:partial => 'shared/subnav/home', :locals > => {:active => :home}) > ? ? ? do_render > ? ? end > > ? end > > passes if I render the partial directly in the view, > > render :partial => 'shared/subnav/home', :locals => {:active => :home} > > but it fails if the partial is rendered by a helper; > > module ApplicationHelper > ? def subnav(partial, args={}) > ? ? active = args[:active] || :no_highlight > ? ? if partial == :home > ? ? ? partial = (logged_in? ? 'home' : 'login') > ? ? end > ? ? render :partial => "shared/subnav/#{partial}", :locals => {:active > => active} > ? end > end > > Is there any way to check whether the helper renders it? > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From ramos.gaston at gmail.com Thu Aug 14 10:43:01 2008 From: ramos.gaston at gmail.com (Gaston Ramos) Date: Thu, 14 Aug 2008 11:43:01 -0300 Subject: [rspec-users] require StepGroup problem In-Reply-To: <810a540e0808131811p40114fb1u6df913bc09c5d651@mail.gmail.com> References: <20080813181813.GA5544@marlasina> <810a540e0808131811p40114fb1u6df913bc09c5d651@mail.gmail.com> Message-ID: <20080814144301.GA14175@marlasina> El mi?, 13 de ago de 2008, a las 07:11:49 -0600, Pat Maddox dijo: > On Wed, Aug 13, 2008 at 12:18 PM, Gaston Ramos wrote: > > Hi guys, I'm trying to run this story http://pastie.org/252361 > > You need to fully-qualify the class name, which is Spec::Story::StepGroup. > > Although I'm not sure why you're defining the steps this way in the > first place. I think you want to use steps_for to define them, and > with_steps_for to run them. Thanks! it worked, but now I'm having another problem: http://pastie.org/252951 http://pastie.org/252953 What's wrong? > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -- "Premature optimization is the root of all evil (or at least most of it) in programming." (Donald Knuth) +-------------------------------------+ Gast?n Ramos http://gastonramos.wordpress.com/ GNU/Linux Counter user #450312 From mark at mwilden.com Thu Aug 14 10:49:15 2008 From: mark at mwilden.com (Mark Wilden) Date: Thu, 14 Aug 2008 07:49:15 -0700 Subject: [rspec-users] Do you remember RSpactor? In-Reply-To: <7456bc53-dd26-4649-9096-8315e8e54e56@k30g2000hse.googlegroups.com> References: <12836674.201217855238019.JavaMail.andreas@hackmac.local> <489C6CE6.909@shopwatch.org> <3c30da400808081011nda35541lf352072bafeca193@mail.gmail.com> <7456bc53-dd26-4649-9096-8315e8e54e56@k30g2000hse.googlegroups.com> Message-ID: <3c30da400808140749j31a408c9pcc7c72d51778cacb@mail.gmail.com> On Thu, Aug 14, 2008 at 2:26 AM, rubyphunk wrote: > On 8 Aug., 19:11, "Mark Wilden" wrote: > > I've been using RSpactor (the gem version, not the GUI) fairly happily > for a > > month or so. However, when trying the GUI version out, it became clear > that > > RSpactor loads things differently than 'rake spec'. Today, using the gem > > version, I found that I get a MissingSourceFile trying to require json. > > 'rake spec' works fine. > > RSpactor loads things the same way as 'rake spec' does. The problem > comes from the environment RSpactor.app is running in. > I was talking about the gem version, not RSpactor.app. However, you can use RSpactor already for your daily work. I do, and a > lot of other people too. > I was using the gem version very happily for a month or more, until I ran into tests failing on RSpactor that passed with rake spec and autotest. I think RSpactor has a lot of promise for Mac users and I wish the project luck. Unfortunately I don't have the capacity to add another beta project to my plate, otherwise I'd try to be more helpful. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefano.crocco at alice.it Thu Aug 14 10:49:46 2008 From: stefano.crocco at alice.it (Stefano Crocco) Date: Thu, 14 Aug 2008 16:49:46 +0200 Subject: [rspec-users] formatter writing output on different files Message-ID: <200808141649.46931.stefano.crocco@alice.it> Hello to every one, First of all, sorry if this message has already reached the list. I sent it yesterday, but since today I don't see it in the archives, I'm resending it. I'm writing an application and using rspec to test it. I like very much it's html output, since it allows me to look at it and see how something is supposed to work. The only problem is that the list of example is quickly growing to a size that makes looking for a particular example a bit time- consuming. So I got the idea to split the output into several files. Something like: a_spec.rb -> a_results.html b_spec.rb -> b_results.html Since I put all the specs related to a class in a single spec file, this would allow me to have a clear overview of the class and to be able to locate quickly the example I'm looking for. The only problem is that, as far as I know, rspec doesn't provide similar features. So, I decided to try and write a custom rspec formatter which does what I described above. Before I start coding, however, I'd like to know the answers to some questions: 1) is there any reason my idea is not a good one? 2) has something like this already been implemented? I searched google, this mailing list and the ruby mailing list, but found nothing 3) what's the best way for a formatter to access the name of the file an example comes from? Looking at the RDoc documentation, the only way I found is to use the Spec::Example::ExampleMethods#implementation_backtrace, which contains the filename and line of the example in its first entry. Is this reliable? Is there a better way? Thanks in advance Stefano From mark at mwilden.com Thu Aug 14 10:52:56 2008 From: mark at mwilden.com (Mark Wilden) Date: Thu, 14 Aug 2008 07:52:56 -0700 Subject: [rspec-users] require StepGroup problem In-Reply-To: <20080814144301.GA14175@marlasina> References: <20080813181813.GA5544@marlasina> <810a540e0808131811p40114fb1u6df913bc09c5d651@mail.gmail.com> <20080814144301.GA14175@marlasina> Message-ID: <3c30da400808140752q636eab0bn4b597f9fbcc9cbf7@mail.gmail.com> I don't know about anyone else, but I find I'm far less likely to read short snippets of code if I have to click links instead of just reading them inline. Just my two sense. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.dennis at gmail.com Thu Aug 14 10:58:05 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 14 Aug 2008 10:58:05 -0400 Subject: [rspec-users] How do you stub out callbacks? In-Reply-To: <48A438E9.1040600@mail.pigdestroyer.co.uk> References: <48A438E9.1040600@mail.pigdestroyer.co.uk> Message-ID: <85d99afe0808140758n1c5d9b9ua227a28c4932a8c6@mail.gmail.com> On Thu, Aug 14, 2008 at 9:53 AM, Rob Lacey wrote: > Hi there, > > I'm trying to write a spec for and existing model. It has an after_create > callback which I'd like to stub out. Any quick solution to this? > My first question is why do you want to stub it out? My second question is what spec are you wanting to stub it out in? -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From ben at benmabey.com Thu Aug 14 12:33:22 2008 From: ben at benmabey.com (Ben Mabey) Date: Thu, 14 Aug 2008 10:33:22 -0600 Subject: [rspec-users] require StepGroup problem In-Reply-To: <20080814144301.GA14175@marlasina> References: <20080813181813.GA5544@marlasina> <810a540e0808131811p40114fb1u6df913bc09c5d651@mail.gmail.com> <20080814144301.GA14175@marlasina> Message-ID: <48A45E52.8040803@benmabey.com> Gaston Ramos wrote: > El mi?, 13 de ago de 2008, a las 07:11:49 -0600, Pat Maddox dijo: > >> On Wed, Aug 13, 2008 at 12:18 PM, Gaston Ramos wrote: >> >>> Hi guys, I'm trying to run this story http://pastie.org/252361 >>> >> You need to fully-qualify the class name, which is Spec::Story::StepGroup. >> >> Although I'm not sure why you're defining the steps this way in the >> first place. I think you want to use steps_for to define them, and >> with_steps_for to run them. >> > > Thanks! it worked, but now I'm having another problem: > > http://pastie.org/252951 > > http://pastie.org/252953 > > What's wrong? > > It looks like the runner can't find your steps. Like Pat said, people typically use the steps_for construct for defining steps. I reworked your story to illustrate the proper usage: http://pastie.org/253015 This blog post talks about using 'rubyesque' stories: http://www.continuousthinking.com/2008/3/5/trying-rspec-s-rubyesque-stories Also, I created a rails app for a presentation (http://www.benmabey.com/2008/05/10/slides-and-code-from-my-bddrspec-presentation/) where I show the different ways of using the story runner (rubyesque and plain text). If you are familiar with git you can download it and look at how I did both ways (I used tags to mark my commits.) To list the tags simply type ?git tag? and to checkout a tag into a new branch type ?git checkout -b tag_name tag_name?. The link: http://www.benmabey.com/wp-content/uploads/2008/05/story_runner_demo.tar.gz Vi su blog.. si esta escribiendo los relatos en espansol hay un 'patch' que sorpete espaonol (pues, castellano :) ) para las palabras (Given => Dado, When => Cuando, etc..): http://github.com/nando/rspec/commit/4ad3fbc3d78ccb39f2745b0f901828ed4a539ad2 Tambien, Aslak Helles?y tiene un projecto que se llama "cucumber" que es un "rewrite of the story runner using treetop" que ya sorpete lenguaje differentes: http://github.com/aslakhellesoy/cucumber/tree/master No he hablado espanol hace mucho anos, espero que me entiende. :) Hope that helps, Ben From jonathan at parkerhill.com Thu Aug 14 12:49:24 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Thu, 14 Aug 2008 12:49:24 -0400 Subject: [rspec-users] How do you stub out callbacks? In-Reply-To: <48A438E9.1040600@mail.pigdestroyer.co.uk> References: <48A438E9.1040600@mail.pigdestroyer.co.uk> Message-ID: <1CAD6403-6431-411F-B86F-D8A12423178A@parkerhill.com> Don't stub out callbacks, rather spec the behavior of the model, which might mean stubbing out methods (in a different model?) called by the callback. On Aug 14, 2008, at 9:53 AM, Rob Lacey wrote: > Hi there, > > I'm trying to write a spec for and existing model. It has an > after_create callback which I'd like to stub out. Any quick > solution to this? > > Many thanks > > Rob Lacey > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ben at benmabey.com Thu Aug 14 12:50:31 2008 From: ben at benmabey.com (Ben Mabey) Date: Thu, 14 Aug 2008 10:50:31 -0600 Subject: [rspec-users] How do you stub out callbacks? In-Reply-To: <48A438E9.1040600@mail.pigdestroyer.co.uk> References: <48A438E9.1040600@mail.pigdestroyer.co.uk> Message-ID: <48A46257.7050602@benmabey.com> Rob Lacey wrote: > Hi there, > > I'm trying to write a spec for and existing model. It has an > after_create callback which I'd like to stub out. Any quick solution > to this? > > Many thanks > > Rob Lacey > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users What you may want to do is move the after_create into an observer and then disconnect your observers during most of your specs. You can do this with Pat Maddox's plugin: http://evang.eli.st/blog/2007/11/22/better-rails-testing-decoupling-observers http://github.com/pat-maddox/no-peeping-toms/tree/master -Ben From dchelimsky at gmail.com Thu Aug 14 13:14:33 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 14 Aug 2008 12:14:33 -0500 Subject: [rspec-users] template.expect_render fails when partial is rendered from a helper In-Reply-To: References: Message-ID: <57c63afe0808141014y6dd3db55s34c6f5c629476d82@mail.gmail.com> On Fri, Aug 8, 2008 at 3:46 PM, J2M wrote: > My spec; > > describe 'subnav rendering while logged in' do > > before do > template.stub!(:logged_in?).and_return(true) > template.stub! > (:current_profile).at_least(:once).and_return(mock_profile) > end > > def do_render > render "/homepages/show.html.erb" > end > > it "should render the logged in partial for homepages" do > template.expect_render(:partial => 'shared/subnav/home', :locals > => {:active => :home}) > do_render > end > > end > > passes if I render the partial directly in the view, > > render :partial => 'shared/subnav/home', :locals => {:active => :home} > > but it fails if the partial is rendered by a helper; > > module ApplicationHelper > def subnav(partial, args={}) > active = args[:active] || :no_highlight > if partial == :home > partial = (logged_in? ? 'home' : 'login') > end > render :partial => "shared/subnav/#{partial}", :locals => {:active > => active} > end > end > > Is there any way to check whether the helper renders it? If the code in the subnav method is resulting in what you are assuming it is, this should work. I'd try putting exactly the same code (with everything hard coded and no conditional logic) in the subnav method and see if you get the same result. If you get an error, please copy the error in your response. Cheers, David From tgateau at seethroo.us Thu Aug 14 13:42:29 2008 From: tgateau at seethroo.us (tgateau at seethroo.us) Date: Thu, 14 Aug 2008 10:42:29 -0700 (PDT) Subject: [rspec-users] problem with get and post methods.. require missing ? In-Reply-To: <49824.76.79.202.162.1218658580.squirrel@seethroo.us> References: <49482.76.79.202.162.1218652426.squirrel@seethroo.us> <49824.76.79.202.162.1218658580.squirrel@seethroo.us> Message-ID: <49405.76.166.178.99.1218735749.squirrel@seethroo.us> Hello, I got an error when I run my spec test of a controlleur : the get and post methodes are unknown. here is my test file : ## setup_controller_spec.rb : ## require File.dirname(__FILE__) + '/../spec_helper' require "#{LIB_DIR}/application" require "#{LIB_DIR}/setups_controller" describe "A SetupController" do before :each do @setup_controller = SetupsController.new end it "should get step 1 first" do get 'step1' response.should be_success end ### here is my spec_helper file : ## ENV["RAILS_ENV"] = "test" require "rubygems" require "activerecord" require "spec" require File.dirname(__FILE__) + '/../config/environment' LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)), *%w[.. app controllers]) puts LIB_DIR ### I get the error : ## NoMethodError in 'A SetupController should get step 1 first' undefined method `get' for # ./setup_controller_spec.rb:13: ### (the same thing happens with the post methode) depending on the RSpec doc, this methode should exist in the rspec plugin... http://rspec.info/documentation/rails/writing/controllers.html ##sample : get 'some_action' response.should render_template("path/to/template/for/action") ### I think it's another require problem... Or maybe I make a mistake in my installation of the plugin (I just execute the 2 commands in my working directory : ruby script/plugin install http://rspec.rubyforge.org/svn/tags/REL_1_1_3/rspec ruby script/plugin install http://rspec.rubyforge.org/svn/tags/REL_1_1_3/rspec_on_rails ) Could somebody help me for this problem ? Thanks Thibault From dchelimsky at gmail.com Thu Aug 14 13:47:44 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 14 Aug 2008 12:47:44 -0500 Subject: [rspec-users] problem with get and post methods.. require missing ? In-Reply-To: <49405.76.166.178.99.1218735749.squirrel@seethroo.us> References: <49482.76.79.202.162.1218652426.squirrel@seethroo.us> <49824.76.79.202.162.1218658580.squirrel@seethroo.us> <49405.76.166.178.99.1218735749.squirrel@seethroo.us> Message-ID: <57c63afe0808141047n5252d46u154486511c67d44a@mail.gmail.com> On Thu, Aug 14, 2008 at 12:42 PM, wrote: > > Hello, I got an error when I run my spec test of a controlleur : the get > and post methodes are unknown. here is my test file : > > ## > setup_controller_spec.rb : > ## > > require File.dirname(__FILE__) + '/../spec_helper' > require "#{LIB_DIR}/application" > require "#{LIB_DIR}/setups_controller" > > describe "A SetupController" do > before :each do > @setup_controller = SetupsController.new > end > > it "should get step 1 first" do > get 'step1' > response.should be_success > end > ### > > here is my spec_helper file : > ## > ENV["RAILS_ENV"] = "test" > require "rubygems" > require "activerecord" > require "spec" > require File.dirname(__FILE__) + '/../config/environment' > LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)), *%w[.. app > controllers]) > > puts LIB_DIR > ### > > I get the error : > ## > NoMethodError in 'A SetupController should get step 1 first' > undefined method `get' for > # > ./setup_controller_spec.rb:13: The spec doesn't know it is supposed to be a controller spec. For it to know that, it needs to be in RAILS_ROOT/spec/controllers, or you can use this argument to the describe method: describe SetupController, :type => :controller do ... end HTH, David > ### > > (the same thing happens with the post methode) > > depending on the RSpec doc, this methode should exist in the rspec plugin... > http://rspec.info/documentation/rails/writing/controllers.html > ##sample : > get 'some_action' > response.should render_template("path/to/template/for/action") > ### > > I think it's another require problem... > Or maybe I make a mistake in my installation of the plugin > (I just execute the 2 commands in my working directory : > ruby script/plugin install > http://rspec.rubyforge.org/svn/tags/REL_1_1_3/rspec > ruby script/plugin install > http://rspec.rubyforge.org/svn/tags/REL_1_1_3/rspec_on_rails > ) > > Could somebody help me for this problem ? > Thanks > Thibault > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jonathan at parkerhill.com Thu Aug 14 13:51:42 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Thu, 14 Aug 2008 13:51:42 -0400 Subject: [rspec-users] problem with get and post methods.. require missing ? In-Reply-To: <57c63afe0808141047n5252d46u154486511c67d44a@mail.gmail.com> References: <49482.76.79.202.162.1218652426.squirrel@seethroo.us> <49824.76.79.202.162.1218658580.squirrel@seethroo.us> <49405.76.166.178.99.1218735749.squirrel@seethroo.us> <57c63afe0808141047n5252d46u154486511c67d44a@mail.gmail.com> Message-ID: <37F0522F-1C51-4D8F-A65B-947E4ADA2B61@parkerhill.com> and, is it SetupController or SetupsController ? On Aug 14, 2008, at 1:47 PM, David Chelimsky wrote: > On Thu, Aug 14, 2008 at 12:42 PM, wrote: >> >> Hello, I got an error when I run my spec test of a controlleur : >> the get >> and post methodes are unknown. here is my test file : >> >> ## >> setup_controller_spec.rb : >> ## >> >> require File.dirname(__FILE__) + '/../spec_helper' >> require "#{LIB_DIR}/application" >> require "#{LIB_DIR}/setups_controller" >> >> describe "A SetupController" do >> before :each do >> @setup_controller = SetupsController.new >> end >> >> it "should get step 1 first" do >> get 'step1' >> response.should be_success >> end >> ### >> >> here is my spec_helper file : >> ## >> ENV["RAILS_ENV"] = "test" >> require "rubygems" >> require "activerecord" >> require "spec" >> require File.dirname(__FILE__) + '/../config/environment' >> LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)), *%w >> [.. app >> controllers]) >> >> puts LIB_DIR >> ### >> >> I get the error : >> ## >> NoMethodError in 'A SetupController should get step 1 first' >> undefined method `get' for >> # >> ./setup_controller_spec.rb:13: > > The spec doesn't know it is supposed to be a controller spec. For it > to know that, it needs to be in RAILS_ROOT/spec/controllers, or you > can use this argument to the describe method: > > describe SetupController, :type => :controller do > ... > end > > HTH, > David > >> ### >> >> (the same thing happens with the post methode) >> >> depending on the RSpec doc, this methode should exist in the rspec >> plugin... >> http://rspec.info/documentation/rails/writing/controllers.html >> ##sample : >> get 'some_action' >> response.should render_template("path/to/template/for/action") >> ### >> >> I think it's another require problem... >> Or maybe I make a mistake in my installation of the plugin >> (I just execute the 2 commands in my working directory : >> ruby script/plugin install >> http://rspec.rubyforge.org/svn/tags/REL_1_1_3/rspec >> ruby script/plugin install >> http://rspec.rubyforge.org/svn/tags/REL_1_1_3/rspec_on_rails >> ) >> >> Could somebody help me for this problem ? >> Thanks >> Thibault >> _______________________________________________ >> 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 tgateau at seethroo.us Thu Aug 14 14:12:20 2008 From: tgateau at seethroo.us (tgateau at seethroo.us) Date: Thu, 14 Aug 2008 11:12:20 -0700 (PDT) Subject: [rspec-users] problem with get and post methods.. require missing ? In-Reply-To: <57c63afe0808141047n5252d46u154486511c67d44a@mail.gmail.com> References: <49482.76.79.202.162.1218652426.squirrel@seethroo.us> <49824.76.79.202.162.1218658580.squirrel@seethroo.us> <49405.76.166.178.99.1218735749.squirrel@seethroo.us> <57c63afe0808141047n5252d46u154486511c67d44a@mail.gmail.com> Message-ID: <49514.76.166.178.99.1218737540.squirrel@seethroo.us> I have checked : I am in the RAILS_ROOT/spec/controllers directory I have tried with the second solution, but the get and post methodes remain undefined. Could it be a version compatibility problem ? I'm using rails 2.1.0, and the REL_1_1_3 for the rspec plugin. What is the best version of rspec and rails to make them work well together ? Thib. > On Thu, Aug 14, 2008 at 12:42 PM, wrote: >> >> Hello, I got an error when I run my spec test of a controlleur : the get >> and post methodes are unknown. here is my test file : >> >> ## >> setup_controller_spec.rb : >> ## >> >> require File.dirname(__FILE__) + '/../spec_helper' >> require "#{LIB_DIR}/application" >> require "#{LIB_DIR}/setups_controller" >> >> describe "A SetupController" do >> before :each do >> @setup_controller = SetupsController.new >> end >> >> it "should get step 1 first" do >> get 'step1' >> response.should be_success >> end >> ### >> >> here is my spec_helper file : >> ## >> ENV["RAILS_ENV"] = "test" >> require "rubygems" >> require "activerecord" >> require "spec" >> require File.dirname(__FILE__) + '/../config/environment' >> LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)), *%w[.. app >> controllers]) >> >> puts LIB_DIR >> ### >> >> I get the error : >> ## >> NoMethodError in 'A SetupController should get step 1 first' >> undefined method `get' for >> # >> ./setup_controller_spec.rb:13: > > The spec doesn't know it is supposed to be a controller spec. For it > to know that, it needs to be in RAILS_ROOT/spec/controllers, or you > can use this argument to the describe method: > > describe SetupController, :type => :controller do > ... > end > > HTH, > David > >> ### >> >> (the same thing happens with the post methode) >> >> depending on the RSpec doc, this methode should exist in the rspec >> plugin... >> http://rspec.info/documentation/rails/writing/controllers.html >> ##sample : >> get 'some_action' >> response.should render_template("path/to/template/for/action") >> ### >> >> I think it's another require problem... >> Or maybe I make a mistake in my installation of the plugin >> (I just execute the 2 commands in my working directory : >> ruby script/plugin install >> http://rspec.rubyforge.org/svn/tags/REL_1_1_3/rspec >> ruby script/plugin install >> http://rspec.rubyforge.org/svn/tags/REL_1_1_3/rspec_on_rails >> ) >> >> Could somebody help me for this problem ? >> Thanks >> Thibault >> _______________________________________________ >> 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 Aug 14 14:24:31 2008 From: lists at ruby-forum.com (Ben Men) Date: Thu, 14 Aug 2008 20:24:31 +0200 Subject: [rspec-users] Autotest setup to run Story Runner? In-Reply-To: <54EB15AE-9C47-4D02-A765-C311F08FECBE@gmail.com> References: <54EB15AE-9C47-4D02-A765-C311F08FECBE@gmail.com> Message-ID: <22dff54ab7ee5ab93fd92a882139c677@ruby-forum.com> Kamal Fariz wrote: > > Can Story Runner run a specific scenario in a story? Like how Spec > Runner can just execute a particular example. > I realize this question is a little old, but I have exactly the same need. The only solution I have is trying to build much smaller stories so that they run a bit quicker, though this can get messy. I would absolutely love to be able to run changed scenarios upon saving, like how autotest works for the specs. Has anyone achieved this yet? -- Posted via http://www.ruby-forum.com/. From tgateau at seethroo.us Thu Aug 14 14:26:27 2008 From: tgateau at seethroo.us (tgateau at seethroo.us) Date: Thu, 14 Aug 2008 11:26:27 -0700 (PDT) Subject: [rspec-users] problem with get and post methods.. require missing ? In-Reply-To: <49514.76.166.178.99.1218737540.squirrel@seethroo.us> References: <49482.76.79.202.162.1218652426.squirrel@seethroo.us> <49824.76.79.202.162.1218658580.squirrel@seethroo.us> <49405.76.166.178.99.1218735749.squirrel@seethroo.us> <57c63afe0808141047n5252d46u154486511c67d44a@mail.gmail.com> <49514.76.166.178.99.1218737540.squirrel@seethroo.us> Message-ID: <49545.76.166.178.99.1218738387.squirrel@seethroo.us> > and, is it SetupController or SetupsController ? it's a SetupsController. my controller file is RAILS_ROOT/app/controllers/setups_controller.rb I have just tried with a setups_controller_spec.rb spec file, but the undefined method remains here is my new setups_controller_spec.rb file : in RAILS_ROOT/spec/controllers ## quire File.dirname(__FILE__) + '/../spec_helper' require "#{LIB_DIR}/application" require "#{LIB_DIR}/setups_controller" describe SetupsController, :type => :controller do before :each do @setup_controller = SetupsController.new end it "should exist" do @setup_controller.should_not be_nil @setup_controller.should be_an_instance_of(SetupsController) end it "should get step 1 first" do get 'step1' response.should be_success end end ### > > I have checked : I am in the RAILS_ROOT/spec/controllers directory > I have tried with the second solution, but the get and post methodes > remain undefined. > Could it be a version compatibility problem ? > I'm using rails 2.1.0, and the REL_1_1_3 for the rspec plugin. > What is the best version of rspec and rails to make them work well > together ? > Thib. > >> On Thu, Aug 14, 2008 at 12:42 PM, wrote: >>> >>> Hello, I got an error when I run my spec test of a controlleur : the >>> get >>> and post methodes are unknown. here is my test file : >>> >>> ## >>> setup_controller_spec.rb : >>> ## >>> >>> require File.dirname(__FILE__) + '/../spec_helper' >>> require "#{LIB_DIR}/application" >>> require "#{LIB_DIR}/setups_controller" >>> >>> describe "A SetupController" do >>> before :each do >>> @setup_controller = SetupsController.new >>> end >>> >>> it "should get step 1 first" do >>> get 'step1' >>> response.should be_success >>> end >>> ### >>> >>> here is my spec_helper file : >>> ## >>> ENV["RAILS_ENV"] = "test" >>> require "rubygems" >>> require "activerecord" >>> require "spec" >>> require File.dirname(__FILE__) + '/../config/environment' >>> LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)), *%w[.. >>> app >>> controllers]) >>> >>> puts LIB_DIR >>> ### >>> >>> I get the error : >>> ## >>> NoMethodError in 'A SetupController should get step 1 first' >>> undefined method `get' for >>> # >>> ./setup_controller_spec.rb:13: >> >> The spec doesn't know it is supposed to be a controller spec. For it >> to know that, it needs to be in RAILS_ROOT/spec/controllers, or you >> can use this argument to the describe method: >> >> describe SetupController, :type => :controller do >> ... >> end >> >> HTH, >> David >> >>> ### >>> >>> (the same thing happens with the post methode) >>> >>> depending on the RSpec doc, this methode should exist in the rspec >>> plugin... >>> http://rspec.info/documentation/rails/writing/controllers.html >>> ##sample : >>> get 'some_action' >>> response.should render_template("path/to/template/for/action") >>> ### >>> >>> I think it's another require problem... >>> Or maybe I make a mistake in my installation of the plugin >>> (I just execute the 2 commands in my working directory : >>> ruby script/plugin install >>> http://rspec.rubyforge.org/svn/tags/REL_1_1_3/rspec >>> ruby script/plugin install >>> http://rspec.rubyforge.org/svn/tags/REL_1_1_3/rspec_on_rails >>> ) >>> >>> Could somebody help me for this problem ? >>> Thanks >>> Thibault >>> _______________________________________________ >>> 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 zach.dennis at gmail.com Thu Aug 14 17:00:30 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 14 Aug 2008 17:00:30 -0400 Subject: [rspec-users] Autotest setup to run Story Runner? In-Reply-To: <22dff54ab7ee5ab93fd92a882139c677@ruby-forum.com> References: <54EB15AE-9C47-4D02-A765-C311F08FECBE@gmail.com> <22dff54ab7ee5ab93fd92a882139c677@ruby-forum.com> Message-ID: <85d99afe0808141400t2f0ba97tb93206dfa0684727@mail.gmail.com> On Thu, Aug 14, 2008 at 2:24 PM, Ben Men wrote: > Kamal Fariz wrote: > >> >> Can Story Runner run a specific scenario in a story? Like how Spec >> Runner can just execute a particular example. >> > > > I realize this question is a little old, but I have exactly the same > need. > > The only solution I have is trying to build much smaller stories so that > they run a bit quicker, though this can get messy. > > I would absolutely love to be able to run changed scenarios upon saving, > like how autotest works for the specs. > > Has anyone achieved this yet? That would be very difficult to do and to do well (with autotest or RSpactor) since stories cover a complete vertical slice of the application, and it'd be almost impossible to know what source file (or method) affect will what stories. Continuous integration works very well for this. Let another machine pull an update (or you can push an update) and it runs the specs and stories. When I was at Atomic Object I wrote a small growl notifier which received updates from our continuous integration server telling it when something failed. It was beautiful. Of course this was really easy to write since the continuous integration server was written in a way that allowed you to attach listeners (and remote monitors) to it over the network. -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From zach.dennis at gmail.com Thu Aug 14 17:09:56 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 14 Aug 2008 17:09:56 -0400 Subject: [rspec-users] Stubbing calls to the command line In-Reply-To: <477ba9f2b13cb126d6942e6c27c0413d@ruby-forum.com> References: <477ba9f2b13cb126d6942e6c27c0413d@ruby-forum.com> Message-ID: <85d99afe0808141409g3db9f968p94b6f855ab3be1e9@mail.gmail.com> On Thu, Aug 14, 2008 at 3:42 AM, Andy Croll wrote: > I'm using a call to wget to download a large datafile (multiple > megabytes) having assumed this will be quicker than using open-uri. > > How can I spec the behaviour? Ideally I'd also like to not be hitting > the internet every time I test! > > in my_object_spec.rb > > describe ".get_data" do > before(:each) do > @my_obj = MyObject.create(@valid_attributes) > end > it "should download the file" do > # behaviour goes here > end > end > > > in my_object.rb: > > def get_data > `wget --output-document=#{self.filename} #{self.file_uri}` > end > > I'll be massively grateful for any help anyone can give me. I might end up with a separate object which managed making the wget system call, and then I've have an integration-style test which ensured it correctly downloaded a given passed in URL. class MyObject def get_data WGet.download("http://some/path") end end class WGet def download(url) `wget #{url}` end end And I probably wouldn't have a spec for WGet. I might make the integration-style test a story. Perhaps when it ran I'd start script/server in test mode, and then copy over a dummy file and pull it down from "http://localhost:3000/public/dummy". -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From lists at ruby-forum.com Thu Aug 14 17:10:45 2008 From: lists at ruby-forum.com (Ben Men) Date: Thu, 14 Aug 2008 23:10:45 +0200 Subject: [rspec-users] Autotest setup to run Story Runner? In-Reply-To: <85d99afe0808141400t2f0ba97tb93206dfa0684727@mail.gmail.com> References: <54EB15AE-9C47-4D02-A765-C311F08FECBE@gmail.com> <22dff54ab7ee5ab93fd92a882139c677@ruby-forum.com> <85d99afe0808141400t2f0ba97tb93206dfa0684727@mail.gmail.com> Message-ID: Zach Dennis wrote: > That would be very difficult to do and to do well (with autotest or > RSpactor) since stories cover a complete vertical slice of the > application, and it'd be almost impossible to know what source file > (or method) affect will what stories. Sure, I agree, but I think it would still be incredibly useful even if it ran a single scenario every time you edit that scenario - not necessarily the source files that the scenario would "operate" on. > Continuous integration works very well for this. Let another machine > pull an update (or you can push an update) and it runs the specs and > stories. When I was at Atomic Object I wrote a small growl notifier > which received updates from our continuous integration server telling > it when something failed. It was beautiful. Of course this was really > easy to write since the continuous integration server was written in a > way that allowed you to attach listeners (and remote monitors) to it > over the network. I've already got TeamCity (highly recommended) running for both stories and examples every time I check into SVN. I'm doing things as test-driven as possible , and more times than not it's a story driving development rather than a spec. Test driving things this way means I get to run the stories all the time, and a bit of automation would be awesome. Hell, I'd settle to just be able to execute a single scenario by hand at this point. Running an entire story is still too large for me sometimes =) -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu Aug 14 17:18:07 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 14 Aug 2008 16:18:07 -0500 Subject: [rspec-users] problem with get and post methods.. require missing ? In-Reply-To: <49514.76.166.178.99.1218737540.squirrel@seethroo.us> References: <49482.76.79.202.162.1218652426.squirrel@seethroo.us> <49824.76.79.202.162.1218658580.squirrel@seethroo.us> <49405.76.166.178.99.1218735749.squirrel@seethroo.us> <57c63afe0808141047n5252d46u154486511c67d44a@mail.gmail.com> <49514.76.166.178.99.1218737540.squirrel@seethroo.us> Message-ID: <32242954-F903-4458-8B71-9AF191A0C07D@gmail.com> On Aug 14, 2008, at 1:12 PM, tgateau at seethroo.us wrote: > > I have checked : I am in the RAILS_ROOT/spec/controllers directory > I have tried with the second solution, but the get and post methodes > remain undefined. > Could it be a version compatibility problem ? > I'm using rails 2.1.0, and the REL_1_1_3 for the rspec plugin. > What is the best version of rspec and rails to make them work well > together ? Rails 2.1.0 came out months after Rspec 1.1.3 :) Try Rspec 1.1.4 (at github), Cheers, David > > Thib. > >> On Thu, Aug 14, 2008 at 12:42 PM, wrote: >>> >>> Hello, I got an error when I run my spec test of a controlleur : >>> the get >>> and post methodes are unknown. here is my test file : >>> >>> ## >>> setup_controller_spec.rb : >>> ## >>> >>> require File.dirname(__FILE__) + '/../spec_helper' >>> require "#{LIB_DIR}/application" >>> require "#{LIB_DIR}/setups_controller" >>> >>> describe "A SetupController" do >>> before :each do >>> @setup_controller = SetupsController.new >>> end >>> >>> it "should get step 1 first" do >>> get 'step1' >>> response.should be_success >>> end >>> ### >>> >>> here is my spec_helper file : >>> ## >>> ENV["RAILS_ENV"] = "test" >>> require "rubygems" >>> require "activerecord" >>> require "spec" >>> require File.dirname(__FILE__) + '/../config/environment' >>> LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)), * >>> %w[.. app >>> controllers]) >>> >>> puts LIB_DIR >>> ### >>> >>> I get the error : >>> ## >>> NoMethodError in 'A SetupController should get step 1 first' >>> undefined method `get' for >>> # >>> ./setup_controller_spec.rb:13: >> >> The spec doesn't know it is supposed to be a controller spec. For it >> to know that, it needs to be in RAILS_ROOT/spec/controllers, or you >> can use this argument to the describe method: >> >> describe SetupController, :type => :controller do >> ... >> end >> >> HTH, >> David >> >>> ### >>> >>> (the same thing happens with the post methode) >>> >>> depending on the RSpec doc, this methode should exist in the rspec >>> plugin... >>> http://rspec.info/documentation/rails/writing/controllers.html >>> ##sample : >>> get 'some_action' >>> response.should render_template("path/to/template/for/action") >>> ### >>> >>> I think it's another require problem... >>> Or maybe I make a mistake in my installation of the plugin >>> (I just execute the 2 commands in my working directory : >>> ruby script/plugin install >>> http://rspec.rubyforge.org/svn/tags/REL_1_1_3/rspec >>> ruby script/plugin install >>> http://rspec.rubyforge.org/svn/tags/REL_1_1_3/rspec_on_rails >>> ) >>> >>> Could somebody help me for this problem ? >>> Thanks >>> Thibault >>> _______________________________________________ >>> 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 tgateau at seethroo.us Thu Aug 14 20:23:54 2008 From: tgateau at seethroo.us (tgateau at seethroo.us) Date: Thu, 14 Aug 2008 17:23:54 -0700 (PDT) Subject: [rspec-users] problem with get and post methods.. require missing ? In-Reply-To: <32242954-F903-4458-8B71-9AF191A0C07D@gmail.com> References: <49482.76.79.202.162.1218652426.squirrel@seethroo.us> <49824.76.79.202.162.1218658580.squirrel@seethroo.us> <49405.76.166.178.99.1218735749.squirrel@seethroo.us> <57c63afe0808141047n5252d46u154486511c67d44a@mail.gmail.com> <49514.76.166.178.99.1218737540.squirrel@seethroo.us> <32242954-F903-4458-8B71-9AF191A0C07D@gmail.com> Message-ID: <50869.76.166.178.99.1218759834.squirrel@seethroo.us> I have updated the plugins, and it seems to be working well indeed ! Thanks Thib > On Aug 14, 2008, at 1:12 PM, tgateau at seethroo.us wrote: >> >> I have checked : I am in the RAILS_ROOT/spec/controllers directory >> I have tried with the second solution, but the get and post methodes >> remain undefined. >> Could it be a version compatibility problem ? >> I'm using rails 2.1.0, and the REL_1_1_3 for the rspec plugin. >> What is the best version of rspec and rails to make them work well >> together ? > > Rails 2.1.0 came out months after Rspec 1.1.3 :) > > Try Rspec 1.1.4 (at github), > > Cheers, > David > >> >> Thib. >> >>> On Thu, Aug 14, 2008 at 12:42 PM, wrote: >>>> >>>> Hello, I got an error when I run my spec test of a controlleur : >>>> the get >>>> and post methodes are unknown. here is my test file : >>>> >>>> ## >>>> setup_controller_spec.rb : >>>> ## >>>> >>>> require File.dirname(__FILE__) + '/../spec_helper' >>>> require "#{LIB_DIR}/application" >>>> require "#{LIB_DIR}/setups_controller" >>>> >>>> describe "A SetupController" do >>>> before :each do >>>> @setup_controller = SetupsController.new >>>> end >>>> >>>> it "should get step 1 first" do >>>> get 'step1' >>>> response.should be_success >>>> end >>>> ### >>>> >>>> here is my spec_helper file : >>>> ## >>>> ENV["RAILS_ENV"] = "test" >>>> require "rubygems" >>>> require "activerecord" >>>> require "spec" >>>> require File.dirname(__FILE__) + '/../config/environment' >>>> LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)), * >>>> %w[.. app >>>> controllers]) >>>> >>>> puts LIB_DIR >>>> ### >>>> >>>> I get the error : >>>> ## >>>> NoMethodError in 'A SetupController should get step 1 first' >>>> undefined method `get' for >>>> # >>>> ./setup_controller_spec.rb:13: >>> >>> The spec doesn't know it is supposed to be a controller spec. For it >>> to know that, it needs to be in RAILS_ROOT/spec/controllers, or you >>> can use this argument to the describe method: >>> >>> describe SetupController, :type => :controller do >>> ... >>> end >>> >>> HTH, >>> David >>> >>>> ### >>>> >>>> (the same thing happens with the post methode) >>>> >>>> depending on the RSpec doc, this methode should exist in the rspec >>>> plugin... >>>> http://rspec.info/documentation/rails/writing/controllers.html >>>> ##sample : >>>> get 'some_action' >>>> response.should render_template("path/to/template/for/action") >>>> ### >>>> >>>> I think it's another require problem... >>>> Or maybe I make a mistake in my installation of the plugin >>>> (I just execute the 2 commands in my working directory : >>>> ruby script/plugin install >>>> http://rspec.rubyforge.org/svn/tags/REL_1_1_3/rspec >>>> ruby script/plugin install >>>> http://rspec.rubyforge.org/svn/tags/REL_1_1_3/rspec_on_rails >>>> ) >>>> >>>> Could somebody help me for this problem ? >>>> Thanks >>>> Thibault >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Thu Aug 14 23:58:35 2008 From: lists at ruby-forum.com (Andy Croll) Date: Fri, 15 Aug 2008 05:58:35 +0200 Subject: [rspec-users] Stubbing calls to the command line In-Reply-To: <6886D175-2935-49A0-A58F-A4BF67C8D26A@railsnewbie.com> References: <477ba9f2b13cb126d6942e6c27c0413d@ruby-forum.com> <6886D175-2935-49A0-A58F-A4BF67C8D26A@railsnewbie.com> Message-ID: <05b59220955d1959f28d91b563bbba06@ruby-forum.com> Scott Taylor wrote: > Use Kernel.stub!(:`, "wget..."), and use Kernel.send(:`, "wget") > instead of literal backticks. Interestingly this doesn't quite work, but I used the principle. The Kernel module is mixed into Object so when you use `shellcommand... ` you can intercept the call on the object itself. So I was able to: @my_obj.stub!(:`) ...in the before block and @my_obj.should_receive(:`, "wget...") ...in the test and use the short form: `wget... ` ...in the actual method. Thanks for your help chaps. -- Posted via http://www.ruby-forum.com/. From mailing_lists at railsnewbie.com Fri Aug 15 01:43:28 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 15 Aug 2008 01:43:28 -0400 Subject: [rspec-users] Stubbing calls to the command line In-Reply-To: <05b59220955d1959f28d91b563bbba06@ruby-forum.com> References: <477ba9f2b13cb126d6942e6c27c0413d@ruby-forum.com> <6886D175-2935-49A0-A58F-A4BF67C8D26A@railsnewbie.com> <05b59220955d1959f28d91b563bbba06@ruby-forum.com> Message-ID: <8A29F48E-64ED-4C6F-A721-2BB928B72FD1@railsnewbie.com> On Aug 14, 2008, at 11:58 PM, Andy Croll wrote: > Scott Taylor wrote: >> Use Kernel.stub!(:`, "wget..."), and use Kernel.send(:`, "wget") >> instead of literal backticks. Oops. Meant Kernel.stub!(:`).with("wget..").and_return "some return value". >> > > Interestingly this doesn't quite work, but I used the principle. > > The Kernel module is mixed into Object so when you use > `shellcommand... > ` you can intercept the call on the object itself. > > So I was able to: > > @my_obj.stub!(:`) ...in the before block > > and > > @my_obj.should_receive(:`, "wget...") ...in the test > > and use the short form: > > `wget... ` ...in the actual method. > > Thanks for your help chaps. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Yeah - the top level should work, too: main = self main.should_receive(:`).with("wget...") `wget...` The downside is that you would need to pass around around your top level instance of object (what I've been calling "main" here). Scott From lists at ruby-forum.com Fri Aug 15 04:59:04 2008 From: lists at ruby-forum.com (Martin Bernd Schmeil) Date: Fri, 15 Aug 2008 10:59:04 +0200 Subject: [rspec-users] Any news on the rSpec books? In-Reply-To: References: <200805031906.49313.michael@schuerig.de> Message-ID: Any news on this? -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Fri Aug 15 06:28:35 2008 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 15 Aug 2008 11:28:35 +0100 Subject: [rspec-users] Proper Encapsulation of SQL WHERE / ORDER BY Clauses Message-ID: <85B7D8F5-DD95-49D2-8327-C6108F712FAC@mattwynne.net> Hi TDD Fans, I'm pretty new to Ruby / RSpec / Rails but not to TDD. This is more of a general 'how do you do good design in a rails app' question than an rspec-specific question. I'm asking it here because I know this list is read by lots of people who care about good design, but please feel free to point me somewhere else if you think it's not relevant to this list. Probably through my inexperience with the language / framework, I'm finding that I'm tending to clutter my controllers with SQL-specific stuff. e.g. def get_cities City.paginate(:all, get_find_params.merge!( :page => params [:page] )) end def get_find_params find_params = { :order => get_order_clause } if params[:name] || params[:last_24] find_params.merge! :conditions => get_conditions end return find_params end def get_conditions "name like '%#{params[:name]}%'" + (params[:last_24] ? " AND created_at >= '#{DateTime.now - 1.days}'" : "") end def get_order_clause (params[:sort] ? 'created_at DESC, ' : "") + 'name ASC' end This is obviously horribly brittle to write specs for, but I'm not really sure what I should do instead... How do I get my models to encapsulate this stuff, especially given I'm using the will_paginate plug-in? Any tips / pointers greatly appreciated. cheers, Matt http://blog.mattwynne.net http://songkick.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Fri Aug 15 06:58:05 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 15 Aug 2008 05:58:05 -0500 Subject: [rspec-users] Any news on the rSpec books? In-Reply-To: References: <200805031906.49313.michael@schuerig.de> Message-ID: <57c63afe0808150358i52db0e4cn747d2d8a429cbcee@mail.gmail.com> On Fri, Aug 15, 2008 at 3:59 AM, Martin Bernd Schmeil wrote: > Any news on this? We've enlisted the help of three more authors: Dan North, Bryan Helmkamp and Zach Dennis. Dan is going to contribute a BDD overview. Bryan and Zach are working on the section on using RSpec with Rails. I'm wrapping up a rather detailed tutorial. We don't have a date certain on this, but we are definitely making rapid progress at this point. I'll keep the list posted. Cheers, David > > -- > 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 Fri Aug 15 07:25:05 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 15 Aug 2008 06:25:05 -0500 Subject: [rspec-users] Proper Encapsulation of SQL WHERE / ORDER BY Clauses In-Reply-To: <85B7D8F5-DD95-49D2-8327-C6108F712FAC@mattwynne.net> References: <85B7D8F5-DD95-49D2-8327-C6108F712FAC@mattwynne.net> Message-ID: <57c63afe0808150425m24301802uafa04d237d8df17e@mail.gmail.com> On Fri, Aug 15, 2008 at 5:28 AM, Matt Wynne wrote: > Hi TDD Fans, > I'm pretty new to Ruby / RSpec / Rails but not to TDD. > This is more of a general 'how do you do good design in a rails app' > question than an rspec-specific question. I'm asking it here because I know > this list is read by lots of people who care about good design, but please > feel free to point me somewhere else if you think it's not relevant to this > list. > Probably through my inexperience with the language / framework, I'm finding > that I'm tending to clutter my controllers with SQL-specific stuff. > e.g. > def get_cities > > City.paginate(:all, get_find_params.merge!( :page => params[:page] )) > > end > > def get_find_params > find_params = { :order => get_order_clause } > > if params[:name] || params[:last_24] > find_params.merge! :conditions => get_conditions > end > > return find_params > > end > > def get_conditions > "name like '%#{params[:name]}%'" + (params[:last_24] ? " AND > created_at >= '#{DateTime.now - 1.days}'" : "") > end > > def get_order_clause > (params[:sort] ? 'created_at DESC, ' : "") + 'name ASC' > end > This is obviously horribly brittle to write specs for, but I'm not really > sure what I should do instead... > How do I get my models to encapsulate this stuff, especially given I'm using > the will_paginate plug-in? > Any tips / pointers greatly appreciated. > cheers, > Matt Hey Matt - welcome! The paginate() method lives on the model class, so there's nothing stopping you from wrapping those calls in methods on the model, slinging around the params object. # CityController def get_cities City.paginate_all(params) end # City def self.paginate_all(params) self.paginate(:all, get_find_params(params).merge!(:page => params[:page])) end etc HTH, David From matt at mattwynne.net Fri Aug 15 07:39:06 2008 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 15 Aug 2008 12:39:06 +0100 Subject: [rspec-users] Any news on the rSpec books? In-Reply-To: <57c63afe0808150358i52db0e4cn747d2d8a429cbcee@mail.gmail.com> References: <200805031906.49313.michael@schuerig.de> <57c63afe0808150358i52db0e4cn747d2d8a429cbcee@mail.gmail.com> Message-ID: Aidy Lewis (who posts on here from time to time) and I were using RSpec at a .NET shop, using the story runner as a layer over Watir to drive ASP.NET websites, and I know Aidy is still carrying on with that work. I'd suggest including a chapter about how to drive non-ruby apps through RSpec might broaden the book's appeal. cheers, Matt On 15 Aug 2008, at 11:58, David Chelimsky wrote: > On Fri, Aug 15, 2008 at 3:59 AM, Martin Bernd Schmeil > wrote: >> Any news on this? > > We've enlisted the help of three more authors: Dan North, Bryan > Helmkamp and Zach Dennis. Dan is going to contribute a BDD overview. > Bryan and Zach are working on the section on using RSpec with Rails. > I'm wrapping up a rather detailed tutorial. > > We don't have a date certain on this, but we are definitely making > rapid progress at this point. I'll keep the list posted. > > Cheers, > David > >> >> -- >> 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 matt at mattwynne.net Fri Aug 15 07:46:26 2008 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 15 Aug 2008 12:46:26 +0100 Subject: [rspec-users] Proper Encapsulation of SQL WHERE / ORDER BY Clauses In-Reply-To: <57c63afe0808150425m24301802uafa04d237d8df17e@mail.gmail.com> References: <85B7D8F5-DD95-49D2-8327-C6108F712FAC@mattwynne.net> <57c63afe0808150425m24301802uafa04d237d8df17e@mail.gmail.com> Message-ID: On 15 Aug 2008, at 12:25, David Chelimsky wrote: > Hey Matt - welcome! > > The paginate() method lives on the model class, so there's nothing > stopping you from wrapping those calls in methods on the model, > slinging around the params object. > > # CityController > > def get_cities > City.paginate_all(params) > end > > # City > > def self.paginate_all(params) > self.paginate(:all, get_find_params(params).merge!(:page => params > [:page])) > end > > etc > Aha. Cool, thanks. For my next question: how do I go about driving out change to the model, spec-first? I'm thinking I would call (in my spec) City.should_receive(:paginate).with(:conditions => "name like '%# {test_params[:name}%'" .... ) City.paginate_all(test_params) Thereby covering the code in get_find_params() Is that the right approach? cheers, Matt From matt at mattwynne.net Fri Aug 15 08:42:02 2008 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 15 Aug 2008 13:42:02 +0100 Subject: [rspec-users] Autotest and subclasses / namespaces Message-ID: <52F53D48-AAED-4580-B2F2-844CD664F7A9@mattwynne.net> I am writing a controller admin/cities_controller.rb it inherits from AdminController, so it's defined like class Admin::CitiesController > AdminController Whenever I save the controller file, autotest freaks out: uninitialized constant Admin::AdminController (NameError) I'm pretty used to just hitting CTRL-C to get autotest to re-load all the files, or flicking to the spec file, and saving it to get a similar effect. But it is fairly irritating. Any suggestions for how to hack autotest to get this to flow more nicely? cheers, Matt ---- http://blog.mattwynne.net http://songkick.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Fri Aug 15 09:29:59 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 15 Aug 2008 08:29:59 -0500 Subject: [rspec-users] Proper Encapsulation of SQL WHERE / ORDER BY Clauses In-Reply-To: References: <85B7D8F5-DD95-49D2-8327-C6108F712FAC@mattwynne.net> <57c63afe0808150425m24301802uafa04d237d8df17e@mail.gmail.com> Message-ID: On Aug 15, 2008, at 6:46 AM, Matt Wynne wrote: > On 15 Aug 2008, at 12:25, David Chelimsky wrote: > >> Hey Matt - welcome! >> >> The paginate() method lives on the model class, so there's nothing >> stopping you from wrapping those calls in methods on the model, >> slinging around the params object. >> >> # CityController >> >> def get_cities >> City.paginate_all(params) >> end >> >> # City >> >> def self.paginate_all(params) >> self.paginate(:all, get_find_params(params).merge!(:page => >> params[:page])) >> end >> >> etc >> > > Aha. Cool, thanks. > > For my next question: how do I go about driving out change to the > model, spec-first? > > I'm thinking I would call (in my spec) > > City.should_receive(:paginate).with(:conditions => "name like > '%#{test_params[:name}%'" .... ) > City.paginate_all(test_params) > > Thereby covering the code in get_find_params() > > Is that the right approach? That's probably how I would do it. Might also consider wrapping the params in a separate object that manages the extraction. David > > > cheers, > Matt > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Fri Aug 15 09:31:29 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 15 Aug 2008 08:31:29 -0500 Subject: [rspec-users] Any news on the rSpec books? In-Reply-To: References: <200805031906.49313.michael@schuerig.de> <57c63afe0808150358i52db0e4cn747d2d8a429cbcee@mail.gmail.com> Message-ID: On Aug 15, 2008, at 6:39 AM, Matt Wynne wrote: > Aidy Lewis (who posts on here from time to time) and I were using > RSpec at a .NET shop, using the story runner as a layer over Watir > to drive ASP.NET websites, and I know Aidy is still carrying on with > that work. > > I'd suggest including a chapter about how to drive non-ruby apps > through RSpec might broaden the book's appeal. Great idea. Thanks! > > > cheers, > Matt > > On 15 Aug 2008, at 11:58, David Chelimsky wrote: > >> On Fri, Aug 15, 2008 at 3:59 AM, Martin Bernd Schmeil >> wrote: >>> Any news on this? >> >> We've enlisted the help of three more authors: Dan North, Bryan >> Helmkamp and Zach Dennis. Dan is going to contribute a BDD overview. >> Bryan and Zach are working on the section on using RSpec with Rails. >> I'm wrapping up a rather detailed tutorial. >> >> We don't have a date certain on this, but we are definitely making >> rapid progress at this point. I'll keep the list posted. >> >> Cheers, >> David >> >>> >>> -- >>> Posted via http://www.ruby-forum.com/. >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aidy.lewis at googlemail.com Fri Aug 15 10:23:27 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Fri, 15 Aug 2008 15:23:27 +0100 Subject: [rspec-users] Rake and Story HTML Message-ID: <7ac2300c0808150723v2348b20m8d065bad41a11e29@mail.gmail.com> Hi, I have a rake file require 'rake' require 'rake/runtest' task :default => [:dcs] task :dcs do Rake.run_tests 'projects/dcs/runner/**/*.rb' end That cycles through the runner folder and executes the tests. However, I am unsure as to where I can run the ruby command with the html format switch. I am having trouble with Watir running through Team City so I am just a sheduled batch file cd\ cd c:\workingDir svn update cd C:\workingDir\trunk rake PAUSE Cheers Aidy From tastapod at gmail.com Fri Aug 15 11:29:43 2008 From: tastapod at gmail.com (Dan North) Date: Fri, 15 Aug 2008 16:29:43 +0100 Subject: [rspec-users] Any news on the rSpec books? In-Reply-To: References: <200805031906.49313.michael@schuerig.de> <57c63afe0808150358i52db0e4cn747d2d8a429cbcee@mail.gmail.com> Message-ID: There are also some success stories around using rspec story runner + jruby as a functional testing layer for Java apps. Someone blogged about it a while ago but I forget who. Cheers, Dan 2008/8/15 David Chelimsky > > On Aug 15, 2008, at 6:39 AM, Matt Wynne wrote: > > Aidy Lewis (who posts on here from time to time) and I were using RSpec at >> a .NET shop, using the story runner as a layer over Watir to drive >> ASP.NET websites, and I know Aidy is still carrying on with that work. >> >> I'd suggest including a chapter about how to drive non-ruby apps through >> RSpec might broaden the book's appeal. >> > > Great idea. Thanks! > > > > >> >> cheers, >> Matt >> >> On 15 Aug 2008, at 11:58, David Chelimsky wrote: >> >> On Fri, Aug 15, 2008 at 3:59 AM, Martin Bernd Schmeil >>> wrote: >>> >>>> Any news on this? >>>> >>> >>> We've enlisted the help of three more authors: Dan North, Bryan >>> Helmkamp and Zach Dennis. Dan is going to contribute a BDD overview. >>> Bryan and Zach are working on the section on using RSpec with Rails. >>> I'm wrapping up a rather detailed tutorial. >>> >>> We don't have a date certain on this, but we are definitely making >>> rapid progress at this point. I'll keep the list posted. >>> >>> Cheers, >>> David >>> >>> >>>> -- >>>> Posted via http://www.ruby-forum.com/. >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mailing_lists at railsnewbie.com Fri Aug 15 19:19:31 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 15 Aug 2008 19:19:31 -0400 Subject: [rspec-users] Proper Encapsulation of SQL WHERE / ORDER BY Clauses In-Reply-To: References: <85B7D8F5-DD95-49D2-8327-C6108F712FAC@mattwynne.net> <57c63afe0808150425m24301802uafa04d237d8df17e@mail.gmail.com> Message-ID: <0F7F05B1-2344-42EF-98BF-57D1430E75B8@railsnewbie.com> On Aug 15, 2008, at 9:29 AM, David Chelimsky wrote: > On Aug 15, 2008, at 6:46 AM, Matt Wynne wrote: > >> On 15 Aug 2008, at 12:25, David Chelimsky wrote: >> >>> Hey Matt - welcome! >>> >>> The paginate() method lives on the model class, so there's nothing >>> stopping you from wrapping those calls in methods on the model, >>> slinging around the params object. >>> >>> # CityController >>> >>> def get_cities >>> City.paginate_all(params) >>> end >>> >>> # City >>> >>> def self.paginate_all(params) >>> self.paginate(:all, get_find_params(params).merge!(:page => >>> params[:page])) >>> end >>> >>> etc >>> >> >> Aha. Cool, thanks. >> >> For my next question: how do I go about driving out change to the >> model, spec-first? >> >> I'm thinking I would call (in my spec) >> >> City.should_receive(:paginate).with(:conditions => "name like >> '%#{test_params[:name}%'" .... ) >> City.paginate_all(test_params) >> >> Thereby covering the code in get_find_params() >> >> Is that the right approach? > > That's probably how I would do it. Might also consider wrapping the > params in a separate object that manages the extraction. That's how I've started doing it - putting sql statements in a module: http://gist.github.com/5675 This allows me to test the sql statements seperately from the actual finder. Also - just to give you the heads up - You should almost never use literal string substitutions in sql statements - it allows for sql injection attacks: http://en.wikipedia.org/wiki/Sql_injection Best, Scott Taylor From jonathan at parkerhill.com Fri Aug 15 19:51:44 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Fri, 15 Aug 2008 19:51:44 -0400 Subject: [rspec-users] how many scenarios Message-ID: Hi, at the risk of posing an insignificant question, I'm curious how many Scenarios you are putting into a given Story file? How many would you consider 'alot'? 'too much'? and why? From mark at mwilden.com Fri Aug 15 20:17:35 2008 From: mark at mwilden.com (Mark Wilden) Date: Fri, 15 Aug 2008 17:17:35 -0700 Subject: [rspec-users] how many scenarios In-Reply-To: References: Message-ID: <3c30da400808151717x485fe604md5bb64179524ff66@mail.gmail.com> On Fri, Aug 15, 2008 at 4:51 PM, Jonathan Linowes wrote: > Hi, at the risk of posing an insignificant question, I'm curious how many > Scenarios you are putting into a given Story file? How many would you > consider 'alot'? 'too much'? and why? > As few as possible. As many as necessary. (Don't you hate einsteinian answers like that?) ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sat Aug 16 08:10:21 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 16 Aug 2008 07:10:21 -0500 Subject: [rspec-users] formatter writing output on different files In-Reply-To: <200808141649.46931.stefano.crocco@alice.it> References: <200808141649.46931.stefano.crocco@alice.it> Message-ID: <57c63afe0808160510j36eb9fe4pe7b19e4ccd95c816@mail.gmail.com> On Thu, Aug 14, 2008 at 9:49 AM, Stefano Crocco wrote: > Hello to every one, > > First of all, sorry if this message has already reached the list. I sent it > yesterday, but since today I don't see it in the archives, I'm resending it. > > I'm writing an application and using rspec to test it. I like very much it's > html output, since it allows me to look at it and see how something is > supposed to work. The only problem is that the list of example is quickly > growing to a size that makes looking for a particular example a bit time- > consuming. So I got the idea to split the output into several files. Something > like: > > a_spec.rb -> a_results.html > b_spec.rb -> b_results.html > > Since I put all the specs related to a class in a single spec file, this would > allow me to have a clear overview of the class and to be able to locate > quickly the example I'm looking for. The only problem is that, as far as I > know, rspec doesn't provide similar features. > > So, I decided to try and write a custom rspec formatter which does what I > described above. Before I start coding, however, I'd like to know the answers > to some questions: > > 1) is there any reason my idea is not a good one? I think it's a good idea. > 2) has something like this already been implemented? I searched google, this > mailing list and the ruby mailing list, but found nothing Not to my knowledge. > 3) what's the best way for a formatter to access the name of the file an > example comes from? Looking at the RDoc documentation, the only way I found is > to use the Spec::Example::ExampleMethods#implementation_backtrace, which > contains the filename and line of the example in its first entry. Is this > reliable? Is there a better way? None that I know of in the current code base. Good luck! > > Thanks in advance > > Stefano > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sat Aug 16 08:12:56 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 16 Aug 2008 07:12:56 -0500 Subject: [rspec-users] Autotest and subclasses / namespaces In-Reply-To: <52F53D48-AAED-4580-B2F2-844CD664F7A9@mattwynne.net> References: <52F53D48-AAED-4580-B2F2-844CD664F7A9@mattwynne.net> Message-ID: <57c63afe0808160512n30b65591qa2517f924ff6626f@mail.gmail.com> On Fri, Aug 15, 2008 at 7:42 AM, Matt Wynne wrote: > I am writing a controller admin/cities_controller.rb > it inherits from AdminController, so it's defined like > class Admin::CitiesController > AdminController > Whenever I save the controller file, autotest freaks out: > uninitialized constant Admin::AdminController (NameError) > I'm pretty used to just hitting CTRL-C to get autotest to re-load all the > files, or flicking to the spec file, and saving it to get a similar effect. > But it is fairly irritating. > Any suggestions for how to hack autotest to get this to flow more nicely? I've seen this happen on occasion but have just done what you're doing (workarounds) to get by. Has anyone experienced this running autotest against test/unit? I don't think rspec is doing anything that would interfere with autotest loading the right files, but it's possible. > > cheers, > Matt > ---- > http://blog.mattwynne.net > http://songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Sat Aug 16 10:15:20 2008 From: lists at ruby-forum.com (Joseph Wilk) Date: Sat, 16 Aug 2008 16:15:20 +0200 Subject: [rspec-users] Real story examples & guidelines learnt Message-ID: Hello, I have been putting together over the last couple of months various guidelines I've learnt and picked as I've used Rspec stories. After speaking to lots of people I found they initially found great resources to understand Rspec's story framework. However from there a lot of people have struggled to find real examples or guidance on stories. I do not claim to be an expert but I hope that this might help people who are using Rspec stories and want to learn from some of my mistakes and successes. I would also be happy to hear what other people have learnt as they use stories and any other feedback. http://www.joesniff.co.uk/ruby/telling-a-good-story-rspec-stories-from-the-trenches.html -- Joseph Wilk http://www.joesniff.co.uk -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Sat Aug 16 15:32:04 2008 From: ben at benmabey.com (Ben Mabey) Date: Sat, 16 Aug 2008 13:32:04 -0600 Subject: [rspec-users] Autotest and subclasses / namespaces In-Reply-To: <52F53D48-AAED-4580-B2F2-844CD664F7A9@mattwynne.net> References: <52F53D48-AAED-4580-B2F2-844CD664F7A9@mattwynne.net> Message-ID: <48A72B34.4070805@benmabey.com> Matt Wynne wrote: > I am writing a controller admin/cities_controller.rb > > it inherits from AdminController, so it's defined like > > class Admin::CitiesController > AdminController > > Whenever I save the controller file, autotest freaks out: > > uninitialized constant Admin::AdminController (NameError) > > I'm pretty used to just hitting CTRL-C to get autotest to re-load all > the files, or flicking to the spec file, and saving it to get a > similar effect. > > But it is fairly irritating. > > Any suggestions for how to hack autotest to get this to flow more nicely? Hmm... I am using namedspaced controllers on my current project and I am not running into those issues. I am using rspec edge, ZenTest 3.9.1, and rails 2.1.0. Have you copied your code exactly in your original email? If so, I might see a difference in how we are doing things and that might be your problem. My base controller is also namedspaced.. So in my app/controllers/admin dir I have the following: base_contoller.rb: module Admin class BaseController < ::ApplicationController .... end end Then: other_controller.rb: module Admin class OtherController < BaseController ... end end Note that I could also do: base_contoller.rb: class Admin::BaseController < ApplicationController other_controller.rb: class Admin::OtherController < Admin::BaseController So.. If your AdminController is namespaced you should change your other controllers to: class Admin::CitiesController < Admin::AdminController If it is not namespaced (but, it really should be IMO) then you could try this: class Admin::CitiesController < ::AdminController Hope that helps, Ben From cremes.devlist at mac.com Sat Aug 16 17:25:28 2008 From: cremes.devlist at mac.com (Chuck Remes) Date: Sat, 16 Aug 2008 16:25:28 -0500 Subject: [rspec-users] [bug] mock expectations fail when a subclass is instantiated Message-ID: <63BA672A-3BE7-4EEC-8A83-B5669DD834C8@mac.com> I took a look at the web site but did not see any issue/bug tracker, so I'm reporting this here. The mock framework fails to differentiate between messages sent to a parent class versus a subclass, so some of my expectations fail when I assert some expectation on a parent. Here's code to show it: cremes$ cat c.rb class A end class B < A end class C def foo a = A.new b = B.new end end cremes$ cat c_spec.rb require 'rubygems' require 'spec' require 'c' describe C, "mock" do it "should incorrectly pick up message sent to parent class as a subclass err" do A.should_receive(:new).once c = C.new c.foo end end cremes$ spec c_spec.rb F 1) NoMethodError in 'C mock should incorrectly pick up message sent to parent class as a subclass err' undefined method `new' for B:Class ./c.rb:10:in `foo' ./c_spec.rb:9: Finished in 0.006664 seconds 1 example, 1 failure If I capture the exception thrown here, it is at lib/spec/mocks/ proxy.rb line 75. I'd provide a patch if I knew how to fix it! :) cr From dchelimsky at gmail.com Sat Aug 16 18:51:44 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 16 Aug 2008 17:51:44 -0500 Subject: [rspec-users] [bug] mock expectations fail when a subclass is instantiated In-Reply-To: <63BA672A-3BE7-4EEC-8A83-B5669DD834C8@mac.com> References: <63BA672A-3BE7-4EEC-8A83-B5669DD834C8@mac.com> Message-ID: <57c63afe0808161551o3b3a7595wd2acbb4c9b06aa31@mail.gmail.com> On Sat, Aug 16, 2008 at 4:25 PM, Chuck Remes wrote: > I took a look at the web site but did not see any issue/bug tracker http://rspec.lighthouseapp.com I forwarded this there: http://rspec.lighthouseapp.com/projects/5645/tickets/496 Will respond in that ticket. Cheers, David >so I'm > reporting this here. > > The mock framework fails to differentiate between messages sent to a parent > class versus a subclass, so some of my expectations fail when I assert some > expectation on a parent. Here's code to show it: > > cremes$ cat c.rb > class A > end > > class B < A > end > > class C > def foo > a = A.new > b = B.new > end > end > > > cremes$ cat c_spec.rb > require 'rubygems' > require 'spec' > require 'c' > > describe C, "mock" do > it "should incorrectly pick up message sent to parent class as a subclass > err" do > A.should_receive(:new).once > c = C.new > c.foo > end > end > > > cremes$ spec c_spec.rb > F > > 1) > NoMethodError in 'C mock should incorrectly pick up message sent to parent > class as a subclass err' > undefined method `new' for B:Class > ./c.rb:10:in `foo' > ./c_spec.rb:9: > > Finished in 0.006664 seconds > > 1 example, 1 failure > > > If I capture the exception thrown here, it is at lib/spec/mocks/proxy.rb > line 75. I'd provide a patch if I knew how to fix it! :) > > cr > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aidy.lewis at googlemail.com Mon Aug 18 03:34:20 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Mon, 18 Aug 2008 00:34:20 -0700 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> Message-ID: <7ac2300c0808180034i7406f9f0n816145106b75b54f@mail.gmail.com> Matt, Do you want to pair on this? I am writing some stuff for the Watir site. I sent you some example code as well. Aidy On 12/08/2008, Matt Wynne wrote: > > Can I help the project by writing some docs about the plain-text story > runner for the rspec.info website? It would surely help me to get it wired > in my own mind if I have to write it up for the world. > > Would this be helpful / appreciated? > > What format would you want them in? > > > cheers, > Matt > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Mon Aug 18 03:43:31 2008 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 18 Aug 2008 08:43:31 +0100 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <7ac2300c0808180034i7406f9f0n816145106b75b54f@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <7ac2300c0808180034i7406f9f0n816145106b75b54f@mail.gmail.com> Message-ID: <495F17AB-2183-424F-9794-BBA99E6ACE11@mattwynne.net> That would be cool, though I think it might be hard to compete with something like this: http://www.joesniff.co.uk/ruby/telling-a-good-story-rspec-stories- from-the-trenches.html cheers, Matt ---- http://blog.mattwynne.net On 18 Aug 2008, at 08:34, aidy lewis wrote: > Matt, > > Do you want to pair on this? I am writing some stuff for the Watir > site. I sent you some example code as well. > > Aidy > > On 12/08/2008, Matt Wynne wrote: >> >> Can I help the project by writing some docs about the plain-text >> story >> runner for the rspec.info website? It would surely help me to get >> it wired >> in my own mind if I have to write it up for the world. >> >> Would this be helpful / appreciated? >> >> What format would you want them in? >> >> >> cheers, >> Matt >> >> _______________________________________________ >> 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 eshopworks.co.uk Mon Aug 18 04:52:13 2008 From: joe at eshopworks.co.uk (Joseph Wilk) Date: Mon, 18 Aug 2008 09:52:13 +0100 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <495F17AB-2183-424F-9794-BBA99E6ACE11@mattwynne.net> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <7ac2300c0808180034i7406f9f0n816145106b75b54f@mail.gmail.com> <495F17AB-2183-424F-9794-BBA99E6ACE11@mattwynne.net> Message-ID: <1219049533.19643.17.camel@esw023.esw.eshopworks.co.uk> Hello, I left out of my Rspec story post Selenium/Webrat integration. I thought I would release that as a separate post. While I can write about how I deal with Selenium/Webrat in Rspec I'm yet to use Watir. So I think putting something together on Watir integration as Matt suggested would be really helpful to the community. -- Joseph Wilk http://www.joesniff.co.uk On Mon, 2008-08-18 at 08:43 +0100, Matt Wynne wrote: > That would be cool, though I think it might be hard to compete with > something like this: > http://www.joesniff.co.uk/ruby/telling-a-good-story-rspec-stories- > from-the-trenches.html > > cheers, > Matt > ---- > http://blog.mattwynne.net > > > On 18 Aug 2008, at 08:34, aidy lewis wrote: > > > Matt, > > > > Do you want to pair on this? I am writing some stuff for the Watir > > site. I sent you some example code as well. > > > > Aidy > > > > On 12/08/2008, Matt Wynne wrote: > >> > >> Can I help the project by writing some docs about the plain-text > >> story > >> runner for the rspec.info website? It would surely help me to get > >> it wired > >> in my own mind if I have to write it up for the world. > >> > >> Would this be helpful / appreciated? > >> > >> What format would you want them in? > >> > >> > >> cheers, > >> Matt > >> > >> _______________________________________________ > >> 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 Mon Aug 18 05:07:41 2008 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 18 Aug 2008 10:07:41 +0100 Subject: [rspec-users] Autotest and subclasses / namespaces In-Reply-To: <48A72B34.4070805@benmabey.com> References: <52F53D48-AAED-4580-B2F2-844CD664F7A9@mattwynne.net> <48A72B34.4070805@benmabey.com> Message-ID: <83080370-B851-40F6-9289-9AA15AB63CF8@mattwynne.net> Thanks for the tips Ben. We upgraded to Rails 2.1 (from 1.x) on Friday and this seems to have gone away. I'll report back though if I learn anything else. cheers, Matt ---- http://blog.mattwynne.net On 16 Aug 2008, at 20:32, Ben Mabey wrote: > Matt Wynne wrote: >> I am writing a controller admin/cities_controller.rb >> >> it inherits from AdminController, so it's defined like >> >> class Admin::CitiesController > AdminController >> >> Whenever I save the controller file, autotest freaks out: >> >> uninitialized constant Admin::AdminController (NameError) >> >> I'm pretty used to just hitting CTRL-C to get autotest to re-load all >> the files, or flicking to the spec file, and saving it to get a >> similar effect. >> >> But it is fairly irritating. >> >> Any suggestions for how to hack autotest to get this to flow more >> nicely? > > > Hmm... I am using namedspaced controllers on my current project and > I am > not running into those issues. I am using rspec edge, ZenTest 3.9.1, > and rails 2.1.0. > > Have you copied your code exactly in your original email? If so, I > might see a difference in how we are doing things and that might be > your > problem. > My base controller is also namedspaced.. So in my app/controllers/ > admin > dir I have the following: > > base_contoller.rb: > module Admin > class BaseController < ::ApplicationController > .... > end > end > > Then: > > other_controller.rb: > module Admin > class OtherController < BaseController > ... > end > end > > Note that I could also do: > > base_contoller.rb: > class Admin::BaseController < ApplicationController > > other_controller.rb: > class Admin::OtherController < Admin::BaseController > > > > > So.. If your AdminController is namespaced you should change your > other > controllers to: > class Admin::CitiesController < Admin::AdminController > > If it is not namespaced (but, it really should be IMO) then you could > try this: > class Admin::CitiesController < ::AdminController > > Hope that helps, > Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Mon Aug 18 05:57:26 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 18 Aug 2008 11:57:26 +0200 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> Message-ID: <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> On Tue, Aug 12, 2008 at 6:45 PM, Matt Wynne wrote: > Can I help the project by writing some docs about the plain-text story > runner for the rspec.info website? It would surely help me to get it wired > in my own mind if I have to write it up for the world. > Would this be helpful / appreciated? > What format would you want them in? > The RSpec Story runner is likely to be deprecated in favour of the new feature runner (temporarily called Cucumber). http://www.nabble.com/-ANN--Cucumber-td18876816.html The RSpec Story runner will continue to exist for a while, I just wanted to let you know that future development and documentation efforts will be focused on Cucumber. Cucumber also has some documentation and examples on Github, more specifically: * How to use without Rails * How to use with Rails+Webrat * How to use with Watir Please let me know if you'd like to help out documenting Cucumber. One thing that is missing is a migration guide from RSpec Story runner. Cheers, Aslak > cheers, > Matt > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Mon Aug 18 07:06:23 2008 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 18 Aug 2008 12:06:23 +0100 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> Message-ID: > > The RSpec Story runner is likely to be deprecated in favour of the new > feature runner (temporarily called Cucumber). > http://www.nabble.com/-ANN--Cucumber-td18876816.html > And this is going to be distributed as a separate plug-in from RSpec? From aslak.hellesoy at gmail.com Mon Aug 18 07:11:47 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 18 Aug 2008 13:11:47 +0200 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> Message-ID: <8d961d900808180411i1710578ew3673201968c794df@mail.gmail.com> On Mon, Aug 18, 2008 at 1:06 PM, Matt Wynne wrote: >> >> The RSpec Story runner is likely to be deprecated in favour of the new >> feature runner (temporarily called Cucumber). >> http://www.nabble.com/-ANN--Cucumber-td18876816.html >> > > And this is going to be distributed as a separate plug-in from RSpec? For the time being it is in a separate Git repo. It can be built as a gem and installed as a gem. Rails users can also install it as a plugin. We haven't decided yet whether it will continue to be in a separate repo or added to the RSpec codebase. From a maintenance perspective I think it's easier to keep things separate and small than lump everything together in a big codebase. From a Rails user perspective it means you need to install 3 plugins instead of 2 (RSpec+RSpec-Rails+Cucumber). What do you think is the best thing to do? Aslak > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Mon Aug 18 07:24:55 2008 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 18 Aug 2008 12:24:55 +0100 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <8d961d900808180411i1710578ew3673201968c794df@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <8d961d900808180411i1710578ew3673201968c794df@mail.gmail.com> Message-ID: I think it's better to make them separate. Conceptually, the story runner slightly confuses the identity of what RSpec is - is it for specifying behaviour of individual classes (a la TDD) or is it for specifying the behaviour of the whole system? I think the describe / it / should thing is powerful enough in its own right as a way to express behaviour of individual classes. Coming from writing XUnit tests I absolutely love it - it's such a natural way to describe the desired behaviour. Presumably you might also end up needing something like a Cucumber- Rails plugin, or are you envisaging tying Cucumber to rails? cheers, Matt ---- http://blog.mattwynne.net http://songkick.com In case you wondered: The opinions expressed in this email are my own and do not necessarily reflect the views of any former, current or future employers of mine. On 18 Aug 2008, at 12:11, aslak hellesoy wrote: > On Mon, Aug 18, 2008 at 1:06 PM, Matt Wynne > wrote: >>> >>> The RSpec Story runner is likely to be deprecated in favour of >>> the new >>> feature runner (temporarily called Cucumber). >>> http://www.nabble.com/-ANN--Cucumber-td18876816.html >>> >> >> And this is going to be distributed as a separate plug-in from RSpec? > > For the time being it is in a separate Git repo. It can be built as a > gem and installed as a gem. Rails users can also install it as a > plugin. > > We haven't decided yet whether it will continue to be in a separate > repo or added to the RSpec codebase. From a maintenance perspective I > think it's easier to keep things separate and small than lump > everything together in a big codebase. From a Rails user perspective > it means you need to install 3 plugins instead of 2 > (RSpec+RSpec-Rails+Cucumber). > > What do you think is the best thing to do? > > 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 aslak.hellesoy at gmail.com Mon Aug 18 08:13:21 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 18 Aug 2008 14:13:21 +0200 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <8d961d900808180411i1710578ew3673201968c794df@mail.gmail.com> Message-ID: <8d961d900808180513x575bcdf8we5a0d6da8eb1b474@mail.gmail.com> On Mon, Aug 18, 2008 at 1:24 PM, Matt Wynne wrote: > I think it's better to make them separate. Conceptually, the story runner > slightly confuses the identity of what RSpec is - is it for specifying > behaviour of individual classes (a la TDD) or is it for specifying the > behaviour of the whole system? I think the describe / it / should thing is > powerful enough in its own right as a way to express behaviour of individual > classes. Coming from writing XUnit tests I absolutely love it - it's such a > natural way to describe the desired behaviour. > > Presumably you might also end up needing something like a Cucumber-Rails > plugin, or are you envisaging tying Cucumber to rails? > Cucumber is not tied to Rails at all - it is designed to work with any Ruby code (including JRuby and hopefully soon other Rubies). However, Cucumber comes with a couple of hooks for Rails, which in turn have a dependency on RSpec-Rails: http://github.com/aslakhellesoy/cucumber/tree/master/lib/cucumber/rails/rspec.rb http://github.com/aslakhellesoy/cucumber/tree/master/lib/cucumber/rails/world.rb When you use Cucumber's generators to set it up in a Rails project (as described in the README), these hooks are enabled by default. Aslak > cheers, > Matt > ---- > http://blog.mattwynne.net > http://songkick.com > > In case you wondered: The opinions expressed in this email are my own and do > not necessarily reflect the views of any former, current or future employers > of mine. > > On 18 Aug 2008, at 12:11, aslak hellesoy wrote: > >> On Mon, Aug 18, 2008 at 1:06 PM, Matt Wynne wrote: >>>> >>>> The RSpec Story runner is likely to be deprecated in favour of the new >>>> feature runner (temporarily called Cucumber). >>>> http://www.nabble.com/-ANN--Cucumber-td18876816.html >>>> >>> >>> And this is going to be distributed as a separate plug-in from RSpec? >> >> For the time being it is in a separate Git repo. It can be built as a >> gem and installed as a gem. Rails users can also install it as a >> plugin. >> >> We haven't decided yet whether it will continue to be in a separate >> repo or added to the RSpec codebase. From a maintenance perspective I >> think it's easier to keep things separate and small than lump >> everything together in a big codebase. From a Rails user perspective >> it means you need to install 3 plugins instead of 2 >> (RSpec+RSpec-Rails+Cucumber). >> >> What do you think is the best thing to do? >> >> 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 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aidy.lewis at googlemail.com Mon Aug 18 08:29:08 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Mon, 18 Aug 2008 13:29:08 +0100 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> Message-ID: <7ac2300c0808180529w3d22758bxdf7ac20f93402999@mail.gmail.com> Hi Aslak 2008/8/18 aslak hellesoy : > * How to use with Watir gem sources --add http://gems.github.com/ gem install aslakhellesoy-cucumber I am unable top find the Watir and Cucumber example Aidy From aslak.hellesoy at gmail.com Mon Aug 18 08:34:24 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 18 Aug 2008 14:34:24 +0200 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <7ac2300c0808180529w3d22758bxdf7ac20f93402999@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <7ac2300c0808180529w3d22758bxdf7ac20f93402999@mail.gmail.com> Message-ID: <8d961d900808180534l39d4f432je9f0a180a080bf23@mail.gmail.com> On Mon, Aug 18, 2008 at 2:29 PM, aidy lewis wrote: > Hi Aslak > > > 2008/8/18 aslak hellesoy : >> * How to use with Watir > > gem sources --add http://gems.github.com/ > gem install aslakhellesoy-cucumber > > I am unable top find the Watir and Cucumber example > I may have forgotten to include the examples in the gem. Until I get it fixed and push a new gem - try to get the source from Git instead: git clone git://github.com/aslakhellesoy/cucumber.git Look in the examples/watir directory: http://github.com/aslakhellesoy/cucumber/tree/master/examples/watir Aslak > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aidy.lewis at googlemail.com Mon Aug 18 09:02:23 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Mon, 18 Aug 2008 14:02:23 +0100 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <8d961d900808180534l39d4f432je9f0a180a080bf23@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <7ac2300c0808180529w3d22758bxdf7ac20f93402999@mail.gmail.com> <8d961d900808180534l39d4f432je9f0a180a080bf23@mail.gmail.com> Message-ID: <7ac2300c0808180602x6324411bkcdadc53dbbb16423@mail.gmail.com> Aslak > Look in the examples/watir directory: > http://github.com/aslakhellesoy/cucumber/tree/master/examples/watir > > Aslak > OK. Can I expand on this for your example? Aidy From matt at mattwynne.net Mon Aug 18 09:20:16 2008 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 18 Aug 2008 14:20:16 +0100 Subject: [rspec-users] Autotest and subclasses / namespaces In-Reply-To: <83080370-B851-40F6-9289-9AA15AB63CF8@mattwynne.net> References: <52F53D48-AAED-4580-B2F2-844CD664F7A9@mattwynne.net> <48A72B34.4070805@benmabey.com> <83080370-B851-40F6-9289-9AA15AB63CF8@mattwynne.net> Message-ID: Nope, despite my efforts to repro this earlier, it's started happening again. Check out the output from autotest: /usr/local/bin/ruby -S script/spec -O spec/spec.opts /Users/matt/ Documents/projects/songkick/skweb/app/controllers/admin/ cities_controller.rb spec/controllers/admin/cities_controller_spec.rb /Users/matt/Documents/projects/songkick/skweb/app/controllers/admin/ cities_controller.rb:1: uninitialized constant Admin (NameError) from /Users/matt/Documents/projects/songkick/skweb/vendor/ plugins/rspec/lib/spec/runner/example_group_runner.rb:14:in `load' from /Users/matt/Documents/projects/songkick/skweb/vendor/ plugins/rspec/lib/spec/runner/example_group_runner.rb:14:in `load_files' from /Users/matt/Documents/projects/songkick/skweb/vendor/ plugins/rspec/lib/spec/runner/example_group_runner.rb:13:in `each' from /Users/matt/Documents/projects/songkick/skweb/vendor/ plugins/rspec/lib/spec/runner/example_group_runner.rb:13:in `load_files' from /Users/matt/Documents/projects/songkick/skweb/vendor/ plugins/rspec/lib/spec/runner/options.rb:98:in `run_examples' from /Users/matt/Documents/projects/songkick/skweb/vendor/ plugins/rspec/lib/spec/runner/command_line.rb:19:in `run' from script/spec:4 /usr/local/bin/ruby -S script/spec -O spec/spec.opts /Users/matt/ Documents/projects/songkick/skweb/app/controllers/admin/ cities_controller.rb spec/controllers/admin/cities_controller_spec.rb ................ Finished in 0.183342 seconds 16 examples, 0 failures The first time, I saved the controller, and it bombed. The second time, I switched to the spec and saved that. Each time it looks as though the same parameters are being passed to script/spec, but something different is happening after that... I've tried variously referring to the base class ::AdminController, as Ben suggested but it doesn't seem to make any difference. Right now, it looks like class Admin::CitiesController < ::AdminController Perhaps the reason the spec works is that it shares some behaviour with the AdminController specs: require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require File.expand_path(File.dirname(__FILE__) + '/../ admin_controller_spec') describe Admin::CitiesController do it_should_behave_like "all admin controllers" ... etc I'm using ZenTest 3.10.0 / Rails 2.1 / RSpec 1.1.4 cheers, Matt ---- http://blog.mattwynne.net http://songkick.com In case you wondered: The opinions expressed in this email are my own and do not necessarily reflect the views of any former, current or future employers of mine. On 18 Aug 2008, at 10:07, Matt Wynne wrote: > Thanks for the tips Ben. > > We upgraded to Rails 2.1 (from 1.x) on Friday and this seems to > have gone away. I'll report back though if I learn anything else. > > cheers, > Matt > ---- > http://blog.mattwynne.net > > On 16 Aug 2008, at 20:32, Ben Mabey wrote: > >> Matt Wynne wrote: >>> I am writing a controller admin/cities_controller.rb >>> >>> it inherits from AdminController, so it's defined like >>> >>> class Admin::CitiesController > AdminController >>> >>> Whenever I save the controller file, autotest freaks out: >>> >>> uninitialized constant Admin::AdminController (NameError) >>> >>> I'm pretty used to just hitting CTRL-C to get autotest to re-load >>> all >>> the files, or flicking to the spec file, and saving it to get a >>> similar effect. >>> >>> But it is fairly irritating. >>> >>> Any suggestions for how to hack autotest to get this to flow more >>> nicely? >> >> >> Hmm... I am using namedspaced controllers on my current project >> and I am >> not running into those issues. I am using rspec edge, ZenTest 3.9.1, >> and rails 2.1.0. >> >> Have you copied your code exactly in your original email? If so, I >> might see a difference in how we are doing things and that might >> be your >> problem. >> My base controller is also namedspaced.. So in my app/controllers/ >> admin >> dir I have the following: >> >> base_contoller.rb: >> module Admin >> class BaseController < ::ApplicationController >> .... >> end >> end >> >> Then: >> >> other_controller.rb: >> module Admin >> class OtherController < BaseController >> ... >> end >> end >> >> Note that I could also do: >> >> base_contoller.rb: >> class Admin::BaseController < ApplicationController >> >> other_controller.rb: >> class Admin::OtherController < Admin::BaseController >> >> >> >> >> So.. If your AdminController is namespaced you should change your >> other >> controllers to: >> class Admin::CitiesController < Admin::AdminController >> >> If it is not namespaced (but, it really should be IMO) then you could >> try this: >> class Admin::CitiesController < ::AdminController >> >> Hope that helps, >> Ben >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Mon Aug 18 09:27:37 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 18 Aug 2008 08:27:37 -0500 Subject: [rspec-users] Autotest and subclasses / namespaces In-Reply-To: References: <52F53D48-AAED-4580-B2F2-844CD664F7A9@mattwynne.net> <48A72B34.4070805@benmabey.com> <83080370-B851-40F6-9289-9AA15AB63CF8@mattwynne.net> Message-ID: <57c63afe0808180627i482ef7aqbf65593c664f483b@mail.gmail.com> On Mon, Aug 18, 2008 at 8:20 AM, Matt Wynne wrote: > Nope, despite my efforts to repro this earlier, it's started happening > again. > > Check out the output from autotest: > > /usr/local/bin/ruby -S script/spec -O spec/spec.opts > /Users/matt/Documents/projects/songkick/skweb/app/controllers/admin/cities_controller.rb The fact that autotest is trying to load the controller file itself is probably the source of the problem here. I'm sure you noted this earlier, but what version of rspec and zentest are you using? Have you modified the mappings in rails_rspec.rb (you can do this in RAILS_ROOT/.autotest or ~/.autotest)? > spec/controllers/admin/cities_controller_spec.rb > /Users/matt/Documents/projects/songkick/skweb/app/controllers/admin/cities_controller.rb:1: > uninitialized constant Admin (NameError) > from > /Users/matt/Documents/projects/songkick/skweb/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:14:in > `load' > from > /Users/matt/Documents/projects/songkick/skweb/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:14:in > `load_files' > from > /Users/matt/Documents/projects/songkick/skweb/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:13:in > `each' > from > /Users/matt/Documents/projects/songkick/skweb/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:13:in > `load_files' > from > /Users/matt/Documents/projects/songkick/skweb/vendor/plugins/rspec/lib/spec/runner/options.rb:98:in > `run_examples' > from > /Users/matt/Documents/projects/songkick/skweb/vendor/plugins/rspec/lib/spec/runner/command_line.rb:19:in > `run' > from script/spec:4 > /usr/local/bin/ruby -S script/spec -O spec/spec.opts > /Users/matt/Documents/projects/songkick/skweb/app/controllers/admin/cities_controller.rb > spec/controllers/admin/cities_controller_spec.rb > ................ > > Finished in 0.183342 seconds > > 16 examples, 0 failures > > > The first time, I saved the controller, and it bombed. The second time, I > switched to the spec and saved that. Each time it looks as though the same > parameters are being passed to script/spec, but something different is > happening after that... > > I've tried variously referring to the base class ::AdminController, as Ben > suggested but it doesn't seem to make any difference. > > Right now, it looks like > > class Admin::CitiesController < ::AdminController > > > Perhaps the reason the spec works is that it shares some behaviour with the > AdminController specs: > > require File.expand_path(File.dirname(__FILE__) + > '/../../spec_helper') > require File.expand_path(File.dirname(__FILE__) + > '/../admin_controller_spec') > > describe Admin::CitiesController do > > it_should_behave_like "all admin controllers" > > ... etc > > > I'm using ZenTest 3.10.0 / Rails 2.1 / RSpec 1.1.4 > > cheers, > Matt > ---- > http://blog.mattwynne.net > http://songkick.com > > In case you wondered: The opinions expressed in this email are my own and do > not necessarily reflect the views of any former, current or future employers > of mine. > > On 18 Aug 2008, at 10:07, Matt Wynne wrote: > >> Thanks for the tips Ben. >> >> We upgraded to Rails 2.1 (from 1.x) on Friday and this seems to have gone >> away. I'll report back though if I learn anything else. >> >> cheers, >> Matt >> ---- >> http://blog.mattwynne.net >> >> On 16 Aug 2008, at 20:32, Ben Mabey wrote: >> >>> Matt Wynne wrote: >>>> >>>> I am writing a controller admin/cities_controller.rb >>>> >>>> it inherits from AdminController, so it's defined like >>>> >>>> class Admin::CitiesController > AdminController >>>> >>>> Whenever I save the controller file, autotest freaks out: >>>> >>>> uninitialized constant Admin::AdminController (NameError) >>>> >>>> I'm pretty used to just hitting CTRL-C to get autotest to re-load all >>>> the files, or flicking to the spec file, and saving it to get a >>>> similar effect. >>>> >>>> But it is fairly irritating. >>>> >>>> Any suggestions for how to hack autotest to get this to flow more >>>> nicely? >>> >>> >>> Hmm... I am using namedspaced controllers on my current project and I am >>> not running into those issues. I am using rspec edge, ZenTest 3.9.1, >>> and rails 2.1.0. >>> >>> Have you copied your code exactly in your original email? If so, I >>> might see a difference in how we are doing things and that might be your >>> problem. >>> My base controller is also namedspaced.. So in my app/controllers/admin >>> dir I have the following: >>> >>> base_contoller.rb: >>> module Admin >>> class BaseController < ::ApplicationController >>> .... >>> end >>> end >>> >>> Then: >>> >>> other_controller.rb: >>> module Admin >>> class OtherController < BaseController >>> ... >>> end >>> end >>> >>> Note that I could also do: >>> >>> base_contoller.rb: >>> class Admin::BaseController < ApplicationController >>> >>> other_controller.rb: >>> class Admin::OtherController < Admin::BaseController >>> >>> >>> >>> >>> So.. If your AdminController is namespaced you should change your other >>> controllers to: >>> class Admin::CitiesController < Admin::AdminController >>> >>> If it is not namespaced (but, it really should be IMO) then you could >>> try this: >>> class Admin::CitiesController < ::AdminController >>> >>> Hope that helps, >>> Ben >>> _______________________________________________ >>> 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 aslak.hellesoy at gmail.com Mon Aug 18 09:27:54 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 18 Aug 2008 15:27:54 +0200 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <7ac2300c0808180602x6324411bkcdadc53dbbb16423@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <7ac2300c0808180529w3d22758bxdf7ac20f93402999@mail.gmail.com> <8d961d900808180534l39d4f432je9f0a180a080bf23@mail.gmail.com> <7ac2300c0808180602x6324411bkcdadc53dbbb16423@mail.gmail.com> Message-ID: <8d961d900808180627of1a5541k821efd00f42723f9@mail.gmail.com> On Mon, Aug 18, 2008 at 3:02 PM, aidy lewis wrote: > Aslak > >> Look in the examples/watir directory: >> http://github.com/aslakhellesoy/cucumber/tree/master/examples/watir >> >> Aslak >> > OK. Can I expand on this for your example? > What do you mean by expand? Aslak > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aidy.lewis at googlemail.com Mon Aug 18 09:31:23 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Mon, 18 Aug 2008 14:31:23 +0100 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <8d961d900808180627of1a5541k821efd00f42723f9@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <7ac2300c0808180529w3d22758bxdf7ac20f93402999@mail.gmail.com> <8d961d900808180534l39d4f432je9f0a180a080bf23@mail.gmail.com> <7ac2300c0808180602x6324411bkcdadc53dbbb16423@mail.gmail.com> <8d961d900808180627of1a5541k821efd00f42723f9@mail.gmail.com> Message-ID: <7ac2300c0808180631y6b9aad4aqab1182cb7cdcac63@mail.gmail.com> Aslak 2008/8/18 aslak hellesoy : > > What do you mean by expand? > > Aslak > I was going to give a more detailed example... Aidy From matt at mattwynne.net Mon Aug 18 09:39:00 2008 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 18 Aug 2008 14:39:00 +0100 Subject: [rspec-users] Autotest and subclasses / namespaces In-Reply-To: <57c63afe0808180627i482ef7aqbf65593c664f483b@mail.gmail.com> References: <52F53D48-AAED-4580-B2F2-844CD664F7A9@mattwynne.net> <48A72B34.4070805@benmabey.com> <83080370-B851-40F6-9289-9AA15AB63CF8@mattwynne.net> <57c63afe0808180627i482ef7aqbf65593c664f483b@mail.gmail.com> Message-ID: <5F8FADFE-0680-410E-B721-3B3E8CC7A152@mattwynne.net> On 18 Aug 2008, at 14:27, David Chelimsky wrote: >> Check out the output from autotest: >> >> /usr/local/bin/ruby -S script/spec -O spec/spec.opts >> /Users/matt/Documents/projects/songkick/skweb/app/controllers/ >> admin/cities_controller.rb > > The fact that autotest is trying to load the controller file itself is > probably the source of the problem here. I had changed the controller file though (I'm refactoring). Would you expect autotest to still just load the corresponding spec, rather than the changed controller source file itself? > > I'm sure you noted this earlier, but what version of rspec and zentest > are you using? >> I'm using ZenTest 3.10.0 / Rails 2.1 / RSpec 1.1.4 > Have you modified the mappings in rails_rspec.rb (you > can do this in RAILS_ROOT/.autotest or ~/.autotest)? I do have an ~/.autotest but it's only got Growl stuff in it, and there's nothing in my rails root. cheers, Matt From aslak.hellesoy at gmail.com Mon Aug 18 09:40:17 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 18 Aug 2008 15:40:17 +0200 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <7ac2300c0808180631y6b9aad4aqab1182cb7cdcac63@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <7ac2300c0808180529w3d22758bxdf7ac20f93402999@mail.gmail.com> <8d961d900808180534l39d4f432je9f0a180a080bf23@mail.gmail.com> <7ac2300c0808180602x6324411bkcdadc53dbbb16423@mail.gmail.com> <8d961d900808180627of1a5541k821efd00f42723f9@mail.gmail.com> <7ac2300c0808180631y6b9aad4aqab1182cb7cdcac63@mail.gmail.com> Message-ID: <8d961d900808180640w327aff44n6c5f216364e9d661@mail.gmail.com> On Mon, Aug 18, 2008 at 3:31 PM, aidy lewis wrote: > Aslak > > 2008/8/18 aslak hellesoy : > >> >> What do you mean by expand? >> >> Aslak >> > > I was going to give a more detailed example... > That would be awesome. If you're familiar with Git you can clone my Cucumber and commit your changes to your clone. If not I'll accept a patch. Just put it in RSpec's Lighthouse and tag it with cucumber Aslak > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Aug 18 09:42:04 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 18 Aug 2008 08:42:04 -0500 Subject: [rspec-users] Autotest and subclasses / namespaces In-Reply-To: <5F8FADFE-0680-410E-B721-3B3E8CC7A152@mattwynne.net> References: <52F53D48-AAED-4580-B2F2-844CD664F7A9@mattwynne.net> <48A72B34.4070805@benmabey.com> <83080370-B851-40F6-9289-9AA15AB63CF8@mattwynne.net> <57c63afe0808180627i482ef7aqbf65593c664f483b@mail.gmail.com> <5F8FADFE-0680-410E-B721-3B3E8CC7A152@mattwynne.net> Message-ID: <57c63afe0808180642k6de76384i5b2027e16de74e10@mail.gmail.com> On Mon, Aug 18, 2008 at 8:39 AM, Matt Wynne wrote: > On 18 Aug 2008, at 14:27, David Chelimsky wrote: >>> >>> Check out the output from autotest: >>> >>> /usr/local/bin/ruby -S script/spec -O spec/spec.opts >>> >>> /Users/matt/Documents/projects/songkick/skweb/app/controllers/admin/cities_controller.rb >> >> The fact that autotest is trying to load the controller file itself is >> probably the source of the problem here. > > I had changed the controller file though (I'm refactoring). Would you expect > autotest to still just load the corresponding spec, rather than the changed > controller source file itself? That's correct. Autotest *should* only load the spec files and they, in turn, should require anything they need. I'm not saying this is an autotest bug. It's getting it's direction as to what files to load when from the mappings set up in rails_rspec.rb and .autotest, so the bug is likely in there somewhere. > >> >> I'm sure you noted this earlier, but what version of rspec and zentest >> are you using? > >>> I'm using ZenTest 3.10.0 / Rails 2.1 / RSpec 1.1.4 > >> Have you modified the mappings in rails_rspec.rb (you >> can do this in RAILS_ROOT/.autotest or ~/.autotest)? > > I do have an ~/.autotest but it's only got Growl stuff in it, and there's > nothing in my rails root. K - that shouldn't be the issue. Why don't you try getting the latest rspec from git and see if the problem persists. > > cheers, > Matt > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Mon Aug 18 10:53:24 2008 From: lists at ruby-forum.com (Andy Orahood) Date: Mon, 18 Aug 2008 16:53:24 +0200 Subject: [rspec-users] rspec book In-Reply-To: <4898396E-3350-4B81-90E7-0A4D70DB4D56@gmail.com> References: <179298cf86522724ea39d7c88f79f9e6@ruby-forum.com> <4898396E-3350-4B81-90E7-0A4D70DB4D56@gmail.com> Message-ID: David Chelimsky wrote: > On Jun 16, 2008, at 6:37 AM, Juanma Cervera wrote: >> When can we expect it to arrive? > > Assuming no set-backs, beta by mid-summer. > > Cheers, > David Oh I hope so. Is the beta close? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Mon Aug 18 10:55:39 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 18 Aug 2008 09:55:39 -0500 Subject: [rspec-users] rspec book In-Reply-To: References: <179298cf86522724ea39d7c88f79f9e6@ruby-forum.com> <4898396E-3350-4B81-90E7-0A4D70DB4D56@gmail.com> Message-ID: <57c63afe0808180755h6cd215a9qd87fc7678037cd86@mail.gmail.com> On Mon, Aug 18, 2008 at 9:53 AM, Andy Orahood wrote: > David Chelimsky wrote: >> On Jun 16, 2008, at 6:37 AM, Juanma Cervera wrote: >>> When can we expect it to arrive? >> >> Assuming no set-backs, beta by mid-summer. >> >> Cheers, >> David > > Oh I hope so. Is the beta close? Depends on the meaning of "close." Given that we started working on the book over 2 years ago, we're close. Happening next week? Probably not. I'll be blogging/posting/etc when I have a solid schedule to report. Cheers, David > -- > 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 Mon Aug 18 12:00:03 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Mon, 18 Aug 2008 17:00:03 +0100 Subject: [rspec-users] command line options in story runner run method Message-ID: <7ac2300c0808180900m7b91dd18ldf02b969983dbfc6@mail.gmail.com> Hi, Can anyone give me some sample syntax of using a command line switch in the Story Runner run method please? Thanks Aidy From matt at mattwynne.net Mon Aug 18 12:10:37 2008 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 18 Aug 2008 17:10:37 +0100 Subject: [rspec-users] Argument Constraints where the Argument is a Hash Message-ID: <3F457557-DB10-401A-9766-1669E9881A49@mattwynne.net> Hi folks, I have an object whose constructor I want to stub, specifying that it should be passed a hash containing an expected set of key / value pairs. Note that the actual hash might contain more key / value pairs, but I don't care, as long as my expected ones are there I thought I might be able to write this: expected_params = { :page => "1", :city_id => city.id.to_s, :name => "thingy" } Venue::Query.should_receive(:new).with( include (expected_params) ).and_return(query) ... but it doesn't seem to work. What's my best approach? Thanks for your patience and support as I get up to speed with this stuff folks. You're all very kind! cheers, Matt ---- http://blog.mattwynne.net http://songkick.com In case you wondered: The opinions expressed in this email are my own and do not necessarily reflect the views of any former, current or future employers of mine. -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Mon Aug 18 12:22:25 2008 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 18 Aug 2008 17:22:25 +0100 Subject: [rspec-users] Argument Constraints where the Argument is a Hash In-Reply-To: <3F457557-DB10-401A-9766-1669E9881A49@mattwynne.net> References: <3F457557-DB10-401A-9766-1669E9881A49@mattwynne.net> Message-ID: Okay, I realised the with() is calling the == method on whatever you pass in, so I did this: module EquateAnyHashContainingAllMyElements def ==(other) self.keys.all? do |key| other.has_key?(key) end end end .... expected_params = { :page => "1", :city_id => city.id.to_s, :name => name_filter } expected_params.extend(EquateAnyHashContainingAllMyElements) Venue::Query.should_receive(:new).with ( expected_params ).and_return(query) Thoughts? Is there a neater way to do this? Be as brutal as you like ... ;) cheers, Matt ---- http://blog.mattwynne.net http://songkick.com In case you wondered: The opinions expressed in this email are my own and do not necessarily reflect the views of any former, current or future employers of mine. On 18 Aug 2008, at 17:10, Matt Wynne wrote: > Hi folks, > > I have an object whose constructor I want to stub, specifying that > it should be passed a hash containing an expected set of key / > value pairs. > > Note that the actual hash might contain more key / value pairs, but > I don't care, as long as my expected ones are there > > I thought I might be able to write this: > > expected_params = { > :page => "1", > :city_id => city.id.to_s, > :name => "thingy" } > > Venue::Query.should_receive(:new).with( include > (expected_params) ).and_return(query) > > ... but it doesn't seem to work. > > What's my best approach? > > Thanks for your patience and support as I get up to speed with this > stuff folks. You're all very kind! > > cheers, > Matt > ---- > http://blog.mattwynne.net > http://songkick.com > > In case you wondered: The opinions expressed in this email are my > own and do not necessarily reflect the views of any former, current > or future employers of mine. > > _______________________________________________ > 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 Mon Aug 18 12:23:13 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 18 Aug 2008 11:23:13 -0500 Subject: [rspec-users] Argument Constraints where the Argument is a Hash In-Reply-To: <3F457557-DB10-401A-9766-1669E9881A49@mattwynne.net> References: <3F457557-DB10-401A-9766-1669E9881A49@mattwynne.net> Message-ID: On Aug 18, 2008, at 11:10 AM, Matt Wynne wrote: > Hi folks, > > I have an object whose constructor I want to stub, specifying that > it should be passed a hash containing an expected set of key / value > pairs. > > Note that the actual hash might contain more key / value pairs, but > I don't care, as long as my expected ones are there > > I thought I might be able to write this: > > expected_params = { > :page => "1", > :city_id => city.id.to_s, > :name => "thingy" } > > > Venue: > :Query. > should_receive( > :new).with( include(expected_params) ).and_return(query) Close ... ...with( hash_including(expected_params).and... Cheers, David > > ... but it doesn't seem to work. > > What's my best approach? > > Thanks for your patience and support as I get up to speed with this > stuff folks. You're all very kind! > > cheers, > Matt > ---- > http://blog.mattwynne.net > http://songkick.com > > In case you wondered: The opinions expressed in this email are my > own and do not necessarily reflect the views of any former, current > or future employers of mine. > > _______________________________________________ > 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 Aug 18 13:01:04 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Mon, 18 Aug 2008 18:01:04 +0100 Subject: [rspec-users] command line options in story runner run method In-Reply-To: <7ac2300c0808180900m7b91dd18ldf02b969983dbfc6@mail.gmail.com> References: <7ac2300c0808180900m7b91dd18ldf02b969983dbfc6@mail.gmail.com> Message-ID: <7ac2300c0808181001x4729339w9a652c2c395e5e9e@mail.gmail.com> Hi, 2008/8/18 aidy lewis : > Hi, > > Can anyone give me some sample syntax of using a command line switch > in the Story Runner run method please? This is what I have def run_local_story(filename, options={}) options = {"-fh:" => "C:/rspec_reports/#{filename}.htm"} run File.join(File.dirname(__FILE__), "../projects/#{filename}"), options end However, no exception is thrown, but neither is a file created. I am also unsure on what part of the code the html report should be created. Aidy From dchelimsky at gmail.com Mon Aug 18 13:07:40 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 18 Aug 2008 12:07:40 -0500 Subject: [rspec-users] command line options in story runner run method In-Reply-To: <7ac2300c0808181001x4729339w9a652c2c395e5e9e@mail.gmail.com> References: <7ac2300c0808180900m7b91dd18ldf02b969983dbfc6@mail.gmail.com> <7ac2300c0808181001x4729339w9a652c2c395e5e9e@mail.gmail.com> Message-ID: <57c63afe0808181007i6d270b8dq703b659ccbb4a4ec@mail.gmail.com> On Mon, Aug 18, 2008 at 12:01 PM, aidy lewis wrote: > Hi, > > 2008/8/18 aidy lewis : >> Hi, >> >> Can anyone give me some sample syntax of using a command line switch >> in the Story Runner run method please? > > This is what I have > > def run_local_story(filename, options={}) > options = {"-fh:" => "C:/rspec_reports/#{filename}.htm"} > run File.join(File.dirname(__FILE__), "../projects/#{filename}"), options > end > Those options don't make it to the runner, which reads the actual command line (ARGV). What I typically do is load up runner files that look like this: # stories/accounting/stories.rb with_steps_for :accounting do run 'path/to/a/story/file' end The, in a terminal: $ ruby stories/accounting/stories.rb -fh:/rspec_reports/#{filename}.htm HTH, David > However, no exception is thrown, but neither is a file created. I am > also unsure on what part of the code the html report should be > created. > > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tastapod at gmail.com Mon Aug 18 14:52:28 2008 From: tastapod at gmail.com (Dan North) Date: Mon, 18 Aug 2008 19:52:28 +0100 Subject: [rspec-users] Do you remember RSpactor? In-Reply-To: <7456bc53-dd26-4649-9096-8315e8e54e56@k30g2000hse.googlegroups.com> References: <12836674.201217855238019.JavaMail.andreas@hackmac.local> <489C6CE6.909@shopwatch.org> <3c30da400808081011nda35541lf352072bafeca193@mail.gmail.com> <7456bc53-dd26-4649-9096-8315e8e54e56@k30g2000hse.googlegroups.com> Message-ID: The runtime environment for OSX GUI apps is controlled by an (optional) file called ~/.MacOSX/environment.plist, which you can edit using the Property List Editor. Under the Root node you create key-value pairs like: GEM_HOME => /Users/Dan/Library/gems. Property List Editor won't let you create a file in a hidden directory (starting with a dot) so instead you can do this from a terminal window: % mkdir ~/.MacOSX % touch ~/.MacOSX/environment.plist % open ~/.MacOSX/environment.plist hth, Dan 2008/8/14 rubyphunk > On 8 Aug., 19:11, "Mark Wilden" wrote: > > I've been using RSpactor (the gem version, not the GUI) fairly happily > for a > > month or so. However, when trying the GUI version out, it became clear > that > > RSpactor loads things differently than 'rake spec'. Today, using the gem > > version, I found that I get a MissingSourceFile trying to require json. > > 'rake spec' works fine. > > RSpactor loads things the same way as 'rake spec' does. The problem > comes from the environment RSpactor.app is running in. > I haven't figured out yet how to change that.. > > > So I'd suggest that RSpactor is not quite ready for primetime, in case > > anyone's thinking of using it. > > You're right RSpactor is not a final release, its a first beta. So if > you encounter problems please report them to the lighthouse project > http://rspactor.lighthouseapp.com or simply fork, fix, commit :) > However, you can use RSpactor already for your daily work. I do, and a > lot of other people too. > _______________________________________________ > 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 Aug 18 14:57:30 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Mon, 18 Aug 2008 19:57:30 +0100 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <8d961d900808180640w327aff44n6c5f216364e9d661@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <7ac2300c0808180529w3d22758bxdf7ac20f93402999@mail.gmail.com> <8d961d900808180534l39d4f432je9f0a180a080bf23@mail.gmail.com> <7ac2300c0808180602x6324411bkcdadc53dbbb16423@mail.gmail.com> <8d961d900808180627of1a5541k821efd00f42723f9@mail.gmail.com> <7ac2300c0808180631y6b9aad4aqab1182cb7cdcac63@mail.gmail.com> <8d961d900808180640w327aff44n6c5f216364e9d661@mail.gmail.com> Message-ID: <7ac2300c0808181157i4a3b379ak48f84df08670ab68@mail.gmail.com> Hi, Bret Pettichord tells me yourself and him worked together on an improvement to the watir example. Could you commit it and i will expand on it and wrap it up into an AUT object model. Aidy. On 8/18/08, aslak hellesoy wrote: > On Mon, Aug 18, 2008 at 3:31 PM, aidy lewis > wrote: >> Aslak >> >> 2008/8/18 aslak hellesoy : >> >>> >>> What do you mean by expand? >>> >>> Aslak >>> >> >> I was going to give a more detailed example... >> > > That would be awesome. If you're familiar with Git you can clone my > Cucumber and commit your changes to your clone. If not I'll accept a > patch. Just put it in RSpec's Lighthouse and tag it with cucumber > > Aslak > >> 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 > -- Sent from Google Mail for mobile | mobile.google.com From aslak.hellesoy at gmail.com Mon Aug 18 15:13:55 2008 From: aslak.hellesoy at gmail.com (=?ISO-8859-1?Q?Aslak_Helles=F8y?=) Date: Mon, 18 Aug 2008 21:13:55 +0200 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <7ac2300c0808181157i4a3b379ak48f84df08670ab68@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <7ac2300c0808180529w3d22758bxdf7ac20f93402999@mail.gmail.com> <8d961d900808180534l39d4f432je9f0a180a080bf23@mail.gmail.com> <7ac2300c0808180602x6324411bkcdadc53dbbb16423@mail.gmail.com> <8d961d900808180627of1a5541k821efd00f42723f9@mail.gmail.com> <7ac2300c0808180631y6b9aad4aqab1182cb7cdcac63@mail.gmail.com> <8d961d900808180640w327aff44n6c5f216364e9d661@mail.gmail.com> <7ac2300c0808181157i4a3b379ak48f84df08670ab68@mail.gmail.com> Message-ID: On Aug 18, 2008, at 8:57 PM, aidy lewis wrote: > Hi, > Bret Pettichord tells me yourself and him worked together on an > improvement to the watir example. Could you commit it and i will > expand on it and wrap it up into an AUT object model. > Aidy. > Hi Aidy. So you and I have the same Bret number eh? ;-) I committed it on Aug 6th, with Bret's kudos and everything: http://github.com/aslakhellesoy/cucumber/search?q=bret&choice=grep (click on the "commit" link to see what we did and where the files are) Aslak > On 8/18/08, aslak hellesoy wrote: >> On Mon, Aug 18, 2008 at 3:31 PM, aidy lewis > > >> wrote: >>> Aslak >>> >>> 2008/8/18 aslak hellesoy : >>> >>>> >>>> What do you mean by expand? >>>> >>>> Aslak >>>> >>> >>> I was going to give a more detailed example... >>> >> >> That would be awesome. If you're familiar with Git you can clone my >> Cucumber and commit your changes to your clone. If not I'll accept a >> patch. Just put it in RSpec's Lighthouse and tag it with cucumber >> >> Aslak >> >>> 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 >> > > -- > Sent from Google Mail for mobile | mobile.google.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ml at e4net.com Mon Aug 18 15:46:21 2008 From: ml at e4net.com (Jim Morris) Date: Mon, 18 Aug 2008 12:46:21 -0700 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> Message-ID: <48A9D18D.3070704@e4net.com> aslak hellesoy wrote: > > The RSpec Story runner is likely to be deprecated in favour of the new > feature runner (temporarily called Cucumber). > http://www.nabble.com/-ANN--Cucumber-td18876816.html This is REALLY bad news!! I asked this question a while back, I have a LOT of code using story runner, I have committed to do all my integration testing via stories, although the ruby style ones not the plain text ones. To hear that they will be deprecated is not good news, and will cause me a lot of grief if I have to rewrite several thousand lines of code, or I simply won't be able to use the latest RSpec. I suggest that cucumber stay separate, and RSpec keep the story runner, either as core or as an add on. Deprecating something that is being used extensively will not make your users happy. -- Jim Morris, http://blog.wolfman.com From dchelimsky at gmail.com Mon Aug 18 16:09:11 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 18 Aug 2008 15:09:11 -0500 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <48A9D18D.3070704@e4net.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <48A9D18D.3070704@e4net.com> Message-ID: <57c63afe0808181309h4b94a7b2u89a07ec2dc82325f@mail.gmail.com> On Mon, Aug 18, 2008 at 2:46 PM, Jim Morris wrote: > aslak hellesoy wrote: > >> >> The RSpec Story runner is likely to be deprecated in favour of the new >> feature runner (temporarily called Cucumber). >> http://www.nabble.com/-ANN--Cucumber-td18876816.html > > This is REALLY bad news!! I asked this question a while back, I have a LOT > of code using story runner, I have committed to do all my integration > testing via stories, although the ruby style ones not the plain text ones. > > To hear that they will be deprecated is not good news, and will cause me a > lot of grief if I have to rewrite several thousand lines of code, or I > simply won't be able to use the latest RSpec. > > I suggest that cucumber stay separate, and RSpec keep the story runner, > either as core or as an add on. > > Deprecating something that is being used extensively will not make your > users happy. Unless of course they are provided an easy transition to a new tool that's much better :) > > > -- > Jim Morris, http://blog.wolfman.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Mon Aug 18 16:26:27 2008 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 18 Aug 2008 21:26:27 +0100 Subject: [rspec-users] Proper Encapsulation of SQL WHERE / ORDER BY Clauses In-Reply-To: <0F7F05B1-2344-42EF-98BF-57D1430E75B8@railsnewbie.com> References: <85B7D8F5-DD95-49D2-8327-C6108F712FAC@mattwynne.net> <57c63afe0808150425m24301802uafa04d237d8df17e@mail.gmail.com> <0F7F05B1-2344-42EF-98BF-57D1430E75B8@railsnewbie.com> Message-ID: Thanks Scott. I refactored it today to use what I called a QueryAdapter, namespaced inside the model. It basically subclasses Hash, takes the params from the controller into the constructor, and becomes the hash to be sent to find_all. I feels much better, as I now have the code that's coupled to the database in one place, but I'd welcome feedback: # VenuesController def get_venues Venue.paginate( :all, Venue::QueryAdapter.new(params) ) end # Responsible for mapping a hash of parameters that will typically be POSTed to a controller into a hash that can be sent to find(:all) # containing SQL clauses in :conditions / :order. # This helps us decouple the view / controller layers from any database specific stuff. class Venue::QueryAdapter < Hash def initialize(params) parse params self.merge!(get_find_params) end private def parse(params) @sort_column = params[:sort] @city_id = params[:city_id] @name = params[:name] @page = params[:page] end def get_find_params find_params = {} find_params.merge!( :order => get_order_clause ) if get_order_clause.length > 0 find_params.merge!( :conditions => get_where_clause ) if get_where_clause.length > 0 find_params.merge!( :page => @page ) return find_params end def get_where_clause clause = [] clause << "city_id = #{@city_id}" if @city_id clause << "name like '%#{@name}%'" if @name return clause.join(" AND ") end def get_order_clause clause = [] clause << 'created_on DESC' if @sort_column == 'created_at' clause << 'name ASC' return clause.join(", ") end end cheers, Matt ---- http://blog.mattwynne.net http://songkick.com In case you wondered: The opinions expressed in this email are my own and do not necessarily reflect the views of any former, current or future employers of mine. On 16 Aug 2008, at 00:19, Scott Taylor wrote: > > On Aug 15, 2008, at 9:29 AM, David Chelimsky wrote: > >> On Aug 15, 2008, at 6:46 AM, Matt Wynne wrote: >> >>> On 15 Aug 2008, at 12:25, David Chelimsky wrote: >>> >>>> Hey Matt - welcome! >>>> >>>> The paginate() method lives on the model class, so there's nothing >>>> stopping you from wrapping those calls in methods on the model, >>>> slinging around the params object. >>>> >>>> # CityController >>>> >>>> def get_cities >>>> City.paginate_all(params) >>>> end >>>> >>>> # City >>>> >>>> def self.paginate_all(params) >>>> self.paginate(:all, get_find_params(params).merge!(:page => >>>> params[:page])) >>>> end >>>> >>>> etc >>>> >>> >>> Aha. Cool, thanks. >>> >>> For my next question: how do I go about driving out change to the >>> model, spec-first? >>> >>> I'm thinking I would call (in my spec) >>> >>> City.should_receive(:paginate).with(:conditions => "name like '% >>> #{test_params[:name}%'" .... ) >>> City.paginate_all(test_params) >>> >>> Thereby covering the code in get_find_params() >>> >>> Is that the right approach? >> >> That's probably how I would do it. Might also consider wrapping >> the params in a separate object that manages the extraction. > > That's how I've started doing it - putting sql statements in a module: > > http://gist.github.com/5675 > > This allows me to test the sql statements seperately from the > actual finder. > > Also - just to give you the heads up - You should almost never use > literal string substitutions in sql statements - it allows for sql > injection attacks: > > http://en.wikipedia.org/wiki/Sql_injection > > Best, > > Scott Taylor > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mark at mwilden.com Mon Aug 18 17:18:29 2008 From: mark at mwilden.com (Mark Wilden) Date: Mon, 18 Aug 2008 14:18:29 -0700 Subject: [rspec-users] Proper Encapsulation of SQL WHERE / ORDER BY Clauses In-Reply-To: References: <85B7D8F5-DD95-49D2-8327-C6108F712FAC@mattwynne.net> <57c63afe0808150425m24301802uafa04d237d8df17e@mail.gmail.com> <0F7F05B1-2344-42EF-98BF-57D1430E75B8@railsnewbie.com> Message-ID: <3c30da400808181418x6b49f16fnb86290bca7a0be2a@mail.gmail.com> On Mon, Aug 18, 2008 at 1:26 PM, Matt Wynne wrote: > def get_where_clause > > clause = [] > > clause << "city_id = #{@city_id}" if @city_id > clause << "name like '%#{@name}%'" if @name > I think you've still got SQL injection problems here. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Mon Aug 18 18:01:00 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 19 Aug 2008 00:01:00 +0200 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <48A9D18D.3070704@e4net.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <48A9D18D.3070704@e4net.com> Message-ID: <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> On Mon, Aug 18, 2008 at 9:46 PM, Jim Morris wrote: > aslak hellesoy wrote: > >> >> The RSpec Story runner is likely to be deprecated in favour of the new >> feature runner (temporarily called Cucumber). >> http://www.nabble.com/-ANN--Cucumber-td18876816.html > > This is REALLY bad news!! I asked this question a while back, I have a LOT > of code using story runner, I have committed to do all my integration > testing via stories, although the ruby style ones not the plain text ones. > Calm down. You are not the only one who has invested in stories - plain text or Ruby. I am also involved in a couple of projects that has lot of RSpec stories. This is actually the main reason I wrote Cucumber - I got tired of many of the shortcomings that I have outlined at the bottom of Cucumber's README. Nobody is going to delete the RSpec story runner. (Some said taking something off the Internet is like taking pee out of a swimming pool). For what I know it will still be available for download 20 years from now. I am only making people aware of Cucumber and encouraging them to invest in improving it rather than the old one. I realise that in order for people to be able to make the switch painlessly, there needs to be good documentation - both about how to migrate old style stories and also general documentation about how to use Cucumber. I intend to provide most of this, and welcome others to join in. The code also needs to be more or less of a drop-in replacement, and one of my primary goals going forward is to make it exactly that. FYI - Cucumber already supports pure Ruby style. It's not 100% similar to RSpec Story runner in pure Ruby mode, but close. http://github.com/aslakhellesoy/cucumber/tree/master/examples/calculator_ruby_features I'm inviting you to provide some constructive feedback about how we could improve it to make the transition easier for people like yourself. A natural part of software evolution is that every now and then a tool, library or program gets replaced by something better. While it's certainly possible to maintain two different products, it takes a lot more time. Time that I don't have. Am I to understand from your email that you're stepping up and offering to help maintain and govern the future of the story runner? > To hear that they will be deprecated is not good news, and will cause me a > lot of grief if I have to rewrite several thousand lines of code, or I > simply won't be able to use the latest RSpec. > What exactly is your understanding of deprecation and how have you concluded that you will have rewrite several thousands of LOC? > I suggest that cucumber stay separate, and RSpec keep the story runner, > either as core or as an add on. > > Deprecating something that is being used extensively will not make your > users happy. > What David said. Aslak > > -- > Jim Morris, http://blog.wolfman.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ml at e4net.com Tue Aug 19 00:28:45 2008 From: ml at e4net.com (Jim Morris) Date: Mon, 18 Aug 2008 21:28:45 -0700 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <48A9D18D.3070704@e4net.com> <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> Message-ID: <48AA4BFD.6010401@e4net.com> aslak hellesoy wrote: > I'm inviting you to provide some constructive feedback about how we > could improve it to make the transition easier for people like > yourself. I'll give it a try, I'll port some of my stories to cucumber and see how it goes. > > A natural part of software evolution is that every now and then a > tool, library or program gets replaced by something better. While it's > certainly possible to maintain two different products, it takes a lot > more time. Time that I don't have. Am I to understand from your email > that you're stepping up and offering to help maintain and govern the > future of the story runner? True, but Story runner was only released in the last version of RSpec so it isn't exactly old. Depending on how hard it is to port from story runner to cucumber, I'll have to make a decision to either port, or maintain the old code, it is a trade off of time. Right now I have my entire integration testing suite written using story runner. On an initial look at cucumber it looks like the steps remain pretty much the same, although I see you added Before and After, and I was using before story and after story listeners for setup, not sure what scope the Before and After have. I also use a before Scenario listener to clear the context before each scenario. > > What exactly is your understanding of deprecation and how have you > concluded that you will have rewrite several thousands of LOC? What I have seen in the Ruby world (and Java) is that deprecation means the next release prints some warning that the feature is deprecated if you use it, then the following release it is removed entirely. I'll site the Ruby Gem Sequel as an example of some recent deprecations, that caused me to go through many lines of code and update them as the feature I was using was deprecated, and I initially got a lot of warnings, then all my scripts stopped working after an upgrade. Maybe I won't have to rewrite "thousands" of lines of code, at least I hope not, if the steps remain the same, I guess I'll need to massage them and rewrite many of the scenarios to fit the new format. I have to say my reaction is due to the fact that tests are something you want to write once and forget, I don't mind writing new tests using cucumber moving forward, but to have to revisit old tests is not a good use of my time. If you were to reword deprecation to frozen I'd be a lot happier :) then I can leave my old tests alone and use cucumber for new tests. -- Jim Morris, http://blog.wolfman.com From matt at mattwynne.net Tue Aug 19 02:57:50 2008 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 19 Aug 2008 07:57:50 +0100 Subject: [rspec-users] Proper Encapsulation of SQL WHERE / ORDER BY Clauses In-Reply-To: <3c30da400808181418x6b49f16fnb86290bca7a0be2a@mail.gmail.com> References: <85B7D8F5-DD95-49D2-8327-C6108F712FAC@mattwynne.net> <57c63afe0808150425m24301802uafa04d237d8df17e@mail.gmail.com> <0F7F05B1-2344-42EF-98BF-57D1430E75B8@railsnewbie.com> <3c30da400808181418x6b49f16fnb86290bca7a0be2a@mail.gmail.com> Message-ID: <3CA18CAE-32FA-4DEF-A7A5-370F3A89D7BD@mattwynne.net> Thanks for the reminder. This stuff is in a protected admin area so I don't really care, but I should play on the safe side anyhow. cheers, Matt ---- http://blog.mattwynne.net http://songkick.com In case you wondered: The opinions expressed in this email are my own and do not necessarily reflect the views of any former, current or future employers of mine. On 18 Aug 2008, at 22:18, Mark Wilden wrote: > On Mon, Aug 18, 2008 at 1:26 PM, Matt Wynne > wrote: > def get_where_clause > > clause = [] > > clause << "city_id = #{@city_id}" if @city_id > clause << "name like '%#{@name}%'" if @name > > I think you've still got SQL injection problems here. > > ///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 aslak.hellesoy at gmail.com Tue Aug 19 03:42:59 2008 From: aslak.hellesoy at gmail.com (=?ISO-8859-1?Q?Aslak_Helles=F8y?=) Date: Tue, 19 Aug 2008 09:42:59 +0200 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <48AA4BFD.6010401@e4net.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <48A9D18D.3070704@e4net.com> <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> <48AA4BFD.6010401@e4net.com> Message-ID: <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> On Aug 19, 2008, at 6:28 AM, Jim Morris wrote: > aslak hellesoy wrote: > >> I'm inviting you to provide some constructive feedback about how we >> could improve it to make the transition easier for people like >> yourself. > > I'll give it a try, I'll port some of my stories to cucumber and see > how it goes. > >> A natural part of software evolution is that every now and then a >> tool, library or program gets replaced by something better. While >> it's >> certainly possible to maintain two different products, it takes a lot >> more time. Time that I don't have. Am I to understand from your email >> that you're stepping up and offering to help maintain and govern the >> future of the story runner? > > True, but Story runner was only released in the last version of > RSpec so it isn't exactly old. It was introduced in version 1.1.0 - about 8 months ago. That's not old I agree with you. > > Depending on how hard it is to port from story runner to cucumber, > I'll have to make a decision to either port, or maintain the old > code, it is a trade off of time. Right now I have my entire > integration testing suite written using story runner. > I would recommend that you keep using the story runner until the effort required to switch is so small that you can do it in an hour or two. > On an initial look at cucumber it looks like the steps remain pretty > much the same, although I see you added They do remain pretty much the same, but I'm considering to move them from the toplevel scope and into classes (I prefer pure Ruby constructs instead of inventing our own cleverness). class MySteps < Cucumber::Steps # Same as Story runnner steps_for(:my) Given /bla bla/ do end end > Before and After, and I was using before story and after story > listeners for setup, not sure what scope the Before and After have. > I also use a before Scenario listener to clear the context before > each scenario. > Right now the scope of Before/After is global - i.e. all Before and After blocks will run before and after each scenario. I have deliberately postponed adding scoping of this until I better understand how people want to define this scoping. Here is one ideas: class MySteps < Cucumber::Steps # Same as Story runnner steps_for(:my) Before do # This block will run before all scenarios that use steps from MySteps # Any scenarios not using any of these will not have this block run end Given /bla bla/ do end end I'm open to other ideas too. In any case, a backwards compatible layer should be added so you can still use Scenario listeners if you wish. >> What exactly is your understanding of deprecation and how have you >> concluded that you will have rewrite several thousands of LOC? > > What I have seen in the Ruby world (and Java) is that deprecation > means the next release prints some warning that the feature is > deprecated if you use it, then the following release it is removed > entirely. > > I'll site the Ruby Gem Sequel as an example of some recent > deprecations, that caused me to go through many lines of code and > update them as the feature I was using was deprecated, and I > initially got a lot of warnings, then all my scripts stopped working > after an upgrade. > Don't worry. We'll keep it around inside RSpec for a while still. Only when we are confident that migration to Cucumber is painless will we take it out. At that point it will probably just be moved to a separate Git repo so those who wish can maintain it as a separate project. > Maybe I won't have to rewrite "thousands" of lines of code, at least > I hope not, if the steps remain the same, I guess I'll need to > massage them and rewrite many of the scenarios to fit the new format. > My goal is that you won't have to change anything at all, except perhaps the parts that deal with running stories (you'll get a Rake task and can delete your all.rb file). You shouldn't have to change the story/step files. > I have to say my reaction is due to the fact that tests are > something you want to write once and forget, I don't mind writing > new tests using cucumber moving forward, but to have to revisit old > tests is not a good use of my time. If you were to reword > deprecation to frozen I'd be a lot happier :) then I can leave my > old tests alone and use cucumber for new tests. > Words are powerful aren't they :-) Frozen is probably a better word. No more significant development on it. Thanks a lot for your feedback - looking forward to more concrete ones so I can make Cucumber better. Aslak > > > -- > Jim Morris, http://blog.wolfman.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Tue Aug 19 07:18:27 2008 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 19 Aug 2008 12:18:27 +0100 Subject: [rspec-users] Parameters and View Specs Message-ID: Sigh. Sorry to ask such a dumb question, but I've hit one of those walls... I'm testing a view which uses the params[] hash directly. (Aside: is this bad form?) How the heckers do I set up the params hash in my test? I've tried calling render 'some/view', { :first_param => true } ...but nothing seems to be coming though. What am I doing wrong? cheers, Matt ---- http://blog.mattwynne.net http://songkick.com In case you wondered: The opinions expressed in this email are my own and do not necessarily reflect the views of any former, current or future employers of mine. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Tue Aug 19 07:22:05 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 19 Aug 2008 06:22:05 -0500 Subject: [rspec-users] Parameters and View Specs In-Reply-To: References: Message-ID: <57c63afe0808190422w263b5804r69403049c2baf732@mail.gmail.com> On Tue, Aug 19, 2008 at 6:18 AM, Matt Wynne wrote: > Sigh. Sorry to ask such a dumb question, but I've hit one of those walls... > I'm testing a view which uses the params[] hash directly. (Aside: is this > bad form?) > How the heckers do I set up the params hash in my test? > I've tried calling > render 'some/view', { :first_param => true } > ...but nothing seems to be coming though. > What am I doing wrong? http://rspec.info/documentation/rails/writing/views.html Cheers, David From aidy.lewis at googlemail.com Tue Aug 19 08:09:05 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Tue, 19 Aug 2008 13:09:05 +0100 Subject: [rspec-users] command line options in story runner run method In-Reply-To: <57c63afe0808181007i6d270b8dq703b659ccbb4a4ec@mail.gmail.com> References: <7ac2300c0808180900m7b91dd18ldf02b969983dbfc6@mail.gmail.com> <7ac2300c0808181001x4729339w9a652c2c395e5e9e@mail.gmail.com> <57c63afe0808181007i6d270b8dq703b659ccbb4a4ec@mail.gmail.com> Message-ID: <7ac2300c0808190509q2e7443fk5169f57e167b2318@mail.gmail.com> Hi David, 2008/8/18 David Chelimsky : > Those options don't make it to the runner, which reads the actual > command line (ARGV). > > What I typically do is load up runner files that look like this: > > # stories/accounting/stories.rb > with_steps_for :accounting do > run 'path/to/a/story/file' > end > > The, in a terminal: > > $ ruby stories/accounting/stories.rb -fh:/rspec_reports/#{filename}.htm I created a rake file that cycles through a number of runner folders and runs individual ruby files using the kernal 'system' method so that I can produce HTML reports. task :dcs do require 'find' Find.find("projects/dcs/runner") do |path| path.length string_end = path.length string_begin = string_end -3 result = path.slice string_begin ... string_end if result == ".rb" source_location = "C:\\SvnProjects\\RubyUatFramework\\test\\" path = path.gsub("/", "\\") full_path = source_location + path system("ruby #{full_path} -fh: C:\\rspec_reports\\#{Time.now.to_i}.htm") end end end However, I think I am having problems with the format switch. The HTML will appear in the console but not on the file system. Thanks for the help Aidy From jonkinney at gmail.com Tue Aug 19 09:38:11 2008 From: jonkinney at gmail.com (Jonathan Kinney) Date: Tue, 19 Aug 2008 08:38:11 -0500 Subject: [rspec-users] When to mock Message-ID: I noticed that the examples on the rspec website for model code http://rspec.info/documentation/rails/writing/models.html have no mocks or stubs. However both the controller example and view example do have mocks and stubs implemented. I was having some problems getting mocks to work in my model (using mock_model and passing in a hash or stubs) but I'm wondering if I shouldn't be mocking or stubbing in my model at all? I've done the googling on mocks vs stubs and read a bunch or info, I'm just wondring how some of the fellow rspec users implement mocking and stubbing in their specs and whether or not it is ok to mock and or stub in a model? Thanks, -Jon -------------- next part -------------- An HTML attachment was scrubbed... URL: From mailing_lists at railsnewbie.com Tue Aug 19 10:08:10 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 19 Aug 2008 10:08:10 -0400 Subject: [rspec-users] When to mock In-Reply-To: References: Message-ID: <00EC0D2B-E65B-483F-A025-A3A3BB35753F@railsnewbie.com> On Aug 19, 2008, at 9:38 AM, Jonathan Kinney wrote: > I noticed that the examples on the rspec website for model code http://rspec.info/documentation/rails/writing/models.html > have no mocks or stubs. However both the controller example and > view example do have mocks and stubs implemented. I was having some > problems getting mocks to work in my model (using mock_model and > passing in a hash or stubs) but I'm wondering if I shouldn't be > mocking or stubbing in my model at all? I've done the googling on > mocks vs stubs and read a bunch or info, I'm just wondring how some > of the fellow rspec users implement mocking and stubbing in their > specs and whether or not it is ok to mock and or stub in a model? > Of course it's OK to mock - but with that said, you should probably have some sort of "real" integration tests, which do touch the database. Ultimately, it's all about convenience and your comfort level. The reason mocking is as popular as it is is simply because of slow test suites (google Dan Manges and unitrecord, if you are curious). Scott -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at mwilden.com Tue Aug 19 10:14:45 2008 From: mark at mwilden.com (Mark Wilden) Date: Tue, 19 Aug 2008 07:14:45 -0700 Subject: [rspec-users] When to mock In-Reply-To: References: Message-ID: <3c30da400808190714u4b2fc6ccq2acc16ad4b938ce5@mail.gmail.com> On Tue, Aug 19, 2008 at 6:38 AM, Jonathan Kinney wrote: > I noticed that the examples on the rspec website for model code > http://rspec.info/documentation/rails/writing/models.html have no mocks or > stubs. However both the controller example and view example do have mocks > and stubs implemented. I was having some problems getting mocks to work in > my model (using mock_model and passing in a hash or stubs) but I'm wondering > if I shouldn't be mocking or stubbing in my model at all? > In a model spec, clearly you don't want to mock any part of the model under test, because then you're not testing it. However, anything else (including other models) is fair game. Mocks are used specifically to avoid testing something, usually because you (or someone else) is testing it elsewhere. Mocks make sure that the object under test is behaving correctly in its interactions with other code - but (in a unit spec, at least), you don't want to redundantly or expensively also test that other code. That's my take, at least ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Tue Aug 19 10:21:14 2008 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 19 Aug 2008 15:21:14 +0100 Subject: [rspec-users] When to mock In-Reply-To: <00EC0D2B-E65B-483F-A025-A3A3BB35753F@railsnewbie.com> References: <00EC0D2B-E65B-483F-A025-A3A3BB35753F@railsnewbie.com> Message-ID: <9C11E55C-0C36-44F4-97D6-333A729BF0CE@mattwynne.net> It's also, for me, nice to isolate the code I'm testing using mocks. So if I'm building a controller and I mock out the behaviour I will expect it to call on the model layer, I know that any failing tests must be due to bugs in the controller class, nowhere else. Coming from using an NHibernate / POCO stack in .NET where my domain (model) objects were completely de-coupled from their persistence behaviour, I've found it quite hard working with ActiveRecord objects. It seems like the path of least resistance when you're working with objects that inherit from ActiveRecord::Base is just to put your TDD principles to one side, set up stock data in your database, call the model from your tests and forget about trying to mock anything out. Trying to get a mockable seam in between your own model logic and ActiveRecord's persistence code seems to hard... at least for me at this stage of my ruby learnings. So, in summary, I guess I would advise you to mock wherever you can, unless you're testing an object that inherits from ActiveRecord::Base. People draw the line in lots of different places though, so you'll probably find other people much less keen on mocking than me. cheers, Matt ---- http://blog.mattwynne.net http://songkick.com In case you wondered: The opinions expressed in this email are my own and do not necessarily reflect the views of any former, current or future employers of mine. On 19 Aug 2008, at 15:08, Scott Taylor wrote: > > On Aug 19, 2008, at 9:38 AM, Jonathan Kinney wrote: > >> I noticed that the examples on the rspec website for model code >> http://rspec.info/documentation/rails/writing/models.html have no >> mocks or stubs. However both the controller example and view >> example do have mocks and stubs implemented. I was having some >> problems getting mocks to work in my model (using mock_model and >> passing in a hash or stubs) but I'm wondering if I shouldn't be >> mocking or stubbing in my model at all? I've done the googling on >> mocks vs stubs and read a bunch or info, I'm just wondring how >> some of the fellow rspec users implement mocking and stubbing in >> their specs and whether or not it is ok to mock and or stub in a >> model? >> > > Of course it's OK to mock - but with that said, you should probably > have some sort of "real" integration tests, which do touch the > database. > > Ultimately, it's all about convenience and your comfort level. The > reason mocking is as popular as it is is simply because of slow > test suites (google Dan Manges and unitrecord, if you are curious). > > Scott > > _______________________________________________ > 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 Tue Aug 19 10:23:49 2008 From: mark at mwilden.com (Mark Wilden) Date: Tue, 19 Aug 2008 07:23:49 -0700 Subject: [rspec-users] When to mock In-Reply-To: <00EC0D2B-E65B-483F-A025-A3A3BB35753F@railsnewbie.com> References: <00EC0D2B-E65B-483F-A025-A3A3BB35753F@railsnewbie.com> Message-ID: <3c30da400808190723n515ea6dave3da59fe78bb805a@mail.gmail.com> On Tue, Aug 19, 2008 at 7:08 AM, Scott Taylor wrote: > > Ultimately, it's all about convenience and your comfort level. The reason > mocking is as popular as it is is simply because of slow test suites (google > Dan Manges and unitrecord, if you are curious). > Another reason why you'd mock out the database is that that's not your code - it's ActiveRecord and MySQL/PostgreSQL/etc (which one would imagine have been rather thoroughly tested elsewhere:). The idea is that if you know you're calling ActiveRecord methods correctly, you don't actually have to go any deeper than that in a unit spec. The key, I think, is to ask yourself "what am I testing/speccing?" Generally (again, for a unit test), it's the contents of a file or files that you are writing - very often, a single method. You want to make sure that you've specified what the contents of that method do, and that the lines of code in it are correct. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Tue Aug 19 14:05:41 2008 From: lists at ruby-forum.com (Satish Gunnu) Date: Tue, 19 Aug 2008 20:05:41 +0200 Subject: [rspec-users] rake spec loads development environment Message-ID: <1c51d85b1455b71e6461316a77073874@ruby-forum.com> Hi, I am new to rspec and started implementing it on my project yesterday. I have followed the instructions and installed rspec gem and rspec plugin into my project. I created couple of sample stories and tried running the specs using spec command which worked fine, but when I started using rake spec command it is loading development environment instead of test environment. I tried to putting some STDOUT's in spec_helper.rb but it seems that this file is never interpreted. Am I missing something? Please help, Thanks in advance. -SatishG -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Tue Aug 19 14:19:56 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 19 Aug 2008 13:19:56 -0500 Subject: [rspec-users] rake spec loads development environment In-Reply-To: <1c51d85b1455b71e6461316a77073874@ruby-forum.com> References: <1c51d85b1455b71e6461316a77073874@ruby-forum.com> Message-ID: On Aug 19, 2008, at 1:05 PM, Satish Gunnu wrote: > Hi, > > I am new to rspec and started implementing it on my project > yesterday. > I have followed the instructions What instructions? > and installed rspec gem and rspec > plugin into my project. I created couple of sample stories and tried > running the specs using spec command which worked fine, but when I > started using rake spec command it is loading development environment > instead of test environment. I tried to putting some STDOUT's in > spec_helper.rb but it seems that this file is never interpreted. Are you including it from your spec files? > Am I > missing something? Please help, Thanks in advance. > > -SatishG > -- > 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 Tue Aug 19 16:08:37 2008 From: lists at ruby-forum.com (Satish Gunnu) Date: Tue, 19 Aug 2008 22:08:37 +0200 Subject: [rspec-users] rake spec loads development environment In-Reply-To: References: <1c51d85b1455b71e6461316a77073874@ruby-forum.com> Message-ID: Hi David, Most of my knowledge came from peepcode rspec screencast and the following link. http://rspec.rubyforge.org/documentation/rails/install.html Here are the steps I have done to get going. 1) Installed rspec gem 2) Installed rspec plugin in my project 3) created a test_spec.rb file which have sample stories 4) ruby script/generate rspec 5) rake spec I have one initializer file for oracle_driver in initializers directory which is set to not load in test environment. when I run rake spec command this initializer is invoked and I see that the environment is set to development but not test. To answer your second questions, I am not including it from my spec files. BTW I am using rpsec 1.1.4 and rails 2.1.0. Sorry for not being elaborate in my prev post. Thanks, SatishG. David Chelimsky wrote: > On Aug 19, 2008, at 1:05 PM, Satish Gunnu wrote: > >> Hi, >> >> I am new to rspec and started implementing it on my project >> yesterday. >> I have followed the instructions > > What instructions? > >> and installed rspec gem and rspec >> plugin into my project. I created couple of sample stories and tried >> running the specs using spec command which worked fine, but when I >> started using rake spec command it is loading development environment >> instead of test environment. I tried to putting some STDOUT's in >> spec_helper.rb but it seems that this file is never interpreted. > > Are you including it from your spec files? -- Posted via http://www.ruby-forum.com/. From jonathan at parkerhill.com Tue Aug 19 16:10:14 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 19 Aug 2008 16:10:14 -0400 Subject: [rspec-users] rake spec loads development environment In-Reply-To: <1c51d85b1455b71e6461316a77073874@ruby-forum.com> References: <1c51d85b1455b71e6461316a77073874@ruby-forum.com> Message-ID: <1F25F8BD-8DF1-4713-90A3-36A7677CD256@parkerhill.com> On Aug 19, 2008, at 2:05 PM, Satish Gunnu wrote: > Hi, > > I am new to rspec and started implementing it on my project > yesterday. > I have followed the instructions and installed rspec gem and rspec > plugin into my project. I created couple of sample stories and tried > running the specs using spec command which worked fine, but when I > started using rake spec command it is loading development environment > instead of test environment. I tried to putting some STDOUT's in > spec_helper.rb but it seems that this file is never interpreted. Am I > missing something? Please help, Thanks in advance. > > -SatishG > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users iirc, it looks at the development environment to prepare the db schema, but still runs the specs in test. Is that what you're seeing? From lists at ruby-forum.com Tue Aug 19 16:32:37 2008 From: lists at ruby-forum.com (Satish Gunnu) Date: Tue, 19 Aug 2008 22:32:37 +0200 Subject: [rspec-users] rake spec loads development environment In-Reply-To: <1F25F8BD-8DF1-4713-90A3-36A7677CD256@parkerhill.com> References: <1c51d85b1455b71e6461316a77073874@ruby-forum.com> <1F25F8BD-8DF1-4713-90A3-36A7677CD256@parkerhill.com> Message-ID: Yes I think that is what's happening in my case. is this how it is supposed to work? or can we have rspec ignore the step to look at development environment. thanks so much for all your help. > iirc, it looks at the development environment to prepare the db > schema, but still runs the specs in test. Is that what you're seeing? -- Posted via http://www.ruby-forum.com/. From jonathan at parkerhill.com Tue Aug 19 17:08:25 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 19 Aug 2008 17:08:25 -0400 Subject: [rspec-users] rake spec loads development environment In-Reply-To: References: <1c51d85b1455b71e6461316a77073874@ruby-forum.com> <1F25F8BD-8DF1-4713-90A3-36A7677CD256@parkerhill.com> Message-ID: <1DF992C3-CC79-485A-9D56-4DCD70F77CBB@parkerhill.com> On Aug 19, 2008, at 4:32 PM, Satish Gunnu wrote: > Yes I think that is what's happening in my case. is this how it is > supposed to work? or can we have rspec ignore the step to look at > development environment. thanks so much for all your help. you'll notice that vendor/plugins/rspec-rails/rspec.rake contains the line spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop which you could change or comment out > > >> iirc, it looks at the development environment to prepare the db >> schema, but still runs the specs in test. Is that what you're seeing? > > -- > 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 mwilden.com Tue Aug 19 17:09:51 2008 From: mark at mwilden.com (Mark Wilden) Date: Tue, 19 Aug 2008 14:09:51 -0700 Subject: [rspec-users] rake spec loads development environment In-Reply-To: References: <1c51d85b1455b71e6461316a77073874@ruby-forum.com> Message-ID: <3c30da400808191409q353ca05cye5cb011ce019dc6d@mail.gmail.com> > > http://rspec.rubyforge.org/documentation/rails/install.html > I sure wish someone would take that page down - it's caused me more than my share of grief. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at mwilden.com Tue Aug 19 17:11:52 2008 From: mark at mwilden.com (Mark Wilden) Date: Tue, 19 Aug 2008 14:11:52 -0700 Subject: [rspec-users] rake spec loads development environment In-Reply-To: <1DF992C3-CC79-485A-9D56-4DCD70F77CBB@parkerhill.com> References: <1c51d85b1455b71e6461316a77073874@ruby-forum.com> <1F25F8BD-8DF1-4713-90A3-36A7677CD256@parkerhill.com> <1DF992C3-CC79-485A-9D56-4DCD70F77CBB@parkerhill.com> Message-ID: <3c30da400808191411s47535fa8l5c83364fac70bd99@mail.gmail.com> On Tue, Aug 19, 2008 at 2:08 PM, Jonathan Linowes wrote: > > you'll notice that vendor/plugins/rspec-rails/rspec.rake contains the line > > spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) > ? "db:test:prepare" : :noop > > which you could change or comment out You'd have to remember to run your migrations against the test db as well as the dev db. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Tue Aug 19 17:14:10 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 19 Aug 2008 16:14:10 -0500 Subject: [rspec-users] rake spec loads development environment In-Reply-To: References: <1c51d85b1455b71e6461316a77073874@ruby-forum.com> Message-ID: <57c63afe0808191414s1ff2586dxc84b2b2849cd13a0@mail.gmail.com> On Tue, Aug 19, 2008 at 3:08 PM, Satish Gunnu wrote: > Hi David, > > Most of my knowledge came from peepcode rspec screencast and the > following link. > http://rspec.rubyforge.org/documentation/rails/install.html > > Here are the steps I have done to get going. > > 1) Installed rspec gem > 2) Installed rspec plugin in my project > 3) created a test_spec.rb file which have sample stories > 4) ruby script/generate rspec > 5) rake spec > > I have one initializer file for oracle_driver in initializers > directory which is set to not load in test environment. when I run rake > spec command this initializer is invoked and I see that the environment > is set to development but not test. > > To answer your second questions, I am not including it from my spec > files. I'd recommend doing so if you want the spec_helper.rb file to be loaded. It will set the environment for you correctly. > > BTW I am using rpsec 1.1.4 and rails 2.1.0. Sorry for not being > elaborate in my prev post. > > Thanks, > SatishG. > > > > > > David Chelimsky wrote: >> On Aug 19, 2008, at 1:05 PM, Satish Gunnu wrote: >> >>> Hi, >>> >>> I am new to rspec and started implementing it on my project >>> yesterday. >>> I have followed the instructions >> >> What instructions? >> >>> and installed rspec gem and rspec >>> plugin into my project. I created couple of sample stories and tried >>> running the specs using spec command which worked fine, but when I >>> started using rake spec command it is loading development environment >>> instead of test environment. I tried to putting some STDOUT's in >>> spec_helper.rb but it seems that this file is never interpreted. >> >> Are you including it from your spec files? > > -- > 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 Tue Aug 19 17:21:13 2008 From: lists at ruby-forum.com (Satish Gunnu) Date: Tue, 19 Aug 2008 23:21:13 +0200 Subject: [rspec-users] rake spec loads development environment In-Reply-To: <3c30da400808191411s47535fa8l5c83364fac70bd99@mail.gmail.com> References: <1c51d85b1455b71e6461316a77073874@ruby-forum.com> <1F25F8BD-8DF1-4713-90A3-36A7677CD256@parkerhill.com> <1DF992C3-CC79-485A-9D56-4DCD70F77CBB@parkerhill.com> <3c30da400808191411s47535fa8l5c83364fac70bd99@mail.gmail.com> Message-ID: <09d12574eda0d02f31cef61f3080f801@ruby-forum.com> Awesome. Thanks guys. Appreciate your help. Mark Wilden wrote: > On Tue, Aug 19, 2008 at 2:08 PM, Jonathan Linowes > wrote: > >> >> you'll notice that vendor/plugins/rspec-rails/rspec.rake contains the line >> >> spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) >> ? "db:test:prepare" : :noop >> >> which you could change or comment out > > > You'd have to remember to run your migrations against the test db as > well as > the dev db. > > ///ark -- Posted via http://www.ruby-forum.com/. From jonathan at parkerhill.com Tue Aug 19 17:35:21 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 19 Aug 2008 17:35:21 -0400 Subject: [rspec-users] rake spec loads development environment In-Reply-To: <1DF992C3-CC79-485A-9D56-4DCD70F77CBB@parkerhill.com> References: <1c51d85b1455b71e6461316a77073874@ruby-forum.com> <1F25F8BD-8DF1-4713-90A3-36A7677CD256@parkerhill.com> <1DF992C3-CC79-485A-9D56-4DCD70F77CBB@parkerhill.com> Message-ID: On Aug 19, 2008, at 5:08 PM, Jonathan Linowes wrote: > > On Aug 19, 2008, at 4:32 PM, Satish Gunnu wrote: > >> Yes I think that is what's happening in my case. is this how it is >> supposed to work? or can we have rspec ignore the step to look at >> development environment. thanks so much for all your help. > > you'll notice that vendor/plugins/rspec-rails/rspec.rake contains > the line > > spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', > 'database.yml')) ? "db:test:prepare" : :noop > > which you could change or comment out note, I ran into this wanting to run through my specs on my production server, which doesnt have a development environment but does have a production one. So instead I run (via a cap deploy:spec task i wrote) rake spec RAILS_ENV=production that way the db:test:prepare uses the production db rather than the development one > >> >> >>> iirc, it looks at the development environment to prepare the db >>> schema, but still runs the specs in test. Is that what you're >>> seeing? >> >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Tue Aug 19 17:37:54 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 19 Aug 2008 16:37:54 -0500 Subject: [rspec-users] rake spec loads development environment In-Reply-To: <3c30da400808191409q353ca05cye5cb011ce019dc6d@mail.gmail.com> References: <1c51d85b1455b71e6461316a77073874@ruby-forum.com> <3c30da400808191409q353ca05cye5cb011ce019dc6d@mail.gmail.com> Message-ID: <57c63afe0808191437x2a7e5844s8fe582b3ade8755c@mail.gmail.com> Done On Tue, Aug 19, 2008 at 4:09 PM, Mark Wilden wrote: >> http://rspec.rubyforge.org/documentation/rails/install.html > > > I sure wish someone would take that page down - it's caused me more than my > share of grief. > > ///ark > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jarmo.p at gmail.com Tue Aug 19 17:53:24 2008 From: jarmo.p at gmail.com (juuuser) Date: Tue, 19 Aug 2008 14:53:24 -0700 (PDT) Subject: [rspec-users] failing before :all doesn't move progress bar in html reports Message-ID: <19059450.post@talk.nabble.com> Hello. I've found one bug when failing before :all block doesn't move html report's progress bar correctly. You can test it out easily by doing something like this: describe "bad bad bad" do before :all do true.should be_false end it "empty" do end end Now run this spec with html formatter and you should get 100% width to rspec-header div, but it has width of 0%. When you add some other describe blocks with specs then it would be something below 100%, but should be 100% if everything is finished. I've fixed this in my custom htmlformatter by adding these lines into example_failed method prior invoking super: def example_failed example, counter, failure #.... #some other stuff #.... if example.description == "before(:all)" @example_number += @options.example_groups[example_group_number-1].examples.size end super end If there's any better solution, please let me know :) Best Regards, juuser. -- View this message in context: http://www.nabble.com/failing-before-%3Aall-doesn%27t-move-progress-bar-in-html-reports-tp19059450p19059450.html Sent from the rspec-users mailing list archive at Nabble.com. From mauricio.linhares at gmail.com Tue Aug 19 17:55:07 2008 From: mauricio.linhares at gmail.com (=?ISO-8859-1?Q?Maur=EDcio_Linhares?=) Date: Tue, 19 Aug 2008 18:55:07 -0300 Subject: [rspec-users] failing before :all doesn't move progress bar in html reports In-Reply-To: <19059450.post@talk.nabble.com> References: <19059450.post@talk.nabble.com> Message-ID: Maybe you shouldn't be placing spectations in a before or after filter, it doesn't make much sense. On Tue, Aug 19, 2008 at 6:53 PM, juuuser wrote: > > Hello. > > I've found one bug when failing before :all block doesn't move html > report's > progress bar correctly. > > You can test it out easily by doing something like this: > > describe "bad bad bad" do > > before :all do > true.should be_false > end > > it "empty" do > end > > end > > Now run this spec with html formatter and you should get 100% width to > rspec-header div, but it has width of 0%. When you add some other describe > blocks with specs then it would be something below 100%, but should be 100% > if everything is finished. > > I've fixed this in my custom htmlformatter by adding these lines into > example_failed method prior invoking super: > > def example_failed example, counter, failure > > #.... > #some other stuff > #.... > > if example.description == "before(:all)" > @example_number += > @options.example_groups[example_group_number-1].examples.size > end > super > > end > > If there's any better solution, please let me know :) > > Best Regards, > juuser. > -- Maur?cio Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) Jo?o Pessoa, PB, +55 83 8867-7208 -------------- next part -------------- An HTML attachment was scrubbed... URL: From pergesu at gmail.com Tue Aug 19 18:06:38 2008 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 19 Aug 2008 18:06:38 -0400 Subject: [rspec-users] failing before :all doesn't move progress bar in html reports In-Reply-To: References: <19059450.post@talk.nabble.com> Message-ID: <810a540e0808191506wb3bc012i11dad96680600447@mail.gmail.com> On Tue, Aug 19, 2008 at 5:55 PM, Maur?cio Linhares wrote: > Maybe you shouldn't be placing spectations in a before or after filter, it > doesn't make much sense. I disagree. They can be useful for verifying assumptions about fixture data. At any rate, a bug's a bug. juuser: can you please submit a ticket @ http://rspec.lighthouseapp.com ? Pat From jarmo.p at gmail.com Tue Aug 19 18:11:14 2008 From: jarmo.p at gmail.com (juuuser) Date: Tue, 19 Aug 2008 15:11:14 -0700 (PDT) Subject: [rspec-users] failing before :all doesn't move progress bar in html reports In-Reply-To: References: <19059450.post@talk.nabble.com> Message-ID: <19059735.post@talk.nabble.com> It makes sense to me. Let's say that you want to initialize object in your before :all, but this fails. For example, in my case I'm using RSpec for automated web testing with Watir and I'm logging into web application from before :all and if this fails then it's logical that there's no point to execute any further specs and carry on with next describe block, but html report won't be correct. Maur?cio Linhares-3 wrote: > > Maybe you shouldn't be placing spectations in a before or after filter, it > doesn't make much sense. > -- View this message in context: http://www.nabble.com/failing-before-%3Aall-doesn%27t-move-progress-bar-in-html-reports-tp19059450p19059735.html Sent from the rspec-users mailing list archive at Nabble.com. From lists at ruby-forum.com Tue Aug 19 18:17:35 2008 From: lists at ruby-forum.com (RSL ___) Date: Wed, 20 Aug 2008 00:17:35 +0200 Subject: [rspec-users] RSpec raising routing errors where Rails doesn't? Message-ID: <0f883ab9d476d44870f02651511332ab@ruby-forum.com> Hopefully someone here can help me figure out why the ERB: <% form_for(@fund, :url => {:host => PRIVATE_HOST}, :html => {:class => 'fund', :multipart => true}) do |f| %> raises an error in my specs: No route matches {:action=>"index"} but works fine in my app and generates the following, desired HTML:
. Many thanks in advance. RSL -- Posted via http://www.ruby-forum.com/. From pergesu at gmail.com Tue Aug 19 18:22:51 2008 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 19 Aug 2008 18:22:51 -0400 Subject: [rspec-users] Any news on the rSpec books? In-Reply-To: References: <200805031906.49313.michael@schuerig.de> <57c63afe0808150358i52db0e4cn747d2d8a429cbcee@mail.gmail.com> Message-ID: <810a540e0808191522i556844e9r9233c6948c4fa5d0@mail.gmail.com> On Fri, Aug 15, 2008 at 11:29 AM, Dan North wrote: > There are also some success stories around using rspec story runner + jruby > as a functional testing layer for Java apps. Someone blogged about it a > while ago but I forget who. http://pivots.pivotallabs.com/users/pzabelin/blog/articles/375-functional-tests-for-java-project-rspec-jruby From pergesu at gmail.com Tue Aug 19 18:26:27 2008 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 19 Aug 2008 18:26:27 -0400 Subject: [rspec-users] Stubbing calls to the command line In-Reply-To: <85d99afe0808141409g3db9f968p94b6f855ab3be1e9@mail.gmail.com> References: <477ba9f2b13cb126d6942e6c27c0413d@ruby-forum.com> <85d99afe0808141409g3db9f968p94b6f855ab3be1e9@mail.gmail.com> Message-ID: <810a540e0808191526i700e3c42va948226c6fc45c85@mail.gmail.com> On Thu, Aug 14, 2008 at 5:09 PM, Zach Dennis wrote: > I might end up with a separate object which managed making the wget > system call, and then I've have an integration-style test which > ensured it correctly downloaded a given passed in URL. +1 From pergesu at gmail.com Tue Aug 19 19:04:51 2008 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 19 Aug 2008 19:04:51 -0400 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <8d961d900808180411i1710578ew3673201968c794df@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <8d961d900808180411i1710578ew3673201968c794df@mail.gmail.com> Message-ID: <810a540e0808191604k5575d22cw18f3a28e6d44d35d@mail.gmail.com> > What do you think is the best thing to do? I would prefer to merge it into RSpec whenever it's ready. One of the strong points about RSpec is that it's a complete BDD toolkit: example framework for developer testing, feature runner for customer test, and the mock objects framework. People can get started with one part of the toolkit, and gradually use the other pieces as their wants and needs develop. I think it was a big win when RBehave merged into RSpec. If Cucumber represents significant improvements over the current Story Runner, I'd like to see those improvements make it into RSpec. Pat From dchelimsky at gmail.com Tue Aug 19 19:33:09 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 19 Aug 2008 18:33:09 -0500 Subject: [rspec-users] RSpec raising routing errors where Rails doesn't? In-Reply-To: <0f883ab9d476d44870f02651511332ab@ruby-forum.com> References: <0f883ab9d476d44870f02651511332ab@ruby-forum.com> Message-ID: <57c63afe0808191633w3352d5atc0cdd1c62a5a69fd@mail.gmail.com> On Tue, Aug 19, 2008 at 5:17 PM, RSL ___ wrote: > Hopefully someone here can help me figure out why the ERB: > > <% form_for(@fund, :url => {:host => PRIVATE_HOST}, :html => {:class > => 'fund', :multipart => true}) do |f| %> > > raises an error in my specs: > > No route matches {:action=>"index"} > > but works fine in my app and generates the following, desired HTML: > > enctype="multipart/form-data" > action="http://domain.com:3000/funds/18/edit">. If you're using edge rails, there was a recent change that broke rspec: http://rspec.lighthouseapp.com/projects/5645/tickets/497 I haven't had time to address this, nor will I for at least several days. I will have time to merge in a patch, however, if anybody else has the time to fix the problem. Cheers, David > Many thanks in advance. > > RSL > -- > 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-rspec at shopwatch.org Tue Aug 19 20:40:02 2008 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Tue, 19 Aug 2008 20:40:02 -0400 Subject: [rspec-users] I want RSpec for CSS layout. Message-ID: <48AB67E2.1000009@shopwatch.org> I don't even know how it'd be possible (through Selenium?), but I want it. I want to see if my stupid CSS hacks break. I want to say: describe "#nav-column" do body = something("#body-column") it "should line up at the top" do dom[:top].should_be == body.dom[:top] end it "should always be to the right" do dom[:left].should_be > body.dom[:right] end end And I want to be able to run it on Firefox, IE6, IE7, and Safari. Lazyweb... go. From joshknowles at gmail.com Tue Aug 19 20:51:29 2008 From: joshknowles at gmail.com (Josh Knowles) Date: Tue, 19 Aug 2008 20:51:29 -0400 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <810a540e0808191604k5575d22cw18f3a28e6d44d35d@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <8d961d900808180411i1710578ew3673201968c794df@mail.gmail.com> <810a540e0808191604k5575d22cw18f3a28e6d44d35d@mail.gmail.com> Message-ID: On 8/19/08, Pat Maddox wrote: > I would prefer to merge it into RSpec whenever it's ready. For whatever its worth I agree with Pat. Most of the short-comings of the existing story runner that Aslak describes in the Cucumber README are things that we at weplay have had to hack together. Having some standardization for running a single scenario, or all scenarios, would make developing tools on-top of the framework that much easier. Josh -- Josh Knowles phone: 509-979-1593 email: joshknowles at gmail.com web: http://joshknowles.com From ml at e4net.com Wed Aug 20 01:04:57 2008 From: ml at e4net.com (Jim Morris) Date: Tue, 19 Aug 2008 22:04:57 -0700 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <48A9D18D.3070704@e4net.com> <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> Message-ID: <48ABA5F9.1070801@e4net.com> Aslak Helles?y wrote: > > Right now the scope of Before/After is global - i.e. all Before and > After blocks will run before and after each scenario. I have > deliberately postponed adding scoping of this until I better understand > how people want to define this scoping. > > Here is one ideas: > > class MySteps < Cucumber::Steps # Same as Story runnner steps_for(:my) > Before do > # This block will run before all scenarios that use steps from MySteps > # Any scenarios not using any of these will not have this block run > end > > Given /bla bla/ do > end > end > > I'm open to other ideas too. I'd like to have a before story and after story as well as a before scenario and after scenario. Right now I do global setup for a story, and cleanup when the story is done. I also do a setup before each scenario as well. It would be nice to have the ability to do both. Thanks -- Jim Morris, http://blog.wolfman.com From aslak.hellesoy at gmail.com Wed Aug 20 02:14:57 2008 From: aslak.hellesoy at gmail.com (=?ISO-8859-1?Q?Aslak_Helles=F8y?=) Date: Wed, 20 Aug 2008 08:14:57 +0200 Subject: [rspec-users] Any news on the rSpec books? In-Reply-To: <810a540e0808191522i556844e9r9233c6948c4fa5d0@mail.gmail.com> References: <200805031906.49313.michael@schuerig.de> <57c63afe0808150358i52db0e4cn747d2d8a429cbcee@mail.gmail.com> <810a540e0808191522i556844e9r9233c6948c4fa5d0@mail.gmail.com> Message-ID: <952DF645-631A-4D6B-9DC3-0321CB74063F@gmail.com> On Aug 20, 2008, at 12:22 AM, Pat Maddox wrote: > On Fri, Aug 15, 2008 at 11:29 AM, Dan North > wrote: >> There are also some success stories around using rspec story runner >> + jruby >> as a functional testing layer for Java apps. Someone blogged about >> it a >> while ago but I forget who. > > http://pivots.pivotallabs.com/users/pzabelin/blog/articles/375-functional-tests-for-java-project-rspec-jruby http://github.com/aslakhellesoy/cucumber/tree/master/examples/java > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Wed Aug 20 02:17:37 2008 From: aslak.hellesoy at gmail.com (=?ISO-8859-1?Q?Aslak_Helles=F8y?=) Date: Wed, 20 Aug 2008 08:17:37 +0200 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <810a540e0808191604k5575d22cw18f3a28e6d44d35d@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <8d961d900808180411i1710578ew3673201968c794df@mail.gmail.com> <810a540e0808191604k5575d22cw18f3a28e6d44d35d@mail.gmail.com> Message-ID: <719AC55F-39FD-4295-9591-9991F5A16063@gmail.com> On Aug 20, 2008, at 1:04 AM, Pat Maddox wrote: >> What do you think is the best thing to do? > > I would prefer to merge it into RSpec whenever it's ready. One of the > strong points about RSpec is that it's a complete BDD toolkit: example > framework for developer testing, feature runner for customer test, and > the mock objects framework. People can get started with one part of > the toolkit, and gradually use the other pieces as their wants and I agree. These are the key success factors of Ruby on Rails. -Which consists of 5 or so gems Aslak > > needs develop. I think it was a big win when RBehave merged into > RSpec. If Cucumber represents significant improvements over the > current Story Runner, I'd like to see those improvements make it into > RSpec. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Wed Aug 20 02:20:07 2008 From: aslak.hellesoy at gmail.com (=?ISO-8859-1?Q?Aslak_Helles=F8y?=) Date: Wed, 20 Aug 2008 08:20:07 +0200 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <48ABA5F9.1070801@e4net.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <48A9D18D.3070704@e4net.com> <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> Message-ID: <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> On Aug 20, 2008, at 7:04 AM, Jim Morris wrote: > Aslak Helles?y wrote: > >> Right now the scope of Before/After is global - i.e. all Before and >> After blocks will run before and after each scenario. I have >> deliberately postponed adding scoping of this until I better >> understand how people want to define this scoping. >> Here is one ideas: >> class MySteps < Cucumber::Steps # Same as Story runnner >> steps_for(:my) >> Before do >> # This block will run before all scenarios that use steps from >> MySteps >> # Any scenarios not using any of these will not have this block >> run >> end >> Given /bla bla/ do >> end >> end >> I'm open to other ideas too. > > I'd like to have a before story and after story as well as a before > scenario and after scenario. > > Right now I do global setup for a story, and cleanup when the story > is done. I also do a setup before each scenario as well. > > It would be nice to have the ability to do both. Can you give me a code example? (In Cucumber it's Feature, not Story) Aslak > > > Thanks > > -- > Jim Morris, http://blog.wolfman.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Wed Aug 20 03:21:44 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 20 Aug 2008 09:21:44 +0200 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <48ABBA8A.5030500@e4net.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <48A9D18D.3070704@e4net.com> <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <48ABBA8A.5030500@e4net.com> Message-ID: <8d961d900808200021m6fb3cf4asabe0188d64098f6b@mail.gmail.com> On Wed, Aug 20, 2008 at 8:32 AM, Jim Morris wrote: > Aslak Helles?y wrote: > >>> >>> I'd like to have a before story and after story as well as a before >>> scenario and after scenario. >>> >>> Right now I do global setup for a story, and cleanup when the story is >>> done. I also do a setup before each scenario as well. >>> >>> It would be nice to have the ability to do both. >> >> Can you give me a code example? (In Cucumber it's Feature, not Story) >> > > An example of how I would use it or an example of how to do it? > Of how you would use it. Assume that you have something like this for scenario-level before/after: class MySteps < Cucumber::Steps # Same as Story runnner steps_for(:my) Before do # This block will run before all scenarios that use steps from MySteps # Any scenarios not using any of these will not have this block run end Given /bla bla/ do end end Aslak > Right now I use the listeners to call a before_story and after_story and > before_scenario. > > My Stories (Features) test the database as well as the return values of > various calls, so the before_story sets up the database accessors via > Sequel, putting them in global variables so I can easily access them from > anywhere. > > In the before_scenario I for instance make sure the user is logged out and > the database is cleared. > > -- > Jim Morris, http://blog.wolfman.com > From matt at mattwynne.net Wed Aug 20 04:51:14 2008 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 20 Aug 2008 09:51:14 +0100 Subject: [rspec-users] I want RSpec for CSS layout. In-Reply-To: <48AB67E2.1000009@shopwatch.org> References: <48AB67E2.1000009@shopwatch.org> Message-ID: +1 cheers, Matt ---- http://blog.mattwynne.net http://songkick.com In case you wondered: The opinions expressed in this email are my own and do not necessarily reflect the views of any former, current or future employers of mine. On 20 Aug 2008, at 01:40, Jay Levitt wrote: > I don't even know how it'd be possible (through Selenium?), but I > want it. I want to see if my stupid CSS hacks break. I want to say: > > describe "#nav-column" do > body = something("#body-column") > > it "should line up at the top" do > dom[:top].should_be == body.dom[:top] > end > > it "should always be to the right" do > dom[:left].should_be > body.dom[:right] > end > > end > > And I want to be able to run it on Firefox, IE6, IE7, and Safari. > > Lazyweb... go. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aidy.lewis at googlemail.com Wed Aug 20 08:19:37 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Wed, 20 Aug 2008 13:19:37 +0100 Subject: [rspec-users] Story Runner Example with Watir Message-ID: <7ac2300c0808200519r1946e475pa521315b29fe8ed0@mail.gmail.com> Lies here gem install watir http://wiki.openqa.org/display/WTR/Example+Frameworks I will need to port this to Cucumber Feedback Welcome. Aidy From lists at ruby-forum.com Wed Aug 20 09:09:16 2008 From: lists at ruby-forum.com (RSL ___) Date: Wed, 20 Aug 2008 15:09:16 +0200 Subject: [rspec-users] RSpec raising routing errors where Rails doesn't? In-Reply-To: <57c63afe0808191633w3352d5atc0cdd1c62a5a69fd@mail.gmail.com> References: <0f883ab9d476d44870f02651511332ab@ruby-forum.com> <57c63afe0808191633w3352d5atc0cdd1c62a5a69fd@mail.gmail.com> Message-ID: Thanks, David but unfortunately for me this is happening on 2.0.2 Rails, with rspec/rspec-rails, from about a month and a half ago. Must be something else. Here's hoping someone else has run across this. :/ -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Wed Aug 20 09:13:41 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 20 Aug 2008 15:13:41 +0200 Subject: [rspec-users] Story Runner Example with Watir In-Reply-To: <7ac2300c0808200519r1946e475pa521315b29fe8ed0@mail.gmail.com> References: <7ac2300c0808200519r1946e475pa521315b29fe8ed0@mail.gmail.com> Message-ID: <8d961d900808200613r854fa42re89843ebb3ef0218@mail.gmail.com> On Wed, Aug 20, 2008 at 2:19 PM, aidy lewis wrote: > Lies here > > gem install watir > > http://wiki.openqa.org/display/WTR/Example+Frameworks > > I will need to port this to Cucumber > That would be great! Would you consider storing the code in Cucumber's watir example directory? examples/watir_gmail. That way it's easier to maintain if Cucumber changes.' You can clone my cucumber git repo and commit/push it to your clone and let me merge it into the official cucu8mber repo (mine). Or you can upload a zip in RSpec's Lighthouse and tag it with cucumber and watir. I'll then add it straight to my Cucumber git repo. I realize Watir users may want a separate zip download, but it would still be nice to have the official example live in an SCM I have access to. Cheers, Aslak > Feedback Welcome. > > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Aug 20 09:17:20 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 Aug 2008 08:17:20 -0500 Subject: [rspec-users] RSpec raising routing errors where Rails doesn't? In-Reply-To: References: <0f883ab9d476d44870f02651511332ab@ruby-forum.com> <57c63afe0808191633w3352d5atc0cdd1c62a5a69fd@mail.gmail.com> Message-ID: <57c63afe0808200617w76e7fe4ew3d169966814a30db@mail.gmail.com> Please post the code example. On Wed, Aug 20, 2008 at 8:09 AM, RSL ___ wrote: > Thanks, David but unfortunately for me this is happening on 2.0.2 Rails, > with rspec/rspec-rails, from about a month and a half ago. Must be > something else. Here's hoping someone else has run across this. :/ > -- > 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 Wed Aug 20 09:35:00 2008 From: lists at ruby-forum.com (RSL ___) Date: Wed, 20 Aug 2008 15:35:00 +0200 Subject: [rspec-users] RSpec raising routing errors where Rails doesn't? In-Reply-To: <57c63afe0808200617w76e7fe4ew3d169966814a30db@mail.gmail.com> References: <0f883ab9d476d44870f02651511332ab@ruby-forum.com> <57c63afe0808191633w3352d5atc0cdd1c62a5a69fd@mail.gmail.com> <57c63afe0808200617w76e7fe4ew3d169966814a30db@mail.gmail.com> Message-ID: <950ba4b8a6fe272738d46c012a7bf173@ruby-forum.com> David Chelimsky wrote: > Please post the code example. I have reduced the failing Rspec code to this: require File.dirname(__FILE__) + '/../../spec_helper' describe "funds/_form.fbml.erb" do before(:each) do @current_user = stub_model(User) @fund = stub_model(Fund, :supporters => [@current_user]) assigns[:fund] = @fund template.stub!(:current_user).and_return(@current_user) end it "should just render the template" do render "funds/_form.fbml.erb" end end which errors with: ActionView::TemplateError in 'funds/_form.fbml.erb should just render the template' No route matches {:action=>"index"} On line #6 of funds/_form.fbml.erb 3:

You can still change your email address and payment details at any time. Payment details are verified against fraud on the day of payout to your good cause.

4: 5: 6: <% form_for(@fund, :url => {:host => PRIVATE_HOST}, :html => {:class => 'fund', :multipart => true}) do |f| %> 7: <%= error_messages_for :fund %> 8:

9: /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1408:in `generate' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/url_rewriter.rb:124:in `rewrite_path' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/url_rewriter.rb:103:in `rewrite_url' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/url_rewriter.rb:81:in `rewrite' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:616:in `url_for' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/url_helper.rb:71:in `send' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/url_helper.rb:71:in `url_for' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/form_tag_helper.rb:395:in `html_options_for_form' /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/object/misc.rb:28:in `returning' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/form_tag_helper.rb:393:in `html_options_for_form' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/form_tag_helper.rb:38:in `form_tag' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/form_helper.rb:185:in `form_for' app/views/funds/_form.fbml.erb:6:in `_run_erb_47app47views47funds47_form46fbml46erb' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:in `send' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:in `compile_and_render_template' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:365:in `render_template' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:316:in `render_file' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1100:in `render_for_file' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:861:in `render_with_no_layout' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/layout.rb:270:in `render_without_benchmark' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:51:in `render' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in `measure' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:51:in `render' vendor/plugins/rspec-rails/lib/spec/rails/example/view_example_group.rb:130:in `send' vendor/plugins/rspec-rails/lib/spec/rails/example/view_example_group.rb:130:in `render' spec/views/funds/_form.fbml.erb_spec.rb:13 vendor/plugins/rspec/lib/spec/example/example_methods.rb:83:in `instance_eval' vendor/plugins/rspec/lib/spec/example/example_methods.rb:83:in `eval_block' vendor/plugins/rspec/lib/spec/example/example_methods.rb:21:in `execute' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:48:in `timeout' vendor/plugins/rspec/lib/spec/example/example_methods.rb:18:in `execute' vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:305:in `execute_examples' vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:304:in `each' vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:304:in `execute_examples' vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:132:in `run' vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:22:in `run' vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in `each' vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in `run' vendor/plugins/rspec/lib/spec/runner/options.rb:106:in `run_examples' vendor/plugins/rspec/lib/spec/runner/command_line.rb:19:in `run' script/spec:4 Hope that helps and thanks for your assistance. RSL -- Posted via http://www.ruby-forum.com/. From jonathan at parkerhill.com Wed Aug 20 10:04:31 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Wed, 20 Aug 2008 10:04:31 -0400 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <48A9D18D.3070704@e4net.com> <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> Message-ID: <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> On Aug 20, 2008, at 2:20 AM, Aslak Helles?y wrote: > (In Cucumber it's Feature, not Story) no offense, but while you're being picky about names, I dont see too much difference between 'story' and 'feature' but 'cucumber' is a really random meaningless name From dchelimsky at gmail.com Wed Aug 20 10:20:02 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 Aug 2008 09:20:02 -0500 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <48A9D18D.3070704@e4net.com> <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> Message-ID: <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> On Wed, Aug 20, 2008 at 9:04 AM, Jonathan Linowes wrote: > > On Aug 20, 2008, at 2:20 AM, Aslak Helles?y wrote: > >> (In Cucumber it's Feature, not Story) > > no offense, but while you're being picky about names, I dont see too much > difference between 'story' and 'feature' I see them as very different. User Stories are inputs to a development process and Features are the outputs. When I've worked with FitNesse, we had stories on cards and a suite of FitNesse tests. Sometimes a Story would come up in an iteration that was an enhancement of an existing feature. In those cases we did not add new FitNesse tests, but simply enhanced the existing ones instead. So the FitNesse test suite grew to represent executable documentation of an existing system, not a tracking system for stories over the course of iterations. Had we grouped all the FitNesse tests by the stories as they came in, in which iteration, etc, etc, they would have been much more difficult to navigate and maintain. Automated scenarios live in the same place that FitNesse tests do. Ideally, we would group them by Story going into an iteration and then by Feature coming out, but we don't really have a good way of doing that. Maybe the right approach would be to group them by neither Story nor Feature, but rather by execution context. For example, right now I've got stories that run one happy path scenario and one error path scenario that run in-browser, accompanied by a more exhaustive set of error path scenarios that run in-memory. These live in separate Story files and are only coupled together by their names. It would be nice if I could have a suite of in-browser scenarios, a suite of in-memory scenarios that touch the full stack (in rails), and possibly a suite of scenarios that touch only a given model. Then each scenario can be tagged to a Story and a Feature, and the runner could support running everything by Story, Feature or Execution Context, thus supporting readability, navigability, etc, from a number of useful perspectives. WDYT? > but 'cucumber' is a really random meaningless name > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Wed Aug 20 10:49:52 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 20 Aug 2008 16:49:52 +0200 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <48A9D18D.3070704@e4net.com> <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> Message-ID: <8d961d900808200749i63833acve7cfb471153ce5d4@mail.gmail.com> On Wed, Aug 20, 2008 at 4:20 PM, David Chelimsky wrote: > On Wed, Aug 20, 2008 at 9:04 AM, Jonathan Linowes > wrote: >> >> On Aug 20, 2008, at 2:20 AM, Aslak Helles?y wrote: >> >>> (In Cucumber it's Feature, not Story) >> >> no offense, but while you're being picky about names, I dont see too much >> difference between 'story' and 'feature' > > I see them as very different. > > User Stories are inputs to a development process and Features are the outputs. > That's a brilliant description. Much better than these ramblings: http://www.nabble.com/Re%3A--ANN--Cucumber-p18899320.html I would add to that that the features, which are the outputs of the development process, are the inputs to the outcomes. AKA Business value. These two posts complement that aspect nicely: http://www.artima.com/weblogs/viewpost.jsp?thread=183405 http://sirenian.livejournal.com/2008/05/14/ Regarding Cucumber - yes, the name is completely meaningless, but a couple of chicks who attended my presentation about it at Agile 2008 told me afterwards it made their mind drift... That's good enough for me. Aslak > When I've worked with FitNesse, we had stories on cards and a suite of > FitNesse tests. Sometimes a Story would come up in an iteration that > was an enhancement of an existing feature. In those cases we did not > add new FitNesse tests, but simply enhanced the existing ones instead. > So the FitNesse test suite grew to represent executable documentation > of an existing system, not a tracking system for stories over the > course of iterations. > > Had we grouped all the FitNesse tests by the stories as they came in, > in which iteration, etc, etc, they would have been much more difficult > to navigate and maintain. > > Automated scenarios live in the same place that FitNesse tests do. > Ideally, we would group them by Story going into an iteration and then > by Feature coming out, but we don't really have a good way of doing > that. > > Maybe the right approach would be to group them by neither Story nor > Feature, but rather by execution context. For example, right now I've > got stories that run one happy path scenario and one error path > scenario that run in-browser, accompanied by a more exhaustive set of > error path scenarios that run in-memory. These live in separate Story > files and are only coupled together by their names. > > It would be nice if I could have a suite of in-browser scenarios, a > suite of in-memory scenarios that touch the full stack (in rails), and > possibly a suite of scenarios that touch only a given model. Then each > scenario can be tagged to a Story and a Feature, and the runner could > support running everything by Story, Feature or Execution Context, > thus supporting readability, navigability, etc, from a number of > useful perspectives. > > WDYT? > >> but 'cucumber' is a really random meaningless name >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mark at mwilden.com Wed Aug 20 11:32:57 2008 From: mark at mwilden.com (Mark Wilden) Date: Wed, 20 Aug 2008 08:32:57 -0700 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <8d961d900808200749i63833acve7cfb471153ce5d4@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <48A9D18D.3070704@e4net.com> <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> <8d961d900808200749i63833acve7cfb471153ce5d4@mail.gmail.com> Message-ID: <3c30da400808200832i2cbcc56ar5d5890c7f155acfb@mail.gmail.com> On Wed, Aug 20, 2008 at 7:49 AM, aslak hellesoy wrote: > > Regarding Cucumber - yes, the name is completely meaningless, but a > couple of chicks who attended my presentation about it at Agile 2008 > told me afterwards it made their mind drift... That's good enough for > me. > Aslak, please feel free to use whatever verbiage you choose. I just wanted to mention that for some (including myself), such comments don't reflect well on the speaker. Maybe I'm just showing my age. :) ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Wed Aug 20 11:52:16 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 20 Aug 2008 17:52:16 +0200 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <3c30da400808200832i2cbcc56ar5d5890c7f155acfb@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> <8d961d900808200749i63833acve7cfb471153ce5d4@mail.gmail.com> <3c30da400808200832i2cbcc56ar5d5890c7f155acfb@mail.gmail.com> Message-ID: <8d961d900808200852i4b9b618h60e77ccefd654821@mail.gmail.com> On Wed, Aug 20, 2008 at 5:32 PM, Mark Wilden wrote: > On Wed, Aug 20, 2008 at 7:49 AM, aslak hellesoy > wrote: >> >> Regarding Cucumber - yes, the name is completely meaningless, but a >> couple of chicks who attended my presentation about it at Agile 2008 >> told me afterwards it made their mind drift... That's good enough for >> me. > > Aslak, please feel free to use whatever verbiage you choose. I just wanted > to mention that for some (including myself), such comments don't reflect > well on the speaker. Maybe I'm just showing my age. :) > I can live with that. If you really want to know the origin of the name, check out the bottom of http://github.com/aslakhellesoy/cucumber/tree/master/README.textile Let's get back on topic. Aslak > ///ark > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Wed Aug 20 12:24:40 2008 From: ben at benmabey.com (Ben Mabey) Date: Wed, 20 Aug 2008 10:24:40 -0600 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> Message-ID: <48AC4548.90201@benmabey.com> aslak hellesoy wrote: > The RSpec Story runner is likely to be deprecated in favour of the new > feature runner (temporarily called Cucumber). > http://www.nabble.com/-ANN--Cucumber-td18876816.html > > The RSpec Story runner will continue to exist for a while, I just > wanted to let you know that future development and documentation > efforts will be focused on Cucumber. Cucumber also has some > documentation and examples on Github, more specifically: > > * How to use without Rails > * How to use with Rails+Webrat > * How to use with Watir > > Please let me know if you'd like to help out documenting Cucumber. One > thing that is missing is a migration guide from RSpec Story runner. > Do you prefer to keep such documentation in the README or would a github wiki be better? -Ben From lists at ruby-forum.com Wed Aug 20 12:24:53 2008 From: lists at ruby-forum.com (RSL ___) Date: Wed, 20 Aug 2008 18:24:53 +0200 Subject: [rspec-users] RSpec raising routing errors where Rails doesn't? In-Reply-To: <950ba4b8a6fe272738d46c012a7bf173@ruby-forum.com> References: <0f883ab9d476d44870f02651511332ab@ruby-forum.com> <57c63afe0808191633w3352d5atc0cdd1c62a5a69fd@mail.gmail.com> <57c63afe0808200617w76e7fe4ew3d169966814a30db@mail.gmail.com> <950ba4b8a6fe272738d46c012a7bf173@ruby-forum.com> Message-ID: <2db843f0c61fa1df932b538b074ba154@ruby-forum.com> I gave up on solving this. Very very strange that it even occurs. Stranger still that I circumvented the problem by writing a view helper to construct the url like this: def private_fund_form_url(fund) if fund.new_record? funds_url(:host => PRIVATE_HOST) else fund_url(fund, :host => PRIVATE_HOST) end end [which is what the form_for should have been doing internally anyhow] and specing it in isolation. It passes in the helper specs so I just stub out the helper call in the view specs and all is well. Thanks again for your help, David. RSL -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed Aug 20 12:37:35 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 Aug 2008 11:37:35 -0500 Subject: [rspec-users] command line options in story runner run method In-Reply-To: <7ac2300c0808190509q2e7443fk5169f57e167b2318@mail.gmail.com> References: <7ac2300c0808180900m7b91dd18ldf02b969983dbfc6@mail.gmail.com> <7ac2300c0808181001x4729339w9a652c2c395e5e9e@mail.gmail.com> <57c63afe0808181007i6d270b8dq703b659ccbb4a4ec@mail.gmail.com> <7ac2300c0808190509q2e7443fk5169f57e167b2318@mail.gmail.com> Message-ID: <57c63afe0808200937t1ae52822l9863132b7ea25449@mail.gmail.com> On Tue, Aug 19, 2008 at 7:09 AM, aidy lewis wrote: > Hi David, > > 2008/8/18 David Chelimsky : > >> Those options don't make it to the runner, which reads the actual >> command line (ARGV). >> >> What I typically do is load up runner files that look like this: >> >> # stories/accounting/stories.rb >> with_steps_for :accounting do >> run 'path/to/a/story/file' >> end >> >> The, in a terminal: >> >> $ ruby stories/accounting/stories.rb -fh:/rspec_reports/#{filename}.htm > > I created a rake file that cycles through a number of runner folders > and runs individual ruby files using the kernal 'system' method so > that I can produce HTML reports. > > > task :dcs do > require 'find' > Find.find("projects/dcs/runner") do |path| > path.length > string_end = path.length > string_begin = string_end -3 > result = path.slice string_begin ... string_end > if result == ".rb" > source_location = "C:\\SvnProjects\\RubyUatFramework\\test\\" > path = path.gsub("/", "\\") > full_path = source_location + path > system("ruby #{full_path} -fh: C:\\rspec_reports\\#{Time.now.to_i}.htm") > end > end > end > > > However, I think I am having problems with the format switch. The HTML > will appear in the console but not on the file system. Try removing the space between ":" and "C:\\": system("ruby #{full_path} -fh:C:\\rspec_reports\\#{Time.now.to_i}.htm") That work? > > Thanks for the help > > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aidy.lewis at googlemail.com Wed Aug 20 12:45:11 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Wed, 20 Aug 2008 17:45:11 +0100 Subject: [rspec-users] command line options in story runner run method In-Reply-To: <57c63afe0808200937t1ae52822l9863132b7ea25449@mail.gmail.com> References: <7ac2300c0808180900m7b91dd18ldf02b969983dbfc6@mail.gmail.com> <7ac2300c0808181001x4729339w9a652c2c395e5e9e@mail.gmail.com> <57c63afe0808181007i6d270b8dq703b659ccbb4a4ec@mail.gmail.com> <7ac2300c0808190509q2e7443fk5169f57e167b2318@mail.gmail.com> <57c63afe0808200937t1ae52822l9863132b7ea25449@mail.gmail.com> Message-ID: <7ac2300c0808200945r654f46a9xb5d5c15e6ba846a2@mail.gmail.com> Hi David, Thanks for getting back. I piped it. system("ruby #{full_path} -fh > C:\\rspec_reports\\#{file_name}.htm") Works fine (in windows) Aidy 2008/8/20 David Chelimsky : > On Tue, Aug 19, 2008 at 7:09 AM, aidy lewis wrote: >> Hi David, >> >> 2008/8/18 David Chelimsky : >> >>> Those options don't make it to the runner, which reads the actual >>> command line (ARGV). >>> >>> What I typically do is load up runner files that look like this: >>> >>> # stories/accounting/stories.rb >>> with_steps_for :accounting do >>> run 'path/to/a/story/file' >>> end >>> >>> The, in a terminal: >>> >>> $ ruby stories/accounting/stories.rb -fh:/rspec_reports/#{filename}.htm >> >> I created a rake file that cycles through a number of runner folders >> and runs individual ruby files using the kernal 'system' method so >> that I can produce HTML reports. >> >> >> task :dcs do >> require 'find' >> Find.find("projects/dcs/runner") do |path| >> path.length >> string_end = path.length >> string_begin = string_end -3 >> result = path.slice string_begin ... string_end >> if result == ".rb" >> source_location = "C:\\SvnProjects\\RubyUatFramework\\test\\" >> path = path.gsub("/", "\\") >> full_path = source_location + path >> system("ruby #{full_path} -fh: C:\\rspec_reports\\#{Time.now.to_i}.htm") >> end >> end >> end >> >> >> However, I think I am having problems with the format switch. The HTML >> will appear in the console but not on the file system. > > Try removing the space between ":" and "C:\\": > > system("ruby #{full_path} -fh:C:\\rspec_reports\\#{Time.now.to_i}.htm") > > That work? > >> >> Thanks for the help >> >> 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 aidy.lewis at googlemail.com Wed Aug 20 12:47:29 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Wed, 20 Aug 2008 17:47:29 +0100 Subject: [rspec-users] Story Runner Example with Watir In-Reply-To: <8d961d900808200613r854fa42re89843ebb3ef0218@mail.gmail.com> References: <7ac2300c0808200519r1946e475pa521315b29fe8ed0@mail.gmail.com> <8d961d900808200613r854fa42re89843ebb3ef0218@mail.gmail.com> Message-ID: <7ac2300c0808200947m4d4ec977q45337baf2752e84b@mail.gmail.com> Hi Aslak 2008/8/20 aslak hellesoy : > On Wed, Aug 20, 2008 at 2:19 PM, aidy lewis wrote: > Would you consider storing the code in Cucumber's watir example > directory? examples/watir_gmail. That way it's easier to maintain if > Cucumber changes.' > Yes, will commit in a few days Aidy From lists at ruby-forum.com Wed Aug 20 15:03:00 2008 From: lists at ruby-forum.com (Joseph Wilk) Date: Wed, 20 Aug 2008 21:03:00 +0200 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <8d961d900808180411i1710578ew3673201968c794df@mail.gmail.com> <810a540e0808191604k5575d22cw18f3a28e6d44d35d@mail.gmail.com> Message-ID: I agree with Pat also. But I think importantly we need a little tool/guide on converting the old stories to cucumber before any movement. I'm currently evaluating moving our stories to cucumber. I'll see if I can put something together that might help others (if its not already available?). Also the word 'feature' resolves so many issues I had with stories and how they mapped into my testing framework. Thanks Aslak! -- Joseph Wilk http://www.joesniff.co.uk Josh Knowles wrote: > On 8/19/08, Pat Maddox wrote: >> I would prefer to merge it into RSpec whenever it's ready. > > For whatever its worth I agree with Pat. Most of the short-comings of > the existing story runner that Aslak describes in the Cucumber README > are things that we at weplay have had to hack together. Having some > standardization for running a single scenario, or all scenarios, would > make developing tools on-top of the framework that much easier. > > Josh > > -- > Josh Knowles > phone: 509-979-1593 > email: joshknowles at gmail.com > web: http://joshknowles.com -- Posted via http://www.ruby-forum.com/. From ml at e4net.com Wed Aug 20 16:24:22 2008 From: ml at e4net.com (Jim Morris) Date: Wed, 20 Aug 2008 13:24:22 -0700 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <8d961d900808200021m6fb3cf4asabe0188d64098f6b@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <48A9D18D.3070704@e4net.com> <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <48ABBA8A.5030500@e4net.com> <8d961d900808200021m6fb3cf4asabe0188d64098f6b@mail.gmail.com> Message-ID: <48AC7D76.8000905@e4net.com> aslak hellesoy wrote: > > Of how you would use it. Assume that you have something like this for > scenario-level before/after: > > class MySteps < Cucumber::Steps # Same as Story runnner steps_for(:my) > Before do > # This block will run before all scenarios that use steps from MySteps > # Any scenarios not using any of these will not have this block run > end > > Given /bla bla/ do > end > end > > Aslak > Ok here is an example from one of my current stories.... Modified to be Cucumber-like, although I see you put the Before and after in the steps, I'd p[refer them to be global, but could live with them in the steps class. Of course where would you put the scenarios before and after? They probably need to be global? (Note I am not using Rails,this is an integration test against a Web Application testing the full stack using net/http and some helpers to wrap that. It can test remote servers, It also uses Sequel to test that the database gets setup properly, again a bunch of helpers lets me inject data directly into the database and test afterwards). # setup several users each with their own web context # setup global database accessor BeforeFeature do # actual user names to login as user_names= %w(user50 user51 user52) $umap= {} $wr= {} user_names.each_with_index do |e, i| n= "user#{i+1}" $umap[n]= e $wr[n]= WebRequest.new end $users= {} $loggedin= {} $db= MyDBHelper.new('local', false) end # logout the users AfterFeature do $wr.each_value { |w| w.logout } end # called before each scenario # to clean up any state conatianing globals used to communicate between steps # and log out any user that was logged in during the previous Scenario BeforeScenario do $wr.each_key do |u| $wr[u].logout if $loggedin[u] end $last_error= nil $roomid= nil $roomobjectid= nil $last_doc= nil $bagid= nil end -- Jim Morris, http://blog.wolfman.com From aslak.hellesoy at gmail.com Thu Aug 21 02:58:40 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 21 Aug 2008 08:58:40 +0200 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <48AC4548.90201@benmabey.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <48AC4548.90201@benmabey.com> Message-ID: <8d961d900808202358x18a7834bgb1270759affe28f9@mail.gmail.com> On Wed, Aug 20, 2008 at 6:24 PM, Ben Mabey wrote: > aslak hellesoy wrote: >> The RSpec Story runner is likely to be deprecated in favour of the new >> feature runner (temporarily called Cucumber). >> http://www.nabble.com/-ANN--Cucumber-td18876816.html >> >> The RSpec Story runner will continue to exist for a while, I just >> wanted to let you know that future development and documentation >> efforts will be focused on Cucumber. Cucumber also has some >> documentation and examples on Github, more specifically: >> >> * How to use without Rails >> * How to use with Rails+Webrat >> * How to use with Watir >> >> Please let me know if you'd like to help out documenting Cucumber. One >> thing that is missing is a migration guide from RSpec Story runner. >> > > > > Do you prefer to keep such documentation in the README or would a github > wiki be better? > Good idea, I have moved the README.textile to http://github.com/aslakhellesoy/cucumber/wikis/home Everyone here is welcome to edit it. If you have concrete experience (or wishes) about how to migrate existing stories to Cucumber this would be the place to do it. Aslak > -Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Thu Aug 21 12:08:34 2008 From: lists at ruby-forum.com (Joseph Wilk) Date: Thu, 21 Aug 2008 18:08:34 +0200 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <8d961d900808202358x18a7834bgb1270759affe28f9@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <48AC4548.90201@benmabey.com> <8d961d900808202358x18a7834bgb1270759affe28f9@mail.gmail.com> Message-ID: <85cbdebfbc8e3a616f6fe032c5eb6ef7@ruby-forum.com> Hello, I've been looking through the cucumber documentation and have a couple of questions. I'm curious which of the disadvantages you list would be impossible/very difficult in the classic story runner. I'm just trying to envisage if Cucumber and the classic story runner where to co-exist what would the Cucumber plugin be able to do that the classic story runner could never realistically hope to achieve. Also looking at one of your disadvantages: * 'Limited colouring of output' I've been playing around with patches here and there to improve the colour of the classic story runner formatters. Do you still see limitations in this as it is in edge? My final question is about the Rspec book. I've no idea when this will be released or what pressures there are on publish deadlines. How much would this effect a move to Cucumber (avoiding having redundant story examples in the book when we all use Cucumber)? Thanks, -- Joseph Wilk http://www.joesniff.co.uk aslak hellesoy wrote: > On Wed, Aug 20, 2008 at 6:24 PM, Ben Mabey wrote: >>> * How to use without Rails >> wiki be better? >> > > Good idea, I have moved the README.textile to > http://github.com/aslakhellesoy/cucumber/wikis/home > > Everyone here is welcome to edit it. If you have concrete experience > (or wishes) about how to migrate existing stories to Cucumber this > would be the place to do it. > > Aslak -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Aug 21 13:56:50 2008 From: lists at ruby-forum.com (RSL ___) Date: Thu, 21 Aug 2008 19:56:50 +0200 Subject: [rspec-users] rescue_from failing to rescue [from] Message-ID: Having some weird failures of rescue_from in all my specs. They still rescue in actual usage, just not in my specs. Made a pastie of the code: http://pastie.org/257399 This is with latest [as of 1:00 PM Eastern time zone] rspec/rspec-rails/edge. Thanks in advance for any replies on this. RSL -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Aug 21 14:32:11 2008 From: lists at ruby-forum.com (RSL ___) Date: Thu, 21 Aug 2008 20:32:11 +0200 Subject: [rspec-users] rescue_from failing to rescue [from] In-Reply-To: References: Message-ID: Apparently this is documented behavior and can be fixed with @controller.use_rails_error_handling! though I'm not sure why they're suddenly failing now [since use_rails_error_handling! has been in rspec-rails since June of last year, heh] but I'm not looking this gift horse in the mouth. RSL RSL ___ wrote: > Having some weird failures of rescue_from in all my specs. They still > rescue in actual usage, just not in my specs. Made a pastie of the code: > http://pastie.org/257399 This is with latest [as of 1:00 PM Eastern time > zone] rspec/rspec-rails/edge. Thanks in advance for any replies on this. > > RSL -- Posted via http://www.ruby-forum.com/. From mark at mwilden.com Thu Aug 21 15:25:16 2008 From: mark at mwilden.com (Mark Wilden) Date: Thu, 21 Aug 2008 12:25:16 -0700 Subject: [rspec-users] rake spec order of running tests Message-ID: <3c30da400808211225m5cb6acd4l59b89ce30a5d4d5e@mail.gmail.com> We ran into a situation today where running 'rake spec' on one machine produced different results than when running on a different machine. My reasoned hunch is that the tests were run in a different order, due to the file-globbing producing differently ordered file lists. Because some tests used fixtures and some didn't, that resulted in different test db contents, depending on the order the tests were run (clearly, these tests need fixing). I haven't really looked into this at all, for now. But it occurs to me that if my suspicion is correct, this situation would be fixed by running tests in alphabetical order. Presumably this would be a change to the spec Rake task. Does this make any kind of sense? If so, I (or someone better suited to the task) could look into it further. (Coincidentally, a similar situation resulted in a contribution I made to Visual FoxPro!) ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Thu Aug 21 15:51:15 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 21 Aug 2008 14:51:15 -0500 Subject: [rspec-users] rake spec order of running tests In-Reply-To: <3c30da400808211225m5cb6acd4l59b89ce30a5d4d5e@mail.gmail.com> References: <3c30da400808211225m5cb6acd4l59b89ce30a5d4d5e@mail.gmail.com> Message-ID: <57c63afe0808211251p2044b55dn18f96d73e878d54e@mail.gmail.com> On Thu, Aug 21, 2008 at 2:25 PM, Mark Wilden wrote: > We ran into a situation today where running 'rake spec' on one machine > produced different results than when running on a different machine. My > reasoned hunch is that the tests were run in a different order, due to the > file-globbing producing differently ordered file lists. Because some tests > used fixtures and some didn't, that resulted in different test db contents, > depending on the order the tests were run (clearly, these tests need > fixing). > > I haven't really looked into this at all, for now. But it occurs to me that > if my suspicion is correct, this situation would be fixed by running tests > in alphabetical order. Presumably this would be a change to the spec Rake > task. > > Does this make any kind of sense? If so, I (or someone better suited to the > task) could look into it further. (Coincidentally, a similar situation > resulted in a contribution I made to Visual FoxPro!) My personal feeling is that the code examples should be able to run in any arbitrary order and still pass (no dependencies between examples), so I would recommend you find the dependency rather than working around the problem by enforcing order. Cheers, David > ///ark > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ml at e4net.com Thu Aug 21 16:46:14 2008 From: ml at e4net.com (Jim Morris) Date: Thu, 21 Aug 2008 13:46:14 -0700 Subject: [rspec-users] Cucumber table docs? Message-ID: <48ADD416.8060801@e4net.com> Hi, I'm looking at the examples in cucumber, and I see the fit-like tables, but for the life of me I don't see how they map to the steps, ie how does the table data get fitted into the steps parameters. Maybe some documentation for these tables is in order ;) Thanks Jim -- Jim Morris, http://blog.wolfman.com From mark at mwilden.com Thu Aug 21 17:29:00 2008 From: mark at mwilden.com (Mark Wilden) Date: Thu, 21 Aug 2008 14:29:00 -0700 Subject: [rspec-users] rake spec order of running tests In-Reply-To: <57c63afe0808211251p2044b55dn18f96d73e878d54e@mail.gmail.com> References: <3c30da400808211225m5cb6acd4l59b89ce30a5d4d5e@mail.gmail.com> <57c63afe0808211251p2044b55dn18f96d73e878d54e@mail.gmail.com> Message-ID: <3c30da400808211429t544df7cgc5fef55572352be5@mail.gmail.com> On Thu, Aug 21, 2008 at 12:51 PM, David Chelimsky wrote: > > My personal feeling is that the code examples should be able to run in > any arbitrary order and still pass (no dependencies between examples) I agree, which is why I said "clearly these tests need fixing." Maybe a better suggestion would be to execute the tests in random order each time... However, the point was that we didn't -know- there was an order dependency, and neither would the guy whose specs all passed before he went on vacation. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Fri Aug 22 09:18:12 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 22 Aug 2008 08:18:12 -0500 Subject: [rspec-users] rake spec order of running tests In-Reply-To: <3c30da400808211429t544df7cgc5fef55572352be5@mail.gmail.com> References: <3c30da400808211225m5cb6acd4l59b89ce30a5d4d5e@mail.gmail.com> <57c63afe0808211251p2044b55dn18f96d73e878d54e@mail.gmail.com> <3c30da400808211429t544df7cgc5fef55572352be5@mail.gmail.com> Message-ID: <57c63afe0808220618i4b9f789fva20a1f5d9a8380d7@mail.gmail.com> On Thu, Aug 21, 2008 at 4:29 PM, Mark Wilden wrote: > On Thu, Aug 21, 2008 at 12:51 PM, David Chelimsky > wrote: >> >> My personal feeling is that the code examples should be able to run in >> any arbitrary order and still pass (no dependencies between examples) > > I agree, which is why I said "clearly these tests need fixing." Got it. > Maybe a > better suggestion would be to execute the tests in random order each time... There's been some discussion of this but it never got completed. > > However, the point was that we didn't -know- there was an order dependency, > and neither would the guy whose specs all passed before he went on vacation. Any chance the different machines are windows and otherwise? By default the files are loaded alphabetically, but that means different things on windows machines (which treat alpha without regard to case) and pretty much anything else. > > ///ark > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mark at mwilden.com Fri Aug 22 10:50:46 2008 From: mark at mwilden.com (Mark Wilden) Date: Fri, 22 Aug 2008 07:50:46 -0700 Subject: [rspec-users] rake spec order of running tests In-Reply-To: <57c63afe0808220618i4b9f789fva20a1f5d9a8380d7@mail.gmail.com> References: <3c30da400808211225m5cb6acd4l59b89ce30a5d4d5e@mail.gmail.com> <57c63afe0808211251p2044b55dn18f96d73e878d54e@mail.gmail.com> <3c30da400808211429t544df7cgc5fef55572352be5@mail.gmail.com> <57c63afe0808220618i4b9f789fva20a1f5d9a8380d7@mail.gmail.com> Message-ID: <3c30da400808220750l2dfa6c0xe2d088bd4a398f0c@mail.gmail.com> On Fri, Aug 22, 2008 at 6:18 AM, David Chelimsky wrote: > > Any chance the different machines are windows and otherwise? By > default the files are loaded alphabetically, but that means different > things on windows machines (which treat alpha without regard to case) > and pretty much anything else. > The specs ran fine a Free-BSD machine, but failed on Windows and OS X machines. The guy who "initiated" the failures was on Windows but doesn't tend to run rake spec locally (this was Bruce, Pat). Maybe I'll have a look at the random order thing... ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Fri Aug 22 11:38:02 2008 From: ben at benmabey.com (Ben Mabey) Date: Fri, 22 Aug 2008 09:38:02 -0600 Subject: [rspec-users] rake spec order of running tests In-Reply-To: <3c30da400808220750l2dfa6c0xe2d088bd4a398f0c@mail.gmail.com> References: <3c30da400808211225m5cb6acd4l59b89ce30a5d4d5e@mail.gmail.com> <57c63afe0808211251p2044b55dn18f96d73e878d54e@mail.gmail.com> <3c30da400808211429t544df7cgc5fef55572352be5@mail.gmail.com> <57c63afe0808220618i4b9f789fva20a1f5d9a8380d7@mail.gmail.com> <3c30da400808220750l2dfa6c0xe2d088bd4a398f0c@mail.gmail.com> Message-ID: <48AEDD5A.6030907@benmabey.com> Mark Wilden wrote: > On Fri, Aug 22, 2008 at 6:18 AM, David Chelimsky > wrote: > > > Any chance the different machines are windows and otherwise? By > default the files are loaded alphabetically, but that means different > things on windows machines (which treat alpha without regard to case) > and pretty much anything else. > > > The specs ran fine a Free-BSD machine, but failed on Windows and OS X > machines. The guy who "initiated" the failures was on Windows but > doesn't tend to run rake spec locally (this was Bruce, Pat). > > Maybe I'll have a look at the random order thing... > I think autotest does this already... It will at least mess with the order of your specs/tests so that brittle ones are exposed. -Ben > ///ark > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From luke at lukemelia.com Fri Aug 22 13:37:24 2008 From: luke at lukemelia.com (Luke Melia) Date: Fri, 22 Aug 2008 13:37:24 -0400 Subject: [rspec-users] Autotest setup to run Story Runner? In-Reply-To: References: <54EB15AE-9C47-4D02-A765-C311F08FECBE@gmail.com> <22dff54ab7ee5ab93fd92a882139c677@ruby-forum.com> <85d99afe0808141400t2f0ba97tb93206dfa0684727@mail.gmail.com> Message-ID: <80B0F5E8-1270-4261-9E89-DB5528A6EAC9@lukemelia.com> On Aug 14, 2008, at 5:10 PM, Ben Men wrote: > ... I think it would still be incredibly useful even if > it ran a single scenario every time you edit that scenario - not > necessarily the source files that the scenario would "operate" on. You can pull this off pretty easily with rstakeout. Luke -- Luke Melia luke at lukemelia.com http://www.lukemelia.com/ From jonathan at parkerhill.com Fri Aug 22 13:53:42 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Fri, 22 Aug 2008 13:53:42 -0400 Subject: [rspec-users] story vs feature (was Documentation for Plain-Text Stories) In-Reply-To: <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <48A9D18D.3070704@e4net.com> <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> Message-ID: <1341C3E7-DB99-4F7D-8576-60F2107B3C7F@parkerhill.com> On Aug 20, 2008, at 10:20 AM, David Chelimsky wrote: > > I see them as very different. > > User Stories are inputs to a development process and Features are > the outputs. I decided to churn on this for a few days before responding. Actually I was going to let it drop, but kept thinking about it. Given your observation (above) I see an analogy between Stores -> Features, and Specs -> Tests, that is, I write specs as input, I develop the code, and tests are the outputs. Same code, different purpose. You (or someone) named this framework rspec perhaps because 'spec' is more descriptive and accurate than 'test', but more importantly because there is a large body of work and history with conventional QA and testing, and it was important to coin a new term (spec) to distinguish BDD from conventional testing. However, you can use test tools to do BDD (e.g. as many people has chosen to continue using Test Unit and shoulda rather than rspec for whatever reasons). But with regard to stories vs features, there really isnt a legacy and baggage about the word 'story', so changing the name to 'feature' is mostly semantics. Personally, I do not see a feature as separate from a story, because a feature means nothing without some context. Stories provide that context. Scenarios provide the specifics. I might write and organize my stories by individual feature, but theres other ways as well: workflows, goals/objectives, different starting setups, user roles, and so on, all involving one or more sets of features. I'm not trying to be argumentative, and I'm wholeheartedly appreciative of the work you and Alask and everyone does on this project. If anything, I'm just trying to sort all this out for myself. From john.j.reilly at gmail.com Fri Aug 22 18:30:18 2008 From: john.j.reilly at gmail.com (John Reilly) Date: Fri, 22 Aug 2008 15:30:18 -0700 (PDT) Subject: [rspec-users] Controller specs erroneously loading views in edge rails? Message-ID: <87fc2bcc-f42e-4a90-bfed-fdaec43c4c6b@25g2000hsx.googlegroups.com> Hello, I think I may have found a bug between rspec and edge rails... But I'm new to this so I'm hoping someone else can confirm before I go filing bug reports. Basically, I'm seeing what "appears" to be my controller specs deciding to load the views, even though I haven't called integrate_views. When I generate a default rspec_scaffold, the specs fail with an ActionView::TemplateError: > % script/generate rspec_scaffold Bike name:string sku:string > ... > rake spec > ... > Mock 'Bike_1017' received unexpected message :name with (no args) > On line #11 of app/views/index.html.erb If I modify the generated index spec like this, the spec passes: ...snip... > it "should expose all bikes as @bikes" do > Bike.should_receive(:find).with(:all).and_return([mock_bike]) > > # adding these lines cause the spec to pass... > mock_bike.should_receive(:name) > mock_bike.should_receive(:sku) > > get :index > assigns[:bikes].should == [mock_bike] > end ...snip... While this "fixes" the failures, it's no longer an isolated test of the controller. After spending some time with git-bisect, it looks like this problem was introduced in a commit to edge rails: http://github.com/rails/rails/commit/1129a24caff9f1804c2bff6569c0cbd8598dfa86 The default rspec_scaffold tests pass before this commit, and fail after this commit. More details here: http://johnreilly.tumblr.com/post/47016047/rspec-is-mocking-me Am I insane? Or does this happen for anyone else? :-) Thanks, -- John Reilly From svenfuchs at artweb-design.de Sat Aug 23 07:12:34 2008 From: svenfuchs at artweb-design.de (Sven Fuchs) Date: Sat, 23 Aug 2008 13:12:34 +0200 Subject: [rspec-users] Controller specs erroneously loading views in edge rails? In-Reply-To: <87fc2bcc-f42e-4a90-bfed-fdaec43c4c6b@25g2000hsx.googlegroups.com> References: <87fc2bcc-f42e-4a90-bfed-fdaec43c4c6b@25g2000hsx.googlegroups.com> Message-ID: <791A8191-D2C0-47C0-AE62-5765D6E090FE@artweb-design.de> Trying to port an existing app to current Rails edge I've seen similar things yesterday. I've also updated RSpec/Rails to recent edge. Here are two workarounds I've come up with for two of the problems. I'm not sure if they cause other problems themselves, but maybe they're still useful as a hint. http://pastie.org/private/5ueehxiqhdgok0d8udksa I don't feel familiar enough with RSpec's guts to provide a patch. #render_partial on ActionView::Base seems to break because the method signature has changed. #render on ControllerExampleGroup seems to break because #render_file apparently has been removed. On 23.08.2008, at 00:30, John Reilly wrote: > Hello, > > I think I may have found a bug between rspec and edge rails... But I'm > new to this so I'm hoping someone else can confirm before I go filing > bug reports. > > Basically, I'm seeing what "appears" to be my controller specs > deciding to load the views, even though I haven't called > integrate_views. When I generate a default rspec_scaffold, the specs > fail with an ActionView::TemplateError: > >> % script/generate rspec_scaffold Bike name:string sku:string >> ... >> rake spec >> ... >> Mock 'Bike_1017' received unexpected message :name with (no args) >> On line #11 of app/views/index.html.erb > > If I modify the generated index spec like this, the spec passes: > > ...snip... >> it "should expose all bikes as @bikes" do >> Bike.should_receive(:find).with(:all).and_return([mock_bike]) >> >> # adding these lines cause the spec to pass... >> mock_bike.should_receive(:name) >> mock_bike.should_receive(:sku) >> >> get :index >> assigns[:bikes].should == [mock_bike] >> end > ...snip... > > While this "fixes" the failures, it's no longer an isolated test of > the controller. > > After spending some time with git-bisect, it looks like this problem > was introduced in a commit to edge rails: > http://github.com/rails/rails/commit/1129a24caff9f1804c2bff6569c0cbd8598dfa86 > > The default rspec_scaffold tests pass before this commit, and fail > after this commit. > > More details here: > http://johnreilly.tumblr.com/post/47016047/rspec-is-mocking-me > > Am I insane? Or does this happen for anyone else? :-) > > Thanks, > -- John Reilly > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -- sven fuchs svenfuchs at artweb-design.de artweb design http://www.artweb-design.de gr?nberger 65 + 49 (0) 30 - 47 98 69 96 (phone) d-10245 berlin + 49 (0) 171 - 35 20 38 4 (mobile) From dchelimsky at gmail.com Sat Aug 23 10:28:27 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 23 Aug 2008 09:28:27 -0500 Subject: [rspec-users] Controller specs erroneously loading views in edge rails? In-Reply-To: <791A8191-D2C0-47C0-AE62-5765D6E090FE@artweb-design.de> References: <87fc2bcc-f42e-4a90-bfed-fdaec43c4c6b@25g2000hsx.googlegroups.com> <791A8191-D2C0-47C0-AE62-5765D6E090FE@artweb-design.de> Message-ID: <57c63afe0808230728g6d7cb048w23017945b91a67f3@mail.gmail.com> There are a number of changes to action pack recently that are incompatible with rspec. Please report these to lighthouse. Thanks, David On Sat, Aug 23, 2008 at 6:12 AM, Sven Fuchs wrote: > Trying to port an existing app to current Rails edge I've seen similar > things yesterday. I've also updated RSpec/Rails to recent edge. > > Here are two workarounds I've come up with for two of the problems. I'm not > sure if they cause other problems themselves, but maybe they're still useful > as a hint. > > http://pastie.org/private/5ueehxiqhdgok0d8udksa > > I don't feel familiar enough with RSpec's guts to provide a patch. > > #render_partial on ActionView::Base seems to break because the method > signature has changed. > #render on ControllerExampleGroup seems to break because #render_file > apparently has been removed. > > > > On 23.08.2008, at 00:30, John Reilly wrote: > >> Hello, >> >> I think I may have found a bug between rspec and edge rails... But I'm >> new to this so I'm hoping someone else can confirm before I go filing >> bug reports. >> >> Basically, I'm seeing what "appears" to be my controller specs >> deciding to load the views, even though I haven't called >> integrate_views. When I generate a default rspec_scaffold, the specs >> fail with an ActionView::TemplateError: >> >>> % script/generate rspec_scaffold Bike name:string sku:string >>> ... >>> rake spec >>> ... >>> Mock 'Bike_1017' received unexpected message :name with (no args) >>> On line #11 of app/views/index.html.erb >> >> If I modify the generated index spec like this, the spec passes: >> >> ...snip... >>> >>> it "should expose all bikes as @bikes" do >>> Bike.should_receive(:find).with(:all).and_return([mock_bike]) >>> >>> # adding these lines cause the spec to pass... >>> mock_bike.should_receive(:name) >>> mock_bike.should_receive(:sku) >>> >>> get :index >>> assigns[:bikes].should == [mock_bike] >>> end >> >> ...snip... >> >> While this "fixes" the failures, it's no longer an isolated test of >> the controller. >> >> After spending some time with git-bisect, it looks like this problem >> was introduced in a commit to edge rails: >> >> http://github.com/rails/rails/commit/1129a24caff9f1804c2bff6569c0cbd8598dfa86 >> >> The default rspec_scaffold tests pass before this commit, and fail >> after this commit. >> >> More details here: >> http://johnreilly.tumblr.com/post/47016047/rspec-is-mocking-me >> >> Am I insane? Or does this happen for anyone else? :-) >> >> Thanks, >> -- John Reilly >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > -- > sven fuchs svenfuchs at artweb-design.de > artweb design http://www.artweb-design.de > gr?nberger 65 + 49 (0) 30 - 47 98 69 96 (phone) > d-10245 berlin + 49 (0) 171 - 35 20 38 4 (mobile) > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From joe at pinkpucker.net Sat Aug 23 13:11:39 2008 From: joe at pinkpucker.net (Joe Van Dyk) Date: Sat, 23 Aug 2008 10:11:39 -0700 Subject: [rspec-users] Upgraded to 2.1 and 1.1.4 from 2.0 and 1.1.3, no output from 'rake spec' Message-ID: $ rake spec --trace (in /Users/joe/projects/tanga) ** Invoke spec (first_time) ** Invoke db:test:prepare (first_time) ** Invoke db:abort_if_pending_migrations (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:abort_if_pending_migrations ** Execute db:test:prepare ** Invoke db:test:clone_structure (first_time) ** Invoke db:structure:dump (first_time) ** Invoke environment ** Execute db:structure:dump ** Invoke db:test:purge (first_time) ** Invoke environment ** Execute db:test:purge ** Execute db:test:clone_structure ** Execute spec $ Running "script/spec /path/to/spec" also doesn't give output. Any ideas? I ran "script/generate rspec" and let it overwrite everything. From john.j.reilly at gmail.com Sat Aug 23 13:44:37 2008 From: john.j.reilly at gmail.com (John Reilly) Date: Sat, 23 Aug 2008 10:44:37 -0700 (PDT) Subject: [rspec-users] Controller specs erroneously loading views in edge rails? In-Reply-To: <57c63afe0808230728g6d7cb048w23017945b91a67f3@mail.gmail.com> References: <87fc2bcc-f42e-4a90-bfed-fdaec43c4c6b@25g2000hsx.googlegroups.com> <791A8191-D2C0-47C0-AE62-5765D6E090FE@artweb-design.de> <57c63afe0808230728g6d7cb048w23017945b91a67f3@mail.gmail.com> Message-ID: <02195db4-f58c-484f-a1ad-e4ea57b0ce2d@i76g2000hsf.googlegroups.com> On Aug 23, 9:28?am, "David Chelimsky" wrote: > There are a number of changes to action pack recently that are > incompatible with rspec. Please report these to lighthouse. I'm assuming you mean rspec's lighthouse, not rails'? :) -- John Reilly From dchelimsky at gmail.com Sat Aug 23 14:35:45 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 23 Aug 2008 13:35:45 -0500 Subject: [rspec-users] Controller specs erroneously loading views in edge rails? In-Reply-To: <02195db4-f58c-484f-a1ad-e4ea57b0ce2d@i76g2000hsf.googlegroups.com> References: <87fc2bcc-f42e-4a90-bfed-fdaec43c4c6b@25g2000hsx.googlegroups.com> <791A8191-D2C0-47C0-AE62-5765D6E090FE@artweb-design.de> <57c63afe0808230728g6d7cb048w23017945b91a67f3@mail.gmail.com> <02195db4-f58c-484f-a1ad-e4ea57b0ce2d@i76g2000hsf.googlegroups.com> Message-ID: <57c63afe0808231135o44f230b3vadea80f256d3c01a@mail.gmail.com> On Sat, Aug 23, 2008 at 12:44 PM, John Reilly wrote: > On Aug 23, 9:28 am, "David Chelimsky" wrote: >> There are a number of changes to action pack recently that are >> incompatible with rspec. Please report these to lighthouse. > > I'm assuming you mean rspec's lighthouse, not rails'? :) Right. From svenfuchs at artweb-design.de Sat Aug 23 16:57:37 2008 From: svenfuchs at artweb-design.de (Sven Fuchs) Date: Sat, 23 Aug 2008 22:57:37 +0200 Subject: [rspec-users] Controller specs erroneously loading views in edge rails? In-Reply-To: <57c63afe0808230728g6d7cb048w23017945b91a67f3@mail.gmail.com> References: <87fc2bcc-f42e-4a90-bfed-fdaec43c4c6b@25g2000hsx.googlegroups.com> <791A8191-D2C0-47C0-AE62-5765D6E090FE@artweb-design.de> <57c63afe0808230728g6d7cb048w23017945b91a67f3@mail.gmail.com> Message-ID: <18656E85-26FE-4E5D-A015-04540FC1510B@artweb-design.de> Ok, done. http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/508-recent-changes-in-actionpack-break-controller-specs Thanks! On 23.08.2008, at 16:28, David Chelimsky wrote: > There are a number of changes to action pack recently that are > incompatible with rspec. Please report these to lighthouse. > > Thanks, > David > > On Sat, Aug 23, 2008 at 6:12 AM, Sven Fuchs > wrote: >> Trying to port an existing app to current Rails edge I've seen >> similar >> things yesterday. I've also updated RSpec/Rails to recent edge. >> >> Here are two workarounds I've come up with for two of the problems. >> I'm not >> sure if they cause other problems themselves, but maybe they're >> still useful >> as a hint. >> >> http://pastie.org/private/5ueehxiqhdgok0d8udksa >> >> I don't feel familiar enough with RSpec's guts to provide a patch. >> >> #render_partial on ActionView::Base seems to break because the method >> signature has changed. >> #render on ControllerExampleGroup seems to break because #render_file >> apparently has been removed. >> >> >> >> On 23.08.2008, at 00:30, John Reilly wrote: >> >>> Hello, >>> >>> I think I may have found a bug between rspec and edge rails... But >>> I'm >>> new to this so I'm hoping someone else can confirm before I go >>> filing >>> bug reports. >>> >>> Basically, I'm seeing what "appears" to be my controller specs >>> deciding to load the views, even though I haven't called >>> integrate_views. When I generate a default rspec_scaffold, the >>> specs >>> fail with an ActionView::TemplateError: >>> >>>> % script/generate rspec_scaffold Bike name:string sku:string >>>> ... >>>> rake spec >>>> ... >>>> Mock 'Bike_1017' received unexpected message :name with (no args) >>>> On line #11 of app/views/index.html.erb >>> >>> If I modify the generated index spec like this, the spec passes: >>> >>> ...snip... >>>> >>>> it "should expose all bikes as @bikes" do >>>> Bike.should_receive(:find).with(:all).and_return([mock_bike]) >>>> >>>> # adding these lines cause the spec to pass... >>>> mock_bike.should_receive(:name) >>>> mock_bike.should_receive(:sku) >>>> >>>> get :index >>>> assigns[:bikes].should == [mock_bike] >>>> end >>> >>> ...snip... >>> >>> While this "fixes" the failures, it's no longer an isolated test of >>> the controller. >>> >>> After spending some time with git-bisect, it looks like this problem >>> was introduced in a commit to edge rails: >>> >>> http://github.com/rails/rails/commit/1129a24caff9f1804c2bff6569c0cbd8598dfa86 >>> >>> The default rspec_scaffold tests pass before this commit, and fail >>> after this commit. >>> >>> More details here: >>> http://johnreilly.tumblr.com/post/47016047/rspec-is-mocking-me >>> >>> Am I insane? Or does this happen for anyone else? :-) >>> >>> Thanks, >>> -- John Reilly >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> -- >> sven fuchs svenfuchs at artweb-design.de >> artweb design http://www.artweb-design.de >> gr?nberger 65 + 49 (0) 30 - 47 98 69 96 (phone) >> d-10245 berlin + 49 (0) 171 - 35 20 38 4 (mobile) >> >> >> >> >> _______________________________________________ >> 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 -- sven fuchs svenfuchs at artweb-design.de artweb design http://www.artweb-design.de gr?nberger 65 + 49 (0) 30 - 47 98 69 96 (phone) d-10245 berlin + 49 (0) 171 - 35 20 38 4 (mobile) From lists at ruby-forum.com Sat Aug 23 20:01:27 2008 From: lists at ruby-forum.com (Pat Parslow) Date: Sun, 24 Aug 2008 02:01:27 +0200 Subject: [rspec-users] Upgraded to 2.1 and 1.1.4 from 2.0 and 1.1.3, no output from 'rake spec' In-Reply-To: References: Message-ID: <0e0c12e97fb8488c58575e858fe1d551@ruby-forum.com> Joe Van Dyk wrote: > $ rake spec --trace > (in /Users/joe/projects/tanga) > ** Invoke spec (first_time) > ** Invoke db:test:prepare (first_time) > ** Invoke db:abort_if_pending_migrations (first_time) > ** Invoke environment (first_time) > ** Execute environment > ** Execute db:abort_if_pending_migrations > ** Execute db:test:prepare > ** Invoke db:test:clone_structure (first_time) > ** Invoke db:structure:dump (first_time) > ** Invoke environment > ** Execute db:structure:dump > ** Invoke db:test:purge (first_time) > ** Invoke environment > ** Execute db:test:purge > ** Execute db:test:clone_structure > ** Execute spec > > $ > > > Running "script/spec /path/to/spec" also doesn't give output. > I am getting the same problem on XP with a fresh install (ruby 1.8.6 patch 111 - not so fresh, I admit) Rails 2.1 rspec 1.1.4 I think the problem may be something to do with not being able to check out the rspec 1.4.1 after cloning the git. It complains that: error: You have local changes to 'examples/stories/game-of-life/behaviour/storie s/CellsWithMoreThanThreeNeighboursDie.story'; cannot switch branches. which is rich as I just downloaded it and haven't changed anything :-) > Any ideas? I ran "script/generate rspec" and let it overwrite > everything. Ditto... -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sun Aug 24 07:36:36 2008 From: lists at ruby-forum.com (Pat Parslow) Date: Sun, 24 Aug 2008 13:36:36 +0200 Subject: [rspec-users] Upgraded to 2.1 and 1.1.4 from 2.0 and 1.1.3, no output from 'rake spec' In-Reply-To: <0e0c12e97fb8488c58575e858fe1d551@ruby-forum.com> References: <0e0c12e97fb8488c58575e858fe1d551@ruby-forum.com> Message-ID: <4b7cc968240b5318e83b968c73711319@ruby-forum.com> Pat Parslow wrote: *snip* >> > > I am getting the same problem on XP with a fresh install (ruby 1.8.6 > patch 111 - not so fresh, I admit) Rails 2.1 rspec 1.1.4 > > I think the problem may be something to do with not being able to check > out the rspec 1.4.1 after cloning the git. It complains that: > > error: You have local changes to > 'examples/stories/game-of-life/behaviour/storie > s/CellsWithMoreThanThreeNeighboursDie.story'; cannot switch branches. > > which is rich as I just downloaded it and haven't changed anything :-) > > >> Any ideas? I ran "script/generate rspec" and let it overwrite >> everything. > > Ditto... OK, so it wasn't that. I did a git pull and then checked-out 1.1.4 and it still behaved the same way (but it might be nice to tell people that the git clone they get might need updating before it can be checked out - I am trying to work that one out still) It occurred to me that I had the rspec gem installed (this will at least partly give the chance to have a laugh at me...) so I tried putting a require 'rubygems' in script\spec. Voila, I can now run single tests using ruby script\spec path\to\spec with success. However, rake spec still does nothing (well, nothing visible) The odd thing is, as I was typing this, it occurred to me I had removed the rspec gem when trying to get the plugin to work. So I checked, and, sure enough, no rspec gem. I think I must be a bear of very little brain, because I cannot for the life of me work out what is going on! -- Posted via http://www.ruby-forum.com/. From ichsan at gmail.com Sun Aug 24 10:39:34 2008 From: ichsan at gmail.com (Muhammad Ichsan) Date: Sun, 24 Aug 2008 21:39:34 +0700 Subject: [rspec-users] What are we spec'ing? Message-ID: Dear All, I'm a new member here. I've been using RSpec since my first Rails project. I'm proud that I've deliver the most bugs free app in my office (In my country, spec'ing even autotesting is not common). Thanks to Ruby community that make autotesting very easy and encouraging. I think Ruby is the best entry to start making quality codes. Because ruby's way is direct and focus. There are things that bother me. On of them is this. What are we spec'ing actually? I've heard that we should not do this it "should save the person" person = Person.new({:name => 'Jack'}) person.save! Person.find(person.id).should != null end bacause, it seems that we're are spec'ing the Active Record which is already well tested. So, any of you can give me some bad examples or bad ways to do spec'ing and why. I'd like to learn from other references too. Thanks! -- ~A useful man to others is a lucky man http://michsan.blogspot.com Rzqies, Order now! http://rzqies.wordpress.com From ichsan at gmail.com Sun Aug 24 10:44:04 2008 From: ichsan at gmail.com (Muhammad Ichsan) Date: Sun, 24 Aug 2008 21:44:04 +0700 Subject: [rspec-users] Spec'ing exhaustively? Message-ID: Dear All, Before I know spec'ing, I've been practicing testing using JUnit. I remember that once Kent Beck said (if I'm not mistaken) that we should not test exhaustively. Instead, we should test until our doubt in the quality is gone. What about spec'ing? Is spec'ing aimed to create good documentations or just to remove the doubt? If it is to remove the doubt, then spec'ing will be pragmatic not exhaustively. -- ~A useful man to others is a lucky man http://michsan.blogspot.com Rzqies, Order now! http://rzqies.wordpress.com From jim at saturnflyer.com Sun Aug 24 10:53:01 2008 From: jim at saturnflyer.com (Jim Gay) Date: Sun, 24 Aug 2008 10:53:01 -0400 Subject: [rspec-users] What are we spec'ing? In-Reply-To: References: Message-ID: On Aug 24, 2008, at 10:39 AM, Muhammad Ichsan wrote: > Dear All, > > I'm a new member here. I've been using RSpec since my first Rails > project. I'm proud that I've deliver the most bugs free app in my > office (In my country, spec'ing even autotesting is not common). > Thanks to Ruby community that make autotesting very easy and > encouraging. I think Ruby is the best entry to start making quality > codes. Because ruby's way is direct and focus. > > There are things that bother me. On of them is this. What are we > spec'ing actually? I've heard that we should not do this > > it "should save the person" > person = Person.new({:name => 'Jack'}) > person.save! > Person.find(person.id).should != null > end > > bacause, it seems that we're are spec'ing the Active Record which is > already well tested. So, any of you can give me some bad examples or > bad ways to do spec'ing and why. I'd like to learn from other > references too. > > > Thanks! Check out this thread: http://groups.google.com/group/rspec/browse_thread/thread/7bb484873d327232/a2d46045dcbf1066?lnk=st&q=Should(not%3F)+test+associations+(was%3A+Dealing+with+dependent+data)#a2d46045dcbf1066 It helped me better understand what to spec. -Jim From dchelimsky at gmail.com Sun Aug 24 11:07:56 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 24 Aug 2008 10:07:56 -0500 Subject: [rspec-users] Spec'ing exhaustively? In-Reply-To: References: Message-ID: <57c63afe0808240807q32804d9bi25d686276d993970@mail.gmail.com> On Sun, Aug 24, 2008 at 9:44 AM, Muhammad Ichsan wrote: > Dear All, > > Before I know spec'ing, I've been practicing testing using JUnit. I > remember that once Kent Beck said (if I'm not mistaken) that we should > not test exhaustively. Instead, we should test until our doubt in the > quality is gone. What about spec'ing? Is spec'ing aimed to create good > documentations or just to remove the doubt? If it is to remove the > doubt, then spec'ing will be pragmatic not exhaustively. Spec'ing, or "coding by example" as we've been calling it lately, all started with TDD. No matter what you call it, or how you approach the process, the goal is the same: reliable, maintainable software. Testing "until our doubt in the quality is gone" makes sense to me regardless of whether you call the process TDD, BDD, testing, spec'ing, coding by example, etc, etc, etc. I include "maintainable" in my definition of quality. For me, if code examples document the code and that documentation makes it easier to maintain, than those code examples serve to increase confidence (or remove doubt, if you prefer) in quality. Make sense? From dchelimsky at gmail.com Sun Aug 24 12:31:59 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 24 Aug 2008 11:31:59 -0500 Subject: [rspec-users] story vs feature (was Documentation for Plain-Text Stories) In-Reply-To: <1341C3E7-DB99-4F7D-8576-60F2107B3C7F@parkerhill.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <48A9D18D.3070704@e4net.com> <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> <1341C3E7-DB99-4F7D-8576-60F2107B3C7F@parkerhill.com> Message-ID: <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> On Fri, Aug 22, 2008 at 12:53 PM, Jonathan Linowes wrote: > > On Aug 20, 2008, at 10:20 AM, David Chelimsky wrote: >> >> I see them as very different. >> >> User Stories are inputs to a development process and Features are the >> outputs. > > I decided to churn on this for a few days before responding. Actually I was > going to let it drop, but kept thinking about it. > > Given your observation (above) I see an analogy between Stores -> Features, > and Specs -> Tests, that is, I write specs as input, I develop the code, > and tests are the outputs. Same code, different purpose. > > You (or someone) named this framework rspec perhaps because 'spec' is more > descriptive and accurate than 'test', but more importantly because there is > a large body of work and history with conventional QA and testing, and it > was important to coin a new term (spec) to distinguish BDD from conventional > testing. Steven Baker named the framework rspec. I believe his motivation was Uncle Bob saying "specify, don't verify" when talking about what TDD and ATDD is about. Sadly, "spec" has just as much baggage, if not more, as "test" does. These days we're calling these things "code examples," (tongue pressing into cheek) so maybe we should change the name to rcodeexample? > However, you can use test tools to do BDD (e.g. as many people has > chosen to continue using Test Unit and shoulda rather than rspec for > whatever reasons). Agreed. Tools is tools. Process is process. (boat is boat ....) > But with regard to stories vs features, there really isnt a legacy and > baggage about the word 'story', so changing the name to 'feature' is mostly > semantics. User Stories have been around since the late 90's. I'd say that qualifies them for legacy/baggage. > Personally, I do not see a feature as separate from a story, because a > feature means nothing without some context. Stories provide that context. > Scenarios provide the specifics. I might write and organize my stories by > individual feature, but theres other ways as well: workflows, > goals/objectives, different starting setups, user roles, and so on, all > involving one or more sets of features. > > I'm not trying to be argumentative, and I'm wholeheartedly appreciative of > the work you and Alask and everyone does on this project. If anything, I'm > just trying to sort all this out for myself. This is something that's bugged me since rbehave first appeared (even before we merged it into rspec). I've discussed this w/ Dan North a few times and we've agreed on some aspects of this but not all. I won't speak for Dan here, but my experience tells me that there is not a clean mapping of stories (the things that drive development) to features (the things that exist in the system because they have already been developed). For example, imagine we're working on a conference organization/registration tool and way back in iteration 1 we had a story about the organizer being able to see a report of conference registrations (this may sound familiar if you saw my talk at RailsConf). Imagine that one of the conference organizers noted that a given conference was reporting 100% full even though only 499 of the goal of 500 had registered. So a new story gets added suggesting that it should not be rounded up to 100%. So now we have two choices. We can add a new story file with a new narrative and a single scenario, or we can crack open the existing story file and add a single scenario. In terms of the feature (which is the report), I see this as just another scenario. In terms of driving development and estimating effort, I see this as a new User Story. Does this clarify or further confuse? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ichsan at gmail.com Sun Aug 24 12:37:26 2008 From: ichsan at gmail.com (Muhammad Ichsan) Date: Sun, 24 Aug 2008 23:37:26 +0700 Subject: [rspec-users] What are we spec'ing? In-Reply-To: References: Message-ID: On Sun, Aug 24, 2008 at 9:53 PM, Jim Gay wrote: > On Aug 24, 2008, at 10:39 AM, Muhammad Ichsan wrote: > > Check out this thread: > http://groups.google.com/group/rspec/browse_thread/thread/7bb484873d327232/a2d46045dcbf1066?lnk=st&q=Should(not%3F)+test+associations+(was%3A+Dealing+with+dependent+data)#a2d46045dcbf1066 Nice link! Thanks. Actually I got a little confused on David's statement: > Try this as a next step: > > * code a little > * comment out your code > * write a small example for a small bit of the commented code > * watch it fail > * uncomment just enough to make it pass > * watch it pass > * repeat the last 4 steps I don't really get it. Would you give me a simple example? Thanks -- ~A useful man to others is a lucky man http://michsan.blogspot.com Rzqies, Order now! http://rzqies.wordpress.com From nick at deadorange.com Sun Aug 24 15:31:27 2008 From: nick at deadorange.com (Nick Hoffman) Date: Sun, 24 Aug 2008 15:31:27 -0400 Subject: [rspec-users] Running specs within a spec server Message-ID: <4B4ACD15-04DE-46EE-B36A-086F9F586112@deadorange.com> Hi guys. I'm unable to run my specs through a spec server. I've spent several hours searching and playing around with this problem, and I simply can't find a solution. So if anyone has any suggestions, I'm all ears. Does script/server need to be running in conjunction with the spec server? I have "--drb" specified in spec/spec.opts . I start the spec server with either of these commands: $ rake spec:server:start $ script/spec_server and confirm that it's running and listening: $ lsof -nPi | grep ruby ruby 20809 nick 4u IPv6 0x3c2e4bc 0t0 TCP [::1]:8989 (LISTEN) However, when I run any of these commands: $ rake spec:models $ spec -X spec/models/property_spec.rb $ script/spec -X spec/models/property_spec.rb This error occurs: /opt/local/lib/ruby/1.8/drb/drb.rb:855:in `initialize': getaddrinfo: nodename nor servname provided, or not known (SocketError) The full trace is at http://pastie.org/259026 I went into /opt/local/lib/ruby/1.8/drb/drb.rb , looked around line 855, put this debug message at the beginning of #self.open_server_inaddr_any : puts "host = [#{host}] , port = [#{port}]" and ran a spec again. That line spat this out: host = [wombat.local] , port = [0] The port number doesn't seem right, but then again, the authors of drb might be working some magic here. So, if you have any suggestions for how I can solve this, I'd love to hear from you. Thanks! Nick I'm using: $ ruby --version; rails --version; spec --version ruby 1.8.7 (2008-06-20 patchlevel 22) [i686-darwin9.3.0] Rails 2.1.0 RSpec-1.1.4 (build 20080526202855) - BDD for Ruby http://rspec.rubyforge.org/ From lists-rspec at shopwatch.org Sun Aug 24 16:18:37 2008 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Sun, 24 Aug 2008 16:18:37 -0400 Subject: [rspec-users] story vs feature (was Documentation for Plain-Text Stories) In-Reply-To: <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <48A9D18D.3070704@e4net.com> <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> <1341C3E7-DB99-4F7D-8576-60F2107B3C7F@parkerhill.com> <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> Message-ID: <48B1C21D.3030301@shopwatch.org> David Chelimsky wrote: > Agreed. Tools is tools. Process is process. (boat is boat ....) And parts is parts. Let's not forget that: http://www.youtube.com/watch?v=OTzLVIc-O5E Jay From lists at ruby-forum.com Sun Aug 24 20:54:51 2008 From: lists at ruby-forum.com (aa aa) Date: Mon, 25 Aug 2008 02:54:51 +0200 Subject: [rspec-users] no out for parameterized stories? Message-ID: <269fd806c5c1b5a35111bf348f6564ba@ruby-forum.com> Hi, I just install rspec (and rspec-rails) from git and tried to write a user story, its all good but the output lacks the parameters i used. Here's an example of what is happening === RSPEC FILE stories/example.rb === Story "A story", %{ As a user I want to do something So I can have some benefit }, :type => RailsStory do Scenario "Rspec Example" do Given "A parameterized story called", "story name" do |name| end end end ==== OUTPUT === > ruby stories/all.rb Running 1 scenario Story: A story As a user I want to do something So I can have some benefit Scenario: Rspec Example Given A parameterized story called =============== Notice the last line? Anyone know whats happening here? -- Posted via http://www.ruby-forum.com/. From nick at deadorange.com Sun Aug 24 14:46:11 2008 From: nick at deadorange.com (Nick) Date: Sun, 24 Aug 2008 11:46:11 -0700 (PDT) Subject: [rspec-users] Running specs within spec_server Message-ID: <01555ff8-94f2-4620-a686-5432cd9d551e@s50g2000hsb.googlegroups.com> Hi guys. I'm unable to run my specs through a spec server. I've spent several hours searching and playing around with this problem, and I simply can't find a solution. So if anyone has any suggestions, I'm all ears. Does script/server need to be running in conjunction with the spec server? I have "--drb" specified in spec/spec.opts . I start the spec server with either of these commands: $ rake spec:server:start $ script/spec_server and confirm that it's running and listening: $ lsof -nPi | grep ruby ruby 20809 nick 4u IPv6 0x3c2e4bc 0t0 TCP [::1]:8989 (LISTEN) However, when I run any of these commands: $ rake spec:models $ spec -X spec/models/property_spec.rb $ script/spec -X spec/models/property_spec.rb This error occurs: /opt/local/lib/ruby/1.8/drb/drb.rb:855:in `initialize': getaddrinfo: nodename nor servname provided, or not known (SocketError) The full trace is at http://pastie.org/259026 I went into /opt/local/lib/ruby/1.8/drb/drb.rb , looked around line 855, put this debug message at the beginning of #self.open_server_inaddr_any : puts "host = [#{host}] , port = [#{port}]" and ran a spec again. That line spat this out: host = [wombat.local] , port = [0] The port number doesn't seem right, but then again, the authors of drb might be working some magic here. So, if you have any suggestions for how I can solve this, I'd love to hear from you. Thanks! Nick I'm using: $ ruby --version; rails --version; spec --version ruby 1.8.7 (2008-06-20 patchlevel 22) [i686-darwin9.3.0] Rails 2.1.0 RSpec-1.1.4 (build 20080526202855) - BDD for Ruby http://rspec.rubyforge.org/ From jonathan at parkerhill.com Mon Aug 25 10:45:31 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Mon, 25 Aug 2008 10:45:31 -0400 Subject: [rspec-users] OT 'parts' In-Reply-To: <48B1C21D.3030301@shopwatch.org> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <48A9D18D.3070704@e4net.com> <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> <1341C3E7-DB99-4F7D-8576-60F2107B3C7F@parkerhill.com> <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> <48B1C21D.3030301@shopwatch.org> Message-ID: On Aug 24, 2008, at 4:18 PM, Jay Levitt wrote: > David Chelimsky wrote: >> Agreed. Tools is tools. Process is process. (boat is boat ....) > > And parts is parts. Let's not forget that: > > http://www.youtube.com/watch?v=OTzLVIc-O5E > > Jay OT, reminds me of when, a while back, I was developing CAD software, and had a potential customer call who told me (with a strong Boston accent) their company designs pots. "Oh, neat, what kind of pots, you mean cooking pots?" I asked. "No, no," she replied, "machine 'pots' " Needless to say, I didnt win the client :) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From jonathan at parkerhill.com Mon Aug 25 11:12:34 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Mon, 25 Aug 2008 11:12:34 -0400 Subject: [rspec-users] story vs feature (was Documentation for Plain-Text Stories) In-Reply-To: <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <48A9D18D.3070704@e4net.com> <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> <1341C3E7-DB99-4F7D-8576-60F2107B3C7F@parkerhill.com> <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> Message-ID: <24AD51D2-3DBC-4972-AB58-747282D5A63C@parkerhill.com> On Aug 24, 2008, at 12:31 PM, David Chelimsky wrote: > > In terms of the feature (which is the report), I see this as just > another scenario. > > In terms of driving development and estimating effort, I see this as a > new User Story. > > Does this clarify or further confuse? >> I see your scenario of 499 registrants as a new feature of the existing story :) From aslak.hellesoy at gmail.com Mon Aug 25 11:19:30 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 25 Aug 2008 17:19:30 +0200 Subject: [rspec-users] story vs feature (was Documentation for Plain-Text Stories) In-Reply-To: <24AD51D2-3DBC-4972-AB58-747282D5A63C@parkerhill.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> <1341C3E7-DB99-4F7D-8576-60F2107B3C7F@parkerhill.com> <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> <24AD51D2-3DBC-4972-AB58-747282D5A63C@parkerhill.com> Message-ID: <8d961d900808250819p216e25e0t83e8eef64a324610@mail.gmail.com> On Mon, Aug 25, 2008 at 5:12 PM, Jonathan Linowes wrote: > > On Aug 24, 2008, at 12:31 PM, David Chelimsky wrote: >> >> In terms of the feature (which is the report), I see this as just >> another scenario. >> >> In terms of driving development and estimating effort, I see this as a >> new User Story. >> >> Does this clarify or further confuse? >>> > > > I see your scenario of 499 registrants as a new feature of the existing > story :) > In light of what David and I have said previously, I would express it exactly the other way around: "The scenarios in this user story describe an expansion of the existing feature." In other words, the story (and its scenarios) are inputs to the development. The output is a fatter feature. Aslak > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jonathan at parkerhill.com Mon Aug 25 11:37:01 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Mon, 25 Aug 2008 11:37:01 -0400 Subject: [rspec-users] story vs feature (was Documentation for Plain-Text Stories) In-Reply-To: <8d961d900808250819p216e25e0t83e8eef64a324610@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> <1341C3E7-DB99-4F7D-8576-60F2107B3C7F@parkerhill.com> <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> <24AD51D2-3DBC-4972-AB58-747282D5A63C@parkerhill.com> <8d961d900808250819p216e25e0t83e8eef64a324610@mail.gmail.com> Message-ID: On Aug 25, 2008, at 11:19 AM, aslak hellesoy wrote: > On Mon, Aug 25, 2008 at 5:12 PM, Jonathan Linowes > wrote: >> >> On Aug 24, 2008, at 12:31 PM, David Chelimsky wrote: >>> >>> In terms of the feature (which is the report), I see this as just >>> another scenario. >>> >>> In terms of driving development and estimating effort, I see this >>> as a >>> new User Story. >>> >>> Does this clarify or further confuse? >>>> >> >> >> I see your scenario of 499 registrants as a new feature of the >> existing >> story :) >> > > In light of what David and I have said previously, I would express it > exactly the other way around: > > "The scenarios in this user story describe an expansion of the > existing feature." > > In other words, the story (and its scenarios) are inputs to the > development. The output is a fatter feature. > > Aslak Aslak, so in terms of the cucumber runner and BDD development process, where would you add the scenario? reopen an existing .story file? > >> >> _______________________________________________ >> 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 aslak.hellesoy at gmail.com Mon Aug 25 12:53:02 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 25 Aug 2008 18:53:02 +0200 Subject: [rspec-users] story vs feature (was Documentation for Plain-Text Stories) In-Reply-To: References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> <1341C3E7-DB99-4F7D-8576-60F2107B3C7F@parkerhill.com> <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> <24AD51D2-3DBC-4972-AB58-747282D5A63C@parkerhill.com> <8d961d900808250819p216e25e0t83e8eef64a324610@mail.gmail.com> Message-ID: <8d961d900808250953t3a94dbfcncca378adc97b31f9@mail.gmail.com> On Mon, Aug 25, 2008 at 5:37 PM, Jonathan Linowes wrote: > > On Aug 25, 2008, at 11:19 AM, aslak hellesoy wrote: > >> On Mon, Aug 25, 2008 at 5:12 PM, Jonathan Linowes >> wrote: >>> >>> On Aug 24, 2008, at 12:31 PM, David Chelimsky wrote: >>>> >>>> In terms of the feature (which is the report), I see this as just >>>> another scenario. >>>> >>>> In terms of driving development and estimating effort, I see this as a >>>> new User Story. >>>> >>>> Does this clarify or further confuse? >>>>> >>> >>> >>> I see your scenario of 499 registrants as a new feature of the existing >>> story :) >>> >> >> In light of what David and I have said previously, I would express it >> exactly the other way around: >> >> "The scenarios in this user story describe an expansion of the >> existing feature." >> >> In other words, the story (and its scenarios) are inputs to the >> development. The output is a fatter feature. >> >> Aslak > > Aslak, so in terms of the cucumber runner and BDD development process, where > would you add the scenario? reopen an existing .story file? > Yes, add it to an existing .feature file (or create a new one if the story's scenario don't fit in an existing feature). 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 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From nick at deadorange.com Mon Aug 25 12:53:12 2008 From: nick at deadorange.com (Nick Hoffman) Date: Mon, 25 Aug 2008 12:53:12 -0400 Subject: [rspec-users] How much test data to use in specs Message-ID: I'm not sure how much test data I should be using in my specs. I'm writing specs for the Property model in my Rails app. Its "address" attribute is going to be validated with this regex: /\A\d+[a-z]? [-', a-z]{2,128}\Z/i At the moment, my plan is to spec out the following possibilities. A property is invalid if its address: 1) doesn't begin with a digit; 2) is shorter than 2 characters; 3) is longer than 128 characters; I should also test that certain characters, such as ! @ # $ etc, invalidate a property. However, all of that seems like blacklisting, and achieves poor coverage of the regular expression. Should I create a list of valid and invalid addresses to test against the regex? That seems like a decent idea, but seems synonymous with fixtures. What would you guys recommend? Cheers, Nick From zach.dennis at gmail.com Mon Aug 25 13:29:53 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 25 Aug 2008 13:29:53 -0400 Subject: [rspec-users] How much test data to use in specs In-Reply-To: References: Message-ID: <85d99afe0808251029g816c7ecvabc9ecbf1f830978@mail.gmail.com> On Mon, Aug 25, 2008 at 12:53 PM, Nick Hoffman wrote: > I'm not sure how much test data I should be using in my specs. I'm writing > specs for the Property model in my Rails app. Its "address" attribute is > going to be validated with this regex: > /\A\d+[a-z]? [-', a-z]{2,128}\Z/i > > At the moment, my plan is to spec out the following possibilities. A > property is invalid if its address: > 1) doesn't begin with a digit; > 2) is shorter than 2 characters; > 3) is longer than 128 characters; > > I should also test that certain characters, such as ! @ # $ etc, invalidate > a property. > > However, all of that seems like blacklisting, and achieves poor coverage of > the regular expression. > > Should I create a list of valid and invalid addresses to test against the > regex? That seems like a decent idea, but seems synonymous with fixtures. > What would you guys recommend? > I might do something like the following... describe Property, "email validations" do ["1invalid.email at example.com", "can't start with a digit", "invalid.email2 at example.com", "can't end with a digit" ].in_groups_of(2) do |email, description| it description do prop = Property.new :email => email prop.should_not be_valid prop.should have(1).error_on(:email) end end end -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From masterkain at gmail.com Mon Aug 25 14:11:20 2008 From: masterkain at gmail.com (Claudio Poli) Date: Mon, 25 Aug 2008 11:11:20 -0700 (PDT) Subject: [rspec-users] rspec and rcov Message-ID: <714a4eef-5082-49d9-a904-896a73c5b8a8@8g2000hse.googlegroups.com> hi everyone, does anyone experience this problem? kain-osx:mysite kain$ rake spec:rcov (in /Users/kain/Sites/mysite) .................... Finished in 1.567164 seconds 20 examples, 0 failures /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:131:in `wrap': stack level too deep (SystemStackError) from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:131:in `wrap' from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:90:in `write_text' from /usr/local/lib/ruby/1.8/rexml/formatters/default.rb:50:in `write' from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:75:in `write_element' from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:73:in `each' from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:73:in `write_element' from /usr/local/lib/ruby/1.8/rexml/formatters/default.rb:31:in `write' from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:75:in `write_element' ... 11 levels... from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov.rb: 640:in `dump_coverage_info' from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov.rb: 640:in `each' from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov.rb: 640:in `dump_coverage_info' from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/bin/rcov:421 rake aborted! Command /usr/local/bin/ruby -I"/usr/local/lib/ruby/gems/1.8/gems/ rspec-1.1.4/lib" -S rcov --exclude "spec/*,gems/*" --rails -o "coverage" "/usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.4/bin/spec" -- "spec/models/account_spec.rb" "spec/models/dictionary_spec.rb" -- options "/Users/kain/Sites/mysite/spec/spec.opts" failed From dchelimsky at gmail.com Mon Aug 25 14:15:32 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 25 Aug 2008 13:15:32 -0500 Subject: [rspec-users] rspec and rcov In-Reply-To: <714a4eef-5082-49d9-a904-896a73c5b8a8@8g2000hse.googlegroups.com> References: <714a4eef-5082-49d9-a904-896a73c5b8a8@8g2000hse.googlegroups.com> Message-ID: <57c63afe0808251115icd522dv1b400853c61015de@mail.gmail.com> On Mon, Aug 25, 2008 at 1:11 PM, Claudio Poli wrote: > hi everyone, > does anyone experience this problem? Hi Claudio, There are a few issues at lighthouse related to running rcov: http://rspec.lighthouseapp.com/projects/5645-rspec/tickets?q=rcov+state%3Aopen&filter=created%3Atoday Don't know if yours is the same, but you may want to take a peek at those. Cheers, David > > kain-osx:mysite kain$ rake spec:rcov > (in /Users/kain/Sites/mysite) > .................... > > Finished in 1.567164 seconds > > 20 examples, 0 failures > /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:131:in `wrap': > stack level too deep (SystemStackError) > from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:131:in `wrap' > from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:90:in > `write_text' > from /usr/local/lib/ruby/1.8/rexml/formatters/default.rb:50:in > `write' > from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:75:in > `write_element' > from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:73:in `each' > from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:73:in > `write_element' > from /usr/local/lib/ruby/1.8/rexml/formatters/default.rb:31:in > `write' > from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:75:in > `write_element' > ... 11 levels... > from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov.rb: > 640:in `dump_coverage_info' > from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov.rb: > 640:in `each' > from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov.rb: > 640:in `dump_coverage_info' > from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/bin/rcov:421 > rake aborted! > Command /usr/local/bin/ruby -I"/usr/local/lib/ruby/gems/1.8/gems/ > rspec-1.1.4/lib" -S rcov --exclude "spec/*,gems/*" --rails -o > "coverage" "/usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.4/bin/spec" -- > "spec/models/account_spec.rb" "spec/models/dictionary_spec.rb" -- > options "/Users/kain/Sites/mysite/spec/spec.opts" failed > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From masterkain at gmail.com Mon Aug 25 14:30:37 2008 From: masterkain at gmail.com (Claudio Poli) Date: Mon, 25 Aug 2008 20:30:37 +0200 Subject: [rspec-users] rspec and rcov In-Reply-To: <57c63afe0808251115icd522dv1b400853c61015de@mail.gmail.com> References: <714a4eef-5082-49d9-a904-896a73c5b8a8@8g2000hse.googlegroups.com> <57c63afe0808251115icd522dv1b400853c61015de@mail.gmail.com> Message-ID: hi David, thanks for the reply, I didn't find on lighthouse this specific exception. I think it's something related to the rexml version in ruby 1.8.7 (2008-06-20 patchlevel 22) [i686-darwin9.3.0] but not sure how to fix it. Claudio Il giorno 25/ago/08, alle ore 20:15, David Chelimsky ha scritto: > On Mon, Aug 25, 2008 at 1:11 PM, Claudio Poli > wrote: >> hi everyone, >> does anyone experience this problem? > > Hi Claudio, > > There are a few issues at lighthouse related to running rcov: > > http://rspec.lighthouseapp.com/projects/5645-rspec/tickets?q=rcov+state%3Aopen&filter=created%3Atoday > > Don't know if yours is the same, but you may want to take a peek at > those. > > Cheers, > David > >> >> kain-osx:mysite kain$ rake spec:rcov >> (in /Users/kain/Sites/mysite) >> .................... >> >> Finished in 1.567164 seconds >> >> 20 examples, 0 failures >> /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:131:in `wrap': >> stack level too deep (SystemStackError) >> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb: >> 131:in `wrap' >> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:90:in >> `write_text' >> from /usr/local/lib/ruby/1.8/rexml/formatters/default.rb:50:in >> `write' >> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:75:in >> `write_element' >> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:73:in >> `each' >> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:73:in >> `write_element' >> from /usr/local/lib/ruby/1.8/rexml/formatters/default.rb:31:in >> `write' >> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:75:in >> `write_element' >> ... 11 levels... >> from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/ >> rcov.rb: >> 640:in `dump_coverage_info' >> from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/ >> rcov.rb: >> 640:in `each' >> from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/ >> rcov.rb: >> 640:in `dump_coverage_info' >> from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/bin/ >> rcov:421 >> rake aborted! >> Command /usr/local/bin/ruby -I"/usr/local/lib/ruby/gems/1.8/gems/ >> rspec-1.1.4/lib" -S rcov --exclude "spec/*,gems/*" --rails -o >> "coverage" "/usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.4/bin/spec" >> -- >> "spec/models/account_spec.rb" "spec/models/dictionary_spec.rb" -- >> options "/Users/kain/Sites/mysite/spec/spec.opts" failed >> >> _______________________________________________ >> 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 nick at deadorange.com Mon Aug 25 14:50:11 2008 From: nick at deadorange.com (Nick Hoffman) Date: Mon, 25 Aug 2008 14:50:11 -0400 Subject: [rspec-users] How much test data to use in specs In-Reply-To: <85d99afe0808251029g816c7ecvabc9ecbf1f830978@mail.gmail.com> References: <85d99afe0808251029g816c7ecvabc9ecbf1f830978@mail.gmail.com> Message-ID: On 2008-08-25, at 13:29, Zach Dennis wrote: > I might do something like the following... > > describe Property, "email validations" do > > ["1invalid.email at example.com", "can't start with a digit", > "invalid.email2 at example.com", "can't end with a digit" > ].in_groups_of(2) do |email, description| > it description do > prop = Property.new :email => email > prop.should_not be_valid > prop.should have(1).error_on(:email) > end > end > end > > > -- > Zach Dennis > http://www.continuousthinking.com > http://www.mutuallyhuman.com Hi Zach. That's a great way of iterating over test data. Do you have any suggestions for how much test data to use? Cheers, Nick From dchelimsky at gmail.com Mon Aug 25 14:53:41 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 25 Aug 2008 13:53:41 -0500 Subject: [rspec-users] rspec and rcov In-Reply-To: References: <714a4eef-5082-49d9-a904-896a73c5b8a8@8g2000hse.googlegroups.com> <57c63afe0808251115icd522dv1b400853c61015de@mail.gmail.com> Message-ID: <57c63afe0808251153l7561e998te4c28f1adf8362ad@mail.gmail.com> Please file a new ticket for this then. Thanks, David On Mon, Aug 25, 2008 at 1:30 PM, Claudio Poli wrote: > hi David, > thanks for the reply, I didn't find on lighthouse this specific exception. > I think it's something related to the rexml version in ruby 1.8.7 > (2008-06-20 patchlevel 22) [i686-darwin9.3.0] but not sure how to fix it. > > Claudio > > Il giorno 25/ago/08, alle ore 20:15, David Chelimsky ha scritto: > >> On Mon, Aug 25, 2008 at 1:11 PM, Claudio Poli >> wrote: >>> >>> hi everyone, >>> does anyone experience this problem? >> >> Hi Claudio, >> >> There are a few issues at lighthouse related to running rcov: >> >> >> http://rspec.lighthouseapp.com/projects/5645-rspec/tickets?q=rcov+state%3Aopen&filter=created%3Atoday >> >> Don't know if yours is the same, but you may want to take a peek at those. >> >> Cheers, >> David >> >>> >>> kain-osx:mysite kain$ rake spec:rcov >>> (in /Users/kain/Sites/mysite) >>> .................... >>> >>> Finished in 1.567164 seconds >>> >>> 20 examples, 0 failures >>> /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:131:in `wrap': >>> stack level too deep (SystemStackError) >>> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:131:in >>> `wrap' >>> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:90:in >>> `write_text' >>> from /usr/local/lib/ruby/1.8/rexml/formatters/default.rb:50:in >>> `write' >>> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:75:in >>> `write_element' >>> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:73:in `each' >>> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:73:in >>> `write_element' >>> from /usr/local/lib/ruby/1.8/rexml/formatters/default.rb:31:in >>> `write' >>> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:75:in >>> `write_element' >>> ... 11 levels... >>> from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov.rb: >>> 640:in `dump_coverage_info' >>> from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov.rb: >>> 640:in `each' >>> from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov.rb: >>> 640:in `dump_coverage_info' >>> from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/bin/rcov:421 >>> rake aborted! >>> Command /usr/local/bin/ruby -I"/usr/local/lib/ruby/gems/1.8/gems/ >>> rspec-1.1.4/lib" -S rcov --exclude "spec/*,gems/*" --rails -o >>> "coverage" "/usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.4/bin/spec" -- >>> "spec/models/account_spec.rb" "spec/models/dictionary_spec.rb" -- >>> options "/Users/kain/Sites/mysite/spec/spec.opts" failed >>> >>> _______________________________________________ >>> 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 zach.dennis at gmail.com Mon Aug 25 16:02:08 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 25 Aug 2008 16:02:08 -0400 Subject: [rspec-users] How much test data to use in specs In-Reply-To: References: <85d99afe0808251029g816c7ecvabc9ecbf1f830978@mail.gmail.com> Message-ID: <85d99afe0808251302l58ab5cfbh3ddb786c72e68a02@mail.gmail.com> On Mon, Aug 25, 2008 at 2:50 PM, Nick Hoffman wrote: > On 2008-08-25, at 13:29, Zach Dennis wrote: >> >> I might do something like the following... >> >> describe Property, "email validations" do >> >> ["1invalid.email at example.com", "can't start with a digit", >> "invalid.email2 at example.com", "can't end with a digit" >> ].in_groups_of(2) do |email, description| >> it description do >> prop = Property.new :email => email >> prop.should_not be_valid >> prop.should have(1).error_on(:email) >> end >> end >> end >> >> >> -- Zach Dennis >> http://www.continuousthinking.com >> http://www.mutuallyhuman.com > > Hi Zach. That's a great way of iterating over test data. Do you have any > suggestions for how much test data to use? > I'd probably start with the first invalid email/description that I can think of. Perhaps it can't start with a digit. Then I'd update the regexp to reflect that. Next I'd add a second invalid email/description and update the regexp to reflect that. Rinse and repeat until your regexp is where you need it. This should help you not add redundant emails which test the same thing. When you get to the case where you allow from 2 up to 128 characters, you could just test those two edge cases (rather than emails which 2 characters, 3 characters, 4 characters, ... 128 characters. -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From aslak.hellesoy at gmail.com Mon Aug 25 16:15:42 2008 From: aslak.hellesoy at gmail.com (=?UTF-8?Q?Aslak_Helles=C3=B8y?=) Date: Mon, 25 Aug 2008 22:15:42 +0200 Subject: [rspec-users] rspec and rcov In-Reply-To: <57c63afe0808251153l7561e998te4c28f1adf8362ad@mail.gmail.com> References: <714a4eef-5082-49d9-a904-896a73c5b8a8@8g2000hse.googlegroups.com> <57c63afe0808251115icd522dv1b400853c61015de@mail.gmail.com> <57c63afe0808251153l7561e998te4c28f1adf8362ad@mail.gmail.com> Message-ID: <69E65517-1E87-489F-A258-69F4F5DCC465@gmail.com> > Please file a new ticket for this then. > But first check topfunky's recent tweet on REXML. I'm almost certain you've been bitten by a REXML bug. > Thanks, > David > > On Mon, Aug 25, 2008 at 1:30 PM, Claudio Poli > wrote: >> hi David, >> thanks for the reply, I didn't find on lighthouse this specific >> exception. >> I think it's something related to the rexml version in ruby 1.8.7 >> (2008-06-20 patchlevel 22) [i686-darwin9.3.0] but not sure how to >> fix it. >> >> Claudio >> >> Il giorno 25/ago/08, alle ore 20:15, David Chelimsky ha scritto: >> >>> On Mon, Aug 25, 2008 at 1:11 PM, Claudio Poli >>> wrote: >>>> >>>> hi everyone, >>>> does anyone experience this problem? >>> >>> Hi Claudio, >>> >>> There are a few issues at lighthouse related to running rcov: >>> >>> >>> http://rspec.lighthouseapp.com/projects/5645-rspec/tickets?q=rcov+state%3Aopen&filter=created%3Atoday >>> >>> Don't know if yours is the same, but you may want to take a peek >>> at those. >>> >>> Cheers, >>> David >>> >>>> >>>> kain-osx:mysite kain$ rake spec:rcov >>>> (in /Users/kain/Sites/mysite) >>>> .................... >>>> >>>> Finished in 1.567164 seconds >>>> >>>> 20 examples, 0 failures >>>> /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:131:in `wrap': >>>> stack level too deep (SystemStackError) >>>> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:131:in >>>> `wrap' >>>> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:90:in >>>> `write_text' >>>> from /usr/local/lib/ruby/1.8/rexml/formatters/default.rb:50:in >>>> `write' >>>> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:75:in >>>> `write_element' >>>> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:73:in >>>> `each' >>>> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:73:in >>>> `write_element' >>>> from /usr/local/lib/ruby/1.8/rexml/formatters/default.rb:31:in >>>> `write' >>>> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:75:in >>>> `write_element' >>>> ... 11 levels... >>>> from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/ >>>> rcov.rb: >>>> 640:in `dump_coverage_info' >>>> from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/ >>>> rcov.rb: >>>> 640:in `each' >>>> from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/ >>>> rcov.rb: >>>> 640:in `dump_coverage_info' >>>> from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/bin/ >>>> rcov:421 >>>> rake aborted! >>>> Command /usr/local/bin/ruby -I"/usr/local/lib/ruby/gems/1.8/gems/ >>>> rspec-1.1.4/lib" -S rcov --exclude "spec/*,gems/*" --rails -o >>>> "coverage" "/usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.4/bin/ >>>> spec" -- >>>> "spec/models/account_spec.rb" "spec/models/dictionary_spec.rb" -- >>>> options "/Users/kain/Sites/mysite/spec/spec.opts" failed >>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From masterkain at gmail.com Mon Aug 25 17:38:35 2008 From: masterkain at gmail.com (Claudio Poli) Date: Mon, 25 Aug 2008 23:38:35 +0200 Subject: [rspec-users] rspec and rcov In-Reply-To: <69E65517-1E87-489F-A258-69F4F5DCC465@gmail.com> References: <714a4eef-5082-49d9-a904-896a73c5b8a8@8g2000hse.googlegroups.com> <57c63afe0808251115icd522dv1b400853c61015de@mail.gmail.com> <57c63afe0808251153l7561e998te4c28f1adf8362ad@mail.gmail.com> <69E65517-1E87-489F-A258-69F4F5DCC465@gmail.com> Message-ID: <9CA70E1A-B9B7-4D75-BF3D-99EB2B5B42E0@gmail.com> got this and monkeypatched rails with the fix proposed by Koz, rspec test linked in topfunky's tweet pass, but still same error about rspec:rcov rake task. I'm going to open a lighthouse ticket, feel free to close it if it's not pertinent, thanks. claudio Il giorno 25/ago/08, alle ore 22:15, Aslak Helles?y ha scritto: > >> Please file a new ticket for this then. >> > > But first check topfunky's recent tweet on REXML. I'm almost certain > you've been bitten by a REXML bug. > >> Thanks, >> David >> >> On Mon, Aug 25, 2008 at 1:30 PM, Claudio Poli >> wrote: >>> hi David, >>> thanks for the reply, I didn't find on lighthouse this specific >>> exception. >>> I think it's something related to the rexml version in ruby 1.8.7 >>> (2008-06-20 patchlevel 22) [i686-darwin9.3.0] but not sure how to >>> fix it. >>> >>> Claudio >>> >>> Il giorno 25/ago/08, alle ore 20:15, David Chelimsky ha scritto: >>> >>>> On Mon, Aug 25, 2008 at 1:11 PM, Claudio Poli >>>> >>>> wrote: >>>>> >>>>> hi everyone, >>>>> does anyone experience this problem? >>>> >>>> Hi Claudio, >>>> >>>> There are a few issues at lighthouse related to running rcov: >>>> >>>> >>>> http://rspec.lighthouseapp.com/projects/5645-rspec/tickets?q=rcov+state%3Aopen&filter=created%3Atoday >>>> >>>> Don't know if yours is the same, but you may want to take a peek >>>> at those. >>>> >>>> Cheers, >>>> David >>>> >>>>> >>>>> kain-osx:mysite kain$ rake spec:rcov >>>>> (in /Users/kain/Sites/mysite) >>>>> .................... >>>>> >>>>> Finished in 1.567164 seconds >>>>> >>>>> 20 examples, 0 failures >>>>> /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:131:in `wrap': >>>>> stack level too deep (SystemStackError) >>>>> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:131:in >>>>> `wrap' >>>>> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:90:in >>>>> `write_text' >>>>> from /usr/local/lib/ruby/1.8/rexml/formatters/default.rb:50:in >>>>> `write' >>>>> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:75:in >>>>> `write_element' >>>>> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:73:in >>>>> `each' >>>>> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:73:in >>>>> `write_element' >>>>> from /usr/local/lib/ruby/1.8/rexml/formatters/default.rb:31:in >>>>> `write' >>>>> from /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:75:in >>>>> `write_element' >>>>> ... 11 levels... >>>>> from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/ >>>>> rcov.rb: >>>>> 640:in `dump_coverage_info' >>>>> from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/ >>>>> rcov.rb: >>>>> 640:in `each' >>>>> from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/ >>>>> rcov.rb: >>>>> 640:in `dump_coverage_info' >>>>> from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/bin/ >>>>> rcov:421 >>>>> rake aborted! >>>>> Command /usr/local/bin/ruby -I"/usr/local/lib/ruby/gems/1.8/gems/ >>>>> rspec-1.1.4/lib" -S rcov --exclude "spec/*,gems/*" --rails -o >>>>> "coverage" "/usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.4/bin/ >>>>> spec" -- >>>>> "spec/models/account_spec.rb" "spec/models/dictionary_spec.rb" -- >>>>> options "/Users/kain/Sites/mysite/spec/spec.opts" failed >>>>> >>>>> _______________________________________________ >>>>> rspec-users mailing list >>>>> rspec-users at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Mon Aug 25 18:00:58 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 25 Aug 2008 17:00:58 -0500 Subject: [rspec-users] How much test data to use in specs In-Reply-To: <85d99afe0808251302l58ab5cfbh3ddb786c72e68a02@mail.gmail.com> References: <85d99afe0808251029g816c7ecvabc9ecbf1f830978@mail.gmail.com> <85d99afe0808251302l58ab5cfbh3ddb786c72e68a02@mail.gmail.com> Message-ID: <57c63afe0808251500o78e65eb7rbd4404d86f507b88@mail.gmail.com> On Mon, Aug 25, 2008 at 3:02 PM, Zach Dennis wrote: > On Mon, Aug 25, 2008 at 2:50 PM, Nick Hoffman wrote: >> On 2008-08-25, at 13:29, Zach Dennis wrote: >>> >>> I might do something like the following... >>> >>> describe Property, "email validations" do >>> >>> ["1invalid.email at example.com", "can't start with a digit", >>> "invalid.email2 at example.com", "can't end with a digit" >>> ].in_groups_of(2) do |email, description| >>> it description do >>> prop = Property.new :email => email >>> prop.should_not be_valid >>> prop.should have(1).error_on(:email) >>> end >>> end >>> end >>> >>> >>> -- Zach Dennis >>> http://www.continuousthinking.com >>> http://www.mutuallyhuman.com >> >> Hi Zach. That's a great way of iterating over test data. Do you have any >> suggestions for how much test data to use? >> > > I'd probably start with the first invalid email/description that I can > think of. Perhaps it can't start with a digit. Then I'd update the > regexp to reflect that. Next I'd add a second invalid > email/description and update the regexp to reflect that. Rinse and > repeat until your regexp is where you need it. This is nit-picky, I realize, but saying "until your regexp is where you need it" suggests that you'll know when you get there by looking at the regexp. I'd suggest that you know when you get there by looking at the code examples and feeling confident that you've covered all of the edge cases. > This should help you > not add redundant emails which test the same thing. When you get to > the case where you allow from 2 up to 128 characters, you could just > test those two edge cases (rather than emails which 2 characters, 3 > characters, 4 characters, ... 128 characters. If the boundaries are 2 and 128, I would test 1,2,3,127,128,129 - the boundary and either side of it. Might seem like overkill, but I've seen a bug or two make its way to production because the boundary wasn't clearly understood. FWIW, David > > -- > 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 > From joe at pinkpucker.net Mon Aug 25 19:29:43 2008 From: joe at pinkpucker.net (Joe Van Dyk) Date: Mon, 25 Aug 2008 16:29:43 -0700 Subject: [rspec-users] Upgraded to 2.1 and 1.1.4 from 2.0 and 1.1.3, no output from 'rake spec' In-Reply-To: References: Message-ID: Any ideas? On Sat, Aug 23, 2008 at 10:11 AM, Joe Van Dyk wrote: > $ rake spec --trace > (in /Users/joe/projects/tanga) > ** Invoke spec (first_time) > ** Invoke db:test:prepare (first_time) > ** Invoke db:abort_if_pending_migrations (first_time) > ** Invoke environment (first_time) > ** Execute environment > ** Execute db:abort_if_pending_migrations > ** Execute db:test:prepare > ** Invoke db:test:clone_structure (first_time) > ** Invoke db:structure:dump (first_time) > ** Invoke environment > ** Execute db:structure:dump > ** Invoke db:test:purge (first_time) > ** Invoke environment > ** Execute db:test:purge > ** Execute db:test:clone_structure > ** Execute spec > > $ > > > Running "script/spec /path/to/spec" also doesn't give output. > > Any ideas? I ran "script/generate rspec" and let it overwrite everything. > From matt at mattwynne.net Mon Aug 25 19:44:32 2008 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 26 Aug 2008 00:44:32 +0100 Subject: [rspec-users] Upgraded to 2.1 and 1.1.4 from 2.0 and 1.1.3, no output from 'rake spec' In-Reply-To: References: Message-ID: <5F794BF3-FC33-4990-A0E0-48B81682DA3B@mattwynne.net> What happens if you run an individual spec file with ruby from the command line? e.g. ruby spec/models/blog_post_spec.rb Do you get any more clues from that? Also bear in mind that script/generate rspec will have overwritten your spec/spec_helper.rb file, where you might have put custom stuff for your project (loading fixtures etc) - do a diff against the version you had before you upgraded and see if there's anything obvious missing from the new one. cheers, Matt ---- http://blog.mattwynne.net http://songkick.com In case you wondered: The opinions expressed in this email are my own and do not necessarily reflect the views of any former, current or future employers of mine. On 26 Aug 2008, at 00:29, Joe Van Dyk wrote: > Any ideas? > > On Sat, Aug 23, 2008 at 10:11 AM, Joe Van Dyk > wrote: >> $ rake spec --trace >> (in /Users/joe/projects/tanga) >> ** Invoke spec (first_time) >> ** Invoke db:test:prepare (first_time) >> ** Invoke db:abort_if_pending_migrations (first_time) >> ** Invoke environment (first_time) >> ** Execute environment >> ** Execute db:abort_if_pending_migrations >> ** Execute db:test:prepare >> ** Invoke db:test:clone_structure (first_time) >> ** Invoke db:structure:dump (first_time) >> ** Invoke environment >> ** Execute db:structure:dump >> ** Invoke db:test:purge (first_time) >> ** Invoke environment >> ** Execute db:test:purge >> ** Execute db:test:clone_structure >> ** Execute spec >> >> $ >> >> >> Running "script/spec /path/to/spec" also doesn't give output. >> >> Any ideas? I ran "script/generate rspec" and let it overwrite >> everything. >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Tue Aug 26 14:34:17 2008 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 26 Aug 2008 19:34:17 +0100 Subject: [rspec-users] stub_model() and ActiveRecord Associations Message-ID: Hi all, I have what I thought was quite a simple requirement but something to do with the way ActiveRecord's associations work is making it quite puzzling. I guess I can sum it up with this failing test: before(:each) do @source_comment = @source.comments.create(:user_id => 1) @target_comment = @target.comments.create(:user_id => 1) end it "should return the same object from create() as from the array" do (@target_comment.equal?(@target.comments[0])).should be_true do_merge end What I actually want to be able to do, is mock a method call on the @target_comment but I'm finding that I get unreliable results: @target.comments[0].should_receive(:merge_in) # works # @target_comment.should_receive(:merge_in) # doesn't work The code I'm testing is using self.comments.each() to access the object it's going to call merge_in() on - the one I want to mock. Any tips here folks? Someone here has suggested that what I really need to do is express my mock like... (commence pseudo code) Comment.should_receive_instance_method(:merge_in).with (...).on_an_object_matching{|o| o.id = @target_comment.id} (/pseudo code) Has anyone else come across similar issues? How did you approach them? cheers, Matt ---- http://blog.mattwynne.net http://songkick.com In case you wondered: The opinions expressed in this email are my own and do not necessarily reflect the views of any former, current or future employers of mine. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Tue Aug 26 20:01:18 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 26 Aug 2008 19:01:18 -0500 Subject: [rspec-users] stub_model() and ActiveRecord Associations In-Reply-To: References: Message-ID: <57c63afe0808261701gf43162dg564241c5fdd4cc02@mail.gmail.com> On Tue, Aug 26, 2008 at 1:34 PM, Matt Wynne wrote: > Hi all, > I have what I thought was quite a simple requirement but something to do > with the way ActiveRecord's associations work is making it quite puzzling. > I guess I can sum it up with this failing test: > before(:each) do > @source_comment = @source.comments.create(:user_id => 1) > @target_comment = @target.comments.create(:user_id => 1) > end > > it "should return the same object from create() as from the array" > do > (@target_comment.equal?(@target.comments[0])).should be_true > > do_merge > > end > What I actually want to be able to do, is mock a method call on the > @target_comment but I'm finding that I get unreliable results: > @target.comments[0].should_receive(:merge_in) # works > # @target_comment.should_receive(:merge_in) # doesn't work > > The code I'm testing is using self.comments.each() to access the object it's > going to call merge_in() on - the one I want to mock. > Any tips here folks? > Someone here has suggested that what I really need to do is express my mock > like... (commence pseudo code) > Comment.should_receive_instance_method(:merge_in).with(...).on_an_object_matching{|o| > o.id = @target_comment.id} > (/pseudo code) > > Has anyone else come across similar issues? How did you approach them? Here's the basic deal: Model.find(1).equal?(Model.find(1)) => false AR does not cache objects, so when you ask it for what you *think* might the same object twice, you get different ones. mocha offers an 'any_instance' method, which gives you basically what you are describing with should_receive_instance_method, but rspec does not yet have a counterpart in its mocking library. I can tell you how I handle this, but let me say that this is a less than perfect way to handle a less than perfect situation so it's difficult for me to say "this is a recommended approach." That said ... @target_comment = stub_model(Target) @target.stub!(:comments).and_return([@target_comment]) HTH, David > cheers, > Matt From mark at mwilden.com Tue Aug 26 21:51:14 2008 From: mark at mwilden.com (Mark Wilden) Date: Tue, 26 Aug 2008 18:51:14 -0700 Subject: [rspec-users] stub_model() and ActiveRecord Associations In-Reply-To: <57c63afe0808261701gf43162dg564241c5fdd4cc02@mail.gmail.com> References: <57c63afe0808261701gf43162dg564241c5fdd4cc02@mail.gmail.com> Message-ID: <3c30da400808261851o6e0fda93o3a1897e9e1335755@mail.gmail.com> On Tue, Aug 26, 2008 at 5:01 PM, David Chelimsky wrote: > @target_comment = stub_model(Target) > @target.stub!(:comments).and_return([@target_comment]) > That's what we do - what would the drawbacks be? ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Tue Aug 26 22:03:21 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 26 Aug 2008 21:03:21 -0500 Subject: [rspec-users] stub_model() and ActiveRecord Associations In-Reply-To: <3c30da400808261851o6e0fda93o3a1897e9e1335755@mail.gmail.com> References: <57c63afe0808261701gf43162dg564241c5fdd4cc02@mail.gmail.com> <3c30da400808261851o6e0fda93o3a1897e9e1335755@mail.gmail.com> Message-ID: <57c63afe0808261903u34b84216q7a702a44e35a549@mail.gmail.com> On Tue, Aug 26, 2008 at 8:51 PM, Mark Wilden wrote: > On Tue, Aug 26, 2008 at 5:01 PM, David Chelimsky > wrote: > >> >> @target_comment = stub_model(Target) >> @target.stub!(:comments).and_return([@target_comment]) > > That's what we do - what would the drawbacks be? It's more invasive than I'd like. It's not all that risky though. I just feel dirty whenever I mock methods on the objects I'm focused on. FWIW. Cheers, David > > ///ark > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From zach.dennis at gmail.com Tue Aug 26 22:26:50 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Tue, 26 Aug 2008 22:26:50 -0400 Subject: [rspec-users] stub_model() and ActiveRecord Associations In-Reply-To: <57c63afe0808261903u34b84216q7a702a44e35a549@mail.gmail.com> References: <57c63afe0808261701gf43162dg564241c5fdd4cc02@mail.gmail.com> <3c30da400808261851o6e0fda93o3a1897e9e1335755@mail.gmail.com> <57c63afe0808261903u34b84216q7a702a44e35a549@mail.gmail.com> Message-ID: <85d99afe0808261926j4d776d18i5aa30ec6b50532f4@mail.gmail.com> On Tue, Aug 26, 2008 at 10:03 PM, David Chelimsky wrote: > On Tue, Aug 26, 2008 at 8:51 PM, Mark Wilden wrote: >> On Tue, Aug 26, 2008 at 5:01 PM, David Chelimsky >> wrote: >> >>> >>> @target_comment = stub_model(Target) >>> @target.stub!(:comments).and_return([@target_comment]) >> >> That's what we do - what would the drawbacks be? > > It's more invasive than I'd like. It's not all that risky though. I > just feel dirty whenever I mock methods on the objects I'm focused on. > FWIW. A similar approach I've used when I'm not utilizing custom SQL logic (that requires hitting the database) which is less "dirty" IMO than modifying the object you're focusing on is: comments = [stub_model(Target)] @target.comments = comments -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From matt at mattwynne.net Wed Aug 27 03:34:58 2008 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 27 Aug 2008 08:34:58 +0100 Subject: [rspec-users] stub_model() and ActiveRecord Associations In-Reply-To: <57c63afe0808261701gf43162dg564241c5fdd4cc02@mail.gmail.com> References: <57c63afe0808261701gf43162dg564241c5fdd4cc02@mail.gmail.com> Message-ID: <023F03D2-914A-4E38-A8C9-9022E90BE945@mattwynne.net> > Here's the basic deal: > > Model.find(1).equal?(Model.find(1)) > => false > > AR does not cache objects, so when you ask it for what you *think* > might the same object twice, you get different ones. I thought as much... So does AR just cache the object's attributes instead and construct them on the fly as and when you ask for them? > mocha offers an 'any_instance' method, which gives you basically what > you are describing with should_receive_instance_method, but rspec does > not yet have a counterpart in its mocking library. Interesting. I'd love to dive in and write one for RSpec but I think it might be a bit beyond me right now. You can't really mix mocking frameworks in RSpec, right? > I can tell you how I handle this, but let me say that this is a less > than perfect way to handle a less than perfect situation so it's > difficult for me to say "this is a recommended approach." That said > ... > > @target_comment = stub_model(Target) > @target.stub!(:comments).and_return([@target_comment]) Bugger - I was hoping you wouldn't say that :) Okay well at least I know what the deal is. Thanks as usual David. cheers, Matt From lists at ruby-forum.com Wed Aug 27 05:42:08 2008 From: lists at ruby-forum.com (aa aa) Date: Wed, 27 Aug 2008 11:42:08 +0200 Subject: [rspec-users] story runner not running on build machine Message-ID: <474ca3b709afe109c841899b3ee09da6@ruby-forum.com> Hi, have my stories running fine here on my dev machine but they blow up on the build machine. Rspec and Rspec-rails are installed as plugins When i attempt to run > ruby stories/all.rb on the dev server i get this error stories/steps/fields_steps.rb:1: undefined method `steps_for' for main:Object (NoMethodError) what is going on here?! It doesn't seem to be loading the plugin does it? -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Wed Aug 27 08:22:55 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 27 Aug 2008 08:22:55 -0400 Subject: [rspec-users] stub_model() and ActiveRecord Associations In-Reply-To: <023F03D2-914A-4E38-A8C9-9022E90BE945@mattwynne.net> References: <57c63afe0808261701gf43162dg564241c5fdd4cc02@mail.gmail.com> <023F03D2-914A-4E38-A8C9-9022E90BE945@mattwynne.net> Message-ID: <85d99afe0808270522r59a16256k9cb5429e8933d0d2@mail.gmail.com> On Wed, Aug 27, 2008 at 3:34 AM, Matt Wynne wrote: >> Here's the basic deal: >> >> Model.find(1).equal?(Model.find(1)) >> => false >> >> AR does not cache objects, so when you ask it for what you *think* >> might the same object twice, you get different ones. > > I thought as much... So does AR just cache the object's attributes instead > and construct them on the fly as and when you ask for them? It caches the SQL statements and their results. It uses the cached results to build an instance of your model. Although the identify of the objects are different, they are equal. f = Foo.create :name => "blah" f.equal?(Foo.last) # false f == Foo.last # true I don't know your ultimate goal, but you could rely on object equality (and not identify equality) in your test: @target_comment.should == @target_comments.first And then rely on @target_comments.first to set up your expectation for :merge_in. -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From dchelimsky at gmail.com Wed Aug 27 08:26:35 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 27 Aug 2008 07:26:35 -0500 Subject: [rspec-users] stub_model() and ActiveRecord Associations In-Reply-To: <85d99afe0808270522r59a16256k9cb5429e8933d0d2@mail.gmail.com> References: <57c63afe0808261701gf43162dg564241c5fdd4cc02@mail.gmail.com> <023F03D2-914A-4E38-A8C9-9022E90BE945@mattwynne.net> <85d99afe0808270522r59a16256k9cb5429e8933d0d2@mail.gmail.com> Message-ID: <57c63afe0808270526v4ae5ad34x102b217ce8f6f4ee@mail.gmail.com> On Wed, Aug 27, 2008 at 7:22 AM, Zach Dennis wrote: > On Wed, Aug 27, 2008 at 3:34 AM, Matt Wynne wrote: >>> Here's the basic deal: >>> >>> Model.find(1).equal?(Model.find(1)) >>> => false >>> >>> AR does not cache objects, so when you ask it for what you *think* >>> might the same object twice, you get different ones. >> >> I thought as much... So does AR just cache the object's attributes instead >> and construct them on the fly as and when you ask for them? > > > It caches the SQL statements and their results. It uses the cached > results to build an instance of your model. Although the identify of > the objects are different, they are equal. > > f = Foo.create :name => "blah" > f.equal?(Foo.last) # false > f == Foo.last # true > > I don't know your ultimate goal, He's trying to set a message expectation on an object that gets returned by AR. Since AR builds a new object for each request, you can't get a handle on it in the code example. > but you could rely on object equality > (and not identify equality) in your test: > > @target_comment.should == @target_comments.first > > And then rely on @target_comments.first to set up your expectation for > :merge_in. > > -- > 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 > From dchelimsky at gmail.com Wed Aug 27 08:32:01 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 27 Aug 2008 07:32:01 -0500 Subject: [rspec-users] stub_model() and ActiveRecord Associations In-Reply-To: <023F03D2-914A-4E38-A8C9-9022E90BE945@mattwynne.net> References: <57c63afe0808261701gf43162dg564241c5fdd4cc02@mail.gmail.com> <023F03D2-914A-4E38-A8C9-9022E90BE945@mattwynne.net> Message-ID: <57c63afe0808270532j4ce970afu434351f0d9d7895@mail.gmail.com> On Wed, Aug 27, 2008 at 2:34 AM, Matt Wynne wrote: >> Here's the basic deal: >> >> Model.find(1).equal?(Model.find(1)) >> => false >> >> AR does not cache objects, so when you ask it for what you *think* >> might the same object twice, you get different ones. > > I thought as much... So does AR just cache the object's attributes instead > and construct them on the fly as and when you ask for them? > >> mocha offers an 'any_instance' method, which gives you basically what >> you are describing with should_receive_instance_method, but rspec does >> not yet have a counterpart in its mocking library. > > Interesting. I'd love to dive in and write one for RSpec but I think it > might be a bit beyond me right now. http://rubyurl.com/PHwC - it got started but a) the patch was never completed and b) there are some mixed feelings about supporting it. Feel free to add to the conversation in that ticket. > You can't really mix mocking frameworks > in RSpec, right? Right. >> I can tell you how I handle this, but let me say that this is a less >> than perfect way to handle a less than perfect situation so it's >> difficult for me to say "this is a recommended approach." That said >> ... >> >> @target_comment = stub_model(Target) >> @target.stub!(:comments).and_return([@target_comment]) > > Bugger - I was hoping you wouldn't say that :) > > Okay well at least I know what the deal is. Thanks as usual David. > > cheers, > Matt > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Aug 27 08:36:23 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 27 Aug 2008 07:36:23 -0500 Subject: [rspec-users] story runner not running on build machine In-Reply-To: <474ca3b709afe109c841899b3ee09da6@ruby-forum.com> References: <474ca3b709afe109c841899b3ee09da6@ruby-forum.com> Message-ID: <57c63afe0808270536o716a87ffy98475f51e7a2d6e2@mail.gmail.com> On Wed, Aug 27, 2008 at 4:42 AM, aa aa wrote: > Hi, have my stories running fine here on my dev machine but they blow up > on the build machine. Rspec and Rspec-rails are installed as plugins > > When i attempt to run >> ruby stories/all.rb > on the dev server i get this error > stories/steps/fields_steps.rb:1: undefined method `steps_for' for > main:Object (NoMethodError) > > what is going on here?! > It doesn't seem to be loading the plugin does it? Are you using git for your project? If so, did you delete the .git directories in rspec and rspec-rails? If not, the files in those directories didn't get committed to your project. To fix, remove the rspec and rspec-rails directories from your project and commit it. Then re-install, this time removing the .git directories, commit and push. HTH, David > -- > 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 Aug 27 08:38:43 2008 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 27 Aug 2008 13:38:43 +0100 Subject: [rspec-users] stub_model() and ActiveRecord Associations In-Reply-To: <57c63afe0808270526v4ae5ad34x102b217ce8f6f4ee@mail.gmail.com> References: <57c63afe0808261701gf43162dg564241c5fdd4cc02@mail.gmail.com> <023F03D2-914A-4E38-A8C9-9022E90BE945@mattwynne.net> <85d99afe0808270522r59a16256k9cb5429e8933d0d2@mail.gmail.com> <57c63afe0808270526v4ae5ad34x102b217ce8f6f4ee@mail.gmail.com> Message-ID: <9C44D477-312B-449D-8D81-7080291AFEC1@mattwynne.net> On 27 Aug 2008, at 13:26, David Chelimsky wrote: > On Wed, Aug 27, 2008 at 7:22 AM, Zach Dennis > wrote: >> On Wed, Aug 27, 2008 at 3:34 AM, Matt Wynne >> wrote: >>>> Here's the basic deal: >>>> >>>> Model.find(1).equal?(Model.find(1)) >>>> => false >>>> >>>> AR does not cache objects, so when you ask it for what you *think* >>>> might the same object twice, you get different ones. >>> >>> I thought as much... So does AR just cache the object's >>> attributes instead >>> and construct them on the fly as and when you ask for them? >> >> >> It caches the SQL statements and their results. It uses the cached >> results to build an instance of your model. Although the identify of >> the objects are different, they are equal. >> >> f = Foo.create :name => "blah" >> f.equal?(Foo.last) # false >> f == Foo.last # true >> >> I don't know your ultimate goal, > > He's trying to set a message expectation on an object that gets > returned by AR. Since AR builds a new object for each request, you > can't get a handle on it in the code example. You've got it. I worked around it using the foo.stub!(:bars) = [] hack, but I too feel dirty about it. I think I'm going to need a couple of old-fashioned database-coupled tests to prove to myself that all this works OK. From joe at pinkpucker.net Wed Aug 27 10:56:13 2008 From: joe at pinkpucker.net (Joe Van Dyk) Date: Wed, 27 Aug 2008 07:56:13 -0700 Subject: [rspec-users] Upgraded to 2.1 and 1.1.4 from 2.0 and 1.1.3, no output from 'rake spec' In-Reply-To: <5F794BF3-FC33-4990-A0E0-48B81682DA3B@mattwynne.net> References: <5F794BF3-FC33-4990-A0E0-48B81682DA3B@mattwynne.net> Message-ID: No, I don't get any output from that, or by using the spec command. Nothing got overwritten. Joe On Mon, Aug 25, 2008 at 4:44 PM, Matt Wynne wrote: > What happens if you run an individual spec file with ruby from the command > line? > > e.g. > ruby spec/models/blog_post_spec.rb > > Do you get any more clues from that? > > Also bear in mind that script/generate rspec will have overwritten your > spec/spec_helper.rb file, where you might have put custom stuff for your > project (loading fixtures etc) - do a diff against the version you had > before you upgraded and see if there's anything obvious missing from the new > one. > > cheers, > Matt > ---- > http://blog.mattwynne.net > http://songkick.com > > In case you wondered: The opinions expressed in this email are my own and do > not necessarily reflect the views of any former, current or future employers > of mine. > > > > On 26 Aug 2008, at 00:29, Joe Van Dyk wrote: > >> Any ideas? >> >> On Sat, Aug 23, 2008 at 10:11 AM, Joe Van Dyk wrote: >>> >>> $ rake spec --trace >>> (in /Users/joe/projects/tanga) >>> ** Invoke spec (first_time) >>> ** Invoke db:test:prepare (first_time) >>> ** Invoke db:abort_if_pending_migrations (first_time) >>> ** Invoke environment (first_time) >>> ** Execute environment >>> ** Execute db:abort_if_pending_migrations >>> ** Execute db:test:prepare >>> ** Invoke db:test:clone_structure (first_time) >>> ** Invoke db:structure:dump (first_time) >>> ** Invoke environment >>> ** Execute db:structure:dump >>> ** Invoke db:test:purge (first_time) >>> ** Invoke environment >>> ** Execute db:test:purge >>> ** Execute db:test:clone_structure >>> ** Execute spec >>> >>> $ >>> >>> >>> Running "script/spec /path/to/spec" also doesn't give output. >>> >>> Any ideas? I ran "script/generate rspec" and let it overwrite >>> everything. >>> >> _______________________________________________ >> 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 baz at madeofstone.net Wed Aug 27 11:12:14 2008 From: baz at madeofstone.net (Rahoul Baruah) Date: Wed, 27 Aug 2008 16:12:14 +0100 Subject: [rspec-users] How much test data to use in specs In-Reply-To: References: Message-ID: <14C2F08B-4675-4AEC-9FEB-CAE74D74FEF9@madeofstone.net> Hi all, On 25 Aug 2008, at 17:53, Nick Hoffman wrote: > At the moment, my plan is to spec out the following possibilities. > A property is invalid if its address: > 1) doesn't begin with a digit; > 2) is shorter than 2 characters; > 3) is longer than 128 characters; Personally I think that if those three points are your specification then your RSpec should match that. So: * it "should not begin with a digit", * it "should not be shorter than 2 characters", * it "should not be longer than 128 characters" and * it "should allow valid addresses" (this is for clarity, so you have an example of a valid address in your documentation). If your regex allows or disallows more or less than those four clauses then your specification does not match your implementation. Baz Rahoul Baruah Web design and development: http://www.3hv.co.uk/ Nottingham Forest: http://www.eighteensixtyfive.co.uk/ Serious Rails Hosting: http://www.brightbox.co.uk/ Lifecast: http://www.madeofstone.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Wed Aug 27 11:35:14 2008 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 27 Aug 2008 16:35:14 +0100 Subject: [rspec-users] How much test data to use in specs In-Reply-To: <14C2F08B-4675-4AEC-9FEB-CAE74D74FEF9@madeofstone.net> References: <14C2F08B-4675-4AEC-9FEB-CAE74D74FEF9@madeofstone.net> Message-ID: <1EF0CC1B-7142-44CA-B92B-E29FAFE5FD7B@mattwynne.net> > > On 25 Aug 2008, at 17:53, Nick Hoffman wrote: > >> At the moment, my plan is to spec out the following possibilities. >> A property is invalid if its address: >> 1) doesn't begin with a digit; >> 2) is shorter than 2 characters; >> 3) is longer than 128 characters; > > > > Personally I think that if those three points are your > specification then your RSpec should match that. > > So: > * it "should not begin with a digit", > * it "should not be shorter than 2 characters", > * it "should not be longer than 128 characters" and > * it "should allow valid addresses" (this is for clarity, so you > have an example of a valid address in your documentation). > > If your regex allows or disallows more or less than those four > clauses then your specification does not match your implementation. > So this is interesting, because my approach seems to be more like this: describe "when the address does not begin with a digit" do it "should be invalid" do ... end end describe "when the address is less than two characters long" do it "should be invalid" do ... end end describe "when the address is more than two characters long" do describe "and the address is less than 128 characters long" do it "should be valid" do ... end end describe "and the address is more than 128 characters long" do it "should be invalid" do ... end end end Is anyone else using ExampleGroups like this? Or is it just me?! cheers, Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Wed Aug 27 12:16:32 2008 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 27 Aug 2008 17:16:32 +0100 Subject: [rspec-users] array_including() Message-ID: <54FDC633-7CE3-45B0-961B-8E1D76A047AB@mattwynne.net> I found myself having to write this today: class ArrayMatcher def initialize(array_to_match) @array_to_match = array_to_match end def ==(other) ok = true @array_to_match.each do |item| ok = ok and other.include?(item) end ok end end def array_including(array_to_match) ArrayMatcher.new(array_to_match) end Is there already something in the framework that does this? cheers, Matt ---- http://blog.mattwynne.net http://songkick.com In case you wondered: The opinions expressed in this email are my own and do not necessarily reflect the views of any former, current or future employers of mine. -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Wed Aug 27 12:28:49 2008 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 27 Aug 2008 17:28:49 +0100 Subject: [rspec-users] array_including() In-Reply-To: <54FDC633-7CE3-45B0-961B-8E1D76A047AB@mattwynne.net> References: <54FDC633-7CE3-45B0-961B-8E1D76A047AB@mattwynne.net> Message-ID: <345B4F63-46DE-402A-8747-739468C76A80@mattwynne.net> On a similar vein, is there a neater way to express: assigns[:events].include?(@event_1).should be_true cheers, Matt ---- http://blog.mattwynne.net http://songkick.com In case you wondered: The opinions expressed in this email are my own and do not necessarily reflect the views of any former, current or future employers of mine. On 27 Aug 2008, at 17:16, Matt Wynne wrote: > I found myself having to write this today: > > class ArrayMatcher > > def initialize(array_to_match) > @array_to_match = array_to_match > end > > def ==(other) > > ok = true > > @array_to_match.each do |item| > ok = ok and other.include?(item) > end > > ok > > end > > end > > def array_including(array_to_match) > ArrayMatcher.new(array_to_match) > end > > Is there already something in the framework that does this? > > cheers, > Matt > ---- > http://blog.mattwynne.net > http://songkick.com > > In case you wondered: The opinions expressed in this email are my > own and do not necessarily reflect the views of any former, current > or future employers of mine. > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Wed Aug 27 12:45:17 2008 From: lists at ruby-forum.com (Joseph Wilk) Date: Wed, 27 Aug 2008 18:45:17 +0200 Subject: [rspec-users] array_including() In-Reply-To: <54FDC633-7CE3-45B0-961B-8E1D76A047AB@mattwynne.net> References: <54FDC633-7CE3-45B0-961B-8E1D76A047AB@mattwynne.net> Message-ID: Hello, I believe Pat Maddox has implemented a matcher that does the same thing but there has been a battle to find out what to call it: http://www.ruby-forum.com/topic/162000#new However I've not seen it in source yet. -- Joseph Wilk http://www.joesniff.co.uk Matt Wynne wrote: > I found myself having to write this today: > > class ArrayMatcher > > def initialize(array_to_match) > @array_to_match = array_to_match > end > > def ==(other) > > ok = true > > @array_to_match.each do |item| > ok = ok and other.include?(item) > end > > ok > > end > > end > > def array_including(array_to_match) > ArrayMatcher.new(array_to_match) > end > > Is there already something in the framework that does this? > > cheers, > Matt > ---- > http://blog.mattwynne.net > http://songkick.com > > In case you wondered: The opinions expressed in this email are my own > and do not necessarily reflect the views of any former, current or > future employers of mine. -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Wed Aug 27 12:52:16 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 27 Aug 2008 12:52:16 -0400 Subject: [rspec-users] array_including() In-Reply-To: <345B4F63-46DE-402A-8747-739468C76A80@mattwynne.net> References: <54FDC633-7CE3-45B0-961B-8E1D76A047AB@mattwynne.net> <345B4F63-46DE-402A-8747-739468C76A80@mattwynne.net> Message-ID: <85d99afe0808270952j1028c1f2ya7a9779302d7cb51@mail.gmail.com> On Wed, Aug 27, 2008 at 12:28 PM, Matt Wynne wrote: > On a similar vein, is there a neater way to express: > assigns[:events].include?(@event_1).should be_true assigns[:events].should include(@event_1) -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From baz at madeofstone.net Wed Aug 27 12:57:24 2008 From: baz at madeofstone.net (Rahoul Baruah) Date: Wed, 27 Aug 2008 17:57:24 +0100 Subject: [rspec-users] How much test data to use in specs In-Reply-To: <1EF0CC1B-7142-44CA-B92B-E29FAFE5FD7B@mattwynne.net> References: <14C2F08B-4675-4AEC-9FEB-CAE74D74FEF9@madeofstone.net> <1EF0CC1B-7142-44CA-B92B-E29FAFE5FD7B@mattwynne.net> Message-ID: <0375912D-4B5C-47F8-A18D-962BDD00C7C2@madeofstone.net> On 27 Aug 2008, at 16:35, Matt Wynne wrote: > describe "when the address is less than two characters long" do > it "should be invalid" do ... end > end > > describe "when the address is more than two characters long" do > > describe "and the address is less than 128 characters long" do > it "should be valid" do ... end > end > > describe "and the address is more than 128 characters long" do > it "should be invalid" do ... end > end > > end For this, trivial, example, I find that far too verbose. The "specification" says "if it is less than 2 characters then invalid" and "if it is more than 128 characters then invalid" . But you are actually running three checks - "if less than 2", "if greater than 2 but less than 128" and "if greater than 2 and greater than 128". B Rahoul Baruah Web design and development: http://www.3hv.co.uk/ Nottingham Forest: http://www.eighteensixtyfive.co.uk/ Serious Rails Hosting: http://www.brightbox.co.uk/ Lifecast: http://www.madeofstone.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Wed Aug 27 13:20:06 2008 From: lists at ruby-forum.com (Lake Denman) Date: Wed, 27 Aug 2008 19:20:06 +0200 Subject: [rspec-users] Four Question From an RSpec Baby - Give me something to chew Message-ID: The project has been written - around 10,000 lines of code, but certainly less than that to add tests to. There has been no official testing put into place, and I'd very much like to implement RSpec into the project for a few reasons, but mostly to setup solid examples for the behavior of the application. It was suggested to me to begin with Unit Tests. The User Model is almost 1000 lines with plenty of methods and no coverage, so I figured I would start there. After installing Rcov to track my progress, I wrote about 10 passing examples that were, I guess, pretty trivial - the methods I tested all dealt directly with an "instantiated user object"(is that the correct terminology?). I have been writing the user examples in the order that a real user might usually take (A User who: is activating his account, is logging in, forgets his password and resets it, wants to use a new email address, wants to change his username.) Now, I'm not sure of the next step in the process, I'm stuck! The method (upgrade) takes a Payment object parameter. Inside the upgrade method, some payment object attributes are set (user_id, payment_type) and then saved. Then, the user object that is being upgraded has some attributes that are set (payment_id, member, member_since) and finally the user is saved, ending the method. And to top it all off, this method takes place in a transaction. For a visual guide: def upgrade(payment) transaction do payment.user_id = self.id payment.payment_type = Payment::SUBSCRIPTION_PAYMENT_TYPE return false unless (payment.save and payment.external_id) self.subscription_id = payment.external_id self.payment_id = payment.id self.member = true self.member_since = AppLib.today_utc self.save return true end end Now that you have sufficient back story (I hope), here are my questions: 1.) Do I need to use any mocking/stubbing in this example (or in Unit Tests) 2.) Is it wrong to access multiple objects (user and payment in my example) in a Unit Test example? 3.) Would you mind showing me an example of how you might implement a spec for this method. 4.) Could you PLEASE PLEASE PLEASE guide me to a resource that helped you the most with figuring out Unit Testing with RSpec. Not limited to books or blog posts... good source code examples might be helpful. Hopefully you can see my sincere want to know more and I wish that a simple "want" will blossom into a realization of a "need" to test test test. Thanks for any help you can provide me on my journey - I have a long way ahead of me. Lake -- Posted via http://www.ruby-forum.com/. From nick at deadorange.com Wed Aug 27 14:03:37 2008 From: nick at deadorange.com (Nick Hoffman) Date: Wed, 27 Aug 2008 14:03:37 -0400 Subject: [rspec-users] How much test data to use in specs In-Reply-To: <0375912D-4B5C-47F8-A18D-962BDD00C7C2@madeofstone.net> References: <14C2F08B-4675-4AEC-9FEB-CAE74D74FEF9@madeofstone.net> <1EF0CC1B-7142-44CA-B92B-E29FAFE5FD7B@mattwynne.net> <0375912D-4B5C-47F8-A18D-962BDD00C7C2@madeofstone.net> Message-ID: On 2008-08-27, at 12:57, Rahoul Baruah wrote: > For this, trivial, example, I find that far too verbose. > > The "specification" says "if it is less than 2 characters then > invalid" and "if it is more than 128 characters then invalid" . > > But you are actually running three checks - "if less than 2", "if > greater than 2 but less than 128" and "if greater than 2 and greater > than 128". > > B > > > Rahoul Baruah This is what I ended up with: Property addresses that are valid - can't be 129 characters - can't have a 1-letter street name - can't have an & - can't have an ! - can't have a " - can't have 2 letters after the street number - can't be missing a street number - can't have only 3 characters - can't be empty - can have 128 characters - can have 127 characters - can have only 5 characters - can have only 4 characters - can have a , - can have a - - can have a ' - can have 1 letter after the street number - can have multiple spaces Each of the "can ..." examples are proper addresses in the sense that they're variations of: - "123 A Street With A Long Name" - "123B Maple Ave" - "123 O'Connor Street" - etc One thing that I didn't do is write examples for each invalid character. That'd be too hairy and verbose. Instead, I picked a few, and wrote examples for them, as you can see above (Eg: "can't have an &"). Cheers, Nick From nick at deadorange.com Wed Aug 27 14:25:54 2008 From: nick at deadorange.com (Nick Hoffman) Date: Wed, 27 Aug 2008 14:25:54 -0400 Subject: [rspec-users] Four Question From an RSpec Baby - Give me something to chew In-Reply-To: References: Message-ID: <2E9509B7-BA5C-4DBC-B76A-D6F5DC1C856D@deadorange.com> On 2008-08-27, at 13:20, Lake Denman wrote: > For a visual guide: > def upgrade(payment) > transaction do > payment.user_id = self.id > payment.payment_type = Payment::SUBSCRIPTION_PAYMENT_TYPE > return false unless (payment.save and payment.external_id) > self.subscription_id = payment.external_id > self.payment_id = payment.id > self.member = true > self.member_since = AppLib.today_utc > self.save > return true > end > end Hi Lake. > 1.) Do I need to use any mocking/stubbing in this example (or in Unit > Tests) You need to use whatever you think is most suitable for your application. I'm sure many people on here would use mocks and stubs extensively throughout that method. For example, they might mock the entire "payment" object, and stub out AppLib.today_utc . > 2.) Is it wrong to access multiple objects (user and payment in my > example) in a Unit Test example? I don't think so, but I'm not a unit test expert. > 3.) Would you mind showing me an example of how you might implement a > spec for this method. User upgrade - can succeed if the payment amount is correct - fails if the payment amount is incorrect - can succeed if the payment type is valid - fails if the payment type if invalid etc.. I'm new to RSpec though, so there's probably a "better"/clearer/more efficient way of doing it. > 4.) Could you PLEASE PLEASE PLEASE guide me to a resource that helped > you the most with figuring out Unit Testing with RSpec. Not limited to > books or blog posts... good source code examples might be helpful. Why not use BDD? =) http://blog.davidchelimsky.net/articles/2007/05/14/an-introduction-to-rspec-part-i http://blog.davidchelimsky.net/articles/2006/11/06/view-spec-tutorial http://blog.withoutincident.com/2007/5/29/blogification-part-ii-rspec-bdd-and-authors > Hopefully you can see my sincere want to know more and I wish that a > simple "want" will blossom into a realization of a "need" to test test > test. Just search, read, try, and ask. > Thanks for any help you can provide me on my journey - I have a long > way > ahead of me. That doesn't answer all of your questions directly, but hopefully it'll be helpful in one way or another. Cheers, Nick From matt at mattwynne.net Wed Aug 27 14:40:12 2008 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 27 Aug 2008 19:40:12 +0100 Subject: [rspec-users] Four Question From an RSpec Baby - Give me something to chew In-Reply-To: <2E9509B7-BA5C-4DBC-B76A-D6F5DC1C856D@deadorange.com> References: <2E9509B7-BA5C-4DBC-B76A-D6F5DC1C856D@deadorange.com> Message-ID: <13FC9A63-3EC6-4792-8BE2-1C847DB4B5D2@mattwynne.net> I have another, more general tip - read this book: http://www.amazon.com/Working-Effectively-Legacy-Robert-Martin/dp/ 0131177052 Michael's definition of Legacy Code is simply 'code that isn't covered by tests'. So... err... that would be your whole app! The book suggests chipping away at the lack of test coverage by writing tests (or specs) when you - change code to add a feature - need to fix a bug (write a test / spec that fails because of the bug... fix the bug... high five) So rather than trying to tackle all 1000 lines of you user model at once, you have some practical motivation. This is also a great habit to get into for future work. Working with legacy code is particularly tricky as it may be hard to test, since it wasn't written with testing in mind. The book has some great guidance in the techniques you can use to introduce 'seams' between parts of the code that you'll need to test in isolation. cheers, Matt ---- http://blog.mattwynne.net http://songkick.com In case you wondered: The opinions expressed in this email are my own and do not necessarily reflect the views of any former, current or future employers of mine. On 27 Aug 2008, at 19:25, Nick Hoffman wrote: > On 2008-08-27, at 13:20, Lake Denman wrote: >> For a visual guide: >> def upgrade(payment) >> transaction do >> payment.user_id = self.id >> payment.payment_type = Payment::SUBSCRIPTION_PAYMENT_TYPE >> return false unless (payment.save and payment.external_id) >> self.subscription_id = payment.external_id >> self.payment_id = payment.id >> self.member = true >> self.member_since = AppLib.today_utc >> self.save >> return true >> end >> end > > > Hi Lake. > >> 1.) Do I need to use any mocking/stubbing in this example (or in Unit >> Tests) > > You need to use whatever you think is most suitable for your > application. I'm sure many people on here would use mocks and stubs > extensively throughout that method. For example, they might mock > the entire "payment" object, and stub out AppLib.today_utc . > >> 2.) Is it wrong to access multiple objects (user and payment in my >> example) in a Unit Test example? > > I don't think so, but I'm not a unit test expert. > >> 3.) Would you mind showing me an example of how you might implement a >> spec for this method. > > User upgrade > - can succeed if the payment amount is correct > - fails if the payment amount is incorrect > - can succeed if the payment type is valid > - fails if the payment type if invalid > etc.. > > I'm new to RSpec though, so there's probably a "better"/clearer/ > more efficient way of doing it. > >> 4.) Could you PLEASE PLEASE PLEASE guide me to a resource that helped >> you the most with figuring out Unit Testing with RSpec. Not >> limited to >> books or blog posts... good source code examples might be helpful. > > Why not use BDD? =) > http://blog.davidchelimsky.net/articles/2007/05/14/an-introduction- > to-rspec-part-i > http://blog.davidchelimsky.net/articles/2006/11/06/view-spec-tutorial > http://blog.withoutincident.com/2007/5/29/blogification-part-ii- > rspec-bdd-and-authors > >> Hopefully you can see my sincere want to know more and I wish that a >> simple "want" will blossom into a realization of a "need" to test >> test >> test. > > Just search, read, try, and ask. > >> Thanks for any help you can provide me on my journey - I have a >> long way >> ahead of me. > > That doesn't answer all of your questions directly, but hopefully > it'll be helpful in one way or another. Cheers, > Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Wed Aug 27 14:46:02 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 27 Aug 2008 13:46:02 -0500 Subject: [rspec-users] How much test data to use in specs In-Reply-To: References: <14C2F08B-4675-4AEC-9FEB-CAE74D74FEF9@madeofstone.net> <1EF0CC1B-7142-44CA-B92B-E29FAFE5FD7B@mattwynne.net> <0375912D-4B5C-47F8-A18D-962BDD00C7C2@madeofstone.net> Message-ID: <57c63afe0808271146i7f6a4b55l87621238c94a0241@mail.gmail.com> On Wed, Aug 27, 2008 at 1:03 PM, Nick Hoffman wrote: > On 2008-08-27, at 12:57, Rahoul Baruah wrote: > >> For this, trivial, example, I find that far too verbose. >> >> The "specification" says "if it is less than 2 characters then invalid" >> and "if it is more than 128 characters then invalid" . >> >> But you are actually running three checks - "if less than 2", "if greater >> than 2 but less than 128" and "if greater than 2 and greater than 128". >> >> B >> >> >> Rahoul Baruah >> > > This is what I ended up with: > > Property addresses that are valid > - can't be 129 characters > - can't have a 1-letter street name > - can't have an & > - can't have an ! > - can't have a " > - can't have 2 letters after the street number > - can't be missing a street number > - can't have only 3 characters > - can't be empty > - can have 128 characters > - can have 127 characters > - can have only 5 characters > - can have only 4 characters > - can have a , > - can have a - > - can have a ' > - can have 1 letter after the street number > - can have multiple spaces > > Each of the "can ..." examples are proper addresses in the sense that > they're variations of: > - "123 A Street With A Long Name" > - "123B Maple Ave" > - "123 O'Connor Street" > - etc > > One thing that I didn't do is write examples for each invalid character. > That'd be too hairy and verbose. Instead, I picked a few, and wrote examples > for them, as you can see above (Eg: "can't have an &"). If you want to (not necessarily advising this, but I've seen it done) you can do this: ['!','(',')','&'].each do |char| it "can't have #{char}" do ... end end That makes the output very verbose, but the spec file is easy to grok. > > > Cheers, > Nick > _______________________________________________ > 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 Aug 27 14:46:09 2008 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 27 Aug 2008 14:46:09 -0400 Subject: [rspec-users] Four Question From an RSpec Baby - Give me something to chew In-Reply-To: References: Message-ID: <810a540e0808271146l2dbbe05cu37a67a2cb4241a5@mail.gmail.com> On Wed, Aug 27, 2008 at 1:20 PM, Lake Denman wrote: > The project has been written - around 10,000 lines of code, but > certainly less than that to add tests to. There has been no official > testing put into place, and I'd very much like to implement RSpec into > the project for a few reasons, but mostly to setup solid examples for > the behavior of the application. > > It was suggested to me to begin with Unit Tests. The User Model is > almost 1000 lines with plenty of methods and no coverage, so I figured I > would start there. After installing Rcov to track my progress, I wrote > about 10 passing examples that were, I guess, pretty trivial - the > methods I tested all dealt directly with an "instantiated user > object"(is that the correct terminology?). When trying to get a large, existing code base under test, I think it's more valuable to begin with some very high-level tests that cover a lot of ground. Basically, you're going for "something broke" rather than "this specific thing broke" with these. As time goes on and you develop high functional coverage over the code, you can write more focused tests that will alert you to specific breakages. Also, keep in mind that one of the primary benefits of unit testing is as a design tool. When you're retrofitting tests, you don't get that benefit (except for the frequent cases where you go "gosh, this design sucks!") However, taking a couple weeks off to write exhaustive tests for your code base is basically never feasible. So you have to make tradeoffs. The simplest approach is to write tests to cover any code that you're changing. You'll need to spend some extra time and mental energy analyzing the various pathways, because the code you're changing has dependencies, and there are other dependencies on the code you're change, all of which you have to discover and account for. "Working Effectively with Legacy Code" by Michael Feathers has great information on this. So start off with high-level tests to maximize your value. At this point, that means being alerted to regressions. The lowest level you should probably go is controller tests...set up some state, hit the action, verify that the leftover state is what you expect. Writing even higher level tests with Cucumber would be an even better idea, I think. It covers more of the stack and lets you actually take pathways through the application. Actually now that I think about it, a combo of acceptance tests and controller specs would probably be best. Acceptance tests for happy paths, controller specs for testing other paths at a slightly lower level. > I have been writing the user examples in the order that a real user > might usually take (A User who: is activating his account, is logging > in, forgets his password and resets it, wants to use a new email > address, wants to change his username.) > > Now, I'm not sure of the next step in the process, I'm stuck! The method > (upgrade) takes a Payment object parameter. Inside the upgrade method, > some payment object attributes are set (user_id, payment_type) and then > saved. Then, the user object that is being upgraded has some attributes > that are set (payment_id, member, member_since) and finally the user is > saved, ending the method. And to top it all off, this method takes place > in a transaction. > > For a visual guide: > def upgrade(payment) > transaction do > payment.user_id = self.id > payment.payment_type = Payment::SUBSCRIPTION_PAYMENT_TYPE > return false unless (payment.save and payment.external_id) > self.subscription_id = payment.external_id > self.payment_id = payment.id > self.member = true > self.member_since = AppLib.today_utc > self.save > return true > end > end > > Now that you have sufficient back story (I hope), here are my questions: > > 1.) Do I need to use any mocking/stubbing in this example (or in Unit > Tests) Sure, you can. As I suggested above, you'll want to get some high-level functional coverage over the code you're changing. But then you can zoom in and write some unit tests for it...and using mock objects here will probably point out bad dependencies. > 2.) Is it wrong to access multiple objects (user and payment in my > example) in a Unit Test example? No > 3.) Would you mind showing me an example of how you might implement a > spec for this method. The ideal way is for the object to behave differently once changes have been made. But, in Rails, model objects often just shuffle data around and don't do anything particularly interesting. So the interesting visible behavior is actually in the UI, or at a lower level, the attributes on the models themselves. So for this spec you'd probably just want to run it and make sure that the attributes are what you expect them to be. Pretty easy, so I won't write an example :) > 4.) Could you PLEASE PLEASE PLEASE guide me to a resource that helped > you the most with figuring out Unit Testing with RSpec. Not limited to > books or blog posts... good source code examples might be helpful. http://blog.davidchelimsky.net/ is a good starting point. Read his articles, and then the blogs listed on the right side of the page. Check out the Webrat and Merb projects, all their code is RSpec'd Cheers, Pat From jonathan at parkerhill.com Wed Aug 27 14:55:30 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Wed, 27 Aug 2008 14:55:30 -0400 Subject: [rspec-users] How much test data to use in specs In-Reply-To: References: <14C2F08B-4675-4AEC-9FEB-CAE74D74FEF9@madeofstone.net> <1EF0CC1B-7142-44CA-B92B-E29FAFE5FD7B@mattwynne.net> <0375912D-4B5C-47F8-A18D-962BDD00C7C2@madeofstone.net> Message-ID: <30CC04D7-4BBA-4A3F-886F-B11FC6002C2D@parkerhill.com> what if my office were at Route 102 & Yahoo! Way, Suite #123 :) On Aug 27, 2008, at 2:03 PM, Nick Hoffman wrote: > On 2008-08-27, at 12:57, Rahoul Baruah wrote: >> For this, trivial, example, I find that far too verbose. >> >> The "specification" says "if it is less than 2 characters then >> invalid" and "if it is more than 128 characters then invalid" . >> >> But you are actually running three checks - "if less than 2", "if >> greater than 2 but less than 128" and "if greater than 2 and >> greater than 128". >> >> B >> >> >> Rahoul Baruah > > This is what I ended up with: > > Property addresses that are valid > - can't be 129 characters > - can't have a 1-letter street name > - can't have an & > - can't have an ! > - can't have a " > - can't have 2 letters after the street number > - can't be missing a street number > - can't have only 3 characters > - can't be empty > - can have 128 characters > - can have 127 characters > - can have only 5 characters > - can have only 4 characters > - can have a , > - can have a - > - can have a ' > - can have 1 letter after the street number > - can have multiple spaces > > Each of the "can ..." examples are proper addresses in the sense > that they're variations of: > - "123 A Street With A Long Name" > - "123B Maple Ave" > - "123 O'Connor Street" > - etc > > One thing that I didn't do is write examples for each invalid > character. That'd be too hairy and verbose. Instead, I picked a > few, and wrote examples for them, as you can see above (Eg: "can't > have an &"). > > Cheers, > Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Wed Aug 27 14:58:18 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 27 Aug 2008 20:58:18 +0200 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <85cbdebfbc8e3a616f6fe032c5eb6ef7@ruby-forum.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <48AC4548.90201@benmabey.com> <8d961d900808202358x18a7834bgb1270759affe28f9@mail.gmail.com> <85cbdebfbc8e3a616f6fe032c5eb6ef7@ruby-forum.com> Message-ID: <8d961d900808271158p1afc789dv3a91cb06cc07bdb@mail.gmail.com> On Thu, Aug 21, 2008 at 6:08 PM, Joseph Wilk wrote: > Hello, > > I've been looking through the cucumber documentation and have a couple > of questions. > Hi, Sorry for the late reply, > I'm curious which of the disadvantages you list would be impossible/very > difficult in the classic story runner. I'm just trying to envisage if >From http://github.com/aslakhellesoy/cucumber/wikis - 10 means big effort, 1 small. Relatively. Your opinion may differ. 5: Hard to get started with. A special "all.rb" file must be written before it can be used. 3: No out of the box Rake support, which puts a lot of people off. 3: No i18n, so if you want to write stories in a different language than English you're out of luck. 8: Poor error reporting. No way to know on what line a plain text story failed during execution or parsing. 1: Limited colouring of output. 5: No simple way to execute only one scenario. 8: No command line tool to run stories. 2: No easy before or after hooks. 5: No highlighting of step parameters in the output 2: No detection of ambiguous step names > Cucumber and the classic story runner where to co-exist what would the > Cucumber plugin be able to do that the classic story runner could never I assume that by plugin you mean Rails plugin? (Cucumber is a standalone library that *may* be used as a Rails plugin). > realistically hope to achieve. > The Story runner could achieve this if someone put enough effort into it. That would have to be someone other than me, because I don't have the time (or desire) to do it. Let's say it's up for grabs. > Also looking at one of your disadvantages: > * 'Limited colouring of output' > I've been playing around with patches here and there to improve the > colour of the classic story runner formatters. Do you still see > limitations in this as it is in edge? > That's one of the easiest things to fix, and also one of the smallest disadvantages IMO. > My final question is about the Rspec book. I've no idea when this will > be released or what pressures there are on publish deadlines. How much > would this effect a move to Cucumber (avoiding having redundant story > examples in the book when we all use Cucumber)? > Regarding the book - we haven't decided whether or not to cover Cucumber. In any case, *writing* stories/features for the Story runner will be almost identical to Cucumber features. On Tuesday I ported one of our projects at work over to Cucumber. Over 1000 steps. I ended up having to change almost nothing in the text or step defs (except for resolving some duplicates and ambiguities that Cucumber complains about where RSR says nothing). I have written up what I did and will post it to the Cucumber wiki next week when I have some time to proofread it. Cheers, Aslak > Thanks, > -- > Joseph Wilk > http://www.joesniff.co.uk > aslak hellesoy wrote: >> On Wed, Aug 20, 2008 at 6:24 PM, Ben Mabey wrote: >>>> * How to use without Rails >>> wiki be better? >>> >> >> Good idea, I have moved the README.textile to >> http://github.com/aslakhellesoy/cucumber/wikis/home >> >> Everyone here is welcome to edit it. If you have concrete experience >> (or wishes) about how to migrate existing stories to Cucumber this >> would be the place to do it. >> >> Aslak > > -- > 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 Wed Aug 27 15:05:28 2008 From: nick at deadorange.com (Nick Hoffman) Date: Wed, 27 Aug 2008 15:05:28 -0400 Subject: [rspec-users] How much test data to use in specs In-Reply-To: <30CC04D7-4BBA-4A3F-886F-B11FC6002C2D@parkerhill.com> References: <14C2F08B-4675-4AEC-9FEB-CAE74D74FEF9@madeofstone.net> <1EF0CC1B-7142-44CA-B92B-E29FAFE5FD7B@mattwynne.net> <0375912D-4B5C-47F8-A18D-962BDD00C7C2@madeofstone.net> <30CC04D7-4BBA-4A3F-886F-B11FC6002C2D@parkerhill.com> Message-ID: On 2008-08-27, at 14:55, Jonathan Linowes wrote: > what if my office were at > > Route 102 & Yahoo! Way, Suite #123 > > :) Good point. Thinking about it again, there's probably not all that much need to prevent addresses from having symbols such as !, &, ", etc. If people really want to put them in, why not? Does your office actually not have a proper street number? -Nick From cremes.devlist at mac.com Wed Aug 27 15:06:49 2008 From: cremes.devlist at mac.com (Chuck Remes) Date: Wed, 27 Aug 2008 14:06:49 -0500 Subject: [rspec-users] How much test data to use in specs In-Reply-To: <30CC04D7-4BBA-4A3F-886F-B11FC6002C2D@parkerhill.com> References: <14C2F08B-4675-4AEC-9FEB-CAE74D74FEF9@madeofstone.net> <1EF0CC1B-7142-44CA-B92B-E29FAFE5FD7B@mattwynne.net> <0375912D-4B5C-47F8-A18D-962BDD00C7C2@madeofstone.net> <30CC04D7-4BBA-4A3F-886F-B11FC6002C2D@parkerhill.com> Message-ID: We'd recommend that you start sending our your resum?. :) cr On Aug 27, 2008, at 1:55 PM, Jonathan Linowes wrote: > what if my office were at > > Route 102 & Yahoo! Way, Suite #123 > > :) > > > On Aug 27, 2008, at 2:03 PM, Nick Hoffman wrote: > >> On 2008-08-27, at 12:57, Rahoul Baruah wrote: >>> For this, trivial, example, I find that far too verbose. >>> >>> The "specification" says "if it is less than 2 characters then >>> invalid" and "if it is more than 128 characters then invalid" . >>> >>> But you are actually running three checks - "if less than 2", "if >>> greater than 2 but less than 128" and "if greater than 2 and >>> greater than 128". >>> >>> B >>> >>> >>> Rahoul Baruah >> >> This is what I ended up with: >> >> Property addresses that are valid >> - can't be 129 characters >> - can't have a 1-letter street name >> - can't have an & >> - can't have an ! >> - can't have a " >> - can't have 2 letters after the street number >> - can't be missing a street number >> - can't have only 3 characters >> - can't be empty >> - can have 128 characters >> - can have 127 characters >> - can have only 5 characters >> - can have only 4 characters >> - can have a , >> - can have a - >> - can have a ' >> - can have 1 letter after the street number >> - can have multiple spaces From nick at deadorange.com Wed Aug 27 15:24:35 2008 From: nick at deadorange.com (Nick Hoffman) Date: Wed, 27 Aug 2008 15:24:35 -0400 Subject: [rspec-users] How much test data to use in specs In-Reply-To: <57c63afe0808271146i7f6a4b55l87621238c94a0241@mail.gmail.com> References: <14C2F08B-4675-4AEC-9FEB-CAE74D74FEF9@madeofstone.net> <1EF0CC1B-7142-44CA-B92B-E29FAFE5FD7B@mattwynne.net> <0375912D-4B5C-47F8-A18D-962BDD00C7C2@madeofstone.net> <57c63afe0808271146i7f6a4b55l87621238c94a0241@mail.gmail.com> Message-ID: On 2008-08-27, at 14:46, David Chelimsky wrote: > If you want to (not necessarily advising this, but I've seen it > done) you can do this: > > ['!','(',')','&'].each do |char| > it "can't have #{char}" do > ... > end > end > > That makes the output very verbose, but the spec file is easy to grok. Hi David. I ended up creating valid and invalid test data, as well as a method to iterate over them and write the descriptions and examples for me. You can have a look at it at http://pastie.org/261175 . If you have any suggestions for improvements, I'd love to hear them. Cheers, Nick From mark at mwilden.com Wed Aug 27 15:25:01 2008 From: mark at mwilden.com (Mark Wilden) Date: Wed, 27 Aug 2008 12:25:01 -0700 Subject: [rspec-users] Four Question From an RSpec Baby - Give me something to chew In-Reply-To: References: Message-ID: <3c30da400808271225s50a3fb4bv802f150991332275@mail.gmail.com> On Wed, Aug 27, 2008 at 10:20 AM, Lake Denman wrote: > def upgrade(payment) > transaction do > payment.user_id = self.id > payment.payment_type = Payment::SUBSCRIPTION_PAYMENT_TYPE > return false unless (payment.save and payment.external_id) > self.subscription_id = payment.external_id > self.payment_id = payment.id > self.member = true > self.member_since = AppLib.today_utc > self.save > return true > end > end > > 2.) Is it wrong to access multiple objects (user and payment in my > example) in a Unit Test example? > I'll disagree with Pat and say yes (in general). A unit test/spec should exercise a unit, which I usually consider to end at the class boundary. For example, this code relies on Payment#save being correct. If it's buggy (or doesn't exist), a spec of this User method could very well fail, even if there is nothing wrong with the payment method. That's not a unit test, in my view. I would mock out the payment in a spec for this method to ensure that save and external_id are called, but not rely on them being correct (or even existing). In a spec for Payment#save, I would make sure that it sets external_id correctly (if that's what it's supposed to do). The combination of the two specs would be enough (in my view) to document and test the behavior of these classes. I won't rattle on about the benefits of unit tests, other than to say that by testing only one unit at a time, you reduce the odds of that horrible moment when you change one line of code and 36 tests in 18 other spec files fail. All that said, pragmatism trumps purity, and if you're willing to spec two "units" in one "unit test," and it makes your life easier to do so, then go for it. :) The other thing I would say is that mocking and stubbing are powerful tools that you should add to your arsenal as soon as possible. I've had several coworkers who resisted using them, only to finally achieve that "aha!" moment later. Your tests get easier to write, and they're less brittle to change. I might add that I learned much of this from working on a prior codebase of Pat's. That doesn't mean I couldn't have got it all wrong, of course. :) ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at deadorange.com Wed Aug 27 15:27:41 2008 From: nick at deadorange.com (Nick Hoffman) Date: Wed, 27 Aug 2008 15:27:41 -0400 Subject: [rspec-users] How much test data to use in specs In-Reply-To: References: <14C2F08B-4675-4AEC-9FEB-CAE74D74FEF9@madeofstone.net> <1EF0CC1B-7142-44CA-B92B-E29FAFE5FD7B@mattwynne.net> <0375912D-4B5C-47F8-A18D-962BDD00C7C2@madeofstone.net> <57c63afe0808271146i7f6a4b55l87621238c94a0241@mail.gmail.com> Message-ID: <2F13DA98-7BBB-46EA-A605-75CD2FE857B8@deadorange.com> On 2008-08-27, at 15:24, Nick Hoffman wrote: > Hi David. I ended up creating valid and invalid test data, as well > as a method to iterate over them and write the descriptions and > examples for me. You can have a look at it at http://pastie.org/ > 261175 . If you have any suggestions for improvements, I'd love to > hear them. > > Cheers, > Nick I forgot to mention that I'm using the "factories-and-workers" plugin: http://github.com/dfl/factories-and-workers/ which provides the the "build_property" method. From mark at mwilden.com Wed Aug 27 15:28:21 2008 From: mark at mwilden.com (Mark Wilden) Date: Wed, 27 Aug 2008 12:28:21 -0700 Subject: [rspec-users] How much test data to use in specs In-Reply-To: References: <14C2F08B-4675-4AEC-9FEB-CAE74D74FEF9@madeofstone.net> <1EF0CC1B-7142-44CA-B92B-E29FAFE5FD7B@mattwynne.net> <0375912D-4B5C-47F8-A18D-962BDD00C7C2@madeofstone.net> <30CC04D7-4BBA-4A3F-886F-B11FC6002C2D@parkerhill.com> Message-ID: <3c30da400808271228j74d923c7p37e16822bf285ada@mail.gmail.com> On Wed, Aug 27, 2008 at 12:05 PM, Nick Hoffman wrote: > On 2008-08-27, at 14:55, Jonathan Linowes wrote: > >> what if my office were at >> >> Route 102 & Yahoo! Way, Suite #123 >> >> :) >> > > Good point. Thinking about it again, there's probably not all that much > need to prevent addresses from having symbols such as !, &, ", etc. If > people really want to put them in, why not? > Validation isn't just about preventing users from doing things they want to do - it's also to prevent errors. At any rate, what consitutes a valid address is a business rule, and isn't a programming issue. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at deadorange.com Wed Aug 27 15:38:28 2008 From: nick at deadorange.com (Nick Hoffman) Date: Wed, 27 Aug 2008 15:38:28 -0400 Subject: [rspec-users] Application-wide spec_helper method Message-ID: <9C60741D-BEE4-4A9B-9DFA-F32BF134759D@deadorange.com> If a helper method can be used for multiple model specs, obviously it should not be placed within a specific model's spec helper file. Is there a recommended file in which to put such a method? Maybe spec/ helpers/application_helper_spec.rb ? -Nick From avdi at avdi.org Wed Aug 27 16:49:40 2008 From: avdi at avdi.org (Avdi Grimm) Date: Wed, 27 Aug 2008 16:49:40 -0400 Subject: [rspec-users] Four Question From an RSpec Baby - Give me something to chew In-Reply-To: References: Message-ID: I'll just second the other suggestions of a) getting some high-level integration tests over the app; b) doing the detailed specs just-in-time when you need to make a change; and c) reading Michael Feathers' book. I've been in the same position, and the above three points helped a lot. -- Avdi Home: http://avdi.org Developer Blog: http://avdi.org/devblog/ Twitter: http://twitter.com/avdi Journal: http://avdi.livejournal.com From lists at ruby-forum.com Wed Aug 27 20:44:23 2008 From: lists at ruby-forum.com (aa aa) Date: Thu, 28 Aug 2008 02:44:23 +0200 Subject: [rspec-users] story runner not running on build machine In-Reply-To: <57c63afe0808270536o716a87ffy98475f51e7a2d6e2@mail.gmail.com> References: <474ca3b709afe109c841899b3ee09da6@ruby-forum.com> <57c63afe0808270536o716a87ffy98475f51e7a2d6e2@mail.gmail.com> Message-ID: <688d1203e1f4844a625b637b249a99fa@ruby-forum.com> David Chelimsky wrote: > On Wed, Aug 27, 2008 at 4:42 AM, aa aa wrote: >> It doesn't seem to be loading the plugin does it? > Are you using git for your project? No, we are using subversion and i used the script/install command which strips out the git dirs anyway doesn't it? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Aug 27 20:45:05 2008 From: lists at ruby-forum.com (aa aa) Date: Thu, 28 Aug 2008 02:45:05 +0200 Subject: [rspec-users] story runner not running on build machine In-Reply-To: <688d1203e1f4844a625b637b249a99fa@ruby-forum.com> References: <474ca3b709afe109c841899b3ee09da6@ruby-forum.com> <57c63afe0808270536o716a87ffy98475f51e7a2d6e2@mail.gmail.com> <688d1203e1f4844a625b637b249a99fa@ruby-forum.com> Message-ID: <90ad2cc47a666ddc714c6e3d1999ad26@ruby-forum.com> aa aa wrote: > No, we are using subversion and i used the script/install command which of course, i meant > script/plugin install whoops -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Wed Aug 27 23:18:03 2008 From: ben at benmabey.com (Ben Mabey) Date: Wed, 27 Aug 2008 21:18:03 -0600 Subject: [rspec-users] story runner not running on build machine In-Reply-To: <474ca3b709afe109c841899b3ee09da6@ruby-forum.com> References: <474ca3b709afe109c841899b3ee09da6@ruby-forum.com> Message-ID: <48B618EB.3080501@benmabey.com> aa aa wrote: > Hi, have my stories running fine here on my dev machine but they blow up > on the build machine. Rspec and Rspec-rails are installed as plugins > > When i attempt to run > >> ruby stories/all.rb >> > on the dev server i get this error > stories/steps/fields_steps.rb:1: undefined method `steps_for' for > main:Object (NoMethodError) > > what is going on here?! > It doesn't seem to be loading the plugin does it? > Please post a runner file, your spec helper, and a steps file. -Ben From mailing_lists at railsnewbie.com Wed Aug 27 23:46:03 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 27 Aug 2008 23:46:03 -0400 Subject: [rspec-users] Four Question From an RSpec Baby - Give me something to chew In-Reply-To: <13FC9A63-3EC6-4792-8BE2-1C847DB4B5D2@mattwynne.net> References: <2E9509B7-BA5C-4DBC-B76A-D6F5DC1C856D@deadorange.com> <13FC9A63-3EC6-4792-8BE2-1C847DB4B5D2@mattwynne.net> Message-ID: On Aug 27, 2008, at 2:40 PM, Matt Wynne wrote: > I have another, more general tip - read this book: > http://www.amazon.com/Working-Effectively-Legacy-Robert-Martin/dp/0131177052 > > Michael's definition of Legacy Code is simply 'code that isn't > covered by tests'. So... err... that would be your whole app! Well - I think it was zenspider who said legacy code is code either: 1) you didn't write, or 2) you didn't *just* write 20 minutes ago. There is something to it. > > > The book suggests chipping away at the lack of test coverage by > writing tests (or specs) when you > - change code to add a feature > - need to fix a bug (write a test / spec that fails because of the > bug... fix the bug... high five) +1 With my last job, I inherited an 8000 line rails code base with 30 Test::Unit tests, 25 of which were failing. I decided to delete those, and start a fresh with test suite (under rspec, of course). Over a few months, without ever going out of my way to write specs for legacy code, I had over over 80% coverage (if I remember correctly). Just chip away as you would normally, and sooner or later the crap code gets replaced. Don't get overwhelmed by rcov. Just write specs for everything *you* write, and write specs for anything else you touch. Especially regressions. Usually you can get in a few extra specs when writing a regression that has nothing to do with the bug itself (it's a sort of testing after the fact - almost like proving theorems of an existing system). Honestly, you won't have time to write new specs - it's frustrating / painful to write specs *after* code, and so it doesn't usually get done (since it's not any fun). Just chip away gradually and you'll get there eventually. If you're really eager to go off and write extra specs, just write really clear specs and then show the HTML specdocs to your boss - he'll probably appreciate it, especially if formal specs hadn't been drafted up previously. Scott From matt at mattwynne.net Thu Aug 28 02:54:15 2008 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 28 Aug 2008 07:54:15 +0100 Subject: [rspec-users] Four Question From an RSpec Baby - Give me something to chew In-Reply-To: References: <2E9509B7-BA5C-4DBC-B76A-D6F5DC1C856D@deadorange.com> <13FC9A63-3EC6-4792-8BE2-1C847DB4B5D2@mattwynne.net> Message-ID: <1FDDC4DC-9A9E-427B-8FD6-1A0AA2F2CB8C@mattwynne.net> On 28 Aug 2008, at 04:46, Scott Taylor wrote: > Especially regressions. Usually you can get in a few extra specs > when writing a regression that has nothing to do with the bug > itself (it's a sort of testing after the fact - almost like proving > theorems of an existing system). The Feathers book talks about writing tests in this situation almost the way a scientist might perform experiments on a mysterious chemical to try and determine its properties - writing tests to validate the assumptions you're making about the behaviour of the class as you read the code and try to understand it. Writing executable specs as you do this obviously leaves your team a lot better off in the long run than if you just dived in there, figured it out, made your change and scarpered. From lists at ruby-forum.com Thu Aug 28 03:39:06 2008 From: lists at ruby-forum.com (aa aa) Date: Thu, 28 Aug 2008 09:39:06 +0200 Subject: [rspec-users] story runner not running on build machine In-Reply-To: <48B618EB.3080501@benmabey.com> References: <474ca3b709afe109c841899b3ee09da6@ruby-forum.com> <48B618EB.3080501@benmabey.com> Message-ID: Ben Mabey wrote: > aa aa wrote: >> >> what is going on here?! >> It doesn't seem to be loading the plugin does it? >> > Please post a runner file, your spec helper, and a steps file. > > -Ben odd, i changed the line in the all.rb from >Dir[File.expand_path("#{dir}/**/*.rb")].uniq.each do |file| to >Dir[File.expand_path("#{dir}/*.rb")].uniq.each do |file| and it worked.... -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu Aug 28 08:02:39 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 28 Aug 2008 07:02:39 -0500 Subject: [rspec-users] Application-wide spec_helper method In-Reply-To: <9C60741D-BEE4-4A9B-9DFA-F32BF134759D@deadorange.com> References: <9C60741D-BEE4-4A9B-9DFA-F32BF134759D@deadorange.com> Message-ID: <57c63afe0808280502g6fc2ccf0r57d939167ad0ccb6@mail.gmail.com> On Wed, Aug 27, 2008 at 2:38 PM, Nick Hoffman wrote: > If a helper method can be used for multiple model specs, obviously it should > not be placed within a specific model's spec helper file. Is there a > recommended file in which to put such a method? Maybe > spec/helpers/application_helper_spec.rb ? This is a very confusing question. Model's don't typically get individual spec helper files, so I'm not sure what you're getting at. Can you give an example? From dchelimsky at gmail.com Thu Aug 28 08:31:30 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 28 Aug 2008 07:31:30 -0500 Subject: [rspec-users] How much test data to use in specs In-Reply-To: References: <14C2F08B-4675-4AEC-9FEB-CAE74D74FEF9@madeofstone.net> <1EF0CC1B-7142-44CA-B92B-E29FAFE5FD7B@mattwynne.net> <0375912D-4B5C-47F8-A18D-962BDD00C7C2@madeofstone.net> <57c63afe0808271146i7f6a4b55l87621238c94a0241@mail.gmail.com> Message-ID: <57c63afe0808280531q3f7abf60q601c7c071fc15a9e@mail.gmail.com> On Wed, Aug 27, 2008 at 2:24 PM, Nick Hoffman wrote: > On 2008-08-27, at 14:46, David Chelimsky wrote: >> >> If you want to (not necessarily advising this, but I've seen it done) you >> can do this: >> >> ['!','(',')','&'].each do |char| >> it "can't have #{char}" do >> ... >> end >> end >> >> That makes the output very verbose, but the spec file is easy to grok. > > Hi David. I ended up creating valid and invalid test data, as well as a > method to iterate over them and write the descriptions and examples for me. > You can have a look at it at http://pastie.org/261175 . If you have any > suggestions for improvements, I'd love to hear them. Hey Nick, I can definitely see some value in this, though there are a few things that I'd do differently. Have a look at http://pastie.org/261642 and let me know if you have any questions/comments. The only thing I'm not sure about is the actual method name - it's not speaking to me, but I'm at a loss for a better one. Maybe after some coffee ... Cheers, David > > Cheers, > Nick From zach.dennis at gmail.com Thu Aug 28 08:53:31 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 28 Aug 2008 08:53:31 -0400 Subject: [rspec-users] story runner not running on build machine In-Reply-To: References: <474ca3b709afe109c841899b3ee09da6@ruby-forum.com> <48B618EB.3080501@benmabey.com> Message-ID: <85d99afe0808280553i4ba7274dv6f758d69e377f922@mail.gmail.com> On Thu, Aug 28, 2008 at 3:39 AM, aa aa wrote: > Ben Mabey wrote: >> aa aa wrote: >>> >>> what is going on here?! >>> It doesn't seem to be loading the plugin does it? >>> >> Please post a runner file, your spec helper, and a steps file. >> >> -Ben > > odd, i changed the line in the all.rb from >>Dir[File.expand_path("#{dir}/**/*.rb")].uniq.each do |file| > to >>Dir[File.expand_path("#{dir}/*.rb")].uniq.each do |file| > > and it worked.... That will only load .rb files that are in the same directory as the all.rb file. So it won't load things like stories/foo/thingy.rb or stories/foo/blah/thingy.rb. My guess is that is not what you want.This is assuming your all.rb file looked like: dir = File.dirname(__FILE__) Dir[File.expand_path("#{dir}/**/*.rb")].uniq.each do |file| require file end -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From aidy.lewis at googlemail.com Thu Aug 28 09:22:45 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Thu, 28 Aug 2008 14:22:45 +0100 Subject: [rspec-users] error paths: a new scenerio or test in story runner? Message-ID: <7ac2300c0808280622p6de97a8na95a1372c41417d7@mail.gmail.com> Hi, I think the scenario based way of defining acceptance tests is akin to scenarios in use-cases. In use-cases we can have a happy path with extends for error conditions etc. Should I create extra scenarios for my error conditions (making my tests less understandable) or should I create a new error path story with copied over scenarios Aidy From dchelimsky at gmail.com Thu Aug 28 10:09:53 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 28 Aug 2008 09:09:53 -0500 Subject: [rspec-users] error paths: a new scenerio or test in story runner? In-Reply-To: <7ac2300c0808280622p6de97a8na95a1372c41417d7@mail.gmail.com> References: <7ac2300c0808280622p6de97a8na95a1372c41417d7@mail.gmail.com> Message-ID: <57c63afe0808280709x24a55453m2f2bb3a359d7658f@mail.gmail.com> On Thu, Aug 28, 2008 at 8:22 AM, aidy lewis wrote: > Hi, > > I think the scenario based way of defining acceptance tests is akin to > scenarios in use-cases. > > In use-cases we can have a happy path with extends for error conditions etc. > > Should I create extra scenarios for my error conditions (making my > tests less understandable) or should I create a new error path story > with copied over scenarios This was something that was bugging me for a while. I used to work w/ Fitnesse quite a bit. If you're not familiar, check out http://fitnesse.org. FIT (the underlying acceptance test framework in FitNesse) is fantastic for tabular data, but it wasn't really great at scenario/flow-oriented structure. Rick Mugridge's DoFixture opened the door to some great improvements, and it was the best we had so far at that point, but it still felt like the square peg/round hole problem to me. Along came rbehave (which is now RSpec's Story Runner) from Dan North, and it was a great solution to the flow-structure problem (for me). Readabilty, clarity, simplicity, etc, etc. But then I ran into the same question you're asking now. In the end, FIT tables are a great solution for tabular data (which is a good solution for expressing numerous edge cases) and Story Runner is a great solution for flow structures. So I had this idea that we should have a way of expressing tabular data in the context of the Story Runner. When I discussed this w/ Aslak, it turns out that he had been thinking about the same problem, so we had a little brainstorming session and arrived at a general direction. Then he actually implemented it in Cucumber, and it's awesome. That said, I'd recommend taking a look at Cucumber. Let us know what you think. Cheers, David > > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aidy.lewis at googlemail.com Thu Aug 28 11:38:45 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Thu, 28 Aug 2008 16:38:45 +0100 Subject: [rspec-users] error paths: a new scenerio or test in story runner? In-Reply-To: <57c63afe0808280709x24a55453m2f2bb3a359d7658f@mail.gmail.com> References: <7ac2300c0808280622p6de97a8na95a1372c41417d7@mail.gmail.com> <57c63afe0808280709x24a55453m2f2bb3a359d7658f@mail.gmail.com> Message-ID: <7ac2300c0808280838h2792405dle1205b19cfe49dd7@mail.gmail.com> Hi David, On 28/08/2008, David Chelimsky wrote: > On Thu, Aug 28, 2008 at 8:22 AM, aidy lewis wrote: > > Hi, > > > > I think the scenario based way of defining acceptance tests is akin to > > scenarios in use-cases. > > > > In use-cases we can have a happy path with extends for error conditions etc. > > > > Should I create extra scenarios for my error conditions (making my > > tests less understandable) or should I create a new error path story > > with copied over scenarios > > > This was something that was bugging me for a while. I used to work w/ > Fitnesse quite a bit. If you're not familiar, check out > http://fitnesse.org. FIT (the underlying acceptance test framework in > FitNesse) is fantastic for tabular data, but it wasn't really great at > scenario/flow-oriented structure. Rick Mugridge's DoFixture opened the > door to some great improvements, and it was the best we had so far at > that point, but it still felt like the square peg/round hole problem > to me. Users see and convey things in a natural flow not in a tabular format: Bill payments are good in a horizontal and vertical structure. For UI testing FIT gets messy. > But then I ran into the same question you're asking now. In the end, > FIT tables are a great solution for tabular data (which is a good > solution for expressing numerous edge cases) and Story Runner is a > great solution for flow structures. So I had this idea that we should > have a way of expressing tabular data in the context of the Story > Runner. In my opinion, this will effect the linguistics of the Story Runner; but I offer no alternative. > > When I discussed this w/ Aslak, it turns out that he had been thinking > about the same problem, so we had a little brainstorming session and > arrived at a general direction. Then he actually implemented it in > Cucumber, and it's awesome. > > That said, I'd recommend taking a look at Cucumber. Let us know what you think. I am currently studying it. Aidy From nick at deadorange.com Thu Aug 28 12:37:51 2008 From: nick at deadorange.com (Nick Hoffman) Date: Thu, 28 Aug 2008 12:37:51 -0400 Subject: [rspec-users] How much test data to use in specs In-Reply-To: <57c63afe0808280531q3f7abf60q601c7c071fc15a9e@mail.gmail.com> References: <14C2F08B-4675-4AEC-9FEB-CAE74D74FEF9@madeofstone.net> <1EF0CC1B-7142-44CA-B92B-E29FAFE5FD7B@mattwynne.net> <0375912D-4B5C-47F8-A18D-962BDD00C7C2@madeofstone.net> <57c63afe0808271146i7f6a4b55l87621238c94a0241@mail.gmail.com> <57c63afe0808280531q3f7abf60q601c7c071fc15a9e@mail.gmail.com> Message-ID: On 2008-08-28, at 08:31, David Chelimsky wrote: > On Wed, Aug 27, 2008 at 2:24 PM, Nick Hoffman > wrote: >> On 2008-08-27, at 14:46, David Chelimsky wrote: >>> >>> If you want to (not necessarily advising this, but I've seen it >>> done) you >>> can do this: >>> >>> ['!','(',')','&'].each do |char| >>> it "can't have #{char}" do >>> ... >>> end >>> end >>> >>> That makes the output very verbose, but the spec file is easy to >>> grok. >> >> Hi David. I ended up creating valid and invalid test data, as well >> as a >> method to iterate over them and write the descriptions and examples >> for me. >> You can have a look at it at http://pastie.org/261175 . If you have >> any >> suggestions for improvements, I'd love to hear them. > > Hey Nick, > > I can definitely see some value in this, though there are a few things > that I'd do differently. Have a look at http://pastie.org/261642 and > let me know if you have any questions/comments. The only thing I'm not > sure about is the actual method name - it's not speaking to me, but > I'm at a loss for a better one. Maybe after some coffee ... > > Cheers, > David Thanks for taking a look and making some suggestions, David. Much appreciated. I've incorporated some of them into the method. The method's name was "describe_property_attributes" because it was being used to describe the Property (as in "real estate") model in my application. I've just finished abstracting it out so that it can now be used with any model class. If you're interested, I've pasted it at http://pastie.org/261829 From nick at deadorange.com Thu Aug 28 12:41:09 2008 From: nick at deadorange.com (Nick Hoffman) Date: Thu, 28 Aug 2008 12:41:09 -0400 Subject: [rspec-users] Application-wide spec_helper method In-Reply-To: <57c63afe0808280502g6fc2ccf0r57d939167ad0ccb6@mail.gmail.com> References: <9C60741D-BEE4-4A9B-9DFA-F32BF134759D@deadorange.com> <57c63afe0808280502g6fc2ccf0r57d939167ad0ccb6@mail.gmail.com> Message-ID: <3B4561D4-9743-49EC-8103-43FF40B69F2E@deadorange.com> On 2008-08-28, at 08:02, David Chelimsky wrote: > On Wed, Aug 27, 2008 at 2:38 PM, Nick Hoffman > wrote: >> If a helper method can be used for multiple model specs, obviously >> it should >> not be placed within a specific model's spec helper file. Is there a >> recommended file in which to put such a method? Maybe >> spec/helpers/application_helper_spec.rb ? > > This is a very confusing question. Model's don't typically get > individual spec helper files, so I'm not sure what you're getting at. > Can you give an example? I asked because I had begun to abstract my #describe_properties method away from the Property model so that it can be used with any model. Now that the method's been converted from this: http://pastie.org/261175 to this: http://pastie.org/261829 I'd like to use it with multiple models. Cheers, Nick From zach.dennis at gmail.com Thu Aug 28 13:27:33 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 28 Aug 2008 13:27:33 -0400 Subject: [rspec-users] Application-wide spec_helper method In-Reply-To: <3B4561D4-9743-49EC-8103-43FF40B69F2E@deadorange.com> References: <9C60741D-BEE4-4A9B-9DFA-F32BF134759D@deadorange.com> <57c63afe0808280502g6fc2ccf0r57d939167ad0ccb6@mail.gmail.com> <3B4561D4-9743-49EC-8103-43FF40B69F2E@deadorange.com> Message-ID: <85d99afe0808281027o78627c3aj6610a6eeab48cffd@mail.gmail.com> You can put it in a module and include it for model specs in spec_helper.rb Spec::Runner.configure do |config| # ... config.include DescribeModelAttributeSpecHelper, :type => :model end Zach On Thu, Aug 28, 2008 at 12:41 PM, Nick Hoffman wrote: > On 2008-08-28, at 08:02, David Chelimsky wrote: >> >> On Wed, Aug 27, 2008 at 2:38 PM, Nick Hoffman wrote: >>> >>> If a helper method can be used for multiple model specs, obviously it >>> should >>> not be placed within a specific model's spec helper file. Is there a >>> recommended file in which to put such a method? Maybe >>> spec/helpers/application_helper_spec.rb ? >> >> This is a very confusing question. Model's don't typically get >> individual spec helper files, so I'm not sure what you're getting at. >> Can you give an example? > > I asked because I had begun to abstract my #describe_properties method away > from the Property model so that it can be used with any model. Now that the > method's been converted from this: > http://pastie.org/261175 > to this: > http://pastie.org/261829 > I'd like to use it with multiple models. > > Cheers, > 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 dchelimsky at gmail.com Thu Aug 28 13:57:48 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 28 Aug 2008 12:57:48 -0500 Subject: [rspec-users] Application-wide spec_helper method In-Reply-To: <85d99afe0808281027o78627c3aj6610a6eeab48cffd@mail.gmail.com> References: <9C60741D-BEE4-4A9B-9DFA-F32BF134759D@deadorange.com> <57c63afe0808280502g6fc2ccf0r57d939167ad0ccb6@mail.gmail.com> <3B4561D4-9743-49EC-8103-43FF40B69F2E@deadorange.com> <85d99afe0808281027o78627c3aj6610a6eeab48cffd@mail.gmail.com> Message-ID: <57c63afe0808281057k13b2fc39w31b4cc3dddcffaa7@mail.gmail.com> On Thu, Aug 28, 2008 at 12:27 PM, Zach Dennis wrote: > You can put it in a module and include it for model specs in spec_helper.rb > > Spec::Runner.configure do |config| > # ... > config.include DescribeModelAttributeSpecHelper, :type => :model > end What he said. > > Zach > > On Thu, Aug 28, 2008 at 12:41 PM, Nick Hoffman wrote: >> On 2008-08-28, at 08:02, David Chelimsky wrote: >>> >>> On Wed, Aug 27, 2008 at 2:38 PM, Nick Hoffman wrote: >>>> >>>> If a helper method can be used for multiple model specs, obviously it >>>> should >>>> not be placed within a specific model's spec helper file. Is there a >>>> recommended file in which to put such a method? Maybe >>>> spec/helpers/application_helper_spec.rb ? >>> >>> This is a very confusing question. Model's don't typically get >>> individual spec helper files, so I'm not sure what you're getting at. >>> Can you give an example? >> >> I asked because I had begun to abstract my #describe_properties method away >> from the Property model so that it can be used with any model. Now that the >> method's been converted from this: >> http://pastie.org/261175 >> to this: >> http://pastie.org/261829 >> I'd like to use it with multiple models. >> >> Cheers, >> 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 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From nick at deadorange.com Thu Aug 28 14:02:29 2008 From: nick at deadorange.com (Nick Hoffman) Date: Thu, 28 Aug 2008 14:02:29 -0400 Subject: [rspec-users] Application-wide spec_helper method In-Reply-To: <57c63afe0808281057k13b2fc39w31b4cc3dddcffaa7@mail.gmail.com> References: <9C60741D-BEE4-4A9B-9DFA-F32BF134759D@deadorange.com> <57c63afe0808280502g6fc2ccf0r57d939167ad0ccb6@mail.gmail.com> <3B4561D4-9743-49EC-8103-43FF40B69F2E@deadorange.com> <85d99afe0808281027o78627c3aj6610a6eeab48cffd@mail.gmail.com> <57c63afe0808281057k13b2fc39w31b4cc3dddcffaa7@mail.gmail.com> Message-ID: On 2008-08-28, at 13:57, David Chelimsky wrote: > On Thu, Aug 28, 2008 at 12:27 PM, Zach Dennis > wrote: >> You can put it in a module and include it for model specs in >> spec_helper.rb >> >> Spec::Runner.configure do |config| >> # ... >> config.include DescribeModelAttributeSpecHelper, :type => :model >> end > > What he said. Thanks guys! From nick at deadorange.com Fri Aug 29 00:24:17 2008 From: nick at deadorange.com (Nick Hoffman) Date: Fri, 29 Aug 2008 00:24:17 -0400 Subject: [rspec-users] How to spec the existence of specs Message-ID: <6195F570-5770-4BEB-8264-CECD91CC827D@deadorange.com> I'm writing a Rails plugin that generates specs for Rails models. Obviously, I want to use RSpec to spec this plugin. The plugin, called ModelSpeccer, contains a module with three methods. Each method generates specs depending on its arguments. How can my plugin's specs check that each method in ModelSpeccer created the correct specs? Thanks, Nick From lists at ruby-forum.com Fri Aug 29 04:51:49 2008 From: lists at ruby-forum.com (Joseph Wilk) Date: Fri, 29 Aug 2008 10:51:49 +0200 Subject: [rspec-users] How much test data to use in specs In-Reply-To: References: <14C2F08B-4675-4AEC-9FEB-CAE74D74FEF9@madeofstone.net> <1EF0CC1B-7142-44CA-B92B-E29FAFE5FD7B@mattwynne.net> <0375912D-4B5C-47F8-A18D-962BDD00C7C2@madeofstone.net> <57c63afe0808271146i7f6a4b55l87621238c94a0241@mail.gmail.com> <57c63afe0808280531q3f7abf60q601c7c071fc15a9e@mail.gmail.com> Message-ID: <9eb9b44fb9387bdba8c924f498020635@ruby-forum.com> I started using a set of methods to deal with this problem from code in the RadiantCMS(http://radiantcms.org/) project. http://gist.github.com/7936 I stopped using it after a while finding the tests did not read well. Your method improves on Radiant's which has tempted me to start testing models like this again. Thanks! -- Joseph Wilk http://www.joesniff.co.uk Nick Hoffman wrote: > On 2008-08-28, at 08:31, David Chelimsky wrote: >>>> ... >>> You can have a look at it at http://pastie.org/261175 . If you have >> >> Cheers, >> David > > Thanks for taking a look and making some suggestions, David. Much > appreciated. I've incorporated some of them into the method. > > The method's name was "describe_property_attributes" because it was > being used to describe the Property (as in "real estate") model in my > application. I've just finished abstracting it out so that it can now > be used with any model class. If you're interested, I've pasted it at > http://pastie.org/261829 -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Aug 29 05:06:38 2008 From: lists at ruby-forum.com (Joseph Wilk) Date: Fri, 29 Aug 2008 11:06:38 +0200 Subject: [rspec-users] How to spec the existence of specs In-Reply-To: <6195F570-5770-4BEB-8264-CECD91CC827D@deadorange.com> References: <6195F570-5770-4BEB-8264-CECD91CC827D@deadorange.com> Message-ID: >Each method generates specs depending on its arguments How does each method generate the specs? * Using script/generate rspec... or * File handling and writing your own? -- Joseph Wilk http://www.joesniff.co.uk Nick Hoffman wrote: > I'm writing a Rails plugin that generates specs for Rails models. > Obviously, I want to use RSpec to spec this plugin. > > The plugin, called ModelSpeccer, contains a module with three methods. > Each method generates specs depending on its arguments. How can my > plugin's specs check that each method in ModelSpeccer created the > correct specs? > > Thanks, > Nick -- Posted via http://www.ruby-forum.com/. From nick at deadorange.com Fri Aug 29 10:03:43 2008 From: nick at deadorange.com (Nick Hoffman) Date: Fri, 29 Aug 2008 10:03:43 -0400 Subject: [rspec-users] How much test data to use in specs In-Reply-To: <9eb9b44fb9387bdba8c924f498020635@ruby-forum.com> References: <14C2F08B-4675-4AEC-9FEB-CAE74D74FEF9@madeofstone.net> <1EF0CC1B-7142-44CA-B92B-E29FAFE5FD7B@mattwynne.net> <0375912D-4B5C-47F8-A18D-962BDD00C7C2@madeofstone.net> <57c63afe0808271146i7f6a4b55l87621238c94a0241@mail.gmail.com> <57c63afe0808280531q3f7abf60q601c7c071fc15a9e@mail.gmail.com> <9eb9b44fb9387bdba8c924f498020635@ruby-forum.com> Message-ID: <6715B0EF-1F1A-4EB5-9B00-C762709E1F90@deadorange.com> On 2008-08-29, at 04:51, Joseph Wilk wrote: > I started using a set of methods to deal with this problem from code > in > the RadiantCMS(http://radiantcms.org/) project. > > http://gist.github.com/7936 > > I stopped using it after a while finding the tests did not read well. > Your method improves on Radiant's which has tempted me to start > testing > models like this again. > > Thanks! > -- > Joseph Wilk > http://www.joesniff.co.uk Thanks for the vote of confidence, Joseph! I have two other methods that go alongside #describe_model_attribute which you might find useful. I'm in the process of wrapping them up into a plugin. Until that's finished, I've pasted them at http://pastie.org/262508 and http://pastie.org/262509 . Cheers, Nick From nick at deadorange.com Fri Aug 29 10:10:50 2008 From: nick at deadorange.com (Nick Hoffman) Date: Fri, 29 Aug 2008 10:10:50 -0400 Subject: [rspec-users] How to spec the existence of specs In-Reply-To: References: <6195F570-5770-4BEB-8264-CECD91CC827D@deadorange.com> Message-ID: On 2008-08-29, at 05:06, Joseph Wilk wrote: >> Each method generates specs depending on its arguments > > How does each method generate the specs? > * Using script/generate rspec... > or > * File handling and writing your own? > > -- > Joseph Wilk > http://www.joesniff.co.uk Hi again Joseph. Each method generates the specs by calling RSpec's #describe and #it methods, like this: def check_model_attributes_when_nil(model, ... ... columns_to_check.each do |attribute| describe model, "with '#{attribute}' set to nil" do ... it "should be invalid" do @model_instance.should_not be_valid end ... end end From lists at ruby-forum.com Fri Aug 29 10:53:10 2008 From: lists at ruby-forum.com (Jack Sprat) Date: Fri, 29 Aug 2008 16:53:10 +0200 Subject: [rspec-users] RSpec Book(s) on the radar In-Reply-To: <57c63afe0801021412n2c22df17n7bdb84c245331693@mail.gmail.com> References: <1299.216.167.174.73.1191590398.squirrel@webmail.skidmore.us> <8244a5ee7150b6f670511260a69eed98@ruby-forum.com> <57c63afe0801020652w32871bebsc6876eb3c4ab9566@mail.gmail.com> <604BD6AC-D087-4810-B970-87A61BBA7A83@superinfinite.com> <57c63afe0801021412n2c22df17n7bdb84c245331693@mail.gmail.com> Message-ID: David Chelimsky wrote: > On Jan 2, 2008 8:05 PM, Bart Zonneveld wrote: > >> Curious, are the Stories going to be part of the rspec book? > > Yep. > >> Eagerly waiting on that one... > > Us too! David...February has given way to September (almost) and stll no date or beta book. We really, really need this book. Is it still going to happen, and if so, when? Thanks! Jack -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Fri Aug 29 11:02:28 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 29 Aug 2008 10:02:28 -0500 Subject: [rspec-users] RSpec Book(s) on the radar In-Reply-To: References: <1299.216.167.174.73.1191590398.squirrel@webmail.skidmore.us> <8244a5ee7150b6f670511260a69eed98@ruby-forum.com> <57c63afe0801020652w32871bebsc6876eb3c4ab9566@mail.gmail.com> <604BD6AC-D087-4810-B970-87A61BBA7A83@superinfinite.com> <57c63afe0801021412n2c22df17n7bdb84c245331693@mail.gmail.com> Message-ID: <57c63afe0808290802w5c7e49e1u1b304af970e1d821@mail.gmail.com> It's definitely happening. We've enlisted a few additional contributors and the wheels are spinning faster now. As for the beta book, I don't know if there will be on at this point. We may go straight to print. Either way, I'll update as I know more and I'll start blogging about progress shortly. Cheers, David On Fri, Aug 29, 2008 at 9:53 AM, Jack Sprat wrote: > David Chelimsky wrote: >> On Jan 2, 2008 8:05 PM, Bart Zonneveld wrote: >> >>> Curious, are the Stories going to be part of the rspec book? >> >> Yep. >> >>> Eagerly waiting on that one... >> >> Us too! > > David...February has given way to September (almost) and stll no date or > beta book. We really, really need this book. Is it still going to > happen, and if so, when? > > Thanks! > Jack > -- > 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 Fri Aug 29 11:05:03 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 29 Aug 2008 10:05:03 -0500 Subject: [rspec-users] How much test data to use in specs In-Reply-To: <6715B0EF-1F1A-4EB5-9B00-C762709E1F90@deadorange.com> References: <1EF0CC1B-7142-44CA-B92B-E29FAFE5FD7B@mattwynne.net> <0375912D-4B5C-47F8-A18D-962BDD00C7C2@madeofstone.net> <57c63afe0808271146i7f6a4b55l87621238c94a0241@mail.gmail.com> <57c63afe0808280531q3f7abf60q601c7c071fc15a9e@mail.gmail.com> <9eb9b44fb9387bdba8c924f498020635@ruby-forum.com> <6715B0EF-1F1A-4EB5-9B00-C762709E1F90@deadorange.com> Message-ID: <57c63afe0808290805g3fb0484etdf4b17cd257287b5@mail.gmail.com> On Fri, Aug 29, 2008 at 9:03 AM, Nick Hoffman wrote: > On 2008-08-29, at 04:51, Joseph Wilk wrote: >> >> I started using a set of methods to deal with this problem from code in >> the RadiantCMS(http://radiantcms.org/) project. >> >> http://gist.github.com/7936 >> >> I stopped using it after a while finding the tests did not read well. >> Your method improves on Radiant's which has tempted me to start testing >> models like this again. >> >> Thanks! >> -- >> Joseph Wilk >> http://www.joesniff.co.uk > > Thanks for the vote of confidence, Joseph! I have two other methods that go > alongside #describe_model_attribute which you might find useful. I'm in the > process of wrapping them up into a plugin. Until that's finished, I've > pasted them at http://pastie.org/262508 and http://pastie.org/262509 . Hey Nick - I'm not clear why you need these, given that you already have the describe_model_attributes macro, which you can use to handle nils and will give you a meaningful error if there is a problem with your factory. What's your goal here? > > Cheers, > Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From nick at deadorange.com Fri Aug 29 11:30:06 2008 From: nick at deadorange.com (Nick Hoffman) Date: Fri, 29 Aug 2008 11:30:06 -0400 Subject: [rspec-users] How much test data to use in specs In-Reply-To: <57c63afe0808290805g3fb0484etdf4b17cd257287b5@mail.gmail.com> References: <1EF0CC1B-7142-44CA-B92B-E29FAFE5FD7B@mattwynne.net> <0375912D-4B5C-47F8-A18D-962BDD00C7C2@madeofstone.net> <57c63afe0808271146i7f6a4b55l87621238c94a0241@mail.gmail.com> <57c63afe0808280531q3f7abf60q601c7c071fc15a9e@mail.gmail.com> <9eb9b44fb9387bdba8c924f498020635@ruby-forum.com> <6715B0EF-1F1A-4EB5-9B00-C762709E1F90@deadorange.com> <57c63afe0808290805g3fb0484etdf4b17cd257287b5@mail.gmail.com> Message-ID: <0FB1E7DB-48AB-4C06-8F44-806FB061B902@deadorange.com> On 2008-08-29, at 11:05, David Chelimsky wrote: > On Fri, Aug 29, 2008 at 9:03 AM, Nick Hoffman > wrote: >> On 2008-08-29, at 04:51, Joseph Wilk wrote: >>> >>> I started using a set of methods to deal with this problem from >>> code in >>> the RadiantCMS(http://radiantcms.org/) project. >>> >>> http://gist.github.com/7936 >>> >>> I stopped using it after a while finding the tests did not read >>> well. >>> Your method improves on Radiant's which has tempted me to start >>> testing >>> models like this again. >>> >>> Thanks! >>> -- >>> Joseph Wilk >>> http://www.joesniff.co.uk >> >> Thanks for the vote of confidence, Joseph! I have two other methods >> that go >> alongside #describe_model_attribute which you might find useful. >> I'm in the >> process of wrapping them up into a plugin. Until that's finished, >> I've >> pasted them at http://pastie.org/262508 and http://pastie.org/ >> 262509 . > > Hey Nick - I'm not clear why you need these, given that you already > have the describe_model_attributes macro, which you can use to handle > nils and will give you a meaningful error if there is a problem with > your factory. What's your goal here? Hi David. My goal with these methods is to automate the speccing of model attributes and reduce the amount of code that needs to be written. I created #describe_model_factory so that there would be a spec specifically for the factories that I create, rather than relying on other specs to indirectly ensure that my factories work properly. Looking at the methods again, you're correct that #describe_model_attribute includes most of the functionality of #check_model_attributes_when_nil . That's not very DRY then, eh? I should probably get rid of #check_model_attributes_when_nil , and add an argument to #describe_model_attribute that allows the user to specify whether or not an error message should exist when the attribute being specced is invalid. How does that sound? -Nick From jonathan at parkerhill.com Fri Aug 29 12:17:54 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Fri, 29 Aug 2008 12:17:54 -0400 Subject: [rspec-users] uploads with webrat in stories Message-ID: <2CC8290E-BED9-49E7-8A15-7A4793B3B0BB@parkerhill.com> I've read through the messages on this list, and have file upload specs working in my model and controller tests, using :file => ActionController::TestUploadedFile.new(filepath) But its not working in stories using webrat. I've tried fills_in "foo[file]", :with => filepath and fills_in "foo[file]", :with => ActionController::TestUploadedFile.new (filepath) both fail (0) when submit clicks_button 'Update' oddly, in either case, a browser get opened, with something like file:///Users/jonathan/rails/myproject/tmp/webrat-1220026536.html which is blank suggestions? thx linoj From ben at benmabey.com Fri Aug 29 12:52:42 2008 From: ben at benmabey.com (Ben Mabey) Date: Fri, 29 Aug 2008 10:52:42 -0600 Subject: [rspec-users] uploads with webrat in stories In-Reply-To: <2CC8290E-BED9-49E7-8A15-7A4793B3B0BB@parkerhill.com> References: <2CC8290E-BED9-49E7-8A15-7A4793B3B0BB@parkerhill.com> Message-ID: <48B8295A.5070601@benmabey.com> Jonathan Linowes wrote: > I've read through the messages on this list, and have file upload > specs working in my model and controller tests, using :file => > ActionController::TestUploadedFile.new(filepath) > > But its not working in stories using webrat. I've tried > > fills_in "foo[file]", :with => filepath > and > fills_in "foo[file]", :with => > ActionController::TestUploadedFile.new(filepath) > > both fail (0) when submit > clicks_button 'Update' > > oddly, in either case, a browser get opened, with something like > file:///Users/jonathan/rails/myproject/tmp/webrat-1220026536.html > which is blank > > suggestions? > > thx > linoj > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users I haven't been able to get the webrat uploading method (attaches_file) to work.... If you haven't tried that method give it a shot, but I haven't gotten it to work. To upload in stories I have done this: csv_file = ..... file_to_upload = ActionController::TestUploadedFile.new(csv_file.path, Mime::CSV) post my_path, "import_file" => file_to_upload In my story I didn't have other fields in the form so I didn't bother to investigate why webrat wasn't working.. the clear disadvantage of the way I used is that I'm doing the post directly. -Ben From jonathan at parkerhill.com Fri Aug 29 13:19:19 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Fri, 29 Aug 2008 13:19:19 -0400 Subject: [rspec-users] uploads with webrat in stories In-Reply-To: <48B8295A.5070601@benmabey.com> References: <2CC8290E-BED9-49E7-8A15-7A4793B3B0BB@parkerhill.com> <48B8295A.5070601@benmabey.com> Message-ID: <4DDE00B1-836A-4F07-98BF-DAFA5E671B27@parkerhill.com> On Aug 29, 2008, at 12:52 PM, Ben Mabey wrote: > Jonathan Linowes wrote: >> I've read through the messages on this list, and have file upload >> specs working in my model and controller tests, using :file => >> ActionController::TestUploadedFile.new(filepath) >> >> But its not working in stories using webrat. I've tried >> >> fills_in "foo[file]", :with => filepath >> and >> fills_in "foo[file]", :with => >> ActionController::TestUploadedFile.new(filepath) >> >> both fail (0) when submit >> clicks_button 'Update' >> >> oddly, in either case, a browser get opened, with something like >> file:///Users/jonathan/rails/myproject/tmp/webrat-1220026536.html >> which is blank >> >> suggestions? >> >> thx >> linoj >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > I haven't been able to get the webrat uploading method (attaches_file) > to work.... If you haven't tried that method give it a shot, but I > haven't gotten it to work. To upload in stories I have done this: > > csv_file = ..... > file_to_upload = ActionController::TestUploadedFile.new(csv_file.path, > Mime::CSV) > post my_path, "import_file" => file_to_upload > i am trying that too, but at this point in my story i dont actually have the current record object to generate the form action path. How would i extract the :action = path from the in the current response.body ? > > In my story I didn't have other fields in the form so I didn't > bother to > investigate why webrat wasn't working.. the clear disadvantage of the > way I used is that I'm doing the post directly. > > -Ben > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From chris at cobaltedge.com Fri Aug 29 13:58:02 2008 From: chris at cobaltedge.com (Christopher Bailey) Date: Fri, 29 Aug 2008 10:58:02 -0700 Subject: [rspec-users] uploads with webrat in stories In-Reply-To: <48B8295A.5070601@benmabey.com> References: <2CC8290E-BED9-49E7-8A15-7A4793B3B0BB@parkerhill.com> <48B8295A.5070601@benmabey.com> Message-ID: <443c240c0808291058ha4bfcc3q7eaa852eade0b7d4@mail.gmail.com> I too would suggest trying attaches_file. I use it in a few different stories I have, and it works fine for me. I don't believe I'm doing anything nonstandard. Here's the basics of what one of mine looks like (stripped out some fills_in's, etc. to declutter the example): When "create a new hotel with photo from a '$source'" do |source| visits new_location_path fills_in 'Name', :with => 'Maui' attaches_file 'location_photo', File.join(Rails.root, 'stories', 'fixtures', 'BigPizza.jpg') clicks_button 'Save' end On Fri, Aug 29, 2008 at 9:52 AM, Ben Mabey wrote: > Jonathan Linowes wrote: > > I've read through the messages on this list, and have file upload > > specs working in my model and controller tests, using :file => > > ActionController::TestUploadedFile.new(filepath) > > > > But its not working in stories using webrat. I've tried > > > > fills_in "foo[file]", :with => filepath > > and > > fills_in "foo[file]", :with => > > ActionController::TestUploadedFile.new(filepath) > > > > both fail (0) when submit > > clicks_button 'Update' > > > > oddly, in either case, a browser get opened, with something like > > file:///Users/jonathan/rails/myproject/tmp/webrat-1220026536.html > > which is blank > > > > suggestions? > > > > thx > > linoj > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > I haven't been able to get the webrat uploading method (attaches_file) > to work.... If you haven't tried that method give it a shot, but I > haven't gotten it to work. To upload in stories I have done this: > > csv_file = ..... > file_to_upload = ActionController::TestUploadedFile.new(csv_file.path, > Mime::CSV) > post my_path, "import_file" => file_to_upload > > > In my story I didn't have other fields in the form so I didn't bother to > investigate why webrat wasn't working.. the clear disadvantage of the > way I used is that I'm doing the post directly. > > -Ben > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Christopher Bailey Cobalt Edge LLC http://cobaltedge.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From tastapod at gmail.com Fri Aug 29 14:19:17 2008 From: tastapod at gmail.com (Dan North) Date: Fri, 29 Aug 2008 20:19:17 +0200 Subject: [rspec-users] Documentation for Plain-Text Stories In-Reply-To: <810a540e0808191604k5575d22cw18f3a28e6d44d35d@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <8d961d900808180411i1710578ew3673201968c794df@mail.gmail.com> <810a540e0808191604k5575d22cw18f3a28e6d44d35d@mail.gmail.com> Message-ID: As the author of the original scenario runner, if Aslak has come up with a nicer implementation - both in terms of design and hackability - then I say chuck my one out and use his :) As long as it is an easy adjustment (i.e. transparent or with an easy migration) for users of the current scenario runner then I think we should ship it in. Cheers, Dan 2008/8/20 Pat Maddox > > What do you think is the best thing to do? > > I would prefer to merge it into RSpec whenever it's ready. One of the > strong points about RSpec is that it's a complete BDD toolkit: example > framework for developer testing, feature runner for customer test, and > the mock objects framework. People can get started with one part of > the toolkit, and gradually use the other pieces as their wants and > needs develop. I think it was a big win when RBehave merged into > RSpec. If Cucumber represents significant improvements over the > current Story Runner, I'd like to see those improvements make it into > RSpec. > > 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 jonathan at parkerhill.com Fri Aug 29 14:31:13 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Fri, 29 Aug 2008 14:31:13 -0400 Subject: [rspec-users] uploads with webrat in stories In-Reply-To: <4DDE00B1-836A-4F07-98BF-DAFA5E671B27@parkerhill.com> References: <2CC8290E-BED9-49E7-8A15-7A4793B3B0BB@parkerhill.com> <48B8295A.5070601@benmabey.com> <4DDE00B1-836A-4F07-98BF-DAFA5E671B27@parkerhill.com> Message-ID: <849731ED-1AA4-47E2-81E5-3CA3D8E5AFE4@parkerhill.com> On Aug 29, 2008, at 1:19 PM, Jonathan Linowes wrote: > i am trying that too, but at this point in my story i dont actually > have the current record object to generate the form action path. > How would i extract the :action = path from the in the > current response.body ? got it #assuming only one form on the page path = response.body.match(/action=\"([^"]+)\"/)[1] still, i dont like bypassing webrat though From tastapod at gmail.com Fri Aug 29 14:37:02 2008 From: tastapod at gmail.com (Dan North) Date: Fri, 29 Aug 2008 20:37:02 +0200 Subject: [rspec-users] story vs feature (was Documentation for Plain-Text Stories) In-Reply-To: <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> <1341C3E7-DB99-4F7D-8576-60F2107B3C7F@parkerhill.com> <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> Message-ID: At the risk of being a bit controversial... 2008/8/24 David Chelimsky [...] > Sadly, "spec" has just as much baggage, if not more, as "test" does. > These days we're calling these things "code examples," (tongue > pressing into cheek) so maybe we should change the name to > rcodeexample? Or rbehave? The rbehave.org domain is available (I registered it some time ago), and rspec has naturally evolved from its original goal of code-level specs to become a full-stack behaviour description framework. Just a thought. With regard to the stories and features thing, I see a BDD-shaped story as providing a context - and justification - for a feature: As a [stakeholder] *I want [a feature] *So that [I get some benefit] Before we started using this structure, a "story" would often just be the middle line, so it wasn't immediately obvious who the stakeholder was or why they wanted the feature, which in turn would often lead to over-work, under-work or just plain wrong-work. Of course the word "story" has its own baggage. In XP a story is "a placeholder/promise for a conversation", and as such could just be a title scribbled on a card. I wrote the story articleto put this all in context - if you ask 5 agile folks what a story is, you will likely get 6 answers. I agree that *the feature is the interesting thing*, and also that there may be several stories about the same feature in different broad contexts. In any event the scenarios provide the definition of "Done" for the feature, which is kind of the whole point. So I guess I'm saying I'm ambivalent about the story/feature distinction. I don't look at stories as work units as much as a more formal description of (some aspect of) a feature. After speaking with Aslak - and some FDD folks I met at Agile 2008 - I can fully agree with organising stories by feature. In fact in Peter Coad's FDD they have features within feature sets, within subject areas, which might well map to stories within features within [not sure - subject areas? themes? something broader anyway]. FDD features seem to be "thinner" than what I understand Aslak's description of features to be. One thing that makes me happy is that we seem to have consensus around the word "scenario" - which is where the outside-in work really starts. Cheers, Dan -------------- next part -------------- An HTML attachment was scrubbed... URL: From loop at superinfinite.com Fri Aug 29 14:37:40 2008 From: loop at superinfinite.com (Bart Zonneveld) Date: Fri, 29 Aug 2008 20:37:40 +0200 Subject: [rspec-users] BDDish rspecish question Message-ID: Hey list, This is a kinda quirky question for this list, but I do think it belongs here. I'm currently writing an app with users with different roles. Roles are sequentially so to speak, so role 2 can do everything role 1 can, and so on. If I truly test my whole app, I should test all behaviour for each role, I guess. I could solve that by doing some clever shared steps and all, but my main question is this: should I test the behaviour of my entire app for each role, or not, since that behaviour is embedded in the app itself? thanks a bunch, bartz From tastapod at gmail.com Fri Aug 29 14:39:56 2008 From: tastapod at gmail.com (Dan North) Date: Fri, 29 Aug 2008 20:39:56 +0200 Subject: [rspec-users] I want RSpec for CSS layout. In-Reply-To: References: <48AB67E2.1000009@shopwatch.org> Message-ID: ooh, that would be lovely. LayoutBehave anyone? 2008/8/20 Matt Wynne > +1 > > cheers, > Matt > ---- > http://blog.mattwynne.net > http://songkick.com > > In case you wondered: The opinions expressed in this email are my own and > do not necessarily reflect the views of any former, current or future > employers of mine. > > > > > On 20 Aug 2008, at 01:40, Jay Levitt wrote: > > I don't even know how it'd be possible (through Selenium?), but I want it. >> I want to see if my stupid CSS hacks break. I want to say: >> >> describe "#nav-column" do >> body = something("#body-column") >> >> it "should line up at the top" do >> dom[:top].should_be == body.dom[:top] >> end >> >> it "should always be to the right" do >> dom[:left].should_be > body.dom[:right] >> end >> >> end >> >> And I want to be able to run it on Firefox, IE6, IE7, and Safari. >> >> Lazyweb... go. >> _______________________________________________ >> 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 dchelimsky at gmail.com Fri Aug 29 15:06:25 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 29 Aug 2008 14:06:25 -0500 Subject: [rspec-users] BDDish rspecish question In-Reply-To: References: Message-ID: <57c63afe0808291206u74588234w620666563373923f@mail.gmail.com> On Fri, Aug 29, 2008 at 1:37 PM, Bart Zonneveld wrote: > Hey list, > > This is a kinda quirky It's only quirky-ish. > question for this list, but I do think it belongs > here. I'm currently writing an app with users with different roles. Roles > are sequentially so to speak, so role 2 can do everything role 1 can, and so > on. > If I truly test my whole app, I should test all behaviour for each role, I > guess. I could solve that by doing some clever shared steps and all, but my > main question is this: should I test the behaviour of my entire app for each > role, or not, since that behaviour is embedded in the app itself? >From a testing perspective, you should test as much as you need to feel confident your app works. >From a refactoring perspective, you should test as much as you need to feel confident refactoring. >From a BDD perspective, the roles and permissions shouldn't exist until there are automated scenarios and code examples driving them into existence. The problem of multiple roles * multiple permissions (per role) can make this explode quite a bit. There is a relatively new feature in cucumber that lets you express things in a tabular format in addition to scenarios (think FIT, but plain text). So you can do this: Scenario: roles 3 and up can create a user Given I am in the 'role 3' role When I try to create a new user Then I am allowed | role | action | response | | role 1 | create a new user | denied | | role 2 | create a new user | denied | | role 3 | create a new user | allowed | | role 4 | create a new user | allowed | | role 5 | create a new user | allowed | (that looks right if you view in a monospace font) For my money (even thought it's free), this is the perfect situation for this format, as it allows you to express a number of cases/rules in a clear succinct way. HTH, David > thanks a bunch, > bartz > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Fri Aug 29 15:11:53 2008 From: lists at ruby-forum.com (Joseph Wilk) Date: Fri, 29 Aug 2008 21:11:53 +0200 Subject: [rspec-users] uploads with webrat in stories In-Reply-To: <849731ED-1AA4-47E2-81E5-3CA3D8E5AFE4@parkerhill.com> References: <2CC8290E-BED9-49E7-8A15-7A4793B3B0BB@parkerhill.com> <48B8295A.5070601@benmabey.com> <4DDE00B1-836A-4F07-98BF-DAFA5E671B27@parkerhill.com> <849731ED-1AA4-47E2-81E5-3CA3D8E5AFE4@parkerhill.com> Message-ID: When Webrat matches 'Exception caught' on the get/post response body it tries to save the response body down as a html file and then invokes opening it in a browser (I believe the opening only works on OS X though I've never tested it in another os). This is a very useful feature unless you get a blank page :) I've had blank errors before which I've suspect was a bug but I never got around to looking at why they did not contain the response body. >oddly, in either case, a browser get opened, with something like >file:///Users/jonathan/rails/myproject/tmp/webrat-1220026536.html >which is blank -- Joseph Wilk http://www.joesniff.co.uk -- Posted via http://www.ruby-forum.com/. From loop at superinfinite.com Fri Aug 29 15:23:53 2008 From: loop at superinfinite.com (Bart Zonneveld) Date: Fri, 29 Aug 2008 21:23:53 +0200 Subject: [rspec-users] BDDish rspecish question In-Reply-To: <57c63afe0808291206u74588234w620666563373923f@mail.gmail.com> References: <57c63afe0808291206u74588234w620666563373923f@mail.gmail.com> Message-ID: <2164EAA9-D136-4A0D-8175-2C6A94A0B248@superinfinite.com> On 29 aug 2008, at 21:06, David Chelimsky wrote: > On Fri, Aug 29, 2008 at 1:37 PM, Bart Zonneveld > wrote: >> Hey list, >> >> This is a kinda quirky > > It's only quirky-ish. That made me laugh out loud :). >> question for this list, but I do think it belongs >> here. I'm currently writing an app with users with different roles. >> Roles >> are sequentially so to speak, so role 2 can do everything role 1 >> can, and so >> on. >> If I truly test my whole app, I should test all behaviour for each >> role, I >> guess. I could solve that by doing some clever shared steps and >> all, but my >> main question is this: should I test the behaviour of my entire app >> for each >> role, or not, since that behaviour is embedded in the app itself? > >> > From a testing perspective, you should test as much as you need to > feel confident your app works. This... > From a refactoring perspective, you should test as much as you need to > feel confident refactoring. and this means at its least 100% coverage by stories in my book. And since I am using stories, and stories only to drive implementation of features... > From a BDD perspective, the roles and permissions shouldn't exist > until there are automated scenarios and code examples driving them > into existence. there aren't any permissions in the system yet. Most of the times a different role means a certain form field is available or not, or a certain action (think new/create) is allowed or not. So I'm thinking of testing exhaustively for my most basic role, and just testing whether extra features are available and functional for higher roles, instead of testing the basic functionality for each and every role. > The problem of multiple roles * multiple permissions (per role) can > make this explode quite a bit. There is a relatively new feature in > cucumber that lets you express things in a tabular format in addition > to scenarios (think FIT, but plain text). So you can do this: > > Scenario: roles 3 and up can create a user > Given I am in the 'role 3' role > When I try to create a new user > Then I am allowed > > | role | action | response | > | role 1 | create a new user | denied | > | role 2 | create a new user | denied | > | role 3 | create a new user | allowed | > | role 4 | create a new user | allowed | > | role 5 | create a new user | allowed | This means something like... Given I have role 1 When I try to create a new user Then I should see a message telling me I'm not allowed to do so Given I have role 3 When I try to create a new user Then I should be allowed to do so And there should be a new user created right? > For my money (even thought it's free), this is the perfect situation > for this format, as it allows you to express a number of cases/rules > in a clear succinct way. It most certainly does, however, in my app I'm not really restricting acces on that detailed level. This looks absolutely perfect for a situation where role 1 can not, role 2 can, role 3 can not, and role 4 can create a new user. thanks for the great reply, bartz From email at acgreen.co.uk Fri Aug 29 15:14:02 2008 From: email at acgreen.co.uk (Anthony Green) Date: Fri, 29 Aug 2008 20:14:02 +0100 Subject: [rspec-users] RSpec Book(s) on the radar In-Reply-To: <57c63afe0808290802w5c7e49e1u1b304af970e1d821@mail.gmail.com> Message-ID: If this has any sway at all... I've bought every (ruby/rails) beta book from pragprog and manning and nearly always followed it up with a hard copy on publication. I'd like to see a beta please, please, please Tony On 29/08/2008 16:02, "David Chelimsky" wrote: > It's definitely happening. We've enlisted a few additional > contributors and the wheels are spinning faster now. > > As for the beta book, I don't know if there will be on at this point. > We may go straight to print. Either way, I'll update as I know more > and I'll start blogging about progress shortly. > > Cheers, > David From tastapod at gmail.com Fri Aug 29 15:54:30 2008 From: tastapod at gmail.com (Dan North) Date: Fri, 29 Aug 2008 21:54:30 +0200 Subject: [rspec-users] BDDish rspecish question In-Reply-To: <57c63afe0808291206u74588234w620666563373923f@mail.gmail.com> References: <57c63afe0808291206u74588234w620666563373923f@mail.gmail.com> Message-ID: This is one of the tiny-but-amazing details that makes me excited about cucumber. (That's one of those sentences you don't want blogged... "No, I meant cucumber the *framework*") Aslak has done some really cool stuff here - I don't think we've started to realise the power of combining tables and GWT scenarios - I have a hunch that there will be some rather nice emergent behaviour once people become familiar with it. Plus because cucumber is grammar-based, we will start discovering other complementary formats to GWT. Hmm - rather fun! 2008/8/29 David Chelimsky > On Fri, Aug 29, 2008 at 1:37 PM, Bart Zonneveld > wrote: > > Hey list, > > > > This is a kinda quirky > > It's only quirky-ish. > > > question for this list, but I do think it belongs > > here. I'm currently writing an app with users with different roles. Roles > > are sequentially so to speak, so role 2 can do everything role 1 can, and > so > > on. > > If I truly test my whole app, I should test all behaviour for each role, > I > > guess. I could solve that by doing some clever shared steps and all, but > my > > main question is this: should I test the behaviour of my entire app for > each > > role, or not, since that behaviour is embedded in the app itself? > > >From a testing perspective, you should test as much as you need to > feel confident your app works. > > >From a refactoring perspective, you should test as much as you need to > feel confident refactoring. > > >From a BDD perspective, the roles and permissions shouldn't exist > until there are automated scenarios and code examples driving them > into existence. > > The problem of multiple roles * multiple permissions (per role) can > make this explode quite a bit. There is a relatively new feature in > cucumber that lets you express things in a tabular format in addition > to scenarios (think FIT, but plain text). So you can do this: > > Scenario: roles 3 and up can create a user > Given I am in the 'role 3' role > When I try to create a new user > Then I am allowed > > | role | action | response | > | role 1 | create a new user | denied | > | role 2 | create a new user | denied | > | role 3 | create a new user | allowed | > | role 4 | create a new user | allowed | > | role 5 | create a new user | allowed | > > (that looks right if you view in a monospace font) > > For my money (even thought it's free), this is the perfect situation > for this format, as it allows you to express a number of cases/rules > in a clear succinct way. > > HTH, > David > > > thanks a bunch, > > bartz > > _______________________________________________ > > 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 jonathan at parkerhill.com Fri Aug 29 16:15:31 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Fri, 29 Aug 2008 16:15:31 -0400 Subject: [rspec-users] uploads with webrat in stories In-Reply-To: <443c240c0808291058ha4bfcc3q7eaa852eade0b7d4@mail.gmail.com> References: <2CC8290E-BED9-49E7-8A15-7A4793B3B0BB@parkerhill.com> <48B8295A.5070601@benmabey.com> <443c240c0808291058ha4bfcc3q7eaa852eade0b7d4@mail.gmail.com> Message-ID: On Aug 29, 2008, at 1:58 PM, Christopher Bailey wrote: > I too would suggest trying attaches_file. I use it in a few > different stories I have, and it works fine for me. I don't > believe I'm doing anything nonstandard. Here's the basics of what yep, works for me :) thx -------------- next part -------------- An HTML attachment was scrubbed... URL: From rick.denatale at gmail.com Fri Aug 29 18:57:37 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Fri, 29 Aug 2008 18:57:37 -0400 Subject: [rspec-users] RSpec Book(s) on the radar In-Reply-To: References: <57c63afe0808290802w5c7e49e1u1b304af970e1d821@mail.gmail.com> Message-ID: On Fri, Aug 29, 2008 at 3:14 PM, Anthony Green wrote: > > If this has any sway at all... I've bought every (ruby/rails) beta book > from > pragprog and manning and nearly always followed it up with a hard copy on > publication. > > I'd like to see a beta please, please, please +10 I'm a big fan of the Prag's beta program, 99 44/100% of the time it results in a much better book. For a subject I'm interested in, and RSpec is certainly that, I usually buy the PDF + dead tree later package. I just downloaded the latest beta edition of their GIT book today. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Fri Aug 29 19:05:53 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 29 Aug 2008 18:05:53 -0500 Subject: [rspec-users] RSpec Book(s) on the radar In-Reply-To: References: <57c63afe0808290802w5c7e49e1u1b304af970e1d821@mail.gmail.com> Message-ID: <57c63afe0808291605j7fcb5552u8a634a1eb374f393@mail.gmail.com> On Fri, Aug 29, 2008 at 5:57 PM, Rick DeNatale wrote: > On Fri, Aug 29, 2008 at 3:14 PM, Anthony Green wrote: >> >> If this has any sway at all... I've bought every (ruby/rails) beta book >> from >> pragprog and manning and nearly always followed it up with a hard copy on >> publication. >> >> I'd like to see a beta please, please, please Me too! If the decision was only mine to make, you'd see a beta book. In fact, you may well see one anyway, but it is not my decision to make and it's a decision that has not yet been made. As soon as I know something firm I'll post about it. Cheers, David > > +10 > > I'm a big fan of the Prag's beta program, 99 44/100% of the time it results > in a much better book. > > For a subject I'm interested in, and RSpec is certainly that, I usually buy > the PDF + dead tree later package. > > I just downloaded the latest beta edition of their GIT book today. > > -- > Rick DeNatale > > My blog on Ruby > http://talklikeaduck.denhaven2.com/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Fri Aug 29 19:22:34 2008 From: ben at benmabey.com (Ben Mabey) Date: Fri, 29 Aug 2008 17:22:34 -0600 Subject: [rspec-users] Cucumber and multi-line steps Message-ID: <48B884BA.5000709@benmabey.com> Hi all, Where can we add tickets for Cucumber? While trying to migrate a current project I ran into a snag.. specially that cucumber does not support multi-line steps like the edge rspec story runner (which makes sense since this was such a new feature to the story runner.) Anyways, I don't have enough time at the moment to dig into it myself so I'd like to at least log it. Should we just use the rspec lighthouse account or should we create a new one? Thanks, Ben From matt at matt-darby.com Fri Aug 29 19:12:46 2008 From: matt at matt-darby.com (matt at matt-darby.com) Date: Fri, 29 Aug 2008 23:12:46 +0000 Subject: [rspec-users] RSpec Book(s) on the radar In-Reply-To: References: <57c63afe0808290802w5c7e49e1u1b304af970e1d821@mail.gmail.com> Message-ID: <31172832-1220051550-cardhu_decombobulator_blackberry.rim.net-1416137890-@bxe272.bisx.prod.on.blackberry> +1! Sent from my Verizon Wireless BlackBerry -----Original Message----- From: "Rick DeNatale" Date: Fri, 29 Aug 2008 18:57:37 To: rspec-users Subject: Re: [rspec-users] RSpec Book(s) on the radar _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Fri Aug 29 19:25:29 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 29 Aug 2008 18:25:29 -0500 Subject: [rspec-users] Cucumber and multi-line steps In-Reply-To: <48B884BA.5000709@benmabey.com> References: <48B884BA.5000709@benmabey.com> Message-ID: <57c63afe0808291625p11d14271n61bcf28b3d9104b9@mail.gmail.com> On Fri, Aug 29, 2008 at 6:22 PM, Ben Mabey wrote: > Hi all, > Where can we add tickets for Cucumber? While trying to migrate a > current project I ran into a snag.. specially that cucumber does not > support multi-line steps like the edge rspec story runner (which makes > sense since this was such a new feature to the story runner.) Anyways, > I don't have enough time at the moment to dig into it myself so I'd like > to at least log it. > > Should we just use the rspec lighthouse account or should we create a > new one? I just created a lighthouse project for it: http://rspec.lighthouseapp.com/projects/16211 Aslak and I were discussing this today and he's planning to add it soon, so if you do want to take it on yourself, be sure to coordinate w/ him. Cheers, David > > Thanks, > Ben > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mailing_lists at railsnewbie.com Fri Aug 29 21:12:08 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 29 Aug 2008 21:12:08 -0400 Subject: [rspec-users] I want RSpec for CSS layout. In-Reply-To: References: <48AB67E2.1000009@shopwatch.org> Message-ID: On Aug 29, 2008, at 2:39 PM, Dan North wrote: > ooh, that would be lovely. > > LayoutBehave anyone? > Well, I don't see why there couldn't be one, assuming there was a CSS parser out there. I've started a treetop CSS2 parser, but just don't have the time to devote to it. Anyone interested? Scott From nick at deadorange.com Fri Aug 29 22:40:25 2008 From: nick at deadorange.com (Nick Hoffman) Date: Fri, 29 Aug 2008 22:40:25 -0400 Subject: [rspec-users] Application-wide spec_helper method In-Reply-To: <85d99afe0808281027o78627c3aj6610a6eeab48cffd@mail.gmail.com> References: <9C60741D-BEE4-4A9B-9DFA-F32BF134759D@deadorange.com> <57c63afe0808280502g6fc2ccf0r57d939167ad0ccb6@mail.gmail.com> <3B4561D4-9743-49EC-8103-43FF40B69F2E@deadorange.com> <85d99afe0808281027o78627c3aj6610a6eeab48cffd@mail.gmail.com> Message-ID: <4E011A29-B8F4-4B5B-AB40-B2E0A59746D5@deadorange.com> On 2008-08-28, at 13:27, Zach Dennis wrote: > You can put it in a module and include it for model specs in > spec_helper.rb > > Spec::Runner.configure do |config| > # ... > config.include DescribeModelAttributeSpecHelper, :type => :model > end > > Zach Hi Zach. I put the methods into the module "ModelSpeccer" in lib/ ModelSpeccer.rb and then added this to spec_helper.rb : config.include ModelSpeccer, :type => :model Unfortunately though, when I run my specs, Ruby isn't finding the module: $ script/spec spec/models/property_spec.rb /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/ active_support/dependencies.rb:278:in `load_missing_constant': uninitialized constant ModelSpeccer (NameError) Any suggestions for how to correct this? Thanks! Nick From lists at sourceillustrated.com Fri Aug 29 22:44:30 2008 From: lists at sourceillustrated.com (John Wells) Date: Fri, 29 Aug 2008 22:44:30 -0400 Subject: [rspec-users] RSpec Book(s) on the radar In-Reply-To: <31172832-1220051550-cardhu_decombobulator_blackberry.rim.net-1416137890-@bxe272.bisx.prod.on.blackberry> References: <57c63afe0808290802w5c7e49e1u1b304af970e1d821@mail.gmail.com> <31172832-1220051550-cardhu_decombobulator_blackberry.rim.net-1416137890-@bxe272.bisx.prod.on.blackberry> Message-ID: <44dddf400808291944h43b632b5uceddbbeb74ba647c@mail.gmail.com> On Fri, Aug 29, 2008 at 7:12 PM, wrote: > +1! +1 here too...please pressure these mysterious lurking powers that be to publish a beta ;-) From mailing_lists at railsnewbie.com Fri Aug 29 23:05:56 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 29 Aug 2008 23:05:56 -0400 Subject: [rspec-users] Application-wide spec_helper method In-Reply-To: <4E011A29-B8F4-4B5B-AB40-B2E0A59746D5@deadorange.com> References: <9C60741D-BEE4-4A9B-9DFA-F32BF134759D@deadorange.com> <57c63afe0808280502g6fc2ccf0r57d939167ad0ccb6@mail.gmail.com> <3B4561D4-9743-49EC-8103-43FF40B69F2E@deadorange.com> <85d99afe0808281027o78627c3aj6610a6eeab48cffd@mail.gmail.com> <4E011A29-B8F4-4B5B-AB40-B2E0A59746D5@deadorange.com> Message-ID: On Aug 29, 2008, at 10:40 PM, Nick Hoffman wrote: > On 2008-08-28, at 13:27, Zach Dennis wrote: >> You can put it in a module and include it for model specs in >> spec_helper.rb >> >> Spec::Runner.configure do |config| >> # ... >> config.include DescribeModelAttributeSpecHelper, :type => :model >> end >> >> Zach > > Hi Zach. I put the methods into the module "ModelSpeccer" in lib/ > ModelSpeccer.rb and then added this to spec_helper.rb : > config.include ModelSpeccer, :type => :model > > Unfortunately though, when I run my specs, Ruby isn't finding the > module: This isn't ruby - if you want ruby to include it, you'll need a require statement (or a load, or autoload). If you want rails const_missing stuff to load it automatically, I'm guessing you'll need to name the file lib/model_speccer.rb, and the module to be named ModelSpeccer Scott From lists-rspec at shopwatch.org Sat Aug 30 10:52:48 2008 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Sat, 30 Aug 2008 10:52:48 -0400 Subject: [rspec-users] I want RSpec for CSS layout. In-Reply-To: References: <48AB67E2.1000009@shopwatch.org> Message-ID: <48B95EC0.3060606@shopwatch.org> Scott Taylor wrote: > > On Aug 29, 2008, at 2:39 PM, Dan North wrote: > >> ooh, that would be lovely. >> >> LayoutBehave anyone? >> > > Well, I don't see why there couldn't be one, assuming there was a CSS > parser out there. > > I've started a treetop CSS2 parser, but just don't have the time to > devote to it. Anyone interested? Ah, but a CSS parser wouldn't tell me if a browser bug had mis-rendered the page. What I really want to do is automate the oh-so-common process of: 1. Make some seemingly trivial CSS change 2. See that it seems to work 3. Go about my day 4. Five days later, when I hit a different code path in IE6, notice that it looks funny and never used to 5. Try to bisect the version to see when it happened which has to happen in the browser (assuming that the browser passes its miscalculated X/Y coordinates back to the DOM properly). > > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From zach.dennis at gmail.com Sat Aug 30 11:33:19 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Sat, 30 Aug 2008 11:33:19 -0400 Subject: [rspec-users] Application-wide spec_helper method In-Reply-To: References: <9C60741D-BEE4-4A9B-9DFA-F32BF134759D@deadorange.com> <57c63afe0808280502g6fc2ccf0r57d939167ad0ccb6@mail.gmail.com> <3B4561D4-9743-49EC-8103-43FF40B69F2E@deadorange.com> <85d99afe0808281027o78627c3aj6610a6eeab48cffd@mail.gmail.com> <4E011A29-B8F4-4B5B-AB40-B2E0A59746D5@deadorange.com> Message-ID: <85d99afe0808300833lfc12d8dle101408fb983df55@mail.gmail.com> On Fri, Aug 29, 2008 at 11:05 PM, Scott Taylor wrote: > > On Aug 29, 2008, at 10:40 PM, Nick Hoffman wrote: > >> On 2008-08-28, at 13:27, Zach Dennis wrote: >>> >>> You can put it in a module and include it for model specs in >>> spec_helper.rb >>> >>> Spec::Runner.configure do |config| >>> # ... >>> config.include DescribeModelAttributeSpecHelper, :type => :model >>> end >>> >>> Zach >> >> Hi Zach. I put the methods into the module "ModelSpeccer" in >> lib/ModelSpeccer.rb and then added this to spec_helper.rb : >> config.include ModelSpeccer, :type => :model >> >> Unfortunately though, when I run my specs, Ruby isn't finding the module: > > This isn't ruby - if you want ruby to include it, you'll need a require > statement (or a load, or autoload). I think Scott means to say "this isn't rspec, you need to tell ruby to load the file using require". I would keep your spec helpers separate from application code (like app/ or lib/ directories). I typically put these files in spec/spec_helpers/ and then in your spec_helper.rb I require all ruby files like so: Dir[File.dirname(__FILE__) + "/spec_helpers/**/*.rb"].each do |f| require f end Just a thought, -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From matt at mattwynne.net Sat Aug 30 11:58:21 2008 From: matt at mattwynne.net (Matt Wynne) Date: Sat, 30 Aug 2008 16:58:21 +0100 Subject: [rspec-users] I want RSpec for CSS layout. In-Reply-To: <48B95EC0.3060606@shopwatch.org> References: <48AB67E2.1000009@shopwatch.org> <48B95EC0.3060606@shopwatch.org> Message-ID: <4740B5E6-9701-4DAE-B912-7C90EB5FC346@mattwynne.net> I have been in a few pub conversations now about 'photoshop-driven- development' where we show the machine what the page should look like (a photoshop mock-up), and keeps failing the build until we produce something that every browser can render to look like the mock-up. Surely with all that CCTV out there in the world now there must be some image-recognition software we could use to make this dream come true. On 30 Aug 2008, at 15:52, Jay Levitt wrote: > Scott Taylor wrote: >> On Aug 29, 2008, at 2:39 PM, Dan North wrote: >>> ooh, that would be lovely. >>> >>> LayoutBehave anyone? >>> >> Well, I don't see why there couldn't be one, assuming there was a >> CSS parser out there. >> I've started a treetop CSS2 parser, but just don't have the time >> to devote to it. Anyone interested? > > Ah, but a CSS parser wouldn't tell me if a browser bug had mis- > rendered the page. What I really want to do is automate the oh-so- > common process of: > > 1. Make some seemingly trivial CSS change > 2. See that it seems to work > 3. Go about my day > 4. Five days later, when I hit a different code path in IE6, notice > that it looks funny and never used to > 5. Try to bisect the version to see when it happened > > which has to happen in the browser (assuming that the browser > passes its miscalculated X/Y coordinates back to the DOM properly). > >> Scott >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Sat Aug 30 12:02:32 2008 From: matt at mattwynne.net (Matt Wynne) Date: Sat, 30 Aug 2008 17:02:32 +0100 Subject: [rspec-users] story vs feature (was Documentation for Plain-Text Stories) In-Reply-To: References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> <1341C3E7-DB99-4F7D-8576-60F2107B3C7F@parkerhill.com> <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> Message-ID: On 29 Aug 2008, at 19:37, Dan North wrote: > 2008/8/24 David Chelimsky > [...] > Sadly, "spec" has just as much baggage, if not more, as "test" does. > These days we're calling these things "code examples," (tongue > pressing into cheek) so maybe we should change the name to > rcodeexample? > > Or rbehave? > > The rbehave.org domain is available (I registered it some time > ago), and rspec has naturally evolved from its original goal of > code-level specs to become a full-stack behaviour description > framework. or RubyDD or RuBehave :) I actually really like calling them specs rather than tests, at a unit-testing level. It makes a real difference to me that I'm expressing a *specification* for the class I'm about to code - it makes it much more natural to do it before you write the implementation when it's a spec rather than a test. cheers, Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at mwilden.com Sat Aug 30 12:35:52 2008 From: mark at mwilden.com (Mark Wilden) Date: Sat, 30 Aug 2008 09:35:52 -0700 Subject: [rspec-users] Application-wide spec_helper method In-Reply-To: <85d99afe0808300833lfc12d8dle101408fb983df55@mail.gmail.com> References: <9C60741D-BEE4-4A9B-9DFA-F32BF134759D@deadorange.com> <57c63afe0808280502g6fc2ccf0r57d939167ad0ccb6@mail.gmail.com> <3B4561D4-9743-49EC-8103-43FF40B69F2E@deadorange.com> <85d99afe0808281027o78627c3aj6610a6eeab48cffd@mail.gmail.com> <4E011A29-B8F4-4B5B-AB40-B2E0A59746D5@deadorange.com> <85d99afe0808300833lfc12d8dle101408fb983df55@mail.gmail.com> Message-ID: <3c30da400808300935l4cfcee95o90de951bcbc3c22a@mail.gmail.com> On Sat, Aug 30, 2008 at 8:33 AM, Zach Dennis wrote: > On Fri, Aug 29, 2008 at 11:05 PM, Scott Taylor > > This isn't ruby - if you want ruby to include it, you'll need a require > > statement (or a load, or autoload). > > I think Scott means to say "this isn't rspec, you need to tell ruby to > load the file using require". > I think Zach means to say "this isn't Rails." :) ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From mailing_lists at railsnewbie.com Sat Aug 30 13:29:53 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 30 Aug 2008 13:29:53 -0400 Subject: [rspec-users] I want RSpec for CSS layout. In-Reply-To: <48B95EC0.3060606@shopwatch.org> References: <48AB67E2.1000009@shopwatch.org> <48B95EC0.3060606@shopwatch.org> Message-ID: <5B4AAD53-13C6-46AE-BADA-DA88472C6374@railsnewbie.com> On Aug 30, 2008, at 10:52 AM, Jay Levitt wrote: > Scott Taylor wrote: >> On Aug 29, 2008, at 2:39 PM, Dan North wrote: >>> ooh, that would be lovely. >>> >>> LayoutBehave anyone? >>> >> Well, I don't see why there couldn't be one, assuming there was a >> CSS parser out there. >> I've started a treetop CSS2 parser, but just don't have the time to >> devote to it. Anyone interested? > > Ah, but a CSS parser wouldn't tell me if a browser bug had mis- > rendered the page. What I really want to do is automate the oh-so- > common process of: > > 1. Make some seemingly trivial CSS change > 2. See that it seems to work > 3. Go about my day > 4. Five days later, when I hit a different code path in IE6, notice > that it looks funny and never used to > 5. Try to bisect the version to see when it happened > > which has to happen in the browser (assuming that the browser passes > its miscalculated X/Y coordinates back to the DOM properly). Well, I see no reason why you couldn't build derivatives of the compliant parser to match certain browsers. Some of these bugs are well known, especially the IE 5.5/6 box model ones. Plus - if something *passed* in the parser, but *failed* in the browser, it would be a legitimate bug with the parser (derivative). Scott From tero at tilus.net Sat Aug 30 14:12:03 2008 From: tero at tilus.net (Tero Tilus) Date: Sat, 30 Aug 2008 21:12:03 +0300 Subject: [rspec-users] story vs feature (was Documentation for Plain-Text Stories) In-Reply-To: References: <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> <1341C3E7-DB99-4F7D-8576-60F2107B3C7F@parkerhill.com> <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> Message-ID: <20080830181203.GQ3867@uivelo.tilus.net> 2008-08-30 17:02, Matt Wynne: > RuBehave Now _that's_ cool! I love it! -- Tero Tilus ## 050 3635 235 ## http://www.tilus.net/koti/tero/ From mailing_lists at railsnewbie.com Sat Aug 30 14:31:59 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 30 Aug 2008 14:31:59 -0400 Subject: [rspec-users] story vs feature (was Documentation for Plain-Text Stories) In-Reply-To: <20080830181203.GQ3867@uivelo.tilus.net> References: <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> <1341C3E7-DB99-4F7D-8576-60F2107B3C7F@parkerhill.com> <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> <20080830181203.GQ3867@uivelo.tilus.net> Message-ID: <3C05E277-985C-4C63-AE49-4342CD703E47@railsnewbie.com> On Aug 30, 2008, at 2:12 PM, Tero Tilus wrote: > 2008-08-30 17:02, Matt Wynne: >> RuBehave > > Now _that's_ cool! I love it! Personally, I always liked the rbehave / rspec combo, of Mike Myers & Ali G. Scott From ashley.moran at patchspace.co.uk Sat Aug 30 14:56:08 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Sat, 30 Aug 2008 19:56:08 +0100 Subject: [rspec-users] I want RSpec for CSS layout. In-Reply-To: <4740B5E6-9701-4DAE-B912-7C90EB5FC346@mattwynne.net> References: <48AB67E2.1000009@shopwatch.org> <48B95EC0.3060606@shopwatch.org> <4740B5E6-9701-4DAE-B912-7C90EB5FC346@mattwynne.net> Message-ID: On Aug 30, 2008, at 4:58 pm, Matt Wynne wrote: > I have been in a few pub conversations now about 'photoshop-driven- > development' where we show the machine what the page should look > like (a photoshop mock-up), and keeps failing the build until we > produce something that every browser can render to look like the > mock-up. I had a nose around the WebKit source a while back, and it looked like their integration testing was done basically by pure regression tests - save a PNG (or whatever) in a directory, and compare page renderings to the last reference copy. However that will break on different platforms with different font renderings, anti-aliasing algorithms etc unless you make it fuzzy (maybe blur the output and use a subtract calculation). Maybe you could make it work with the Watir+screenshot code that Aslak made ages ago? Just a thought anyway. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From lists at ruby-forum.com Sat Aug 30 15:38:59 2008 From: lists at ruby-forum.com (Joseph Wilk) Date: Sat, 30 Aug 2008 21:38:59 +0200 Subject: [rspec-users] I want RSpec for CSS layout. In-Reply-To: References: <48AB67E2.1000009@shopwatch.org> Message-ID: <2f896cac42fbfadb748556362da1f9f9@ruby-forum.com> I do some CSS testing through selenium and screw-unit-server. Mainly checking what the style properties of certain dom elements are after executing some JavaScript. I use selenium-grid to invoke the different browsers. Defining what is 'correct' seems a big difficulty. Sometimes a little variation in rendering is ok and in other designs it breaks everything! I've been playing with the idea of inspecting the position of elements in a page from the dom and using this to generate a SVG layout style document. I'm thinking more position rather than colours/fonts. At somepoint when I'm happy with the design I can generate this SVG and then check against this to see if the layout matches as things change. Nice thing about SVG is that its easy to change and has a visual representation to be inspected. The SVG becomes like the spec. my two cents. -- Joseph Wilk http://www.joesniff.co.uk Scott Taylor wrote: > On Aug 29, 2008, at 2:39 PM, Dan North wrote: > >> ooh, that would be lovely. >> >> LayoutBehave anyone? >> > > Well, I don't see why there couldn't be one, assuming there was a CSS > parser out there. > > I've started a treetop CSS2 parser, but just don't have the time to > devote to it. Anyone interested? > > Scott -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Sun Aug 31 07:56:07 2008 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 31 Aug 2008 12:56:07 +0100 Subject: [rspec-users] story vs feature (was Documentation for Plain-Text Stories) In-Reply-To: <3C05E277-985C-4C63-AE49-4342CD703E47@railsnewbie.com> References: <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> <1341C3E7-DB99-4F7D-8576-60F2107B3C7F@parkerhill.com> <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> <20080830181203.GQ3867@uivelo.tilus.net> <3C05E277-985C-4C63-AE49-4342CD703E47@railsnewbie.com> Message-ID: <30B96A63-7091-4083-B502-ED7BF24E7E43@mattwynne.net> On 30 Aug 2008, at 19:31, Scott Taylor wrote: > > On Aug 30, 2008, at 2:12 PM, Tero Tilus wrote: > >> 2008-08-30 17:02, Matt Wynne: >>> RuBehave >> >> Now _that's_ cool! I love it! > > Personally, I always liked the rbehave / rspec combo, of Mike Myers > & Ali G. > > Scott :) One of the main adoption barriers we had with rspec at the BBC was the uniquely British problem of 'rspec' sounding, to the uninitiated, rather too much like 'arse peck'. From dchelimsky at gmail.com Sun Aug 31 09:21:32 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 31 Aug 2008 08:21:32 -0500 Subject: [rspec-users] story vs feature (was Documentation for Plain-Text Stories) In-Reply-To: <30B96A63-7091-4083-B502-ED7BF24E7E43@mattwynne.net> References: <48AA4BFD.6010401@e4net.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> <1341C3E7-DB99-4F7D-8576-60F2107B3C7F@parkerhill.com> <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> <20080830181203.GQ3867@uivelo.tilus.net> <3C05E277-985C-4C63-AE49-4342CD703E47@railsnewbie.com> <30B96A63-7091-4083-B502-ED7BF24E7E43@mattwynne.net> Message-ID: <57c63afe0808310621p1da0a3a0w88d7593f37f30494@mail.gmail.com> On Sun, Aug 31, 2008 at 6:56 AM, Matt Wynne wrote: > On 30 Aug 2008, at 19:31, Scott Taylor wrote: > >> >> On Aug 30, 2008, at 2:12 PM, Tero Tilus wrote: >> >>> 2008-08-30 17:02, Matt Wynne: >>>> >>>> RuBehave >>> >>> Now _that's_ cool! I love it! >> >> Personally, I always liked the rbehave / rspec combo, of Mike Myers & Ali >> G. >> >> Scott > > :) > > One of the main adoption barriers we had with rspec at the BBC was the > uniquely British problem of 'rspec' sounding, to the uninitiated, rather too > much like 'arse peck'. I think that could be resolved with a CI-driven contraption that you keep in your back pocket and gives you a little peck whenever the build fails. WDYT? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sun Aug 31 09:39:56 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 31 Aug 2008 08:39:56 -0500 Subject: [rspec-users] story vs feature (was Documentation for Plain-Text Stories) In-Reply-To: References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> <1341C3E7-DB99-4F7D-8576-60F2107B3C7F@parkerhill.com> <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> Message-ID: <57c63afe0808310639q5b2f09c8x8722cc37044df384@mail.gmail.com> On Fri, Aug 29, 2008 at 1:37 PM, Dan North wrote: > At the risk of being a bit controversial... > > 2008/8/24 David Chelimsky > [...] >> >> Sadly, "spec" has just as much baggage, if not more, as "test" does. >> These days we're calling these things "code examples," (tongue >> pressing into cheek) so maybe we should change the name to >> rcodeexample? I was really only joking. > Or rbehave? > > The rbehave.org domain is available (I registered it some time ago), and > rspec has naturally evolved from its original goal of code-level specs to > become a full-stack behaviour description framework. I think we're not at the point where we can really play with the name of the code-level framework. Changing rspec's name would impact a lot of people. Consider the following: * RubySpec uses MSpec, based on RSpec. * Ruby itself runs its build against RubySpec. * NetBeans supports RSpec. * TextMate's official bundle repo includes an RSpec bundle. * Numerous open source projects use rspec for code examples. * Including many rails plugins, so rails apps are depending on plugins that depend on rspec. I'm not saying it's something that should never happen. But we're in a time right now (IMO) where it's both too late and too early to do it. Too late because of wide usage and momentum. Too early because a) it's not deeply ingrained enough quite yet for users to accept the burden of the name change and b) we don't really have the team/infrastructure/support system to make it an easy transition. > Just a thought. > > With regard to the stories and features thing, I see a BDD-shaped story as > providing a context - and justification - for a feature: > > As a [stakeholder] > I want [a feature] > So that [I get some benefit] > > Before we started using this structure, a "story" would often just be the > middle line, so it wasn't immediately obvious who the stakeholder was or why > they wanted the feature, which in turn would often lead to over-work, > under-work or just plain wrong-work. Of course the word "story" has its own > baggage. In XP a story is "a placeholder/promise for a conversation", and as > such could just be a title scribbled on a card. I wrote the story article to > put this all in context - if you ask 5 agile folks what a story is, you will > likely get 6 answers. > > I agree that the feature is the interesting thing, and also that there may > be several stories about the same feature in different broad contexts. In > any event the scenarios provide the definition of "Done" for the feature, > which is kind of the whole point. So I guess I'm saying I'm ambivalent about > the story/feature distinction. I don't look at stories as work units as much > as a more formal description of (some aspect of) a feature. > > After speaking with Aslak - and some FDD folks I met at Agile 2008 - I can > fully agree with organising stories by feature. Stories? Do you mean scenarios? > In fact in Peter Coad's FDD > they have features within feature sets, within subject areas, which might > well map to stories within features within [not sure - subject areas? > themes? something broader anyway]. FDD features seem to be "thinner" than > what I understand Aslak's description of features to be. It seems that there is no word that is baggage-free. I think that trying to think of this in terms of FDD would just add more confusion. I do like Feature, in part, because it refers to the system. User Stories are about how a user uses the system, where as a Feature is about how the system responds to use. So Features are about system behaviour. Maybe we should just go back to where we started, and call these things (Stories/Features) ... ahem ... Behaviours. It's a thought. > One thing that makes me happy is that we seem to have consensus around the > word "scenario" - which is where the outside-in work really starts. Agreed. Stories and/or Features seem to be more about organization and communication. Scenarios drive code development. FWIW, David > > Cheers, > Dan > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jonathan at parkerhill.com Sun Aug 31 09:45:58 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Sun, 31 Aug 2008 09:45:58 -0400 Subject: [rspec-users] story vs feature (was Documentation for Plain-Text Stories) In-Reply-To: <30B96A63-7091-4083-B502-ED7BF24E7E43@mattwynne.net> References: <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> <1341C3E7-DB99-4F7D-8576-60F2107B3C7F@parkerhill.com> <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> <20080830181203.GQ3867@uivelo.tilus.net> <3C05E277-985C-4C63-AE49-4342CD703E47@railsnewbie.com> <30B96A63-7091-4083-B502-ED7BF24E7E43@mattwynne.net> Message-ID: <55E64C31-95D8-4D87-810F-2D87563CD755@parkerhill.com> On Aug 31, 2008, at 7:56 AM, Matt Wynne wrote: > On 30 Aug 2008, at 19:31, Scott Taylor wrote: > >> >> On Aug 30, 2008, at 2:12 PM, Tero Tilus wrote: >> >>> 2008-08-30 17:02, Matt Wynne: >>>> RuBehave >>> >>> Now _that's_ cool! I love it! >> >> Personally, I always liked the rbehave / rspec combo, of Mike >> Myers & Ali G. >> >> Scott > > :) > > One of the main adoption barriers we had with rspec at the BBC was > the uniquely British problem of 'rspec' sounding, to the > uninitiated, rather too much like 'arse peck'. with cucumber? ouch! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From jonathan at parkerhill.com Sun Aug 31 10:02:22 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Sun, 31 Aug 2008 10:02:22 -0400 Subject: [rspec-users] story vs feature (was Documentation for Plain-Text Stories) In-Reply-To: <57c63afe0808310639q5b2f09c8x8722cc37044df384@mail.gmail.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> <1341C3E7-DB99-4F7D-8576-60F2107B3C7F@parkerhill.com> <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> <57c63afe0808310639q5b2f09c8x8722cc37044df384@mail.gmail.com> Message-ID: <690C297B-6C0A-46D4-861E-7FAFA08502FB@parkerhill.com> On Aug 31, 2008, at 9:39 AM, David Chelimsky wrote: > Agreed. Stories and/or Features seem to be more about organization and > communication. Scenarios drive code development. +1 I also like to organize them into workflows, tasks, goals Which makes me think maybe the scenario should be a more independent, reusable item From dchelimsky at gmail.com Sun Aug 31 10:17:52 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 31 Aug 2008 09:17:52 -0500 Subject: [rspec-users] story vs feature (was Documentation for Plain-Text Stories) In-Reply-To: <690C297B-6C0A-46D4-861E-7FAFA08502FB@parkerhill.com> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> <1341C3E7-DB99-4F7D-8576-60F2107B3C7F@parkerhill.com> <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> <57c63afe0808310639q5b2f09c8x8722cc37044df384@mail.gmail.com> <690C297B-6C0A-46D4-861E-7FAFA08502FB@parkerhill.com> Message-ID: <57c63afe0808310717w17b3ca50i28b092f1cfd1fa30@mail.gmail.com> On Sun, Aug 31, 2008 at 9:02 AM, Jonathan Linowes wrote: > > On Aug 31, 2008, at 9:39 AM, David Chelimsky wrote: > >> Agreed. Stories and/or Features seem to be more about organization and >> communication. Scenarios drive code development. > > +1 > I also like to organize them into workflows, tasks, goals > Which makes me think maybe the scenario should be a more independent, > reusable item We've talked about a tagging scheme that would allow you run scenarios in any logical combinations, but unless we want to go to one-scenario-per-file (which I, personally, don't), we still need a default organization scheme. WDYT? From cremes.devlist at mac.com Sun Aug 31 10:36:46 2008 From: cremes.devlist at mac.com (Chuck Remes) Date: Sun, 31 Aug 2008 09:36:46 -0500 Subject: [rspec-users] spec'ing the existence of #require Message-ID: <4F69D24C-47C2-436F-8B19-BCD2E87FB2C3@mac.com> I looked through the mailing list archive but unfortunately my search terms are too generic (spec and require...). I am writing ruby code that runs under jruby in an embedded environment. Periodically I will install new code that passes all specs only to have it fail when it can't find a new class I defined (missing #require). My spec_helper.rb file does a wildcard search and loads all rb files in the tree, so it always picks up new files. Clearly I need to change that and be more specific in my require lines. Any suggestions on how to best accomplish this? cr From matt at mattwynne.net Sun Aug 31 13:26:49 2008 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 31 Aug 2008 18:26:49 +0100 Subject: [rspec-users] spec'ing the existence of #require In-Reply-To: <4F69D24C-47C2-436F-8B19-BCD2E87FB2C3@mac.com> References: <4F69D24C-47C2-436F-8B19-BCD2E87FB2C3@mac.com> Message-ID: <6BD27E9E-3B3C-47C0-9273-C5672ADCDC24@mattwynne.net> Could you put a mocking expectation on Kernel? (which is where #require is defined) Kernel.should_receive(:require).with(expected_file_name) On 31 Aug 2008, at 15:36, Chuck Remes wrote: > I looked through the mailing list archive but unfortunately my > search terms are too generic (spec and require...). > > I am writing ruby code that runs under jruby in an embedded > environment. Periodically I will install new code that passes all > specs only to have it fail when it can't find a new class I defined > (missing #require). > > My spec_helper.rb file does a wildcard search and loads all rb > files in the tree, so it always picks up new files. Clearly I need > to change that and be more specific in my require lines. > > Any suggestions on how to best accomplish this? > > cr > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Sun Aug 31 13:30:08 2008 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 31 Aug 2008 18:30:08 +0100 Subject: [rspec-users] I want RSpec for CSS layout. In-Reply-To: References: <48AB67E2.1000009@shopwatch.org> <48B95EC0.3060606@shopwatch.org> <4740B5E6-9701-4DAE-B912-7C90EB5FC346@mattwynne.net> Message-ID: On 30 Aug 2008, at 19:56, Ashley Moran wrote: > > On Aug 30, 2008, at 4:58 pm, Matt Wynne wrote: > >> I have been in a few pub conversations now about 'photoshop-driven- >> development' where we show the machine what the page should look >> like (a photoshop mock-up), and keeps failing the build until we >> produce something that every browser can render to look like the >> mock-up. > > > I had a nose around the WebKit source a while back, and it looked > like their integration testing was done basically by pure > regression tests - save a PNG (or whatever) in a directory, and > compare page renderings to the last reference copy. However that > will break on different platforms with different font renderings, > anti-aliasing algorithms etc unless you make it fuzzy (maybe blur > the output and use a subtract calculation). > > Maybe you could make it work with the Watir+screenshot code that > Aslak made ages ago? This is going to rock. Has Lazyweb started working on it yet? From mailing_lists at railsnewbie.com Sun Aug 31 13:42:58 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 31 Aug 2008 13:42:58 -0400 Subject: [rspec-users] spec'ing the existence of #require In-Reply-To: <4F69D24C-47C2-436F-8B19-BCD2E87FB2C3@mac.com> References: <4F69D24C-47C2-436F-8B19-BCD2E87FB2C3@mac.com> Message-ID: On Aug 31, 2008, at 10:36 AM, Chuck Remes wrote: > I looked through the mailing list archive but unfortunately my > search terms are too generic (spec and require...). > > I am writing ruby code that runs under jruby in an embedded > environment. Periodically I will install new code that passes all > specs only to have it fail when it can't find a new class I defined > (missing #require). > > My spec_helper.rb file does a wildcard search and loads all rb files > in the tree, Why? Why don't you just have it load lib/your_project_name.rb, which requires everything else? Scott > so it always picks up new files. Clearly I need to change that and > be more specific in my require lines. > > Any suggestions on how to best accomplish this? > > cr > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From cremes.devlist at mac.com Sun Aug 31 15:38:49 2008 From: cremes.devlist at mac.com (Chuck Remes) Date: Sun, 31 Aug 2008 14:38:49 -0500 Subject: [rspec-users] spec'ing the existence of #require In-Reply-To: References: <4F69D24C-47C2-436F-8B19-BCD2E87FB2C3@mac.com> Message-ID: <68E26C1E-A87E-4951-A1AC-877F4A35FAB6@mac.com> On Aug 31, 2008, at 12:42 PM, Scott Taylor wrote: > > On Aug 31, 2008, at 10:36 AM, Chuck Remes wrote: > >> I looked through the mailing list archive but unfortunately my >> search terms are too generic (spec and require...). >> >> I am writing ruby code that runs under jruby in an embedded >> environment. Periodically I will install new code that passes all >> specs only to have it fail when it can't find a new class I defined >> (missing #require). >> >> My spec_helper.rb file does a wildcard search and loads all rb >> files in the tree, > > Why? Why don't you just have it load lib/your_project_name.rb, > which requires everything else? I don't know. Is that the right way to do it? The way I am doing it now mimics how the rspec gem includes all of the rspec files for testing, so I took that as an accepted practice. I'll be happy to try your method if it doesn't have a hidden gotcha too. cr From lists at ruby-forum.com Sun Aug 31 15:40:23 2008 From: lists at ruby-forum.com (Joseph Wilk) Date: Sun, 31 Aug 2008 21:40:23 +0200 Subject: [rspec-users] How to spec the existence of specs In-Reply-To: References: <6195F570-5770-4BEB-8264-CECD91CC827D@deadorange.com> Message-ID: <856dfd450e0abafe95c14a0a2091e3ec@ruby-forum.com> I've been giving this some thought, I've not had the chance to test it out yet, but here are my examples: -- it "should add a 'it' test" do example_group = Class.new(Spec::Example::ExampleGroup) example_group.should_receive(:it).with(...) ... example.class_eval do describe_model_attribute(model, attribute, valid_values, invalid_values) end end describe "valid model" it "should generate a spec which will pass" do example_group = Class.new(Spec::Example::ExampleGroup) do describe_model_attribute(model, attribute, valid_values, invalid_values) end example_group.run.should be_true end end -- So this means the scope of 'it' and 'describe' are against ExampleGroup. Giving you something to mock against to check 'it'/'describe'. Invoking run on the ExampleGroup class will run the specs you generate, and then you can check if they succeed/fail. An alternative to checking the output could be to test that the model has the relevant methods invoked on it. I hope that helps -- Joseph Wilk http://www.joesniff.co.uk Nick Hoffman wrote: > On 2008-08-29, at 05:06, Joseph Wilk wrote: >>> Each method generates specs depending on its arguments >> >> How does each method generate the specs? >> * Using script/generate rspec... >> or >> * File handling and writing your own? >> >> -- >> Joseph Wilk >> http://www.joesniff.co.uk > > Hi again Joseph. Each method generates the specs by calling RSpec's > #describe and #it methods, like this: > > def check_model_attributes_when_nil(model, ... > ... > columns_to_check.each do |attribute| > describe model, "with '#{attribute}' set to nil" do > ... > it "should be invalid" do > @model_instance.should_not be_valid > end > ... > end > end -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Sun Aug 31 15:58:10 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 31 Aug 2008 14:58:10 -0500 Subject: [rspec-users] spec'ing the existence of #require In-Reply-To: <68E26C1E-A87E-4951-A1AC-877F4A35FAB6@mac.com> References: <4F69D24C-47C2-436F-8B19-BCD2E87FB2C3@mac.com> <68E26C1E-A87E-4951-A1AC-877F4A35FAB6@mac.com> Message-ID: <57c63afe0808311258h67c3359k218b308f881e0ab2@mail.gmail.com> On Sun, Aug 31, 2008 at 2:38 PM, Chuck Remes wrote: > > On Aug 31, 2008, at 12:42 PM, Scott Taylor wrote: > >> >> On Aug 31, 2008, at 10:36 AM, Chuck Remes wrote: >> >>> I looked through the mailing list archive but unfortunately my search >>> terms are too generic (spec and require...). >>> >>> I am writing ruby code that runs under jruby in an embedded environment. >>> Periodically I will install new code that passes all specs only to have it >>> fail when it can't find a new class I defined (missing #require). >>> >>> My spec_helper.rb file does a wildcard search and loads all rb files in >>> the tree, >> >> Why? Why don't you just have it load lib/your_project_name.rb, which >> requires everything else? > > I don't know. Is that the right way to do it? The way I am doing it now > mimics how the rspec gem includes all of the rspec files for testing, It does? What I see is that the spec files all include spec_helper.rb, which, in turn, adds lib to the path and then requires 'spec'. What are you thinking of when you say the gem includes all the files for testing? > so I > took that as an accepted practice. I'll be happy to try your method if it > doesn't have a hidden gotcha too. > > cr > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cremes.devlist at mac.com Sun Aug 31 22:27:21 2008 From: cremes.devlist at mac.com (Chuck Remes) Date: Sun, 31 Aug 2008 21:27:21 -0500 Subject: [rspec-users] spec'ing the existence of #require In-Reply-To: <57c63afe0808311258h67c3359k218b308f881e0ab2@mail.gmail.com> References: <4F69D24C-47C2-436F-8B19-BCD2E87FB2C3@mac.com> <68E26C1E-A87E-4951-A1AC-877F4A35FAB6@mac.com> <57c63afe0808311258h67c3359k218b308f881e0ab2@mail.gmail.com> Message-ID: On Aug 31, 2008, at 2:58 PM, David Chelimsky wrote: > On Sun, Aug 31, 2008 at 2:38 PM, Chuck Remes > wrote: >> >> On Aug 31, 2008, at 12:42 PM, Scott Taylor wrote: >> >>> >>> On Aug 31, 2008, at 10:36 AM, Chuck Remes wrote: >>> >>>> I looked through the mailing list archive but unfortunately my >>>> search >>>> terms are too generic (spec and require...). >>>> >>>> I am writing ruby code that runs under jruby in an embedded >>>> environment. >>>> Periodically I will install new code that passes all specs only >>>> to have it >>>> fail when it can't find a new class I defined (missing #require). >>>> >>>> My spec_helper.rb file does a wildcard search and loads all rb >>>> files in >>>> the tree, >>> >>> Why? Why don't you just have it load lib/your_project_name.rb, >>> which >>> requires everything else? >> >> I don't know. Is that the right way to do it? The way I am doing it >> now >> mimics how the rspec gem includes all of the rspec files for testing, > > It does? What I see is that the spec files all include spec_helper.rb, > which, in turn, adds lib to the path and then requires 'spec'. What > are you thinking of when you say the gem includes all the files for > testing? You are right. That is *not* what rspec does. I know I copied this from some major gem that used rspec but now I can't find it. I retract what I said about rspec including everything (via the spec_helper.rb). I'll try creating a single file that #requires everything I need and see if that accomplishes all I need. Thanks for the tips. cr