From r_j_h_box-sf at yahoo.com Sun Feb 1 02:40:54 2009 From: r_j_h_box-sf at yahoo.com (r_j_h_box-sf at yahoo.com) Date: Sat, 31 Jan 2009 23:40:54 -0800 (PST) Subject: [rspec-users] resource urls only work *after* a get() in controller spec References: <960691.61104.qm@web31811.mail.mud.yahoo.com> <4984FDE4.4000903@benmabey.com> Message-ID: <917544.78176.qm@web31807.mail.mud.yahoo.com> thanks, Ben - that didn't do the trick, though. I traced it down as far as this: the controller hasn't initialized its current url - that's the immediate cause of the method-on-nil complaint. It hasn't, because the controller isn't technically handling a request yet (i.e., process()). I tried monkey-patching the controller to allow me to call its initialize_current_url to get around this, but I didn't (yet) find how to fake up its request and params sufficiently to have that work. Understandably, the controller can't know what the current url is, unless rpsec-rails were to have a way to discover it from the example group. I'm not sure that I'm proposing a change to a declarative style for controller actions - for my purpose, I'd be satisfied to fake it to think 'index' is the current url (in advance of processing the real request as specified by get() and friends). Hopefully this rings enough bells to make a workaround self-evident to somebody. Anybody? Else I'll see what I can dig up from the rspec/rspec-rails source that can be enough of a resource. Thanks, Randy ----- Original Message ---- > From: Ben Mabey > To: rspec-users > Sent: Saturday, January 31, 2009 5:41:56 PM > Subject: Re: [rspec-users] resource urls only work *after* a get() in controller spec > > r_j_h_box-sf at yahoo.com wrote: > > I'm encountering an interesting symptom during example execution. I'm > > making a shared example group that dries up belongs-to-me before_filter > > testing, and it makes a callback to the example group that says > > it_should_behave_like that. The callback tells the shared example > > where to expect a redirect for failure. > > > > It seems that prior to > > executing a get() (etc), the resource-based url functions aren't > > accessible. Following the get(), topics_url works fine. But before > > then, it gives an error like this: > > > > http://pastie.org/376096 > > > > Is > > this a known issue? Is there a workaround I can use? > For a workaround try doing a "include ActionController::UrlWriter" in your > shared example group. > > -Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Sun Feb 1 02:58:49 2009 From: lists at ruby-forum.com (Jim Morris) Date: Sun, 1 Feb 2009 08:58:49 +0100 Subject: [rspec-users] [Cucumber, Merb, Webrat] undefined method 'response' for In-Reply-To: <7bfeb788238eb4753e075ed48ee4e498@ruby-forum.com> References: <7bfeb788238eb4753e075ed48ee4e498@ruby-forum.com> Message-ID: Justin Smestad wrote: > Daniel, I have fixed this in my fork: > http://github.com/jsmestad/merb_cucumber/tree/master > I still get the same error after installing jsmestad-merb_cucumber-0.5.1.3 from gems.github.com Did the version get bumped OK? or do I need to clone and build locally? Thanks -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sun Feb 1 03:04:33 2009 From: lists at ruby-forum.com (Jim Morris) Date: Sun, 1 Feb 2009 09:04:33 +0100 Subject: [rspec-users] [Cucumber, Merb, Webrat] undefined method 'response' for In-Reply-To: References: <7bfeb788238eb4753e075ed48ee4e498@ruby-forum.com> Message-ID: <830d29f36c5d6c408b07bd803d489693@ruby-forum.com> Jim Morris wrote: > Justin Smestad wrote: >> Daniel, I have fixed this in my fork: >> http://github.com/jsmestad/merb_cucumber/tree/master >> > > I still get the same error after installing > jsmestad-merb_cucumber-0.5.1.3 from gems.github.com > Did the version get bumped OK? or do I need to clone and build locally? > > Thanks never mind, NOTE you have to redo the... merb-gen cucumber --session-type webrat after installing your fixed version. Thanks -- Posted via http://www.ruby-forum.com/. From phlip2005 at gmail.com Sun Feb 1 10:50:22 2009 From: phlip2005 at gmail.com (Phlip) Date: Sun, 01 Feb 2009 07:50:22 -0800 Subject: [rspec-users] undefined method `inherit' for Merb::Test::ExampleGroup Message-ID: RSpeckers: I'm trying to install this into a Merb-generated RSpec rig: http://code.jeremyevans.net/doc/fixture_dependencies/ It requires inserting their test case into RSpec. This is the documented way to do it: describe 'Post' do inherit FixtureDependencies::SequelTestCase And that leads to the syntax error in the subject line. (No stack trace is available - ask the Merb spec runner why!) Has anyone seen that one before? -- Phlip From tomk32 at gmx.de Sun Feb 1 13:36:21 2009 From: tomk32 at gmx.de (Thomas R. Koll) Date: Sun, 1 Feb 2009 19:36:21 +0100 Subject: [rspec-users] undefined method `inherit' for Merb::Test::ExampleGroup In-Reply-To: References: Message-ID: Hi Phlip, Are you sure it's inherit and not extend? Second, I guess the missing trace is cuz you should put a 'before' block into the describe. Took me some time to figure that out last month... so try this and let us know the results: describe 'Post' do before do extend FixtureDependencies::SequelTestCase end end ciao, tom Am 01.02.2009 um 16:50 schrieb Phlip: > RSpeckers: > > I'm trying to install this into a Merb-generated RSpec rig: > > http://code.jeremyevans.net/doc/fixture_dependencies/ > > It requires inserting their test case into RSpec. This is the > documented way to do it: > > describe 'Post' do > inherit FixtureDependencies::SequelTestCase > > And that leads to the syntax error in the subject line. (No stack > trace is available - ask the Merb spec runner why!) > > Has anyone seen that one before? -- Thomas R. "TomK32" Koll <> http://ananasblau.com just a geek trying to change the world http://github.com/TomK32 From phlip2005 at gmail.com Sun Feb 1 15:42:57 2009 From: phlip2005 at gmail.com (Phlip) Date: Sun, 01 Feb 2009 12:42:57 -0800 Subject: [rspec-users] undefined method `inherit' for Merb::Test::ExampleGroup In-Reply-To: References: Message-ID: Thomas R. Koll wrote: > Are you sure it's inherit and not extend? Per the blogs, inherit() got invented to install Test::Unit::TestCase, to get its extra goodies. That's a class, so you can't extend or import it! Were those blog entries since redacted? > Second, I guess the missing trace is cuz you should > put a 'before' block into the describe. Huh? The trace is just missing; test runners should propagate it. > describe 'Post' do > before do > extend FixtureDependencies::SequelTestCase > end > end Here's the relevant bits that don't work. (I changed the goal library to the 'assert2' patched into Test::Unit::Assertions.) require File.join( File.dirname(__FILE__), '..', "spec_helper" ) require 'test/unit' require 'assert2' describe 'Post' do before do include Test::Unit::TestCase # inherit Test::Unit::TestCase # does not compile # include Test::Unit::Assertions # does not import assert{} end it 'should have fixtures' do posts = posts(:Joan_Crawford_Has_Risen, :Jammin, :Sardonicus, :Lithium) posts[0].body.should == 'From the Grave' posts[0].tags.should include(tags(:progressive)) # this line never compiles assert{ posts[0].tags.include? tags(:rocksteady) } end end The rspec-rails plugin sure has me spoiled, huh? I formerly thought Test::Unit::Assertions would be automatically available, even without Rails around... -- Phlip From r_j_h_box-sf at yahoo.com Mon Feb 2 01:18:54 2009 From: r_j_h_box-sf at yahoo.com (r_j_h_box-sf at yahoo.com) Date: Sun, 1 Feb 2009 22:18:54 -0800 (PST) Subject: [rspec-users] resource urls only work *after* a get() in controller spec Message-ID: <442469.18333.qm@web31807.mail.mud.yahoo.com> Okay, following up on this item. Would you believe a workaround of (gasp) get :index, prior to expecting route-based URLs to work? (slaps forehead). or do_action(), provided by the host example group (the more concrete example group, I mean - what's the right terminology there?). I tried reproducing the stuff I saw being done in action_controller/test_process.rb up to the point where the resource url function started working, but when I did that (setting up the controller name and action, essentially), I wasn't getting it to work, but I ran out of time budget for fooling with it. If anyone thinks of a better way, I'm all ears. Until then, Randy ----- Original Message ---- > From: "r_j_h_box-sf at yahoo.com" > To: rspec-users > Sent: Saturday, January 31, 2009 11:40:54 PM > Subject: Re: [rspec-users] resource urls only work *after* a get() in controller spec > > thanks, Ben - that didn't do the trick, though. > > I traced it down as far as this: > > the controller hasn't initialized its current url - that's the immediate cause > of the method-on-nil complaint. It hasn't, because the controller isn't > technically handling a request yet (i.e., process()). I tried monkey-patching > the controller to allow me to call its initialize_current_url to get around > this, but I didn't (yet) find how to fake up its request and params sufficiently > to have that work. > > Understandably, the controller can't know what the current url is, unless > rpsec-rails were to have a way to discover it from the example group. I'm not > sure that I'm proposing a change to a declarative style for controller actions - > for my purpose, I'd be satisfied to fake it to think 'index' is the current url > (in advance of processing the real request as specified by get() and friends). > > Hopefully this rings enough bells to make a workaround self-evident to > somebody. Anybody? Else I'll see what I can dig up from the rspec/rspec-rails > source that can be enough of a resource. > > Thanks, > > Randy > > > > > > ----- Original Message ---- > > From: Ben Mabey > > To: rspec-users > > Sent: Saturday, January 31, 2009 5:41:56 PM > > Subject: Re: [rspec-users] resource urls only work *after* a get() in > controller spec > > > > r_j_h_box-sf at yahoo.com wrote: > > > I'm encountering an interesting symptom during example execution. I'm > > > making a shared example group that dries up belongs-to-me before_filter > > > testing, and it makes a callback to the example group that says > > > it_should_behave_like that. The callback tells the shared example > > > where to expect a redirect for failure. > > > > > > It seems that prior to > > > executing a get() (etc), the resource-based url functions aren't > > > accessible. Following the get(), topics_url works fine. But before > > > then, it gives an error like this: > > > > > > http://pastie.org/376096 > > > > > > Is > > > this a known issue? Is there a workaround I can use? > > For a workaround try doing a "include ActionController::UrlWriter" in your > > shared example group. > > > > -Ben > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Mon Feb 2 03:09:49 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 2 Feb 2009 08:09:49 +0000 Subject: [rspec-users] resource urls only work *after* a get() in controller spec In-Reply-To: <442469.18333.qm@web31807.mail.mud.yahoo.com> References: <442469.18333.qm@web31807.mail.mud.yahoo.com> Message-ID: <696F41EA-F5BF-45D0-A191-BF6908253965@mattwynne.net> On 2 Feb 2009, at 06:18, r_j_h_box-sf at yahoo.com wrote: > > Okay, following up on this item. Would you believe a workaround of > (gasp) get :index, prior to expecting route-based URLs to work? > (slaps That's what I was going to suggest. We have all our routing tests in a separate file (away from the controllers) and this what we do there. > forehead). or do_action(), provided by the host example group (the > more concrete example group, I mean - what's the right terminology > there?). This is another approach that can work too. We call it #do_request. You can override helper methods like this as you go into describe blocks so you can have a very basic on the outside level and specialise it as you get into more detail. > \ > tried reproducing the stuff I saw being done in > action_controller/test_process.rb up to the point where the resource > url function started working, but when I did that (setting up the > controller name and action, essentially), I wasn't getting it to work, > but I ran out of time budget for fooling with it. > > If anyone thinks of a better way, I'm all ears. > > Until then, > > Randy > > > > ----- Original Message ---- >> From: "r_j_h_box-sf at yahoo.com" >> To: rspec-users >> Sent: Saturday, January 31, 2009 11:40:54 PM >> Subject: Re: [rspec-users] resource urls only work *after* a get() >> in controller spec >> >> thanks, Ben - that didn't do the trick, though. >> >> I traced it down as far as this: >> >> the controller hasn't initialized its current url - that's the >> immediate cause >> of the method-on-nil complaint. It hasn't, because the controller >> isn't >> technically handling a request yet (i.e., process()). I tried >> monkey-patching >> the controller to allow me to call its initialize_current_url to >> get around >> this, but I didn't (yet) find how to fake up its request and params >> sufficiently >> to have that work. >> >> Understandably, the controller can't know what the current url is, >> unless >> rpsec-rails were to have a way to discover it from the example >> group. I'm not >> sure that I'm proposing a change to a declarative style for >> controller actions - >> for my purpose, I'd be satisfied to fake it to think 'index' is the >> current url >> (in advance of processing the real request as specified by get() >> and friends). >> >> Hopefully this rings enough bells to make a workaround self-evident >> to >> somebody. Anybody? Else I'll see what I can dig up from the rspec/ >> rspec-rails >> source that can be enough of a resource. >> >> Thanks, >> >> Randy >> >> >> >> >> >> ----- Original Message ---- >>> From: Ben Mabey >>> To: rspec-users >>> Sent: Saturday, January 31, 2009 5:41:56 PM >>> Subject: Re: [rspec-users] resource urls only work *after* a get() >>> in >> controller spec >>> >>> r_j_h_box-sf at yahoo.com wrote: >>>> I'm encountering an interesting symptom during example >>>> execution. I'm >>>> making a shared example group that dries up belongs-to-me >>>> before_filter >>>> testing, and it makes a callback to the example group that says >>>> it_should_behave_like that. The callback tells the shared example >>>> where to expect a redirect for failure. >>>> >>>> It seems that prior to >>>> executing a get() (etc), the resource-based url functions aren't >>>> accessible. Following the get(), topics_url works fine. But >>>> before >>>> then, it gives an error like this: >>>> >>>> http://pastie.org/376096 >>>> >>>> Is >>>> this a known issue? Is there a workaround I can use? >>> For a workaround try doing a "include ActionController::UrlWriter" >>> in your >>> shared example group. >>> >>> -Ben >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Matt Wynne http://blog.mattwynne.net http://www.songkick.com From dchelimsky at gmail.com Mon Feb 2 03:27:11 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 2 Feb 2009 02:27:11 -0600 Subject: [rspec-users] simple == with prettier error messages + good documentation In-Reply-To: <338510.91289.qm@web31802.mail.mud.yahoo.com> References: <167563.64595.qm@web31805.mail.mud.yahoo.com> <57c63afe0901291025i1b1a18dah17b76a4650af60d1@mail.gmail.com> <8d961d900901291102l67a1414bq1f4dbfd1951979e4@mail.gmail.com> <57c63afe0901291118h5e18acafg5cdc57994b5df9ed@mail.gmail.com> <57c63afe0901291314y205a899bj1763d7d713792a81@mail.gmail.com> <8d961d900901291327le97eed7pa9ab234cd5539fe9@mail.gmail.com> <664078.75402.qm@web31813.mail.mud.yahoo.com> <57c63afe0901291420o126515bfg5ef0077a6672820a@mail.gmail.com> <338510.91289.qm@web31802.mail.mud.yahoo.com> Message-ID: <57c63afe0902020027n5d7dec62v1f8f167e1bec9171@mail.gmail.com> On Sat, Jan 31, 2009 at 12:02 PM, wrote: > Passing the it() and describe() args through to the reporting layer sounds > like a great idea. I've thought more about the reporting-levels approach. > The numeric as I postulated earlier is probably not the most useful thing. > > As a product manager, I want to be able to flexibly present the appropriate > documentation to different audiences, to avoid the need for maintaining > multiple docs. > > describe "an example group", :audience => :execs > describe "an example group", :audience => :owner > describe "an example group", :audience => :users > describe "an example group", :audience => :developers > > These could be entirely ad-hoc, allowing the developer to select the desired > labels for the situation at hand. > > When generating reports, you'd state which audiences to generate docs for > (maybe with a default set coded into a helper?). > > When generating reports to text, any examples or groups that were skipped > would be simply tabulated, and the summary would be displayed at the bottom: > > Skipped 7 example groups and 27 examples for Users. > Skipped 3 example groups and 12 examples for Developers. > > And when generating reports to HTML, any docs for not-specified roles could > simply be folded/hidden by default, allowing the viewer to drill down. Of > course, this could be skipped by setting an option for static HTML purposes, > and the skipped items could be reported in the same way as the text version. > > Does this seem like a useful way to treat the various detail levels of > documentation we want to present to different audiences? Hey Randy, I just committed code that makes the options available to the formatters for both example groups and individual examples. If you grab the latest from git, take a look at examples/passing/filtered_formatter_example.rb and you'll see how it works. This should let you experiment with different ways of filtering things. The approach you suggest does seem sound, but I'm not prepared to add any first class support for anything like that to rspec proper until its been proven effective. I'm also interested in figuring out how to apply this to the actual run, not just the reporting. i.e. use options as a tagging system to determine which groups and/or individual examples to run. This would require some entry point earlier in the process, and I'm not quite sure the best approach yet. Ideas are welcome. Cheers, David > > Randy > > > ________________________________ > From: David Chelimsky > > Randy: >> http://gist.github.com/54764 >> >> Then when generating spec docs, you could vary the detail level on what's >> generated, to generate only up to level-2 documentation, or to generate >> full-detail documentation if you prefer. >> >> Nested it()s could do the same thing, I suppose. Not sure what side >> effects >> would come into play. Pretty clearly, a nested it() wouldn't have an >> embedded transaction or respect the outer before() block, since the outer >> if() would handle both those things. > > For a number of technical reasons, the nested code example (it()) is a > non-starter. > > The idea of having some means of flagging examples so they report > differently is possible. Right now, example groups and examples each > take a hash in their declarations: > > describe "an example group", :with => "some, :args => "like this" do > it "an example", :with => "some", :other => "args" > ... > end > end > > Those are accessible to the runner, and are used internally for > assorted filtering. As of this moment, they don't make it past the > reporters, because the object that goes to formatters is a wrapper w/ > limited information instead of the real example. We could add the > options to that wrapper though, and then you'd be able to write a > custom formatter that would do anything you like based on the > configuration of those options. > > WDYT about that? > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From zuperinfinite at gmail.com Mon Feb 2 06:05:48 2009 From: zuperinfinite at gmail.com (Bart Zonneveld) Date: Mon, 2 Feb 2009 12:05:48 +0100 Subject: [rspec-users] [Cucumber] Cucumber and acts_as_xapian Message-ID: <8353FB40-93EF-49E6-9737-4553D525AC5D@gmail.com> Hey list, Anyone have experience with acts_as_xapian and Cucumber? I'm struggling with updating xapian's index, to actually "find" fluff that has been indexed.. In a scenario, I'm adding a bunch of articles, and in the actual search step, I run: When "I search for \"$query\"" do |query| %x[rake RAILS_ENV=test xapian:update_index] fill_in "Search", :with => query click_button 'Search' end At this point in the scenario, I can see there are articles in the database. But if I try to query the articles using xapian after the update_index rake task has run, I don't see any results. Could this have to do with transactional fixtures or something? Really stuck here, because I obviously don't want to stub these searches, and I do want to test them. thanks, bartz From andre.x.pretorius at gmail.com Mon Feb 2 08:24:46 2009 From: andre.x.pretorius at gmail.com (AndreXP) Date: Mon, 2 Feb 2009 05:24:46 -0800 (PST) Subject: [rspec-users] [Cucumber] and rake pass command-line params Message-ID: <21789574.post@talk.nabble.com> Hi list, I might have not asked this correctly in previous post.. and most definitely weren?t clear! let?s try again :) I can?t seem to find any examples of using a rake variable in the Cucumber task. What I want to do is run my cucumber test using cruisecontrol and setting a variable in script to either to start Firefox or Internet Explorer with selenium. Which leads me to the question, how do I access this browser_type variable in my_steps.rb file? ## Rakefile Cucumber::Rake::Task.new do |t| profile = ENV['PROFILE'] || 'default' browser_type = ENV['BROWSER'] || '*chrome' t.cucumber_opts = "--profile #{profile}" end ## my_steps.rb Before do browser = Selenium::SeleniumDriver.new(server_host, server_port, browser_type, root_url, time_out) end Let me guess, it?s very easy... but I am still new to the Ruby World :clap: -- View this message in context: http://www.nabble.com/-Cucumber--and-rake-pass-command-line-params-tp21789574p21789574.html Sent from the rspec-users mailing list archive at Nabble.com. From aslak.hellesoy at gmail.com Mon Feb 2 08:58:06 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 2 Feb 2009 14:58:06 +0100 Subject: [rspec-users] [Cucumber] and rake pass command-line params In-Reply-To: <21789574.post@talk.nabble.com> References: <21789574.post@talk.nabble.com> Message-ID: <8d961d900902020558t751ccb5dy7e9eb3797d4e21d9@mail.gmail.com> On Mon, Feb 2, 2009 at 2:24 PM, AndreXP wrote: > > Hi list, > > I might have not asked this correctly in previous post.. and most definitely > weren't clear! let's try again :) > > I can't seem to find any examples of using a rake variable in the Cucumber > task. What I want to do is run my cucumber test using cruisecontrol and > setting a variable in script to either to start Firefox or Internet Explorer > with selenium. Which leads me to the question, how do I access this > browser_type variable in my_steps.rb file? > I suggest you look up ENV['BROWSER'] (and anything else you might need to configure Selenium) directly in your my_steps.rb file (I also suggest you move Before blocks to features/support/env.rb) # Rakefile Cucumber::Rake::Task.new do |t| profile = ENV['PROFILE'] || 'default' t.cucumber_opts = "--profile #{profile}" end # features/support/env.rb Before do browser_type = ENV['BROWSER'] || '*chrome' browser = Selenium::SeleniumDriver.new(server_host, server_port, browser_type, root_url, time_out) end If you want to rely less on environment variables, you can make yourself a YAML file with settings (e.g. selenium.yml) consisting of a Hash of Hash: chrome: server_host: foo browser: *chrome timeout: 2 ie: server_host: bar browser: *ie timeout: 9 And do something like this in your env.rb: profile = ENV['PROFILE'] c = YAML.read_file('features/selenium.yml')[profile] browser = Selenium::SeleniumDriver.new(c['server_host'], ...) -and be done with one single env var - PROFILE HTH, Aslak > ## Rakefile > Cucumber::Rake::Task.new do |t| > profile = ENV['PROFILE'] || 'default' > browser_type = ENV['BROWSER'] || '*chrome' > t.cucumber_opts = "--profile #{profile}" > end > > ## my_steps.rb > Before do > browser = Selenium::SeleniumDriver.new(server_host, server_port, > browser_type, root_url, time_out) > end > > Let me guess, it's very easy... but I am still new to the Ruby World :clap: > > -- > View this message in context: http://www.nabble.com/-Cucumber--and-rake-pass-command-line-params-tp21789574p21789574.html > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -- Aslak (::) From andre.x.pretorius at gmail.com Mon Feb 2 10:53:22 2009 From: andre.x.pretorius at gmail.com (Andre Pretorius) Date: Mon, 2 Feb 2009 15:53:22 +0000 Subject: [rspec-users] [Cucumber] and rake pass command-line params In-Reply-To: <8d961d900902020558t751ccb5dy7e9eb3797d4e21d9@mail.gmail.com> References: <21789574.post@talk.nabble.com> <8d961d900902020558t751ccb5dy7e9eb3797d4e21d9@mail.gmail.com> Message-ID: <6270078a0902020753k39e919bqad17d41110fffe0a@mail.gmail.com> Great advice, I did all the suggestions you made, and... it is GOOD and CLEAN:) Thanks Aslak On Mon, Feb 2, 2009 at 1:58 PM, aslak hellesoy wrote: > On Mon, Feb 2, 2009 at 2:24 PM, AndreXP > wrote: > > > > Hi list, > > > > I might have not asked this correctly in previous post.. and most > definitely > > weren't clear! let's try again :) > > > > I can't seem to find any examples of using a rake variable in the > Cucumber > > task. What I want to do is run my cucumber test using cruisecontrol and > > setting a variable in script to either to start Firefox or Internet > Explorer > > with selenium. Which leads me to the question, how do I access this > > browser_type variable in my_steps.rb file? > > > > I suggest you look up ENV['BROWSER'] (and anything else you might need > to configure Selenium) directly in your my_steps.rb file > (I also suggest you move Before blocks to features/support/env.rb) > > # Rakefile > Cucumber::Rake::Task.new do |t| > profile = ENV['PROFILE'] || 'default' > t.cucumber_opts = "--profile #{profile}" > end > > # features/support/env.rb > Before do > browser_type = ENV['BROWSER'] || '*chrome' > browser = Selenium::SeleniumDriver.new(server_host, server_port, > browser_type, root_url, time_out) > end > > If you want to rely less on environment variables, you can make > yourself a YAML file with settings (e.g. selenium.yml) consisting of a > Hash of Hash: > > chrome: > server_host: foo > browser: *chrome > timeout: 2 > ie: > server_host: bar > browser: *ie > timeout: 9 > > And do something like this in your env.rb: > > profile = ENV['PROFILE'] > c = YAML.read_file('features/selenium.yml')[profile] > browser = Selenium::SeleniumDriver.new(c['server_host'], ...) > > -and be done with one single env var - PROFILE > > HTH, > Aslak > > > ## Rakefile > > Cucumber::Rake::Task.new do |t| > > profile = ENV['PROFILE'] || 'default' > > browser_type = ENV['BROWSER'] || '*chrome' > > t.cucumber_opts = "--profile #{profile}" > > end > > > > ## my_steps.rb > > Before do > > browser = Selenium::SeleniumDriver.new(server_host, server_port, > > browser_type, root_url, time_out) > > end > > > > Let me guess, it's very easy... but I am still new to the Ruby World > :clap: > > > > -- > > View this message in context: > http://www.nabble.com/-Cucumber--and-rake-pass-command-line-params-tp21789574p21789574.html > > Sent from the rspec-users mailing list archive at Nabble.com. > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > -- > Aslak (::) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Mon Feb 2 11:00:14 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 02 Feb 2009 09:00:14 -0700 Subject: [rspec-users] [Cucumber] Cucumber and acts_as_xapian In-Reply-To: <8353FB40-93EF-49E6-9737-4553D525AC5D@gmail.com> References: <8353FB40-93EF-49E6-9737-4553D525AC5D@gmail.com> Message-ID: <4987188E.2000309@benmabey.com> Bart Zonneveld wrote: > Hey list, > > Anyone have experience with acts_as_xapian and Cucumber? I'm > struggling with updating xapian's index, to actually "find" fluff that > has been indexed.. > In a scenario, I'm adding a bunch of articles, and in the actual > search step, I run: > > When "I search for \"$query\"" do |query| > %x[rake RAILS_ENV=test xapian:update_index] > fill_in "Search", :with => query > click_button 'Search' > end > > At this point in the scenario, I can see there are articles in the > database. But if I try to query the articles using xapian after the > update_index rake task has run, I don't see any results. > Could this have to do with transactional fixtures or something? Really > stuck here, because I obviously don't want to stub these searches, and > I do want to test them. Yeah, I would say this is due to the transactions. Try disabling the transactions and cleaning up the DB yourself (i.e. truncating all the tables) in the Before hooks. -Ben > > thanks, > bartz > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Mon Feb 2 11:30:44 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Mon, 2 Feb 2009 17:30:44 +0100 Subject: [rspec-users] [RSpec] Cannot save or be_valid when using xss_terminate Message-ID: <0f614a1150c01be8d66f61cfc1ee2703@ruby-forum.com> Hi, I have a Rails app that uses xss_terminate to sanitize the user input before it gets saved to the DB. In my specs when I call @product.should be_valid or @product.save, I get the following error message: -- NoMethodError in 'Creating a product with all necessary attributes should be valid' undefined method `empty?' for Mon Feb 02 16:59:00 +0100 2009:Time -- The other error messages are related to xss_terminate source code. Has anyone had any trouble in specing models that are sanitized by xss_terminate? Best regards, -- Posted via http://www.ruby-forum.com/. From jonathan at parkerhill.com Mon Feb 2 11:44:36 2009 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Mon, 2 Feb 2009 11:44:36 -0500 Subject: [rspec-users] [RSpec] Cannot save or be_valid when using xss_terminate In-Reply-To: <0f614a1150c01be8d66f61cfc1ee2703@ruby-forum.com> References: <0f614a1150c01be8d66f61cfc1ee2703@ruby-forum.com> Message-ID: <0F113341-36A7-40DB-A200-5EB8656F2EC1@parkerhill.com> On Feb 2, 2009, at 11:30 AM, Fernando Perez wrote: > Hi, > > I have a Rails app that uses xss_terminate to sanitize the user input > before it gets saved to the DB. In my specs when I call > @product.should > be_valid or @product.save, I get the following error message: > -- > NoMethodError in 'Creating a product with all necessary attributes > should be valid' > undefined method `empty?' for Mon Feb 02 16:59:00 +0100 2009:Time > -- > > The other error messages are related to xss_terminate source code. Has > anyone had any trouble in specing models that are sanitized by > xss_terminate? > > > Best regards, > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users I rspec models that use xss_terminate with no problem. I have not see the error you're getting. linoj From lists at ruby-forum.com Mon Feb 2 12:07:05 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Mon, 2 Feb 2009 18:07:05 +0100 Subject: [rspec-users] [RSpec] Cannot save or be_valid when using xss_terminate In-Reply-To: <0F113341-36A7-40DB-A200-5EB8656F2EC1@parkerhill.com> References: <0f614a1150c01be8d66f61cfc1ee2703@ruby-forum.com> <0F113341-36A7-40DB-A200-5EB8656F2EC1@parkerhill.com> Message-ID: > I rspec models that use xss_terminate with no problem. I have not see > the error you're getting. > > linoj Thanks. Knowing that it is possible to spec models that use xss_terminate I was able to figure out that in one of my attributes I was passing a Time object, so simply converting it to a string with to_s fixed the issue. -- Posted via http://www.ruby-forum.com/. From r_j_h_box-sf at yahoo.com Mon Feb 2 12:15:15 2009 From: r_j_h_box-sf at yahoo.com (r_j_h_box-sf at yahoo.com) Date: Mon, 2 Feb 2009 09:15:15 -0800 (PST) Subject: [rspec-users] [Cucumber] Cucumber and acts_as_xapian References: <8353FB40-93EF-49E6-9737-4553D525AC5D@gmail.com> <4987188E.2000309@benmabey.com> Message-ID: <628693.66146.qm@web31813.mail.mud.yahoo.com> A question for edumacational purposes here: Instead of disabling transactions, would it be effective to include all the steps of inserting the record and running the search, inside one scenario? Given [the record is added to the database" When [I search for it] Then [I should find it] If this can't work, then something is confusing me. I haven't gotten into integration testing yet, but I would like to be armed with some level of understanding going in. Randy ----- Original Message ---- > From: Ben Mabey > To: rspec-users > Sent: Monday, February 2, 2009 8:00:14 AM > Subject: Re: [rspec-users] [Cucumber] Cucumber and acts_as_xapian > > Bart Zonneveld wrote: > > Hey list, > > > > Anyone have experience with acts_as_xapian and Cucumber? I'm struggling with > updating xapian's index, to actually "find" fluff that has been indexed.. > > In a scenario, I'm adding a bunch of articles, and in the actual search step, > I run: > > > > When "I search for \"$query\"" do |query| > > %x[rake RAILS_ENV=test xapian:update_index] > > fill_in "Search", :with => query > > click_button 'Search' > > end > > > > At this point in the scenario, I can see there are articles in the database. > But if I try to query the articles using xapian after the update_index rake task > has run, I don't see any results. > > Could this have to do with transactional fixtures or something? Really stuck > here, because I obviously don't want to stub these searches, and I do want to > test them. > > Yeah, I would say this is due to the transactions. Try disabling the > transactions and cleaning up the DB yourself (i.e. truncating all the tables) in > the Before hooks. > > -Ben > > > > thanks, > > 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 From walketim at gmail.com Mon Feb 2 13:00:48 2009 From: walketim at gmail.com (Tim Walker) Date: Mon, 2 Feb 2009 11:00:48 -0700 Subject: [rspec-users] [Cucumber] --dry-run Message-ID: <1ebf5a4d0902021000x8557018p8b7e586653f078be@mail.gmail.com> Hi Guys, I see in the Cucmber --help that -d akd --dry-run is supported but it doesn't seem to work. Anyone know why? Thanks, very much. Tim From aslak.hellesoy at gmail.com Mon Feb 2 13:12:43 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 2 Feb 2009 19:12:43 +0100 Subject: [rspec-users] [Cucumber] --dry-run In-Reply-To: <1ebf5a4d0902021000x8557018p8b7e586653f078be@mail.gmail.com> References: <1ebf5a4d0902021000x8557018p8b7e586653f078be@mail.gmail.com> Message-ID: <8d961d900902021012w7afc6e5cx6319f3c0baa43a6b@mail.gmail.com> On Mon, Feb 2, 2009 at 7:00 PM, Tim Walker wrote: > Hi Guys, > > I see in the Cucmber --help that -d akd --dry-run is supported but it > doesn't seem to work. > > Anyone know why? > Because it has a bug that has been fixed in 0.2 prereleases (0.1.99.x) http://tinyurl.com/cucumber-0-2-beta Aslak > Thanks, very much. > > Tim > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From lists at ruby-forum.com Mon Feb 2 13:49:46 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 2 Feb 2009 19:49:46 +0100 Subject: [rspec-users] RSpec - Testing ActiveRecord addins In-Reply-To: <17909deb32f03dca8bd4186ab90a1dd8@ruby-forum.com> References: <45017.216.185.71.24.1233264276.squirrel@webmail.harte-lyne.ca> <49822850.9000902@benmabey.com> <9bfb9a52fdbe0f05bac07fb2b6e3650c@ruby-forum.com> <49827174.6040904@benmabey.com> <3678fd4c32e5f78368ced27b0136ee73@ruby-forum.com> <3f6e65a6-ff4c-481a-b036-1a9c7aa5bf09@m15g2000vbp.googlegroups.com> <17909deb32f03dca8bd4186ab90a1dd8@ruby-forum.com> Message-ID: James Byrne wrote: > > What is happening is that RSpec is blowing up at its own logger code in > the default spec_helper.rb file. This happens whether or not ActAsFu is > installed and whether or not my custom logger is commented out in > environment.rb I poked at this a bit and hit upon the problem. As distributed, spec_helper.rb says this: config.before(:each) do full_example_description = "#{self.class.description} #{@method_name}" logger.info( "\n\n#{full_example_description}\n#{'-' * (full_example_description.length)}") end The fix is to prefix logger with Rails:: thus: config.before(:each) do full_example_description = "#{self.class.description} #{@method_name}" Rails::logger.info( "\n\n#{full_example_description}\n#{'-' * (full_example_description.length)}") end I have one other difficulty when running this on MS-WinXPpro under cygwin. The newline character seems to have no effect. I can force it to behave locally by adding a \r in front of each \n but, obviously, that will have unfortunate consequences on *nix. Suggestions welcome. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Mon Feb 2 14:12:59 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 2 Feb 2009 20:12:59 +0100 Subject: [rspec-users] RSpec - Testing ActiveRecord addins In-Reply-To: References: <45017.216.185.71.24.1233264276.squirrel@webmail.harte-lyne.ca> <49822850.9000902@benmabey.com> <9bfb9a52fdbe0f05bac07fb2b6e3650c@ruby-forum.com> <49827174.6040904@benmabey.com> <3678fd4c32e5f78368ced27b0136ee73@ruby-forum.com> <3f6e65a6-ff4c-481a-b036-1a9c7aa5bf09@m15g2000vbp.googlegroups.com> <17909deb32f03dca8bd4186ab90a1dd8@ruby-forum.com> Message-ID: James Byrne wrote: > > I have one other difficulty when running this on MS-WinXPpro under > cygwin. The newline character seems to have no effect. I can force it > to behave locally by adding a \r in front of each \n but, obviously, > that will have unfortunate consequences on *nix. Actually, that technique does not seem to work either. A ^M is inserted into the og file, but it has no evident effect. -- Posted via http://www.ruby-forum.com/. From zuperinfinite at gmail.com Mon Feb 2 14:40:27 2009 From: zuperinfinite at gmail.com (Bart Zonneveld) Date: Mon, 2 Feb 2009 20:40:27 +0100 Subject: [rspec-users] [Cucumber] Cucumber and acts_as_xapian In-Reply-To: <628693.66146.qm@web31813.mail.mud.yahoo.com> References: <8353FB40-93EF-49E6-9737-4553D525AC5D@gmail.com> <4987188E.2000309@benmabey.com> <628693.66146.qm@web31813.mail.mud.yahoo.com> Message-ID: <764F34CF-023A-43B2-8492-94F5BB02EEDA@gmail.com> On 2 feb 2009, at 18:15, r_j_h_box-sf at yahoo.com wrote: > > A question for edumacational purposes here: Instead of disabling > transactions, would it be effective to include all the steps of > inserting the record and running the search, inside one scenario? That is exactly what I am doing in my full scenario, but I omitted those steps for brevity :) > If this can't work, then something is confusing me. I haven't > gotten into integration testing yet, but I would like to be armed > with some level of understanding going in. See here for some examples: http://github.com/aslakhellesoy/cucumber/tree/master/examples Plenty more on the cucumber wikis @ github. cheers, bartz > ----- Original Message ---- >> From: Ben Mabey >> To: rspec-users >> Sent: Monday, February 2, 2009 8:00:14 AM >> Subject: Re: [rspec-users] [Cucumber] Cucumber and acts_as_xapian >> >> Bart Zonneveld wrote: >>> Hey list, >>> >>> Anyone have experience with acts_as_xapian and Cucumber? I'm >>> struggling with >> updating xapian's index, to actually "find" fluff that has been >> indexed.. >>> In a scenario, I'm adding a bunch of articles, and in the actual >>> search step, >> I run: >>> >>> When "I search for \"$query\"" do |query| >>> %x[rake RAILS_ENV=test xapian:update_index] >>> fill_in "Search", :with => query >>> click_button 'Search' >>> end >>> >>> At this point in the scenario, I can see there are articles in the >>> database. >> But if I try to query the articles using xapian after the >> update_index rake task >> has run, I don't see any results. >>> Could this have to do with transactional fixtures or something? >>> Really stuck >> here, because I obviously don't want to stub these searches, and I >> do want to >> test them. >> >> Yeah, I would say this is due to the transactions. Try disabling the >> transactions and cleaning up the DB yourself (i.e. truncating all >> the tables) in >> the Before hooks. >> >> -Ben >>> >>> thanks, >>> 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 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From zuperinfinite at gmail.com Mon Feb 2 14:40:55 2009 From: zuperinfinite at gmail.com (Bart Zonneveld) Date: Mon, 2 Feb 2009 20:40:55 +0100 Subject: [rspec-users] [Cucumber] Cucumber and acts_as_xapian In-Reply-To: <4987188E.2000309@benmabey.com> References: <8353FB40-93EF-49E6-9737-4553D525AC5D@gmail.com> <4987188E.2000309@benmabey.com> Message-ID: <174A257B-34A2-4016-ADE7-B29C8FE1635C@gmail.com> On 2 feb 2009, at 17:00, Ben Mabey wrote: > Bart Zonneveld wrote: >> Hey list, >> >> Anyone have experience with acts_as_xapian and Cucumber? I'm >> struggling with updating xapian's index, to actually "find" fluff >> that has been indexed.. >> In a scenario, I'm adding a bunch of articles, and in the actual >> search step, I run: >> >> When "I search for \"$query\"" do |query| >> %x[rake RAILS_ENV=test xapian:update_index] >> fill_in "Search", :with => query >> click_button 'Search' >> end >> >> At this point in the scenario, I can see there are articles in the >> database. But if I try to query the articles using xapian after the >> update_index rake task has run, I don't see any results. >> Could this have to do with transactional fixtures or something? >> Really stuck here, because I obviously don't want to stub these >> searches, and I do want to test them. > > Yeah, I would say this is due to the transactions. Try disabling > the transactions and cleaning up the DB yourself (i.e. truncating > all the tables) in the Before hooks. Aye, it was, spot on Ben. thanks! bartz From ben at benmabey.com Mon Feb 2 15:24:05 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 02 Feb 2009 13:24:05 -0700 Subject: [rspec-users] [Cucumber] Cucumber and acts_as_xapian In-Reply-To: <628693.66146.qm@web31813.mail.mud.yahoo.com> References: <8353FB40-93EF-49E6-9737-4553D525AC5D@gmail.com> <4987188E.2000309@benmabey.com> <628693.66146.qm@web31813.mail.mud.yahoo.com> Message-ID: <49875665.1080001@benmabey.com> r_j_h_box-sf at yahoo.com wrote: > A question for edumacational purposes here: Instead of disabling transactions, would it be effective to include all the steps of inserting the record and running the search, inside one scenario? > > Given [the record is added to the database" > When [I search for it] > Then [I should find it] > > If this can't work, then something is confusing me. I haven't gotten into integration testing yet, but I would like to be armed with some level of understanding going in. > > Randy > Your intuition is correct. It should work assuming that all of the DB calls happen in the same transaction and therefor the same process. However, the problem that I think Bart is facing is that while all of this is taking place in the same scenario it is not all taking place in the same process. If you notice he is piping a call out to a rake task: %x[rake RAILS_ENV=test xapian:update_index] That rake task is not going to be able to see the items that the Given has created because those INSERTs are being wrapped into a transaction that will be rolled back at the end of the scenario. For this reason the use of transactions need to be avoided so the separate processes are operating on the same data within the DB. I wrote about this on the wiki in the troubleshooting page in the context of selenium- the root problem is the same in both cases. HTH, Ben > > > ----- Original Message ---- > >> From: Ben Mabey >> To: rspec-users >> Sent: Monday, February 2, 2009 8:00:14 AM >> Subject: Re: [rspec-users] [Cucumber] Cucumber and acts_as_xapian >> >> Bart Zonneveld wrote: >> >>> Hey list, >>> >>> Anyone have experience with acts_as_xapian and Cucumber? I'm struggling with >>> >> updating xapian's index, to actually "find" fluff that has been indexed.. >> >>> In a scenario, I'm adding a bunch of articles, and in the actual search step, >>> >> I run: >> >>> When "I search for \"$query\"" do |query| >>> %x[rake RAILS_ENV=test xapian:update_index] >>> fill_in "Search", :with => query >>> click_button 'Search' >>> end >>> >>> At this point in the scenario, I can see there are articles in the database. >>> >> But if I try to query the articles using xapian after the update_index rake task >> has run, I don't see any results. >> >>> Could this have to do with transactional fixtures or something? Really stuck >>> >> here, because I obviously don't want to stub these searches, and I do want to >> test them. >> >> Yeah, I would say this is due to the transactions. Try disabling the >> transactions and cleaning up the DB yourself (i.e. truncating all the tables) in >> the Before hooks. >> >> -Ben >> >>> thanks, >>> 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 >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Mon Feb 2 16:30:01 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Mon, 2 Feb 2009 22:30:01 +0100 Subject: [rspec-users] [RSpec] rcov and/or rexml bug? Message-ID: <1d5d31eff1533f2d92d2ac0bc40c97d9@ruby-forum.com> Hi, Running: Ruby 1.8.7 p72, RSpec 1.1.12 and rcov 0.8.1.2.0, I get the following error message with $ rake spec:rcov -- /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/formatters/pretty.rb:131:in `[]': no implicit conversion from nil to integer (TypeError) from /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/formatters/pretty.rb:131:in `wrap' from /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/formatters/pretty.rb:131:in `wrap' from /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/formatters/pretty.rb:90:in `write_text' from /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/formatters/default.rb:50:in `write' from /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/formatters/pretty.rb:75:in `write_element' from /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/formatters/pretty.rb:73:in `each' from /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/formatters/pretty.rb:73:in `write_element' from /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/formatters/default.rb:31:in `write' from /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/formatters/pretty.rb:75:in `write_element' from /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/formatters/pretty.rb:73:in `each' from /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/formatters/pretty.rb:73:in `write_element' from /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/formatters/default.rb:31:in `write' from /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/formatters/pretty.rb:117:in `write_document' from /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/formatters/pretty.rb:111:in `each' from /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/formatters/pretty.rb:111:in `write_document' from /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/formatters/default.rb:28:in `write' from /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/document.rb:195:in `write' from (eval):93:in `pretty' from /usr/local/ruby1.8.7/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov/report.rb:1003:in `create_file' from /usr/local/ruby1.8.7/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov/report.rb:708:in `execute' from /usr/local/ruby1.8.7/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov/report.rb:125:in `each' from /usr/local/ruby1.8.7/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov/report.rb:125:in `each_file_pair_sorted' from /usr/local/ruby1.8.7/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov/report.rb:707:in `execute' from /usr/local/ruby1.8.7/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov.rb:640:in `dump_coverage_info' from /usr/local/ruby1.8.7/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov.rb:640:in `each' from /usr/local/ruby1.8.7/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov.rb:640:in `dump_coverage_info' from /usr/local/ruby1.8.7/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/bin/rcov:421 rake aborted! -- Anyone ran into that? Should I downgrade my Ruby version to have it work? I previously updated it to its latest release hoping bugs would be fixed. -- Posted via http://www.ruby-forum.com/. From mailing_lists at bengreenberg.net Mon Feb 2 18:30:20 2009 From: mailing_lists at bengreenberg.net (Ben Greenberg) Date: Mon, 02 Feb 2009 18:30:20 -0500 Subject: [rspec-users] Trouble validating an exception In-Reply-To: <1ebf5a4d0902021000x8557018p8b7e586653f078be@mail.gmail.com> References: <1ebf5a4d0902021000x8557018p8b7e586653f078be@mail.gmail.com> Message-ID: <4987820C.3010104@bengreenberg.net> Hi all, This spec always passes: lambda do process_card @credit_card, billing_info, 10604, '1.1.1.1', @gateway end.should raise_error(MinimalCart::CaptureFailureError) do |ex| ex.should be_nil ex.should_not be_nil ex.responses.should be_nil ex.responses.should_include @auth_response ex.responses.include?.with('a').should be_true end Clearly, it makes no sense. Somehow the exception validation block is not running. What am I doing wrong? Thanks Ben From pergesu at gmail.com Mon Feb 2 19:22:37 2009 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 2 Feb 2009 16:22:37 -0800 Subject: [rspec-users] Trouble validating an exception In-Reply-To: <4987820C.3010104@bengreenberg.net> References: <1ebf5a4d0902021000x8557018p8b7e586653f078be@mail.gmail.com> <4987820C.3010104@bengreenberg.net> Message-ID: <810a540e0902021622g2944dbb2y3b597dbe1f15d936@mail.gmail.com> On Mon, Feb 2, 2009 at 3:30 PM, Ben Greenberg wrote: > Hi all, > > This spec always passes: > > lambda do > process_card @credit_card, billing_info, 10604, '1.1.1.1', @gateway > end.should raise_error(MinimalCart::CaptureFailureError) do |ex| > ex.should be_nil > ex.should_not be_nil > ex.responses.should be_nil > ex.responses.should_include @auth_response > ex.responses.include?.with('a').should be_true > end > > Clearly, it makes no sense. Somehow the exception validation block is not > running. What am I doing wrong? try using { } instead of do..end. Pretty sure that the problem you're experiencing has to do with Ruby's block precedence. Pat From pergesu at gmail.com Mon Feb 2 19:24:11 2009 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 2 Feb 2009 16:24:11 -0800 Subject: [rspec-users] Trouble validating an exception In-Reply-To: <810a540e0902021622g2944dbb2y3b597dbe1f15d936@mail.gmail.com> References: <1ebf5a4d0902021000x8557018p8b7e586653f078be@mail.gmail.com> <4987820C.3010104@bengreenberg.net> <810a540e0902021622g2944dbb2y3b597dbe1f15d936@mail.gmail.com> Message-ID: <810a540e0902021624h2c14ece7ge13188ec7a763d2e@mail.gmail.com> On Mon, Feb 2, 2009 at 4:22 PM, Pat Maddox wrote: > On Mon, Feb 2, 2009 at 3:30 PM, Ben Greenberg > wrote: >> Hi all, >> >> This spec always passes: >> >> lambda do >> process_card @credit_card, billing_info, 10604, '1.1.1.1', @gateway >> end.should raise_error(MinimalCart::CaptureFailureError) do |ex| >> ex.should be_nil >> ex.should_not be_nil >> ex.responses.should be_nil >> ex.responses.should_include @auth_response >> ex.responses.include?.with('a').should be_true >> end >> >> Clearly, it makes no sense. Somehow the exception validation block is not >> running. What am I doing wrong? > > try using { } instead of do..end. Pretty sure that the problem you're > experiencing has to do with Ruby's block precedence. oops I should have been more specific. I meant use { } for the block after raise_error: lambda do process_card @credit_card, billing_info, 10604, '1.1.1.1', @gateway end.should raise_error(MinimalCart::CaptureFailureError) { |ex| ex.should be_nil ex.should_not be_nil ex.responses.should be_nil ex.responses.should_include @auth_response ex.responses.include?.with('a').should be_true } Although I think that do..end.method is hideous and so I would change the lambda to use curly braces as well :) Pat From scott at railsnewbie.com Mon Feb 2 19:26:25 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Mon, 2 Feb 2009 19:26:25 -0500 Subject: [rspec-users] Trouble validating an exception In-Reply-To: <4987820C.3010104@bengreenberg.net> References: <1ebf5a4d0902021000x8557018p8b7e586653f078be@mail.gmail.com> <4987820C.3010104@bengreenberg.net> Message-ID: On Feb 2, 2009, at 6:30 PM, Ben Greenberg wrote: > Hi all, > > This spec always passes: > > lambda do > process_card @credit_card, billing_info, 10604, '1.1.1.1', > @gateway > end.should raise_error(MinimalCart::CaptureFailureError) do |ex| > ex.should be_nil > ex.should_not be_nil > ex.responses.should be_nil > ex.responses.should_include @auth_response > ex.responses.include?.with('a').should be_true > end > > Clearly, it makes no sense. Somehow the exception validation block > is not running. What am I doing wrong? raise_error doesn't take a block, and so it's being ignored: http://rspec.rubyforge.org/rspec/1.1.12/classes/Spec/Matchers.html#M000483 Scott From scott at railsnewbie.com Mon Feb 2 19:27:08 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Mon, 2 Feb 2009 19:27:08 -0500 Subject: [rspec-users] Trouble validating an exception In-Reply-To: <4987820C.3010104@bengreenberg.net> References: <1ebf5a4d0902021000x8557018p8b7e586653f078be@mail.gmail.com> <4987820C.3010104@bengreenberg.net> Message-ID: <1F0A114A-F805-48CE-8F90-FE8E17B9B437@railsnewbie.com> On Feb 2, 2009, at 6:30 PM, Ben Greenberg wrote: > Hi all, > > This spec always passes: > > lambda do > process_card @credit_card, billing_info, 10604, '1.1.1.1', > @gateway > end.should raise_error(MinimalCart::CaptureFailureError) do |ex| > ex.should be_nil > ex.should_not be_nil > ex.responses.should be_nil > ex.responses.should_include @auth_response > ex.responses.include?.with('a').should be_true > end > > Clearly, it makes no sense. Somehow the exception validation block > is not running. What am I doing wrong? Disregard my last email. I was being stupid. Scott From phlip2005 at gmail.com Mon Feb 2 21:19:23 2009 From: phlip2005 at gmail.com (Phlip) Date: Mon, 02 Feb 2009 18:19:23 -0800 Subject: [rspec-users] undefined method `inherit' for Merb::Test::ExampleGroup In-Reply-To: References: Message-ID: <4987A9AB.1080108@gmail.com> I have to bump this one because it looks like it's on RSpec's core feature list, and I reeally need a fix for it. Feel free to blame Merb, if they munged the inherit() method somehow! > Here's the relevant bits that don't work. (I changed the goal library to > the 'assert2' patched into Test::Unit::Assertions.) > > require File.join( File.dirname(__FILE__), '..', "spec_helper" ) > require 'test/unit' > require 'assert2' > > > describe 'Post' do > > before do > include Test::Unit::TestCase > # inherit Test::Unit::TestCase # does not compile > # include Test::Unit::Assertions # does not import assert{} > end > > it 'should have fixtures' do > posts = posts(:Joan_Crawford_Has_Risen, :Jammin, :Sardonicus, :Lithium) > posts[0].body.should == 'From the Grave' > posts[0].tags.should include(tags(:progressive)) > > # this line never compiles > assert{ posts[0].tags.include? tags(:rocksteady) } > end > > end > > The rspec-rails plugin sure has me spoiled, huh? I formerly thought > Test::Unit::Assertions would be automatically available, even without > Rails around... > From pergesu at gmail.com Mon Feb 2 23:11:11 2009 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 2 Feb 2009 20:11:11 -0800 Subject: [rspec-users] undefined method `inherit' for Merb::Test::ExampleGroup In-Reply-To: <4987A9AB.1080108@gmail.com> References: <4987A9AB.1080108@gmail.com> Message-ID: <810a540e0902022011x754426f3r6a38fb46c13e35f0@mail.gmail.com> I'll blame Merb on the basis that there is no "inherit" in RSpec. I'm guessing it's some kind of merb extension. Pat On Mon, Feb 2, 2009 at 6:19 PM, Phlip wrote: > I have to bump this one because it looks like it's on RSpec's core feature > list, and I reeally need a fix for it. > > Feel free to blame Merb, if they munged the inherit() method somehow! > >> Here's the relevant bits that don't work. (I changed the goal library to >> the 'assert2' patched into Test::Unit::Assertions.) >> >> require File.join( File.dirname(__FILE__), '..', "spec_helper" ) >> require 'test/unit' >> require 'assert2' >> >> >> describe 'Post' do >> >> before do >> include Test::Unit::TestCase >> # inherit Test::Unit::TestCase # does not compile >> # include Test::Unit::Assertions # does not import assert{} >> end >> >> it 'should have fixtures' do >> posts = posts(:Joan_Crawford_Has_Risen, :Jammin, :Sardonicus, :Lithium) >> posts[0].body.should == 'From the Grave' >> posts[0].tags.should include(tags(:progressive)) >> >> # this line never compiles >> assert{ posts[0].tags.include? tags(:rocksteady) } >> end >> >> end >> >> The rspec-rails plugin sure has me spoiled, huh? I formerly thought >> Test::Unit::Assertions would be automatically available, even without Rails >> around... >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From phlip2005 at gmail.com Mon Feb 2 23:36:18 2009 From: phlip2005 at gmail.com (Phlip) Date: Mon, 02 Feb 2009 20:36:18 -0800 Subject: [rspec-users] undefined method `inherit' for Merb::Test::ExampleGroup In-Reply-To: <810a540e0902022011x754426f3r6a38fb46c13e35f0@mail.gmail.com> References: <4987A9AB.1080108@gmail.com> <810a540e0902022011x754426f3r6a38fb46c13e35f0@mail.gmail.com> Message-ID: <4987C9C2.4090102@gmail.com> Pat Maddox wrote: > I'll blame Merb on the basis that there is no "inherit" in RSpec. I'm > guessing it's some kind of merb extension. http://blog.davidchelimsky.net/2007/4/1/rspec-plays-nice-with-others I know I know - time flies! If it has been superseded, then how do you inject a batch of assertions defined in someone else's class into RSpec? For example, how does RSpec on Rails import its ActiveSupport::TestCase assertions? From pergesu at gmail.com Tue Feb 3 00:00:09 2009 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 2 Feb 2009 21:00:09 -0800 Subject: [rspec-users] undefined method `inherit' for Merb::Test::ExampleGroup In-Reply-To: <4987C9C2.4090102@gmail.com> References: <4987A9AB.1080108@gmail.com> <810a540e0902022011x754426f3r6a38fb46c13e35f0@mail.gmail.com> <4987C9C2.4090102@gmail.com> Message-ID: <810a540e0902022100v60602b14u5a74c34ff823ed7d@mail.gmail.com> On Mon, Feb 2, 2009 at 8:36 PM, Phlip wrote: > Pat Maddox wrote: > >> I'll blame Merb on the basis that there is no "inherit" in RSpec. I'm >> guessing it's some kind of merb extension. > > http://blog.davidchelimsky.net/2007/4/1/rspec-plays-nice-with-others > > I know I know - time flies! > > If it has been superseded, then how do you inject a batch of assertions > defined in someone else's class into RSpec? > > For example, how does RSpec on Rails import its ActiveSupport::TestCase > assertions? rspec-rails defines Spec::Rails::Example::RailsExampleGroup that inherits from ActiveSupport::TestCase. All other example groups are subclasses of REG. What you want to do is something along the lines of: class SequelExampleGroup < FixtureDependencies::SequelTestCase extend Spec::Example::ExampleGroupMethods include Spec::Example::ExampleMethods # also any other modules that contain merb-specific expectations Spec::Example::ExampleGroupFactory.register :sequel, self end describe 'Post', :type => :sequel do ... end (I don't know that that's exactly it, but it should get you going) I think that forcing you to inherit from FixtureDependencies::SequelTestCase is pretty sucky and I'm not sure why they don't just have some modules that you could mix in in the Spec::Runner.configure block. Pat From dchelimsky at gmail.com Tue Feb 3 00:05:32 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 2 Feb 2009 23:05:32 -0600 Subject: [rspec-users] undefined method `inherit' for Merb::Test::ExampleGroup In-Reply-To: <4987C9C2.4090102@gmail.com> References: <4987A9AB.1080108@gmail.com> <810a540e0902022011x754426f3r6a38fb46c13e35f0@mail.gmail.com> <4987C9C2.4090102@gmail.com> Message-ID: <57c63afe0902022105hf214a34r8928a6ad08ea4fb5@mail.gmail.com> On Mon, Feb 2, 2009 at 10:36 PM, Phlip wrote: > Pat Maddox wrote: > >> I'll blame Merb on the basis that there is no "inherit" in RSpec. I'm >> guessing it's some kind of merb extension. > > http://blog.davidchelimsky.net/2007/4/1/rspec-plays-nice-with-others > > I know I know - time flies! > > If it has been superseded, then how do you inject a batch of assertions > defined in someone else's class into RSpec? module MyMethods # define matchers end Spec::Runner.configure do |c| c.include MyMethods end That will include the module in every example group, regardless of the base class. > > For example, how does RSpec on Rails import its ActiveSupport::TestCase > assertions? > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Tue Feb 3 03:30:06 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 3 Feb 2009 09:30:06 +0100 Subject: [rspec-users] [Cucumber] 0.1.99.x parse errors Message-ID: <8d961d900902030030l240b5b1lef156770f5ad66f4@mail.gmail.com> Folks, If you encounter parse errors on 0.1.99.x (0.2 prereleases), please do the following: 1) Create a http://gist.github.com/ with the full (but minimal) feature that fails to parse 2) Got to the *raw* view of that gist and comy the URL 3) Paste it into Lighthouse a ticket, and mention what 0.1.99.x version you're on Please update existing tickets This lets me easily debug parser errors with: bin/cucumber your_gist_url Thanks, Aslak (::) From lists at ruby-forum.com Tue Feb 3 06:58:55 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Tue, 3 Feb 2009 12:58:55 +0100 Subject: [rspec-users] webrat methods are undefined In-Reply-To: <57449cb6b55e765c1db8f544595cf206@ruby-forum.com> References: <897488b954d8536cb88314d26c128d13@ruby-forum.com> <27253a92e9ba59a23181303eb39111d6@ruby-forum.com> <85d99afe0901280933y532204eew37ae49b58f430f70@mail.gmail.com> <85d99afe0901281149q139df019nf8148310e6fb7707@mail.gmail.com> <57449cb6b55e765c1db8f544595cf206@ruby-forum.com> Message-ID: I was able to download the zip file and lo...the tests ran. Thanks for all your help! Tom -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Feb 3 08:32:55 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 3 Feb 2009 14:32:55 +0100 Subject: [rspec-users] [RSpec] rcov and/or rexml bug? In-Reply-To: <1d5d31eff1533f2d92d2ac0bc40c97d9@ruby-forum.com> References: <1d5d31eff1533f2d92d2ac0bc40c97d9@ruby-forum.com> Message-ID: <226f56f3f134b7e2635100218229096a@ruby-forum.com> Fernando Perez wrote: > Hi, > > Running: Ruby 1.8.7 p72, RSpec 1.1.12 and rcov 0.8.1.2.0, I get the > following error message with $ rake spec:rcov > > Anyone ran into that? Should I downgrade my Ruby version to have it > work? I previously updated it to its latest release hoping bugs would be > fixed. I do not think it has anything to do with Ruby. Using Ruby 1.8.6, Rails 2.2.2, RSpec 1.1.12 and Rcov 0.8.1.2.0 I get this error: rake spec:rcov invalid option: --output_dir rake aborted! I also had problems with spec_helper and the Rails logger. I am thinking that maybe RSpec 1.1.12, Rails 2.2.2 and perhaps Rcov 0.8.1 have some incompatibilities. -- Posted via http://www.ruby-forum.com/. From phlip2005 at gmail.com Tue Feb 3 08:47:59 2009 From: phlip2005 at gmail.com (Phlip) Date: Tue, 03 Feb 2009 05:47:59 -0800 Subject: [rspec-users] undefined method `inherit' for Merb::Test::ExampleGroup In-Reply-To: <57c63afe0902022105hf214a34r8928a6ad08ea4fb5@mail.gmail.com> References: <4987A9AB.1080108@gmail.com> <810a540e0902022011x754426f3r6a38fb46c13e35f0@mail.gmail.com> <4987C9C2.4090102@gmail.com> <57c63afe0902022105hf214a34r8928a6ad08ea4fb5@mail.gmail.com> Message-ID: <49884B0F.9080503@gmail.com> David Chelimsky wrote: > Spec::Runner.configure do |c| > c.include MyMethods > end Tx that was it! From dchelimsky at gmail.com Tue Feb 3 10:32:15 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 3 Feb 2009 09:32:15 -0600 Subject: [rspec-users] [RSpec] rcov and/or rexml bug? In-Reply-To: <226f56f3f134b7e2635100218229096a@ruby-forum.com> References: <1d5d31eff1533f2d92d2ac0bc40c97d9@ruby-forum.com> <226f56f3f134b7e2635100218229096a@ruby-forum.com> Message-ID: <57c63afe0902030732l6b7db945pf97035e2a7e592f4@mail.gmail.com> On Tue, Feb 3, 2009 at 7:32 AM, James Byrne wrote: > Fernando Perez wrote: >> Hi, >> >> Running: Ruby 1.8.7 p72, RSpec 1.1.12 and rcov 0.8.1.2.0, I get the >> following error message with $ rake spec:rcov > >> >> Anyone ran into that? Should I downgrade my Ruby version to have it >> work? I previously updated it to its latest release hoping bugs would be >> fixed. > > I do not think it has anything to do with Ruby. Using Ruby 1.8.6, Rails > 2.2.2, > RSpec 1.1.12 and Rcov 0.8.1.2.0 I get this error: > > rake spec:rcov > > invalid option: --output_dir > rake aborted! > > I also had problems with spec_helper and the Rails logger. I am > thinking that maybe RSpec 1.1.12, Rails 2.2.2 and perhaps Rcov 0.8.1 > have some incompatibilities. Try spicycode's rcov: [sudo] gem install spicycode-rcov --source http://gems.github.com > > -- > 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 Feb 3 12:08:03 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 3 Feb 2009 18:08:03 +0100 Subject: [rspec-users] Rcov rake task problems Message-ID: <43db262247c45eea4b1a810cffadfc88@ruby-forum.com> OS = MS-WinXPproSP3 / CYGWIN_NT-5.1 1.5.25(0.156/4/2) 2008-06-12 19:34 ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin] rails (2.2.2) rake (0.8.3) rcov (0.8.1.1.0) I am trying to develop a rake task that will aggregate the results for testunit, spec and cucumber tests. However, I find that I continually run into this error: $rake rcov --trace (in /home/byrnejb/projects/proforma.git) rake aborted! undefined method `rcov=' for # /home/byrnejb/projects/proforma.git/lib/tasks/rcov_new.rake:26 /usr/lib/ruby/gems/1.8/gems/rcov-0.8.1.1.0/lib/rcov/rcovtask.rb:92:in `initializ e' /home/byrnejb/projects/proforma.git/lib/tasks/rcov_new.rake:24:in `new' /home/byrnejb/projects/proforma.git/lib/tasks/rcov_new.rake:24 /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1851:in `in_namespace' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:892:in `namespace' /home/byrnejb/projects/proforma.git/lib/tasks/rcov_new.rake:11 /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies. rb:142:in `load_without_new_constant_marking' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies. rb:142:in `load' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies. rb:521:in `new_constants_in' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies. rb:142:in `load' /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/rails.rb:8 /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/rails.rb:8:in `each' /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/rails.rb:8 /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_requi re' /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' /home/byrnejb/projects/proforma.git/Rakefile:10 /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2349:in `load' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2349:in `raw_load_rakefile' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1985:in `load_rakefile' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_h andling' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1984:in `load_rakefile' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1969:in `run' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_h andling' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in `run' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31 /usr/bin/rake:19:in `load' /usr/bin/rake:19 All the rcov tasks, including those provided cucumber and rspec, are broken in the same fashion. I tried dropping back to an earlier version of rcov (0.8.1.1.0) from 0.8.1.2.0 but I obtain the same error. Has anyone any idea what might be wrong? The rake task used in this example is: require 'rcov/rcovtask' namespace :rcov do desc "Generate code coverage with rcov" task :coverage do rm_f "doc/coverage/coverage.data" rm_f "doc/coverage" mkdir "doc/coverage" rcov = %(rcov --rails --aggregate doc/coverage/coverage.data --text-summary -Ilib --html -o doc/coverage test/**/*_test.rb) system rcov system "open doc/coverage/index.html" if PLATFORM['darwin'] end end -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Feb 3 12:10:35 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 3 Feb 2009 18:10:35 +0100 Subject: [rspec-users] [RSpec] rcov and/or rexml bug? In-Reply-To: <57c63afe0902030732l6b7db945pf97035e2a7e592f4@mail.gmail.com> References: <1d5d31eff1533f2d92d2ac0bc40c97d9@ruby-forum.com> <226f56f3f134b7e2635100218229096a@ruby-forum.com> <57c63afe0902030732l6b7db945pf97035e2a7e592f4@mail.gmail.com> Message-ID: David Chelimsky wrote: > On Tue, Feb 3, 2009 at 7:32 AM, James Byrne > wrote: >> >> thinking that maybe RSpec 1.1.12, Rails 2.2.2 and perhaps Rcov 0.8.1 >> have some incompatibilities. > > Try spicycode's rcov: > > [sudo] gem install spicycode-rcov --source http://gems.github.com I get the same errors as with rcov: $rake rcov --trace (in /home/byrnejb/projects/proforma.git) rake aborted! undefined method `rcov=' for # /home/byrnejb/projects/proforma.git/lib/tasks/rcov_new.rake:26 /usr/lib/ruby/gems/1.8/gems/spicycode-rcov-0.8.1.5.0/lib/rcov/rcovtask.rb:92:in `initialize' -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Feb 3 12:30:51 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 3 Feb 2009 18:30:51 +0100 Subject: [rspec-users] Rcov rake task problems In-Reply-To: <43db262247c45eea4b1a810cffadfc88@ruby-forum.com> References: <43db262247c45eea4b1a810cffadfc88@ruby-forum.com> Message-ID: <85b9ebff4366eb3ea061e114e20a4b92@ruby-forum.com> desc "Rcov code coverage reports" task :rcov => "rcov:all" require 'rcov/rcovtask' namespace :rcov do Rcov::RcovTask.new(:all) do task :rcov => "rcov:testunit" end Rcov::RcovTask.new(:testunit) do |t| t.libs << "test" t.output_dir = 'coverage' t.test_files = FileList['test/**/test*.rb'] t.verbose = true end end However, this rake task works. So, the problem is in my rake task coding and not with rcov itself. -- Posted via http://www.ruby-forum.com/. From cwdinfo at gmail.com Tue Feb 3 12:42:47 2009 From: cwdinfo at gmail.com (s.ross) Date: Tue, 3 Feb 2009 09:42:47 -0800 Subject: [rspec-users] [Cucumber] How Do You Use Cucumber? Message-ID: <06BC16CC-2028-4F2B-A2C4-AF0C6A9061A6@gmail.com> I'm using Cucumber on my current project and it's causing me to wonder what other people's experience has been. I've read discussions about speeding up Cucumber and a basically everything else I can. Also, the rSpec book is articulate on the subject. What I'm curious about is whether a survey like this (in your opinions) would add useful information: Survey: How You Use Cucumber Do you: - Write failing steps first, then make them pass? - Use mocks/stubs? - Hit the database exactly as the application would or do you cache intermediate results? - Run: - Single scenarios instead of a whole feature - Individual features instead of single scenarios - All features instead of individual scenarios - Negative as well as positive scenarios - Use the helpful snippets for pending steps - Still use rSpec controller or view specs - Write features, then refactor parts out into shared steps later - Use the Textmate bundle - Run Cucumber all the time when developing controllers/views - Only run Cucumber for integration tests - Use an imperative or declarative style to describe scenarios - Ever include substitutable elements for readability that aren't used (i.e., /"(.*)" looks at his watch/ do |user| # user not referenced in step I'm happy to put a survey out there on whatever survey site people think is good once I have a good set of questions if there is interest and then tabulate the results. Good idea? Repetitive? Comments? Thanks, Steve From mark at mwilden.com Tue Feb 3 13:14:23 2009 From: mark at mwilden.com (Mark Wilden) Date: Tue, 3 Feb 2009 10:14:23 -0800 Subject: [rspec-users] [Cucumber] How Do You Use Cucumber? In-Reply-To: <06BC16CC-2028-4F2B-A2C4-AF0C6A9061A6@gmail.com> References: <06BC16CC-2028-4F2B-A2C4-AF0C6A9061A6@gmail.com> Message-ID: <3c30da400902031014j14078271td5d8d4ae07822aba@mail.gmail.com> On Tue, Feb 3, 2009 at 9:42 AM, s.ross wrote: > - Use the Textmate bundle > I just wanted to reply to this - Tim Pope's Cucumber plugin for Vim is awesome. You can be editing a feature step and go to its definition with a keystroke. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Tue Feb 3 13:49:40 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 3 Feb 2009 19:49:40 +0100 Subject: [rspec-users] Cucumber - but really ruby Message-ID: In the cucumber rake task I see this construct: t.rcov_opts = %w{--rails --exclude lib\/ruby,lib64\/ruby,\/usr,osx\/objc,gems\/,test\/,spec\/,features\/} t.rcov_opts << %[--output "coverage"] My questions is: What do %w and % represent with respect to the "block"? in the first case and the "array"? in the second? I cannot find an explanation of either usage in the documentation. -- Posted via http://www.ruby-forum.com/. From seatmanu at gmail.com Tue Feb 3 13:56:20 2009 From: seatmanu at gmail.com (Emmanuel Pinault) Date: Tue, 3 Feb 2009 10:56:20 -0800 Subject: [rspec-users] Cucumber - but really ruby In-Reply-To: References: Message-ID: <9FE04EE9-8C8B-4105-BD05-8D45942F25DE@gmail.com> w% is a ruby notation. It creates an Array of of the literal string you type separated by white space Emmanuel On Feb 3, 2009, at 10:49 AM, James Byrne wrote: > In the cucumber rake task I see this construct: > > t.rcov_opts = %w{--rails --exclude > lib\/ruby,lib64\/ruby,\/usr,osx\/objc,gems\/,test\/,spec\/,features\/} > t.rcov_opts << %[--output "coverage"] > > My questions is: What do %w and % represent with respect to the > "block"? in the first case and the "array"? in the second? I cannot > find an explanation of either usage in the documentation. > -- > 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 Feb 3 14:04:58 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 3 Feb 2009 20:04:58 +0100 Subject: [rspec-users] Cucumber - but really ruby In-Reply-To: <9FE04EE9-8C8B-4105-BD05-8D45942F25DE@gmail.com> References: <9FE04EE9-8C8B-4105-BD05-8D45942F25DE@gmail.com> Message-ID: <72347ae374363f20f9b32c438309be6d@ruby-forum.com> Emmanuel Pinault wrote: > w% is a ruby notation. It creates an Array of of the literal string > you type separated by white space > > Emmanuel Thank you. What does %[...] do? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Tue Feb 3 14:03:00 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 3 Feb 2009 13:03:00 -0600 Subject: [rspec-users] Cucumber - but really ruby In-Reply-To: References: Message-ID: <57c63afe0902031103h46e08c29ye81b3102f28e5685@mail.gmail.com> On Tue, Feb 3, 2009 at 12:49 PM, James Byrne wrote: > In the cucumber rake task I see this construct: > > t.rcov_opts = %w{--rails --exclude > lib\/ruby,lib64\/ruby,\/usr,osx\/objc,gems\/,test\/,spec\/,features\/} > t.rcov_opts << %[--output "coverage"] > > My questions is: What do %w and % represent with respect to the > "block"? in the first case and the "array"? in the second? I cannot > find an explanation of either usage in the documentation. They're not really a block and an array - the %w can be followed by the delimiter of your choice, and makes an array of the words between the first and next instance of that delimiter. For example, each of these: %w{these words} %w[these words] %w|these words| %w%these words% ... all produce this array: ["these","words"] 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 ngocdaothanh at gmail.com Tue Feb 3 14:01:19 2009 From: ngocdaothanh at gmail.com (Ngoc Dao) Date: Wed, 4 Feb 2009 04:01:19 +0900 Subject: [rspec-users] Cucumber - but really ruby In-Reply-To: <9FE04EE9-8C8B-4105-BD05-8D45942F25DE@gmail.com> References: <9FE04EE9-8C8B-4105-BD05-8D45942F25DE@gmail.com> Message-ID: <5c493e530902031101v5385f80gb1f167246c9adf82@mail.gmail.com> Explanation: http://jimhoskins.com/2008/10/07/ruby-percent-syntax-percent-functions/ Ngoc. On Wed, Feb 4, 2009 at 3:56 AM, Emmanuel Pinault wrote: > w% is a ruby notation. It creates an Array of of the literal string you > type separated by white space > > Emmanuel > > On Feb 3, 2009, at 10:49 AM, James Byrne wrote: > > In the cucumber rake task I see this construct: >> >> t.rcov_opts = %w{--rails --exclude >> lib\/ruby,lib64\/ruby,\/usr,osx\/objc,gems\/,test\/,spec\/,features\/} >> t.rcov_opts << %[--output "coverage"] >> >> My questions is: What do %w and % represent with respect to the >> "block"? in the first case and the "array"? in the second? I cannot >> find an explanation of either usage in the documentation. >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Tue Feb 3 14:10:56 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 3 Feb 2009 20:10:56 +0100 Subject: [rspec-users] Cucumber - but really ruby In-Reply-To: <72347ae374363f20f9b32c438309be6d@ruby-forum.com> References: <9FE04EE9-8C8B-4105-BD05-8D45942F25DE@gmail.com> <72347ae374363f20f9b32c438309be6d@ruby-forum.com> Message-ID: <0158016c10142308be77ec6ce62572f0@ruby-forum.com> James Byrne wrote: > > Thank you. What does %[...] do? This would not happen to be the same thing as %Q[..] would it? -- Posted via http://www.ruby-forum.com/. From godfoca at gmail.com Tue Feb 3 14:04:47 2009 From: godfoca at gmail.com (=?ISO-8859-1?Q?Nicol=E1s_Sanguinetti?=) Date: Tue, 3 Feb 2009 17:04:47 -0200 Subject: [rspec-users] Cucumber - but really ruby In-Reply-To: References: Message-ID: %w == string.split(/\s+/) (maybe not exactly that regexp, but basically it's an array of the words--hence the w) % == string, but without needing to escape the quotes. It's the same as using %Q (ie, it understands escape sequences and interpolated expressions inside, while %q is a literal string) HTH -foca On Tue, Feb 3, 2009 at 4:49 PM, James Byrne wrote: > In the cucumber rake task I see this construct: > > t.rcov_opts = %w{--rails --exclude > lib\/ruby,lib64\/ruby,\/usr,osx\/objc,gems\/,test\/,spec\/,features\/} > t.rcov_opts << %[--output "coverage"] > > My questions is: What do %w and % represent with respect to the > "block"? in the first case and the "array"? in the second? I cannot > find an explanation of either usage in the documentation. > -- > 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 Feb 3 14:14:03 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 3 Feb 2009 13:14:03 -0600 Subject: [rspec-users] Cucumber - but really ruby In-Reply-To: <0158016c10142308be77ec6ce62572f0@ruby-forum.com> References: <9FE04EE9-8C8B-4105-BD05-8D45942F25DE@gmail.com> <72347ae374363f20f9b32c438309be6d@ruby-forum.com> <0158016c10142308be77ec6ce62572f0@ruby-forum.com> Message-ID: <57c63afe0902031114oa98c56fuc971e5007d3b7bc9@mail.gmail.com> On Tue, Feb 3, 2009 at 1:10 PM, James Byrne wrote: > James Byrne wrote: >> >> Thank you. What does %[...] do? > > This would not happen to be the same thing as %Q[..] would it? Nope. http://www.rubycentral.com/pickaxe/tut_stdtypes.html scroll down to strings > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From seatmanu at gmail.com Tue Feb 3 14:16:37 2009 From: seatmanu at gmail.com (Emmanuel Pinault) Date: Tue, 3 Feb 2009 11:16:37 -0800 Subject: [rspec-users] Cucumber - but really ruby In-Reply-To: <72347ae374363f20f9b32c438309be6d@ruby-forum.com> References: <9FE04EE9-8C8B-4105-BD05-8D45942F25DE@gmail.com> <72347ae374363f20f9b32c438309be6d@ruby-forum.com> Message-ID: <7FC31443-B54C-40EF-BA23-460FCACBC23C@gmail.com> Could not remember that one but based on testing on irb, seems to do the reverse :) Array to string. so %[test blah] becomes "test blah" On Feb 3, 2009, at 11:04 AM, James Byrne wrote: > Emmanuel Pinault wrote: >> w% is a ruby notation. It creates an Array of of the literal string >> you type separated by white space >> >> Emmanuel > > Thank you. What does %[...] do? > -- > 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 Feb 3 14:18:17 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 3 Feb 2009 20:18:17 +0100 Subject: [rspec-users] Cucumber - but really ruby % and %w In-Reply-To: <0158016c10142308be77ec6ce62572f0@ruby-forum.com> References: <9FE04EE9-8C8B-4105-BD05-8D45942F25DE@gmail.com> <72347ae374363f20f9b32c438309be6d@ruby-forum.com> <0158016c10142308be77ec6ce62572f0@ruby-forum.com> Message-ID: James Byrne wrote: > > This would not happen to be the same thing as %Q[..] would it? Apparently, the construct: t.rcov_opts = %w{--rails --exclude lib\/ruby,lib64\/ruby,\/usr,osx\/objc,gems\/,test\/,spec\/,features\/} t.rcov_opts << %[--output "coverage"] is equivalent to: t.rcov_opts = [ "--rails" "--exclude" "lib\/ruby,lib64\/ruby,\/usr,osx\/objc,gems\/,test\/,spec\/,features\/" "--output" "coverage" ] Posted so that I can google for it next time. -- Posted via http://www.ruby-forum.com/. From f.mischa at gmail.com Tue Feb 3 14:18:27 2009 From: f.mischa at gmail.com (Mischa Fierer) Date: Tue, 3 Feb 2009 13:18:27 -0600 Subject: [rspec-users] Cucumber - but really ruby In-Reply-To: <0158016c10142308be77ec6ce62572f0@ruby-forum.com> References: <9FE04EE9-8C8B-4105-BD05-8D45942F25DE@gmail.com> <72347ae374363f20f9b32c438309be6d@ruby-forum.com> <0158016c10142308be77ec6ce62572f0@ruby-forum.com> Message-ID: A full listing of this stuff can be found here: http://www.zenspider.com/Languages/Ruby/QuickRef.html#6 % appears to be the same thing as %Q On Tue, Feb 3, 2009 at 1:10 PM, James Byrne wrote: > James Byrne wrote: > > > > Thank you. What does %[...] do? > > This would not happen to be the same thing as %Q[..] would it? > -- > 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 dchelimsky at gmail.com Tue Feb 3 14:40:45 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 3 Feb 2009 13:40:45 -0600 Subject: [rspec-users] [Cucumber] 0.1.99.x parse errors In-Reply-To: <8d961d900902030030l240b5b1lef156770f5ad66f4@mail.gmail.com> References: <8d961d900902030030l240b5b1lef156770f5ad66f4@mail.gmail.com> Message-ID: <57c63afe0902031140v7ce15fc1ldb860dbf7bdab73a@mail.gmail.com> On Tue, Feb 3, 2009 at 2:30 AM, aslak hellesoy wrote: > Folks, > > If you encounter parse errors on 0.1.99.x (0.2 prereleases), please do > the following: > > 1) Create a http://gist.github.com/ with the full (but minimal) > feature that fails to parse > 2) Got to the *raw* view of that gist and comy the URL > 3) Paste it into Lighthouse a ticket, and mention what 0.1.99.x > version you're on > > Please update existing tickets > > This lets me easily debug parser errors with: > bin/cucumber your_gist_url This is BRILLIANT, Aslak. Opens the door for a number of different online conversations about features. David > Thanks, > Aslak (::) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Tue Feb 3 14:52:56 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 3 Feb 2009 20:52:56 +0100 Subject: [rspec-users] Cucumber - but really ruby In-Reply-To: <57c63afe0902031114oa98c56fuc971e5007d3b7bc9@mail.gmail.com> References: <9FE04EE9-8C8B-4105-BD05-8D45942F25DE@gmail.com> <72347ae374363f20f9b32c438309be6d@ruby-forum.com> <0158016c10142308be77ec6ce62572f0@ruby-forum.com> <57c63afe0902031114oa98c56fuc971e5007d3b7bc9@mail.gmail.com> Message-ID: <9b1351da71927f5d0c1492cbbd19e21c@ruby-forum.com> David Chelimsky wrote: > On Tue, Feb 3, 2009 at 1:10 PM, James Byrne > wrote: >> James Byrne wrote: >>> >>> Thank you. What does %[...] do? >> >> This would not happen to be the same thing as %Q[..] would it? > > Nope. > > http://www.rubycentral.com/pickaxe/tut_stdtypes.html > > scroll down to strings I did. I can find nothing that discusses the %[] construct. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Feb 3 15:00:32 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 3 Feb 2009 21:00:32 +0100 Subject: [rspec-users] Rcov - Specifying rake tasks Message-ID: <80addea73439be01121419279f879fc6@ruby-forum.com> I am trying to get a customized rcov rake task working. What I have so far looks like this: desc "Rcov code coverage reports" require 'rcov/rcovtask' require 'spec/rake/spectask' require 'cucumber/rake/task' task :rcov => "rcov:all" namespace :rcov do Rcov::RcovTask.new(:all) do task :rcov => "rcov:cucumber" end Cucumber::Rake::Task.new(:cucumber) do |t| ... Spec::Rake::SpecTask.new(:rspec) do |t ... Rcov::RcovTask.new(:testunit) do |t| ... Now, rake rcov:cucumber runs the cucumber rcov task as expected. However, both rake rcov and rake rcov:all run rake rcov:testunit. I cannot fathom why. Can someone explain this to me? -- Posted via http://www.ruby-forum.com/. From godfoca at gmail.com Tue Feb 3 15:46:23 2009 From: godfoca at gmail.com (=?ISO-8859-1?Q?Nicol=E1s_Sanguinetti?=) Date: Tue, 3 Feb 2009 18:46:23 -0200 Subject: [rspec-users] Cucumber - but really ruby In-Reply-To: <9b1351da71927f5d0c1492cbbd19e21c@ruby-forum.com> References: <9FE04EE9-8C8B-4105-BD05-8D45942F25DE@gmail.com> <72347ae374363f20f9b32c438309be6d@ruby-forum.com> <0158016c10142308be77ec6ce62572f0@ruby-forum.com> <57c63afe0902031114oa98c56fuc971e5007d3b7bc9@mail.gmail.com> <9b1351da71927f5d0c1492cbbd19e21c@ruby-forum.com> Message-ID: Uh, seems my email never arrived? This is what I had written: %w == string.split(/\s+/) (maybe not exactly that regexp, but basically it's an array of the words--hence the w) % == string, but without needing to escape the quotes. It's the same as using %Q (ie, it understands escape sequences and interpolated expressions inside, while %q is a literal string) HTH -foca On Tue, Feb 3, 2009 at 5:52 PM, James Byrne wrote: > David Chelimsky wrote: >> On Tue, Feb 3, 2009 at 1:10 PM, James Byrne >> wrote: >>> James Byrne wrote: >>>> >>>> Thank you. What does %[...] do? >>> >>> This would not happen to be the same thing as %Q[..] would it? >> >> Nope. >> >> http://www.rubycentral.com/pickaxe/tut_stdtypes.html >> >> scroll down to strings > > I did. I can find nothing that discusses the %[] construct. > -- > 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 Feb 3 15:57:26 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 3 Feb 2009 21:57:26 +0100 Subject: [rspec-users] Rcov - Specifying rake tasks In-Reply-To: <80addea73439be01121419279f879fc6@ruby-forum.com> References: <80addea73439be01121419279f879fc6@ruby-forum.com> Message-ID: <2cfd81b8ba3969c0ebb94496d0f0306a@ruby-forum.com> I am having a good deal of trouble grappling with how rake tasks are processed. In my rcov.rake file I have this: desc "Rcov code coverage reports" require 'rcov/rcovtask' require 'spec/rake/spectask' require 'cucumber/rake/task' #task :rcov => "rcov:complete" namespace :rcov do ... Cucumber::Rake::Task.new(:cucumber) do |t| puts "Why am I in the cucumber task? ... end Spec::Rake::SpecTask.new(:rspec) do |t| puts "Why am I in the rspec task? ... end end Rcov::RcovTask.new(:testunit) do |t| puts "Why am I in the rspec task? ... end Rcov::RcovTask.new(:complete) do puts "What the hell am I doing here?" ... end end When I run rake rcov:cucumber I see this: Why am I in the cucumber task? Why am I in the rspec task? Why am I in the testunit task? What the hell am I doing here? This indicates that the entire rake task is processed regardless of the argument given, which to me makes no sense at all. Can somebody explain why I am observing this behaviour? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Tue Feb 3 17:20:02 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 3 Feb 2009 16:20:02 -0600 Subject: [rspec-users] rspec and shoulda, together again at last Message-ID: <57c63afe0902031420y11bb4f9sb763327388d81211@mail.gmail.com> Joe Ferris at thoughbot just announced the latest release of shoulda with an exciting new feature: RSpec-compatible ActiveRecord matchers! http://giantrobots.thoughtbot.com/2009/2/3/speculating-with-shoulda I'm excited about this for a few reasons. To quote Tammer Saleh, shoulda's creator (from his comment on the post above): "All in all, this should be a big win for both projects ? rspec gets the tasty matchers, and shoulda gets cleaner internal code and contributions from the rspec community." Big thanks to Joe Ferris who pursued this idea, contributed the necessary changes to RSpec, and did a ton of work refactoring shoulda to make it happen. Cheers, David From lists at ruby-forum.com Tue Feb 3 18:05:56 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 4 Feb 2009 00:05:56 +0100 Subject: [rspec-users] Rcov - Specifying rake tasks In-Reply-To: <2cfd81b8ba3969c0ebb94496d0f0306a@ruby-forum.com> References: <80addea73439be01121419279f879fc6@ruby-forum.com> <2cfd81b8ba3969c0ebb94496d0f0306a@ruby-forum.com> Message-ID: <272b4af98349a80ea00a169453576046@ruby-forum.com> James Byrne wrote: > I am having a good deal of trouble grappling with how rake tasks are > processed. In my rcov.rake file I have this: I think that I have this straightened now. Cucumber::Rake::Task.new(:cucumber) etc. are factory methods that are processed as encountered by rake. -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Tue Feb 3 18:14:10 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 4 Feb 2009 00:14:10 +0100 Subject: [rspec-users] [Cucumber] 0.1.99.x parse errors In-Reply-To: <57c63afe0902031140v7ce15fc1ldb860dbf7bdab73a@mail.gmail.com> References: <8d961d900902030030l240b5b1lef156770f5ad66f4@mail.gmail.com> <57c63afe0902031140v7ce15fc1ldb860dbf7bdab73a@mail.gmail.com> Message-ID: <8d961d900902031514m22473bc7i63de7417692cdbe@mail.gmail.com> On Tue, Feb 3, 2009 at 8:40 PM, David Chelimsky wrote: > On Tue, Feb 3, 2009 at 2:30 AM, aslak hellesoy wrote: >> Folks, >> >> If you encounter parse errors on 0.1.99.x (0.2 prereleases), please do >> the following: >> >> 1) Create a http://gist.github.com/ with the full (but minimal) >> feature that fails to parse >> 2) Got to the *raw* view of that gist and comy the URL >> 3) Paste it into Lighthouse a ticket, and mention what 0.1.99.x >> version you're on >> >> Please update existing tickets >> >> This lets me easily debug parser errors with: >> bin/cucumber your_gist_url > > This is BRILLIANT, Aslak. Opens the door for a number of different > online conversations about features. > Thanks David :-) I added this to make it easier to communicate. I hope people won't use it to actually *run* features :-) Or maybe this is the start of web2.0 requirements specifications? :-) Aslak > David > >> Thanks, >> Aslak (::) >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From lists at ruby-forum.com Tue Feb 3 20:21:23 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 4 Feb 2009 02:21:23 +0100 Subject: [rspec-users] Rcov - Specifying rake tasks In-Reply-To: <272b4af98349a80ea00a169453576046@ruby-forum.com> References: <80addea73439be01121419279f879fc6@ruby-forum.com> <2cfd81b8ba3969c0ebb94496d0f0306a@ruby-forum.com> <272b4af98349a80ea00a169453576046@ruby-forum.com> Message-ID: James Byrne wrote: > I think that I have this straightened now. > Cucumber::Rake::Task.new(:cucumber) etc. are factory methods that are > processed as encountered by rake. Having spent the day delving into Rake and the internals of factory methods for Rake included with RSpec and Cucumber, I did a little write up on how to create a custom Rake task for Rcov. I would appreciate it if people with a deeper knowledge of Rake and Rcov would review this document and point out any errors or misunderstandings that it may contain. The URL is http://wiki.rubyonrails.org/rails/pages/HowToCustomizeAnRcovRakeTask Thanks -- Posted via http://www.ruby-forum.com/. From mark.thomson at ieee.org Tue Feb 3 20:52:16 2009 From: mark.thomson at ieee.org (MarkMT) Date: Tue, 3 Feb 2009 17:52:16 -0800 (PST) Subject: [rspec-users] have_tag with a block Message-ID: <73f9ae8d-a26d-4f8c-aff6-1d9222779024@r34g2000vbp.googlegroups.com> This is really a webrat question, but I haven't had any reaction to this from the webrat group. Maybe someone here can offer a comment... I've been fooling around with webrat view matchers in merb / cucumber and I'm trying to figure out whether the block parameter in have_tag actually does anything. I've tried passing a block with pure nonsense in it and the interpreter just seems to accept it and ignore it as if it doesn't exist. Initially I had hoped there was something like 'with_tag' you could nest inside a block, but I guess that was a rails thing. However from my quick look at the code, although with fairly limited ruby experience, I got the impression that 'have_tag' passes any matching markup it finds into the block as a parameter. But none of my experiments have been able to confirm this. Does anyone have first hand knowledge of / successful experience with have_tag with a block? From dchelimsky at gmail.com Tue Feb 3 21:01:50 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 3 Feb 2009 20:01:50 -0600 Subject: [rspec-users] have_tag with a block In-Reply-To: <73f9ae8d-a26d-4f8c-aff6-1d9222779024@r34g2000vbp.googlegroups.com> References: <73f9ae8d-a26d-4f8c-aff6-1d9222779024@r34g2000vbp.googlegroups.com> Message-ID: <57c63afe0902031801q299858cfo788ae9730170e4b0@mail.gmail.com> On Tue, Feb 3, 2009 at 7:52 PM, MarkMT wrote: > This is really a webrat question, but I haven't had any reaction to > this from the webrat group. Maybe someone here can offer a comment... > > I've been fooling around with webrat view matchers in merb / cucumber > and I'm trying to figure out whether the block parameter in have_tag > actually does anything. I've tried passing a block with pure nonsense > in it and the interpreter just seems to accept it and ignore it as if > it doesn't exist. > > Initially I had hoped there was something like 'with_tag' you could > nest inside a block, but I guess that was a rails thing. However from > my quick look at the code, although with fairly limited ruby > experience, I got the impression that 'have_tag' passes any matching > markup it finds into the block as a parameter. But none of my > experiments have been able to confirm this. > > Does anyone have first hand knowledge of / successful experience with > have_tag with a block? Not first hand experience, but I'm looking at the specs in webrat: http://github.com/brynary/webrat/blob/e5ae16367cfd656617815fd9b9c405bc6bb3a97d/spec/public/matchers_spec.rb If you scroll down to describe "#have_tag", you'll see a couple of examples. It looks like your instinct is at least close to correct. Can you post an example of what you're trying to do? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From zach.dennis at gmail.com Tue Feb 3 22:47:14 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Tue, 3 Feb 2009 22:47:14 -0500 Subject: [rspec-users] nokogiri selector help In-Reply-To: References: <51054F01-B154-4D21-9B11-96AEF17F7B15@parkerhill.com> <85d99afe0901250858we266949l2473e4da56b8d1ed@mail.gmail.com> Message-ID: <85d99afe0902031947h21b6404bm7e519eb750833d21@mail.gmail.com> On Fri, Jan 30, 2009 at 9:45 PM, Jonathan Linowes wrote: > > On Jan 25, 2009, at 11:58 AM, Zach Dennis wrote: > >> On Sat, Jan 24, 2009 at 12:05 AM, Jonathan Linowes >> wrote: >>> >>> hiya, >>> >>> i want the selector that would return a of a table if any td >>> contains >>> some text, so i can use it in click_link_within >>> >>> e.g. When I click the "show" link within the row containing >>> "user at example.com" >>> >>> >>> When /^I click the "(.+)" link within the row containing "(.+)"$/ do >>> |link, >>> text| >>> selector = ?? >>> click_link_within selector, link >>> end >> >> You can use an XPath selector to find the parent. Try: >> >> selector = "//table//tr//td[contains(.,'user at example.com')]//.." > > hi Zach, > > that works as a selector when I do > doc = Nokogiri::HTML.parse( response.body ) > doc.xpath(selector) > returns the correct dom elements > > but when used with click_link_within I get the error > > Nokogiri::CSS::SyntaxError Exception: unexpected '//' after '' > Sorry for the late reply, but this is a bug in webrat not a nokogiri issue. I've created a ticket for it at lighthouse: http://webrat.lighthouseapp.com/projects/10503-webrat/tickets/153-within-should-support-xpath -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From mark.thomson at ieee.org Wed Feb 4 00:44:34 2009 From: mark.thomson at ieee.org (MarkMT) Date: Tue, 3 Feb 2009 21:44:34 -0800 (PST) Subject: [rspec-users] have_tag with a block In-Reply-To: <57c63afe0902031801q299858cfo788ae9730170e4b0@mail.gmail.com> References: <73f9ae8d-a26d-4f8c-aff6-1d9222779024@r34g2000vbp.googlegroups.com> <57c63afe0902031801q299858cfo788ae9730170e4b0@mail.gmail.com> Message-ID: Thanks David. Those specs are very instructive. I have no idea what I was doing wrong before, but the behavior I'm seeing now is indeed consistent with the specs and matches what I had understood from the code I'd looked at (I suspect it'll stop working as soon as I send this :-) ). Actually my situation is slightly more complex than what the specs cover. I have something like this - and I'm testing it with a cucumber step that looks like this - Then /^the response should contain a link to new user registration$/ do @response.should have_tag('div', :id =>'registration_link', :content => 'New User? Register ') { |match| match.should have_tag('a', :href => '/User/register', :content => 'here') } end One of the things I was unsure about was whether I could mix both the text content and the second tag inside the outer element. Turns out that this works just fine with the test above. Also, have_tag ('div#registration_link'...) works just as well as have_tag('div', :id => 'registration_link'...) Mark. On Feb 3, 8:01?pm, David Chelimsky wrote: > On Tue, Feb 3, 2009 at 7:52 PM, MarkMT wrote: > > This is really a webrat question, but I haven't had any reaction to > > this from the webrat group. Maybe someone here can offer a comment... > > > I've been fooling around with webrat view matchers in merb / cucumber > > and I'm trying to figure out whether the block parameter in have_tag > > actually does anything. I've tried passing a block with pure nonsense > > in it and the interpreter just seems to accept it and ignore it as if > > it doesn't exist. > > > Initially I had hoped there was something like 'with_tag' you could > > nest inside a block, but I guess that was a rails thing. However from > > my quick look at the code, although with fairly limited ruby > > experience, I got the impression that 'have_tag' passes any matching > > markup it finds into the block as a parameter. But none of my > > experiments have been able to confirm this. > > > Does anyone have first hand knowledge of / successful experience with > > have_tag with a block? > > Not first hand experience, but I'm looking at the specs in webrat: > > http://github.com/brynary/webrat/blob/e5ae16367cfd656617815fd9b9c405b... > > If you scroll down to describe "#have_tag", you'll see a couple of > examples. It looks like your instinct is at least close to correct. > > Can you post an example of what you're trying to do? > > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From johnjkle at gmail.com Wed Feb 4 04:07:29 2009 From: johnjkle at gmail.com (John Kolokotronis) Date: Wed, 4 Feb 2009 01:07:29 -0800 (PST) Subject: [rspec-users] [Rspec] How do you nest before(:all) or after(:all) blocks? Message-ID: <3aac08fd-5a32-4549-87bd-8a3b888f959c@h20g2000yqn.googlegroups.com> Hi all, I'm new to Rspec but loving it so far and looking to use it as a replacement for a Test::Unit framework I have which drives a web app via Watir. So far, things have worked very well with Rspec but I can't get my head around how before/after(:all) blocks would work in nested groups, or even if what I am doing is possible. What I want to do is something like this: describe "This is a set of tests: " do before(:all) do puts "this should only appear once" end describe "Test 1" do puts "test 1" end describe "Test 2" do puts "test 2" end end Expecting the before(:all) block to run only once and see something like: - this should only appear once - test 1 - test 2 but what I am getting is: - this should only appear once - test 1 - this should only appear once - test 2 So my question is, how can you add before/after(:all) blocks that run once and only once for for all examples, if all the examples are nested in one main describe block? Is that something that's even possible? I'd appreciate any pointers anyone may have. Thanks! Regards, John From dchelimsky at gmail.com Wed Feb 4 09:03:19 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Feb 2009 08:03:19 -0600 Subject: [rspec-users] [Rspec] How do you nest before(:all) or after(:all) blocks? In-Reply-To: <3aac08fd-5a32-4549-87bd-8a3b888f959c@h20g2000yqn.googlegroups.com> References: <3aac08fd-5a32-4549-87bd-8a3b888f959c@h20g2000yqn.googlegroups.com> Message-ID: <57c63afe0902040603m2e0a9460maf9457d40c888205@mail.gmail.com> On Wed, Feb 4, 2009 at 3:07 AM, John Kolokotronis wrote: > Hi all, > > I'm new to Rspec but loving it so far and looking to use it as a > replacement for a Test::Unit framework I have which drives a web app > via Watir. So far, things have worked very well with Rspec but I can't > get my head around how before/after(:all) blocks would work in nested > groups, or even if what I am doing is possible. > > What I want to do is something like this: > > describe "This is a set of tests: " do > before(:all) do > puts "this should only appear once" > end > > describe "Test 1" do > puts "test 1" > end > > describe "Test 2" do > puts "test 2" > end > end > > Expecting the before(:all) block to run only once and see something > like: > > - this should only appear once > - test 1 > - test 2 > > but what I am getting is: > > - this should only appear once > - test 1 > - this should only appear once > - test 2 > > So my question is, how can you add before/after(:all) blocks that run > once and only once for for all examples, if all the examples are > nested in one main describe block? Is that something that's even > possible? I'd appreciate any pointers anyone may have. Thanks! Right now it's not possible. There's an open ticket on this: http://rspec.lighthouseapp.com/projects/5645/tickets/632 > > Regards, > > John > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From johnjkle at gmail.com Wed Feb 4 10:07:48 2009 From: johnjkle at gmail.com (John Kolokotronis) Date: Wed, 4 Feb 2009 07:07:48 -0800 (PST) Subject: [rspec-users] [Rspec] How do you nest before(:all) or after(:all) blocks? In-Reply-To: <57c63afe0902040603m2e0a9460maf9457d40c888205@mail.gmail.com> References: <3aac08fd-5a32-4549-87bd-8a3b888f959c@h20g2000yqn.googlegroups.com> <57c63afe0902040603m2e0a9460maf9457d40c888205@mail.gmail.com> Message-ID: <6b5fec40-6c29-410d-b55f-23034ccd4ae2@f3g2000yqf.googlegroups.com> Thanks for the reply David - much appreciated. At least now I know that it can't be done, rather than pursuing it further for now. I'll just have to live without that functionality for now and add it later on if a fix is made available. Regards, John On Feb 4, 2:03?pm, David Chelimsky wrote: > On Wed, Feb 4, 2009 at 3:07 AM, John Kolokotronis wrote: > > Hi all, > > > I'm new to Rspec but loving it so far and looking to use it as a > > replacement for a Test::Unit framework I have which drives a web app > > via Watir. So far, things have worked very well with Rspec but I can't > > get my head around how before/after(:all) blocks would work in nested > > groups, or even if what I am doing is possible. > > > What I want to do is something like this: > > > describe "This is a set of tests: " do > > ? ? ? ?before(:all) do > > ? ? ? ? ? ? ? ?puts "this should only appear once" > > ? ? ? ?end > > > ? ? ? ?describe "Test 1" do > > ? ? ? ? ? ? ? ?puts "test 1" > > ? ? ? ?end > > > ? ? ? ?describe "Test 2" do > > ? ? ? ? ? ? ? ?puts "test 2" > > ? ? ? ?end > > end > > > Expecting the before(:all) block to run only once and see something > > like: > > > - this should only appear once > > - test 1 > > - test 2 > > > but what I am getting is: > > > - this should only appear once > > - test 1 > > - this should only appear once > > - test 2 > > > So my question is, how can you add before/after(:all) blocks that run > > once and only once for for all examples, if all the examples are > > nested in one main describe block? Is that something that's even > > possible? I'd appreciate any pointers anyone may have. Thanks! > > Right now it's not possible. There's an open ticket on this: > > http://rspec.lighthouseapp.com/projects/5645/tickets/632 > > > > > Regards, > > > John > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From scott at railsnewbie.com Wed Feb 4 10:30:09 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Wed, 04 Feb 2009 10:30:09 -0500 Subject: [rspec-users] [Rspec] How do you nest before(:all) or after(:all) blocks? In-Reply-To: <3aac08fd-5a32-4549-87bd-8a3b888f959c@h20g2000yqn.googlegroups.com> References: <3aac08fd-5a32-4549-87bd-8a3b888f959c@h20g2000yqn.googlegroups.com> Message-ID: <4989B481.8030806@railsnewbie.com> John Kolokotronis wrote: > Hi all, > > I'm new to Rspec but loving it so far and looking to use it as a > replacement for a Test::Unit framework I have which drives a web app > via Watir. So far, things have worked very well with Rspec but I can't > get my head around how before/after(:all) blocks would work in nested > groups, or even if what I am doing is possible. > > What I want to do is something like this: > > describe "This is a set of tests: " do > before(:all) do > puts "this should only appear once" > end > > describe "Test 1" do > puts "test 1" > end > > describe "Test 2" do > puts "test 2" > end > end > > Expecting the before(:all) block to run only once and see something > like: > > - this should only appear once > - test 1 > - test 2 > > but what I am getting is: > > - this should only appear once > - test 1 > - this should only appear once > - test 2 > > So my question is, how can you add before/after(:all) blocks that run > once and only once for for all examples, if all the examples are > nested in one main describe block? Is that something that's even > possible? I'd appreciate any pointers anyone may have. Thanks! > > Why do you want before(:all)? Generally it's use is disregarded, just as global variables are considered harmful, not because they can't be used well, but because 99% of the times they aren't. Scott From johnjkle at gmail.com Wed Feb 4 12:55:07 2009 From: johnjkle at gmail.com (John Kolokotronis) Date: Wed, 4 Feb 2009 09:55:07 -0800 (PST) Subject: [rspec-users] [Rspec] How do you nest before(:all) or after(:all) blocks? In-Reply-To: <4989B481.8030806@railsnewbie.com> References: <3aac08fd-5a32-4549-87bd-8a3b888f959c@h20g2000yqn.googlegroups.com> <4989B481.8030806@railsnewbie.com> Message-ID: > Why do you want before(:all)? ?Generally it's use is disregarded, just > as global variables are considered harmful, not because they can't be > used well, but because 99% of the times they aren't. Because I want to be able to create a single @browser object at the beginning of my tests and have it passed to all examples. Without nested examples, that works just fine - I can create my browser instance in the before(:all) block and avoid using a global variable. In nested examples, I don't see a good way to do that - I could always set up the browser instance as a global (did that in the past with Test::Unit and many Watir users do so) but I'd like to avoid this. If I didn't use a before(:all) block or a global variable, would there be any way to pass my browser object to all example groups? Currently my tests look like this: describe "A series of tests" do before(:all) do @browser = Watir::Browser.new end it "Test 1: it should go to www.google.com" do @browser.goto("www.google.com") end end Obviously, been able to use nested describe groups would make the tests easier to read for non-coders here and that's why I wanted to use them... Regards, John From chris at cobaltedge.com Wed Feb 4 13:21:17 2009 From: chris at cobaltedge.com (Christopher Bailey) Date: Wed, 4 Feb 2009 10:21:17 -0800 Subject: [rspec-users] Cucumber/Webrat fails to find fields when run after specs Message-ID: <443c240c0902041021y17c276ddq534b8e25d278d335@mail.gmail.com> I've been battling the strangest behavior, and hoping someone can shed some light... I am using RSpec for MVC tests, and then Cucumber for stories/features. I am new to Cucumber, and recently finished converting our RSpec Story Runner suite to it. What I'm seeing is that if I clean the database (e.g. rake db:reset), then run all my specs, then run the features, Webrat fails to find various fields on form pages. If I run them in the reverse order, with features first, then specs, often times various specs fail (seems somewhat random and odd in what may fail). I believe that if I clean the database between each, that things work. I did not previously have to do that with story runner. But, also, what I'm finding is that I can't seem to run rake db:reset twice in the same rake task (due to Rake's usual not allowing that), so this makes setting up a rake task for CruiseControl.rb hard, as it won't reset the DB a second time. I could probably just run it as a shell command, but that seems like a terrible hack. I'm running into this both on MacOS X, and on my CI server which is Ubuntu 8.04 running CruiseControl.rb (from git:// github.com/benburkert/cruisecontrolrb.git). Has anyone else seen this kind of thing, any ideas? My versions: ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0] rails (2.2.2) rspec (1.1.11) rspec-rails (1.1.11) aslakhellesoy-cucumber (0.1.99.19) nokogiri (1.1.1) webrat (0.4.1) -- Christopher Bailey Cobalt Edge LLC http://cobaltedge.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Wed Feb 4 13:49:02 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Wed, 4 Feb 2009 19:49:02 +0100 Subject: [rspec-users] Can cucumber/webrat set a value on a hidden field Message-ID: I am using auto_complete to provide a list of persons from which the user can select one. On selection from the auto_complete list, a hidden field is updated with the id of the selected person. This is all wrapped in a form, that then can be submitted by the user (by clicking the provided submit button). On submission, the person (based on the id in the hidden field) is added to a group. I assume I can?t use the auto_complete ajax calls from within Cucumber. But I wondered if I could make a step that would update the value of the hidden field (as if I had selected the user from the auto_complete field). According to this documentation (http://gitrdoc.com/brynary/webrat/tree/master/classes/Webrat/Scope.html) there should be a set_hidden_field method. But the method no longer appears to be in the webrat/core/scope.rb file Based on the above documentation the method should be # File lib/webrat/core/scope.rb, line 53 def set_hidden_field(field_locator, options = {}) field = locate_field(field_locator, HiddenField) field.set(options[:to]) end but adding this into the scope.rb file, still gives me undefined method `set_hidden_field' for # (NoMethodError) when I try to call it in a step. Any help would be greatly appreciated. Tom -- Posted via http://www.ruby-forum.com/. From cwdinfo at gmail.com Wed Feb 4 14:27:37 2009 From: cwdinfo at gmail.com (s.ross) Date: Wed, 4 Feb 2009 11:27:37 -0800 Subject: [rspec-users] have_tag with a block In-Reply-To: References: <73f9ae8d-a26d-4f8c-aff6-1d9222779024@r34g2000vbp.googlegroups.com> <57c63afe0902031801q299858cfo788ae9730170e4b0@mail.gmail.com> Message-ID: <05C74F47-085C-47C6-ADE4-A12D448FEAF5@gmail.com> Hi-- On Feb 3, 2009, at 9:44 PM, MarkMT wrote: > Thanks David. Those specs are very instructive. I have no idea what I > was doing wrong before, but the behavior I'm seeing now is indeed > consistent with the specs and matches what I had understood from the > code I'd looked at (I suspect it'll stop working as soon as I send > this :-) ). > > Actually my situation is slightly more complex than what the specs > cover. I have something like this - > > > > and I'm testing it with a cucumber step that looks like this - > > Then /^the response should contain a link to new user registration$/ > do > @response.should have_tag('div', :id =>'registration_link', :content > => 'New User? Register ') { |match| > match.should have_tag('a', :href => '/User/register', :content => > 'here') > } > end > > One of the things I was unsure about was whether I could mix both the > text content and the second tag inside the outer element. Turns out > that this works just fine with the test above. Also, have_tag > ('div#registration_link'...) works just as well as have_tag('div', :id > => 'registration_link'...) > I'm writing a similar kind of scenario and want to make sure I am scoping my "assertion" (if you will) to the stuff inside the tag. The idea is that all people to whom this page is addressed are on the address line (but not necessarily the only thing on the address line. So the first guess was:
joe, bob
recipients.split(/,\s*/).each do |recipient| response.should have_tag('div[address-line]', recipient) end This doesn't work. Change the expectation to: response.should have_tag('div[address-line]', Regexp.new(recipient)) and, predictably, it works. But is that scoped to include only text that matches the regexp within the div[address-line]? The code I really wanted to write (phrase stolen from the RSpec Book) was: recipients.split(/,\s*/).each do |recipient| response.should have_tag('div[address-line]') do |r| r.should include(recipient) end end But that gives me a failed expectation showing a gruesomely complicated representation of the page DOM and comparing it to 'joe'. Question: Is there an accepted way to scope text substrings to within tags? Thanks From aslak.hellesoy at gmail.com Wed Feb 4 15:54:30 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 4 Feb 2009 21:54:30 +0100 Subject: [rspec-users] Cucumber/Webrat fails to find fields when run after specs In-Reply-To: <443c240c0902041021y17c276ddq534b8e25d278d335@mail.gmail.com> References: <443c240c0902041021y17c276ddq534b8e25d278d335@mail.gmail.com> Message-ID: <8d961d900902041254q51248e24s5f86f0e5eba4a8be@mail.gmail.com> On Wed, Feb 4, 2009 at 7:21 PM, Christopher Bailey wrote: > I've been battling the strangest behavior, and hoping someone can shed some > light... > I am using RSpec for MVC tests, and then Cucumber for stories/features. I > am new to Cucumber, and recently finished converting our RSpec Story Runner > suite to it. What I'm seeing is that if I clean the database (e.g. rake > db:reset), then run all my specs, then run the features, Webrat fails to > find various fields on form pages. If I run them in the reverse order, with Use puts response.body in the failing step definitions to see the html > features first, then specs, often times various specs fail (seems somewhat > random and odd in what may fail). Sounds like you have residual data in your test database. Do you have transactions turned on for both rspec and cucumber? Do your features rely on specific data being in the database before the run? How do you get it in there? Aslak > I believe that if I clean the database between each, that things work. I > did not previously have to do that with story runner. But, also, what I'm > finding is that I can't seem to run rake db:reset twice in the same rake > task (due to Rake's usual not allowing that), so this makes setting up a > rake task for CruiseControl.rb hard, as it won't reset the DB a second time. > I could probably just run it as a shell command, but that seems like a > terrible hack. > I'm running into this both on MacOS X, and on my CI server which is Ubuntu > 8.04 running CruiseControl.rb > (from git://github.com/benburkert/cruisecontrolrb.git). Has anyone else > seen this kind of thing, any ideas? My versions: > ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0] > rails (2.2.2) > rspec (1.1.11) > rspec-rails (1.1.11) > aslakhellesoy-cucumber (0.1.99.19) > nokogiri (1.1.1) > webrat (0.4.1) > -- > Christopher Bailey > Cobalt Edge LLC > http://cobaltedge.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From mailing_lists at bengreenberg.net Mon Feb 2 13:55:21 2009 From: mailing_lists at bengreenberg.net (Ben Greenberg) Date: Mon, 02 Feb 2009 13:55:21 -0500 Subject: [rspec-users] Trouble validating an exception In-Reply-To: <1ebf5a4d0902021000x8557018p8b7e586653f078be@mail.gmail.com> References: <1ebf5a4d0902021000x8557018p8b7e586653f078be@mail.gmail.com> Message-ID: <49874199.3010206@bengreenberg.net> Hi all, This spec always passes: lambda do process_card @credit_card, billing_info, 10604, '1.1.1.1', @gateway end.should raise_error(MinimalCart::CaptureFailureError) do |ex| ex.should be_nil ex.should_not be_nil ex.responses.should be_nil ex.responses.should_include @auth_response ex.responses.include?.with('a').should be_true end Clearly, it makes no sense. Somehow the exception validation block is not running. What am I doing wrong? Thanks Ben From chris at cobaltedge.com Wed Feb 4 19:43:16 2009 From: chris at cobaltedge.com (Christopher Bailey) Date: Wed, 4 Feb 2009 16:43:16 -0800 Subject: [rspec-users] Cucumber/Webrat fails to find fields when run after specs In-Reply-To: <8d961d900902041254q51248e24s5f86f0e5eba4a8be@mail.gmail.com> References: <443c240c0902041021y17c276ddq534b8e25d278d335@mail.gmail.com> <8d961d900902041254q51248e24s5f86f0e5eba4a8be@mail.gmail.com> Message-ID: <443c240c0902041643n3486d544o406e3ee566016f2e@mail.gmail.com> On Wed, Feb 4, 2009 at 12:54 PM, aslak hellesoy wrote: > On Wed, Feb 4, 2009 at 7:21 PM, Christopher Bailey > wrote: > > I've been battling the strangest behavior, and hoping someone can shed > some > > light... > > I am using RSpec for MVC tests, and then Cucumber for stories/features. > I > > am new to Cucumber, and recently finished converting our RSpec Story > Runner > > suite to it. What I'm seeing is that if I clean the database (e.g. rake > > db:reset), then run all my specs, then run the features, Webrat fails to > > find various fields on form pages. If I run them in the reverse order, > with > > Use puts response.body in the failing step definitions to see the html > I'll do that (can't at the moment, but will next go-around). > > > features first, then specs, often times various specs fail (seems > somewhat > > random and odd in what may fail). > > Sounds like you have residual data in your test database. Do you have > transactions turned on for both rspec and cucumber? > Do your features rely on specific data being in the database before > the run? How do you get it in there? > I start with a clean DB, then run the specs. At the end, data is left in there. I am running transactional RSpec specs as far as I know, although maybe there's something explicit I need to do? I thought they were on by default. I've noticed that data gets leftover between tests a lot. I see that I have transactional fixtures enabled (I don't use any fixtures though - all my data is created by my own factory methods/generators which are either run in before methods or in the actual spec case). I have Cucumber transactional turned on via this line in env.rb: Cucumber::Rails.use_transactional_fixtures No features rely on any pre-existing data. > > Aslak > > > I believe that if I clean the database between each, that things work. I > > did not previously have to do that with story runner. But, also, what > I'm > > finding is that I can't seem to run rake db:reset twice in the same rake > > task (due to Rake's usual not allowing that), so this makes setting up a > > rake task for CruiseControl.rb hard, as it won't reset the DB a second > time. > > I could probably just run it as a shell command, but that seems like a > > terrible hack. > > I'm running into this both on MacOS X, and on my CI server which is > Ubuntu > > 8.04 running CruiseControl.rb > > (from git://github.com/benburkert/cruisecontrolrb.git). Has anyone else > > seen this kind of thing, any ideas? My versions: > > ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0] > > rails (2.2.2) > > rspec (1.1.11) > > rspec-rails (1.1.11) > > aslakhellesoy-cucumber (0.1.99.19) > > nokogiri (1.1.1) > > webrat (0.4.1) > > -- > > Christopher Bailey > > Cobalt Edge LLC > > http://cobaltedge.com > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > Aslak (::) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Christopher Bailey Cobalt Edge LLC http://cobaltedge.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From brad.forsyth at inspire2go.com Wed Feb 4 20:42:12 2009 From: brad.forsyth at inspire2go.com (Brad) Date: Wed, 4 Feb 2009 17:42:12 -0800 (PST) Subject: [rspec-users] MyModel.stub!l works in 1.1.11 but fails in 1.1.12 Message-ID: <696a1064-9291-4b8f-94e1-495545c1e9ac@33g2000yqm.googlegroups.com> I have a controller spec that works find with Rails 2.2.2 and Rspec- Rails 1.1.11. The code is: @activity=mock_model(Activity, :id => 7) Activity.stub!(:get).with("7").and_return(@activity When I update to 1.1.12 ArgumentError in 'ActivitiesController' wrong number of arguments (2 for 1) For some reason the file rspec-1.1.12/lib/spec/mocks/proxy.rb at line 149 149 return @target.respond_to?(sym, true) is attempting to send two arguments. Rspec 1.1.11 did not have the second argument ('true'). What is going on here? Any help appreciated. Brad From dchelimsky at gmail.com Wed Feb 4 22:22:11 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Feb 2009 21:22:11 -0600 Subject: [rspec-users] MyModel.stub!l works in 1.1.11 but fails in 1.1.12 In-Reply-To: <696a1064-9291-4b8f-94e1-495545c1e9ac@33g2000yqm.googlegroups.com> References: <696a1064-9291-4b8f-94e1-495545c1e9ac@33g2000yqm.googlegroups.com> Message-ID: <57c63afe0902041922x56a9d4a3ge3f2c15d63961b45@mail.gmail.com> On Wed, Feb 4, 2009 at 7:42 PM, Brad wrote: > I have a controller spec that works find with Rails 2.2.2 and Rspec- > Rails 1.1.11. The code is: > > @activity=mock_model(Activity, :id => 7) > Activity.stub!(:get).with("7").and_return(@activity > > When I update to 1.1.12 > > ArgumentError in 'ActivitiesController' wrong number of arguments (2 > for 1) > > For some reason the file > rspec-1.1.12/lib/spec/mocks/proxy.rb at line 149 > 149 return @target.respond_to?(sym, true) > > is attempting to send two arguments. Rspec 1.1.11 did not have the > second argument ('true'). What is going on here? http://www.ruby-doc.org/core/classes/Object.html#M000333 The optional second argument determines whether to include private methods or not. We added it to resolve a bug: http://rspec.lighthouseapp.com/projects/5645/tickets/450 Is the code in question overriding respond_to? ? > > Any help appreciated. > > Brad > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Feb 5 00:05:47 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Feb 2009 23:05:47 -0600 Subject: [rspec-users] [OT] Jay Fields' blog on developer testing Message-ID: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> I highly recommend this blog post by Jay Fields: http://blog.jayfields.com/2009/02/thoughts-on-developer-testing.html Cheers, David From mr.gaffo at gmail.com Thu Feb 5 00:47:18 2009 From: mr.gaffo at gmail.com (Mike Gaffney) Date: Wed, 04 Feb 2009 23:47:18 -0600 Subject: [rspec-users] Cucumber/Webrat fails to find fields when run after specs In-Reply-To: <443c240c0902041643n3486d544o406e3ee566016f2e@mail.gmail.com> References: <443c240c0902041021y17c276ddq534b8e25d278d335@mail.gmail.com> <8d961d900902041254q51248e24s5f86f0e5eba4a8be@mail.gmail.com> <443c240c0902041643n3486d544o406e3ee566016f2e@mail.gmail.com> Message-ID: <498A7D66.3020203@gmail.com> Are you running selenium or normal webrat (eg config.mode = :rails or config.mode = :selenium)? Christopher Bailey wrote: > On Wed, Feb 4, 2009 at 12:54 PM, aslak hellesoy > > wrote: > > On Wed, Feb 4, 2009 at 7:21 PM, Christopher Bailey > > wrote: > > I've been battling the strangest behavior, and hoping someone > can shed some > > light... > > I am using RSpec for MVC tests, and then Cucumber for > stories/features. I > > am new to Cucumber, and recently finished converting our RSpec > Story Runner > > suite to it. What I'm seeing is that if I clean the database > (e.g. rake > > db:reset), then run all my specs, then run the features, Webrat > fails to > > find various fields on form pages. If I run them in the reverse > order, with > > Use puts response.body in the failing step definitions to see the html > > > I'll do that (can't at the moment, but will next go-around). > > > > > features first, then specs, often times various specs fail > (seems somewhat > > random and odd in what may fail). > > Sounds like you have residual data in your test database. Do you have > transactions turned on for both rspec and cucumber? > Do your features rely on specific data being in the database before > the run? How do you get it in there? > > > I start with a clean DB, then run the specs. At the end, data is left > in there. I am running transactional RSpec specs as far as I know, > although maybe there's something explicit I need to do? I thought > they were on by default. I've noticed that data gets leftover between > tests a lot. I see that I have transactional fixtures enabled (I > don't use any fixtures though - all my data is created by my own > factory methods/generators which are either run in before methods or > in the actual spec case). I have Cucumber transactional turned on via > this line in env.rb: > > Cucumber::Rails.use_transactional_fixtures > > No features rely on any pre-existing data. > > > > Aslak > > > I believe that if I clean the database between each, that things > work. I > > did not previously have to do that with story runner. But, > also, what I'm > > finding is that I can't seem to run rake db:reset twice in the > same rake > > task (due to Rake's usual not allowing that), so this makes > setting up a > > rake task for CruiseControl.rb hard, as it won't reset the DB a > second time. > > I could probably just run it as a shell command, but that seems > like a > > terrible hack. > > I'm running into this both on MacOS X, and on my CI server which > is Ubuntu > > 8.04 running CruiseControl.rb > > (from git://github.com/benburkert/cruisecontrolrb.git > ). Has anyone else > > seen this kind of thing, any ideas? My versions: > > ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0] > > rails (2.2.2) > > rspec (1.1.11) > > rspec-rails (1.1.11) > > aslakhellesoy-cucumber (0.1.99.19) > > nokogiri (1.1.1) > > webrat (0.4.1) > > -- > > Christopher Bailey > > Cobalt Edge LLC > > http://cobaltedge.com > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > Aslak (::) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > -- > Christopher Bailey > Cobalt Edge LLC > http://cobaltedge.com > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From chris at cobaltedge.com Thu Feb 5 02:08:14 2009 From: chris at cobaltedge.com (Christopher Bailey) Date: Wed, 4 Feb 2009 23:08:14 -0800 Subject: [rspec-users] Cucumber/Webrat fails to find fields when run after specs In-Reply-To: <498A7D66.3020203@gmail.com> References: <443c240c0902041021y17c276ddq534b8e25d278d335@mail.gmail.com> <8d961d900902041254q51248e24s5f86f0e5eba4a8be@mail.gmail.com> <443c240c0902041643n3486d544o406e3ee566016f2e@mail.gmail.com> <498A7D66.3020203@gmail.com> Message-ID: <443c240c0902042308i41db06banab9269f4367fd19b@mail.gmail.com> Just normal Webrat, no Selenium, it's not installed, etc. I've now got things working, although I honestly have no idea what changed that makes it consistently run now. I did update to rspec and rspec-rails 1.1.12, but it still failed for a while after that. My primary residual concern is that the DB isn't clean after the specs run, which means it's not clean for the features/Cucumber run. I can't seem to get db:reset rake task to run again because rake has already run it (and calling reenable on it doesn't seem to change that). I've tried a few alternatives to calling that task specifically, but I think rake has seen them all as dependencies or what not already. On Wed, Feb 4, 2009 at 9:47 PM, Mike Gaffney wrote: > Are you running selenium or normal webrat (eg config.mode = :rails or > config.mode = :selenium)? > > > Christopher Bailey wrote: > >> On Wed, Feb 4, 2009 at 12:54 PM, aslak hellesoy > aslak.hellesoy at gmail.com>> wrote: >> >> On Wed, Feb 4, 2009 at 7:21 PM, Christopher Bailey >> > wrote: >> > I've been battling the strangest behavior, and hoping someone >> can shed some >> > light... >> > I am using RSpec for MVC tests, and then Cucumber for >> stories/features. I >> > am new to Cucumber, and recently finished converting our RSpec >> Story Runner >> > suite to it. What I'm seeing is that if I clean the database >> (e.g. rake >> > db:reset), then run all my specs, then run the features, Webrat >> fails to >> > find various fields on form pages. If I run them in the reverse >> order, with >> >> Use puts response.body in the failing step definitions to see the html >> >> >> I'll do that (can't at the moment, but will next go-around). >> >> >> > features first, then specs, often times various specs fail >> (seems somewhat >> > random and odd in what may fail). >> >> Sounds like you have residual data in your test database. Do you have >> transactions turned on for both rspec and cucumber? >> Do your features rely on specific data being in the database before >> the run? How do you get it in there? >> >> >> I start with a clean DB, then run the specs. At the end, data is left in >> there. I am running transactional RSpec specs as far as I know, although >> maybe there's something explicit I need to do? I thought they were on by >> default. I've noticed that data gets leftover between tests a lot. I see >> that I have transactional fixtures enabled (I don't use any fixtures though >> - all my data is created by my own factory methods/generators which are >> either run in before methods or in the actual spec case). I have Cucumber >> transactional turned on via this line in env.rb: >> >> Cucumber::Rails.use_transactional_fixtures >> >> No features rely on any pre-existing data. >> >> >> Aslak >> >> > I believe that if I clean the database between each, that things >> work. I >> > did not previously have to do that with story runner. But, >> also, what I'm >> > finding is that I can't seem to run rake db:reset twice in the >> same rake >> > task (due to Rake's usual not allowing that), so this makes >> setting up a >> > rake task for CruiseControl.rb hard, as it won't reset the DB a >> second time. >> > I could probably just run it as a shell command, but that seems >> like a >> > terrible hack. >> > I'm running into this both on MacOS X, and on my CI server which >> is Ubuntu >> > 8.04 running CruiseControl.rb >> > (from git://github.com/benburkert/cruisecontrolrb.git >> ). Has anyone else >> > seen this kind of thing, any ideas? My versions: >> > ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0] >> > rails (2.2.2) >> > rspec (1.1.11) >> > rspec-rails (1.1.11) >> > aslakhellesoy-cucumber (0.1.99.19) >> > nokogiri (1.1.1) >> > webrat (0.4.1) >> > -- >> > Christopher Bailey >> > Cobalt Edge LLC >> > http://cobaltedge.com >> > >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> >> >> >> -- >> Aslak (::) >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> >> >> -- >> Christopher Bailey >> Cobalt Edge LLC >> http://cobaltedge.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 > -- Christopher Bailey Cobalt Edge LLC http://cobaltedge.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at mwilden.com Thu Feb 5 02:32:52 2009 From: mark at mwilden.com (Mark Wilden) Date: Wed, 4 Feb 2009 23:32:52 -0800 Subject: [rspec-users] Cucumber/Webrat fails to find fields when run after specs In-Reply-To: <443c240c0902042308i41db06banab9269f4367fd19b@mail.gmail.com> References: <443c240c0902041021y17c276ddq534b8e25d278d335@mail.gmail.com> <8d961d900902041254q51248e24s5f86f0e5eba4a8be@mail.gmail.com> <443c240c0902041643n3486d544o406e3ee566016f2e@mail.gmail.com> <498A7D66.3020203@gmail.com> <443c240c0902042308i41db06banab9269f4367fd19b@mail.gmail.com> Message-ID: <3c30da400902042332q7151124bxe57ec8e3c1d8df26@mail.gmail.com> On Wed, Feb 4, 2009 at 11:08 PM, Christopher Bailey wrote: > > My primary residual concern is that the DB isn't clean after the specs run, > which means it's not clean for the features/Cucumber run. > Fixtures? ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Thu Feb 5 02:48:25 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 5 Feb 2009 07:48:25 +0000 Subject: [rspec-users] [Rspec] How do you nest before(:all) or after(:all) blocks? In-Reply-To: References: <3aac08fd-5a32-4549-87bd-8a3b888f959c@h20g2000yqn.googlegroups.com> <4989B481.8030806@railsnewbie.com> Message-ID: <63C63C59-2895-45AE-BCBB-E78481FFF0A2@mattwynne.net> On 4 Feb 2009, at 17:55, John Kolokotronis wrote: >> Why do you want before(:all)? Generally it's use is disregarded, >> just >> as global variables are considered harmful, not because they can't be >> used well, but because 99% of the times they aren't. > > Because I want to be able to create a single @browser object at the > beginning > of my tests and have it passed to all examples. Without nested > examples, that Have you considered using Cucumber rather than RSpec as the driver to run these tests? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From chris at cobaltedge.com Thu Feb 5 03:23:40 2009 From: chris at cobaltedge.com (Christopher Bailey) Date: Thu, 5 Feb 2009 00:23:40 -0800 Subject: [rspec-users] Cucumber/Webrat fails to find fields when run after specs In-Reply-To: <3c30da400902042332q7151124bxe57ec8e3c1d8df26@mail.gmail.com> References: <443c240c0902041021y17c276ddq534b8e25d278d335@mail.gmail.com> <8d961d900902041254q51248e24s5f86f0e5eba4a8be@mail.gmail.com> <443c240c0902041643n3486d544o406e3ee566016f2e@mail.gmail.com> <498A7D66.3020203@gmail.com> <443c240c0902042308i41db06banab9269f4367fd19b@mail.gmail.com> <3c30da400902042332q7151124bxe57ec8e3c1d8df26@mail.gmail.com> Message-ID: <443c240c0902050023t2d64fc2w6e429c9806717ab9@mail.gmail.com> I don't use fixtures or have any anywhere. On Wed, Feb 4, 2009 at 11:32 PM, Mark Wilden wrote: > On Wed, Feb 4, 2009 at 11:08 PM, Christopher Bailey wrote: > >> >> My primary residual concern is that the DB isn't clean after the specs >> run, which means it's not clean for the features/Cucumber run. >> > > Fixtures? > > ///ark > > _______________________________________________ > 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 johnjkle at gmail.com Thu Feb 5 04:10:54 2009 From: johnjkle at gmail.com (John Kolokotronis) Date: Thu, 5 Feb 2009 01:10:54 -0800 (PST) Subject: [rspec-users] [Rspec] How do you nest before(:all) or after(:all) blocks? In-Reply-To: <63C63C59-2895-45AE-BCBB-E78481FFF0A2@mattwynne.net> References: <3aac08fd-5a32-4549-87bd-8a3b888f959c@h20g2000yqn.googlegroups.com> <4989B481.8030806@railsnewbie.com> <63C63C59-2895-45AE-BCBB-E78481FFF0A2@mattwynne.net> Message-ID: <8526b46a-f268-466b-97ee-210a4fcb1436@n10g2000yqm.googlegroups.com> > Have you considered using Cucumber rather than RSpec as the driver to ? > run these tests? TBH, I haven't really looked at Cucumber much, as I'm just getting started with Rspec itself. My impression though was that Cucumber replaced the story runner and the way my tests are structured just seems better suited to Rspec, rather than written as user stories... From aslak.hellesoy at gmail.com Thu Feb 5 04:23:57 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 5 Feb 2009 10:23:57 +0100 Subject: [rspec-users] Cucumber/Webrat fails to find fields when run after specs In-Reply-To: <443c240c0902041643n3486d544o406e3ee566016f2e@mail.gmail.com> References: <443c240c0902041021y17c276ddq534b8e25d278d335@mail.gmail.com> <8d961d900902041254q51248e24s5f86f0e5eba4a8be@mail.gmail.com> <443c240c0902041643n3486d544o406e3ee566016f2e@mail.gmail.com> Message-ID: <8d961d900902050123o19857b1y12db5e38e79ba337@mail.gmail.com> On Thu, Feb 5, 2009 at 1:43 AM, Christopher Bailey wrote: > On Wed, Feb 4, 2009 at 12:54 PM, aslak hellesoy > wrote: >> >> On Wed, Feb 4, 2009 at 7:21 PM, Christopher Bailey >> wrote: >> > I've been battling the strangest behavior, and hoping someone can shed >> > some >> > light... >> > I am using RSpec for MVC tests, and then Cucumber for stories/features. >> > I >> > am new to Cucumber, and recently finished converting our RSpec Story >> > Runner >> > suite to it. What I'm seeing is that if I clean the database (e.g. rake >> > db:reset), then run all my specs, then run the features, Webrat fails to >> > find various fields on form pages. If I run them in the reverse order, >> > with >> >> Use puts response.body in the failing step definitions to see the html > > I'll do that (can't at the moment, but will next go-around). > >> >> > features first, then specs, often times various specs fail (seems >> > somewhat >> > random and odd in what may fail). >> >> Sounds like you have residual data in your test database. Do you have >> transactions turned on for both rspec and cucumber? >> Do your features rely on specific data being in the database before >> the run? How do you get it in there? > > I start with a clean DB, then run the specs. At the end, data is left in That's probably the source of your problem. Either fix it so that data in DB after specs == data before. Or if you can't do that - clear the db before running cucumber. You can invoke a Rake task explicitly with something like Task['taskname'].invoke Aslak > there. I am running transactional RSpec specs as far as I know, although > maybe there's something explicit I need to do? I thought they were on by > default. I've noticed that data gets leftover between tests a lot. I see > that I have transactional fixtures enabled (I don't use any fixtures though > - all my data is created by my own factory methods/generators which are > either run in before methods or in the actual spec case). I have Cucumber > transactional turned on via this line in env.rb: > Cucumber::Rails.use_transactional_fixtures > No features rely on any pre-existing data. > >> >> Aslak >> >> > I believe that if I clean the database between each, that things work. >> > I >> > did not previously have to do that with story runner. But, also, what >> > I'm >> > finding is that I can't seem to run rake db:reset twice in the same rake >> > task (due to Rake's usual not allowing that), so this makes setting up a >> > rake task for CruiseControl.rb hard, as it won't reset the DB a second >> > time. >> > I could probably just run it as a shell command, but that seems like a >> > terrible hack. >> > I'm running into this both on MacOS X, and on my CI server which is >> > Ubuntu >> > 8.04 running CruiseControl.rb >> > (from git://github.com/benburkert/cruisecontrolrb.git). Has anyone else >> > seen this kind of thing, any ideas? My versions: >> > ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0] >> > rails (2.2.2) >> > rspec (1.1.11) >> > rspec-rails (1.1.11) >> > aslakhellesoy-cucumber (0.1.99.19) >> > nokogiri (1.1.1) >> > webrat (0.4.1) >> > -- >> > Christopher Bailey >> > Cobalt Edge LLC >> > http://cobaltedge.com >> > >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> >> >> >> -- >> Aslak (::) >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > -- > Christopher Bailey > Cobalt Edge LLC > http://cobaltedge.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From matt at mattwynne.net Thu Feb 5 04:38:54 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 5 Feb 2009 09:38:54 +0000 Subject: [rspec-users] [Cucumber, Webrat] Error backtraces shown as HTML in console Message-ID: Since upgrading to Cucumber 0.1.99.19 I've noticed that the backtraces appearing in the console output are of the form: Page load was not successful (Code: 500): Followed by the dump of the rails error page. That page looks fine in a browser, and it's helpful enough to see it when save_and_open_page does its thing, but I'm pretty used to reading plain old stacktraces in the console - the HTML output is very hard to read. Is this a known issue, or a feature, or have I just got something configured wrong? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From chris at cobaltedge.com Thu Feb 5 05:33:07 2009 From: chris at cobaltedge.com (Christopher Bailey) Date: Thu, 5 Feb 2009 02:33:07 -0800 Subject: [rspec-users] Cucumber/Webrat fails to find fields when run after specs In-Reply-To: <8d961d900902050123o19857b1y12db5e38e79ba337@mail.gmail.com> References: <443c240c0902041021y17c276ddq534b8e25d278d335@mail.gmail.com> <8d961d900902041254q51248e24s5f86f0e5eba4a8be@mail.gmail.com> <443c240c0902041643n3486d544o406e3ee566016f2e@mail.gmail.com> <8d961d900902050123o19857b1y12db5e38e79ba337@mail.gmail.com> Message-ID: <443c240c0902050233j6d84fa26n3fe7b3b410aece3e@mail.gmail.com> Data before is nothing. I'm not sure why there's data after. I would clear the data before running Cucumber, but after running specs by doing a "rake db:reset" or similar, but it has no effect, because that's the same task that started off the whole thing. I'm running this under CruiseControl and so you set up a cruise task, which looks like: task :cruise do RAILS_ENV = ENV['RAILS_ENV'] = 'test' CruiseControl::invoke_rake_task 'db:reset' CruiseControl::invoke_rake_task 'cruise_coverage' CruiseControl::invoke_rake_task 'db:reset' # This one has no effect CruiseControl::invoke_rake_task 'features' CruiseControl::invoke_rake_task 'ci_tag' end I've marked it as you can see, where that second db:reset has no effect (because Rake thinks it has already run it (which it has) above). I've tried doing things like making the "features" rake task itself depend on db:reset, or depend on a custom task that does a db:reset, etc., but while you see CruiseControl spit out that it's supposed to do that task, the task never gets run. This is the same behavior if you do it simply with something like: task :twotest do Rake::Task['db:reset'].invoke puts "do it again..." Rake::Task['db:reset'].reenable # this doesn't appear to work Rake::Task['db:reset'].invoke end That will only run it once. I can resort to doing a shell command, but what a hack, seems like there has to be better way. On Thu, Feb 5, 2009 at 1:23 AM, aslak hellesoy wrote: > On Thu, Feb 5, 2009 at 1:43 AM, Christopher Bailey > wrote: > > On Wed, Feb 4, 2009 at 12:54 PM, aslak hellesoy < > aslak.hellesoy at gmail.com> > > wrote: > >> > >> On Wed, Feb 4, 2009 at 7:21 PM, Christopher Bailey < > chris at cobaltedge.com> > >> wrote: > >> > I've been battling the strangest behavior, and hoping someone can shed > >> > some > >> > light... > >> > I am using RSpec for MVC tests, and then Cucumber for > stories/features. > >> > I > >> > am new to Cucumber, and recently finished converting our RSpec Story > >> > Runner > >> > suite to it. What I'm seeing is that if I clean the database (e.g. > rake > >> > db:reset), then run all my specs, then run the features, Webrat fails > to > >> > find various fields on form pages. If I run them in the reverse > order, > >> > with > >> > >> Use puts response.body in the failing step definitions to see the html > > > > I'll do that (can't at the moment, but will next go-around). > > > >> > >> > features first, then specs, often times various specs fail (seems > >> > somewhat > >> > random and odd in what may fail). > >> > >> Sounds like you have residual data in your test database. Do you have > >> transactions turned on for both rspec and cucumber? > >> Do your features rely on specific data being in the database before > >> the run? How do you get it in there? > > > > I start with a clean DB, then run the specs. At the end, data is left in > > That's probably the source of your problem. Either fix it so that data > in DB after specs == data before. Or if you can't do that - clear the > db before running cucumber. > You can invoke a Rake task explicitly with something like > Task['taskname'].invoke > > Aslak > > > there. I am running transactional RSpec specs as far as I know, although > > maybe there's something explicit I need to do? I thought they were on by > > default. I've noticed that data gets leftover between tests a lot. I > see > > that I have transactional fixtures enabled (I don't use any fixtures > though > > - all my data is created by my own factory methods/generators which are > > either run in before methods or in the actual spec case). I have > Cucumber > > transactional turned on via this line in env.rb: > > Cucumber::Rails.use_transactional_fixtures > > No features rely on any pre-existing data. > > > >> > >> Aslak > >> > >> > I believe that if I clean the database between each, that things work. > >> > I > >> > did not previously have to do that with story runner. But, also, what > >> > I'm > >> > finding is that I can't seem to run rake db:reset twice in the same > rake > >> > task (due to Rake's usual not allowing that), so this makes setting up > a > >> > rake task for CruiseControl.rb hard, as it won't reset the DB a second > >> > time. > >> > I could probably just run it as a shell command, but that seems like > a > >> > terrible hack. > >> > I'm running into this both on MacOS X, and on my CI server which is > >> > Ubuntu > >> > 8.04 running CruiseControl.rb > >> > (from git://github.com/benburkert/cruisecontrolrb.git). Has anyone > else > >> > seen this kind of thing, any ideas? My versions: > >> > ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0] > >> > rails (2.2.2) > >> > rspec (1.1.11) > >> > rspec-rails (1.1.11) > >> > aslakhellesoy-cucumber (0.1.99.19) > >> > nokogiri (1.1.1) > >> > webrat (0.4.1) > >> > -- > >> > Christopher Bailey > >> > Cobalt Edge LLC > >> > http://cobaltedge.com > >> > > >> > _______________________________________________ > >> > rspec-users mailing list > >> > rspec-users at rubyforge.org > >> > http://rubyforge.org/mailman/listinfo/rspec-users > >> > > >> > >> > >> > >> -- > >> Aslak (::) > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > -- > > Christopher Bailey > > Cobalt Edge LLC > > http://cobaltedge.com > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > Aslak (::) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Christopher Bailey Cobalt Edge LLC http://cobaltedge.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Thu Feb 5 06:00:08 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 5 Feb 2009 12:00:08 +0100 Subject: [rspec-users] [Cucumber, Webrat] Error backtraces shown as HTML in console In-Reply-To: References: Message-ID: <8d961d900902050300q54a19aefnaca7e763fe12f6af@mail.gmail.com> On Thu, Feb 5, 2009 at 10:38 AM, Matt Wynne wrote: > Since upgrading to Cucumber 0.1.99.19 I've noticed that the backtraces > appearing in the console output are of the form: > > Page load was not successful (Code: 500): > > Followed by the dump of the rails error page. That page looks fine in a > browser, and it's helpful enough to see it when save_and_open_page does its > thing, but I'm pretty used to reading plain old stacktraces in the console - > the HTML output is very hard to read. > Rails' HTML error page or Cucumber's HTML formatter? (The latter is very rudimentary in 0.1.99). > Is this a known issue, or a feature, or have I just got something configured > wrong? > It's an unknown issue (bug). Try --backtrace. Please file a bug report. Aslak > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Thu Feb 5 07:35:13 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 5 Feb 2009 12:35:13 +0000 Subject: [rspec-users] [Cucumber, Webrat] Error backtraces shown as HTML in console In-Reply-To: <8d961d900902050300q54a19aefnaca7e763fe12f6af@mail.gmail.com> References: <8d961d900902050300q54a19aefnaca7e763fe12f6af@mail.gmail.com> Message-ID: <2C6FB417-AA52-4A94-8102-B8D611590CA9@mattwynne.net> On 5 Feb 2009, at 11:00, aslak hellesoy wrote: > On Thu, Feb 5, 2009 at 10:38 AM, Matt Wynne > wrote: >> Since upgrading to Cucumber 0.1.99.19 I've noticed that the >> backtraces >> appearing in the console output are of the form: >> >> Page load was not successful (Code: 500): >> >> Followed by the dump of the rails error page. That page looks fine >> in a >> browser, and it's helpful enough to see it when save_and_open_page >> does its >> thing, but I'm pretty used to reading plain old stacktraces in the >> console - >> the HTML output is very hard to read. >> > > Rails' HTML error page or Cucumber's HTML formatter? (The latter is > very rudimentary in 0.1.99). Rails' HTML error page. It comes up both in my browser (presumably save_and_open_page doing its thing) and the same HTML is dumped to the console. For example, this is coming out in the console:

Extracted source (around line #1):

1: <% if concert.any_media? %>
       2:   <% media_summary_images do |images| %>
       3:     <div id="media">
       4:       <h3>Photos from previous concerts</h3>
       

> > >> Is this a known issue, or a feature, or have I just got something >> configured >> wrong? >> > > It's an unknown issue (bug). Try --backtrace. Thanks for the suggestion. I tried that, it doesn't seem to make any difference. > Please file a bug report. OK, but I am really surprised nobody else is getting this - it feels more to me like I've got some configuration setting wrong, or a mismatch in Cucumber / Webrat versions - our setup has been doing a long while and doesn't always have the very bleedingest edge (I think we're still on webrat 4.0, for example) and there is sometimes crufty lying around that gets in the way. Can anyone else confirm that with latest Cucumber and Webrat they *don't* get this behaviour? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From matt at mattwynne.net Thu Feb 5 07:48:30 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 5 Feb 2009 12:48:30 +0000 Subject: [rspec-users] [OT] Jay Fields' blog on developer testing In-Reply-To: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> Message-ID: <825DD81D-4A90-4043-875E-13ED710FE06B@mattwynne.net> I like this line: > Today's testing patterns are like beta software. The patterns have > been tested internally, but are rarely proven in the wild. As such, > the patterns will sometimes work given the right context, and other > times they will shit the bed. So true, so hard to explain, so well put. On 5 Feb 2009, at 05:05, David Chelimsky wrote: > I highly recommend this blog post by Jay Fields: > http://blog.jayfields.com/2009/02/thoughts-on-developer-testing.html > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Matt Wynne http://blog.mattwynne.net http://www.songkick.com From brad.forsyth at inspire2go.com Thu Feb 5 08:07:41 2009 From: brad.forsyth at inspire2go.com (Brad) Date: Thu, 5 Feb 2009 05:07:41 -0800 (PST) Subject: [rspec-users] MyModel.stub!l works in 1.1.11 but fails in 1.1.12 In-Reply-To: <57c63afe0902041922x56a9d4a3ge3f2c15d63961b45@mail.gmail.com> References: <696a1064-9291-4b8f-94e1-495545c1e9ac@33g2000yqm.googlegroups.com> <57c63afe0902041922x56a9d4a3ge3f2c15d63961b45@mail.gmail.com> Message-ID: <23405bf1-b6e9-4c71-a0ab-3b15aa5501fb@q30g2000prq.googlegroups.com> On Feb 4, 10:22?pm, David Chelimsky wrote: > On Wed, Feb 4, 2009 at 7:42 PM, Brad wrote: > > I have a controller spec that works find with Rails 2.2.2 and Rspec- > > Rails 1.1.11. ?The code is: > > > ?@activity=mock_model(Activity, :id => 7) > > ?Activity.stub!(:get).with("7").and_return(@activity > > > When I update to 1.1.12 > > > ArgumentError in 'ActivitiesController' wrong number of arguments (2 > > for 1) > > > For some reason the file > > ?rspec-1.1.12/lib/spec/mocks/proxy.rb at line 149 > > 149 ? ? ? ?return @target.respond_to?(sym, true) > > > is attempting to send two arguments. Rspec 1.1.11 did not have the > > second argument ('true'). ?What is going on here? > > http://www.ruby-doc.org/core/classes/Object.html#M000333 > > The optional second argument determines whether to include private > methods or not. We added it to resolve a bug: > > http://rspec.lighthouseapp.com/projects/5645/tickets/450 > > Is the code in question overriding respond_to? ? > That is the problem! The Activities has a method_missing and responds_to? that falls back to super. Thank you very much for your prompt (and helpful) response, David. Not having my Spec's work drive me crazy : ) Brad > > > > Any help appreciated. > > > Brad > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From zuperinfinite at gmail.com Thu Feb 5 10:34:02 2009 From: zuperinfinite at gmail.com (Bart Zonneveld) Date: Thu, 5 Feb 2009 16:34:02 +0100 Subject: [rspec-users] Can cucumber/webrat set a value on a hidden field In-Reply-To: References: Message-ID: <0CACE49F-D663-4E0B-9BEE-E5C73D36C111@gmail.com> On 4-feb-2009, at 19:49, Tom Hoen wrote: > According to this documentation > (http://gitrdoc.com/brynary/webrat/tree/master/classes/Webrat/ > Scope.html) > there should be a set_hidden_field method. But the method no longer > appears to be in the webrat/core/scope.rb file Probably because it didn't appear *yet* into that file :). I got bitten by the fact that I was using the wrong version of webrat some days ago. Using version 0.4.1, I can succesfully set hidden field using set_hidden_field. hope this helps, bartz From cflipse at gmail.com Thu Feb 5 11:05:52 2009 From: cflipse at gmail.com (Chris Flipse) Date: Thu, 5 Feb 2009 11:05:52 -0500 Subject: [rspec-users] [rspec] [rails] Specing a form builder Message-ID: I'm trying to set up and run a new form builder under rails, which lives under the helpers directory, but isn't really a helper. (Not a module, so doesn't mix in well) Short of dropping down into a view spec, how do I set up to actually spec the form builder? describe RandomFormBuilder do attr_reader :builder before do @object = mock_model(Foo) @builder = RandomFormBuilder.new(:foo, @object, #template#, {}, nil) end describe "#text_field" do it "should have a label" do @builder.text_field(:foo).should have_tag("label", "Foo") end end end class RandomFormBuilder < ActionView::Helpers::FormBuilder def text_field(method, *args) label(method) super(method, *args) end end That's sort of what I've got at the moment. #template# supposed to be an object with access to all the normal helpers, I _think_. using helper in that location gives me a NoMethodError. using self in that location ends up with the helper trying to delegate methods to Spec::Rails::Example::RailsExampleGroup::Subclass .... has anybody figured out what hoops this needs? -- // anything worth taking seriously is worth making fun of // http://blog.devcaffeine.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Thu Feb 5 11:17:14 2009 From: ben at benmabey.com (Ben Mabey) Date: Thu, 05 Feb 2009 09:17:14 -0700 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> Message-ID: <498B110A.4020904@benmabey.com> David Chelimsky wrote: > I highly recommend this blog post by Jay Fields: > http://blog.jayfields.com/2009/02/thoughts-on-developer-testing.html > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Great post. Very down to earth and realistic. This post raised a question for me. Jay talks about how the pattern Object Mother gave way to Test Data Builders. I use Fixjour ("Word to your object mother")[1], and other similar projects in my apps to provide a set of sane default attributes for my models. You can then easily override those defaults by passing in a hash with the values that you need for the test. After reading Nat's post about Object Mother vs Test Data Builders[2] , I have come to the conclusion that the "Object Mother" libs that are popular in ruby land (i.e. Fixjour, Factory Girl) are really more in line with the Test Data Builder pattern. Does everyone agree with this conclusion or am I missing something? It may be that I just use it differently, but according to Nat's post Test Builders provide a sane set of defaults that you can then explicitly override like so: Invoice invoiceWithNoPostcode = new InvoiceBuilder() .withRecipient(new RecipientBuilder() .withAddress(new AddressBuilder() .withNoPostcode() .build()) .build()) .build(); Well.. this looks a lot like what I do in Ruby (but a lot more verbose): invoice_with_no_postcode = new_invoice(:recipient => new_recipient(:address => new_address(:postcode => nil))) Nat points out that problems with Object Mother arise when people start adding factory methods to deal with the edge cases, such as ObjectMother.new_invoice_with_no_postal_code. I totally agree that this would be a problem since such abstraction results in hard to follow tests (this is why I hate fixtures actually). From the projects I have worked on I haven't seen the Object Mother libs abused this way and they are used more like a Test Data Builder. The only difference I see is in implementation, meaning the ruby libs tend to group all the factory methods on one object or module just like Object Mother, while the pattern Nat describes uses a separate builder class for each object. I think this is really just details though and results from Ruby's differences from Java. Any thoughts? Are Ruby's Object Mothers really Test Data Builders? -Ben 1. http://github.com/nakajima/fixjour/tree/master 2. http://nat.truemesh.com/archives/000714.html From cflipse at gmail.com Thu Feb 5 11:24:22 2009 From: cflipse at gmail.com (Chris Flipse) Date: Thu, 5 Feb 2009 11:24:22 -0500 Subject: [rspec-users] [rspec] [rails] Specing a form builder In-Reply-To: References: Message-ID: got it. The normal FormBuilder class uses template as a pass through for the basic form fields. before do helper = Object.new.extend ActionView::Helpers::FormHelper @object = mock_model(Foo) @builder = RandomFormBuilder(:foo, @object, helper, {}, nil) end then all works beautifully. On Thu, Feb 5, 2009 at 11:05 AM, Chris Flipse wrote: > I'm trying to set up and run a new form builder under rails, which lives > under the helpers directory, but isn't really a helper. (Not a module, so > doesn't mix in well) > > Short of dropping down into a view spec, how do I set up to actually spec > the form builder? > > describe RandomFormBuilder do > attr_reader :builder > before do > @object = mock_model(Foo) > @builder = RandomFormBuilder.new(:foo, @object, #template#, {}, nil) > end > > describe "#text_field" do > it "should have a label" do > @builder.text_field(:foo).should have_tag("label", "Foo") > end > end > end > > class RandomFormBuilder < ActionView::Helpers::FormBuilder > def text_field(method, *args) > label(method) > super(method, *args) > end > end > > That's sort of what I've got at the moment. #template# supposed to be an > object with access to all the normal helpers, I _think_. > using helper in that location gives me a NoMethodError. > > using self in that location ends up with the helper trying to delegate > methods to Spec::Rails::Example::RailsExampleGroup::Subclass .... > > > has anybody figured out what hoops this needs? > > -- > // anything worth taking seriously is worth making fun of > // http://blog.devcaffeine.com/ > -- // anything worth taking seriously is worth making fun of // http://blog.devcaffeine.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Thu Feb 5 11:55:25 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 5 Feb 2009 10:55:25 -0600 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: <498B110A.4020904@benmabey.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <498B110A.4020904@benmabey.com> Message-ID: <57c63afe0902050855p6f8446ect6a12f4feb555cf88@mail.gmail.com> On Thu, Feb 5, 2009 at 10:17 AM, Ben Mabey wrote: > David Chelimsky wrote: >> >> I highly recommend this blog post by Jay Fields: >> http://blog.jayfields.com/2009/02/thoughts-on-developer-testing.html >> >> Cheers, >> David >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > Great post. Very down to earth and realistic. > > This post raised a question for me. Jay talks about how the pattern Object > Mother gave way to Test Data Builders. I use Fixjour ("Word to your object > mother")[1], and other similar projects in my apps to provide a set of sane > default attributes for my models. You can then easily override those > defaults by passing in a hash with the values that you need for the test. > After reading Nat's post about Object Mother vs Test Data Builders[2] , I > have come to the conclusion that the "Object Mother" libs that are popular > in ruby land (i.e. Fixjour, Factory Girl) are really more in line with the > Test Data Builder pattern. Does everyone agree with this conclusion or am I > missing something? It may be that I just use it differently, but according > to Nat's post Test Builders provide a sane set of defaults that you can then > explicitly override like so: > > Invoice invoiceWithNoPostcode = new InvoiceBuilder() > .withRecipient(new RecipientBuilder() > .withAddress(new AddressBuilder() > .withNoPostcode() > .build()) > .build()) > .build(); > > Well.. this looks a lot like what I do in Ruby (but a lot more verbose): > > invoice_with_no_postcode = new_invoice(:recipient => new_recipient(:address > => new_address(:postcode => nil))) > > Nat points out that problems with Object Mother arise when people start > adding factory methods to deal with the edge cases, such as > ObjectMother.new_invoice_with_no_postal_code. I totally agree that this > would be a problem since such abstraction results in hard to follow tests > (this is why I hate fixtures actually). From the projects I have worked on > I haven't seen the Object Mother libs abused this way and they are used more > like a Test Data Builder. The only difference I see is in implementation, > meaning the ruby libs tend to group all the factory methods on one object or > module just like Object Mother, while the pattern Nat describes uses a > separate builder class for each object. I think this is really just details > though and results from Ruby's differences from Java. > > Any thoughts? Are Ruby's Object Mothers really Test Data Builders? I'd say yes. We also have a naming conflict in terms of test categories. The definitions as I understand them are: * Unit tests test units - generally one object at a time, or perhaps more than one object that live within a single component, but never crossing the component/layer boundary. * Integration tests test integration - between two or more components. * Functional tests test functionality - of the application as a whole (more like cucumber scenarios) By these definitions: * what Rails calls unit tests are really integration tests (model and database layers) * what Rails calls functional tests are really bigger integration tests (controller + model + database) * what Rails calls integration tests are really functional tests (scenarios that take you through routing) Confused? Me too. Cheers, David > -Ben > > 1. http://github.com/nakajima/fixjour/tree/master > 2. http://nat.truemesh.com/archives/000714.html > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mark at mwilden.com Thu Feb 5 13:26:36 2009 From: mark at mwilden.com (Mark Wilden) Date: Thu, 5 Feb 2009 10:26:36 -0800 Subject: [rspec-users] [OT] Jay Fields' blog on developer testing In-Reply-To: <825DD81D-4A90-4043-875E-13ED710FE06B@mattwynne.net> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <825DD81D-4A90-4043-875E-13ED710FE06B@mattwynne.net> Message-ID: <3c30da400902051026q2dbaadc3v6371c33057c8c463@mail.gmail.com> On Thu, Feb 5, 2009 at 8:17 AM, Ben Mabey wrote: > David Chelimsky wrote: > >> I highly recommend this blog post by Jay Fields: >> http://blog.jayfields.com/2009/02/thoughts-on-developer-testing.html >> > It sounded to me like another of those "xxx is not a panacea" articles, and that "you shouldn't do anything blindly" and "if it doesn't work, you shouldn't do it." Point taken (and taken and taken). It was also indicative to me that Jay devotes just one word to TDD. Literally, one word! He focused exclusively on testing as a way to find bugs. That's not why I write tests. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Thu Feb 5 13:54:06 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 5 Feb 2009 18:54:06 +0000 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: <57c63afe0902050855p6f8446ect6a12f4feb555cf88@mail.gmail.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <498B110A.4020904@benmabey.com> <57c63afe0902050855p6f8446ect6a12f4feb555cf88@mail.gmail.com> Message-ID: <765FE7DD-D22A-4FD0-BB44-5449981EF979@mattwynne.net> On 5 Feb 2009, at 16:55, David Chelimsky wrote: >> > We also have a naming conflict in terms of test categories. The > definitions as I understand them are: > > * Unit tests test units - generally one object at a time, or perhaps > more than one object that live within a single component, but never > crossing the component/layer boundary. > * Integration tests test integration - between two or more components. > * Functional tests test functionality - of the application as a whole > (more like cucumber scenarios) > > By these definitions: > > * what Rails calls unit tests are really integration tests (model and > database layers) > * what Rails calls functional tests are really bigger integration > tests (controller + model + database) > * what Rails calls integration tests are really functional tests > (scenarios that take you through routing) > > Confused? Me too. And me. As much as Rails has done to promote automated testing, I feel like this confused and confusing language is a real setback. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From lists at ruby-forum.com Thu Feb 5 14:04:55 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Thu, 5 Feb 2009 20:04:55 +0100 Subject: [rspec-users] Can cucumber/webrat set a value on a hidden field In-Reply-To: <0CACE49F-D663-4E0B-9BEE-E5C73D36C111@gmail.com> References: <0CACE49F-D663-4E0B-9BEE-E5C73D36C111@gmail.com> Message-ID: Bart Zonneveld wrote: > Using version 0.4.1, I can succesfully set hidden field using > set_hidden_field. > Bart - Thanks for the heads up that 4.1 was released and contained the set_hidden_field method. I have updated my webrat plugin to 4.1, but unfortunately, sub-domain redirects seem to be broken again (which was fixed in zdennis' fork: git://github.com/zdennis/webrat.git -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Feb 5 14:13:44 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Thu, 5 Feb 2009 20:13:44 +0100 Subject: [rspec-users] redirects while using subdomains not working in 4.1 Message-ID: With the great help of David C., Scott T., and Dennis Z., redirecting while using a sub-domain worked in Dennis' fork: git://github.com/zdennis/webrat.git. Unfortunately, after upgrading to 4.1 (so I could use set_hidden_field), I am getting responses of "You are being redirected" instead of getting the page that the user was being redirected to. Did not all of Dennis's changes make it in? All the best, Tom -- Posted via http://www.ruby-forum.com/. From scott at railsnewbie.com Thu Feb 5 14:36:30 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Thu, 5 Feb 2009 14:36:30 -0500 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: <498B110A.4020904@benmabey.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <498B110A.4020904@benmabey.com> Message-ID: <1E8112F3-C2D0-4029-9AFE-82CA27F5F8AD@railsnewbie.com> > > Nat points out that problems with Object Mother arise when people > start adding factory methods to deal with the edge cases, such as > ObjectMother.new_invoice_with_no_postal_code. I totally agree that > this would be a problem since such abstraction results in hard to > follow tests (this is why I hate fixtures actually). From the > projects I have worked on I haven't seen the Object Mother libs > abused this way and they are used more like a Test Data Builder. > The only difference I see is in implementation, meaning the ruby > libs tend to group all the factory methods on one object or module > just like Object Mother, while the pattern Nat describes uses a > separate builder class for each object. I think this is really just > details though and results from Ruby's differences from Java. > > Any thoughts? Are Ruby's Object Mothers really Test Data Builders? Yeah, at least FixtureReplacement takes that stance, which is why I didn't call "Object Mother" Scott From lists at ruby-forum.com Thu Feb 5 15:25:20 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 5 Feb 2009 21:25:20 +0100 Subject: [rspec-users] Bizarre problem with Rake / Rcov Message-ID: I am writing a custom rake task for rcov. The intent is top produce three variants of a test, each using slightly different options. This is the basic code: R_RCOV_AGGREG_FILE = 'coverage.data' # Use single quotes here so that regexp argument is not munged. R_RCOV_EXCLUDE_DIR = 'lib\/ruby,lib64\/ruby' R_RCOV_OUTPUT_DIR = 'test_coverage' R_RCOV_AGGREG_OPTS = "--aggregate #{R_RCOV_AGGREG_FILE} " + "--text-summary --no-html " R_RCOV_BASIC_OPTS = [ " --rails ", " --exclude #{R_RCOV_EXCLUDE_DIR} " ] R_RCOV_FINAL_OPTS = " --aggregate #{R_RCOV_AGGREG_FILE} " R_RCOV_BROWSER = 'firefox' # make the output directory an array. r_rcov_dir = R_RCOV_OUTPUT_DIR.scan(/\w+/) [ 'single', 'aggregate', 'final' ].each do |reptype| # Set the rcov options variables according to report type r_rcov_opta = nil if reptype == 'single' r_rcov_opta = R_RCOV_AGGREG_OPTS if reptype == 'aggregate' r_rcov_opta = R_RCOV_FINAL_OPTS if reptype == 'final' # builds task int_testunit_X Rcov::RcovTask.new("int_testunit_#{reptype}") do |t| t.test_files = FileList['test/**/test*.rb'] t.libs << "test" t.output_dir = r_rcov_dir t.rcov_opts = R_RCOV_BASIC_OPTS t.rcov_opts << r_rcov_opta puts "testunit #{reptype} opts: #{R_RCOV_BASIC_OPTS} size " + "#{R_RCOV_BASIC_OPTS.size}" puts " " puts "testunit #{reptype} opta: #{r_rcov_opta}" puts " " puts "testunit #{reptype} options: #{t.rcov_opts}" puts " " t.verbose = true end end The problem is this. Somewhere the constant value R_RCOV_BASIC_OPTS is being changed. A rake run using puts and displaying R_RCOV_BASIC_OPTS.size gives this output: testunit single opts: --rails --exclude lib\/ruby,lib64\/ruby size 5 testunit single opta: testunit single options: --rails --exclude lib\/ruby,lib64\/ruby testunit aggregate opts: --rails --exclude lib\/ruby,lib64\/ruby --aggregate coverage.data --text-summary --no-html --aggregate coverage.data --text-summary --no-html --aggregate coverage.data --text-summary --no-html size 8 testunit aggregate opta: --aggregate coverage.data --text-summary --no-html testunit aggregate options: --rails --exclude lib\/ruby,lib64\/ruby --aggregate coverage.data --text-summary --no-html --aggregate coverage.data --text-summary --no-html --aggregate coverage.data --text-summary --no-html testunit final opts: --rails --exclude lib\/ruby,lib64\/ruby --aggregate coverage.data --text-summary --no-html --aggregate coverage.data --text-summary --no-html --aggregate coverage.data --text-summary --no-html --aggregate coverage.data --aggregate coverage.data --aggregate coverage.data size 11 testunit final opta: --aggregate coverage.data testunit final options: --rails --exclude lib\/ruby,lib64\/ruby --aggregate coverage.data --text-summary --no-html --aggregate coverage.data --text-summary --no-html --aggregate coverage.data --text-summary --no-html --aggregate coverage.data --aggregate coverage.data --aggregate coverage.data Checking my rake task lists only these places where R_RCOV_BASIC_OPTS is referenced: 22 R_RCOV_BASIC_OPTS = [ " --rails ", " --exclude #{R_RCOV_EXCLUDE_DIR} " ] 57 t.rcov_opts = R_RCOV_BASIC_OPTS 68 t.rcov_opts = R_RCOV_BASIC_OPTS 77 t.rcov_opts = R_RCOV_BASIC_OPTS 79 puts "testunit #{reptype} opts: #{R_RCOV_BASIC_OPTS} size " + 80 "#{R_RCOV_BASIC_OPTS.size}" Where and How is this constant getting its value changed? The evidence indicates that the array R_RCOV_BASIC_OPTS has the contents of rcov_opta appended each time that the factory method is called but I cannot see where or how this is happening. On a related note. I find that Rdebug does not support watch points, so that I cannot trace where in the rake program the constant is changing. Is there an alternative debugger for Ruby that does so? -- Posted via http://www.ruby-forum.com/. From joshknowles at gmail.com Thu Feb 5 18:13:24 2009 From: joshknowles at gmail.com (Josh Knowles) Date: Thu, 5 Feb 2009 18:13:24 -0500 Subject: [rspec-users] redirects while using subdomains not working in 4.1 In-Reply-To: References: Message-ID: On Thu, Feb 5, 2009 at 2:13 PM, Tom Hoen wrote: > Did not all of Dennis's changes make it in? As far as I know I merged everything in. Please feel free to open up a ticket in lighthouse, and/or startup a thread on the Webrat mailing list with a specific example of whats going wrong and we'll get it fixed. Even better would be a patch which includes a failing integration test :-) -- Josh Knowles phone: 509-979-1593 email: joshknowles at gmail.com web: http://joshknowles.com From matt at mattwynne.net Thu Feb 5 18:43:57 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 5 Feb 2009 23:43:57 +0000 Subject: [rspec-users] [Cucumber] Progress Bar Message-ID: Inspired by Nick Evans' RSpec progress bar[1], I had a little crack at implementing the progress bar for cucumber, 'cause I want to know how long a break I can take while the features are running :) It's in my fork, in the coverage_formatter branch: http://github.com/mattwynne/cucumber/tree/master It will dump failing feature, scenario, step and the exception as the features run. No specs for it, it's just a spike. [1]http://ekenosen.net/nick/devblog/2008/12/better-progress-bar-for-rspec/ Matt Wynne http://blog.mattwynne.net http://www.songkick.com From pergesu at gmail.com Thu Feb 5 19:20:42 2009 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 5 Feb 2009 16:20:42 -0800 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: <498B110A.4020904@benmabey.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <498B110A.4020904@benmabey.com> Message-ID: <810a540e0902051620n6979f773kc9903fa0d9e9c17c@mail.gmail.com> On Thu, Feb 5, 2009 at 8:17 AM, Ben Mabey wrote: > Any thoughts? Are Ruby's Object Mothers really Test Data Builders? Here's what I think is important: * Make fixture setup explicit by inlining it on a per example/group basis * Keep fixture setup short by hiding the object graph construction * Allow concise parameterization of the fixture objects * Focus 100% on structure (0% on behavior) in methods/objects to build your data. This minimizes accidental coupling between examples. The name you give a tool that fulfills these goals is never going to be central to valuable conversation, so I think it's of minimal importance. The rest of this email is somewhat ranty, and originally appeared before what you just read above...but I figured I'd save some people time and separate it out so you can skip over it if you want :) ----------------- I don't know what the distinction is, and to tell you the truth I don't think it matters. There's miniscule evidence to suggest that these are fundamentally different (quotes from http://martinfowler.com/bliki/ObjectMother.html) 1) These canned objects often aren't just right for a particular test, but often can be made right with some additional setup Okay, but he doesn't say HOW that additional setup comes about. Do you get an object from the mother and then call some setters on it? Do you parameterize calls to the OM? You can do either of those with all of the fixture replacement tools that I know of. 2) The canned objects that the Object Mother produces become familiar to the team, often invading even discussions with the users I guess this is where the "mother" thing comes from...mothers have children, children are unique like snowflakes and have names and personalities and yadda yadda. Personally I think that cast of characters blows as a testing pattern. It always leads to inadvertent coupling between tests and muddles intent. What makes more sense to you as a developer, "that customer object in this test is Joe Bob" or "that customer object is a customer with an account balance of $10k". If you want to get into pattern specifics, the question really is "am I using factory methods or a builder," to which the answer is "factory methods" for every tool I've seen. Well, not quite. You can imagine that new_user :name => "Pat", :email => "pat.maddox at gmail.com" is a different form of UserBuilder.new.with_name("Pat").with_email("pat.maddox at gmail.com").build see... def new_user(options={}) options.inject(UserBuilder.new) {|b,pair| b.send("with_#{pair.first}", pair.last) }.build end A beautiful outcome of using Ruby is that many traditional patterns fade in importance. If you want to be very technical, these tools are neither Object Mothers nor Test Data Builders right out of the box (assuming that TDB uses the actual Builder pattern). Rather, they're just factories/factory methods, dynamically generated by reflecting on given classes. The real question is which one communicates better. I'd say TDB does because it says exactly what it is - it builds data for your tests. You could use it in a conversation and the other party would not need to know that it's a pattern of any kind. But...Rails has fucked up the testing lexicon for tons of Ruby programmers. There's already a lot of fuzziness between unit/functional/integration in the testing community as a whole, and as David pointed out it's made worse in the Rails world by how *wrong* Rails gets the names. So when I talk to people I strictly use "developer tests" and "acceptance tests." I find that a much more valuable distinction to make. And for developer tests, it makes a lot more sense to discuss them in terms of value and tradeoffs than it is to try to put them in certain buckets. How does that fit into this discussion? Well, to me, a fixture is a set of objects in known states that comprise the context in which a test runs. To lots of Rails developers, fixtures are yaml files that define records in the test db. Instant communication problem, because it implies the question is Fixjour vs Foxy fixtures, which is absolutely not the case. Pat From zach.dennis at gmail.com Thu Feb 5 21:59:54 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 5 Feb 2009 21:59:54 -0500 Subject: [rspec-users] redirects while using subdomains not working in 4.1 In-Reply-To: References: Message-ID: <85d99afe0902051859r483efd07v87b584e81fda1ec6@mail.gmail.com> On Thu, Feb 5, 2009 at 2:13 PM, Tom Hoen wrote: > With the great help of David C., Scott T., and Dennis Z., redirecting > while using a sub-domain worked in Dennis' fork: > git://github.com/zdennis/webrat.git. > > Unfortunately, after upgrading to 4.1 (so I could use set_hidden_field), > I am getting responses of "You are being redirected" instead of getting > the page that the user was being redirected to. > > Did not all of Dennis's changes make it in? Were you using one of my branches, and was it working for you? I just pulled down the latest webrat and installed it on a project that uses subdomains, and all of the features are still passing. -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From lists at ruby-forum.com Fri Feb 6 05:37:20 2009 From: lists at ruby-forum.com (Juanma Cervera) Date: Fri, 6 Feb 2009 11:37:20 +0100 Subject: [rspec-users] Fixjour and others Message-ID: <5017299bb2890a5d4dcb3d9e5fc8427e@ruby-forum.com> Hello I have seen that some people in this list is using Fixjour as the replacement of fixtures. But I can't understand why it is superior or better than other approaches to the subject like Machinist o FactoryGirl. What are the problems this library resolve? Can somebody explain this a little. Thank you. Juanma -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Feb 6 06:01:02 2009 From: lists at ruby-forum.com (Juanma Cervera) Date: Fri, 6 Feb 2009 12:01:02 +0100 Subject: [rspec-users] Fixjour and others In-Reply-To: <5017299bb2890a5d4dcb3d9e5fc8427e@ruby-forum.com> References: <5017299bb2890a5d4dcb3d9e5fc8427e@ruby-forum.com> Message-ID: <7fcfd657f00f5805dce71c323239f2dd@ruby-forum.com> I'm sorry for the question. I have just seen that this question is already treated in a very near thread. I didn't see it. Juanma -- Posted via http://www.ruby-forum.com/. From scott at railsnewbie.com Fri Feb 6 07:09:47 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Fri, 06 Feb 2009 07:09:47 -0500 Subject: [rspec-users] Fixjour and others In-Reply-To: <5017299bb2890a5d4dcb3d9e5fc8427e@ruby-forum.com> References: <5017299bb2890a5d4dcb3d9e5fc8427e@ruby-forum.com> Message-ID: <498C288B.8030004@railsnewbie.com> Juanma Cervera wrote: > Hello > I have seen that some people in this list is using Fixjour as the > replacement of fixtures. > But I can't understand why it is superior or better than other > approaches to the subject like Machinist o FactoryGirl. > What are the problems this library resolve? > > Can somebody explain this a little. > Excuse the rant, but I need to go to bed before I wake up in 2 hours: I think part of it is that the other plugins all have an interface that sort of makes you want to throw up in your mouth. Or at least, they do for me. The only two interfaces that I've understood are FixtureReplacements and Fixjour, and they happen to generate the same methods. I asked Pat exactly what he thought it provided over FixtureReplacement. Here were his exact words: "So my main objective with fixjour is to have the simplest implementation possible, with a very simple API. So it will create the following methods: new_[model], create_[model], and valid_[model]_attributes." The interface isn't much different from FRs on a day to day basis. FR provides a ton more but its internal implementation is shit and very un-hackable. I don't know anything about Machinist. Factory girl was written because of a misconception with FixtureReplacement (the author thought that it didn't allow lambdas for associations - which is my own fault, because the api probably sucked). He also thought that it that relied to heavily on random values (although, I have no idea on how to provide good defaults - and I don't think that FG has solved that issue, either). Put the ThoughtBot machine in full drive, and it's not hard to get recognition (it also doesn't hurt to have like 30 rails developers at your company who probably all adopt it at the same time - that's like 1/3 of rubyconf). I'm not taking anything away from the plugin - it looks relatively clean, and I'm sure the internals are OK. Object Daddy was developed at about the same time as FR, and as far as I know, also originated from this Dan Manges post: http://www.dcmanges.com/blog/38 IMHO, I don't like the idea of defining test data in the model, and I don't like the necessarily tight coupling of one class => one fixture. Usually thats a good bet, but we all have "edge" cases. Once in a while an "Admin" won't be it's own class, it'll be a boolean field on the User. Does this mean that I now should need to pass :admin => true for every test case against a user? Couldn't I just say "create_admin" instead of create_user(:admin => true)? There are a ton of subtle details to each of them (like: do they support attr_protected attributes, lambdas for wrapping the association when defining it, inheriting default fixtures, model namespacing, automatically merging attributes, creating custom named fixtures (for those times you want admin_user but don't have an Admin model), etc. etc.). Creating a matrix of these things and seeing which plugins implement which would be interesting. Ultimately, I guess it comes down to the API, and what feels correct and clean. All of these do basically the same thing at the core, but they can all be abused to create terrible specs. That's my .02 on the matter, Scott > Thank you. > Juanma > From lists at ruby-forum.com Fri Feb 6 09:12:00 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Fri, 6 Feb 2009 15:12:00 +0100 Subject: [rspec-users] redirects while using subdomains not working in 4.1 In-Reply-To: <85d99afe0902051859r483efd07v87b584e81fda1ec6@mail.gmail.com> References: <85d99afe0902051859r483efd07v87b584e81fda1ec6@mail.gmail.com> Message-ID: Zach Dennis wrote: > > Were you using one of my branches, and was it working for you? > > I just pulled down the latest webrat and installed it on a project > that uses subdomains, and all of the features are still passing. Zach - I was using this fork: http://github.com/zdennis/webrat/tree/make_current_url_fully_qualified, and it was working. I moved to the most recent version of webrat, hoping to use set_hidden_field, which did not seem to be in your fork. I would love to help figure out why it is not working for me, but I just don't know enough about ruby/rails/webrat/mechanize etc yet. Though I will try to track down what is going wrong, it is unlikely I will find it. First, I am going to make sure that I am current on all of the pieces. I develop on a Vista machine, but run tests on Ubuntu running in VMWare. It may be that one of the dependencies is out of date (rspec, cucumber, webrat, etc.). Currently, I have the following installed: rspec (1.1.12, 1.1.4) rspec-rails (1.1.12) webrat (0.4.0) hpricot (0.6.161) cucumber (0.1.16, 0.1.14, 0.1.12) Rails 2.1.2 The first test that fails is a simple login. After successfully completing the login (filling in login and password and clicking login), the user is redirected to their personal page. At this point, Cucumber is seeing the response as "You are being redirected" instead of following the redirect. The message contains the correct redirect url, so I know the login is working. The first step of my login feature is the following: visit login_path(:host => "rpems.test") Any advice you can give would be greatly appreciated. Tom -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Fri Feb 6 10:20:31 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Fri, 6 Feb 2009 10:20:31 -0500 Subject: [rspec-users] redirects while using subdomains not working in 4.1 In-Reply-To: References: <85d99afe0902051859r483efd07v87b584e81fda1ec6@mail.gmail.com> Message-ID: <85d99afe0902060720i496683e1r2b2021428352d064@mail.gmail.com> On Fri, Feb 6, 2009 at 9:12 AM, Tom Hoen wrote: > Zach Dennis wrote: > >> >> Were you using one of my branches, and was it working for you? >> >> I just pulled down the latest webrat and installed it on a project >> that uses subdomains, and all of the features are still passing. > > Zach - > > I was using this fork: > http://github.com/zdennis/webrat/tree/make_current_url_fully_qualified, I am pretty certain that the change in this branch never got committed to webrat. The ticket is still open: http://webrat.lighthouseapp.com/projects/10503/tickets/140-current_url-should-be-fully-qualified dstar opened a ticket which is related, as in it requires that all urls are fully qualified, I don't believe it has been committed either look back at it: http://webrat.lighthouseapp.com/projects/10503/tickets/147-linkabsolute_href-is-broken I haven't tried out dstar's patch, but I believe we solve the same problem, we just do it at different points. Perhaps Bryan or Josh could look at these. In the meantime I have pushed an updated branch which includes all of webrat 4.1. Hopefully in the meantime this will solve the issue for you: http://github.com/zdennis/webrat/tree/make_current_url_fully_qualified-4.1 > and it was working. I moved to the most recent version of webrat, hoping > to use set_hidden_field, which did not seem to be in your fork. > > I would love to help figure out why it is not working for me, but I just > don't know enough about ruby/rails/webrat/mechanize etc yet. Though I > will try to track down what is going wrong, it is unlikely I will find > it. > > First, I am going to make sure that I am current on all of the pieces. I > develop on a Vista machine, but run tests on Ubuntu running in VMWare. > It may be that one of the dependencies is out of date (rspec, cucumber, > webrat, etc.). > > Currently, I have the following installed: > rspec (1.1.12, 1.1.4) > rspec-rails (1.1.12) > webrat (0.4.0) > hpricot (0.6.161) > cucumber (0.1.16, 0.1.14, 0.1.12) > Rails 2.1.2 > > The first test that fails is a simple login. After successfully > completing the login (filling in login and password and clicking login), > the user is redirected to their personal page. At this point, Cucumber > is seeing the response as "You are being redirected" instead of > following the redirect. The message contains the correct redirect url, > so I know the login is working. > > The first step of my login feature is the following: > visit login_path(:host => "rpems.test") > > Any advice you can give would be greatly appreciated. > > Tom > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From zach.dennis at gmail.com Fri Feb 6 10:21:39 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Fri, 6 Feb 2009 10:21:39 -0500 Subject: [rspec-users] redirects while using subdomains not working in 4.1 In-Reply-To: <85d99afe0902060720i496683e1r2b2021428352d064@mail.gmail.com> References: <85d99afe0902051859r483efd07v87b584e81fda1ec6@mail.gmail.com> <85d99afe0902060720i496683e1r2b2021428352d064@mail.gmail.com> Message-ID: <85d99afe0902060721j7ec672cauca90e867f851593d@mail.gmail.com> On Fri, Feb 6, 2009 at 10:20 AM, Zach Dennis wrote: > On Fri, Feb 6, 2009 at 9:12 AM, Tom Hoen wrote: >> Zach Dennis wrote: >> >>> >>> Were you using one of my branches, and was it working for you? >>> >>> I just pulled down the latest webrat and installed it on a project >>> that uses subdomains, and all of the features are still passing. >> >> Zach - >> >> I was using this fork: >> http://github.com/zdennis/webrat/tree/make_current_url_fully_qualified, > > I am pretty certain that the change in this branch never got committed > to webrat. The ticket is still open: > > http://webrat.lighthouseapp.com/projects/10503/tickets/140-current_url-should-be-fully-qualified > > dstar opened a ticket which is related, as in it requires that all > urls are fully qualified, I don't believe it has been committed either > look back at it: > > http://webrat.lighthouseapp.com/projects/10503/tickets/147-linkabsolute_href-is-broken > > I haven't tried out dstar's patch, but I believe we solve the same > problem, we just do it at different points. Correction -- I believe his problem forces the problem in my ticket to be solved. I don't know if my patch solves his problem. > > Perhaps Bryan or Josh could look at these. In the meantime I have > pushed an updated branch which includes all of webrat 4.1. Hopefully > in the meantime this will solve the issue for you: > > http://github.com/zdennis/webrat/tree/make_current_url_fully_qualified-4.1 > >> and it was working. I moved to the most recent version of webrat, hoping >> to use set_hidden_field, which did not seem to be in your fork. >> >> I would love to help figure out why it is not working for me, but I just >> don't know enough about ruby/rails/webrat/mechanize etc yet. Though I >> will try to track down what is going wrong, it is unlikely I will find >> it. >> >> First, I am going to make sure that I am current on all of the pieces. I >> develop on a Vista machine, but run tests on Ubuntu running in VMWare. >> It may be that one of the dependencies is out of date (rspec, cucumber, >> webrat, etc.). >> >> Currently, I have the following installed: >> rspec (1.1.12, 1.1.4) >> rspec-rails (1.1.12) >> webrat (0.4.0) >> hpricot (0.6.161) >> cucumber (0.1.16, 0.1.14, 0.1.12) >> Rails 2.1.2 >> >> The first test that fails is a simple login. After successfully >> completing the login (filling in login and password and clicking login), >> the user is redirected to their personal page. At this point, Cucumber >> is seeing the response as "You are being redirected" instead of >> following the redirect. The message contains the correct redirect url, >> so I know the login is working. >> >> The first step of my login feature is the following: >> visit login_path(:host => "rpems.test") >> >> Any advice you can give would be greatly appreciated. >> >> Tom >> >> >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Zach Dennis > http://www.continuousthinking.com > http://www.mutuallyhuman.com > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From hayafirst at gmail.com Fri Feb 6 10:41:01 2009 From: hayafirst at gmail.com (Yi Wen) Date: Fri, 6 Feb 2009 09:41:01 -0600 Subject: [rspec-users] Is RSpec Ruby1.9 ready? Message-ID: Hi, I saw a message on Nov, 2008 in this mailing list from David: "I'm not sure how to fix that problem, but before you go much further you should know that RSpec does not yet run under 1.9. It's something I want to raise in priority soon, and patches are welcome, but that's the state of things today." And I haven't seen any update on this issue since then. But according to this site , RSpec works under Ruby 1.9. So Is there any "official" response on this issue? Thanks Yi -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Fri Feb 6 11:43:33 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 6 Feb 2009 10:43:33 -0600 Subject: [rspec-users] Is RSpec Ruby1.9 ready? In-Reply-To: References: Message-ID: <57c63afe0902060843y67daccadt6859d0e4d6527e68@mail.gmail.com> On Fri, Feb 6, 2009 at 9:41 AM, Yi Wen wrote: > Hi, > > I saw a message on Nov, 2008 in this mailing list from David: > > "I'm not sure how to fix that problem, but before you go much further > you should know that RSpec does not yet run under 1.9. It's something > I want to raise in priority soon, and patches are welcome, but that's > the state of things today." > > > And I haven't seen any update on this issue since then. But according to > this site, RSpec works under Ruby 1.9. > > So Is there any "official" response on this issue? It may generally *work*, but right now RSpec's own spec suite is not passing in 1.9. Here's what is reported (running the specs using "multiruby bin/spec spec"): ruby 1.8.6 1246 examples, 0 failures, 4 pending ruby 1.8.7 1246 examples, 0 failures, 4 pending ruby 1.9.1 1238 examples, 49 failures, 4 pending Note that we not only have failures, but we also get a different number of examples reported in 1.9.1. Until these are resolved, RSpec does not *officially* support 1.9.1. If anybody is interested in helping us get there - most of the failures are related to just a few issues, so fixing one issue might resolve many of these failures. I'll document the remaining issues in lighthouse later today or over the weekend. If you're interested and feeling impatient, just grab the latest from git and run the specs w/ ruby 1.9 and you'll see what's going on. Thanks, David Officially, right now 49 of RSpec's own specs are failing against 1.9. TheIt is *mostly* working, but there are a few subtle issues that either need to be either fixed or formally documented as unsupported. This is high on the list right now, but so are a couple of other things. If anybody is interested in helping out, we're down to 49 failing specs. > > Thanks > > Yi > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri Feb 6 11:44:20 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 6 Feb 2009 10:44:20 -0600 Subject: [rspec-users] Is RSpec Ruby1.9 ready? In-Reply-To: <57c63afe0902060843y67daccadt6859d0e4d6527e68@mail.gmail.com> References: <57c63afe0902060843y67daccadt6859d0e4d6527e68@mail.gmail.com> Message-ID: <57c63afe0902060844o4eddc19dw3dc7c83d3d7ac667@mail.gmail.com> On Fri, Feb 6, 2009 at 10:43 AM, David Chelimsky wrote: > On Fri, Feb 6, 2009 at 9:41 AM, Yi Wen wrote: >> Hi, >> >> I saw a message on Nov, 2008 in this mailing list from David: >> >> "I'm not sure how to fix that problem, but before you go much further >> you should know that RSpec does not yet run under 1.9. It's something >> I want to raise in priority soon, and patches are welcome, but that's >> the state of things today." >> >> >> And I haven't seen any update on this issue since then. But according to >> this site, RSpec works under Ruby 1.9. >> >> So Is there any "official" response on this issue? > > It may generally *work*, but right now RSpec's own spec suite is not > passing in 1.9. Here's what is reported (running the specs using > "multiruby bin/spec spec"): > > > ruby 1.8.6 > 1246 examples, 0 failures, 4 pending > > ruby 1.8.7 > 1246 examples, 0 failures, 4 pending > > ruby 1.9.1 > 1238 examples, 49 failures, 4 pending > > Note that we not only have failures, but we also get a different > number of examples reported in 1.9.1. Until these are resolved, RSpec > does not *officially* support 1.9.1. > > If anybody is interested in helping us get there - most of the > failures are related to just a few issues, so fixing one issue might > resolve many of these failures. I'll document the remaining issues in > lighthouse later today or over the weekend. If you're interested and > feeling impatient, just grab the latest from git and run the specs w/ > ruby 1.9 and you'll see what's going on. > > Thanks, > David pressed send too soon - please ignore the 2nd version :) > > > Officially, right now 49 of RSpec's own specs are failing against 1.9. > TheIt is *mostly* working, but there are a few subtle issues that > either need to be either fixed or formally documented as unsupported. > This is high on the list right now, but so are a couple of other > things. > > If anybody is interested in helping out, we're down to 49 failing specs. > >> >> Thanks >> >> Yi >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > From lists at ruby-forum.com Fri Feb 6 12:17:10 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Fri, 6 Feb 2009 18:17:10 +0100 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: <810a540e0902051620n6979f773kc9903fa0d9e9c17c@mail.gmail.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <498B110A.4020904@benmabey.com> <810a540e0902051620n6979f773kc9903fa0d9e9c17c@mail.gmail.com> Message-ID: <5e105b9bc212a8013a9030a1b5983f54@ruby-forum.com> Pat Maddox wrote: > On Thu, Feb 5, 2009 at 8:17 AM, Ben Mabey wrote: >> Any thoughts? Are Ruby's Object Mothers really Test Data Builders? > > Here's what I think is important: > > * Make fixture setup explicit by inlining it on a per example/group > basis > * Keep fixture setup short by hiding the object graph construction > * Allow concise parameterization of the fixture objects > * Focus 100% on structure (0% on behavior) in methods/objects to build > your data. This minimizes accidental coupling between examples. > Jay's blog post finally got me inspired in using RSpec. I decided to give a last chance at it, and I wrote my own "Factory framework" after failing at using Machinist effectively and seeing the pain to maintain fixtures. Now I fully enjoy specing my models, and all my tests are straightforward as each test has its own "setup", it's definitely not dry but I don't care, it is so much easier to maintain so much easier to spot any bugs in the specs themselves and it happens a lot. Each model has a dedicated prepopulated before(:each) describe section were setup is "shared" by many examples, it's usually used to test my custom find methods were many models are part of the equation. Specing Models heavily like I now do, also forces me to refactor my app to transfer as much mogic as I can from the controllers to the models. You can't imagine how much code actually fits in the model, it's amazing, some of my controllers wen't down by 50% and it enabled me to spec effectively the models which I couldn't do until now. The next big step will be specing controllers, as it is more painful than models, but now that my controllers are ripped I guess it will be easier. Also I am already seeing some specs that are not efficient, refactoring specs is a compulsory task, so experiment different patterns as Jay proposes in his blog. -- Posted via http://www.ruby-forum.com/. From jeff.a.talbot at gmail.com Fri Feb 6 12:12:22 2009 From: jeff.a.talbot at gmail.com (Jeff Talbot) Date: Fri, 6 Feb 2009 11:12:22 -0600 Subject: [rspec-users] RecordNotFound bubbling thru to cucumber Message-ID: <69f72d390902060912p19ab0chf080da614b7de898@mail.gmail.com> Hello, I have a controller action that raises a RecordNotFound exception if you're not allowed to see something. In my global application controller (application.rb), I catch these and render the 404 template. But when I run cucumber (using webrat), it's getting the full stacktrace (the step blows up). Any ideas why? I have consider_all_requests_local turned off in my test.rb. Jeff From joahking at gmail.com Fri Feb 6 12:42:54 2009 From: joahking at gmail.com (Joaquin Rivera Padron) Date: Fri, 6 Feb 2009 18:42:54 +0100 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: <5e105b9bc212a8013a9030a1b5983f54@ruby-forum.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <498B110A.4020904@benmabey.com> <810a540e0902051620n6979f773kc9903fa0d9e9c17c@mail.gmail.com> <5e105b9bc212a8013a9030a1b5983f54@ruby-forum.com> Message-ID: <8277b7f40902060942s1068b613of39ffe615aeb5ed1@mail.gmail.com> hey fernando, maybe you want to take a look at http://www.patmaddox.com/blog/2009/1/15/how-i-test-controllers-2009-remix and give Cucumber a try regarding controllers spec-ing hth, joaquin -------------- next part -------------- An HTML attachment was scrubbed... URL: From sfeley at gmail.com Fri Feb 6 12:50:18 2009 From: sfeley at gmail.com (Stephen Eley) Date: Fri, 6 Feb 2009 12:50:18 -0500 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: <5e105b9bc212a8013a9030a1b5983f54@ruby-forum.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <498B110A.4020904@benmabey.com> <810a540e0902051620n6979f773kc9903fa0d9e9c17c@mail.gmail.com> <5e105b9bc212a8013a9030a1b5983f54@ruby-forum.com> Message-ID: <1fb4df0902060950k11906ccfgd29a5182ba559051@mail.gmail.com> On Fri, Feb 6, 2009 at 12:17 PM, Fernando Perez wrote: > > The next big step will be specing controllers, as it is more painful > than models, but now that my controllers are ripped I guess it will be > easier. I've stopped. Mostly because of the question Jay asks in that article: "Why are you testing?" I realized I had *no idea* why I was testing controllers, except that I had been lurking here and reading the RSpec docs and assumed that was the Way It Was Done. Finessing all those mocks and stubs does chew up major time, and I noticed that the controller code I was spending all that time writing stubs around wasn't typically code that broke. Most controllers for most apps are so boilerplate that if you can trust your framework (Rails or Merb) you can probably trust the controller. "If it hurts, you're doing it wrong" is a pretty good principle across modern development. I'm sure there are people for whom mocking and testing every controller action isn't painful, or may even be fun. I'm not one of them, so there's no point in doing it just for rote. I probably _would_ do some controller isolation testing if I had something complicated to do in an action or if my controllers seemed prone to breaking and I wasn't sure why. As David says, knowing more techniques helps you pick the right one for the right task. I'm using Cucumber with Webrat for simple request verifications now and just matching on the output. I find it's more fun and doesn't hurt (after I fixed some bugs with the Merb autotest flow) and it tells me the same stuff as the controller testing, and more, in maybe a tenth as much time to write. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From scott at railsnewbie.com Fri Feb 6 13:21:45 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Fri, 6 Feb 2009 13:21:45 -0500 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: <1fb4df0902060950k11906ccfgd29a5182ba559051@mail.gmail.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <498B110A.4020904@benmabey.com> <810a540e0902051620n6979f773kc9903fa0d9e9c17c@mail.gmail.com> <5e105b9bc212a8013a9030a1b5983f54@ruby-forum.com> <1fb4df0902060950k11906ccfgd29a5182ba559051@mail.gmail.com> Message-ID: On Feb 6, 2009, at 12:50 PM, Stephen Eley wrote: > On Fri, Feb 6, 2009 at 12:17 PM, Fernando Perez forum.com> wrote: >> >> The next big step will be specing controllers, as it is more painful >> than models, but now that my controllers are ripped I guess it will >> be >> easier. > > I've stopped. Mostly because of the question Jay asks in that > article: "Why are you testing?" I realized I had *no idea* why I was > testing controllers, except that I had been lurking here and reading > the RSpec docs and assumed that was the Way It Was Done. Finessing > all those mocks and stubs does chew up major time, and I noticed that > the controller code I was spending all that time writing stubs around > wasn't typically code that broke. Most controllers for most apps are > so boilerplate that if you can trust your framework (Rails or Merb) > you can probably trust the controller. +1 I've found that sometimes writing a very *simple* controller test, which hits the db is a better solution when you don't have the time and resources for a full cucumber story. Mocking a controller without some sort of macros (like rspec-on-rails- on-crack) is just too laborious and repetitive for my liking. Scott From joshknowles at gmail.com Fri Feb 6 13:37:25 2009 From: joshknowles at gmail.com (Josh Knowles) Date: Fri, 6 Feb 2009 13:37:25 -0500 Subject: [rspec-users] redirects while using subdomains not working in 4.1 In-Reply-To: <85d99afe0902060720i496683e1r2b2021428352d064@mail.gmail.com> References: <85d99afe0902051859r483efd07v87b584e81fda1ec6@mail.gmail.com> <85d99afe0902060720i496683e1r2b2021428352d064@mail.gmail.com> Message-ID: On Fri, Feb 6, 2009 at 10:20 AM, Zach Dennis wrote: > Perhaps Bryan or Josh could look at these. In the meantime I have > pushed an updated branch which includes all of webrat 4.1. Hopefully > in the meantime this will solve the issue for you: > > http://github.com/zdennis/webrat/tree/make_current_url_fully_qualified-4.1 I will dig more into this over the weekend. -- Josh Knowles phone: 509-979-1593 email: joshknowles at gmail.com web: http://joshknowles.com From lists at ruby-forum.com Fri Feb 6 14:25:41 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Fri, 6 Feb 2009 20:25:41 +0100 Subject: [rspec-users] redirects while using subdomains not working in 4.1 In-Reply-To: <85d99afe0902060721j7ec672cauca90e867f851593d@mail.gmail.com> References: <85d99afe0902051859r483efd07v87b584e81fda1ec6@mail.gmail.com> <85d99afe0902060720i496683e1r2b2021428352d064@mail.gmail.com> <85d99afe0902060721j7ec672cauca90e867f851593d@mail.gmail.com> Message-ID: Zach Dennis wrote: > > Correction -- I believe his problem forces the problem in my ticket to > be solved. I don't know if my patch solves his problem. > Zach - Thanks for the quick patch I grabbed your code, but it did not solve the problem. Here is what I am seeing. When fully_qualify_current_url is called, it uses current_host to build the fully qualified url. However, current_host checks whether current_url has a value (which it doesn't at first) and returns "www.example.com" as the host. So I am always getting "http://www.example.com/" as the url. This makes internal_redirect? return false (as the host in the current_host is different from that in the response.header("Location"). Looking at the actual response, it has the correct host in the HTTP_HOST value, but I can't figure out how to get to it (though i continue to look) and am not sure if it is appropriate to use as a comparison to the "Location" host. Any thoughts on this? Tom -- Posted via http://www.ruby-forum.com/. From nick at ekenosen.net Fri Feb 6 14:43:58 2009 From: nick at ekenosen.net (nicholas a. evans) Date: Fri, 6 Feb 2009 14:43:58 -0500 Subject: [rspec-users] [Cucumber] Progress Bar In-Reply-To: References: Message-ID: <276ff9870902061143i3b9e6eb6o31c90e20ee47adf3@mail.gmail.com> Yay! Thanks for this. I kept saying "I'll get around to this... tomorrow!" And well... :-) -- Nick On Thu, Feb 5, 2009 at 6:43 PM, Matt Wynne wrote: > Inspired by Nick Evans' RSpec progress bar[1], I had a little crack at > implementing the progress bar for cucumber, 'cause I want to know how long a > break I can take while the features are running :) > > It's in my fork, in the coverage_formatter branch: > http://github.com/mattwynne/cucumber/tree/master > > It will dump failing feature, scenario, step and the exception as the > features run. > > No specs for it, it's just a spike. > > [1]http://ekenosen.net/nick/devblog/2008/12/better-progress-bar-for-rspec/ > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cwdinfo at gmail.com Fri Feb 6 22:00:54 2009 From: cwdinfo at gmail.com (s.ross) Date: Fri, 6 Feb 2009 19:00:54 -0800 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <498B110A.4020904@benmabey.com> <810a540e0902051620n6979f773kc9903fa0d9e9c17c@mail.gmail.com> <5e105b9bc212a8013a9030a1b5983f54@ruby-forum.com> <1fb4df0902060950k11906ccfgd29a5182ba559051@mail.gmail.com> Message-ID: <8A1D92FE-81CC-4BC4-99CB-3DA60EF76C36@gmail.com> On Feb 6, 2009, at 10:21 AM, Scott Taylor wrote: > > On Feb 6, 2009, at 12:50 PM, Stephen Eley wrote: > >> On Fri, Feb 6, 2009 at 12:17 PM, Fernando Perez > forum.com> wrote: >>> >>> The next big step will be specing controllers, as it is more painful >>> than models, but now that my controllers are ripped I guess it >>> will be >>> easier. >> >> I've stopped. Mostly because of the question Jay asks in that >> article: "Why are you testing?" I realized I had *no idea* why I was >> testing controllers, except that I had been lurking here and reading >> the RSpec docs and assumed that was the Way It Was Done. Finessing >> all those mocks and stubs does chew up major time, and I noticed that >> the controller code I was spending all that time writing stubs around >> wasn't typically code that broke. Most controllers for most apps are >> so boilerplate that if you can trust your framework (Rails or Merb) >> you can probably trust the controller. > > +1 > > I've found that sometimes writing a very *simple* controller test, > which hits the db is a better solution when you don't have the time > and resources for a full cucumber story. > > Mocking a controller without some sort of macros (like rspec-on- > rails-on-crack) is just too laborious and repetitive for my liking. > > Scott I did stop writing new controller specs, but we were discussing the use-case for controller specs in the new Cukified world. Supposing you write scenarios that pretty much describe your app, what could possibly go wrong that a controller spec would catch but a cucumber story pass? My environment is not using Selenium or Watir, so any action that is Ajaxey potentially needs a controller spec example. I'm less clear that routing needs to be in the specs, but shoulda makes that stupid-simple, so it's a way to make sure I don't break something embarrassing when I'm goofing around in routes. I'm starting to think that Cucumber can do 90+% of the heavy lifting, but for describing what kind of response a controller will ship back (json or html), based on the request, user-agent specific stuff. All that would probably have to happen in controller specs. In response to Jay's post, I test what I'm afraid might fail. I test it to clarify my thinking as I build it. So if it's important that a controller return json in response to an XmlHttp request, then that's part of the spec. Does this sound reasonable? From lists at ruby-forum.com Sat Feb 7 01:06:50 2009 From: lists at ruby-forum.com (Brijesh Shah) Date: Sat, 7 Feb 2009 07:06:50 +0100 Subject: [rspec-users] How to write test cases in rcov Message-ID: Hi I am using rcov to generate code coverage. But I don't know how to write cases for that... I have installed rcov gem and and execute rcov test/*.rb command. It shows me some code coverage in files. Can anyone help me by giving example that how to write test cases and where to write... Thanks in advance... -- Posted via http://www.ruby-forum.com/. From biot023 at gmail.com Sat Feb 7 06:16:49 2009 From: biot023 at gmail.com (doug livesey) Date: Sat, 7 Feb 2009 11:16:49 +0000 Subject: [rspec-users] Speccing the format portion of a controller Message-ID: <50873a360902070316jba97fadtac033703550a40cc@mail.gmail.com> Hi -- I have a hacky work-around for this, but wondered if anyone could tell me the canonical way of sending the get/put/etc. portion of a spec with format information.I guess with something that might look like this: def do_get get :index, :format => :xml end Cheers, Doug. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sat Feb 7 07:41:46 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 7 Feb 2009 06:41:46 -0600 Subject: [rspec-users] Speccing the format portion of a controller In-Reply-To: <50873a360902070316jba97fadtac033703550a40cc@mail.gmail.com> References: <50873a360902070316jba97fadtac033703550a40cc@mail.gmail.com> Message-ID: <57c63afe0902070441w6a535a33wd4ca119adc019e57@mail.gmail.com> On Sat, Feb 7, 2009 at 5:16 AM, doug livesey wrote: > Hi -- I have a hacky work-around for this, but wondered if anyone could tell > me the canonical way of sending the get/put/etc. portion of a spec with > format information. This is what is in the specs generated by rspec-rails: request.env["HTTP_ACCEPT"] = "application/xml" get :index HTH, David > I guess with something that might look like this: > def do_get > get :index, :format => :xml > end > Cheers, > Doug. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Sat Feb 7 10:23:42 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Sat, 7 Feb 2009 16:23:42 +0100 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: <8277b7f40902060942s1068b613of39ffe615aeb5ed1@mail.gmail.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <498B110A.4020904@benmabey.com> <810a540e0902051620n6979f773kc9903fa0d9e9c17c@mail.gmail.com> <5e105b9bc212a8013a9030a1b5983f54@ruby-forum.com> <8277b7f40902060942s1068b613of39ffe615aeb5ed1@mail.gmail.com> Message-ID: <8d1c4c8c20f342c65608c9a5102093e2@ruby-forum.com> Joaquin Rivera Padron wrote: > hey fernando, > maybe you want to take a look at > http://www.patmaddox.com/blog/2009/1/15/how-i-test-controllers-2009-remix > and give Cucumber a try regarding controllers spec-ing > hth, > joaquin Hi, I already use Cucumber+Webrat for testing that my publicly accessible pages get rendered somehow correctly, and I am very pleased with it, so I guess I don't have to dive into deep testing my controllers as I expected to. Unfortunately most info / screencasts / docs available teach people how to test controllers, routing, views, etc, but they fail to teach people how to write better code in order to avoid having to test controllers and such. -- Posted via http://www.ruby-forum.com/. From nick at deadorange.com Sat Feb 7 10:59:45 2009 From: nick at deadorange.com (Nick Hoffman) Date: Sat, 7 Feb 2009 10:59:45 -0500 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: <8A1D92FE-81CC-4BC4-99CB-3DA60EF76C36@gmail.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <498B110A.4020904@benmabey.com> <810a540e0902051620n6979f773kc9903fa0d9e9c17c@mail.gmail.com> <5e105b9bc212a8013a9030a1b5983f54@ruby-forum.com> <1fb4df0902060950k11906ccfgd29a5182ba559051@mail.gmail.com> <8A1D92FE-81CC-4BC4-99CB-3DA60EF76C36@gmail.com> Message-ID: <0124D27A-38CB-4ACE-8CCB-604C96476657@deadorange.com> On 06/02/2009, at 10:00 PM, s.ross wrote: > I did stop writing new controller specs, but we were discussing the > use-case for controller specs in the new Cukified world. Supposing > you write scenarios that pretty much describe your app, what could > possibly go wrong that a controller spec would catch but a cucumber > story pass? My environment is not using Selenium or Watir, so any > action that is Ajaxey potentially needs a controller spec example. > I'm less clear that routing needs to be in the specs, but shoulda > makes that stupid-simple, so it's a way to make sure I don't break > something embarrassing when I'm goofing around in routes. > > I'm starting to think that Cucumber can do 90+% of the heavy > lifting, but for describing what kind of response a controller will > ship back (json or html), based on the request, user-agent specific > stuff. All that would probably have to happen in controller specs. > > In response to Jay's post, I test what I'm afraid might fail. I test > it to clarify my thinking as I build it. So if it's important that a > controller return json in response to an XmlHttp request, then > that's part of the spec. > > Does this sound reasonable? When writing Cucumber stories and features for controllers, should you cover every edge case? For example, should you write stories that feed bad or missing data to your controllers, or should that be left to RSpec? -Nick From biot023 at gmail.com Sat Feb 7 11:00:02 2009 From: biot023 at gmail.com (doug livesey) Date: Sat, 7 Feb 2009 16:00:02 +0000 Subject: [rspec-users] Speccing the format portion of a controller In-Reply-To: <57c63afe0902070441w6a535a33wd4ca119adc019e57@mail.gmail.com> References: <50873a360902070316jba97fadtac033703550a40cc@mail.gmail.com> <57c63afe0902070441w6a535a33wd4ca119adc019e57@mail.gmail.com> Message-ID: <50873a360902070800x22791973t20c447e2dbe2c61d@mail.gmail.com> Cheers for that -- that's what I thought was the hacky solution! ;)I'm now reassured that I'm not being evil -- thanks! Doug. 2009/2/7 David Chelimsky > On Sat, Feb 7, 2009 at 5:16 AM, doug livesey wrote: > > Hi -- I have a hacky work-around for this, but wondered if anyone could > tell > > me the canonical way of sending the get/put/etc. portion of a spec with > > format information. > > This is what is in the specs generated by rspec-rails: > > request.env["HTTP_ACCEPT"] = "application/xml" > get :index > > HTH, > David > > > I guess with something that might look like this: > > def do_get > > get :index, :format => :xml > > end > > Cheers, > > Doug. > > _______________________________________________ > > 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 Sat Feb 7 11:14:01 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 7 Feb 2009 10:14:01 -0600 Subject: [rspec-users] Speccing the format portion of a controller In-Reply-To: <50873a360902070800x22791973t20c447e2dbe2c61d@mail.gmail.com> References: <50873a360902070316jba97fadtac033703550a40cc@mail.gmail.com> <57c63afe0902070441w6a535a33wd4ca119adc019e57@mail.gmail.com> <50873a360902070800x22791973t20c447e2dbe2c61d@mail.gmail.com> Message-ID: <2834A267-B45A-42C1-88BE-2C727327413C@gmail.com> On Feb 7, 2009, at 10:00 AM, doug livesey wrote: > Cheers for that -- that's what I thought was the hacky solution! ;) > I'm now reassured that I'm not being evil -- thanks! Not so fast! It works, and it's what rspec uses, but that doesn't make it good ( as opposed to evil ). I'd add support for something friendlier, but maybe it really belongs in rails proper. > Doug. > > 2009/2/7 David Chelimsky > On Sat, Feb 7, 2009 at 5:16 AM, doug livesey > wrote: > > Hi -- I have a hacky work-around for this, but wondered if anyone > could tell > > me the canonical way of sending the get/put/etc. portion of a spec > with > > format information. > > This is what is in the specs generated by rspec-rails: > > request.env["HTTP_ACCEPT"] = "application/xml" > get :index > > HTH, > David > > > I guess with something that might look like this: > > def do_get > > get :index, :format => :xml > > end > > Cheers, > > Doug. > > _______________________________________________ > > 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 pergesu at gmail.com Sat Feb 7 11:20:42 2009 From: pergesu at gmail.com (Pat Maddox) Date: Sat, 7 Feb 2009 08:20:42 -0800 Subject: [rspec-users] Speccing the format portion of a controller In-Reply-To: <50873a360902070316jba97fadtac033703550a40cc@mail.gmail.com> References: <50873a360902070316jba97fadtac033703550a40cc@mail.gmail.com> Message-ID: <810a540e0902070820y1968975cu24bf34678923ec39@mail.gmail.com> On Sat, Feb 7, 2009 at 3:16 AM, doug livesey wrote:. def do_get get :index, :format => "xml" end should work. Notice it's a string instead of symbol. Pat From joahking at gmail.com Sat Feb 7 11:29:50 2009 From: joahking at gmail.com (Joaquin Rivera Padron) Date: Sat, 7 Feb 2009 17:29:50 +0100 Subject: [rspec-users] testing out cucumber scenario outline feature Message-ID: <8277b7f40902070829l5013d3e2l90ce42914a80ba60@mail.gmail.com> hey there, I've been playing with Scenario Outline according to cucumber wiki. I have paste the tests made in http://gist.github.com/59920 the short answers: http://wiki.github.com/aslakhellesoy/cucumber/scenario-outlines seems inaccurate, Examples should be More Examples. Should I edit the wiki for you? when you do: $ gem install cucumber you get version 0.1.16, right? the data in examples does not seem to be getting to the steps if you get cucumber vesion 0.1.99.21, then it is webrat who fails with: `load_missing_constant': uninitialized constant Spec::Runner (NameError) in: /webrat-0.4.1/lib/webrat/rspec-rails.rb:8 I am missing something? should I open a ticket on lighthouse? cheers joaquin -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Sat Feb 7 11:42:35 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Sat, 7 Feb 2009 17:42:35 +0100 Subject: [rspec-users] [RSpec] rcov and/or rexml bug? In-Reply-To: <57c63afe0902030732l6b7db945pf97035e2a7e592f4@mail.gmail.com> References: <1d5d31eff1533f2d92d2ac0bc40c97d9@ruby-forum.com> <226f56f3f134b7e2635100218229096a@ruby-forum.com> <57c63afe0902030732l6b7db945pf97035e2a7e592f4@mail.gmail.com> Message-ID: David Chelimsky wrote: > On Tue, Feb 3, 2009 at 7:32 AM, James Byrne > wrote: >> >> thinking that maybe RSpec 1.1.12, Rails 2.2.2 and perhaps Rcov 0.8.1 >> have some incompatibilities. > > Try spicycode's rcov: > > [sudo] gem install spicycode-rcov --source http://gems.github.com Something got screwed when uninstalling the old rcov gem, I now get the following error message: rm -r coverage /usr/local/ruby1.8.7//bin/ruby: No such file or directory -- rcov (LoadError) rake aborted! What is it looking for? an rcov binary? When I issue: $ which rcov, it can't find anything. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sat Feb 7 11:55:44 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Sat, 7 Feb 2009 17:55:44 +0100 Subject: [rspec-users] [RSpec] rcov and/or rexml bug? In-Reply-To: References: <1d5d31eff1533f2d92d2ac0bc40c97d9@ruby-forum.com> <226f56f3f134b7e2635100218229096a@ruby-forum.com> <57c63afe0902030732l6b7db945pf97035e2a7e592f4@mail.gmail.com> Message-ID: <7a98104e01b51224e4cb66cea68977b6@ruby-forum.com> > Something got screwed when uninstalling the old rcov gem, I now get the > following error message: > Finally got things back to 'almost' normal, I had to edit my $PATH var to make rcov 0.8.1.2 work and bug on: /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/formatters/pretty.rb:131:in `[]': no implicit conversion from nil to integer (TypeError) So I uninstalled rcov, and installed instead: spicycode-rcov, but now it cannot find the binary file. Using spicycode do I need to make any tweak to a rake file? -- Posted via http://www.ruby-forum.com/. From lists-rspec at shopwatch.org Sat Feb 7 11:16:18 2009 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Sat, 07 Feb 2009 11:16:18 -0500 Subject: [rspec-users] Fixjour and others In-Reply-To: <498C288B.8030004@railsnewbie.com> References: <5017299bb2890a5d4dcb3d9e5fc8427e@ruby-forum.com> <498C288B.8030004@railsnewbie.com> Message-ID: <498DB3D2.6000809@shopwatch.org> Scott Taylor wrote: > [ > "So my main objective with fixjour is to have the simplest > implementation possible, with a very simple API. So it will create the > following methods: new_[model], create_[model], and > valid_[model]_attributes." This seems to be an anti-pattern in the Rails community: "I can't follow Library X, so I'll write Library Y, which is lightweight and obeys YAGNI, and is the simplest possible implementation." I confess: I've done it too. But it's nearly always the wrong approach. If you can't follow Library X's *implementation*, but you agree with its *philosophies*, refactor it! Competing libraries should have different goals, different purposes, different anything other than just "cleaner code". If Merb can refactor itself into Rails, you can do it with fixtures, authentication, file attachments, or what have you. As easy as Github makes forking, the choice of libraries should no longer be driven by "this one was updated most recently" or "this one uses the most recent design idioms". As someone wrote recently: The minute you start coding, you're writing legacy code. Jay Levitt From lists at ruby-forum.com Sat Feb 7 12:06:47 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Sat, 7 Feb 2009 18:06:47 +0100 Subject: [rspec-users] [RSpec] rcov and/or rexml bug? In-Reply-To: <7a98104e01b51224e4cb66cea68977b6@ruby-forum.com> References: <1d5d31eff1533f2d92d2ac0bc40c97d9@ruby-forum.com> <226f56f3f134b7e2635100218229096a@ruby-forum.com> <57c63afe0902030732l6b7db945pf97035e2a7e592f4@mail.gmail.com> <7a98104e01b51224e4cb66cea68977b6@ruby-forum.com> Message-ID: > So I uninstalled rcov, and installed instead: spicycode-rcov, but now it > cannot find the binary file. Using spicycode do I need to make any tweak > to a rake file? I finally got everything working with no bugs by doing: 1) git clone git://github.com/spicycode/rcov.git 2) cd rcov 3) sudo ruby setup.rb At this point it would still not work as it couln't find the rcov binary. So I did one more step: 4) sudo ruby setup.rb config Maybe step 3 can be replaced by step 4? However now spicycode-rcov doesn't appear in $ gem list, and I don't know how to uninstall it or update it. God I hate apps that don't offer a clear and easy an uninstall option. -- Posted via http://www.ruby-forum.com/. From nick at deadorange.com Sat Feb 7 12:30:14 2009 From: nick at deadorange.com (Nick Hoffman) Date: Sat, 7 Feb 2009 12:30:14 -0500 Subject: [rspec-users] [RSpec] Setting a gem dep on rspec-rails Message-ID: <9CED04E8-7F30-4A1F-8996-FC0D350C9CCC@deadorange.com> For a while now, I've had the following in config/environment.rb : config.gem 'haml' config.gem 'rspec', :lib => 'spec' config.gem 'rspec-rails', :lib => 'spec/rails' I just tried running the Rails console in production mode, and this warning occured: irb: warn: can't alias context from irb_context. After some googling, I learned that the gem deps on rspec and rspec- rails are causing that warning. When I remove those two gem deps from environment.rb , the warning disappears. With that said, I'm wondering what the accepted way to setup gem dependencies on rspec and rspec-rails is. Should one not bother? Should the "config.gem" lines go in config/environments/test.rb ? Thanks, Nick From biot023 at gmail.com Sat Feb 7 12:33:17 2009 From: biot023 at gmail.com (doug livesey) Date: Sat, 7 Feb 2009 17:33:17 +0000 Subject: [rspec-users] Speccing the format portion of a controller In-Reply-To: <2834A267-B45A-42C1-88BE-2C727327413C@gmail.com> References: <50873a360902070316jba97fadtac033703550a40cc@mail.gmail.com> <57c63afe0902070441w6a535a33wd4ca119adc019e57@mail.gmail.com> <50873a360902070800x22791973t20c447e2dbe2c61d@mail.gmail.com> <2834A267-B45A-42C1-88BE-2C727327413C@gmail.com> Message-ID: <50873a360902070933w7a2a6c30x55bc215d5284d03f@mail.gmail.com> Well, I can guarantee that it's better than any home-grown solution I would attempt, so I'll be happy w/ that for now! ;)Cheers again, Doug. 2009/2/7 David Chelimsky > On Feb 7, 2009, at 10:00 AM, doug livesey wrote: > > Cheers for that -- that's what I thought was the hacky solution! ;)I'm now > reassured that I'm not being evil -- thanks! > > > Not so fast! It works, and it's what rspec uses, but that doesn't make it > good ( as opposed to evil ). > > I'd add support for something friendlier, but maybe it really belongs in > rails proper. > > Doug. > > 2009/2/7 David Chelimsky < dchelimsky at gmail.com> > >> On Sat, Feb 7, 2009 at 5:16 AM, doug livesey < >> biot023 at gmail.com> wrote: >> > Hi -- I have a hacky work-around for this, but wondered if anyone could >> tell >> > me the canonical way of sending the get/put/etc. portion of a spec with >> > format information. >> >> This is what is in the specs generated by rspec-rails: >> >> request.env["HTTP_ACCEPT"] = "application/xml" >> get :index >> >> HTH, >> David >> >> > I guess with something that might look like this: >> > def do_get >> > get :index, :format => :xml >> > end >> > Cheers, >> > Doug. >> > _______________________________________________ >> > 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 nick at deadorange.com Sat Feb 7 12:33:32 2009 From: nick at deadorange.com (Nick Hoffman) Date: Sat, 7 Feb 2009 12:33:32 -0500 Subject: [rspec-users] [RSpec] Setting a gem dep on rspec-rails In-Reply-To: <9CED04E8-7F30-4A1F-8996-FC0D350C9CCC@deadorange.com> References: <9CED04E8-7F30-4A1F-8996-FC0D350C9CCC@deadorange.com> Message-ID: <669C95F5-6288-4D2A-BBE9-29C7825CF5B3@deadorange.com> On 07/02/2009, at 12:30 PM, Nick Hoffman wrote: > For a while now, I've had the following in config/environment.rb : > > config.gem 'haml' > config.gem 'rspec', :lib => 'spec' > config.gem 'rspec-rails', :lib => 'spec/rails' > > I just tried running the Rails console in production mode, and this > warning occured: > > irb: warn: can't alias context from irb_context. > > After some googling, I learned that the gem deps on rspec and rspec- > rails are causing that warning. When I remove those two gem deps > from environment.rb , the warning disappears. > > With that said, I'm wondering what the accepted way to setup gem > dependencies on rspec and rspec-rails is. Should one not bother? > Should the "config.gem" lines go in config/environments/test.rb ? > > Thanks, > Nick I should've tried the second solution I proposed before sending that email. If you put the gem dependencies in config/environments/test.rb and then enter the Rails console in test mode (script/console test), the warning occurs. -Nick From joe at josephwilk.net Sat Feb 7 12:41:43 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Sat, 07 Feb 2009 17:41:43 +0000 Subject: [rspec-users] testing out cucumber scenario outline feature In-Reply-To: <8277b7f40902070829l5013d3e2l90ce42914a80ba60@mail.gmail.com> References: <8277b7f40902070829l5013d3e2l90ce42914a80ba60@mail.gmail.com> Message-ID: <498DC7D7.40401@josephwilk.net> Joaquin Rivera Padron wrote: > hey there, > I've been playing with Scenario Outline according to cucumber wiki. I > have paste the tests made in http://gist.github.com/59920 > > the short answers: > http://wiki.github.com/aslakhellesoy/cucumber/scenario-outlines seems > inaccurate, Examples should be More Examples. Should I edit the wiki > for you? >Q 1. Is the wiki http://wiki.github.com/aslakhellesoy/cucumber/scenario-outlines not accurate? The keyword for scenario outline tables has always been 'Examples'. In the latest version 0.1.99.* it can also now be 'Scenarios'. So your example does look like a bug rather than a wiki error. However the bug has been fixed in the latest version of cucumber 0.1.99 (Which is still in beta) the example works fine: http://gist.github.com/59939 The github wiki is freely editable by anyone, so if you want to improve the wiki in the future please do. > > when you do: > $ gem install cucumber > you get version 0.1.16, right? the data in examples does not seem to > be getting to the steps > > if you get cucumber vesion 0.1.99.21, then it is webrat who fails with: > `load_missing_constant': uninitialized constant Spec::Runner (NameError) > in: > /webrat-0.4.1/lib/webrat/rspec-rails.rb:8 I've not come across this one before but it looks like its not finding your Rspec gem/plugin. -- Joseph Wilk http://blog.josephwilk.net > > I am missing something? should I open a ticket on lighthouse? > cheers > joaquin > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From joahking at gmail.com Sat Feb 7 12:52:15 2009 From: joahking at gmail.com (Joaquin Rivera Padron) Date: Sat, 7 Feb 2009 18:52:15 +0100 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: <0124D27A-38CB-4ACE-8CCB-604C96476657@deadorange.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <498B110A.4020904@benmabey.com> <810a540e0902051620n6979f773kc9903fa0d9e9c17c@mail.gmail.com> <5e105b9bc212a8013a9030a1b5983f54@ruby-forum.com> <1fb4df0902060950k11906ccfgd29a5182ba559051@mail.gmail.com> <8A1D92FE-81CC-4BC4-99CB-3DA60EF76C36@gmail.com> <0124D27A-38CB-4ACE-8CCB-604C96476657@deadorange.com> Message-ID: <8277b7f40902070952r7c32473epe15d894e943f1d69@mail.gmail.com> 2009/2/7 Nick Hoffman > When writing Cucumber stories and features for controllers, should you > cover every edge case? For example, should you write stories that feed bad > or missing data to your controllers, or should that be left to RSpec? > -Nick the missing data case should be left for a Scenario with some step like And I leave an obligatory field blank, and check for error messages, but I guess that does not sounds new. More interesting is the "bad data case", are you thinking in let's say some hacking attack to the app? I would say that belongs outside Features, but where? what do you think? or am I missreading your opinion lsd, joaquin -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.dennis at gmail.com Sat Feb 7 12:56:19 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Sat, 7 Feb 2009 12:56:19 -0500 Subject: [rspec-users] [RSpec] Setting a gem dep on rspec-rails In-Reply-To: <9CED04E8-7F30-4A1F-8996-FC0D350C9CCC@deadorange.com> References: <9CED04E8-7F30-4A1F-8996-FC0D350C9CCC@deadorange.com> Message-ID: <85d99afe0902070956k5470d668jd893a91b230f2971@mail.gmail.com> On Sat, Feb 7, 2009 at 12:30 PM, Nick Hoffman wrote: > For a while now, I've had the following in config/environment.rb : > > config.gem 'haml' > config.gem 'rspec', :lib => 'spec' > config.gem 'rspec-rails', :lib => 'spec/rails' > > I just tried running the Rails console in production mode, and this warning > occured: > > irb: warn: can't alias context from irb_context. > > After some googling, I learned that the gem deps on rspec and rspec-rails > are causing that warning. When I remove those two gem deps from > environment.rb , the warning disappears. > > With that said, I'm wondering what the accepted way to setup gem > dependencies on rspec and rspec-rails is. Should one not bother? Should the > "config.gem" lines go in config/environments/test.rb ? Rails config.gem has never seemed to work 100% with libraries that shouldn't be loaded in all environments. With that said, I point you to the wiki: http://wiki.github.com/dchelimsky/rspec/rails-with-rspec-gems If you try to use the rake tasks to find gem dependencies for your app, it will not list them by default unless you set RAILS_ENV=test. ie: RAILS_ENV=test rake gems IMO, running "rake gems" should tell you the configured gems for *everything*, and it should say what environments a particular gem is required. It kind of defeats the purpose if I have to be so specific when asking the "rake gems" task what gems the application relies on. I've haven't successfully gotten all of the rake tasks for gems to work 100% in the test environment. For the most part the "gems" and "gems:unpack" do function. You can successfully bypass cofnig.gem and the associated rake tasks by using "gem unpack". ie: cd vendor/gems ; gem unpack rspec ; gem unpack rspec-rails Personally, I put rspec and rspec-rails in vendor/plugins, even if it's just using "gem unpack" to put them there. It makes easier to upgrade to recent changes in rspec/rspec-rails in order to try out bug fixes, or take advantage of new features. Basically you've got options. I'd recommend gem unpacking into vendor/gems or vendor/plugins. I don't see an advantage at this point of using config.gem since it doesn't work 100% of the time, and it doesn't work necessarily as it should (of course IMO), -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From dchelimsky at gmail.com Sat Feb 7 13:16:58 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 7 Feb 2009 12:16:58 -0600 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: <0124D27A-38CB-4ACE-8CCB-604C96476657@deadorange.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <498B110A.4020904@benmabey.com> <810a540e0902051620n6979f773kc9903fa0d9e9c17c@mail.gmail.com> <5e105b9bc212a8013a9030a1b5983f54@ruby-forum.com> <1fb4df0902060950k11906ccfgd29a5182ba559051@mail.gmail.com> <8A1D92FE-81CC-4BC4-99CB-3DA60EF76C36@gmail.com> <0124D27A-38CB-4ACE-8CCB-604C96476657@deadorange.com> Message-ID: <57c63afe0902071016y75030c14i8674776569da07bf@mail.gmail.com> On Sat, Feb 7, 2009 at 9:59 AM, Nick Hoffman wrote: > On 06/02/2009, at 10:00 PM, s.ross wrote: >> >> I did stop writing new controller specs, but we were discussing the >> use-case for controller specs in the new Cukified world. Supposing you write >> scenarios that pretty much describe your app, what could possibly go wrong >> that a controller spec would catch but a cucumber story pass? My environment >> is not using Selenium or Watir, so any action that is Ajaxey potentially >> needs a controller spec example. I'm less clear that routing needs to be in >> the specs, but shoulda makes that stupid-simple, so it's a way to make sure >> I don't break something embarrassing when I'm goofing around in routes. >> >> I'm starting to think that Cucumber can do 90+% of the heavy lifting, but >> for describing what kind of response a controller will ship back (json or >> html), based on the request, user-agent specific stuff. All that would >> probably have to happen in controller specs. >> >> In response to Jay's post, I test what I'm afraid might fail. I test it to >> clarify my thinking as I build it. So if it's important that a controller >> return json in response to an XmlHttp request, then that's part of the spec. >> >> Does this sound reasonable? > > When writing Cucumber stories and features for controllers, should you cover > every edge case? For example, should you write stories that feed bad or > missing data to your controllers, or should that be left to RSpec? Depends on the team and who can read what and who cares about what. In most cases, Cucumber is a significantly better developer/stakeholder collaboration tool than RSpec is. If your stakeholders trust you to cover the edge cases, then they don't need to be in cucumber, but they certainly can be. IASTDH, David > -Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Sat Feb 7 13:27:08 2009 From: pergesu at gmail.com (Pat Maddox) Date: Sat, 7 Feb 2009 10:27:08 -0800 Subject: [rspec-users] [RSpec] Setting a gem dep on rspec-rails In-Reply-To: <9CED04E8-7F30-4A1F-8996-FC0D350C9CCC@deadorange.com> References: <9CED04E8-7F30-4A1F-8996-FC0D350C9CCC@deadorange.com> Message-ID: <810a540e0902071027x53abfe30y348579c44b517bac@mail.gmail.com> On Sat, Feb 7, 2009 at 9:30 AM, Nick Hoffman wrote: > With that said, I'm wondering what the accepted way to setup gem > dependencies on rspec and rspec-rails is. Should one not bother? Should the > "config.gem" lines go in config/environments/test.rb ? I don't bother to use config.gem with rspec, but if you do then yes it should go in test.rb Pat From dchelimsky at gmail.com Sat Feb 7 13:54:08 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 7 Feb 2009 12:54:08 -0600 Subject: [rspec-users] Speccing the format portion of a controller In-Reply-To: <810a540e0902070820y1968975cu24bf34678923ec39@mail.gmail.com> References: <50873a360902070316jba97fadtac033703550a40cc@mail.gmail.com> <810a540e0902070820y1968975cu24bf34678923ec39@mail.gmail.com> Message-ID: <57c63afe0902071054s2b36417fiaa06bb29402025c5@mail.gmail.com> On Sat, Feb 7, 2009 at 10:20 AM, Pat Maddox wrote: > On Sat, Feb 7, 2009 at 3:16 AM, doug livesey wrote:. > > def do_get > get :index, :format => "xml" > end > > should work. Notice it's a string instead of symbol. I should change the gen'd specs then. That's simpler, ay? > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sat Feb 7 14:02:03 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 7 Feb 2009 13:02:03 -0600 Subject: [rspec-users] [RSpec] Setting a gem dep on rspec-rails In-Reply-To: <810a540e0902071027x53abfe30y348579c44b517bac@mail.gmail.com> References: <9CED04E8-7F30-4A1F-8996-FC0D350C9CCC@deadorange.com> <810a540e0902071027x53abfe30y348579c44b517bac@mail.gmail.com> Message-ID: <57c63afe0902071102q4058ab63vf6050dd6af3538a9@mail.gmail.com> On Sat, Feb 7, 2009 at 12:27 PM, Pat Maddox wrote: > On Sat, Feb 7, 2009 at 9:30 AM, Nick Hoffman wrote: >> With that said, I'm wondering what the accepted way to setup gem >> dependencies on rspec and rspec-rails is. Should one not bother? Should the >> "config.gem" lines go in config/environments/test.rb ? > > I don't bother to use config.gem with rspec, but if you do then yes it > should go in test.rb I don't either, but I'd like to get it working for ppl who want to do it. If anybody w/ config.gem fu wants to help, that'd be awesome. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From joahking at gmail.com Sat Feb 7 14:25:26 2009 From: joahking at gmail.com (Joaquin Rivera Padron) Date: Sat, 7 Feb 2009 20:25:26 +0100 Subject: [rspec-users] testing out cucumber scenario outline feature In-Reply-To: <498DC7D7.40401@josephwilk.net> References: <8277b7f40902070829l5013d3e2l90ce42914a80ba60@mail.gmail.com> <498DC7D7.40401@josephwilk.net> Message-ID: <8277b7f40902071125g24ec890el5b05459d470b9cc1@mail.gmail.com> hey thanks joseph, I tried this out: $ ruby script/plugin install git://github.com/dchelimsky/rspec.git -r 'tag 1.1.12' $ ruby script/plugin install git://github.com/dchelimsky/rspec-rails.git -r 'tag 1.1.12' now Webrat finds correctly rspec-rails. Before it was a system gem and so it failed, and all my $ spec spec were doing fine. now with Examples as the keyword everything runs fine. $ cucumber features/manage_cukes.feature Feature: Manage cukes In order to use scenario outlines everything should work Scenario Outline: Testing scenario outlines # features/manage_cukes.feature:5 Given there are Examples: | cuke_versions | | cuke_version 1 | | cuke_version 2 | | cuke_version 3 | | cuke_version 4 | 4 scenarios 4 undefined steps You can implement step definitions for missing steps with these snippets: Given /^there are cuke_version 1$/ do pending end Given /^there are cuke_version 2$/ do pending end Given /^there are cuke_version 3$/ do pending end Given /^there are cuke_version 4$/ do pending end the thing was I was expecting the step like this: Given /^there are $/ do cuke_version.should_not be_nil end and then the step get called 4 times with the right data each time. But the wiki states "*IMPORTANT: Your step definitions will never have to match a placeholder. They will need to match the values that will replace the placeholder*" so its a feature. Then I must be missing the purpose of it. I'll dive the code and see... thanks joaquin -------------- next part -------------- An HTML attachment was scrubbed... URL: From cwdinfo at gmail.com Sat Feb 7 14:33:08 2009 From: cwdinfo at gmail.com (s.ross) Date: Sat, 7 Feb 2009 11:33:08 -0800 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: <0124D27A-38CB-4ACE-8CCB-604C96476657@deadorange.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <498B110A.4020904@benmabey.com> <810a540e0902051620n6979f773kc9903fa0d9e9c17c@mail.gmail.com> <5e105b9bc212a8013a9030a1b5983f54@ruby-forum.com> <1fb4df0902060950k11906ccfgd29a5182ba559051@mail.gmail.com> <8A1D92FE-81CC-4BC4-99CB-3DA60EF76C36@gmail.com> <0124D27A-38CB-4ACE-8CCB-604C96476657@deadorange.com> Message-ID: Hi-- On Feb 7, 2009, at 7:59 AM, Nick Hoffman wrote: > On 06/02/2009, at 10:00 PM, s.ross wrote: >> I did stop writing new controller specs, but we were discussing the >> use-case for controller specs in the new Cukified world. Supposing >> you write scenarios that pretty much describe your app, what could >> possibly go wrong that a controller spec would catch but a cucumber >> story pass? My environment is not using Selenium or Watir, so any >> action that is Ajaxey potentially needs a controller spec example. >> I'm less clear that routing needs to be in the specs, but shoulda >> makes that stupid-simple, so it's a way to make sure I don't break >> something embarrassing when I'm goofing around in routes. >> >> I'm starting to think that Cucumber can do 90+% of the heavy >> lifting, but for describing what kind of response a controller will >> ship back (json or html), based on the request, user-agent specific >> stuff. All that would probably have to happen in controller specs. >> >> In response to Jay's post, I test what I'm afraid might fail. I >> test it to clarify my thinking as I build it. So if it's important >> that a controller return json in response to an XmlHttp request, >> then that's part of the spec. >> >> Does this sound reasonable? > > When writing Cucumber stories and features for controllers, should > you cover every edge case? For example, should you write stories > that feed bad or missing data to your controllers, or should that be > left to RSpec? > -Nick Why wouldn't you cover the negative scenario. E.g.: Feature: Projects dashboard Scenario: A user who has not set up any projects yet should be sent to the "set up new project now!" page Given a user, "Emil" has no projects When "Emil" clicks on the "dashboard" link Then he sees the "new project" page And he sees the greeting "set up new project now!" Scenario: A user who has one or more projects should be able to examine the list of projects Given a user, "Gary" has 1 project When "Gary" clicks on the "dashboard" link Then he sees the "project list" page Wouldn't that make sense? From dchelimsky at gmail.com Sat Feb 7 14:33:17 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 7 Feb 2009 13:33:17 -0600 Subject: [rspec-users] How to write test cases in rcov In-Reply-To: References: Message-ID: <57c63afe0902071133t21cbd8d4l20d5cdba79bc75@mail.gmail.com> On Sat, Feb 7, 2009 at 12:06 AM, Brijesh Shah wrote: > Hi I am using rcov to generate code coverage. But I don't know how to > write cases for that... > > I have installed rcov gem and and execute rcov test/*.rb command. It > shows me some code coverage in files. > > Can anyone help me by giving example that how to write test cases and > where to write... > > Thanks in advance... http://rspec.info/documentation/tools/rcov.html 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 luke at lukemelia.com Sat Feb 7 19:03:48 2009 From: luke at lukemelia.com (Luke Melia) Date: Sat, 7 Feb 2009 19:03:48 -0500 Subject: [rspec-users] [Cucumber] Progress Bar In-Reply-To: <276ff9870902061143i3b9e6eb6o31c90e20ee47adf3@mail.gmail.com> References: <276ff9870902061143i3b9e6eb6o31c90e20ee47adf3@mail.gmail.com> Message-ID: <38053BF0-3FFD-4C48-AB91-53EC913B562A@lukemelia.com> FYI, brynary has a progress formatter in testjour that could probably be ported. On Feb 6, 2009, at 2:43 PM, nicholas a. evans wrote: > Yay! Thanks for this. I kept saying "I'll get around to this... > tomorrow!" And well... :-) > > -- > Nick > > On Thu, Feb 5, 2009 at 6:43 PM, Matt Wynne wrote: >> Inspired by Nick Evans' RSpec progress bar[1], I had a little crack >> at >> implementing the progress bar for cucumber, 'cause I want to know >> how long a >> break I can take while the features are running :) >> >> It's in my fork, in the coverage_formatter branch: >> http://github.com/mattwynne/cucumber/tree/master >> >> It will dump failing feature, scenario, step and the exception as the >> features run. >> >> No specs for it, it's just a spike. >> >> [1]http://ekenosen.net/nick/devblog/2008/12/better-progress-bar-for-rspec/ >> >> Matt Wynne >> http://blog.mattwynne.net >> http://www.songkick.com >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -- Luke Melia luke at lukemelia.com http://www.lukemelia.com/ From nick at deadorange.com Sat Feb 7 21:05:53 2009 From: nick at deadorange.com (Nick Hoffman) Date: Sat, 7 Feb 2009 21:05:53 -0500 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: <57c63afe0902071016y75030c14i8674776569da07bf@mail.gmail.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <498B110A.4020904@benmabey.com> <810a540e0902051620n6979f773kc9903fa0d9e9c17c@mail.gmail.com> <5e105b9bc212a8013a9030a1b5983f54@ruby-forum.com> <1fb4df0902060950k11906ccfgd29a5182ba559051@mail.gmail.com> <8A1D92FE-81CC-4BC4-99CB-3DA60EF76C36@gmail.com> <0124D27A-38CB-4ACE-8CCB-604C96476657@deadorange.com> <57c63afe0902071016y75030c14i8674776569da07bf@mail.gmail.com> Message-ID: On 07/02/2009, at 1:16 PM, David Chelimsky wrote: > On Sat, Feb 7, 2009 at 9:59 AM, Nick Hoffman > wrote: >> When writing Cucumber stories and features for controllers, should >> you cover >> every edge case? For example, should you write stories that feed >> bad or >> missing data to your controllers, or should that be left to RSpec? > > Depends on the team and who can read what and who cares about what. > > In most cases, Cucumber is a significantly better > developer/stakeholder collaboration tool than RSpec is. If your > stakeholders trust you to cover the edge cases, then they don't need > to be in cucumber, but they certainly can be. > > IASTDH, > David Makes sense. Thanks for the clarification. By the way, what on Earth is IASTDH? A few Google searches later, I'm still none the wiser. From wolfmanjm at gmail.com Sat Feb 7 21:34:23 2009 From: wolfmanjm at gmail.com (Jim Morris) Date: Sat, 7 Feb 2009 18:34:23 -0800 (PST) Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: <498B110A.4020904@benmabey.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <498B110A.4020904@benmabey.com> Message-ID: Yet another way to do fixtures/factories is a hybrid that I outline in my blog, its basically what I do. http://blog.wolfman.com/posts/42 Basically I can't use the existing libraries as I am not using ActiveRecord. On Feb 5, 8:17?am, Ben Mabey wrote: > David Chelimsky wrote: > > I highly recommend this blog post by Jay Fields: > >http://blog.jayfields.com/2009/02/thoughts-on-developer-testing.html > > > Cheers, > > David > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > Great post. ?Very down to earth and realistic. > > This post raised a question for me. ?Jay talks about how the pattern > Object Mother gave way to Test Data Builders. ?I use Fixjour ("Word to > your object mother")[1], and other similar projects in my apps to > provide a set of sane default attributes for my models. ?You can then > easily override those defaults by passing in a hash with the values that > you need for the test. ?After reading Nat's post about Object Mother vs > Test Data Builders[2] , I have come to the conclusion that the "Object > Mother" libs that are popular in ruby land (i.e. Fixjour, Factory Girl) > are really more in line with the Test Data Builder pattern. ?Does > everyone agree with this conclusion or am I missing something? ?It may > be that I just use it differently, but according to Nat's post Test > Builders provide a sane set of defaults that you can then explicitly > override like so: > > Invoice invoiceWithNoPostcode = new InvoiceBuilder() > ? ? .withRecipient(new RecipientBuilder() > ? ? ? ? .withAddress(new AddressBuilder() > ? ? ? ? ? ? .withNoPostcode() > ? ? ? ? ? ? .build()) > ? ? ? ? .build()) > ? ? .build(); > > Well.. this looks a lot like what I do in Ruby (but a lot more verbose): > > invoice_with_no_postcode = new_invoice(:recipient => > new_recipient(:address => new_address(:postcode => nil))) > > Nat points out that problems with Object Mother arise when people start > adding factory methods to deal with the edge cases, such as > ObjectMother.new_invoice_with_no_postal_code. ?I totally agree that this > would be a problem since such abstraction results in hard to follow > tests (this is why I hate fixtures actually). ?From the projects I have > worked on I haven't seen the Object Mother libs abused this way and they > are used more like a Test Data Builder. ?The only difference I see is in > implementation, meaning the ruby libs tend to group all the factory > methods on one object or module just like Object Mother, while the > pattern Nat describes uses a separate builder class for each object. ?I > think this is really just details though and results from Ruby's > differences from Java. > > Any thoughts? ?Are Ruby's Object Mothers really Test Data Builders? > > -Ben > > 1.http://github.com/nakajima/fixjour/tree/master > 2.http://nat.truemesh.com/archives/000714.html > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From wolfmanjm at gmail.com Sat Feb 7 21:36:05 2009 From: wolfmanjm at gmail.com (Jim Morris) Date: Sat, 7 Feb 2009 18:36:05 -0800 (PST) Subject: [rspec-users] Fixjour and others In-Reply-To: <498DB3D2.6000809@shopwatch.org> References: <5017299bb2890a5d4dcb3d9e5fc8427e@ruby-forum.com> <498C288B.8030004@railsnewbie.com> <498DB3D2.6000809@shopwatch.org> Message-ID: <6220c7d9-43bc-4f0e-889e-4dc85a22740c@g1g2000pra.googlegroups.com> Well sometimes one can't use an existing library becuase of some reason or other, like in my case not using ActiveRecord. So I came up with yet another way to do it, I think it is a hyvrid between Fixtures and Factories. outlined here... http://blog.wolfman.com/posts/42 On Feb 7, 8:16?am, Jay Levitt wrote: > Scott Taylor wrote: > > ?> [ > > > "So my main objective with fixjour is to have the simplest > > implementation possible, with a very simple API. So it will create the > > following methods: new_[model], create_[model], and > > valid_[model]_attributes." > > This seems to be an anti-pattern in the Rails community: > > "I can't follow Library X, so I'll write Library Y, which is lightweight and > obeys YAGNI, and is the simplest possible implementation." > > I confess: I've done it too. ?But it's nearly always the wrong approach. ?If > you can't follow Library X's *implementation*, but you agree with its > *philosophies*, refactor it! > > Competing libraries should have different goals, different purposes, > different anything other than just "cleaner code". ?If Merb can refactor > itself into Rails, you can do it with fixtures, authentication, file > attachments, or what have you. ?As easy as Github makes forking, the choice > of libraries should no longer be driven by "this one was updated most > recently" or "this one uses the most recent design idioms". > > As someone wrote recently: The minute you start coding, you're writing > legacy code. > > Jay Levitt > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sat Feb 7 22:45:34 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 7 Feb 2009 21:45:34 -0600 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <498B110A.4020904@benmabey.com> <810a540e0902051620n6979f773kc9903fa0d9e9c17c@mail.gmail.com> <5e105b9bc212a8013a9030a1b5983f54@ruby-forum.com> <1fb4df0902060950k11906ccfgd29a5182ba559051@mail.gmail.com> <8A1D92FE-81CC-4BC4-99CB-3DA60EF76C36@gmail.com> <0124D27A-38CB-4ACE-8CCB-604C96476657@deadorange.com> <57c63afe0902071016y75030c14i8674776569da07bf@mail.gmail.com> Message-ID: <57c63afe0902071945v38a8ec89s3c8b9509c5cbf0d7@mail.gmail.com> On Sat, Feb 7, 2009 at 8:05 PM, Nick Hoffman wrote: > On 07/02/2009, at 1:16 PM, David Chelimsky wrote: >> >> On Sat, Feb 7, 2009 at 9:59 AM, Nick Hoffman wrote: >>> >>> When writing Cucumber stories and features for controllers, should you >>> cover >>> every edge case? For example, should you write stories that feed bad or >>> missing data to your controllers, or should that be left to RSpec? >> >> Depends on the team and who can read what and who cares about what. >> >> In most cases, Cucumber is a significantly better >> developer/stakeholder collaboration tool than RSpec is. If your >> stakeholders trust you to cover the edge cases, then they don't need >> to be in cucumber, but they certainly can be. >> >> IASTDH, >> David > > Makes sense. Thanks for the clarification. > > By the way, what on Earth is IASTDH? A few Google searches later, I'm still > none the wiser. I made it up. I was about to write HTH, but I was sure it did not help, hence IASTDH - inconsistent though - IA for I am, but D for didn't, so it should either be ISTDH or IASTDNH. HTH, David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From rem.gagnon at gmail.com Sun Feb 8 07:44:44 2009 From: rem.gagnon at gmail.com (Remi Gagnon) Date: Sun, 8 Feb 2009 07:44:44 -0500 Subject: [rspec-users] How to spec within a block? Message-ID: I want to mock to Model.to_xml but not his block. How to do it? Here is what I have (sorry for the formatting) output = @detenteur.to_xml( :skip_types => false, :skip_instruct => true, :dasherize => false, :only => [:inte_no] ) do |xml_detenteur| p xml_detenteur.intervenant_adresses.class.to_s xml_detenteur.intervenant_adresses do p "INTERVENANT ADRESSES" get_object_xml( @detenteur.intervenant_adresses, @detenteur.intervenant_adresses.obtenir_adresses_vigueur, {:builder => xml_detenteur, :skip_instruct => true, :skip_types => false, :dasherize => false, :except => [:inte_no]}) end end So I want to run specs within some blocks like that. Any recipes? Thank you R?mi -------------- next part -------------- An HTML attachment was scrubbed... URL: From rem.gagnon at gmail.com Sun Feb 8 07:48:21 2009 From: rem.gagnon at gmail.com (Remi Gagnon) Date: Sun, 8 Feb 2009 07:48:21 -0500 Subject: [rspec-users] How to return a value passed by ref to a method Message-ID: Hi, I have a recursive method and I want to mock a var passed by ref. Object.should_receive(:my_method).and_return"by_ref"(@value) Something like that. Any idea? R?mi -------------- next part -------------- An HTML attachment was scrubbed... URL: From patnakajima at gmail.com Sun Feb 8 09:01:49 2009 From: patnakajima at gmail.com (Pat Nakajima) Date: Sun, 8 Feb 2009 06:01:49 -0800 (PST) Subject: [rspec-users] Fixjour and others In-Reply-To: <6220c7d9-43bc-4f0e-889e-4dc85a22740c@g1g2000pra.googlegroups.com> References: <5017299bb2890a5d4dcb3d9e5fc8427e@ruby-forum.com> <498C288B.8030004@railsnewbie.com> <498DB3D2.6000809@shopwatch.org> <6220c7d9-43bc-4f0e-889e-4dc85a22740c@g1g2000pra.googlegroups.com> Message-ID: <15bf61cc-f958-40b8-8aa1-84c1eb096f5e@x38g2000yqj.googlegroups.com> I started writing up a response about why I wrote Fixjour, and why I want it to be its own project, but it got really long. Here's a Markdownified gist: http://gist.github.com/60389. For the record, I think FR is a great tool (I link to it in Fixjour's README), it's just not for me. Read the gist above and you'll be able to see why. Pat On Feb 7, 9:36?pm, Jim Morris wrote: > Well sometimes one can't use an existing ?library becuase of some > reason or other, like in my case not using ActiveRecord. > > So I came up with yet another way to do it, I think it is a hyvrid > between Fixtures and Factories. > > outlined here... > > http://blog.wolfman.com/posts/42 > > On Feb 7, 8:16?am, Jay Levitt wrote: > > > Scott Taylor wrote: > > > ?> [ > > > > "So my main objective with fixjour is to have the simplest > > > implementation possible, with a very simple API. So it will create the > > > following methods: new_[model], create_[model], and > > > valid_[model]_attributes." > > > This seems to be an anti-pattern in the Rails community: > > > "I can't follow Library X, so I'll write Library Y, which is lightweight and > > obeys YAGNI, and is the simplest possible implementation." > > > I confess: I've done it too. ?But it's nearly always the wrong approach. ?If > > you can't follow Library X's *implementation*, but you agree with its > > *philosophies*, refactor it! > > > Competing libraries should have different goals, different purposes, > > different anything other than just "cleaner code". ?If Merb can refactor > > itself into Rails, you can do it with fixtures, authentication, file > > attachments, or what have you. ?As easy as Github makes forking, the choice > > of libraries should no longer be driven by "this one was updated most > > recently" or "this one uses the most recent design idioms". > > > As someone wrote recently: The minute you start coding, you're writing > > legacy code. > > > Jay Levitt > > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From biot023 at gmail.com Sun Feb 8 09:11:03 2009 From: biot023 at gmail.com (doug livesey) Date: Sun, 8 Feb 2009 14:11:03 +0000 Subject: [rspec-users] Speccing the format portion of a controller In-Reply-To: <57c63afe0902071054s2b36417fiaa06bb29402025c5@mail.gmail.com> References: <50873a360902070316jba97fadtac033703550a40cc@mail.gmail.com> <810a540e0902070820y1968975cu24bf34678923ec39@mail.gmail.com> <57c63afe0902071054s2b36417fiaa06bb29402025c5@mail.gmail.com> Message-ID: <50873a360902080611q5fe7505bgfa7213974997519c@mail.gmail.com> Groovy!Cheers, Doug. 2009/2/7 David Chelimsky > On Sat, Feb 7, 2009 at 10:20 AM, Pat Maddox wrote: > > On Sat, Feb 7, 2009 at 3:16 AM, doug livesey wrote:. > > > > def do_get > > get :index, :format => "xml" > > end > > > > should work. Notice it's a string instead of symbol. > > I should change the gen'd specs then. That's simpler, ay? > > > > > Pat > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sun Feb 8 09:51:21 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 8 Feb 2009 08:51:21 -0600 Subject: [rspec-users] How to spec within a block? In-Reply-To: References: Message-ID: <57c63afe0902080651l1e989880p1a813b812f726695@mail.gmail.com> On Sun, Feb 8, 2009 at 6:44 AM, Remi Gagnon wrote: > I want to mock to Model.to_xml but not his block. How to do it? > > Here is what I have (sorry for the formatting) > > output = @detenteur.to_xml( :skip_types => false, :skip_instruct => > true, :dasherize => false, :only => [:inte_no] ) do |xml_detenteur| > > p xml_detenteur.intervenant_adresses.class.to_s > xml_detenteur.intervenant_adresses do > p "INTERVENANT ADRESSES" > get_object_xml( @detenteur.intervenant_adresses, > @detenteur.intervenant_adresses.obtenir_adresses_vigueur, {:builder => > xml_detenteur, :skip_instruct => true, :skip_types => false, :dasherize => > false, :except => [:inte_no]}) > > end > end > > So I want to run specs within some blocks like that. > > Any recipes? > > Thank you I'm not sure I understand your goal here. Can you show us what the spec you'd like to be able to write? > > R?mi > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sun Feb 8 10:02:52 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 8 Feb 2009 09:02:52 -0600 Subject: [rspec-users] How to return a value passed by ref to a method In-Reply-To: References: Message-ID: <57c63afe0902080702s651f87enfe880aef3c2bac8e@mail.gmail.com> On Sun, Feb 8, 2009 at 6:48 AM, Remi Gagnon wrote: > Hi, > > I have a recursive method and I want to mock a var passed by ref. > Object.should_receive(:my_method).and_return"by_ref"(@value) > > Something like that. > > Any idea? AFAIK, Ruby has no language construct for "by_ref/by_val," so I'm not sure what you're getting at here. Are you saying that you want the method to return the value of an @value instance variable in the object? > > R?mi > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From nick at deadorange.com Sun Feb 8 10:22:22 2009 From: nick at deadorange.com (Nick Hoffman) Date: Sun, 8 Feb 2009 10:22:22 -0500 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: <57c63afe0902071945v38a8ec89s3c8b9509c5cbf0d7@mail.gmail.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <498B110A.4020904@benmabey.com> <810a540e0902051620n6979f773kc9903fa0d9e9c17c@mail.gmail.com> <5e105b9bc212a8013a9030a1b5983f54@ruby-forum.com> <1fb4df0902060950k11906ccfgd29a5182ba559051@mail.gmail.com> <8A1D92FE-81CC-4BC4-99CB-3DA60EF76C36@gmail.com> <0124D27A-38CB-4ACE-8CCB-604C96476657@deadorange.com> <57c63afe0902071016y75030c14i8674776569da07bf@mail.gmail.com> <57c63afe0902071945v38a8ec89s3c8b9509c5cbf0d7@mail.gmail.com> Message-ID: <318E6099-8772-4E50-8F65-7CDB2FCFC5C3@deadorange.com> On 07/02/2009, at 10:45 PM, David Chelimsky wrote: > On Sat, Feb 7, 2009 at 8:05 PM, Nick Hoffman > wrote: >> On 07/02/2009, at 1:16 PM, David Chelimsky wrote: >>> >>> On Sat, Feb 7, 2009 at 9:59 AM, Nick Hoffman >>> wrote: >>>> >>>> When writing Cucumber stories and features for controllers, >>>> should you >>>> cover >>>> every edge case? For example, should you write stories that feed >>>> bad or >>>> missing data to your controllers, or should that be left to RSpec? >>> >>> Depends on the team and who can read what and who cares about what. >>> >>> In most cases, Cucumber is a significantly better >>> developer/stakeholder collaboration tool than RSpec is. If your >>> stakeholders trust you to cover the edge cases, then they don't need >>> to be in cucumber, but they certainly can be. >>> >>> IASTDH, >>> David >> >> Makes sense. Thanks for the clarification. >> >> By the way, what on Earth is IASTDH? A few Google searches later, >> I'm still >> none the wiser. > > I made it up. I was about to write HTH, but I was sure it did not > help, hence IASTDH - inconsistent though - IA for I am, but D for > didn't, so it should either be ISTDH or IASTDNH. > > HTH, > David Hah! Actually, it was helpful. I was wondering if there's a clear-cut rule that people follow for dealing with edge cases, and you said "do what works for your situation". While some people may not appreciate that answer, it's "correct", and probably the best thing to do, because each team is different. -Nick From rem.gagnon at gmail.com Sun Feb 8 10:26:00 2009 From: rem.gagnon at gmail.com (Remi Gagnon) Date: Sun, 8 Feb 2009 10:26:00 -0500 Subject: [rspec-users] How to return a value passed by ref to a method In-Reply-To: <57c63afe0902080702s651f87enfe880aef3c2bac8e@mail.gmail.com> References: <57c63afe0902080702s651f87enfe880aef3c2bac8e@mail.gmail.com> Message-ID: Hello, This is a question from one of my teammate, I'll revalidate tomorrow with him what is his issue. Thank you R?mi On Sun, Feb 8, 2009 at 10:02 AM, David Chelimsky wrote: > On Sun, Feb 8, 2009 at 6:48 AM, Remi Gagnon wrote: > > Hi, > > > > I have a recursive method and I want to mock a var passed by ref. > > Object.should_receive(:my_method).and_return"by_ref"(@value) > > > > Something like that. > > > > Any idea? > > AFAIK, Ruby has no language construct for "by_ref/by_val," so I'm not > sure what you're getting at here. Are you saying that you want the > method to return the value of an @value instance variable in the > object? > > > > > R?mi > > > > _______________________________________________ > > 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 nick at deadorange.com Sun Feb 8 10:28:43 2009 From: nick at deadorange.com (Nick Hoffman) Date: Sun, 8 Feb 2009 10:28:43 -0500 Subject: [rspec-users] How to spec within a block? In-Reply-To: References: Message-ID: <2886C591-17D5-480C-A437-22F31EF8A7E3@deadorange.com> On 08/02/2009, at 7:44 AM, Remi Gagnon wrote: > I want to mock to Model.to_xml but not his block. How to do it? > > Here is what I have (sorry for the formatting) > > output = @detenteur.to_xml( :skip_types => > false, :skip_instruct => true, :dasherize => false, :only => > [:inte_no] ) do |xml_detenteur| > > p xml_detenteur.intervenant_adresses.class.to_s > xml_detenteur.intervenant_adresses do > p "INTERVENANT ADRESSES" > get_object_xml( @detenteur.intervenant_adresses, > @detenteur.intervenant_adresses.obtenir_adresses_vigueur, {:builder > => xml_detenteur, :skip_instruct => true, :skip_types => > false, :dasherize => false, :except => [:inte_no]}) > > end > end > So I want to run specs within some blocks like that. > > Any recipes? > > Thank you > > R?mi Hi R?mi. If you show us what you've written so far, we can give you some tips. Cheers, Nick From dchelimsky at gmail.com Sun Feb 8 10:49:10 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 8 Feb 2009 09:49:10 -0600 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: <318E6099-8772-4E50-8F65-7CDB2FCFC5C3@deadorange.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <5e105b9bc212a8013a9030a1b5983f54@ruby-forum.com> <1fb4df0902060950k11906ccfgd29a5182ba559051@mail.gmail.com> <8A1D92FE-81CC-4BC4-99CB-3DA60EF76C36@gmail.com> <0124D27A-38CB-4ACE-8CCB-604C96476657@deadorange.com> <57c63afe0902071016y75030c14i8674776569da07bf@mail.gmail.com> <57c63afe0902071945v38a8ec89s3c8b9509c5cbf0d7@mail.gmail.com> <318E6099-8772-4E50-8F65-7CDB2FCFC5C3@deadorange.com> Message-ID: <57c63afe0902080749m3325f3c8gd3238ae04a6b99b@mail.gmail.com> On Sun, Feb 8, 2009 at 9:22 AM, Nick Hoffman wrote: > On 07/02/2009, at 10:45 PM, David Chelimsky wrote: >> >> On Sat, Feb 7, 2009 at 8:05 PM, Nick Hoffman wrote: >>> >>> On 07/02/2009, at 1:16 PM, David Chelimsky wrote: >>>> >>>> On Sat, Feb 7, 2009 at 9:59 AM, Nick Hoffman >>>> wrote: >>>>> >>>>> When writing Cucumber stories and features for controllers, should you >>>>> cover >>>>> every edge case? For example, should you write stories that feed bad or >>>>> missing data to your controllers, or should that be left to RSpec? >>>> >>>> Depends on the team and who can read what and who cares about what. >>>> >>>> In most cases, Cucumber is a significantly better >>>> developer/stakeholder collaboration tool than RSpec is. If your >>>> stakeholders trust you to cover the edge cases, then they don't need >>>> to be in cucumber, but they certainly can be. >>>> >>>> IASTDH, >>>> David >>> >>> Makes sense. Thanks for the clarification. >>> >>> By the way, what on Earth is IASTDH? A few Google searches later, I'm >>> still >>> none the wiser. >> >> I made it up. I was about to write HTH, but I was sure it did not >> help, hence IASTDH - inconsistent though - IA for I am, but D for >> didn't, so it should either be ISTDH or IASTDNH. >> >> HTH, >> David > > Hah! Actually, it was helpful. I was wondering if there's a clear-cut rule > that people follow for dealing with edge cases, and you said "do what works > for your situation". While some people may not appreciate that answer, it's > "correct", and probably the best thing to do, because each team is > different. I think I have a new slogan: Silver Bullets Kill WDYT? > -Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sun Feb 8 10:50:26 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 8 Feb 2009 09:50:26 -0600 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: <57c63afe0902080749m3325f3c8gd3238ae04a6b99b@mail.gmail.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <1fb4df0902060950k11906ccfgd29a5182ba559051@mail.gmail.com> <8A1D92FE-81CC-4BC4-99CB-3DA60EF76C36@gmail.com> <0124D27A-38CB-4ACE-8CCB-604C96476657@deadorange.com> <57c63afe0902071016y75030c14i8674776569da07bf@mail.gmail.com> <57c63afe0902071945v38a8ec89s3c8b9509c5cbf0d7@mail.gmail.com> <318E6099-8772-4E50-8F65-7CDB2FCFC5C3@deadorange.com> <57c63afe0902080749m3325f3c8gd3238ae04a6b99b@mail.gmail.com> Message-ID: <57c63afe0902080750q5dd898cfra5f584e7fc8ffd04@mail.gmail.com> On Sun, Feb 8, 2009 at 9:49 AM, David Chelimsky wrote: > On Sun, Feb 8, 2009 at 9:22 AM, Nick Hoffman wrote: >> On 07/02/2009, at 10:45 PM, David Chelimsky wrote: >>> >>> On Sat, Feb 7, 2009 at 8:05 PM, Nick Hoffman wrote: >>>> >>>> On 07/02/2009, at 1:16 PM, David Chelimsky wrote: >>>>> >>>>> On Sat, Feb 7, 2009 at 9:59 AM, Nick Hoffman >>>>> wrote: >>>>>> >>>>>> When writing Cucumber stories and features for controllers, should you >>>>>> cover >>>>>> every edge case? For example, should you write stories that feed bad or >>>>>> missing data to your controllers, or should that be left to RSpec? >>>>> >>>>> Depends on the team and who can read what and who cares about what. >>>>> >>>>> In most cases, Cucumber is a significantly better >>>>> developer/stakeholder collaboration tool than RSpec is. If your >>>>> stakeholders trust you to cover the edge cases, then they don't need >>>>> to be in cucumber, but they certainly can be. >>>>> >>>>> IASTDH, >>>>> David >>>> >>>> Makes sense. Thanks for the clarification. >>>> >>>> By the way, what on Earth is IASTDH? A few Google searches later, I'm >>>> still >>>> none the wiser. >>> >>> I made it up. I was about to write HTH, but I was sure it did not >>> help, hence IASTDH - inconsistent though - IA for I am, but D for >>> didn't, so it should either be ISTDH or IASTDNH. >>> >>> HTH, >>> David >> >> Hah! Actually, it was helpful. I was wondering if there's a clear-cut rule >> that people follow for dealing with edge cases, and you said "do what works >> for your situation". While some people may not appreciate that answer, it's >> "correct", and probably the best thing to do, because each team is >> different. > > I think I have a new slogan: > > Silver Bullets Kill > > WDYT? Shoulda googled that first :) How about Silver Bullets Kill Software (SBKS) > >> -Nick >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > From ben at benmabey.com Sun Feb 8 13:31:52 2009 From: ben at benmabey.com (Ben Mabey) Date: Sun, 08 Feb 2009 11:31:52 -0700 Subject: [rspec-users] [OT] Silver Bullets (was Object Mother vs Test Data Builder) In-Reply-To: <57c63afe0902080749m3325f3c8gd3238ae04a6b99b@mail.gmail.com> References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <5e105b9bc212a8013a9030a1b5983f54@ruby-forum.com> <1fb4df0902060950k11906ccfgd29a5182ba559051@mail.gmail.com> <8A1D92FE-81CC-4BC4-99CB-3DA60EF76C36@gmail.com> <0124D27A-38CB-4ACE-8CCB-604C96476657@deadorange.com> <57c63afe0902071016y75030c14i8674776569da07bf@mail.gmail.com> <57c63afe0902071945v38a8ec89s3c8b9509c5cbf0d7@mail.gmail.com> <318E6099-8772-4E50-8F65-7CDB2FCFC5C3@deadorange.com> <57c63afe0902080749m3325f3c8gd3238ae04a6b99b@mail.gmail.com> Message-ID: <498F2518.7090301@benmabey.com> David Chelimsky wrote: > On Sun, Feb 8, 2009 at 9:22 AM, Nick Hoffman wrote: > >> On 07/02/2009, at 10:45 PM, David Chelimsky wrote: >> >>> On Sat, Feb 7, 2009 at 8:05 PM, Nick Hoffman wrote: >>> >>>> On 07/02/2009, at 1:16 PM, David Chelimsky wrote: >>>> >>>>> On Sat, Feb 7, 2009 at 9:59 AM, Nick Hoffman >>>>> wrote: >>>>> >>>>>> When writing Cucumber stories and features for controllers, should you >>>>>> cover >>>>>> every edge case? For example, should you write stories that feed bad or >>>>>> missing data to your controllers, or should that be left to RSpec? >>>>>> >>>>> Depends on the team and who can read what and who cares about what. >>>>> >>>>> In most cases, Cucumber is a significantly better >>>>> developer/stakeholder collaboration tool than RSpec is. If your >>>>> stakeholders trust you to cover the edge cases, then they don't need >>>>> to be in cucumber, but they certainly can be. >>>>> >>>>> IASTDH, >>>>> David >>>>> >>>> Makes sense. Thanks for the clarification. >>>> >>>> By the way, what on Earth is IASTDH? A few Google searches later, I'm >>>> still >>>> none the wiser. >>>> >>> I made it up. I was about to write HTH, but I was sure it did not >>> help, hence IASTDH - inconsistent though - IA for I am, but D for >>> didn't, so it should either be ISTDH or IASTDNH. >>> >>> HTH, >>> David >>> >> Hah! Actually, it was helpful. I was wondering if there's a clear-cut rule >> that people follow for dealing with edge cases, and you said "do what works >> for your situation". While some people may not appreciate that answer, it's >> "correct", and probably the best thing to do, because each team is >> different. >> > > I think I have a new slogan: > > Silver Bullets Kill > > WDYT? > > I like it! On a related note I recently came across a quote from Linving Zen[1] that instantly made me think of "best practices". Just like a silver bullet a "best practice" dogmatically stuck to can stifle innovation and can cause unneeded pain. In the end context is king.. but enough of my yammering, here is the quote: "No one can define them or draw up a system around them. That is where we should exercise our judgment....Use depends for each one of us on the place and circumstances. If we were to codify the laws concerning it they might soon become a great bondage for us." Isn't that great!? So how about this for a motto: Best Practices as laws lead to bondage. FYI, I came across this quote on the Presentation Zen[2] site. If you are going to be giving a presentation I highly recommend you check this site out. -Ben 1. http://www.amazon.com/exec/obidos/tg/detail/-/0802131360/ 2.http://www.presentationzen.com/presentationzen/2005/09/whats_good_powe/comments/page/3/ >> -Nick >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From scott at railsnewbie.com Sun Feb 8 15:13:24 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Sun, 08 Feb 2009 15:13:24 -0500 Subject: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing) In-Reply-To: References: <57c63afe0902042105h61ed252bt5997a0eb6053f6f6@mail.gmail.com> <498B110A.4020904@benmabey.com> Message-ID: <498F3CE4.2040900@railsnewbie.com> Jim Morris wrote: > Yet another way to do fixtures/factories is a hybrid that I outline in > my blog, its basically what I do. > > http://blog.wolfman.com/posts/42 > > Basically I can't use the existing libraries as I am not using > ActiveRecord. > I'd be interested in supporting Datamapper, Sequel, and the like. I'll look into for version 3 of FixtureReplacement. Scott > > On Feb 5, 8:17 am, Ben Mabey wrote: > >> David Chelimsky wrote: >> >>> I highly recommend this blog post by Jay Fields: >>> http://blog.jayfields.com/2009/02/thoughts-on-developer-testing.html >>> >>> Cheers, >>> David >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-us... at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> Great post. Very down to earth and realistic. >> >> This post raised a question for me. Jay talks about how the pattern >> Object Mother gave way to Test Data Builders. I use Fixjour ("Word to >> your object mother")[1], and other similar projects in my apps to >> provide a set of sane default attributes for my models. You can then >> easily override those defaults by passing in a hash with the values that >> you need for the test. After reading Nat's post about Object Mother vs >> Test Data Builders[2] , I have come to the conclusion that the "Object >> Mother" libs that are popular in ruby land (i.e. Fixjour, Factory Girl) >> are really more in line with the Test Data Builder pattern. Does >> everyone agree with this conclusion or am I missing something? It may >> be that I just use it differently, but according to Nat's post Test >> Builders provide a sane set of defaults that you can then explicitly >> override like so: >> >> Invoice invoiceWithNoPostcode = new InvoiceBuilder() >> .withRecipient(new RecipientBuilder() >> .withAddress(new AddressBuilder() >> .withNoPostcode() >> .build()) >> .build()) >> .build(); >> >> Well.. this looks a lot like what I do in Ruby (but a lot more verbose): >> >> invoice_with_no_postcode = new_invoice(:recipient => >> new_recipient(:address => new_address(:postcode => nil))) >> >> Nat points out that problems with Object Mother arise when people start >> adding factory methods to deal with the edge cases, such as >> ObjectMother.new_invoice_with_no_postal_code. I totally agree that this >> would be a problem since such abstraction results in hard to follow >> tests (this is why I hate fixtures actually). From the projects I have >> worked on I haven't seen the Object Mother libs abused this way and they >> are used more like a Test Data Builder. The only difference I see is in >> implementation, meaning the ruby libs tend to group all the factory >> methods on one object or module just like Object Mother, while the >> pattern Nat describes uses a separate builder class for each object. I >> think this is really just details though and results from Ruby's >> differences from Java. >> >> Any thoughts? Are Ruby's Object Mothers really Test Data Builders? >> >> -Ben >> >> 1.http://github.com/nakajima/fixjour/tree/master >> 2.http://nat.truemesh.com/archives/000714.html >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From scott at railsnewbie.com Sun Feb 8 15:21:24 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Sun, 08 Feb 2009 15:21:24 -0500 Subject: [rspec-users] How to return a value passed by ref to a method In-Reply-To: References: Message-ID: <498F3EC4.8020702@railsnewbie.com> Remi Gagnon wrote: > Hi, > > I have a recursive method and I want to mock a var passed by ref. > Object.should_receive(:my_method).and_return"by_ref"(@value) > Often a way to spec a recursive function is to alias it, and have the recursive call call the alias. So if you want to check the recursion, you could do something like this (in a lispy-type ruby): http://gist.github.com/60491 Scott From scott at railsnewbie.com Sun Feb 8 15:44:07 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Sun, 08 Feb 2009 15:44:07 -0500 Subject: [rspec-users] Fixjour and others In-Reply-To: <15bf61cc-f958-40b8-8aa1-84c1eb096f5e@x38g2000yqj.googlegroups.com> References: <5017299bb2890a5d4dcb3d9e5fc8427e@ruby-forum.com> <498C288B.8030004@railsnewbie.com> <498DB3D2.6000809@shopwatch.org> <6220c7d9-43bc-4f0e-889e-4dc85a22740c@g1g2000pra.googlegroups.com> <15bf61cc-f958-40b8-8aa1-84c1eb096f5e@x38g2000yqj.googlegroups.com> Message-ID: <498F4417.4090209@railsnewbie.com> Pat Nakajima wrote: > I started writing up a response about why I wrote Fixjour, and why I > want it to be its own project, but it got really long. Here's a > Markdownified gist: http://gist.github.com/60389. > > For the record, I think FR is a great tool (I link to it in Fixjour's > README), it's just not for me. Read the gist above and you'll be able > to see why. > > Pat > +1 Nice post, Pat. I think this post belongs somewhere on the c2 wiki. Although, I still disagree with the create_admin example. Here's a rundown of the different syntaxes: http://gist.github.com/60497 I'd prefer to have the flexibility there. In FR you *could* use create_user(:admin => true) every time, which works well when that's the only attribute given. When extra attributes are needed as well, I think the test can become too busy. But I do think you are on point with this comment: "If I did feel the need for a create_admin helper, it might be a sign that I need an Admin model." I'm not opposed to named fixtures per-se, I'm opposed to named fixtures where the *intent* of the spec becomes obfuscated by the attributes. So why does user_joana_who_has_19_outstand_mortgage_payments also have an invalid email address? Who knows. But with create_admin(:other_flag => true) the meaning of the spec is probably going to be clear, even if the internal implementation isn't. And ultimately, my idea behind a good spec doesn't reveal an internal implementation (black box testing has always been more of my forte) . I'm less gung ho about supporting attr_protected. I can see it going both ways. Thanks for the interesting post, Scott > On Feb 7, 9:36 pm, Jim Morris wrote: > >> Well sometimes one can't use an existing library becuase of some >> reason or other, like in my case not using ActiveRecord. >> >> So I came up with yet another way to do it, I think it is a hyvrid >> between Fixtures and Factories. >> >> outlined here... >> >> http://blog.wolfman.com/posts/42 >> >> On Feb 7, 8:16 am, Jay Levitt wrote: >> >> >>> Scott Taylor wrote: >>> >>> > [ >>> >>>> "So my main objective with fixjour is to have the simplest >>>> implementation possible, with a very simple API. So it will create the >>>> following methods: new_[model], create_[model], and >>>> valid_[model]_attributes." >>>> >>> This seems to be an anti-pattern in the Rails community: >>> >>> "I can't follow Library X, so I'll write Library Y, which is lightweight and >>> obeys YAGNI, and is the simplest possible implementation." >>> >>> I confess: I've done it too. But it's nearly always the wrong approach. If >>> you can't follow Library X's *implementation*, but you agree with its >>> *philosophies*, refactor it! >>> >>> Competing libraries should have different goals, different purposes, >>> different anything other than just "cleaner code". If Merb can refactor >>> itself into Rails, you can do it with fixtures, authentication, file >>> attachments, or what have you. As easy as Github makes forking, the choice >>> of libraries should no longer be driven by "this one was updated most >>> recently" or "this one uses the most recent design idioms". >>> >>> As someone wrote recently: The minute you start coding, you're writing >>> legacy code. >>> >>> Jay Levitt >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Sun Feb 8 16:39:14 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 8 Feb 2009 21:39:14 +0000 Subject: [rspec-users] [RSpec] Setting a gem dep on rspec-rails In-Reply-To: <57c63afe0902071102q4058ab63vf6050dd6af3538a9@mail.gmail.com> References: <9CED04E8-7F30-4A1F-8996-FC0D350C9CCC@deadorange.com> <810a540e0902071027x53abfe30y348579c44b517bac@mail.gmail.com> <57c63afe0902071102q4058ab63vf6050dd6af3538a9@mail.gmail.com> Message-ID: On 7 Feb 2009, at 19:02, David Chelimsky wrote: > On Sat, Feb 7, 2009 at 12:27 PM, Pat Maddox wrote: >> On Sat, Feb 7, 2009 at 9:30 AM, Nick Hoffman >> wrote: >>> With that said, I'm wondering what the accepted way to setup gem >>> dependencies on rspec and rspec-rails is. Should one not bother? >>> Should the >>> "config.gem" lines go in config/environments/test.rb ? >> >> I don't bother to use config.gem with rspec, but if you do then yes >> it >> should go in test.rb > > I don't either, but I'd like to get it working for ppl who want to > do it. > > If anybody w/ config.gem fu wants to help, that'd be awesome. I think this kinda works for us, but I had a couple of issues. One is the problem with rake files, which will depend on RSpec being visible to rake when it loads (which will ignore your vendor/gems folder). I fixed that by putting the rake file in a huge begin / rescue / end block so when the require 'spec' fails it doesn't load the rest of the rake tasks. Ugly but functional. The other issue was to do with a line in spec/rails which clobbers the value of RAILS_ENV to be 'test' whatever it was previously set to. We use an unconventional 'features' environment for running features (means I can run cukes at the same time as specs) but this was going hay-wire. I think David has put a patch for this into rspec-rails' head but I don't know if it's made it's way into a gem yet. So yeah, executive summary: What Pat said. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From matt at mattwynne.net Sun Feb 8 17:35:57 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 8 Feb 2009 22:35:57 +0000 Subject: [rspec-users] RecordNotFound bubbling thru to cucumber In-Reply-To: <69f72d390902060912p19ab0chf080da614b7de898@mail.gmail.com> References: <69f72d390902060912p19ab0chf080da614b7de898@mail.gmail.com> Message-ID: <6168DDB0-7188-4807-A84E-2381EE1CAAC1@mattwynne.net> Which version of cucumber / webrat are you using? On 6 Feb 2009, at 17:12, Jeff Talbot wrote: > Hello, > > I have a controller action that raises a RecordNotFound exception if > you're not allowed to see something. In my global application > controller (application.rb), I catch these and render the 404 > template. But when I run cucumber (using webrat), it's getting the > full stacktrace (the step blows up). Any ideas why? I have > consider_all_requests_local turned off in my test.rb. > > Jeff > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Matt Wynne http://blog.mattwynne.net http://www.songkick.com From matt at mattwynne.net Sun Feb 8 17:54:49 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 8 Feb 2009 22:54:49 +0000 Subject: [rspec-users] [OT] RSpec on MSDN Message-ID: <3E381F4C-1966-4C03-802C-D9B7E0594BF8@mattwynne.net> Just saw this twitter by and thought people might be interested: http://msdn.microsoft.com/en-us/magazine/dd434651.aspx Matt Wynne http://blog.mattwynne.net http://www.songkick.com From patnakajima at gmail.com Sun Feb 8 18:08:40 2009 From: patnakajima at gmail.com (Pat Nakajima) Date: Sun, 8 Feb 2009 18:08:40 -0500 Subject: [rspec-users] Fixjour and others In-Reply-To: <498F4417.4090209@railsnewbie.com> References: <5017299bb2890a5d4dcb3d9e5fc8427e@ruby-forum.com> <498C288B.8030004@railsnewbie.com> <498DB3D2.6000809@shopwatch.org> <6220c7d9-43bc-4f0e-889e-4dc85a22740c@g1g2000pra.googlegroups.com> <15bf61cc-f958-40b8-8aa1-84c1eb096f5e@x38g2000yqj.googlegroups.com> <498F4417.4090209@railsnewbie.com> Message-ID: <97ae2db00902081508u76d3a908u363b9e3cf367f898@mail.gmail.com> I think that named fixtures are primarily a matter of taste. With that being said, I did want to explain mine a bit. > When extra attributes are needed as well, I think the test can become too > busy. > A lot of time, I feel like processing the overrides hash is just a bandaid over something missing from the actual object model. Creating named fixtures is essentially the composition of these patches, which can lead to obfuscating object creation methods that evolve to mask smells in the real code (If I sound a bit dramatic, it's because I was recently on a "perfect storm" project where this happened). I know it's not really feasible to do everything through extra attributes though. I just prefer defining "scenario" methods elsewhere, that are totally detached from the builders, which should be as isolated as possible. > So why does user_joana_who_has_19_outstand_mortgage_payments also have an > invalid email address? Who knows. Totally. That's the kind of setup we were working with before deciding to rip it out. I'm less gung ho about supporting attr_protected. I can see it going both > ways. Today I was working on a side project and the abundance of attr_protected fields really started to stick in my crawl, so I started toying with a way to make it easier to create builders that integrate these fields without losing the fact that they are in fact special. The result is in a branch ( http://github.com/nakajima/fixjour/tree/protected-attributes) until I can figure out whether I like it or not, but the gist is this: define_builder(Person) do |klass, overrides| klass.protected :purchases klass.new :purchases => 0, :email => "foo at blah.com" end The protected fields can then be declared and passed to the creation methods like they were any other method, but we still get to see the fact that they're protected. I'd love to get some feedback on this style, as I'm a bit on the fence about it. Not such much because #protected means other things in Ruby, but because I'm not sure if it should be more explicit. Pat On Sun, Feb 8, 2009 at 3:44 PM, Scott Taylor wrote: > Pat Nakajima wrote: >> >> I started writing up a response about why I wrote Fixjour, and why I >> want it to be its own project, but it got really long. Here's a >> Markdownified gist: http://gist.github.com/60389. >> >> For the record, I think FR is a great tool (I link to it in Fixjour's >> README), it's just not for me. Read the gist above and you'll be able >> to see why. >> >> Pat >> > > +1 > > Nice post, Pat. I think this post belongs somewhere on the c2 wiki. > > Although, I still disagree with the create_admin example. Here's a rundown > of the different syntaxes: > > http://gist.github.com/60497 > > I'd prefer to have the flexibility there. In FR you *could* use > create_user(:admin => true) every time, which works well when that's the > only attribute given. When extra attributes are needed as well, I think the > test can become too busy. But I do think you are on point with this > comment: > > "If I did feel the need for a create_admin helper, it might be a sign that > I need an Admin model." > > I'm not opposed to named fixtures per-se, I'm opposed to named fixtures > where the *intent* of the spec becomes obfuscated by the attributes. So why > does user_joana_who_has_19_outstand_mortgage_payments also have an invalid > email address? Who knows. But with create_admin(:other_flag => true) the > meaning of the spec is probably going to be clear, even if the internal > implementation isn't. And ultimately, my idea behind a good spec doesn't > reveal an internal implementation (black box testing has always been more of > my forte) . > > I'm less gung ho about supporting attr_protected. I can see it going both > ways. > > Thanks for the interesting post, > > Scott > > > > > > > > > >> On Feb 7, 9:36 pm, Jim Morris wrote: >> >>> >>> Well sometimes one can't use an existing library becuase of some >>> reason or other, like in my case not using ActiveRecord. >>> >>> So I came up with yet another way to do it, I think it is a hyvrid >>> between Fixtures and Factories. >>> >>> outlined here... >>> >>> http://blog.wolfman.com/posts/42 >>> >>> On Feb 7, 8:16 am, Jay Levitt wrote: >>> >>> >>>> >>>> Scott Taylor wrote: >>>> > [ >>>> >>>>> >>>>> "So my main objective with fixjour is to have the simplest >>>>> implementation possible, with a very simple API. So it will create the >>>>> following methods: new_[model], create_[model], and >>>>> valid_[model]_attributes." >>>>> >>>> >>>> This seems to be an anti-pattern in the Rails community: >>>> "I can't follow Library X, so I'll write Library Y, which is >>>> lightweight and >>>> obeys YAGNI, and is the simplest possible implementation." >>>> I confess: I've done it too. But it's nearly always the wrong >>>> approach. If >>>> you can't follow Library X's *implementation*, but you agree with its >>>> *philosophies*, refactor it! >>>> Competing libraries should have different goals, different >>>> purposes, >>>> different anything other than just "cleaner code". If Merb can refactor >>>> itself into Rails, you can do it with fixtures, authentication, file >>>> attachments, or what have you. As easy as Github makes forking, the >>>> choice >>>> of libraries should no longer be driven by "this one was updated most >>>> recently" or "this one uses the most recent design idioms". >>>> As someone wrote recently: The minute you start coding, you're >>>> writing >>>> legacy code. >>>> Jay Levitt >>>> _______________________________________________ >>>> rspec-users mailing list >>>> >>>> rspec-us... at rubyforge.orghttp:// rubyforge.org/mailman/listinfo/rspec-users >>>> >>> >>> _______________________________________________ >>> rspec-users mailing list >>> >>> rspec-us... at rubyforge.orghttp:// rubyforge.org/mailman/listinfo/rspec-users >>> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Sun Feb 8 20:35:19 2009 From: lists at ruby-forum.com (Sergio Bayona) Date: Mon, 9 Feb 2009 02:35:19 +0100 Subject: [rspec-users] how can this pass? Message-ID: how could this test pass? I have: class PropertiesController < ApplicationController def show @property = Property.non_existing_method #causes a method missing error end end describe PropertiesController do def mock_property(stubs={}) @mock_property ||= mock_model(Property, stubs) end describe "responding to GET show" do it "should expose the requested property as @property" do Property.should_receive(:non_existing_method).and_return(mock_property) get :show, :id => "37" assigns[:property].should equal(mock_property) end end end SB-MacBook-Pro:test sb$ ruby ./spec/controllers/properties_controller_spec.rb . Finished in 0.134667 seconds 1 example, 0 failures why zero failures? more specifically, why would :non_existing_method return mock_property? and why would the assigns[:property] be equal to mock_property? did I eat some bad mushrooms? Sergio -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Sun Feb 8 20:56:01 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 8 Feb 2009 19:56:01 -0600 Subject: [rspec-users] how can this pass? In-Reply-To: References: Message-ID: <57c63afe0902081756y47f9a234w7464c0d7c89d055b@mail.gmail.com> On Sun, Feb 8, 2009 at 7:35 PM, Sergio Bayona wrote: > how could this test pass? > > I have: > > class PropertiesController < ApplicationController > def show > @property = Property.non_existing_method #causes a method missing > error > end > end > > > describe PropertiesController do > def mock_property(stubs={}) > @mock_property ||= mock_model(Property, stubs) > end > > describe "responding to GET show" do > it "should expose the requested property as @property" do > Property.should_receive(:non_existing_method).and_return(mock_property) * should_receive does not care if the object actually responds to the method - if you tell the object to expect it, it will respond to it * and_return is a declaration of a stub value to return when the object receives the message that it should receive Put that together, and this line says exactly what it looks like it says: The Property class should receive :non_existing_method, and when it does, it should return mock_property to whatever code is calling it. That make any sense now? > get :show, :id => "37" > assigns[:property].should equal(mock_property) > end > end > end > > SB-MacBook-Pro:test sb$ ruby > ./spec/controllers/properties_controller_spec.rb > . > > Finished in 0.134667 seconds > > 1 example, 0 failures > > > why zero failures? more specifically, why would :non_existing_method > return mock_property? and why would the assigns[:property] be equal to > mock_property? did I eat some bad mushrooms? > > Sergio > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Sun Feb 8 20:56:47 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 9 Feb 2009 02:56:47 +0100 Subject: [rspec-users] how can this pass? In-Reply-To: References: Message-ID: <8d961d900902081756y59f125edvcefd23cd53cf777a@mail.gmail.com> On Mon, Feb 9, 2009 at 2:35 AM, Sergio Bayona wrote: > how could this test pass? > > I have: > > class PropertiesController < ApplicationController > def show > @property = Property.non_existing_method #causes a method missing > error > end > end > > > describe PropertiesController do > def mock_property(stubs={}) > @mock_property ||= mock_model(Property, stubs) > end > > describe "responding to GET show" do > it "should expose the requested property as @property" do > Property.should_receive(:non_existing_method).and_return(mock_property) > get :show, :id => "37" > assigns[:property].should equal(mock_property) > end > end > end > > SB-MacBook-Pro:test sb$ ruby > ./spec/controllers/properties_controller_spec.rb > . > > Finished in 0.134667 seconds > > 1 example, 0 failures > > > why zero failures? more specifically, why would :non_existing_method > return mock_property? Because you have stubbed the class method Property#non_existing_method with: Property.should_receive(:non_existing_method).and_return(mock_property) It doesn't make any difference whether this method is already defined or not. Once the stub is set up, calls to the stubbed method will return what you told it to return. > and why would the assigns[:property] be equal to > mock_property? Because your controller's #show method assigns @property with the value returned from Property#non_existing_method (which you stubbed). > did I eat some bad mushrooms? > That I don't know. Why do you think this behaviour is strange/hallucinating? Aslak > Sergio > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From lists at ruby-forum.com Sun Feb 8 21:02:13 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 9 Feb 2009 03:02:13 +0100 Subject: [rspec-users] how can this pass? In-Reply-To: References: Message-ID: <996be7792ffc37105755976b72cc4e60@ruby-forum.com> Sergio Bayona wrote: > how could this test pass? > > I have: > > class PropertiesController < ApplicationController ... > why zero failures? more specifically, why would :non_existing_method > return mock_property? and why would the assigns[:property] be equal to > mock_property? did I eat some bad mushrooms? > > Sergio Ah... Maybe because of this? Property.should_receive(:non_existing_method).and_return(mock_property) -- Posted via http://www.ruby-forum.com/. From mflores at atlanware.com Sun Feb 8 21:09:43 2009 From: mflores at atlanware.com (=?ISO-8859-1?Q?Mat=EDas_Flores?=) Date: Mon, 9 Feb 2009 00:09:43 -0200 Subject: [rspec-users] how can this pass? In-Reply-To: References: Message-ID: <74e4981a0902081809n3ffdabd2sab4c63e2d2904bb5@mail.gmail.com> 2009/2/8 Sergio Bayona > how could this test pass? > > I have: > > class PropertiesController < ApplicationController > def show > @property = Property.non_existing_method #causes a method missing > error > end > end > > > describe PropertiesController do > def mock_property(stubs={}) > @mock_property ||= mock_model(Property, stubs) > end > > describe "responding to GET show" do > it "should expose the requested property as @property" do > > Property.should_receive(:non_existing_method).and_return(mock_property) > get :show, :id => "37" > assigns[:property].should equal(mock_property) > end > end > end > > SB-MacBook-Pro:test sb$ ruby > ./spec/controllers/properties_controller_spec.rb > . > > Finished in 0.134667 seconds > > 1 example, 0 failures > > > why zero failures? more specifically, why would :non_existing_method > return mock_property? and why would the assigns[:property] be equal to > mock_property? Because that's what you're saying with your and_return call above. The and_return method is not part of the expectation: it allows you to specify what value you want to be returned each time the expected message is received. You can find more info at http://rspec.info/documentation/mocks/message_expectations.html. Regards, Mat?as A. Flores > did I eat some bad mushrooms? > > Sergio > -- > 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 mark at mwilden.com Sun Feb 8 21:20:00 2009 From: mark at mwilden.com (Mark Wilden) Date: Sun, 8 Feb 2009 18:20:00 -0800 Subject: [rspec-users] how can this pass? In-Reply-To: References: Message-ID: <3c30da400902081820h696d91aei6c0023f7bda8b413@mail.gmail.com> On Sun, Feb 8, 2009 at 5:35 PM, Sergio Bayona wrote: > how could this test pass? > > I have: > > class PropertiesController < ApplicationController > def show > @property = Property.non_existing_method #causes a method missing > error > end > end > > > describe PropertiesController do > def mock_property(stubs={}) > @mock_property ||= mock_model(Property, stubs) > end > > describe "responding to GET show" do > it "should expose the requested property as @property" do > > Property.should_receive(:non_existing_method).and_return(mock_property) > get :show, :id => "37" > assigns[:property].should equal(mock_property) > end > end > end > > SB-MacBook-Pro:test sb$ ruby > ./spec/controllers/properties_controller_spec.rb > . > > Finished in 0.134667 seconds > > 1 example, 0 failures > > > why zero failures? more specifically, why would :non_existing_method > return mock_property? and why would the assigns[:property] be equal to > mock_property? did I eat some bad mushrooms? > That's just the way this mock library works. It just makes sure it receives a particular message and then returns a certain value in response. It doesn't actually check to see whether the mocked object responds to that message. Given Ruby's dynamic nature, that check might not even be valid at the time. Of course, this can be a source of false positives. That's what you get when you test behavior instead of state. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Sun Feb 8 21:54:36 2009 From: lists at ruby-forum.com (Sergio Bayona) Date: Mon, 9 Feb 2009 03:54:36 +0100 Subject: [rspec-users] how can this pass? In-Reply-To: <8d961d900902081756y59f125edvcefd23cd53cf777a@mail.gmail.com> References: <8d961d900902081756y59f125edvcefd23cd53cf777a@mail.gmail.com> Message-ID: <198fe603cf08783f23858549b495870a@ruby-forum.com> Aslak Helles?y wrote: > On Mon, Feb 9, 2009 at 2:35 AM, Sergio Bayona > wrote: >> >> assigns[:property].should equal(mock_property) >> 1 example, 0 failures >> >> >> why zero failures? more specifically, why would :non_existing_method >> return mock_property? > > Because you have stubbed the class method Property#non_existing_method > with: > Property.should_receive(:non_existing_method).and_return(mock_property) > > It doesn't make any difference whether this method is already defined > or not. Once the stub is set up, calls to the stubbed method will > return what you told it to return. > >> and why would the assigns[:property] be equal to >> mock_property? > > Because your controller's #show method assigns @property with the > value returned from Property#non_existing_method (which you stubbed). > >> did I eat some bad mushrooms? >> > > That I don't know. Why do you think this behaviour is > strange/hallucinating? > > Aslak ah! okay it's starting to make sense... and the mushroom effect is wearing out. just kidding ;) Thank you guys. By the way I just bought the "Rspec Book" and it's seems like a great resource. It has encouraged me to learn the framework. Sergio -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Sun Feb 8 22:29:59 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 8 Feb 2009 21:29:59 -0600 Subject: [rspec-users] how can this pass? In-Reply-To: <198fe603cf08783f23858549b495870a@ruby-forum.com> References: <8d961d900902081756y59f125edvcefd23cd53cf777a@mail.gmail.com> <198fe603cf08783f23858549b495870a@ruby-forum.com> Message-ID: <57c63afe0902081929w3ceedbc7k69a636594e5d7d6b@mail.gmail.com> On Sun, Feb 8, 2009 at 8:54 PM, Sergio Bayona wrote: > Aslak Helles?y wrote: >> On Mon, Feb 9, 2009 at 2:35 AM, Sergio Bayona >> wrote: >>> >>> assigns[:property].should equal(mock_property) >>> 1 example, 0 failures >>> >>> >>> why zero failures? more specifically, why would :non_existing_method >>> return mock_property? >> >> Because you have stubbed the class method Property#non_existing_method >> with: >> Property.should_receive(:non_existing_method).and_return(mock_property) >> >> It doesn't make any difference whether this method is already defined >> or not. Once the stub is set up, calls to the stubbed method will >> return what you told it to return. >> >>> and why would the assigns[:property] be equal to >>> mock_property? >> >> Because your controller's #show method assigns @property with the >> value returned from Property#non_existing_method (which you stubbed). >> >>> did I eat some bad mushrooms? >>> >> >> That I don't know. Why do you think this behaviour is >> strange/hallucinating? >> >> Aslak > > > ah! okay it's starting to make sense... and the mushroom effect is > wearing out. just kidding ;) > > Thank you guys. By the way I just bought the "Rspec Book" and it's seems > like a great resource. It has encouraged me to learn the framework. That's great news, thanks! If you have any constructive feedback to provide about the book, please do so at: http://www.pragprog.com/titles/achbd/errata http://forums.pragprog.com/forums/95 Cheers, David > > Sergio > -- > 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 Mon Feb 9 00:24:11 2009 From: mark at mwilden.com (Mark Wilden) Date: Sun, 8 Feb 2009 21:24:11 -0800 Subject: [rspec-users] how can this pass? In-Reply-To: <198fe603cf08783f23858549b495870a@ruby-forum.com> References: <8d961d900902081756y59f125edvcefd23cd53cf777a@mail.gmail.com> <198fe603cf08783f23858549b495870a@ruby-forum.com> Message-ID: <3c30da400902082124v4e34eaa1sca60a12348170689@mail.gmail.com> On Sun, Feb 8, 2009 at 6:54 PM, Sergio Bayona wrote: > > On Mon, Feb 9, 2009 at 2:35 AM, Sergio Bayona > > wrote: > >> > >> assigns[:property].should equal(mock_property) > >> 1 example, 0 failures > >> > >> > >> why zero failures? more specifically, why would :non_existing_method > >> return mock_property? > Dogpile! ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at mwilden.com Mon Feb 9 00:34:01 2009 From: mark at mwilden.com (Mark Wilden) Date: Sun, 8 Feb 2009 21:34:01 -0800 Subject: [rspec-users] how can this pass? In-Reply-To: <74e4981a0902081809n3ffdabd2sab4c63e2d2904bb5@mail.gmail.com> References: <74e4981a0902081809n3ffdabd2sab4c63e2d2904bb5@mail.gmail.com> Message-ID: <3c30da400902082134r644fcb1aye9076bfe963b97a@mail.gmail.com> On Sun, Feb 8, 2009 at 6:09 PM, Mat?as Flores wrote: > > You can find more info at http://rspec.info/documentation/mocks/message_expectations.html. > On that page, I found this example of using a computed return value with an expectation: my_mock.should_receive(:msg).with(:numeric, :numeric) once.and_return {|a, b| a + b} I'm not familiar with :numeric. Does it mean what it looks like it means? ///ark From aslak.hellesoy at gmail.com Mon Feb 9 06:11:27 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 9 Feb 2009 12:11:27 +0100 Subject: [rspec-users] RecordNotFound bubbling thru to cucumber In-Reply-To: <69f72d390902060912p19ab0chf080da614b7de898@mail.gmail.com> References: <69f72d390902060912p19ab0chf080da614b7de898@mail.gmail.com> Message-ID: <8d961d900902090311s456ae7ddn2c4d2839a2a92103@mail.gmail.com> On Fri, Feb 6, 2009 at 6:12 PM, Jeff Talbot wrote: > Hello, > > I have a controller action that raises a RecordNotFound exception if > you're not allowed to see something. In my global application > controller (application.rb), I catch these and render the 404 > template. But when I run cucumber (using webrat), it's getting the > full stacktrace (the step blows up). Any ideas why? I have It's because Cucumber's Rails support configures ActionController to send all errors straight through. See cucumber/rails/world.rb Patches and suggestions about how to improve this are welcome. (In most cases it's easier to spot errors when exceptions ripple through) Aslak > consider_all_requests_local turned off in my test.rb. > > Jeff > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From mflores at atlanware.com Mon Feb 9 07:22:52 2009 From: mflores at atlanware.com (=?ISO-8859-1?Q?Mat=EDas_Flores?=) Date: Mon, 9 Feb 2009 10:22:52 -0200 Subject: [rspec-users] how can this pass? In-Reply-To: <3c30da400902082134r644fcb1aye9076bfe963b97a@mail.gmail.com> References: <74e4981a0902081809n3ffdabd2sab4c63e2d2904bb5@mail.gmail.com> <3c30da400902082134r644fcb1aye9076bfe963b97a@mail.gmail.com> Message-ID: <74e4981a0902090422g55b24fbemee70256f60e55cb1@mail.gmail.com> 2009/2/9 Mark Wilden > On Sun, Feb 8, 2009 at 6:09 PM, Mat?as Flores > wrote: > > > > You can find more info at > http://rspec.info/documentation/mocks/message_expectations.html. > > > > On that page, I found this example of using a computed return value > with an expectation: > > my_mock.should_receive(:msg).with(:numeric, :numeric) once.and_return > {|a, b| a + b} > > I'm not familiar with :numeric. Does it mean what it looks like it means? > That example is a bit outdated. Use of symbols as mock argument constraints such as :numeric, :string, :anything, etc, are deprecated. The expectation above should be replaced with: my_mock.should_receive(:msg).with(an_instance_of(Numeric), an_instance_of(Numeric)).once.and_return {|a, b| a + b} Regards, Mat?as > ///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 dchelimsky at gmail.com Mon Feb 9 09:26:30 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 9 Feb 2009 08:26:30 -0600 Subject: [rspec-users] how can this pass? In-Reply-To: <74e4981a0902090422g55b24fbemee70256f60e55cb1@mail.gmail.com> References: <74e4981a0902081809n3ffdabd2sab4c63e2d2904bb5@mail.gmail.com> <3c30da400902082134r644fcb1aye9076bfe963b97a@mail.gmail.com> <74e4981a0902090422g55b24fbemee70256f60e55cb1@mail.gmail.com> Message-ID: <57c63afe0902090626j45f6b027ob60022c054c68014@mail.gmail.com> On Mon, Feb 9, 2009 at 6:22 AM, Mat?as Flores wrote: > > 2009/2/9 Mark Wilden >> >> On Sun, Feb 8, 2009 at 6:09 PM, Mat?as Flores >> wrote: >> > >> > You can find more info at >> > http://rspec.info/documentation/mocks/message_expectations.html. >> > >> >> On that page, I found this example of using a computed return value >> with an expectation: >> >> my_mock.should_receive(:msg).with(:numeric, :numeric) once.and_return >> {|a, b| a + b} >> >> I'm not familiar with :numeric. Does it mean what it looks like it means? > > That example is a bit outdated. And now fixed: http://rspec.info/documentation/mocks/message_expectations.html > Use of symbols as mock argument constraints > such as :numeric, :string, :anything, etc, are deprecated. > > The expectation above should be replaced with: > > my_mock.should_receive(:msg).with(an_instance_of(Numeric), > an_instance_of(Numeric)).once.and_return {|a, b| a + b} > > Regards, > Mat?as > >> >> ///ark >> _______________________________________________ >> 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 Feb 9 09:34:26 2009 From: nick at deadorange.com (Nick Hoffman) Date: Mon, 9 Feb 2009 09:34:26 -0500 Subject: [rspec-users] [RSpec] Setting a gem dep on rspec-rails In-Reply-To: References: <9CED04E8-7F30-4A1F-8996-FC0D350C9CCC@deadorange.com> <810a540e0902071027x53abfe30y348579c44b517bac@mail.gmail.com> <57c63afe0902071102q4058ab63vf6050dd6af3538a9@mail.gmail.com> Message-ID: <831C9F9F-9EAB-41A4-A0BE-05BB3CB46BDC@deadorange.com> On 08/02/2009, at 4:39 PM, Matt Wynne wrote: > On 7 Feb 2009, at 19:02, David Chelimsky wrote: > >> On Sat, Feb 7, 2009 at 12:27 PM, Pat Maddox >> wrote: >>> On Sat, Feb 7, 2009 at 9:30 AM, Nick Hoffman >>> wrote: >>>> With that said, I'm wondering what the accepted way to setup gem >>>> dependencies on rspec and rspec-rails is. Should one not bother? >>>> Should the >>>> "config.gem" lines go in config/environments/test.rb ? >>> >>> I don't bother to use config.gem with rspec, but if you do then >>> yes it >>> should go in test.rb >> >> I don't either, but I'd like to get it working for ppl who want to >> do it. >> >> If anybody w/ config.gem fu wants to help, that'd be awesome. > > I think this kinda works for us, but I had a couple of issues. One > is the problem with rake files, which will depend on RSpec being > visible to rake when it loads (which will ignore your vendor/gems > folder). I fixed that by putting the rake file in a huge begin / > rescue / end block so when the require 'spec' fails it doesn't load > the rest of the rake tasks. Ugly but functional. > > The other issue was to do with a line in spec/rails which clobbers > the value of RAILS_ENV to be 'test' whatever it was previously set > to. We use an unconventional 'features' environment for running > features (means I can run cukes at the same time as specs) but this > was going hay-wire. I think David has put a patch for this into > rspec-rails' head but I don't know if it's made it's way into a gem > yet. > > So yeah, executive summary: What Pat said. > > > Matt Wynne I've decided to just freeze the rspec and rspec-rails gems into vendor/ gems/ . It makes life easy when moving the app between hosts, and means that I don't have to worry about config.gem shenanigans. Thanks for all of your suggestions, guys. Much appreciated! From sfeley at gmail.com Mon Feb 9 09:58:59 2009 From: sfeley at gmail.com (Stephen Eley) Date: Mon, 9 Feb 2009 09:58:59 -0500 Subject: [rspec-users] RecordNotFound bubbling thru to cucumber In-Reply-To: <8d961d900902090311s456ae7ddn2c4d2839a2a92103@mail.gmail.com> References: <69f72d390902060912p19ab0chf080da614b7de898@mail.gmail.com> <8d961d900902090311s456ae7ddn2c4d2839a2a92103@mail.gmail.com> Message-ID: <1fb4df0902090658w294d5d46g4b209749905e0f4@mail.gmail.com> On Mon, Feb 9, 2009 at 6:11 AM, aslak hellesoy wrote: > > It's because Cucumber's Rails support configures ActionController to > send all errors straight through. > See cucumber/rails/world.rb > > Patches and suggestions about how to improve this are welcome. > (In most cases it's easier to spot errors when exceptions ripple through) Make it a configuration option? Or catch it with a proxy that inspects the exception then passes it *back* to Rails, and provide matchers or formatting options that display Cucumber's analysis only when the user wants it? I'm with Jeff on this: RecordNotFound isn't necessarily an "error," it's just an exception. One that will frequently come up in normal user interaction. A well-behaved app will do appropriate things with that exception and Cucumber should be able to test for those appropriate things. A testing framework that disrupts the application behavior cannot test it. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From nick at deadorange.com Mon Feb 9 09:56:29 2009 From: nick at deadorange.com (Nick Hoffman) Date: Mon, 9 Feb 2009 09:56:29 -0500 Subject: [rspec-users] step definitons to check login In-Reply-To: References: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> <88fd8ddc0812161547q21ce6a6k8cb226e1624f1f1@mail.gmail.com> <85d99afe0812161552i7b62cfefk694ed78df2de8f43@mail.gmail.com> <88fd8ddc0812161648s55eb11d1od328e6777ac3d5bd@mail.gmail.com> <6422b880674431d4986181d803c5b78f@ruby-forum.com> Message-ID: <1756866F-ED48-45D0-A4C7-579BD8FC5939@deadorange.com> On 17/12/2008, at 9:56 AM, James Byrne wrote: > Re: authlogin > > Can someone familiar with this gem explain where and how the > user_sessions are maintained? I have pawed through the code but it > has > left me rather more confused than not. The best inkling I can > arrive at > is that the authlogic persistence token is stored in the session data > and that the UserSession model serially searches sessions for that > token > string in whatever store medium that the Rails application is using. > However, I cannot seem to identify exactly where and how this is > done in > the code. Advice would be welcome. G'day James. I know this was like 2 months ago, but I finally got around to reading the rest of this thread. The last version of AuthLogic that I used was 1.0.1, so things might have changed a bit since then. Nonetheless... Authlogic uses a model called UserSession to deal with login sessions. If you have a look at UserSessionsController, you'll see that there are only three methods: * new * create * destroy When a user wants to login, they call UserSessionsController#new, which renders a login form. The login form submits to UserSessionsController#create, which authenticates the user. If successful, the session is saved, which causes the application to consider the user "logged-in". When a user wants to logout, they simply visit UserSessionsController#destroy . This kills their UserSession object, which results in the application considering them as "not logged-in". I hope that helps. If you have other questions, feel free to post here, or email me privately, or email Authlogic's author; he's quite friendly. Cheers, Nick From lists at ruby-forum.com Mon Feb 9 10:12:22 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 9 Feb 2009 16:12:22 +0100 Subject: [rspec-users] RSpec Testing ActiveRecord config dependency. Message-ID: <2c7e3dcde2fe495593529a0c8a122298@ruby-forum.com> I have the following library code: def normal_time_now return DateTime.now.utc if default_timezone == :utc return DateTime.now end This is dependent upon a setting in config/environment.rb # Make Active Record use UTC-base instead of local time config.active_record.default_timezone = :utc I want to test that I get the expected results with the config set to utc and otherwise. The library code is used to automatically set a model attribute on create. My existing specification looks somewhat like this: describe "Builds a Model with custom magic columns" do before(:all) do build_model :magiks do string :description # these are Rails' own magic columns ... # these are our custom magic columns ... end @my_mage = Magik.new @my_mage.save! end it "should set each custom magic column present" do (Magik.column_names & ActiveRecord::Base::HLL_AUDIT_COLUMNS).each do |magic_column| @my_mage.read_attribute(magic_column).should_not be_nil end end I can simply create duplicate separate specification file and set the configuration value appropriately in each. Something along the lines of: describe "Builds a Model with custom magic columns" do before(:all) do config.active_record.default_timezone = nil or config.active_record.default_timezone = :utc But this strikes me as inappropriate. I believe that this test belongs inside the basic specification file but I cannot conceive of how to do this. Basically, I require some form of variable setup routine. Does anyone have any suggestions on how to handle this case? Regards, -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Mon Feb 9 10:21:53 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 9 Feb 2009 16:21:53 +0100 Subject: [rspec-users] RecordNotFound bubbling thru to cucumber In-Reply-To: <1fb4df0902090658w294d5d46g4b209749905e0f4@mail.gmail.com> References: <69f72d390902060912p19ab0chf080da614b7de898@mail.gmail.com> <8d961d900902090311s456ae7ddn2c4d2839a2a92103@mail.gmail.com> <1fb4df0902090658w294d5d46g4b209749905e0f4@mail.gmail.com> Message-ID: <8d961d900902090721x70533cd2pb17a8845ec22063c@mail.gmail.com> On Mon, Feb 9, 2009 at 3:58 PM, Stephen Eley wrote: > On Mon, Feb 9, 2009 at 6:11 AM, aslak hellesoy wrote: >> >> It's because Cucumber's Rails support configures ActionController to >> send all errors straight through. >> See cucumber/rails/world.rb >> >> Patches and suggestions about how to improve this are welcome. >> (In most cases it's easier to spot errors when exceptions ripple through) > > Make it a configuration option? Or catch it with a proxy that > inspects the exception then passes it *back* to Rails, and provide > matchers or formatting options that display Cucumber's analysis only > when the user wants it? > > I'm with Jeff on this: RecordNotFound isn't necessarily an "error," > it's just an exception. One that will frequently come up in normal > user interaction. A well-behaved app will do appropriate things with > that exception and Cucumber should be able to test for those > appropriate things. A testing framework that disrupts the application > behavior cannot test it. > Good points. Please create a Lighthouse ticket for this. I'm looking forward to concrete suggestions about how to make this configurable and patches I can pull in :-) Aslak > > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From zach.dennis at gmail.com Mon Feb 9 11:36:30 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 9 Feb 2009 11:36:30 -0500 Subject: [rspec-users] RecordNotFound bubbling thru to cucumber In-Reply-To: <8d961d900902090721x70533cd2pb17a8845ec22063c@mail.gmail.com> References: <69f72d390902060912p19ab0chf080da614b7de898@mail.gmail.com> <8d961d900902090311s456ae7ddn2c4d2839a2a92103@mail.gmail.com> <1fb4df0902090658w294d5d46g4b209749905e0f4@mail.gmail.com> <8d961d900902090721x70533cd2pb17a8845ec22063c@mail.gmail.com> Message-ID: <85d99afe0902090836v58872b8fo551f980a22a64abb@mail.gmail.com> On Mon, Feb 9, 2009 at 10:21 AM, aslak hellesoy wrote: > On Mon, Feb 9, 2009 at 3:58 PM, Stephen Eley wrote: >> On Mon, Feb 9, 2009 at 6:11 AM, aslak hellesoy wrote: >>> >>> It's because Cucumber's Rails support configures ActionController to >>> send all errors straight through. >>> See cucumber/rails/world.rb >>> >>> Patches and suggestions about how to improve this are welcome. >>> (In most cases it's easier to spot errors when exceptions ripple through) >> >> Make it a configuration option? Or catch it with a proxy that >> inspects the exception then passes it *back* to Rails, and provide >> matchers or formatting options that display Cucumber's analysis only >> when the user wants it? >> >> I'm with Jeff on this: RecordNotFound isn't necessarily an "error," >> it's just an exception. One that will frequently come up in normal >> user interaction. A well-behaved app will do appropriate things with >> that exception and Cucumber should be able to test for those >> appropriate things. A testing framework that disrupts the application >> behavior cannot test it. >> > > Good points. Please create a Lighthouse ticket for this. I'm looking > forward to concrete suggestions about how to make this configurable > and patches I can pull in :-) There is already a ticket: http://rspec.lighthouseapp.com/projects/16211/tickets/49-cucumber-and-rails-controller-error-handling =) > > Aslak > >> >> >> -- >> Have Fun, >> Steve Eley (sfeley at gmail.com) >> ESCAPE POD - The Science Fiction Podcast Magazine >> http://www.escapepod.org >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Aslak (::) > _______________________________________________ > 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 zach.dennis at gmail.com Mon Feb 9 11:36:30 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 9 Feb 2009 11:36:30 -0500 Subject: [rspec-users] RecordNotFound bubbling thru to cucumber In-Reply-To: <8d961d900902090721x70533cd2pb17a8845ec22063c@mail.gmail.com> References: <69f72d390902060912p19ab0chf080da614b7de898@mail.gmail.com> <8d961d900902090311s456ae7ddn2c4d2839a2a92103@mail.gmail.com> <1fb4df0902090658w294d5d46g4b209749905e0f4@mail.gmail.com> <8d961d900902090721x70533cd2pb17a8845ec22063c@mail.gmail.com> Message-ID: <85d99afe0902090836v58872b8fo551f980a22a64abb@mail.gmail.com> On Mon, Feb 9, 2009 at 10:21 AM, aslak hellesoy wrote: > On Mon, Feb 9, 2009 at 3:58 PM, Stephen Eley wrote: >> On Mon, Feb 9, 2009 at 6:11 AM, aslak hellesoy wrote: >>> >>> It's because Cucumber's Rails support configures ActionController to >>> send all errors straight through. >>> See cucumber/rails/world.rb >>> >>> Patches and suggestions about how to improve this are welcome. >>> (In most cases it's easier to spot errors when exceptions ripple through) >> >> Make it a configuration option? Or catch it with a proxy that >> inspects the exception then passes it *back* to Rails, and provide >> matchers or formatting options that display Cucumber's analysis only >> when the user wants it? >> >> I'm with Jeff on this: RecordNotFound isn't necessarily an "error," >> it's just an exception. One that will frequently come up in normal >> user interaction. A well-behaved app will do appropriate things with >> that exception and Cucumber should be able to test for those >> appropriate things. A testing framework that disrupts the application >> behavior cannot test it. >> > > Good points. Please create a Lighthouse ticket for this. I'm looking > forward to concrete suggestions about how to make this configurable > and patches I can pull in :-) There is already a ticket: http://rspec.lighthouseapp.com/projects/16211/tickets/49-cucumber-and-rails-controller-error-handling =) > > Aslak > >> >> >> -- >> Have Fun, >> Steve Eley (sfeley at gmail.com) >> ESCAPE POD - The Science Fiction Podcast Magazine >> http://www.escapepod.org >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Aslak (::) > _______________________________________________ > 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 ben at benmabey.com Mon Feb 9 12:04:32 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 09 Feb 2009 10:04:32 -0700 Subject: [rspec-users] RecordNotFound bubbling thru to cucumber In-Reply-To: <8d961d900902090721x70533cd2pb17a8845ec22063c@mail.gmail.com> References: <69f72d390902060912p19ab0chf080da614b7de898@mail.gmail.com> <8d961d900902090311s456ae7ddn2c4d2839a2a92103@mail.gmail.com> <1fb4df0902090658w294d5d46g4b209749905e0f4@mail.gmail.com> <8d961d900902090721x70533cd2pb17a8845ec22063c@mail.gmail.com> Message-ID: <49906220.7030303@benmabey.com> aslak hellesoy wrote: > On Mon, Feb 9, 2009 at 3:58 PM, Stephen Eley wrote: > >> On Mon, Feb 9, 2009 at 6:11 AM, aslak hellesoy wrote: >> >>> It's because Cucumber's Rails support configures ActionController to >>> send all errors straight through. >>> See cucumber/rails/world.rb >>> >>> Patches and suggestions about how to improve this are welcome. >>> (In most cases it's easier to spot errors when exceptions ripple through) >>> >> Make it a configuration option? Or catch it with a proxy that >> inspects the exception then passes it *back* to Rails, and provide >> matchers or formatting options that display Cucumber's analysis only >> when the user wants it? >> >> I'm with Jeff on this: RecordNotFound isn't necessarily an "error," >> it's just an exception. One that will frequently come up in normal >> user interaction. A well-behaved app will do appropriate things with >> that exception and Cucumber should be able to test for those >> appropriate things. A testing framework that disrupts the application >> behavior cannot test it. >> >> > > Good points. Please create a Lighthouse ticket for this. I'm looking > forward to concrete suggestions about how to make this configurable > and patches I can pull in :-) > > Aslak > Instead of creating a new ticket we should probably continue the discussion on this ticket: http://rspec.lighthouseapp.com/projects/16211/tickets/49 -Ben From dchelimsky at gmail.com Mon Feb 9 13:11:46 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 9 Feb 2009 12:11:46 -0600 Subject: [rspec-users] RSpec Testing ActiveRecord config dependency. In-Reply-To: <2c7e3dcde2fe495593529a0c8a122298@ruby-forum.com> References: <2c7e3dcde2fe495593529a0c8a122298@ruby-forum.com> Message-ID: <57c63afe0902091011x554e4347ia95ee741e0d17e42@mail.gmail.com> On Mon, Feb 9, 2009 at 9:12 AM, James Byrne wrote: > I have the following library code: > > def normal_time_now > return DateTime.now.utc if default_timezone == :utc > return DateTime.now > end > > This is dependent upon a setting in config/environment.rb > > # Make Active Record use UTC-base instead of local time > config.active_record.default_timezone = :utc > > I want to test that I get the expected results with the config set to > utc and otherwise. The library code is used to automatically set a > model attribute on create. My existing specification looks somewhat > like this: > > describe "Builds a Model with custom magic columns" do > before(:all) do > build_model :magiks do > string :description > # these are Rails' own magic columns > ... > # these are our custom magic columns > ... > end > @my_mage = Magik.new > @my_mage.save! > end > > it "should set each custom magic column present" do > (Magik.column_names & ActiveRecord::Base::HLL_AUDIT_COLUMNS).each do > |magic_column| > @my_mage.read_attribute(magic_column).should_not be_nil > end > end > > I can simply create duplicate separate specification file and set the > configuration value appropriately in each. Something along the lines of: > > describe "Builds a Model with custom magic columns" do > before(:all) do > config.active_record.default_timezone = nil > or > config.active_record.default_timezone = :utc > > But this strikes me as inappropriate. I believe that this test belongs > inside the basic specification file but I cannot conceive of how to do > this. Basically, I require some form of variable setup routine. Does > anyone have any suggestions on how to handle this case? I'd keep it isolated. You know that config.active_record.default_timezone = :utc works, right? So you don't need to specify that. You're specifying that when default_timezone == :utc, it behaves one way, but otherwise it behaves differently. So: magik = Magik.create def magic.default_timezone; :utc; end .... OR magik = Magik.create magik.stub!(:default_timezone).and_return(:utc) Now this violates a principle that you shouldn't stub things on the object you're spec'ing, but the alternative is to play with global values, which violates other principles. This is the simplest way IMO. But if you're concerned about internals of AR changing, you could do this: describe Thing do before(:each) do @original_default_timezone = Thing.default_timezone end it "does something" do Thing.default_timezone = :abc thing = Thing.new thing.default_timezone.should == :abc end before(:each) do Thing.default_timezone = @original_default_timezone end end That will restore things after each example. HTH, David > > Regards, > -- > 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 Feb 9 14:22:17 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 9 Feb 2009 20:22:17 +0100 Subject: [rspec-users] RSpec Testing ActiveRecord config dependency. In-Reply-To: <57c63afe0902091011x554e4347ia95ee741e0d17e42@mail.gmail.com> References: <2c7e3dcde2fe495593529a0c8a122298@ruby-forum.com> <57c63afe0902091011x554e4347ia95ee741e0d17e42@mail.gmail.com> Message-ID: David Chelimsky wrote: > Now this violates a principle that you shouldn't stub things on the > object you're spec'ing, but the alternative is to play with global > values, which violates other principles. This is the simplest way IMO. > But if you're concerned about internals of AR changing, you could do > this: Since my library extends ActiveRecord::Base and its magic datetime columns I think that I should test that my extension does not change the anticipated behaviour of AR itself. However, default_timezone cannot be set on an instance of AR:Base insofar as I can tell. Further, setting the default_timezone on AR:Base itself does not appear to have any effect: [ "local", "utc" ].each do |tz| ActiveRecord::Base.default_timezone = tz @my_mage = Magik.new @my_mage.description = tz @my_mage.my_time_local = DateTime.now @my_mage.my_time_utc = DateTime.now.utc @my_mage.save! puts @my_mage.description end ... it "should set the UTC time (for _at/_on) correctly" do my_magic = Magik.find_by_description!("local") puts " " puts my_magic.description puts "Local: #{my_magic.my_time_local} = #{my_magic.my_time_local.to_f}" puts " now: #{Time.now} = #{Time.now.to_f}" puts " UTC: #{my_magic.my_time_utc} = #{my_magic.my_time_utc.to_f}" puts " now: #{Time.now.utc} = #{Time.now.utc.to_f}" my_magic = Magik.find_by_description!("utc") puts " " puts my_magic.description puts "Local: #{my_magic.my_time_local} = #{my_magic.my_time_local.to_f}" puts " now: #{Time.now} = #{Time.now.to_f}" puts " UTC: #{my_magic.my_time_utc} = #{my_magic.my_time_utc.to_f}" puts " now: #{Time.now.utc} = #{Time.now.utc.to_f}" Produces this: ..... local Local: Mon Feb 09 14:20:06 UTC 2009 = 1234189206.0 now: Mon Feb 09 14:20:06 -0500 2009 = 1234207206.77585 UTC: Mon Feb 09 19:20:06 UTC 2009 = 1234207206.0 now: Mon Feb 09 19:20:06 UTC 2009 = 1234207206.77609 utc Local: Mon Feb 09 14:20:06 UTC 2009 = 1234189206.0 now: Mon Feb 09 14:20:06 -0500 2009 = 1234207206.77807 UTC: Mon Feb 09 19:20:06 UTC 2009 = 1234207206.0 now: Mon Feb 09 19:20:06 UTC 2009 = 1234207206.7783 . Finished in 0.429892 seconds It seems that I am not overriding the AR:BASE.default_timezone setting since, as far as I can tell, the values stored are the same whatever value I set the default_tz to. Does anyone have a technique to accomplish this? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Mon Feb 9 17:23:21 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 9 Feb 2009 23:23:21 +0100 Subject: [rspec-users] RSpec Testing ActiveRecord config dependency. In-Reply-To: References: <2c7e3dcde2fe495593529a0c8a122298@ruby-forum.com> <57c63afe0902091011x554e4347ia95ee741e0d17e42@mail.gmail.com> Message-ID: <7a1e41de597e1e8d7e36e3033596ca04@ruby-forum.com> James Byrne wrote: > It seems that I am not overriding the AR:BASE.default_timezone setting > since, as far as I can tell, the values stored are the same whatever > value I set the default_tz to. > Well, after a very frustrating afternoon I have finally uncovered what is going on. The problem I had is that I did not consider that AR::Base.default_timezone is used both in and out. The display of datetime values retrieved via AR is adjusted according to the default_timezone setting at the time of retrieval and is not based on any TZ value stored in the database. In my test setup I created rows with the tz value set to :utc and then :local. However, when I ran the tests then I did not bother to reset the tz appropriately for each test. Thus the display of the data was adjusted by AR and confused the hell out of me. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Feb 10 01:18:25 2009 From: lists at ruby-forum.com (Sergio Bayona) Date: Tue, 10 Feb 2009 07:18:25 +0100 Subject: [rspec-users] how can this pass? In-Reply-To: <3c30da400902082124v4e34eaa1sca60a12348170689@mail.gmail.com> References: <8d961d900902081756y59f125edvcefd23cd53cf777a@mail.gmail.com> <198fe603cf08783f23858549b495870a@ruby-forum.com> <3c30da400902082124v4e34eaa1sca60a12348170689@mail.gmail.com> Message-ID: <61828a3b1a6ed3ab01a9712f7d8af733@ruby-forum.com> Mark Wilden wrote: > On Sun, Feb 8, 2009 at 6:54 PM, Sergio Bayona > wrote: > >> > On Mon, Feb 9, 2009 at 2:35 AM, Sergio Bayona >> > wrote: >> >> >> >> assigns[:property].should equal(mock_property) >> >> 1 example, 0 failures >> >> >> >> >> >> why zero failures? more specifically, why would :non_existing_method >> >> return mock_property? >> > > Dogpile! > > ///ark Evidently I'm still not fully getting it... why would this not pass? I mean I know why it doesn't pass. One instance is a mock object and the other is an AR object. But, shouldn't it return the mock property? There's just something elemental about Rspec I still don't get. describe "responding to GET new" do it "should expose a new property as @property" do @account = mock_model(Account) @account.should_receive(:properties) @property = mock_model(Property, :new_record? => false, :errors => []) @account.properties.should_receive(:build).and_return(@property) get :new assigns[:property].should == @property end end def new @property = @account.properties.build respond_to do |format| format.html # new.html.erb format.xml { render :xml => @property } end end 'PropertiesController responding to GET new should expose a new property as @property' FAILED expected: #, got: # (using ==) -- Posted via http://www.ruby-forum.com/. From pergesu at gmail.com Tue Feb 10 03:54:56 2009 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 10 Feb 2009 00:54:56 -0800 Subject: [rspec-users] how can this pass? In-Reply-To: <61828a3b1a6ed3ab01a9712f7d8af733@ruby-forum.com> References: <8d961d900902081756y59f125edvcefd23cd53cf777a@mail.gmail.com> <198fe603cf08783f23858549b495870a@ruby-forum.com> <3c30da400902082124v4e34eaa1sca60a12348170689@mail.gmail.com> <61828a3b1a6ed3ab01a9712f7d8af733@ruby-forum.com> Message-ID: <810a540e0902100054v3913fc2eh51249e89e59abe4a@mail.gmail.com> On Mon, Feb 9, 2009 at 10:18 PM, Sergio Bayona wrote: > Mark Wilden wrote: >> On Sun, Feb 8, 2009 at 6:54 PM, Sergio Bayona >> wrote: >> >>> > On Mon, Feb 9, 2009 at 2:35 AM, Sergio Bayona >>> > wrote: >>> >> >>> >> assigns[:property].should equal(mock_property) >>> >> 1 example, 0 failures >>> >> >>> >> >>> >> why zero failures? more specifically, why would :non_existing_method >>> >> return mock_property? >>> >> >> Dogpile! >> >> ///ark > > Evidently I'm still not fully getting it... why would this not pass? I > mean I know why it doesn't pass. One instance is a mock object and the > other is an AR object. But, shouldn't it return the mock property? > There's just something elemental about Rspec I still don't get. > > > > describe "responding to GET new" do > > it "should expose a new property as @property" do > @account = mock_model(Account) > @account.should_receive(:properties) > @property = mock_model(Property, :new_record? => false, :errors => > []) > @account.properties.should_receive(:build).and_return(@property) > get :new > assigns[:property].should == @property > end > > end > > def new > @property = @account.properties.build > > respond_to do |format| > format.html # new.html.erb > format.xml { render :xml => @property } > end > end > > > > 'PropertiesController responding to GET new should expose a new property > as @property' FAILED > expected: #, > got: # nil, zip: nil, uasap: nil, tax_number: nil, rent_due: nil, units_count: > 0, issues_count: 0, account_id: 1, created_at: nil, updated_at: nil> > (using ==) > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Hi in your new method, where does @account come from? Is it loaded through some kind of before_filter, or as part of the authentication framework? Anyway, once you've built up your mock expectations you now need to inject the mock into the code. You do this by stubbing the code that loads up the @account object - typically you're just doing an Account.find call somewhere. Note also that you need to specify that account returns something when properties is called - you need to hook up the association proxy. it "should expose a new property as @property" do @account = mock_model(Account) Account.should_receive(:find).with("1").and_return @account @account.stub!(:properties).and_return mock('properties proxy') @property = mock_model(Property, :new_record? => false, :errors => []) @account.properties.should_receive(:build).and_return(@property) get :new assigns[:property].should == @property end end additionally I would only have two expectations (should_receive) and would loosen the rest by just stubbing: it "should expose a new property as @property" do # arrange @account = mock_model(Account, :properties => mock('properties proxy')) @property = mock_model(Property, :new_record? => false, :errors => []) @account.properties.stub!(:build).and_return(@property) # sanity check Account.should_receive(:find).with("1").and_return @account # act get :new # assert assigns[:property].should == @property end end I like to minimize the number of expectations(/assertions) that appear in the example. Doing so clearly communicates the important behavior. If the final expectation passes, you can infer that it's doing the right thing with the model because that's the only way to get to your mock @property. Finally I threw in an Account.should_receive("1") because you need to inject the mock account somehow. That does the trick, and it also serves as a sanity check for the contract between controller and model - Account.find is the entry point to the model in this action. Does that make sense? Pat From rem.gagnon at gmail.com Tue Feb 10 10:03:28 2009 From: rem.gagnon at gmail.com (Remi Gagnon) Date: Tue, 10 Feb 2009 10:03:28 -0500 Subject: [rspec-users] Weird message on ActiveSupport::Callbacks::CallbackChain:Class Message-ID: Hi guys, its probably a miss understanding of the framework but I need your assistance. Here is the problem of one of my teammates: I have a hard time writing rspecs for a class I developed. The class in question reads an xml document, instanciates the model classes found in the xml and saves the classes and their attributes in the database with the good foreign keys. The class is stored in a lib. The class : class XmlReader def self.import_xml(xml_doc) objects_xml = Array.new keys_obj = Array.new xml = REXML::Document.new(xml_doc) read_xml(xml, objects_xml, keys_obj) raise AnError.new("Can not save xml objects") if (objects_xml.empty?) objects_xml.each { |instance| save_class(instance, keys_obj[objects_xml.index(instance)]) } end ? end The import_xml function acts as an entry point but there are two other functions involved in the process : - read_xml : reads the xml elements one by one and instanciates the classes that have to be with the attributes found in the xml document. It is called recursively. The two arrays, objects_xml and keys_obj, contain respectively all the instanciated objects found and all the foreign keys defined in the relations of the models. - save_class : saves the instanciated objects contained in the objets_xml array with the good foreign keys for the relations to be well done. Now, I am trying to test if the objects_xml array is empty. If so, the class should raise an error. The rspec : # mocks ? @mock_element = mock(REXML::Element) mock_element.stub!(:text) @mock_element.stub!(:name) @mock_element.stub!(:elements) @xml_doc = mock(REXML::Document, :elements => { "e1" => @mock_element, "e2" => @mock_element }) @xml_doc.stub!(:new) @xml_doc.stub!(:has_elements?) xml_doc.stub!(:encoding) @objets_xml = mock(Array) @objets_xml.stub!(:[]=) @objets_xml.stub!(:[]) objets_xml.stub!(:empty?) @keys_obj = mock(Array) @keys_obj.stub!(:[]=) @keys_obj.stub!(:[]) Array.should_receive(:new).and_return(@objets_xml) Array.should_receive(:new).and_return(@keys_obj) REXML::Document.should_receive(:new).and_return(@xml_doc) XmlReader.should_receive(:read_xml).and_return(true) objets_xml.should_receive(:empty?).and_return(true) lambda { XmlReader.import_xml(xml_valid) }.should raise_error(AnError, "Can not save xml objects") The error : undefined method `new' for ActiveSupport::Callbacks::CallbackChain:Class This is where my problem is. This error occurs after the test is made and finished. In other words, the test passes but the framework fails after it on a callback made in rails for whatever reason. Stack trace : C:/Projets/Iter8_Conversion/vendor/rails/actionpack/lib/action_controller/test_process.rb:471:in `method_missing' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/mocks/proxy.rb:102:in `__send__' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/mocks/proxy.rb:102:in `message_received' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/mocks/proxy.rb:140:in `new' (eval):7:in `teardown_callback_chain' C:/Projets/Iter8_Conversion/vendor/rails/activesupport/lib/active_support/callbacks.rb:277:in `send' C:/Projets/Iter8_Conversion/vendor/rails/activesupport/lib/active_support/callbacks.rb:277:in `run_callbacks' C:/ruby/lib/ruby/gems/1.8/gems/rspec-rails-1.1.12/lib/spec/rails/interop/testcase.rb:10 C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:84:in `instance_eval' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:84:in `eval_each_fail_slow' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:82:in `each' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:82:in `eval_each_fail_slow' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_group_methods.rb:254:in `run_after_each' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_group_methods.rb:253:in `each' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_group_methods.rb:253:in `run_after_each' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:141:in `after_each_example' Can anyone explain what is happening here or does anyone knows how to bypass this ? Many thanks in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at mwilden.com Tue Feb 10 10:19:02 2009 From: mark at mwilden.com (Mark Wilden) Date: Tue, 10 Feb 2009 07:19:02 -0800 Subject: [rspec-users] how can this pass? In-Reply-To: <61828a3b1a6ed3ab01a9712f7d8af733@ruby-forum.com> References: <8d961d900902081756y59f125edvcefd23cd53cf777a@mail.gmail.com> <198fe603cf08783f23858549b495870a@ruby-forum.com> <3c30da400902082124v4e34eaa1sca60a12348170689@mail.gmail.com> <61828a3b1a6ed3ab01a9712f7d8af733@ruby-forum.com> Message-ID: <3c30da400902100719uee1962bq3187651967a6a0a6@mail.gmail.com> On Mon, Feb 9, 2009 at 10:18 PM, Sergio Bayona wrote: > describe "responding to GET new" do > > it "should expose a new property as @property" do > @account = mock_model(Account) > @account.should_receive(:properties) > @property = mock_model(Property, :new_record? => false, :errors => > []) > @account.properties.should_receive(:build).and_return(@property) > get :new > assigns[:property].should == @property > end > > end Another thing is that instance variables shouldn't be used unless necessary. As a rule of thumb, things should have as limited a scope as possible. Prefer class variables to global variables, instance variables to class variables, and local variables to instance variables. Some reasons are 1) to better communicate your intent, 2) to limit the places you have to look to see where a variable is being changed, and 3) to limit the amount of code that might depend on the variable. ///ark From lists at ruby-forum.com Tue Feb 10 10:27:16 2009 From: lists at ruby-forum.com (Francisco Trindade) Date: Tue, 10 Feb 2009 16:27:16 +0100 Subject: [rspec-users] Using cucumber profiles with rake task Message-ID: <5dae25ebd9339a0f2097d9eae28c7d37@ruby-forum.com> Hi, Im trying to set up an environment where I am able to run different cucumber profiles (webrat/selenium) in the same project. I did manage to make them work using the cucumber command, so this command works: cucumber -p selenium features/done/items_selenium.feature The problem I have is when I try to do the same thing using the rake task. I followed the advice given on this thread (http://www.ruby-forum.com/topic/177404) and changed the rake task to what is described below, but apparently the rake task does not consider if you are passing a profile or not, and keeps requiring every file from the features directory, generating some conflicts. Cucumber::Rake::Task.new(:features) do |t| profile = ENV['PROFILE'] || 'default' t.cucumber_opts = "-p #{profile} --format progress" end I did manage to make it work using this parameters in the rake task: Cucumber::Rake::Task.new(:features) do |t| t.cucumber_opts = "--format progress" t.step_pattern = ["features/webrat_steps/**/*.rb","features/support/webrat_env.rb"] t.feature_pattern = "features/**/*_webrat.feature" end but Im wondering if there is not a better way of doing this, reusing the elements from the cucumber profile. Am I missing something? Regards, Francisco -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Tue Feb 10 10:43:35 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Tue, 10 Feb 2009 10:43:35 -0500 Subject: [rspec-users] Using cucumber profiles with rake task In-Reply-To: <5dae25ebd9339a0f2097d9eae28c7d37@ruby-forum.com> References: <5dae25ebd9339a0f2097d9eae28c7d37@ruby-forum.com> Message-ID: <85d99afe0902100743p1481c204n44b33d388167afc9@mail.gmail.com> On Tue, Feb 10, 2009 at 10:27 AM, Francisco Trindade wrote: > Hi, > > Im trying to set up an environment where I am able to run different > cucumber profiles (webrat/selenium) in the same project. > > I did manage to make them work using the cucumber command, so this > command works: > cucumber -p selenium features/done/items_selenium.feature > > The problem I have is when I try to do the same thing using the rake > task. I followed the advice given on this thread > (http://www.ruby-forum.com/topic/177404) and changed the rake task to > what is described below, but apparently the rake task does not consider > if you are passing a profile or not, and keeps requiring every file from > the features directory, generating some conflicts. > > Cucumber::Rake::Task.new(:features) do |t| > profile = ENV['PROFILE'] || 'default' > t.cucumber_opts = "-p #{profile} --format progress" > end > > > I did manage to make it work using this parameters in the rake task: > > Cucumber::Rake::Task.new(:features) do |t| > t.cucumber_opts = "--format progress" > t.step_pattern = > ["features/webrat_steps/**/*.rb","features/support/webrat_env.rb"] > t.feature_pattern = "features/**/*_webrat.feature" > end > > but Im wondering if there is not a better way of doing this, reusing the > elements from the cucumber profile. > > Am I missing something? > The Cucumber rake task doesn't support profiles very well. There is a ticket for this: http://rspec.lighthouseapp.com/projects/16211/tickets/187-rake-task-support-cucumberyml-profiles On the ticket Ben Mabey provided his current solution, which is to clear out the feature list: Cucumber::Rake::Task.new(:selenium) do |t| ENV['WEBRAT'] = 'selenium' t.cucumber_opts = "--profile selenium" t.feature_list = [] end -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From lists at ruby-forum.com Tue Feb 10 11:54:38 2009 From: lists at ruby-forum.com (Francisco Trindade) Date: Tue, 10 Feb 2009 17:54:38 +0100 Subject: [rspec-users] Using cucumber profiles with rake task In-Reply-To: <85d99afe0902100743p1481c204n44b33d388167afc9@mail.gmail.com> References: <5dae25ebd9339a0f2097d9eae28c7d37@ruby-forum.com> <85d99afe0902100743p1481c204n44b33d388167afc9@mail.gmail.com> Message-ID: <9740c4937a40794a232ebb20a7213b88@ruby-forum.com> Thanks, now it makes sense. Regards, Francisco Zach Dennis wrote: > On Tue, Feb 10, 2009 at 10:27 AM, Francisco Trindade > wrote: >> task. I followed the advice given on this thread >> >> elements from the cucumber profile. >> >> Am I missing something? >> > > The Cucumber rake task doesn't support profiles very well. There is a > ticket for this: > > http://rspec.lighthouseapp.com/projects/16211/tickets/187-rake-task-support-cucumberyml-profiles > > On the ticket Ben Mabey provided his current solution, which is to > clear out the feature list: > > Cucumber::Rake::Task.new(:selenium) do |t| > ENV['WEBRAT'] = 'selenium' > t.cucumber_opts = "--profile selenium" > t.feature_list = [] > end > > > -- > Zach Dennis > http://www.continuousthinking.com > http://www.mutuallyhuman.com -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Feb 10 14:10:22 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 10 Feb 2009 20:10:22 +0100 Subject: [rspec-users] RSpec testing AR results Message-ID: The TDD/BDD stuff is really quite amazing. In order to construct tests on a library that I wrote to implement custom magic columns I have learned some extremely valuable information respecting date and time recording in Rails. Which leads to my question: I am presently testing an AR stored time object thus: @my_mage_local[dt_col].to_f.should be_close( @my_mage_local[dt_col].to_f + @my_mage_local.my_time_local.utc_offset, 0.01) However, it occurs to me that instead I might wish to compare datetime values as they are returned from the database without considering their numeric value, which is dependent upon AR itself. When I check the class of a datetime object before casting I see this: @my_mage_local["#{dt_col}_before_type_cast"].class => String Should I be comparing string values instead? For example: @my_mage_local["#{dt_col}_before_type_cast"].should \ be(@my_mage_local[my_time_local_before_type_cast]) -- Posted via http://www.ruby-forum.com/. From afolgueras at gmail.com Fri Feb 6 16:12:01 2009 From: afolgueras at gmail.com (Alex) Date: Fri, 6 Feb 2009 13:12:01 -0800 (PST) Subject: [rspec-users] How to test the code inside the block of the to_xml function? Message-ID: Hi all, when I spec the to_xml function like this: @some_model.should_receive(:to_xml), it dskips the code located in the block, here is the controller code: ... output = @detenteur.to_xml( :skip_types => false, :skip_instruct => true, :dasherize => false, :only => [:inte_no] ) do |xml_detenteur| lots of code... end How can I test the code inside? Thanks! From google at steveluscher.com Sun Feb 8 03:00:47 2009 From: google at steveluscher.com (steveluscher) Date: Sun, 8 Feb 2009 00:00:47 -0800 (PST) Subject: [rspec-users] The TODO note in rspec files can't be shown in "rake notes" In-Reply-To: References: Message-ID: On Dec 10 2008, 7:12 pm, "Kai Fu" wrote: > Could someone tell me how to fix this? Whether I should hack the rails rake > code? I've written about my (hopefully) durable solution to your problem, here: http://steveluscher.com/archives/enumerating-annotations-in-directories-of-your-choosing-with-rakenotes Create a file at lib/tasks/notes.rake: --- # Override the directories that the # SourceAnnotationExtractor traverses # when you call rake notes class SourceAnnotationExtractor def find_with_custom_directories find_without_custom_directories(%w(app lib spec features)) end alias_method_chain :find, :custom_directories end --- ?where %w(app lib spec features) is a list of directories that you want rake:notes to traverse. Cheers, Steven? On Dec 10 2008, 7:12?pm, "Kai Fu" wrote: > I've written a "TODO" comment in a xxx_controller_spec.rb. When I run the > "rake notes" command, it doesn't appear in the output, while other notes > written in the "app" dir are shown correctly. > > Could someone tell me how to fix this? Whether I should hack the rails rake > code? From phlip2005 at gmail.com Mon Feb 2 21:19:23 2009 From: phlip2005 at gmail.com (Phlip) Date: Mon, 02 Feb 2009 18:19:23 -0800 Subject: [rspec-users] undefined method `inherit' for Merb::Test::ExampleGroup In-Reply-To: References: Message-ID: <4987A9AB.1080108@gmail.com> I have to bump this one because it looks like it's on RSpec's core feature list, and I reeally need a fix for it. Feel free to blame Merb, if they munged the inherit() method somehow! > Here's the relevant bits that don't work. (I changed the goal library to > the 'assert2' patched into Test::Unit::Assertions.) > > require File.join( File.dirname(__FILE__), '..', "spec_helper" ) > require 'test/unit' > require 'assert2' > > > describe 'Post' do > > before do > include Test::Unit::TestCase > # inherit Test::Unit::TestCase # does not compile > # include Test::Unit::Assertions # does not import assert{} > end > > it 'should have fixtures' do > posts = posts(:Joan_Crawford_Has_Risen, :Jammin, :Sardonicus, :Lithium) > posts[0].body.should == 'From the Grave' > posts[0].tags.should include(tags(:progressive)) > > # this line never compiles > assert{ posts[0].tags.include? tags(:rocksteady) } > end > > end > > The rspec-rails plugin sure has me spoiled, huh? I formerly thought > Test::Unit::Assertions would be automatically available, even without > Rails around... > From phlip2005 at gmail.com Mon Feb 2 23:36:18 2009 From: phlip2005 at gmail.com (Phlip) Date: Mon, 02 Feb 2009 20:36:18 -0800 Subject: [rspec-users] undefined method `inherit' for Merb::Test::ExampleGroup In-Reply-To: <810a540e0902022011x754426f3r6a38fb46c13e35f0@mail.gmail.com> References: <4987A9AB.1080108@gmail.com> <810a540e0902022011x754426f3r6a38fb46c13e35f0@mail.gmail.com> Message-ID: <4987C9C2.4090102@gmail.com> Pat Maddox wrote: > I'll blame Merb on the basis that there is no "inherit" in RSpec. I'm > guessing it's some kind of merb extension. http://blog.davidchelimsky.net/2007/4/1/rspec-plays-nice-with-others I know I know - time flies! If it has been superseded, then how do you inject a batch of assertions defined in someone else's class into RSpec? For example, how does RSpec on Rails import its ActiveSupport::TestCase assertions? From phlip2005 at gmail.com Tue Feb 3 08:47:59 2009 From: phlip2005 at gmail.com (Phlip) Date: Tue, 03 Feb 2009 05:47:59 -0800 Subject: [rspec-users] undefined method `inherit' for Merb::Test::ExampleGroup In-Reply-To: <57c63afe0902022105hf214a34r8928a6ad08ea4fb5@mail.gmail.com> References: <4987A9AB.1080108@gmail.com> <810a540e0902022011x754426f3r6a38fb46c13e35f0@mail.gmail.com> <4987C9C2.4090102@gmail.com> <57c63afe0902022105hf214a34r8928a6ad08ea4fb5@mail.gmail.com> Message-ID: <49884B0F.9080503@gmail.com> David Chelimsky wrote: > Spec::Runner.configure do |c| > c.include MyMethods > end Tx that was it! From phlip2005 at gmail.com Sun Feb 8 18:48:41 2009 From: phlip2005 at gmail.com (Phlip) Date: Sun, 8 Feb 2009 15:48:41 -0800 Subject: [rspec-users] exemplary way to show a list is sorted? Message-ID: <860c114f0902081548j3b1c18bco44ae938836d02adc@mail.gmail.com> RSpeckers: I'm asserting that a list should be sorted by affinity. The following code is good enough for government work, but is there some more clever way to show that each element is equal or less than the previous element? it 'should rank posts by affinity' do list = @map.sort_frobs_by_affinity list[1].affinity.should >= list[1].affinity list[2].affinity.should >= list[2].affinity list[3].affinity.should >= list[3].affinity list[4].affinity.should >= list[4].affinity end Notice I could just write... list.map(&:affinity) == list.map(&:affinity) ...but it seems that the point of BDD is to make the business logic obvious, not obscured in programming details, right? -- Phlip http://www.oreilly.com/catalog/9780596510657/ ^ assert_xpath http://tinyurl.com/yrc77g <-- assert_latest Model From pradeep.gatram at gmail.com Tue Feb 10 07:41:57 2009 From: pradeep.gatram at gmail.com (Pradeep Gatram) Date: Tue, 10 Feb 2009 04:41:57 -0800 (PST) Subject: [rspec-users] how can this pass? In-Reply-To: <810a540e0902100054v3913fc2eh51249e89e59abe4a@mail.gmail.com> References: <8d961d900902081756y59f125edvcefd23cd53cf777a@mail.gmail.com> <198fe603cf08783f23858549b495870a@ruby-forum.com> <3c30da400902082124v4e34eaa1sca60a12348170689@mail.gmail.com> <61828a3b1a6ed3ab01a9712f7d8af733@ruby-forum.com> <810a540e0902100054v3913fc2eh51249e89e59abe4a@mail.gmail.com> Message-ID: Sergio, Responding to your original question. This issue has bugged me a lot in the past 1 year. And apparently, a lot of other people. As already explained, the spec should indeed pass. But there should be a failure somewhere because your code will obviously not work. Synthesis is a great tool for checking this stuff automatically. Read a bit about it here (http://nutrun.com/weblog/synthesized-testing-a- primer/) and here (http://github.com/gmalamid/synthesis/tree/master) Pradeep From rem.gagnon at gmail.com Sat Feb 7 06:47:34 2009 From: rem.gagnon at gmail.com (rgagnon) Date: Sat, 7 Feb 2009 03:47:34 -0800 (PST) Subject: [rspec-users] How to spec within a block? Message-ID: <3e46d267-2e1e-4e75-a9f8-7514ca54a146@q9g2000yqc.googlegroups.com> I have this and I want to mock the to_xml but not his block cause this is what I want to spec. Is there a way to do this? Sorry for the formatting output = @detenteur.to_xml( :skip_types => false, :skip_instruct => true, :dasherize => false, :only => [:inte_no] ) do |xml_detenteur| p xml_detenteur.intervenant_adresses.class.to_s xml_detenteur.intervenant_adresses do get_object_xml( @detenteur.intervenant_adresses, @detenteur.intervenant_adresses.obtenir_adresses_vigueur, {:builder => xml_detenteur, :skip_instruct => true, :skip_types => false, :dasherize => false, :except => [:inte_no]}) end xml_detenteur.intervenant_telephones do get_object_xml( @detenteur.intervenant_telephones, @detenteur.intervenant_telephones.obtenir_tels_vigueur, {:builder => xml_detenteur, :skip_instruct => true, :skip_types => false, :dasherize => false, :except => [:inte_no]}) end xml_detenteur.intervenants_polices do @polices = polices(@detenteur, @police_no, inte_polices, xml_detenteur) end end From rem.gagnon at gmail.com Tue Feb 10 09:54:21 2009 From: rem.gagnon at gmail.com (Remi Gagnon) Date: Tue, 10 Feb 2009 09:54:21 -0500 Subject: [rspec-users] Weird message on ActiveSupport::Callbacks::CallbackChain:Class Message-ID: Hi guys, its probably a miss understanding of the framework but I need your assistance. Here is the problem of one of my teammates: I have a hard time writing rspecs for a class I developed. The class in question reads an xml document, instanciates the model classes found in the xml and saves the classes and their attributes in the database with the good foreign keys. The class is stored in a lib. The class : class XmlReader def self.import_xml(xml_doc) objects_xml = Array.new keys_obj = Array.new xml = REXML::Document.new(xml_doc) read_xml(xml, objects_xml, keys_obj) * *raise AnError.new("Can not save xml objects") *if* (objects_xml.empty?) objects_xml.each { |instance|** save_class(instance, keys_obj[objects_xml.index(instance)]) } end ? end The import_xml function acts as an entry point but there are two other functions involved in the process : - read_xml : reads the xml elements one by one and instanciates the classes that have to be with the attributes found in the xml document. It is called recursively. The two arrays, objects_xml and keys_obj, contain respectively all the instanciated objects found and all the foreign keys defined in the relations of the models. - save_class : saves the instanciated objects contained in the objets_xml array with the good foreign keys for the relations to be well done. Now, I am trying to test if the objects_xml array is empty. If so, the class should raise an error. The rspec : # mocks ? *@mock_element* = mock(REXML::Element)* * *mock_element*.stub!(*:text*) *@mock_element*.stub!(*:name*) *@mock_element*.stub!(*:elements*) *@xml_doc* = mock(REXML::Document,* :elements* => { "e1" =>* @mock_element*,"e2"=> * @mock_element* }) *@xml_doc*.stub!(*:new*) *@xml_doc*.stub!(*:has_elements?*) *xml_doc*.stub!(*:encoding*) *@objets_xml* = mock(Array) *@objets_xml*.stub!(*:[]=*) *@objets_xml*.stub!(*:[]*)** *objets_xml*.stub!(*:empty?*) *@keys_obj* = mock(Array) *@keys_obj*.stub!(*:[]=*) *@keys_obj*.stub!(*:[]*) Array.should_receive(*:new*).and_return(*@objets_xml*) Array.should_receive(*:new*).and_return(*@keys_obj*) REXML::Document.should_receive(*:new*).and_return(*@xml_doc*) XmlReader.should_receive(*:read_xml*).and_return(*true*)** *objets_xml*.should_receive(*:empty?*).and_return(*true*) doing { XmlReader.import_xml(xml_valid) }.should raise_error(AnError, "Can not save xml objects") The error : undefined method `new' for ActiveSupport::Callbacks::CallbackChain:Class This is where my problem is. This error occurs after the test is made and finished. In other words, the test passes but the framework fails after it on a callback made in rails for whatever reason. Stack trace : C:/Projets/Iter8_Conversion/vendor/rails/actionpack/lib/action_controller/test_process.rb:471:in `method_missing' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/mocks/proxy.rb:102:in `__send__' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/mocks/proxy.rb:102:in `message_received' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/mocks/proxy.rb:140:in `new' (eval):7:in `teardown_callback_chain' C:/Projets/Iter8_Conversion/vendor/rails/activesupport/lib/active_support/callbacks.rb:277:in `send' C:/Projets/Iter8_Conversion/vendor/rails/activesupport/lib/active_support/callbacks.rb:277:in `run_callbacks' C:/ruby/lib/ruby/gems/1.8/gems/rspec-rails-1.1.12/lib/spec/rails/interop/testcase.rb:10 C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:84:in `instance_eval' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:84:in `eval_each_fail_slow' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:82:in `each' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:82:in `eval_each_fail_slow' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_group_methods.rb:254:in `run_after_each' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_group_methods.rb:253:in `each' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_group_methods.rb:253:in `run_after_each' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:141:in `after_each_example' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:57:in `execute' C:/ruby/lib/ruby/1.8/timeout.rb:56:in `timeout' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:49:in `execute' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_group_methods.rb:284:in `execute_examples' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_group_methods.rb:283:in `each' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_group_methods.rb:283:in `execute_examples' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_group_methods.rb:171:in `run' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/runner/example_group_runner.rb:23:in `run' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/runner/example_group_runner.rb:22:in `each' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/runner/example_group_runner.rb:22:in `run' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/runner/options.rb:111:in `run_examples' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/runner/command_line.rb:9:in `run' C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/bin/spec:4 C:/ruby/bin/spec:19:in `load' C:/ruby/bin/spec:19 Can anyone explain what is happening here or does anyone knows how to bypass this ? Many thanks in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rjharmon0316 at yahoo.com Mon Feb 2 01:17:18 2009 From: rjharmon0316 at yahoo.com (Randy Harmon) Date: Sun, 1 Feb 2009 22:17:18 -0800 (PST) Subject: [rspec-users] resource urls only work *after* a get() in controller spec Message-ID: <346979.70476.qm@web31811.mail.mud.yahoo.com> Okay, following up on this item. Would you believe a workaround of (gasp) get :index, prior to expecting route-based URLs to work? (slaps forehead). or do_action(), provided by the host example group (the more concrete example group, I mean - what's the right terminology there?). I tried reproducing the stuff I saw being done in action_controller/test_process.rb up to the point where the resource url function started working, but when I did that (setting up the controller name and action, essentially), I wasn't getting it to work, but I ran out of time budget for fooling with it. If anyone thinks of an approach that could be more robust, I'd sure be interested. Until then, Randy ----- Original Message ---- > From: "r_j_h_box-sf at yahoo.com" > To: rspec-users > Sent: Saturday, January 31, 2009 11:40:54 PM > Subject: Re: [rspec-users] resource urls only work *after* a get() in controller spec > > thanks, Ben - that didn't do the trick, though. > > I traced it down as far as this: > > the controller hasn't initialized its current url - that's the immediate cause > of the method-on-nil complaint. It hasn't, because the controller isn't > technically handling a request yet (i.e., process()). I tried monkey-patching > the controller to allow me to call its initialize_current_url to get around > this, but I didn't (yet) find how to fake up its request and params sufficiently > to have that work. > > Understandably, the controller can't know what the current url is, unless > rpsec-rails were to have a way to discover it from the example group. I'm not > sure that I'm proposing a change to a declarative style for controller actions - > for my purpose, I'd be satisfied to fake it to think 'index' is the current url > (in advance of processing the real request as specified by get() and friends). > > Hopefully this rings enough bells to make a workaround self-evident to > somebody. Anybody? Else I'll see what I can dig up from the rspec/rspec-rails > source that can be enough of a resource. > > Thanks, > > Randy > > > > > > ----- Original Message ---- > > From: Ben Mabey > > To: rspec-users > > Sent: Saturday, January 31, 2009 5:41:56 PM > > Subject: Re: [rspec-users] resource urls only work *after* a get() in > controller spec > > > > r_j_h_box-sf at yahoo.com wrote: > > > I'm encountering an interesting symptom during example execution. I'm > > > making a shared example group that dries up belongs-to-me before_filter > > > testing, and it makes a callback to the example group that says > > > it_should_behave_like that. The callback tells the shared example > > > where to expect a redirect for failure. > > > > > > It seems that prior to > > > executing a get() (etc), the resource-based url functions aren't > > > accessible. Following the get(), topics_url works fine. But before > > > then, it gives an error like this: > > > > > > http://pastie.org/376096 > > > > > > Is > > > this a known issue? Is there a workaround I can use? > > For a workaround try doing a "include ActionController::UrlWriter" in your > > shared example group. > > > > -Ben > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Tue Feb 10 14:52:47 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 10 Feb 2009 13:52:47 -0600 Subject: [rspec-users] Rspec fails In-Reply-To: <08834094-2815-40d5-a37f-1b432521cde8@x16g2000prn.googlegroups.com> References: <08834094-2815-40d5-a37f-1b432521cde8@x16g2000prn.googlegroups.com> Message-ID: <57c63afe0902101152h6f72b7c5xf23de518b38c0946@mail.gmail.com> On Tue, Jan 27, 2009 at 8:04 PM, melvin ram wrote: > >From this code http://pastie.org/372777 I'm getting these errors > http://pastie.org/372702 and it's not making any sense... and it's got > me a little stuck. > > Some help pls? To start with, the code uses rspec's mock syntax, but the errors are coming from mocha, so it looks like you've got both frameworks intermingling. Which one are you trying to use? You can only use one since both invade Object. From dchelimsky at gmail.com Tue Feb 10 15:15:48 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 10 Feb 2009 14:15:48 -0600 Subject: [rspec-users] resource urls only work *after* a get() in controller spec In-Reply-To: <346979.70476.qm@web31811.mail.mud.yahoo.com> References: <346979.70476.qm@web31811.mail.mud.yahoo.com> Message-ID: <57c63afe0902101215q611b9574y3403551c2e60d140@mail.gmail.com> On Mon, Feb 2, 2009 at 12:17 AM, Randy Harmon wrote: > > Okay, following up on this item. Would you believe a workaround of (gasp) get :index, prior to expecting route-based URLs to work? (slaps forehead). or do_action(), provided by the host example group (the more concrete example group, I mean - what's the right terminology there?). > > I tried reproducing the stuff I saw being done in action_controller/test_process.rb up to the point where the resource url function started working, but when I did that (setting up the controller name and action, essentially), I wasn't getting it to work, but I ran out of time budget for fooling with it. > > If anyone thinks of an approach that could be more robust, I'd sure be interested. This sounds like a bug - can somebody familiar w/ this problem please file a ticket at http://rspec.lighthouseapp.com? Thanks, David > > Until then, > > > Randy > > > > ----- Original Message ---- >> From: "r_j_h_box-sf at yahoo.com" >> To: rspec-users >> Sent: Saturday, January 31, 2009 11:40:54 PM >> Subject: Re: [rspec-users] resource urls only work *after* a get() in controller spec >> >> thanks, Ben - that didn't do the trick, though. >> >> I traced it down as far as this: >> >> the controller hasn't initialized its current url - that's the immediate cause >> of the method-on-nil complaint. It hasn't, because the controller isn't >> technically handling a request yet (i.e., process()). I tried monkey-patching >> the controller to allow me to call its initialize_current_url to get around >> this, but I didn't (yet) find how to fake up its request and params sufficiently >> to have that work. >> >> Understandably, the controller can't know what the current url is, unless >> rpsec-rails were to have a way to discover it from the example group. I'm not >> sure that I'm proposing a change to a declarative style for controller actions - >> for my purpose, I'd be satisfied to fake it to think 'index' is the current url >> (in advance of processing the real request as specified by get() and friends). >> >> Hopefully this rings enough bells to make a workaround self-evident to >> somebody. Anybody? Else I'll see what I can dig up from the rspec/rspec-rails >> source that can be enough of a resource. >> >> Thanks, >> >> Randy >> >> >> >> >> >> ----- Original Message ---- >> > From: Ben Mabey >> > To: rspec-users >> > Sent: Saturday, January 31, 2009 5:41:56 PM >> > Subject: Re: [rspec-users] resource urls only work *after* a get() in >> controller spec >> > >> > r_j_h_box-sf at yahoo.com wrote: >> > > I'm encountering an interesting symptom during example execution. I'm >> > > making a shared example group that dries up belongs-to-me before_filter >> > > testing, and it makes a callback to the example group that says >> > > it_should_behave_like that. The callback tells the shared example >> > > where to expect a redirect for failure. >> > > >> > > It seems that prior to >> > > executing a get() (etc), the resource-based url functions aren't >> > > accessible. Following the get(), topics_url works fine. But before >> > > then, it gives an error like this: >> > > >> > > http://pastie.org/376096 >> > > >> > > Is >> > > this a known issue? Is there a workaround I can use? >> > For a workaround try doing a "include ActionController::UrlWriter" in your >> > shared example group. >> > >> > -Ben >> > _______________________________________________ >> > 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 Feb 10 15:19:11 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 10 Feb 2009 14:19:11 -0600 Subject: [rspec-users] exemplary way to show a list is sorted? In-Reply-To: <860c114f0902081548j3b1c18bco44ae938836d02adc@mail.gmail.com> References: <860c114f0902081548j3b1c18bco44ae938836d02adc@mail.gmail.com> Message-ID: <57c63afe0902101219w5accb52fv477e11f8b386fe80@mail.gmail.com> On Sun, Feb 8, 2009 at 5:48 PM, Phlip wrote: > RSpeckers: > > I'm asserting that a list should be sorted by affinity. The following In BDD we say "expecting" instead of "asserting" > code is good enough for government work, but is there some more clever > way to show that each element is equal or less than the previous > element? > > it 'should rank posts by affinity' do > list = @map.sort_frobs_by_affinity > > list[1].affinity.should >= list[1].affinity please use "should be >=" as "should >=" will eventually be deprecated and removed. > list[2].affinity.should >= list[2].affinity > list[3].affinity.should >= list[3].affinity > list[4].affinity.should >= list[4].affinity > end > > Notice I could just write... > > list.map(&:affinity) == list.map(&:affinity) > > ...but it seems that the point of BDD is to make the business logic > obvious, not obscured in programming details, right? Right. I've done stuff like this before: [b,d,a,c].sort_with_special_method.should == [a,b,c,d] Any other patterns out there? David > > -- > Phlip > http://www.oreilly.com/catalog/9780596510657/ > ^ assert_xpath > http://tinyurl.com/yrc77g <-- assert_latest Model > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Tue Feb 10 15:42:59 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 10 Feb 2009 21:42:59 +0100 Subject: [rspec-users] Pass a variable from rake to steps file in cucumber In-Reply-To: <21746008.post@talk.nabble.com> References: <21746008.post@talk.nabble.com> Message-ID: <8d961d900902101242i384e9008rdbeef4402f014397@mail.gmail.com> dude. have you lost your memory? didn't we have this conversation a week ago? http://www.nabble.com/-Cucumber--and-rake-pass-command-line-params-tt21789574.html aslak On Fri, Jan 30, 2009 at 1:26 PM, AndreXP wrote: > > Can anybody tell me how to pass a variable from the rake command to my steps > file using cucumber? I have the following in my Rakefile: > > ## Rakefile > Cucumber::Rake::Task.new do |t| > profile = ENV['PROFILE'] || 'default' > browser_type = ENV['BROWSER'] || '*chrome' > t.cucumber_opts = "--profile #{profile}" > end > > I would like to have access to the "browser_type" variable in my "Before do" > in my_steps.rb file. > > ## my_steps.rb > Before do > $browser = Selenium::SeleniumDriver.new($server_host, $server_port, > "browser_type", $root_url, $time_out) > end > > Thanks for the help. > -- > View this message in context: http://www.nabble.com/Pass-a-variable-from-rake-to-steps-file-in-cucumber-tp21746008p21746008.html > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From nathan at pivotallabs.com Tue Feb 10 15:02:20 2009 From: nathan at pivotallabs.com (Nathan Wilmes) Date: Tue, 10 Feb 2009 12:02:20 -0800 Subject: [rspec-users] issues with the trunk of rspec-rails Message-ID: <8d0d70270902101202y1aeab001hbfa85777e0307108@mail.gmail.com> Hi folks, I'm currently in the process of upgrading an old Rails project to the Rails 2.2.2 and the trunk of RSpec, and ran into several issues with rspec-rails. I've come up with workarounds for all of them, but I wanted to report them to hopefully get them into better shape for other folks. (1) config.include doesn't work on controller, helper, or view specs if no :type parameter is required. config.include sends an include to RailsExampleGroup. Unfortunately, these specs no longer extend RailsExampleGroup. Here's my monkey patch: module Spec module Runner class Configuration def get_type_from_options(options) options[:type] || options[:behaviour_type] || [:controller, :model, :view, :helper, nil] end end end end (2) The render override for RSpec controllers only takes one argument. This means that any controller using two argument forms will fail. Our biggest use case for the two-argument controller form is this: render :update, :status => 404 do {} This case is still allowable and not deprecated in Rails 2.2.2. (3) with_tag is completely broken, as it tries to use the outer class as the subject of 'with_tag', rather than the have_tag matcher that it lives inside. (4) assigns(:xxx) will give really bad errors if your class doesn't happen to define == in such a way that it can equate to FalseClass. Let me know if you'd like examples or extra explanation. =N -------------- next part -------------- An HTML attachment was scrubbed... URL: From r_j_h_box-sf at yahoo.com Tue Feb 10 16:23:02 2009 From: r_j_h_box-sf at yahoo.com (r_j_h_box-sf at yahoo.com) Date: Tue, 10 Feb 2009 13:23:02 -0800 (PST) Subject: [rspec-users] resource urls only work *after* a get() in controller spec In-Reply-To: <57c63afe0902101215q611b9574y3403551c2e60d140@mail.gmail.com> References: <346979.70476.qm@web31811.mail.mud.yahoo.com> <57c63afe0902101215q611b9574y3403551c2e60d140@mail.gmail.com> Message-ID: <402709.8060.qm@web31802.mail.mud.yahoo.com> Done: http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/692-route-based-_url-or-_path-functions-dont-work-until-getpost-are-called Randy ----- Original Message ---- > From: David Chelimsky > To: rspec-users > Sent: Tuesday, February 10, 2009 12:15:48 PM > Subject: Re: [rspec-users] resource urls only work *after* a get() in controller spec > > On Mon, Feb 2, 2009 at 12:17 AM, Randy Harmon wrote: > > > > Okay, following up on this item. Would you believe a workaround of (gasp) get > :index, prior to expecting route-based URLs to work? (slaps forehead). or > do_action(), provided by the host example group (the more concrete example > group, I mean - what's the right terminology there?). > > > > I tried reproducing the stuff I saw being done in > action_controller/test_process.rb up to the point where the resource url > function started working, but when I did that (setting up the controller name > and action, essentially), I wasn't getting it to work, but I ran out of time > budget for fooling with it. > > > > If anyone thinks of an approach that could be more robust, I'd sure be > interested. > > This sounds like a bug - can somebody familiar w/ this problem please > file a ticket at http://rspec.lighthouseapp.com? > > Thanks, > David > > > > > Until then, > > > > > > Randy > > > > > > > > ----- Original Message ---- > >> From: "r_j_h_box-sf at yahoo.com" > >> To: rspec-users > >> Sent: Saturday, January 31, 2009 11:40:54 PM > >> Subject: Re: [rspec-users] resource urls only work *after* a get() in > controller spec > >> > >> thanks, Ben - that didn't do the trick, though. > >> > >> I traced it down as far as this: > >> > >> the controller hasn't initialized its current url - that's the immediate > cause > >> of the method-on-nil complaint. It hasn't, because the controller isn't > >> technically handling a request yet (i.e., process()). I tried > monkey-patching > >> the controller to allow me to call its initialize_current_url to get around > >> this, but I didn't (yet) find how to fake up its request and params > sufficiently > >> to have that work. > >> > >> Understandably, the controller can't know what the current url is, unless > >> rpsec-rails were to have a way to discover it from the example group. I'm > not > >> sure that I'm proposing a change to a declarative style for controller > actions - > >> for my purpose, I'd be satisfied to fake it to think 'index' is the current > url > >> (in advance of processing the real request as specified by get() and > friends). > >> > >> Hopefully this rings enough bells to make a workaround self-evident to > >> somebody. Anybody? Else I'll see what I can dig up from the > rspec/rspec-rails > >> source that can be enough of a resource. > >> > >> Thanks, > >> > >> Randy > >> > >> > >> > >> > >> > >> ----- Original Message ---- > >> > From: Ben Mabey > >> > To: rspec-users > >> > Sent: Saturday, January 31, 2009 5:41:56 PM > >> > Subject: Re: [rspec-users] resource urls only work *after* a get() in > >> controller spec > >> > > >> > r_j_h_box-sf at yahoo.com wrote: > >> > > I'm encountering an interesting symptom during example execution. I'm > >> > > making a shared example group that dries up belongs-to-me before_filter > >> > > testing, and it makes a callback to the example group that says > >> > > it_should_behave_like that. The callback tells the shared example > >> > > where to expect a redirect for failure. > >> > > > >> > > It seems that prior to > >> > > executing a get() (etc), the resource-based url functions aren't > >> > > accessible. Following the get(), topics_url works fine. But before > >> > > then, it gives an error like this: > >> > > > >> > > http://pastie.org/376096 > >> > > > >> > > Is > >> > > this a known issue? Is there a workaround I can use? > >> > For a workaround try doing a "include ActionController::UrlWriter" in your > >> > shared example group. > >> > > >> > -Ben > >> > _______________________________________________ > >> > rspec-users mailing list > >> > rspec-users at rubyforge.org > >> > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Tue Feb 10 16:26:28 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 10 Feb 2009 15:26:28 -0600 Subject: [rspec-users] resource urls only work *after* a get() in controller spec In-Reply-To: <402709.8060.qm@web31802.mail.mud.yahoo.com> References: <346979.70476.qm@web31811.mail.mud.yahoo.com> <57c63afe0902101215q611b9574y3403551c2e60d140@mail.gmail.com> <402709.8060.qm@web31802.mail.mud.yahoo.com> Message-ID: <57c63afe0902101326l1d7c4db4x4d24671f181e06a3@mail.gmail.com> On Tue, Feb 10, 2009 at 3:23 PM, wrote: > > Done: > > http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/692-route-based-_url-or-_path-functions-dont-work-until-getpost-are-called Great. Thx. > > > Randy > > > ----- Original Message ---- >> From: David Chelimsky >> To: rspec-users >> Sent: Tuesday, February 10, 2009 12:15:48 PM >> Subject: Re: [rspec-users] resource urls only work *after* a get() in controller spec >> >> On Mon, Feb 2, 2009 at 12:17 AM, Randy Harmon wrote: >> > >> > Okay, following up on this item. Would you believe a workaround of (gasp) get >> :index, prior to expecting route-based URLs to work? (slaps forehead). or >> do_action(), provided by the host example group (the more concrete example >> group, I mean - what's the right terminology there?). >> > >> > I tried reproducing the stuff I saw being done in >> action_controller/test_process.rb up to the point where the resource url >> function started working, but when I did that (setting up the controller name >> and action, essentially), I wasn't getting it to work, but I ran out of time >> budget for fooling with it. >> > >> > If anyone thinks of an approach that could be more robust, I'd sure be >> interested. >> >> This sounds like a bug - can somebody familiar w/ this problem please >> file a ticket at http://rspec.lighthouseapp.com? >> >> Thanks, >> David >> >> > >> > Until then, >> > >> > >> > Randy >> > >> > >> > >> > ----- Original Message ---- >> >> From: "r_j_h_box-sf at yahoo.com" >> >> To: rspec-users >> >> Sent: Saturday, January 31, 2009 11:40:54 PM >> >> Subject: Re: [rspec-users] resource urls only work *after* a get() in >> controller spec >> >> >> >> thanks, Ben - that didn't do the trick, though. >> >> >> >> I traced it down as far as this: >> >> >> >> the controller hasn't initialized its current url - that's the immediate >> cause >> >> of the method-on-nil complaint. It hasn't, because the controller isn't >> >> technically handling a request yet (i.e., process()). I tried >> monkey-patching >> >> the controller to allow me to call its initialize_current_url to get around >> >> this, but I didn't (yet) find how to fake up its request and params >> sufficiently >> >> to have that work. >> >> >> >> Understandably, the controller can't know what the current url is, unless >> >> rpsec-rails were to have a way to discover it from the example group. I'm >> not >> >> sure that I'm proposing a change to a declarative style for controller >> actions - >> >> for my purpose, I'd be satisfied to fake it to think 'index' is the current >> url >> >> (in advance of processing the real request as specified by get() and >> friends). >> >> >> >> Hopefully this rings enough bells to make a workaround self-evident to >> >> somebody. Anybody? Else I'll see what I can dig up from the >> rspec/rspec-rails >> >> source that can be enough of a resource. >> >> >> >> Thanks, >> >> >> >> Randy >> >> >> >> >> >> >> >> >> >> >> >> ----- Original Message ---- >> >> > From: Ben Mabey >> >> > To: rspec-users >> >> > Sent: Saturday, January 31, 2009 5:41:56 PM >> >> > Subject: Re: [rspec-users] resource urls only work *after* a get() in >> >> controller spec >> >> > >> >> > r_j_h_box-sf at yahoo.com wrote: >> >> > > I'm encountering an interesting symptom during example execution. I'm >> >> > > making a shared example group that dries up belongs-to-me before_filter >> >> > > testing, and it makes a callback to the example group that says >> >> > > it_should_behave_like that. The callback tells the shared example >> >> > > where to expect a redirect for failure. >> >> > > >> >> > > It seems that prior to >> >> > > executing a get() (etc), the resource-based url functions aren't >> >> > > accessible. Following the get(), topics_url works fine. But before >> >> > > then, it gives an error like this: >> >> > > >> >> > > http://pastie.org/376096 >> >> > > >> >> > > Is >> >> > > this a known issue? Is there a workaround I can use? >> >> > For a workaround try doing a "include ActionController::UrlWriter" in your >> >> > shared example group. >> >> > >> >> > -Ben >> >> > _______________________________________________ >> >> > 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 ben at benmabey.com Tue Feb 10 16:30:49 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 10 Feb 2009 14:30:49 -0700 Subject: [rspec-users] [ANN] IRC rooms are now logged Message-ID: <4991F209.3060901@benmabey.com> Hey all, Thanks to Chris Schneider the #rspec, #cucumber, and #webrat freenode rooms are all being logged now! The logs can be found here: http://irclogger.com/ The code is all on github[1] so if you would like to add/change something just fork it and send a pull request to Chris. If you see cschneid in the rooms be sure to tell him thanks. -Ben 1.http://github.com/cschneid/irclogger/tree/master From pergesu at gmail.com Tue Feb 10 17:21:31 2009 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 10 Feb 2009 14:21:31 -0800 Subject: [rspec-users] exemplary way to show a list is sorted? In-Reply-To: <57c63afe0902101219w5accb52fv477e11f8b386fe80@mail.gmail.com> References: <860c114f0902081548j3b1c18bco44ae938836d02adc@mail.gmail.com> <57c63afe0902101219w5accb52fv477e11f8b386fe80@mail.gmail.com> Message-ID: <810a540e0902101421y64c6529bp11d8b5c695b2e75c@mail.gmail.com> On Tue, Feb 10, 2009 at 12:19 PM, David Chelimsky wrote: > Right. I've done stuff like this before: > > [b,d,a,c].sort_with_special_method.should == [a,b,c,d] > > Any other patterns out there? That's how I do it. Pat From dchelimsky at gmail.com Tue Feb 10 17:30:55 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 10 Feb 2009 16:30:55 -0600 Subject: [rspec-users] Pass a variable from rake to steps file in cucumber In-Reply-To: <8d961d900902101242i384e9008rdbeef4402f014397@mail.gmail.com> References: <21746008.post@talk.nabble.com> <8d961d900902101242i384e9008rdbeef4402f014397@mail.gmail.com> Message-ID: <57c63afe0902101430o5a5546e5x7301a93bf2913f84@mail.gmail.com> On Tue, Feb 10, 2009 at 2:42 PM, aslak hellesoy wrote: > dude. have you lost your memory? didn't we have this conversation a week ago? > > http://www.nabble.com/-Cucumber--and-rake-pass-command-line-params-tt21789574.html Sorry - my fault - was going back through some email that was pending moderation :) Note the date is Jan 30. Cheers, David > > aslak > > On Fri, Jan 30, 2009 at 1:26 PM, AndreXP wrote: >> >> Can anybody tell me how to pass a variable from the rake command to my steps >> file using cucumber? I have the following in my Rakefile: >> >> ## Rakefile >> Cucumber::Rake::Task.new do |t| >> profile = ENV['PROFILE'] || 'default' >> browser_type = ENV['BROWSER'] || '*chrome' >> t.cucumber_opts = "--profile #{profile}" >> end >> >> I would like to have access to the "browser_type" variable in my "Before do" >> in my_steps.rb file. >> >> ## my_steps.rb >> Before do >> $browser = Selenium::SeleniumDriver.new($server_host, $server_port, >> "browser_type", $root_url, $time_out) >> end >> >> Thanks for the help. >> -- >> View this message in context: http://www.nabble.com/Pass-a-variable-from-rake-to-steps-file-in-cucumber-tp21746008p21746008.html >> Sent from the rspec-users mailing list archive at Nabble.com. >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Aslak (::) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From patnakajima at gmail.com Tue Feb 10 17:45:22 2009 From: patnakajima at gmail.com (Pat Nakajima) Date: Tue, 10 Feb 2009 17:45:22 -0500 Subject: [rspec-users] issues with the trunk of rspec-rails In-Reply-To: <8d0d70270902101202y1aeab001hbfa85777e0307108@mail.gmail.com> References: <8d0d70270902101202y1aeab001hbfa85777e0307108@mail.gmail.com> Message-ID: <97ae2db00902101445l39975a2cx1e4daff16f093a72@mail.gmail.com> > > (3) with_tag is completely broken, as it tries to use the outer class as > the subject of 'with_tag', rather than the have_tag matcher that it lives > inside. > If you're testing markup (view tests or whatever), take a look at my elementor project[1]. I've found that it makes view testing a lot more expressive, a lot less brittle, and a lot more fun! (Ok, maybe not the last bit). It also uses Nokogiri, so it's much faster than have_tag. 1. http://github.com/nakajima/elementor/tree/master Pat On Tue, Feb 10, 2009 at 3:02 PM, Nathan Wilmes wrote: > Hi folks, > > I'm currently in the process of upgrading an old Rails project to the Rails > 2.2.2 and the trunk of RSpec, and ran into several issues with rspec-rails. > I've come up with workarounds for all of them, but I wanted to report them > to hopefully get them into better shape for other folks. > > (1) config.include doesn't work on controller, helper, or view specs if no > :type parameter is required. > > config.include sends an include to RailsExampleGroup. Unfortunately, these > specs no longer extend RailsExampleGroup. Here's my monkey patch: > module Spec > module Runner > class Configuration > def get_type_from_options(options) > options[:type] || options[:behaviour_type] || [:controller, :model, > :view, :helper, nil] > end > end > end > end > > (2) The render override for RSpec controllers only takes one argument. > This means that any controller using two argument forms will fail. > > Our biggest use case for the two-argument controller form is this: render > :update, :status => 404 do {} > This case is still allowable and not deprecated in Rails 2.2.2. > > (3) with_tag is completely broken, as it tries to use the outer class as > the subject of 'with_tag', rather than the have_tag matcher that it lives > inside. > > (4) assigns(:xxx) will give really bad errors if your class doesn't happen > to define == in such a way that it can equate to FalseClass. > > Let me know if you'd like examples or extra explanation. > =N > > _______________________________________________ > 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 Tue Feb 10 18:22:07 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 11 Feb 2009 00:22:07 +0100 Subject: [rspec-users] exemplary way to show a list is sorted? In-Reply-To: <57c63afe0902101219w5accb52fv477e11f8b386fe80@mail.gmail.com> References: <860c114f0902081548j3b1c18bco44ae938836d02adc@mail.gmail.com> <57c63afe0902101219w5accb52fv477e11f8b386fe80@mail.gmail.com> Message-ID: <6997dd6cfd2ee88c78a4aa242ed9008a@ruby-forum.com> David Chelimsky wrote: > > please use "should be >=" as "should >=" will eventually be deprecated > and removed. > Removed? You are not seriously contemplating forcing people to go back and rewrite formally working specifications simply to tidy up the syntax are you? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Feb 10 18:24:32 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 11 Feb 2009 00:24:32 +0100 Subject: [rspec-users] Bizarre problem with Rake / Rcov In-Reply-To: References: Message-ID: James Byrne wrote: > > Where and How is this constant getting its value changed? The evidence > indicates that the array R_RCOV_BASIC_OPTS has the contents of rcov_opta > appended each time that the factory method is called but I cannot see > where or how this is happening. > t.rcov_opts = R_RCOV_BASIC_OPTS t.rcov_opts << r_rcov_opta sigh... -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Tue Feb 10 18:58:57 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 11 Feb 2009 00:58:57 +0100 Subject: [rspec-users] Pass a variable from rake to steps file in cucumber In-Reply-To: <57c63afe0902101430o5a5546e5x7301a93bf2913f84@mail.gmail.com> References: <21746008.post@talk.nabble.com> <8d961d900902101242i384e9008rdbeef4402f014397@mail.gmail.com> <57c63afe0902101430o5a5546e5x7301a93bf2913f84@mail.gmail.com> Message-ID: <8d961d900902101558j665f3d12nd63dce63f07a3dfb@mail.gmail.com> On Tue, Feb 10, 2009 at 11:30 PM, David Chelimsky wrote: > On Tue, Feb 10, 2009 at 2:42 PM, aslak hellesoy > wrote: >> dude. have you lost your memory? didn't we have this conversation a week ago? >> >> http://www.nabble.com/-Cucumber--and-rake-pass-command-line-params-tt21789574.html > > Sorry - my fault - was going back through some email that was pending > moderation :) Note the date is Jan 30. > Haha. Andre, please disregard my comment. Aslak > Cheers, > David > >> >> aslak >> >> On Fri, Jan 30, 2009 at 1:26 PM, AndreXP wrote: >>> >>> Can anybody tell me how to pass a variable from the rake command to my steps >>> file using cucumber? I have the following in my Rakefile: >>> >>> ## Rakefile >>> Cucumber::Rake::Task.new do |t| >>> profile = ENV['PROFILE'] || 'default' >>> browser_type = ENV['BROWSER'] || '*chrome' >>> t.cucumber_opts = "--profile #{profile}" >>> end >>> >>> I would like to have access to the "browser_type" variable in my "Before do" >>> in my_steps.rb file. >>> >>> ## my_steps.rb >>> Before do >>> $browser = Selenium::SeleniumDriver.new($server_host, $server_port, >>> "browser_type", $root_url, $time_out) >>> end >>> >>> Thanks for the help. >>> -- >>> View this message in context: http://www.nabble.com/Pass-a-variable-from-rake-to-steps-file-in-cucumber-tp21746008p21746008.html >>> Sent from the rspec-users mailing list archive at Nabble.com. >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> >> >> -- >> Aslak (::) >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From zach.dennis at gmail.com Tue Feb 10 20:00:52 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Tue, 10 Feb 2009 20:00:52 -0500 Subject: [rspec-users] exemplary way to show a list is sorted? In-Reply-To: <6997dd6cfd2ee88c78a4aa242ed9008a@ruby-forum.com> References: <860c114f0902081548j3b1c18bco44ae938836d02adc@mail.gmail.com> <57c63afe0902101219w5accb52fv477e11f8b386fe80@mail.gmail.com> <6997dd6cfd2ee88c78a4aa242ed9008a@ruby-forum.com> Message-ID: <85d99afe0902101700l170e93bdi4a733716bfce467a@mail.gmail.com> On Tue, Feb 10, 2009 at 6:22 PM, James Byrne wrote: > David Chelimsky wrote: > >> >> please use "should be >=" as "should >=" will eventually be deprecated >> and removed. >> > > Removed? You are not seriously contemplating forcing people to go back > and rewrite formally working specifications simply to tidy up the syntax > are you? Forcing people, eh? You don't have to upgrade when that release is made. No one is holding a gun to your head. You can always choose to progress with the library, as it continues to evolve into new and better ways of doing things. Given the "should >=" to "should be >=" transition, I'm sure you can safely do a find and replace in merely a few seconds if you bust out a little regexp-fu, or maybe a few minutes if you do separate searches for each operator. If the idea of change is that abrasive to you, go to github, and feel free to fork it yourself. After all, the jamesbyrne-rspec library is only a few minutes away, -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From cflipse at gmail.com Tue Feb 10 20:10:23 2009 From: cflipse at gmail.com (Chris Flipse) Date: Tue, 10 Feb 2009 20:10:23 -0500 Subject: [rspec-users] [cucumber] [alpha] The Backgrounder is run without cleaning up Message-ID: This /could/ just a screwy behavior I'm seeing in SQL lite, but I don't think so; normal scenarios are doing this just fine. I'm playing with the Background feature in the .1.99 beta, and it looks like it's being run before every feature -- but it's not cleaning up afterwards. I have a model with a validates_uniquness_of in place, and I'm seeing something that looks like this: Feature: It should be able to run for multiple files Background: Given a model with unique name "Foobar" Scenario: This one runs okay # .... Scenario: But this one fails # background is run, and fails to create the model because of the validation Is this known, and fixed in github, or have I stumbled on something new? -- // anything worth taking seriously is worth making fun of // http://blog.devcaffeine.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Tue Feb 10 21:43:09 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Wed, 11 Feb 2009 03:43:09 +0100 Subject: [rspec-users] Cucumber - How to enable a disabled field Message-ID: <188f0ffe9c1701e54b876847171d4512@ruby-forum.com> Is there way in Cucumber to enable a field or submit button that was disabled by default (:disable => true). I have a submit button which is enabled using javascript and would like to test the page using Cucumber. Thanks for your advice, Tom -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Feb 10 22:09:47 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 11 Feb 2009 04:09:47 +0100 Subject: [rspec-users] exemplary way to show a list is sorted? In-Reply-To: <85d99afe0902101700l170e93bdi4a733716bfce467a@mail.gmail.com> References: <860c114f0902081548j3b1c18bco44ae938836d02adc@mail.gmail.com> <57c63afe0902101219w5accb52fv477e11f8b386fe80@mail.gmail.com> <6997dd6cfd2ee88c78a4aa242ed9008a@ruby-forum.com> <85d99afe0902101700l170e93bdi4a733716bfce467a@mail.gmail.com> Message-ID: <7e1ef3d95e6a9d848eeb1032755278fd@ruby-forum.com> Zach Dennis wrote: > On Tue, Feb 10, 2009 at 6:22 PM, James Byrne > wrote: >> David Chelimsky wrote: >> >>> >>> please use "should be >=" as "should >=" will eventually be deprecated >>> and removed. >>> >> >> Removed? You are not seriously contemplating forcing people to go back >> and rewrite formally working specifications simply to tidy up the syntax >> are you? > > Forcing people, eh? You don't have to upgrade when that release is > made. No one is holding a gun to your head. You can always choose to > progress with the library, as it continues to evolve into new and > better ways of doing things. There are enterprises in which the stability of development tools and the confidence that one will not be forced to redo work already completed is considered somewhat important, whatever your own situation might be. Likewise, assuming the costs of maintaining a customized variant of a general tool or foregoing future improvements in same to maintain the value of existing work is not a choice savoured by many firms that I can bring to mind, even if yours might be exceptional in this regard. At issue is something commonly referred to as cost/benefit, which ultimately turns into profit and loss. I simply fail to see why evolving a tool in "better ways" necessarily requires that the formerly "better" but now depreciated method be removed. Such action causes avoidable and pointless work. I consider my observation to be both reasonable and pertinent. -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Tue Feb 10 22:52:48 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Tue, 10 Feb 2009 22:52:48 -0500 Subject: [rspec-users] exemplary way to show a list is sorted? In-Reply-To: <7e1ef3d95e6a9d848eeb1032755278fd@ruby-forum.com> References: <860c114f0902081548j3b1c18bco44ae938836d02adc@mail.gmail.com> <57c63afe0902101219w5accb52fv477e11f8b386fe80@mail.gmail.com> <6997dd6cfd2ee88c78a4aa242ed9008a@ruby-forum.com> <85d99afe0902101700l170e93bdi4a733716bfce467a@mail.gmail.com> <7e1ef3d95e6a9d848eeb1032755278fd@ruby-forum.com> Message-ID: <85d99afe0902101952g21beb83fkd332a179924ef88d@mail.gmail.com> On Tue, Feb 10, 2009 at 10:09 PM, James Byrne wrote: > Zach Dennis wrote: >> On Tue, Feb 10, 2009 at 6:22 PM, James Byrne >> wrote: >>> David Chelimsky wrote: >>> >>>> >>>> please use "should be >=" as "should >=" will eventually be deprecated >>>> and removed. >>>> >>> >>> Removed? You are not seriously contemplating forcing people to go back >>> and rewrite formally working specifications simply to tidy up the syntax >>> are you? >> >> Forcing people, eh? You don't have to upgrade when that release is >> made. No one is holding a gun to your head. You can always choose to >> progress with the library, as it continues to evolve into new and >> better ways of doing things. > > There are enterprises in which the stability of development tools and > the confidence that one will not be forced to redo work already > completed is considered somewhat important, whatever your own situation > might be. Likewise, assuming the costs of maintaining a customized > variant of a general tool or foregoing future improvements in same to > maintain the value of existing work is not a choice savoured by many > firms that I can bring to mind, even if yours might be exceptional in > this regard. At issue is something commonly referred to as > cost/benefit, which ultimately turns into profit and loss. > > I simply fail to see why evolving a tool in "better ways" necessarily > requires that the formerly "better" but now depreciated method be > removed. Just like there is cost associated with you taking time to update your software to work with changes in the libraries and tools you use, there is cost that the developers and maintainers of those very libraries and tools will incur in order to maintain backwards compatibility for features that are no longer deemed necessary. This will lead to large negative effects over time, like a snowball rolling down a hill. When the snow is good for packing though--none of that fluffy stuff that doesn't stick. > Such action causes avoidable and pointless work. And to disprove this argument I will defer to the avoidable and pointless work you will be causing those who maintain the software, > I consider my > observation to be both reasonable and pertinent. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From lists at ruby-forum.com Tue Feb 10 22:55:28 2009 From: lists at ruby-forum.com (Sergio Bayona) Date: Wed, 11 Feb 2009 04:55:28 +0100 Subject: [rspec-users] how can this pass? In-Reply-To: <810a540e0902100054v3913fc2eh51249e89e59abe4a@mail.gmail.com> References: <8d961d900902081756y59f125edvcefd23cd53cf777a@mail.gmail.com> <198fe603cf08783f23858549b495870a@ruby-forum.com> <3c30da400902082124v4e34eaa1sca60a12348170689@mail.gmail.com> <61828a3b1a6ed3ab01a9712f7d8af733@ruby-forum.com> <810a540e0902100054v3913fc2eh51249e89e59abe4a@mail.gmail.com> Message-ID: <29e65e6f04024f041827b3c8d8bd610e@ruby-forum.com> Pat Maddox wrote: > On Mon, Feb 9, 2009 at 10:18 PM, Sergio Bayona > wrote: >>>> >> >> other is an AR object. But, shouldn't it return the mock property? >> []) >> respond_to do |format| >> got: #> nil, zip: nil, uasap: nil, tax_number: nil, rent_due: nil, units_count: >> 0, issues_count: 0, account_id: 1, created_at: nil, updated_at: nil> >> (using ==) >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > Hi in your new method, where does @account come from? Is it loaded > through some kind of before_filter, or as part of the authentication > framework? > > Anyway, once you've built up your mock expectations you now need to > inject the mock into the code. You do this by stubbing the code that > loads up the @account object - typically you're just doing an > Account.find call somewhere. Note also that you need to specify that > account returns something when properties is called - you need to hook > up the association proxy. > > it "should expose a new property as @property" do > @account = mock_model(Account) > Account.should_receive(:find).with("1").and_return @account > @account.stub!(:properties).and_return mock('properties proxy') > @property = mock_model(Property, :new_record? => false, :errors => > []) > @account.properties.should_receive(:build).and_return(@property) > get :new > assigns[:property].should == @property > end > end > > additionally I would only have two expectations (should_receive) and > would loosen the rest by just stubbing: > > it "should expose a new property as @property" do > # arrange > @account = mock_model(Account, :properties => mock('properties > proxy')) > @property = mock_model(Property, :new_record? => false, :errors => > []) > @account.properties.stub!(:build).and_return(@property) > > # sanity check > Account.should_receive(:find).with("1").and_return @account > > # act > get :new > > # assert > assigns[:property].should == @property > end > end > > I like to minimize the number of expectations(/assertions) that appear > in the example. Doing so clearly communicates the important behavior. > If the final expectation passes, you can infer that it's doing the > right thing with the model because that's the only way to get to your > mock @property. Finally I threw in an Account.should_receive("1") > because you need to inject the mock account somehow. That does the > trick, and it also serves as a sanity check for the contract between > controller and model - Account.find is the entry point to the model in > this action. > > Does that make sense? > > Pat Thanks Pat. You're right. Account comes from a before_filter that triggers this: def current_account @account ||= Account.find_by_subdomain(account_subdomain) end I have stubbed the code on the spec_helper.rb to do that as: def current_account(account) @controller.stub!(:current_account).and_return(@account = account ? accounts(account) : nil) #should return account fixture end on the property spec now I have: describe PropertiesController do fixtures :accounts, :properties, :users before(:each) do current_account(:default) login_as(:default) end describe "responding to GET new" do it "should expose a new property as @property" do property = mock_model(Property, :new_record? => false, :errors => []) @account.properties.should_receive(:build).and_return(property) get :new assigns[:property].should == property end end end but now the controller complains that @account is nil: The error occurred while evaluating nil.properties /www/rentcloud2/app/controllers/properties_controller.rb:23:in `new' I thought by stubbing the current_account code and returning @account, that'd be available to the application. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Tue Feb 10 23:21:16 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 10 Feb 2009 22:21:16 -0600 Subject: [rspec-users] exemplary way to show a list is sorted? In-Reply-To: <7e1ef3d95e6a9d848eeb1032755278fd@ruby-forum.com> References: <860c114f0902081548j3b1c18bco44ae938836d02adc@mail.gmail.com> <57c63afe0902101219w5accb52fv477e11f8b386fe80@mail.gmail.com> <6997dd6cfd2ee88c78a4aa242ed9008a@ruby-forum.com> <85d99afe0902101700l170e93bdi4a733716bfce467a@mail.gmail.com> <7e1ef3d95e6a9d848eeb1032755278fd@ruby-forum.com> Message-ID: <57c63afe0902102021y42432128xa5c5d7004f53afe4@mail.gmail.com> On Tue, Feb 10, 2009 at 9:09 PM, James Byrne wrote: > Zach Dennis wrote: >> On Tue, Feb 10, 2009 at 6:22 PM, James Byrne >> wrote: >>> David Chelimsky wrote: >>> >>>> >>>> please use "should be >=" as "should >=" will eventually be deprecated >>>> and removed. >>>> >>> >>> Removed? You are not seriously contemplating forcing people to go back >>> and rewrite formally working specifications simply to tidy up the syntax >>> are you? >> >> Forcing people, eh? You don't have to upgrade when that release is >> made. No one is holding a gun to your head. You can always choose to >> progress with the library, as it continues to evolve into new and >> better ways of doing things. > > There are enterprises in which the stability of development tools and > the confidence that one will not be forced to redo work already > completed is considered somewhat important, whatever your own situation > might be. Likewise, assuming the costs of maintaining a customized > variant of a general tool or foregoing future improvements in same to > maintain the value of existing work is not a choice savoured by many > firms that I can bring to mind, even if yours might be exceptional in > this regard. At issue is something commonly referred to as > cost/benefit, which ultimately turns into profit and loss. > > I simply fail to see why evolving a tool in "better ways" necessarily > requires that the formerly "better" but now depreciated method be > removed. Such action causes avoidable and pointless work. I consider my > observation to be both reasonable and pertinent. Keeping dead weight around has a cost as well, and has to be balanced against the concerns you raise. As RSpec's lead maintainer, I reserve the right to introduce well documented but backwards-compatibility-breaking-changes in major releases (i.e. 2.x, 3.x, etc) if I think it's better for RSpec in the long run. This change would be formally deprecated in a 1.x release and not removed before the 2.0 release. I think you'll find that other libraries in our space (ruby/OSS) operate under the same principles. General operating principles aside, we can certainly have a conversation about the relative merits and cost/benefits of this change. For me, the fact that we can say "should >=" in RSpec is unfortunate. It is ugly, and should not exist. It is also duplication of code elsewhere in the system, which has its own cost, so this is not only about tidying up syntax. It's about paying down technical debt. It's about lowering the barrier of entry to contribution so more people play along. I don't want to make a bigger deal out of this than it is, but it seems like we're already passed that point. FWIW, David From dchelimsky at gmail.com Tue Feb 10 23:26:14 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 10 Feb 2009 22:26:14 -0600 Subject: [rspec-users] Bizarre problem with Rake / Rcov In-Reply-To: References: Message-ID: <57c63afe0902102026g26dc190ep84326211f992509e@mail.gmail.com> On Tue, Feb 10, 2009 at 5:24 PM, James Byrne wrote: > James Byrne wrote: > >> >> Where and How is this constant getting its value changed? The evidence >> indicates that the array R_RCOV_BASIC_OPTS has the contents of rcov_opta >> appended each time that the factory method is called but I cannot see >> where or how this is happening. >> > > t.rcov_opts = R_RCOV_BASIC_OPTS > t.rcov_opts << r_rcov_opta > > sigh... Sorry - not following - does this mean you solved the problem? From dchelimsky at gmail.com Tue Feb 10 23:49:12 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 10 Feb 2009 22:49:12 -0600 Subject: [rspec-users] issues with the trunk of rspec-rails In-Reply-To: <8d0d70270902101202y1aeab001hbfa85777e0307108@mail.gmail.com> References: <8d0d70270902101202y1aeab001hbfa85777e0307108@mail.gmail.com> Message-ID: <57c63afe0902102049l4458525jcfe4bc4af8ebcd21@mail.gmail.com> On Tue, Feb 10, 2009 at 2:02 PM, Nathan Wilmes wrote: > Hi folks, > > I'm currently in the process of upgrading an old Rails project to the Rails > 2.2.2 and the trunk of RSpec, and ran into several issues with rspec-rails. > I've come up with workarounds for all of them, but I wanted to report them > to hopefully get them into better shape for other folks. > > (1) config.include doesn't work on controller, helper, or view specs if no > :type parameter is required. > > config.include sends an include to RailsExampleGroup. Unfortunately, these > specs no longer extend RailsExampleGroup. What are they extending? Are they a custom class? You can resolve this by making your custom class the default: Spec::Example::ExampleGroupFactory.default(MyCustomBaseExampleGroupClass) > Here's my monkey patch: > module Spec > module Runner > class Configuration > def get_type_from_options(options) > options[:type] || options[:behaviour_type] || [:controller, :model, > :view, :helper, nil] > end > end > end > end > > (2) The render override for RSpec controllers only takes one argument. This > means that any controller using two argument forms will fail. > > Our biggest use case for the two-argument controller form is this: render > :update, :status => 404 do {} > This case is still allowable and not deprecated in Rails 2.2.2. I can reinstate the extra arg. Are you looking for it to be handled in some way? Or just to not blow up? > (3) with_tag is completely broken, as it tries to use the outer class as the > subject of 'with_tag', rather than the have_tag matcher that it lives > inside. Was it working before and the upgrade broke existing specs? Or is this a general observation? > (4) assigns(:xxx) will give really bad errors if your class doesn't happen > to define == in such a way that it can equate to FalseClass. Can you provide an example? > > Let me know if you'd like examples or extra explanation. Thanks for the insights thus far. Cheers, David > =N > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Feb 11 00:05:41 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 10 Feb 2009 23:05:41 -0600 Subject: [rspec-users] Weird message on ActiveSupport::Callbacks::CallbackChain:Class In-Reply-To: References: Message-ID: <57c63afe0902102105j2efabeebh7a5cd5651d2adae2@mail.gmail.com> On Tue, Feb 10, 2009 at 9:03 AM, Remi Gagnon wrote: > Hi guys, > > its probably a miss understanding of the framework but I need your > assistance. > > Here is the problem of one of my teammates: > I have a hard time writing rspecs for a class I developed. The class in > question reads an xml document, instanciates the model classes found in the > xml and saves the classes and their attributes in the database with the good > foreign keys. The class is stored in a lib. > > The class : > > class XmlReader > > def self.import_xml(xml_doc) > objects_xml = Array.new > keys_obj = Array.new > xml = REXML::Document.new(xml_doc) > read_xml(xml, objects_xml, keys_obj) > raise AnError.new("Can not save xml objects") if (objects_xml.empty?) > objects_xml.each { |instance| > save_class(instance, keys_obj[objects_xml.index(instance)]) > } > end > ? > end > > The import_xml function acts as an entry point but there are two other > functions involved in the process : > - read_xml : reads the xml elements one by one and instanciates the > classes that have to be with the attributes found in the xml document. It is > called recursively. The two arrays, objects_xml and keys_obj, contain > respectively all the instanciated objects found and all the foreign keys > defined in the relations of the models. > - save_class : saves the instanciated objects contained in the > objets_xml array with the good foreign keys for the relations to be well > done. > > Now, I am trying to test if the objects_xml array is empty. If so, the class > should raise an error. > > The rspec : > > # mocks ? > @mock_element = mock(REXML::Element) > mock_element.stub!(:text) > @mock_element.stub!(:name) > @mock_element.stub!(:elements) > @xml_doc = mock(REXML::Document, :elements => { "e1" => @mock_element, "e2" > => @mock_element }) > @xml_doc.stub!(:new) > @xml_doc.stub!(:has_elements?) > xml_doc.stub!(:encoding) > @objets_xml = mock(Array) > @objets_xml.stub!(:[]=) > @objets_xml.stub!(:[]) > objets_xml.stub!(:empty?) > @keys_obj = mock(Array) > @keys_obj.stub!(:[]=) > @keys_obj.stub!(:[]) > > Array.should_receive(:new).and_return(@objets_xml) > Array.should_receive(:new).and_return(@keys_obj) > REXML::Document.should_receive(:new).and_return(@xml_doc) > XmlReader.should_receive(:read_xml).and_return(true) > objets_xml.should_receive(:empty?).and_return(true) > lambda { XmlReader.import_xml(xml_valid) }.should raise_error(AnError, "Can > not save xml objects") This is one of those "Doctor, it hurts when I do this" sorta situations. The whole point of TDD, and BDD, is to write code examples first so that you end up with code that is inherently testable. Back-filling specs on legacy code (code without tests!) is painful, and you are suffering that pain here. That said, what I'd do here is take a cue from Michael Feather's Working Effectively with Legacy Code. Start with a high level characterization test in which you pass the appropriately structured xml doc and specify the expected outcomes. Don't worry about granular specs about which step in the procedure is doing what at first. Once you have a few of those in place, start to refactor those bits out to other methods that you can spec directly. I realize that this doesn't solve your specific problem directly, but I really have no clue from where I'm sitting as to where ActiveSupport::Callbacks::CallbackChain:Class is injecting itself into this process. HTH, David > > The error : > > undefined method `new' for ActiveSupport::Callbacks::CallbackChain:Class > > This is where my problem is. This error occurs after the test is made and > finished. In other words, the test passes but the framework fails after it > on a callback made in rails for whatever reason. > > Stack trace : > > C:/Projets/Iter8_Conversion/vendor/rails/actionpack/lib/action_controller/test_process.rb:471:in > `method_missing' > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/mocks/proxy.rb:102:in > `__send__' > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/mocks/proxy.rb:102:in > `message_received' > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/mocks/proxy.rb:140:in > `new' > (eval):7:in `teardown_callback_chain' > C:/Projets/Iter8_Conversion/vendor/rails/activesupport/lib/active_support/callbacks.rb:277:in > `send' > C:/Projets/Iter8_Conversion/vendor/rails/activesupport/lib/active_support/callbacks.rb:277:in > `run_callbacks' > C:/ruby/lib/ruby/gems/1.8/gems/rspec-rails-1.1.12/lib/spec/rails/interop/testcase.rb:10 > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:84:in > `instance_eval' > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:84:in > `eval_each_fail_slow' > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:82:in > `each' > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:82:in > `eval_each_fail_slow' > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_group_methods.rb:254:in > `run_after_each' > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_group_methods.rb:253:in > `each' > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_group_methods.rb:253:in > `run_after_each' > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:141:in > `after_each_example' > > Can anyone explain what is happening here or does anyone knows how to bypass > this ? > > Many thanks in advance. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From joshknowles at gmail.com Wed Feb 11 00:15:44 2009 From: joshknowles at gmail.com (Josh Knowles) Date: Wed, 11 Feb 2009 00:15:44 -0500 Subject: [rspec-users] issues with the trunk of rspec-rails In-Reply-To: <8d0d70270902101202y1aeab001hbfa85777e0307108@mail.gmail.com> References: <8d0d70270902101202y1aeab001hbfa85777e0307108@mail.gmail.com> Message-ID: On Tue, Feb 10, 2009 at 3:02 PM, Nathan Wilmes wrote: > Hi folks, > > I'm currently in the process of upgrading an old Rails project to the Rails > 2.2.2 and the trunk of RSpec, and ran into several issues with rspec-rails. > I've come up with workarounds for all of them, but I wanted to report them > to hopefully get them into better shape for other folks. > > (1) config.include doesn't work on controller, helper, or view specs if no > :type parameter is required. I ran into the same problem last night. Modules which I was includning via "config.include..." were only available to my model spec and not to my controller specs. Thanks for tracking this down! -- Josh Knowles phone: 509-979-1593 email: joshknowles at gmail.com web: http://joshknowles.com From pergesu at gmail.com Wed Feb 11 01:44:44 2009 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 10 Feb 2009 22:44:44 -0800 Subject: [rspec-users] Cucumber - How to enable a disabled field In-Reply-To: <188f0ffe9c1701e54b876847171d4512@ruby-forum.com> References: <188f0ffe9c1701e54b876847171d4512@ruby-forum.com> Message-ID: <810a540e0902102244g6b2dc22as400da50b312e9211@mail.gmail.com> You have to go through the browser, using something like selenium (which can be driven by cucumber) Pat On 2/10/09, Tom Hoen wrote: > Is there way in Cucumber to enable a field or submit button that was > disabled by default (:disable => true). I have a submit button which is > enabled using javascript and would like to test the page using Cucumber. > > Thanks for your advice, > Tom > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Feb 11 01:58:30 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 11 Feb 2009 00:58:30 -0600 Subject: [rspec-users] issues with the trunk of rspec-rails In-Reply-To: <57c63afe0902102049l4458525jcfe4bc4af8ebcd21@mail.gmail.com> References: <8d0d70270902101202y1aeab001hbfa85777e0307108@mail.gmail.com> <57c63afe0902102049l4458525jcfe4bc4af8ebcd21@mail.gmail.com> Message-ID: <57c63afe0902102258i777b91aega41627eed9b8f9f3@mail.gmail.com> On Tue, Feb 10, 2009 at 10:49 PM, David Chelimsky wrote: > On Tue, Feb 10, 2009 at 2:02 PM, Nathan Wilmes wrote: >> Hi folks, >> >> I'm currently in the process of upgrading an old Rails project to the Rails >> 2.2.2 and the trunk of RSpec, and ran into several issues with rspec-rails. >> I've come up with workarounds for all of them, but I wanted to report them >> to hopefully get them into better shape for other folks. >> >> (1) config.include doesn't work on controller, helper, or view specs if no >> :type parameter is required. >> >> config.include sends an include to RailsExampleGroup. Unfortunately, these >> specs no longer extend RailsExampleGroup. > > What are they extending? Are they a custom class? You can resolve this > by making your custom class the default: > > Spec::Example::ExampleGroupFactory.default(MyCustomBaseExampleGroupClass) Nevermind that response - after discussing a bit with Zach Dennis, he straightened me out. Fix is in (along w/ specs, of course): http://github.com/dchelimsky/rspec-rails/commit/872149262adbf911b6dd1f6c07805f4bdd3b5939 >> Here's my monkey patch: >> module Spec >> module Runner >> class Configuration >> def get_type_from_options(options) >> options[:type] || options[:behaviour_type] || [:controller, :model, >> :view, :helper, nil] >> end >> end >> end >> end >> >> (2) The render override for RSpec controllers only takes one argument. This >> means that any controller using two argument forms will fail. >> >> Our biggest use case for the two-argument controller form is this: render >> :update, :status => 404 do {} >> This case is still allowable and not deprecated in Rails 2.2.2. > > I can reinstate the extra arg. Are you looking for it to be handled in > some way? Or just to not blow up? > >> (3) with_tag is completely broken, as it tries to use the outer class as the >> subject of 'with_tag', rather than the have_tag matcher that it lives >> inside. > > Was it working before and the upgrade broke existing specs? Or is this > a general observation? > >> (4) assigns(:xxx) will give really bad errors if your class doesn't happen >> to define == in such a way that it can equate to FalseClass. > > Can you provide an example? > >> >> Let me know if you'd like examples or extra explanation. > > Thanks for the insights thus far. > > Cheers, > David > >> =N >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > From aslak.hellesoy at gmail.com Wed Feb 11 02:56:41 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 11 Feb 2009 08:56:41 +0100 Subject: [rspec-users] [cucumber] [alpha] The Backgrounder is run without cleaning up In-Reply-To: References: Message-ID: <8d961d900902102356p19bfaab1ncb4df42fcf3fd651@mail.gmail.com> On Wed, Feb 11, 2009 at 2:10 AM, Chris Flipse wrote: > This /could/ just a screwy behavior I'm seeing in SQL lite, but I don't > think so; normal scenarios are doing this just fine. > > I'm playing with the Background feature in the .1.99 beta, and it looks like > it's being run before every feature -- but it's not cleaning up afterwards. > I have a model with a validates_uniquness_of in place, and I'm seeing > something that looks like this: > > Feature: It should be able to run for multiple files > Background: > Given a model with unique name "Foobar" > > Scenario: This one runs okay > # .... > > Scenario: But this one fails > # background is run, and fails to create the model because of the > validation > > Is this known, and fixed in github, or have I stumbled on something new? > It's known: http://rspec.lighthouseapp.com/projects/16211/tickets/181-background-runs-outside-of-transactions It's not fixed yet. Joseph has done some work to address it. I still have some left to do. Aslak > -- > // anything worth taking seriously is worth making fun of > // http://blog.devcaffeine.com/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From lucasefe at gmail.com Wed Feb 11 04:38:19 2009 From: lucasefe at gmail.com (Lucas Florio) Date: Wed, 11 Feb 2009 07:38:19 -0200 Subject: [rspec-users] Best way of writing fetaures for a wizard Message-ID: <2b4626a90902110138g71a8e18dnb86d39c996df3dab@mail.gmail.com> Hi everyone, I am Lucas and I am starting to use cucumber in project. I need to write a scenario that is little bit complex. Lets suppose I have a Thing and then I need to advance that Thing through 4 stages (something like 'import', 'validation', 'authorization', 'export'). Every stage is a special action/post/request with different outcomes, but the presentation is the same every time, just changing a few labels and buttons. But the problem is that for the user/customer this process is named "Authorization". He doesn't care about the stages. What I mean is that the customer only sees one scenario, while I see 4. What Is the proper way to do this kind of multi-action/complex-process? Well, any thoughts we'll be very appreciated. Thanks in advance. -- Lucas Florio Developer ---- Personal: http://www.lucasefe.com.ar/ Development: http://www.drivendevelopment.com.ar/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Wed Feb 11 06:32:07 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 11 Feb 2009 11:32:07 +0000 Subject: [rspec-users] Best way of writing fetaures for a wizard In-Reply-To: <2b4626a90902110138g71a8e18dnb86d39c996df3dab@mail.gmail.com> References: <2b4626a90902110138g71a8e18dnb86d39c996df3dab@mail.gmail.com> Message-ID: <0685D377-2396-4F3F-8EEA-5ECEF7689FE1@mattwynne.net> On 11 Feb 2009, at 09:38, Lucas Florio wrote: > Hi everyone, I am Lucas and I am starting to use cucumber in project. > > I need to write a scenario that is little bit complex. > > Lets suppose I have a Thing and then I need to advance that Thing > through 4 stages (something like 'import', 'validation', > 'authorization', 'export'). > Every stage is a special action/post/request with different > outcomes, but the presentation is the same every time, just changing > a few labels and buttons. > But the problem is that for the user/customer this process is named > "Authorization". He doesn't care about the stages. > > What I mean is that the customer only sees one scenario, while I see > 4. > What Is the proper way to do this kind of multi-action/complex- > process? Does this help? http://blog.mattwynne.net/2008/11/14/dry-up-your-cucumber-steps/ Matt Wynne http://blog.mattwynne.net http://www.songkick.com From dchelimsky at gmail.com Wed Feb 11 08:35:33 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 11 Feb 2009 07:35:33 -0600 Subject: [rspec-users] Best way of writing fetaures for a wizard In-Reply-To: <2b4626a90902110138g71a8e18dnb86d39c996df3dab@mail.gmail.com> References: <2b4626a90902110138g71a8e18dnb86d39c996df3dab@mail.gmail.com> Message-ID: <57c63afe0902110535n3d060770y3d70149b8e5fd1a9@mail.gmail.com> On Wed, Feb 11, 2009 at 3:38 AM, Lucas Florio wrote: > Hi everyone, I am Lucas and I am starting to use cucumber in project. > > I need to write a scenario that is little bit complex. > > Lets suppose I have a Thing and then I need to advance that Thing through 4 > stages (something like 'import', 'validation', 'authorization', 'export'). > Every stage is a special action/post/request with different outcomes, but > the presentation is the same every time, just changing a few labels and > buttons. > But the problem is that for the user/customer this process is named > "Authorization". He doesn't care about the stages. > > What I mean is that the customer only sees one scenario, while I see 4. > What Is the proper way to do this kind of multi-action/complex-process? If you see Cucumber as customer facing and RSpec as developer facing (as I do), then you'd want one scenario in Cucumber and then the details in RSpec. That make sense? Cheers, David > Well, any thoughts we'll be very appreciated. > Thanks in advance. > -- > Lucas Florio > Developer > ---- > Personal: http://www.lucasefe.com.ar/ > Development: http://www.drivendevelopment.com.ar/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Feb 11 08:42:29 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 11 Feb 2009 07:42:29 -0600 Subject: [rspec-users] Problem with refresh_specs In-Reply-To: References: Message-ID: <57c63afe0902110542v410631fbv1d75c68cbcd114df@mail.gmail.com> On Sat, Jan 31, 2009 at 12:45 AM, jschank wrote: > Hello, > I recently unpacked the latest (1.1.12) rspec and rspec rails in my > applicaiton. Manually? Or using "rake gems:unpack"? > When I run my specs I get: > > config.gem: Unpacked gem rspec-1.1.12 in vendor/gems has no > specification file. Run 'rake gems:refresh_specs' to fix this. > config.gem: Unpacked gem rspec-rails-1.1.12 in vendor/gems has no > specification file. Run 'rake gems:refresh_specs' to fix this. > > > However, when I do what it says, I get this: > [jschank at serenity shindg (maps)]$ rake gems:refresh_specs > (in /Users/jschank/Projects/Rails/shindg) > config.gem: Unpacked gem rspec-1.1.12 in vendor/gems has no > specification file. Run 'rake gems:refresh_specs' to fix this. > config.gem: Unpacked gem rspec-rails-1.1.12 in vendor/gems has no > specification file. Run 'rake gems:refresh_specs' to fix this. > rake aborted! > superclass mismatch for class ModelExampleGroup > > A google search isn't helping me. What can I do to make this warning > go away? > besides piping it to dev/null What version of rails are you using? I've not seen this particular problem on any of the releases. The safe bet with rspec right now is manually installing it vendor/plugins - either by unpacking a gem or checking it out from git or using 'script/install'. HTH, David > Thanks, > John Schank > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Wed Feb 11 08:51:37 2009 From: lists at ruby-forum.com (Kaleem Ullah) Date: Wed, 11 Feb 2009 14:51:37 +0100 Subject: [rspec-users] Rspec approach to test model Message-ID: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> Hi, I am quite new to Rspec. I want to use Rspec to test my existing Code. I start from Models (Unit Testing). Here i want your help on a issue. Here is model/user_spec.rb describe User do before(:each) do @user=User.new @user.id='2' @user.email='kkkk at gmail.com' @user.password='1234' @user.crypted_password= '21066966a0578362e2115f3561bd4f144520ccd2' @user.salt= '574f09d3ae2473105567eab77ba9d3ae08ed40df' @user.remember_token= '' @user.remember_token_expires_at= '' @user.name= 'kaleem' @user.company_id='2' @user.title= '' @user.active= '1' @user.reset_password_token= '' end it "should authenticate with valid email,password and approved company" do User.authenticate(@user.email, @user.password).should_not be_nil end it "should NOT authenticate with INvalid email" do @user.email=nil User.authenticate(@user.email, @user.password).should be_nil end it "should NOT authenticate with INvalid password" do @user.password=nil User.authenticate(@user.email, @user.password).should be_nil end it "should remember me" do @user.remember_me @user.remember_token.should_not be_nil @user.remember_token_expires_at.should_not be_nil end it "Remember Token time should be less than Token expires time" do @user.remember_token?.should be_true end it "should forget me" do @user.forget_me @user.remember_token.should be_nil @user.remember_token_expires_at.should be_nil end end Now Questions: 1) is my approach or way of writing specs is right??? 2) How can i make specs for such a model action def activate! self.update_attribute(:active, true) end Thank you :) -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Feb 11 09:52:45 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 11 Feb 2009 15:52:45 +0100 Subject: [rspec-users] exemplary way to show a list is sorted? In-Reply-To: <85d99afe0902101952g21beb83fkd332a179924ef88d@mail.gmail.com> References: <860c114f0902081548j3b1c18bco44ae938836d02adc@mail.gmail.com> <57c63afe0902101219w5accb52fv477e11f8b386fe80@mail.gmail.com> <6997dd6cfd2ee88c78a4aa242ed9008a@ruby-forum.com> <85d99afe0902101700l170e93bdi4a733716bfce467a@mail.gmail.com> <7e1ef3d95e6a9d848eeb1032755278fd@ruby-forum.com> <85d99afe0902101952g21beb83fkd332a179924ef88d@mail.gmail.com> Message-ID: <9542d82d58a4a582c56a9341684218b3@ruby-forum.com> Zach Dennis wrote: > >> Such action causes avoidable and pointless work. > > And to disprove this argument I will defer to the avoidable and > pointless work you will be causing those who maintain the software, > This is a completely illogical, and inherently contradictory, statement. The issue is that a tool is supposed to be reliable. Reliability includes the notion of preserving prior behaviour. This ensures that people who invest their time in using the tool do not have their trust in it destroyed by avoidable changes. Further, by its very nature, a tool is used by vastly more people than those that create the tool, otherwise it has little value. The idea that a large number of people should be inconvenienced in order that a few people are not strikes me as rather selfish and frankly, unprofessional. Have you ever dared to make that type of argument to your employer or client? Yes, software evolves; and yes, there are many things we do in ignorance that experience reveals as both unfortunate and wasteful. But, time is money and causing test suites to fail by removing parts of the API just because they appear ugly seems to me to break the contract that one makes with those who choose to use your tool instead of another. Let use consider this construct: object.should be_close(value,delta) why not object.should be_close_to(value,delta) Or object.should be_near(value,delta) Or object.should approximate(value,delta) instead? Which is "better" then the others? Which is "uglier"? Who cares? Pick one and stick with it; or, if one feels compelled to improve the style then at least keep that which already works, and is in use, working. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Feb 11 09:52:59 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Wed, 11 Feb 2009 15:52:59 +0100 Subject: [rspec-users] Cucumber - How to enable a disabled field In-Reply-To: <810a540e0902102244g6b2dc22as400da50b312e9211@mail.gmail.com> References: <188f0ffe9c1701e54b876847171d4512@ruby-forum.com> <810a540e0902102244g6b2dc22as400da50b312e9211@mail.gmail.com> Message-ID: <67c0f93290b93b82e26a6cb7c65f75f8@ruby-forum.com> Pat Maddox wrote: > You have to go through the browser, using something like selenium > (which can be driven by cucumber) > > Pat Since I only have this one little widget on the page, I was hoping to avoid selenium for now, but alas. Will give it a go. Thanks for your thoughts. Tom -- Posted via http://www.ruby-forum.com/. From cflipse at gmail.com Wed Feb 11 10:24:11 2009 From: cflipse at gmail.com (Chris Flipse) Date: Wed, 11 Feb 2009 10:24:11 -0500 Subject: [rspec-users] [cucumber] [alpha] The Backgrounder is run without cleaning up In-Reply-To: <8d961d900902102356p19bfaab1ncb4df42fcf3fd651@mail.gmail.com> References: <8d961d900902102356p19bfaab1ncb4df42fcf3fd651@mail.gmail.com> Message-ID: Okay, thanks. Wanted to check before filing a bug so I'm not throwing duplicates into the mix. On Wed, Feb 11, 2009 at 2:56 AM, aslak hellesoy wrote: > On Wed, Feb 11, 2009 at 2:10 AM, Chris Flipse wrote: > > This /could/ just a screwy behavior I'm seeing in SQL lite, but I don't > > think so; normal scenarios are doing this just fine. > > > > I'm playing with the Background feature in the .1.99 beta, and it looks > like > > it's being run before every feature -- but it's not cleaning up > afterwards. > > I have a model with a validates_uniquness_of in place, and I'm seeing > > something that looks like this: > > > > Feature: It should be able to run for multiple files > > Background: > > Given a model with unique name "Foobar" > > > > Scenario: This one runs okay > > # .... > > > > Scenario: But this one fails > > # background is run, and fails to create the model because of the > > validation > > > > Is this known, and fixed in github, or have I stumbled on something new? > > > > It's known: > http://rspec.lighthouseapp.com/projects/16211/tickets/181-background-runs-outside-of-transactions > It's not fixed yet. Joseph has done some work to address it. I still > have some left to do. > > Aslak > > > -- > > // anything worth taking seriously is worth making fun of > > // http://blog.devcaffeine.com/ > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > Aslak (::) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- // anything worth taking seriously is worth making fun of // http://blog.devcaffeine.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at deadorange.com Wed Feb 11 11:12:47 2009 From: nick at deadorange.com (Nick Hoffman) Date: Wed, 11 Feb 2009 11:12:47 -0500 Subject: [rspec-users] Rspec approach to test model In-Reply-To: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> Message-ID: <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> On 11/02/2009, at 8:51 AM, Kaleem Ullah wrote: > Hi, > > I am quite new to Rspec. I want to use Rspec to test my existing > Code. I > start from Models (Unit Testing). Here i want your help on a issue. > > Here is model/user_spec.rb > > describe User do > before(:each) do > @user=User.new > @user.id='2' > @user.email='kkkk at gmail.com' > @user.password='1234' > @user.crypted_password= '21066966a0578362e2115f3561bd4f144520ccd2' > @user.salt= '574f09d3ae2473105567eab77ba9d3ae08ed40df' > @user.remember_token= '' > @user.remember_token_expires_at= '' > @user.name= 'kaleem' > @user.company_id='2' > @user.title= '' > @user.active= '1' > @user.reset_password_token= '' > end > > it "should authenticate with valid email,password and approved > company" do > User.authenticate(@user.email, @user.password).should_not be_nil > end > > it "should NOT authenticate with INvalid email" do > @user.email=nil > User.authenticate(@user.email, @user.password).should be_nil > end > > it "should NOT authenticate with INvalid password" do > @user.password=nil > User.authenticate(@user.email, @user.password).should be_nil > end > > it "should remember me" do > @user.remember_me > @user.remember_token.should_not be_nil > @user.remember_token_expires_at.should_not be_nil > end > > it "Remember Token time should be less than Token expires time" do > @user.remember_token?.should be_true > end > > it "should forget me" do > @user.forget_me > @user.remember_token.should be_nil > @user.remember_token_expires_at.should be_nil > end > end > > Now Questions: > 1) is my approach or way of writing specs is right??? > 2) How can i make specs for such a model action > > def activate! > self.update_attribute(:active, true) > end > > Thank you :) Hi Kaleem. All of that looks pretty good so far, though you shouldn't be setting the "id" attribute of an AR model: @user.id = '2' I suggest using the following format for creating your User object: before(:each) do @user = User.new( :email => 'kkkk at gmail.com', :password => '1234', # ..etc.. ) end To spec your #activate! , why not do something like this?: it 'should activate the user' do @user.active.should be_false @user.activate! @user.active.should be_true end Cheers, Nick From dchelimsky at gmail.com Wed Feb 11 11:15:51 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 11 Feb 2009 10:15:51 -0600 Subject: [rspec-users] exemplary way to show a list is sorted? In-Reply-To: <9542d82d58a4a582c56a9341684218b3@ruby-forum.com> References: <860c114f0902081548j3b1c18bco44ae938836d02adc@mail.gmail.com> <57c63afe0902101219w5accb52fv477e11f8b386fe80@mail.gmail.com> <6997dd6cfd2ee88c78a4aa242ed9008a@ruby-forum.com> <85d99afe0902101700l170e93bdi4a733716bfce467a@mail.gmail.com> <7e1ef3d95e6a9d848eeb1032755278fd@ruby-forum.com> <85d99afe0902101952g21beb83fkd332a179924ef88d@mail.gmail.com> <9542d82d58a4a582c56a9341684218b3@ruby-forum.com> Message-ID: <57c63afe0902110815p10875111j6d1904f0015e5c7b@mail.gmail.com> On Wed, Feb 11, 2009 at 8:52 AM, James Byrne wrote: > Zach Dennis wrote: > >> >>> Such action causes avoidable and pointless work. >> >> And to disprove this argument I will defer to the avoidable and >> pointless work you will be causing those who maintain the software, >> > > This is a completely illogical, and inherently contradictory, statement. > > The issue is that a tool is supposed to be reliable. Reliability > includes the notion of preserving prior behaviour. This ensures that > people who invest their time in using the tool do not have their trust > in it destroyed by avoidable changes. > > Further, by its very nature, a tool is used by vastly more people than > those that create the tool, otherwise it has little value. The idea > that a large number of people should be inconvenienced in order that a > few people are not strikes me as rather selfish and frankly, > unprofessional. Have you ever dared to make that type of argument to > your employer or client? > > Yes, software evolves; and yes, there are many things we do in ignorance > that experience reveals as both unfortunate and wasteful. But, time is > money and causing test suites to fail by removing parts of the API just > because they appear ugly seems to me to break the contract that one > makes with those who choose to use your tool instead of another. > > Let use consider this construct: > > object.should be_close(value,delta) > > why not > > object.should be_close_to(value,delta) > > Or > > object.should be_near(value,delta) > > Or > > object.should approximate(value,delta) instead? > > Which is "better" then the others? Which is "uglier"? Who cares? Pick > one and stick with it; or, if one feels compelled to improve the style > then at least keep that which already works, and is in use, working. James, Chill, please! This is not productive at all. You started this thread with a condescending tone and you've already spent more time (and your enterprise's money) ranting about this than it's going to take you to make this change when it comes, and you continue to be insulting with comments about being selfish and unprofessional. If you'd like a civil conversation, then drop the attitude. I explained my position in another post in this thread, and I look forward to your *respectful* responses to those thoughts. Cheers, David From nick at deadorange.com Wed Feb 11 11:40:51 2009 From: nick at deadorange.com (Nick Hoffman) Date: Wed, 11 Feb 2009 11:40:51 -0500 Subject: [rspec-users] exemplary way to show a list is sorted? In-Reply-To: <7e1ef3d95e6a9d848eeb1032755278fd@ruby-forum.com> References: <860c114f0902081548j3b1c18bco44ae938836d02adc@mail.gmail.com> <57c63afe0902101219w5accb52fv477e11f8b386fe80@mail.gmail.com> <6997dd6cfd2ee88c78a4aa242ed9008a@ruby-forum.com> <85d99afe0902101700l170e93bdi4a733716bfce467a@mail.gmail.com> <7e1ef3d95e6a9d848eeb1032755278fd@ruby-forum.com> Message-ID: <6AEC56FC-3B1F-416B-95D7-FCD212C78039@deadorange.com> On 10/02/2009, at 10:09 PM, James Byrne wrote: > Zach Dennis wrote: >> On Tue, Feb 10, 2009 at 6:22 PM, James Byrne >> wrote: >>> David Chelimsky wrote: >>> >>>> >>>> please use "should be >=" as "should >=" will eventually be >>>> deprecated >>>> and removed. >>>> >>> >>> Removed? You are not seriously contemplating forcing people to go >>> back >>> and rewrite formally working specifications simply to tidy up the >>> syntax >>> are you? >> >> Forcing people, eh? You don't have to upgrade when that release is >> made. No one is holding a gun to your head. You can always choose to >> progress with the library, as it continues to evolve into new and >> better ways of doing things. > > There are enterprises in which the stability of development tools and > the confidence that one will not be forced to redo work already > completed is considered somewhat important, whatever your own > situation > might be. Likewise, assuming the costs of maintaining a customized > variant of a general tool or foregoing future improvements in same to > maintain the value of existing work is not a choice savoured by many > firms that I can bring to mind, even if yours might be exceptional in > this regard. At issue is something commonly referred to as > cost/benefit, which ultimately turns into profit and loss. > > I simply fail to see why evolving a tool in "better ways" necessarily > requires that the formerly "better" but now depreciated method be > removed. Such action causes avoidable and pointless work. I > consider my > observation to be both reasonable and pertinent. I hear what you're saying, James, and agree with you to a certain extent. However, one must keep a few things in mind: 1) The syntax in question will be valid, but deprecated, in all 1.x releases. This means that you can continue to use the old syntax. 2) If you're willing to change which version of RSpec a project of yours uses, then you must be willing to change how the project uses RSpec. Change begets change. 3) When a new major version of a project is released, one must be prepared for major changes. If the changes are incompatible with you or your own software, several options exist: 3.1) Do not upgrade to the new major version. 3.2) Fork the new major version, add your desired modifications, then use that fork in your software. 3.3) Modify your software so that it becomes compatible with the new major version of the project in question. 4) Most free and/or open-source projects are run as democracies. However, they are overseen by the lead maintainer(s), who have the final say when it comes to making decisions. This is because they have the most knowledge of, and experience with, the project, and understand best the direction that the project should be going in. Cheers, Nick From lists at ruby-forum.com Wed Feb 11 11:53:45 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 11 Feb 2009 17:53:45 +0100 Subject: [rspec-users] exemplary way to show a list is sorted? In-Reply-To: <57c63afe0902110815p10875111j6d1904f0015e5c7b@mail.gmail.com> References: <860c114f0902081548j3b1c18bco44ae938836d02adc@mail.gmail.com> <57c63afe0902101219w5accb52fv477e11f8b386fe80@mail.gmail.com> <6997dd6cfd2ee88c78a4aa242ed9008a@ruby-forum.com> <85d99afe0902101700l170e93bdi4a733716bfce467a@mail.gmail.com> <7e1ef3d95e6a9d848eeb1032755278fd@ruby-forum.com> <85d99afe0902101952g21beb83fkd332a179924ef88d@mail.gmail.com> <9542d82d58a4a582c56a9341684218b3@ruby-forum.com> <57c63afe0902110815p10875111j6d1904f0015e5c7b@mail.gmail.com> Message-ID: David Chelimsky wrote: > > I explained my position in another post in this thread, and I look > forward to your *respectful* responses to those thoughts. I regret if my initial observation was taken as anything other than that, an observation. One might consider it the textual equivalent to a raised eyebrow, no more. Being told to maintain my own fork of a project was not a response that I either expected or thought warranted. Notwithstanding the heat that this issue appears to have raised, I assure you that I bear no ill will towards any. I simply believe that changes which introduce breakage to previously working code should be avoided wherever possible. This did not seem to me condescending, abrasive, or particularly controversial. Evidently I am wrong. -- Posted via http://www.ruby-forum.com/. From scott at railsnewbie.com Wed Feb 11 11:58:08 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Wed, 11 Feb 2009 11:58:08 -0500 Subject: [rspec-users] Rspec approach to test model In-Reply-To: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> Message-ID: On Feb 11, 2009, at 8:51 AM, Kaleem Ullah wrote: > Hi, > > I am quite new to Rspec. I want to use Rspec to test my existing > Code. I > start from Models (Unit Testing). Here i want your help on a issue. > > Here is model/user_spec.rb > > describe User do > before(:each) do > @user=User.new > @user.id='2' > @user.email='kkkk at gmail.com' > @user.password='1234' > @user.crypted_password= '21066966a0578362e2115f3561bd4f144520ccd2' > @user.salt= '574f09d3ae2473105567eab77ba9d3ae08ed40df' > @user.remember_token= '' > @user.remember_token_expires_at= '' > @user.name= 'kaleem' > @user.company_id='2' > @user.title= '' > @user.active= '1' > @user.reset_password_token= '' > end You could benefit from a factory / data builder. See FixtureReplacement, Fixjour, Factory girl, one of the many others out there which would build this stuff *once* for you. > > > it "should authenticate with valid email,password and approved > company" do > User.authenticate(@user.email, @user.password).should_not be_nil > end > > it "should NOT authenticate with INvalid email" do > @user.email=nil > User.authenticate(@user.email, @user.password).should be_nil > end > > it "should NOT authenticate with INvalid password" do > @user.password=nil > User.authenticate(@user.email, @user.password).should be_nil > end > > it "should remember me" do > @user.remember_me > @user.remember_token.should_not be_nil > @user.remember_token_expires_at.should_not be_nil > end > > it "Remember Token time should be less than Token expires time" do > @user.remember_token?.should be_true > end > > it "should forget me" do > @user.forget_me > @user.remember_token.should be_nil > @user.remember_token_expires_at.should be_nil > end > end > > Now Questions: > 1) is my approach or way of writing specs is right??? Remember: there is no right way of doing things. Does it work for you (and your team)? Is it clear? > > 2) How can i make specs for such a model action > > def activate! > self.update_attribute(:active, true) > end spec1: @user.activate! @user.should be_active spec 2: @user.should_not be_active Scott From lists at ruby-forum.com Wed Feb 11 12:00:01 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 11 Feb 2009 18:00:01 +0100 Subject: [rspec-users] Bizarre problem with Rake / Rcov In-Reply-To: <57c63afe0902102026g26dc190ep84326211f992509e@mail.gmail.com> References: <57c63afe0902102026g26dc190ep84326211f992509e@mail.gmail.com> Message-ID: <6f3d00ddd2d36876d3564402dee46fff@ruby-forum.com> David Chelimsky wrote: > On Tue, Feb 10, 2009 at 5:24 PM, James Byrne > wrote: >> t.rcov_opts << r_rcov_opta >> >> sigh... > > Sorry - not following - does this mean you solved the problem? Yes, a beginners error I am afraid. a = [1, 2] b = a b << [3,4] a => [1,2,3,4] -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed Feb 11 12:28:43 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 11 Feb 2009 11:28:43 -0600 Subject: [rspec-users] exemplary way to show a list is sorted? In-Reply-To: References: <860c114f0902081548j3b1c18bco44ae938836d02adc@mail.gmail.com> <57c63afe0902101219w5accb52fv477e11f8b386fe80@mail.gmail.com> <6997dd6cfd2ee88c78a4aa242ed9008a@ruby-forum.com> <85d99afe0902101700l170e93bdi4a733716bfce467a@mail.gmail.com> <7e1ef3d95e6a9d848eeb1032755278fd@ruby-forum.com> <85d99afe0902101952g21beb83fkd332a179924ef88d@mail.gmail.com> <9542d82d58a4a582c56a9341684218b3@ruby-forum.com> <57c63afe0902110815p10875111j6d1904f0015e5c7b@mail.gmail.com> Message-ID: <34FCA435-AE4F-4CF2-B55B-5A36B9A77FC6@gmail.com> On Feb 11, 2009, at 10:53 AM, James Byrne wrote: > David Chelimsky wrote: > >> >> I explained my position in another post in this thread, and I look >> forward to your *respectful* responses to those thoughts. > > I regret if my initial observation was taken as anything other than > that, an observation. One might consider it the textual equivalent > to a > raised eyebrow, no more. Being told to maintain my own fork of a > project was not a response that I either expected or thought > warranted. > > Notwithstanding the heat that this issue appears to have raised, I > assure you that I bear no ill will towards any. I simply believe that > changes which introduce breakage to previously working code should be > avoided wherever possible. This did not seem to me condescending, > abrasive, or particularly controversial. Evidently I am wrong. Cool. Now we can talk. For the record, the thing that struck me as patronizing was "You are not seriously ... simply to tidy up the syntax" which makes assumptions about the underlying motivations and positions your issues as more important than mine, or anybody else's for that matter. There is a lot more to all of this than meets the eye. RSpec is a tool, but it is also a community project, which means it serves many masters and has to balance many forces. As for the point you make about avoiding compatbility breaking changes, I agree that that carries some weight, but it is not the only concern. One of the biggest problems rspec suffers as a community project is barrier to entry for contributors based on a public perception that rspec is bloated and difficult to understand. So I care about bloat, and this particular issue is about that as much as it is about syntax. I have more to add, but I'm typing on my phone and my other fingers are beginning to get jealous of my thumbs. More later. 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 lists at ruby-forum.com Wed Feb 11 12:47:21 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 11 Feb 2009 18:47:21 +0100 Subject: [rspec-users] Rspec approach to test model In-Reply-To: References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> Message-ID: <22acbf489c1f7269ef6a9f2eea361a4c@ruby-forum.com> Scott Taylor wrote: > On Feb 11, 2009, at 8:51 AM, Kaleem Ullah wrote: > >> @user=User.new >> @user.active= '1' >> @user.reset_password_token= '' >> end > > You could benefit from a factory / data builder. See > FixtureReplacement, Fixjour, Factory girl, one of the many others out > there which would build this stuff *once* for you. Kaleem, I recently installed nakajima-acts_as_fu (0.0.3) gem. This provides a rather painless way of specifying ActiveRecord model schemata on the fly in your specifications. You might find it helpful to look into this. You will discover that some people favour mocks and stubs when dealing with AR models in tests/specifications and some favour hitting the database. Once you decide on your own preference in this matter the choice of approach is somewhat simplified. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Feb 11 12:50:05 2009 From: lists at ruby-forum.com (Kaleem Ullah) Date: Wed, 11 Feb 2009 18:50:05 +0100 Subject: [rspec-users] Rspec approach to test model In-Reply-To: <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> Message-ID: Nick Hoffman wrote: > To spec your #activate! , why not do something like this?: > > it 'should activate the user' do > @user.active.should be_false > @user.activate! > @user.active.should be_true > end > > Thanks for your reply Hoffman :) I did the same but it gives error like "#23000Duplicate entry 'kkkkk at gmail.com Insert INTO (...) Values(...)". It should do update not Insert. But when i try call it with a new instance of user (with no values assigned to any user attribute) then it works. i.e. it "should activate the user" do @user1=User.new @user1.activate! end This works. I think i have to erase all the User attributes from "before (:each)" and only assigned it in Examples which required it. am i right ? Thanks -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Feb 11 12:57:19 2009 From: lists at ruby-forum.com (Kaleem Ullah) Date: Wed, 11 Feb 2009 18:57:19 +0100 Subject: [rspec-users] Rspec approach to test model In-Reply-To: <22acbf489c1f7269ef6a9f2eea361a4c@ruby-forum.com> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <22acbf489c1f7269ef6a9f2eea361a4c@ruby-forum.com> Message-ID: <7ffd679ad7b740187c55c9fa8ffd043a@ruby-forum.com> James Byrne wrote: > I recently installed nakajima-acts_as_fu (0.0.3) gem. This provides a > rather painless way of specifying ActiveRecord model schemata on the fly > in your specifications. You might find it helpful to look into this. > > You will discover that some people favour mocks and stubs when dealing > with AR models in tests/specifications and some favour hitting the > database. Once you decide on your own preference in this matter the > choice of approach is somewhat simplified. Hi james byrne, Good to know that.I will surely look for this gem...... Thanks :) -- Posted via http://www.ruby-forum.com/. From joe at josephwilk.net Wed Feb 11 13:06:34 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Wed, 11 Feb 2009 18:06:34 +0000 Subject: [rspec-users] Cucumber - How to enable a disabled field In-Reply-To: <67c0f93290b93b82e26a6cb7c65f75f8@ruby-forum.com> References: <188f0ffe9c1701e54b876847171d4512@ruby-forum.com> <810a540e0902102244g6b2dc22as400da50b312e9211@mail.gmail.com> <67c0f93290b93b82e26a6cb7c65f75f8@ruby-forum.com> Message-ID: <499313AA.4030807@josephwilk.net> I would highly recommend you take a look at Celerity (http://celerity.rubyforge.org/) as well. The Culerity gem has made it easy to run Celerity (using jruby) alongside your normal ruby app. http://upstream-berlin.com/2009/01/28/culerity-full-stack-rails-testing-with-cucumber-and-celerity/ Since Celerity does not use a GUI it tends to be *much* faster than Selenium. -- Joseph Wilk http://blog.josephwilk.net Tom Hoen wrote: > Pat Maddox wrote: > >> You have to go through the browser, using something like selenium >> (which can be driven by cucumber) >> >> Pat >> > > Since I only have this one little widget on the page, I was hoping to > avoid selenium for now, but alas. Will give it a go. > > Thanks for your thoughts. > Tom > From lists at ruby-forum.com Wed Feb 11 13:40:52 2009 From: lists at ruby-forum.com (Kaleem Ullah) Date: Wed, 11 Feb 2009 19:40:52 +0100 Subject: [rspec-users] Rspec approach to test model In-Reply-To: References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> Message-ID: <28271c01f4857bc17f171d772b786a2e@ruby-forum.com> Scott Taylor wrote: > On Feb 11, 2009, at 8:51 AM, Kaleem Ullah wrote: > >> @user=User.new >> @user.active= '1' >> @user.reset_password_token= '' >> end > > You could benefit from a factory / data builder. See > FixtureReplacement, Fixjour, Factory girl, one of the many others out > there which would build this stuff *once* for you. Hi Scott Taylor, I am in need of such data builders. So nice of you... :) -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Wed Feb 11 14:38:14 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 11 Feb 2009 19:38:14 +0000 Subject: [rspec-users] exemplary way to show a list is sorted? In-Reply-To: References: <860c114f0902081548j3b1c18bco44ae938836d02adc@mail.gmail.com> <57c63afe0902101219w5accb52fv477e11f8b386fe80@mail.gmail.com> <6997dd6cfd2ee88c78a4aa242ed9008a@ruby-forum.com> <85d99afe0902101700l170e93bdi4a733716bfce467a@mail.gmail.com> <7e1ef3d95e6a9d848eeb1032755278fd@ruby-forum.com> <85d99afe0902101952g21beb83fkd332a179924ef88d@mail.gmail.com> <9542d82d58a4a582c56a9341684218b3@ruby-forum.com> <57c63afe0902110815p10875111j6d1904f0015e5c7b@mail.gmail.com> Message-ID: <98B3D689-0EBC-4E3A-9A52-5FA654E3B8AB@mattwynne.net> On 11 Feb 2009, at 16:53, James Byrne wrote: > David Chelimsky wrote: > >> I explained my position in another post in this thread, and I look >> forward to your *respectful* responses to those thoughts. > > I regret if my initial observation was taken as anything other than > that, an observation. One might consider it the textual equivalent > to a > raised eyebrow, no more. Being told to maintain my own fork of a > project was not a response that I either expected or thought > warranted. This is the beauty of github: when someone complains about a project, you can just tell them to fork off! Matt Wynne http://blog.mattwynne.net http://www.songkick.com From nwilmes at gmail.com Wed Feb 11 15:52:56 2009 From: nwilmes at gmail.com (nathan@pivotalsf.com) Date: Wed, 11 Feb 2009 12:52:56 -0800 (PST) Subject: [rspec-users] issues with the trunk of rspec-rails In-Reply-To: <57c63afe0902102049l4458525jcfe4bc4af8ebcd21@mail.gmail.com> References: <8d0d70270902101202y1aeab001hbfa85777e0307108@mail.gmail.com> <57c63afe0902102049l4458525jcfe4bc4af8ebcd21@mail.gmail.com> Message-ID: Snipping down to relevant questions: On Feb 10, 8:49?pm, David Chelimsky wrote: > On Tue, Feb 10, 2009 at 2:02 PM, Nathan Wilmes wrote: > > (2) The render override for RSpec controllers only takes one argument. ?This > > means that any controller using two argument forms will fail. > > > Our biggest use case for the two-argument controller form is this: ?render > > :update, :status => 404 do {} > > This case is still allowable and not deprecated in Rails 2.2.2. > > I can reinstate the extra arg. Are you looking for it to be handled in > some way? Or just to not blow up? It shouldn't blow up - right now it gives argument errors. It _ought_ to behave identically to render :update => true, :status => 404 (Rails 2.2.2 converts the first form to the second). > > (3) with_tag is completely broken, as it tries to use the outer class as the > > subject of 'with_tag', rather than the have_tag matcher that it lives > > inside. > > Was it working before and the upgrade broke existing specs? Or is this > a general observation? Yes, the upgrade broke existing specs.. it used to work fine as of rspec 1.1.4. The breakage appears to have something to do with the 'subject' functionality. > > > (4) assigns(:xxx) will give really bad errors if your class doesn't happen > > to define == in such a way that it can equate to FalseClass. > > Can you provide an example? Let's say I have a simple object class Foo, defined as: class Foo def initialize(bar) @bar = bar end attr_reader :bar def ==(other) self.bar == other.bar end end and a controller that sets a model variable @foo to Foo.new. If you run an rspec controller spec and ask it about assigns(:foo), it will complain with an error about how it doesn't know what the 'bar' method is on FalseClass. It does this the moment you ask for assigns(:foo). Not the biggest deal once you understand what's going on (you can solve it by making the == method smart enough to return false unless other is a Foo class) but a very confusing error to track down. =N From pergesu at gmail.com Wed Feb 11 19:58:01 2009 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 11 Feb 2009 16:58:01 -0800 Subject: [rspec-users] exemplary way to show a list is sorted? In-Reply-To: <9542d82d58a4a582c56a9341684218b3@ruby-forum.com> References: <860c114f0902081548j3b1c18bco44ae938836d02adc@mail.gmail.com> <57c63afe0902101219w5accb52fv477e11f8b386fe80@mail.gmail.com> <6997dd6cfd2ee88c78a4aa242ed9008a@ruby-forum.com> <85d99afe0902101700l170e93bdi4a733716bfce467a@mail.gmail.com> <7e1ef3d95e6a9d848eeb1032755278fd@ruby-forum.com> <85d99afe0902101952g21beb83fkd332a179924ef88d@mail.gmail.com> <9542d82d58a4a582c56a9341684218b3@ruby-forum.com> Message-ID: <810a540e0902111658x6c731j1c58a620edd4b46f@mail.gmail.com> On Wed, Feb 11, 2009 at 6:52 AM, James Byrne wrote: > Further, by its very nature, a tool is used by vastly more people than > those that create the tool, otherwise it has little value. The idea > that a large number of people should be inconvenienced in order that a > few people are not strikes me as rather selfish and frankly, > unprofessional. You are completely out of line even suggesting that David is selfish or unprofessional. Do you have any clue how many changes he HASN'T made because it would break backwards compatibility? How much effort goes into sensibly deprecating stuff? The work he does to keep RSpec working with old versions of Rails (only very recently *announcing* discontinued support of 1.2.x), as well as consistently keeping it working with edge Rails even with all of its internal breakage. The simple fact is that while RSpec owes a great deal to its community as a whole, it would be nowhere near where it is today without David's hard work. Look at the friggin commit logs and the lighthouse tickets. Do you seriously have a problem with making his life a bit easier? Didn't think so. And I can guarantee you that his real motivation isn't selfish in the least - cleaning up the internals makes it easier to understand and modify, allowing more users to become contributors. Here's a little tip that will save you THOUSANDS AND THOUSANDS OF DOLLARS in the future: gem install rspec rspec-rails --version=1.1.12 Pat From pergesu at gmail.com Wed Feb 11 20:21:09 2009 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 11 Feb 2009 17:21:09 -0800 Subject: [rspec-users] How to spec within a block? In-Reply-To: <3e46d267-2e1e-4e75-a9f8-7514ca54a146@q9g2000yqc.googlegroups.com> References: <3e46d267-2e1e-4e75-a9f8-7514ca54a146@q9g2000yqc.googlegroups.com> Message-ID: <810a540e0902111721m3f259653lf89e994ca75a83d0@mail.gmail.com> On Sat, Feb 7, 2009 at 3:47 AM, rgagnon wrote: > I have this and I want to mock the to_xml but not his block cause this > is what I want to spec. Is there a way to do this? Use and_yield to yield an object, and you can set expectations on it. For example: xml_detent = mock('xml detenteur') xml_detent.stub!(:intervenant_adresses).and_return(array_of_addresses) detenteur.stub!(:to_xml).and_yield(xml_detent) Does that make sense? Pat From rem.gagnon at gmail.com Wed Feb 11 20:42:18 2009 From: rem.gagnon at gmail.com (Remi Gagnon) Date: Wed, 11 Feb 2009 20:42:18 -0500 Subject: [rspec-users] How to spec within a block? In-Reply-To: <810a540e0902111721m3f259653lf89e994ca75a83d0@mail.gmail.com> References: <3e46d267-2e1e-4e75-a9f8-7514ca54a146@q9g2000yqc.googlegroups.com> <810a540e0902111721m3f259653lf89e994ca75a83d0@mail.gmail.com> Message-ID: It works thanks for the hints R?mi On Wed, Feb 11, 2009 at 8:21 PM, Pat Maddox wrote: > On Sat, Feb 7, 2009 at 3:47 AM, rgagnon wrote: > > I have this and I want to mock the to_xml but not his block cause this > > is what I want to spec. Is there a way to do this? > > Use and_yield to yield an object, and you can set expectations on it. > For example: > > xml_detent = mock('xml detenteur') > xml_detent.stub!(:intervenant_adresses).and_return(array_of_addresses) > detenteur.stub!(:to_xml).and_yield(xml_detent) > > Does that make sense? > > 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 rem.gagnon at gmail.com Wed Feb 11 20:45:24 2009 From: rem.gagnon at gmail.com (Remi Gagnon) Date: Wed, 11 Feb 2009 20:45:24 -0500 Subject: [rspec-users] Weird message on ActiveSupport::Callbacks::CallbackChain:Class In-Reply-To: <57c63afe0902102105j2efabeebh7a5cd5651d2adae2@mail.gmail.com> References: <57c63afe0902102105j2efabeebh7a5cd5651d2adae2@mail.gmail.com> Message-ID: Thank you David, You are right we are dealing with some code that need to be refactored. We will dig deeper to have more info about this Callbackchain problem R?mi On Wed, Feb 11, 2009 at 12:05 AM, David Chelimsky wrote: > On Tue, Feb 10, 2009 at 9:03 AM, Remi Gagnon wrote: > > Hi guys, > > > > its probably a miss understanding of the framework but I need your > > assistance. > > > > Here is the problem of one of my teammates: > > I have a hard time writing rspecs for a class I developed. The class in > > question reads an xml document, instanciates the model classes found in > the > > xml and saves the classes and their attributes in the database with the > good > > foreign keys. The class is stored in a lib. > > > > The class : > > > > class XmlReader > > > > def self.import_xml(xml_doc) > > objects_xml = Array.new > > keys_obj = Array.new > > xml = REXML::Document.new(xml_doc) > > read_xml(xml, objects_xml, keys_obj) > > raise AnError.new("Can not save xml objects") if (objects_xml.empty?) > > objects_xml.each { |instance| > > save_class(instance, keys_obj[objects_xml.index(instance)]) > > } > > end > > ? > > end > > > > The import_xml function acts as an entry point but there are two other > > functions involved in the process : > > - read_xml : reads the xml elements one by one and instanciates > the > > classes that have to be with the attributes found in the xml document. It > is > > called recursively. The two arrays, objects_xml and keys_obj, contain > > respectively all the instanciated objects found and all the foreign keys > > defined in the relations of the models. > > - save_class : saves the instanciated objects contained in the > > objets_xml array with the good foreign keys for the relations to be well > > done. > > > > Now, I am trying to test if the objects_xml array is empty. If so, the > class > > should raise an error. > > > > The rspec : > > > > # mocks ? > > @mock_element = mock(REXML::Element) > > mock_element.stub!(:text) > > @mock_element.stub!(:name) > > @mock_element.stub!(:elements) > > @xml_doc = mock(REXML::Document, :elements => { "e1" => @mock_element, > "e2" > > => @mock_element }) > > @xml_doc.stub!(:new) > > @xml_doc.stub!(:has_elements?) > > xml_doc.stub!(:encoding) > > @objets_xml = mock(Array) > > @objets_xml.stub!(:[]=) > > @objets_xml.stub!(:[]) > > objets_xml.stub!(:empty?) > > @keys_obj = mock(Array) > > @keys_obj.stub!(:[]=) > > @keys_obj.stub!(:[]) > > > > Array.should_receive(:new).and_return(@objets_xml) > > Array.should_receive(:new).and_return(@keys_obj) > > REXML::Document.should_receive(:new).and_return(@xml_doc) > > XmlReader.should_receive(:read_xml).and_return(true) > > objets_xml.should_receive(:empty?).and_return(true) > > lambda { XmlReader.import_xml(xml_valid) }.should raise_error(AnError, > "Can > > not save xml objects") > > This is one of those "Doctor, it hurts when I do this" sorta > situations. The whole point of TDD, and BDD, is to write code examples > first so that you end up with code that is inherently testable. > Back-filling specs on legacy code (code without tests!) is painful, > and you are suffering that pain here. > > That said, what I'd do here is take a cue from Michael Feather's > Working Effectively with Legacy Code. Start with a high level > characterization test in which you pass the appropriately structured > xml doc and specify the expected outcomes. Don't worry about granular > specs about which step in the procedure is doing what at first. Once > you have a few of those in place, start to refactor those bits out to > other methods that you can spec directly. > > I realize that this doesn't solve your specific problem directly, but > I really have no clue from where I'm sitting as to where > ActiveSupport::Callbacks::CallbackChain:Class is injecting itself into > this process. > > HTH, > David > > > > > > The error : > > > > undefined method `new' for ActiveSupport::Callbacks::CallbackChain:Class > > > > This is where my problem is. This error occurs after the test is made and > > finished. In other words, the test passes but the framework fails after > it > > on a callback made in rails for whatever reason. > > > > Stack trace : > > > > > C:/Projets/Iter8_Conversion/vendor/rails/actionpack/lib/action_controller/test_process.rb:471:in > > `method_missing' > > > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/mocks/proxy.rb:102:in > > `__send__' > > > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/mocks/proxy.rb:102:in > > `message_received' > > > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/mocks/proxy.rb:140:in > > `new' > > (eval):7:in `teardown_callback_chain' > > > C:/Projets/Iter8_Conversion/vendor/rails/activesupport/lib/active_support/callbacks.rb:277:in > > `send' > > > C:/Projets/Iter8_Conversion/vendor/rails/activesupport/lib/active_support/callbacks.rb:277:in > > `run_callbacks' > > > C:/ruby/lib/ruby/gems/1.8/gems/rspec-rails-1.1.12/lib/spec/rails/interop/testcase.rb:10 > > > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:84:in > > `instance_eval' > > > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:84:in > > `eval_each_fail_slow' > > > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:82:in > > `each' > > > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:82:in > > `eval_each_fail_slow' > > > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_group_methods.rb:254:in > > `run_after_each' > > > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_group_methods.rb:253:in > > `each' > > > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_group_methods.rb:253:in > > `run_after_each' > > > C:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:141:in > > `after_each_example' > > > > Can anyone explain what is happening here or does anyone knows how to > bypass > > this ? > > > > Many thanks in advance. > > > > _______________________________________________ > > 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 Wed Feb 11 22:33:13 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 11 Feb 2009 21:33:13 -0600 Subject: [rspec-users] issues with the trunk of rspec-rails In-Reply-To: References: <8d0d70270902101202y1aeab001hbfa85777e0307108@mail.gmail.com> <57c63afe0902102049l4458525jcfe4bc4af8ebcd21@mail.gmail.com> Message-ID: <57c63afe0902111933r775ae7edlf91593cac4c6d8a0@mail.gmail.com> On Wed, Feb 11, 2009 at 2:52 PM, nathan at pivotalsf.com wrote: > On Feb 10, 8:49 pm, David Chelimsky wrote: >> On Tue, Feb 10, 2009 at 2:02 PM, Nathan Wilmes wrote: >> > (2) The render override for RSpec controllers only takes one argument. This >> > means that any controller using two argument forms will fail. >> >> > Our biggest use case for the two-argument controller form is this: render >> > :update, :status => 404 do {} >> > This case is still allowable and not deprecated in Rails 2.2.2. >> >> I can reinstate the extra arg. Are you looking for it to be handled in >> some way? Or just to not blow up? > > It shouldn't blow up - right now it gives argument errors. It _ought_ > to behave identically to > render :update => true, :status => 404 (Rails 2.2.2 converts the first > form to the second). Fixed. 2 down, 2 to go. From dchelimsky at gmail.com Wed Feb 11 23:40:15 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 11 Feb 2009 22:40:15 -0600 Subject: [rspec-users] issues with the trunk of rspec-rails In-Reply-To: References: <8d0d70270902101202y1aeab001hbfa85777e0307108@mail.gmail.com> <57c63afe0902102049l4458525jcfe4bc4af8ebcd21@mail.gmail.com> Message-ID: <57c63afe0902112040g23c8c50cgdf5285c07cce9526@mail.gmail.com> On Wed, Feb 11, 2009 at 2:52 PM, nathan at pivotalsf.com wrote: > On Feb 10, 8:49 pm, David Chelimsky wrote: >> On Tue, Feb 10, 2009 at 2:02 PM, Nathan Wilmes wrote: >> > (3) with_tag is completely broken, as it tries to use the outer class as the >> > subject of 'with_tag', rather than the have_tag matcher that it lives >> > inside. >> >> Was it working before and the upgrade broke existing specs? Or is this >> a general observation? > > Yes, the upgrade broke existing specs.. it used to work fine as of > rspec 1.1.4. > The breakage appears to have something to do with the 'subject' > functionality. Nathan, Taking a closer look at this - before we introduced the implicit subject, nested with_tag and without_tags were passing in the ExampleGroup. The matcher was (and still is) ignoring that argument, and using the HTML it got from the have_tag call. There are also a number of specs in rspec's own suite that show that this works correctly. These pass against rails 2.0.5, 2.1.2, 2.2.2, 2.3.0 and edge (as of earlier today). Take a look at http://github.com/dchelimsky/rspec-rails/blob/333810bf6f062599bd39007a3fe32ba227a4b32a/spec/spec/rails/matchers/assert_select_spec.rb and scroll down to 289, for example. Can you show me an example of what's failing for you? Spec and subject code, and the failure message? Thanks, David From dchelimsky at gmail.com Wed Feb 11 23:46:18 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 11 Feb 2009 22:46:18 -0600 Subject: [rspec-users] How to test the code inside the block of the to_xml function? In-Reply-To: References: Message-ID: <57c63afe0902112046s1e5d3131r96a6b75fdeb5d9ad@mail.gmail.com> On Fri, Feb 6, 2009 at 3:12 PM, Alex wrote: > Hi all, when I spec the to_xml function like this: > @some_model.should_receive(:to_xml), it dskips the code located in the > block, here is the controller code: > > ... > output = @detenteur.to_xml( :skip_types => false, :skip_instruct => > true, :dasherize => false, :only => [:inte_no] ) do |xml_detenteur| > lots of code... > end > > How can I test the code inside? mock_xml_detenteur = mock('xml_detenteur') @some_model.should_receive(:to_xml).and_yield(mock_xml_detenteur) # set expectations on mock_xml_detenteur Make sense? > > Thanks! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From rsanheim at gmail.com Thu Feb 12 00:17:39 2009 From: rsanheim at gmail.com (Rob Sanheim) Date: Thu, 12 Feb 2009 00:17:39 -0500 Subject: [rspec-users] [RSpec] rcov and/or rexml bug? In-Reply-To: References: <1d5d31eff1533f2d92d2ac0bc40c97d9@ruby-forum.com> <226f56f3f134b7e2635100218229096a@ruby-forum.com> <57c63afe0902030732l6b7db945pf97035e2a7e592f4@mail.gmail.com> <7a98104e01b51224e4cb66cea68977b6@ruby-forum.com> Message-ID: On Sat, Feb 7, 2009 at 12:06 PM, Fernando Perez wrote: > >> So I uninstalled rcov, and installed instead: spicycode-rcov, but now it >> cannot find the binary file. Using spicycode do I need to make any tweak >> to a rake file? > > I finally got everything working with no bugs by doing: > > 1) git clone git://github.com/spicycode/rcov.git > 2) cd rcov > 3) sudo ruby setup.rb > > At this point it would still not work as it couln't find the rcov > binary. So I did one more step: > > 4) sudo ruby setup.rb config > > > Maybe step 3 can be replaced by step 4? > > However now spicycode-rcov doesn't appear in $ gem list, and I don't > know how to uninstall it or update it. God I hate apps that don't offer > a clear and easy an uninstall option. > -- > Posted via http://www.ruby-forum.com/. Hi You shouldn't have to clone and install rcov manually. Just do this: gem install spicycode-rcov --source http://gems.github.com It will install just like any other gem. Rob http://thinkrelevance.com http://runcoderun.com From phlip2005 at gmail.com Thu Feb 12 00:27:52 2009 From: phlip2005 at gmail.com (Phlip) Date: Wed, 11 Feb 2009 21:27:52 -0800 Subject: [rspec-users] Rspec approach to test model In-Reply-To: <28271c01f4857bc17f171d772b786a2e@ruby-forum.com> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <28271c01f4857bc17f171d772b786a2e@ruby-forum.com> Message-ID: Kaleem Ullah wrote: > Scott Taylor wrote: >> You could benefit from a factory / data builder. See >> FixtureReplacement, Fixjour, Factory girl, one of the many others out >> there which would build this stuff *once* for you. > I am in need of such data builders. I recently thumped the square peg of FixtureDependencies into the round hole of Merb's RSpec. http://github.com/jeremyevans/fixture_dependencies/tree/master I can answer questions about it if anyone wants to try it. Except how to make it do rake db:fixtures:load. Does anyone know that one? -- Phlip From dchelimsky at gmail.com Thu Feb 12 00:40:29 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 11 Feb 2009 23:40:29 -0600 Subject: [rspec-users] issues with the trunk of rspec-rails In-Reply-To: References: <8d0d70270902101202y1aeab001hbfa85777e0307108@mail.gmail.com> <57c63afe0902102049l4458525jcfe4bc4af8ebcd21@mail.gmail.com> Message-ID: <57c63afe0902112140q199cd857u528cea3626f90392@mail.gmail.com> On Wed, Feb 11, 2009 at 2:52 PM, nathan at pivotalsf.com wrote: > On Feb 10, 8:49 pm, David Chelimsky wrote: >> On Tue, Feb 10, 2009 at 2:02 PM, Nathan Wilmes wrote: >> > (4) assigns(:xxx) will give really bad errors if your class doesn't happen >> > to define == in such a way that it can equate to FalseClass. >> >> Can you provide an example? > > Let's say I have a simple object class Foo, defined as: > > class Foo > def initialize(bar) > @bar = bar > end > attr_reader :bar > > def ==(other) > self.bar == other.bar > end > end > > and a controller that sets a model variable @foo to Foo.new. > > If you run an rspec controller spec and ask it about assigns(:foo), it > will complain with > an error about how it doesn't know what the 'bar' method is on > FalseClass. It does this > the moment you ask for assigns(:foo). > > Not the biggest deal once you understand what's going on (you can > solve it by making the == method smart > enough to return false unless other is a Foo class) but a very > confusing error to track down. Well - you shouldn't have to do such a workaround. Fixed: 3 down, 1 left From lists at ruby-forum.com Thu Feb 12 02:21:04 2009 From: lists at ruby-forum.com (Kaleem Ullah) Date: Thu, 12 Feb 2009 08:21:04 +0100 Subject: [rspec-users] Rspec approach to test model In-Reply-To: References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> Message-ID: <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> Hi all, Below is my model action. def activate! self.update_attribute(:active, true) end here is spec/models/user_spec.rb describe User do before(:each) do @user=User.new(:email=>'kkk at gmail.com',:password='1234'....,) end This is my spec. it "should activate the user" do @user.activate! @user.active.should be_true end but it gives error like "#23000Duplicate entry 'kkkkk at gmail.com Insert INTO (...) Values(...)". It should do update not Insert. But when i try call it with a new instance of user (with no values assigned to any user attribute) then it works. i.e. it "should activate the user" do @user_1=User.new @user_1.activate! @user_1.active.should be_true end I think i have to erase all the User attributes from "before (:each)" and only assigned it in Examples which required it. am i right ? Thanks -- Posted via http://www.ruby-forum.com/. From joahking at gmail.com Thu Feb 12 05:12:46 2009 From: joahking at gmail.com (Joaquin Rivera Padron) Date: Thu, 12 Feb 2009 11:12:46 +0100 Subject: [rspec-users] Rspec approach to test model In-Reply-To: <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> Message-ID: <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> kaleem, method new does not run your model validations, neither does your provided activate! implementation. but save indeed does. my guess is your mixing several contexts (cases, situations) in your single spec. Try decoupling all with more granular examples and you'll get to save shore :-) cheers, joaquin -------------- next part -------------- An HTML attachment was scrubbed... URL: From Malcolm.Beaton at emc.com Thu Feb 12 07:01:16 2009 From: Malcolm.Beaton at emc.com (Beaton, Malcolm) Date: Thu, 12 Feb 2009 12:01:16 -0000 Subject: [rspec-users] Sorry if this is a stupid question Message-ID: Hi everyone I am trying to run the CS examples using Iron ruby/ cucumber from the download and have hit a really irritating snag I have added a subtract method to the CS calculator - Re compiled - Added a features file for it and when I run I get the following Scenario: subtract two numbers # features/subtraction.feature: 6 Given I have entered 70 into the calculator And I have entered 50 into the calculator When I press subtract Then the result should be 20 on the screen And the result class should be Fixnum |input_1|input_2|button |output|class | |30 |20 |subtract|10 | expected: 0, got: 10 (using ==) Diff: @@ -1,2 +1,2 @@ -0 +10 (Spec::Expectations::ExpectationNotMetError) features/subtraction.feature:15:in `/the result should be (.*) on the scre en/' As you can see the calculator returns the right number (10) but somehow the features file is expecting 0??? Even though I have defined 10 as the result? Can anyone help me - I'm doing my head in Below is the subtract method from the steps file and the result compare When /I press subtract/ do @result = @calc.Subtract end Then /the result should be (.*) on the screen/ do |result| @result.should == result.to_i end Malcolm Beaton _______________ EMC Consulting Phone: +44 1784 222127 | Mobile: +44 7768 427309 malcolm.beaton at emc.com www.emc.com/consulting ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Thu Feb 12 07:28:37 2009 From: lists at ruby-forum.com (Jai-gouk Kim) Date: Thu, 12 Feb 2009 13:28:37 +0100 Subject: [rspec-users] [Cucumber, Merb, Webrat] undefined method 'response' for In-Reply-To: <7bfeb788238eb4753e075ed48ee4e498@ruby-forum.com> References: <7bfeb788238eb4753e075ed48ee4e498@ruby-forum.com> Message-ID: Justin Smestad wrote: > Daniel, I have fixed this in my fork: > http://github.com/jsmestad/merb_cucumber/tree/master > Thanks! IT WORKS! -- Posted via http://www.ruby-forum.com/. From yura at brainhouse.ru Thu Feb 12 06:52:49 2009 From: yura at brainhouse.ru (Yury Kotlyarov) Date: Thu, 12 Feb 2009 14:52:49 +0300 Subject: [rspec-users] how to write complex matchers In-Reply-To: <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> Message-ID: <49940D91.8070106@brainhouse.ru> Hi, I am trying to write custom matcher which accepts block to spec views with forms/fieldsets/inputs eg view: ---
Personal Information
  1. ...
spec: --- it "should have form with input fields" do render ... response.should have_form(users_path) do with_field_set 'Personal Information' do with_text_field 'First name', 'user[first_name]' ... end end end matches? of have_form: --- def matches?(response, &block) @block = block if block response.should @scope.have_tag('form[action=?]', @action) do @block.call.matches?(response) end end matches? of have_field_set: --- def matches?(response, &block) @block = block if block response.should @scope.with_tag('fieldset') do @scope.with_tag('legend', @legend) if @legend @scope.with_tag('ol') do @block.call.matches?(response) end end end but I get: NoMethodError in '/users/new should have form with input fields' undefined method `matches?' for true:TrueClass ./spec/views/users/../../custom_ui_matchers/with_field_set.rb:10:in `matches?' ./spec/views/users/../../custom_ui_matchers/have_form.rb:11:in `matches?' ./spec/views/users/../../custom_ui_matchers/have_form.rb:10:in `matches?' ./spec/views/users/new.html.haml_spec.rb:17: /usr/lib64/ruby/1.8/timeout.rb:53:in `timeout' something wrong with yielding block? Gist: http://gist.github.com/62562 Thanks in advance, Yury From dchelimsky at gmail.com Thu Feb 12 09:34:41 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 12 Feb 2009 08:34:41 -0600 Subject: [rspec-users] how to write complex matchers In-Reply-To: <49940D91.8070106@brainhouse.ru> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> <49940D91.8070106@brainhouse.ru> Message-ID: <57c63afe0902120634l19d08556w1d83be44ece00c5d@mail.gmail.com> On Thu, Feb 12, 2009 at 5:52 AM, Yury Kotlyarov wrote: > Hi, > > I am trying to write custom matcher which accepts block to spec views with > forms/fieldsets/inputs eg > > view: > --- >
>
> Personal Information >
    >
  1. > > >
  2. > ... >
>
>
> > spec: > --- > > it "should have form with input fields" do > render ... > response.should have_form(users_path) do > with_field_set 'Personal Information' do > with_text_field 'First name', 'user[first_name]' > ... > end > end > end > > matches? of have_form: > --- > > def matches?(response, &block) > @block = block if block > response.should @scope.have_tag('form[action=?]', @action) do > @block.call.matches?(response) > end > end matches? of have_field_set: --- > > def matches?(response, &block) > > @block = block if block > response.should @scope.with_tag('fieldset') do > @scope.with_tag('legend', @legend) if @legend > @scope.with_tag('ol') do > @block.call.matches?(response) > end > end > end but I get: NoMethodError in '/users/new should have form with input > fields' undefined method `matches?' for true:TrueClass > ./spec/views/users/../../custom_ui_matchers/with_field_set.rb:10:in > `matches?' ./spec/views/users/../../custom_ui_matchers/have_form.rb:11:in > `matches?' ./spec/views/users/../../custom_ui_matchers/have_form.rb:10:in > `matches?' ./spec/views/users/new.html.haml_spec.rb:17: > /usr/lib64/ruby/1.8/timeout.rb:53:in `timeout' something wrong with yielding > block? Gist: http://gist.github.com/62562 Thanks in advance, Yury What does initialize look like? From matt at mattwynne.net Thu Feb 12 09:39:24 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 12 Feb 2009 14:39:24 +0000 Subject: [rspec-users] Sorry if this is a stupid question In-Reply-To: References: Message-ID: <0697F9DE-D26D-4F65-BD3F-028C482F3009@mattwynne.net> Those features look out of date to me. The Scenarios / More Examples format has been deprecated in the latest version on Github. Which version of cucumber are you using? Try this instead: http://wiki.github.com/aslakhellesoy/cucumber/scenario-outlines On 12 Feb 2009, at 12:01, Beaton, Malcolm wrote: > > > Hi everyone > > I am trying to run the CS examples using Iron ruby/ cucumber from > the download and have hit a really irritating snag > > I have added a subtract method to the CS calculator ? Re compiled ? > Added a features file for it and when I run I get the following > > Scenario: subtract two numbers # features/ > subtraction.feature: > 6 > Given I have entered 70 into the calculator > And I have entered 50 into the calculator > When I press subtract > Then the result should be 20 on the screen > And the result class should be Fixnum > > |input_1|input_2|button |output|class | > |30 |20 |subtract|10 | > > expected: 0, > got: 10 (using ==) > Diff: > @@ -1,2 +1,2 @@ > -0 > +10 (Spec::Expectations::ExpectationNotMetError) > features/subtraction.feature:15:in `/the result should be (.*) > on the scre > en/' > > As you can see the calculator returns the right number (10) but > somehow the features file is expecting 0??? Even though I have > defined 10 as the result? > Can anyone help me ? I?m doing my head in > Below is the subtract method from the steps file and the result > compare > > When /I press subtract/ do > @result = @calc.Subtract > end > > Then /the result should be (.*) on the screen/ do |result| > @result.should == result.to_i > end > > > > > Malcolm Beaton > _______________ > EMC Consulting > Phone: +44 1784 222127 | Mobile: +44 7768 427309 > malcolm.beaton at emc.com > www.emc.com/consulting > > > > ______________________________________________________________________ > This email has been scanned by the MessageLabs Email Security System. > For more information please visit http://www.messagelabs.com/email > ______________________________________________________________________ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Matt Wynne http://blog.mattwynne.net http://www.songkick.com From lists at ruby-forum.com Thu Feb 12 10:13:55 2009 From: lists at ruby-forum.com (Jack Phelps) Date: Thu, 12 Feb 2009 16:13:55 +0100 Subject: [rspec-users] Problem with refresh_specs In-Reply-To: <57c63afe0902110542v410631fbv1d75c68cbcd114df@mail.gmail.com> References: <57c63afe0902110542v410631fbv1d75c68cbcd114df@mail.gmail.com> Message-ID: I am getting the same error with version 2.2.2; I'm testing out Heroku right now and am not sure of my ability to install it manually but will try. I'm not especially experienced with any of this, so if anyone's got any tips they're welcome :) -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Feb 12 10:25:34 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 12 Feb 2009 16:25:34 +0100 Subject: [rspec-users] exemplary way to show a list is sorted? In-Reply-To: <810a540e0902111658x6c731j1c58a620edd4b46f@mail.gmail.com> References: <860c114f0902081548j3b1c18bco44ae938836d02adc@mail.gmail.com> <57c63afe0902101219w5accb52fv477e11f8b386fe80@mail.gmail.com> <6997dd6cfd2ee88c78a4aa242ed9008a@ruby-forum.com> <85d99afe0902101700l170e93bdi4a733716bfce467a@mail.gmail.com> <7e1ef3d95e6a9d848eeb1032755278fd@ruby-forum.com> <85d99afe0902101952g21beb83fkd332a179924ef88d@mail.gmail.com> <9542d82d58a4a582c56a9341684218b3@ruby-forum.com> <810a540e0902111658x6c731j1c58a620edd4b46f@mail.gmail.com> Message-ID: <0ccd016ee7c5ed5ee0b270622cf9b936@ruby-forum.com> Pat Maddox wrote: > > You are completely out of line even suggesting that David is selfish > or unprofessional. Do you have any clue how many changes he HASN'T > made because it would break backwards compatibility? How much effort > goes into sensibly deprecating stuff? The work he does to keep RSpec > working with old versions of Rails (only very recently *announcing* > discontinued support of 1.2.x), as well as consistently keeping it > working with edge Rails even with all of its internal breakage. > I did not believe that what I understood from the choice of words used with respect to removing part of the RSpec API could be correct and so I asked whether or not I was mistaken. Evidently because of my phrasing this was somehow turned into a slur on the people who work on RSpec. I regret that but no insult was intended, it was just a statement of how I understood what I had just read incorporated with a request to have my interpretation corrected. If this had been raised in person and not via email I venture that my question would have been answered directly and without rancor. The initial response that I received from Mr. Dennis was uncalled for. It would have been enough to say that there exists a compelling technical reason to remove the item. It would have been useful to outline briefly what that technical reason was. Bear in mind please that those outside of the inner circle of contributors generally are not conversant with all of the issues facing a project. We nonetheless may possess reasonable concerns with respect to its future development. I am well aware that Rails is a moving target and that Ruby is about to go through the convulsions that will accompany the move to 1.9/2.x in the near future. I expect that in consequence a vast amount of software presently in use will either have to be revised extensively or abandoned. I am not dogmatic about backwards compatibly. On the other hand, I also have first hand experience with OSS projects where backwards compatibility appeared inconsequential. Instead of advising people who raise issues like this to go fork their own project, perhaps a brief statement as to why the action is deemed appropriate might be better. Compare the response from Mr. Dennis to that from Mr. Chelimsky. You may now have the last word. -- Posted via http://www.ruby-forum.com/. From Malcolm.Beaton at emc.com Thu Feb 12 10:58:11 2009 From: Malcolm.Beaton at emc.com (Beaton, Malcolm) Date: Thu, 12 Feb 2009 15:58:11 -0000 Subject: [rspec-users] Sorry if this is a stupid question In-Reply-To: <0697F9DE-D26D-4F65-BD3F-028C482F3009@mattwynne.net> References: <0697F9DE-D26D-4F65-BD3F-028C482F3009@mattwynne.net> Message-ID: I installed it via the Gem package manager ? The version I have installed is cucumber-0.1.16 And I have just re written the features file as suggested in the link and it works Weird that the addition in the examples works even though it is in the older format?? Thanks Heaps - I can now keep what little hair I have left Mal -----Original Message----- From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Matt Wynne Sent: 12 February 2009 14:39 To: rspec-users Subject: Re: [rspec-users] Sorry if this is a stupid question Those features look out of date to me. The Scenarios / More Examples format has been deprecated in the latest version on Github. Which version of cucumber are you using? Try this instead: http://wiki.github.com/aslakhellesoy/cucumber/scenario-outlines On 12 Feb 2009, at 12:01, Beaton, Malcolm wrote: > > > Hi everyone > > I am trying to run the CS examples using Iron ruby/ cucumber from > the download and have hit a really irritating snag > > I have added a subtract method to the CS calculator - Re compiled - > Added a features file for it and when I run I get the following > > Scenario: subtract two numbers # features/ > subtraction.feature: > 6 > Given I have entered 70 into the calculator > And I have entered 50 into the calculator > When I press subtract > Then the result should be 20 on the screen > And the result class should be Fixnum > > |input_1|input_2|button |output|class | > |30 |20 |subtract|10 | > > expected: 0, > got: 10 (using ==) > Diff: > @@ -1,2 +1,2 @@ > -0 > +10 (Spec::Expectations::ExpectationNotMetError) > features/subtraction.feature:15:in `/the result should be (.*) > on the scre > en/' > > As you can see the calculator returns the right number (10) but > somehow the features file is expecting 0??? Even though I have > defined 10 as the result? > Can anyone help me - I'm doing my head in > Below is the subtract method from the steps file and the result > compare > > When /I press subtract/ do > @result = @calc.Subtract > end > > Then /the result should be (.*) on the screen/ do |result| > @result.should == result.to_i > end > > > > > Malcolm Beaton > _______________ > EMC Consulting > Phone: +44 1784 222127 | Mobile: +44 7768 427309 > malcolm.beaton at emc.com > www.emc.com/consulting > > > > ______________________________________________________________________ > This email has been scanned by the MessageLabs Email Security System. > For more information please visit http://www.messagelabs.com/email > ______________________________________________________________________ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Matt Wynne http://blog.mattwynne.net http://www.songkick.com _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ From dchelimsky at gmail.com Thu Feb 12 11:22:00 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 12 Feb 2009 10:22:00 -0600 Subject: [rspec-users] exemplary way to show a list is sorted? Message-ID: On Thu, Feb 12, 2009 at 9:25 AM, James Byrne wrote: > Pat Maddox wrote: > >> >> You are completely out of line even suggesting that David is selfish >> or unprofessional. Do you have any clue how many changes he HASN'T >> made because it would break backwards compatibility? How much effort >> goes into sensibly deprecating stuff? The work he does to keep RSpec >> working with old versions of Rails (only very recently *announcing* >> discontinued support of 1.2.x), as well as consistently keeping it >> working with edge Rails even with all of its internal breakage. >> > > I did not believe that what I understood from the choice of words used > with respect to removing part of the RSpec API could be correct and > so I > asked whether or not I was mistaken. Evidently because of my phrasing > this was somehow turned into a slur on the people who work on > RSpec. I > regret that but no insult was intended, it was just a statement of > how I > understood what I had just read incorporated with a request to have my > interpretation corrected. If this had been raised in person and not > via > email I venture that my question would have been answered directly and > without rancor. > > The initial response that I received from Mr. Dennis was uncalled for. I have to take some responsibility for his initial response. Zach and I were chatting in IRC when I read your initial comment, to which I had a very strong and negative reaction. He was really just trying to take the heat off me at the moment. If you take away the reactionary nature of it, however, he did have good points about the nature of open source, as did Nick Hoffman in this thread. > It would have been enough to say that there exists a compelling > technical reason to remove the item. It would have been useful to > outline briefly what that technical reason was. Bear in mind please > that those outside of the inner circle of contributors generally are > not > conversant with all of the issues facing a project. We nonetheless > may > possess reasonable concerns with respect to its future development. > > I am well aware that Rails is a moving target and that Ruby is about > to > go through the convulsions that will accompany the move to 1.9/2.x in > the near future. I expect that in consequence a vast amount of > software > presently in use will either have to be revised extensively or > abandoned. I am not dogmatic about backwards compatibly. On the other > hand, I also have first hand experience with OSS projects where > backwards compatibility appeared inconsequential. I hope you understand now that this is not the case with rspec. > Instead of advising people who raise issues like this to go fork their > own project, perhaps a brief statement as to why the action is deemed > appropriate might be better. Compare the response from Mr. Dennis to > that from Mr. Chelimsky. Again, I had the benefit of time to step back and try to be constructive. Zach's response was reactionary, but he was channeling my reaction. In accepting reappnsibility for this, btw, I'm not trying to dilute it. I still feel that there were some insults thrown at me, and I'm grateful to Zach and Pat for coming to my defense. I also agree that this would all have been much smaller face to face, with pints of beer in our hands. > You may now have the last word. I think we've all said our piece at this point and would love to move on. Are you clear now about the particular change that started this whole thing? Cheers, David From nick at deadorange.com Thu Feb 12 11:33:35 2009 From: nick at deadorange.com (Nick Hoffman) Date: Thu, 12 Feb 2009 11:33:35 -0500 Subject: [rspec-users] Problem with refresh_specs In-Reply-To: References: Message-ID: On 31/01/2009, at 1:45 AM, jschank wrote: > Hello, > I recently unpacked the latest (1.1.12) rspec and rspec rails in my > applicaiton. > When I run my specs I get: > > config.gem: Unpacked gem rspec-1.1.12 in vendor/gems has no > specification file. Run 'rake gems:refresh_specs' to fix this. > config.gem: Unpacked gem rspec-rails-1.1.12 in vendor/gems has no > specification file. Run 'rake gems:refresh_specs' to fix this. > > > However, when I do what it says, I get this: > [jschank at serenity shindg (maps)]$ rake gems:refresh_specs > (in /Users/jschank/Projects/Rails/shindg) > config.gem: Unpacked gem rspec-1.1.12 in vendor/gems has no > specification file. Run 'rake gems:refresh_specs' to fix this. > config.gem: Unpacked gem rspec-rails-1.1.12 in vendor/gems has no > specification file. Run 'rake gems:refresh_specs' to fix this. > rake aborted! > superclass mismatch for class ModelExampleGroup > > A google search isn't helping me. What can I do to make this warning > go away? > besides piping it to dev/null > > Thanks, > John Schank I had this problem yesterday. Each of my gems in vendor/gems/ was missing its specification file. I have to assume that this is because I manually unpacked gems into vendor/gems/ . I found that "rake gems:refresh_specs" failed to put the specification file into each frozen gem's directory because I didn't have any gem dependencies setup in environment.rb . To fix these "has no specification file" warnings, here's what I did: 1) Add the following gem dependencies to config/environment.rb : config.gem 'rspec', :version => '1.1.12', :lib => false config.gem 'rspec-rails', :version => '1.1.12', :lib => false 2) Run "rake gems:refresh_specs". 3) Check that each frozen gem has a specification file: $ ls -l vendor/gems/*/.specification 4) Comment out the gem dependencies in environment.rb . I hope that helps! -Nick From yura at brainhouse.ru Thu Feb 12 12:12:26 2009 From: yura at brainhouse.ru (Yury Kotlyarov) Date: Thu, 12 Feb 2009 20:12:26 +0300 Subject: [rspec-users] how to write complex matchers In-Reply-To: <57c63afe0902120634l19d08556w1d83be44ece00c5d@mail.gmail.com> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> <49940D91.8070106@brainhouse.ru> <57c63afe0902120634l19d08556w1d83be44ece00c5d@mail.gmail.com> Message-ID: <4994587A.2080001@brainhouse.ru> David Chelimsky wrote: > On Thu, Feb 12, 2009 at 5:52 AM, Yury Kotlyarov wrote: > >> Hi, >> >> I am trying to write custom matcher which accepts block to spec views with >> forms/fieldsets/inputs eg >> >> view: >> --- >>
>>
>> Personal Information >>
    >>
  1. >> >> >>
  2. >> ... >>
>>
>>
>> >> spec: >> --- >> >> it "should have form with input fields" do >> render ... >> response.should have_form(users_path) do >> with_field_set 'Personal Information' do >> with_text_field 'First name', 'user[first_name]' >> ... >> end >> end >> end >> >> matches? of have_form: >> --- >> >> def matches?(response, &block) >> @block = block if block >> response.should @scope.have_tag('form[action=?]', @action) do >> @block.call.matches?(response) >> end >> end matches? of have_field_set: --- >> >> def matches?(response, &block) >> >> @block = block if block >> response.should @scope.with_tag('fieldset') do >> @scope.with_tag('legend', @legend) if @legend >> @scope.with_tag('ol') do >> @block.call.matches?(response) >> end >> end >> end but I get: NoMethodError in '/users/new should have form with input >> fields' undefined method `matches?' for true:TrueClass >> ./spec/views/users/../../custom_ui_matchers/with_field_set.rb:10:in >> `matches?' ./spec/views/users/../../custom_ui_matchers/have_form.rb:11:in >> `matches?' ./spec/views/users/../../custom_ui_matchers/have_form.rb:10:in >> `matches?' ./spec/views/users/new.html.haml_spec.rb:17: >> /usr/lib64/ruby/1.8/timeout.rb:53:in `timeout' something wrong with yielding >> block? Gist: http://gist.github.com/62562 Thanks in advance, Yury >> > > What does initialize look like? > > initialize for have_form: class HaveForm def initialize(action, scope, &block) @action, @scope, @block = action, scope, block end ... end def have_form(action, &block) HaveForm.new(action, self, &block) end initialize for have_field_set: class WithFieldSet def initialize(scope, legend = nil, &block) @scope, @legend, @block = scope, legend, block end end def with_field_set(legend = nil, &block) WithFieldSet.new(self, legend, &block) end btw I put it on gist: http://gist.github.com/62562 From nick at deadorange.com Thu Feb 12 13:30:11 2009 From: nick at deadorange.com (Nick Hoffman) Date: Thu, 12 Feb 2009 13:30:11 -0500 Subject: [rspec-users] [RSpec] mock_model not returning a mock Message-ID: <2A4EBE3C-ACDA-4279-841F-8D9CA4222E0D@deadorange.com> I'm experiencing some strange behaviour with an ActiveRecord model object. I'm trying to spec that a mocked AR object, @form, has an error on the "file" attribute. I've confirmed that there *is* an error on the "file" attribute, because I print out the error. However, the spec fails, saying that one error was expected, but zero were found. I've pasted some code to help with figuring this out: http://pastie.org/387327 One thing that I've noticed is that if I comment this out in my spec: 195 @form.valid? then the spec passes. Any idea what's going on? I'd really appreciate any help at all, as I've been banging my head against this for a while, now. -Nick From nick at deadorange.com Thu Feb 12 13:31:20 2009 From: nick at deadorange.com (Nick Hoffman) Date: Thu, 12 Feb 2009 13:31:20 -0500 Subject: [rspec-users] [RSpec] mock_model not returning a mock In-Reply-To: <2A4EBE3C-ACDA-4279-841F-8D9CA4222E0D@deadorange.com> References: <2A4EBE3C-ACDA-4279-841F-8D9CA4222E0D@deadorange.com> Message-ID: <108311AE-F987-49BF-9834-51F3A7ACBE1F@deadorange.com> Ack, that subject is completely wrong! I forgot to update it after re- writing the email. From nick at deadorange.com Thu Feb 12 14:03:49 2009 From: nick at deadorange.com (Nick Hoffman) Date: Thu, 12 Feb 2009 14:03:49 -0500 Subject: [rspec-users] Is #valid? automatically called? Message-ID: <1DFE3480-D6E6-4501-8610-CFE4138894B1@deadorange.com> Does RSpec automatically call #valid? on ActiveRecord models? For instance, when this example is run: it 'should reject a nil value' do @form = TimeShiftForm.new :file => nil puts "@form.errors.count = <<#{@form.errors.count}>>" @form.should have(1).error_on :file puts "@form.errors.count = <<#{@form.errors.count}>>" end This is printed: @form.errors.count = <<0>> @form.errors.count = <<1>> However, I never called @form.valid? , which leads me to believe that RSpec called it for me. If RSpec does in fact call #valid? automatically, should we refrain from manually calling #valid? ? -Nick From pat.maddox at gmail.com Thu Feb 12 14:37:43 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Thu, 12 Feb 2009 11:37:43 -0800 Subject: [rspec-users] Is #valid? automatically called? In-Reply-To: <1DFE3480-D6E6-4501-8610-CFE4138894B1@deadorange.com> References: <1DFE3480-D6E6-4501-8610-CFE4138894B1@deadorange.com> Message-ID: <2c7e61990902121137p513f1690u1d8e54d27a8eb473@mail.gmail.com> On Thu, Feb 12, 2009 at 11:03 AM, Nick Hoffman wrote: > Does RSpec automatically call #valid? on ActiveRecord models? > > For instance, when this example is run: > > it 'should reject a nil value' do > @form = TimeShiftForm.new :file => nil > > puts "@form.errors.count = <<#{@form.errors.count}>>" > @form.should have(1).error_on :file > puts "@form.errors.count = <<#{@form.errors.count}>>" > end > > This is printed: > @form.errors.count = <<0>> > @form.errors.count = <<1>> > > However, I never called @form.valid? , which leads me to believe that RSpec > called it for me. > > If RSpec does in fact call #valid? automatically, should we refrain from > manually calling #valid? ? RSpec doesn't call #valid? automatically in all cases...but if you look at the source for error(s)_on in spec/rails/extensions/active_record/base.rb you'll see that it does call #valid? automatically. Pat From dchelimsky at gmail.com Thu Feb 12 14:59:40 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 12 Feb 2009 13:59:40 -0600 Subject: [rspec-users] Is #valid? automatically called? In-Reply-To: <1DFE3480-D6E6-4501-8610-CFE4138894B1@deadorange.com> References: <1DFE3480-D6E6-4501-8610-CFE4138894B1@deadorange.com> Message-ID: <21B5303F-C2D2-43B9-92F3-835C09C28373@gmail.com> On Feb 12, 2009, at 1:03 PM, Nick Hoffman wrote: > Does RSpec automatically call #valid? on ActiveRecord models? > > For instance, when this example is run: > > it 'should reject a nil value' do > @form = TimeShiftForm.new :file => nil > > puts "@form.errors.count = <<#{@form.errors.count}>>" > @form.should have(1).error_on :file This matcher, have(1).error_on, does call #valid. > > puts "@form.errors.count = <<#{@form.errors.count}>>" > end > > This is printed: > @form.errors.count = <<0>> > @form.errors.count = <<1>> > > However, I never called @form.valid? , which leads me to believe > that RSpec called it for me. In this case, yes, because the matcher needs that. > If RSpec does in fact call #valid? automatically, should we refrain > from manually calling #valid? The fact that you are asking this shows that we're violating the principle of least surprise. We could make it so it doesn't validate, but that would pit the onus on users to validate explicitly (not to mention the upgrade burden). Thoughts? David > > -Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From nathan at pivotallabs.com Thu Feb 12 17:58:26 2009 From: nathan at pivotallabs.com (Nathan Wilmes) Date: Thu, 12 Feb 2009 14:58:26 -0800 (PST) Subject: [rspec-users] issues with the trunk of rspec-rails In-Reply-To: <57c63afe0902112040g23c8c50cgdf5285c07cce9526@mail.gmail.com> References: <8d0d70270902101202y1aeab001hbfa85777e0307108@mail.gmail.com> <57c63afe0902102049l4458525jcfe4bc4af8ebcd21@mail.gmail.com> <57c63afe0902112040g23c8c50cgdf5285c07cce9526@mail.gmail.com> Message-ID: Thanks for making the other fixes! I don't have a 'have_tag' example handy (replaced all the instances with more compact with_tag syntax).. I'll try to get to it later today and send it to you personally. =N On Feb 11, 8:40?pm, David Chelimsky wrote: > On Wed, Feb 11, 2009 at 2:52 PM, nat... at pivotalsf.com wrote: > > On Feb 10, 8:49 pm, David Chelimsky wrote: > >> On Tue, Feb 10, 2009 at 2:02 PM, Nathan Wilmes wrote: > >> > (3) with_tag is completely broken, as it tries to use the outer class as the > >> > subject of 'with_tag', rather than the have_tag matcher that it lives > >> > inside. > > >> Was it working before and the upgrade broke existing specs? Or is this > >> a general observation? > > > Yes, the upgrade broke existing specs.. it used to work fine as of > > rspec 1.1.4. > > ?The breakage appears to have something to do with the 'subject' > > functionality. > > Nathan, > > Taking a closer look at this - before we introduced the implicit > subject, nested with_tag and without_tags were passing in the > ExampleGroup. The matcher was (and still is) ignoring that argument, > and using the HTML it got from the have_tag call. > > There are also a number of specs in rspec's own suite that show that > this works correctly. These pass against rails 2.0.5, 2.1.2, 2.2.2, > 2.3.0 and edge (as of earlier today). > > Take a look athttp://github.com/dchelimsky/rspec-rails/blob/333810bf6f062599bd39007... > and scroll down to 289, for example. > > Can you show me an example of what's failing for you? Spec and subject > code, and the failure message? > > Thanks, > David > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From yura at brainhouse.ru Thu Feb 12 18:09:22 2009 From: yura at brainhouse.ru (Yury Kotlyarov) Date: Fri, 13 Feb 2009 02:09:22 +0300 Subject: [rspec-users] how to write complex matchers In-Reply-To: <4994587A.2080001@brainhouse.ru> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> <49940D91.8070106@brainhouse.ru> <57c63afe0902120634l19d08556w1d83be44ece00c5d@mail.gmail.com> <4994587A.2080001@brainhouse.ru> Message-ID: <4994AC22.1060604@brainhouse.ru> SOLVED! just need to pass matched result to inner block. gist: http://gist.github.com/62562 Many thanks, Yury From pat.maddox at gmail.com Thu Feb 12 18:42:32 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Thu, 12 Feb 2009 15:42:32 -0800 Subject: [rspec-users] Is #valid? automatically called? In-Reply-To: <21B5303F-C2D2-43B9-92F3-835C09C28373@gmail.com> References: <1DFE3480-D6E6-4501-8610-CFE4138894B1@deadorange.com> <21B5303F-C2D2-43B9-92F3-835C09C28373@gmail.com> Message-ID: <2c7e61990902121542h1edf187flcd5a1489ce9f67ca@mail.gmail.com> On Thu, Feb 12, 2009 at 11:59 AM, David Chelimsky wrote: > On Feb 12, 2009, at 1:03 PM, Nick Hoffman wrote: > >> Does RSpec automatically call #valid? on ActiveRecord models? >> >> For instance, when this example is run: >> >> it 'should reject a nil value' do >> @form = TimeShiftForm.new :file => nil >> >> puts "@form.errors.count = <<#{@form.errors.count}>>" >> @form.should have(1).error_on :file > > This matcher, have(1).error_on, does call #valid. > >> >> puts "@form.errors.count = <<#{@form.errors.count}>>" >> end >> >> This is printed: >> @form.errors.count = <<0>> >> @form.errors.count = <<1>> >> >> However, I never called @form.valid? , which leads me to believe that >> RSpec called it for me. > > In this case, yes, because the matcher needs that. > >> If RSpec does in fact call #valid? automatically, should we refrain from >> manually calling #valid? > > The fact that you are asking this shows that we're violating the principle > of least surprise. We could make it so it doesn't validate, but that would > pit the onus on users to validate explicitly (not to mention the upgrade > burden). > > Thoughts? Yes it's a surprise, but maybe a pleasant one? I actually didn't know about this until 2 weeks ago :) One of my coworkers showed me a spec that included error_on but didn't explicitly call valid? We both scratched our heads a bit, prompting me to check out the code. I think it'll catch a few people by surprise. I don't know that it will lead to errors though. And I think it keeps the code a bit cleaner (valid? may be explicit, but it's noisy as well), still expressing the intent well. Pat From yura at brainhouse.ru Thu Feb 12 23:02:51 2009 From: yura at brainhouse.ru (Yury Kotlyarov) Date: Fri, 13 Feb 2009 07:02:51 +0300 Subject: [rspec-users] how to write complex matchers In-Reply-To: <4994AC22.1060604@brainhouse.ru> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> <49940D91.8070106@brainhouse.ru> <57c63afe0902120634l19d08556w1d83be44ece00c5d@mail.gmail.com> <4994587A.2080001@brainhouse.ru> <4994AC22.1060604@brainhouse.ru> Message-ID: <4994F0EB.6060306@brainhouse.ru> Yury Kotlyarov wrote: > SOLVED! just need to pass matched result to inner block. gist: > http://gist.github.com/62562 > > Many thanks, > Yury > I was wrong. It yields just one last line from the inner block. It passes following: it "should have form to create a new user" do render '/users/new' response.should have_form(users_path) do with_field_set 'Personal Information' do with_text_field 'wrong', 'wrong' # there is no such field with_text_field 'First Name', 'user[first_name]' end end end gist: http://gist.github.com/62562 TIA, Yury From tero at tilus.net Thu Feb 12 23:31:00 2009 From: tero at tilus.net (Tero Tilus) Date: Fri, 13 Feb 2009 06:31:00 +0200 Subject: [rspec-users] Is #valid? automatically called? In-Reply-To: <2c7e61990902121542h1edf187flcd5a1489ce9f67ca@mail.gmail.com> References: <1DFE3480-D6E6-4501-8610-CFE4138894B1@deadorange.com> <21B5303F-C2D2-43B9-92F3-835C09C28373@gmail.com> <2c7e61990902121542h1edf187flcd5a1489ce9f67ca@mail.gmail.com> Message-ID: <20090213043059.GJ6235@uivelo.tilus.net> 2009-02-12 15:42, Pat Maddox: >> The fact that you are asking this shows that we're violating the >> principle of least surprise. > > Yes it's a surprise How do you know #errors_on not implicitly validating wouldn't be bigger surprise? Say 30 (instead of three now surprised) people would be surprised. Would documenting implicit validation on code comments. Now it only says "Extension for should have on AR Model instances" on #errors_on. And imo it could very well say "Calls #valid? before returning list of errors." too, although seeing that yourself from source is only one click away if you you have dug yourself that deep in rspec-rails rdoc. -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From pat.maddox at gmail.com Fri Feb 13 00:07:57 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Thu, 12 Feb 2009 21:07:57 -0800 Subject: [rspec-users] Is #valid? automatically called? In-Reply-To: <20090213043059.GJ6235@uivelo.tilus.net> References: <1DFE3480-D6E6-4501-8610-CFE4138894B1@deadorange.com> <21B5303F-C2D2-43B9-92F3-835C09C28373@gmail.com> <2c7e61990902121542h1edf187flcd5a1489ce9f67ca@mail.gmail.com> <20090213043059.GJ6235@uivelo.tilus.net> Message-ID: <2c7e61990902122107k67062d5aoafa330d2c8479aae@mail.gmail.com> On Thu, Feb 12, 2009 at 8:31 PM, Tero Tilus wrote: > 2009-02-12 15:42, Pat Maddox: >>> The fact that you are asking this shows that we're violating the >>> principle of least surprise. >> >> Yes it's a surprise > > How do you know #errors_on not implicitly validating wouldn't be > bigger surprise? Say 30 (instead of three now surprised) people would > be surprised. Well, I don't know. If you've used Rails for a while you know that AR objects don't have errors attached to them until valid? is called. Anyway, I think overall the implicit valid? is a good thing. Pat From mark at mwilden.com Fri Feb 13 00:27:58 2009 From: mark at mwilden.com (Mark Wilden) Date: Thu, 12 Feb 2009 21:27:58 -0800 Subject: [rspec-users] Is #valid? automatically called? In-Reply-To: <20090213043059.GJ6235@uivelo.tilus.net> References: <1DFE3480-D6E6-4501-8610-CFE4138894B1@deadorange.com> <21B5303F-C2D2-43B9-92F3-835C09C28373@gmail.com> <2c7e61990902121542h1edf187flcd5a1489ce9f67ca@mail.gmail.com> <20090213043059.GJ6235@uivelo.tilus.net> Message-ID: <3c30da400902122127k411facfclc4c813938cea59c2@mail.gmail.com> It seems logical that #errors_on would call valid? Otherwise, how would it know? ///ark From scott at railsnewbie.com Fri Feb 13 00:45:02 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Fri, 13 Feb 2009 00:45:02 -0500 Subject: [rspec-users] Is #valid? automatically called? In-Reply-To: <3c30da400902122127k411facfclc4c813938cea59c2@mail.gmail.com> References: <1DFE3480-D6E6-4501-8610-CFE4138894B1@deadorange.com> <21B5303F-C2D2-43B9-92F3-835C09C28373@gmail.com> <2c7e61990902121542h1edf187flcd5a1489ce9f67ca@mail.gmail.com> <20090213043059.GJ6235@uivelo.tilus.net> <3c30da400902122127k411facfclc4c813938cea59c2@mail.gmail.com> Message-ID: <499508DE.5060902@railsnewbie.com> Mark Wilden wrote: > It seems logical that #errors_on would call valid? Otherwise, how would it know? > > That intuitively makes sense. The reason the whole issue is confusing is because of AR's behaviour: >> User.new.valid? => false >> User.new.errors.to_a => [] errors_on(:foo) looks like it'll call errors.on(:foo), which returns nil if valid? isn't called. Scott > ///ark > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tero at tilus.net Fri Feb 13 01:00:37 2009 From: tero at tilus.net (Tero Tilus) Date: Fri, 13 Feb 2009 08:00:37 +0200 Subject: [rspec-users] Is #valid? automatically called? In-Reply-To: <3c30da400902122127k411facfclc4c813938cea59c2@mail.gmail.com> References: <1DFE3480-D6E6-4501-8610-CFE4138894B1@deadorange.com> <21B5303F-C2D2-43B9-92F3-835C09C28373@gmail.com> <2c7e61990902121542h1edf187flcd5a1489ce9f67ca@mail.gmail.com> <20090213043059.GJ6235@uivelo.tilus.net> <3c30da400902122127k411facfclc4c813938cea59c2@mail.gmail.com> Message-ID: <20090213060037.GP6235@uivelo.tilus.net> 2009-02-12 21:27, Mark Wilden: > It seems logical that #errors_on would call valid? Otherwise, how > would it know? ...and that's exactly what I thought too. -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From lists at ruby-forum.com Fri Feb 13 04:01:46 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Fri, 13 Feb 2009 10:01:46 +0100 Subject: [rspec-users] [RSpec] rcov and/or rexml bug? In-Reply-To: References: <1d5d31eff1533f2d92d2ac0bc40c97d9@ruby-forum.com> <226f56f3f134b7e2635100218229096a@ruby-forum.com> <57c63afe0902030732l6b7db945pf97035e2a7e592f4@mail.gmail.com> <7a98104e01b51224e4cb66cea68977b6@ruby-forum.com> Message-ID: <8b63a41dc81127c4757c911228d167f8@ruby-forum.com> > You shouldn't have to clone and install rcov manually. > > Just do this: > > gem install spicycode-rcov --source http://gems.github.com > > It will install just like any other gem. > Except it didn't work for me, the rcov binary doesn't get installed or is not defined properly. Is anyone else experiencing the same problem? -- Posted via http://www.ruby-forum.com/. From liuyn.neph at gmail.com Fri Feb 13 02:45:58 2009 From: liuyn.neph at gmail.com (Yingnan Liu) Date: Fri, 13 Feb 2009 15:45:58 +0800 Subject: [rspec-users] [cucumber][v0.2alpha]Where could I find API docs for custom formatters? Message-ID: Hi, I'm working on update my local Cucumber to the latest version. But it seems the old formatter APIs(step_failed, scenario_executed, etc.) don't work any more. Are there some documents or even Cucumber source code I can refer to? Thanks in advance, Liu -------------- next part -------------- An HTML attachment was scrubbed... URL: From zuperinfinite at gmail.com Fri Feb 13 05:47:51 2009 From: zuperinfinite at gmail.com (Bart Zonneveld) Date: Fri, 13 Feb 2009 11:47:51 +0100 Subject: [rspec-users] [Cucumber] running `cucumber` without a gem Message-ID: <97872818-A6DC-4EA3-9CC4-AEE930887B2A@gmail.com> Hey list, I have a test server, which doesn't have cucumber as gem, so I unpacked it into vendor/gems. After some fiddling with load paths, it works. However, the "binary" cucumber command won't run, since it needs the cucumber gem. I tried adjusting that file to actually use the unpacked gem, but I can't get it to work. What I have now is http://gist.github.com/63844 Any ideas? thanks, bartz From aslak.hellesoy at gmail.com Fri Feb 13 06:06:09 2009 From: aslak.hellesoy at gmail.com (=?utf-8?Q?Aslak_Helles=C3=B8y?=) Date: Fri, 13 Feb 2009 12:06:09 +0100 Subject: [rspec-users] [cucumber][v0.2alpha]Where could I find API docs for custom formatters? In-Reply-To: References: Message-ID: <7879BC39-EC87-4858-960B-52526C7A128C@gmail.com> API is Cucumber::Ast::Visitor. See cucumber/formatter/*.rb for examples Den 13. feb.. 2009 kl. 08.45 skrev Yingnan Liu : > Hi, > > I'm working on update my local Cucumber to the latest version. But > it seems the old formatter APIs(step_failed, scenario_executed, > etc.) don't work any more. Are there some documents or even Cucumber > source code I can refer to? > > Thanks in advance, > Liu > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From joe at josephwilk.net Fri Feb 13 06:12:32 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Fri, 13 Feb 2009 11:12:32 +0000 Subject: [rspec-users] [cucumber][v0.2alpha]Where could I find API docs for custom formatters? In-Reply-To: References: Message-ID: <499555A0.5080700@josephwilk.net> Hello, Are you trying to update an old formatter to the newest release? The old formatter API has changed in the latest release. At the moment the best place to look is the current formatters source code: lib/cucumber/formatter/* pretty_formatter.rb is a good start. Another good place to look would be the visitor class that contains all the formatter hooks. lib/cucumber/ast/visitor.rb Note the current page on the wiki about formatters (http://wiki.github.com/aslakhellesoy/cucumber/custom-formatters) applies to latest stable release (0.1.16). Once we have stablised the Formatter api for version 0.2 we can update this page with the new details HTH, -- Joseph Wilk http://blog.josephwilk.net Yingnan Liu wrote: > Hi, > > I'm working on update my local Cucumber to the latest version. But it > seems the old formatter APIs(step_failed, scenario_executed, etc.) > don't work any more. Are there some documents or even Cucumber source > code I can refer to? > > Thanks in advance, > Liu > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Fri Feb 13 06:14:05 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 13 Feb 2009 05:14:05 -0600 Subject: [rspec-users] [Cucumber] running `cucumber` without a gem In-Reply-To: <97872818-A6DC-4EA3-9CC4-AEE930887B2A@gmail.com> References: <97872818-A6DC-4EA3-9CC4-AEE930887B2A@gmail.com> Message-ID: <57c63afe0902130314v794c01c2qf4c72de8f6e988a5@mail.gmail.com> On Fri, Feb 13, 2009 at 4:47 AM, Bart Zonneveld wrote: > Hey list, > > I have a test server, which doesn't have cucumber as gem, so I unpacked it > into vendor/gems. After some fiddling with load paths, it works. > However, the "binary" cucumber command won't run, since it needs the > cucumber gem. I tried adjusting that file to actually use the unpacked gem, > but I can't get it to work. What I have now is http://gist.github.com/63844 I haven't tried this, but take a peek at http://gist.github.com/63853 The path should include 'lib', and you shouldn't need the other version resolution stuff. HTH, David > > Any ideas? > thanks, > bartz > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From zuperinfinite at gmail.com Fri Feb 13 07:23:40 2009 From: zuperinfinite at gmail.com (Bart Zonneveld) Date: Fri, 13 Feb 2009 13:23:40 +0100 Subject: [rspec-users] [Cucumber] running `cucumber` without a gem In-Reply-To: <57c63afe0902130314v794c01c2qf4c72de8f6e988a5@mail.gmail.com> References: <97872818-A6DC-4EA3-9CC4-AEE930887B2A@gmail.com> <57c63afe0902130314v794c01c2qf4c72de8f6e988a5@mail.gmail.com> Message-ID: <392CF957-DAF2-41C2-8BE3-BC0F952F0397@gmail.com> On 13 feb 2009, at 12:14, David Chelimsky wrote: > On Fri, Feb 13, 2009 at 4:47 AM, Bart Zonneveld > wrote: >> Hey list, >> >> I have a test server, which doesn't have cucumber as gem, so I >> unpacked it >> into vendor/gems. After some fiddling with load paths, it works. >> However, the "binary" cucumber command won't run, since it needs the >> cucumber gem. I tried adjusting that file to actually use the >> unpacked gem, >> but I can't get it to work. What I have now is http://gist.github.com/63844 > > I haven't tried this, but take a peek at http://gist.github.com/63853 > > The path should include 'lib', and you shouldn't need the other > version resolution stuff. Alas, that didn't work. See http://gist.github.com/63874 thanks so far! bartz From felix.elliger at student.hpi.uni-potsdam.de Fri Feb 13 07:16:19 2009 From: felix.elliger at student.hpi.uni-potsdam.de (Felix Elliger) Date: Fri, 13 Feb 2009 13:16:19 +0100 Subject: [rspec-users] [Cucumber] Http Post just returns status code and not Response-object Message-ID: <49956493.4010100@student.hpi.uni-potsdam.de> Hi, I'm really new to cucumber-testing. I want to use an HTTP Post in my step-definitions using the post-method. When I execute response = post '/controller/action' response is of type Fixnum and contains only the status code returned by the post. In rspec it returns an HTTPResponse-instance. Why is it different? I really need the body of the response. Hope somebody can help me. From chad.humphries at gmail.com Fri Feb 13 08:06:20 2009 From: chad.humphries at gmail.com (Chad Humphries) Date: Fri, 13 Feb 2009 08:06:20 -0500 Subject: [rspec-users] [RSpec] rcov and/or rexml bug? In-Reply-To: <8b63a41dc81127c4757c911228d167f8@ruby-forum.com> References: <1d5d31eff1533f2d92d2ac0bc40c97d9@ruby-forum.com> <226f56f3f134b7e2635100218229096a@ruby-forum.com> <57c63afe0902030732l6b7db945pf97035e2a7e592f4@mail.gmail.com> <7a98104e01b51224e4cb66cea68977b6@ruby-forum.com> <8b63a41dc81127c4757c911228d167f8@ruby-forum.com> Message-ID: <4F1BF726-377C-4085-870B-63387DE41AAA@gmail.com> Githubs recent gem builder changes have caused some issues with this. We are looking into it today in more detail. Pulling it down and manually building should definitely work in the meantime. -- Chad Humphries spicycode On Feb 13, 2009, at 4:01 AM, Fernando Perez wrote: > >> You shouldn't have to clone and install rcov manually. >> >> Just do this: >> >> gem install spicycode-rcov --source http://gems.github.com >> >> It will install just like any other gem. >> > Except it didn't work for me, the rcov binary doesn't get installed or > is not defined properly. Is anyone else experiencing the same problem? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From win at wincent.com Fri Feb 13 08:44:27 2009 From: win at wincent.com (Wincent Colaiuta) Date: Fri, 13 Feb 2009 14:44:27 +0100 Subject: [rspec-users] [Cucumber] ssl requirement Message-ID: <2FB82707-2913-40E5-B583-7F63CB0C3D3F@wincent.com> I'm trying to write features for an SSL-only site, but I can't test anything because every request in my stories results in a redirect (the site is set up to redirect non-SSL requests to SSL). In my _specs_ I hack around this problem with this nasty kludge in my spec_helper: module ActionController class TestRequest def ssl? true end end end But this doesn't seem to work for Cucumber when I add it to my features/support/env.rb, as my ssl? override is never called. I guess either Cucumber doesn't use ActionController::TestRequest under the covers, or if it does the real ActionController::TestRequest.ssl? method is evaluated _after_ and so my override gets overridden itself. Any ideas for how I can stop the redirects from happening? Evidently I've already tried changing instances of: get '/foo' To: get '/foo', :protocol => 'https' But, that makes no difference. Cheers, Wincent From aslak.hellesoy at gmail.com Fri Feb 13 09:11:31 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 13 Feb 2009 15:11:31 +0100 Subject: [rspec-users] [Cucumber] Http Post just returns status code and not Response-object In-Reply-To: <49956493.4010100@student.hpi.uni-potsdam.de> References: <49956493.4010100@student.hpi.uni-potsdam.de> Message-ID: <8d961d900902130611k7963f584u5e287fc62551a3cc@mail.gmail.com> On Fri, Feb 13, 2009 at 1:16 PM, Felix Elliger wrote: > Hi, > > I'm really new to cucumber-testing. I want to use an HTTP Post in my > step-definitions using the post-method. > When I execute > > response = post '/controller/action' > I'm guessing you're using Cucumber with Rails. Cucumber step definitions (when used with Rails) run in an instance of Rails' ActionController::IntegrationTest. If you read that API you'll see that the #response method gives you access to what you need. If you haven't used WebRat, I strongly recommend you check it out. It's a thin DSL on top of ActionController::IntegrationTest that Cucumber supports out of the box. It lets you write steps on the HTML level rather than the HTTP level. Aslak > response is of type Fixnum and contains only the status code returned by the > post. In rspec it returns an HTTPResponse-instance. > > Why is it different? I really need the body of the response. > > Hope somebody can help me. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From felix.elliger at student.hpi.uni-potsdam.de Fri Feb 13 09:37:44 2009 From: felix.elliger at student.hpi.uni-potsdam.de (Felix Elliger) Date: Fri, 13 Feb 2009 15:37:44 +0100 Subject: [rspec-users] [Cucumber] Http Post just returns status code and not Response-object In-Reply-To: <8d961d900902130611k7963f584u5e287fc62551a3cc@mail.gmail.com> References: <49956493.4010100@student.hpi.uni-potsdam.de> <8d961d900902130611k7963f584u5e287fc62551a3cc@mail.gmail.com> Message-ID: <499585B8.1080306@student.hpi.uni-potsdam.de> aslak hellesoy schrieb: > On Fri, Feb 13, 2009 at 1:16 PM, Felix Elliger > wrote: > >> Hi, >> >> I'm really new to cucumber-testing. I want to use an HTTP Post in my >> step-definitions using the post-method. >> When I execute >> >> response = post '/controller/action' >> >> > > I'm guessing you're using Cucumber with Rails. Cucumber step > definitions (when used with Rails) run in an instance of Rails' > ActionController::IntegrationTest. If you read that API you'll see > that the #response method gives you access to what you need. > > If you haven't used WebRat, I strongly recommend you check it out. > It's a thin DSL on top of ActionController::IntegrationTest that > Cucumber supports out of the box. It lets you write steps on the HTML > level rather than the HTTP level. > > Aslak > > >> response is of type Fixnum and contains only the status code returned by the >> post. In rspec it returns an HTTPResponse-instance. >> >> Why is it different? I really need the body of the response. >> >> Hope somebody can help me. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > > > > Thanks, that helped a lot. From lists at ruby-forum.com Fri Feb 13 10:20:52 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 13 Feb 2009 16:20:52 +0100 Subject: [rspec-users] [Cucumber] ssl requirement In-Reply-To: <2FB82707-2913-40E5-B583-7F63CB0C3D3F@wincent.com> References: <2FB82707-2913-40E5-B583-7F63CB0C3D3F@wincent.com> Message-ID: Wincent Colaiuta wrote: > I'm trying to write features for an SSL-only site, but I can't test > anything because every request in my stories results in a redirect > (the site is set up to redirect non-SSL requests to SSL). > You could consider moving your spec_helper method into a separate library module, put that in /lib and load it in config/environments/test.rb. You can also look at: http://www.subelsky.com/2007/11/testing-rails-ssl-requirements-on-your.html for ideas, although I do not think that his approach will tie into cucumber. Good luck. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Feb 13 10:22:22 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Fri, 13 Feb 2009 16:22:22 +0100 Subject: [rspec-users] Cucumber - How to enable a disabled field In-Reply-To: <499313AA.4030807@josephwilk.net> References: <188f0ffe9c1701e54b876847171d4512@ruby-forum.com> <810a540e0902102244g6b2dc22as400da50b312e9211@mail.gmail.com> <67c0f93290b93b82e26a6cb7c65f75f8@ruby-forum.com> <499313AA.4030807@josephwilk.net> Message-ID: <00703565ada40f2ac02f2da53bb33cb1@ruby-forum.com> Joseph Wilk wrote: > I would highly recommend you take a look at Celerity > (http://celerity.rubyforge.org/) as well. Celerity (and Culerity) look great, but after trying for a half a day, I could not get jruby to build, so could not install Celerity, so I am back to Selenium. I followed the instructions here: http://dermological.blogspot.com/2007/02/installing-jruby-on-ubuntu.html but when I try to run: ant clean jar I get: java.lang.NoClassDefFoundError: gnu/classpath/Configuration and at that point, gave up. If you could offer help, I would appreciate it and would try again. I am running this on ubuntu 8.041 in VMWARE (within Vista) java -version returns java version "1.6.0_0" OpenJDK Runtime Environment (build 1.6.0_0-b11) OpenJDK Client VM (build 1.6.0_0-b11, mixed mode, sharing) All the best, Tom -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Fri Feb 13 10:28:00 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 13 Feb 2009 09:28:00 -0600 Subject: [rspec-users] [Cucumber] running `cucumber` without a gem In-Reply-To: <392CF957-DAF2-41C2-8BE3-BC0F952F0397@gmail.com> References: <97872818-A6DC-4EA3-9CC4-AEE930887B2A@gmail.com> <57c63afe0902130314v794c01c2qf4c72de8f6e988a5@mail.gmail.com> <392CF957-DAF2-41C2-8BE3-BC0F952F0397@gmail.com> Message-ID: <57c63afe0902130728g10294e49r4ff2e5764846dbd8@mail.gmail.com> On Fri, Feb 13, 2009 at 6:23 AM, Bart Zonneveld wrote: > > On 13 feb 2009, at 12:14, David Chelimsky wrote: > >> On Fri, Feb 13, 2009 at 4:47 AM, Bart Zonneveld >> wrote: >>> >>> Hey list, >>> >>> I have a test server, which doesn't have cucumber as gem, so I unpacked >>> it >>> into vendor/gems. After some fiddling with load paths, it works. >>> However, the "binary" cucumber command won't run, since it needs the >>> cucumber gem. I tried adjusting that file to actually use the unpacked >>> gem, >>> but I can't get it to work. What I have now is >>> http://gist.github.com/63844 >> >> I haven't tried this, but take a peek at http://gist.github.com/63853 >> >> The path should include 'lib', and you shouldn't need the other >> version resolution stuff. > > Alas, that didn't work. See http://gist.github.com/63874 try "load 'cucumber.rb" > > thanks so far! > bartz > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From nick at deadorange.com Fri Feb 13 10:52:06 2009 From: nick at deadorange.com (Nick Hoffman) Date: Fri, 13 Feb 2009 10:52:06 -0500 Subject: [rspec-users] Is #valid? automatically called? In-Reply-To: <21B5303F-C2D2-43B9-92F3-835C09C28373@gmail.com> References: <1DFE3480-D6E6-4501-8610-CFE4138894B1@deadorange.com> <21B5303F-C2D2-43B9-92F3-835C09C28373@gmail.com> Message-ID: <40994D36-3439-4284-AE1F-F179144BBFE1@deadorange.com> On 12/02/2009, at 2:59 PM, David Chelimsky wrote: > On Feb 12, 2009, at 1:03 PM, Nick Hoffman wrote: > >> Does RSpec automatically call #valid? on ActiveRecord models? >> >> For instance, when this example is run: >> >> it 'should reject a nil value' do >> @form = TimeShiftForm.new :file => nil >> >> puts "@form.errors.count = <<#{@form.errors.count}>>" >> @form.should have(1).error_on :file > > This matcher, have(1).error_on, does call #valid. > >> >> puts "@form.errors.count = <<#{@form.errors.count}>>" >> end >> >> This is printed: >> @form.errors.count = <<0>> >> @form.errors.count = <<1>> >> >> However, I never called @form.valid? , which leads me to believe >> that RSpec called it for me. > > In this case, yes, because the matcher needs that. > >> If RSpec does in fact call #valid? automatically, should we refrain >> from manually calling #valid? > > The fact that you are asking this shows that we're violating the > principle of least surprise. We could make it so it doesn't > validate, but that would pit the onus on users to validate > explicitly (not to mention the upgrade burden). > > Thoughts? > > David I think it comes down to how much work you expect to have to do yourself, versus how much "magic" you expect will, or would like to, happen in the background. It never crossed my mind that a matcher would call #valid? . My impression of matchers was that they simply reported on whether or not an object had a specific setting/property. I figured the matcher simply checked the AR model object for the specified error, regardless of whether or not I'd called #valid? . Personally, I don't think that matchers should be modifying the objects that they check. In my mind, a matcher is like an overseer: it reads and reports, but doesn't tinker. Another reason that I think matchers shouldn't call #valid? is because of the inconsistencies doing so can produce between spec examples. Examples that use have(X).errors_on won't have an explicit call to #valid? , while examples that don't use that matcher, but need #valid? to be called, will have an explicit called to #valid? . That's my perspective on the matter. However, I'm not necessarily advocating that the current behaviour change. Others have said that they find it logical that #valid? is called for them. Who's to say who's right? -Nick From win at wincent.com Fri Feb 13 11:36:48 2009 From: win at wincent.com (Wincent Colaiuta) Date: Fri, 13 Feb 2009 17:36:48 +0100 Subject: [rspec-users] [Cucumber] ssl requirement In-Reply-To: References: Message-ID: <86F5BF06-F95F-4A82-B3BE-886512D258BD@wincent.com> Thanks for the reply, James. El 13/2/2009, a las 16:28, James Byrne escribi?: > You could consider moving your spec_helper method into a separate > library module, put that in /lib and load it in > config/environments/test.rb. Moving the hack from the spec_helper.rb file into a different file unfortunately doesn't make it any less of a kludge... > You can also look at: > > http://www.subelsky.com/2007/11/testing-rails-ssl-requirements-on-your.html > > for ideas, although I do not think that his approach will tie into > cucumber. That article is about setting up a local Apache instance to proxy to a local Mongrel instance so that you can connect via HTTPS in local, manual testing on your development machine. I actually already do that (although I am using nginx, not Apache), but that really has nothing to do with RSpec or Cucumber because unless you're doing in-browser testing with Selenium or similar you're not actually making an HTTP/ HTTPS connection at all. Nevertheless, that article led me to this one: http://www.ricroberts.com/articles/2008/09/25/setting-up-ssl-for-rails-and-testing-it-locally Which itself had a hideous suggestion in it that actually works around my problem. Basically the advice consists of doing something like this in your "ssl_required?" method in your application_controller.rb: # always return false for tests return false if RAILS_ENV == 'test' I brand this as "hideous" because it commits the heinous crime of dynamically modifying application behaviour only when execution within the testing context is detected. Ugh. For the time being, though, looks like the only way to get my Cucumber features working. At least until I find out a better way. Cheers, Wincent From scott at railsnewbie.com Fri Feb 13 11:41:49 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Fri, 13 Feb 2009 11:41:49 -0500 Subject: [rspec-users] Is #valid? automatically called? In-Reply-To: <40994D36-3439-4284-AE1F-F179144BBFE1@deadorange.com> References: <1DFE3480-D6E6-4501-8610-CFE4138894B1@deadorange.com> <21B5303F-C2D2-43B9-92F3-835C09C28373@gmail.com> <40994D36-3439-4284-AE1F-F179144BBFE1@deadorange.com> Message-ID: On Feb 13, 2009, at 10:52 AM, Nick Hoffman wrote: > On 12/02/2009, at 2:59 PM, David Chelimsky wrote: >> On Feb 12, 2009, at 1:03 PM, Nick Hoffman >> wrote: >> >>> Does RSpec automatically call #valid? on ActiveRecord models? >>> >>> For instance, when this example is run: >>> >>> it 'should reject a nil value' do >>> @form = TimeShiftForm.new :file => nil >>> >>> puts "@form.errors.count = <<#{@form.errors.count}>>" >>> @form.should have(1).error_on :file >> >> This matcher, have(1).error_on, does call #valid. >> >>> >>> puts "@form.errors.count = <<#{@form.errors.count}>>" >>> end >>> >>> This is printed: >>> @form.errors.count = <<0>> >>> @form.errors.count = <<1>> >>> >>> However, I never called @form.valid? , which leads me to believe >>> that RSpec called it for me. >> >> In this case, yes, because the matcher needs that. >> >>> If RSpec does in fact call #valid? automatically, should we >>> refrain from manually calling #valid? >> >> The fact that you are asking this shows that we're violating the >> principle of least surprise. We could make it so it doesn't >> validate, but that would pit the onus on users to validate >> explicitly (not to mention the upgrade burden). >> >> Thoughts? >> >> David > > I think it comes down to how much work you expect to have to do > yourself, versus how much "magic" you expect will, or would like to, > happen in the background. > > It never crossed my mind that a matcher would call #valid? . My > impression of matchers was that they simply reported on whether or > not an object had a specific setting/property. I figured the matcher > simply checked the AR model object for the specified error, > regardless of whether or not I'd called #valid? . > > Personally, I don't think that matchers should be modifying the > objects that they check. In my mind, a matcher is like an overseer: > it reads and reports, but doesn't tinker. > > Another reason that I think matchers shouldn't call #valid? is > because of the inconsistencies doing so can produce between spec > examples. Examples that use have(X).errors_on won't have an explicit > call to #valid? , while examples that don't use that matcher, but > need #valid? to be called, will have an explicit called to #valid? . > > That's my perspective on the matter. However, I'm not necessarily > advocating that the current behaviour change. Others have said that > they find it logical that #valid? is called for them. Who's to say > who's right? I must say that I found it a bit surprising when I started using rspec with rails (back in 0.8 or something like that). It's something I figured out after a bit of head scratching, but I think it's something my specs are better for in the long run. If it didn't call valid?, I'd probably end up defining a helper method for my specs that wrapped that behavior. Scott From matt at new-bamboo.co.uk Fri Feb 13 07:38:34 2009 From: matt at new-bamboo.co.uk (deimos1986) Date: Fri, 13 Feb 2009 04:38:34 -0800 (PST) Subject: [rspec-users] [Cucumber, Merb, Webrat] undefined method 'response' for In-Reply-To: <830d29f36c5d6c408b07bd803d489693@ruby-forum.com> References: <7bfeb788238eb4753e075ed48ee4e498@ruby-forum.com> <830d29f36c5d6c408b07bd803d489693@ruby-forum.com> Message-ID: <952c4848-8315-4c5b-8c2d-6cc53a2db190@t3g2000yqa.googlegroups.com> Hi Jim, Just want to say thanks for fixing this. It blocked me for a day trying to figure out what broke. Any chance of trying to get this pulled into david's branch as most tutorials reference his branch. Cheers, Matt On Feb 1, 8:04?am, Jim Morris wrote: > Jim Morris wrote: > > Justin Smestad wrote: > >> Daniel, I have fixed this in my fork: > >>http://github.com/jsmestad/merb_cucumber/tree/master > > > I still get the same error after installing > > jsmestad-merb_cucumber-0.5.1.3 from gems.github.com > > Did the version get bumped OK? or do I need to clone and build locally? > > > Thanks > > never mind, NOTE you have to redo the... > > merb-gen cucumber --session-type webrat > > after installing your fixed version. > > Thanks > -- > Posted viahttp://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Fri Feb 13 14:20:37 2009 From: lists at ruby-forum.com (Jim Morris) Date: Fri, 13 Feb 2009 20:20:37 +0100 Subject: [rspec-users] [Cucumber, Merb, Webrat] undefined method 'response' for In-Reply-To: <952c4848-8315-4c5b-8c2d-6cc53a2db190@t3g2000yqa.googlegroups.com> References: <7bfeb788238eb4753e075ed48ee4e498@ruby-forum.com> <830d29f36c5d6c408b07bd803d489693@ruby-forum.com> <952c4848-8315-4c5b-8c2d-6cc53a2db190@t3g2000yqa.googlegroups.com> Message-ID: deimos1986 wrote: > Hi Jim, > Just want to say thanks for fixing this. It blocked me for a day > trying to figure out what broke. Any chance of trying to get this > pulled into david's branch as most tutorials reference his branch. > > Cheers, > Matt It was Justin, I just benefited from his work... and +1 for getting it merged into Davids branch. -- Posted via http://www.ruby-forum.com/. From phlip2005 at gmail.com Fri Feb 13 14:53:44 2009 From: phlip2005 at gmail.com (Phlip) Date: Fri, 13 Feb 2009 11:53:44 -0800 Subject: [rspec-users] how to write complex matchers In-Reply-To: <49940D91.8070106@brainhouse.ru> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> <49940D91.8070106@brainhouse.ru> Message-ID: Yury Kotlyarov wrote: > it "should have form with input fields" do > render ... > response.should have_form(users_path) do > with_field_set 'Personal Information' do > with_text_field 'First name', 'user[first_name]' > ... > end > end > end The minor problem with that system is it forces your test to say exactly what the code says. That's not "driven" development! If you can forbear to use matchers (shocked gasp!), at my day-job we match blocks all the time with assert2's new xpath system: require 'assert2/xpath' assert_xhtml response xpath :form, :action => users_path do xpath :fieldset, ?. => 'Personal Information' do xpath :input, :type => 'text', :name => 'user[first_name]' and xpath :input, :type => 'text', :name => 'user[last_name]' end end From there, wrapping the xpath() calls up into kewt with_text_field() macros would be trivial. They could also absolves the redundant 'user[]' text on the names, for example. If any inner xpath() fails, there, the fault diagnostic contains a formatted & indented copy of the HTML block under inspection. The entire page would not spew out! Only the
or
would. -- Phlip From dchelimsky at gmail.com Fri Feb 13 15:05:40 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 13 Feb 2009 14:05:40 -0600 Subject: [rspec-users] how to write complex matchers In-Reply-To: References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> <49940D91.8070106@brainhouse.ru> Message-ID: <57c63afe0902131205k204cf101v1cc2b2a87fabd2d0@mail.gmail.com> On Fri, Feb 13, 2009 at 1:53 PM, Phlip wrote: > Yury Kotlyarov wrote: > >> it "should have form with input fields" do >> render ... >> response.should have_form(users_path) do >> with_field_set 'Personal Information' do >> with_text_field 'First name', 'user[first_name]' >> ... >> end >> end >> end > > The minor problem with that system is it forces your test to say exactly > what the code says. That's not "driven" development! > > If you can forbear to use matchers (shocked gasp!), at my day-job we match > blocks all the time with assert2's new xpath system: > > require 'assert2/xpath' > > assert_xhtml response > > xpath :form, :action => users_path do > xpath :fieldset, ?. => 'Personal Information' do > xpath :input, :type => 'text', :name => 'user[first_name]' and > xpath :input, :type => 'text', :name => 'user[last_name]' > end > end Hey Philip, This looks pretty cool. I wonder if you'd have any interest in making this a bit more rspec-friendly? Something like an option to run it like this: expect_xpath do xpath :form, :action => users_path do xpath :fieldset, ?. => 'Personal Information' do xpath :input, :type => 'text', :name => 'user[first_name]' and xpath :input, :type => 'text', :name => 'user[last_name]' end end end > > From there, wrapping the xpath() calls up into kewt with_text_field() macros > would be trivial. They could also absolves the redundant 'user[]' text on > the names, for example. > > If any inner xpath() fails, there, the fault diagnostic contains a formatted > & indented copy of the HTML block under inspection. The entire page would > not spew out! Only the or
would. > > -- > Phlip > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri Feb 13 16:16:06 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 13 Feb 2009 15:16:06 -0600 Subject: [rspec-users] the latest rspec clone Message-ID: <57c63afe0902131316g78543cbcqba2adccc84046fa2@mail.gmail.com> Turns out I'm in the market for a new car ... http://jalopnik.com/5151658/hyundai-genesis-coupe-r+spec-live From ben at benmabey.com Fri Feb 13 16:34:24 2009 From: ben at benmabey.com (Ben Mabey) Date: Fri, 13 Feb 2009 14:34:24 -0700 Subject: [rspec-users] the latest rspec clone In-Reply-To: <57c63afe0902131316g78543cbcqba2adccc84046fa2@mail.gmail.com> References: <57c63afe0902131316g78543cbcqba2adccc84046fa2@mail.gmail.com> Message-ID: <4995E760.2010709@benmabey.com> David Chelimsky wrote: > Turns out I'm in the market for a new car ... > > http://jalopnik.com/5151658/hyundai-genesis-coupe-r+spec-live > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > LOL... I expect you to roll into Vegas at this year's railsconf in that bad boy... Oh, and I found the car that I expect Aslak to come in: http://images.loqu.com/contents/821/153/image/shuiguo2.jpg -Ben From nathan at pivotallabs.com Fri Feb 13 18:20:47 2009 From: nathan at pivotallabs.com (Nathan Wilmes) Date: Fri, 13 Feb 2009 15:20:47 -0800 Subject: [rspec-users] What rescue hooks Message-ID: <8d0d70270902131520i40e2328ai119c7ae52a143a6e@mail.gmail.com> A few of our tests attempt to test controllers with production-style rescuing. Before the current rspec/Rails 2.2.2 combo, it was fairly easy to set up for these tests: it "should throw a 404 for strange actions" do controller.use_rails_error_handling! get :strange_action_name response.should be_missing response.body.should include("You've hit our custom 404 page.") end As of trunk rspec/Rails 2.2.2, this doesn't work. It turns out that ActionController::TestCase has invented its own hook for testing. Without this hook set, you end up in 'local development' mode. So to get into production mode, you need to do this: it "should throw a 404 for strange actions" do controller.use_rails_error_handling! # rspec no longer throws the error without hitting Rails logic rescue_action_in_public! # ActionController::TestCase no longer considers this request a local request get :strange_action_name response.should be_missing response.body.should include("You've hit our custom 404 page.") end Of course, if you have 'rescue_from' handlers, these will happen no matter what. I guess my question is, now that the 'rescue_action_in_public!' hook exists in Rails, does it still make sense for rspec-rails to have its own method? Might it make sense to merge the two functionalities in some way? =Nathan -------------- next part -------------- An HTML attachment was scrubbed... URL: From phlip2005 at gmail.com Fri Feb 13 18:49:00 2009 From: phlip2005 at gmail.com (Phlip) Date: Fri, 13 Feb 2009 15:49:00 -0800 Subject: [rspec-users] how to write complex matchers In-Reply-To: <57c63afe0902131205k204cf101v1cc2b2a87fabd2d0@mail.gmail.com> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> <49940D91.8070106@brainhouse.ru> <57c63afe0902131205k204cf101v1cc2b2a87fabd2d0@mail.gmail.com> Message-ID: David Chelimsky wrote: > This looks pretty cool. I wonder if you'd have any interest in making > this a bit more rspec-friendly? Something like an option to run it > like this: > > expect_xpath do It's on my do-list, but... ...are pluggable matchers as hard to write as the OP implied? How would you fix his problem? I need to know that before diving into the spaghetti that Ruby inevitably generates, just below every kewt DSL! From lists at ruby-forum.com Fri Feb 13 19:26:04 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Sat, 14 Feb 2009 01:26:04 +0100 Subject: [rspec-users] Testing misc methods in ApplicationController In-Reply-To: <57c63afe0802220546k5a8a9c9cn87ac6d00ee88485b@mail.gmail.com> References: <57c63afe0802220546k5a8a9c9cn87ac6d00ee88485b@mail.gmail.com> Message-ID: <50047bcf222002cccd8226f77d282be8@ruby-forum.com> How do you spec protected controller methods such as before_filters and helpers that with the params and session hashes? I cannot call controller.my_method if my_method is protected. > Try this: > > controller.andreplace("foo and bar").should eql("+foo +bar") -- Posted via http://www.ruby-forum.com/. From mark at mwilden.com Fri Feb 13 19:49:55 2009 From: mark at mwilden.com (Mark Wilden) Date: Fri, 13 Feb 2009 16:49:55 -0800 Subject: [rspec-users] Testing misc methods in ApplicationController In-Reply-To: <50047bcf222002cccd8226f77d282be8@ruby-forum.com> References: <57c63afe0802220546k5a8a9c9cn87ac6d00ee88485b@mail.gmail.com> <50047bcf222002cccd8226f77d282be8@ruby-forum.com> Message-ID: <3c30da400902131649m48eb4712v3d5d9cd9aa98bcb2@mail.gmail.com> On Fri, Feb 13, 2009 at 4:26 PM, Fernando Perez wrote: > How do you spec protected controller methods such as before_filters and > helpers that with the params and session hashes? You spec the public interface that calls (or causes to be called) the protected methods. ///ark From nick at deadorange.com Fri Feb 13 21:19:04 2009 From: nick at deadorange.com (Nick Hoffman) Date: Fri, 13 Feb 2009 21:19:04 -0500 Subject: [rspec-users] Testing misc methods in ApplicationController In-Reply-To: <50047bcf222002cccd8226f77d282be8@ruby-forum.com> References: <57c63afe0802220546k5a8a9c9cn87ac6d00ee88485b@mail.gmail.com> <50047bcf222002cccd8226f77d282be8@ruby-forum.com> Message-ID: On 13/02/2009, at 7:26 PM, Fernando Perez wrote: > How do you spec protected controller methods such as before_filters > and > helpers that with the params and session hashes? > > I cannot call controller.my_method if my_method is protected. > >> Try this: >> >> controller.andreplace("foo and bar").should eql("+foo +bar") Hey Fernando. As Mark said, the idea behind BDD is to spec the behaviour of your controller, rather than each specific method. So write specs for all of the different behaviours that your controller can exhibit. This will result in your protected and private methods being called. Cheers, Nick From lists at ruby-forum.com Fri Feb 13 22:30:44 2009 From: lists at ruby-forum.com (Blue Iguana) Date: Sat, 14 Feb 2009 04:30:44 +0100 Subject: [rspec-users] Rspec Mentor or Paid Tutor Needed (near LA or remotely) Message-ID: <2738cb7abbc816e5e358ecce1163a107@ruby-forum.com> I need someone who can help me with Rspec. Ideally someone in the Los Angeles area or else remotely via ichat. I can afford to pay up to $50/hour for 16 hours of training. Hopefully someone who's truly enthusiastic about sharing their knowledge and not just for the money. I'm not new to Ruby but not an expert either. Otherwise I wouldn't be asking for help ;) Send email to rspec at spacedogmedia dot com if interested. Thanks. -- Posted via http://www.ruby-forum.com/. From zuperinfinite at gmail.com Sat Feb 14 07:41:40 2009 From: zuperinfinite at gmail.com (Bart Zonneveld) Date: Sat, 14 Feb 2009 13:41:40 +0100 Subject: [rspec-users] [Cucumber] running `cucumber` without a gem In-Reply-To: <57c63afe0902130728g10294e49r4ff2e5764846dbd8@mail.gmail.com> References: <97872818-A6DC-4EA3-9CC4-AEE930887B2A@gmail.com> <57c63afe0902130314v794c01c2qf4c72de8f6e988a5@mail.gmail.com> <392CF957-DAF2-41C2-8BE3-BC0F952F0397@gmail.com> <57c63afe0902130728g10294e49r4ff2e5764846dbd8@mail.gmail.com> Message-ID: <16FB6EFF-7ABD-48F1-96A4-1A4B428FF4FB@gmail.com> On 13 feb 2009, at 16:28, David Chelimsky wrote: > On Fri, Feb 13, 2009 at 6:23 AM, Bart Zonneveld > wrote: >> >> On 13 feb 2009, at 12:14, David Chelimsky wrote: >> >>> On Fri, Feb 13, 2009 at 4:47 AM, Bart Zonneveld >> > >>> wrote: >>>> >>>> Hey list, >>>> >>>> I have a test server, which doesn't have cucumber as gem, so I >>>> unpacked >>>> it >>>> into vendor/gems. After some fiddling with load paths, it works. >>>> However, the "binary" cucumber command won't run, since it needs >>>> the >>>> cucumber gem. I tried adjusting that file to actually use the >>>> unpacked >>>> gem, >>>> but I can't get it to work. What I have now is >>>> http://gist.github.com/63844 >>> >>> I haven't tried this, but take a peek at http://gist.github.com/ >>> 63853 >>> >>> The path should include 'lib', and you shouldn't need the other >>> version resolution stuff. >> >> Alas, that didn't work. See http://gist.github.com/63874 > > try "load 'cucumber.rb" Still no dice. Weird, such a simple concept, but it just won't work... gr, bartz From lists at ruby-forum.com Sat Feb 14 11:05:55 2009 From: lists at ruby-forum.com (James Byrne) Date: Sat, 14 Feb 2009 17:05:55 +0100 Subject: [rspec-users] [Cucumber] ssl requirement In-Reply-To: <86F5BF06-F95F-4A82-B3BE-886512D258BD@wincent.com> References: <2FB82707-2913-40E5-B583-7F63CB0C3D3F@wincent.com> <86F5BF06-F95F-4A82-B3BE-886512D258BD@wincent.com> Message-ID: <643b9236bcba63a9637e04e4f111832d@ruby-forum.com> Wincent Colaiuta wrote: > # always return false for tests > return false if RAILS_ENV == 'test' > > I brand this as "hideous" because it commits the heinous crime of > dynamically modifying application behaviour only when execution within > the testing context is detected. Ugh. > > For the time being, though, looks like the only way to get my Cucumber > features working. At least until I find out a better way. > > Cheers, > Wincent I am reluctant to go forward on this because I have not yet dealt with this problem first hand. However, I looked into this issue briefly in the past and it seemed to me that the behaviour you wish to test might be triggered by setting one or more of the following environment variables. Since you can set these outside your application code then this might satisfy your desire to avoid custom test code therein. It appears that either one of these is sufficient by itself: HTTPS = ?on? HTTP_X_FORWARDED_PROTO = ?https? I read somewhere that this one might prove necessary in addition to the foregoing. HTTP_X_FORWARDED_SSL = ?on? As I wrote, I have not tested any of this. -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Sat Feb 14 11:43:11 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Sat, 14 Feb 2009 11:43:11 -0500 Subject: [rspec-users] [Cucumber] running `cucumber` without a gem In-Reply-To: <16FB6EFF-7ABD-48F1-96A4-1A4B428FF4FB@gmail.com> References: <97872818-A6DC-4EA3-9CC4-AEE930887B2A@gmail.com> <57c63afe0902130314v794c01c2qf4c72de8f6e988a5@mail.gmail.com> <392CF957-DAF2-41C2-8BE3-BC0F952F0397@gmail.com> <57c63afe0902130728g10294e49r4ff2e5764846dbd8@mail.gmail.com> <16FB6EFF-7ABD-48F1-96A4-1A4B428FF4FB@gmail.com> Message-ID: <85d99afe0902140843s78a071e8ge22e98ba30ccf572@mail.gmail.com> Is your file path wrong? I see: $:.unshift 'vendor/gems/cucumber-0.1.6/lib' Shouldn't that be: $:.unshift 'vendor/gems/cucumber-0.1.16/lib' ?? On Sat, Feb 14, 2009 at 7:41 AM, Bart Zonneveld wrote: > > On 13 feb 2009, at 16:28, David Chelimsky wrote: > >> On Fri, Feb 13, 2009 at 6:23 AM, Bart Zonneveld >> wrote: >>> >>> On 13 feb 2009, at 12:14, David Chelimsky wrote: >>> >>>> On Fri, Feb 13, 2009 at 4:47 AM, Bart Zonneveld >>>> >>>> wrote: >>>>> >>>>> Hey list, >>>>> >>>>> I have a test server, which doesn't have cucumber as gem, so I unpacked >>>>> it >>>>> into vendor/gems. After some fiddling with load paths, it works. >>>>> However, the "binary" cucumber command won't run, since it needs the >>>>> cucumber gem. I tried adjusting that file to actually use the unpacked >>>>> gem, >>>>> but I can't get it to work. What I have now is >>>>> http://gist.github.com/63844 >>>> >>>> I haven't tried this, but take a peek at http://gist.github.com/63853 >>>> >>>> The path should include 'lib', and you shouldn't need the other >>>> version resolution stuff. >>> >>> Alas, that didn't work. See http://gist.github.com/63874 >> >> try "load 'cucumber.rb" > > Still no dice. Weird, such a simple concept, but it just won't work... > > gr, > bartz > > _______________________________________________ > 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 oli.azevedo.barnes at gmail.com Sat Feb 14 15:47:54 2009 From: oli.azevedo.barnes at gmail.com (Oliver Barnes) Date: Sat, 14 Feb 2009 18:47:54 -0200 Subject: [rspec-users] [Cucumber] Portuguese keywords not recognized Message-ID: <6466d9040902141247l1405c348g809bc0b03afe1b47@mail.gmail.com> Hello, I've just installed cucumber 0.1.99, and it looks like the Portuguese step keywords aren't recognized for some reason. I'm following this example up on github: http://github.com/aslakhellesoy/cucumber/blob/ae9bf75d586cda232310721f62ecab91fc2336c0/examples/i18n/pt/features/adicao.feature When I switch to the original English keywords, it runs fine. I've also tried using "Caracter?stica", instead of "Funcionalidade" for the translation of "Feature", but that didn't work either. Is this a bug, or have the Portuguese keywords changed? thanks Oliver From yura at brainhouse.ru Sat Feb 14 16:10:12 2009 From: yura at brainhouse.ru (Yury Kotlyarov) Date: Sun, 15 Feb 2009 00:10:12 +0300 Subject: [rspec-users] how to write complex matchers In-Reply-To: References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> <49940D91.8070106@brainhouse.ru> <57c63afe0902131205k204cf101v1cc2b2a87fabd2d0@mail.gmail.com> Message-ID: <49973334.4040706@brainhouse.ru> Phlip wrote: > David Chelimsky wrote: > >> This looks pretty cool. I wonder if you'd have any interest in making >> this a bit more rspec-friendly? Something like an option to run it >> like this: >> >> expect_xpath do > > It's on my do-list, but... > > ...are pluggable matchers as hard to write as the OP implied? How > would you fix his problem? I need to know that before diving into the > spaghetti that Ruby inevitably generates, just below every kewt DSL! > The major problem is fixed: http://github.com/yura/howto-rspec-custom-matchers/ But there are still few open questions in README.rdoc Regards, Yury From phlip2005 at gmail.com Sat Feb 14 16:39:15 2009 From: phlip2005 at gmail.com (Phlip) Date: Sat, 14 Feb 2009 13:39:15 -0800 Subject: [rspec-users] how to write complex matchers In-Reply-To: <49973334.4040706@brainhouse.ru> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> <49940D91.8070106@brainhouse.ru> <57c63afe0902131205k204cf101v1cc2b2a87fabd2d0@mail.gmail.com> <49973334.4040706@brainhouse.ru> Message-ID: Yury Kotlyarov wrote: > The major problem is fixed: > http://github.com/yura/howto-rspec-custom-matchers/ Apologies if I missed something, but is that a howto or a library? Do I git it and run it to ... learn to customize matchers? From yura at brainhouse.ru Sat Feb 14 16:55:42 2009 From: yura at brainhouse.ru (Yury Kotlyarov) Date: Sun, 15 Feb 2009 00:55:42 +0300 Subject: [rspec-users] how to write complex matchers In-Reply-To: References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> <49940D91.8070106@brainhouse.ru> <57c63afe0902131205k204cf101v1cc2b2a87fabd2d0@mail.gmail.com> <49973334.4040706@brainhouse.ru> Message-ID: <49973DDE.2080307@brainhouse.ru> Phlip wrote: > Yury Kotlyarov wrote: > >> The major problem is fixed: >> http://github.com/yura/howto-rspec-custom-matchers/ > > Apologies if I missed something, but is that a howto or a library? Do > I git it and run it to ... learn to customize matchers? > RSpec is a library ;-) And I have some issues with writing custom matchers using rspec. Now I fixed my major showstopper but still have open questions in the README.rdoc. Of course I hope this project will help others to avoid issues I faced. From phlip2005 at gmail.com Sat Feb 14 17:20:00 2009 From: phlip2005 at gmail.com (Phlip) Date: Sat, 14 Feb 2009 14:20:00 -0800 Subject: [rspec-users] how to write complex matchers In-Reply-To: <49973DDE.2080307@brainhouse.ru> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> <49940D91.8070106@brainhouse.ru> <57c63afe0902131205k204cf101v1cc2b2a87fabd2d0@mail.gmail.com> <49973334.4040706@brainhouse.ru> <49973DDE.2080307@brainhouse.ru> Message-ID: >>> http://github.com/yura/howto-rspec-custom-matchers/ > RSpec is a library ;-) Please try again: What is that source code drop. A website? A library? or something else? From lists at ruby-forum.com Sat Feb 14 17:32:22 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Sat, 14 Feb 2009 23:32:22 +0100 Subject: [rspec-users] Testing misc methods in ApplicationController In-Reply-To: <3c30da400902131649m48eb4712v3d5d9cd9aa98bcb2@mail.gmail.com> References: <57c63afe0802220546k5a8a9c9cn87ac6d00ee88485b@mail.gmail.com> <50047bcf222002cccd8226f77d282be8@ruby-forum.com> <3c30da400902131649m48eb4712v3d5d9cd9aa98bcb2@mail.gmail.com> Message-ID: <3a029849cfe817352c2c50eed747ad4d@ruby-forum.com> > You spec the public interface that calls (or causes to be called) the > protected methods. Ok I see. Thanks for the clarification. -- Posted via http://www.ruby-forum.com/. From yura at brainhouse.ru Sat Feb 14 17:46:23 2009 From: yura at brainhouse.ru (Yury Kotlyarov) Date: Sun, 15 Feb 2009 01:46:23 +0300 Subject: [rspec-users] how to write complex matchers In-Reply-To: References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> <49940D91.8070106@brainhouse.ru> <57c63afe0902131205k204cf101v1cc2b2a87fabd2d0@mail.gmail.com> <49973334.4040706@brainhouse.ru> <49973DDE.2080307@brainhouse.ru> Message-ID: <499749BF.2010002@brainhouse.ru> Phlip wrote: >>>> http://github.com/yura/howto-rspec-custom-matchers/ > >> RSpec is a library ;-) > > Please try again: What is that source code drop. A website? A library? > or something else? > ok - from README: The project aims to encourage feedback on the best practices of creating custom expectation matchers and specs for them. Does it make sense? From phlip2005 at gmail.com Sat Feb 14 17:59:56 2009 From: phlip2005 at gmail.com (Phlip) Date: Sat, 14 Feb 2009 14:59:56 -0800 Subject: [rspec-users] how to write complex matchers In-Reply-To: <499749BF.2010002@brainhouse.ru> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> <49940D91.8070106@brainhouse.ru> <57c63afe0902131205k204cf101v1cc2b2a87fabd2d0@mail.gmail.com> <49973334.4040706@brainhouse.ru> <49973DDE.2080307@brainhouse.ru> <499749BF.2010002@brainhouse.ru> Message-ID: Yury Kotlyarov wrote: >>>>> http://github.com/yura/howto-rspec-custom-matchers/ > The project aims to encourage feedback on the best practices of creating > custom expectation matchers and specs for them. > > Does it make sense? That just says it's a "project". One git clone later... It is a Rails 2.3.0 website! TX; I will now go spelunking down inside it for a while. Wish me luck! (-; From cwdinfo at gmail.com Sat Feb 14 21:07:00 2009 From: cwdinfo at gmail.com (s.ross) Date: Sat, 14 Feb 2009 18:07:00 -0800 Subject: [rspec-users] [Cucumber] ssl requirement In-Reply-To: <643b9236bcba63a9637e04e4f111832d@ruby-forum.com> References: <2FB82707-2913-40E5-B583-7F63CB0C3D3F@wincent.com> <86F5BF06-F95F-4A82-B3BE-886512D258BD@wincent.com> <643b9236bcba63a9637e04e4f111832d@ruby-forum.com> Message-ID: I have a fix to SslRequirement that allows you to exclude user- specified domain names. It's quite likely that you won't want to use SSL on some machines when in development. In any case, I have a bear of a time with the Rails Test::Unit setup so that part's missing, but look over: http://github.com/sxross/ssl_requirement/tree/master Cheers On Feb 14, 2009, at 8:05 AM, James Byrne wrote: > Wincent Colaiuta wrote: > >> # always return false for tests >> return false if RAILS_ENV == 'test' >> >> I brand this as "hideous" because it commits the heinous crime of >> dynamically modifying application behaviour only when execution >> within >> the testing context is detected. Ugh. >> >> For the time being, though, looks like the only way to get my >> Cucumber >> features working. At least until I find out a better way. >> >> Cheers, >> Wincent > > I am reluctant to go forward on this because I have not yet dealt with > this problem first hand. However, I looked into this issue briefly in > the past and it seemed to me that the behaviour you wish to test might > be triggered by setting one or more of the following environment > variables. Since you can set these outside your application code then > this might satisfy your desire to avoid custom test code therein. > > It appears that either one of these is sufficient by itself: > > HTTPS = ?on? > HTTP_X_FORWARDED_PROTO = ?https? > > I read somewhere that this one might prove necessary in addition to > the > foregoing. > > HTTP_X_FORWARDED_SSL = ?on? > > As I wrote, I have not tested any of 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 yura at brainhouse.ru Sun Feb 15 01:18:34 2009 From: yura at brainhouse.ru (Yury Kotlyarov) Date: Sun, 15 Feb 2009 09:18:34 +0300 Subject: [rspec-users] how to write complex matchers In-Reply-To: References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> <49940D91.8070106@brainhouse.ru> <57c63afe0902131205k204cf101v1cc2b2a87fabd2d0@mail.gmail.com> <49973334.4040706@brainhouse.ru> <49973DDE.2080307@brainhouse.ru> <499749BF.2010002@brainhouse.ru> Message-ID: <4997B3BA.9040200@brainhouse.ru> Phlip wrote: > Yury Kotlyarov wrote: > >>>>>> http://github.com/yura/howto-rspec-custom-matchers/ > >> The project aims to encourage feedback on the best practices of >> creating custom expectation matchers and specs for them. >> >> Does it make sense? > > That just says it's a "project". > > One git clone later... It is a Rails 2.3.0 website! > > TX; I will now go spelunking down inside it for a while. Wish me luck! > (-; Yes, rails 2.3 app is just an environment to custom matchers spec'ing/development. You can clone the git repo and just `rake spec` to see my issues... Those matchers (spec/lib/custom_ui_matchers/*) will be used in my real project tho. But I still have minor issues which are listed in Open questions section. Comments/remarks on the specs/code/etc are welcome! Good luck! From joahking at gmail.com Sun Feb 15 07:09:47 2009 From: joahking at gmail.com (Joaquin Rivera Padron) Date: Sun, 15 Feb 2009 13:09:47 +0100 Subject: [rspec-users] Celerity and Webrat (using them together, Benchmarks, same API?) Message-ID: <8277b7f40902150409h6345d3cyfb19d189aa6a50df@mail.gmail.com> hey there, I've been using Cucumber + Webrat for a while. The time has come to spec Js and Ajax, so I've been playing around with celerity features (with culerity until now). 1. How usefull would be to have a common API between Webrat and Celerity? I found usefull to translate webrat steps painless with: # step with typical webrat API When /I follow link (.+)/ do |link| visits path_to(link) end # turn it into this, in steps/common_celerity.rb When /I follow link (.+)/ do |link| visits path_to(link) end # trying to retain a single API Webrat-like when using Celerity def visits(link) @browser.goto(link) end 2. benchmarking webrat vs celerity and any other. Also have notice that culerity goes slower than webrat, are there any benchmarks about it? (I'll try to put up some of those later) are you noticing this also? or is it just me? actually $ top shows some defunkt java processes but dont know whos responsible culerity, celerity, jruby or my bad installation :-) 3. Is it posible (I know it is CodeCowboy) to use them both together in same feature run and say something like: # in some feature file been able to say cucumber to use only webrat :webrat => true Scenario running this step with webrat should save my time Given ... would that be doing the feature "too low level" at the eyes of the client? (should the :webrat => true part be moved to some other place?) if the living together webrat and celerity would pass as valid, then my latter implementation of the steps in point 1 (and every step run I guess) would have to make cucumber recognize which of the Webrat::visits or Celerity::visits (or any other) is to be called what do you think? does that make sense? I'll come back with more later... cheers, joaquin -------------- next part -------------- An HTML attachment was scrubbed... URL: From win at wincent.com Sun Feb 15 10:37:28 2009 From: win at wincent.com (Wincent Colaiuta) Date: Sun, 15 Feb 2009 16:37:28 +0100 Subject: [rspec-users] [Cucumber] ssl requirement In-Reply-To: References: Message-ID: <175A766A-F8EF-41C3-9C97-45D74F87F05F@wincent.com> El 14/2/2009, a las 21:56, James Byrne escribi?: > Wincent Colaiuta wrote: > >> # always return false for tests >> return false if RAILS_ENV == 'test' >> >> I brand this as "hideous" because it commits the heinous crime of >> dynamically modifying application behaviour only when execution >> within >> the testing context is detected. Ugh. >> >> For the time being, though, looks like the only way to get my >> Cucumber >> features working. At least until I find out a better way. >> >> Cheers, >> Wincent > > I am reluctant to go forward on this because I have not yet dealt with > this problem first hand. However, I looked into this issue briefly in > the past and it seemed to me that the behaviour you wish to test might > be triggered by setting one or more of the following environment > variables. Since you can set these outside your application code then > this might satisfy your desire to avoid custom test code therein. > > It appears that either one of these is sufficient by itself: > > HTTPS = ?on? > HTTP_X_FORWARDED_PROTO = ?https? > > I read somewhere that this one might prove necessary in addition to > the > foregoing. > > HTTP_X_FORWARDED_SSL = ?on? > > As I wrote, I have not tested any of this. I haven't (yet) tested it either, but from looking at the Rails source code it looks like you could be right. The "ssl?" method is defined in actionpack/lib/action_controller/request.rb as follows: # Is this an SSL request? def ssl? @env['HTTPS'] == 'on' || @env['HTTP_X_FORWARDED_PROTO'] == 'https' end That's in ActionController::Request, which ActionController::TestRequest inherits from (see vendor/rails/ actionpack/lib/action_controller/test_process.rb). So you would think that setting the environment variable should indeed work. Further snooping in the source (actionpack/lib/action_controller/ integration.rb) shows that while using integration tests, at least, you should also be able to do a "session.https!" to indicate that you're simulating an HTTPS request. So in Cucumber stories that should work too (I gather that Cucumber just wraps Rails' built-in integration testing). [Goes off to test if this actually works...] Ok, so I tried just sticking an "ENV['HTTPS'] = 'on'" in my spec/ spec_helper.rb file and re-running my spec suite. Looks like this is not enough in itself, as I got about 77 spec failures, all of them apparently caused by "ssl?" returning false and producing unwanted redirects. It appears that setting ENV in spec/spec_helper.rb has no effect on the @env instance variable inside ActionController::AbstractRequest. Setting it "sooner" (ie. from the command line with "HTTPS=on rake spec") is evidently not the solution either. I'll need to pore over the labyrinthine source code a little more to figure out exactly how and where @env is getting set up. Ok... had to dig a little bit outside of Rails, into the Rack gem installed on the system, to find out where @env is getting set up. Looks like it's getting passed in as a parameter to Rack::Request.initialize, but looks like it's not coming from the environment, and the backtrace I get is totally useless (only one frame in it!). So I guess I'm going to put further investigation on hold. Cheers, Wincent From ben at benmabey.com Sun Feb 15 11:49:57 2009 From: ben at benmabey.com (Ben Mabey) Date: Sun, 15 Feb 2009 09:49:57 -0700 Subject: [rspec-users] Celerity and Webrat (using them together, Benchmarks, same API?) In-Reply-To: <8277b7f40902150409h6345d3cyfb19d189aa6a50df@mail.gmail.com> References: <8277b7f40902150409h6345d3cyfb19d189aa6a50df@mail.gmail.com> Message-ID: <499847B5.6040308@benmabey.com> Joaquin Rivera Padron wrote: > > 1. How usefull would be to have a common API between Webrat and Celerity? Very useful! In fact someone (Kamal) has already started doing that. Check out his work on his webrat fork: http://github.com/kamal/webrat/tree/1543bc64ecf85054f9a033e1fc7670806886b41e/lib/webrat/celerity > 2. benchmarking webrat vs celerity and any other. > > Also have notice that culerity goes slower than webrat, are there any > benchmarks about it? (I'll try to put up some of those later) are you > noticing this also? or is it just me? JRuby and HTMLUnit are going to add some overhead, that is for sure. Additionally, they are having to make real HTTP requests to a server, where as with webrat's rails mode it uses rail's integration session and is a lot more lightweight. I would stick to using the :rails mode in webrat for as much as you can and then switch to Celerity for the parts that need JS, > > > 3. Is it posible (I know it is CodeCowboy) to use them both together > in same feature run and say something like: Yes. If you want to run them on the feature, and you can make it work with your step definitions then webrat provides two helpful methods for you to do this: When /^I do this and that$/ do webrat.simulate do visit some_path # do other non-js stuff end webrat.automate do click_link "Some JS link" # do other JS related things end end So webrat#simulate is only executed in webrat modes that are "simulating" a web browser and have no JS-capabilities. When you are automating a browser, like with the Selenium mode in webrat, the webrat#automate block is ran but not the webrat#simulate. I can't tell if Kamal has added these to his Celerity session but it would fall into the case of #automate (even though it is simulating.. but the fact that it is executing JS is the distinguishing part.) For some features you may only want them to run with a JS solution. In that case I would recommend using Cucumber's new tagging feature (only available in the latest git version) and tag your features that need JS. You can then create some cucumber profiles in cucumber.yml to only run your JS and non-JS features independently of one another. As you can tell, a lot of this stuff is very new. But what you described is the end goal and give it a month or two and it will be ready for easy consumption IMO. As it is now, you may need to help iron out some problems with the Celerity webrat session. The big advantage of sticking to the webrat API though is that you can easily swap out the different adapters (i.e. selenium) and run your features without modifying your step definitions. HTH, Ben From joahking at gmail.com Sun Feb 15 13:26:50 2009 From: joahking at gmail.com (Joaquin Rivera Padron) Date: Sun, 15 Feb 2009 19:26:50 +0100 Subject: [rspec-users] Celerity and Webrat (using them together, Benchmarks, same API?) In-Reply-To: <499847B5.6040308@benmabey.com> References: <8277b7f40902150409h6345d3cyfb19d189aa6a50df@mail.gmail.com> <499847B5.6040308@benmabey.com> Message-ID: <8277b7f40902151026u1b2569bfw4cb2c3c0045bb762@mail.gmail.com> hey Ben, thanks for your answers, I'll give kamal work a try and have a look at the points you are pointing about webrat. I've been playing with culerity for two days and it does not sound difficult to accomplish this we are talking. But I was talking from the culerity part (haven't look too much into webrat). I have already started to bring together the common_celerity.rb steps that culerity provides with the by webrat provided common steps, in the end by redefining webrat methods (like visit, etc) I can manage to retain common steps, but still there's to do. I'll have a closer look to your points and see. Check out here what I have now: http://github.com/joahking/culerity/tree/webrat_api at the moment for cucumber to use culerity to run the steps, I just comment the webrat initialization in env.rb. But the format.yml is indeed a place to look, more on that later, cheers, joaquin -------------- next part -------------- An HTML attachment was scrubbed... URL: From joahking at gmail.com Sun Feb 15 14:21:57 2009 From: joahking at gmail.com (Joaquin Rivera Padron) Date: Sun, 15 Feb 2009 20:21:57 +0100 Subject: [rspec-users] cucumber hooks BeforeAll and AfterAll Message-ID: <8277b7f40902151121s154bbcccp511a619c103795aa@mail.gmail.com> hey there, the short version: right now Cucumber provides hooks Before and After to be run around every step, I have notice some use case where BeforeAll and AfterAll hooks would be useful. are ther plans that they be provided? what you think would be the best place to do it (mother_step.rb)? any ideas about this could be accomplished? the long version: playing with culerity, which according to the author: * when running cucumber culerity spawns a new jruby process (that's the IO.popen call) - this way cucumber runs in plain old ruby (and you can work with your models for test setup etc.) and only celerity runs in jruby * from then on all communication has to go through pipes (in, out) so i am passing the browser config through those pipes to the newsly spawned jruby process * when a test fails the jruby process doesn't get killed, that's the java processes you see. don't have a good idea how to solve this yet. for now you will have to kill those processes by hand. that has improved since now there's a first attempt for built in support to kill orfan java processes at: http://github.com/joahking/culerity/tree/orfan_processes culerity trick happen at step_definitions/common_celerity.rb Before and After hooks, where you build and kill a spawned jruby around every step. There it is easy to see the gain if we could do those in an around All steps manner what do you think? cheers, joaquin -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.dennis at gmail.com Sun Feb 15 14:41:59 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Sun, 15 Feb 2009 14:41:59 -0500 Subject: [rspec-users] cucumber hooks BeforeAll and AfterAll In-Reply-To: <8277b7f40902151121s154bbcccp511a619c103795aa@mail.gmail.com> References: <8277b7f40902151121s154bbcccp511a619c103795aa@mail.gmail.com> Message-ID: <85d99afe0902151141q1db5d60hf019d9ac625f911c@mail.gmail.com> On Sun, Feb 15, 2009 at 2:21 PM, Joaquin Rivera Padron wrote: > hey there, > the short version: > right now Cucumber provides hooks Before and After to be run around every > step, I have notice some use case where BeforeAll and AfterAll hooks would > be useful. > are ther plans that they be provided? what you think would be the best place > to do it (mother_step.rb)? any ideas about this could be accomplished? > BeforeAll is equivalent to just calling code up in env.rb. AfterAll is equivalent to registering a ruby at_exit hook in your env.rb. Of course they don't have to go in your env.rb, you could put them in another file, and then require them from env.rb or just let cucumber auto-load them if they're in your support/ directory. > the long version: > > playing with culerity, which according to the author: > * when running cucumber culerity spawns a new jruby process (that's the > IO.popen call) - this way cucumber runs in plain old ruby (and you can work > with your models for test setup etc.) and only celerity runs in jruby > * from then on all communication has to go through pipes (in, out) so i am > passing the browser config through those pipes to the newsly spawned jruby > process > * when a test fails the jruby process doesn't get killed, that's the java > processes you see. don't have a good idea how to solve this yet. for now you > will have to kill those processes by hand. > > that has improved since now there's a first attempt for built in support to > kill orfan java processes at: > http://github.com/joahking/culerity/tree/orfan_processes > > culerity trick happen at step_definitions/common_celerity.rb Before and > After hooks, where you build and kill a spawned jruby around every step. > There it is easy to see the gain if we could do those in an around All steps > manner > > what do you think? > > cheers, > joaquin > > > _______________________________________________ > 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 ben at benmabey.com Sun Feb 15 14:47:06 2009 From: ben at benmabey.com (Ben Mabey) Date: Sun, 15 Feb 2009 12:47:06 -0700 Subject: [rspec-users] cucumber hooks BeforeAll and AfterAll In-Reply-To: <85d99afe0902151141q1db5d60hf019d9ac625f911c@mail.gmail.com> References: <8277b7f40902151121s154bbcccp511a619c103795aa@mail.gmail.com> <85d99afe0902151141q1db5d60hf019d9ac625f911c@mail.gmail.com> Message-ID: <4998713A.2010008@benmabey.com> Zach Dennis wrote: > On Sun, Feb 15, 2009 at 2:21 PM, Joaquin Rivera Padron > wrote: > >> hey there, >> the short version: >> right now Cucumber provides hooks Before and After to be run around every >> step, I have notice some use case where BeforeAll and AfterAll hooks would >> be useful. >> are ther plans that they be provided? what you think would be the best place >> to do it (mother_step.rb)? any ideas about this could be accomplished? >> >> > > BeforeAll is equivalent to just calling code up in env.rb. > AfterAll is equivalent to registering a ruby at_exit hook in your env.rb. > > Of course they don't have to go in your env.rb, you could put them in > another file, and then require them from env.rb or just let cucumber > auto-load them if they're in your support/ directory. > > To illustrate what Zach is saying here is an example I used on the wiki[1] before: # Global setup ActionMailer::Base.delivery_method = :test ActionMailer::Base.perform_deliveries = true Before do # Scenario setup ActionMailer::Base.deliveries.clear end After do # Scenario teardown Database.truncate_all end at_exit do # Global teardown TempFileManager.clean_up end HTH, Ben 1. http://wiki.github.com/aslakhellesoy/cucumber/migration-from-rspec-stories > >> the long version: >> >> playing with culerity, which according to the author: >> * when running cucumber culerity spawns a new jruby process (that's the >> IO.popen call) - this way cucumber runs in plain old ruby (and you can work >> with your models for test setup etc.) and only celerity runs in jruby >> * from then on all communication has to go through pipes (in, out) so i am >> passing the browser config through those pipes to the newsly spawned jruby >> process >> * when a test fails the jruby process doesn't get killed, that's the java >> processes you see. don't have a good idea how to solve this yet. for now you >> will have to kill those processes by hand. >> >> that has improved since now there's a first attempt for built in support to >> kill orfan java processes at: >> http://github.com/joahking/culerity/tree/orfan_processes >> >> culerity trick happen at step_definitions/common_celerity.rb Before and >> After hooks, where you build and kill a spawned jruby around every step. >> There it is easy to see the gain if we could do those in an around All steps >> manner >> >> what do you think? >> >> cheers, >> joaquin >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > > > > From r_j_h_box-sf at yahoo.com Sun Feb 15 17:19:23 2009 From: r_j_h_box-sf at yahoo.com (r_j_h_box-sf at yahoo.com) Date: Sun, 15 Feb 2009 14:19:23 -0800 (PST) Subject: [rspec-users] [cucumber] can't use 'visit' except with `rake features` Message-ID: <266457.30758.qm@web31805.mail.mud.yahoo.com> I ported some stories from restful_authentication so that they can use cucumber, and it worked fine in `rake features`. Now when I try to run under autospec or `cucumber features`, I'm getting failures with undefined method `get'. When I change 'get' to 'visit', same symptom (undefined method `visit'), but I'm getting other issues (redirects not being detected or issued) when running in rake. I can't see that I'm doing anything out of the ordinary. I have require "webrat/rails" in my support/env.rb, along with... well, here's my env.rb: http://gist.github.com/64875 Anybody have ideas what could be going on here? Thanks, Randy From lists at ruby-forum.com Sun Feb 15 21:39:25 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 16 Feb 2009 03:39:25 +0100 Subject: [rspec-users] [cucumber] can't use 'visit' except with `rake features` In-Reply-To: <266457.30758.qm@web31805.mail.mud.yahoo.com> References: <266457.30758.qm@web31805.mail.mud.yahoo.com> Message-ID: <663455902ba6dc7087329952fd7ded72@ruby-forum.com> unknown wrote: how are you invoking cucumber from the command line? -- Posted via http://www.ruby-forum.com/. From phlip2005 at gmail.com Sun Feb 15 23:12:02 2009 From: phlip2005 at gmail.com (Phlip) Date: Sun, 15 Feb 2009 20:12:02 -0800 Subject: [rspec-users] how to write complex matchers In-Reply-To: <4997B3BA.9040200@brainhouse.ru> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> <49940D91.8070106@brainhouse.ru> <57c63afe0902131205k204cf101v1cc2b2a87fabd2d0@mail.gmail.com> <49973334.4040706@brainhouse.ru> <49973DDE.2080307@brainhouse.ru> <499749BF.2010002@brainhouse.ru> <4997B3BA.9040200@brainhouse.ru> Message-ID: Yury Kotlyarov wrote: > Phlip wrote: >> Yury Kotlyarov wrote: >> >>>>>>> http://github.com/yura/howto-rspec-custom-matchers/ >> >>> The project aims to encourage feedback on the best practices of >>> creating custom expectation matchers and specs for them. >>> >>> Does it make sense? >> >> That just says it's a "project". >> >> One git clone later... It is a Rails 2.3.0 website! >> >> TX; I will now go spelunking down inside it for a while. Wish me luck! >> (-; > > Yes, rails 2.3 app is just an environment to custom matchers > spec'ing/development. You can clone the git repo and just `rake spec` to > see my issues... Special-needs programmer that I am, I declined to obtain the unreleased 2.3.0 of Rails. I tweaked environment.rb back to 2.2.2. That lead to a curious issue that an RSpec maintainer might understand: ----8<----------------------------------------------------- $ rake spec (in /home/phlip/projects/howto-rspec-custom-matchers) /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- application (MissingSourceFile) from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:155:in `require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:262:in `require_or_load' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:221:in `depend_on' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:133:in `require_dependency' from /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:18:in `define_dispatcher_callbacks' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:182:in `call' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:182:in `evaluate_method' ... 19 levels... from /home/phlip/projects/howto-rspec-custom-matchers/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:14:in `load_files' from /home/phlip/projects/howto-rspec-custom-matchers/vendor/plugins/rspec/lib/spec/runner/options.rb:84:in `run_examples' from /home/phlip/projects/howto-rspec-custom-matchers/vendor/plugins/rspec/lib/spec/runner/command_line.rb:9:in `run' from /home/phlip/projects/howto-rspec-custom-matchers/vendor/plugins/rspec/bin/spec:4 ----8<----------------------------------------------------- Apologies for the ugly unformattable stack trace, but I don't know which lines are important. I fixed the "missing application.rb" error via brute force: cp `find . -name application.rb`. With a copy of application.rb in the root folder, 'rake spec' now works, and I can see some "Not Yet Implemented" issues... > Those matchers (spec/lib/custom_ui_matchers/*) will be used in my real > project tho. But I still have minor issues which are listed in Open > questions section. Comments/remarks on the specs/code/etc are welcome! Well, the rake spec generally passed, so someone else will have to tell you whatever it was you did wrong! (-: -- Phlip http://flea.sourceforge.net/PiglegToo_1.html From r_j_h_box-sf at yahoo.com Mon Feb 16 01:16:15 2009 From: r_j_h_box-sf at yahoo.com (r_j_h_box-sf at yahoo.com) Date: Sun, 15 Feb 2009 22:16:15 -0800 (PST) Subject: [rspec-users] [cucumber] can't use 'visit' except with `rake features` In-Reply-To: <663455902ba6dc7087329952fd7ded72@ruby-forum.com> References: <266457.30758.qm@web31805.mail.mud.yahoo.com> <663455902ba6dc7087329952fd7ded72@ruby-forum.com> Message-ID: <846778.56352.qm@web31809.mail.mud.yahoo.com> I'm running it like so: $ cucumber features/ I've also tried using --require config/boot.rb --require features --require config/environment.rb and now, I've tried with --require lib --require features features/ (nope) --require features --require lib features/ (yes!) Shazaaaayam! Okay, thank you for the hint. Lessee, then for autospec... aha. Yep. cucumber.yml, check. Added these working args to the autotest and autotest-all config, working well now. Okay, updated the wiki page to add some details. These work for me now. http://wiki.github.com/aslakhellesoy/cucumber/ruby-on-rails I'd appreciate a review of this stuff I've added - hopefully it provides more help than harm to others in my situation. :) Thanks, Randy ----- Original Message ---- > From: James Byrne > To: rspec-users at rubyforge.org > Sent: Sunday, February 15, 2009 6:39:25 PM > Subject: Re: [rspec-users] [cucumber] can't use 'visit' except with `rake features` > > unknown wrote: > > how are you invoking cucumber from the command line? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From apremdas at gmail.com Mon Feb 16 01:39:48 2009 From: apremdas at gmail.com (Andrew Premdas) Date: Mon, 16 Feb 2009 06:39:48 +0000 Subject: [rspec-users] Sinitra and Cucumber Message-ID: <88fd8ddc0902152239v1c96d9a0o4c3b607f9dbaf529@mail.gmail.com> Hi all, Anyone using cucumber with sinitra (current). Wondering if I need to use Aslaks sinatra/webrat forks. Also if anyone has a sample app :) All best Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: From zuperinfinite at gmail.com Mon Feb 16 03:19:54 2009 From: zuperinfinite at gmail.com (Bart Zonneveld) Date: Mon, 16 Feb 2009 09:19:54 +0100 Subject: [rspec-users] [Cucumber] running `cucumber` without a gem In-Reply-To: <85d99afe0902140843s78a071e8ge22e98ba30ccf572@mail.gmail.com> References: <97872818-A6DC-4EA3-9CC4-AEE930887B2A@gmail.com> <57c63afe0902130314v794c01c2qf4c72de8f6e988a5@mail.gmail.com> <392CF957-DAF2-41C2-8BE3-BC0F952F0397@gmail.com> <57c63afe0902130728g10294e49r4ff2e5764846dbd8@mail.gmail.com> <16FB6EFF-7ABD-48F1-96A4-1A4B428FF4FB@gmail.com> <85d99afe0902140843s78a071e8ge22e98ba30ccf572@mail.gmail.com> Message-ID: <36EE0F54-C824-4C4B-917D-AF6F094BB5E2@gmail.com> On 14-feb-2009, at 17:43, Zach Dennis wrote: > Is your file path wrong? I see: > > $:.unshift 'vendor/gems/cucumber-0.1.6/lib' > > Shouldn't that be: > > $:.unshift 'vendor/gems/cucumber-0.1.16/lib' D'oh! Great catch! However, it still doesn't work :(. See http://gist.github.com/65073 It loads cucumber, then exits without running any features. > > On Sat, Feb 14, 2009 at 7:41 AM, Bart Zonneveld > wrote: >> >> On 13 feb 2009, at 16:28, David Chelimsky wrote: >> >>> On Fri, Feb 13, 2009 at 6:23 AM, Bart Zonneveld >>> >>> wrote: >>>> >>>> On 13 feb 2009, at 12:14, David Chelimsky wrote: >>>> >>>>> On Fri, Feb 13, 2009 at 4:47 AM, Bart Zonneveld >>>>> >>>>> wrote: >>>>>> >>>>>> Hey list, >>>>>> >>>>>> I have a test server, which doesn't have cucumber as gem, so I >>>>>> unpacked >>>>>> it >>>>>> into vendor/gems. After some fiddling with load paths, it works. >>>>>> However, the "binary" cucumber command won't run, since it >>>>>> needs the >>>>>> cucumber gem. I tried adjusting that file to actually use the >>>>>> unpacked >>>>>> gem, >>>>>> but I can't get it to work. What I have now is >>>>>> http://gist.github.com/63844 >>>>> >>>>> I haven't tried this, but take a peek at http://gist.github.com/ >>>>> 63853 >>>>> >>>>> The path should include 'lib', and you shouldn't need the other >>>>> version resolution stuff. >>>> >>>> Alas, that didn't work. See http://gist.github.com/63874 >>> >>> try "load 'cucumber.rb" >> >> Still no dice. Weird, such a simple concept, but it just won't >> work... >> >> gr, >> bartz >> >> _______________________________________________ >> 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 joahking at gmail.com Mon Feb 16 03:57:38 2009 From: joahking at gmail.com (Joaquin Rivera Padron) Date: Mon, 16 Feb 2009 09:57:38 +0100 Subject: [rspec-users] cucumber hooks BeforeAll and AfterAll In-Reply-To: <4998713A.2010008@benmabey.com> References: <8277b7f40902151121s154bbcccp511a619c103795aa@mail.gmail.com> <85d99afe0902151141q1db5d60hf019d9ac625f911c@mail.gmail.com> <4998713A.2010008@benmabey.com> Message-ID: <8277b7f40902160057m3243f027x657dc2db795a8db2@mail.gmail.com> cool thanks, joaquin 2009/2/15 Ben Mabey > Zach Dennis wrote: > >> On Sun, Feb 15, 2009 at 2:21 PM, Joaquin Rivera Padron >> wrote: >> >> >>> hey there, >>> the short version: >>> right now Cucumber provides hooks Before and After to be run around every >>> step, I have notice some use case where BeforeAll and AfterAll hooks >>> would >>> be useful. >>> are ther plans that they be provided? what you think would be the best >>> place >>> to do it (mother_step.rb)? any ideas about this could be accomplished? >>> >>> >>> >> >> BeforeAll is equivalent to just calling code up in env.rb. >> AfterAll is equivalent to registering a ruby at_exit hook in your env.rb. >> >> Of course they don't have to go in your env.rb, you could put them in >> another file, and then require them from env.rb or just let cucumber >> auto-load them if they're in your support/ directory. >> >> >> > > To illustrate what Zach is saying here is an example I used on the wiki[1] > before: > > # Global setup > ActionMailer::Base.delivery_method = :test > ActionMailer::Base.perform_deliveries = true > > Before do > # Scenario setup > ActionMailer::Base.deliveries.clear > end > > After do > # Scenario teardown > Database.truncate_all > end > > at_exit do > # Global teardown > TempFileManager.clean_up > end > > HTH, > Ben > > 1. > http://wiki.github.com/aslakhellesoy/cucumber/migration-from-rspec-stories > > >> >>> the long version: >>> >>> playing with culerity, which according to the author: >>> * when running cucumber culerity spawns a new jruby process (that's the >>> IO.popen call) - this way cucumber runs in plain old ruby (and you can >>> work >>> with your models for test setup etc.) and only celerity runs in jruby >>> * from then on all communication has to go through pipes (in, out) so i >>> am >>> passing the browser config through those pipes to the newsly spawned >>> jruby >>> process >>> * when a test fails the jruby process doesn't get killed, that's the java >>> processes you see. don't have a good idea how to solve this yet. for now >>> you >>> will have to kill those processes by hand. >>> >>> that has improved since now there's a first attempt for built in support >>> to >>> kill orfan java processes at: >>> http://github.com/joahking/culerity/tree/orfan_processes >>> >>> culerity trick happen at step_definitions/common_celerity.rb Before and >>> After hooks, where you build and kill a spawned jruby around every step. >>> There it is easy to see the gain if we could do those in an around All >>> steps >>> manner >>> >>> what do you think? >>> >>> cheers, >>> joaquin >>> >>> >>> _______________________________________________ >>> 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 > -- www.least-significant-bit.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Mon Feb 16 04:02:07 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 16 Feb 2009 10:02:07 +0100 Subject: [rspec-users] cucumber hooks BeforeAll and AfterAll In-Reply-To: <4998713A.2010008@benmabey.com> References: <8277b7f40902151121s154bbcccp511a619c103795aa@mail.gmail.com> <85d99afe0902151141q1db5d60hf019d9ac625f911c@mail.gmail.com> <4998713A.2010008@benmabey.com> Message-ID: <8d961d900902160102gdf25f7p9528e32683aa15a2@mail.gmail.com> On Sun, Feb 15, 2009 at 8:47 PM, Ben Mabey wrote: > Zach Dennis wrote: >> >> On Sun, Feb 15, 2009 at 2:21 PM, Joaquin Rivera Padron >> wrote: >> >>> >>> hey there, >>> the short version: >>> right now Cucumber provides hooks Before and After to be run around every >>> step, I have notice some use case where BeforeAll and AfterAll hooks >>> would >>> be useful. >>> are ther plans that they be provided? what you think would be the best >>> place >>> to do it (mother_step.rb)? any ideas about this could be accomplished? >>> >>> >> >> BeforeAll is equivalent to just calling code up in env.rb. >> AfterAll is equivalent to registering a ruby at_exit hook in your env.rb. >> I updated the most relevant wiki page with this info: http://wiki.github.com/aslakhellesoy/cucumber/hooks Aslak >> Of course they don't have to go in your env.rb, you could put them in >> another file, and then require them from env.rb or just let cucumber >> auto-load them if they're in your support/ directory. >> >> > > To illustrate what Zach is saying here is an example I used on the wiki[1] > before: > > # Global setup > ActionMailer::Base.delivery_method = :test > ActionMailer::Base.perform_deliveries = true > > Before do > # Scenario setup > ActionMailer::Base.deliveries.clear > end > > After do > # Scenario teardown > Database.truncate_all > end > > at_exit do > # Global teardown > TempFileManager.clean_up > end > > HTH, > Ben > > 1. > http://wiki.github.com/aslakhellesoy/cucumber/migration-from-rspec-stories >> >> >>> >>> the long version: >>> >>> playing with culerity, which according to the author: >>> * when running cucumber culerity spawns a new jruby process (that's the >>> IO.popen call) - this way cucumber runs in plain old ruby (and you can >>> work >>> with your models for test setup etc.) and only celerity runs in jruby >>> * from then on all communication has to go through pipes (in, out) so i >>> am >>> passing the browser config through those pipes to the newsly spawned >>> jruby >>> process >>> * when a test fails the jruby process doesn't get killed, that's the java >>> processes you see. don't have a good idea how to solve this yet. for now >>> you >>> will have to kill those processes by hand. >>> >>> that has improved since now there's a first attempt for built in support >>> to >>> kill orfan java processes at: >>> http://github.com/joahking/culerity/tree/orfan_processes >>> >>> culerity trick happen at step_definitions/common_celerity.rb Before and >>> After hooks, where you build and kill a spawned jruby around every step. >>> There it is easy to see the gain if we could do those in an around All >>> steps >>> manner >>> >>> what do you think? >>> >>> cheers, >>> joaquin >>> >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> >> >> >> >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From aslak.hellesoy at gmail.com Mon Feb 16 05:01:08 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 16 Feb 2009 11:01:08 +0100 Subject: [rspec-users] Sinitra and Cucumber In-Reply-To: <88fd8ddc0902152239v1c96d9a0o4c3b607f9dbaf529@mail.gmail.com> References: <88fd8ddc0902152239v1c96d9a0o4c3b607f9dbaf529@mail.gmail.com> Message-ID: <8d961d900902160201r724d71ib965215d0317e791@mail.gmail.com> On Mon, Feb 16, 2009 at 7:39 AM, Andrew Premdas wrote: > Hi all, > > Anyone using cucumber with sinitra (current). Wondering if I need to use > Aslaks sinatra/webrat forks. Also if anyone has a sample app :) > I've created a ticket for it: http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/204-sinatra-example Aslak > All best > > Andrew > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From phlip2005 at gmail.com Sun Feb 15 20:18:04 2009 From: phlip2005 at gmail.com (Phlip) Date: Sun, 15 Feb 2009 17:18:04 -0800 Subject: [rspec-users] [ANN] Merb Mind Maps - a tutorial on RSpec, GraphViz & a little Merb Message-ID: <4998BECC.9050705@gmail.com> Netizens: Crispin & Gregory's new book, /Agile Testing: A Practical Guide for Testers and Agile Teams/, has a kewt "mind map" at the start of each chapter. It inspired me to find a way to use the "tag cloud" on a blog to draw a mind map of the posts, linked by their tags in common. The result is this little project: http://broadcast.oreilly.com/2009/02/merb-mind-maps.html It showcases... - graph theory - including Minimum Spanning Tree - GraphViz - to typeset the mind maps - Merb - a Rails-style website platform - Ruby - that annoying language that won't go away - RSpec - a Behavior Driven Development system - transparent PNG files with ImageMagick drop-shadows - assert{ 2.0 } - an assertion that reflects its expressions - assert{ xpath } - the latest version of my assert_xpath system - TDD for algorithms & graph theory! - fixture-dependencies - a Rails fixture clone with more features - GraphvizR - a lite Ruby gem that wraps GraphViz dot notation - and even a tiny bit of HAML! The algorithm itself depends on none of those things, so any blog could use the algorithm to present the mind-maps that are already latent within it! From phlip2005 at gmail.com Mon Feb 16 10:36:32 2009 From: phlip2005 at gmail.com (Phlip) Date: Mon, 16 Feb 2009 07:36:32 -0800 Subject: [rspec-users] how to write nested XPath matchers In-Reply-To: <57c63afe0902131205k204cf101v1cc2b2a87fabd2d0@mail.gmail.com> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> <49940D91.8070106@brainhouse.ru> <57c63afe0902131205k204cf101v1cc2b2a87fabd2d0@mail.gmail.com> Message-ID: > This looks pretty cool. I wonder if you'd have any interest in making > this a bit more rspec-friendly? Something like an option to run it > like this: Here's the spec. The sauce is below my signature. it 'should have a user form with the first name' do render '/users/new' response.body.should be_xml_with do xpath :form, :action => '/users' do xpath :fieldset do xpath :'legend[ contains(., "Personal Information") ]' and xpath :'label[ contains(., "First name") ]' and xpath :input, :type => 'text', :name => 'user[first_name]' end end end end Now, two issues. Firstly, what is the point of writing verbiage, designed for review by the customer team, if they should not be expected to understand hardcore engineering gibberish beginning with "body.should be_xml_with do"? A sentence that is only partly English does more harm than good! Secondly, when an xpath() fails, it prepares an elaborate and detailed analysis of the entire situation, packs this into a flunk(), and raises it in a Test::Unit::AssertionFailedError. Then RSpec then throws all that stuff away, and provides an incorrect stack trace to an internal error. Switching my 'user[first_name]' to 'user[first_nome]' provides this: NoMethodError in '/users/new should have xpathic tags' You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.first ./spec/views/users/new.html.erb_spec.rb:50: So if I were to rescue my own AssertionFailedError, and pack it into a failure_message, wouldn't that effort be redundant? -- Phlip require 'assert2/xpath' Spec::Runner.configure do |c| c.include Test::Unit::Assertions end # TODO blog this class BeXmlWith def initialize(scope, &block) @scope, @block = scope, block end def matches?(stwing, &block) waz_xdoc = @xdoc @block = block if block @scope.assert_xhtml stwing return (block || @block || proc{}).call ensure @xdoc = waz_xdoc end def failure_message "yack yack yack" end def negative_failure_message "yack yack yack" end end def be_xml_with(&block) BeXmlWith.new(self, &block) end From dchelimsky at gmail.com Mon Feb 16 10:55:08 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 16 Feb 2009 09:55:08 -0600 Subject: [rspec-users] how to write nested XPath matchers In-Reply-To: References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> <49940D91.8070106@brainhouse.ru> <57c63afe0902131205k204cf101v1cc2b2a87fabd2d0@mail.gmail.com> Message-ID: <57c63afe0902160755y138c0370sbd3a074abad3f9e6@mail.gmail.com> On Mon, Feb 16, 2009 at 9:36 AM, Phlip wrote: >> This looks pretty cool. I wonder if you'd have any interest in making >> this a bit more rspec-friendly? Something like an option to run it >> like this: > > Here's the spec. The sauce is below my signature. > > it 'should have a user form with the first name' do > render '/users/new' > response.body.should be_xml_with do > xpath :form, :action => '/users' do > xpath :fieldset do > xpath :'legend[ contains(., "Personal Information") ]' and > xpath :'label[ contains(., "First name") ]' and > xpath :input, :type => 'text', :name => 'user[first_name]' > end > end > end > end > > Now, two issues. Firstly, what is the point of writing verbiage, designed > for review by the customer team, if they should not be expected to > understand hardcore engineering gibberish beginning with "body.should > be_xml_with do"? A sentence that is only partly English does more harm than > good! When RSpec is used as customer facing, they see the docstrings (strings passed to describe() and it()), not the internal code. That's for developers. > Secondly, when an xpath() fails, it prepares an elaborate and detailed > analysis of the entire situation, packs this into a flunk(), and raises it > in a Test::Unit::AssertionFailedError. > > Then RSpec then throws all that stuff away, and provides an incorrect stack > trace to an internal error. Switching my 'user[first_name]' to > 'user[first_nome]' provides this: > > NoMethodError in '/users/new should have xpathic tags' > You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.first > ./spec/views/users/new.html.erb_spec.rb:50: > > So if I were to rescue my own AssertionFailedError, and pack it into a > failure_message, wouldn't that effort be redundant? Take a look at http://github.com/dchelimsky/rspec/blob/f6c75b1417d9178d4dcaaf9e892e23474d340ff6/lib/spec/matchers/wrap_expectation.rb, I think it'll solve this problem. HTH, David > > -- > Phlip > > require 'assert2/xpath' > > Spec::Runner.configure do |c| > c.include Test::Unit::Assertions > end # TODO blog this > > class BeXmlWith > > def initialize(scope, &block) > @scope, @block = scope, block > end > > def matches?(stwing, &block) > waz_xdoc = @xdoc > @block = block if block > @scope.assert_xhtml stwing > return (block || @block || proc{}).call > ensure > @xdoc = waz_xdoc > end > > def failure_message > "yack yack yack" > end > > def negative_failure_message > "yack yack yack" > end > end > > def be_xml_with(&block) > BeXmlWith.new(self, &block) > end > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From nick at deadorange.com Mon Feb 16 14:48:52 2009 From: nick at deadorange.com (Nick Hoffman) Date: Mon, 16 Feb 2009 14:48:52 -0500 Subject: [rspec-users] [RSpec] #and_raise Message-ID: I often use #and_raise like so: @error_message = 'Some error' @sf.should_receive(:shift_time!).and_raise @error_message However, after trying to do this: @argument_error = mock_model ArgumentError, :message => @error_message @sf.should_receive(:shift_time!).and_raise @argument_error and then reading the docs for #and_raise, I realised that #and_raise only accepts a String or exception class. Is there a way to set the exception class and error message? -Nick From dchelimsky at gmail.com Mon Feb 16 16:12:25 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 16 Feb 2009 15:12:25 -0600 Subject: [rspec-users] [RSpec] #and_raise In-Reply-To: References: Message-ID: <57c63afe0902161312mc30c2a9qcea2ab78592eae86@mail.gmail.com> On Mon, Feb 16, 2009 at 1:48 PM, Nick Hoffman wrote: > I often use #and_raise like so: > > @error_message = 'Some error' > @sf.should_receive(:shift_time!).and_raise @error_message > > However, after trying to do this: > > @argument_error = mock_model ArgumentError, > :message => @error_message > @sf.should_receive(:shift_time!).and_raise @argument_error > > and then reading the docs for #and_raise, I realised that #and_raise only > accepts a String or exception class. > > Is there a way to set the exception class and error message? Actually, it accepts an exception class, exception object, or, apparently (though not documented as such) just a string. Instead of a mock, try a real ArgumentError: @sf.should_receive(:shift_time).and_raise(ArgumentError.new(@error_message)) HTH, David > -Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Mon Feb 16 17:07:04 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Mon, 16 Feb 2009 23:07:04 +0100 Subject: [rspec-users] [Cucumber] 0 scenarios running "dirty" features in Autotest Message-ID: <132f28231bdfadd44a79563280cb4e27@ruby-forum.com> When running autotest with AUTOFEATURE=true, all of my specs and features run fine. However, if I have a feature containing a scenario that fails, autotest lists that feature, but then returns "0 scenarios", and then runs all of the features again. Any idea why this might be? Best, Tom -- Posted via http://www.ruby-forum.com/. From cwdinfo at gmail.com Mon Feb 16 17:17:24 2009 From: cwdinfo at gmail.com (s.ross) Date: Mon, 16 Feb 2009 14:17:24 -0800 Subject: [rspec-users] [Cucumber, rspec-rails] uninitialized constant ActionController::UrlEncodedPairParser Message-ID: It seems there's a known anomaly between rspec-rails and Rails 2.3. That causes the error "uninitialized constant ActionController::UrlEncodedPairParser". I know there is a fix in somebody's repo, but what's the best way to get a working gem version of webrat/cucumber/rspec/rspec-rails that will work with 2.2.2 and 2.3? Scrubbing the gems off and installing the latest release gems don't pull in the fix. Thanks From dchelimsky at gmail.com Mon Feb 16 17:28:13 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 16 Feb 2009 16:28:13 -0600 Subject: [rspec-users] [Cucumber, rspec-rails] uninitialized constant ActionController::UrlEncodedPairParser In-Reply-To: References: Message-ID: <08B4ECE2-FD6A-49CC-8727-2D6E9459221D@gmail.com> Sent from my iPhone On Feb 16, 2009, at 4:17 PM, "s.ross" wrote: > It seems there's a known anomaly between rspec-rails and Rails 2.3. > That causes the error "uninitialized constant > ActionController::UrlEncodedPairParser". I know there is a fix in > somebody's repo, but what's the best way to get a working gem > version of webrat/cucumber/rspec/rspec-rails that will work with > 2.2.2 and 2.3? Scrubbing the gems off and installing the latest > release gems don't pull in the fix. The latest gems from github work with rails 2.3: gem install dchelimsky-rspec-rails (that will pull rspec as a dependency as well) > Thanks > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mr.gaffo at gmail.com Mon Feb 16 17:42:51 2009 From: mr.gaffo at gmail.com (Mike Gaffney) Date: Mon, 16 Feb 2009 16:42:51 -0600 Subject: [rspec-users] [Cucumber, rspec-rails] uninitialized constant ActionController::UrlEncodedPairParser In-Reply-To: References: Message-ID: <4999EBEB.9010501@gmail.com> They are now using using the parser in Rack. Likely Rspec doesn't have this yet on a release or possibly even master. Take a look at: http://webrat.lighthouseapp.com/projects/10503/tickets/161-urlencodedpairparser-removed-in-edge-rails For a similar patch. -Mike s.ross wrote: > It seems there's a known anomaly between rspec-rails and Rails 2.3. > That causes the error "uninitialized constant > ActionController::UrlEncodedPairParser". I know there is a fix in > somebody's repo, but what's the best way to get a working gem version > of webrat/cucumber/rspec/rspec-rails that will work with 2.2.2 and > 2.3? Scrubbing the gems off and installing the latest release gems > don't pull in the fix. > > Thanks > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From joshknowles at gmail.com Mon Feb 16 17:57:27 2009 From: joshknowles at gmail.com (Josh Knowles) Date: Mon, 16 Feb 2009 17:57:27 -0500 Subject: [rspec-users] [Cucumber, rspec-rails] uninitialized constant ActionController::UrlEncodedPairParser In-Reply-To: <08B4ECE2-FD6A-49CC-8727-2D6E9459221D@gmail.com> References: <08B4ECE2-FD6A-49CC-8727-2D6E9459221D@gmail.com> Message-ID: On Mon, Feb 16, 2009 at 5:28 PM, David Chelimsky wrote: > The latest gems from github work with rails 2.3: The problem is in Webrat. I have a hack in my fork, but we need to figure out a longer-term solution. Bug is open, hopefully we can knock it out this week. Patches welcome. -- Josh Knowles phone: 509-979-1593 email: joshknowles at gmail.com web: http://joshknowles.com From cwdinfo at gmail.com Mon Feb 16 18:29:32 2009 From: cwdinfo at gmail.com (s.ross) Date: Mon, 16 Feb 2009 15:29:32 -0800 Subject: [rspec-users] [Cucumber, rspec-rails] uninitialized constant ActionController::UrlEncodedPairParser In-Reply-To: References: <08B4ECE2-FD6A-49CC-8727-2D6E9459221D@gmail.com> Message-ID: Applying this patch to webrat: http://webrat.lighthouseapp.com/attachments/87914/lh_161.diff did the trick for 2.2.2 and 2.3. Eek! :) On Feb 16, 2009, at 2:57 PM, Josh Knowles wrote: > On Mon, Feb 16, 2009 at 5:28 PM, David Chelimsky > wrote: >> The latest gems from github work with rails 2.3: > > The problem is in Webrat. I have a hack in my fork, but we need to > figure out a longer-term solution. Bug is open, hopefully we can > knock it out this week. Patches welcome. > > -- > Josh Knowles > phone: 509-979-1593 > email: joshknowles at gmail.com > web: http://joshknowles.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Mon Feb 16 18:23:33 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 16 Feb 2009 17:23:33 -0600 Subject: [rspec-users] [Cucumber, rspec-rails] uninitialized constant ActionController::UrlEncodedPairParser In-Reply-To: <4999EBEB.9010501@gmail.com> References: <4999EBEB.9010501@gmail.com> Message-ID: <21F2C2EC-AB13-423C-A2D3-47DE338DEEDC@gmail.com> Sent from my iPhone On Feb 16, 2009, at 4:42 PM, Mike Gaffney wrote: > They are now using using the parser in Rack. > > Likely Rspec doesn't have this yet on a release or possibly even > master. Actually we do. Grab the latest! > Take a look at: > > http://webrat.lighthouseapp.com/projects/10503/tickets/161-urlencodedpairparser-removed-in-edge-rails > > For a similar patch. > > -Mike > > s.ross wrote: >> It seems there's a known anomaly between rspec-rails and Rails 2.3. >> That causes the error "uninitialized constant >> ActionController::UrlEncodedPairParser". I know there is a fix in >> somebody's repo, but what's the best way to get a working gem >> version of webrat/cucumber/rspec/rspec-rails that will work with >> 2.2.2 and 2.3? Scrubbing the gems off and installing the latest >> release gems don't pull in the fix. >> >> Thanks >> _______________________________________________ >> 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 phlip2005 at gmail.com Mon Feb 16 21:21:38 2009 From: phlip2005 at gmail.com (Phlip) Date: Mon, 16 Feb 2009 18:21:38 -0800 Subject: [rspec-users] how to write nested XPath matchers In-Reply-To: <57c63afe0902160755y138c0370sbd3a074abad3f9e6@mail.gmail.com> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> <49940D91.8070106@brainhouse.ru> <57c63afe0902131205k204cf101v1cc2b2a87fabd2d0@mail.gmail.com> <57c63afe0902160755y138c0370sbd3a074abad3f9e6@mail.gmail.com> Message-ID: <499A1F32.6080004@gmail.com> David Chelimsky wrote: > When RSpec is used as customer facing, they see the docstrings > (strings passed to describe() and it()), not the internal code. That's > for developers. Then why the .should stuff? I'm a developer - technically - and I never needed it! But enough sophistry: Back to business... > Take a look at http://github.com/dchelimsky/rspec/blob/f6c75b1417d9178d4dcaaf9e892e23474d340ff6/lib/spec/matchers/wrap_expectation.rb, > I think it'll solve this problem. This gives the same issue: class BeXmlWith def matches?(stwing, &block) waz_xdoc = @xdoc @scope.wrap_expectation self do @scope.assert_xhtml stwing return (block || @block || proc{}).call end ensure @xdoc = waz_xdoc end attr_accessor :failure_message The same error message for a stray nil: 1) '/users/new should have xpathic tags' FAILED You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.first ./spec/views/users/new.html.erb_spec.rb:50: line 50 is just this one: response.body.should be_xml_with do and yes the response.body is populated... -- Phlip From phlip2005 at gmail.com Mon Feb 16 21:40:18 2009 From: phlip2005 at gmail.com (Phlip) Date: Mon, 16 Feb 2009 18:40:18 -0800 Subject: [rspec-users] how to write nested XPath matchers In-Reply-To: <499A1F32.6080004@gmail.com> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <751FF11C-F3EF-46A3-89E6-0F56D920EF2A@deadorange.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> <49940D91.8070106@brainhouse.ru> <57c63afe0902131205k204cf101v1cc2b2a87fabd2d0@mail.gmail.com> <57c63afe0902160755y138c0370sbd3a074abad3f9e6@mail.gmail.com> <499A1F32.6080004@gmail.com> Message-ID: > The same error message for a stray nil: This attempt, calling simple_matcher directly, gives nearly the same nil: def be_xml_with_(&block) waz_xdoc = @xdoc simple_matcher 'yo' do |given, matcher| wrap_expectation matcher do assert_xhtml given # this works block.call # crashes with a nil.first error! end end ensure @xdoc = waz_xdoc end it 'should have xpathic tags' do render '/users/new' response.body.should be_xml_with{ # error points to this line xpath :form, :action => '/users' So why no stack trace so I can diagnose this? From dchelimsky at gmail.com Tue Feb 17 07:23:12 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 17 Feb 2009 06:23:12 -0600 Subject: [rspec-users] how to write nested XPath matchers In-Reply-To: <499A1F32.6080004@gmail.com> References: <144a55a325ec691e2bc9114bde38a257@ruby-forum.com> <9388ef029b2679e03eb083ba3d9926bb@ruby-forum.com> <8277b7f40902120212ga6ac8e0u4746ade4a7f3d5eb@mail.gmail.com> <49940D91.8070106@brainhouse.ru> <57c63afe0902131205k204cf101v1cc2b2a87fabd2d0@mail.gmail.com> <57c63afe0902160755y138c0370sbd3a074abad3f9e6@mail.gmail.com> <499A1F32.6080004@gmail.com> Message-ID: <57c63afe0902170423i21000cbbt7e32de8c3dc3bd9f@mail.gmail.com> On Mon, Feb 16, 2009 at 8:21 PM, Phlip wrote: > David Chelimsky wrote: > >> When RSpec is used as customer facing, they see the docstrings >> (strings passed to describe() and it()), not the internal code. That's >> for developers. > > Then why the .should stuff? I'm a developer - technically - and I never > needed it! http://dannorth.net/introducing-bdd > > But enough sophistry: Back to business... > >> Take a look at >> http://github.com/dchelimsky/rspec/blob/f6c75b1417d9178d4dcaaf9e892e23474d340ff6/lib/spec/matchers/wrap_expectation.rb, >> I think it'll solve this problem. > > This gives the same issue: > > class BeXmlWith > > def matches?(stwing, &block) > waz_xdoc = @xdoc > > @scope.wrap_expectation self do > @scope.assert_xhtml stwing > return (block || @block || proc{}).call > end > ensure > @xdoc = waz_xdoc > end > > attr_accessor :failure_message > > The same error message for a stray nil: > > > 1) > '/users/new should have xpathic tags' FAILED > You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.first > ./spec/views/users/new.html.erb_spec.rb:50: > > line 50 is just this one: > > response.body.should be_xml_with do That's the line you want to look at to know which example is failing. To see the full backtrace, use the --backtrace (-b) option. To learn about the various rspec options, use the --help (-h) option. > > and yes the response.body is populated... > > -- > Phlip > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cflipse at gmail.com Tue Feb 17 08:48:31 2009 From: cflipse at gmail.com (Chris Flipse) Date: Tue, 17 Feb 2009 08:48:31 -0500 Subject: [rspec-users] [Cucumber] ssl requirement In-Reply-To: <175A766A-F8EF-41C3-9C97-45D74F87F05F@wincent.com> References: <175A766A-F8EF-41C3-9C97-45D74F87F05F@wincent.com> Message-ID: > > Ok, so I tried just sticking an "ENV['HTTPS'] = 'on'" in my > spec/spec_helper.rb file and re-running my spec suite. Looks like this is > not enough in itself, as I got about 77 spec failures, all of them > apparently caused by "ssl?" returning false and producing unwanted > redirects. > Rails doesn't pull the HTTPS from the env, it pulls it from the request headers. In rails integration tests, you specify those by providing a *third* argument for get/post/put/delete: get :show, { :id => :foobar }, { "HTTPS" => "on" } ... If you're using webrat, you can just call header("HTTPS", "on") and that will, as of 0.4, be sticky through all the redirects and everything else your app can throw at it. I've been doing this at work for a while, and it does work. http://devcaffeine.com/2009/02/16/integration-testing-ssl-with-cucumber/ -- // anything worth taking seriously is worth making fun of // http://blog.devcaffeine.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From lenny at aps.org Tue Feb 17 15:27:27 2009 From: lenny at aps.org (Lenny Marks) Date: Tue, 17 Feb 2009 15:27:27 -0500 Subject: [rspec-users] [Cucumber] Level of features / Feature dependent steps Message-ID: <45453541-CD64-44FC-9585-0F857B81A43B@aps.org> Forgive the long post, just looking for input/advice/alternate opinions.. Like many I think that going through the exercise of framing user requests in Cucumber terms(Features, Scenarios..) really helps facilitate necessary conversations and avoid time wasted implementing the wrong thing(e.g. as a requirement/specification tool). However, I'm a bit confused when it comes to tying this in with Cucumber. I've come across many suggestions about audience being king as far as language used in features, but when writing features as part of a specification for a new feature, I consistently find myself writing at a higher level than most any examples I've come across(See example below). In the past we've typically relied on very informal means of specifying new features(Wiki pages, paper, and verbal communication). No that's not our problem..;-) TPI, Even with extensive object level specs, the full details of what an application does and how it is expected to behave from the outside tends to get lost in the app over time. For example, we have a few applications that were developed by a consulting company. Even concentrating only on the UI and the flow of the application, there are many features that are kind of hidden within the app(ex. assign to drop down that should keep most recently used names first). Without being extremely familiar with the app, all you really know(as a developer or tester) is that it renders successfully, which is an obvious maintenance problem. Even with newer apps, after a feature is implemented it tends to get lost inside the application. I was thinking that Cucumber could really work here as a full life cycle tool because the same artifacts that were initially used to specify a feature, could be kept and re-used as documentation for users and testers. Unlike alternatives such as keeping a Wiki page up to date, having features linked to implemented steps serves as integration tests and also ensures that the feature as written, is still accurate/up to date. (Even link Cucumber output to Wiki page) Anyway, reading through Cucumber docs and examples, I almost always see much more specific examples. e.g. (from RSpec book) Feature: Pay bill on line Scenario: Pay a bill Given a checking account with $50 And a payee named Acme And an Acme bill for $37 When I pay the Acme bill Then I should have $13 remaining in my checking account And the payment of $37 to Acme should be listed in Recent Payments That makes sense to me from a testing perspective, but it just doesn't seem right to me from the perspective I speak of above. If I were flushing out this feature with users, I'd have probably wound up with something more like: Scenario: Pay a bill with sufficient funds Given I have a bill to pay And I have enough money in my checking account to cover it When I pay the bill Then my checking account should be debited by the amount payed And the payment should be listed in Recent Payments One problem is that obviously this way involves always writing an extra level of feature dependent steps. It just seems to me that the specific version tends to distract from the actual story. I'm sure I'm looking at this backwards, but does anyone else use Cucumber similarly? Thanks, -lenny From ashley.moran at patchspace.co.uk Tue Feb 17 16:32:32 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Tue, 17 Feb 2009 21:32:32 +0000 Subject: [rspec-users] cucumber hooks BeforeAll and AfterAll In-Reply-To: <4998713A.2010008@benmabey.com> References: <8277b7f40902151121s154bbcccp511a619c103795aa@mail.gmail.com> <85d99afe0902151141q1db5d60hf019d9ac625f911c@mail.gmail.com> <4998713A.2010008@benmabey.com> Message-ID: On 15 Feb 2009, at 19:47, Ben Mabey wrote: > To illustrate what Zach is saying here is an example I used on the > wiki[1] before: > > # Global setup > ActionMailer::Base.delivery_method = :test > ActionMailer::Base.perform_deliveries = true > > Before do > # Scenario setup > ActionMailer::Base.deliveries.clear > end > > After do > # Scenario teardown > Database.truncate_all > end > > at_exit do > # Global teardown > TempFileManager.clean_up > end > > HTH, > Ben I still think it would be nice if you could write BeforeAll do ActionMailer::Base.delivery_method = :test ActionMailer::Base.perform_deliveries = true end AfterAll do # Global teardown TempFileManager.clean_up end *Yes* it's equivalent (largely), but it does make the intent more clear. And expressing intent is a big part of Cucumber (and RSpec) IMHO. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ http://twitter.com/ashleymoran From jonathan at parkerhill.com Tue Feb 17 16:33:34 2009 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 17 Feb 2009 16:33:34 -0500 Subject: [rspec-users] [Cucumber] Level of features / Feature dependent steps In-Reply-To: <45453541-CD64-44FC-9585-0F857B81A43B@aps.org> References: <45453541-CD64-44FC-9585-0F857B81A43B@aps.org> Message-ID: <765F209C-11A6-4CAE-A8F2-06D04854A541@parkerhill.com> On Feb 17, 2009, at 3:27 PM, Lenny Marks wrote: > Forgive the long post, just looking for input/advice/alternate > opinions.. > > Like many I think that going through the exercise of framing user > requests in Cucumber terms(Features, Scenarios..) really helps > facilitate necessary conversations and avoid time wasted > implementing the wrong thing(e.g. as a requirement/specification > tool). However, I'm a bit confused when it comes to tying this in > with Cucumber. I've come across many suggestions about audience > being king as far as language used in features, but when writing > features as part of a specification for a new feature, I > consistently find myself writing at a higher level than most any > examples I've come across(See example below). > > In the past we've typically relied on very informal means of > specifying new features(Wiki pages, paper, and verbal > communication). No that's not our problem..;-) TPI, Even with > extensive object level specs, the full details of what an > application does and how it is expected to behave from the outside > tends to get lost in the app over time. For example, we have a few > applications that were developed by a consulting company. Even > concentrating only on the UI and the flow of the application, there > are many features that are kind of hidden within the app(ex. assign > to drop down that should keep most recently used names first). > Without being extremely familiar with the app, all you really know > (as a developer or tester) is that it renders successfully, which > is an obvious maintenance problem. Even with newer apps, after a > feature is implemented it tends to get lost inside the application. > > I was thinking that Cucumber could really work here as a full life > cycle tool because the same artifacts that were initially used to > specify a feature, could be kept and re-used as documentation for > users and testers. Unlike alternatives such as keeping a Wiki page > up to date, having features linked to implemented steps serves as > integration tests and also ensures that the feature as written, is > still accurate/up to date. (Even link Cucumber output to Wiki page) > > Anyway, reading through Cucumber docs and examples, I almost always > see much more specific examples. > > e.g. (from RSpec book) > Feature: Pay bill on line > > Scenario: Pay a bill > Given a checking account with $50 > And a payee named Acme > And an Acme bill for $37 > When I pay the Acme bill > Then I should have $13 remaining in my checking account > And the payment of $37 to Acme should be listed in Recent > Payments > > That makes sense to me from a testing perspective, but it just > doesn't seem right to me from the perspective I speak of above. If > I were flushing out this feature with users, I'd have probably > wound up with something more like: > > Scenario: Pay a bill with sufficient funds > Given I have a bill to pay > And I have enough money in my checking account to cover it > When I pay the bill > Then my checking account should be debited by the amount payed > And the payment should be listed in Recent Payments > > One problem is that obviously this way involves always writing an > extra level of feature dependent steps. It just seems to me that > the specific version tends to distract from the actual story. I'm > sure I'm looking at this backwards, but does anyone else use > Cucumber similarly? Not sure about your 'life cycle' discussion, but wrt the examples, I do that all the time. You've probably seen earlier discussions about instance variables. Some have advised against it, but I use them. Its manageable if you're consistent. eg @account == 'a checking account', 'my checking account', etc @bill == 'the bill', etc @bill.amount == 'the amount', 'the payment', etc etc And have default setups but also more specific ones as needed, Given /^I have a bill to pay$/ do @bill = Bill.create( :company => 'Acme', :amount => 37 ) end Given /^I have a bill to pay to "(.+)" for \$(\d+)$/ |who, amount| @bill = Bill.create( :company => who, :amount => amount ) end so you can have Given I have a bill to pay or Given I have a bill to pay to "Acme" for $37 I'd probably change your 2nd step to And I have enough money in my checking account to cover the bill so "my checking account" and "the bill" reference @account and @bill If you're managing both checking and savings accounts, i might have @checking and @savings instead of @account, and make the account type another argument, and so on --linoj > > Thanks, > -lenny > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Tue Feb 17 18:06:26 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 17 Feb 2009 17:06:26 -0600 Subject: [rspec-users] What rescue hooks In-Reply-To: <8d0d70270902131520i40e2328ai119c7ae52a143a6e@mail.gmail.com> References: <8d0d70270902131520i40e2328ai119c7ae52a143a6e@mail.gmail.com> Message-ID: <57c63afe0902171506n370ea134m3a6cc64bbedfa8bc@mail.gmail.com> On Fri, Feb 13, 2009 at 5:20 PM, Nathan Wilmes wrote: > A few of our tests attempt to test controllers with production-style > rescuing. Before the current rspec/Rails 2.2.2 combo, it was fairly easy to > set up for these tests: > > it "should throw a 404 for strange actions" do > controller.use_rails_error_handling! > get :strange_action_name > response.should be_missing > response.body.should include("You've hit our custom 404 page.") > end > > As of trunk rspec/Rails 2.2.2, this doesn't work. It turns out that > ActionController::TestCase has invented its own hook for testing. Without > this hook set, you end up > in 'local development' mode. So to get into production mode, you need to do > this: > > it "should throw a 404 for strange actions" do > controller.use_rails_error_handling! # rspec no longer throws the error > without hitting Rails logic > rescue_action_in_public! # ActionController::TestCase no longer considers > this request a local request > > get :strange_action_name > response.should be_missing > response.body.should include("You've hit our custom 404 page.") > end > > Of course, if you have 'rescue_from' handlers, these will happen no matter > what. > > I guess my question is, now that the 'rescue_action_in_public!' hook exists > in Rails, does it still make sense for rspec-rails to have its own method? > Might it make sense > to merge the two functionalities in some way? Nathan, Thanks for bringing this all up. I've made some changes and additions based on this and a few other conversations. Here's how it works now (latest in git and latest github gem, and the next formal release): 1. controller.use_rails_error_handling! now works as it did in 1.1.12 2. controller.use_rails_error_handling! is now deprecated, because rescue_action_in_public! does exactly the same thing without rspec-rails having to monkey patch rails 3. added bypass_rescue, which you can use to bypass any rescued errors (defined in rescue_from) This allows you to do any of the following: 1. specify un_rescued errors with "should raise_error" (default) 2. specify un_rescued errors with status codes (using rescue_action_in_public!) 3. specify rescued errors with bypass_rescue with "should raise_error" 4. specify rescued errors with bypass_rescue with status codes (using rescue_action_in_public!) Both rescue_action_in_public! and bypass_rescue can be declared per-example, or in before(:each). Questions? > > =Nathan > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From oli.azevedo.barnes at gmail.com Tue Feb 17 18:14:45 2009 From: oli.azevedo.barnes at gmail.com (Oliver Barnes) Date: Tue, 17 Feb 2009 20:14:45 -0300 Subject: [rspec-users] [Cucumber] Portuguese keywords not recognized In-Reply-To: <6466d9040902141247l1405c348g809bc0b03afe1b47@mail.gmail.com> References: <6466d9040902141247l1405c348g809bc0b03afe1b47@mail.gmail.com> Message-ID: <6466d9040902171514n6c4f72e5vfdcfe4ecfc8d04de@mail.gmail.com> sorry to bump this up, I am the only one experiencing this problem? anybody else running cucumber in other languages? 2009/2/14 Oliver Barnes : > Hello, > > I've just installed cucumber 0.1.99, and it looks like the Portuguese > step keywords aren't recognized for some reason. I'm following this > example up on github: > > http://github.com/aslakhellesoy/cucumber/blob/ae9bf75d586cda232310721f62ecab91fc2336c0/examples/i18n/pt/features/adicao.feature > > When I switch to the original English keywords, it runs fine. I've > also tried using "Caracter?stica", instead of "Funcionalidade" for the > translation of "Feature", but that didn't work either. > > Is this a bug, or have the Portuguese keywords changed? > > thanks > Oliver > From dchelimsky at gmail.com Tue Feb 17 18:33:39 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 17 Feb 2009 17:33:39 -0600 Subject: [rspec-users] [Cucumber] Portuguese keywords not recognized In-Reply-To: <6466d9040902171514n6c4f72e5vfdcfe4ecfc8d04de@mail.gmail.com> References: <6466d9040902141247l1405c348g809bc0b03afe1b47@mail.gmail.com> <6466d9040902171514n6c4f72e5vfdcfe4ecfc8d04de@mail.gmail.com> Message-ID: <57c63afe0902171533x47618ea9w30962c6f6dfad7e8@mail.gmail.com> On Tue, Feb 17, 2009 at 5:14 PM, Oliver Barnes wrote: > sorry to bump this up, I am the only one experiencing this problem? > anybody else running cucumber in other languages? Oi Oliver, Poderia ver o codigo aqui: http://github.com/aslakhellesoy/cucumber/blob/e1afbf1908fdb3867d857478847403abeedd91d7/lib/cucumber/languages.yml HTH, David > > 2009/2/14 Oliver Barnes : >> Hello, >> >> I've just installed cucumber 0.1.99, and it looks like the Portuguese >> step keywords aren't recognized for some reason. I'm following this >> example up on github: >> >> http://github.com/aslakhellesoy/cucumber/blob/ae9bf75d586cda232310721f62ecab91fc2336c0/examples/i18n/pt/features/adicao.feature >> >> When I switch to the original English keywords, it runs fine. I've >> also tried using "Caracter?stica", instead of "Funcionalidade" for the >> translation of "Feature", but that didn't work either. >> >> Is this a bug, or have the Portuguese keywords changed? >> >> thanks >> Oliver >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Tue Feb 17 18:39:50 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 17 Feb 2009 17:39:50 -0600 Subject: [rspec-users] cucumber hooks BeforeAll and AfterAll In-Reply-To: References: <8277b7f40902151121s154bbcccp511a619c103795aa@mail.gmail.com> <85d99afe0902151141q1db5d60hf019d9ac625f911c@mail.gmail.com> <4998713A.2010008@benmabey.com> Message-ID: <57c63afe0902171539m423fb426jd30c1f23f201ea33@mail.gmail.com> On Tue, Feb 17, 2009 at 3:32 PM, Ashley Moran wrote: > > On 15 Feb 2009, at 19:47, Ben Mabey wrote: > >> To illustrate what Zach is saying here is an example I used on the wiki[1] >> before: >> >> # Global setup >> ActionMailer::Base.delivery_method = :test >> ActionMailer::Base.perform_deliveries = true >> >> Before do >> # Scenario setup >> ActionMailer::Base.deliveries.clear >> end >> >> After do >> # Scenario teardown >> Database.truncate_all >> end >> >> at_exit do >> # Global teardown >> TempFileManager.clean_up >> end >> >> HTH, >> Ben > > I still think it would be nice if you could write > > BeforeAll do > ActionMailer::Base.delivery_method = :test > ActionMailer::Base.perform_deliveries = true > end > > AfterAll do > # Global teardown > TempFileManager.clean_up > end > > *Yes* it's equivalent (largely), but it does make the intent more clear. > And expressing intent is a big part of Cucumber (and RSpec) IMHO. The main problem w/ this for me is that before(:all) in RSpec means something different here (before(:all) the examples in one group). There is also a rarely used before(:suite), which is more akin to what you're proposing here. So *if* we add Before[... some scope ...], I'd prefer it be aligned (or at least not conflict) w/ RSpec's meaning (so ppl don't have to remember which to use where). May I propose: Before(:suite) or Before(:all_features) ?? > > Ashley > > -- > http://www.patchspace.co.uk/ > http://aviewfromafar.net/ > http://twitter.com/ashleymoran > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From hayafirst at gmail.com Tue Feb 17 19:04:41 2009 From: hayafirst at gmail.com (Yi Wen) Date: Tue, 17 Feb 2009 18:04:41 -0600 Subject: [rspec-users] validate_presence_of Message-ID: Hello, according to this post: http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released I should be able to write: describe User do it {should valdate_presence_of(:login)} end with rspec 1.1.12 But I got: NO NAME undefined method `valdate_presence_of' for # What did I do it wrong? Thanks for helping. Yi -------------- next part -------------- An HTML attachment was scrubbed... URL: From hayafirst at gmail.com Tue Feb 17 19:25:00 2009 From: hayafirst at gmail.com (Yi Wen) Date: Tue, 17 Feb 2009 18:25:00 -0600 Subject: [rspec-users] validate_presence_of In-Reply-To: References: Message-ID: Sorry for the spam, I relized there was a typo. It should be it {should validate_presence_of(:login)} It still didn't work On Tue, Feb 17, 2009 at 6:04 PM, Yi Wen wrote: > Hello, > > according to this post: > http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released > > I should be able to write: > > describe User do > it {should valdate_presence_of(:login)} > end > > with rspec 1.1.12 > > But I got: > > NO NAME > undefined method `valdate_presence_of' for > # > > What did I do it wrong? Thanks for helping. > > Yi > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tim at pivotib.com Tue Feb 17 19:42:07 2009 From: tim at pivotib.com (Tim Glen) Date: Tue, 17 Feb 2009 19:42:07 -0500 Subject: [rspec-users] validate_presence_of In-Reply-To: References: Message-ID: <62681A22-04F0-4834-998D-CCFF4B3DEBA2@pivotib.com> > according to this post: http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released > > I should be able to write: > > describe User do > it {should valdate_presence_of(:login)} > end > > with rspec 1.1.12 > > But I got: > > NO NAME > undefined method `valdate_presence_of' for > # Hi Yi, I believe you're looking for validate_presence_of - you missed an "i" in validate From dchelimsky at gmail.com Tue Feb 17 19:56:46 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 17 Feb 2009 18:56:46 -0600 Subject: [rspec-users] validate_presence_of In-Reply-To: References: Message-ID: <57c63afe0902171656i54b6c152xba04693b5128d199@mail.gmail.com> On Tue, Feb 17, 2009 at 6:25 PM, Yi Wen wrote: > Sorry for the spam, I relized there was a typo. It should be > it {should validate_presence_of(:login)} > It still didn't work Scrolling up a bit ... "There are a few matcher libraries out there like rspec-on-rails-matchers that provide matchers like this validate_presence_of(:email)" validate_presence_of() is not part of rspec-rails. You can find libraries that offer comparable matchers at: http://github.com/thoughtbot/shoulda/tree/master http://github.com/joshknowles/rspec-on-rails-matchers/tree/master http://github.com/technoweenie/rspec_on_rails_on_crack/tree/master http://github.com/carlosbrando/remarkable/tree/master HTH, David > > On Tue, Feb 17, 2009 at 6:04 PM, Yi Wen wrote: >> >> Hello, >> >> according to this post: >> http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released >> >> I should be able to write: >> >> describe User do >> it {should valdate_presence_of(:login)} >> end >> >> with rspec 1.1.12 >> >> But I got: >> >> NO NAME >> undefined method `valdate_presence_of' for >> # >> >> What did I do it wrong? Thanks for helping. >> >> Yi > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From hayafirst at gmail.com Tue Feb 17 21:42:52 2009 From: hayafirst at gmail.com (Yi Wen) Date: Tue, 17 Feb 2009 20:42:52 -0600 Subject: [rspec-users] validate_presence_of In-Reply-To: <57c63afe0902171656i54b6c152xba04693b5128d199@mail.gmail.com> References: <57c63afe0902171656i54b6c152xba04693b5128d199@mail.gmail.com> Message-ID: ah! sorry, my bad. Thanks! On Tue, Feb 17, 2009 at 6:56 PM, David Chelimsky wrote: > On Tue, Feb 17, 2009 at 6:25 PM, Yi Wen wrote: > > Sorry for the spam, I relized there was a typo. It should be > > it {should validate_presence_of(:login)} > > It still didn't work > > Scrolling up a bit ... > > "There are a few matcher libraries out there like > rspec-on-rails-matchers that provide matchers like this > validate_presence_of(:email)" > > validate_presence_of() is not part of rspec-rails. You can find > libraries that offer comparable matchers at: > > http://github.com/thoughtbot/shoulda/tree/master > http://github.com/joshknowles/rspec-on-rails-matchers/tree/master > http://github.com/technoweenie/rspec_on_rails_on_crack/tree/master > http://github.com/carlosbrando/remarkable/tree/master > > HTH, > David > > > > > > On Tue, Feb 17, 2009 at 6:04 PM, Yi Wen wrote: > >> > >> Hello, > >> > >> according to this post: > >> http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released > >> > >> I should be able to write: > >> > >> describe User do > >> it {should valdate_presence_of(:login)} > >> end > >> > >> with rspec 1.1.12 > >> > >> But I got: > >> > >> NO NAME > >> undefined method `valdate_presence_of' for > >> # > >> > >> What did I do it wrong? Thanks for helping. > >> > >> Yi > > > > > > _______________________________________________ > > 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 Tue Feb 17 22:06:05 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 17 Feb 2009 21:06:05 -0600 Subject: [rspec-users] validate_presence_of In-Reply-To: References: <57c63afe0902171656i54b6c152xba04693b5128d199@mail.gmail.com> Message-ID: <57c63afe0902171906l5ad6f0a4l2917d103c5b01870@mail.gmail.com> On Tue, Feb 17, 2009 at 8:42 PM, Yi Wen wrote: > ah! sorry, my bad. Thanks! No worries - I always just read the code first too :) > > On Tue, Feb 17, 2009 at 6:56 PM, David Chelimsky > wrote: >> >> On Tue, Feb 17, 2009 at 6:25 PM, Yi Wen wrote: >> > Sorry for the spam, I relized there was a typo. It should be >> > it {should validate_presence_of(:login)} >> > It still didn't work >> >> Scrolling up a bit ... >> >> "There are a few matcher libraries out there like >> rspec-on-rails-matchers that provide matchers like this >> validate_presence_of(:email)" >> >> validate_presence_of() is not part of rspec-rails. You can find >> libraries that offer comparable matchers at: >> >> http://github.com/thoughtbot/shoulda/tree/master >> http://github.com/joshknowles/rspec-on-rails-matchers/tree/master >> http://github.com/technoweenie/rspec_on_rails_on_crack/tree/master >> http://github.com/carlosbrando/remarkable/tree/master >> >> HTH, >> David >> >> >> > >> > On Tue, Feb 17, 2009 at 6:04 PM, Yi Wen wrote: >> >> >> >> Hello, >> >> >> >> according to this post: >> >> http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released >> >> >> >> I should be able to write: >> >> >> >> describe User do >> >> it {should valdate_presence_of(:login)} >> >> end >> >> >> >> with rspec 1.1.12 >> >> >> >> But I got: >> >> >> >> NO NAME >> >> undefined method `valdate_presence_of' for >> >> # >> >> >> >> What did I do it wrong? Thanks for helping. >> >> >> >> Yi >> > >> > >> > _______________________________________________ >> > 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 Wed Feb 18 01:48:32 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 18 Feb 2009 07:48:32 +0100 Subject: [rspec-users] cucumber hooks BeforeAll and AfterAll In-Reply-To: References: <8277b7f40902151121s154bbcccp511a619c103795aa@mail.gmail.com> <85d99afe0902151141q1db5d60hf019d9ac625f911c@mail.gmail.com> <4998713A.2010008@benmabey.com> Message-ID: <8d961d900902172248x9fa2594qa8a3e6931ddf9978@mail.gmail.com> On Tue, Feb 17, 2009 at 10:32 PM, Ashley Moran wrote: > > On 15 Feb 2009, at 19:47, Ben Mabey wrote: > >> To illustrate what Zach is saying here is an example I used on the wiki[1] >> before: >> >> # Global setup >> ActionMailer::Base.delivery_method = :test >> ActionMailer::Base.perform_deliveries = true >> >> Before do >> # Scenario setup >> ActionMailer::Base.deliveries.clear >> end >> >> After do >> # Scenario teardown >> Database.truncate_all >> end >> >> at_exit do >> # Global teardown >> TempFileManager.clean_up >> end >> >> HTH, >> Ben > > I still think it would be nice if you could write > > BeforeAll do > ActionMailer::Base.delivery_method = :test > ActionMailer::Base.perform_deliveries = true > end > > AfterAll do > # Global teardown > TempFileManager.clean_up > end > > *Yes* it's equivalent (largely), but it does make the intent more clear. > And expressing intent is a big part of Cucumber (and RSpec) IMHO. > You can express intent with a comment in this case. I don't want to invent constructs that do nothing. Gold plating. Aslak > Ashley > > -- > http://www.patchspace.co.uk/ > http://aviewfromafar.net/ > http://twitter.com/ashleymoran > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From matt at mattwynne.net Wed Feb 18 03:45:50 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 18 Feb 2009 08:45:50 +0000 Subject: [rspec-users] [Cucumber] Level of features / Feature dependent steps In-Reply-To: <45453541-CD64-44FC-9585-0F857B81A43B@aps.org> References: <45453541-CD64-44FC-9585-0F857B81A43B@aps.org> Message-ID: On 17 Feb 2009, at 20:27, Lenny Marks wrote: > Forgive the long post, just looking for input/advice/alternate > opinions.. > > Like many I think that going through the exercise of framing user > requests in Cucumber terms(Features, Scenarios..) really helps > facilitate necessary conversations and avoid time wasted > implementing the wrong thing(e.g. as a requirement/specification > tool). However, I'm a bit confused when it comes to tying this in > with Cucumber. I've come across many suggestions about audience > being king as far as language used in features, but when writing > features as part of a specification for a new feature, I > consistently find myself writing at a higher level than most any > examples I've come across(See example below). > > In the past we've typically relied on very informal means of > specifying new features(Wiki pages, paper, and verbal > communication). No that's not our problem..;-) TPI, Even with > extensive object level specs, the full details of what an > application does and how it is expected to behave from the outside > tends to get lost in the app over time. For example, we have a few > applications that were developed by a consulting company. Even > concentrating only on the UI and the flow of the application, there > are many features that are kind of hidden within the app(ex. assign > to drop down that should keep most recently used names first). > Without being extremely familiar with the app, all you really > know(as a developer or tester) is that it renders successfully, > which is an obvious maintenance problem. Even with newer apps, after > a feature is implemented it tends to get lost inside the application. > > I was thinking that Cucumber could really work here as a full life > cycle tool because the same artifacts that were initially used to > specify a feature, could be kept and re-used as documentation for > users and testers. Unlike alternatives such as keeping a Wiki page > up to date, having features linked to implemented steps serves as > integration tests and also ensures that the feature as written, is > still accurate/up to date. (Even link Cucumber output to Wiki page) > > Anyway, reading through Cucumber docs and examples, I almost always > see much more specific examples. > > e.g. (from RSpec book) > Feature: Pay bill on line > > Scenario: Pay a bill > Given a checking account with $50 > And a payee named Acme > And an Acme bill for $37 > When I pay the Acme bill > Then I should have $13 remaining in my checking account > And the payment of $37 to Acme should be listed in Recent > Payments > > That makes sense to me from a testing perspective, but it just > doesn't seem right to me from the perspective I speak of above. If I > were flushing out this feature with users, I'd have probably wound > up with something more like: > > Scenario: Pay a bill with sufficient funds > Given I have a bill to pay > And I have enough money in my checking account to cover it > When I pay the bill > Then my checking account should be debited by the amount payed > And the payment should be listed in Recent Payments > > One problem is that obviously this way involves always writing an > extra level of feature dependent steps. It just seems to me that the > specific version tends to distract from the actual story. I'm sure > I'm looking at this backwards, but does anyone else use Cucumber > similarly? > > Thanks, > -lenny My view is, prefer the latter (abstract) style, use the former (specific) style when you have to for clarity. Each can make sense in the right context, but the latter style is definitely much easier to read. In the end I find you usually need some specific examples to drive out a working system if the feature is at all interesting, but trying to stick to the abstract style as long as possible is a good habit to get into. There was a discussion some time ago about calling these two styles 'declarative' and 'imperative'. I'm afraid I'm still too dumb to remember which one is which, but someone else will surely chip in. 'Abstract' and 'Specific' are feeling better to me as I type this. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From jona.hunt777 at gmail.com Wed Feb 18 04:43:19 2009 From: jona.hunt777 at gmail.com (Hunt Jon) Date: Wed, 18 Feb 2009 18:43:19 +0900 Subject: [rspec-users] New Google Groups for Vim and Ruby/Rails Developers Message-ID: <5e1f1f1f0902180143y5ad530a4pc256f76973afcc68@mail.gmail.com> Announcement for new group for Vim users. http://groups.google.com/group/vim-on-rails?hl=en Sharing vim usage for Ruby on Rails development. Includes any platform (Windows, Linux and Mac). Discuss anything related to Ruby and Ruby on Rails development. (migration from TextMate, HAML/SASS, RSpec, Cucumber and etc...) http://groups.google.com/group/vim-on-rails?hl=en Regards, From joshuachisholm at gmail.com Wed Feb 18 08:12:13 2009 From: joshuachisholm at gmail.com (Josh Chisholm) Date: Wed, 18 Feb 2009 13:12:13 +0000 Subject: [rspec-users] [Cucumber] Level of features / Feature dependent steps In-Reply-To: References: <45453541-CD64-44FC-9585-0F857B81A43B@aps.org> Message-ID: <1126d7ae0902180512iac72f61la33abf27113f8244@mail.gmail.com> I find that the _first_ example of some functionality should be imperative (say specifically how to achieve something step by step) and subsequent mentions of the same functionality should be more declarative (say in abstract terms what to achieve, but spare the step by step details). For me, this is consistent with discussing features with customers: it starts out step by step, then in subsequent conversations (especially after implementation of the imperative steps) we can discuss the same thing in more abstract terms. An obvious example is login # login.feature Scenario: Successful login Given there is a user 'josh' And the user 'josh' has the password 'pass' When I visit the login page And I enter the username 'josh' And I enter the password 'pass' And click 'submit' Then I should see 'welcome josh' # some-other.feature Scenario: Something that requires login Given I have logged in successfully ... # login_steps.rb Given /I have logged in successfully/ do Given "there is a user 'josh'" Given "the user 'josh' has the password 'pass'" When "I enter the username 'josh'" ... end There is duplication between the first imperative feature and the login steps, but I think that's a slightly different issue from "Feature coupled steps". The "Given I have logged in successfully" step is not coupled to a particular feature, it is an aggregation of other steps. It is designed to be used in different features. Going back to your example, I would use the first style. Later, I would introduce the aggregate step "Given I have paid a bill with sufficient funds" as and when I needed to. Like Jonathan said, there is still the issue of shared state, but arguments can be passed through the aggregate steps to the imperative steps depending on how you feel about this. Josh On Wed, Feb 18, 2009 at 8:45 AM, Matt Wynne wrote: > > On 17 Feb 2009, at 20:27, Lenny Marks wrote: > >> Forgive the long post, just looking for input/advice/alternate opinions.. >> >> Like many I think that going through the exercise of framing user requests >> in Cucumber terms(Features, Scenarios..) really helps facilitate necessary >> conversations and avoid time wasted implementing the wrong thing(e.g. as a >> requirement/specification tool). However, I'm a bit confused when it comes >> to tying this in with Cucumber. I've come across many suggestions about >> audience being king as far as language used in features, but when writing >> features as part of a specification for a new feature, I consistently find >> myself writing at a higher level than most any examples I've come across(See >> example below). >> >> In the past we've typically relied on very informal means of specifying >> new features(Wiki pages, paper, and verbal communication). No that's not our >> problem..;-) TPI, Even with extensive object level specs, the full details >> of what an application does and how it is expected to behave from the >> outside tends to get lost in the app over time. For example, we have a few >> applications that were developed by a consulting company. Even concentrating >> only on the UI and the flow of the application, there are many features that >> are kind of hidden within the app(ex. assign to drop down that should keep >> most recently used names first). Without being extremely familiar with the >> app, all you really know(as a developer or tester) is that it renders >> successfully, which is an obvious maintenance problem. Even with newer apps, >> after a feature is implemented it tends to get lost inside the application. >> >> I was thinking that Cucumber could really work here as a full life cycle >> tool because the same artifacts that were initially used to specify a >> feature, could be kept and re-used as documentation for users and testers. >> Unlike alternatives such as keeping a Wiki page up to date, having features >> linked to implemented steps serves as integration tests and also ensures >> that the feature as written, is still accurate/up to date. (Even link >> Cucumber output to Wiki page) >> >> Anyway, reading through Cucumber docs and examples, I almost always see >> much more specific examples. >> >> e.g. (from RSpec book) >> Feature: Pay bill on line >> >> Scenario: Pay a bill >> Given a checking account with $50 >> And a payee named Acme >> And an Acme bill for $37 >> When I pay the Acme bill >> Then I should have $13 remaining in my checking account >> And the payment of $37 to Acme should be listed in Recent Payments >> >> That makes sense to me from a testing perspective, but it just doesn't >> seem right to me from the perspective I speak of above. If I were flushing >> out this feature with users, I'd have probably wound up with something more >> like: >> >> Scenario: Pay a bill with sufficient funds >> Given I have a bill to pay >> And I have enough money in my checking account to cover it >> When I pay the bill >> Then my checking account should be debited by the amount payed >> And the payment should be listed in Recent Payments >> >> One problem is that obviously this way involves always writing an extra >> level of feature dependent steps. It just seems to me that the specific >> version tends to distract from the actual story. I'm sure I'm looking at >> this backwards, but does anyone else use Cucumber similarly? >> >> Thanks, >> -lenny > > My view is, prefer the latter (abstract) style, use the former (specific) > style when you have to for clarity. Each can make sense in the right > context, but the latter style is definitely much easier to read. > > In the end I find you usually need some specific examples to drive out a > working system if the feature is at all interesting, but trying to stick to > the abstract style as long as possible is a good habit to get into. > > There was a discussion some time ago about calling these two styles > 'declarative' and 'imperative'. I'm afraid I'm still too dumb to remember > which one is which, but someone else will surely chip in. 'Abstract' and > 'Specific' are feeling better to me as I type this. > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From nick at deadorange.com Wed Feb 18 10:36:22 2009 From: nick at deadorange.com (Nick Hoffman) Date: Wed, 18 Feb 2009 10:36:22 -0500 Subject: [rspec-users] [RSpec] #and_raise In-Reply-To: <57c63afe0902161312mc30c2a9qcea2ab78592eae86@mail.gmail.com> References: <57c63afe0902161312mc30c2a9qcea2ab78592eae86@mail.gmail.com> Message-ID: <4E75153C-8A5C-42DB-AC5F-287265475B12@deadorange.com> On 16/02/2009, at 4:12 PM, David Chelimsky wrote: > On Mon, Feb 16, 2009 at 1:48 PM, Nick Hoffman > wrote: >> I often use #and_raise like so: >> >> @error_message = 'Some error' >> @sf.should_receive(:shift_time!).and_raise @error_message >> >> However, after trying to do this: >> >> @argument_error = mock_model ArgumentError, >> :message => @error_message >> @sf.should_receive(:shift_time!).and_raise @argument_error >> >> and then reading the docs for #and_raise, I realised that >> #and_raise only >> accepts a String or exception class. >> >> Is there a way to set the exception class and error message? > > Actually, it accepts an exception class, exception object, or, > apparently (though not documented as such) just a string. Instead of a > mock, try a real ArgumentError: > > @sf > .should_receive > (:shift_time).and_raise(ArgumentError.new(@error_message)) > > HTH, > David That's great. Thanks, David! From f.mischa at gmail.com Wed Feb 18 11:07:56 2009 From: f.mischa at gmail.com (Mischa Fierer) Date: Wed, 18 Feb 2009 10:07:56 -0600 Subject: [rspec-users] [Cucumber] Level of features / Feature dependent steps In-Reply-To: <1126d7ae0902180512iac72f61la33abf27113f8244@mail.gmail.com> References: <45453541-CD64-44FC-9585-0F857B81A43B@aps.org> <1126d7ae0902180512iac72f61la33abf27113f8244@mail.gmail.com> Message-ID: Ben has a good post on the declarative vs imperative styles here: http://www.benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories/ I totally agree with Josh, and indeed wrote out my own version of his login example before realizing I should probably read his post before replying! I agree that each scenario should go into a good amount of detail about what specifically being tested, rather than letting it be hidden in a step. If other things have to happen in a scenario that do not involve what is being specifically tested but must be included for setup, then if it's DRYer it makes sense to make a more abstract step. This also gives you a speed boost if done correctly, for example a "given I am logged in as foo" step can just post to /session or w/e , rather than going to /login, filling in the form and pressing the button and waiting. I'm not sure if I would go as far into the dsl as you are in the second example, though, Lenny. Depending on whether or not you were able to reuse those steps, as you say, you would over the course of a few months end up with an entire level of scenario dependent steps. I might instead start by just using webrat / generic steps as long as you can, and then taking a look at all your feature files and deciding what you can dry up / what makes sense to move into a more client specific dsl. Finally, having been doing cucumber for a while now, I've found that i've been moving more towards the imperative style, simply because it's faster to work with. For example, if it were in the early stages of the app, I might even do something like Scenario: I Pay a bill when I have enough $ Given a checking account And the checking account has "$50" And a payee named "Acme" And an "Acme" bill for "$37" When I follow "bills to pay" And I follow "Acme" And I press "pay bill" And I press "confirm" Then I should see "payment success" When I follow "account summary" Then I should see "$13 remaining" And I should see "you paid $37 to Acme" This is pretty ugly, but not out of the question imo. While it has its downsides, one benefit is that it encourages a client to actually think about how the site should work before you make it. For example, they actually get to think about things like whether there is a payment success page or not, rather than deciding that there shouldn't be one after you've spent lots of time building it. wdyt? On Wed, Feb 18, 2009 at 7:12 AM, Josh Chisholm wrote: > I find that the _first_ example of some functionality should be > imperative (say specifically how to achieve something step by step) > and subsequent mentions of the same functionality should be more > declarative (say in abstract terms what to achieve, but spare the step > by step details). For me, this is consistent with discussing features > with customers: it starts out step by step, then in subsequent > conversations (especially after implementation of the imperative > steps) we can discuss the same thing in more abstract terms. > > An obvious example is login > > # login.feature > Scenario: Successful login > Given there is a user 'josh' > And the user 'josh' has the password 'pass' > When I visit the login page > And I enter the username 'josh' > And I enter the password 'pass' > And click 'submit' > Then I should see 'welcome josh' > > # some-other.feature > Scenario: Something that requires login > Given I have logged in successfully > ... > > # login_steps.rb > Given /I have logged in successfully/ do > Given "there is a user 'josh'" > Given "the user 'josh' has the password 'pass'" > When "I enter the username 'josh'" > ... > end > > There is duplication between the first imperative feature and the > login steps, but I think that's a slightly different issue from > "Feature coupled steps". The "Given I have logged in successfully" > step is not coupled to a particular feature, it is an aggregation of > other steps. It is designed to be used in different features. > > Going back to your example, I would use the first style. Later, I > would introduce the aggregate step "Given I have paid a bill with > sufficient funds" as and when I needed to. Like Jonathan said, there > is still the issue of shared state, but arguments can be passed > through the aggregate steps to the imperative steps depending on how > you feel about this. > > Josh > > > > > On Wed, Feb 18, 2009 at 8:45 AM, Matt Wynne wrote: > > > > On 17 Feb 2009, at 20:27, Lenny Marks wrote: > > > >> Forgive the long post, just looking for input/advice/alternate > opinions.. > >> > >> Like many I think that going through the exercise of framing user > requests > >> in Cucumber terms(Features, Scenarios..) really helps facilitate > necessary > >> conversations and avoid time wasted implementing the wrong thing(e.g. as > a > >> requirement/specification tool). However, I'm a bit confused when it > comes > >> to tying this in with Cucumber. I've come across many suggestions about > >> audience being king as far as language used in features, but when > writing > >> features as part of a specification for a new feature, I consistently > find > >> myself writing at a higher level than most any examples I've come > across(See > >> example below). > >> > >> In the past we've typically relied on very informal means of specifying > >> new features(Wiki pages, paper, and verbal communication). No that's not > our > >> problem..;-) TPI, Even with extensive object level specs, the full > details > >> of what an application does and how it is expected to behave from the > >> outside tends to get lost in the app over time. For example, we have a > few > >> applications that were developed by a consulting company. Even > concentrating > >> only on the UI and the flow of the application, there are many features > that > >> are kind of hidden within the app(ex. assign to drop down that should > keep > >> most recently used names first). Without being extremely familiar with > the > >> app, all you really know(as a developer or tester) is that it renders > >> successfully, which is an obvious maintenance problem. Even with newer > apps, > >> after a feature is implemented it tends to get lost inside the > application. > >> > >> I was thinking that Cucumber could really work here as a full life cycle > >> tool because the same artifacts that were initially used to specify a > >> feature, could be kept and re-used as documentation for users and > testers. > >> Unlike alternatives such as keeping a Wiki page up to date, having > features > >> linked to implemented steps serves as integration tests and also ensures > >> that the feature as written, is still accurate/up to date. (Even link > >> Cucumber output to Wiki page) > >> > >> Anyway, reading through Cucumber docs and examples, I almost always see > >> much more specific examples. > >> > >> e.g. (from RSpec book) > >> Feature: Pay bill on line > >> > >> Scenario: Pay a bill > >> Given a checking account with $50 > >> And a payee named Acme > >> And an Acme bill for $37 > >> When I pay the Acme bill > >> Then I should have $13 remaining in my checking account > >> And the payment of $37 to Acme should be listed in Recent Payments > >> > >> That makes sense to me from a testing perspective, but it just doesn't > >> seem right to me from the perspective I speak of above. If I were > flushing > >> out this feature with users, I'd have probably wound up with something > more > >> like: > >> > >> Scenario: Pay a bill with sufficient funds > >> Given I have a bill to pay > >> And I have enough money in my checking account to cover it > >> When I pay the bill > >> Then my checking account should be debited by the amount payed > >> And the payment should be listed in Recent Payments > >> > >> One problem is that obviously this way involves always writing an extra > >> level of feature dependent steps. It just seems to me that the specific > >> version tends to distract from the actual story. I'm sure I'm looking at > >> this backwards, but does anyone else use Cucumber similarly? > >> > >> Thanks, > >> -lenny > > > > My view is, prefer the latter (abstract) style, use the former (specific) > > style when you have to for clarity. Each can make sense in the right > > context, but the latter style is definitely much easier to read. > > > > In the end I find you usually need some specific examples to drive out a > > working system if the feature is at all interesting, but trying to stick > to > > the abstract style as long as possible is a good habit to get into. > > > > There was a discussion some time ago about calling these two styles > > 'declarative' and 'imperative'. I'm afraid I'm still too dumb to remember > > which one is which, but someone else will surely chip in. 'Abstract' and > > 'Specific' are feeling better to me as I type this. > > > > Matt Wynne > > http://blog.mattwynne.net > > http://www.songkick.com > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > 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 oli.azevedo.barnes at gmail.com Wed Feb 18 11:44:26 2009 From: oli.azevedo.barnes at gmail.com (Oliver Barnes) Date: Wed, 18 Feb 2009 13:44:26 -0300 Subject: [rspec-users] [Cucumber] Portuguese keywords not recognized In-Reply-To: <57c63afe0902171533x47618ea9w30962c6f6dfad7e8@mail.gmail.com> References: <6466d9040902141247l1405c348g809bc0b03afe1b47@mail.gmail.com> <6466d9040902171514n6c4f72e5vfdcfe4ecfc8d04de@mail.gmail.com> <57c63afe0902171533x47618ea9w30962c6f6dfad7e8@mail.gmail.com> Message-ID: <6466d9040902180844q644836e2had348527aab7fcd3@mail.gmail.com> Valeu David! muito bom poder falar com o mestre em portugu?s :) Mas eu tentei com estes, tanto com passos em ingl?s como em portugu?s: http://pastie.org/392962 com os passos em ingl?s, o cucumber simplesmente responde "0 features". com os passos em portugu?s (que eu n?o tenho certeza se t?m suporte, estou testando just in case), ele n?o reconhece: ./features/step_definitions/busca_de_tese_steps.rb:1: undefined method `Dado' for # (NoMethodError) 2009/2/17 David Chelimsky : > Oi Oliver, > > Poderia ver o codigo aqui: > http://github.com/aslakhellesoy/cucumber/blob/e1afbf1908fdb3867d857478847403abeedd91d7/lib/cucumber/languages.yml > > HTH, > David > >> >> 2009/2/14 Oliver Barnes : >>> Hello, >>> >>> I've just installed cucumber 0.1.99, and it looks like the Portuguese >>> step keywords aren't recognized for some reason. I'm following this >>> example up on github: >>> >>> http://github.com/aslakhellesoy/cucumber/blob/ae9bf75d586cda232310721f62ecab91fc2336c0/examples/i18n/pt/features/adicao.feature >>> >>> When I switch to the original English keywords, it runs fine. I've >>> also tried using "Caracter?stica", instead of "Funcionalidade" for the >>> translation of "Feature", but that didn't work either. >>> >>> Is this a bug, or have the Portuguese keywords changed? >>> >>> thanks >>> Oliver >>> >> _______________________________________________ >> 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 oli.azevedo.barnes at gmail.com Wed Feb 18 11:46:48 2009 From: oli.azevedo.barnes at gmail.com (Oliver Barnes) Date: Wed, 18 Feb 2009 13:46:48 -0300 Subject: [rspec-users] [Cucumber] Portuguese keywords not recognized In-Reply-To: <6466d9040902180844q644836e2had348527aab7fcd3@mail.gmail.com> References: <6466d9040902141247l1405c348g809bc0b03afe1b47@mail.gmail.com> <6466d9040902171514n6c4f72e5vfdcfe4ecfc8d04de@mail.gmail.com> <57c63afe0902171533x47618ea9w30962c6f6dfad7e8@mail.gmail.com> <6466d9040902180844q644836e2had348527aab7fcd3@mail.gmail.com> Message-ID: <6466d9040902180846p36932f28h34ecddfab3fbd807@mail.gmail.com> (it responds "0 Scenarios", not "0 Features", btw) 2009/2/18 Oliver Barnes : > Valeu David! muito bom poder falar com o mestre em portugu?s :) > > Mas eu tentei com estes, tanto com passos em ingl?s como em portugu?s: > > http://pastie.org/392962 > > com os passos em ingl?s, o cucumber simplesmente responde "0 > features". com os passos em portugu?s (que eu n?o tenho certeza se t?m > suporte, estou testando just in case), ele n?o reconhece: > > ./features/step_definitions/busca_de_tese_steps.rb:1: undefined method > `Dado' for # (NoMethodError) > > > 2009/2/17 David Chelimsky : > >> Oi Oliver, >> >> Poderia ver o codigo aqui: >> http://github.com/aslakhellesoy/cucumber/blob/e1afbf1908fdb3867d857478847403abeedd91d7/lib/cucumber/languages.yml >> >> HTH, >> David >> >>> >>> 2009/2/14 Oliver Barnes : >>>> Hello, >>>> >>>> I've just installed cucumber 0.1.99, and it looks like the Portuguese >>>> step keywords aren't recognized for some reason. I'm following this >>>> example up on github: >>>> >>>> http://github.com/aslakhellesoy/cucumber/blob/ae9bf75d586cda232310721f62ecab91fc2336c0/examples/i18n/pt/features/adicao.feature >>>> >>>> When I switch to the original English keywords, it runs fine. I've >>>> also tried using "Caracter?stica", instead of "Funcionalidade" for the >>>> translation of "Feature", but that didn't work either. >>>> >>>> Is this a bug, or have the Portuguese keywords changed? >>>> >>>> thanks >>>> Oliver >>>> >>> _______________________________________________ >>> 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 Feb 18 14:02:15 2009 From: lists at ruby-forum.com (Raimond Garcia) Date: Wed, 18 Feb 2009 20:02:15 +0100 Subject: [rspec-users] Cucumber + Webrat + Selenium + ActionMailer Message-ID: <3aa9e123e627fd97b4d75bd5c2ca0fc4@ruby-forum.com> Hi, We are upgrading to cucumber 0.1.99 in the process we also upgraded to the latest versions of webrat and rspec. However now we are having difficulties checking for ActionMailer.deliveries in the selenium features. I seem to recall being able to check for these without problems using webrat's wrapper for selenium, but maybe my memory is tricking me... Lately we were solving this by using Polomium, here is our config http://gist.github.com/39038 However, with the new configuration for webrat selenium features: Webrat.configure do |config| config.mode = :selenium end We can't seem to get Polonium working nicely with webrat. Is there something wrong with our configuration or how are you guys checking for ActionMailer deliveries in your selenium stories? Cheers, Rai -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Wed Feb 18 15:02:05 2009 From: ben at benmabey.com (Ben Mabey) Date: Wed, 18 Feb 2009 13:02:05 -0700 Subject: [rspec-users] Cucumber + Webrat + Selenium + ActionMailer In-Reply-To: <3aa9e123e627fd97b4d75bd5c2ca0fc4@ruby-forum.com> References: <3aa9e123e627fd97b4d75bd5c2ca0fc4@ruby-forum.com> Message-ID: <499C693D.9090006@benmabey.com> Raimond Garcia wrote: > Hi, > > We are upgrading to cucumber 0.1.99 in the process we also upgraded to > the latest versions of webrat and rspec. However now we are having > difficulties checking for ActionMailer.deliveries in the selenium > features. I seem to recall being able to check for these without > problems using webrat's wrapper for selenium, but maybe my memory is > tricking me... > > Lately we were solving this by using Polomium, here is our config > http://gist.github.com/39038 > > However, with the new configuration for webrat selenium features: > > Webrat.configure do |config| > config.mode = :selenium > end > > We can't seem to get Polonium working nicely with webrat. > > Is there something wrong with our configuration or how are you guys > checking for ActionMailer deliveries in your selenium stories? > > Cheers, > > Rai > One option is to use ARMailer[1] to queue your mail. As long as your selenium process and test process are using the same DB without transactions getting in the way then ARMailer should work fine for what you want to do. Thanks to the guys at weplay EmailSpec[2] works happily with ARMailer so you can use the same helpers that EmailSpec provides for the regular in-memory ActionMailer test deliveries. -Ben 1. http://seattlerb.rubyforge.org/ar_mailer/classes/ActionMailer/ARMailer.html 2. http://github.com/bmabey/email-spec/ From sfeley at gmail.com Wed Feb 18 18:15:16 2009 From: sfeley at gmail.com (Stephen Eley) Date: Wed, 18 Feb 2009 18:15:16 -0500 Subject: [rspec-users] Cucumber + Webrat + Selenium + ActionMailer In-Reply-To: <499C693D.9090006@benmabey.com> References: <3aa9e123e627fd97b4d75bd5c2ca0fc4@ruby-forum.com> <499C693D.9090006@benmabey.com> Message-ID: <1fb4df0902181515y6d95221bw87c4706f3987f0ce@mail.gmail.com> On Wed, Feb 18, 2009 at 3:02 PM, Ben Mabey wrote: > > One option is to use ARMailer[1] to queue your mail. As long as your > selenium process and test process are using the same DB without transactions > getting in the way then ARMailer should work fine for what you want to do. Is changing production infrastructure solely for the sake of making tests work a recommended practice? To me it feels a bit backwards. Raimond: I can't address the problems you're having with Polonium, as I'd never heard of it until this thread (and Googling it was surprisingly hard; I finally found http://github.com/pivotal/polonium). But it does seem to me like Webrat and its various dependencies all manage to break each other's APIs with every minor release, so this doesn't surprise me. I've had to roll back versions of Nokogiri several times for things like this. If you're at the level of integration testing, checking ActionMailer.deliveries may not be the way to go anyway. I'd look instead to see if the e-mails were actually sent. As I see it, even if ActionMailer thinks it's done its job, mail could still fail for other reasons and that's a failed system interaction. Here's an idea I've seen that's independent of delivery method; it's basically just overriding the ActionMailer recipients in test mode so that all e-mails go to one address: http://www.dweebd.com/ruby/capture-actionmailer-output-for-your-qa-team/ >From that point, your tests could use Ruby's standard mail libraries to retrieve the mail and scan it, or scrape 'mail' from the shell, or read the entrails of your enemies, or whatever else you like to confirm that the right stuff is in the message. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From ben at benmabey.com Wed Feb 18 18:27:17 2009 From: ben at benmabey.com (Ben Mabey) Date: Wed, 18 Feb 2009 16:27:17 -0700 Subject: [rspec-users] Cucumber + Webrat + Selenium + ActionMailer In-Reply-To: <1fb4df0902181515y6d95221bw87c4706f3987f0ce@mail.gmail.com> References: <3aa9e123e627fd97b4d75bd5c2ca0fc4@ruby-forum.com> <499C693D.9090006@benmabey.com> <1fb4df0902181515y6d95221bw87c4706f3987f0ce@mail.gmail.com> Message-ID: <499C9955.8080804@benmabey.com> Stephen Eley wrote: > On Wed, Feb 18, 2009 at 3:02 PM, Ben Mabey wrote: > >> One option is to use ARMailer[1] to queue your mail. As long as your >> selenium process and test process are using the same DB without transactions >> getting in the way then ARMailer should work fine for what you want to do. >> > > Is changing production infrastructure solely for the sake of making > tests work a recommended practice? To me it feels a bit backwards. > Well, in this case the ARMailer is an arguably better alternative than waiting on an SMTP connection for ActionMailer in production settings. ARMailer was not created to solve testing woes.. it was created it solve production woes. :) The fact that it helps in testing is just a side effect. -Ben From lists at ruby-forum.com Wed Feb 18 19:39:24 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Thu, 19 Feb 2009 01:39:24 +0100 Subject: [rspec-users] validate_presence_of In-Reply-To: References: Message-ID: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> Yi Wen wrote: > Hello, > > according to this post: > http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released > > I should be able to write: > > describe User do > it {should valdate_presence_of(:login)} > end What's the point in testing validates_presence_of for a model? It's already tested in the framework, and so readable that a quick glance on the model says it all. I would only test it if I added some bizarre behavior with procs and so on. What's the community's position about that? -- Posted via http://www.ruby-forum.com/. From pat.maddox at gmail.com Wed Feb 18 20:29:22 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Wed, 18 Feb 2009 17:29:22 -0800 Subject: [rspec-users] validate_presence_of In-Reply-To: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> Message-ID: <2c7e61990902181729u7ce8a097g580a3b603e996ea5@mail.gmail.com> On Wed, Feb 18, 2009 at 4:39 PM, Fernando Perez wrote: > Yi Wen wrote: >> Hello, >> >> according to this post: >> http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released >> >> I should be able to write: >> >> describe User do >> it {should valdate_presence_of(:login)} >> end > > What's the point in testing validates_presence_of for a model? It's > already tested in the framework, and so readable that a quick glance on > the model says it all. I would only test it if I added some bizarre > behavior with procs and so on. > > What's the community's position about that? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > I'm with you, but there's nothing even *close* to consensus on this. A lot of people liken it to double-entry bookkeeping. Pat From pat.maddox at gmail.com Wed Feb 18 20:43:30 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Wed, 18 Feb 2009 17:43:30 -0800 Subject: [rspec-users] Cucumber + Webrat + Selenium + ActionMailer In-Reply-To: <1fb4df0902181515y6d95221bw87c4706f3987f0ce@mail.gmail.com> References: <3aa9e123e627fd97b4d75bd5c2ca0fc4@ruby-forum.com> <499C693D.9090006@benmabey.com> <1fb4df0902181515y6d95221bw87c4706f3987f0ce@mail.gmail.com> Message-ID: <2c7e61990902181743w693ba1c8kb2c4912b9bd0cf07@mail.gmail.com> On Wed, Feb 18, 2009 at 3:15 PM, Stephen Eley wrote: > On Wed, Feb 18, 2009 at 3:02 PM, Ben Mabey wrote: >> >> One option is to use ARMailer[1] to queue your mail. As long as your >> selenium process and test process are using the same DB without transactions >> getting in the way then ARMailer should work fine for what you want to do. > > Is changing production infrastructure solely for the sake of making > tests work a recommended practice? To me it feels a bit backwards. I'm not commenting on this particular situation, but if I want to use some library, but I can't figure out how to write tests for my code that uses it, then I don't use it. Basically, if I have to change something to make it testable, I do. Pat From jim at saturnflyer.com Wed Feb 18 20:46:52 2009 From: jim at saturnflyer.com (Jim Gay) Date: Wed, 18 Feb 2009 20:46:52 -0500 Subject: [rspec-users] validate_presence_of In-Reply-To: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> Message-ID: On Feb 18, 2009, at 7:39 PM, Fernando Perez wrote: > Yi Wen wrote: >> Hello, >> >> according to this post: >> http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released >> >> I should be able to write: >> >> describe User do >> it {should valdate_presence_of(:login)} >> end > > What's the point in testing validates_presence_of for a model? It's > already tested in the framework, and so readable that a quick glance > on > the model says it all. I would only test it if I added some bizarre > behavior with procs and so on. > > What's the community's position about that? It shouldn't be a test, it's a spec. So it's done *before* you write the code. The specs describe the behavior of the application. From grail at goldweb.com.au Wed Feb 18 20:47:56 2009 From: grail at goldweb.com.au (Alex Satrapa) Date: Thu, 19 Feb 2009 12:47:56 +1100 Subject: [rspec-users] validate_presence_of In-Reply-To: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> Message-ID: <01C973AD-FF8D-468A-A494-F10285758C40@goldweb.com.au> On 19/02/2009, at 11:39 , Fernando Perez wrote: > What's the point in testing validates_presence_of for a model? It's > already tested in the framework, and so readable that a quick glance > on > the model says it all. Some people want the spec to stand as a contract, so you can then hand the spec over to the proverbial trained monkeys and have them write all the necessary code from scratch exactly the way you want it written. These are not people I enjoy working with, so I play loose with the specs and only spec stuff that matters to me at the time, code that little bit, and get on with the next terribly pressing task. Alex -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 220 bytes Desc: This is a digitally signed message part URL: From zach.dennis at gmail.com Wed Feb 18 20:53:31 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 18 Feb 2009 20:53:31 -0500 Subject: [rspec-users] validate_presence_of In-Reply-To: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> Message-ID: <85d99afe0902181753i6ae91805o24d8f9b4d2603721@mail.gmail.com> On Wed, Feb 18, 2009 at 7:39 PM, Fernando Perez wrote: > Yi Wen wrote: >> Hello, >> >> according to this post: >> http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released >> >> I should be able to write: >> >> describe User do >> it {should valdate_presence_of(:login)} >> end > > What's the point in testing validates_presence_of for a model? IMO... It definitely doesn't provide any design benefits since that decision has already been made for you, but it does provide a developer-level example to communicate the behaviour of a model, and it covers regression. I prefer both of these. The flip-side would be that if you and your customer wrote scenarios which communicated the same intent, as well as were executable then you'd also achieve these benefits. While this works, if often doesn't fit the bill for a scenario very well (I prefer less verbose, higher level declarative scenarios) and it misses out on providing developer documentation for how a particular object should behave. For me, a non-option is to have neither of these in place. > It's > already tested in the framework, and so readable that a quick glance on > the model says it all. I would only test it if I added some bizarre > behavior with procs and so on. What's tested in the framework is that validates_presence works. What isn't tested is that your Item model needs to ensure it always belongs to an :order. I'm more interested in the fact that Item always requires an order. I expected the Rails developers to do their due diligence to ensure validates_presence_of works in all of its intricacies. > > What's the community's position about that? What Pat said. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From zach.dennis at gmail.com Wed Feb 18 21:02:22 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 18 Feb 2009 21:02:22 -0500 Subject: [rspec-users] validate_presence_of In-Reply-To: <01C973AD-FF8D-468A-A494-F10285758C40@goldweb.com.au> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <01C973AD-FF8D-468A-A494-F10285758C40@goldweb.com.au> Message-ID: <85d99afe0902181802n5678eb6ah135a5d4e53a936f1@mail.gmail.com> On Wed, Feb 18, 2009 at 8:47 PM, Alex Satrapa wrote: > On 19/02/2009, at 11:39 , Fernando Perez wrote: > >> What's the point in testing validates_presence_of for a model? It's >> already tested in the framework, and so readable that a quick glance on >> the model says it all. > > Some people want the spec to stand as a contract, so you can then hand the > spec over to the proverbial trained monkeys and have them write all the > necessary code from scratch exactly the way you want it written. I have never seen or heard of anyone who writes a spec (developer level RSpec spec), but not the code and then hands it over to someone else and demands that that person implements it. If you do or have could you share, I'm interested in hearing about that experience. > > These are not people I enjoy working with, so I play loose with the specs > and only spec stuff that matters to me at the time, code that little bit, > and get on with the next terribly pressing task. > > Alex > > > _______________________________________________ > 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 zach.dennis at gmail.com Wed Feb 18 21:06:42 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 18 Feb 2009 21:06:42 -0500 Subject: [rspec-users] validate_presence_of In-Reply-To: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> Message-ID: <85d99afe0902181806g3daaa43atea43e5561f9c7824@mail.gmail.com> On Wed, Feb 18, 2009 at 7:39 PM, Fernando Perez wrote: > Yi Wen wrote: >> Hello, >> >> according to this post: >> http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released >> >> I should be able to write: >> >> describe User do >> it {should valdate_presence_of(:login)} >> end > > What's the point in testing validates_presence_of for a model? It's > already tested in the framework, and so readable that a quick glance on > the model says it all. I would only test it if I added some bizarre > behavior with procs and so on. > Question for folks who don't like writing any examples for this kind of thing (including scenarios/steps). If I go tuck away some behaviour behind a nice declarative interface, will you not care about having examples showing that your objects utilize that behaviour? Not testing things that have no logic makes sense. However, validation methods have logic, it's just wrapped up behind a nice interface. > What's the community's position about that? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From grail at goldweb.com.au Wed Feb 18 22:02:29 2009 From: grail at goldweb.com.au (Alex Satrapa) Date: Thu, 19 Feb 2009 14:02:29 +1100 Subject: [rspec-users] validate_presence_of In-Reply-To: <85d99afe0902181802n5678eb6ah135a5d4e53a936f1@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <01C973AD-FF8D-468A-A494-F10285758C40@goldweb.com.au> <85d99afe0902181802n5678eb6ah135a5d4e53a936f1@mail.gmail.com> Message-ID: On 19/02/2009, at 13:02 , Zach Dennis wrote: > I have never seen or heard of anyone who writes a spec (developer > level RSpec spec), but not the code and then hands it over to someone > else and demands that that person implements it. The fun begins when you can point out two or three conflicting requirements on the first page, such as "end date should not be null" right next to, "a version with no end date is current for all dates after the start date." Then I sat the guy down and introduced him to autotest, commited the specification to version control, removed all but the first three entries and showed how to build from small pieces. So truthfully speaking, I've not yet worked in an environment where RSpec was used to specify a design up front. And I certainly won't be introducing new managers to RSpec before introducing them to unit testing, then testing driven development, and then behaviour driven development. I prefer my feet intact and still attached to my legs! Alex -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 220 bytes Desc: This is a digitally signed message part URL: From dchelimsky at gmail.com Wed Feb 18 22:05:02 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 18 Feb 2009 21:05:02 -0600 Subject: [rspec-users] validate_presence_of In-Reply-To: References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <01C973AD-FF8D-468A-A494-F10285758C40@goldweb.com.au> <85d99afe0902181802n5678eb6ah135a5d4e53a936f1@mail.gmail.com> Message-ID: <57c63afe0902181905h63e317a5q53e54517dbe22f9b@mail.gmail.com> On Wed, Feb 18, 2009 at 9:02 PM, Alex Satrapa wrote: > On 19/02/2009, at 13:02 , Zach Dennis wrote: > >> I have never seen or heard of anyone who writes a spec (developer >> level RSpec spec), but not the code and then hands it over to someone >> else and demands that that person implements it. > > The fun begins when you can point out two or three conflicting requirements > on the first page, such as "end date should not be null" right next to, "a > version with no end date is current for all dates after the start date." > > Then I sat the guy down and introduced him to autotest, commited the > specification to version control, removed all but the first three entries > and showed how to build from small pieces. > > So truthfully speaking, I've not yet worked in an environment where RSpec > was used to specify a design up front. And I certainly won't be introducing > new managers to RSpec before introducing them to unit testing, then testing > driven development, and then behaviour driven development. I prefer my feet > intact and still attached to my legs! Why not start w/ RSpec but do it right? > > Alex > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Wed Feb 18 22:24:05 2009 From: lists at ruby-forum.com (Mike Frawley) Date: Thu, 19 Feb 2009 04:24:05 +0100 Subject: [rspec-users] Which webrat gem should be used? In-Reply-To: <8d961d900901151602oc162e94i9c7b0dfe6ffa08e4@mail.gmail.com> References: <8d961d900901151602oc162e94i9c7b0dfe6ffa08e4@mail.gmail.com> Message-ID: I'm having trouble getting cucumber working. I have webrat 0.4.1 installed, but still get the error: /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- spec/rails (MissingSourceFile) Aslak Helles?y wrote: > If you're on Rails and use RSpec matchers, the latest official webrat > 0.3.4 > gem is broken. It doesn't contain the webrat/rspec-rails.rb file (a > packaging bug). > > aslakhellesoy-webrat (0.3.2.2) works fine. I tried replacing line 10 in support/env from `require 'webrat'` to: require 'aslakhellesoy-webrat' and: gem 'aslakhellesoy-webrat', '0.3.2.2' But neither worked. (If using `gem` is the wrong way to load a particular gem in a rails project please point me out the correct way to me :) I also just tried uninstalling the 'webrat' gem, leaving only 'aslakhellesoy-webrat', and changed line 10 back to `require 'webrat'`, but still have get the error. Thanks, Mike ??? -- Posted via http://www.ruby-forum.com/. From mark at mwilden.com Wed Feb 18 22:37:09 2009 From: mark at mwilden.com (Mark Wilden) Date: Wed, 18 Feb 2009 19:37:09 -0800 Subject: [rspec-users] Cucumber + Webrat + Selenium + ActionMailer In-Reply-To: <2c7e61990902181743w693ba1c8kb2c4912b9bd0cf07@mail.gmail.com> References: <3aa9e123e627fd97b4d75bd5c2ca0fc4@ruby-forum.com> <499C693D.9090006@benmabey.com> <1fb4df0902181515y6d95221bw87c4706f3987f0ce@mail.gmail.com> <2c7e61990902181743w693ba1c8kb2c4912b9bd0cf07@mail.gmail.com> Message-ID: <3c30da400902181937g28f4751fy20d85b49c1df1be1@mail.gmail.com> On Wed, Feb 18, 2009 at 5:43 PM, Pat Maddox wrote: > > Basically, if I have to change something to make it testable, I do. Yeah. Testability is a positive attribute. If you'd change code to make it more readable or more speedy, why not more testable? ///ark From pat.maddox at gmail.com Wed Feb 18 22:41:32 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Wed, 18 Feb 2009 19:41:32 -0800 Subject: [rspec-users] validate_presence_of In-Reply-To: <85d99afe0902181806g3daaa43atea43e5561f9c7824@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <85d99afe0902181806g3daaa43atea43e5561f9c7824@mail.gmail.com> Message-ID: <2c7e61990902181941k3cbd286dpce9849e3f561f16@mail.gmail.com> On Wed, Feb 18, 2009 at 6:06 PM, Zach Dennis wrote: > On Wed, Feb 18, 2009 at 7:39 PM, Fernando Perez wrote: >> Yi Wen wrote: >>> Hello, >>> >>> according to this post: >>> http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released >>> >>> I should be able to write: >>> >>> describe User do >>> it {should valdate_presence_of(:login)} >>> end >> >> What's the point in testing validates_presence_of for a model? It's >> already tested in the framework, and so readable that a quick glance on >> the model says it all. I would only test it if I added some bizarre >> behavior with procs and so on. >> > > Question for folks who don't like writing any examples for this kind > of thing (including scenarios/steps). If I go tuck away some behaviour > behind a nice declarative interface, will you not care about having > examples showing that your objects utilize that behaviour? That's a huge "depends" but yeah, basically. I don't really test code that can't possibly break. Declarative code like Rails validations or associations can't possibly break*, it can only be removed. Don't remove it unless you need to then, right? I came to this conclusion re: validations/assocations by observing the evolution of how people write specs for them. You start off doing something like: describe User do it "should require a name" do User.new(:name => '').should have_at_least(1).error_on(:name) end end and after you write a bunch of those you look for a way to DRY up your specs a bit so you write some kind of custom matcher. Make it nice and concise and you end up with shoulda macros: describe User do should_require_attributes :name end You could literally write a couple lines of adapter code that would take this specification and generate the production class! def describe(klass, &block) (class << klass; self; end).class_eval do alias_method :should_require_attributes, :validates_presence_of end klass.class_eval &block end What does it give you? I'm looking at the shoulda examples and chuckling at how ridiculous the AR ones are (controller ones are nice, they use macros for stuff that you can't program declaratively). class PostTest < Test::Unit::TestCase should_belong_to :user should_have_many :tags, :through => :taggings should_require_unique_attributes :title should_require_attributes :body, :message => /wtf/ should_require_attributes :title should_only_allow_numeric_values_for :user_id end and in AR (not 100% sure this makes it pass, I'm just writing, you get the idea) class Post < ActiveRecord::Base belongs_to :user has_many :tags, :through => :taggings validates_uniqueness_of :title validates_presence_of :body, :title validates_format_of :message, :with => /wtf/ validates_numericality_of :user_id end There are two types of specification that I've found useful: declaration and example. Rails association and validation macros are specification by declaration. RSpec gives us specification by example. Effectively this means that a class's specification is split between its implementation (declarative parts) and RSpec examples. If your code is specified declaratively, you don't need to write examples. > Not testing things that have no logic makes sense. However, validation > methods have logic, it's just wrapped up behind a nice interface. Sure but can that logic break? Pat * Associations can break via changes to the db, but that will get caught by other specs or acceptance tests that make use of the associations From grail at goldweb.com.au Wed Feb 18 22:41:32 2009 From: grail at goldweb.com.au (Alex Satrapa) Date: Thu, 19 Feb 2009 14:41:32 +1100 Subject: [rspec-users] validate_presence_of In-Reply-To: <57c63afe0902181905h63e317a5q53e54517dbe22f9b@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <01C973AD-FF8D-468A-A494-F10285758C40@goldweb.com.au> <85d99afe0902181802n5678eb6ah135a5d4e53a936f1@mail.gmail.com> <57c63afe0902181905h63e317a5q53e54517dbe22f9b@mail.gmail.com> Message-ID: <24A55437-B042-449C-B5AE-8CED992CAD6D@goldweb.com.au> On 19/02/2009, at 14:05 , David Chelimsky wrote: > Why not start w/ RSpec but do it right? I made the mistake of showing the guy a spec from a previous project and narrating (not showing) how the code was built from the spec. So the manager didn't realise that the spec was built one line at a time. My fault entirely, the guy is now "doing it right" :) Alex -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 220 bytes Desc: This is a digitally signed message part URL: From mark at mwilden.com Wed Feb 18 22:42:10 2009 From: mark at mwilden.com (Mark Wilden) Date: Wed, 18 Feb 2009 19:42:10 -0800 Subject: [rspec-users] validate_presence_of In-Reply-To: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> Message-ID: <3c30da400902181942u195c2628uc1271630f4c929b3@mail.gmail.com> On Wed, Feb 18, 2009 at 4:39 PM, Fernando Perez wrote: >> >> I should be able to write: >> >> describe User do >> it {should valdate_presence_of(:login)} >> end > > What's the point in testing validates_presence_of for a model? To make sure you wrote that line of code. ///ark From dchelimsky at gmail.com Wed Feb 18 22:43:38 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 18 Feb 2009 21:43:38 -0600 Subject: [rspec-users] validate_presence_of In-Reply-To: <3c30da400902181942u195c2628uc1271630f4c929b3@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <3c30da400902181942u195c2628uc1271630f4c929b3@mail.gmail.com> Message-ID: <57c63afe0902181943i3267e6bbjc72b78efacae07da@mail.gmail.com> On Wed, Feb 18, 2009 at 9:42 PM, Mark Wilden wrote: > On Wed, Feb 18, 2009 at 4:39 PM, Fernando Perez wrote: >>> >>> I should be able to write: >>> >>> describe User do >>> it {should valdate_presence_of(:login)} >>> end >> >> What's the point in testing validates_presence_of for a model? > > To make sure you wrote that line of code. Close. To make sure you "will" write that line of code. > > ///ark > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pat.maddox at gmail.com Wed Feb 18 22:45:36 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Wed, 18 Feb 2009 19:45:36 -0800 Subject: [rspec-users] validate_presence_of In-Reply-To: <3c30da400902181942u195c2628uc1271630f4c929b3@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <3c30da400902181942u195c2628uc1271630f4c929b3@mail.gmail.com> Message-ID: <2c7e61990902181945r227e649cya6b7ece6298e34e6@mail.gmail.com> On Wed, Feb 18, 2009 at 7:42 PM, Mark Wilden wrote: > On Wed, Feb 18, 2009 at 4:39 PM, Fernando Perez wrote: >>> >>> I should be able to write: >>> >>> describe User do >>> it {should valdate_presence_of(:login)} >>> end >> >> What's the point in testing validates_presence_of for a model? > > To make sure you wrote that line of code. and how do you make sure you wrote this one? it {should valdate_presence_of(:login)} :) From dchelimsky at gmail.com Wed Feb 18 22:48:37 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 18 Feb 2009 21:48:37 -0600 Subject: [rspec-users] validate_presence_of In-Reply-To: <2c7e61990902181945r227e649cya6b7ece6298e34e6@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <3c30da400902181942u195c2628uc1271630f4c929b3@mail.gmail.com> <2c7e61990902181945r227e649cya6b7ece6298e34e6@mail.gmail.com> Message-ID: <57c63afe0902181948k7668841h220939f874b2f84@mail.gmail.com> On Wed, Feb 18, 2009 at 9:45 PM, Pat Maddox wrote: > On Wed, Feb 18, 2009 at 7:42 PM, Mark Wilden wrote: >> On Wed, Feb 18, 2009 at 4:39 PM, Fernando Perez wrote: >>>> >>>> I should be able to write: >>>> >>>> describe User do >>>> it {should valdate_presence_of(:login)} >>>> end >>> >>> What's the point in testing validates_presence_of for a model? >> >> To make sure you wrote that line of code. > > and how do you make sure you wrote this one? > it {should valdate_presence_of(:login)} By removing the line from the model, running the specs, and looking for a failiure :) > > :) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From sfeley at gmail.com Wed Feb 18 23:21:53 2009 From: sfeley at gmail.com (Stephen Eley) Date: Wed, 18 Feb 2009 23:21:53 -0500 Subject: [rspec-users] Cucumber + Webrat + Selenium + ActionMailer In-Reply-To: <499C9955.8080804@benmabey.com> References: <3aa9e123e627fd97b4d75bd5c2ca0fc4@ruby-forum.com> <499C693D.9090006@benmabey.com> <1fb4df0902181515y6d95221bw87c4706f3987f0ce@mail.gmail.com> <499C9955.8080804@benmabey.com> Message-ID: <1fb4df0902182021m497b243ap95b76303d7842a04@mail.gmail.com> On Wed, Feb 18, 2009 at 6:27 PM, Ben Mabey wrote: > > Well, in this case the ARMailer is an arguably better alternative than > waiting on an SMTP connection for ActionMailer in production settings. > ARMailer was not created to solve testing woes.. it was created it solve > production woes. :) The fact that it helps in testing is just a side > effect. Oh, sure. I wasn't trying to be critical against ARMailer itself; I do think that e-mail is the sort of side process that ought to be brought out of the request critical path one way or another. But that's unrelated here. It just seems like the sort of process change that might be overkill for 'I upgraded my gems and then my testing toolchain broke.' Testability may be a factor in initial tool selection, but in this case the tool *was* testable until the tests were broken by an unrelated change. Once a production process is in place, I think changes to it should be driven by business requirements. I just had a sympathetic twitch for the original poster. I could be on some other forum, asking about agility training for my dog or something, and somebody will say "See, if you had a cat, you wouldn't have that problem." Yeah, maybe, but the fact that my dog is a dog wasn't really the problem. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From sfeley at gmail.com Wed Feb 18 23:37:21 2009 From: sfeley at gmail.com (Stephen Eley) Date: Wed, 18 Feb 2009 23:37:21 -0500 Subject: [rspec-users] Cucumber + Webrat + Selenium + ActionMailer In-Reply-To: <2c7e61990902181743w693ba1c8kb2c4912b9bd0cf07@mail.gmail.com> References: <3aa9e123e627fd97b4d75bd5c2ca0fc4@ruby-forum.com> <499C693D.9090006@benmabey.com> <1fb4df0902181515y6d95221bw87c4706f3987f0ce@mail.gmail.com> <2c7e61990902181743w693ba1c8kb2c4912b9bd0cf07@mail.gmail.com> Message-ID: <1fb4df0902182037w75fa506haeac3fc3d0400c9c@mail.gmail.com> On Wed, Feb 18, 2009 at 8:43 PM, Pat Maddox wrote: > > I'm not commenting on this particular situation, but if I want to use > some library, but I can't figure out how to write tests for my code > that uses it, then I don't use it. I take the opposite view. My *goal* in coding isn't to write good tests, it's to solve somebody's problem. My own or someone else's. The right tool to help solve the problem is the right tool. Testing plays a supporting role, not a decision-making role. Anyway, there are very few cases where I can't figure out *some* straightforward way to test a behavior. The last time it happened, ironically enough, was when I found a bug in Merb's Autotest hooks for Rspec. There was a loop termination issue such that Rspec worked fine until you tried to run Cucumber right after it with the merb-cucumber gem. Writing specs to prove that your specs terminate was... Well, after a couple hours I gave up and just submitted a patch with "I know this is the wrong way to do things, but here. My head hurts." -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From hayafirst at gmail.com Wed Feb 18 23:42:50 2009 From: hayafirst at gmail.com (Yi Wen) Date: Wed, 18 Feb 2009 22:42:50 -0600 Subject: [rspec-users] validate_presence_of In-Reply-To: <01C973AD-FF8D-468A-A494-F10285758C40@goldweb.com.au> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <01C973AD-FF8D-468A-A494-F10285758C40@goldweb.com.au> Message-ID: We should write a test/spec, whatever you call it, *first* before you want your code. But it doesn't mean one who writes the spec/test will use a monkey coding the code to fix the test. To be realistic, a programmer will write this test, and implement it right away. Just like how TDD should be done. Without this syntax sugar, we still have to test validates_presence_of to make sure it's there and won't broken, right? So this simple syntax is nice because it's lees code to type in. I really don't see how trained monkeys come into play in this scenario. :) I am not a huge fan of "spec contract" for unit testing. Unit testing is a tool for developers to write better, DRY-er and more loosely-coupled code. At most it is a communication tool among developers. It's never meant to be for non-technical / clients / business people. Cucumber might serve that purpose. Yi On Wed, Feb 18, 2009 at 7:47 PM, Alex Satrapa wrote: > On 19/02/2009, at 11:39 , Fernando Perez wrote: > > What's the point in testing validates_presence_of for a model? It's >> already tested in the framework, and so readable that a quick glance on >> the model says it all. >> > > Some people want the spec to stand as a contract, so you can then hand the > spec over to the proverbial trained monkeys and have them write all the > necessary code from scratch exactly the way you want it written. > > These are not people I enjoy working with, so I play loose with the specs > and only spec stuff that matters to me at the time, code that little bit, > and get on with the next terribly pressing task. > > Alex > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Thu Feb 19 00:13:43 2009 From: ben at benmabey.com (Ben Mabey) Date: Wed, 18 Feb 2009 22:13:43 -0700 Subject: [rspec-users] Cucumber + Webrat + Selenium + ActionMailer In-Reply-To: <1fb4df0902182021m497b243ap95b76303d7842a04@mail.gmail.com> References: <3aa9e123e627fd97b4d75bd5c2ca0fc4@ruby-forum.com> <499C693D.9090006@benmabey.com> <1fb4df0902181515y6d95221bw87c4706f3987f0ce@mail.gmail.com> <499C9955.8080804@benmabey.com> <1fb4df0902182021m497b243ap95b76303d7842a04@mail.gmail.com> Message-ID: <499CEA87.5000804@benmabey.com> Stephen Eley wrote: > On Wed, Feb 18, 2009 at 6:27 PM, Ben Mabey wrote: > >> Well, in this case the ARMailer is an arguably better alternative than >> waiting on an SMTP connection for ActionMailer in production settings. >> ARMailer was not created to solve testing woes.. it was created it solve >> production woes. :) The fact that it helps in testing is just a side >> effect. >> > > Oh, sure. I wasn't trying to be critical against ARMailer itself; I > do think that e-mail is the sort of side process that ought to be > brought out of the request critical path one way or another. But > that's unrelated here. It just seems like the sort of process change > that might be overkill for 'I upgraded my gems and then my testing > toolchain broke.' Testability may be a factor in initial tool > selection, but in this case the tool *was* testable until the tests > were broken by an unrelated change. Once a production process is in > place, I think changes to it should be driven by business > requirements. > Yeah, and so I probably wouldn't change to ARMailer in production if that was an issue or wasn't really needed. So I agree with you there. However, I wouldn't have a problem in using ARMailer in my tests but still use straight ActionMailer in production. ActionMailer works and I don't need to test that. What I'm interested in testing is if I am sending the correct emails at the correct time. If I really need to test this part of the app in conjunction with selenium or another secondary process then setting up ARMailer just for that purpose seems like a reasonable investment. Once you have that tested the only point of failure in production would be your ActionMailer settings. I'll point out that you will face the same risk when using ActionMailer in :test mode anyways. So coming up with a method to test your settings would be needed in either case. My method for doing this is clicking through the site once to fire off an email and never changing the working production settings again. :) An alternative to using ARMailer would be to use something like Mailtrap[1] that acts as a dummy SMTP server to capture the emails from the app. You would then need to provide a way for the tests to access these emails to verify them. Both ways involve some extra work. If it isn't worth the investment then the only other option is to test the emails apart from the selenium tests. It just depends on how important it is that you test everything at the same time. -Ben 1. http://github.com/mmower/mailtrap/tree/master From mr.gaffo at gmail.com Thu Feb 19 00:17:50 2009 From: mr.gaffo at gmail.com (Mike Gaffney) Date: Wed, 18 Feb 2009 23:17:50 -0600 Subject: [rspec-users] validate_presence_of In-Reply-To: <2c7e61990902181941k3cbd286dpce9849e3f561f16@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <85d99afe0902181806g3daaa43atea43e5561f9c7824@mail.gmail.com> <2c7e61990902181941k3cbd286dpce9849e3f561f16@mail.gmail.com> Message-ID: <499CEB7E.40305@gmail.com> Pat, not nitpicking just using your eample, which was close, but you missed one of the reasons we like shoulda type tests:: should_require_attributes :body, :message => /wtf/ makes you put validates_presence_of :body, :message => "hey dude, wtf, you need a body!" because we have a bunch of custom error messages. Another reason for this is that while you may trust the rails guys to keep validates_presence of working, they may change HOW it works and forget a deprecation warning. Ruby isn't a compiled language so sometimes test like this do help. We had an eye opener on this a month ago when we went to edge rails. Finally, the shoulda tests are nice for things like column lengths and maximums when you are using multiple database backends because you often just plain forget about things like default column size differences between oracle and mysql, for intance pretend you're an oracle head: Migration.up: t.column :name, :string Model: validates_length_of :name, :maximum => 4000, :message => "We gave you 4000 characters, what more could you type?" Shoulda should_ensure_length_in_range :name, (0..4000), :long_message => "We gave you 4000 characters, what more could you type?" Will pass in oracle and fail in mysql because the default size is 255 in Mysql and 4000 in oracle. We had a ton of these creep up on us over the last few years because we just plain forgot, but the shoulda macro exercises it and all of the assumptions so it doesn't happen any more. Pat Maddox wrote: > On Wed, Feb 18, 2009 at 6:06 PM, Zach Dennis wrote: > >> On Wed, Feb 18, 2009 at 7:39 PM, Fernando Perez wrote: >> >>> Yi Wen wrote: >>> >>>> Hello, >>>> >>>> according to this post: >>>> http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released >>>> >>>> I should be able to write: >>>> >>>> describe User do >>>> it {should valdate_presence_of(:login)} >>>> end >>>> >>> What's the point in testing validates_presence_of for a model? It's >>> already tested in the framework, and so readable that a quick glance on >>> the model says it all. I would only test it if I added some bizarre >>> behavior with procs and so on. >>> >>> >> Question for folks who don't like writing any examples for this kind >> of thing (including scenarios/steps). If I go tuck away some behaviour >> behind a nice declarative interface, will you not care about having >> examples showing that your objects utilize that behaviour? >> > > That's a huge "depends" but yeah, basically. I don't really test code > that can't possibly break. Declarative code like Rails validations or > associations can't possibly break*, it can only be removed. Don't > remove it unless you need to then, right? > > I came to this conclusion re: validations/assocations by observing the > evolution of how people write specs for them. You start off doing > something like: > > describe User do > it "should require a name" do > User.new(:name => '').should have_at_least(1).error_on(:name) > end > end > > and after you write a bunch of those you look for a way to DRY up your > specs a bit so you write some kind of custom matcher. Make it nice > and concise and you end up with shoulda macros: > > describe User do > should_require_attributes :name > end > > You could literally write a couple lines of adapter code that would > take this specification and generate the production class! > > def describe(klass, &block) > (class << klass; self; end).class_eval do > alias_method :should_require_attributes, :validates_presence_of > end > klass.class_eval &block > end > > What does it give you? > > I'm looking at the shoulda examples and chuckling at how ridiculous > the AR ones are (controller ones are nice, they use macros for stuff > that you can't program declaratively). > > class PostTest < Test::Unit::TestCase > should_belong_to :user > should_have_many :tags, :through => :taggings > > should_require_unique_attributes :title > should_require_attributes :body, :message => /wtf/ > should_require_attributes :title > should_only_allow_numeric_values_for :user_id > end > > and in AR (not 100% sure this makes it pass, I'm just writing, you get the idea) > > class Post < ActiveRecord::Base > belongs_to :user > has_many :tags, :through => :taggings > > validates_uniqueness_of :title > validates_presence_of :body, :title > validates_format_of :message, :with => /wtf/ > validates_numericality_of :user_id > end > > There are two types of specification that I've found useful: > declaration and example. Rails association and validation macros are > specification by declaration. RSpec gives us specification by > example. Effectively this means that a class's specification is split > between its implementation (declarative parts) and RSpec examples. > > If your code is specified declaratively, you don't need to write examples. > > >> Not testing things that have no logic makes sense. However, validation >> methods have logic, it's just wrapped up behind a nice interface. >> > > Sure but can that logic break? > > Pat > > * Associations can break via changes to the db, but that will get > caught by other specs or acceptance tests that make use of the > associations > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From sfeley at gmail.com Thu Feb 19 00:31:13 2009 From: sfeley at gmail.com (Stephen Eley) Date: Thu, 19 Feb 2009 00:31:13 -0500 Subject: [rspec-users] validate_presence_of In-Reply-To: <3c30da400902181942u195c2628uc1271630f4c929b3@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <3c30da400902181942u195c2628uc1271630f4c929b3@mail.gmail.com> Message-ID: <1fb4df0902182131r1ec87c23hf503548ac877d595@mail.gmail.com> On Wed, Feb 18, 2009 at 10:42 PM, Mark Wilden wrote: > On Wed, Feb 18, 2009 at 4:39 PM, Fernando Perez wrote: >> >> What's the point in testing validates_presence_of for a model? > > To make sure you wrote that line of code. And the circle spins round and round... Specs that mirror the code that closely are a bad idea, I think. The problem with that example is that the syntax of the code is driving the syntax of the spec, even if the spec was written first. You're no longer thinking about high-level behavior, you're thinking about the presence of a certain line in Rails. I write those sorts of model specs a little differently. I just poke at things and set expectations on whether they break. I'd write this example like: describe User do before(:each) do @this = User.make_unsaved # I use machinist for my factory methods end it "is valid" do @this.should be_valid end it "can save" do @this.save.should be_true end it "requires a login" do @this.login = nil @this.should_not be_valid end it "may have a password reminder" do @this.password_reminder = nil @this.should be_valid end it "does not allow duplicate logins" do @that = User.make(:login => "EvilTwin") @this.login = "EvilTwin" @this.should_not be_valid end end ...And so forth. It's wordier, but very readable, and it doesn't rely on the validation being done with a specific Rails method. In fact, when I shifted to using Merb and Datamapper, I didn't have to change these sorts of tests at all. Also, while I used to be very anal and write "should have(1).error_on(:login)" and such, I eventually realized that there's no point. Checking on 'valid?' is entire and sufficient. The first example proves that the default factory case is valid, so as long as we're only changing one thing at a time, we know that that's the thing that breaks validity. (Or, in the case of "may have," *doesn't* break validity.) -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From sfeley at gmail.com Thu Feb 19 00:40:20 2009 From: sfeley at gmail.com (Stephen Eley) Date: Thu, 19 Feb 2009 00:40:20 -0500 Subject: [rspec-users] validate_presence_of In-Reply-To: References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <01C973AD-FF8D-468A-A494-F10285758C40@goldweb.com.au> Message-ID: <1fb4df0902182140n452afb9fh82855768acb7aa7@mail.gmail.com> On Wed, Feb 18, 2009 at 11:42 PM, Yi Wen wrote: > > Without this syntax sugar, we still have to test validates_presence_of to > make sure it's there and won't broken, right? Wrong. You don't have to test validates_presence_of. What matters, and therefore what you should test, is whether the model will complain at you if a particular value is left empty. validates_presence_of happens to be the name of the method in ActiveRecord that does that. But if you decide to write your own check_to_see_if_this_thingy_is_in_my_whatsis() method that does the same thing, a good *behavior* spec will not break. Because the behavior remains the same. If your spec breaks because you changed a method call, you're not testing behavior any more. You're testing syntax. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From sfeley at gmail.com Thu Feb 19 00:44:49 2009 From: sfeley at gmail.com (Stephen Eley) Date: Thu, 19 Feb 2009 00:44:49 -0500 Subject: [rspec-users] Cucumber + Webrat + Selenium + ActionMailer In-Reply-To: <499CEA87.5000804@benmabey.com> References: <3aa9e123e627fd97b4d75bd5c2ca0fc4@ruby-forum.com> <499C693D.9090006@benmabey.com> <1fb4df0902181515y6d95221bw87c4706f3987f0ce@mail.gmail.com> <499C9955.8080804@benmabey.com> <1fb4df0902182021m497b243ap95b76303d7842a04@mail.gmail.com> <499CEA87.5000804@benmabey.com> Message-ID: <1fb4df0902182144i4d3f655eh3cf7befa27a905a5@mail.gmail.com> On Thu, Feb 19, 2009 at 12:13 AM, Ben Mabey wrote: > > Both ways involve some extra work. If it isn't worth the investment then > the only other option is to test the emails apart from the selenium tests. > It just depends on how important it is that you test everything at the same > time. Good point. I have to confess, when I first read the message about using the Selenium framework to test e-mail delivery, my first thought was: "Er... Selenium? Are you automating the browser to check your Gmail or something...?" -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From dchelimsky at gmail.com Thu Feb 19 00:58:19 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 18 Feb 2009 23:58:19 -0600 Subject: [rspec-users] validate_presence_of In-Reply-To: <1fb4df0902182131r1ec87c23hf503548ac877d595@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <3c30da400902181942u195c2628uc1271630f4c929b3@mail.gmail.com> <1fb4df0902182131r1ec87c23hf503548ac877d595@mail.gmail.com> Message-ID: <57c63afe0902182158w4a6cd740n9608b28819fdaabc@mail.gmail.com> On Wed, Feb 18, 2009 at 11:31 PM, Stephen Eley wrote: > On Wed, Feb 18, 2009 at 10:42 PM, Mark Wilden wrote: >> On Wed, Feb 18, 2009 at 4:39 PM, Fernando Perez wrote: >>> >>> What's the point in testing validates_presence_of for a model? >> >> To make sure you wrote that line of code. > > And the circle spins round and round... > > Specs that mirror the code that closely are a bad idea, I think. The > problem with that example is that the syntax of the code is driving > the syntax of the spec, even if the spec was written first. You're no > longer thinking about high-level behavior, you're thinking about the > presence of a certain line in Rails. > > I write those sorts of model specs a little differently. I just poke > at things and set expectations on whether they break. I'd write this > example like: > > describe User do > before(:each) do > @this = User.make_unsaved # I use machinist for my factory methods > end > > it "is valid" do > @this.should be_valid > end > > it "can save" do > @this.save.should be_true > end > > it "requires a login" do > @this.login = nil > @this.should_not be_valid > end > > it "may have a password reminder" do > @this.password_reminder = nil > @this.should be_valid > end > > it "does not allow duplicate logins" do > @that = User.make(:login => "EvilTwin") > @this.login = "EvilTwin" > @this.should_not be_valid > end > end > > ...And so forth. It's wordier, but very readable, and it doesn't rely > on the validation being done with a specific Rails method. In fact, > when I shifted to using Merb and Datamapper, I didn't have to change > these sorts of tests at all. That's huge! > Also, while I used to be very anal and write "should > have(1).error_on(:login)" and such, I eventually realized that there's > no point. Checking on 'valid?' is entire and sufficient. The first > example proves that the default factory case is valid, so as long as > we're only changing one thing at a time, we know that that's the thing > that breaks validity. (Or, in the case of "may have," *doesn't* break > validity.) I think this depends on whether or not error messages are part of the conversation w/ the customer. If not, that seems fine. I find that I'll spec validations directly, but not associations. There's no need to say that a team has_many players when you have examples like team.should have(9).players_on_the_field. But my validation specs do tend to be closely tied to AR methods like valid?(), which, as your example suggests, is impeding my ability to choose a different ORM lib. Time for some re-thinking! Cheers, David > > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Feb 19 01:56:05 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 19 Feb 2009 00:56:05 -0600 Subject: [rspec-users] [ANN] rspec-1.2 release candidate Message-ID: <57c63afe0902182256h37f6449exc29e03cf1275d804@mail.gmail.com> Hey fellow behaviour-drivers, rspec-1.2 and rspec-rails-1.2 are just about ready, but I'd like to get some feedback from the field before the release. Would the adventurous among you kindly grab the latest github gems (1.1.99.7 as of this email) and check 'em out? I'm hoping to release rspec-1.2 shortly after rails-2.3.1 is released. [sudo] gem install dchelimsky-rspec [sudo] gem install dchelimsky-rspec-rails Notable changes include: == rspec * lots and lots of refactoring - internals are getting cleaner and leaner * substantially works with ruby-1.9.1, though there are still some issues * cleaner integration with the new heckle 1.4.2 release * require 'spec/test/unit' to run your T::U tests w/ rspec and start refactoring them to code examples * require 'spec/autorun' to run examples with the ruby command == rspec-rails * supports rails 2.0.5, 2.1.2, 2.2.2, 2.3.0, edge (as of release time) * config.gem actually works now * example groups are all subclasses of rails test classes (instead of just Test::Unit::TestCase or ActionController::TestCase) * spec_server fixes! - it pretty much works now for all supported versions of rails * bypass_rescue in controller specs for granular specification of action errors You can see more complete release notes at: http://github.com/dchelimsky/rspec/blob/master/History.txt http://github.com/dchelimsky/rspec-rails/blob/master/History.txt And upgrade notes for rspec-rails at: http://github.com/dchelimsky/rspec-rails/blob/master/Upgrade.markdown Cheers, David From ben at benmabey.com Thu Feb 19 02:46:02 2009 From: ben at benmabey.com (Ben Mabey) Date: Thu, 19 Feb 2009 00:46:02 -0700 Subject: [rspec-users] [Cucumber] Hi-res logo? Message-ID: <499D0E3A.1000105@benmabey.com> I'm hoping that the designer (or the co-worker programmer) who won the Cucumber logo contest will see this message... I'm looking for a hi-res or vector-based version of the Cucumber logo for use in a presentation. If the image is not vector based then a hi-res version with a transparent background would be preferred. The one on cukes.info and in the repo are okay but aren't quite big enough and become too pixelated when I make it larger. Can anyone help me out? Thanks, Ben From matt at mattwynne.net Thu Feb 19 03:29:11 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 19 Feb 2009 08:29:11 +0000 Subject: [rspec-users] validate_presence_of In-Reply-To: <1fb4df0902182140n452afb9fh82855768acb7aa7@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <01C973AD-FF8D-468A-A494-F10285758C40@goldweb.com.au> <1fb4df0902182140n452afb9fh82855768acb7aa7@mail.gmail.com> Message-ID: <13F88062-E7FE-4973-ACB3-4330D56A8F98@mattwynne.net> On 19 Feb 2009, at 05:40, Stephen Eley wrote: > On Wed, Feb 18, 2009 at 11:42 PM, Yi Wen wrote: >> >> Without this syntax sugar, we still have to test >> validates_presence_of to >> make sure it's there and won't broken, right? > > Wrong. You don't have to test validates_presence_of. What matters, > and therefore what you should test, is whether the model will complain > at you if a particular value is left empty. > > validates_presence_of happens to be the name of the method in > ActiveRecord that does that. But if you decide to write your own > check_to_see_if_this_thingy_is_in_my_whatsis() method that does the > same thing, a good *behavior* spec will not break. Because the > behavior remains the same. I agree with you is why I've avoided using things like this: http://github.com/redinger/validation_reflection/tree/master As I understand it, this just checks that you wrote the correct line of code in the the AR model class. As Pat said, there is so little value in doing this it seems pointless to me. I've not looked at the shoulda macros. Would they still pass if I decided to replace my call to a rails validation helper with check_to_see_if_this_thingy_is_in_my_whatsis()? Or are they just reflecting on the model's calls to the rails framework? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From aslak.hellesoy at gmail.com Thu Feb 19 03:32:05 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 19 Feb 2009 09:32:05 +0100 Subject: [rspec-users] [Cucumber] Hi-res logo? In-Reply-To: <499D0E3A.1000105@benmabey.com> References: <499D0E3A.1000105@benmabey.com> Message-ID: <8d961d900902190032o1d90543ei6db0a150402301b9@mail.gmail.com> On Thu, Feb 19, 2009 at 8:46 AM, Ben Mabey wrote: > I'm hoping that the designer (or the co-worker programmer) who won the > Cucumber logo contest will see this message... > > I'm looking for a hi-res or vector-based version of the Cucumber logo for > use in a presentation. If the image is not vector based then a hi-res > version with a transparent background would be preferred. The one on > cukes.info and in the repo are okay but aren't quite big enough and become > too pixelated when I make it larger. > > Can anyone help me out? > It's all here: http://github.com/aslakhellesoy/cucumber_site Aslak > Thanks, > Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From win at wincent.com Thu Feb 19 04:57:12 2009 From: win at wincent.com (Wincent Colaiuta) Date: Thu, 19 Feb 2009 10:57:12 +0100 Subject: [rspec-users] [ANN] rspec-1.2 release candidate In-Reply-To: References: Message-ID: <31D30E37-CF11-4541-B3E4-20C5068AEFB4@wincent.com> El 19/2/2009, a las 7:56, David Chelimsky escribi?: > rspec-1.2 and rspec-rails-1.2 are just about ready, but I'd like to > get some feedback from the field before the release. Would the > adventurous among you kindly grab the latest github gems (1.1.99.7 as > of this email) and check 'em out? I'm hoping to release rspec-1.2 > shortly after rails-2.3.1 is released. > > [sudo] gem install dchelimsky-rspec > [sudo] gem install dchelimsky-rspec-rails Or, if you don't have gems.github.com in your RubyGems "source" list: [sudo] gem install --source http://gems.github.com dchelimsky-rspec [sudo] gem install --source http://gems.github.com dchelimsky-rspec- rails Wincent From lists at ruby-forum.com Thu Feb 19 05:25:27 2009 From: lists at ruby-forum.com (Raimond Garcia) Date: Thu, 19 Feb 2009 11:25:27 +0100 Subject: [rspec-users] Cucumber + Webrat + Selenium + ActionMailer In-Reply-To: <1fb4df0902182144i4d3f655eh3cf7befa27a905a5@mail.gmail.com> References: <3aa9e123e627fd97b4d75bd5c2ca0fc4@ruby-forum.com> <499C693D.9090006@benmabey.com> <1fb4df0902181515y6d95221bw87c4706f3987f0ce@mail.gmail.com> <499C9955.8080804@benmabey.com> <1fb4df0902182021m497b243ap95b76303d7842a04@mail.gmail.com> <499CEA87.5000804@benmabey.com> <1fb4df0902182144i4d3f655eh3cf7befa27a905a5@mail.gmail.com> Message-ID: <9fa97fb652c4210d767e16757a4610e5@ruby-forum.com> Thanks guys, very interesting points. As a good collegue of mine says, its all about trade offs :) I agree with changing your production code to make it more testable, definitely, especially early on in the development process, once your site is up and running it would have to be done with extra care, we don't wanna be sending hundreds of emails accidentally, and I must confess I can unfortunately relate, even though it was a team effort to achieve it :) Thus I'm happy you mentioned Duncan Beevers blog post, Steve, cheers. I'll definitely recommend it as a precaution tool to the team. For my particular situation ARMailer sounds just like what we need to get the build passing again, and will certainly shot out a couple of emails from the staging server to make sure emails are actually being send. >"Er... Selenium? Are you automating the browser to check your >Gmail or something...?" Well this might sound like a crazy idea... but I admit that I've discussed this before with my team, and concluded that, without including speed limit constraints, it was the most thorough way of testing our signup and confirmation system :) Thanks again for all your help! Cheers, Rai P.S. I'll follow up with a confirmation post just to let the people know how it worked out for us with ARMailer. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Feb 19 05:31:44 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Thu, 19 Feb 2009 11:31:44 +0100 Subject: [rspec-users] validate_presence_of In-Reply-To: <1fb4df0902182140n452afb9fh82855768acb7aa7@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <01C973AD-FF8D-468A-A494-F10285758C40@goldweb.com.au> <1fb4df0902182140n452afb9fh82855768acb7aa7@mail.gmail.com> Message-ID: <5f1773b761ae0615dcd9054346a8529c@ruby-forum.com> > Wrong. You don't have to test validates_presence_of. What matters, > and therefore what you should test, is whether the model will complain > at you if a particular value is left empty. > ... > If your spec breaks because you changed a method call, you're not > testing behavior any more. You're testing syntax. I totally agree with your point of view. > Also, while I used to be very anal and write "should > have(1).error_on(:login)" and such, I eventually realized that there's > no point. Checking on 'valid?' is entire and sufficient. I also came to the same conclusion. That's why I am very cautious with "rake stats" and rcov, it entices people to write dumb tests / specs just to get the figures up. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu Feb 19 08:58:37 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 19 Feb 2009 07:58:37 -0600 Subject: [rspec-users] [ANN] rspec-1.2 release candidate In-Reply-To: <31D30E37-CF11-4541-B3E4-20C5068AEFB4@wincent.com> References: <31D30E37-CF11-4541-B3E4-20C5068AEFB4@wincent.com> Message-ID: <57c63afe0902190558m14107313j9bfa949c48c1c9f1@mail.gmail.com> On Thu, Feb 19, 2009 at 3:57 AM, Wincent Colaiuta wrote: > El 19/2/2009, a las 7:56, David Chelimsky escribi?: > >> rspec-1.2 and rspec-rails-1.2 are just about ready, but I'd like to >> get some feedback from the field before the release. Would the >> adventurous among you kindly grab the latest github gems (1.1.99.7 as >> of this email) and check 'em out? I'm hoping to release rspec-1.2 >> shortly after rails-2.3.1 is released. >> >> [sudo] gem install dchelimsky-rspec >> [sudo] gem install dchelimsky-rspec-rails > > > Or, if you don't have gems.github.com in your RubyGems "source" list: > > [sudo] gem install --source http://gems.github.com dchelimsky-rspec > [sudo] gem install --source http://gems.github.com dchelimsky-rspec-rails Thanks, Wincent! Forgot that little bit - I *do* have gems.github in my RubyGems source list! Cheers, David > > Wincent > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From sfeley at gmail.com Thu Feb 19 09:20:52 2009 From: sfeley at gmail.com (Stephen Eley) Date: Thu, 19 Feb 2009 09:20:52 -0500 Subject: [rspec-users] validate_presence_of In-Reply-To: <57c63afe0902182158w4a6cd740n9608b28819fdaabc@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <3c30da400902181942u195c2628uc1271630f4c929b3@mail.gmail.com> <1fb4df0902182131r1ec87c23hf503548ac877d595@mail.gmail.com> <57c63afe0902182158w4a6cd740n9608b28819fdaabc@mail.gmail.com> Message-ID: <1fb4df0902190620x57758b14k27fa84fcf5411fd2@mail.gmail.com> On Thu, Feb 19, 2009 at 12:58 AM, David Chelimsky wrote: > >> Also, while I used to be very anal and write "should >> have(1).error_on(:login)" and such, I eventually realized that there's >> no point. Checking on 'valid?' is entire and sufficient. > > I think this depends on whether or not error messages are part of the > conversation w/ the customer. If not, that seems fine. But "should have(1).error_on(:login)" isn't a test on error messages. It's a test on a key called :login. The conversation with the customer has no bearing on that; the customer's never asked about the errors data structure. I do check for error messages making it to the user, but not in my model specs. Those get checked in my request specs. (Or my Cucumber features, whichever I'm doing that day.) So again, it's covered; just not twice. > But my validation specs do tend to be closely tied to AR methods like > valid?(), which, as your example suggests, is impeding my ability to > choose a different ORM lib. Time for some re-thinking! To be fair, the only reason the tests I quoted work when I switched to Datamapper is because DM coincidentally (or not) uses the same "valid?" method that AR does. Eventually you do have to hit your API. I just like to hit it at the highest level that proves the behavior I care about. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From dchelimsky at gmail.com Thu Feb 19 09:38:46 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 19 Feb 2009 08:38:46 -0600 Subject: [rspec-users] [ANN] rspec-1.2 release candidate In-Reply-To: <57c63afe0902182256h37f6449exc29e03cf1275d804@mail.gmail.com> References: <57c63afe0902182256h37f6449exc29e03cf1275d804@mail.gmail.com> Message-ID: <57c63afe0902190638o712339d5nec5b76bfe3890f20@mail.gmail.com> On Thu, Feb 19, 2009 at 12:56 AM, David Chelimsky wrote: > Hey fellow behaviour-drivers, > > rspec-1.2 and rspec-rails-1.2 are just about ready, but I'd like to > get some feedback from the field before the release. Would the > adventurous among you kindly grab the latest github gems (1.1.99.7 as > of this email) and check 'em out? I'm hoping to release rspec-1.2 > shortly after rails-2.3.1 is released. > > [sudo] gem install dchelimsky-rspec > [sudo] gem install dchelimsky-rspec-rails FYI - documentation on upgrading your rails app: http://wiki.github.com/dchelimsky/rspec/rails-with-rspec-gems There are some gotchas that are explained there. Please feel free to improve the wiki page if you come up with any steps or problems that I missed. Thanks, David > > Notable changes include: > > == rspec > > * lots and lots of refactoring - internals are getting cleaner and leaner > * substantially works with ruby-1.9.1, though there are still some issues > * cleaner integration with the new heckle 1.4.2 release > * require 'spec/test/unit' to run your T::U tests w/ rspec and start > refactoring them to code examples > * require 'spec/autorun' to run examples with the ruby command > > == rspec-rails > > * supports rails 2.0.5, 2.1.2, 2.2.2, 2.3.0, edge (as of release time) > * config.gem actually works now > * example groups are all subclasses of rails test classes (instead of > just Test::Unit::TestCase or ActionController::TestCase) > * spec_server fixes! - it pretty much works now for all supported > versions of rails > * bypass_rescue in controller specs for granular specification of action errors > > You can see more complete release notes at: > > http://github.com/dchelimsky/rspec/blob/master/History.txt > http://github.com/dchelimsky/rspec-rails/blob/master/History.txt > > And upgrade notes for rspec-rails at: > > http://github.com/dchelimsky/rspec-rails/blob/master/Upgrade.markdown > > Cheers, > David > From lasitha.ranatunga at gmail.com Thu Feb 19 09:52:58 2009 From: lasitha.ranatunga at gmail.com (lasitha) Date: Thu, 19 Feb 2009 06:52:58 -0800 (PST) Subject: [rspec-users] Ruby 1.9 - autospec loadpath problem In-Reply-To: <57c63afe0812010221x58dd37e3w1a7d741df1256b70@mail.gmail.com> References: <57a815bf0811301424k131b4155xafee88459449eb@mail.gmail.com> <57c63afe0812010221x58dd37e3w1a7d741df1256b70@mail.gmail.com> Message-ID: <22102148.post@talk.nabble.com> On Mon, Dec 01, 2008 at 03:51pm, David Chelimsky wrote: >On Sun, Nov 30, 2008 at 4:24 PM, Mikel Lindsaar wrote: >> [...] >> mikel at baci.local ~/ruby_programs/mail >> $ autospec >> /usr/local/bin/autotest:19:in `load': Is a directory - >> /usr/local/lib/ruby-trunk/gems/1.9.1/gems/rspec-1.1.11/lib/autotest >> (Errno::EISDIR) >> from /usr/local/bin/autotest:19:in `
' >> [...] >> So load is trying to load autotest the directory instead of autotest the >> script. >> Any ideas on how to get it to load the right thing? > >I'm not sure how to fix that problem, but before you go much further >you should know that RSpec does not yet run under 1.9. [...] I just ran across this (rspec 1.1.99.7, zentest 3.11.1, ruby 1.9.1-p0) and thought i'd follow up. It appears this is related to rubygems being loaded automatically in ruby 1.9... Cucumber (and rspec for that matter) contains an 'autotest' directory under /lib and it appears earlier in the load path than the ZenTest directories. As evidence, running the following gets past the error: $ ruby --disable-gems `which autotest` Of course that would then necessitate activating needed gems manually, which seems to be counter-productive if 1.9 is encouraging the opposite approach. It's not clear to me that this is a rspec or zentest bug - it might just as easily be a rubygems or ruby deficiency (couldn't 'load' just ignore directories?). Unfortunately i'm not experienced enough with any of these libraries to know where to take this next. If anyone would point me in a direction, i'd be happy to keep digging. In the meantime, here's a hack to $RUBY_HOME/bin/autotest (the one generated by rubygems): @@ -19 +19,2 @@ -load 'autotest' +zentest_gem_dir = Gem.source_index.find_name('ZenTest', version).first.full_gem_path +load File.join(zentest_gem_dir, 'bin', 'autotest') That is very likely the _wrong_ way to calculate zentest_gem_dir... I googled and poked around but couldn't find any definitive API. Any enlightenment on that would also be appreciated. Cheers, lasitha -- View this message in context: http://www.nabble.com/Ruby-1.9---autospec-loadpath-problem-tp20763177p22102148.html Sent from the rspec-users mailing list archive at Nabble.com. From lists at ruby-forum.com Thu Feb 19 09:54:59 2009 From: lists at ruby-forum.com (Raimond Garcia) Date: Thu, 19 Feb 2009 15:54:59 +0100 Subject: [rspec-users] Cucumber + Webrat + Selenium + ActionMailer In-Reply-To: <9fa97fb652c4210d767e16757a4610e5@ruby-forum.com> References: <3aa9e123e627fd97b4d75bd5c2ca0fc4@ruby-forum.com> <499C693D.9090006@benmabey.com> <1fb4df0902181515y6d95221bw87c4706f3987f0ce@mail.gmail.com> <499C9955.8080804@benmabey.com> <1fb4df0902182021m497b243ap95b76303d7842a04@mail.gmail.com> <499CEA87.5000804@benmabey.com> <1fb4df0902182144i4d3f655eh3cf7befa27a905a5@mail.gmail.com> <9fa97fb652c4210d767e16757a4610e5@ruby-forum.com> Message-ID: <54bf7268cc8b3140727473d005e4bd29@ruby-forum.com> >1. >http://seattlerb.rubyforge.org/ar_mailer/classes/ActionMailer/ARMailer.html > P.S. I'll follow up with a confirmation post just to let the people know > how it worked out for us with ARMailer. Yeap everything worked like a charm, once again checking email contents like there is no tomorrow ;-) Rai -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu Feb 19 09:55:13 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 19 Feb 2009 08:55:13 -0600 Subject: [rspec-users] validate_presence_of In-Reply-To: <1fb4df0902182140n452afb9fh82855768acb7aa7@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <01C973AD-FF8D-468A-A494-F10285758C40@goldweb.com.au> <1fb4df0902182140n452afb9fh82855768acb7aa7@mail.gmail.com> Message-ID: <57c63afe0902190655y66b388cbs9e109da6b738defd@mail.gmail.com> On Wed, Feb 18, 2009 at 11:40 PM, Stephen Eley wrote: > If your spec breaks because you changed a method call, you're not > testing behavior any more. You're testing syntax. We've got to stop making laws out of guidelines. This is a very general statement about what is really a very specific situation, and it is not in any way as black and white as this statement sounds. But *somebody* is going to read this, not understand the context, and think it's international law. Code examples are clients of the subject code, just like any other clients that are part of the subject code. You don't expect all of the other objects in your app to work correctly when you change a method name in only one place, do you? You need to change all the clients, including the code examples. In Chicago we don't have any j-walking laws (at least that I know of - I've yet to be arrested for it). The guideline we operate under is that you should wait for the light, but we don't always follow that guideline. When I'm at an intersection and don't have the light, I look both ways, like I learned back in kindergarten, and cross if its safe. If there are no cars coming, I'm very likely to survive the incident. If there are cars coming, I can still navigate my way across the street and, if I do so carefully, correctly, and with precise timing, I might well survive. Guidelines are great tools, but if we followed guidelines like laws we'd never get where we're going. FWIW, David From mr.gaffo at gmail.com Thu Feb 19 10:00:46 2009 From: mr.gaffo at gmail.com (Mike Gaffney) Date: Thu, 19 Feb 2009 09:00:46 -0600 Subject: [rspec-users] validate_presence_of In-Reply-To: <57c63afe0902182158w4a6cd740n9608b28819fdaabc@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <3c30da400902181942u195c2628uc1271630f4c929b3@mail.gmail.com> <1fb4df0902182131r1ec87c23hf503548ac877d595@mail.gmail.com> <57c63afe0902182158w4a6cd740n9608b28819fdaabc@mail.gmail.com> Message-ID: <499D741E.4050908@gmail.com> Dave, you make a good point. In our system, where we are converting a legacy database/application, we typically have no user stories and have the technical (or you could argue user) requirement that the database logic / constraints get converted. This is where we are typically just encoding all of the should_have_many, etcs. They at a first glance do seem like fragile and redundant tests but when you consider that the schema isn't in rails standard format, simple has_manys are not always going to work so we actually need to test our configuration of the associations. -Mike David Chelimsky wrote: > On Wed, Feb 18, 2009 at 11:31 PM, Stephen Eley wrote: > >> On Wed, Feb 18, 2009 at 10:42 PM, Mark Wilden wrote: >> >>> On Wed, Feb 18, 2009 at 4:39 PM, Fernando Perez wrote: >>> >>>> What's the point in testing validates_presence_of for a model? >>>> >>> To make sure you wrote that line of code. >>> >> And the circle spins round and round... >> >> Specs that mirror the code that closely are a bad idea, I think. The >> problem with that example is that the syntax of the code is driving >> the syntax of the spec, even if the spec was written first. You're no >> longer thinking about high-level behavior, you're thinking about the >> presence of a certain line in Rails. >> >> I write those sorts of model specs a little differently. I just poke >> at things and set expectations on whether they break. I'd write this >> example like: >> >> describe User do >> before(:each) do >> @this = User.make_unsaved # I use machinist for my factory methods >> end >> >> it "is valid" do >> @this.should be_valid >> end >> >> it "can save" do >> @this.save.should be_true >> end >> >> it "requires a login" do >> @this.login = nil >> @this.should_not be_valid >> end >> >> it "may have a password reminder" do >> @this.password_reminder = nil >> @this.should be_valid >> end >> >> it "does not allow duplicate logins" do >> @that = User.make(:login => "EvilTwin") >> @this.login = "EvilTwin" >> @this.should_not be_valid >> end >> end >> >> ...And so forth. It's wordier, but very readable, and it doesn't rely >> on the validation being done with a specific Rails method. In fact, >> when I shifted to using Merb and Datamapper, I didn't have to change >> these sorts of tests at all. >> > > That's huge! > > >> Also, while I used to be very anal and write "should >> have(1).error_on(:login)" and such, I eventually realized that there's >> no point. Checking on 'valid?' is entire and sufficient. The first >> example proves that the default factory case is valid, so as long as >> we're only changing one thing at a time, we know that that's the thing >> that breaks validity. (Or, in the case of "may have," *doesn't* break >> validity.) >> > > I think this depends on whether or not error messages are part of the > conversation w/ the customer. If not, that seems fine. > > I find that I'll spec validations directly, but not associations. > There's no need to say that a team has_many players when you have > examples like team.should have(9).players_on_the_field. > > But my validation specs do tend to be closely tied to AR methods like > valid?(), which, as your example suggests, is impeding my ability to > choose a different ORM lib. Time for some re-thinking! > > Cheers, > David > > >> -- >> Have Fun, >> Steve Eley (sfeley at gmail.com) >> ESCAPE POD - The Science Fiction Podcast Magazine >> http://www.escapepod.org >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- -Mike Gaffney (http://rdocul.us) From zach.dennis at gmail.com Thu Feb 19 10:05:42 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 19 Feb 2009 10:05:42 -0500 Subject: [rspec-users] validate_presence_of In-Reply-To: <1fb4df0902182131r1ec87c23hf503548ac877d595@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <3c30da400902181942u195c2628uc1271630f4c929b3@mail.gmail.com> <1fb4df0902182131r1ec87c23hf503548ac877d595@mail.gmail.com> Message-ID: <85d99afe0902190705o4904d696q1ae544c47d425ae0@mail.gmail.com> On Thu, Feb 19, 2009 at 12:31 AM, Stephen Eley wrote: > On Wed, Feb 18, 2009 at 10:42 PM, Mark Wilden wrote: >> On Wed, Feb 18, 2009 at 4:39 PM, Fernando Perez wrote: >>> >>> What's the point in testing validates_presence_of for a model? >> >> To make sure you wrote that line of code. > > And the circle spins round and round... > > Specs that mirror the code that closely are a bad idea, I think. The > problem with that example is that the syntax of the code is driving > the syntax of the spec, even if the spec was written first. You're no > longer thinking about high-level behavior, you're thinking about the > presence of a certain line in Rails. A highly expressive declarative phrase has been pushed down to nothing more than "a certain line". :) While I agree with you in general, I think the wrong approach is to immediately disallow ourselves from using words or phrases that are found in the implementation in the specs. Yes, validates_presence_of can be used in the implementation, but it also serves as great, readable, behaviour expressing documentation. I'm not going to fault anyone or any spec where it is used, since the phrase itself is highly communicative. I'd be more concerned with its implementation rather than the fact that someone found it as a clear way to write attribute requiring examples. > > I write those sorts of model specs a little differently. I just poke > at things and set expectations on whether they break. I'd write this > example like: > > describe User do > before(:each) do > @this = User.make_unsaved # I use machinist for my factory methods > end > > it "is valid" do > @this.should be_valid > end > > it "can save" do > @this.save.should be_true > end > > it "requires a login" do > @this.login = nil > @this.should_not be_valid > end > > it "may have a password reminder" do > @this.password_reminder = nil > @this.should be_valid > end > > it "does not allow duplicate logins" do > @that = User.make(:login => "EvilTwin") > @this.login = "EvilTwin" > @this.should_not be_valid > end > end > > ...And so forth. It's wordier, but very readable, and it doesn't rely > on the validation being done with a specific Rails method. In fact, > when I shifted to using Merb and Datamapper, I didn't have to change > these sorts of tests at all. > > Also, while I used to be very anal and write "should > have(1).error_on(:login)" and such, I eventually realized that there's > no point. Checking on 'valid?' is entire and sufficient. The first > example proves that the default factory case is valid, so as long as > we're only changing one thing at a time, we know that that's the thing > that breaks validity. (Or, in the case of "may have," *doesn't* break > validity.) I like the idea of having "may have" examples for optional attributes. > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From hayafirst at gmail.com Thu Feb 19 10:41:26 2009 From: hayafirst at gmail.com (Yi Wen) Date: Thu, 19 Feb 2009 09:41:26 -0600 Subject: [rspec-users] validate_presence_of In-Reply-To: <1fb4df0902182140n452afb9fh82855768acb7aa7@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <01C973AD-FF8D-468A-A494-F10285758C40@goldweb.com.au> <1fb4df0902182140n452afb9fh82855768acb7aa7@mail.gmail.com> Message-ID: Good point, that's actually I am debating with myself everyday and haven't got a clear answer. This is classical "calssic unit tester" vs. mockist war. :) Talking about this case: 1. I haven't checked how should valite_presence_of is implemented, but it could pretty much be checking if the value is left blank. So it is behavior tests 2. I couldn't see any reason why I would want to write my own version of check_to_see_if_this_thingy_is_in_my_whatsis. So this is not a very realistic assumption. 3. By checking if validation fails when a value is left blank, I am actually kind of testing Rails and here's why: what if they introduce a bug in validates_presence_of that makes my test break? What if they have a bug in valid? to make my test break? To strictly just testing *my* own code, the test should be something like Person.should_receive(:validates_presence_of).with(:email) I am not really advocating the view of mockists. Just throw a question here. :) Yi On Wed, Feb 18, 2009 at 11:40 PM, Stephen Eley wrote: > On Wed, Feb 18, 2009 at 11:42 PM, Yi Wen wrote: > > > > Without this syntax sugar, we still have to test validates_presence_of to > > make sure it's there and won't broken, right? > > Wrong. You don't have to test validates_presence_of. What matters, > and therefore what you should test, is whether the model will complain > at you if a particular value is left empty. > > validates_presence_of happens to be the name of the method in > ActiveRecord that does that. But if you decide to write your own > check_to_see_if_this_thingy_is_in_my_whatsis() method that does the > same thing, a good *behavior* spec will not break. Because the > behavior remains the same. > > If your spec breaks because you changed a method call, you're not > testing behavior any more. You're testing syntax. > > > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aidy.lewis at googlemail.com Thu Feb 19 10:49:25 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Thu, 19 Feb 2009 15:49:25 +0000 Subject: [rspec-users] Cucumber 0.2 final release date? Message-ID: <7ac2300c0902190749x3d659b40w7cc84e5a6f8aedea@mail.gmail.com> Hi, I know this seems all take and no give, but do we have an estimated final release date for Cucumber 0.2? Thanks Aidy Celerity, Cucumber and Firewatir: http://skillsmatter.com/event/ruby-on-rails/lrug-march From dchelimsky at gmail.com Thu Feb 19 10:55:07 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 19 Feb 2009 09:55:07 -0600 Subject: [rspec-users] validate_presence_of In-Reply-To: <1fb4df0902190620x57758b14k27fa84fcf5411fd2@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <3c30da400902181942u195c2628uc1271630f4c929b3@mail.gmail.com> <1fb4df0902182131r1ec87c23hf503548ac877d595@mail.gmail.com> <57c63afe0902182158w4a6cd740n9608b28819fdaabc@mail.gmail.com> <1fb4df0902190620x57758b14k27fa84fcf5411fd2@mail.gmail.com> Message-ID: <57c63afe0902190755t2ae78302p813565f9fb97c8eb@mail.gmail.com> On Thu, Feb 19, 2009 at 8:20 AM, Stephen Eley wrote: > On Thu, Feb 19, 2009 at 12:58 AM, David Chelimsky wrote: >> >>> Also, while I used to be very anal and write "should >>> have(1).error_on(:login)" and such, I eventually realized that there's >>> no point. Checking on 'valid?' is entire and sufficient. >> >> I think this depends on whether or not error messages are part of the >> conversation w/ the customer. If not, that seems fine. > > But "should have(1).error_on(:login)" isn't a test on error messages. > It's a test on a key called :login. The conversation with the > customer has no bearing on that; the customer's never asked about the > errors data structure. The code in the examples are for developers. The docstrings are for customers. In this very specific case, the matcher doesn't support the specific error message, but if it did, the example would be: describe User do context "with punctuation in the login" do it "raises an error saying Login can't have punctuation" do user = User.generate(:login => "my.login!name") model.should have(1).error_on(:login).with("can't have punctuation") end end end Even without that ability, this would be fairly expressive to both customer and developer: describe User do context "with punctuation in the login" do it "raises an error saying Login can't have punctuation" do user = User.generate(:login => "my.login!name") model.should have(1).error_on(:login) end end end > I do check for error messages making it to the user, but not in my > model specs. Those get checked in my request specs. (Or my Cucumber > features, whichever I'm doing that day.) So again, it's covered; just > not twice. This is where this all gets tricky. TDD (remember? that's where this all started) says you don't write any subject code without a failing *unit test*. This is not about the end result - it's about a process. What you're talking about here is the end result: post-code testing. If you're true to the process, then you'd have material in both places. The cost of this is something that looks like duplication, but it's not really, because at the high level we're specifying the behaviour of the system, and at the low level we're specifying the behaviour of a single object - fulfilling its role in that system. The cost of *not* doing this is different in rails than it is in home grown systems. In home grown systems, since we are in charge of defining what objects have what responsibilities, the cost of only spec'ing from 10k feet is more time tracking down bugs. In rails, this is somewhat mitigated by the conventions we've established of keeping types of behaviour (like error message generation) in commonly accepted locations. If a merb request spec or cucumber scenario fails on an error message, we can be pretty certain the source is a model object. But even that is subject to the level of complexity of the model. If a view is dealing with a complex object graph, then there are multiple potential sources for the failure, in which case there is some benefit to having things specified at the object level. >> But my validation specs do tend to be closely tied to AR methods like >> valid?(), which, as your example suggests, is impeding my ability to >> choose a different ORM lib. Time for some re-thinking! > > To be fair, the only reason the tests I quoted work when I switched to > Datamapper is because DM coincidentally (or not) uses the same > "valid?" method that AR does. Eventually you do have to hit your API. > I just like to hit it at the highest level that proves the behavior I > care about. Agreed in general. Just keep in mind that behaviour exists at more than one level. At the object level, behaviour == responsibility. If I'm a controller and my responsibility is to take a message from you, re-package it and hand it off to the appropriate model, then *that* is my behaviour. Cheers, David > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From zach.dennis at gmail.com Thu Feb 19 11:05:54 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 19 Feb 2009 11:05:54 -0500 Subject: [rspec-users] validate_presence_of In-Reply-To: References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <01C973AD-FF8D-468A-A494-F10285758C40@goldweb.com.au> <1fb4df0902182140n452afb9fh82855768acb7aa7@mail.gmail.com> Message-ID: <85d99afe0902190805y3469dabfi2d029ce97f35e379@mail.gmail.com> On Thu, Feb 19, 2009 at 10:41 AM, Yi Wen wrote: > Good point, that's actually I am debating with myself everyday and haven't > got a clear answer. This is classical "calssic unit tester" vs. mockist war. > :) > > Talking about this case: > > 1. I haven't checked how should valite_presence_of is implemented, but it > could pretty much be checking if the value is left blank. So it is behavior > tests > > 2. I couldn't see any reason why I would want to write my own version of > check_to_see_if_this_thingy_is_in_my_whatsis. So this is not a very > realistic assumption. > > 3. By checking if validation fails when a value is left blank, I am actually > kind of testing Rails and here's why: what if they introduce a bug in > validates_presence_of that makes my test break? What if they have a bug in > valid? to make my test break? To strictly just testing *my* own code, the > test should be something like > Person.should_receive(:validates_presence_of).with(:email) > > I am not really advocating the view of mockists. Just throw a question here. This is a good example of strictly testing *your* code. But, to the last statement--it is not a very good example of when to use mock expectations. I don't think it advocates an accurate view of *mockists*. > :) > > Yi > > On Wed, Feb 18, 2009 at 11:40 PM, Stephen Eley wrote: >> >> On Wed, Feb 18, 2009 at 11:42 PM, Yi Wen wrote: >> > >> > Without this syntax sugar, we still have to test validates_presence_of >> > to >> > make sure it's there and won't broken, right? >> >> Wrong. You don't have to test validates_presence_of. What matters, >> and therefore what you should test, is whether the model will complain >> at you if a particular value is left empty. >> >> validates_presence_of happens to be the name of the method in >> ActiveRecord that does that. But if you decide to write your own >> check_to_see_if_this_thingy_is_in_my_whatsis() method that does the >> same thing, a good *behavior* spec will not break. Because the >> behavior remains the same. >> >> If your spec breaks because you changed a method call, you're not >> testing behavior any more. You're testing syntax. >> >> >> >> -- >> Have Fun, >> Steve Eley (sfeley at gmail.com) >> ESCAPE POD - The Science Fiction Podcast Magazine >> http://www.escapepod.org >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > 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 lenny at aps.org Thu Feb 19 11:09:04 2009 From: lenny at aps.org (Lenny Marks) Date: Thu, 19 Feb 2009 08:09:04 -0800 Subject: [rspec-users] [Cucumber] Level of features / Feature dependent steps In-Reply-To: References: <45453541-CD64-44FC-9585-0F857B81A43B@aps.org> <1126d7ae0902180512iac72f61la33abf27113f8244@mail.gmail.com> Message-ID: <723AF188-CA47-4266-8F13-2C514C2B8326@aps.org> Just wanted to thank everyone for their replies. I actually recall that thread now about imperative vs. declarative. I've just re-read Ben's post along with some of the linked content off the post and now and I feel a bit more comfortable with the direction I was going in. I personally tend to favor the declarative style. At least for my current projects, Cucumber/SDD seems most attractive as a tool that encourages us to write user stories so that we code the right stuff and then allows us to turn those stories into executable documentation that also tests the full stack sanity of our app. I can definitely see using more specifics in the steps to lessen the burden of writing so many customized steps, at least when they don't distract much from the goal of the story. Recently I was writing a feature for an application for sending very business logic connected correspondences. If I have a scenario that applies to all correspondences and I see a step such as "Given I am sending a 'CTA'" as opposed "Given I am sending a correspondence", then I think it's kind of distracting. One thing I came across in the http://goruco2008.confreaks.com/01_helmkamp.html screencast was the concept of using verbs in scenario titles(e.g. reject duplicate names). Up until now I think I had been taking my translation of 'scenario' a bit too literal and using the scenario titles only state what makes the scenario different and not what the expected behavior should be(e.g reject duplicates). I'm not sure what I think about it yet, but stating the expected behavior in the scenario title and using the steps to demonstrate it can potentially make things less ambiguous when specifics are plugged in. I guess that just sounds more like a feature(sub-feature) to me, but I the line seems pretty blurry and I think has more to do with feature size. I'm curious how others use scenario titles but that may be worth another thread. Anyway, I think the imperative style lends itself more to developers thinking from the testing perspective(does every field on my registration make it into the system) while the declarative style is better suited as customer facing stories. Very subjective stuff, but for us, I see a lot of value having the executable documentation(accurate and up to date) that gives reasonable assurance on sanity but also documents(without a lot of noise) what's in the app. What a developer/tester needs to click through and what they should expect to see, should that need to be done(after refactoring a bunch of javascript or stylesheets or whatever). -lenny On Feb 18, 2009, at 8:07 AM, Mischa Fierer wrote: > Ben has a good post on the declarative vs imperative styles here: > > http://www.benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories/ > > I totally agree with Josh, and indeed wrote out my own version of > his login example before realizing I should probably read his post > before replying! > > I agree that each scenario should go into a good amount of detail > about what specifically being tested, rather than letting it be > hidden in a step. If other things have to happen in a scenario that > do not involve what is being specifically tested but must be > included for setup, then if it's DRYer it makes sense to make a more > abstract step. > > This also gives you a speed boost if done correctly, for example a > "given I am logged in as foo" step can just post to /session or w/ > e , rather than going to /login, filling in the form and pressing > the button and waiting. > > I'm not sure if I would go as far into the dsl as you are in the > second example, though, Lenny. Depending on whether or not you were > able to reuse those steps, as you say, you would over the course of > a few months end up with an entire level of scenario dependent steps. > > I might instead start by just using webrat / generic steps as long > as you can, and then taking a look at all your feature files and > deciding what you can dry up / what makes sense to move into a more > client specific dsl. > > Finally, having been doing cucumber for a while now, I've found that > i've been moving more towards the imperative style, simply because > it's faster to work with. > For example, if it were in the early stages of the app, I might even > do something like > > Scenario: I Pay a bill when I have enough $ > Given a checking account > And the checking account has "$50" > And a payee named "Acme" > And an "Acme" bill for "$37" > When I follow "bills to pay" > And I follow "Acme" > And I press "pay bill" > And I press "confirm" > Then I should see "payment success" > When I follow "account summary" > Then I should see "$13 remaining" > And I should see "you paid $37 to Acme" > > This is pretty ugly, but not out of the question imo. While it has > its downsides, one benefit is that it encourages a client to > actually think about how the site should work before you make it. > For example, they actually get to think about things like whether > there is a payment success page or not, rather than deciding that > there shouldn't be one after you've spent lots of time building it. > > wdyt? > > > > > On Wed, Feb 18, 2009 at 7:12 AM, Josh Chisholm > wrote: > I find that the _first_ example of some functionality should be > imperative (say specifically how to achieve something step by step) > and subsequent mentions of the same functionality should be more > declarative (say in abstract terms what to achieve, but spare the step > by step details). For me, this is consistent with discussing features > with customers: it starts out step by step, then in subsequent > conversations (especially after implementation of the imperative > steps) we can discuss the same thing in more abstract terms. > > An obvious example is login > > # login.feature > Scenario: Successful login > Given there is a user 'josh' > And the user 'josh' has the password 'pass' > When I visit the login page > And I enter the username 'josh' > And I enter the password 'pass' > And click 'submit' > Then I should see 'welcome josh' > > # some-other.feature > Scenario: Something that requires login > Given I have logged in successfully > ... > > # login_steps.rb > Given /I have logged in successfully/ do > Given "there is a user 'josh'" > Given "the user 'josh' has the password 'pass'" > When "I enter the username 'josh'" > ... > end > > There is duplication between the first imperative feature and the > login steps, but I think that's a slightly different issue from > "Feature coupled steps". The "Given I have logged in successfully" > step is not coupled to a particular feature, it is an aggregation of > other steps. It is designed to be used in different features. > > Going back to your example, I would use the first style. Later, I > would introduce the aggregate step "Given I have paid a bill with > sufficient funds" as and when I needed to. Like Jonathan said, there > is still the issue of shared state, but arguments can be passed > through the aggregate steps to the imperative steps depending on how > you feel about this. > > Josh > > > > > On Wed, Feb 18, 2009 at 8:45 AM, Matt Wynne > wrote: > > > > On 17 Feb 2009, at 20:27, Lenny Marks wrote: > > > >> Forgive the long post, just looking for input/advice/alternate > opinions.. > >> > >> Like many I think that going through the exercise of framing user > requests > >> in Cucumber terms(Features, Scenarios..) really helps facilitate > necessary > >> conversations and avoid time wasted implementing the wrong > thing(e.g. as a > >> requirement/specification tool). However, I'm a bit confused when > it comes > >> to tying this in with Cucumber. I've come across many > suggestions about > >> audience being king as far as language used in features, but when > writing > >> features as part of a specification for a new feature, I > consistently find > >> myself writing at a higher level than most any examples I've come > across(See > >> example below). > >> > >> In the past we've typically relied on very informal means of > specifying > >> new features(Wiki pages, paper, and verbal communication). No > that's not our > >> problem..;-) TPI, Even with extensive object level specs, the > full details > >> of what an application does and how it is expected to behave from > the > >> outside tends to get lost in the app over time. For example, we > have a few > >> applications that were developed by a consulting company. Even > concentrating > >> only on the UI and the flow of the application, there are many > features that > >> are kind of hidden within the app(ex. assign to drop down that > should keep > >> most recently used names first). Without being extremely familiar > with the > >> app, all you really know(as a developer or tester) is that it > renders > >> successfully, which is an obvious maintenance problem. Even with > newer apps, > >> after a feature is implemented it tends to get lost inside the > application. > >> > >> I was thinking that Cucumber could really work here as a full > life cycle > >> tool because the same artifacts that were initially used to > specify a > >> feature, could be kept and re-used as documentation for users and > testers. > >> Unlike alternatives such as keeping a Wiki page up to date, > having features > >> linked to implemented steps serves as integration tests and also > ensures > >> that the feature as written, is still accurate/up to date. (Even > link > >> Cucumber output to Wiki page) > >> > >> Anyway, reading through Cucumber docs and examples, I almost > always see > >> much more specific examples. > >> > >> e.g. (from RSpec book) > >> Feature: Pay bill on line > >> > >> Scenario: Pay a bill > >> Given a checking account with $50 > >> And a payee named Acme > >> And an Acme bill for $37 > >> When I pay the Acme bill > >> Then I should have $13 remaining in my checking account > >> And the payment of $37 to Acme should be listed in Recent > Payments > >> > >> That makes sense to me from a testing perspective, but it just > doesn't > >> seem right to me from the perspective I speak of above. If I were > flushing > >> out this feature with users, I'd have probably wound up with > something more > >> like: > >> > >> Scenario: Pay a bill with sufficient funds > >> Given I have a bill to pay > >> And I have enough money in my checking account to cover it > >> When I pay the bill > >> Then my checking account should be debited by the amount > payed > >> And the payment should be listed in Recent Payments > >> > >> One problem is that obviously this way involves always writing an > extra > >> level of feature dependent steps. It just seems to me that the > specific > >> version tends to distract from the actual story. I'm sure I'm > looking at > >> this backwards, but does anyone else use Cucumber similarly? > >> > >> Thanks, > >> -lenny > > > > My view is, prefer the latter (abstract) style, use the former > (specific) > > style when you have to for clarity. Each can make sense in the right > > context, but the latter style is definitely much easier to read. > > > > In the end I find you usually need some specific examples to drive > out a > > working system if the feature is at all interesting, but trying to > stick to > > the abstract style as long as possible is a good habit to get into. > > > > There was a discussion some time ago about calling these two styles > > 'declarative' and 'imperative'. I'm afraid I'm still too dumb to > remember > > which one is which, but someone else will surely chip in. > 'Abstract' and > > 'Specific' are feeling better to me as I type this. > > > > Matt Wynne > > http://blog.mattwynne.net > > http://www.songkick.com > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > 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 sfeley at gmail.com Thu Feb 19 11:40:39 2009 From: sfeley at gmail.com (Stephen Eley) Date: Thu, 19 Feb 2009 11:40:39 -0500 Subject: [rspec-users] validate_presence_of In-Reply-To: <57c63afe0902190655y66b388cbs9e109da6b738defd@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <01C973AD-FF8D-468A-A494-F10285758C40@goldweb.com.au> <1fb4df0902182140n452afb9fh82855768acb7aa7@mail.gmail.com> <57c63afe0902190655y66b388cbs9e109da6b738defd@mail.gmail.com> Message-ID: <1fb4df0902190840t57636b1dnc7bdbaf756bbfe30@mail.gmail.com> On Thu, Feb 19, 2009 at 9:55 AM, David Chelimsky wrote: > On Wed, Feb 18, 2009 at 11:40 PM, Stephen Eley wrote: > > >> If your spec breaks because you changed a method call, you're not >> testing behavior any more. You're testing syntax. > > > We've got to stop making laws out of guidelines. This is a very > general statement about what is really a very specific situation, and > it is not in any way as black and white as this statement sounds. But > *somebody* is going to read this, not understand the context, and > think it's international law. Doesn't it increase the probability that someone will read it and not understand the context when you deliberately take it out of context to make a point? >8-> Anyway, I wasn't declaring any laws. I didn't say "specs must never break when method calls change." That would be an impossible standard, since at some point *everything* comes down to a method call. I actually didn't express any imperatives at all. I will agree that "You're not testing behavior any more" is a bit of an overblown statement, since the line between 'behavior' and 'syntax' is highly subjective. Every test is really a test on both. I was expressing my own opinion on where I feel the line is drawn, but it was mostly in response to "You have to do *this*, right?" There's a lot of testing dogma out there. I'm starting to think everyone who gets vocal on the subject lapses into sounding dogmatic eventually...including, apparently, myself. To the extent that I sounded like I was trying to hand down the One True Way, I apologize and withdraw my fervor. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From dchelimsky at gmail.com Thu Feb 19 11:49:45 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 19 Feb 2009 10:49:45 -0600 Subject: [rspec-users] Ruby 1.9 - autospec loadpath problem In-Reply-To: <22102148.post@talk.nabble.com> References: <57a815bf0811301424k131b4155xafee88459449eb@mail.gmail.com> <57c63afe0812010221x58dd37e3w1a7d741df1256b70@mail.gmail.com> <22102148.post@talk.nabble.com> Message-ID: <57c63afe0902190849m4954d192iac667c318a10038@mail.gmail.com> On Thu, Feb 19, 2009 at 8:52 AM, lasitha wrote: > > On Mon, Dec 01, 2008 at 03:51pm, David Chelimsky > wrote: >>On Sun, Nov 30, 2008 at 4:24 PM, Mikel Lindsaar wrote: >>> [...] >>> mikel at baci.local ~/ruby_programs/mail >>> $ autospec >>> /usr/local/bin/autotest:19:in `load': Is a directory - >>> /usr/local/lib/ruby-trunk/gems/1.9.1/gems/rspec-1.1.11/lib/autotest >>> (Errno::EISDIR) >>> from /usr/local/bin/autotest:19:in `
' >>> [...] >>> So load is trying to load autotest the directory instead of autotest the >>> script. >>> Any ideas on how to get it to load the right thing? >> >>I'm not sure how to fix that problem, but before you go much further >>you should know that RSpec does not yet run under 1.9. [...] > > I just ran across this (rspec 1.1.99.7, zentest 3.11.1, ruby 1.9.1-p0) and > thought i'd follow up. > > It appears this is related to rubygems being loaded automatically in ruby > 1.9... Cucumber (and rspec for that matter) contains an 'autotest' directory > under /lib and it appears earlier in the load path than the ZenTest > directories. > > As evidence, running the following gets past the error: > $ ruby --disable-gems `which autotest` > > Of course that would then necessitate activating needed gems manually, which > seems to be counter-productive if 1.9 is encouraging the opposite approach. > > It's not clear to me that this is a rspec or zentest bug - it might just as > easily be a rubygems or ruby deficiency (couldn't 'load' just ignore > directories?). Sounds like Autotest's discovery process is going to need to be revisited. rspec and rspec-rails each have their own subclasses of Autotest, and the autotest executable decides what specific class to load by combing the load path for "autotest/discover" - so rspec and rspec-rails both need to have autotest directories to make that work. Merb apps do the same. > Unfortunately i'm not experienced enough with any of these libraries to know > where to take this next. > If anyone would point me in a direction, i'd be happy to keep digging. > > In the meantime, here's a hack to $RUBY_HOME/bin/autotest (the one generated > by rubygems): > > @@ -19 +19,2 @@ > -load 'autotest' > +zentest_gem_dir = Gem.source_index.find_name('ZenTest', > version).first.full_gem_path > +load File.join(zentest_gem_dir, 'bin', 'autotest') > > That is very likely the _wrong_ way to calculate zentest_gem_dir... I > googled and poked around but couldn't find any definitive API. Any > enlightenment on that would also be appreciated. For a temp solution this seems reasonable to me. Anybody else have a better idea? > > Cheers, > lasitha > > -- > View this message in context: http://www.nabble.com/Ruby-1.9---autospec-loadpath-problem-tp20763177p22102148.html > Sent from the rspec-users mailing list archive at Nabble.com. From sfeley at gmail.com Thu Feb 19 12:15:35 2009 From: sfeley at gmail.com (Stephen Eley) Date: Thu, 19 Feb 2009 12:15:35 -0500 Subject: [rspec-users] validate_presence_of In-Reply-To: <57c63afe0902190755t2ae78302p813565f9fb97c8eb@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <3c30da400902181942u195c2628uc1271630f4c929b3@mail.gmail.com> <1fb4df0902182131r1ec87c23hf503548ac877d595@mail.gmail.com> <57c63afe0902182158w4a6cd740n9608b28819fdaabc@mail.gmail.com> <1fb4df0902190620x57758b14k27fa84fcf5411fd2@mail.gmail.com> <57c63afe0902190755t2ae78302p813565f9fb97c8eb@mail.gmail.com> Message-ID: <1fb4df0902190915n6d74d9dex8b6672fde28ad426@mail.gmail.com> On Thu, Feb 19, 2009 at 10:55 AM, David Chelimsky wrote: > > This is where this all gets tricky. Yep. >8-> > TDD (remember? that's where this all started) says you don't write any > subject code without a failing *unit test*. This is not about the end > result - it's about a process. What you're talking about here is the > end result: post-code testing. Yes. And I didn't. The test "it 'requires a login'" fails until I write a validation for the login field. I don't write the validation until I have that test. Once that test is written, any way of validating login's presence -- with validates_presence_of in AR, or a :nullable => false on the property in DataMapper, or a callback before saving, or whatever -- will pass the test. I have written the code to pass the test, and I have followed TDD principles. I can now move on to the next problem. But I did not write any code yet setting the message. Because I haven't written any tests for the message. At this point I don't care what the message is, just that I have the right data. I care about the message when I start focusing on presentation. When I write specs for the exchange with the user, I will write a test. I might reopen the model's spec and add it there (maintaining 'unit test' purity), or I might put it in the request spec, but either way a test will break before the code is written. I think that keeps the *spirit* of TDD, whether or not it follows its shelving rules. And yes, I know it all comes down to "it depends." On a larger project that would have a lot of people on it, I'd probably insist on more formalism for the sake of keeping things organized. But if it's a small app with a focus on shipping fast and frequently, having one test that fails is enough. > If you're true to the process, then you'd have material in both > places. The cost of this is something that looks like duplication, but > it's not really, because at the high level we're specifying the > behaviour of the system, and at the low level we're specifying the > behaviour of a single object - fulfilling its role in that system. And again: the extent to which I'd do that is the extent to which I care how the system is organized. Sometimes it really does matter. More often, to me, it doesn't. If an integration spec breaks, there's *usually* no mystery to me because I can just look at the backtrace to see what broke and fix it in a few seconds. Writing low-level specs to help isolate what's obvious and quickly fixed without them doesn't save time. Sometimes it is more complicated and confusing, and if it takes me too long to understand why the high level is broken, I'll sometimes write more unit specs to figure it out. That's not backwards. A test still broke. If I always have at least one test that fails on any incorrect behavior that matters, and I never ship with failing tests, then my testing has satisfactory coverage, whether it's an integration test or a unit test or a highly trained hamster reviewing my log files. Having more tests and finer detail only matters if it saves me time. (Which, sometimes, it does.) That's just my opinion. Not the law. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From sfeley at gmail.com Thu Feb 19 12:30:17 2009 From: sfeley at gmail.com (Stephen Eley) Date: Thu, 19 Feb 2009 12:30:17 -0500 Subject: [rspec-users] validate_presence_of In-Reply-To: <1fb4df0902190915n6d74d9dex8b6672fde28ad426@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <3c30da400902181942u195c2628uc1271630f4c929b3@mail.gmail.com> <1fb4df0902182131r1ec87c23hf503548ac877d595@mail.gmail.com> <57c63afe0902182158w4a6cd740n9608b28819fdaabc@mail.gmail.com> <1fb4df0902190620x57758b14k27fa84fcf5411fd2@mail.gmail.com> <57c63afe0902190755t2ae78302p813565f9fb97c8eb@mail.gmail.com> <1fb4df0902190915n6d74d9dex8b6672fde28ad426@mail.gmail.com> Message-ID: <1fb4df0902190930k1d4a3077jae03311c3fffde7b@mail.gmail.com> On Thu, Feb 19, 2009 at 12:15 PM, Stephen Eley wrote: > > But I did not write any code yet setting the message. Because I > haven't written any tests for the message. At this point I don't care > what the message is, just that I have the right data. I care about > the message when I start focusing on presentation. By the way, this spun off a whole line of thought in my head that maybe the way Rails handles validation messages in general is wrong. It's certainly a violation of separation of concerns: models aren't supposed to care about presentation, and yet we're putting plain English (or other language, or internationalized, or whatever) text in then that isn't relevant to the data, just for the purpose of presenting it to the user. *This* is backwards, and maybe that's why I felt some conflict about where the spec on that message should go. The responsibility of the model is to report a problem, not to declare the exact wording of that report. In an ideal MVC world models wouldn't be filling up hashes with message text at all. They'd return exceptions on save, and the standard create/update boilerplate in the controller would contain a rescue instead of an if-then, and responsibility of turning the properties of that exception into English would happen somewhere at the view level. Am I onto something here? (Heh. Maybe I agree with Pat after all: I just went from a very minor "I can't figure out how to test this" to the arrogance of suggesting that pretty much every Ruby ORM should be rewritten.) >8-> -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From mark at mwilden.com Thu Feb 19 12:38:09 2009 From: mark at mwilden.com (Mark Wilden) Date: Thu, 19 Feb 2009 09:38:09 -0800 Subject: [rspec-users] validate_presence_of In-Reply-To: <1fb4df0902182140n452afb9fh82855768acb7aa7@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <01C973AD-FF8D-468A-A494-F10285758C40@goldweb.com.au> <1fb4df0902182140n452afb9fh82855768acb7aa7@mail.gmail.com> Message-ID: <3c30da400902190938s4c792ba7jfc34a30c3627dee1@mail.gmail.com> On Wed, Feb 18, 2009 at 9:40 PM, Stephen Eley wrote: > On Wed, Feb 18, 2009 at 11:42 PM, Yi Wen wrote: > > validates_presence_of happens to be the name of the method in > ActiveRecord that does that. But if you decide to write your own > check_to_see_if_this_thingy_is_in_my_whatsis() method that does the > same thing, a good *behavior* spec will not break. Because the > behavior remains the same. I think you're talking about state-based, blackbox testing, rather than behavior-based whitebox testing. RSpec unit tests are all about speccing that one object calls another object's method at the right time. The idea being that if that behavior occurs, and that the other object's method has been similarly tested, that you're OK. ///ark From dchelimsky at gmail.com Thu Feb 19 13:25:34 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 19 Feb 2009 12:25:34 -0600 Subject: [rspec-users] validate_presence_of In-Reply-To: <3c30da400902190938s4c792ba7jfc34a30c3627dee1@mail.gmail.com> References: <32d6ca509dc412ddc8df57a75ac4b261@ruby-forum.com> <01C973AD-FF8D-468A-A494-F10285758C40@goldweb.com.au> <1fb4df0902182140n452afb9fh82855768acb7aa7@mail.gmail.com> <3c30da400902190938s4c792ba7jfc34a30c3627dee1@mail.gmail.com> Message-ID: <57c63afe0902191025q27d396f7j2463ca1e2073b70c@mail.gmail.com> On Thu, Feb 19, 2009 at 11:38 AM, Mark Wilden wrote: > On Wed, Feb 18, 2009 at 9:40 PM, Stephen Eley wrote: >> On Wed, Feb 18, 2009 at 11:42 PM, Yi Wen wrote: >> >> validates_presence_of happens to be the name of the method in >> ActiveRecord that does that. But if you decide to write your own >> check_to_see_if_this_thingy_is_in_my_whatsis() method that does the >> same thing, a good *behavior* spec will not break. Because the >> behavior remains the same. > > I think you're talking about state-based, blackbox testing, rather > than behavior-based whitebox testing. RSpec unit tests are all about > speccing that one object calls another object's method at the right > time. This is true in cases where the object delegates responsibility and that delegation is significant. If a collaborator is polymorphic, and the correct collaborator is chosen based on conditions external to the subject, then it makes sense to spec interactions. If the collaborator connects to an external resource like a database or a network, then stubbing the collaborator makes good sense. On the contrary, if the collaborator is created internally and is always the same object and does not require any setup outside of the subject, then spec'ing interactions doesn't make sense. Make sense? > The idea being that if that behavior occurs, and that the other > object's method has been similarly tested, that you're OK. With the caveat that somewhere there is some level of integration testing going on. Although it looks like J.B. Rainsberger disagrees: http://agile2009.agilealliance.org/node/708 (you have to have an account to view this - but the title of his proposed talk is "Integration Tests are a Scam"). I don't know enough of the detail of his arguments to argue them here, but it seems like an interesting discussion. FWIW, David > > ///ark > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tero at tilus.net Thu Feb 19 13:34:41 2009 From: tero at tilus.net (Tero Tilus) Date: Thu, 19 Feb 2009 20:34:41 +0200 Subject: [rspec-users] ActiveRecord::Base.should_receive(:find) fails Message-ID: <20090219183440.GC22708@uivelo.tilus.net> I've got an AR-model with some find-magic I want to test. When I have ActiveRecord::Base.should_receive(:find).with(anything(),assert_options) MyModel.find(:all,find_options) in my example find-method somehow disappears alltogether and I get NoMethodError in 'MyModel find-options are passed on correctly' undefined method `find' for MyModel And docs tell that (at least something really close to that one) should work http://rspec.info/documentation/mocks/partial_mocks.html -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From dchelimsky at gmail.com Thu Feb 19 13:47:18 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 19 Feb 2009 12:47:18 -0600 Subject: [rspec-users] ActiveRecord::Base.should_receive(:find) fails In-Reply-To: <20090219183440.GC22708@uivelo.tilus.net> References: <20090219183440.GC22708@uivelo.tilus.net> Message-ID: <57c63afe0902191047y619152cie8b8394529bc7d98@mail.gmail.com> On Thu, Feb 19, 2009 at 12:34 PM, Tero Tilus wrote: > I've got an AR-model with some find-magic I want to test. When I have > > ActiveRecord::Base.should_receive(:find).with(anything(),assert_options) > MyModel.find(:all,find_options) MyModel != ActiveRecord::Base Try this MyModel.should_receive(:find).with(anything(),assert_options) MyModel.find(:all,find_options) > > in my example find-method somehow disappears alltogether and I get > > NoMethodError in 'MyModel find-options are passed on correctly' > undefined method `find' for MyModel > > And docs tell that (at least something really close to that one) > should work > > http://rspec.info/documentation/mocks/partial_mocks.html > > -- > Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From html-kurs at gmx.de Thu Feb 19 15:54:46 2009 From: html-kurs at gmx.de (Martin) Date: Thu, 19 Feb 2009 21:54:46 +0100 Subject: [rspec-users] Mocking / stubbing errors for ActiveRecord Message-ID: <499DC716.3050904@gmx.de> Hi, I'm trying to test my views using rspec. I want to test my edit- and new-view also for the case an error occurs (something like "title can't be blank" and so on). Can someone point me please to an example where I can see how to mock my model and stub all methods needed for the view? Thank you, Martin From jim at saturnflyer.com Thu Feb 19 16:15:04 2009 From: jim at saturnflyer.com (Jim Gay) Date: Thu, 19 Feb 2009 16:15:04 -0500 Subject: [rspec-users] Mocking / stubbing errors for ActiveRecord In-Reply-To: <499DC716.3050904@gmx.de> References: <499DC716.3050904@gmx.de> Message-ID: <629813E2-88E1-4777-8BD6-0446E9C10A66@saturnflyer.com> On Feb 19, 2009, at 3:54 PM, Martin wrote: > Hi, > > I'm trying to test my views using rspec. I want to test my edit- and > new-view also for the case an error occurs (something like "title > can't be blank" and so on). > Can someone point me please to an example where I can see how to > mock my model and stub all methods needed for the view? Here's how I addressed it http://pastie.org/394417 > Thank you, > Martin From dchelimsky at gmail.com Thu Feb 19 16:18:27 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 19 Feb 2009 15:18:27 -0600 Subject: [rspec-users] Mocking / stubbing errors for ActiveRecord In-Reply-To: <499DC716.3050904@gmx.de> References: <499DC716.3050904@gmx.de> Message-ID: <57c63afe0902191318yfd870c8y2bc63c1c900302c8@mail.gmail.com> On Thu, Feb 19, 2009 at 2:54 PM, Martin wrote: > Hi, > > I'm trying to test my views using rspec. I want to test my edit- and > new-view also for the case an error occurs (something like "title can't be > blank" and so on). > Can someone point me please to an example where I can see how to mock my > model and stub all methods needed for the view? Here's a start: http://rspec.info/rails/writing/views.html Also: rails foo cd foo script/generate rspec script/generate rspec_scaffold thing name:string Now look at spec/views/things/*.html.erb_spec.rb HTH, David > > Thank you, > Martin > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Thu Feb 19 16:24:09 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 19 Feb 2009 21:24:09 +0000 Subject: [rspec-users] Mocking / stubbing errors for ActiveRecord In-Reply-To: <499DC716.3050904@gmx.de> References: <499DC716.3050904@gmx.de> Message-ID: On 19 Feb 2009, at 20:54, Martin wrote: > Hi, > > I'm trying to test my views using rspec. I want to test my edit- and > new-view also for the case an error occurs (something like "title > can't be blank" and so on). > Can someone point me please to an example where I can see how to > mock my model and stub all methods needed for the view? I guess this isn't exactly what you want to hear, but I would counsel you against mocking your whole model object for a form with lots of fields - those kind of 'broad' mocks can be very brittle to changes in your domain model. Can you try using stub_model instead? This creates an instance of your actual model class, but with a crippled database connection. You can then create an invalid model object and throw it to the view. Something like: assigns[:book] = stub_model(Book, :title => '') If your model is at all interesting, you might want to keep the attributes that make a valid Book somewhere: valid_book = { :title => "Test Book Title", :author => "Test Author" } assigns[:book] = stub_model(Book, valid_book.merge(:title => '')) I generally hide these behind a helper method, like def stub_book(attributes = {}) stub_model Book, { :title => "Test Book Title", :author => "Test Author" }.merge(attributes) end Does that help? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From zuperinfinite at gmail.com Thu Feb 19 16:39:09 2009 From: zuperinfinite at gmail.com (Bart Zonneveld) Date: Thu, 19 Feb 2009 22:39:09 +0100 Subject: [rspec-users] Mocking / stubbing errors for ActiveRecord In-Reply-To: <499DC716.3050904@gmx.de> References: <499DC716.3050904@gmx.de> Message-ID: On 19 feb 2009, at 21:54, Martin wrote: > Hi, > > I'm trying to test my views using rspec. I want to test my edit- and > new-view also for the case an error occurs (something like "title > can't be blank" and so on). > Can someone point me please to an example where I can see how to > mock my model and stub all methods needed for the view? If you happen to use Cucumber as well, I strongly suggest you check the error messages there. First of all, it's easier since you don't have to go mad stubbing and mucking about (sorry, had to make that joke :P), and error messages more or less belong into integration tests. At least, that's my opinion. cheers, bartz From zach.dennis at gmail.com Thu Feb 19 16:51:58 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 19 Feb 2009 16:51:58 -0500 Subject: [rspec-users] Mocking / stubbing errors for ActiveRecord In-Reply-To: <499DC716.3050904@gmx.de> References: <499DC716.3050904@gmx.de> Message-ID: <85d99afe0902191351t4c1eba82u8adf82c1443f2966@mail.gmail.com> On Thu, Feb 19, 2009 at 3:54 PM, Martin wrote: > Hi, > > I'm trying to test my views using rspec. I want to test my edit- and > new-view also for the case an error occurs (something like "title can't be > blank" and so on). > Can someone point me please to an example where I can see how to mock my > model and stub all methods needed for the view? Here's two ways to approach writing examples against ensuring errors show up: http://gist.github.com/67135 Note, that if your model really exists, you can use stub_model instead of mock_model. > > Thank you, > Martin > _______________________________________________ > 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 zach.dennis at gmail.com Thu Feb 19 16:53:21 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 19 Feb 2009 16:53:21 -0500 Subject: [rspec-users] Mocking / stubbing errors for ActiveRecord In-Reply-To: References: <499DC716.3050904@gmx.de> Message-ID: <85d99afe0902191353m31bf8476xcd930f075d4d9099@mail.gmail.com> On Thu, Feb 19, 2009 at 4:24 PM, Matt Wynne wrote: > > On 19 Feb 2009, at 20:54, Martin wrote: > >> Hi, >> >> I'm trying to test my views using rspec. I want to test my edit- and >> new-view also for the case an error occurs (something like "title can't be >> blank" and so on). >> Can someone point me please to an example where I can see how to mock my >> model and stub all methods needed for the view? > > I guess this isn't exactly what you want to hear, but I would counsel you > against mocking your whole model object for a form with lots of fields - > those kind of 'broad' mocks can be very brittle to changes in your domain > model. > > Can you try using stub_model instead? This creates an instance of your > actual model class, but with a crippled database connection. You can then > create an invalid model object and throw it to the view. Something like: > > assigns[:book] = stub_model(Book, :title => '') > > If your model is at all interesting, you might want to keep the attributes > that make a valid Book somewhere: > > valid_book = { > :title => "Test Book Title", > :author => "Test Author" > } > assigns[:book] = stub_model(Book, valid_book.merge(:title => '')) > > I generally hide these behind a helper method, like > > def stub_book(attributes = {}) > stub_model Book, { > :title => "Test Book Title", > :author => "Test Author" > }.merge(attributes) > end Why hide them behind a helper? Why not just only specify them in examples where they are used? ie: it "should display the book title" do @book.stub!(:title).and_return "The Scarlet Letter" render ... response.should include_text("The Scarlet Letter") end > > Does that help? > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From zach.dennis at gmail.com Thu Feb 19 17:11:17 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 19 Feb 2009 17:11:17 -0500 Subject: [rspec-users] Mocking / stubbing errors for ActiveRecord In-Reply-To: <85d99afe0902191351t4c1eba82u8adf82c1443f2966@mail.gmail.com> References: <499DC716.3050904@gmx.de> <85d99afe0902191351t4c1eba82u8adf82c1443f2966@mail.gmail.com> Message-ID: <85d99afe0902191411s203a1369gb4d7d0ee8d34aa3e@mail.gmail.com> On Thu, Feb 19, 2009 at 4:51 PM, Zach Dennis wrote: > On Thu, Feb 19, 2009 at 3:54 PM, Martin wrote: >> Hi, >> >> I'm trying to test my views using rspec. I want to test my edit- and >> new-view also for the case an error occurs (something like "title can't be >> blank" and so on). >> Can someone point me please to an example where I can see how to mock my >> model and stub all methods needed for the view? > > Here's two ways to approach writing examples against ensuring errors show up: > > http://gist.github.com/67135 > This gist is to show you how-to verify errors are displayed in a view, not necessarily that you should go stubbing a bunch of superfluous errors that may exist in the model to ensure they all show up. You should only need to know that the errors are being displayed and one dummy error message does that. > Note, that if your model really exists, you can use stub_model instead > of mock_model. > > > > >> >> Thank you, >> Martin >> _______________________________________________ >> 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 > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From lists at ruby-forum.com Fri Feb 20 05:35:07 2009 From: lists at ruby-forum.com (Juanma Cervera) Date: Fri, 20 Feb 2009 11:35:07 +0100 Subject: [rspec-users] [ANN] rspec-1.2 release candidate In-Reply-To: <57c63afe0902190558m14107313j9bfa949c48c1c9f1@mail.gmail.com> References: <57c63afe0902182256h37f6449exc29e03cf1275d804@mail.gmail.com> <31D30E37-CF11-4541-B3E4-20C5068AEFB4@wincent.com> <57c63afe0902190558m14107313j9bfa949c48c1c9f1@mail.gmail.com> Message-ID: <47e4b956d5e2a4ffc7eab7f43602575d@ruby-forum.com> David, I have an error when trying to run autospec. It works when I run 'rake spec' I don know why it is still using the rspec-1.1.12 gem. /usr/lib/ruby/gems/1.8/gems/dchelimsky-rspec-1.1.99.7/lib/spec/autorun.rb:3: undefined method `autorun' for Spec::Runner:Module (NoMethodError) from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `require' from /home/jmcervera/.gem/ruby/1.8/gems/activesupport-2.3.0/lib/active_support/dependencies.rb:158:in `require' from ./spec/models/../spec_helper.rb:5 from ./spec/models/cliente_spec.rb:1:in `require' from ./spec/models/cliente_spec.rb:1 from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/runner/example_group_runner.rb:15:in `load' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/runner/example_group_runner.rb:15:in `load_files' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/runner/example_group_runner.rb:14:in `each' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/runner/example_group_runner.rb:14:in `load_files' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/runner/options.rb:94:in `run_examples' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/runner/command_line.rb:9:in `run' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.12/bin/spec:4 Thanks Juanma -- Posted via http://www.ruby-forum.com/. From chris.webstar at gmail.com Fri Feb 20 07:15:26 2009 From: chris.webstar at gmail.com (Christian Hoeppner) Date: Fri, 20 Feb 2009 12:15:26 +0000 Subject: [rspec-users] Autotest won't pickup any tests Message-ID: <067EF338-8816-417E-963F-4BC157E18EFD@gmail.com> Hey there, I've tried using Nick Sieger's "plugin" to have autotest run my tests for gems and other non-rails stuff. However, it doesn't seem to match any tests for any files. Not being sure what was wrong, I traced the execution of RspecAutotest.run() and saw that tests_for_file() never got called. I also replicated a tests_for_file() call by hand in irb, and it does match the right spec file for any given implementation file. Here's what I use: ZenTest (3.11.1), rspec (1.1.12), ruby, ruby 1.8.1 (2003-12-25) [i686- darwin]. Sieger's file is the latest from svn, dated from 2007. From matt at mattwynne.net Fri Feb 20 09:20:20 2009 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 20 Feb 2009 14:20:20 +0000 Subject: [rspec-users] Mocking / stubbing errors for ActiveRecord In-Reply-To: <85d99afe0902191353m31bf8476xcd930f075d4d9099@mail.gmail.com> References: <499DC716.3050904@gmx.de> <85d99afe0902191353m31bf8476xcd930f075d4d9099@mail.gmail.com> Message-ID: <5424C9CE-2689-4139-80ED-DC45DCEA4AB9@mattwynne.net> On 19 Feb 2009, at 21:53, Zach Dennis wrote: > On Thu, Feb 19, 2009 at 4:24 PM, Matt Wynne > wrote: >> >> On 19 Feb 2009, at 20:54, Martin wrote: >> >>> Hi, >>> >>> I'm trying to test my views using rspec. I want to test my edit- and >>> new-view also for the case an error occurs (something like "title >>> can't be >>> blank" and so on). >>> Can someone point me please to an example where I can see how to >>> mock my >>> model and stub all methods needed for the view? >> >> I guess this isn't exactly what you want to hear, but I would >> counsel you >> against mocking your whole model object for a form with lots of >> fields - >> those kind of 'broad' mocks can be very brittle to changes in your >> domain >> model. >> >> Can you try using stub_model instead? This creates an instance of >> your >> actual model class, but with a crippled database connection. You >> can then >> create an invalid model object and throw it to the view. Something >> like: >> >> assigns[:book] = stub_model(Book, :title => '') >> >> If your model is at all interesting, you might want to keep the >> attributes >> that make a valid Book somewhere: >> >> valid_book = { >> :title => "Test Book Title", >> :author => "Test Author" >> } >> assigns[:book] = stub_model(Book, valid_book.merge(:title => '')) >> >> I generally hide these behind a helper method, like >> >> def stub_book(attributes = {}) >> stub_model Book, { >> :title => "Test Book Title", >> :author => "Test Author" >> }.merge(attributes) >> end > > Why hide them behind a helper? Why not just only specify them in > examples where they are used? ie: > > it "should display the book title" do > @book.stub!(:title).and_return "The Scarlet Letter" > render ... > response.should include_text("The Scarlet Letter") > end Why hide them in a helper? because I don't want the noise of all the attributes needed to make a valid book in each test. @book = stub_book :title => "The Scarlet Letter" This is basically the same pattern people use things like factory_girl for, just using stub_model. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From zach.dennis at gmail.com Fri Feb 20 09:57:33 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Fri, 20 Feb 2009 09:57:33 -0500 Subject: [rspec-users] Mocking / stubbing errors for ActiveRecord In-Reply-To: <5424C9CE-2689-4139-80ED-DC45DCEA4AB9@mattwynne.net> References: <499DC716.3050904@gmx.de> <85d99afe0902191353m31bf8476xcd930f075d4d9099@mail.gmail.com> <5424C9CE-2689-4139-80ED-DC45DCEA4AB9@mattwynne.net> Message-ID: <85d99afe0902200657n6347e2b2k32efe5e6b32c5305@mail.gmail.com> On Fri, Feb 20, 2009 at 9:20 AM, Matt Wynne wrote: > > On 19 Feb 2009, at 21:53, Zach Dennis wrote: > >> On Thu, Feb 19, 2009 at 4:24 PM, Matt Wynne wrote: >>> >>> On 19 Feb 2009, at 20:54, Martin wrote: >>> >>>> Hi, >>>> >>>> I'm trying to test my views using rspec. I want to test my edit- and >>>> new-view also for the case an error occurs (something like "title can't >>>> be >>>> blank" and so on). >>>> Can someone point me please to an example where I can see how to mock my >>>> model and stub all methods needed for the view? >>> >>> I guess this isn't exactly what you want to hear, but I would counsel you >>> against mocking your whole model object for a form with lots of fields - >>> those kind of 'broad' mocks can be very brittle to changes in your domain >>> model. >>> >>> Can you try using stub_model instead? This creates an instance of your >>> actual model class, but with a crippled database connection. You can then >>> create an invalid model object and throw it to the view. Something like: >>> >>> assigns[:book] = stub_model(Book, :title => '') >>> >>> If your model is at all interesting, you might want to keep the >>> attributes >>> that make a valid Book somewhere: >>> >>> valid_book = { >>> :title => "Test Book Title", >>> :author => "Test Author" >>> } >>> assigns[:book] = stub_model(Book, valid_book.merge(:title => '')) >>> >>> I generally hide these behind a helper method, like >>> >>> def stub_book(attributes = {}) >>> stub_model Book, { >>> :title => "Test Book Title", >>> :author => "Test Author" >>> }.merge(attributes) >>> end >> >> Why hide them behind a helper? Why not just only specify them in >> examples where they are used? ie: >> >> it "should display the book title" do >> @book.stub!(:title).and_return "The Scarlet Letter" >> render ... >> response.should include_text("The Scarlet Letter") >> end > > Why hide them in a helper? because I don't want the noise of all the > attributes needed to make a valid book in each test. > > @book = stub_book :title => "The Scarlet Letter" > > This is basically the same pattern people use things like factory_girl for, > just using stub_model. Ah, I'm with you now. I thought you were eluding to doing the following (but I realize now that wasn't what you were getting at): assigns[:book] = stub_book render .. response.should include_text("The Scarlet Letter") -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From dchelimsky at gmail.com Fri Feb 20 10:56:11 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 20 Feb 2009 09:56:11 -0600 Subject: [rspec-users] Autotest won't pickup any tests In-Reply-To: <067EF338-8816-417E-963F-4BC157E18EFD@gmail.com> References: <067EF338-8816-417E-963F-4BC157E18EFD@gmail.com> Message-ID: <57c63afe0902200756q60c87e11wc8caa27bd8af3291@mail.gmail.com> On Fri, Feb 20, 2009 at 6:15 AM, Christian Hoeppner wrote: > Hey there, > > I've tried using Nick Sieger's "plugin" to have autotest run my tests for > gems and other non-rails stuff. However, it doesn't seem to match any tests > for any files. Not being sure what was wrong, I traced the execution of > RspecAutotest.run() and saw that tests_for_file() never got called. I also > replicated a tests_for_file() call by hand in irb, and it does match the > right spec file for any given implementation file. That lib is way outdated. RSpec now supports autotest directly with the autospec command. > > Here's what I use: > ZenTest (3.11.1), rspec (1.1.12), ruby, ruby 1.8.1 (2003-12-25) > [i686-darwin]. > > Sieger's file is the latest from svn, dated from 2007. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Fri Feb 20 12:09:14 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 20 Feb 2009 18:09:14 +0100 Subject: [rspec-users] Cucumber Feature Scenario critique Message-ID: <5f0f67d14c7eee172dc6db9a14be3ded@ruby-forum.com> When I initially began working with cucumber and developing features and steps from existing code I went through a process (prompted by the members of this group) of developing increasingly abstract (declarative?) wording for the feature scenario steps. Now, I am finally at the stage where I am using features to drive new code. I would appreciate very much some advice on how to word a design desire into a feature scenario. The example I have chosen is that of a client. In our design and requirements discussions we have arrived at the idea of "client" being that of an ephemeral "role" assigned to a durable "entity". A client role is thus conceived as episodic in nature. An entity can be a client for a period of years, then dormant for a period (whether due to change in their business patterns or a departure to a competitive service) and then active again. For tax reasons it is important to know precisely when a client was active and when they were not. For business reasons it is important that dormant accounts be deactivated as soon as this state is detected and confirmed. It is however, vital that all previous history of activity not be disturbed by any changes in status and that all the cumulative history of a single legal entity be kept together. The questions I have relate to how best put this down as a set of features or scenarios within a feature or features. I am toying with the idea of a general, application wide, feature file (app.feature) that contains the barest statement of what each major component or element of the evolving application requires. Then, as the step definitions are expressed, the detailed features are arranged in hierarchy of files according to their anticipated nature (external component, model, controller, view, service or library so far). So to begin with, at the highest level I think something like this might serve: app.feature Feature: A Web Based Business Application for Transportation and Customs In Order To: Conduct Routine Business An: Authorized User Should: Securely Access the Web Application To: Reduce Costs #The work will be done anyway and the price won't change Scenario: The Application Has Authorized Users ... Scenario: The Application Has Entities ... Scenario: The Application Has Clients Given I have a user named "admin" And the user named "admin" authenticates And the user named "admin" is authorized to "add" "clients" When they visit the add new client page And they provide valid client data And they submit the new client Then they should see a new client added message The app.feature file will contain no further specifics respecting clients. To deal with these specifics I will later create a model/clients/client.feature file (or files) that will detail the implementation of that model. The step definitions given above will go into model/clients/step_definitions/client_steps.rb I think this approach will work but I really have no experience with organizing a large scale project around BDD. Any insight and experience that anyone can provide is greatly appreciated. As a supplemental issue: We use a project administration system (Redmine). Have any of you adopted practices with respect to the relationships between issue tickets and feature scenarios that you found useful? -- Posted via http://www.ruby-forum.com/. From pat.maddox at gmail.com Fri Feb 20 12:59:48 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Fri, 20 Feb 2009 09:59:48 -0800 Subject: [rspec-users] Mocking / stubbing errors for ActiveRecord In-Reply-To: <5424C9CE-2689-4139-80ED-DC45DCEA4AB9@mattwynne.net> References: <499DC716.3050904@gmx.de> <85d99afe0902191353m31bf8476xcd930f075d4d9099@mail.gmail.com> <5424C9CE-2689-4139-80ED-DC45DCEA4AB9@mattwynne.net> Message-ID: <2c7e61990902200959s214fd1b9wc82c9f8e048d4f2e@mail.gmail.com> On Fri, Feb 20, 2009 at 6:20 AM, Matt Wynne wrote: > > On 19 Feb 2009, at 21:53, Zach Dennis wrote: > >> On Thu, Feb 19, 2009 at 4:24 PM, Matt Wynne wrote: >>> >>> On 19 Feb 2009, at 20:54, Martin wrote: >>> >>>> Hi, >>>> >>>> I'm trying to test my views using rspec. I want to test my edit- and >>>> new-view also for the case an error occurs (something like "title can't >>>> be >>>> blank" and so on). >>>> Can someone point me please to an example where I can see how to mock my >>>> model and stub all methods needed for the view? >>> >>> I guess this isn't exactly what you want to hear, but I would counsel you >>> against mocking your whole model object for a form with lots of fields - >>> those kind of 'broad' mocks can be very brittle to changes in your domain >>> model. >>> >>> Can you try using stub_model instead? This creates an instance of your >>> actual model class, but with a crippled database connection. You can then >>> create an invalid model object and throw it to the view. Something like: >>> >>> assigns[:book] = stub_model(Book, :title => '') >>> >>> If your model is at all interesting, you might want to keep the >>> attributes >>> that make a valid Book somewhere: >>> >>> valid_book = { >>> :title => "Test Book Title", >>> :author => "Test Author" >>> } >>> assigns[:book] = stub_model(Book, valid_book.merge(:title => '')) >>> >>> I generally hide these behind a helper method, like >>> >>> def stub_book(attributes = {}) >>> stub_model Book, { >>> :title => "Test Book Title", >>> :author => "Test Author" >>> }.merge(attributes) >>> end >> >> Why hide them behind a helper? Why not just only specify them in >> examples where they are used? ie: >> >> it "should display the book title" do >> @book.stub!(:title).and_return "The Scarlet Letter" >> render ... >> response.should include_text("The Scarlet Letter") >> end > > Why hide them in a helper? because I don't want the noise of all the > attributes needed to make a valid book in each test. Also so that when you change validations, you only have to change one part of test code instead of every test that uses that model. Pat From ben at benmabey.com Fri Feb 20 13:34:40 2009 From: ben at benmabey.com (Ben Mabey) Date: Fri, 20 Feb 2009 11:34:40 -0700 Subject: [rspec-users] [RSpec][OT] have autospec just run changed files Message-ID: <499EF7C0.20301@benmabey.com> Hello all, Is there a way to have autospec and/or RSpactor just run the specs for the files that have changed and not run the entire spec suite afterwards? If you start autospec with -f it will wait for a change but it will then run the entire suite after the individual one passes. The project that I am working on now has a spec suite that is too long for the normal autospec cycle. However, I like having that tight feedback loop for the files I touch. Any ideas? Thanks, Ben From lists at technomage.com Fri Feb 20 13:32:20 2009 From: lists at technomage.com (Michael Latta) Date: Fri, 20 Feb 2009 10:32:20 -0800 Subject: [rspec-users] Cucumber Feature Scenario critique In-Reply-To: <5f0f67d14c7eee172dc6db9a14be3ded@ruby-forum.com> References: <5f0f67d14c7eee172dc6db9a14be3ded@ruby-forum.com> Message-ID: <754D5764-3410-4D13-888E-B972DB36F198@technomage.com> I would suggest a different approach to organizing the features. In particular I would recommend the features be used to test implementation invariant aspects of the system. Our features are whole stack sequences that involve views, controllers, and models in almost every case. We test the "system" not the parts. In the ideal case you will specify the system up front so little should change from bug reports unless they are really a change in requirements. Requirements changes have a different workflow than implementation bugs. I would recommend you track that difference in your project management system. Keep an eye on how much changes after implementation to measure how good your requirements capture has been. Michael On Feb 20, 2009, at 9:09 AM, James Byrne wrote: > When I initially began working with cucumber and developing features > and > steps from existing code I went through a process (prompted by the > members of this group) of developing increasingly abstract > (declarative?) wording for the feature scenario steps. Now, I am > finally at the stage where I am using features to drive new code. I > would appreciate very much some advice on how to word a design desire > into a feature scenario. > > The example I have chosen is that of a client. In our design and > requirements discussions we have arrived at the idea of "client" being > that of an ephemeral "role" assigned to a durable "entity". A client > role is thus conceived as episodic in nature. An entity can be a > client > for a period of years, then dormant for a period (whether due to > change > in their business patterns or a departure to a competitive service) > and > then active again. > > For tax reasons it is important to know precisely when a client was > active and when they were not. For business reasons it is important > that dormant accounts be deactivated as soon as this state is detected > and confirmed. It is however, vital that all previous history of > activity not be disturbed by any changes in status and that all the > cumulative history of a single legal entity be kept together. > > The questions I have relate to how best put this down as a set of > features or scenarios within a feature or features. I am toying with > the > idea of a general, application wide, feature file (app.feature) that > contains the barest statement of what each major component or > element of > the evolving application requires. Then, as the step definitions are > expressed, the detailed features are arranged in hierarchy of files > according to their anticipated nature (external component, model, > controller, view, service or library so far). > > So to begin with, at the highest level I think something like this > might > serve: > > app.feature > Feature: A Web Based Business Application for Transportation and > Customs > In Order To: Conduct Routine Business > An: Authorized User > Should: Securely Access the Web Application > To: Reduce Costs #The work will be done anyway and the price won't > change > > Scenario: The Application Has Authorized Users > ... > > Scenario: The Application Has Entities > ... > > Scenario: The Application Has Clients > Given I have a user named "admin" > And the user named "admin" authenticates > And the user named "admin" is authorized to "add" "clients" > When they visit the add new client page > And they provide valid client data > And they submit the new client > Then they should see a new client added message > > The app.feature file will contain no further specifics respecting > clients. To deal with these specifics I will later create a > model/clients/client.feature file (or files) that will detail the > implementation of that model. The step definitions given above will > go > into model/clients/step_definitions/client_steps.rb > > I think this approach will work but I really have no experience with > organizing a large scale project around BDD. Any insight and > experience > that anyone can provide is greatly appreciated. > > As a supplemental issue: We use a project administration system > (Redmine). Have any of you adopted practices with respect to the > relationships between issue tickets and feature scenarios that you > found > useful? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ashley.moran at patchspace.co.uk Fri Feb 20 14:20:07 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Fri, 20 Feb 2009 19:20:07 +0000 Subject: [rspec-users] [~OT] Celerity LinkedIn group Message-ID: <1C65198C-FF9B-4637-A4DF-B66D1D5932FA@patchspace.co.uk> Hi all Marginally on-topic... as part of my compulsion to create LinkedIn groups, I made a group[1] for Celerity[2] today. Thought I would announce here, as there are quite possibly more Celerity users here than on the official Celerity mailing list! And if you haven't tried Celerity with Cucumber, you should! It rocks =) Ashley [1] http://www.linkedin.com/e/vgh/1814903/eml-grp-sub/ [2] http://celerity.rubyforge.org/ -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ http://twitter.com/ashleymoran From peter.a.jaros at gmail.com Fri Feb 20 14:33:16 2009 From: peter.a.jaros at gmail.com (Peter Jaros) Date: Fri, 20 Feb 2009 14:33:16 -0500 Subject: [rspec-users] [RSpec][OT] have autospec just run changed files In-Reply-To: <499EF7C0.20301@benmabey.com> References: <499EF7C0.20301@benmabey.com> Message-ID: <937d9d810902201133k76ab868x64e6cb36b1723ee@mail.gmail.com> I don't know about RSpactor, but autospec will keep track of failing specs and re-run them along with changed specs and specs for changed files. It won't run the entire suite until everything has passed. You could temporarily add a dummy example somewhere in your suite which always fails. That way autospec will never think it's ready to run the whole suite. Other than that, I can't think of a way to do it short of writing your own autospec style and overriding the #run algorithm. Peeja On Fri, Feb 20, 2009 at 1:34 PM, Ben Mabey wrote: > Hello all, > Is there a way to have autospec and/or RSpactor just run the specs for the > files that have changed and not run the entire spec suite afterwards? If > you start autospec with -f it will wait for a change but it will then run > the entire suite after the individual one passes. The project that I am > working on now has a spec suite that is too long for the normal autospec > cycle. However, I like having that tight feedback loop for the files I > touch. Any ideas? > > Thanks, > Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From zach.dennis at gmail.com Fri Feb 20 14:56:01 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Fri, 20 Feb 2009 14:56:01 -0500 Subject: [rspec-users] Mocking / stubbing errors for ActiveRecord In-Reply-To: <2c7e61990902200959s214fd1b9wc82c9f8e048d4f2e@mail.gmail.com> References: <499DC716.3050904@gmx.de> <85d99afe0902191353m31bf8476xcd930f075d4d9099@mail.gmail.com> <5424C9CE-2689-4139-80ED-DC45DCEA4AB9@mattwynne.net> <2c7e61990902200959s214fd1b9wc82c9f8e048d4f2e@mail.gmail.com> Message-ID: <85d99afe0902201156u451661eblb85415be45dd66bb@mail.gmail.com> On Fri, Feb 20, 2009 at 12:59 PM, Pat Maddox wrote: > On Fri, Feb 20, 2009 at 6:20 AM, Matt Wynne wrote: >> >> On 19 Feb 2009, at 21:53, Zach Dennis wrote: >> >>> On Thu, Feb 19, 2009 at 4:24 PM, Matt Wynne wrote: >>>> >>>> On 19 Feb 2009, at 20:54, Martin wrote: >>>> >>>>> Hi, >>>>> >>>>> I'm trying to test my views using rspec. I want to test my edit- and >>>>> new-view also for the case an error occurs (something like "title can't >>>>> be >>>>> blank" and so on). >>>>> Can someone point me please to an example where I can see how to mock my >>>>> model and stub all methods needed for the view? >>>> >>>> I guess this isn't exactly what you want to hear, but I would counsel you >>>> against mocking your whole model object for a form with lots of fields - >>>> those kind of 'broad' mocks can be very brittle to changes in your domain >>>> model. >>>> >>>> Can you try using stub_model instead? This creates an instance of your >>>> actual model class, but with a crippled database connection. You can then >>>> create an invalid model object and throw it to the view. Something like: >>>> >>>> assigns[:book] = stub_model(Book, :title => '') >>>> >>>> If your model is at all interesting, you might want to keep the >>>> attributes >>>> that make a valid Book somewhere: >>>> >>>> valid_book = { >>>> :title => "Test Book Title", >>>> :author => "Test Author" >>>> } >>>> assigns[:book] = stub_model(Book, valid_book.merge(:title => '')) >>>> >>>> I generally hide these behind a helper method, like >>>> >>>> def stub_book(attributes = {}) >>>> stub_model Book, { >>>> :title => "Test Book Title", >>>> :author => "Test Author" >>>> }.merge(attributes) >>>> end >>> >>> Why hide them behind a helper? Why not just only specify them in >>> examples where they are used? ie: >>> >>> it "should display the book title" do >>> @book.stub!(:title).and_return "The Scarlet Letter" >>> render ... >>> response.should include_text("The Scarlet Letter") >>> end >> >> Why hide them in a helper? because I don't want the noise of all the >> attributes needed to make a valid book in each test. > > Also so that when you change validations, you only have to change one > part of test code instead of every test that uses that model. > Right, it wasn't what I thought Matt was getting at. I thought he was specifically referring to hiding things pertinent in a view spec behind a helper. But that turned out to not be the case, -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From lists at ruby-forum.com Fri Feb 20 15:13:16 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 20 Feb 2009 21:13:16 +0100 Subject: [rspec-users] specifying which button webrat should press In-Reply-To: References: <3a2f55b7586243049a0672974fabbaba@ruby-forum.com> <8d961d900811192106g6dc93a0fq5ef890c1ac9d4724@mail.gmail.com> <88fd8ddc0811200544j749b7f8fm957fb374569243c0@mail.gmail.com> Message-ID: Given this:

If I want webrat to select on the ccs id (#submit_commit_client) rather than the value (Create) how do I pass this to click_button? I have tried this: click_button("#submit_commit_client") Which gives this error: Could not find button "#submit_commit_client" (Webrat::NotFoundError) /usr/lib64/ruby/gems/1.8/gems/webrat-0.4.1/lib/webrat/core/locators/locator.rb:14:in `locate!' -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Fri Feb 20 15:24:34 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Fri, 20 Feb 2009 15:24:34 -0500 Subject: [rspec-users] specifying which button webrat should press In-Reply-To: References: <3a2f55b7586243049a0672974fabbaba@ruby-forum.com> <8d961d900811192106g6dc93a0fq5ef890c1ac9d4724@mail.gmail.com> <88fd8ddc0811200544j749b7f8fm957fb374569243c0@mail.gmail.com> Message-ID: <85d99afe0902201224h5948738anb13016780d1c71d7@mail.gmail.com> On Fri, Feb 20, 2009 at 3:13 PM, James Byrne wrote: > Given this: > >
> >

> value="Create" /> >

> >
> > If I want webrat to select on the ccs id (#submit_commit_client) rather > than the value (Create) how do I pass this to click_button? > > I have tried this: > > click_button("#submit_commit_client") > Can you use the following or do you need to use an id for other reason? click_button "Create" > Which gives this error: > > Could not find button "#submit_commit_client" (Webrat::NotFoundError) > > /usr/lib64/ruby/gems/1.8/gems/webrat-0.4.1/lib/webrat/core/locators/locator.rb:14:in > `locate!' > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From sfeley at gmail.com Fri Feb 20 15:33:12 2009 From: sfeley at gmail.com (Stephen Eley) Date: Fri, 20 Feb 2009 15:33:12 -0500 Subject: [rspec-users] [RSpec][OT] have autospec just run changed files In-Reply-To: <937d9d810902201133k76ab868x64e6cb36b1723ee@mail.gmail.com> References: <499EF7C0.20301@benmabey.com> <937d9d810902201133k76ab868x64e6cb36b1723ee@mail.gmail.com> Message-ID: <1fb4df0902201233j2691cc97iba777ecc3ce78906@mail.gmail.com> On Fri, Feb 20, 2009 at 2:33 PM, Peter Jaros wrote: > > Other than that, I can't think of a way to do it short of writing your > own autospec style and overriding the #run algorithm. Which is almost exactly what I was about to suggest. >8-> Only you don't have to override #run, you can just fake it out at the point where it reruns all tests and skip that part. 1.) Make an autotest directory in your project. 2.) Add a file 'discover.rb' and include the following: Autotest.add_discovery { "mabey" } # Or whatever you want to call your specialization 3.) If you're using Rails and RSpec, you then need to add a file 'mabey_rails_rspec.rb'. If only RSpec, just 'mabey_rspec.rb'. If you're using Merb and RSpec, it needs to be 'mabey_merb_rspec.rb'. You get the point. Autotest's class and file discovery is just wonky. In it: class Autotest::MabeyRailsRspec < Autotest::RailsRspec # Or whatever your appropriate chain is def rerun_all_tests reset end end I figured that out from reading the Autotest code a while back and figuring out how to fix problems with Merb, RSpec and Cucumber. My conclusion is that Autotest is *sort of* elegant in its own way, but that way appears to be based on the standards of someone high on a cocktail of LSD and laudanum. It uses convention over configuration...sort of...except that you have to configure the conventions first. And then too much is hardcoded, and its inheritance and class-naming structure means you have to predict every possible combination of frameworks in advance. Someone needs to either hit it with the design pattern stick or write a new one. Maybe I will, the next time I manage to take a couple days off. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From lists at ruby-forum.com Fri Feb 20 15:46:22 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 20 Feb 2009 21:46:22 +0100 Subject: [rspec-users] Cucumber Feature Scenario critique In-Reply-To: <754D5764-3410-4D13-888E-B972DB36F198@technomage.com> References: <5f0f67d14c7eee172dc6db9a14be3ded@ruby-forum.com> <754D5764-3410-4D13-888E-B972DB36F198@technomage.com> Message-ID: <42495fa2279e8a645b94c98a603ee8f3@ruby-forum.com> Michael Latta wrote: > I would suggest a different approach to organizing the features. ... > Requirements changes have a different workflow than implementation > bugs. I would recommend you track that difference in your project > management system. Keep an eye on how much changes after > implementation to measure how good your requirements capture has been. > > Michael This is probably another case where I simply have not yet established in myself a sensible mental framework for working with BDD. Bear with me as I struggle through this adjustment. My apprehension so far is that features are intended to drive out the design requirements by explicitly stating concrete examples of what the client considers desirable. The idea of a contract between developer and client arises from the mutual agreement on functional expression as given in the feature scenarios. Definition steps, on the other hand, are the purview of the design/development team. They can take any reasonable form so long as they: 1. test the functionality of the implementation in a meaningful way 2. meet the requirements of the scenario Unit tests are the purview of the implementers and are tied to their respective code modules. My concern arises from a desire to establish how I should organize the features in relation to one another. Given my understanding respecting features I proceeded from the belief that one could arbitrarily start anywhere in the system design. Features would allow one to elaborate both up and down in detail as appropriate for the stage of the project and the area of immediate concern. As a practical matter it appears to me that the logical flow is Authentication/Authorization, administrative functions relating to record maintenance, algorithmic user applications, report generation, utilities, and finally loose ends. The application can be sliced so that all or most of these issues are dealt with within one specific aspect before tackling another. We are using Redmine to administer the project so milestones, issue tracking and such are kept in there. However, I have acquired this notion of functional decomposition relating to features. As i see it the basic gross requirements of the system (there will be clients, there will be invoices, etc.) are expressed as scenarios in a feature file somewhere. Then as more detail is driven out more features are inserted into the composition tree as appropriate. Is this completely at odds with what I should be doing? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Feb 20 15:50:44 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 20 Feb 2009 21:50:44 +0100 Subject: [rspec-users] specifying which button webrat should press In-Reply-To: <85d99afe0902201224h5948738anb13016780d1c71d7@mail.gmail.com> References: <3a2f55b7586243049a0672974fabbaba@ruby-forum.com> <8d961d900811192106g6dc93a0fq5ef890c1ac9d4724@mail.gmail.com> <88fd8ddc0811200544j749b7f8fm957fb374569243c0@mail.gmail.com> <85d99afe0902201224h5948738anb13016780d1c71d7@mail.gmail.com> Message-ID: Zach Dennis wrote: > > Can you use the following or do you need to use an id for other reason? > > click_button "Create" > That is how I am doing the check now. I am simply investigating whether another means is available to me. At the back of my mind is the idea that it is the presence of the function and not the form of the label that is important. By adding an id to the input tag and selecting on that then whatever the button itself is labeled as becomes unimportant. -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Fri Feb 20 16:03:48 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Fri, 20 Feb 2009 16:03:48 -0500 Subject: [rspec-users] specifying which button webrat should press In-Reply-To: References: <3a2f55b7586243049a0672974fabbaba@ruby-forum.com> <8d961d900811192106g6dc93a0fq5ef890c1ac9d4724@mail.gmail.com> <88fd8ddc0811200544j749b7f8fm957fb374569243c0@mail.gmail.com> <85d99afe0902201224h5948738anb13016780d1c71d7@mail.gmail.com> Message-ID: <85d99afe0902201303i2cd24303s614d6d830fd28cd6@mail.gmail.com> On Fri, Feb 20, 2009 at 3:50 PM, James Byrne wrote: > Zach Dennis wrote: > >> >> Can you use the following or do you need to use an id for other reason? >> >> click_button "Create" >> > > That is how I am doing the check now. I am simply investigating whether > another means is available to me. You should be able to click the button by id, by not using a CSS selector. ie: click_button "submit_commit_client" > At the back of my mind is the idea > that it is the presence of the function and not the form of the label > that is important. By adding an id to the input tag and selecting on > that then whatever the button itself is labeled as becomes unimportant. -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From lists at ruby-forum.com Fri Feb 20 16:28:34 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 20 Feb 2009 22:28:34 +0100 Subject: [rspec-users] specifying which button webrat should press In-Reply-To: <85d99afe0902201303i2cd24303s614d6d830fd28cd6@mail.gmail.com> References: <3a2f55b7586243049a0672974fabbaba@ruby-forum.com> <8d961d900811192106g6dc93a0fq5ef890c1ac9d4724@mail.gmail.com> <88fd8ddc0811200544j749b7f8fm957fb374569243c0@mail.gmail.com> <85d99afe0902201224h5948738anb13016780d1c71d7@mail.gmail.com> <85d99afe0902201303i2cd24303s614d6d830fd28cd6@mail.gmail.com> Message-ID: <6a89561e244e69d663bf7220d5b4a3d1@ruby-forum.com> Zach Dennis wrote: > > You should be able to click the button by id, by not using a CSS > selector. ie: > > click_button "submit_commit_client" > You are right. That works. Thank you. Regards, -- Posted via http://www.ruby-forum.com/. From fkchang2000 at yahoo.com Fri Feb 20 16:41:27 2009 From: fkchang2000 at yahoo.com (Forrest Chang) Date: Fri, 20 Feb 2009 13:41:27 -0800 (PST) Subject: [rspec-users] Using cucumber profiles with rake task References: Message-ID: <249741.2675.qm@web82808.mail.mud.yahoo.com> ----- Original Message ---- > Message: 4 > Date: Tue, 10 Feb 2009 10:43:35 -0500 > From: Zach Dennis > The Cucumber rake task doesn't support profiles very well. There is a > ticket for this: > > http://rspec.lighthouseapp.com/projects/16211/tickets/187-rake-task-support-cucumberyml-profiles > > On the ticket Ben Mabey provided his current solution, which is to > clear out the feature list: > > Cucumber::Rake::Task.new(:selenium) do |t| > ENV['WEBRAT'] = 'selenium' > t.cucumber_opts = "--profile selenium" > t.feature_list = [] > end > I just did this sort of thing, you also need to set t.step_list = [], else the rake task will expand all steps in the features directories as well. Forrest From sfeley at gmail.com Fri Feb 20 23:02:10 2009 From: sfeley at gmail.com (Stephen Eley) Date: Fri, 20 Feb 2009 23:02:10 -0500 Subject: [rspec-users] Cucumber Feature Scenario critique In-Reply-To: <42495fa2279e8a645b94c98a603ee8f3@ruby-forum.com> References: <5f0f67d14c7eee172dc6db9a14be3ded@ruby-forum.com> <754D5764-3410-4D13-888E-B972DB36F198@technomage.com> <42495fa2279e8a645b94c98a603ee8f3@ruby-forum.com> Message-ID: <1fb4df0902202002p4c4bbd19v1874f753878a0b82@mail.gmail.com> On Fri, Feb 20, 2009 at 3:46 PM, James Byrne wrote: > > As a practical matter it appears to me that the logical flow is > Authentication/Authorization, administrative functions relating to > record maintenance, algorithmic user applications, report generation, > utilities, and finally loose ends. The application can be sliced so > that all or most of these issues are dealt with within one specific > aspect before tackling another. > [ . . . ] > > Is this completely at odds with what I should be doing? Well... In my opinion, yes and no. I personally have my doubts about the 'waterfall' chain of serial projects you're talking about here. "We will do authorization. Then we will do admin screens. Then we will..." For one thing it's not very agile; what you learn when you start getting requirements for reporting will surely change what you thought was 'complete' earlier. And it seems harder to sell and keep the client engaged because the sexy stuff, the business value the client *cares* about, doesn't happen until somewhere in the middle. It's my experience that the most effective projects begin early with things you can *show.* You can't really show off authorization. It's visible, but it doesn't excite people. You need to have some basic stuff in for it before you can open it up to the public, but it's not necessarily Square One, and treating it like it is might overemphasize its importance. (And I say this as someone who recently spent a couple of days designing a hierarchical polymorphic authorization framework from hell [http://tinyurl.com/d6w4t8] so don't think I'm discounting it completely.) So I'd personally worry less about getting all your administrative ducks in a row before you start to do anything interesting, and instead _start_ with whatever drives the most value to your company and then build the support framework around it only when it's needed. You might find when you do that that you need fewer struts and pins and guywires than you thought you did. ...But that has nothing to do with RSpec and very little to do with BDD, except in a very general 'start with the behavior you *care* about the most' sense. Odds aren't high that the thing you care about the most in the application is logging in. So spec that out later and start with something more interesting. You'll hit the ground running. Otherwise, it all looks fine. >8-> -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From lists at ruby-forum.com Fri Feb 20 23:33:06 2009 From: lists at ruby-forum.com (James Byrne) Date: Sat, 21 Feb 2009 05:33:06 +0100 Subject: [rspec-users] Cucumber Feature Scenario critique In-Reply-To: <1fb4df0902202002p4c4bbd19v1874f753878a0b82@mail.gmail.com> References: <5f0f67d14c7eee172dc6db9a14be3ded@ruby-forum.com> <754D5764-3410-4D13-888E-B972DB36F198@technomage.com> <42495fa2279e8a645b94c98a603ee8f3@ruby-forum.com> <1fb4df0902202002p4c4bbd19v1874f753878a0b82@mail.gmail.com> Message-ID: Stephen Eley wrote: > > Well... In my opinion, yes and no. I personally have my doubts about > the 'waterfall' chain of serial projects you're talking about here. > "We will do authorization. Then we will do admin screens. Then we > will..." Perhaps I expressed myself poorly, or perhaps I am missing something fundamental in your commentary. I did not mean to imply that an authorization system had to be "finished", and then record maintenance system "done", before getting into the interesting bits. I only meant that having tried to start in the middle, with the interesting bits insofar as the client is concerned, I quickly discovered that some minimal provision for authentication and record maintenance seemed a prerequisite to support work on the middle. For some reason I seem to have an aversion to using fixtures for this purpose and prefer some sort of interactive UI, however primitive. For instance this is my authorization implementation: def authorized?(auth_request={}) #myrole = auth_request[:role] #myctlr = auth_request[:controller] #myactn = auth_request[:action] return true if self.administrator return false end I did not spend very much time or effort on this but it seemed best to provide the authorization interface when working on user facing components. The future elaboration of the authorization system will nonetheless still present the same interface to the rest of the system, or so I intend. What I am grasping at understanding is how elaborate the feature files should be and how the interrelationship between features are best managed or expressed. -- Posted via http://www.ruby-forum.com/. From mark at mwilden.com Fri Feb 20 23:32:56 2009 From: mark at mwilden.com (Mark Wilden) Date: Fri, 20 Feb 2009 20:32:56 -0800 Subject: [rspec-users] Cucumber Feature Scenario critique In-Reply-To: <1fb4df0902202002p4c4bbd19v1874f753878a0b82@mail.gmail.com> References: <5f0f67d14c7eee172dc6db9a14be3ded@ruby-forum.com> <754D5764-3410-4D13-888E-B972DB36F198@technomage.com> <42495fa2279e8a645b94c98a603ee8f3@ruby-forum.com> <1fb4df0902202002p4c4bbd19v1874f753878a0b82@mail.gmail.com> Message-ID: <3c30da400902202032h64502609yf60fb9f5daafd5ce@mail.gmail.com> On Fri, Feb 20, 2009 at 8:02 PM, Stephen Eley wrote: > > You can't really show off authorization. It's visible, but it doesn't > excite people. You need to have some basic stuff in for it before you > can open it up to the public, but it's not necessarily Square One, and > treating it like it is might overemphasize its importance. Agreed. I've seen projects that weren't public yet, didn't do anything useful, yet had a full authorization model - which did nothing but annoy new developers. ///ark From ben at benmabey.com Sat Feb 21 01:33:46 2009 From: ben at benmabey.com (Ben Mabey) Date: Fri, 20 Feb 2009 23:33:46 -0700 Subject: [rspec-users] [RSpec][OT] have autospec just run changed files In-Reply-To: <1fb4df0902201233j2691cc97iba777ecc3ce78906@mail.gmail.com> References: <499EF7C0.20301@benmabey.com> <937d9d810902201133k76ab868x64e6cb36b1723ee@mail.gmail.com> <1fb4df0902201233j2691cc97iba777ecc3ce78906@mail.gmail.com> Message-ID: <499FA04A.1020308@benmabey.com> Stephen Eley wrote: > On Fri, Feb 20, 2009 at 2:33 PM, Peter Jaros wrote: > >> Other than that, I can't think of a way to do it short of writing your >> own autospec style and overriding the #run algorithm. >> > > Which is almost exactly what I was about to suggest. >8-> Only you > don't have to override #run, you can just fake it out at the point > where it reruns all tests and skip that part. > > 1.) Make an autotest directory in your project. > 2.) Add a file 'discover.rb' and include the following: > Autotest.add_discovery { "mabey" } # Or whatever you want to call > your specialization > 3.) If you're using Rails and RSpec, you then need to add a file > 'mabey_rails_rspec.rb'. If only RSpec, just 'mabey_rspec.rb'. If > you're using Merb and RSpec, it needs to be 'mabey_merb_rspec.rb'. > You get the point. Autotest's class and file discovery is just wonky. > In it: > > class Autotest::MabeyRailsRspec < Autotest::RailsRspec # Or > whatever your appropriate chain is > def rerun_all_tests > reset > end > end > > I figured that out from reading the Autotest code a while back and > figuring out how to fix problems with Merb, RSpec and Cucumber. My > conclusion is that Autotest is *sort of* elegant in its own way, but > that way appears to be based on the standards of someone high on a > cocktail of LSD and laudanum. It uses convention over > configuration...sort of...except that you have to configure the > conventions first. And then too much is hardcoded, and its > inheritance and class-naming structure means you have to predict every > possible combination of frameworks in advance. > > Someone needs to either hit it with the design pattern stick or write > a new one. Maybe I will, the next time I manage to take a couple days > off. > > > > Thanks a lot! I couldn't get your exact way to work so I ended up monkey patching Autotest with your #rerun_all_tests in my .autotest file. So far it is working great. Thanks again! -Ben From listaccount at e-tobi.net Sat Feb 21 06:31:05 2009 From: listaccount at e-tobi.net (Tobi) Date: Sat, 21 Feb 2009 12:31:05 +0100 Subject: [rspec-users] Mocking base class methods Message-ID: <499FE5F9.3050905@e-tobi.net> Hi! I need to write some wrapper classes, that derive from SWIG generated proxy classes for some C/C++ extensions. The Ruby wrapper classes need to do a lot of 'super' calls to the base classes generated by SWIG. The question is: Is there any way to make RSpec mock a base class and record/verify that certain methods on a base class are called? As long as the methods in the derived class have different names this is no problem, but otherwise it doesn't seem to be possible - at least not with RSpec's mocking/stubbing facilities, does it? I see other ways to do this, like wrapping an instance of the Swig class instead of deriving from it or writing some custom mocking code that fakes the base class e.g. with define_method, but I'm especially asking if this is possible with RSpec. thx, Tobias module Swig class Base def initialize(arg) end def do_something(arg) end end end module Wrapper class Derived << Swig::Base def initialize(arg) super(arg) yield(self) if block_given? end def do_something(arg) do_something(arg) # additional behaviour here end end end describe Wrapper::Derived do it 'should initialize the base class with the same argument' do # No idea, how to mock Base.initialize() here end it 'should do something with the base class when doing something' do # No idea, how to mock Base.do_something() here end end From html-kurs at gmx.de Sat Feb 21 07:04:36 2009 From: html-kurs at gmx.de (Martin) Date: Sat, 21 Feb 2009 13:04:36 +0100 Subject: [rspec-users] Mocking / stubbing errors for ActiveRecord In-Reply-To: References: <499DC716.3050904@gmx.de> Message-ID: <499FEDD4.7030508@gmx.de> Hello alltogether, thanks for your help. A mixture of stub_model and .errors.stub!() helped me to solve my problem. I also stumbled across the right arguments of have_tag. I thought it's similar to assert_select as the docs said. But it isn't. I found http://rubypond.com/articles/2008/03/31/using-rspec-have_tag/ which is a nice introduction to it. Thanks again, Martin From zuperinfinite at gmail.com Sat Feb 21 10:28:07 2009 From: zuperinfinite at gmail.com (Bart Zonneveld) Date: Sat, 21 Feb 2009 16:28:07 +0100 Subject: [rspec-users] [OT] Googled for 'cucumber page caching' Message-ID: ...and found this as 4th result: http://www.cafepress.com/foodparadise/4708787 cheers, bartz From phlip2005 at gmail.com Sat Feb 21 11:44:17 2009 From: phlip2005 at gmail.com (Phlip) Date: Sat, 21 Feb 2009 08:44:17 -0800 Subject: [rspec-users] [OT] Googled for 'cucumber page caching' In-Reply-To: References: Message-ID: Bart Zonneveld wrote: > ...and found this as 4th result: > http://www.cafepress.com/foodparadise/4708787 I have a husband named Dean Wormer at Faber. Still want to show me your cucumber? -- Marion Wormer From zach.dennis at gmail.com Sat Feb 21 14:48:21 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Sat, 21 Feb 2009 14:48:21 -0500 Subject: [rspec-users] Mocking base class methods In-Reply-To: <499FE5F9.3050905@e-tobi.net> References: <499FE5F9.3050905@e-tobi.net> Message-ID: <85d99afe0902211148p585d5e5cx283232b250f2e8b4@mail.gmail.com> On Sat, Feb 21, 2009 at 6:31 AM, Tobi wrote: > Hi! > > I need to write some wrapper classes, that derive from SWIG generated > proxy classes for some C/C++ extensions. > > The Ruby wrapper classes need to do a lot of 'super' calls to the base > classes generated by SWIG. > > The question is: Is there any way to make RSpec mock a base class and > record/verify that certain methods on a base class are called? > > As long as the methods in the derived class have different names this is > no problem, but otherwise it doesn't seem to be possible - at least not > with RSpec's mocking/stubbing facilities, does it? > > I see other ways to do this, like wrapping an instance of the Swig class > instead of deriving from it or writing some custom mocking code that fakes > the base class e.g. with define_method, but I'm especially asking if this > is possible with RSpec. +1 to composition over inheritance here. Mocking at different layers of an inheritance hierarchy sounds like trouble and screams to pull that thing apart. Composition will allow you to separate an inheritance hierarchy (if you do need one) from the swig base classes, and it provides a clean separation between the swig stuff and your application stuff. > > thx, > > Tobias > > module Swig > class Base > def initialize(arg) > end > > def do_something(arg) > end > end > end > > module Wrapper > class Derived << Swig::Base > def initialize(arg) > super(arg) > yield(self) if block_given? > end > > def do_something(arg) > do_something(arg) > # additional behaviour here > end > end > end > > describe Wrapper::Derived do > it 'should initialize the base class with the same argument' do > # No idea, how to mock Base.initialize() here > end > > it 'should do something with the base class when doing something' do > # No idea, how to mock Base.do_something() here > 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 listaccount at e-tobi.net Sat Feb 21 16:24:06 2009 From: listaccount at e-tobi.net (Tobi) Date: Sat, 21 Feb 2009 22:24:06 +0100 Subject: [rspec-users] Mocking base class methods In-Reply-To: <85d99afe0902211148p585d5e5cx283232b250f2e8b4@mail.gmail.com> References: <499FE5F9.3050905@e-tobi.net> <85d99afe0902211148p585d5e5cx283232b250f2e8b4@mail.gmail.com> Message-ID: <49A070F6.2060107@e-tobi.net> Zach Dennis wrote: > +1 to composition over inheritance here. Mocking at different layers > of an inheritance hierarchy sounds like trouble and screams to pull > that thing apart. Good point! I've already tried the composition approach. It solves the testabilitiy problems, but it doesn't feel right in this case. Inheritance seems to be the more natural approach. The C++ application will call virtual methods on the base class which should be overriden in a derived class. So it seems to make sense to have the same inheritance tree in the Ruby counter parts. If I would use composition, I would at least need to dynamically extend the referenced base class so I can override some of the methods that are the counter parts of the virtual C++ methods. And I would need to expose the referenced class to the C++ code. I've finally found a way to kinda mock the base class in some way: module BaseClassMock attr_accessor :base def self.included(klass) class << klass @@base_class = Object.new def base_class return @@base_class end end end def initialize(*args) @@base_class.new(*args) if @@base_class.respond_to?(:new) @base = Object.new end def method_missing(symbol, *args) @base.send(symbol, *args) end end Any base class (Swig classes in my case) should then be declared for RSpec like: module Swig class Base; include BaseClassMock; end end And in the specs I can then do: Derived.base_class.should_receive(:new).with('something') d = Derived.new('something') or: d = Derived.new d.base.should_receive(:do_something) d.do_something Tobias From mark at mwilden.com Sat Feb 21 20:29:55 2009 From: mark at mwilden.com (Mark Wilden) Date: Sat, 21 Feb 2009 17:29:55 -0800 Subject: [rspec-users] [Cucumber] host! Message-ID: <3c30da400902211729x4f569a68l29bcd6c7d0fbdf2d@mail.gmail.com> I'm trying to set a specific host that all my Cucumber steps should use. Putting 'host! "beta.rupture.local"' in Before in env.rb doesn't produce any errors, but it doesn't seem to be making the next request use that host, either. If I explicitly create a step whose definition includes 'host! "beta.rupture.local"' then the next request does use that host. But I don't want to have to include this step in every feature. ///ark From aslak.hellesoy at gmail.com Sun Feb 22 05:03:34 2009 From: aslak.hellesoy at gmail.com (=?utf-8?Q?Aslak_Helles=C3=B8y?=) Date: Sun, 22 Feb 2009 11:03:34 +0100 Subject: [rspec-users] [Cucumber] host! In-Reply-To: <3c30da400902211729x4f569a68l29bcd6c7d0fbdf2d@mail.gmail.com> References: <3c30da400902211729x4f569a68l29bcd6c7d0fbdf2d@mail.gmail.com> Message-ID: Den 22. feb.. 2009 kl. 02.29 skrev Mark Wilden : > I'm trying to set a specific host that all my Cucumber steps should > use. Putting 'host! "beta.rupture.local"' in Before in env.rb doesn't > produce any errors, but it doesn't seem to be making the next request > use that host, either. > > If I explicitly create a step whose definition includes 'host! > "beta.rupture.local"' then the next request does use that host. But I > don't want to have to include this step in every feature. > Please submit a bug report. Aslak > ///ark > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Sun Feb 22 05:23:57 2009 From: lists at ruby-forum.com (Kaleem Ullah) Date: Sun, 22 Feb 2009 11:23:57 +0100 Subject: [rspec-users] Culerity Error while running feature. Message-ID: Hi All, I need your guide on an issue. My Environment: Window xp , Rails 2.2.2, Rspec-rails 1.1.11, Rspec 1.1.11, Cucmber , Webrat,Culerity I installed the jruby, sets its path in environment. It shows me Version of jruby also. Now the problem is when before installing langalex-culerity(http://github.com/langalex/culerity/tree/master) my cucumber and rspec are working fine. Now i have to test my javascript and ajax and i installed cularity. When i run "rake features". it gives me this error. Scenario: Log in # features/manage_logins.feature:5 C:/Documents and Settings/Administrator/My Documents/NetBeansProjects/1.4/vendor/gems/langalex-culerity-0.1.2/lib/culerity.rb :7:in `popen': Exec format error - jruby C:/Documents and Settings/Administrator/My Documents/NetBeansProjects/1.4/vendor/gem s/langalex-culerity-0.1.2/lib/culerity.rb (Errno::ENOEXEC) from C:/Documents and Settings/Administrator/My Documents/NetBeansProjects/1.4/vendor/gems/langalex-culerity-0.1.2/li b/culerity.rb:7:in `run_server' from ./features/step_definitions/common_celerity.rb:2:in `__cucumber_45721280' from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.1.16/bin/../lib/cucumber/core_ext/proc.rb:48:in `__send__' from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.1.16/bin/../lib/cucumber/core_ext/proc.rb:48:in `call_in' from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.1.16/bin/../lib/cucumber/executor.rb:86:in `execute_scenario' from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.1.16/bin/../lib/cucumber/executor.rb:86:in `each' from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.1.16/bin/../lib/cucumber/executor.rb:86:in `execute_scenario' from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.1.16/bin/../lib/cucumber/executor.rb:75:in `visit_scenario' ... 10 levels... from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.1.16/bin/../lib/cucumber/cli.rb:13:in `execute' from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.1.16/bin/cucumber:6 from c:/ruby/bin/cucumber:19:in `load' from c:/ruby/bin/cucumber:19 Thanks for your Help. Regards, Kaleem Ullah -- Posted via http://www.ruby-forum.com/. From joahking at gmail.com Sun Feb 22 07:42:35 2009 From: joahking at gmail.com (Joaquin Rivera Padron) Date: Sun, 22 Feb 2009 13:42:35 +0100 Subject: [rspec-users] Culerity Error while running feature. In-Reply-To: References: Message-ID: <8277b7f40902220442w7e94c5d1gab8f085d19728dd5@mail.gmail.com> hey Kaleem, I am myself no expert on w$ but the line throwing the error is def self.run_server IO.popen("jruby #{__FILE__}", 'r+') end are you able to run popen calls in w$ ? try your irb and see, if not maybe there's some w$ expert who can help hope that helps joaquin -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Sun Feb 22 10:34:37 2009 From: lists at ruby-forum.com (Jacob Radford) Date: Sun, 22 Feb 2009 16:34:37 +0100 Subject: [rspec-users] =?utf-8?q?=5BCucumber=2C_Webrat=5D_Error_backtraces?= =?utf-8?q?_shown_as_HTML_=09in_co?= In-Reply-To: <2C6FB417-AA52-4A94-8102-B8D611590CA9@mattwynne.net> References: <8d961d900902050300q54a19aefnaca7e763fe12f6af@mail.gmail.com> <2C6FB417-AA52-4A94-8102-B8D611590CA9@mattwynne.net> Message-ID: <4ce11b3f91545ac52bcdc75865442bc1@ruby-forum.com> > Rails' HTML error page. It comes up both in my browser (presumably > save_and_open_page doing its thing) and the same HTML is dumped to the > console. > > Can anyone else confirm that with latest Cucumber and Webrat they > *don't* get this behaviour? I do see this behavior and it is specifically a Webrat issue. I'm linking to the gist which I use to remedy it: http://gist.github.com/68497 Hope that helps. -- Posted via http://www.ruby-forum.com/. From joahking at gmail.com Sun Feb 22 10:37:17 2009 From: joahking at gmail.com (Joaquin Rivera Padron) Date: Sun, 22 Feb 2009 16:37:17 +0100 Subject: [rspec-users] Cucumber now runs Webrat and Celerity together Message-ID: <8277b7f40902220737r801a61bxb15140f2208fe8c1@mail.gmail.com> hey there, I have Cucumber running Webrat and Celerity (using culerity) together, check it out in the sample project: http://github.com/joahking/cukes/tree/masters It's a first try, but it runs. I get them by following a feature directory structure similar to the suggested in http://wiki.github.com/aslakhellesoy/cucumber/setting-up-selenium (also thanks to the hints Ben Mabbey pointed) by defining profiles for webrat and celerity you can run features with any of them: cucumber -p webrat and cucumber -p celerity only I don't seem to get Celerity browser to receive the ajax pushing from rails action (have tried browser.wait, also other recommendations from celerity github wiki, but it wont go), any help would be appreciated. cheers, joaquin -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Sun Feb 22 10:49:59 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 22 Feb 2009 16:49:59 +0100 Subject: [rspec-users] Culerity Error while running feature. In-Reply-To: <8277b7f40902220442w7e94c5d1gab8f085d19728dd5@mail.gmail.com> References: <8277b7f40902220442w7e94c5d1gab8f085d19728dd5@mail.gmail.com> Message-ID: <8d961d900902220749o6885037kf8b848098f5a50f@mail.gmail.com> On Sun, Feb 22, 2009 at 1:42 PM, Joaquin Rivera Padron wrote: > hey Kaleem, > I am myself no expert on w$ but the line throwing the error is > def self.run_server > IO.popen("jruby #{__FILE__}", 'r+') When forking a new ruby interpreter, always use rbconfig: require 'rbconfig' ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']) IO.popen("#{ruby} #{__FILE__}", 'r+') If you don't, you might end up running a different ruby than the one you want. Aslak > end > are you able to run popen calls in w$ ? try your irb and see, if not maybe > there's some w$ expert who can help > > hope that helps > joaquin > > > > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From dchelimsky at gmail.com Sun Feb 22 11:10:35 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 22 Feb 2009 10:10:35 -0600 Subject: [rspec-users] [ANN] rspec-1.2 release candidate In-Reply-To: <47e4b956d5e2a4ffc7eab7f43602575d@ruby-forum.com> References: <57c63afe0902182256h37f6449exc29e03cf1275d804@mail.gmail.com> <31D30E37-CF11-4541-B3E4-20C5068AEFB4@wincent.com> <57c63afe0902190558m14107313j9bfa949c48c1c9f1@mail.gmail.com> <47e4b956d5e2a4ffc7eab7f43602575d@ruby-forum.com> Message-ID: <57c63afe0902220810r5874e922s9f87cab3afb40cf4@mail.gmail.com> On Fri, Feb 20, 2009 at 4:35 AM, Juanma Cervera wrote: > David, > > I have an error when trying to run autospec. > It works when I run 'rake spec' > > I don know why it is still using the rspec-1.1.12 gem. > > > /usr/lib/ruby/gems/1.8/gems/dchelimsky-rspec-1.1.99.7/lib/spec/autorun.rb:3: > undefined method `autorun' for Spec::Runner:Module (NoMethodError) > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in > `gem_original_require' > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in > `require' > from > /home/jmcervera/.gem/ruby/1.8/gems/activesupport-2.3.0/lib/active_support/dependencies.rb:158:in > `require' > from ./spec/models/../spec_helper.rb:5 > from ./spec/models/cliente_spec.rb:1:in `require' > from ./spec/models/cliente_spec.rb:1 > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/runner/example_group_runner.rb:15:in > `load' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/runner/example_group_runner.rb:15:in > `load_files' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/runner/example_group_runner.rb:14:in > `each' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/runner/example_group_runner.rb:14:in > `load_files' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/runner/options.rb:94:in > `run_examples' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/runner/command_line.rb:9:in > `run' > from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.12/bin/spec:4 Can you please submit a bug report? Thanks, David > > Thanks > Juanma > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sun Feb 22 11:39:22 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 22 Feb 2009 10:39:22 -0600 Subject: [rspec-users] [RSpec][OT] have autospec just run changed files In-Reply-To: <499FA04A.1020308@benmabey.com> References: <499EF7C0.20301@benmabey.com> <937d9d810902201133k76ab868x64e6cb36b1723ee@mail.gmail.com> <1fb4df0902201233j2691cc97iba777ecc3ce78906@mail.gmail.com> <499FA04A.1020308@benmabey.com> Message-ID: <57c63afe0902220839x1154ba30r37ad7d11254a462@mail.gmail.com> On Sat, Feb 21, 2009 at 12:33 AM, Ben Mabey wrote: > Stephen Eley wrote: >> >> On Fri, Feb 20, 2009 at 2:33 PM, Peter Jaros >> wrote: >> >>> >>> Other than that, I can't think of a way to do it short of writing your >>> own autospec style and overriding the #run algorithm. >>> >> >> Which is almost exactly what I was about to suggest. >8-> Only you >> don't have to override #run, you can just fake it out at the point >> where it reruns all tests and skip that part. >> >> 1.) Make an autotest directory in your project. >> 2.) Add a file 'discover.rb' and include the following: >> Autotest.add_discovery { "mabey" } # Or whatever you want to call >> your specialization >> 3.) If you're using Rails and RSpec, you then need to add a file >> 'mabey_rails_rspec.rb'. If only RSpec, just 'mabey_rspec.rb'. If >> you're using Merb and RSpec, it needs to be 'mabey_merb_rspec.rb'. >> You get the point. Autotest's class and file discovery is just wonky. >> In it: >> >> class Autotest::MabeyRailsRspec < Autotest::RailsRspec # Or >> whatever your appropriate chain is >> def rerun_all_tests >> reset >> end >> end >> >> I figured that out from reading the Autotest code a while back and >> figuring out how to fix problems with Merb, RSpec and Cucumber. My >> conclusion is that Autotest is *sort of* elegant in its own way, but >> that way appears to be based on the standards of someone high on a >> cocktail of LSD and laudanum. It uses convention over >> configuration...sort of...except that you have to configure the >> conventions first. And then too much is hardcoded, and its >> inheritance and class-naming structure means you have to predict every >> possible combination of frameworks in advance. >> >> Someone needs to either hit it with the design pattern stick or write >> a new one. Maybe I will, the next time I manage to take a couple days >> off. >> >> >> >> > > Thanks a lot! > I couldn't get your exact way to work so I ended up monkey patching Autotest > with your #rerun_all_tests in my .autotest file. So far it is working > great. Thanks again! I wonder if this might be a better approach to dealing with Autotest extensions. There seems to be an issue with Autotest extensions and ruby 1.9 (1.9 confusing bin/autotest and an ./autoest directory). We could do the following without putting any burden on Autotest: Move what is now in lib/autotest/rspec.rb (lib/autotest/rails_rspec.rb in rspec-rails) to something like lib/spec/autotest.rb, which you'd have to require in .autotest. Done! Unless I'm missing something. This would put an extra step to using autotest, but it solves the 1.9 problem and it also makes it so we no longer need autospec, which I wouldn't mind getting rid of in the long run. Thoughts? > > -Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From joahking at gmail.com Sun Feb 22 13:24:25 2009 From: joahking at gmail.com (Joaquin Rivera Padron) Date: Sun, 22 Feb 2009 19:24:25 +0100 Subject: [rspec-users] Culerity Error while running feature. In-Reply-To: <8d961d900902220749o6885037kf8b848098f5a50f@mail.gmail.com> References: <8277b7f40902220442w7e94c5d1gab8f085d19728dd5@mail.gmail.com> <8d961d900902220749o6885037kf8b848098f5a50f@mail.gmail.com> Message-ID: <8277b7f40902221024q4adaeb98y775a47b3e12b4d9c@mail.gmail.com> cool, I'll give that a try in short thanks joaquin 2009/2/22, aslak hellesoy : > On Sun, Feb 22, 2009 at 1:42 PM, Joaquin Rivera Padron > wrote: >> hey Kaleem, >> I am myself no expert on w$ but the line throwing the error is >> def self.run_server >> IO.popen("jruby #{__FILE__}", 'r+') > > When forking a new ruby interpreter, always use rbconfig: > > require 'rbconfig' > ruby = File.join(Config::CONFIG['bindir'], > Config::CONFIG['ruby_install_name']) > IO.popen("#{ruby} #{__FILE__}", 'r+') > > If you don't, you might end up running a different ruby than the one you > want. > > Aslak > >> end >> are you able to run popen calls in w$ ? try your irb and see, if not maybe >> there's some w$ expert who can help >> >> hope that helps >> joaquin >> >> >> >> >> >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Aslak (::) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- www.least-significant-bit.com From hayafirst at gmail.com Sun Feb 22 14:47:17 2009 From: hayafirst at gmail.com (Yi Wen) Date: Sun, 22 Feb 2009 13:47:17 -0600 Subject: [rspec-users] [cucumber] Cucumber and CI Message-ID: The rhythm for wrking with cucumber advertised by http://cukes.info/ is to write tests that fails first, then code that fixes it. Now my question is, what is the implication when combine this with Continuous Integration? We all know when we do TDD/BDD in unit level, one test can be fixed fairly quick in a coupe minutes and we can check in and kick off a build. It is a ideal scene for doing CI: frequent checkin and fast feedback on build results. Cucumber, as far as my understanding goes, works on feature level. It could take people days to finish a cucumber feature. In the meantime, the cucumber test remains broken. What do we do then? We cannot check in any code because that'll break the build. So we can only checkin code after several days? It doesn't sound right to me. Any takes on this issue? Thanks in advance. Yi -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at mwilden.com Sun Feb 22 15:19:31 2009 From: mark at mwilden.com (Mark Wilden) Date: Sun, 22 Feb 2009 12:19:31 -0800 Subject: [rspec-users] [Cucumber] host! In-Reply-To: References: <3c30da400902211729x4f569a68l29bcd6c7d0fbdf2d@mail.gmail.com> Message-ID: <3c30da400902221219t73daaf8fn3f4d8e9849c30774@mail.gmail.com> On Sun, Feb 22, 2009 at 2:03 AM, Aslak Helles?y wrote: > Den 22. feb.. 2009 kl. 02.29 skrev Mark Wilden : > >> I'm trying to set a specific host that all my Cucumber steps should >> use. Putting 'host! "beta.rupture.local"' in Before in env.rb doesn't >> produce any errors, but it doesn't seem to be making the next request >> use that host, either. >> >> If I explicitly create a step whose definition includes 'host! >> "beta.rupture.local"' then the next request does use that host. But I >> don't want to have to include this step in every feature. >> > Ple Sure. Where? I don't see anything on http://wiki.github.com/aslakhellesoy/cucumber and if Lighthouse has a search function, I couldn't find it. ///ark From v.ondruch at gmail.com Sun Feb 22 15:34:15 2009 From: v.ondruch at gmail.com (vo.x) Date: Sun, 22 Feb 2009 12:34:15 -0800 (PST) Subject: [rspec-users] send_file testing Message-ID: <7ca1493b-5301-44bb-98ce-3441480bba85@f33g2000vbf.googlegroups.com> Hello all, Is there some best practice how to test Rails controller action which is using send_file method? Could you help me please? Vit From zach.dennis at gmail.com Sun Feb 22 16:07:27 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Sun, 22 Feb 2009 16:07:27 -0500 Subject: [rspec-users] [cucumber] Cucumber and CI In-Reply-To: References: Message-ID: <85d99afe0902221307k3bf9a1bfld00743e37be454db@mail.gmail.com> On Sun, Feb 22, 2009 at 2:47 PM, Yi Wen wrote: > The rhythm for wrking with cucumber advertised by http://cukes.info/ is to > write tests that fails first, then code that fixes it. Now my question is, > what is the implication when combine this with Continuous Integration? > > We all know when we do TDD/BDD in unit level, one test can be fixed fairly > quick in a coupe minutes and we can check in and kick off a build. It is a > ideal scene for doing CI: frequent checkin and fast feedback on build > results. > > Cucumber, as far as my understanding goes, works on feature level. It could > take people days to finish a cucumber feature. In the meantime, the cucumber > test remains broken. What do we do then? We cannot check in any code because > that'll break the build. So we can only checkin code after several days? It > doesn't sound right to me. Any takes on this issue? Thanks in advance. > I use git, create a new branch for a feature, and work in that branch while I'm implementing the feature. As I reach stable points in the feature (even though it may not be done) I will merge into master and push the changes. Usually at this point I've reached the end of a step definition so the next step isn't failing, it's just pending. If unable to reach a stable point to merge back into master one option is to call "pending" inside of the step definition you were last working on, so CI doesn't use that to signify that someone broke the build. This lets you merge back into master and push. Most of the time I work in the feature branch, continually updating and rebasing as others push changes so I'm not out of sync, and then I merge back into master and push when the feature is either stable or done. I'm sure there are lots of ways to go about this though, -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From mark at mwilden.com Sun Feb 22 16:09:41 2009 From: mark at mwilden.com (Mark Wilden) Date: Sun, 22 Feb 2009 13:09:41 -0800 Subject: [rspec-users] [cucumber] Cucumber and CI In-Reply-To: References: Message-ID: <3c30da400902221309s7a64950en10acba4a3c463581@mail.gmail.com> On Sun, Feb 22, 2009 at 11:47 AM, Yi Wen wrote: > Cucumber, as far as my understanding goes, works on feature level. It could > take people days to finish a cucumber feature. In the meantime, the cucumber > test remains broken. What do we do then? We cannot check in any code because > that'll break the build. So we can only checkin code after several days? It > doesn't sound right to me. Any takes on this issue? Thanks in advance. What I do is write the feature, and check that in. Then I work on each step definition TDD-wise, checking in each as it runs without error and without failing the expectation. So I check in yellow (with pending steps) and when there are no more pending steps, I mark the feature as finished. ///ark From aslak.hellesoy at gmail.com Sun Feb 22 16:13:29 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 22 Feb 2009 22:13:29 +0100 Subject: [rspec-users] [Cucumber] host! In-Reply-To: <3c30da400902221219t73daaf8fn3f4d8e9849c30774@mail.gmail.com> References: <3c30da400902211729x4f569a68l29bcd6c7d0fbdf2d@mail.gmail.com> <3c30da400902221219t73daaf8fn3f4d8e9849c30774@mail.gmail.com> Message-ID: <8d961d900902221313h4e4bf405x7b845afd5b711429@mail.gmail.com> On Sun, Feb 22, 2009 at 9:19 PM, Mark Wilden wrote: > On Sun, Feb 22, 2009 at 2:03 AM, Aslak Helles?y > wrote: >> Den 22. feb.. 2009 kl. 02.29 skrev Mark Wilden : >> >>> I'm trying to set a specific host that all my Cucumber steps should >>> use. Putting 'host! "beta.rupture.local"' in Before in env.rb doesn't >>> produce any errors, but it doesn't seem to be making the next request >>> use that host, either. >>> >>> If I explicitly create a step whose definition includes 'host! >>> "beta.rupture.local"' then the next request does use that host. But I >>> don't want to have to include this step in every feature. >>> >> Ple > > Sure. Where? I don't see anything on > http://wiki.github.com/aslakhellesoy/cucumber and if Lighthouse has a > search function, I couldn't find it. > Both the "Getting in touch" page in the wiki and the top menu on cukes.info has links to Lighthouse. Aslak > ///ark > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From aslak.hellesoy at gmail.com Sun Feb 22 16:36:56 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 22 Feb 2009 22:36:56 +0100 Subject: [rspec-users] [cucumber] Cucumber and CI In-Reply-To: References: Message-ID: <8d961d900902221336x7822dc36p43ea7c29bca44430@mail.gmail.com> On Sun, Feb 22, 2009 at 8:47 PM, Yi Wen wrote: > The rhythm for wrking with cucumber advertised by http://cukes.info/ is to > write tests that fails first, then code that fixes it. Now my question is, > what is the implication when combine this with Continuous Integration? > * Nobody checks in code with failing tests (cucumber features, rspec tests, anything else). * If someone accidentally does, CI will run all tests and tell the team. > We all know when we do TDD/BDD in unit level, one test can be fixed fairly > quick in a coupe minutes and we can check in and kick off a build. It is a > ideal scene for doing CI: frequent checkin and fast feedback on build > results. > > Cucumber, as far as my understanding goes, works on feature level. It could > take people days to finish a cucumber feature. In the meantime, the cucumber > test remains broken. What do we do then? We cannot check in any code because A feature typically consists of several scenarios. You don't have to implement all scenarios before you commit. You don't have to write all scenarios when you start working on a feature. I recommend you never have more than one yellow scenario at a time. The same goes for scenarios, which consist of several steps. I recommend you commit every time you have made a step go from yellow to green (via red). This way, many successive commits will gradually build the whole feature. In my experience, getting a step to go from yellow to green rarely takes more than an hour (usually less). Is there anything preventing you from working this way? Aslak > that'll break the build. So we can only checkin code after several days? It > doesn't sound right to me. Any takes on this issue? Thanks in advance. > > Yi > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From mark at mwilden.com Sun Feb 22 18:18:48 2009 From: mark at mwilden.com (Mark Wilden) Date: Sun, 22 Feb 2009 15:18:48 -0800 Subject: [rspec-users] [cucumber] Cucumber and CI In-Reply-To: <8d961d900902221336x7822dc36p43ea7c29bca44430@mail.gmail.com> References: <8d961d900902221336x7822dc36p43ea7c29bca44430@mail.gmail.com> Message-ID: <3c30da400902221518p5605eb50qc28d895b087b7da7@mail.gmail.com> On Sun, Feb 22, 2009 at 1:36 PM, aslak hellesoy wrote: > You don't have to write all > scenarios when you start working on a feature. I recommend you never > have more than one yellow scenario at a time. Whereas I use scenarios as a "to-do" list. I'll keep adding them as I think of them or as they come up in discussion. ///ark From hayafirst at gmail.com Sun Feb 22 19:09:53 2009 From: hayafirst at gmail.com (Yi Wen) Date: Sun, 22 Feb 2009 18:09:53 -0600 Subject: [rspec-users] [cucumber] Cucumber and CI In-Reply-To: <8d961d900902221336x7822dc36p43ea7c29bca44430@mail.gmail.com> References: <8d961d900902221336x7822dc36p43ea7c29bca44430@mail.gmail.com> Message-ID: Wait for an hour before I can checkin something is still too long for me. I'd like to checkin every couple minutes most of time. But I think to make each step just pending first and then make it green when I finish implementation for the step makes sense. I probably will still use unit tests passing as checkin points. Thanks Yi On Sun, Feb 22, 2009 at 3:36 PM, aslak hellesoy wrote: > On Sun, Feb 22, 2009 at 8:47 PM, Yi Wen wrote: > > The rhythm for wrking with cucumber advertised by http://cukes.info/ is > to > > write tests that fails first, then code that fixes it. Now my question > is, > > what is the implication when combine this with Continuous Integration? > > > > * Nobody checks in code with failing tests (cucumber features, rspec > tests, anything else). > * If someone accidentally does, CI will run all tests and tell the team. > > > We all know when we do TDD/BDD in unit level, one test can be fixed > fairly > > quick in a coupe minutes and we can check in and kick off a build. It is > a > > ideal scene for doing CI: frequent checkin and fast feedback on build > > results. > > > > Cucumber, as far as my understanding goes, works on feature level. It > could > > take people days to finish a cucumber feature. In the meantime, the > cucumber > > test remains broken. What do we do then? We cannot check in any code > because > > A feature typically consists of several scenarios. You don't have to > implement all scenarios before you commit. You don't have to write all > scenarios when you start working on a feature. I recommend you never > have more than one yellow scenario at a time. > > The same goes for scenarios, which consist of several steps. > > I recommend you commit every time you have made a step go from yellow > to green (via red). > This way, many successive commits will gradually build the whole feature. > > In my experience, getting a step to go from yellow to green rarely > takes more than an hour (usually less). > Is there anything preventing you from working this way? > > Aslak > > > that'll break the build. So we can only checkin code after several days? > It > > doesn't sound right to me. Any takes on this issue? Thanks in advance. > > > > Yi > > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > Aslak (::) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hayafirst at gmail.com Sun Feb 22 19:14:44 2009 From: hayafirst at gmail.com (Yi Wen) Date: Sun, 22 Feb 2009 18:14:44 -0600 Subject: [rspec-users] [cucumber] Cucumber and CI In-Reply-To: <3c30da400902221518p5605eb50qc28d895b087b7da7@mail.gmail.com> References: <8d961d900902221336x7822dc36p43ea7c29bca44430@mail.gmail.com> <3c30da400902221518p5605eb50qc28d895b087b7da7@mail.gmail.com> Message-ID: I totally agree with you on this. I have a feeling a lot of people kind of use cucumber as a sexy way for doing waterfall. On Sun, Feb 22, 2009 at 5:18 PM, Mark Wilden wrote: > On Sun, Feb 22, 2009 at 1:36 PM, aslak hellesoy > wrote: > > You don't have to write all > > scenarios when you start working on a feature. I recommend you never > > have more than one yellow scenario at a time. > > Whereas I use scenarios as a "to-do" list. I'll keep adding them as I > think of them or as they come up in discussion. > > ///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 dchelimsky at gmail.com Sun Feb 22 19:18:54 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 22 Feb 2009 18:18:54 -0600 Subject: [rspec-users] [cucumber] Cucumber and CI In-Reply-To: References: <8d961d900902221336x7822dc36p43ea7c29bca44430@mail.gmail.com> <3c30da400902221518p5605eb50qc28d895b087b7da7@mail.gmail.com> Message-ID: <57c63afe0902221618t4c326ceakec0504e164b958cd@mail.gmail.com> On Sun, Feb 22, 2009 at 6:14 PM, Yi Wen wrote: > I totally agree with you on this. I have a feeling a lot of people kind of > use cucumber as a sexy way for doing waterfall. That may be so, but one view of agile is that each iteration is a mini-waterfall. BDD suggests that we *should* define all of the scenarios in the iteration planning meeting because we use them as a planning tool (how can we estimate a feature at all before we've talked about the acceptance criteria?). FWIW, David > > On Sun, Feb 22, 2009 at 5:18 PM, Mark Wilden wrote: >> >> On Sun, Feb 22, 2009 at 1:36 PM, aslak hellesoy >> wrote: >> > You don't have to write all >> > scenarios when you start working on a feature. I recommend you never >> > have more than one yellow scenario at a time. >> >> Whereas I use scenarios as a "to-do" list. I'll keep adding them as I >> think of them or as they come up in discussion. >> >> ///ark >> _______________________________________________ >> 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 phlip2005 at gmail.com Sun Feb 22 21:36:55 2009 From: phlip2005 at gmail.com (Phlip) Date: Sun, 22 Feb 2009 18:36:55 -0800 Subject: [rspec-users] [cucumber] Cucumber and CI In-Reply-To: References: <8d961d900902221336x7822dc36p43ea7c29bca44430@mail.gmail.com> <3c30da400902221518p5605eb50qc28d895b087b7da7@mail.gmail.com> Message-ID: Yi Wen wrote: > I totally agree with you on this. I have a feeling a lot of people kind > of use cucumber as a sexy way for doing waterfall. "Storytests" are very well represented in the Agile development community in general. Cucumber is a (slam-dunk) reinterpretation of Ward Cunningham's FIT concept. (Naturally, born of Java, FIT had no direct translation to Ruby, and that's probably a good thing!) It's only waterfall if your product-owner writes or commissions _thousands_ of story tests before doing _any_ of them. I heavily suspect that the author of a cucumber "feature" can hardly wait to see it pass, and I suspect they will refrain from diverting energy to writing another one. That is the heart of Agile - the feedback loop. So what's the maximum number of cucumber features that anyone has ever seen on-deck but not yet passing? That's a bad metric, exactly like excess inventory in a warehouse. -- Phlip From hayafirst at gmail.com Sun Feb 22 22:06:39 2009 From: hayafirst at gmail.com (Yi Wen) Date: Sun, 22 Feb 2009 21:06:39 -0600 Subject: [rspec-users] [cucumber] Cucumber and CI In-Reply-To: References: <8d961d900902221336x7822dc36p43ea7c29bca44430@mail.gmail.com> <3c30da400902221518p5605eb50qc28d895b087b7da7@mail.gmail.com> Message-ID: yeah, you guys are probably right on this. I was just over stating. :) Yi On Sun, Feb 22, 2009 at 8:36 PM, Phlip wrote: > Yi Wen wrote: > > I totally agree with you on this. I have a feeling a lot of people kind of >> use cucumber as a sexy way for doing waterfall. >> > > "Storytests" are very well represented in the Agile development community > in general. Cucumber is a (slam-dunk) reinterpretation of Ward Cunningham's > FIT concept. > > (Naturally, born of Java, FIT had no direct translation to Ruby, and that's > probably a good thing!) > > It's only waterfall if your product-owner writes or commissions _thousands_ > of story tests before doing _any_ of them. > > I heavily suspect that the author of a cucumber "feature" can hardly wait > to see it pass, and I suspect they will refrain from diverting energy to > writing another one. That is the heart of Agile - the feedback loop. > > So what's the maximum number of cucumber features that anyone has ever seen > on-deck but not yet passing? That's a bad metric, exactly like excess > inventory in a warehouse. > > -- > Phlip > > > _______________________________________________ > 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 phlip2005 at gmail.com Sun Feb 22 22:53:39 2009 From: phlip2005 at gmail.com (Phlip) Date: Sun, 22 Feb 2009 19:53:39 -0800 Subject: [rspec-users] [cucumber] Cucumber and CI In-Reply-To: References: <8d961d900902221336x7822dc36p43ea7c29bca44430@mail.gmail.com> <3c30da400902221518p5605eb50qc28d895b087b7da7@mail.gmail.com> Message-ID: Yi Wen wrote: > yeah, you guys are probably right on this. I was just over stating. :) Ah, but Waterfall is indeed like the Emissaries of the Shadow. If you defeat one of them, in one form, another one will always appear, take shape, and grow... I myself have heard well-meaning product managers say "When we go for the rewrite, we are going to make sure we specify each feature, first, before coding them!" They said that because the last effort - code-and-fix - had grown until it died under the weight of its cruft. They perceived their inability to safely request new features as evidence that they did not specify enough, up-front. These managers knew better than to use classic Waterfall, but they still didn't understand that Big Requirements Up Front is essentially Waterfall's worst aspect. And so they re-invented Waterfall, yet again, in yet another form. So keep flying that flag of vigilance, there! -- Phlip From lists at ruby-forum.com Sun Feb 22 23:22:53 2009 From: lists at ruby-forum.com (Kaleem Ullah) Date: Mon, 23 Feb 2009 05:22:53 +0100 Subject: [rspec-users] Culerity Error while running feature. In-Reply-To: <8277b7f40902221024q4adaeb98y775a47b3e12b4d9c@mail.gmail.com> References: <8277b7f40902220442w7e94c5d1gab8f085d19728dd5@mail.gmail.com> <8d961d900902220749o6885037kf8b848098f5a50f@mail.gmail.com> <8277b7f40902221024q4adaeb98y775a47b3e12b4d9c@mail.gmail.com> Message-ID: <06c5acce4666b553cfcad7da2a490152@ruby-forum.com> Let me try... Thanks for your reply..... -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Mon Feb 23 02:24:10 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 23 Feb 2009 08:24:10 +0100 Subject: [rspec-users] [cucumber] Cucumber and CI In-Reply-To: References: <8d961d900902221336x7822dc36p43ea7c29bca44430@mail.gmail.com> <3c30da400902221518p5605eb50qc28d895b087b7da7@mail.gmail.com> Message-ID: <8d961d900902222324i5870a9fcvd27e7b4ddae50a6f@mail.gmail.com> On Mon, Feb 23, 2009 at 3:36 AM, Phlip wrote: > Yi Wen wrote: > >> I totally agree with you on this. I have a feeling a lot of people kind of >> use cucumber as a sexy way for doing waterfall. > > "Storytests" are very well represented in the Agile development community in > general. Cucumber is a (slam-dunk) reinterpretation of Ward Cunningham's FIT > concept. > > (Naturally, born of Java, FIT had no direct translation to Ruby, and that's > probably a good thing!) > It actually did. It's just that very few have ever used it: http://fit.rubyforge.org/ > It's only waterfall if your product-owner writes or commissions _thousands_ > of story tests before doing _any_ of them. > > I heavily suspect that the author of a cucumber "feature" can hardly wait to > see it pass, and I suspect they will refrain from diverting energy to > writing another one. That is the heart of Agile - the feedback loop. > Well said. That's the feeling I get when I work with this Cucumber. > So what's the maximum number of cucumber features that anyone has ever seen > on-deck but not yet passing? That's a bad metric, exactly like excess Do you mean "on filesystem"? I have used Cucumber on 5-6 projects now, and I never exceed 1. If there is a bigger backlog "somewhere else" (pile of cards, word documents...) then I keep them there for as long as possible. > inventory in a warehouse. > > -- > Phlip > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From v.ondruch at gmail.com Mon Feb 23 02:43:10 2009 From: v.ondruch at gmail.com (vo.x) Date: Sun, 22 Feb 2009 23:43:10 -0800 (PST) Subject: [rspec-users] send_file testing In-Reply-To: <7ca1493b-5301-44bb-98ce-3441480bba85@f33g2000vbf.googlegroups.com> References: <7ca1493b-5301-44bb-98ce-3441480bba85@f33g2000vbf.googlegroups.com> Message-ID: <30fcc9c6-64a1-47cf-842c-3495418c6f4b@j8g2000yql.googlegroups.com> Just to be clear, this is how the action looks: def download log = ActivityLog.find(params[:id]) if log send_file log.path else flash[:notice] = _("Log file \"#{params[:id]}\" was not found.") redirect_to :action => 'index' end end Vit From pat.maddox at gmail.com Mon Feb 23 04:52:50 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Mon, 23 Feb 2009 01:52:50 -0800 Subject: [rspec-users] [cucumber] Cucumber and CI In-Reply-To: References: <8d961d900902221336x7822dc36p43ea7c29bca44430@mail.gmail.com> <3c30da400902221518p5605eb50qc28d895b087b7da7@mail.gmail.com> Message-ID: <2c7e61990902230152u7c2bd7a1n9b5b69b8faf23140@mail.gmail.com> On Sun, Feb 22, 2009 at 6:36 PM, Phlip wrote: > So what's the maximum number of cucumber features that anyone has ever seen > on-deck but not yet passing? That's a bad metric, exactly like excess > inventory in a warehouse. I don't know that it's bad. At the beginning of an iteration, I have most of the features & scenarios that I'll be working on. So I start off with a big pile of yellows, and as the iteration moves on it gradually turns green. I'd say we average 8-10 pending features at the beginning of each iteration maybe. Pat From chris.webstar at gmail.com Mon Feb 23 05:17:47 2009 From: chris.webstar at gmail.com (Christian Hoeppner) Date: Mon, 23 Feb 2009 10:17:47 +0000 Subject: [rspec-users] Autotest won't pickup any tests In-Reply-To: <57c63afe0902200756q60c87e11wc8caa27bd8af3291@mail.gmail.com> References: <067EF338-8816-417E-963F-4BC157E18EFD@gmail.com> <57c63afe0902200756q60c87e11wc8caa27bd8af3291@mail.gmail.com> Message-ID: <1AC72844-E6A5-482A-9F38-DA94A4771497@gmail.com> *smacks forehead* Who would have known. Ha! I spent the entire weekend "debugging" that lib. Now, how do I create a rake task that runs autospec with a few options? On 20/02/2009, at 15:56, David Chelimsky wrote: > On Fri, Feb 20, 2009 at 6:15 AM, Christian Hoeppner > wrote: >> Hey there, >> >> I've tried using Nick Sieger's "plugin" to have autotest run my >> tests for >> gems and other non-rails stuff. However, it doesn't seem to match >> any tests >> for any files. Not being sure what was wrong, I traced the >> execution of >> RspecAutotest.run() and saw that tests_for_file() never got called. >> I also >> replicated a tests_for_file() call by hand in irb, and it does >> match the >> right spec file for any given implementation file. > > That lib is way outdated. RSpec now supports autotest directly with > the autospec command. > >> >> Here's what I use: >> ZenTest (3.11.1), rspec (1.1.12), ruby, ruby 1.8.1 (2003-12-25) >> [i686-darwin]. >> >> Sieger's file is the latest from svn, dated from 2007. >> _______________________________________________ >> 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 Saludos, Chris Hoeppner S.A.T. Gigabyte Solution S.L. 637 333 204 928 821 633 chris.webstar at gmail.com codigo404.wordpress.com From lists at ruby-forum.com Mon Feb 23 06:12:17 2009 From: lists at ruby-forum.com (Hoor Net) Date: Mon, 23 Feb 2009 12:12:17 +0100 Subject: [rspec-users] [cucumber ]Missing lettersm 'a' mafter rake features Message-ID: I am just starting with any testing really, but I chose this post as a tutorial. http://www.ultrasaurus.com/sarahblog/2008/12/rails-2-day-3-behavior-driven-development/comment-page-1/#comment-454 I have WinXP, so I had to install one more gem for the colors. After making my first features/tasklist.feature file which is: Feature: Tasks In order to keep track of tasks People should be able to Create a list of tasks Scenario: List Tasks Given that I have created a task "task 1" When I go to the tasks page Then I should see "task 1" After this I run the: rake features and you won't believe what happened! Take a look at the result: http://gist.github.com/68907 The 'a' letters ARE MISSING!!!! Any ideas? -- Posted via http://www.ruby-forum.com/. From joe at josephwilk.net Mon Feb 23 06:28:36 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Mon, 23 Feb 2009 11:28:36 +0000 Subject: [rspec-users] [cucumber ]Missing lettersm 'a' mafter rake features In-Reply-To: References: Message-ID: <49A28864.7010706@josephwilk.net> Hoor Net wrote: > I am just starting with any testing really, but I chose this post as a > tutorial. > http://www.ultrasaurus.com/sarahblog/2008/12/rails-2-day-3-behavior-driven-development/comment-page-1/#comment-454 > > I have WinXP, so I had to install one more gem for the colors. > After making my first features/tasklist.feature file which is: > Feature: Tasks > In order to keep track of tasks > People should be able to > Create a list of tasks > > Scenario: List Tasks > Given that I have created a task "task 1" > When I go to the tasks page > Then I should see "task 1" > > > After this I run the: > rake features > > and you won't believe what happened! > Take a look at the result: > http://gist.github.com/68907 > > The 'a' letters ARE MISSING!!!! > > Any ideas? > Take a look at: http://wiki.github.com/aslakhellesoy/cucumber/troubleshooting -- Joseph Wilk http://blog.josephwilk.net From lists at ruby-forum.com Mon Feb 23 07:01:03 2009 From: lists at ruby-forum.com (Hoor Net) Date: Mon, 23 Feb 2009 13:01:03 +0100 Subject: [rspec-users] [cucumber ]Missing lettersm 'a' mafter rake features In-Reply-To: <49A28864.7010706@josephwilk.net> References: <49A28864.7010706@josephwilk.net> Message-ID: It works! It works! Thanks a LOT!!! Joseph Wilk wrote: > Hoor Net wrote: >> >> Take a look at the result: >> http://gist.github.com/68907 >> >> The 'a' letters ARE MISSING!!!! >> >> Any ideas? >> > Take a look at: > > http://wiki.github.com/aslakhellesoy/cucumber/troubleshooting > > -- > Joseph Wilk > http://blog.josephwilk.net -- Posted via http://www.ruby-forum.com/. From phlip2005 at gmail.com Mon Feb 23 07:38:20 2009 From: phlip2005 at gmail.com (Phlip) Date: Mon, 23 Feb 2009 04:38:20 -0800 Subject: [rspec-users] [cucumber] Cucumber and CI In-Reply-To: <8d961d900902222324i5870a9fcvd27e7b4ddae50a6f@mail.gmail.com> References: <8d961d900902221336x7822dc36p43ea7c29bca44430@mail.gmail.com> <3c30da400902221518p5605eb50qc28d895b087b7da7@mail.gmail.com> <8d961d900902222324i5870a9fcvd27e7b4ddae50a6f@mail.gmail.com> Message-ID: aslak hellesoy wrote: >> So what's the maximum number of cucumber features that anyone has ever seen >> on-deck but not yet passing? That's a bad metric, exactly like excess >> inventory in a warehouse. > > Do you mean "on filesystem"? I have used Cucumber on 5-6 projects now, > and I never exceed 1. If there is a bigger backlog "somewhere else" > (pile of cards, word documents...) then I keep them there for as long > as possible. Among the Agile consultants, the metric there is: Time between fully specifying a feature and profiting from its use. You use each cards as a tickler for one last conversation with an onsite customer, before cutting the test and code, right? BTW, another CI metric for cucumberists to answer is: After passing a cucumber test, it latches, and gates integration. I think cucumber builds that latch effect in with the 'pending' keyword, right? Pass the cuke, take it out, integrate, and then it runs in your integration batch, right? -- Phlip From dchelimsky at gmail.com Mon Feb 23 08:49:44 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 23 Feb 2009 07:49:44 -0600 Subject: [rspec-users] Autotest won't pickup any tests In-Reply-To: <1AC72844-E6A5-482A-9F38-DA94A4771497@gmail.com> References: <067EF338-8816-417E-963F-4BC157E18EFD@gmail.com> <57c63afe0902200756q60c87e11wc8caa27bd8af3291@mail.gmail.com> <1AC72844-E6A5-482A-9F38-DA94A4771497@gmail.com> Message-ID: <57c63afe0902230549i4eaca8am3a3491946b0e24fc@mail.gmail.com> On Mon, Feb 23, 2009 at 4:17 AM, Christian Hoeppner wrote: > *smacks forehead* Who would have known. Ha! I spent the entire weekend > "debugging" that lib. > > Now, how do I create a rake task that runs autospec with a few options? RSpec options, Autotest options, or both? > > On 20/02/2009, at 15:56, David Chelimsky wrote: > >> On Fri, Feb 20, 2009 at 6:15 AM, Christian Hoeppner >> wrote: >>> >>> Hey there, >>> >>> I've tried using Nick Sieger's "plugin" to have autotest run my tests for >>> gems and other non-rails stuff. However, it doesn't seem to match any >>> tests >>> for any files. Not being sure what was wrong, I traced the execution of >>> RspecAutotest.run() and saw that tests_for_file() never got called. I >>> also >>> replicated a tests_for_file() call by hand in irb, and it does match the >>> right spec file for any given implementation file. >> >> That lib is way outdated. RSpec now supports autotest directly with >> the autospec command. >> >>> >>> Here's what I use: >>> ZenTest (3.11.1), rspec (1.1.12), ruby, ruby 1.8.1 (2003-12-25) >>> [i686-darwin]. >>> >>> Sieger's file is the latest from svn, dated from 2007. >>> _______________________________________________ >>> 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 > > Saludos, > Chris Hoeppner > S.A.T. Gigabyte Solution S.L. > 637 333 204 > 928 821 633 > chris.webstar at gmail.com > codigo404.wordpress.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Mon Feb 23 09:36:42 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 23 Feb 2009 15:36:42 +0100 Subject: [rspec-users] Cucumber 0.2 final release date? In-Reply-To: <7ac2300c0902190749x3d659b40w7cc84e5a6f8aedea@mail.gmail.com> References: <7ac2300c0902190749x3d659b40w7cc84e5a6f8aedea@mail.gmail.com> Message-ID: <8d961d900902230636te143bc6o92ca13f709688ee9@mail.gmail.com> On Thu, Feb 19, 2009 at 4:49 PM, aidy lewis wrote: > Hi, > > I know this seems all take and no give, but do we have an estimated > final release date for Cucumber 0.2? > I'm afraid I can't give a release date. 0.2 is fixed(ish) scope, and therefore time can't be fixed at the same time. I have a lot of travel the next month, so it will take a least a month I'm afraid. Aslak > Thanks > > Aidy > > Celerity, Cucumber and Firewatir: > http://skillsmatter.com/event/ruby-on-rails/lrug-march > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) From apremdas at gmail.com Mon Feb 23 09:56:12 2009 From: apremdas at gmail.com (Andrew Premdas) Date: Mon, 23 Feb 2009 14:56:12 +0000 Subject: [rspec-users] [cucumber] Cucumber and CI In-Reply-To: References: <8d961d900902221336x7822dc36p43ea7c29bca44430@mail.gmail.com> Message-ID: <88fd8ddc0902230656v5691d28fj913909b4c9612ba5@mail.gmail.com> I'd question the wisdom of checking into an integration server every couple of minutes. I'm not sure if you meant that but if you did then I think these sort of checkins have to be in bigger chunks. The reason is that each checkin to an intergration server is asking my colleagues to checkout my code and integrate it into their current work. So everything I check in to the intergration server should be fit for them to use, and ideally it should have been reviewed (self review, or even better a bit of peer review - easy enought if pairing). You just can't do that in 2 minutes. IMO a complete scenario is about the smallest size chunk to integrate with, and a complete feature about the largest Of course if your using Git (or any distributed vcs) you can just branch, commit locally and rebase from the master. If you want to push to get a backup as well, you can always have a backup target in addition to your integration target. If your not using Git (or something similar) locally I'd highly reccomend that. I think its reasonable to make failing steps pending for an integration commit, but its not something I would like to do regularly, much prefer to wait a bit longer before integrating and make them green. I really don't like working with more than 1 failing step, but find that occasionally I end up doing that (normally because a new step prompts a refactoring of and older step and that then breaks as well) HTH Andrew 2009/2/23 Yi Wen > Wait for an hour before I can checkin something is still too long for me. > I'd like to checkin every couple minutes most of time. > > But I think to make each step just pending first and then make it green > when I finish implementation for the step makes sense. I probably will still > use unit tests passing as checkin points. > > Thanks > > Yi > > On Sun, Feb 22, 2009 at 3:36 PM, aslak hellesoy wrote: > >> On Sun, Feb 22, 2009 at 8:47 PM, Yi Wen wrote: >> > The rhythm for wrking with cucumber advertised by http://cukes.info/ is >> to >> > write tests that fails first, then code that fixes it. Now my question >> is, >> > what is the implication when combine this with Continuous Integration? >> > >> >> * Nobody checks in code with failing tests (cucumber features, rspec >> tests, anything else). >> * If someone accidentally does, CI will run all tests and tell the team. >> >> > We all know when we do TDD/BDD in unit level, one test can be fixed >> fairly >> > quick in a coupe minutes and we can check in and kick off a build. It is >> a >> > ideal scene for doing CI: frequent checkin and fast feedback on build >> > results. >> > >> > Cucumber, as far as my understanding goes, works on feature level. It >> could >> > take people days to finish a cucumber feature. In the meantime, the >> cucumber >> > test remains broken. What do we do then? We cannot check in any code >> because >> >> A feature typically consists of several scenarios. You don't have to >> implement all scenarios before you commit. You don't have to write all >> scenarios when you start working on a feature. I recommend you never >> have more than one yellow scenario at a time. >> >> The same goes for scenarios, which consist of several steps. >> >> I recommend you commit every time you have made a step go from yellow >> to green (via red). >> This way, many successive commits will gradually build the whole feature. >> >> In my experience, getting a step to go from yellow to green rarely >> takes more than an hour (usually less). >> Is there anything preventing you from working this way? >> >> Aslak >> >> > that'll break the build. So we can only checkin code after several days? >> It >> > doesn't sound right to me. Any takes on this issue? Thanks in advance. >> > >> > Yi >> > >> > >> > >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> >> >> >> -- >> Aslak (::) >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at mwilden.com Mon Feb 23 10:22:22 2009 From: mark at mwilden.com (Mark Wilden) Date: Mon, 23 Feb 2009 07:22:22 -0800 Subject: [rspec-users] [cucumber] Cucumber and CI In-Reply-To: <88fd8ddc0902230656v5691d28fj913909b4c9612ba5@mail.gmail.com> References: <8d961d900902221336x7822dc36p43ea7c29bca44430@mail.gmail.com> <88fd8ddc0902230656v5691d28fj913909b4c9612ba5@mail.gmail.com> Message-ID: <3c30da400902230722ifdd659ewc09e6b84b2e4cd7c@mail.gmail.com> On Mon, Feb 23, 2009 at 6:56 AM, Andrew Premdas wrote: > I'd question the wisdom of checking into an integration server every couple > of minutes. Our mantra is ABC: Always Be Committing. So we commit anytime we feel like it, as long as it doesn't break the build. This makes life a lot easier when there is merging to do. > I'm not sure if you meant that but if you did then I think these > sort of checkins have to be in bigger chunks. The reason is that each > checkin to an intergration server is asking my colleagues to checkout my > code and integrate it into their current work. Just because I push doesn't mean my coworkers have to pull. > IMO a complete > scenario is about the smallest size chunk to integrate with, and a complete > feature about the largest A refactoring, a new method (and its tests), a new test, a fixed typo - these are all appropriate chunks of code to check in. I think this is far superior to making massive checkins at the end of each iteration. We usually fall somewhere in between. ///ark From chris.webstar at gmail.com Mon Feb 23 10:26:53 2009 From: chris.webstar at gmail.com (Christian Hoeppner) Date: Mon, 23 Feb 2009 15:26:53 +0000 Subject: [rspec-users] Autotest won't pickup any tests In-Reply-To: <57c63afe0902230549i4eaca8am3a3491946b0e24fc@mail.gmail.com> References: <067EF338-8816-417E-963F-4BC157E18EFD@gmail.com> <57c63afe0902200756q60c87e11wc8caa27bd8af3291@mail.gmail.com> <1AC72844-E6A5-482A-9F38-DA94A4771497@gmail.com> <57c63afe0902230549i4eaca8am3a3491946b0e24fc@mail.gmail.com> Message-ID: <52C220DB-05F4-4874-A0C5-00889FEE2CDD@gmail.com> I'm not really sure what options autotest has, since the website is on "coming soon", and autotest -h doesn't show any help, so I'm thinking about rspec options, like the rpsec command to use, arguments (--diff unified --color, etc). Is there a place to read up on autotest behavior and options? I couldn't even find a manpage, but maybe I'm not looking hard enough. On 23/02/2009, at 13:49, David Chelimsky wrote: > On Mon, Feb 23, 2009 at 4:17 AM, Christian Hoeppner > wrote: >> *smacks forehead* Who would have known. Ha! I spent the entire >> weekend >> "debugging" that lib. >> >> Now, how do I create a rake task that runs autospec with a few >> options? > > RSpec options, Autotest options, or both? > >> >> On 20/02/2009, at 15:56, David Chelimsky wrote: >> >>> On Fri, Feb 20, 2009 at 6:15 AM, Christian Hoeppner >>> wrote: >>>> >>>> Hey there, >>>> >>>> I've tried using Nick Sieger's "plugin" to have autotest run my >>>> tests for >>>> gems and other non-rails stuff. However, it doesn't seem to match >>>> any >>>> tests >>>> for any files. Not being sure what was wrong, I traced the >>>> execution of >>>> RspecAutotest.run() and saw that tests_for_file() never got >>>> called. I >>>> also >>>> replicated a tests_for_file() call by hand in irb, and it does >>>> match the >>>> right spec file for any given implementation file. >>> >>> That lib is way outdated. RSpec now supports autotest directly with >>> the autospec command. >>> >>>> >>>> Here's what I use: >>>> ZenTest (3.11.1), rspec (1.1.12), ruby, ruby 1.8.1 (2003-12-25) >>>> [i686-darwin]. >>>> >>>> Sieger's file is the latest from svn, dated from 2007. >>>> _______________________________________________ >>>> 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 >> >> Saludos, >> Chris Hoeppner >> S.A.T. Gigabyte Solution S.L. >> 637 333 204 >> 928 821 633 >> chris.webstar at gmail.com >> codigo404.wordpress.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 Saludos, Chris Hoeppner S.A.T. Gigabyte Solution S.L. 637 333 204 928 821 633 chris.webstar at gmail.com codigo404.wordpress.com From phlip2005 at gmail.com Mon Feb 23 10:44:46 2009 From: phlip2005 at gmail.com (Phlip) Date: Mon, 23 Feb 2009 07:44:46 -0800 Subject: [rspec-users] [cucumber] Cucumber and CI In-Reply-To: <3c30da400902230722ifdd659ewc09e6b84b2e4cd7c@mail.gmail.com> References: <8d961d900902221336x7822dc36p43ea7c29bca44430@mail.gmail.com> <88fd8ddc0902230656v5691d28fj913909b4c9612ba5@mail.gmail.com> <3c30da400902230722ifdd659ewc09e6b84b2e4cd7c@mail.gmail.com> Message-ID: Mark Wilden wrote: >> I'd question the wisdom of checking into an integration server every couple >> of minutes. > > Our mantra is ABC: Always Be Committing. So we commit anytime we feel > like it, as long as it doesn't break the build. This makes life a lot > easier when there is merging to do. In a post-Agile world, we often need to remind the juniors about the Best Practices that started the movement. Integrate every time you could use a roll-back. Use incremental testing, and a test server. You can't integrate if your changed tests fail. The first step of integrating pulls And work in one room, so if you know another pair is in the same module, you just holler to them to integrate as soon as possible, each time you do it. -- Phlip From dchelimsky at gmail.com Mon Feb 23 10:56:44 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 23 Feb 2009 09:56:44 -0600 Subject: [rspec-users] Autotest won't pickup any tests In-Reply-To: <52C220DB-05F4-4874-A0C5-00889FEE2CDD@gmail.com> References: <067EF338-8816-417E-963F-4BC157E18EFD@gmail.com> <57c63afe0902200756q60c87e11wc8caa27bd8af3291@mail.gmail.com> <1AC72844-E6A5-482A-9F38-DA94A4771497@gmail.com> <57c63afe0902230549i4eaca8am3a3491946b0e24fc@mail.gmail.com> <52C220DB-05F4-4874-A0C5-00889FEE2CDD@gmail.com> Message-ID: <57c