From patrick at collinatorstudios.com Sat May 1 03:29:42 2010 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Sat, 1 May 2010 00:29:42 -0700 (PDT) Subject: [rspec-users] update_attributes fails in rake spec but not in script/spec??? In-Reply-To: References: Message-ID: Well, after some investigating, I discovered than another one of my spec files was causing this behavior. When removing this other spec file, the one that was failing via rake spec no longer failed.. Totally bizarre. This is the spec that fails: http://gist.github.com/386129 And this is the spec that when I delete, the other one that failed now passes: http://gist.github.com/386125 This is so weird, I would really love it if someone could shed some light on this. Patrick J. Collins http://collinatorstudios.com From dchelimsky at gmail.com Sat May 1 07:36:33 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 1 May 2010 06:36:33 -0500 Subject: [rspec-users] update_attributes fails in rake spec but not in script/spec??? In-Reply-To: References: Message-ID: <28C71138-5872-43E0-8A86-1494E198AAFA@gmail.com> On May 1, 2010, at 2:29 AM, Patrick J. Collins wrote: > Well, after some investigating, I discovered than another one of my spec files > was causing this behavior. When removing this other spec file, the one that > was failing via rake spec no longer failed.. Totally bizarre. > > This is the spec that fails: > http://gist.github.com/386129 > > And this is the spec that when I delete, the other one that failed now passes: > http://gist.github.com/386125 > > This is so weird, I would really love it if someone could shed some light on > this. Hey Patrick, This is just a guess, but on line 3 of http://gist.github.com/386125, ActionView::Helpers is being mixed in to the main object, which means it's methods are made accessible to every single object in the system. It's very likely that it is overriding methods that are deeper down the stack. Try moving that include statement inside the ExampleGroup (i.e. inside the describe block). If that doesn't work, please run the specs with the -b flag, which produces a full backtrace, and then gist the output for us. HTH, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From patrick at collinatorstudios.com Sat May 1 08:09:54 2010 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Sat, 1 May 2010 05:09:54 -0700 (PDT) Subject: [rspec-users] update_attributes fails in rake spec but not in script/spec??? In-Reply-To: <28C71138-5872-43E0-8A86-1494E198AAFA@gmail.com> References: <28C71138-5872-43E0-8A86-1494E198AAFA@gmail.com> Message-ID: > ActionView::Helpers is being mixed in to the main object, which means it's > methods are made accessible to every single object in the system. It's very > likely that it is overriding methods Hi David, Ahh.. Thank you very much, that was indeed the problem. rake spec now passes all test. Patrick J. Collins http://collinatorstudios.com From tero at tilus.net Sat May 1 15:59:25 2010 From: tero at tilus.net (Tero Tilus) Date: Sat, 01 May 2010 22:59:25 +0300 Subject: [rspec-users] Good practices on spec'ing views? In-Reply-To: References: Message-ID: <1272743043-sup-7238@tilus.net> Stefan Kanev, 2010-04-30 11:26: > And most importantly, how does the process of writing view specs > feel? It sucks. ;) I don't feel like getting any return on the investment, so I don't write them. IMO views should be about looks, and looks only. The most prominent regression issue with views (as I regard them) is getting browsers to render them right (enough). If somebody does (even partially) automatized (even single browser) render testing, I'm all ears. -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From patrick at collinatorstudios.com Sun May 2 02:48:23 2010 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Sat, 1 May 2010 23:48:23 -0700 (PDT) Subject: [rspec-users] named route failing in class spec Message-ID: I have something like: class Foo def initialize(template) @template = template end def link link_to "foo", foo_path end def method_missing(*args, &block) @template.send(*args, &block) end end ... before(:all) do @foo = Foo.new(self) end it "should have a link" do @foo.link.should match /href/ end ... But I get this error: NoMethodError in 'FooRenderer should have a link' undefined method `foo_path' for # ... What can I include in my spec to get foo_path to be recognized? Thank you. Patrick J. Collins http://collinatorstudios.com From dchelimsky at gmail.com Sun May 2 09:07:11 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 2 May 2010 08:07:11 -0500 Subject: [rspec-users] named route failing in class spec In-Reply-To: References: Message-ID: <72A0EC1F-7D53-4E10-A5E9-0310082A17E2@gmail.com> On May 2, 2010, at 1:48 AM, Patrick J. Collins wrote: > I have something like: > > class Foo > > def initialize(template) > @template = template > end > > def link > link_to "foo", foo_path > end > > def method_missing(*args, &block) > @template.send(*args, &block) > end > end > > ... > before(:all) do > @foo = Foo.new(self) > end > > it "should have a link" do > @foo.link.should match /href/ > end > > ... But I get this error: > > NoMethodError in 'FooRenderer should have a link' > undefined method `foo_path' for > # > > ... What can I include in my spec to get foo_path to be recognized? Whate versions of ruby, rspec, and rails are you using? Please make it a habit to include this information in queries like this. From patrick at collinatorstudios.com Sun May 2 12:51:42 2010 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Sun, 2 May 2010 09:51:42 -0700 (PDT) Subject: [rspec-users] named route failing in class spec In-Reply-To: <72A0EC1F-7D53-4E10-A5E9-0310082A17E2@gmail.com> References: <72A0EC1F-7D53-4E10-A5E9-0310082A17E2@gmail.com> Message-ID: > Whate versions of ruby, rspec, and rails are you using? Please make it a habit to include this information in queries like this. ruby 1.8.7 rails 2.3.5 rspec 1.3.0 Patrick J. Collins http://collinatorstudios.com From dchelimsky at gmail.com Sun May 2 14:23:14 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 2 May 2010 13:23:14 -0500 Subject: [rspec-users] named route failing in class spec In-Reply-To: References: Message-ID: On Sun, May 2, 2010 at 1:48 AM, Patrick J. Collins wrote: > I have something like: > > class Foo > > ?def initialize(template) > ? ?@template = template > ?end > > ?def link > ? ?link_to "foo", foo_path > ?end > > ?def method_missing(*args, &block) > ? ?@template.send(*args, &block) > ?end > end > > ... > before(:all) do > ?@foo = Foo.new(self) > end Generally speaking, before(:each) is a better choice than before(:all). Each example gets run in its own instance, and using before(:all) risks leaking state from example to example. The pattern that you're implementing here is called the Self-Shunt Pattern, in which the example itself acts like a player in the code being tested. This is usually done to instrument the code so the example can observe calls made to other objects (like a mock). This is a pattern that I believe pre-dates mock objects, and is rarely implemented these days because mocks allow us to better separate things. Of course, this is a bit different from what's going on here. Here the example is being used as a delegate to handle services not available to the object. Named routes are made available to controller, view, and helper specs, so you can get them by either storing this file in any of those folders (spec/helpers, for example). HTH, David > it "should have a link" do > ?@foo.link.should match /href/ > end > > ... ?But I get this error: > > NoMethodError in 'FooRenderer should have a link' > undefined method `foo_path' for > # > > ... ?What can I include in my spec to get foo_path to be recognized? > From patrick at collinatorstudios.com Sun May 2 20:40:17 2010 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Sun, 2 May 2010 17:40:17 -0700 (PDT) Subject: [rspec-users] named route failing in class spec In-Reply-To: References: Message-ID: > This is a pattern that I believe pre-dates mock objects, and is rarely > implemented these days because mocks allow us to better separate things. Hi David, As I am still quite new to rspec, my way of working has been purely based off of my own best guess of how to do something... This is the reason why I am seeking some conversation and guidance from an Rspec expert (still am waiting to make that happen btw). Anyway, as I am a bit fuzzy on this, would you please give me a quick demonstration of how you would structure a test for /href/ that would utilize a more modern approach? Thank you. Patrick J. Collins http://collinatorstudios.com From longhiandrea at gmail.com Mon May 3 07:06:20 2010 From: longhiandrea at gmail.com (andrea longhi) Date: Mon, 3 May 2010 04:06:20 -0700 (PDT) Subject: [rspec-users] Error: can't convert Rspec::Mocks::Mock to String Message-ID: Hello *, I started today to test rspec current beta with ruby 1.9.2 and rails 3.0. I created a basic app with a scaffold. I am experiencing a lot of failures in the geneated controller spec. I am pasting the complete error string: can't convert Rspec::Mocks::Mock to String (Rspec::Mocks::Mock#to_str gives Rspec::Mocks::Mock) This is my current rspec gems setup: rspec (2.0.0.beta.8) rspec-core (2.0.0.beta.8) rspec-expectations (2.0.0.beta.8) rspec-mocks (2.0.0.beta.8) rspec-rails (2.0.0.beta.8) Of course no error is raised using ruby 1.9.1 or 1.8.7 Am I missing something? regards Andrea From dchelimsky at gmail.com Mon May 3 08:14:17 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 3 May 2010 07:14:17 -0500 Subject: [rspec-users] Error: can't convert Rspec::Mocks::Mock to String In-Reply-To: References: Message-ID: On May 3, 2010, at 6:06 AM, andrea longhi wrote: > Hello *, > I started today to test rspec current beta with ruby 1.9.2 and rails > 3.0. I created a basic app with a scaffold. I am experiencing a lot of > failures in the geneated controller spec. I am pasting the complete > error string: > > can't convert Rspec::Mocks::Mock to String (Rspec::Mocks::Mock#to_str > gives Rspec::Mocks::Mock) > > This is my current rspec gems setup: > > rspec (2.0.0.beta.8) > rspec-core (2.0.0.beta.8) > rspec-expectations (2.0.0.beta.8) > rspec-mocks (2.0.0.beta.8) > rspec-rails (2.0.0.beta.8) > > Of course no error is raised using ruby 1.9.1 or 1.8.7 > Am I missing something? > > regards > Andrea I see the same error (hadn't run against 1.9.2 in a while). Reported to http://github.com/rspec/rspec-rails/issues/issue/41 -------------- next part -------------- An HTML attachment was scrubbed... URL: From longhiandrea at gmail.com Mon May 3 09:22:22 2010 From: longhiandrea at gmail.com (andrea longhi) Date: Mon, 3 May 2010 06:22:22 -0700 (PDT) Subject: [rspec-users] Error: can't convert Rspec::Mocks::Mock to String In-Reply-To: References: Message-ID: <53e4ee6b-e52e-4c88-bcf6-ae7be28902ff@k41g2000yqb.googlegroups.com> On 3 Mag, 14:14, David Chelimsky wrote: > I see the same error (hadn't run against 1.9.2 in a while). Reported tohttp://github.com/rspec/rspec-rails/issues/issue/41 Thanks David. I added this to my spec_helper.rb file Rspec::Mocks::Mock.module_eval do alias to_str to_s end and now it seems to work properly with no side effects, at least for now regards Andrea From timcharper at gmail.com Mon May 3 14:35:08 2010 From: timcharper at gmail.com (Tim Harper) Date: Mon, 3 May 2010 12:35:08 -0600 Subject: [rspec-users] Kernel#debugger reminder method is unhelpful Message-ID: I'm not exactly sure what the motivation behind the "debugger" catch was, perhaps a convenience method to allow your code to remain littered with debugger statements? At any rate, it's obstructed my normal use of ruby-debug, and regardless of whether I've passed the -d or --debug flag, it still complains that the debugger is ignored unless if I use the rdebug wrapper. require 'ruby-debug'; debugger # <- does not work under rspec 2.0, regardless if -d or --debug was provided # ^ This is how you use the debugger with spork, effectively -------------- next part -------------- An HTML attachment was scrubbed... URL: From timcharper at gmail.com Mon May 3 14:37:50 2010 From: timcharper at gmail.com (Tim Harper) Date: Mon, 3 May 2010 12:37:50 -0600 Subject: [rspec-users] Kernel#debugger reminder method is unhelpful In-Reply-To: References: Message-ID: Actually, now that I think about it, Spork claims the Kernel#debugger method before Rspec checks if it should install it's catch, so it might be fine. Still, I would prefer if if the above "require 'ruby-debug'; debugger" convention still worked. Tim On Mon, May 3, 2010 at 12:35 PM, Tim Harper wrote: > I'm not exactly sure what the motivation behind the "debugger" catch was, > perhaps a convenience method to allow your code to remain littered with > debugger statements? At any rate, it's obstructed my normal use of > ruby-debug, and regardless of whether I've passed the -d or --debug flag, it > still complains that the debugger is ignored unless if I use the rdebug > wrapper. > > > require 'ruby-debug'; debugger # <- does not work under rspec 2.0, > regardless if -d or --debug was provided > > # ^ This is how you use the debugger with spork, effectively > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timcharper at gmail.com Mon May 3 15:49:39 2010 From: timcharper at gmail.com (Tim Harper) Date: Mon, 3 May 2010 13:49:39 -0600 Subject: [rspec-users] Kernel#debugger reminder method is unhelpful In-Reply-To: References: Message-ID: On Mon, May 3, 2010 at 12:37 PM, Tim Harper wrote: > Actually, now that I think about it, Spork claims the Kernel#debugger > method before Rspec checks if it should install it's catch, so it might be > fine. > > Still, I would prefer if if the above "require 'ruby-debug'; debugger" > convention still worked. > > Tim > This patch resolves the issue: http://github.com/timcharper/rspec-core/commit/c476e088ebabb4a89c8566be4fa07849d88271ac Here is a related bug report: http://github.com/rspec/rspec-core/issues/#issue/24 -------------- next part -------------- An HTML attachment was scrubbed... URL: From francisco.licea at gmail.com Tue May 4 15:51:05 2010 From: francisco.licea at gmail.com (Frank) Date: Tue, 4 May 2010 12:51:05 -0700 (PDT) Subject: [rspec-users] Expecting an array but getting a string using webrat Message-ID: Hi Guys, I'm new to webrat and I've encountered a problem. I have a nested form that I've created using the steps similar to the Rails Casts http://railscasts.com/episodes/75-complex-forms-part-3 As context, I have a form for programming exercises with a title and description. The form also has a field for the associated Hint object, just a regular text area field for the hint text. When I submit a form using webrat and cucumber my application receives 'params' with: "new_hint_attributes"=>"[{\"text\"=>\"This is hint 1\"}]" The key 'new_hint_attributes' maps to a string causing the application to crash during a cucumber test. But when I submit the form using the browser my application receives 'params' with: "new_hint_attributes"=>[{"text"=>"This is hint 1"}] The key 'new_hint_attributes' maps to an array and everything works fine. I was wondering what I might be doing wrong. Also, I was wondering if this ticket my be related: https://webrat.lighthouseapp.com/projects/10503/tickets/259-webratmechanize-treats-array-as-string From zach.dennis at gmail.com Wed May 5 14:23:44 2010 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 5 May 2010 14:23:44 -0400 Subject: [rspec-users] Good practices on spec'ing views? In-Reply-To: References: Message-ID: On Fri, Apr 30, 2010 at 4:26 AM, Stefan Kanev wrote: > Hey guys. > > I've been doing RSpec for more than a year by now, yet I cannot help but > feel that I've never got a single view spec right. I can see that I have > very few view specs and that my views tend be a lot messier than everything > else. I've read the chapter in the RSpec book about spec'ing views, but I > still think I'm not getting it right. > > Assuming that I'm a view spec noob, would you guys care to share your > experience with writing them? What works and what doesn't? What should I > avoid at all cost? And most importantly, how does the process of writing > view specs feel? > Before Cucumber came onto the scene view specs were a lot more prevalent and relevant. Cucumber does an excellent job of allowing us to drive the implementation the views based on what our scenarios need. When Cucumber is not being used, I find view specs do offer a benefit, but when using Cucumber, I find that takes the cake to driving the view implementation. These days, I always use Cucumber though, so it's been a while since I've written view specs. In The Rspec Book, section 24.6 (chapter 24), "When I write view specs" offers some tips for determining when to write view specs. Have you read this section? Zach -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) http://ideafoundry.info/behavior-driven-development (first rate BDD training) @zachdennis (twitter) -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.rooney62 at googlemail.com Thu May 6 05:02:02 2010 From: ben.rooney62 at googlemail.com (ben rooney) Date: Thu, 6 May 2010 10:02:02 +0100 Subject: [rspec-users] Failing test despite "expected" and "got" being identical ... Message-ID: Slightly flummoxed on this one. Spec::Mocks::MockExpectationError in 'ChartEventsController handling GET /chart_events should find all chart_events given a value' expected: ([:all, {:conditions=>["value LIKE ?", "%chart_event%"]}]) got: ([:all, {:conditions=>["value LIKE ?", "%chart_event%"]}]) In other words it got exactly what it expected, but, er, failed? Controller: if params[:q] @chart_events = ChartEvent.find(:all, :conditions =>['value LIKE ?', "%#{(params[:q])}%"]) else @chart_events = ChartEvent.all(:order=>'value') end controller_spec before do @chart_event = mock_model(ChartEvent, :value => "chart_event") ChartEvent.stub!(:find).and_return([@chart_event]) end it "should find all chart_events given a value" do ChartEvent.should_receive(:find).with([:all, {:conditions=>["value LIKE ?", "%#{@chart_event.value}%"]}]).and_return([@chart_event]) get :index, :q => @chart_event.value end From rick.denatale at gmail.com Thu May 6 09:47:01 2010 From: rick.denatale at gmail.com (Rick DeNatale) Date: Thu, 6 May 2010 09:47:01 -0400 Subject: [rspec-users] Failing test despite "expected" and "got" being identical ... In-Reply-To: References: Message-ID: On Thu, May 6, 2010 at 5:02 AM, ben rooney wrote: > Slightly flummoxed on this one. > > Spec::Mocks::MockExpectationError in 'ChartEventsController handling > GET /chart_events should find all chart_events given a value' > ?expected: ([:all, {:conditions=>["value LIKE ?", "%chart_event%"]}]) > ? ? ? got: ([:all, {:conditions=>["value LIKE ?", "%chart_event%"]}]) > > In other words it got exactly what it expected, but, er, failed? > > Controller: > ? ?if params[:q] > ? ? ?@chart_events = ChartEvent.find(:all, :conditions =>['value LIKE > ?', "%#{(params[:q])}%"]) > ? ?else > ? ? ?@chart_events = ChartEvent.all(:order=>'value') > ? ?end > > > controller_spec > ?before do > ? ?@chart_event ? ? = mock_model(ChartEvent, :value => "chart_event") > ? ?ChartEvent.stub!(:find).and_return([@chart_event]) > ?end > > ?it "should find all chart_events given a value" do > ? ?ChartEvent.should_receive(:find).with([:all, {:conditions=>["value > LIKE ?", "%#{@chart_event.value}%"]}]).and_return([@chart_event]) > ? ?get :index, :q => @chart_event.value > ?end I think you want ChartEvent.should_receive(:find).with(:all, {:conditions=>["value LIKE ?", "%#{@chart_event.value}%"]})... The output from the message expectation failure is a bit confusing, but the argument list to the with method should look like the argument list to the expected method. The expectation here is that find should get one argument, an array with a symbol and a hash, rather than two parameters, a symbol and a hash. It would be better if the failure were reported like this: expected: ([:all, {:conditions=>["value LIKE ?", "%chart_event%"]}]) got: (:all, {:conditions=>["value LIKE ?", "%chart_event%"]}) -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From dchelimsky at gmail.com Thu May 6 11:04:49 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 6 May 2010 10:04:49 -0500 Subject: [rspec-users] Failing test despite "expected" and "got" being identical ... In-Reply-To: References: Message-ID: On May 6, 2010, at 8:47 AM, Rick DeNatale wrote: > On Thu, May 6, 2010 at 5:02 AM, ben rooney wrote: >> Slightly flummoxed on this one. >> >> Spec::Mocks::MockExpectationError in 'ChartEventsController handling >> GET /chart_events should find all chart_events given a value' >> expected: ([:all, {:conditions=>["value LIKE ?", "%chart_event%"]}]) >> got: ([:all, {:conditions=>["value LIKE ?", "%chart_event%"]}]) >> >> In other words it got exactly what it expected, but, er, failed? >> >> Controller: >> if params[:q] >> @chart_events = ChartEvent.find(:all, :conditions =>['value LIKE >> ?', "%#{(params[:q])}%"]) >> else >> @chart_events = ChartEvent.all(:order=>'value') >> end >> >> >> controller_spec >> before do >> @chart_event = mock_model(ChartEvent, :value => "chart_event") >> ChartEvent.stub!(:find).and_return([@chart_event]) >> end >> >> it "should find all chart_events given a value" do >> ChartEvent.should_receive(:find).with([:all, {:conditions=>["value >> LIKE ?", "%#{@chart_event.value}%"]}]).and_return([@chart_event]) >> get :index, :q => @chart_event.value >> end > > I think you want ChartEvent.should_receive(:find).with(:all, > {:conditions=>["value LIKE ?", "%#{@chart_event.value}%"]})... > > The output from the message expectation failure is a bit confusing, > but the argument list to the with method should look like the argument > list to the expected method. The expectation here is that find should > get one argument, an array with a symbol and a hash, rather than two > parameters, a symbol and a hash. > > It would be better if the failure were reported like this: > > expected: ([:all, {:conditions=>["value LIKE ?", "%chart_event%"]}]) > got: (:all, {:conditions=>["value LIKE ?", "%chart_event%"]}) > FYI - it _is_ reported this way in rspec-2. From phillipkoebbe at gmail.com Thu May 6 11:09:31 2010 From: phillipkoebbe at gmail.com (Phillip Koebbe) Date: Thu, 06 May 2010 10:09:31 -0500 Subject: [rspec-users] and_return question Message-ID: <4BE2DBAB.5080402@gmail.com> Are these two forms theoretically functionally equivalent: 1) car = stub_model(Car) Car.stub(:new).and_return(car) 2) Car.stub(:new).and_return(stub_model(Car)) I ask because I thought they were, but just hit something that suggests they are not. I was originally using the first form, but then thought I'd shorten it up a little (especially since nothing special is happening in the stub_model call), so I changed it to form 2. But when I did, I got an error: NoMethodError in 'Web::Agent::NelliesController get :new should assign to @nelly' You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.id= /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/object/misc.rb:39:in `returning' ./spec/controllers/web/agent/nellies_controller_spec.rb:140: script/spec:10: Line 140 of the spec was where I was using form 2. I change it back to form 1 and the error went away. Thoughts? Peace, Phillip From ben.rooney62 at googlemail.com Thu May 6 11:54:19 2010 From: ben.rooney62 at googlemail.com (ben rooney) Date: Thu, 6 May 2010 16:54:19 +0100 Subject: [rspec-users] Failing test despite "expected" and "got" being identical ... Message-ID: Thanks guys The law of posting questions came into force. About three minutes after posting my q, I found my mistake (which was exactly as you said). I figured I must have done something wrong, so went back and started again, but it was the reporting that was baffling me - and that is already being sorted. Many thanks Ben From lbocseg at yahoo.com.br Thu May 6 19:42:53 2010 From: lbocseg at yahoo.com.br (Rodrigo Rosenfeld Rosas) Date: Thu, 06 May 2010 20:42:53 -0300 Subject: [rspec-users] RSpec tasks, JRuby and rvm Message-ID: <4BE353FD.6090509@yahoo.com.br> I've been playing with rvm these days and I had a bad surprise today. $ rvm install jruby $ rvm jruby $ rake test failed... Of course you didn't understand. I didn't explain yet... I've written a Rakefile following RSpec homepage instructions and adding some options to ruby (namely "--ng", for working with nailgun support). But the error seems to be related to gems access. If I run the RSpec command from a terminal where I executed "rvm jruby", it works. In another terminal it won't work. I'm testing a Java Maven project with JRuby and RSpec. It was working prior to rvm use. But calling the "ruby" executable using the full path, as RSpec tasks does, doesn't seem to suffice. "rvm jruby" probably sets up a proper environment that is not reproduced by RSpec when calling the configured ruby interpreter. Of course I could contact the RVM developers about this, but I would like to understand first why RSpec needs to spawn a separate process in its task... Does anyone here knows the reason? Thanks in advance... Rodrigo. __________________________________________________ Fa?a liga??es para outros computadores com o novo Yahoo! Messenger http://br.beta.messenger.yahoo.com/ From dchelimsky at gmail.com Thu May 6 22:47:44 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 6 May 2010 21:47:44 -0500 Subject: [rspec-users] RSpec tasks, JRuby and rvm In-Reply-To: <4BE353FD.6090509@yahoo.com.br> References: <4BE353FD.6090509@yahoo.com.br> Message-ID: <0F7D8208-8A63-49E9-B9C5-015F658D43B9@gmail.com> On May 6, 2010, at 6:42 PM, Rodrigo Rosenfeld Rosas wrote: > I've been playing with rvm these days and I had a bad surprise today. > > $ rvm install jruby > $ rvm jruby > $ rake test > > failed... > > Of course you didn't understand. I didn't explain yet... > > I've written a Rakefile following RSpec homepage instructions and adding some options to ruby (namely "--ng", for working with nailgun support). But the error seems to be related to gems access. If I run the RSpec command from a terminal where I executed "rvm jruby", it works. In another terminal it won't work. > > I'm testing a Java Maven project with JRuby and RSpec. It was working prior to rvm use. But calling the "ruby" executable using the full path, as RSpec tasks does, doesn't seem to suffice. "rvm jruby" probably sets up a proper environment that is not reproduced by RSpec when calling the configured ruby interpreter. > > Of course I could contact the RVM developers about this, but I would like to understand first why RSpec needs to spawn a separate process in its task... Does anyone here knows the reason? This has been an open issue for a long time. We wrote the task that way originally because there are some cases in which we need to spawn a separate process (if you want to run rcov, for example). What we'd like to do is have it shell out in those cases, but otherwise just invoke the rspec runner directly. Just haven't prioritized it. If anybody wants to make a patch for this, I'd be glad to merge it (assuming it's sound and spec'd). We need this for rspec 1 and rspec 2. David From dchelimsky at gmail.com Thu May 6 22:51:03 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 6 May 2010 21:51:03 -0500 Subject: [rspec-users] and_return question In-Reply-To: <4BE2DBAB.5080402@gmail.com> References: <4BE2DBAB.5080402@gmail.com> Message-ID: <2CF48BA9-A8A4-472A-8285-2881FC70740F@gmail.com> On May 6, 2010, at 10:09 AM, Phillip Koebbe wrote: > Are these two forms theoretically functionally equivalent: > > 1) > > car = stub_model(Car) > Car.stub(:new).and_return(car) > > 2) > > Car.stub(:new).and_return(stub_model(Car)) > > I ask because I thought they were, but just hit something that suggests they are not. I was originally using the first form, but then thought I'd shorten it up a little (especially since nothing special is happening in the stub_model call), so I changed it to form 2. But when I did, I got an error: > > NoMethodError in 'Web::Agent::NelliesController get :new should assign to @nelly' > You have a nil object when you didn't expect it! > You might have expected an instance of ActiveRecord::Base. > The error occurred while evaluating nil.id= > /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/object/misc.rb:39:in `returning' > ./spec/controllers/web/agent/nellies_controller_spec.rb:140: > script/spec:10: > > Line 140 of the spec was where I was using form 2. I change it back to form 1 and the error went away. > > Thoughts? stub_model(Car) invokes Car.new. The call to Car.stub(:new) overrides new() before stub_model(Car) is evaluated. Make sense? From longhiandrea at gmail.com Fri May 7 06:59:29 2010 From: longhiandrea at gmail.com (andrea longhi) Date: Fri, 7 May 2010 03:59:29 -0700 (PDT) Subject: [rspec-users] Rspec beta8: helper methods issues Message-ID: <7ad93cf5-38d1-4717-9bd3-1ce0b9c7da8a@d19g2000yqf.googlegroups.com> Hello everybody, I am experiencing the following problems, I googled quickly but I couldn't find any documentation or solution to those issues: 1) the generator rails g rspec:helper does nothing; 2) there seems to be no way to test helper methods as I used to do... for example the following spec it 'should set monday as first day of the week' do helper.ordered_day_names.first.should == 'Lun' end raises the error undefined local variable or method `helper' for # 3) testing views where I call helper methods I need to explicitly stub out the helper methods, even if I include the helper module. This all happens with rspec beta 8, rails 3.0beta3, and ruby 1.9.2 Regards Andrea From phillipkoebbe at gmail.com Fri May 7 07:10:53 2010 From: phillipkoebbe at gmail.com (Phillip Koebbe) Date: Fri, 07 May 2010 06:10:53 -0500 Subject: [rspec-users] and_return question In-Reply-To: <2CF48BA9-A8A4-472A-8285-2881FC70740F@gmail.com> References: <4BE2DBAB.5080402@gmail.com> <2CF48BA9-A8A4-472A-8285-2881FC70740F@gmail.com> Message-ID: <4BE3F53D.2010402@gmail.com> On 2010-05-06 9:51 PM, David Chelimsky wrote: > On May 6, 2010, at 10:09 AM, Phillip Koebbe wrote: > >> Are these two forms theoretically functionally equivalent: >> >> 1) >> >> car = stub_model(Car) >> Car.stub(:new).and_return(car) >> >> 2) >> >> Car.stub(:new).and_return(stub_model(Car)) >> >> I ask because I thought they were, but just hit something that suggests they are not. I was originally using the first form, but then thought I'd shorten it up a little (especially since nothing special is happening in the stub_model call), so I changed it to form 2. But when I did, I got an error: >> >> NoMethodError in 'Web::Agent::NelliesController get :new should assign to @nelly' >> You have a nil object when you didn't expect it! >> You might have expected an instance of ActiveRecord::Base. >> The error occurred while evaluating nil.id= >> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/object/misc.rb:39:in `returning' >> ./spec/controllers/web/agent/nellies_controller_spec.rb:140: >> script/spec:10: >> >> Line 140 of the spec was where I was using form 2. I change it back to form 1 and the error went away. >> >> Thoughts? > stub_model(Car) invokes Car.new. The call to Car.stub(:new) overrides new() before stub_model(Car) is evaluated. Make sense? Thank, David! Yes, it makes perfect sense. I have use form 2 a few times before without any difficulty, and hadn't really thought about it. In this particular case, though, I was doing something just slightly different that happened to expose this very important detail. Peace, Phillip From jam5t3r.lists at gmail.com Fri May 7 07:39:14 2010 From: jam5t3r.lists at gmail.com (Jamie D) Date: Fri, 7 May 2010 12:39:14 +0100 Subject: [rspec-users] Rspec beta8: helper methods issues In-Reply-To: <7ad93cf5-38d1-4717-9bd3-1ce0b9c7da8a@d19g2000yqf.googlegroups.com> References: <7ad93cf5-38d1-4717-9bd3-1ce0b9c7da8a@d19g2000yqf.googlegroups.com> Message-ID: from: http://github.com/rspec/rspec-rails - no helper specs (yet) - no routing specs (yet) - only works with ActiveRecord (for now) On 7 May 2010 11:59, andrea longhi wrote: > Hello everybody, > > I am experiencing the following problems, I googled quickly but I > couldn't find any documentation or solution to those issues: > > 1) the generator rails g rspec:helper does nothing; > 2) there seems to be no way to test helper methods as I used to do... > for example > the following spec > it 'should set monday as first day of the week' do > helper.ordered_day_names.first.should == 'Lun' > end > raises the error undefined local variable or method `helper' for > # > 3) testing views where I call helper methods I need to explicitly stub > out the helper methods, even if I include the helper module. > > This all happens with rspec beta 8, rails 3.0beta3, and ruby 1.9.2 > > Regards > Andrea > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Fri May 7 07:37:19 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 7 May 2010 06:37:19 -0500 Subject: [rspec-users] Rspec beta8: helper methods issues In-Reply-To: <7ad93cf5-38d1-4717-9bd3-1ce0b9c7da8a@d19g2000yqf.googlegroups.com> References: <7ad93cf5-38d1-4717-9bd3-1ce0b9c7da8a@d19g2000yqf.googlegroups.com> Message-ID: On May 7, 2010, at 5:59 AM, andrea longhi wrote: > Hello everybody, > > I am experiencing the following problems, I googled quickly but I > couldn't find any documentation or solution to those issues: > > 1) the generator rails g rspec:helper does nothing; See Known Issues on http://github.com/rspec/rspec-rails. Helper specs are coming soon - certainly before any final release - but not yet. > 2) there seems to be no way to test helper methods as I used to do... > for example > the following spec > it 'should set monday as first day of the week' do > helper.ordered_day_names.first.should == 'Lun' > end > raises the error undefined local variable or method `helper' for > # > 3) testing views where I call helper methods I need to explicitly stub > out the helper methods, even if I include the helper module. > > This all happens with rspec beta 8, rails 3.0beta3, and ruby 1.9.2 > > Regards > Andrea > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Fri May 7 08:35:52 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 7 May 2010 07:35:52 -0500 Subject: [rspec-users] Expecting an array but getting a string using webrat In-Reply-To: References: Message-ID: On May 4, 2010, at 2:51 PM, Frank wrote: > Hi Guys, > > I'm new to webrat and I've encountered a problem. I have a nested form > that I've created using the steps similar to the Rails Casts > http://railscasts.com/episodes/75-complex-forms-part-3 > > As context, I have a form for programming exercises with a title and > description. The form also has a field for the associated Hint object, > just a regular text area field for the hint text. > > When I submit a form using webrat and cucumber my application receives > 'params' with: > > "new_hint_attributes"=>"[{\"text\"=>\"This is hint 1\"}]" > > The key 'new_hint_attributes' maps to a string causing the application > to crash during a cucumber test. > > But when I submit the form using the browser my application receives > 'params' with: > > "new_hint_attributes"=>[{"text"=>"This is hint 1"}] > > The key 'new_hint_attributes' maps to an array and everything works > fine. > > I was wondering what I might be doing wrong. > > Also, I was wondering if this ticket my be related: > https://webrat.lighthouseapp.com/projects/10503/tickets/259-webratmechanize-treats-array-as-string I'm not sure about this myself, but you may want to check the Cucumber and Webrat lists since those are the libraries you're seeing trouble with: http://groups.google.com/group/cukes http://groups.google.com/group/webrat From dchelimsky at gmail.com Fri May 7 08:36:44 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 7 May 2010 07:36:44 -0500 Subject: [rspec-users] Expecting an array but getting a string using webrat In-Reply-To: References: Message-ID: On May 7, 2010, at 7:35 AM, David Chelimsky wrote: > > On May 4, 2010, at 2:51 PM, Frank wrote: > >> Hi Guys, >> >> I'm new to webrat and I've encountered a problem. I have a nested form >> that I've created using the steps similar to the Rails Casts >> http://railscasts.com/episodes/75-complex-forms-part-3 >> >> As context, I have a form for programming exercises with a title and >> description. The form also has a field for the associated Hint object, >> just a regular text area field for the hint text. >> >> When I submit a form using webrat and cucumber my application receives >> 'params' with: >> >> "new_hint_attributes"=>"[{\"text\"=>\"This is hint 1\"}]" >> >> The key 'new_hint_attributes' maps to a string causing the application >> to crash during a cucumber test. >> >> But when I submit the form using the browser my application receives >> 'params' with: >> >> "new_hint_attributes"=>[{"text"=>"This is hint 1"}] >> >> The key 'new_hint_attributes' maps to an array and everything works >> fine. >> >> I was wondering what I might be doing wrong. >> >> Also, I was wondering if this ticket my be related: >> https://webrat.lighthouseapp.com/projects/10503/tickets/259-webratmechanize-treats-array-as-string > > I'm not sure about this myself, but you may want to check the Cucumber and Webrat lists since those are the libraries you're seeing trouble with: > > http://groups.google.com/group/cukes > http://groups.google.com/group/webrat Ah - I see you already did :) http://groups.google.com/group/webrat/browse_thread/thread/d8e6bac15cb8fbd7 Feel free to post back here if you find a solution. Thanks, David From lists at ruby-forum.com Fri May 7 09:06:12 2010 From: lists at ruby-forum.com (Amit Kulkarni) Date: Fri, 7 May 2010 15:06:12 +0200 Subject: [rspec-users] Rspec model generate problem Message-ID: <01c1cd91e749c8cf3104e2b087fa4f5c@ruby-forum.com> Hello, I am currently working on Ubuntu machine in which there is already a spec file generated which has some models So i just updated by entering the command "ruby script/generate rspec" Now when i try to generate rspec model then it shows error as "The name 'User' is either already used in your application or reserved by Ruby on Rails.Please choose an alternative and run this generator again." I am getting this for almost for every rspec model Please suggest. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri May 7 09:08:25 2010 From: lists at ruby-forum.com (Amit Kulkarni) Date: Fri, 7 May 2010 15:08:25 +0200 Subject: [rspec-users] Rspec model generation problem Message-ID: Hello, I am currently working on Ubuntu machine in which there is already a spec file generated which has some models So i just updated by entering the command "ruby script/generate rspec" Now when i try to generate rspec model then it shows error as "The name 'User' is either already used in your application or reserved by Ruby on Rails.Please choose an alternative and run this generator again." I am getting this for almost for every rspec model Please suggest. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri May 7 09:16:31 2010 From: lists at ruby-forum.com (Amit Kulkarni) Date: Fri, 7 May 2010 15:16:31 +0200 Subject: [rspec-users] Rspec model generation problem In-Reply-To: References: Message-ID: <956346a7aaae4c9c715a2add8889aae3@ruby-forum.com> Amit Kulkarni wrote: > Hello, > I am currently working on Ubuntu machine in which there is already a > spec file generated which has some models > So i just updated by entering the command "ruby script/generate rspec" > Now when i try to generate rspec model then it shows error as > > "The name 'User' is either already used in your application or reserved > by Ruby on Rails.Please choose an alternative and run this generator > again." > > I am getting this for almost for every rspec model > Please suggest. Versions which i am using Rails 2.3.4 rspec 1.3.0 rspec-rails (1.3.2) ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux] cucumber (0.7.2) cucumber-rails (0.3.1) -- Posted via http://www.ruby-forum.com/. From jbrainsberger at gmail.com Fri May 7 21:49:52 2010 From: jbrainsberger at gmail.com (J. B. Rainsberger) Date: Fri, 07 May 2010 19:49:52 -0600 Subject: [rspec-users] Good practices on spec'ing views? In-Reply-To: References: Message-ID: <4BE4C340.7000105@gmail.com> Stefan Kanev wrote: > I've been doing RSpec for more than a year by now, yet I cannot help but > feel that I've never got a single view spec right. I can see that I have > very few view specs and that my views tend be a lot messier than > everything else. I've read the chapter in the RSpec book about spec'ing > views, but I still think I'm not getting it right. > > Assuming that I'm a view spec noob, would you guys care to share your > experience with writing them? What works and what doesn't? What should I > avoid at all cost? And most importantly, how does the process of writing > view specs feel? I write view specs, and doing so encourages me to move behavior out of the views and into the controller. I find it easy to write specs to check how I render dynamic data, but still don't have a good feel for writing specs that check that action buttons submit the form I expect to submit. I imagine writing more of the latter kind of spec will encourage me to avoid complex form submissions. I treat view specs like any other specs: when I have a tough time writing the spec, then I rethink my design choices. -- J. B. Rainsberger :: http://www.jbrains.ca :: http://www.thecodewhisperer.com From johngferguson at gmail.com Thu May 6 21:03:08 2010 From: johngferguson at gmail.com (Jferg) Date: Thu, 6 May 2010 18:03:08 -0700 (PDT) Subject: [rspec-users] RSpec newb - why is my negative test not passing? Message-ID: <6a2592de-9b6c-40ab-b548-ca7663a8905c@d39g2000yqa.googlegroups.com> Why won't this test work? I am trying to use RSpec to drive a negative test where my code will throw an exception which it does however, the test does not pass. It fails due to my exception. However, I am using should raise_exception: ----------------------- describe "Making non-existent url tiny" do it "should raise exception" do url = "tttttt.dddddd" exception_new = Exception.new "Test URL Error" TinyUrlService.should_receive(:get).with(url).and_raise(exception_new) TinyUrlService.make_tiny(url).should raise_exception end end =========================================== Here is the code under test: ------------------------------------- require 'httparty' class TinyUrlService class InvalidUrl < Exception def intialize original_e super original_e.message end end include HTTParty base_uri 'tinyurl.com' def self.make_tiny (targetUrl) return get('/api-create.php', :query =>{:url => validate_url(targetUrl)}) end private def self.validate_url(tiny_url) get(tiny_url) return tiny_url rescue Exception => e raise InvalidUrl.new(e) end end ===================================== Here is the exception reported: TinyUrlService::InvalidUrl: Test URL Error ../lib/tiny_url_service.rb:23:in `validate_url' ../lib/tiny_url_service.rb:15:in `make_tiny' /Users/johnferguson/ruby/flitter/specs/tiny_url_spec.rb:11: -e:1:in `load' -e:1: From simon.peter.nicholls at googlemail.com Mon May 3 17:03:00 2010 From: simon.peter.nicholls at googlemail.com (Si) Date: Mon, 3 May 2010 14:03:00 -0700 (PDT) Subject: [rspec-users] Does rspec 2 have fixture support? Message-ID: <509e1c2c-196d-4515-a508-d1b1fdd8b54a@o11g2000yqj.googlegroups.com> Am I right in thinking that rspec 2, being based on Micronaut, has no Rails fixture support? I tried to get my specs running under rspec-* 2.0.0.beta.8 and Rails 3 edge, but no dice on the fixture front. I've tried controller and request specs in a new app, just in case. Same story. Looking over at Micronaut now though, it seems fixture support is a non-goal. Or am I missing something else? From rick.denatale at gmail.com Sat May 8 12:43:14 2010 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sat, 8 May 2010 12:43:14 -0400 Subject: [rspec-users] RSpec newb - why is my negative test not passing? In-Reply-To: <6a2592de-9b6c-40ab-b548-ca7663a8905c@d39g2000yqa.googlegroups.com> References: <6a2592de-9b6c-40ab-b548-ca7663a8905c@d39g2000yqa.googlegroups.com> Message-ID: On Thu, May 6, 2010 at 9:03 PM, Jferg wrote: > Why won't this test work? > > I am trying to use RSpec to drive a negative test where my code will > throw an exception which it does however, the test does not pass. ?It > fails due to my exception. ?However, I am using should > raise_exception: > ----------------------- > > describe "Making non-existent url tiny" do > > ?it "should raise exception" do > ? ?url = "tttttt.dddddd" > ? ?exception_new = Exception.new "Test URL Error" > > TinyUrlService.should_receive(:get).with(url).and_raise(exception_new) > ? ?lambda {TinyUrlService.make_tiny(url)}.should raise_exception > ?end > end -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From johngferguson at gmail.com Sat May 8 22:56:37 2010 From: johngferguson at gmail.com (Jferg) Date: Sat, 8 May 2010 19:56:37 -0700 (PDT) Subject: [rspec-users] RSpec newb - why is my negative test not passing? In-Reply-To: References: <6a2592de-9b6c-40ab-b548-ca7663a8905c@d39g2000yqa.googlegroups.com> Message-ID: Thanks, next time I'll read the documentation with more attention to what is written there. It works as you said and as is documented. On May 8, 12:43?pm, Rick DeNatale wrote: > On Thu, May 6, 2010 at 9:03 PM, Jferg wrote: > > Why won't this test work? > > > I am trying to use RSpec to drive a negative test where my code will > > throw an exception which it does however, the test does not pass. ?It > > fails due to my exception. ?However, I am using should > > raise_exception: > > ----------------------- > > > describe "Making non-existent url tiny" do > > > ?it "should raise exception" do > > ? ?url = "tttttt.dddddd" > > ? ?exception_new = Exception.new "Test URL Error" > > > TinyUrlService.should_receive(:get).with(url).and_raise(exception_new) > > ?? ?lambda {TinyUrlService.make_tiny(url)}.should raise_exception > > > ?end > > end > > -- > Rick DeNatale > > Blog:http://talklikeaduck.denhaven2.com/ > Github:http://github.com/rubyredrick > Twitter: @RickDeNatale > WWR:http://www.workingwithrails.com/person/9021-rick-denatale > LinkedIn:http://www.linkedin.com/in/rickdenatale > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > -- > You received this message because you are subscribed to the Google Groups "rspec" group. > To post to this group, send email to rspec at googlegroups.com. > To unsubscribe from this group, send email to rspec+unsubscribe at googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rspec?hl=en. From rfmpnca at gmail.com Sat May 8 15:59:13 2010 From: rfmpnca at gmail.com (RFine) Date: Sat, 8 May 2010 12:59:13 -0700 (PDT) Subject: [rspec-users] What are the common causes of rspec hanging? Message-ID: <47288417-4d60-4a08-9563-0c39b074780f@v12g2000prb.googlegroups.com> I'm responsible for a relatively large RoR application, and have been struggling with intermittent rspec "hangs" for over a year despite many debugging attempts. I realize that we can't debug my personal application here, but I'm wondering if other people could answer this thread and mention the types of bugs that have resulted in rspec hangs for me and other people with the same problem to consider. Thanks Russell From mail at rodrigoflores.org Sun May 9 08:45:29 2010 From: mail at rodrigoflores.org (Rodrigo Flores) Date: Sun, 9 May 2010 09:45:29 -0300 Subject: [rspec-users] Autospec doing nothing Message-ID: Hi When I run autospec on a rails project I get nothing. flores at Suomi(9:41)~/Code/Sabbre/camisa10 % autospec (Not running features. To run features in autotest, set AUTOFEATURE=true.) (Not running features. To run features in autotest, set AUTOFEATURE=true.) loading autotest/rails_rspec style: RailsRspec -------------------------------------------------------------------------------- (a bunch of blank lines) flores at Suomi(9:41)~/Code/Sabbre/camisa10 % Any ideas ? My Operating System is Mac OS X Snow Leopard, my ruby is 1.8.7. Rspec: 1.3.0 Rspec-Rails: 1.3.2 autotest: 4.2.9 autotest-growl : 0.2.4, 0.2.3 autotest-rails: 4.1.0 -- =================== Rodrigo L. M. Flores Computer Science Msc. Student - IME - USP Computer Science Degree - IME - USP Homepage (en): http://www.rodrigoflores.org Blog (pt-BR): http://blog.rodrigoflores.org Linux User # : 351304 Jabber: im at rodrigoflores.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at rodrigoflores.org Sun May 9 08:56:00 2010 From: mail at rodrigoflores.org (Rodrigo Flores) Date: Sun, 9 May 2010 09:56:00 -0300 Subject: [rspec-users] Autospec doing nothing In-Reply-To: References: Message-ID: Ops I searched on the list archive and I found a topic from a month ago about this. My ZenTest version is 4.3.1 My .autotest file is in my ~ and contains only require "autotest/growl" rake spec is running succesfully. On Sun, May 9, 2010 at 09:45, Rodrigo Flores wrote: > Hi > > When I run autospec on a rails project I get nothing. > > flores at Suomi(9:41)~/Code/Sabbre/camisa10 % autospec > (Not running features. To run features in autotest, set AUTOFEATURE=true.) > (Not running features. To run features in autotest, set AUTOFEATURE=true.) > loading autotest/rails_rspec > style: RailsRspec > > > > -------------------------------------------------------------------------------- > > (a bunch of blank lines) > > flores at Suomi(9:41)~/Code/Sabbre/camisa10 % > > > Any ideas ? > > My Operating System is Mac OS X Snow Leopard, my ruby is 1.8.7. > > Rspec: 1.3.0 > Rspec-Rails: 1.3.2 > autotest: 4.2.9 > autotest-growl : 0.2.4, 0.2.3 > autotest-rails: 4.1.0 > > > -- > =================== > Rodrigo L. M. Flores > Computer Science Msc. Student - IME - USP > Computer Science Degree - IME - USP > Homepage (en): http://www.rodrigoflores.org > Blog (pt-BR): http://blog.rodrigoflores.org > Linux User # : 351304 > Jabber: im at rodrigoflores.org > -- =================== Rodrigo L. M. Flores Computer Science Msc. Student - IME - USP Computer Science Degree - IME - USP Homepage (en): http://www.rodrigoflores.org Blog (pt-BR): http://blog.rodrigoflores.org Linux User # : 351304 Jabber: im at rodrigoflores.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Mon May 10 03:43:49 2010 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 10 May 2010 08:43:49 +0100 Subject: [rspec-users] What are the common causes of rspec hanging? In-Reply-To: <47288417-4d60-4a08-9563-0c39b074780f@v12g2000prb.googlegroups.com> References: <47288417-4d60-4a08-9563-0c39b074780f@v12g2000prb.googlegroups.com> Message-ID: <10FF1707-E92E-4AAB-BD36-111A645F5DB0@mattwynne.net> You might want to try running the specs with --format specdoc so you can do a better post mortem. Also remember you can look at log/test.log to see what was happening when it hung. On 8 May 2010, at 20:59, RFine wrote: > I'm responsible for a relatively large RoR application, and have been > struggling with intermittent rspec "hangs" for over a year despite > many debugging attempts. I realize that we can't debug my personal > application here, but I'm wondering if other people could answer this > thread and mention the types of bugs that have resulted in rspec hangs > for me and other people with the same problem to consider. > > Thanks > > Russell > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From rsanheim at gmail.com Mon May 10 19:51:16 2010 From: rsanheim at gmail.com (Rob Sanheim) Date: Mon, 10 May 2010 19:51:16 -0400 Subject: [rspec-users] Does rspec 2 have fixture support? In-Reply-To: <509e1c2c-196d-4515-a508-d1b1fdd8b54a@o11g2000yqj.googlegroups.com> References: <509e1c2c-196d-4515-a508-d1b1fdd8b54a@o11g2000yqj.googlegroups.com> Message-ID: I paired with Chad on Micronaut, and can confirm that fixtures were not on our priority list. Note that fixtures would be supplied by rspec-rails, though, not rspec-core (i.e. Micronaut), so other folks may be working on adding fixture support there. - Rob http://thinkrelevance.com On Mon, May 3, 2010 at 5:03 PM, Si wrote: > Am I right in thinking that rspec 2, being based on Micronaut, has no > Rails fixture support? > > I tried to get my specs running under rspec-* 2.0.0.beta.8 and Rails 3 > edge, but no dice on the fixture front. I've tried controller and > request specs in a new app, just in case. Same story. > > Looking over at Micronaut now though, it seems fixture support is a > non-goal. Or am I missing something else? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon May 10 20:03:35 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 10 May 2010 19:03:35 -0500 Subject: [rspec-users] Does rspec 2 have fixture support? In-Reply-To: References: <509e1c2c-196d-4515-a508-d1b1fdd8b54a@o11g2000yqj.googlegroups.com> Message-ID: On May 10, 2010, at 6:51 PM, Rob Sanheim wrote: > I paired with Chad on Micronaut, and can confirm that fixtures were > not on our priority list. Note that fixtures would be supplied by > rspec-rails, though, not rspec-core (i.e. Micronaut), so other folks > may be working on adding fixture support there. Not yet, but I just added an issue for it: http://github.com/rspec/rspec-rails/issues > > - Rob > > http://thinkrelevance.com > > On Mon, May 3, 2010 at 5:03 PM, Si wrote: >> Am I right in thinking that rspec 2, being based on Micronaut, has no >> Rails fixture support? >> >> I tried to get my specs running under rspec-* 2.0.0.beta.8 and Rails 3 >> edge, but no dice on the fixture front. I've tried controller and >> request specs in a new app, just in case. Same story. >> >> Looking over at Micronaut now though, it seems fixture support is a >> non-goal. Or am I missing something else? >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.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 stephen.bannasch at deanbrook.org Mon May 10 21:48:16 2010 From: stephen.bannasch at deanbrook.org (Stephen Bannasch) Date: Mon, 10 May 2010 21:48:16 -0400 Subject: [rspec-users] questions about meta-programming in a shared_examples group Message-ID: I've created a shared_examples group that helps me dry up the testing of a large set of similar rails controllers. These controllers have an html interface but mostly what I am testing with the shared_examples group is the rendering of four different forms of xml that relate to running a dynamically created Java Web Start jnlp. The html reports when running one of the controller specs looks like this: Embeddable::DataCollectorsController GET show with mime type of otml renders the requested data_collector as otml without error Here's an example of what one of the controller specs looks like: http://github.com/stepheneb/rigse/blob/master/spec/controllers/embeddable/data_collectors_controller_spec.rb require 'spec_helper' describe Embeddable::DataCollectorsController do it_should_behave_like 'an embeddable controller' def with_tags_like_an_otml_data_collector with_tag('OTDataCollector') do with_tag('source') do with_tag('OTDataGraphable') do with_tag('dataProducer') end end with_tag('xDataAxis') do with_tag('OTDataAxis') end with_tag('yDataAxis') do with_tag('OTDataAxis') end end end end I love how clearly each controller spec reads now and how the part that is different in the otml rendering stands out. But I wondered if the way I am using lambdas in the shared_examples helper is fragile and might break if internals in rspec change. The meta-programming I did to get some of this to work seemed a bit messy and I was wondering if there was a simpler way. The describe statement in the shared_examples_for 'an embeddable controller' for that example looks like this: describe "with mime type of otml" do it "renders the requested #{model_ivar_name_lambda.call} as otml without error" do The beginning of the shared_examples group looks like this: http://github.com/stepheneb/rigse/blob/master/spec/support/embeddable_controller_helper.rb shared_examples_for 'an embeddable controller' do integrate_views controller_class_lambda = lambda { self.send(:described_class) } model_class_lambda = lambda { controller_class_lambda.call.name[/(.*)Controller/, 1].singularize.constantize } model_ivar_name_lambda = lambda { model_class_lambda.call.name.delete_module.underscore_module } def with_tags_like_an_otml(model_name) self.send("with_tags_like_an_otml_#{model_name}".to_sym) end before(:each) do @model_class = model_class_lambda.call @model_ivar_name = model_ivar_name_lambda.call unless instance_variable_defined?("@#{@model_ivar_name}".to_sym) @model_ivar = instance_variable_set("@#{@model_ivar_name}", Factory.create(@model_ivar_name)) end end The method in the controller spec: with_tags_like_an_otml_data_collector is used in the shared_examples group later like this: with_tag('library') do with_tags_like_an_otml(@model_ivar_name) end From dchelimsky at gmail.com Tue May 11 01:47:44 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 11 May 2010 00:47:44 -0500 Subject: [rspec-users] questions about meta-programming in a shared_examples group In-Reply-To: References: Message-ID: <6B760086-C7E3-4A79-A6ED-2E6443ADE98C@gmail.com> Hi Stephen, On May 10, 2010, at 8:48 PM, Stephen Bannasch wrote: > I've created a shared_examples group that helps me dry up the testing of a large set of similar rails controllers. > > These controllers have an html interface but mostly what I am testing with the shared_examples group is the rendering of four different forms of xml that relate to running a dynamically created Java Web Start jnlp. > > The html reports when running one of the controller specs looks like this: > > Embeddable::DataCollectorsController GET show with mime type of otml > renders the requested data_collector as otml without error > > Here's an example of what one of the controller specs looks like: > > http://github.com/stepheneb/rigse/blob/master/spec/controllers/embeddable/data_collectors_controller_spec.rb > > require 'spec_helper' > > describe Embeddable::DataCollectorsController do > > it_should_behave_like 'an embeddable controller' > > def with_tags_like_an_otml_data_collector > with_tag('OTDataCollector') do > with_tag('source') do > with_tag('OTDataGraphable') do > with_tag('dataProducer') > end > end > with_tag('xDataAxis') do > with_tag('OTDataAxis') > end > with_tag('yDataAxis') do > with_tag('OTDataAxis') > end > end > end > > end > > I love how clearly each controller spec reads now and how the part that is different in the otml rendering stands out. > > But I wondered if the way I am using lambdas in the shared_examples helper is fragile and might break if internals in rspec change. The meta-programming I did to get some of this to work seemed a bit messy and I was wondering if there was a simpler way. The most obvious problem is that "have_tag" and "with_tag" will not be supported in rspec-rails-2. I haven't looked at it in a while, but you may want to take a look at the assert2 gem. It's mostly focused on test/unit assertions, but there is an rspec matcher named be_html_with that offers a nice dsl for something close to what you're trying to do. Check the bottom of http://groups.google.com/group/merb/browse_thread/thread/3588d3f75fa0e65c. > The describe statement in the shared_examples_for 'an embeddable controller' for that example looks like this: > > describe "with mime type of otml" do > it "renders the requested #{model_ivar_name_lambda.call} as otml without error" do > > The beginning of the shared_examples group looks like this: > > http://github.com/stepheneb/rigse/blob/master/spec/support/embeddable_controller_helper.rb > > shared_examples_for 'an embeddable controller' do > integrate_views > > controller_class_lambda = lambda { > self.send(:described_class) > } > model_class_lambda = lambda { > controller_class_lambda.call.name[/(.*)Controller/, 1].singularize.constantize > } > model_ivar_name_lambda = lambda { > model_class_lambda.call.name.delete_module.underscore_module > } > > def with_tags_like_an_otml(model_name) > self.send("with_tags_like_an_otml_#{model_name}".to_sym) > end > > before(:each) do > @model_class = model_class_lambda.call > @model_ivar_name = model_ivar_name_lambda.call > unless instance_variable_defined?("@#{@model_ivar_name}".to_sym) > @model_ivar = instance_variable_set("@#{@model_ivar_name}", > Factory.create(@model_ivar_name)) > end > end > > > The method in the controller spec: with_tags_like_an_otml_data_collector is used in the shared_examples group later like this: > > with_tag('library') do > with_tags_like_an_otml(@model_ivar_name) > end > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From cflipse at gmail.com Tue May 11 16:00:52 2010 From: cflipse at gmail.com (Chris Flipse) Date: Tue, 11 May 2010 16:00:52 -0400 Subject: [rspec-users] survey: roles in controller specs Message-ID: I have a bit of a question on how people are organizing their controller specs, once you take user roles into account. I'm not entirely sure that I've found a way to do it that feels "natural" to me. So, say I've got a controller that I want to ensure is locked down to a particular set of users. I can't decide how the layer the describes/contexts: describe PostsController do context "as a normal user" do before { logged_in } describe "POST create" do it "is forbidden" do post :create, :post => {} response.should be_forbidden end end ... Other specs .... end context "as an editor" do before { logged_in.with_role :editor } describe "POST create" do ... end end This is the direction that the flow of the language seems right to me, when it's dumped in the specdocs -- "PostsController, as a normal user POST create is forbidden", but from another standpoint, it breaks up the specification of a single method into a couple of different locations in the file, and may require duplicating quite a bit of setup. How does everyone else deal with this? -- // anything worth taking seriously is worth making fun of // http://blog.devcaffeine.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From jbrainsberger at gmail.com Tue May 11 17:23:42 2010 From: jbrainsberger at gmail.com (J. B. Rainsberger) Date: Tue, 11 May 2010 15:23:42 -0600 Subject: [rspec-users] survey: roles in controller specs In-Reply-To: References: Message-ID: <4BE9CADE.3070702@gmail.com> Chris Flipse wrote: > I have a bit of a question on how people are organizing their controller > specs, once you take user roles into account. I'm not entirely sure > that I've found a way to do it that feels "natural" to me. > This is the direction that the flow of the language seems right to me, > when it's dumped in the specdocs -- "PostsController, as a normal user > POST create is forbidden", but from another standpoint, it breaks up the > specification of a single method into a couple of different locations in > the file, and may require duplicating quite a bit of setup. > > How does everyone else deal with this? I tend to organize these specs by permissions, not roles. Instead of checking what a normal user can do or an editor can do, I simply assume that everyone can create a post (no spec required) except those who should not be permitted, for which I write a spec. All my authorization specs are of the form " is not permitted to do " and I organize them by action. -- J. B. Rainsberger :: http://www.jbrains.ca :: http://www.thecodewhisperer.com From lists at ruby-forum.com Wed May 12 09:46:46 2010 From: lists at ruby-forum.com (Sascha Popovic) Date: Wed, 12 May 2010 15:46:46 +0200 Subject: [rspec-users] Versions of RSpec & Rails Message-ID: <22b2ff9354f6f039d5e3d564b7353dd4@ruby-forum.com> Hello. I'm new to ROR and i'm trying to use RSpec. I use Rails 2.3.5. I installed RSpec and RSpec-Rails as Plugin in my Project and i installed the Gem. Then i user script/generate rspec to generate the needed files. When i want to use RSpec over Rake with "rake spec" i get the following error: ----------------------------------------------------------------- ** Invoke environment (first_time) ** Execute environment ** Invoke spec (first_time) ** Execute spec ** Invoke spec:models (first_time) ** Invoke db:test:prepare (first_time) ** Invoke db:abort_if_pending_migrations (first_time) ** Invoke environment ** Execute db:abort_if_pending_migrations rake aborted! RSpec failures D:/Workspaces/NetBeans/RubyOnRails/feeder/lib/tasks/rspec.rake:13 C:/Programme/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call' C:/Programme/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute' C:/Programme/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each' C:/Programme/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute' C:/Programme/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain' C:/Programme/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/1.8/monitor.rb:242:in `mon_synchronize' C:/Programme/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain' C:/Programme/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke' C:/Programme/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task' C:/Programme/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level' C:/Programme/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each' C:/Programme/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level' C:/Programme/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling' C:/Programme/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level' C:/Programme/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run' C:/Programme/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling' C:/Programme/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run' C:/Programme/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31 C:/Programme/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:19:in `load' C:\Programme\NetBeans 6.8\ruby2\jruby-1.4.0\bin\rake:19 ** Execute db:test:prepare ** Invoke db:test:load (first_time) ** Invoke db:test:purge (first_time) ** Invoke environment ** Execute db:test:purge ** Invoke spec:controllers (first_time) ** Invoke db:test:prepare ** Execute spec:controllers Finished in 0,0 seconds. 0 tests, 0 failures, 0 errors ----------------------------------------------------------------- I thought this is an error because of the version of RSpec. First i used the Version 1.3.2 for rspec-rails and the Version 1.3.0 for RSpec. I got the same error message. then i used the Version 1.2.9 for rspec and for rspec-rails and again i get the error message. Searching at google for the error doesn't help and now, i don't now the solution for my problem. Can somebody please help me? -- Posted via http://www.ruby-forum.com/. From mattriches at gmail.com Wed May 12 09:52:18 2010 From: mattriches at gmail.com (Matt Riches) Date: Wed, 12 May 2010 14:52:18 +0100 Subject: [rspec-users] Versions of RSpec & Rails In-Reply-To: <22b2ff9354f6f039d5e3d564b7353dd4@ruby-forum.com> References: <22b2ff9354f6f039d5e3d564b7353dd4@ruby-forum.com> Message-ID: I could be wrong, Im new to rspec and RoR myself, but I can see the line "** Execute db:abort_if_pending_migrations" before teh abort happens. Have you rune rake db:migrate recently? Matt On 12 May 2010 14:46, Sascha Popovic wrote: > Hello. > I'm new to ROR and i'm trying to use RSpec. > I use Rails 2.3.5. > > I installed RSpec and RSpec-Rails as Plugin in my Project and i > installed the Gem. > Then i user script/generate rspec to generate the needed files. > > When i want to use RSpec over Rake with "rake spec" i get the following > error: > > ----------------------------------------------------------------- > > ** Invoke environment (first_time) > ** Execute environment > ** Invoke spec (first_time) > ** Execute spec > ** Invoke spec:models (first_time) > ** Invoke db:test:prepare (first_time) > ** Invoke db:abort_if_pending_migrations (first_time) > ** Invoke environment > ** Execute db:abort_if_pending_migrations > rake aborted! > RSpec failures > D:/Workspaces/NetBeans/RubyOnRails/feeder/lib/tasks/rspec.rake:13 > C:/Programme/NetBeans > 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in > `call' > C:/Programme/NetBeans > 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in > `execute' > C:/Programme/NetBeans > 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in > `each' > C:/Programme/NetBeans > 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in > `execute' > C:/Programme/NetBeans > 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in > `invoke_with_call_chain' > C:/Programme/NetBeans > 6.8/ruby2/jruby-1.4.0/lib/ruby/1.8/monitor.rb:242:in `mon_synchronize' > C:/Programme/NetBeans > 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in > `invoke_with_call_chain' > C:/Programme/NetBeans > 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in > `invoke' > C:/Programme/NetBeans > 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in > `invoke_task' > C:/Programme/NetBeans > 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in > `top_level' > C:/Programme/NetBeans > 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in > `each' > C:/Programme/NetBeans > 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in > `top_level' > C:/Programme/NetBeans > 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in > `standard_exception_handling' > C:/Programme/NetBeans > 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in > `top_level' > C:/Programme/NetBeans > 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in > `run' > C:/Programme/NetBeans > 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in > `standard_exception_handling' > C:/Programme/NetBeans > 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in > `run' > C:/Programme/NetBeans > 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31 > C:/Programme/NetBeans > 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:19:in > `load' > C:\Programme\NetBeans 6.8\ruby2\jruby-1.4.0\bin\rake:19 > ** Execute db:test:prepare > ** Invoke db:test:load (first_time) > ** Invoke db:test:purge (first_time) > ** Invoke environment > ** Execute db:test:purge > ** Invoke spec:controllers (first_time) > ** Invoke db:test:prepare > ** Execute spec:controllers > > Finished in 0,0 seconds. > 0 tests, 0 failures, 0 errors > > ----------------------------------------------------------------- > > > > I thought this is an error because of the version of RSpec. > First i used the Version 1.3.2 for rspec-rails and the Version 1.3.0 for > RSpec. > I got the same error message. > then i used the Version 1.2.9 for rspec and for rspec-rails and again i > get the error message. > > Searching at google for the error doesn't help and now, i don't now the > solution for my problem. > > Can somebody please help me? > -- > 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 scott.a.woods at gmail.com Sun May 9 09:43:32 2010 From: scott.a.woods at gmail.com (Scott Woods) Date: Sun, 9 May 2010 06:43:32 -0700 (PDT) Subject: [rspec-users] Rails 3, Rspec 2, Autotest In-Reply-To: References: <1fe754a00478376a73632b794f3c9f43@ruby-forum.com> Message-ID: <102c797c-8384-4512-80ff-5106f9f1ca75@u7g2000vbq.googlegroups.com> I get a slightly different error when following the gist. Here is my error, in case the extra data point helps: $ autotest loading autotest/rails_rspec_rspec2 Error loading Autotest style autotest/rails_rspec_rspec2 (no such file to load -- autotest/rails_rspec_rspec2). Aborting. Note the extra "rspec" in the path that it's trying to load. Here is some more info about my environment: woods at beidleheimer ~/src/git/example $ gem list rspec *** LOCAL GEMS *** rspec (2.0.0.beta.8, 1.3.0, 1.2.9, 1.2.8, 1.2.6, 1.2.2, 1.2.0, 1.1.9, 1.1.3, 1.1.0) rspec-core (2.0.0.beta.8) rspec-expectations (2.0.0.beta.8) rspec-mocks (2.0.0.beta.8) rspec-rails (1.3.2, 1.2.9, 1.2.7.1, 1.2.6, 1.2.2, 1.2.0, 1.1.9) woods at beidleheimer ~/src/git/example $ gem list rails *** LOCAL GEMS *** rails (3.0.0.beta3, 2.3.5, 2.3.4, 2.3.3, 2.3.2, 2.2.2, 2.1.2, 2.1.1, 2.1.0, 2.0.4, 2.0.2, 2.0.1, 1.2.3) woods at beidleheimer ~/src/git/example $ ruby --version ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10] On Apr 17, 10:42?am, Tim Riendeau wrote: > I am having similar issue getting this working. I am running rails3.beta3 with ruby 1.8.7. I followedhttp://gist.github.com/365816and I get the following: > > loading autotest/rails_rspec2 > Autotest style autotest/rails_rspec2 doesn't seem to exist. Aborting. > > I uninstalled and reinstalled the ZenTest & autotest gems with no luck. The same thing occurs in other rails3 apps. > > Any help would be much appreciated > > --Tim > > On Apr 15, 2010, at 11:40 AM, Mark Pittillo wrote: > > > Trying to set up a Rails 3 project with RSpec and Autotest. ?I followed > > these steps exactly: > > >http://gist.github.com/365816 > > > But when I start up autotest, I get: > > > $ autotest > > loading autotest/rails > > style: Rails > > > instead of: > > > $ autotest > > loading autotest/rails_rspec2 > > style: RailsRspec2 > > > And autotest doesn't seem to do anything. ?Any idea what's happening? > > I'm using Ruby 1.9.2-head in rvm. ?Relevant gems: > > > autotest (4.2.9) > > autotest-rails (4.1.0) > > rspec (2.0.0.beta.6) > > rspec-core (2.0.0.beta.6) > > rspec-expectations (2.0.0.beta.6) > > rspec-mocks (2.0.0.beta.6) > > rspec-rails (2.0.0.beta.6) > > ZenTest (4.3.1) > > > Thanks a lot for any help. > > Mark > > -- > > Posted viahttp://www.ruby-forum.com/. > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > > > ?smime.p7s > 5KViewDownload > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From petr.blaho at gmail.com Tue May 11 04:33:38 2010 From: petr.blaho at gmail.com (petr.blaho) Date: Tue, 11 May 2010 01:33:38 -0700 (PDT) Subject: [rspec-users] Question about 'its' method in rspec2 Message-ID: <555dae0a-29af-4e95-945e-420e6ec9b371@24g2000yqy.googlegroups.com> Hi there, is 'its' method implemented in rspec2? I use rspec2 with rails3 and want to use syntax like in this example: describe Array do subject { Array.new(4) } its(:length) { should == 4 } end Is it possible? With regards Petr Blaho From dchelimsky at gmail.com Wed May 12 20:53:27 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 12 May 2010 19:53:27 -0500 Subject: [rspec-users] Question about 'its' method in rspec2 In-Reply-To: <555dae0a-29af-4e95-945e-420e6ec9b371@24g2000yqy.googlegroups.com> References: <555dae0a-29af-4e95-945e-420e6ec9b371@24g2000yqy.googlegroups.com> Message-ID: On May 11, 2010, at 3:33 AM, petr.blaho wrote: > Hi there, > > is 'its' method implemented in rspec2? Not yet, but coming soon: http://github.com/rspec/rspec-core/issues#issue/22 Cheers, David > I use rspec2 with rails3 and want to use syntax like in this example: > > describe Array do > subject { Array.new(4) } > its(:length) { should == 4 } > end > > Is it possible? > > With regards > Petr Blaho > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Wed May 12 21:04:14 2010 From: dchelimsky at gmail.com (dchelimsky at gmail.com) Date: Wed, 12 May 2010 18:04:14 -0700 (PDT) Subject: [rspec-users] Rails 3, Rspec 2, Autotest In-Reply-To: <102c797c-8384-4512-80ff-5106f9f1ca75@u7g2000vbq.googlegroups.com> References: <1fe754a00478376a73632b794f3c9f43@ruby-forum.com> <102c797c-8384-4512-80ff-5106f9f1ca75@u7g2000vbq.googlegroups.com> Message-ID: On May 9, 8:43?am, Scott Woods wrote: > I get a slightly different error when following the gist. Here is my > error, in case the extra data point helps: > > $ autotest > loading autotest/rails_rspec_rspec2 > Error loading Autotest style autotest/rails_rspec_rspec2 (no such file > to load -- autotest/rails_rspec_rspec2). Aborting. > > Note the extra "rspec" in the path that it's trying to load. That's because autotest looks in the gem paths and the load path for any files named autotest/discover.rb. It's finding the one in the rspec-1.3.0 gem, which adds 'rspec', and the one in your app, which is probably adding 'rspec2'. Try adding a file to your app named autotest/rails_rspec_rspec2.rb and require 'autotest/rails_rspec2' in that file. Let us know if that works. > > Here is some more info about my environment: > > woods at beidleheimer ~/src/git/example $ gem list rspec > > *** LOCAL GEMS *** > > rspec (2.0.0.beta.8, 1.3.0, 1.2.9, 1.2.8, 1.2.6, 1.2.2, 1.2.0, 1.1.9, > 1.1.3, 1.1.0) > rspec-core (2.0.0.beta.8) > rspec-expectations (2.0.0.beta.8) > rspec-mocks (2.0.0.beta.8) > rspec-rails (1.3.2, 1.2.9, 1.2.7.1, 1.2.6, 1.2.2, 1.2.0, 1.1.9) > woods at beidleheimer ~/src/git/example $ gem list rails > > *** LOCAL GEMS *** > > rails (3.0.0.beta3, 2.3.5, 2.3.4, 2.3.3, 2.3.2, 2.2.2, 2.1.2, 2.1.1, > 2.1.0, 2.0.4, 2.0.2, 2.0.1, 1.2.3) > woods at beidleheimer ~/src/git/example $ ruby --version > ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10] > > On Apr 17, 10:42?am, Tim Riendeau wrote: > > > > > I am having similar issue getting this working. I am running rails3.beta3 with ruby 1.8.7. I followedhttp://gist.github.com/365816andI get the following: > > > loading autotest/rails_rspec2 > > Autotest style autotest/rails_rspec2 doesn't seem to exist. Aborting. > > > I uninstalled and reinstalled the ZenTest & autotest gems with no luck. The same thing occurs in other rails3 apps. > > > Any help would be much appreciated > > > --Tim > > > On Apr 15, 2010, at 11:40 AM, Mark Pittillo wrote: > > > > Trying to set up a Rails 3 project with RSpec and Autotest. ?I followed > > > these steps exactly: > > > >http://gist.github.com/365816 > > > > But when I start up autotest, I get: > > > > $ autotest > > > loading autotest/rails > > > style: Rails > > > > instead of: > > > > $ autotest > > > loading autotest/rails_rspec2 > > > style: RailsRspec2 > > > > And autotest doesn't seem to do anything. ?Any idea what's happening? > > > I'm using Ruby 1.9.2-head in rvm. ?Relevant gems: > > > > autotest (4.2.9) > > > autotest-rails (4.1.0) > > > rspec (2.0.0.beta.6) > > > rspec-core (2.0.0.beta.6) > > > rspec-expectations (2.0.0.beta.6) > > > rspec-mocks (2.0.0.beta.6) > > > rspec-rails (2.0.0.beta.6) > > > ZenTest (4.3.1) > > > > Thanks a lot for any help. > > > Mark > > > -- > > > Posted viahttp://www.ruby-forum.com/. > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-us... at rubyforge.org > > >http://rubyforge.org/mailman/listinfo/rspec-users > > > ?smime.p7s > > 5KViewDownload > > > _______________________________________________ > > 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 > > -- > You received this message because you are subscribed to the Google Groups "rspec" group. > To post to this group, send email to rspec at googlegroups.com. > To unsubscribe from this group, send email to rspec+unsubscribe at googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rspec?hl=en. From antsmailinglist at gmail.com Thu May 13 07:41:05 2010 From: antsmailinglist at gmail.com (Ants Pants) Date: Thu, 13 May 2010 13:41:05 +0200 Subject: [rspec-users] First Post (Best Practices) Message-ID: Hello everyone, I'm just working my way through the RSpec/Cucumber book, I love the tool but not so much the learning curve :( Starting with my first view, is it okay for me, in the BDD world, to do the following or can I put them all in one 'it' block to save on having to render the page every time. Or must they be in separate blocks with separate renders? Or is there a fourth more elegant solution? %w{ name address_1 address_2 address_3 postcode town_city state country email phone www }.each do |field| it "renders form field #{field} to create a new competition" do @competition.stub!(field.intern).and_return '' render "competitions/new.html.erb" response.should have_selector("input[type=text]", :name => "competition[#{field}]", :value => '') end end Is it okay to post this type of question if nothing jumps out at me after googling? Thanks ants -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Thu May 13 09:18:59 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 13 May 2010 08:18:59 -0500 Subject: [rspec-users] First Post (Best Practices) In-Reply-To: References: Message-ID: On May 13, 2010, at 6:41 AM, Ants Pants wrote: > Hello everyone, > > I'm just working my way through the RSpec/Cucumber book, I love the tool but not so much the learning curve :( Welcome! We're here to help. > Starting with my first view, is it okay for me, in the BDD world, to do the following or can I put them all in one 'it' block to save on having to render the page every time. Or must they be in separate blocks with separate renders? Or is there a fourth more elegant solution? > > %w{ name address_1 address_2 address_3 postcode town_city state country email phone www }.each do |field| > it "renders form field #{field} to create a new competition" do > @competition.stub!(field.intern).and_return '' > render "competitions/new.html.erb" > response.should have_selector("input[type=text]", :name => "competition[#{field}]", :value => '') > end > end > > Is it okay to post this type of question if nothing jumps out at me after googling? Yes! And thanks for googling first. There is a guideline that comes from TDD that there should be one expectation per example. This is not a law, and is not necessarily the best way to go every time. One benefit is that it's easier to read the examples and understand what they're specifying. Another is that when we make a change in the implementation that results in an example failing, if there are multiple expectations that should fail, we learn more if they're all in separate examples than if they're all piled up in one example. In terms of iterating through a list of fields, I personally do it all the time and it rarely causes any pain _as long as it is only one level deep_. If you start nesting these, you're in for a world of pain when new requirements come in that point to a change in behaviour, because you have to start teasing things apart. Another approach to the same issue would be a custom matcher: Rspec::Matchers.define :have_text_field_named do |name| match do |response| response.should have_selector("input[type=text]", :name => "competition[#{name}]", :value => '') end failure_message_for_should do |response| "expected text field named #{name}, got:\n#{response.body.inspect}" end end Now you can say: describe "competitions/new.html.erb" do describe "form fields" do before(:each) do assigns[:competition] = double('competition').as_null_object end %w[name address_1 address_2 address_3 postcode town_city state country email phone www].each do |field| it "renders a #{field} field to create a new competition" do render response.should have_text_field_named(field) end end end end Notes: - using as_null_object means you don't have to stub out the methods on the competition - if you pass the path to the template file as the first argument to the outermost call to describe(), render() will render it implicitly, so it doesn't need to be in the example as well. - code in the example is now focused on what is unique to that example - I prefer to use %w[] over %w{} because it creates an array, not a hash or a lambda :) All of this said, there is a general trend away from view specs in light of the Cucumber + (Webrat || Capybara) equation. My personal feeling is that it's important to know how to use them because they are very useful from time to time. But that's only one opinion. HTH, David > Thanks > > ants From antsmailinglist at gmail.com Thu May 13 11:10:41 2010 From: antsmailinglist at gmail.com (Ants Pants) Date: Thu, 13 May 2010 17:10:41 +0200 Subject: [rspec-users] First Post (Best Practices) In-Reply-To: References: Message-ID: Thanks for so much information that I will look into. I was aware of using Cucumber/Webrat for this purpose but I'm doing things the long way until it feels unnatural. This way, I'll be in the position to weigh up the pros and cons of a best approach in the future. For now, I'll leave the fields in the loop as I'd like to be able to see the wood for the trees. Thanks for the tip between {} and [] as coming form Perl, I just thought they were the delimiters. Still got a lot to learn on all fronts. Again, thanks. -ants On 13 May 2010 15:18, David Chelimsky wrote: > On May 13, 2010, at 6:41 AM, Ants Pants wrote: > > > Hello everyone, > > > > I'm just working my way through the RSpec/Cucumber book, I love the tool > but not so much the learning curve :( > > Welcome! We're here to help. > > > Starting with my first view, is it okay for me, in the BDD world, to do > the following or can I put them all in one 'it' block to save on having to > render the page every time. Or must they be in separate blocks with separate > renders? Or is there a fourth more elegant solution? > > > > %w{ name address_1 address_2 address_3 postcode town_city state country > email phone www }.each do |field| > > it "renders form field #{field} to create a new competition" do > > @competition.stub!(field.intern).and_return '' > > render "competitions/new.html.erb" > > response.should have_selector("input[type=text]", :name => > "competition[#{field}]", :value => '') > > end > > end > > > > Is it okay to post this type of question if nothing jumps out at me > after googling? > > Yes! And thanks for googling first. > > There is a guideline that comes from TDD that there should be one > expectation per example. This is not a law, and is not necessarily the best > way to go every time. One benefit is that it's easier to read the examples > and understand what they're specifying. Another is that when we make a > change in the implementation that results in an example failing, if there > are multiple expectations that should fail, we learn more if they're all in > separate examples than if they're all piled up in one example. > > In terms of iterating through a list of fields, I personally do it all the > time and it rarely causes any pain _as long as it is only one level deep_. > If you start nesting these, you're in for a world of pain when new > requirements come in that point to a change in behaviour, because you have > to start teasing things apart. > > Another approach to the same issue would be a custom matcher: > > Rspec::Matchers.define :have_text_field_named do |name| > match do |response| > response.should have_selector("input[type=text]", :name => > "competition[#{name}]", :value => '') > end > > failure_message_for_should do |response| > "expected text field named #{name}, got:\n#{response.body.inspect}" > end > end > > Now you can say: > > describe "competitions/new.html.erb" do > > describe "form fields" do > before(:each) do > assigns[:competition] = double('competition').as_null_object > end > > %w[name address_1 address_2 address_3 postcode town_city state country > email phone www].each do |field| > it "renders a #{field} field to create a new competition" do > render > response.should have_text_field_named(field) > end > end > > end > end > > Notes: > > - using as_null_object means you don't have to stub out the methods on the > competition > - if you pass the path to the template file as the first argument to the > outermost call to describe(), render() will render it implicitly, so it > doesn't need to be in the example as well. > - code in the example is now focused on what is unique to that example > - I prefer to use %w[] over %w{} because it creates an array, not a hash or > a lambda :) > > All of this said, there is a general trend away from view specs in light of > the Cucumber + (Webrat || Capybara) equation. My personal feeling is that > it's important to know how to use them because they are very useful from > time to time. But that's only one opinion. > > HTH, > David > > > Thanks > > > > ants > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Thu May 13 11:18:54 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 13 May 2010 10:18:54 -0500 Subject: [rspec-users] First Post (Best Practices) In-Reply-To: References: Message-ID: On May 13, 2010, at 10:10 AM, Ants Pants wrote: > Thanks for so much information that I will look into. > > I was aware of using Cucumber/Webrat for this purpose but I'm doing > things the long way until it feels unnatural. This way, I'll be in > the position to weigh up the pros and cons of a best approach in the > future. > > For now, I'll leave the fields in the loop as I'd like to be able to > see the wood for the trees. > > Thanks for the tip between {} and [] as coming form Perl, I just > thought they were the delimiters. They are just delimeters. I'm just talking about style. > Still got a lot to learn on all fronts. > > Again, thanks. > > -ants > > On 13 May 2010 15:18, David Chelimsky wrote: > On May 13, 2010, at 6:41 AM, Ants Pants wrote: > > > Hello everyone, > > > > I'm just working my way through the RSpec/Cucumber book, I love > the tool but not so much the learning curve :( > > Welcome! We're here to help. > > > Starting with my first view, is it okay for me, in the BDD world, > to do the following or can I put them all in one 'it' block to save > on having to render the page every time. Or must they be in separate > blocks with separate renders? Or is there a fourth more elegant > solution? > > > > %w{ name address_1 address_2 address_3 postcode town_city state > country email phone www }.each do |field| > > it "renders form field #{field} to create a new competition" do > > @competition.stub!(field.intern).and_return '' > > render "competitions/new.html.erb" > > response.should have_selector("input[type=text]", :name => > "competition[#{field}]", :value => '') > > end > > end > > > > Is it okay to post this type of question if nothing jumps out at > me after googling? > > Yes! And thanks for googling first. > > There is a guideline that comes from TDD that there should be one > expectation per example. This is not a law, and is not necessarily > the best way to go every time. One benefit is that it's easier to > read the examples and understand what they're specifying. Another is > that when we make a change in the implementation that results in an > example failing, if there are multiple expectations that should > fail, we learn more if they're all in separate examples than if > they're all piled up in one example. > > In terms of iterating through a list of fields, I personally do it > all the time and it rarely causes any pain _as long as it is only > one level deep_. If you start nesting these, you're in for a world > of pain when new requirements come in that point to a change in > behaviour, because you have to start teasing things apart. > > Another approach to the same issue would be a custom matcher: > > Rspec::Matchers.define :have_text_field_named do |name| > match do |response| > response.should have_selector("input[type=text]", :name => > "competition[#{name}]", :value => '') > end > > failure_message_for_should do |response| > "expected text field named #{name}, got:\n#{response.body.inspect}" > end > end > > Now you can say: > > describe "competitions/new.html.erb" do > > describe "form fields" do > before(:each) do > assigns[:competition] = double('competition').as_null_object > end > > %w[name address_1 address_2 address_3 postcode town_city state > country email phone www].each do |field| > it "renders a #{field} field to create a new competition" do > render > response.should have_text_field_named(field) > end > end > > end > end > > Notes: > > - using as_null_object means you don't have to stub out the methods > on the competition > - if you pass the path to the template file as the first argument to > the outermost call to describe(), render() will render it > implicitly, so it doesn't need to be in the example as well. > - code in the example is now focused on what is unique to that example > - I prefer to use %w[] over %w{} because it creates an array, not a > hash or a lambda :) > > All of this said, there is a general trend away from view specs in > light of the Cucumber + (Webrat || Capybara) equation. My personal > feeling is that it's important to know how to use them because they > are very useful from time to time. But that's only one opinion. > > HTH, > David > > > Thanks > > > > ants > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.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 simon.peter.nicholls at googlemail.com Thu May 13 18:17:23 2010 From: simon.peter.nicholls at googlemail.com (Si) Date: Thu, 13 May 2010 15:17:23 -0700 (PDT) Subject: [rspec-users] Does rspec 2 have fixture support? In-Reply-To: References: <509e1c2c-196d-4515-a508-d1b1fdd8b54a@o11g2000yqj.googlegroups.com> Message-ID: <04f6c103-be1c-419d-8af0-240d6c888940@r11g2000yqa.googlegroups.com> OK, thanks guys. On May 11, 2:03?am, David Chelimsky wrote: > On May 10, 2010, at 6:51 PM, Rob Sanheim wrote: > > > I paired with Chad on Micronaut, and can confirm that fixtures were > > not on our priority list. ?Note that fixtures would be supplied by > > rspec-rails, though, not rspec-core (i.e. Micronaut), so other folks > > may be working on adding fixture support there. > > Not yet, but I just added an issue for it:http://github.com/rspec/rspec-rails/issues > > > > > > > - Rob > > >http://thinkrelevance.com > > > On Mon, May 3, 2010 at 5:03 PM, Si wrote: > >> Am I right in thinking that rspec 2, being based on Micronaut, has no > >> Rails fixture support? > > >> I tried to get my specs running under rspec-* 2.0.0.beta.8 and Rails 3 > >> edge, but no dice on the fixture front. I've tried controller and > >> request specs in a new app, just in case. Same story. > > >> Looking over at Micronaut now though, it seems fixture support is a > >> non-goal. Or am I missing something else? > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-us... at rubyforge.org > >>http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > -- > You received this message because you are subscribed to the Google Groups "rspec" group. > To post to this group, send email to rspec at googlegroups.com. > To unsubscribe from this group, send email to rspec+unsubscribe at googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rspec?hl=en. From matt at mattwynne.net Thu May 13 18:45:16 2010 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 13 May 2010 23:45:16 +0100 Subject: [rspec-users] First Post (Best Practices) In-Reply-To: References: Message-ID: On 13 May 2010, at 12:41, Ants Pants wrote: > Hello everyone, Hello and welcome :) > I'm just working my way through the RSpec/Cucumber book, I love the tool but not so much the learning curve :( > > Starting with my first view, is it okay for me, in the BDD world, to do the following or can I put them all in one 'it' block to save on having to render the page every time. Don't worry about performance here - it's negligible. In general I always err towards the idea of 'one assertion per test', so that when I get a failing test (or 'example' as we call them in RSpec) I know exactly what has gone broken. > Or must they be in separate blocks with separate renders? Or is there a fourth more elegant solution? Some people don't bother testing views in this much detail, and just rely on Cucumber tests to tell them whether the page works as expected. On the other hand you might well find that this level of detail helps you to think about the design of the objects that the view uses. If you search this list for previous threads about 'should I spec views' you will find plenty has already been said on this topic. > > %w{ name address_1 address_2 address_3 postcode town_city state country email phone www }.each do |field| > it "renders form field #{field} to create a new competition" do > @competition.stub!(field.intern).and_return '' > render "competitions/new.html.erb" > response.should have_selector("input[type=text]", :name => "competition[#{field}]", :value => '') > end > end > > Is it okay to post this type of question if nothing jumps out at me after googling? Of course but remember we're all busy people and not getting paid for this - remember to ask the plants[1] in the office before you ask us! > > Thanks > > ants > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users [1]http://www.cb1.com/~john/computing/rubber-plant-effect.html From daniel.amselem at gmail.com Fri May 14 11:09:15 2010 From: daniel.amselem at gmail.com (Daniel Salmeron Amselem) Date: Fri, 14 May 2010 08:09:15 -0700 (PDT) Subject: [rspec-users] RSpec and Factory Girl: Destroying an object Message-ID: <860dd52a-2571-4d39-84fe-50c4d55854e2@o14g2000yqb.googlegroups.com> Hi, I have a problem when testing the deletion of a record from the database. I am using RSpec methods to check if my account object is being destroyed. The factory creates an account object and saves it into the DB. Also the two should_receive expectations seem to work. The problem is that when checking the database after the "delete :destroy, :id => account" line, the account record still exists. it "should be able to destroy an account" do account = Factory(:account) Account.should_receive(:find).and_return(account) account.should_receive(:destroy) delete :destroy, :id => account Account.all.should == [] response.should be_success response.should render_template("new") end # app/controllers/accounts_controller.rb def destroy account = Account.find(params[:id]) account.destroy redirect_to accounts_path end I hope someone can help me on this one. Thanks From mailinglists at patmaddox.com Fri May 14 11:27:30 2010 From: mailinglists at patmaddox.com (Pat Maddox) Date: Fri, 14 May 2010 08:27:30 -0700 Subject: [rspec-users] RSpec and Factory Girl: Destroying an object In-Reply-To: <860dd52a-2571-4d39-84fe-50c4d55854e2@o14g2000yqb.googlegroups.com> References: <860dd52a-2571-4d39-84fe-50c4d55854e2@o14g2000yqb.googlegroups.com> Message-ID: On May 14, 2010, at 8:09 AM, Daniel Salmeron Amselem wrote: > Hi, > > I have a problem when testing the deletion of a record from the > database. I am using RSpec methods to check if my account object is > being destroyed. > > The factory creates an account object and saves it into the DB. Also > the two should_receive expectations seem to work. > > The problem is that when checking the database after the > "delete :destroy, :id => account" line, the account record still > exists. > > > it "should be able to destroy an account" do > account = Factory(:account) > Account.should_receive(:find).and_return(account) > account.should_receive(:destroy) > > delete :destroy, :id => account > > Account.all.should == [] > response.should be_success > response.should render_template("new") > end > > # app/controllers/accounts_controller.rb > def destroy > account = Account.find(params[:id]) > account.destroy > > redirect_to accounts_path > end > > I hope someone can help me on this one. You've mocked out the call to destroy, which hides the original implementation. Pick either a state-based test (checking the database, don't use mocks) or mock-based test, but don't mix and match. Pat From daniel.amselem at gmail.com Fri May 14 16:11:50 2010 From: daniel.amselem at gmail.com (Daniel Salmeron Amselem) Date: Fri, 14 May 2010 13:11:50 -0700 (PDT) Subject: [rspec-users] RSpec and Factory Girl: Destroying an object In-Reply-To: References: <860dd52a-2571-4d39-84fe-50c4d55854e2@o14g2000yqb.googlegroups.com> Message-ID: Hey Pat, thanks for replying. How would you test this method? Checking the database or mocking? Is there any advantage of using one over the other ? I don't really understand the benefits of using mocks, so could you tell me how would you write the test using both methods (mocking, and checking the DB? Could you explain me the advantages of using mocking and advantages of checking de DB? Thank you very much, Dani On May 14, 5:27?pm, Pat Maddox wrote: > On May 14, 2010, at 8:09 AM, Daniel Salmeron Amselem wrote: > > > > > > > Hi, > > > I have a problem when testing the deletion of a record from the > > database. I am using RSpec methods to check if my account object is > > being destroyed. > > > The factory creates an account object and saves it into the DB. Also > > the two should_receive expectations seem to work. > > > The problem is that when checking the database after the > > "delete :destroy, :id => account" line, the account record still > > exists. > > > ? ?it "should be able to destroy an account" do > > ? ? ?account = Factory(:account) > > ? ? ?Account.should_receive(:find).and_return(account) > > ? ? ?account.should_receive(:destroy) > > > ? ? ?delete :destroy, :id => account > > > ? ? ?Account.all.should == [] > > ? ? ?response.should be_success > > ? ? ?response.should render_template("new") > > ? ?end > > > ?# app/controllers/accounts_controller.rb > > ?def destroy > > ? ?account = Account.find(params[:id]) > > ? ?account.destroy > > > ? ?redirect_to accounts_path > > ?end > > > I hope someone can help me on this one. > > You've mocked out the call to destroy, which hides the original implementation. ?Pick either a state-based test (checking the database, don't use mocks) or mock-based test, but don't mix and match. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > -- > You received this message because you are subscribed to the Google Groups "rspec" group. > To post to this group, send email to rspec at googlegroups.com. > To unsubscribe from this group, send email to rspec+unsubscribe at googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rspec?hl=en. From jbrainsberger at gmail.com Fri May 14 20:19:54 2010 From: jbrainsberger at gmail.com (J. B. Rainsberger) Date: Fri, 14 May 2010 18:19:54 -0600 Subject: [rspec-users] RSpec and Factory Girl: Destroying an object In-Reply-To: References: <860dd52a-2571-4d39-84fe-50c4d55854e2@o14g2000yqb.googlegroups.com> Message-ID: <4BEDE8AA.50306@gmail.com> Daniel Salmeron Amselem wrote: > How would you test this method? Checking the database or mocking? Is > there any advantage of using one over the other ? Hi, Dani. You originally wrote that you want "to check if my account object is being destroyed." I can think of a few reasons to check this: 1. I don't yet know Rails well and want to check that I understand how #destroy works. 2. I don't trust Rails to destroy an object correctly. 3. I've configured some behavior of my object in a way that might cause Rails to destroy it differently than I expect. 4. I think I've found a bug in Rails. Do you want to check the destroy method for one of these reasons, or something else entirely? I ask, because that information guides me to choose one of three options: 1. Check #destroy by invoking it directly. 2. Check a client by stubbing/mocking #destroy. 3. Don't check #destroy at all. Since I didn't write #destroy, I prefer not to check it. (Principle: Don't Test The Platform.) If I don't trust #destroy, I check it by invoking it directly, because I think there might be a bug in Rails. If I don't understand what #destroy does, I check it by invoking it directly, because I'm writing Learning Tests. (Principle: Write examples to check your assumptions about how someone else's code works.) > I don't really understand the benefits of using mocks, so could you > tell me how would you write the test using both methods (mocking, and > checking the DB? Could you explain me the advantages of using mocking > and advantages of checking de DB? I think of it this way: if I want to check #destroy, I invoke it directly with the database; but if I want to check that my code asks to destroy an object at the right time, I mock #destroy; and finally, if I want to check that my code reacts appropriately after destroying an object, then I stub #destroy. To understand some of the underlying principles, I humbly recommend this: http://jbrains.ca/integrated_tests_are_a_scam (The articles are in order from newest first, so start at the end). Enjoy. -- J. B. Rainsberger :: http://www.jbrains.ca :: http://www.thecodewhisperer.com From lists at ruby-forum.com Sat May 15 15:30:01 2010 From: lists at ruby-forum.com (Brian Dicasa) Date: Sat, 15 May 2010 21:30:01 +0200 Subject: [rspec-users] Running spec tests from ruby code Message-ID: <6bc9da49c55e26aa3cd802877efc102b@ruby-forum.com> I'm trying to do some more custom testing with rails and I'm trying to write a rake task that will perform this testing. What I need the task to do is load the rails environment, run some MySql scripts and then run some spec files. However, I'm not sure on how to go about running spec files from within ruby code. I've posted a question on stack over flow but haven't gotten much response. I've copied my current code and error I'm running into below (its also on stack over flow). Thanks for any help guys. require "spec/autorun" require"spec" require "spec/rake/spectask" RAILS_ENV = 'test' namespace :run_all_tests do desc "Run all of your tests" puts "Reseting test database..." system "mysql --user=root --password=dev < C:\\Brian\\Work\\Personal\\BrianSite\\database\\BrianSite_test_CreateScript.sql" puts "Filling database tables with test data..." system "mysql --user=root --password=dev < C:\\Brian\\Work\\Personal\\BrianSite\\database\\Fill_Test_Tables.sql" puts "Starting rails test environment..." task :run => :environment do puts "RAILS_ENV is #{RAILS_ENV}" # Run rspec test files here... require "spec/models/blog_spec.rb" end end C:/Ruby/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/options.rb:283:in fi les_to_load': File or directory not found: run_all_tests:run (RuntimeError) from C:/Ruby/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/options. rb:275:ineach' from C:/Ruby/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/options. rb:275:in files_to_load' from C:/Ruby/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/options. rb:133:inrun_examples' from C:/Ruby/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner.rb:61:in run' from C:/Ruby/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner.rb:45:in autorun' from C:/Ruby/bin/rake:19 -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sat May 15 20:18:57 2010 From: lists at ruby-forum.com (Kwang how Tan) Date: Sun, 16 May 2010 02:18:57 +0200 Subject: [rspec-users] Failing Flash Spec Message-ID: I am having failing simple spec which I couldn't figure out why :-( http://gist.github.com/402517 * ffaker (0.4.0) * machinist (1.0.6) * rails (3.0.0.beta3) * rspec (2.0.0.beta.8) * rspec-core (2.0.0.beta.8) * rspec-expectations (2.0.0.beta.8) * rspec-mocks (2.0.0.beta.8) * rspec-rails (2.0.0.beta.8) Can someone help. Thx -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Sun May 16 08:37:45 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 16 May 2010 07:37:45 -0500 Subject: [rspec-users] Failing Flash Spec In-Reply-To: References: Message-ID: On May 15, 2010, at 7:18 PM, Kwang how Tan wrote: > I am having failing simple spec which I couldn't figure out why :-( > http://gist.github.com/402517 > > * ffaker (0.4.0) > * machinist (1.0.6) > * rails (3.0.0.beta3) > * rspec (2.0.0.beta.8) > * rspec-core (2.0.0.beta.8) > * rspec-expectations (2.0.0.beta.8) > * rspec-mocks (2.0.0.beta.8) > * rspec-rails (2.0.0.beta.8) > > Can someone help. Not if you don't post the failure messages :) Please do so. From scott at railsnewbie.com Sun May 16 13:54:15 2010 From: scott at railsnewbie.com (Scott Taylor) Date: Sun, 16 May 2010 13:54:15 -0400 Subject: [rspec-users] Quickcheck testing framework Message-ID: <17434AD5-131E-43EA-A9E0-7F2FED095053@railsnewbie.com> Hey all, I'm wondering if anyone has any experience with an automated test-case generation tool like Quickcheck (for erlang/haskell). I'd be interested in hearing any impressions, war stories, or dev workflows regarding a tool like this. Talking off list to David C, he suggested that it might be a complimentary tool to a TDD/BDD framework like rspec. It appears as though there is a similar project out there for ruby named rushcheck (http://rushcheck.rubyforge.org/). Doesn't seem like it's been maintained in a few years, though, and I'm guessing no one is using it. I wonder if it these automated test generation tools are more appropriate in functional languages like Haskell and Erlang. Scott From node.js99 at gmail.com Fri May 14 18:55:48 2010 From: node.js99 at gmail.com (Nadal) Date: Fri, 14 May 2010 15:55:48 -0700 (PDT) Subject: [rspec-users] A full rails application with rspec test code Message-ID: <68e6dd6e-27c9-4f9b-946f-de9608ca5130@q13g2000vbm.googlegroups.com> I used bostonrb code base http://github.com/bostonrb/bostonrb to learn about shoulda. Similarly is there a decent rails based application with test code in rspec to see how to write good rspec test code at both unit and functional level. I am trying to get started with rspec. Thanks From stuart.hungerford at gmail.com Fri May 14 20:03:42 2010 From: stuart.hungerford at gmail.com (Stu) Date: Fri, 14 May 2010 17:03:42 -0700 (PDT) Subject: [rspec-users] spec/support directory outside Rails?... Message-ID: <23345df3-575d-4cfc-b2bc-e66d9487992f@g5g2000pre.googlegroups.com> Hi, I have a group of non-Rails Ruby projects that all make heavy use of RSpec. Each of these projects has a "spec" directory with a "helper.rb" file. All the *_spec.rb files in the spec directory tree do the usual require File.dirname(__FILE__) + "/../helper" like dance. I understand that RSpec for Rails will look for a "spec/ support" directory and require any files found there? Is there a similar scheme for non-Rails projects? Any advice on this much appreciated! Stu From stuart.hungerford at gmail.com Fri May 14 20:25:36 2010 From: stuart.hungerford at gmail.com (Stu) Date: Fri, 14 May 2010 17:25:36 -0700 (PDT) Subject: [rspec-users] Best practices for managing fixtures outside Rails?... Message-ID: Hi, I have a non-Rails Ruby project that uses RSpec. It needs a shared collection of fixture-like objects created, although they have nothing to do with Rails, AR or database entries: w1 = Widget.new(10) w2 = Widget.new(20) w3 = Widget.new(30) # ... g1 = Gadget.new(w1, w2) g2 = Gadget.new(w3, w1) g3 = Gadget.new(w2, w3) #... Currently these are in a shared examples.rb file and are brought into various *_spec.rb files in a way that feels like a real hack. I've since discovered a fork of Machinist that works with PORO's and allows those object to have an initializer with arguments, so I should be able to replace the above with machinist blueprints etc. I figure I'm not the first person in the world to be using RSpec and fixture-like objects in this way, so are there any best practices for doing this outside Rails? I've read this a number of times, but it's starting to sink in that projects need to manage their specs/tests with the same agility and care they devote to the code. Any advice much appreciated, Stu From rhydiant at googlemail.com Sat May 15 03:56:31 2010 From: rhydiant at googlemail.com (rhydiant) Date: Sat, 15 May 2010 00:56:31 -0700 (PDT) Subject: [rspec-users] Stubbing return arguments Message-ID: I'm writting a code example for the following method: def upload(email_address, product_data) errors = [] user = resolve_user_from(email_address) product_file_name = ProductFileHandler.persist(user, product_data, errors) if errors.blank? # ... do some stuff else # ... do some other stuff end end ProductFileHandler.persist will add any errors it encounters to the errors array I pass in. In my test of upload, I want to stub that error array with different values. After much googling and RSpec doc searching I can't find a way to stub arguments like that? Is this possible with RSpec? From dchelimsky at gmail.com Sun May 16 19:02:51 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 16 May 2010 18:02:51 -0500 Subject: [rspec-users] spec/support directory outside Rails?... In-Reply-To: <23345df3-575d-4cfc-b2bc-e66d9487992f@g5g2000pre.googlegroups.com> References: <23345df3-575d-4cfc-b2bc-e66d9487992f@g5g2000pre.googlegroups.com> Message-ID: <3BAFF7CD-0E53-45AF-A006-CA5C8716DB94@gmail.com> On May 14, 2010, at 7:03 PM, Stu wrote: > Hi, > > I have a group of non-Rails Ruby projects that all make heavy use of > RSpec. Each of these projects has a "spec" directory with a > "helper.rb" file. All the *_spec.rb files in the spec directory tree > do the usual > > require File.dirname(__FILE__) + "/../helper" > > like dance. I understand that RSpec for Rails will look for a "spec/ > support" directory and require any files found there? Is there a > similar scheme for non-Rails projects? That doesn't happen automatically in RSpec. The spec/spec_helper.rb file that gets generated when you configure a rails app with rspec includes this line: Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} Just include a similar line in your helper file and you're good to go. > > Any advice on this much appreciated! > > Stu From dchelimsky at gmail.com Sun May 16 19:10:00 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 16 May 2010 18:10:00 -0500 Subject: [rspec-users] Stubbing return arguments In-Reply-To: References: Message-ID: On May 15, 2010, at 2:56 AM, rhydiant wrote: > I'm writting a code example for the following method: > > def upload(email_address, product_data) > errors = [] > user = resolve_user_from(email_address) > product_file_name = ProductFileHandler.persist(user, > product_data, errors) > if errors.blank? > # ... do some stuff > else > # ... do some other stuff > end > end > > ProductFileHandler.persist will add any errors it encounters to the > errors array I pass in. In my test of upload, I want to stub that > error array with different values. After much googling and RSpec doc > searching I can't find a way to stub arguments like that? Is this > possible with RSpec? Assuming your goal is to test the different branches of the "if errors.blank?" conditional, you could do something like this: ProductFileHandler.stub(:persist) do |_,_,errors| # add stuff to errors here # return a reasonable value for product_file_name here end When the ProductFileHandler class receives the persist message, it will now invoke this block with the three arguments it receives (user, product_data, errors). Make sense? This is pretty invasive but, given the current design, probably the simplest way to go. If you want something less invasive, you probably need to change the design. HTH, David From dchelimsky at gmail.com Sun May 16 19:16:41 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 16 May 2010 18:16:41 -0500 Subject: [rspec-users] Best practices for managing fixtures outside Rails?... In-Reply-To: References: Message-ID: On May 14, 2010, at 7:25 PM, Stu wrote: > Hi, > > I have a non-Rails Ruby project that uses RSpec. It needs a shared > collection of fixture-like objects created, although they have nothing > to do with Rails, AR or database entries: > > w1 = Widget.new(10) > w2 = Widget.new(20) > w3 = Widget.new(30) > # ... > > g1 = Gadget.new(w1, w2) > g2 = Gadget.new(w3, w1) > g3 = Gadget.new(w2, w3) > #... > > Currently these are in a shared examples.rb file and are brought into > various *_spec.rb files in a way that feels like a real hack. I've > since discovered a fork of Machinist that works with PORO's and allows > those object to have an initializer with arguments, so I should be > able to replace the above with machinist blueprints etc. > > I figure I'm not the first person in the world to be using RSpec and > fixture-like objects in this way, so are there any best practices for > doing this outside Rails? I've read this a number of times, but it's > starting to sink in that projects need to manage their specs/tests > with the same agility and care they devote to the code. > > Any advice much appreciated, > > Stu I'm not sure there enough people doing this sort of thing and writing about it to have established any conventions or recommended practices. I'd probably just follow the rails conventions here in terms of where blueprints live, etc. HTH, David From dchelimsky at gmail.com Sun May 16 20:13:28 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 16 May 2010 19:13:28 -0500 Subject: [rspec-users] Quickcheck testing framework In-Reply-To: <17434AD5-131E-43EA-A9E0-7F2FED095053@railsnewbie.com> References: <17434AD5-131E-43EA-A9E0-7F2FED095053@railsnewbie.com> Message-ID: On May 16, 2010, at 12:54 PM, Scott Taylor wrote: > Hey all, > > I'm wondering if anyone has any experience with an automated test-case generation tool like Quickcheck (for erlang/haskell). I'd be interested in hearing any impressions, war stories, or dev workflows regarding a tool like this. Talking off list to David C, he suggested that it might be a complimentary tool to a TDD/BDD framework like rspec. My thinking here is that it could be useful to drive out an initial implementation using TDD, and at the point we think we've got the solution we want, add something quickcheck-like to try to poke holes in it. I'd probably then add new examples if any cases I hadn't considered were revealed through this process. > It appears as though there is a similar project out there for ruby named rushcheck (http://rushcheck.rubyforge.org/). It's up on github too: http://github.com/hayeah/rushcheck. Same guy has this too: http://github.com/hayeah/rantly - random data generator - looks like you could do stuff like: Rantly.new.each(100) do thing.method_that_accepts_a_string(string).should have_some_quality end This would cause 100 random strings to be generated and passed to thing.method_that_accepts_a_string. Assuming the matcher verifies some set of rules about the outcomes, you've basically got quick check. The documentation is behind (the lib used to be called something else and some method names have changed), but I think it wouldn't take much work to be able to adapt this for use in RSpec. > Doesn't seem like it's been maintained in a few years, though, and I'm guessing no one is using it. I wonder if it these automated test generation tools are more appropriate in functional languages like Haskell and Erlang. From rhydiant at googlemail.com Sun May 16 20:29:55 2010 From: rhydiant at googlemail.com (rhydiant) Date: Sun, 16 May 2010 17:29:55 -0700 (PDT) Subject: [rspec-users] Stubbing return arguments In-Reply-To: References: Message-ID: <0b03b1fa-56e7-413b-930c-290b3f7c2aad@y6g2000pra.googlegroups.com> Thanks for the reply David, works a treat. I'll probably end up refacting away from that design but right now that's exactly what I need. Regards Rhydian On May 17, 9:10?am, David Chelimsky wrote: > On May 15, 2010, at 2:56 AM, rhydiant wrote: > > > > > I'm writting a code example for the following method: > > > ? ?def upload(email_address, product_data) > > ? ? ?errors = [] > > ? ? ?user = resolve_user_from(email_address) > > ? ? ?product_file_name = ProductFileHandler.persist(user, > > product_data, errors) > > ? ? ?if errors.blank? > > ? ? ? ?# ... do some stuff > > ? ? ?else > > ? ? ? ?# ... do some other stuff > > ? ? ?end > > ? ?end > > > ProductFileHandler.persist will add any errors it encounters to the > > errors array I pass in. In my test of upload, I want to stub that > > error array with different values. After much googling and RSpec doc > > searching I can't find a way to stub arguments like that? Is this > > possible with RSpec? > > Assuming your goal is to test the different branches of the "if errors.blank?" conditional, you could do something like this: > > ProductFileHandler.stub(:persist) do |_,_,errors| > ? # add stuff to errors here > ? # return a reasonable value for product_file_name here > end > > When the ProductFileHandler class receives the persist message, it will now invoke this block with the three arguments it receives (user, product_data, errors). Make sense? > > This is pretty invasive but, given the current design, probably the simplest way to go. If you want something less invasive, you probably need to change the design. > > HTH, > David > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > -- > You received this message because you are subscribed to the Google Groups "rspec" group. > To post to this group, send email to rspec at googlegroups.com. > To unsubscribe from this group, send email to rspec+unsubscribe at googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rspec?hl=en. From scott at railsnewbie.com Sun May 16 21:31:42 2010 From: scott at railsnewbie.com (Scott Taylor) Date: Sun, 16 May 2010 21:31:42 -0400 Subject: [rspec-users] Best practices for managing fixtures outside Rails?... In-Reply-To: References: Message-ID: <352C92A8-F775-4769-9FF2-CE855F46C7B8@railsnewbie.com> On May 14, 2010, at 8:25 PM, Stu wrote: > Hi, > > I have a non-Rails Ruby project that uses RSpec. It needs a shared > collection of fixture-like objects created, although they have nothing > to do with Rails, AR or database entries: > > w1 = Widget.new(10) > w2 = Widget.new(20) > w3 = Widget.new(30) > # ... > > g1 = Gadget.new(w1, w2) > g2 = Gadget.new(w3, w1) > g3 = Gadget.new(w2, w3) > #... > > Currently these are in a shared examples.rb file and are brought into > various *_spec.rb files in a way that feels like a real hack. I've > since discovered a fork of Machinist that works with PORO's and allows > those object to have an initializer with arguments, so I should be > able to replace the above with machinist blueprints etc. > > I figure I'm not the first person in the world to be using RSpec and > fixture-like objects in this way, so are there any best practices for > doing this outside Rails? I've read this a number of times, but it's > starting to sink in that projects need to manage their specs/tests > with the same agility and care they devote to the code. > > Any advice much appreciated, I've always used FixtureReplacement in place of fixtures, which clears up my spec/fixtures directory. Often on rails projects I'll have spec/fixtures/mailers, and possibly other random files in spec/fixtures, scaling up the organization as necessary. Any of the ruby files I'll require from the spec_helper. Regards, Scott From scott at railsnewbie.com Mon May 17 00:10:47 2010 From: scott at railsnewbie.com (Scott Taylor) Date: Mon, 17 May 2010 00:10:47 -0400 Subject: [rspec-users] Quickcheck testing framework In-Reply-To: References: <17434AD5-131E-43EA-A9E0-7F2FED095053@railsnewbie.com> Message-ID: <8FD25E18-29A9-4997-AD30-705A4014458D@railsnewbie.com> On May 16, 2010, at 8:13 PM, David Chelimsky wrote: > On May 16, 2010, at 12:54 PM, Scott Taylor wrote: > >> Hey all, >> >> I'm wondering if anyone has any experience with an automated test-case generation tool like Quickcheck (for erlang/haskell). I'd be interested in hearing any impressions, war stories, or dev workflows regarding a tool like this. Talking off list to David C, he suggested that it might be a complimentary tool to a TDD/BDD framework like rspec. > > My thinking here is that it could be useful to drive out an initial implementation using TDD, and at the point we think we've got the solution we want, add something quickcheck-like to try to poke holes in it. I'd probably then add new examples if any cases I hadn't considered were revealed through this process. Have you watched John Hughes' presentation on the matter? http://video.google.com/videoplay?docid=4655369445141008672# It's sort of interesting that he won't do any TDD - he'll let the reduction process generate the "minimum" test case, and go from there (that's not explicitly stated in that video, although I'm pretty sure I've heard him say it before). If I had a tool like this, I'm guessing I'd probably have a workflow like the following: 1. use the random test case generator, and fix any issues that were obvious. 2. If something wasn't obvious, I'd go and write a test case for in a more traditional testing tool (rspec). I often use the debugger in conjunction with the spec runner, running the one test case with a debugger statement at the start of the test case. 3. Any regressions would (obviously) happen in the traditional tool. The big win with a tool like this is not testing boundary cases, it's in having the tool "write" the test cases for you. OTOH, I wonder if the simplicity of the implementation would be sacrificed when taking this approach. Another drawback - I have no idea how such a tool would integrate with a build server. > >> It appears as though there is a similar project out there for ruby named rushcheck (http://rushcheck.rubyforge.org/). > > It's up on github too: http://github.com/hayeah/rushcheck. Same guy has this too: http://github.com/hayeah/rantly - random data generator - looks like you could do stuff like: > > Rantly.new.each(100) do > thing.method_that_accepts_a_string(string).should have_some_quality > end There's a blog post about the library here, if anyone is interested: http://www.metacircus.com/hacking/2009/04/10/look-ma-no-monads.html I've been thinking about integrating a port of the ruby library faker into scriptcheck, the javascript testing tool I've been working on: http://github.com/Marak/Faker.js http://github.com/smtlaissezfaire/scriptcheck > > This would cause 100 random strings to be generated and passed to thing.method_that_accepts_a_string. Assuming the matcher verifies some set of rules about the outcomes, you've basically got quick check. Yeah, pretty much. One issue, though, is that you don't want to hard code the number of random generations. You'll also want a convenient way to run just one given test case easily (which rspec already has). You'll probably also want to separate these random generation tests from the rest of your tests. Hitting a database 1000 times for one test is going to be costly. Now that I'm thinking about it, it might make a ton of sense in languages like erlang or haskell where everything is functional because those languages lend themselves to parallelization since there are no shared resources. Regards, Scott From lists at ruby-forum.com Mon May 17 05:37:44 2010 From: lists at ruby-forum.com (Kwang how Tan) Date: Mon, 17 May 2010 11:37:44 +0200 Subject: [rspec-users] Failing Flash Spec In-Reply-To: References: Message-ID: <1333f222aa7285ec5524bd78602d5e35@ruby-forum.com> > Not if you don't post the failure messages :) Please do so. Sorry, I don't understand what you mean. Please explain. Thx -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Mon May 17 06:05:16 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 17 May 2010 05:05:16 -0500 Subject: [rspec-users] Failing Flash Spec In-Reply-To: <1333f222aa7285ec5524bd78602d5e35@ruby-forum.com> References: <1333f222aa7285ec5524bd78602d5e35@ruby-forum.com> Message-ID: On Mon, May 17, 2010 at 4:37 AM, Kwang how Tan wrote: >> Not if you don't post the failure messages :) Please do so. > > Sorry, I don't understand what you mean. > Please explain. Please run the spec and post the failure messages you get. Use the -b flag you get a full backtrace: spec spec/controllers/sessions_controller_spec.rb -b Thanks, David From dchelimsky at gmail.com Mon May 17 06:38:41 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 17 May 2010 05:38:41 -0500 Subject: [rspec-users] Quickcheck testing framework In-Reply-To: <8FD25E18-29A9-4997-AD30-705A4014458D@railsnewbie.com> References: <17434AD5-131E-43EA-A9E0-7F2FED095053@railsnewbie.com> <8FD25E18-29A9-4997-AD30-705A4014458D@railsnewbie.com> Message-ID: <4081A033-35E7-4236-BA1C-6E22E261DAE1@gmail.com> On May 16, 2010, at 11:10 PM, Scott Taylor wrote: > > On May 16, 2010, at 8:13 PM, David Chelimsky wrote: > >> On May 16, 2010, at 12:54 PM, Scott Taylor wrote: >> >>> Hey all, >>> >>> I'm wondering if anyone has any experience with an automated test-case generation tool like Quickcheck (for erlang/haskell). I'd be interested in hearing any impressions, war stories, or dev workflows regarding a tool like this. Talking off list to David C, he suggested that it might be a complimentary tool to a TDD/BDD framework like rspec. >> >> My thinking here is that it could be useful to drive out an initial implementation using TDD, and at the point we think we've got the solution we want, add something quickcheck-like to try to poke holes in it. I'd probably then add new examples if any cases I hadn't considered were revealed through this process. > > Have you watched John Hughes' presentation on the matter? > > http://video.google.com/videoplay?docid=4655369445141008672# I haven't yet. I'll give it a look-see later today. > It's sort of interesting that he won't do any TDD - he'll let the reduction process generate the "minimum" test case, and go from there (that's not explicitly stated in that video, although I'm pretty sure I've heard him say it before). > > If I had a tool like this, I'm guessing I'd probably have a workflow like the following: > > 1. use the random test case generator, and fix any issues that were obvious. > 2. If something wasn't obvious, I'd go and write a test case for in a more traditional testing tool (rspec). I often use the debugger in conjunction with the spec runner, running the one test case with a debugger statement at the start of the test case. > 3. Any regressions would (obviously) happen in the traditional tool. > > The big win with a tool like this is not testing boundary cases, it's in having the tool "write" the test cases for you. OTOH, I wonder if the simplicity of the implementation would be sacrificed when taking this approach. My guess is that it would. > Another drawback - I have no idea how such a tool would integrate with a build server. What integration point would there need to be? It's just Ruby. >>> It appears as though there is a similar project out there for ruby named rushcheck (http://rushcheck.rubyforge.org/). >> >> It's up on github too: http://github.com/hayeah/rushcheck. Same guy has this too: http://github.com/hayeah/rantly - random data generator - looks like you could do stuff like: >> >> Rantly.new.each(100) do >> thing.method_that_accepts_a_string(string).should have_some_quality >> end > > There's a blog post about the library here, if anyone is interested: > > http://www.metacircus.com/hacking/2009/04/10/look-ma-no-monads.html > > I've been thinking about integrating a port of the ruby library faker into scriptcheck, the javascript testing tool I've been working on: > > http://github.com/Marak/Faker.js > http://github.com/smtlaissezfaire/scriptcheck > >> >> This would cause 100 random strings to be generated and passed to thing.method_that_accepts_a_string. Assuming the matcher verifies some set of rules about the outcomes, you've basically got quick check. > > Yeah, pretty much. One issue, though, is that you don't want to hard code the number of random generations. Why not? Wouldn't it make sense to have smaller numbers in some cases and larger ones in others? > You'll also want a convenient way to run just one given test case easily (which rspec already has). You'll probably also want to separate these random generation tests from the rest of your tests. Exactly! This is what I had in mind when I said "at the point we think we've got the solution we want, add something quickcheck-like to try to poke holes in it." The steps would be: 1. Drive out minimal implementation with specs 2. Write some quickcheck-ish tests in a separate location 3. Run them 4. If there are any failures, use them to evaluate and enhance the specs that I'd already written This would really amplify the distinction between specs and tests. Plus, the tests would be indirectly testing the specs as much as they are testing the implementation. Of course, this is all theoretical. If we could just use quickcheck and still get all the documentation and implementation-driving benefits of TDD, I'd probably move in that direction myself :) > Hitting a database 1000 times for one test is going to be costly. If we used the process I just outlined, we could run the specs using autotest (ironic), and only run the tests on demand and on the CI server. > Now that I'm thinking about it, it might make a ton of sense in languages like erlang or haskell where everything is functional because those languages lend themselves to parallelization since there are no shared resources. > > Regards, > > Scott From lists at ruby-forum.com Mon May 17 22:32:34 2010 From: lists at ruby-forum.com (Kwang how Tan) Date: Tue, 18 May 2010 04:32:34 +0200 Subject: [rspec-users] Failing Flash Spec In-Reply-To: References: <1333f222aa7285ec5524bd78602d5e35@ruby-forum.com> Message-ID: <86ecfbbd8436d5c42a373d9b2f5689db@ruby-forum.com> Here are the failure messages, and the backtraces. Thx 1) SessionsController #create authenticate fail flash.now[:error] should be set to failure Failure/Error: flash.now[:error].should == "Invalid username or password!" expected: "Invalid username or password!", got: nil (using ==) # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/expectations/fail_with.rb:23:in `fail_with' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/matchers/operator_matcher.rb:39:in `fail_with_message' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/matchers/operator_matcher.rb:61:in `__delegate_operator' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/matchers/operator_matcher.rb:51:in `eval_match' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/matchers/operator_matcher.rb:29:in `block in use_custom_matcher_or_delegate' # ./spec/controllers/sessions_spec.rb:33:in `block (4 levels) in ' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:41:in `instance_eval' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:41:in `block in run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:39:in `catch' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:39:in `run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:181:in `block in run_examples' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:179:in `map' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:179:in `run_examples' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:171:in `run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in `block in run_all' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in `each' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in `inject' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in `run_all' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:27:in `block in run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:34:in `block in report' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:140:in `sync_output' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:29:in `report' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:26:in `run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:12:in `block in autorun' 2) SessionsController #create authenticate successfully should redirect Failure/Error: expects(:redirect_to_target_or_default).with(twikets_path) not all expectations were satisfied unsatisfied expectations: - expected exactly once, not yet invoked: #.redirect_to_target_or_default('/twikets') satisfied expectations: - allowed any number of times, already invoked once: User(id: integer, username: string, name: string, password_hash: string, password_salt: string, status: string, lock_version: integer, created_at: datetime, updated_at: datetime).authenticate(any_parameters) # ./spec/controllers/sessions_spec.rb:44:in `block (4 levels) in ' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:41:in `instance_eval' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:41:in `block in run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:39:in `catch' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:39:in `run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:181:in `block in run_examples' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:179:in `map' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:179:in `run_examples' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:171:in `run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in `block in run_all' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in `each' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in `inject' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in `run_all' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:27:in `block in run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:34:in `block in report' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:140:in `sync_output' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:29:in `report' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:26:in `run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:12:in `block in autorun' Finished in 0.47966 seconds 14 examples, 2 failures -- Posted via http://www.ruby-forum.com/. From billturner at gmail.com Mon May 17 13:21:57 2010 From: billturner at gmail.com (Bill Turner) Date: Mon, 17 May 2010 10:21:57 -0700 (PDT) Subject: [rspec-users] A full rails application with rspec test code In-Reply-To: <68e6dd6e-27c9-4f9b-946f-de9608ca5130@q13g2000vbm.googlegroups.com> References: <68e6dd6e-27c9-4f9b-946f-de9608ca5130@q13g2000vbm.googlegroups.com> Message-ID: There's a pretty good list of full apps with good test coverage here: http://jetpackweb.com/blog/2009/10/14/high-quality-ruby-on-rails-example-applications/ bostonrb is there, and some don't use RSpec, but several do. That would be a good place to start, but I'm eager to see some others as well. Bill On May 14, 6:55?pm, Nadal wrote: > I used bostonrb code basehttp://github.com/bostonrb/bostonrbto learn > about shoulda. Similarly is there a decent rails based application > with test code in rspec to see how to write good rspec test code at > both unit and functional level. > > I am trying to get started with rspec. > > Thanks > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > -- > You received this message because you are subscribed to the Google Groups "rspec" group. > To post to this group, send email to rspec at googlegroups.com. > To unsubscribe from this group, send email to rspec+unsubscribe at googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rspec?hl=en. From dchelimsky at gmail.com Mon May 17 23:01:00 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 17 May 2010 22:01:00 -0500 Subject: [rspec-users] Failing Flash Spec In-Reply-To: <86ecfbbd8436d5c42a373d9b2f5689db@ruby-forum.com> References: <1333f222aa7285ec5524bd78602d5e35@ruby-forum.com> <86ecfbbd8436d5c42a373d9b2f5689db@ruby-forum.com> Message-ID: On Mon, May 17, 2010 at 9:32 PM, Kwang how Tan wrote: > Here are the failure messages, and the backtraces. > > Thx > > 1) SessionsController #create authenticate fail flash.now[:error] should > be set to failure > ? ?Failure/Error: flash.now[:error].should == "Invalid username or > password!" > ? ?expected: "Invalid username or password!", > ? ? ? ? got: nil (using ==) I think the problem here is that the expectation is set on flash.now, but that's not how flash.now works - views still just access flash (not flash.now). Try this: it 'flash.now[:error] should be set to failure' do post :create flash[:error].should == "Invalid username or password!" end > > 2) SessionsController #create authenticate successfully should redirect > ? ?Failure/Error: > expects(:redirect_to_target_or_default).with(twikets_path) And in this case the expects message is being sent to the example group, not the controller. Try: controller.expects(:redirect_to_target_or_default).with(twikets_path) HTH, David From lists at ruby-forum.com Tue May 18 00:52:11 2010 From: lists at ruby-forum.com (Kwang how Tan) Date: Tue, 18 May 2010 06:52:11 +0200 Subject: [rspec-users] Failing Flash Spec In-Reply-To: References: <1333f222aa7285ec5524bd78602d5e35@ruby-forum.com> <86ecfbbd8436d5c42a373d9b2f5689db@ruby-forum.com> Message-ID: Both Spec still fail :( 1) SessionsController #create authenticate fail flash.now[:error] should be set to failure Failure/Error: flash[:error].should == "Invalid username or password!" expected: "Invalid username or password!", got: nil (using ==) # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/expectations/fail_with.rb:23:in `fail_with' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/matchers/operator_matcher.rb:39:in `fail_with_message' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/matchers/operator_matcher.rb:61:in `__delegate_operator' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/matchers/operator_matcher.rb:51:in `eval_match' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/matchers/operator_matcher.rb:29:in `block in use_custom_matcher_or_delegate' # ./spec/controllers/sessions_spec.rb:33:in `block (4 levels) in ' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:41:in `instance_eval' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:41:in `block in run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:39:in `catch' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:39:in `run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:181:in `block in run_examples' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:179:in `map' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:179:in `run_examples' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:171:in `run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in `block in run_all' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in `each' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in `inject' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in `run_all' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:27:in `block in run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:34:in `block in report' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:140:in `sync_output' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:29:in `report' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:26:in `run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:12:in `block in autorun' 2) SessionsController #create authenticate successfully should redirect Failure/Error: controller.expects(:redirect_to_target_or_default).with(twikets_path) undefined local variable or method `controller' for # # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/matchers/method_missing.rb:6:in `method_missing' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/actionpack-3.0.0.beta3/lib/action_dispatch/testing/assertions/routing.rb:174:in `method_missing' # ./spec/controllers/sessions_spec.rb:44:in `block (4 levels) in ' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:41:in `instance_eval' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:41:in `block in run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:39:in `catch' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:39:in `run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:181:in `block in run_examples' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:179:in `map' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:179:in `run_examples' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:171:in `run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in `block in run_all' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in `each' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in `inject' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in `run_all' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:27:in `block in run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:34:in `block in report' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:140:in `sync_output' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:29:in `report' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:26:in `run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:12:in `block in autorun' Finished in 0.40236 seconds 14 examples, 2 failures -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Tue May 18 10:27:47 2010 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 18 May 2010 15:27:47 +0100 Subject: [rspec-users] Quickcheck testing framework In-Reply-To: <17434AD5-131E-43EA-A9E0-7F2FED095053@railsnewbie.com> References: <17434AD5-131E-43EA-A9E0-7F2FED095053@railsnewbie.com> Message-ID: <50B7780E-269F-483B-BE27-33DE3B5C31D7@mattwynne.net> On 16 May 2010, at 18:54, Scott Taylor wrote: > > Hey all, > > I'm wondering if anyone has any experience with an automated test-case generation tool like Quickcheck (for erlang/haskell). I'd be interested in hearing any impressions, war stories, or dev workflows regarding a tool like this. Talking off list to David C, he suggested that it might be a complimentary tool to a TDD/BDD framework like rspec. > > It appears as though there is a similar project out there for ruby named rushcheck (http://rushcheck.rubyforge.org/). Doesn't seem like it's been maintained in a few years, though, and I'm guessing no one is using it. I wonder if it these automated test generation tools are more appropriate in functional languages like Haskell and Erlang. > > Scott A year ago I was at the SPA conference (which I'm at right now) in London. The whole week ended up being very Haskell-themed, with Simon Peyton-Jones doing a keynote, a couple of different tutorials and some impromptu dojos at lunchtime. Then on the last day a couple of French guys ran a fascinating session. They had a simple CLI Java app which simulated an ATM machine. The first part of the exercise was to build a model of the behaviour of the ATM program. The model was based on naming the different states that the ATM could be in (waiting for PIN, waiting for amount etc) and the possible transitions between those states (enter incorrect PIN, enter amount etc). We then used Haskell to build a representation of that model in code. The idea (which we didn't have time to get to in the session) was then to connect the Haskell model to the real application and use QuickCheck to spray test-cases at it, through the Haskell model. One of the interesting things for me was how similar that model felt to a set of Cucumber features. In Cucumber we express behaviour in terms of scenarios where we put the application into a particular state, interfere with it in some way, and then see what state it has transitioned into. So when we write Gherkin features for our programs we're really building up a model of how we expect the application to behave. I wondered at the time whether there was any way to either actually generate a Haskell wrapper model from Gherkin code (in order to use QuickCheck) or somehow write a QuickCheck-like program in Ruby that understood Gherkin. Then I went back to work and forgot all about it. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From myron.marston at gmail.com Wed May 19 17:11:21 2010 From: myron.marston at gmail.com (Myron Marston) Date: Wed, 19 May 2010 14:11:21 -0700 (PDT) Subject: [rspec-users] How to separate unit and integration spec suites? Message-ID: On my current rails project we're using both rspec and cucumber. We've been diligent about keeping our specs as true unit tests, using nulldb and mocking/stubbing to disconnect the specs from the database and keep each spec focused on the class/method under test. Our cucumber features are integration tests and use the database (as they should). This separation has worked well for us up to now. Our specs have remained fairly fast, even as our spec suite has grown (around 1200 specs, currently). I've started working on building an REST-inspired HTTP API for the app. Initially, I've continued to use cucumber to integration test the API. However, I'm now convinced that as great as cucumber is for integration testing the user-facing parts of our application, it's not the right tool for integration testing the API. I'd like to write my API integration tests using just rspec and rack-test. But I really like the fact that "rake spec" runs only the unit tests, and is much faster than running all of the tests. I don't want to give that up. Is there an easy way to setup multiple spec suites within a single rails app? I'd like to run the integration test specs separately from the unit test specs. Thanks, Myron From dchelimsky at gmail.com Wed May 19 17:19:40 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 19 May 2010 16:19:40 -0500 Subject: [rspec-users] How to separate unit and integration spec suites? In-Reply-To: References: Message-ID: <9F1A12CE-C021-4D81-9011-BB8C47F3C6F6@gmail.com> On May 19, 2010, at 4:11 PM, Myron Marston wrote: > On my current rails project we're using both rspec and cucumber. > We've been diligent about keeping our specs as true unit tests, using > nulldb and mocking/stubbing to disconnect the specs from the database > and keep each spec focused on the class/method under test. Our > cucumber features are integration tests and use the database (as they > should). This separation has worked well for us up to now. Our specs > have remained fairly fast, even as our spec suite has grown (around > 1200 specs, currently). > > I've started working on building an REST-inspired HTTP API for the > app. Initially, I've continued to use cucumber to integration test > the API. However, I'm now convinced that as great as cucumber is for > integration testing the user-facing parts of our application, it's not > the right tool for integration testing the API. I'd like to write my > API integration tests using just rspec and rack-test. But I really > like the fact that "rake spec" runs only the unit tests, and is much > faster than running all of the tests. I don't want to give that up. > > Is there an easy way to setup multiple spec suites within a single > rails app? I'd like to run the integration test specs separately from > the unit test specs. In rspec-1 you pretty much have to do it by directories. In rspec-2 you can use arbitrary hash key/values as filters: describe "something", :suite => "my fast suite" do ... end RSpec.configure do |c| c.filter_run :suite => "my fast suite" end As of now there is not an easy way to hook into that to create different "profiles" like Cucumber, but it'd be pretty easy to add and we should definitely do so before rspec-2 goes final. Because the filtering can be arbitrarily complex (using lambdas), we need to keep it in ruby, but maybe we have a DSL for named filters that we can key off on the command line. Something like: RSpec.configure do |c| c.filter :fast, :suite => "my fast suite" end Then, on the command line: rspec spec --filter fast WDYT? From myron.marston at gmail.com Wed May 19 17:45:06 2010 From: myron.marston at gmail.com (Myron Marston) Date: Wed, 19 May 2010 14:45:06 -0700 (PDT) Subject: [rspec-users] How to separate unit and integration spec suites? In-Reply-To: <9F1A12CE-C021-4D81-9011-BB8C47F3C6F6@gmail.com> References: <9F1A12CE-C021-4D81-9011-BB8C47F3C6F6@gmail.com> Message-ID: <11f36cd2-9779-4874-add5-744029b2ef85@u20g2000pru.googlegroups.com> The new tagging support in rspec 2 looks fantastic, but I don't think we're ready to upgrade to rspec 2 yet, especially since it's still in beta. How does the directory approach work with rspec 1? (And feel free to point me to a blog post or wiki entry that documents this--I've done some googling but haven't found anything yet). Myron On May 19, 2:19?pm, David Chelimsky wrote: > On May 19, 2010, at 4:11 PM, Myron Marston wrote: > > > > > On my current rails project we're using both rspec and cucumber. > > We've been diligent about keeping our specs as true unit tests, using > > nulldb and mocking/stubbing to disconnect the specs from the database > > and keep each spec focused on the class/method under test. ?Our > > cucumber features are integration tests and use the database (as they > > should). ?This separation has worked well for us up to now. ?Our specs > > have remained fairly fast, even as our spec suite has grown (around > > 1200 specs, currently). > > > I've started working on building an REST-inspired HTTP API for the > > app. ?Initially, I've continued to use cucumber to integration test > > the API. ?However, I'm now convinced that as great as cucumber is for > > integration testing the user-facing parts of our application, it's not > > the right tool for integration testing the API. ?I'd like to write my > > API integration tests using just rspec and rack-test. ?But I really > > like the fact that "rake spec" runs only the unit tests, and is much > > faster than running all of the tests. ?I don't want to give that up. > > > Is there an easy way to setup multiple spec suites within a single > > rails app? ?I'd like to run the integration test specs separately from > > the unit test specs. > > In rspec-1 you pretty much have to do it by directories. In rspec-2 you can use arbitrary hash key/values as filters: > > describe "something", :suite => "my fast suite" do > ? ... > end > > RSpec.configure do |c| > ? c.filter_run :suite => "my fast suite" > end > > As of now there is not an easy way to hook into that to create different "profiles" like Cucumber, but it'd be pretty easy to add and we should definitely do so before rspec-2 goes final. Because the filtering can be arbitrarily complex (using lambdas), we need to keep it in ruby, but maybe we have a DSL for named filters that we can key off on the command line. Something like: > > RSpec.configure do |c| > ? c.filter :fast, :suite => "my fast suite" > end > > Then, on the command line: > > rspec spec --filter fast > > WDYT? > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > -- > You received this message because you are subscribed to the Google Groups "rspec" group. > To post to this group, send email to rspec at googlegroups.com. > To unsubscribe from this group, send email to rspec+unsubscribe at googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rspec?hl=en. From dchelimsky at gmail.com Wed May 19 21:19:52 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 19 May 2010 20:19:52 -0500 Subject: [rspec-users] How to separate unit and integration spec suites? In-Reply-To: <11f36cd2-9779-4874-add5-744029b2ef85@u20g2000pru.googlegroups.com> References: <9F1A12CE-C021-4D81-9011-BB8C47F3C6F6@gmail.com> <11f36cd2-9779-4874-add5-744029b2ef85@u20g2000pru.googlegroups.com> Message-ID: On May 19, 2010, at 4:45 PM, Myron Marston wrote: > The new tagging support in rspec 2 looks fantastic, but I don't think > we're ready to upgrade to rspec 2 yet, especially since it's still in > beta. > > How does the directory approach work with rspec 1? (And feel free to > point me to a blog post or wiki entry that documents this--I've done > some googling but haven't found anything yet). Take a peek at http://github.com/dchelimsky/rspec-rails/blob/master/generators/rspec/templates/rspec.rake#L86 to see how rspec-rails-1.3.2 configures rake tasks to run files in different directories. HTH, David > > Myron > > On May 19, 2:19 pm, David Chelimsky wrote: >> On May 19, 2010, at 4:11 PM, Myron Marston wrote: >> >> >> >>> On my current rails project we're using both rspec and cucumber. >>> We've been diligent about keeping our specs as true unit tests, using >>> nulldb and mocking/stubbing to disconnect the specs from the database >>> and keep each spec focused on the class/method under test. Our >>> cucumber features are integration tests and use the database (as they >>> should). This separation has worked well for us up to now. Our specs >>> have remained fairly fast, even as our spec suite has grown (around >>> 1200 specs, currently). >> >>> I've started working on building an REST-inspired HTTP API for the >>> app. Initially, I've continued to use cucumber to integration test >>> the API. However, I'm now convinced that as great as cucumber is for >>> integration testing the user-facing parts of our application, it's not >>> the right tool for integration testing the API. I'd like to write my >>> API integration tests using just rspec and rack-test. But I really >>> like the fact that "rake spec" runs only the unit tests, and is much >>> faster than running all of the tests. I don't want to give that up. >> >>> Is there an easy way to setup multiple spec suites within a single >>> rails app? I'd like to run the integration test specs separately from >>> the unit test specs. >> >> In rspec-1 you pretty much have to do it by directories. In rspec-2 you can use arbitrary hash key/values as filters: >> >> describe "something", :suite => "my fast suite" do >> ... >> end >> >> RSpec.configure do |c| >> c.filter_run :suite => "my fast suite" >> end >> >> As of now there is not an easy way to hook into that to create different "profiles" like Cucumber, but it'd be pretty easy to add and we should definitely do so before rspec-2 goes final. Because the filtering can be arbitrarily complex (using lambdas), we need to keep it in ruby, but maybe we have a DSL for named filters that we can key off on the command line. Something like: >> >> RSpec.configure do |c| >> c.filter :fast, :suite => "my fast suite" >> end >> >> Then, on the command line: >> >> rspec spec --filter fast >> >> WDYT? >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users >> >> -- >> You received this message because you are subscribed to the Google Groups "rspec" group. >> To post to this group, send email to rspec at googlegroups.com. >> To unsubscribe from this group, send email to rspec+unsubscribe at googlegroups.com. >> For more options, visit this group athttp://groups.google.com/group/rspec?hl=en. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From audrey.lee.is.me at gmail.com Tue May 18 14:08:23 2010 From: audrey.lee.is.me at gmail.com (Audrey A Lee) Date: Tue, 18 May 2010 11:08:23 -0700 (PDT) Subject: [rspec-users] How I make browser act-as-robot-driven ? Message-ID: <0dbd24cf-464f-4871-ab16-9275ae063bdc@34g2000prs.googlegroups.com> Dear list, Today I am working through the simple tutorial here: http://wiki.github.com/aslakhellesoy/cucumber/ruby-on-rails It has me install Cucumber-Rails and then create a feature. Then I watch the feature fail when I run rake cucumber Then I watch the feature pass after I implement some code with the help of: script/generate rspec_scaffold Frooble name:string color:string description:text So I am happy. I am curious though. I'd like to have a browser appear and act-as-robot-driven. This is convenient for my development efforts. It allows me to rapidly create a development state inside a controller and then halt the controller with a debugger statement. Then I attach my mind to that state and tinker with values of variables and snippets of code. This is behavior I observed on a Rails project I wrote back in late 2009. Back then I was using this combination of gems: - cucumber 0.6.x - rspec-rails-1.2.9 - Selenium-1.1.14 So, here is my question: Using this combo of gems, is it possible to have a browser appear and act-as-robot-driven: cucumber (0.7.3) cucumber-rails (0.3.1) capybara (0.3.5) ??? From josephwilk at me.com Tue May 18 16:10:27 2010 From: josephwilk at me.com (Joseph Wilk) Date: Tue, 18 May 2010 21:10:27 +0100 Subject: [rspec-users] Quickcheck testing framework In-Reply-To: <4081A033-35E7-4236-BA1C-6E22E261DAE1@gmail.com> References: <17434AD5-131E-43EA-A9E0-7F2FED095053@railsnewbie.com> <8FD25E18-29A9-4997-AD30-705A4014458D@railsnewbie.com> <4081A033-35E7-4236-BA1C-6E22E261DAE1@gmail.com> Message-ID: On 17 May 2010, at 11:38, David Chelimsky wrote: > On May 16, 2010, at 11:10 PM, Scott Taylor wrote: > >> >> On May 16, 2010, at 8:13 PM, David Chelimsky wrote: >> >>> On May 16, 2010, at 12:54 PM, Scott Taylor wrote: >>> >>>> Hey all, >>>> >>>> I'm wondering if anyone has any experience with an automated test- >>>> case generation tool like Quickcheck (for erlang/haskell). I'd be >>>> interested in hearing any impressions, war stories, or dev >>>> workflows regarding a tool like this. Talking off list to David >>>> C, he suggested that it might be a complimentary tool to a TDD/ >>>> BDD framework like rspec. This is something I've been playing around with in Cucumber for quite a while. My main thought is I want to make more use of dead CPU time. When I'm sleeping I want my tests and system being exercised. What I'm thinking is a tool in Cucumber a little like heckle. Mutating the matches/inputs (which in cucumber represent regexp matches) and examing the output. A cucumber test can be seen as a black box with inputs we can prod at and observe the output. What I want out of this is a report which shows me failures and what inputs where used. In order to prevent a sprawl of failures it would be useful to derive from the failures rules which describe a group of failing tests. I.e with int between 1 and 100 test failed. I think of this This is a different usecase to Rspec but thought some of my thoughts might be useful. >>>> >>> >>> My thinking here is that it could be useful to drive out an >>> initial implementation using TDD, and at the point we think we've >>> got the solution we want, add something quickcheck-like to try to >>> poke holes in it. I'd probably then add new examples if any cases >>> I hadn't considered were revealed through this process. >> >> Have you watched John Hughes' presentation on the matter? >> >> http://video.google.com/videoplay?docid=4655369445141008672# > > I haven't yet. I'll give it a look-see later today. > >> It's sort of interesting that he won't do any TDD - he'll let the >> reduction process generate the "minimum" test case, and go from >> there (that's not explicitly stated in that video, although I'm >> pretty sure I've heard him say it before). >> >> If I had a tool like this, I'm guessing I'd probably have a >> workflow like the following: >> >> 1. use the random test case generator, and fix any issues that were >> obvious. >> 2. If something wasn't obvious, I'd go and write a test case for in >> a more traditional testing tool (rspec). I often use the debugger >> in conjunction with the spec runner, running the one test case with >> a debugger statement at the start of the test case. >> 3. Any regressions would (obviously) happen in the traditional tool. >> >> The big win with a tool like this is not testing boundary cases, >> it's in having the tool "write" the test cases for you. OTOH, I >> wonder if the simplicity of the implementation would be sacrificed >> when taking this approach. > > My guess is that it would. > >> Another drawback - I have no idea how such a tool would integrate >> with a build server. > > What integration point would there need to be? It's just Ruby. > >>>> It appears as though there is a similar project out there for >>>> ruby named rushcheck (http://rushcheck.rubyforge.org/). >>> >>> It's up on github too: http://github.com/hayeah/rushcheck. Same >>> guy has this too: http://github.com/hayeah/rantly - random data >>> generator - looks like you could do stuff like: >>> >>> Rantly.new.each(100) do >>> thing.method_that_accepts_a_string(string).should have_some_quality >>> end >> >> There's a blog post about the library here, if anyone is interested: >> >> http://www.metacircus.com/hacking/2009/04/10/look-ma-no-monads.html >> >> I've been thinking about integrating a port of the ruby library >> faker into scriptcheck, the javascript testing tool I've been >> working on: >> >> http://github.com/Marak/Faker.js >> http://github.com/smtlaissezfaire/scriptcheck >> >>> >>> This would cause 100 random strings to be generated and passed to >>> thing.method_that_accepts_a_string. Assuming the matcher verifies >>> some set of rules about the outcomes, you've basically got quick >>> check. >> >> Yeah, pretty much. One issue, though, is that you don't want to >> hard code the number of random generations. > > Why not? Wouldn't it make sense to have smaller numbers in some > cases and larger ones in others? > >> You'll also want a convenient way to run just one given test case >> easily (which rspec already has). You'll probably also want to >> separate these random generation tests from the rest of your tests. > > Exactly! This is what I had in mind when I said "at the point we > think we've got the solution we want, add something quickcheck-like > to try to poke holes in it." The steps would be: > > 1. Drive out minimal implementation with specs > 2. Write some quickcheck-ish tests in a separate location > 3. Run them > 4. If there are any failures, use them to evaluate and enhance the > specs that I'd already written > > This would really amplify the distinction between specs and tests. > Plus, the tests would be indirectly testing the specs as much as > they are testing the implementation. Of course, this is all > theoretical. If we could just use quickcheck and still get all the > documentation and implementation-driving benefits of TDD, I'd > probably move in that direction myself :) > >> Hitting a database 1000 times for one test is going to be costly. > > If we used the process I just outlined, we could run the specs using > autotest (ironic), and only run the tests on demand and on the CI > server. > >> Now that I'm thinking about it, it might make a ton of sense in >> languages like erlang or haskell where everything is functional >> because those languages lend themselves to parallelization since >> there are no shared resources. >> >> Regards, >> >> Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Thu May 20 08:13:08 2010 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 20 May 2010 13:13:08 +0100 Subject: [rspec-users] How to separate unit and integration spec suites? In-Reply-To: References: Message-ID: On 19 May 2010, at 22:11, Myron Marston wrote: > On my current rails project we're using both rspec and cucumber. > We've been diligent about keeping our specs as true unit tests, using > nulldb and mocking/stubbing to disconnect the specs from the database > and keep each spec focused on the class/method under test. Our > cucumber features are integration tests and use the database (as they > should). This separation has worked well for us up to now. Our specs > have remained fairly fast, even as our spec suite has grown (around > 1200 specs, currently). > > I've started working on building an REST-inspired HTTP API for the > app. Initially, I've continued to use cucumber to integration test > the API. However, I'm now convinced that as great as cucumber is for > integration testing the user-facing parts of our application, it's not > the right tool for integration testing the API. I know this isn't why you're here, but can I ask why not? At Songkick we actually went the other way and ended up converting rspec-based integration tests for the API into cukes when we got the hang of testing it via Cucumber. > I'd like to write my > API integration tests using just rspec and rack-test. But I really > like the fact that "rake spec" runs only the unit tests, and is much > faster than running all of the tests. I don't want to give that up. > > Is there an easy way to setup multiple spec suites within a single > rails app? I'd like to run the integration test specs separately from > the unit test specs. > > Thanks, > Myron > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Thu May 20 12:49:20 2010 From: lists at ruby-forum.com (Tom Ten Thij) Date: Thu, 20 May 2010 18:49:20 +0200 Subject: [rspec-users] Strange issue with the 'its' construct Message-ID: The 'its' construct seems to not be working for me. I have narrowed it down to a basic example that I think should be working. Note that when I use a normal 'it' block with a subject in it, that works fine. Any insights would be welcome: http://gist.github.com/407789 Cheers, Tom. == Below is just a copy of the content of the gist == >: cat spec/controllers/simple_spec.rb require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe HomeController do context "looking at an email" do subject do mail = TMail::Mail.new mail.from = "origin at example.com" mail end # This passes as expected. it "should have the correct from address" do subject.from.should == ['origin at example.com'] end # I don't understand why this fails. its(:from) { should == ['origin at example.com'] } end end >: ./script/spec spec/controllers/simple_spec.rb -b .F 1) NoMethodError in 'HomeController looking at an email from should == ["origin at example.com"]' undefined method `from' for # /my/project/vendor/gems/rspec-1.3.0/lib/spec/example/subject.rb:25:in `send' /my/project/vendor/gems/rspec-1.3.0/lib/spec/example/subject.rb:25:in `subject' /my/project/vendor/gems/rspec-1.3.0/lib/spec/example/subject.rb:91:in `should' ./spec/controllers/simple_spec.rb:14: /my/project/vendor/gems/rspec-1.3.0/lib/spec/example/example_methods.rb:40:in `instance_eval' /my/project/vendor/gems/rspec-1.3.0/lib/spec/example/example_methods.rb:40:in `execute' /Users/tomtt/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/timeout.rb:53:in `timeout' /my/project/vendor/gems/rspec-1.3.0/lib/spec/example/example_methods.rb:37:in `execute' /my/project/vendor/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:214:in `run_examples' /my/project/vendor/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:212:in `each' /my/project/vendor/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:212:in `run_examples' /my/project/vendor/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:103:in `run' /my/project/vendor/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:23:in `run' /my/project/vendor/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:22:in `each' /my/project/vendor/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:22:in `run' /my/project/vendor/gems/rspec-1.3.0/lib/spec/runner/options.rb:152:in `run_examples' /my/project/vendor/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:in `run' ./script/spec:10: Finished in 0.031435 seconds 2 examples, 1 failure Attachments: http://www.ruby-forum.com/attachment/4745/simple_spec.rb -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu May 20 13:56:31 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 20 May 2010 12:56:31 -0500 Subject: [rspec-users] Strange issue with the 'its' construct In-Reply-To: References: Message-ID: <15593B4E-FEBD-4ABC-811E-2DF94CB20250@gmail.com> On May 20, 2010, at 11:49 AM, Tom Ten Thij wrote: > The 'its' construct seems to not be working for me. I have narrowed it > down to a basic example that I think should be working. Note that when I > use a normal 'it' block with a subject in it, that works fine. > > Any insights would be welcome: http://gist.github.com/407789 > > Cheers, Tom. > > == Below is just a copy of the content of the gist == > >> : cat spec/controllers/simple_spec.rb > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > > describe HomeController do > context "looking at an email" do > subject do > mail = TMail::Mail.new > mail.from = "origin at example.com" > mail > end > > # This passes as expected. > it "should have the correct from address" do > subject.from.should == ['origin at example.com'] > end > > # I don't understand why this fails. > its(:from) { should == ['origin at example.com'] } > end > end > >> : ./script/spec spec/controllers/simple_spec.rb -b Please file a bug at https://rspec.lighthouseapp.com/projects/5645-rspec if there's not one already. Thanks, David > .F > > 1) > NoMethodError in 'HomeController looking at an email from should == > ["origin at example.com"]' > undefined method `from' for # > /my/project/vendor/gems/rspec-1.3.0/lib/spec/example/subject.rb:25:in > `send' > /my/project/vendor/gems/rspec-1.3.0/lib/spec/example/subject.rb:25:in > `subject' > /my/project/vendor/gems/rspec-1.3.0/lib/spec/example/subject.rb:91:in > `should' > ./spec/controllers/simple_spec.rb:14: > /my/project/vendor/gems/rspec-1.3.0/lib/spec/example/example_methods.rb:40:in > `instance_eval' > /my/project/vendor/gems/rspec-1.3.0/lib/spec/example/example_methods.rb:40:in > `execute' > /Users/tomtt/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/timeout.rb:53:in > `timeout' > /my/project/vendor/gems/rspec-1.3.0/lib/spec/example/example_methods.rb:37:in > `execute' > /my/project/vendor/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:214:in > `run_examples' > /my/project/vendor/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:212:in > `each' > /my/project/vendor/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:212:in > `run_examples' > /my/project/vendor/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:103:in > `run' > /my/project/vendor/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:23:in > `run' > /my/project/vendor/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:22:in > `each' > /my/project/vendor/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:22:in > `run' > /my/project/vendor/gems/rspec-1.3.0/lib/spec/runner/options.rb:152:in > `run_examples' > /my/project/vendor/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:in > `run' > ./script/spec:10: > > Finished in 0.031435 seconds > > 2 examples, 1 failure > > Attachments: > http://www.ruby-forum.com/attachment/4745/simple_spec.rb > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From sqapro at gmail.com Thu May 20 16:21:49 2010 From: sqapro at gmail.com (Chuck van der Linden) Date: Thu, 20 May 2010 13:21:49 -0700 (PDT) Subject: [rspec-users] How I make browser act-as-robot-driven ? In-Reply-To: <0dbd24cf-464f-4871-ab16-9275ae063bdc@34g2000prs.googlegroups.com> References: <0dbd24cf-464f-4871-ab16-9275ae063bdc@34g2000prs.googlegroups.com> Message-ID: On May 18, 11:08?am, Audrey A Lee wrote: > Dear list, > > Today I am working through the simple tutorial here: > ?http://wiki.github.com/aslakhellesoy/cucumber/ruby-on-rails > > It has me install Cucumber-Rails and then create a feature. > > Then I watch the feature fail when I run > rake cucumber > > Then I watch the feature pass after I implement some code with the > help of: > > script/generate rspec_scaffold Frooble name:string color:string > description:text > > So I am happy. > > I am curious though. > > I'd like to have a browser appear and act-as-robot-driven. > > This is convenient for my development efforts. > > It allows me to rapidly create a development state inside a controller > and then halt the controller with a debugger statement. > > Then I attach my mind to that state and tinker with values of > variables and snippets of code. > > This is behavior I observed on a Rails project I wrote back in late > 2009. > > Back then I was using this combination of gems: > > - cucumber 0.6.x > - rspec-rails-1.2.9 > - Selenium-1.1.14 > > So, here is my question: > > Using this combo of gems, is it possible to have a browser appear and > act-as-robot-driven: > > cucumber (0.7.3) > cucumber-rails (0.3.1) > capybara (0.3.5) > > ??? > _______________________________________________ If you are looking for an easy way to 'drive' a browser with Ruby I'd suggest looking at WATIR (Web Application Testing In Ruby) which is designed for just that sort of thing. I use it along with Cucumber to do regression test suites that test the system 'end to end' In my case I happen to use it within the Watircraft framework, just because it makes things a bit easier when doing a whole suite of tests, but for simple stuff it's probably overkill. There's also something called 'watercuke' referenced in the ccumber wiki (which I really don't know much about) that provides a enhanced level of integration.. If you search the web you can perhaps also find some recordings that people have done at various conferences or user-group meetings where demo's were done of using Water and Cucumber together From aslak.hellesoy at gmail.com Thu May 20 16:41:50 2010 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 20 May 2010 22:41:50 +0200 Subject: [rspec-users] How I make browser act-as-robot-driven ? In-Reply-To: References: <0dbd24cf-464f-4871-ab16-9275ae063bdc@34g2000prs.googlegroups.com> Message-ID: On Thu, May 20, 2010 at 10:21 PM, Chuck van der Linden wrote: > > On May 18, 11:08?am, Audrey A Lee wrote: >> Dear list, >> >> Today I am working through the simple tutorial here: >> ?http://wiki.github.com/aslakhellesoy/cucumber/ruby-on-rails >> >> It has me install Cucumber-Rails and then create a feature. >> >> Then I watch the feature fail when I run >> rake cucumber >> >> Then I watch the feature pass after I implement some code with the >> help of: >> >> script/generate rspec_scaffold Frooble name:string color:string >> description:text >> >> So I am happy. >> >> I am curious though. >> >> I'd like to have a browser appear and act-as-robot-driven. >> >> This is convenient for my development efforts. >> >> It allows me to rapidly create a development state inside a controller >> and then halt the controller with a debugger statement. >> >> Then I attach my mind to that state and tinker with values of >> variables and snippets of code. >> >> This is behavior I observed on a Rails project I wrote back in late >> 2009. >> >> Back then I was using this combination of gems: >> >> - cucumber 0.6.x >> - rspec-rails-1.2.9 >> - Selenium-1.1.14 >> >> So, here is my question: >> >> Using this combo of gems, is it possible to have a browser appear and >> act-as-robot-driven: >> >> cucumber (0.7.3) >> cucumber-rails (0.3.1) >> capybara (0.3.5) >> >> ??? >> _______________________________________________ > > If you are looking for an easy way to 'drive' a browser with Ruby I'd > suggest looking at WATIR (Web Application Testing In Ruby) which is > designed for just that sort of thing. > I actually recommend you look at Capybara instead of Watir. It supports all major browsers by using the rock-solid Selenium2 (WebDriver) under the hood. Watir works too, but if you use Capybara you can use all of the features/step_definitions/web_steps.rb out of the box. Just add the @javascript tag above a Feature or Scenario and it should just work. Aslak > I use it along with Cucumber to do regression test suites that test > the system 'end to end' > > In my case I happen to use it within the Watircraft framework, just > because it makes things a bit easier when doing a whole suite of > tests, but for simple stuff it's probably overkill. > > There's also something called 'watercuke' referenced in the ccumber > wiki (which I really don't know much about) that provides a enhanced > level of integration.. > > If you search the web you can perhaps also find some recordings that > people have done at various conferences or user-group meetings where > demo's were done of using Water and Cucumber together > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Thu May 20 20:53:04 2010 From: lists at ruby-forum.com (Tom Ten Thij) Date: Fri, 21 May 2010 02:53:04 +0200 Subject: [rspec-users] Strange issue with the 'its' construct In-Reply-To: <15593B4E-FEBD-4ABC-811E-2DF94CB20250@gmail.com> References: <15593B4E-FEBD-4ABC-811E-2DF94CB20250@gmail.com> Message-ID: David Chelimsky wrote: > Please file a bug at https://rspec.lighthouseapp.com/projects/5645-rspec > if there's not one already. I was unable to find one, so I created this: https://rspec.lighthouseapp.com/projects/5645-rspec/tickets/998-explicit-subject-block-in-a-controller-spec-returns-the-controller-instead-of-the-subject-defined-in-the-example-group Another finding is that this only occurs when running the file from spec/controllers, it's fine when run from spec/models. Details are on the ticket. Thanks, Tom -- Posted via http://www.ruby-forum.com/. From stefan.kanev at gmail.com Fri May 21 09:34:27 2010 From: stefan.kanev at gmail.com (Stefan Kanev) Date: Fri, 21 May 2010 15:34:27 +0200 Subject: [rspec-users] Good practices on spec'ing views? In-Reply-To: <4BE4C340.7000105@gmail.com> References: <4BE4C340.7000105@gmail.com> Message-ID: Thank you for your answers! > In The Rspec Book, section 24.6 (chapter 24), "When I write view specs" offers some tips for determining when to write view specs. Have you read this section? I though I did, but I revisited it and I learned some new things. Thanks! I did some thinking on my own and I reached some conclusions. I would like to share them -- it will help me structure my reasoning. I would be happy to hear what you think. This is going to be long. I'm assuming that I want to use test doubles in view specs. I don't see much value in testing model, view and helper code at once. Also, I'm only checking for the presence of text and occasionally for the presence of a link. I'm not asserting DOM structure or rendering order. There is a big difference between using doubles in controller specs and in view specs. Controllers depend only on the models. Using test doubles in their specs leads you to a nice, clean public interface of the models and only a handful of simple messages in the actions. The code is just a simple moderator. This is what a clean controller should be, in my opinion. Views, on the other hand, know a lot of tiny details about the models. After all, they should if they are to present that information in a humane way. Thus, they are more coupled to the models than controllers. This requires more intricate test doubles. Furthermore, they also invoke helpers to do some of the work. Not only you have to mock them too, but most of the time helpers just take a model and return a result dependent on it. This is tricky to mock (simplest case you make a mock of the model and set an expectation on a helper). That's two problems with test doubles in view specs -- (1) view and model is more tightly coupled and (2) you have helpers as a depend-on component. At this point, getting the test doubles right is too much work. The usual problem that I have, is that as soon as I complete a refactoring in the model, I have to spend an equal (or even greater) effort to fix the doubles in spec failures, that are false negatives. I think I've seen this named 'fragile test'. Thus, my approach would be to avoid writing view specs most of the time and make sure I've provided the safety net with Cucumber. That is my case against view specs. I can see two reasons to write them, though. First, I can consider it as purchasing technical debt. I write a view spec instead of a Cucumber scenario for a small behavior modification. This gives me the safety net for a lower price (view specs take considerably less time), but the cost is that it hinders refactoring. Second, if I have something complex to display and no idea now to organize it, I can use a view spec to drive the design. This let's me base it on feedback, but when I've implemented the functionality back-to-back, the view spec has turned into an expensive artifact that hinders further refactoring. I've done that a few times -- it really helps me with the design, but I find myself removing the spec after a while since it takes just too much time to maintain. I also see two things that might invalidate this reasoning. First, presenters. They group the model and helpers logic that the view depends on, so now I would have to mock only one object. More importantly, that object is specifically designed to be used by the view, which means that the test double will be simple and that I can use the view spec to drive the design of the presenter. Second, moving all logic from the view to helpers that take the model as a parameter. This should simplify the test doubles, although you still will have to set expectations on helper invocations. This moves the intricate knowledge of the models in the helpers, which are easier to test. The view mediates models and helpers. I'm not sure if I like the resulting design. While the views look slick, you have to understand the helpers first in order to understand the view. Logic that belongs together is scattered around in multiple files, intermingled with other logic. Also, at this point I don't see much reason to write a view spec either, since the code that could possibly break is either in models or helpers, which are tested in isolation. If you insist on doing it, setting up test doubles is still a bit weird (you have to set expectations and define results on helpers and you have to use mocks for models). It gets particularly tricky when the view iterates over a collection and calls a few helpers with each item. On the more general note, while controllers are pretty OO in they nature and thus can tolerate test doubles, views are, well, just procedural Ruby embedded in HTML. Applying mocks to them doesn't seem a good fit to me. So, what do you think? Does this make sense? Did I miss anything? -------------- next part -------------- An HTML attachment was scrubbed... URL: From adam.sroka at gmail.com Fri May 21 15:27:40 2010 From: adam.sroka at gmail.com (Adam Sroka) Date: Fri, 21 May 2010 12:27:40 -0700 Subject: [rspec-users] Good practices on spec'ing views? In-Reply-To: <4BE4C340.7000105@gmail.com> References: <4BE4C340.7000105@gmail.com> Message-ID: I have had similar experiences. If I submit the form and assert stuff about the next page that comes up then I end up with a big slow integration test like the kind you talk about as bad. It seems to me like this is an overly coupled design, but I don't know a way around it if I intend to use HTML forms as designed. On the other hand, I can have a button click call something asynchronously. I can put the Ajax call in its own javascript object. Then I can stub that. Jasmine helps me do that quite nicely. I am not entirely sure what all of the implications of this are. It seems to me that even though the latter solution has more complexity in terms of javascript my tests are telling me that it has lower coupling and higher cohesion (i.e. page behavior is in javascript objects, not on the server. Some objects know how to talk to a server, but I can ignore those objects when I want to ignore the server.) On Fri, May 7, 2010 at 6:49 PM, J. B. Rainsberger wrote: > Stefan Kanev wrote: > >> I've been doing RSpec for more than a year by now, yet I cannot help but >> feel that I've never got a single view spec right. I can see that I have >> very few view specs and that my views tend be a lot messier than >> everything else. I've read the chapter in the RSpec book about spec'ing >> views, but I still think I'm not getting it right. >> >> Assuming that I'm a view spec noob, would you guys care to share your >> experience with writing them? What works and what doesn't? What should I >> avoid at all cost? And most importantly, how does the process of writing >> view specs feel? > > I write view specs, and doing so encourages me to move behavior out of the > views and into the controller. I find it easy to write specs to check how I > render dynamic data, but still don't have a good feel for writing specs that > check that action buttons submit the form I expect to submit. I imagine > writing more of the latter kind of spec will encourage me to avoid complex > form submissions. > > I treat view specs like any other specs: when I have a tough time writing > the spec, then I rethink my design choices. > -- > J. B. Rainsberger :: http://www.jbrains.ca :: > http://www.thecodewhisperer.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From adam.sroka at gmail.com Fri May 21 15:44:09 2010 From: adam.sroka at gmail.com (Adam Sroka) Date: Fri, 21 May 2010 12:44:09 -0700 Subject: [rspec-users] Good practices on spec'ing views? In-Reply-To: References: Message-ID: I test dynamic behavior in views using a combination of RSpec, Watir, and Jasmine. I don't test the structure of the view. I keep the structure simple and keep client side behavior mostly in client side code (i.e. javascript.) RSpec + Watir + jasmine is a heavy set of testing tools, but that is because most of the heavy lifting in modern web apps is in the browser. I want to make sure that it can't break. I keep it from getting too big or too slow by eliminating interactions with the server by mocking/stubbing Ajax calls. On Fri, Apr 30, 2010 at 1:26 AM, Stefan Kanev wrote: > Hey guys. > I've been doing RSpec for more than a year by now, yet I cannot help but > feel that I've never got a single view spec right. I can see that I have > very few view specs and that my views tend be a lot messier than everything > else. I've read the chapter in the RSpec book about spec'ing views, but I > still think I'm not getting it right. > Assuming that I'm a view spec noob, would you guys care to share your > experience with writing them? What works and what doesn't? What should I > avoid at all cost? And most importantly, how does the process of writing > view specs feel? > Thanks, > Stefan > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From patrick at collinatorstudios.com Sat May 22 12:47:43 2010 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Sat, 22 May 2010 09:47:43 -0700 (PDT) Subject: [rspec-users] customize output of script/spec? Message-ID: Hi, I am just curious-- is there any way to customize the output of the "expect", "got" that is returned? I often find myself comparing big blocks of text that are virtually identical except one minor detail (like a missing letter somewhere), and it's quite hard to tell what is different between the expected and got.. Is there perhaps a way to make it so that the actual differences have a different foreground or background color in the terminal? Thanks. Patrick J. Collins http://collinatorstudios.com From elliot.winkler at gmail.com Sat May 22 16:22:46 2010 From: elliot.winkler at gmail.com (Elliot Winkler) Date: Sat, 22 May 2010 15:22:46 -0500 Subject: [rspec-users] customize output of script/spec? In-Reply-To: References: Message-ID: I don't think RSpec has a built-in way to customize that. I think you'll just have to override the matcher you're using. Clone the git repo (or, `gem install open_gem` and then `gem open rspec`) and take a look at the spec/matchers/* directory for more (note that `.should ==`, `.should_not ==` is OperatorMatcher and not EqualMatcher). As for detecting the differences, you could check out one of these solutions [1], and then use the ansi-termcolor or colored gems to colorize the differences. -- Elliot [1]: http://stackoverflow.com/questions/80091/diff-a-ruby-string-or-array On Sat, May 22, 2010 at 11:47 AM, Patrick J. Collins < patrick at collinatorstudios.com> wrote: > Hi, > > I am just curious-- is there any way to customize the output of the > "expect", > "got" that is returned? > > I often find myself comparing big blocks of text that are virtually > identical > except one minor detail (like a missing letter somewhere), and it's quite > hard > to tell what is different between the expected and got.. > > Is there perhaps a way to make it so that the actual differences have a > different foreground or background color in the terminal? > > Thanks. > > Patrick J. Collins > http://collinatorstudios.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 node.js99 at gmail.com Sat May 22 18:41:17 2010 From: node.js99 at gmail.com (Nadal) Date: Sat, 22 May 2010 15:41:17 -0700 (PDT) Subject: [rspec-users] Not able to run tests for rspec itself Message-ID: I am talking about rspec itself and running tests written for rspec. This is what I did. > git clone http://github.com/dchelimsky/rspec.git > cd rspec > rake test I am getting following error rake aborted! No such file or directory - /Users/nadal/.rubyforge/user-config.yml /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe/rubyforge.rb:44:in `read' /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe/rubyforge.rb:44:in `define_rubyforge_tasks' /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:507:in `send' /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:507:in `load_plugin_tasks' /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:501:in `each' /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:501:in `load_plugin_tasks' /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:572:in `post_initialize' /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:293:in `spec' /Users/nadal/dev/working/rspec/Rakefile:11 From node.js99 at gmail.com Sat May 22 20:42:34 2010 From: node.js99 at gmail.com (Nadal) Date: Sat, 22 May 2010 17:42:34 -0700 (PDT) Subject: [rspec-users] Not able to run tests on rails Message-ID: This is what I did. Please tell me where did I go wrong. # I am using rails 2.3.5 rails demo cd demo ruby script/generate scaffold User name:string rake db:migrate rake db:test:prepare ruby script/plugin install git://github.com/dchelimsky/rspec.git -r 'refs/tags/1.2.9' ruby script/plugin install git://github.com/dchelimsky/rspec-rails.git -r 'refs/tags/1.2.9' mkdir spec/models touch spec/models/user_test.rb # this is the contents of user_test.rb require File.dirname(__FILE__) + '/../spec_helper' describe User do before(:each) do @user = User.new end describe "attributes" do it "should be valid" do @user.should be_valid end end end # then I ran test and nothing happen. The output is blank. rake spec:models From node.js99 at gmail.com Sat May 22 21:17:58 2010 From: node.js99 at gmail.com (Nadal) Date: Sat, 22 May 2010 18:17:58 -0700 (PDT) Subject: [rspec-users] Not able to run tests on rails In-Reply-To: References: Message-ID: Got it. File name should be user_spec.rb and not user_test.rb . On May 22, 8:42?pm, Nadal wrote: > This is what I did. Please tell me where did I go wrong. > > # I am using rails 2.3.5 > rails demo > cd demo > ruby script/generate scaffold User name:string > rake db:migrate > rake db:test:prepare > > ruby script/plugin install git://github.com/dchelimsky/rspec.git -r > 'refs/tags/1.2.9' > ruby script/plugin install git://github.com/dchelimsky/rspec-rails.git > -r 'refs/tags/1.2.9' > > mkdir spec/models > > touch spec/models/user_test.rb > > # this is the contents of user_test.rb > require File.dirname(__FILE__) + '/../spec_helper' > describe User do > ? before(:each) do > ? ? @user = User.new > ? end > ? describe "attributes" do > ? ? it "should be valid" do > ? ? ? @user.should be_valid > ? ? end > ? end > end > > # then I ran test and nothing happen. The output is blank. > rake spec:models > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > -- > You received this message because you are subscribed to the Google Groups "rspec" group. > To post to this group, send email to rspec at googlegroups.com. > To unsubscribe from this group, send email to rspec+unsubscribe at googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rspec?hl=en. From dchelimsky at gmail.com Sun May 23 11:35:48 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 23 May 2010 10:35:48 -0500 Subject: [rspec-users] Not able to run tests for rspec itself In-Reply-To: References: Message-ID: <3616B6E8-60AC-4CF4-A9E7-0140EE89A7F3@gmail.com> On May 22, 2010, at 5:41 PM, Nadal wrote: > I am talking about rspec itself and running tests written for rspec. > This is what I did. > >> git clone http://github.com/dchelimsky/rspec.git >> cd rspec >> rake test > > I am getting following error > > > rake aborted! > No such file or directory - /Users/nadal/.rubyforge/user-config.yml > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe/rubyforge.rb:44:in > `read' > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe/rubyforge.rb:44:in > `define_rubyforge_tasks' > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:507:in `send' > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:507:in > `load_plugin_tasks' > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:501:in `each' > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:501:in > `load_plugin_tasks' > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:572:in > `post_initialize' > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:293:in `spec' > /Users/nadal/dev/working/rspec/Rakefile:11 This works for me, using a clean gemset with rvm: $ gem install rake geminstaller $ git clone git://github.com/dchelimsky/rspec $ cd rspec $ geminstaller geminstaller.yml $ rake spec Give that a whirl and let us know how it works out. Cheers, David From bcardarella at gmail.com Sun May 23 11:41:23 2010 From: bcardarella at gmail.com (Brian Cardarella) Date: Sun, 23 May 2010 08:41:23 -0700 (PDT) Subject: [rspec-users] How do I isolation test against different gem versions? Message-ID: <8a897c95-e8b5-41cb-9536-cbca473c36ea@k31g2000vbu.googlegroups.com> I would like to support both ActiveRecord 2.x and ActiveModel 3.x for a given library. It is not clear to me how to write tests for this. If I require 'active_record' then all of the dependencies are also loaded and are now in the load path as well as the Gem loaded list. Considering that AR and AM share dependencies but of different versions conflicts occur. Is this possible? The difference in code is not enough to warrant breaking into separate gems. From rick.denatale at gmail.com Sun May 23 12:54:13 2010 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sun, 23 May 2010 12:54:13 -0400 Subject: [rspec-users] How do I isolation test against different gem versions? In-Reply-To: <8a897c95-e8b5-41cb-9536-cbca473c36ea@k31g2000vbu.googlegroups.com> References: <8a897c95-e8b5-41cb-9536-cbca473c36ea@k31g2000vbu.googlegroups.com> Message-ID: On Sun, May 23, 2010 at 11:41 AM, Brian Cardarella wrote: > I would like to support both ActiveRecord 2.x and ActiveModel 3.x for > a given library. It is not clear to me how to write tests for this. If > I require 'active_record' then all of the dependencies are also loaded > and are now in the load path as well as the Gem loaded list. > Considering that AR and AM share dependencies but of different > versions conflicts occur. > > Is this possible? The difference in code is not enough to warrant > breaking into separate gems. I do something similar for RiCal, which works using either activesupport or the tzinfo gem. I've set up rake tasks to run the specs with either one. What I do is to have an auxiliary ruby file to do the right require which the spec task invokes via the -r option. You should be able to do something similar by having the auxiliary files use the gem directive to specify a particular version of active_record. Have a look at http://github.com/rubyredrick/ri_cal/tree/master/tasks/ Particularly spec.rake and the files in the gem_loader sub directory. HTH -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From bcardarella at gmail.com Sun May 23 13:55:24 2010 From: bcardarella at gmail.com (Brian Cardarella) Date: Sun, 23 May 2010 10:55:24 -0700 (PDT) Subject: [rspec-users] How do I isolation test against different gem versions? In-Reply-To: References: <8a897c95-e8b5-41cb-9536-cbca473c36ea@k31g2000vbu.googlegroups.com> Message-ID: <3d7a14f0-9b8c-4fbc-be1e-3969869d6333@e21g2000vbl.googlegroups.com> Rick, Cool, this looks like it should work. My original approach was to find something that would work under autospec but I think that might be getting too greedy in this case. Thank-you! - Brian On May 23, 12:54?pm, Rick DeNatale wrote: > On Sun, May 23, 2010 at 11:41 AM, Brian Cardarella > > wrote: > > I would like to support both ActiveRecord 2.x and ActiveModel 3.x for > > a given library. It is not clear to me how to write tests for this. If > > I require 'active_record' then all of the dependencies are also loaded > > and are now in the load path as well as the Gem loaded list. > > Considering that AR and AM share dependencies but of different > > versions conflicts occur. > > > Is this possible? The difference in code is not enough to warrant > > breaking into separate gems. > > I do something similar for RiCal, which works using either > activesupport or the tzinfo gem. ?I've set up rake tasks to run the > specs with either one. > > What I do is to have an auxiliary ruby file to do the right require > which the spec task invokes via the -r option. > > You should be able to do something similar by having the auxiliary > files use the gem directive to specify a particular version of > active_record. > > Have a look athttp://github.com/rubyredrick/ri_cal/tree/master/tasks/ > > Particularly spec.rake and the files in the gem_loader sub directory. > > HTH > > -- > Rick DeNatale > > Blog:http://talklikeaduck.denhaven2.com/ > Github:http://github.com/rubyredrick > Twitter: @RickDeNatale > WWR:http://www.workingwithrails.com/person/9021-rick-denatale > LinkedIn:http://www.linkedin.com/in/rickdenatale > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > -- > You received this message because you are subscribed to the Google Groups "rspec" group. > To post to this group, send email to rspec at googlegroups.com. > To unsubscribe from this group, send email to rspec+unsubscribe at googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rspec?hl=en. From dchelimsky at gmail.com Sun May 23 15:18:39 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 23 May 2010 14:18:39 -0500 Subject: [rspec-users] How do I isolation test against different gem versions? In-Reply-To: <3d7a14f0-9b8c-4fbc-be1e-3969869d6333@e21g2000vbl.googlegroups.com> References: <8a897c95-e8b5-41cb-9536-cbca473c36ea@k31g2000vbu.googlegroups.com> <3d7a14f0-9b8c-4fbc-be1e-3969869d6333@e21g2000vbl.googlegroups.com> Message-ID: <4D83289C-F8D5-4B64-9FFD-312F8C23997F@gmail.com> On May 23, 2010, at 12:55 PM, Brian Cardarella wrote: > Rick, > > Cool, this looks like it should work. My original approach was to > find something that would work under autospec but I think that might > be getting too greedy in this case. You could hook that up if you want to. Just need clear out the rspec mappings and replace them with your own - then you could have a conditional based on a command line param. I've got a few blog posts on configuring autotest: http://blog.davidchelimsky.net/?s=autotest HTH, David > Thank-you! > > - Brian > > On May 23, 12:54 pm, Rick DeNatale wrote: >> On Sun, May 23, 2010 at 11:41 AM, Brian Cardarella >> >> wrote: >>> I would like to support both ActiveRecord 2.x and ActiveModel 3.x for >>> a given library. It is not clear to me how to write tests for this. If >>> I require 'active_record' then all of the dependencies are also loaded >>> and are now in the load path as well as the Gem loaded list. >>> Considering that AR and AM share dependencies but of different >>> versions conflicts occur. >> >>> Is this possible? The difference in code is not enough to warrant >>> breaking into separate gems. >> >> I do something similar for RiCal, which works using either >> activesupport or the tzinfo gem. I've set up rake tasks to run the >> specs with either one. >> >> What I do is to have an auxiliary ruby file to do the right require >> which the spec task invokes via the -r option. >> >> You should be able to do something similar by having the auxiliary >> files use the gem directive to specify a particular version of >> active_record. >> >> Have a look athttp://github.com/rubyredrick/ri_cal/tree/master/tasks/ >> >> Particularly spec.rake and the files in the gem_loader sub directory. >> >> HTH >> >> -- >> Rick DeNatale >> >> Blog:http://talklikeaduck.denhaven2.com/ >> Github:http://github.com/rubyredrick >> Twitter: @RickDeNatale >> WWR:http://www.workingwithrails.com/person/9021-rick-denatale >> LinkedIn:http://www.linkedin.com/in/rickdenatale >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users >> >> -- >> You received this message because you are subscribed to the Google Groups "rspec" group. >> To post to this group, send email to rspec at googlegroups.com. >> To unsubscribe from this group, send email to rspec+unsubscribe at googlegroups.com. >> For more options, visit this group athttp://groups.google.com/group/rspec?hl=en. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From node.js99 at gmail.com Sun May 23 16:50:58 2010 From: node.js99 at gmail.com (Nadal) Date: Sun, 23 May 2010 13:50:58 -0700 (PDT) Subject: [rspec-users] Not able to run tests for rspec itself In-Reply-To: <3616B6E8-60AC-4CF4-A9E7-0140EE89A7F3@gmail.com> References: <3616B6E8-60AC-4CF4-A9E7-0140EE89A7F3@gmail.com> Message-ID: Did everything that was instructed. Still the same error. No such file or directory - /Users/nadal/.rubyforge/user-config.yml On May 23, 11:35?am, David Chelimsky wrote: > On May 22, 2010, at 5:41 PM, Nadal wrote: > > > > > > > I am talking about rspec itself and running tests written for rspec. > > This is what I did. > > >> git clonehttp://github.com/dchelimsky/rspec.git > >> cd rspec > >> rake test > > > I am getting following error > > > rake aborted! > > No such file or directory - /Users/nadal/.rubyforge/user-config.yml > > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe/rubyforge.rb:44:in > > `read' > > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe/rubyforge.rb:44:in > > `define_rubyforge_tasks' > > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:507:in `send' > > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:507:in > > `load_plugin_tasks' > > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:501:in `each' > > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:501:in > > `load_plugin_tasks' > > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:572:in > > `post_initialize' > > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:293:in `spec' > > /Users/nadal/dev/working/rspec/Rakefile:11 > > This works for me, using a clean gemset with rvm: > > $ gem install rake geminstaller > $ git clone git://github.com/dchelimsky/rspec > $ cd rspec > $ geminstaller geminstaller.yml > $ rake spec > > Give that a whirl and let us know how it works out. > > Cheers, > David > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > -- > You received this message because you are subscribed to the Google Groups "rspec" group. > To post to this group, send email to rspec at googlegroups.com. > To unsubscribe from this group, send email to rspec+unsubscribe at googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rspec?hl=en. From dchelimsky at gmail.com Sun May 23 19:04:20 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 23 May 2010 18:04:20 -0500 Subject: [rspec-users] Not able to run tests for rspec itself In-Reply-To: References: <3616B6E8-60AC-4CF4-A9E7-0140EE89A7F3@gmail.com> Message-ID: On Sun, May 23, 2010 at 3:50 PM, Nadal wrote: > Did everything that was instructed. > > Still the same error. > > No such file or directory - /Users/nadal/.rubyforge/user-config.yml Try adding that file and see what happens :) > > > > On May 23, 11:35?am, David Chelimsky wrote: >> On May 22, 2010, at 5:41 PM, Nadal wrote: >> >> >> >> >> >> > I am talking about rspec itself and running tests written for rspec. >> > This is what I did. >> >> >> git clonehttp://github.com/dchelimsky/rspec.git >> >> cd rspec >> >> rake test >> >> > I am getting following error >> >> > rake aborted! >> > No such file or directory - /Users/nadal/.rubyforge/user-config.yml >> > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe/rubyforge.rb:44:in >> > `read' >> > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe/rubyforge.rb:44:in >> > `define_rubyforge_tasks' >> > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:507:in `send' >> > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:507:in >> > `load_plugin_tasks' >> > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:501:in `each' >> > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:501:in >> > `load_plugin_tasks' >> > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:572:in >> > `post_initialize' >> > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:293:in `spec' >> > /Users/nadal/dev/working/rspec/Rakefile:11 >> >> This works for me, using a clean gemset with rvm: >> >> $ gem install rake geminstaller >> $ git clone git://github.com/dchelimsky/rspec >> $ cd rspec >> $ geminstaller geminstaller.yml >> $ rake spec >> >> Give that a whirl and let us know how it works out. >> >> Cheers, >> David >> >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users >> >> -- >> You received this message because you are subscribed to the Google Groups "rspec" group. >> To post to this group, send email to rspec at googlegroups.com. >> To unsubscribe from this group, send email to rspec+unsubscribe at googlegroups.com. >> For more options, visit this group athttp://groups.google.com/group/rspec?hl=en. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From apremdas at gmail.com Mon May 24 05:33:39 2010 From: apremdas at gmail.com (Andrew Premdas) Date: Mon, 24 May 2010 10:33:39 +0100 Subject: [rspec-users] old crumbly rspec Message-ID: Hi List, Being pretty lazy here, but I figure you can help very quickly and others might benefit from the results. I write old crumbly rspec (see gist http://gist.github.com/411689), and I would like to improve, can you take my crumbly spec and make it shiny? Also if you can post any links to recent relevant blog articles that would be much appreciated Best one I can find at the moment is: http://eggsonbread.com/2010/03/28/my-rspec-best-practices-and-tips/ TIA Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: From node.js99 at gmail.com Mon May 24 06:56:42 2010 From: node.js99 at gmail.com (Nadal) Date: Mon, 24 May 2010 03:56:42 -0700 (PDT) Subject: [rspec-users] Not able to run tests for rspec itself In-Reply-To: References: <3616B6E8-60AC-4CF4-A9E7-0140EE89A7F3@gmail.com> Message-ID: <44d5d20d-78af-4dd5-a150-f1b8f0d08e03@c7g2000vbc.googlegroups.com> Creating an empty ~/.rubyforge/user-config.yml did it. >$ rake spec warning: couldn't activate the rubyforge plugin, skipping Profiling enabled. ..................... Thanks a bunch. On May 23, 7:04?pm, David Chelimsky wrote: > On Sun, May 23, 2010 at 3:50 PM, Nadal wrote: > > Did everything that was instructed. > > > Still the same error. > > > No such file or directory - /Users/nadal/.rubyforge/user-config.yml > > Try adding that file and see what happens :) > > > > > > > > > On May 23, 11:35?am, David Chelimsky wrote: > >> On May 22, 2010, at 5:41 PM, Nadal wrote: > > >> > I am talking about rspec itself and running tests written for rspec. > >> > This is what I did. > > >> >> git clonehttp://github.com/dchelimsky/rspec.git > >> >> cd rspec > >> >> rake test > > >> > I am getting following error > > >> > rake aborted! > >> > No such file or directory - /Users/nadal/.rubyforge/user-config.yml > >> > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe/rubyforge.rb:44:in > >> > `read' > >> > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe/rubyforge.rb:44:in > >> > `define_rubyforge_tasks' > >> > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:507:in `send' > >> > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:507:in > >> > `load_plugin_tasks' > >> > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:501:in `each' > >> > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:501:in > >> > `load_plugin_tasks' > >> > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:572:in > >> > `post_initialize' > >> > /usr/local/lib/ruby/gems/1.8/gems/hoe-2.6.0/lib/hoe.rb:293:in `spec' > >> > /Users/nadal/dev/working/rspec/Rakefile:11 > > >> This works for me, using a clean gemset with rvm: > > >> $ gem install rake geminstaller > >> $ git clone git://github.com/dchelimsky/rspec > >> $ cd rspec > >> $ geminstaller geminstaller.yml > >> $ rake spec > > >> Give that a whirl and let us know how it works out. > > >> Cheers, > >> David > > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > >> -- > >> You received this message because you are subscribed to the Google Groups "rspec" group. > >> To post to this group, send email to rspec at googlegroups.com. > >> To unsubscribe from this group, send email to rspec+unsubscribe at googlegroups.com. > >> For more options, visit this group athttp://groups.google.com/group/rspec?hl=en. > > _______________________________________________ > > 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 > > -- > You received this message because you are subscribed to the Google Groups "rspec" group. > To post to this group, send email to rspec at googlegroups.com. > To unsubscribe from this group, send email to rspec+unsubscribe at googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rspec?hl=en. From hooligan495 at gmail.com Tue May 25 13:33:49 2010 From: hooligan495 at gmail.com (Jay McGaffigan) Date: Tue, 25 May 2010 13:33:49 -0400 Subject: [rspec-users] Rspec Sinatra and Activerecord Message-ID: Hi, I have a sinatra app that I've integrated with Activerecord that I am trying to write some specs for. I have a simple spec where I am essentially getting "all" rows from my model table. However I'd like to stub out the call. so.. in my spec's before block I try to do something like: ActiveRecord::Base.should_receive(:establish_connection) in my spec I do : it "should retreive all ids" do IdMap.should_receive(:find_all_by_site_id).with("abc-123").and_return("") get "map/site1" end and my spec keeps failing on IdMap.should_receive.... It complains that it cannot connect to the database. If I swap in mocha and do IdMap.expect.... it works. I'd prefer to stick with Rspec's mocking and stubbing library in this case tho... I was wondering if anyone could shed some light on whether or not I am doing somethign wrong? Thanks! Jay From lists at ruby-forum.com Tue May 25 13:50:23 2010 From: lists at ruby-forum.com (Pito Salas) Date: Tue, 25 May 2010 19:50:23 +0200 Subject: [rspec-users] [CUCUMBER] Noob question Message-ID: <2d62c4f3f4f4264bc9e67f8e5b320978@ruby-forum.com> Meta question: is this the right/best place to ask for assistance with Cucumber or am I in the wrong place? Anyway, here goes. I just started using cucumber and it's very impressive! Check out this fragment: And I go to the home page Then I should see "Choose Your Jurisdiction:" within "h2" And I follow "Middlesex" Then I should see "Middlesex" within "#user-navigation" My problem is that it's failing on the 4th step. And it looks like the "click" on the link "middlesex" didn't have the expected effect. In other words, when used interactively I see what I expect to see in user-navigation. So my question is about debugging this problem. What I need to know is: - is the "And I follow "Middlesex" step actually clicking on what I think it is? - is that click working or doing what it should do? - what page is being examined by the "Then I should see "Middlesex" within "#user-navigation" step? These are all debugging questions, right, if I could see those I could figure out what was going wrong. Any tips would be greatly appreciated! -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Tue May 25 13:59:21 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 25 May 2010 12:59:21 -0500 Subject: [rspec-users] [CUCUMBER] Noob question In-Reply-To: <2d62c4f3f4f4264bc9e67f8e5b320978@ruby-forum.com> References: <2d62c4f3f4f4264bc9e67f8e5b320978@ruby-forum.com> Message-ID: <9CFA87DF-9EE7-4A53-9586-5FE45EE28665@gmail.com> Cucumber has it's own list: http://groups.google.com/group/cukes Feel free to ask us your rspec questions here, though :) Cheers, David On May 25, 2010, at 12:50 PM, Pito Salas wrote: > Meta question: is this the right/best place to ask for assistance with > Cucumber or am I in the wrong place? > > Anyway, here goes. I just started using cucumber and it's very > impressive! > > Check out this fragment: > > And I go to the home page > Then I should see "Choose Your Jurisdiction:" within "h2" > And I follow "Middlesex" > Then I should see "Middlesex" within "#user-navigation" > > My problem is that it's failing on the 4th step. > > And it looks like the "click" on the link "middlesex" didn't have the > expected effect. In other words, when used interactively I see what I > expect to see in user-navigation. > > So my question is about debugging this problem. What I need to know is: > > - is the "And I follow "Middlesex" step actually clicking on what I > think it is? > - is that click working or doing what it should do? > - what page is being examined by the "Then I should see "Middlesex" > within "#user-navigation" step? > > These are all debugging questions, right, if I could see those I could > figure out what was going wrong. > > Any tips would be greatly appreciated! > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Tue May 25 19:18:15 2010 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 26 May 2010 00:18:15 +0100 Subject: [rspec-users] old crumbly rspec In-Reply-To: References: Message-ID: Cursory look at that blog post seems like it's covered most of what's in this talk, but worth mentioning anyway, it's good: http://pure-rspec-rubynation.heroku.com/ http://video2010.scottishrubyconference.com/show_video/3/1 On 24 May 2010, at 10:33, Andrew Premdas wrote: > Hi List, > > Being pretty lazy here, but I figure you can help very quickly and others might benefit from the results. I write old crumbly rspec (see gist http://gist.github.com/411689), and I would like to improve, can you take my crumbly spec and make it shiny? > > Also if you can post any links to recent relevant blog articles that would be much appreciated > > Best one I can find at the moment is: > > http://eggsonbread.com/2010/03/28/my-rspec-best-practices-and-tips/ > > TIA > > Andrew > > _______________________________________________ > 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 apremdas at gmail.com Wed May 26 05:15:55 2010 From: apremdas at gmail.com (Andrew Premdas) Date: Wed, 26 May 2010 10:15:55 +0100 Subject: [rspec-users] [CUCUMBER] Noob question In-Reply-To: <2d62c4f3f4f4264bc9e67f8e5b320978@ruby-forum.com> References: <2d62c4f3f4f4264bc9e67f8e5b320978@ruby-forum.com> Message-ID: On 25 May 2010 18:50, Pito Salas wrote: > Meta question: is this the right/best place to ask for assistance with > Cucumber or am I in the wrong place? > > Anyway, here goes. I just started using cucumber and it's very > impressive! > > Check out this fragment: > > And I go to the home page > Then I should see "Choose Your Jurisdiction:" within "h2" > And I follow "Middlesex" > Then I should see "Middlesex" within "#user-navigation" > > My problem is that it's failing on the 4th step. > > And it looks like the "click" on the link "middlesex" didn't have the > expected effect. In other words, when used interactively I see what I > expect to see in user-navigation. > > So my question is about debugging this problem. What I need to know is: > > - is the "And I follow "Middlesex" step actually clicking on what I > think it is? > - is that click working or doing what it should do? > - what page is being examined by the "Then I should see "Middlesex" > within "#user-navigation" step? > > These are all debugging questions, right, if I could see those I could > figure out what was going wrong. > > Any tips would be greatly appreciated! > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > With rspec you can put 'debugger' in your steps and then run the spec from the command prompt. Make sure you have the ruby-debug gem installed. In cucumber you can put a 'debugger' statement in any step definition. Hopefully this will be enough to get you started All best Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed May 26 09:23:51 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 26 May 2010 08:23:51 -0500 Subject: [rspec-users] should RSpec add '.' to $LOAD_PATH for ruby-1.9.2? Message-ID: <77CF6592-1C23-4963-90BF-89999367BE44@gmail.com> Ruby-1.9.2 removes '.' from the $LOAD_PATH. There have been a couple of issues reported against rspec-core-2 asking RSpec to add '.' to $LOAD_PATH for 1.9.2. My instinct is that this is the wrong way to go; that Ruby is telling us to get used to typing "./" when we run command line tools. What do _you_ think? ================= http://github.com/rspec/rspec-core/issues/issue/28 http://github.com/rspec/rspec-core/issues/issue/29 From johnf.pub at distb.net Wed May 26 10:00:13 2010 From: johnf.pub at distb.net (John Feminella) Date: Wed, 26 May 2010 10:00:13 -0400 Subject: [rspec-users] should RSpec add '.' to $LOAD_PATH for ruby-1.9.2? In-Reply-To: <77CF6592-1C23-4963-90BF-89999367BE44@gmail.com> References: <77CF6592-1C23-4963-90BF-89999367BE44@gmail.com> Message-ID: I've updated my tests for 1.9.2, and although initially I thought it was obnoxious, it's a very sensible change. If `.` is in `$:`, then your `require` line needs to change depending on where you run rspec (or any other command invoking your Ruby scripts) from. What's much more sensible is to replace all usages of `require '...'` that depend on `.` with a `require_relative` directive instead. ~ jf -- John Feminella Principal Consultant, Distilled Brilliance On Wed, May 26, 2010 at 09:23, David Chelimsky wrote: > Ruby-1.9.2 removes '.' from the $LOAD_PATH. There have been a couple of issues reported against rspec-core-2 asking RSpec to add '.' to $LOAD_PATH for 1.9.2. My instinct is that this is the wrong way to go; that Ruby is telling us to get used to typing "./" when we run command line tools. What do _you_ think? > > ================= > http://github.com/rspec/rspec-core/issues/issue/28 > http://github.com/rspec/rspec-core/issues/issue/29 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed May 26 10:18:57 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 26 May 2010 09:18:57 -0500 Subject: [rspec-users] should RSpec add '.' to $LOAD_PATH for ruby-1.9.2? In-Reply-To: <77CF6592-1C23-4963-90BF-89999367BE44@gmail.com> References: <77CF6592-1C23-4963-90BF-89999367BE44@gmail.com> Message-ID: <82F769F4-F5DC-4835-9C5B-AE64BD1C5F76@gmail.com> On May 26, 2010, at 8:23 AM, David Chelimsky wrote: > Ruby-1.9.2 removes '.' from the $LOAD_PATH. There have been a couple of issues reported against rspec-core-2 asking RSpec to add '.' to $LOAD_PATH for 1.9.2. My instinct is that this is the wrong way to go; that Ruby is telling us to get used to typing "./" when we run command line tools. What do _you_ think? > > ================= > http://github.com/rspec/rspec-core/issues/issue/28 > http://github.com/rspec/rspec-core/issues/issue/29 Upon further review (d'oh), it turns out there is a solution for this already built into rspec-2. Just add a .rspec file in the project root (or home directory for global settings) and add a line that reads "-I.". I'll make sure this is documented in the README. Cheers, David From node.js99 at gmail.com Wed May 26 14:07:54 2010 From: node.js99 at gmail.com (Nadal) Date: Wed, 26 May 2010 11:07:54 -0700 (PDT) Subject: [rspec-users] Why pending only works inside it Message-ID: <4df6dbb6-7c2c-409b-bfda-0173f87818fa@c13g2000vbr.googlegroups.com> I wrote following code and it did not work. describe User do it { should validate_presence_of(:email) } pending "should raise an error when email is blank and record is saved with false option" end Then I put pending inside it like one given below and it worked. describe User do it { should validate_presence_of(:email) } it "" do pending "should raise an error when email is blank and record is saved with false option" end end I know that rspec is well thought out . Then why rspec is forcing me to put empty it around pending line. Why can't I just say that something is pending and I will get to it later. Thanks for all the good work. From johnf.pub at distb.net Wed May 26 14:20:31 2010 From: johnf.pub at distb.net (John Feminella) Date: Wed, 26 May 2010 14:20:31 -0400 Subject: [rspec-users] Why pending only works inside it In-Reply-To: <4df6dbb6-7c2c-409b-bfda-0173f87818fa@c13g2000vbr.googlegroups.com> References: <4df6dbb6-7c2c-409b-bfda-0173f87818fa@c13g2000vbr.googlegroups.com> Message-ID: You can use an empty block instead: ===begin Ruby describe Apple do it "should be delicious" do # real test end it "should be crunchy" # still pending end ===end Ruby Then you'll get: ===begin shell Apple - should be delicious - should be crunchy (PENDING: Not Yet Implemented) ===end shell Hope that helps. -- John Feminella Principal Consultant, Distilled Brilliance On Wed, May 26, 2010 at 14:07, Nadal wrote: > I wrote following code and it did not work. > > > describe User do > ?it { should validate_presence_of(:email) } > ?pending "should raise an error when email is blank and record is > saved with false option" > end > > > Then I put pending inside it like one given below and it worked. > > > describe User do > ?it { should validate_presence_of(:email) } > ?it "" do > ?pending "should raise an error when email is blank and record is > saved with false option" > ?end > end > > > > I know that rspec is well thought out . Then why rspec is forcing me > to put empty it around pending line. Why can't I just say that > something is pending and I will get to it later. > > Thanks for all the good work. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From scott at railsnewbie.com Wed May 26 14:20:05 2010 From: scott at railsnewbie.com (Scott Taylor) Date: Wed, 26 May 2010 14:20:05 -0400 Subject: [rspec-users] Why pending only works inside it In-Reply-To: <4df6dbb6-7c2c-409b-bfda-0173f87818fa@c13g2000vbr.googlegroups.com> References: <4df6dbb6-7c2c-409b-bfda-0173f87818fa@c13g2000vbr.googlegroups.com> Message-ID: <8A8AA028-6028-499F-9C93-EA59A5A5569A@railsnewbie.com> On May 26, 2010, at 2:07 PM, Nadal wrote: > I wrote following code and it did not work. > > > describe User do > it { should validate_presence_of(:email) } > pending "should raise an error when email is blank and record is > saved with false option" > end > > > Then I put pending inside it like one given below and it worked. > > > describe User do > it { should validate_presence_of(:email) } > it "" do > pending "should raise an error when email is blank and record is > saved with false option" > end > end > Use an it with no block: it "should raise an error when email is blank and record is saved with false option" Scott > > > I know that rspec is well thought out . Then why rspec is forcing me > to put empty it around pending line. Why can't I just say that > something is pending and I will get to it later. > > Thanks for all the good work. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From node.js99 at gmail.com Wed May 26 16:04:44 2010 From: node.js99 at gmail.com (Nadal) Date: Wed, 26 May 2010 13:04:44 -0700 (PDT) Subject: [rspec-users] Why pending only works inside it In-Reply-To: <8A8AA028-6028-499F-9C93-EA59A5A5569A@railsnewbie.com> References: <4df6dbb6-7c2c-409b-bfda-0173f87818fa@c13g2000vbr.googlegroups.com> <8A8AA028-6028-499F-9C93-EA59A5A5569A@railsnewbie.com> Message-ID: <5aa9ff6d-19ab-4fd9-a9a7-9b03af53de1d@m33g2000vbi.googlegroups.com> Thanks. That got me moving. I like how in rspec I can say context when I mean context and describe when I mean describe. Going by that principal here I should have been allowed to say pending when I mean pending and I should not be forced to use it which would come in report as pending. It is nitpicking but paying attention to such detail has made rspec so great. Just a fresh perspective since I am trying out rspec for the first time. On May 26, 2:20?pm, Scott Taylor wrote: > On May 26, 2010, at 2:07 PM, Nadal wrote: > > > > > > > I wrote following code and it did not work. > > > describe User do > > it { should validate_presence_of(:email) } > > pending "should raise an error when email is blank and record is > > saved with false option" > > end > > > Then I put pending inside it like one given below and it worked. > > > describe User do > > it { should validate_presence_of(:email) } > > it "" do > > ?pending "should raise an error when email is blank and record is > > saved with false option" > > end > > end > > Use an it with no block: > > it "should raise an error when email is blank and record is saved with false option" > > Scott > > > > > I know that rspec is well thought out . Then why rspec is forcing me > > to put empty it around pending line. Why can't I just say that > > something is pending and I will get to it later. > > > Thanks for all the good work. > > _______________________________________________ > > 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 walketim at gmail.com Wed May 26 16:23:09 2010 From: walketim at gmail.com (Tim Walker) Date: Wed, 26 May 2010 14:23:09 -0600 Subject: [rspec-users] old crumbly rspec In-Reply-To: References: Message-ID: What is the functional difference between "it" and "specify" Thanks! Tim On Tue, May 25, 2010 at 5:18 PM, Matt Wynne wrote: > Cursory look at that blog post seems like it's covered most of what's in > this talk, but worth mentioning anyway, it's good: > http://pure-rspec-rubynation.heroku.com/ > http://video2010.scottishrubyconference.com/show_video/3/1 > On 24 May 2010, at 10:33, Andrew Premdas wrote: > > Hi List, > Being pretty lazy here, but I figure you can help very quickly and others > might benefit from the results. I write old crumbly rspec (see > gist?http://gist.github.com/411689), and I would like to improve, can you > take my crumbly spec and make it shiny? > Also if you can post any links to recent relevant blog articles that would > be much appreciated > Best one I can find at the moment is: > http://eggsonbread.com/2010/03/28/my-rspec-best-practices-and-tips/ > TIA > Andrew > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed May 26 16:28:39 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 26 May 2010 15:28:39 -0500 Subject: [rspec-users] Why pending only works inside it In-Reply-To: <5aa9ff6d-19ab-4fd9-a9a7-9b03af53de1d@m33g2000vbi.googlegroups.com> References: <4df6dbb6-7c2c-409b-bfda-0173f87818fa@c13g2000vbr.googlegroups.com> <8A8AA028-6028-499F-9C93-EA59A5A5569A@railsnewbie.com> <5aa9ff6d-19ab-4fd9-a9a7-9b03af53de1d@m33g2000vbi.googlegroups.com> Message-ID: <895B74A1-80C7-428D-9F62-831404D62F61@gmail.com> On May 26, 2010, at 3:04 PM, Nadal wrote: > Thanks. That got me moving. > > I like how in rspec I can say context when I mean context and describe > when I mean describe. Going by that principal here I should have been > allowed to say pending when I mean pending and I should not be forced > to use it which would come in report as pending. > > It is nitpicking but paying attention to such detail has made rspec so > great. Just a fresh perspective since I am trying out rspec for the > first time. In rspec-2 you _can_ say pending like this: describe 'something' do context 'in some context' do pending 'it does something or other' > > On May 26, 2:20 pm, Scott Taylor wrote: >> On May 26, 2010, at 2:07 PM, Nadal wrote: >> >> >> >> >> >>> I wrote following code and it did not work. >> >>> describe User do >>> it { should validate_presence_of(:email) } >>> pending "should raise an error when email is blank and record is >>> saved with false option" >>> end >> >>> Then I put pending inside it like one given below and it worked. >> >>> describe User do >>> it { should validate_presence_of(:email) } >>> it "" do >>> pending "should raise an error when email is blank and record is >>> saved with false option" >>> end >>> end >> >> Use an it with no block: >> >> it "should raise an error when email is blank and record is saved with false option" >> >> Scott >> >> >> >>> I know that rspec is well thought out . Then why rspec is forcing me >>> to put empty it around pending line. Why can't I just say that >>> something is pending and I will get to it later. >> >>> Thanks for all the good work. >>> _______________________________________________ >>> 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 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Wed May 26 16:29:02 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 26 May 2010 15:29:02 -0500 Subject: [rspec-users] old crumbly rspec In-Reply-To: References: Message-ID: <3A8C5E8B-A438-4CB5-9AA2-93EC149474EC@gmail.com> On May 26, 2010, at 3:23 PM, Tim Walker wrote: > What is the functional difference between "it" and "specify" None. > > Thanks! > > Tim > > On Tue, May 25, 2010 at 5:18 PM, Matt Wynne wrote: >> Cursory look at that blog post seems like it's covered most of what's in >> this talk, but worth mentioning anyway, it's good: >> http://pure-rspec-rubynation.heroku.com/ >> http://video2010.scottishrubyconference.com/show_video/3/1 >> On 24 May 2010, at 10:33, Andrew Premdas wrote: >> >> Hi List, >> Being pretty lazy here, but I figure you can help very quickly and others >> might benefit from the results. I write old crumbly rspec (see >> gist http://gist.github.com/411689), and I would like to improve, can you >> take my crumbly spec and make it shiny? >> Also if you can post any links to recent relevant blog articles that would >> be much appreciated >> Best one I can find at the moment is: >> http://eggsonbread.com/2010/03/28/my-rspec-best-practices-and-tips/ >> TIA >> Andrew >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.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 node.js99 at gmail.com Wed May 26 16:32:50 2010 From: node.js99 at gmail.com (Nadal) Date: Wed, 26 May 2010 13:32:50 -0700 (PDT) Subject: [rspec-users] Why pending only works inside it In-Reply-To: <895B74A1-80C7-428D-9F62-831404D62F61@gmail.com> References: <4df6dbb6-7c2c-409b-bfda-0173f87818fa@c13g2000vbr.googlegroups.com> <8A8AA028-6028-499F-9C93-EA59A5A5569A@railsnewbie.com> <5aa9ff6d-19ab-4fd9-a9a7-9b03af53de1d@m33g2000vbi.googlegroups.com> <895B74A1-80C7-428D-9F62-831404D62F61@gmail.com> Message-ID: awesome. That's much better. On May 26, 4:28?pm, David Chelimsky wrote: > On May 26, 2010, at 3:04 PM, Nadal wrote: > > > Thanks. That got me moving. > > > I like how in rspec I can say context when I mean context and describe > > when I mean describe. Going by that principal here I should have been > > allowed to say pending when I mean pending and I should not be forced > > to use it which would come in report as pending. > > > It is nitpicking but paying attention to such detail has made rspec so > > great. Just a fresh perspective since I am trying out rspec for the > > first time. > > In rspec-2 you _can_ say pending like this: > > describe 'something' do > ? context 'in some context' do > ? ? pending 'it does something or other' > > > > > > > > > On May 26, 2:20 pm, Scott Taylor wrote: > >> On May 26, 2010, at 2:07 PM, Nadal wrote: > > >>> I wrote following code and it did not work. > > >>> describe User do > >>> it { should validate_presence_of(:email) } > >>> pending "should raise an error when email is blank and record is > >>> saved with false option" > >>> end > > >>> Then I put pending inside it like one given below and it worked. > > >>> describe User do > >>> it { should validate_presence_of(:email) } > >>> it "" do > >>> ?pending "should raise an error when email is blank and record is > >>> saved with false option" > >>> end > >>> end > > >> Use an it with no block: > > >> it "should raise an error when email is blank and record is saved with false option" > > >> Scott > > >>> I know that rspec is well thought out . Then why rspec is forcing me > >>> to put empty it around pending line. Why can't I just say that > >>> something is pending and I will get to it later. > > >>> Thanks for all the good work. > >>> _______________________________________________ > >>> 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 > > _______________________________________________ > > 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 node.js99 at gmail.com Wed May 26 17:05:32 2010 From: node.js99 at gmail.com (Nadal) Date: Wed, 26 May 2010 14:05:32 -0700 (PDT) Subject: [rspec-users] old crumbly rspec In-Reply-To: <3A8C5E8B-A438-4CB5-9AA2-93EC149474EC@gmail.com> References: <3A8C5E8B-A438-4CB5-9AA2-93EC149474EC@gmail.com> Message-ID: <298491e6-dc26-4681-a577-bd65592fddfd@v37g2000vbv.googlegroups.com> As David said, there is no difference between "it" and "specify". One of them is alias of other one. However semantically you can use them differently. The two examples given below are same. However second one reads better. I like to use specify when I have explicitly created a subject. Implicit subjects read better with it. describe User do context "create a user" do subject { User.create(:email => 'second at example.com') } it { subject.id.should_not be_nil} end end describe User do context "create a user" do subject { User.create(:email => 'second at example.com') } specify { subject.id.should_not be_nil} end end On May 26, 4:29?pm, David Chelimsky wrote: > On May 26, 2010, at 3:23 PM, Tim Walker wrote: > > > What is the functional difference between "it" and "specify" > > None. > > > > > > > > > Thanks! > > > Tim > > > On Tue, May 25, 2010 at 5:18 PM, Matt Wynne wrote: > >> Cursory look at that blog post seems like it's covered most of what's in > >> this talk, but worth mentioning anyway, it's good: > >>http://pure-rspec-rubynation.heroku.com/ > >>http://video2010.scottishrubyconference.com/show_video/3/1 > >> On 24 May 2010, at 10:33, Andrew Premdas wrote: > > >> Hi List, > >> Being pretty lazy here, but I figure you can help very quickly and others > >> might benefit from the results. I write old crumbly rspec (see > >> gisthttp://gist.github.com/411689), and I would like to improve, can you > >> take my crumbly spec and make it shiny? > >> Also if you can post any links to recent relevant blog articles that would > >> be much appreciated > >> Best one I can find at the moment is: > >>http://eggsonbread.com/2010/03/28/my-rspec-best-practices-and-tips/ > >> TIA > >> Andrew > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-us... at rubyforge.org > >>http://rubyforge.org/mailman/listinfo/rspec-users > > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-us... at rubyforge.org > >>http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Wed May 26 17:46:13 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 26 May 2010 16:46:13 -0500 Subject: [rspec-users] old crumbly rspec In-Reply-To: <298491e6-dc26-4681-a577-bd65592fddfd@v37g2000vbv.googlegroups.com> References: <3A8C5E8B-A438-4CB5-9AA2-93EC149474EC@gmail.com> <298491e6-dc26-4681-a577-bd65592fddfd@v37g2000vbv.googlegroups.com> Message-ID: <6915E8E4-09F8-4B53-B750-788B2F79D2F4@gmail.com> On May 26, 2010, at 4:05 PM, Nadal wrote: > As David said, there is no difference between "it" and "specify". One > of them is alias of other one. However semantically you can use them > differently. > > The two examples given below are same. However second one reads > better. I like to use specify when I have explicitly created a > subject. Implicit subjects read better with it. > > describe User do > context "create a user" do > subject { User.create(:email => 'second at example.com') } > it { subject.id.should_not be_nil} > end > end > > describe User do > context "create a user" do > subject { User.create(:email => 'second at example.com') } > specify { subject.id.should_not be_nil} > end > end > In this case you can also use "its": describe User do context "create a user" do subject { User.create(:email => 'second at example.com') } its(:id) { should_not be_nil} end end That doesn't always work out well, depending on how deep you need to dig into the subject, but it can work well in some cases. Cheers, David > On May 26, 4:29 pm, David Chelimsky wrote: >> On May 26, 2010, at 3:23 PM, Tim Walker wrote: >> >>> What is the functional difference between "it" and "specify" >> >> None. >> >> >> >> >> >> >> >>> Thanks! >> >>> Tim >> >>> On Tue, May 25, 2010 at 5:18 PM, Matt Wynne wrote: >>>> Cursory look at that blog post seems like it's covered most of what's in >>>> this talk, but worth mentioning anyway, it's good: >>>> http://pure-rspec-rubynation.heroku.com/ >>>> http://video2010.scottishrubyconference.com/show_video/3/1 >>>> On 24 May 2010, at 10:33, Andrew Premdas wrote: >> >>>> Hi List, >>>> Being pretty lazy here, but I figure you can help very quickly and others >>>> might benefit from the results. I write old crumbly rspec (see >>>> gisthttp://gist.github.com/411689), and I would like to improve, can you >>>> take my crumbly spec and make it shiny? >>>> Also if you can post any links to recent relevant blog articles that would >>>> be much appreciated >>>> Best one I can find at the moment is: >>>> http://eggsonbread.com/2010/03/28/my-rspec-best-practices-and-tips/ >>>> TIA >>>> Andrew >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-us... at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-us... at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-us... at rubyforge.org >>> http://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 node.js99 at gmail.com Wed May 26 21:11:13 2010 From: node.js99 at gmail.com (Nadal) Date: Wed, 26 May 2010 18:11:13 -0700 (PDT) Subject: [rspec-users] old crumbly rspec In-Reply-To: <6915E8E4-09F8-4B53-B750-788B2F79D2F4@gmail.com> References: <3A8C5E8B-A438-4CB5-9AA2-93EC149474EC@gmail.com> <298491e6-dc26-4681-a577-bd65592fddfd@v37g2000vbv.googlegroups.com> <6915E8E4-09F8-4B53-B750-788B2F79D2F4@gmail.com> Message-ID: <7a145be5-2769-4732-9769-f137dc597ee6@y12g2000vbg.googlegroups.com> I knew its existed but did not know any use case. Thanks for an excellent example. As you said in some cases its might make sentence more readable. good stuff. On May 26, 5:46?pm, David Chelimsky wrote: > On May 26, 2010, at 4:05 PM, Nadal wrote: > > > > > > > As David said, there is no difference between "it" and "specify". One > > of them is alias of other one. However semantically you can use them > > differently. > > > The two examples given below are same. However second one reads > > better. I like to use specify when I have explicitly created a > > subject. Implicit subjects read better with it. > > > describe User do > > ?context "create a user" do > > ? ?subject { User.create(:email => 'sec... at example.com') } > > ? ?it { subject.id.should_not be_nil} > > ?end > > end > > > describe User do > > ?context "create a user" do > > ? ?subject { User.create(:email => 'sec... at example.com') } > > ? ?specify { subject.id.should_not be_nil} > > ?end > > end > > In this case you can also use "its": > > describe User do > ? context "create a user" do > ? ? subject { User.create(:email => 'sec... at example.com') } > ? ? its(:id) { should_not be_nil} > ? end > end > > That doesn't always work out well, depending on how deep you need to dig into the subject, but it can work well in some cases. > > Cheers, > David > > > > > > > On May 26, 4:29 pm, David Chelimsky wrote: > >> On May 26, 2010, at 3:23 PM, Tim Walker wrote: > > >>> What is the functional difference between "it" and "specify" > > >> None. > > >>> Thanks! > > >>> Tim > > >>> On Tue, May 25, 2010 at 5:18 PM, Matt Wynne wrote: > >>>> Cursory look at that blog post seems like it's covered most of what's in > >>>> this talk, but worth mentioning anyway, it's good: > >>>>http://pure-rspec-rubynation.heroku.com/ > >>>>http://video2010.scottishrubyconference.com/show_video/3/1 > >>>> On 24 May 2010, at 10:33, Andrew Premdas wrote: > > >>>> Hi List, > >>>> Being pretty lazy here, but I figure you can help very quickly and others > >>>> might benefit from the results. I write old crumbly rspec (see > >>>> gisthttp://gist.github.com/411689), and I would like to improve, can you > >>>> take my crumbly spec and make it shiny? > >>>> Also if you can post any links to recent relevant blog articles that would > >>>> be much appreciated > >>>> Best one I can find at the moment is: > >>>>http://eggsonbread.com/2010/03/28/my-rspec-best-practices-and-tips/ > >>>> TIA > >>>> Andrew > >>>> _______________________________________________ > >>>> rspec-users mailing list > >>>> rspec-us... at rubyforge.org > >>>>http://rubyforge.org/mailman/listinfo/rspec-users > > >>>> _______________________________________________ > >>>> rspec-users mailing list > >>>> rspec-us... at rubyforge.org > >>>>http://rubyforge.org/mailman/listinfo/rspec-users > > >>> _______________________________________________ > >>> rspec-users mailing list > >>> rspec-us... at rubyforge.org > >>>http://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-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 node.js99 at gmail.com Wed May 26 22:37:36 2010 From: node.js99 at gmail.com (Nadal) Date: Wed, 26 May 2010 19:37:36 -0700 (PDT) Subject: [rspec-users] How do I improve the readability of my specs Message-ID: Here is my spec. describe Exception2db do context "attributes" do subject { Exception2db.create(:exception => $exception_data_xml) } specify { subject.controller.should == 'exception2db/main' } specify { subject.error_message.should == 'RuntimeError: 46' } specify { subject.user_agent.should == "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.38 Safari/533.4" } end end Here is specdoc. Exception2db attributes - should == "exception2db/main" - should == "RuntimeError: 46" - should == "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.38 Safari/533.4" All the tests are passing. However the specdoc message is not very clean. How can I improve the message? What am I missing? The idea of wrapping each of my specify inside "it" to just to have better message is not very DRY. From rhydiant at googlemail.com Wed May 26 23:01:26 2010 From: rhydiant at googlemail.com (rhydiant) Date: Wed, 26 May 2010 20:01:26 -0700 (PDT) Subject: [rspec-users] as_null_object Message-ID: <385dac10-f581-45f8-80b6-217206fdec5c@a39g2000prb.googlegroups.com> Given that RSpec has the following methods to create test doubles ... double(:my_test_double) mock(:my_mock_object) stub(:my_stub) Is there a way to/ plans to introduce a similar syntax for null objects? null_object(:my_null_object) Instead of mock(:bar, :is_null_object => true) or mock(:foo).as_null_object I think this would be cleaner, what do you think? From dchelimsky at gmail.com Wed May 26 23:22:41 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 26 May 2010 22:22:41 -0500 Subject: [rspec-users] as_null_object In-Reply-To: <385dac10-f581-45f8-80b6-217206fdec5c@a39g2000prb.googlegroups.com> References: <385dac10-f581-45f8-80b6-217206fdec5c@a39g2000prb.googlegroups.com> Message-ID: <6BD7E57E-552C-4CC3-9752-1CACC1FCD9CD@gmail.com> On May 26, 2010, at 10:01 PM, rhydiant wrote: > Given that RSpec has the following methods to create test doubles ... > > double(:my_test_double) > mock(:my_mock_object) > stub(:my_stub) double(), mock(), and stub() all return the same type of object: a test double (actually, it's a Mock, but that's for legacy reasons - the class name might change to Double in the future). The difference between "mocking" and "stubbing" is at the method level. I'd actually like to deprecate mock() and stub() in the long run to reduce the noise. > Is there a way to/ plans to introduce a similar syntax for null > objects? > > null_object(:my_null_object) You could easily do this yourself, like this: def null_object(*args) double(*args).as_null_object end I don't think I'd want to add this to rspec directly, for the noise reduction reasons I wrote above. > Instead of mock(:bar, :is_null_object => true) or > mock(:foo).as_null_object FYI - :null_object => true is deprecated (you'll start seeing deprecation notices in the next beta if you're using it). > I think this would be cleaner, what do you think? Clean is relative. It might be slightly less typing, but I don't know that it's any more expressive, and IMO it increases the noise level. Another thing to consider is that there are other "decorators" that use this same pattern: double(name).as_something. That all make sense? Cheers, David From dchelimsky at gmail.com Wed May 26 23:44:03 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 26 May 2010 22:44:03 -0500 Subject: [rspec-users] How do I improve the readability of my specs In-Reply-To: References: Message-ID: On May 26, 2010, at 9:37 PM, Nadal wrote: > Here is my spec. > > describe Exception2db do > context "attributes" do > subject { Exception2db.create(:exception => $exception_data_xml) } > > specify { subject.controller.should == 'exception2db/main' } > specify { subject.error_message.should == 'RuntimeError: 46' } > specify { subject.user_agent.should == "Mozilla/5.0 (Macintosh; U; > Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko) > Chrome/5.0.375.38 Safari/533.4" } > end > end > > Here is specdoc. > > Exception2db attributes > - should == "exception2db/main" > - should == "RuntimeError: 46" > - should == "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) > AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.38 Safari/533.4" > > All the tests are passing. However the specdoc message is not very > clean. > > How can I improve the message? What am I missing? The idea of wrapping > each of my specify inside "it" to just to have better message is not > very DRY. I look at it the other way: accepting unclear messages just to keep things DRY is missing the point. DRY is about reducing duplication of concepts, not letters. At its heart, DRY is about maintenance. Duplication can come in very sinister forms, like two methods with different names on two different objects that accomplish the same task. That's the sort of duplication that kills maintenance because a new requirement comes in and you don't even realize you have two places to change in the code base. Consider the following two examples: it "concats the first and last name" do first_name = "David" last_name = "Chelimsky" person = Person.new( :first_name => first_name, :last_name => last_name ) person.full_name.should == "#{first_name} #{last_name}" end it "concats the first and last name" do person = Person.new( :first_name => "David", :last_name => "Chelimsky" ) person.full_name.should == "David Chelimsky" end Which one is DRYer? You could argue the first one is, because the string literals are not repeated. You could argue that the second one is, because the variable names are not repeated. You might argue the first one is because, even though the variable names are repeated, the failure message you get if you type "frist_name" will be very informative. You might argue that typing "Chelmisky" in the second one would also give you an informative message. Also, the first one very likely duplicates the actual implementation of the full_name method. And on, and on, and on, and on. Here's what I don't really think you can argue against: the second one is easier to read and understand. In the example you gave, I have absolutely no idea what those specs are telling me about the Exception2db object. After some study, I _think_ I understand, but it took a minute. What I'd like to see in the specdoc output is something like: Exception2db stores the controller stores the runtime error stores the user agent Now I know what this thing DOES. Sure, the spec is going to have more lines in it, but the concepts expressed in the specdoc are _different_ from the concepts in the expectations. In my book, that's not a DRY violation at all. HTH, David ps - there is some irony in the fact that I keep repeating myself on this exact topic on this list. I think I need to write this up in a blog post and point people to that in the future. Now THAT would be DRY. From phillipkoebbe at gmail.com Thu May 27 00:04:29 2010 From: phillipkoebbe at gmail.com (Phillip Koebbe) Date: Wed, 26 May 2010 23:04:29 -0500 Subject: [rspec-users] How do I improve the readability of my specs In-Reply-To: References: Message-ID: <4BFDEF4D.900@gmail.com> On 2010-05-26 10:44 PM, David Chelimsky wrote: > ps - there is some irony in the fact that I keep repeating myself on > this exact topic on this list. I think I need to write this up in a > blog post and point people to that in the future. Now THAT would be DRY. +1 Please do. From rhydiant at googlemail.com Thu May 27 01:07:20 2010 From: rhydiant at googlemail.com (rhydiant) Date: Wed, 26 May 2010 22:07:20 -0700 (PDT) Subject: [rspec-users] as_null_object In-Reply-To: <6BD7E57E-552C-4CC3-9752-1CACC1FCD9CD@gmail.com> References: <385dac10-f581-45f8-80b6-217206fdec5c@a39g2000prb.googlegroups.com> <6BD7E57E-552C-4CC3-9752-1CACC1FCD9CD@gmail.com> Message-ID: <73e617e9-e4d2-4526-ab92-bf7363124b80@a27g2000prj.googlegroups.com> Makes sense... So would you tend to use double() in place of mock()/ stub()? On May 27, 1:22?pm, David Chelimsky wrote: > On May 26, 2010, at 10:01 PM, rhydiant wrote: > > > Given that RSpec has the following methods to create test doubles ... > > > ?double(:my_test_double) > > ?mock(:my_mock_object) > > ?stub(:my_stub) > > double(), mock(), and stub() all return the same type of object: a test double (actually, it's a Mock, but that's for legacy reasons - the class name might change to Double in the future). The difference between "mocking" and "stubbing" is at the method level. I'd actually like to deprecate mock() and stub() in the long run to reduce the noise. > > > Is there a way to/ plans to introduce a similar syntax for null > > objects? > > > ?null_object(:my_null_object) > > You could easily do this yourself, like this: > > def null_object(*args) > ? double(*args).as_null_object > end > > I don't think I'd want to add this to rspec directly, for the noise reduction reasons I wrote above. > > > Instead of mock(:bar, :is_null_object => true) or > > mock(:foo).as_null_object > > FYI - :null_object => true is deprecated (you'll start seeing deprecation notices in the next beta if you're using it). > > > I think this would be cleaner, what do you think? > > Clean is relative. It might be slightly less typing, but I don't know that it's any more expressive, and IMO it increases the noise level. Another thing to consider is that there are other "decorators" that use this same pattern: double(name).as_something. > > That all make sense? > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Thu May 27 01:13:03 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 27 May 2010 00:13:03 -0500 Subject: [rspec-users] as_null_object In-Reply-To: <73e617e9-e4d2-4526-ab92-bf7363124b80@a27g2000prj.googlegroups.com> References: <385dac10-f581-45f8-80b6-217206fdec5c@a39g2000prb.googlegroups.com> <6BD7E57E-552C-4CC3-9752-1CACC1FCD9CD@gmail.com> <73e617e9-e4d2-4526-ab92-bf7363124b80@a27g2000prj.googlegroups.com> Message-ID: On Thu, May 27, 2010 at 12:07 AM, rhydiant wrote: > Makes sense... So would you tend to use double() in place of mock()/ > stub()? That's pretty much what I do all the time now, though I haven't gone back and changed all the specs I've ever written. Yet :) > > On May 27, 1:22?pm, David Chelimsky wrote: >> On May 26, 2010, at 10:01 PM, rhydiant wrote: >> >> > Given that RSpec has the following methods to create test doubles ... >> >> > ?double(:my_test_double) >> > ?mock(:my_mock_object) >> > ?stub(:my_stub) >> >> double(), mock(), and stub() all return the same type of object: a test double (actually, it's a Mock, but that's for legacy reasons - the class name might change to Double in the future). The difference between "mocking" and "stubbing" is at the method level. I'd actually like to deprecate mock() and stub() in the long run to reduce the noise. >> >> > Is there a way to/ plans to introduce a similar syntax for null >> > objects? >> >> > ?null_object(:my_null_object) >> >> You could easily do this yourself, like this: >> >> def null_object(*args) >> ? double(*args).as_null_object >> end >> >> I don't think I'd want to add this to rspec directly, for the noise reduction reasons I wrote above. >> >> > Instead of mock(:bar, :is_null_object => true) or >> > mock(:foo).as_null_object >> >> FYI - :null_object => true is deprecated (you'll start seeing deprecation notices in the next beta if you're using it). >> >> > I think this would be cleaner, what do you think? >> >> Clean is relative. It might be slightly less typing, but I don't know that it's any more expressive, and IMO it increases the noise level. Another thing to consider is that there are other "decorators" that use this same pattern: double(name).as_something. >> >> That all make sense? >> >> Cheers, >> David >> _______________________________________________ >> 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 Thu May 27 02:44:07 2010 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 27 May 2010 07:44:07 +0100 Subject: [rspec-users] How do I improve the readability of my specs In-Reply-To: References: Message-ID: <00AF8B8F-FFB2-4897-BB78-8144141E5226@mattwynne.net> On 27 May 2010, at 04:44, David Chelimsky wrote: > On May 26, 2010, at 9:37 PM, Nadal wrote: > >> Here is my spec. >> >> describe Exception2db do >> context "attributes" do >> subject { Exception2db.create(:exception => $exception_data_xml) } >> >> specify { subject.controller.should == 'exception2db/main' } >> specify { subject.error_message.should == 'RuntimeError: 46' } >> specify { subject.user_agent.should == "Mozilla/5.0 (Macintosh; U; >> Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko) >> Chrome/5.0.375.38 Safari/533.4" } >> end >> end >> >> Here is specdoc. >> >> Exception2db attributes >> - should == "exception2db/main" >> - should == "RuntimeError: 46" >> - should == "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) >> AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.38 Safari/533.4" >> >> All the tests are passing. However the specdoc message is not very >> clean. >> >> How can I improve the message? What am I missing? The idea of wrapping >> each of my specify inside "it" to just to have better message is not >> very DRY. > > I look at it the other way: accepting unclear messages just to keep things DRY is missing the point. > > DRY is about reducing duplication of concepts, not letters. At its heart, DRY is about maintenance. Duplication can come in very sinister forms, like two methods with different names on two different objects that accomplish the same task. That's the sort of duplication that kills maintenance because a new requirement comes in and you don't even realize you have two places to change in the code base. > > Consider the following two examples: > > it "concats the first and last name" do > first_name = "David" > last_name = "Chelimsky" > person = Person.new( > :first_name => first_name, > :last_name => last_name > ) > person.full_name.should == "#{first_name} #{last_name}" > end > > it "concats the first and last name" do > person = Person.new( > :first_name => "David", > :last_name => "Chelimsky" > ) > person.full_name.should == "David Chelimsky" > end > > Which one is DRYer? You could argue the first one is, because the string literals are not repeated. You could argue that the second one is, because the variable names are not repeated. You might argue the first one is because, even though the variable names are repeated, the failure message you get if you type "frist_name" will be very informative. You might argue that typing "Chelmisky" in the second one would also give you an informative message. Also, the first one very likely duplicates the actual implementation of the full_name method. And on, and on, and on, and on. > > Here's what I don't really think you can argue against: the second one is easier to read and understand. > > In the example you gave, I have absolutely no idea what those specs are telling me about the Exception2db object. After some study, I _think_ I understand, but it took a minute. What I'd like to see in the specdoc output is something like: > > Exception2db > stores the controller > stores the runtime error > stores the user agent > > Now I know what this thing DOES. Sure, the spec is going to have more lines in it, but the concepts expressed in the specdoc are _different_ from the concepts in the expectations. In my book, that's not a DRY violation at all. > > HTH, > David > > ps - there is some irony in the fact that I keep repeating myself on this exact topic on this list. I think I need to write this up in a blog post and point people to that in the future. Now THAT would be DRY. Great explanation David. There's a slightly different point about this, which is that in the BDD world we aspire to build things from the "outside in". These splendid methods that automatically generate specdoc from code are great in simple cases, but very often it's advisable to start by writing a plain-english description of what you're setting out to do before you write any code. Jumping straight in to writing the code (the solution) without clearly having stated the goal can mean you miss a chance to get insights into your design. cheers, Matt http://blog.mattwynne.net From node.js99 at gmail.com Thu May 27 09:39:22 2010 From: node.js99 at gmail.com (Nadal) Date: Thu, 27 May 2010 06:39:22 -0700 (PDT) Subject: [rspec-users] How do I improve the readability of my specs In-Reply-To: <00AF8B8F-FFB2-4897-BB78-8144141E5226@mattwynne.net> References: <00AF8B8F-FFB2-4897-BB78-8144141E5226@mattwynne.net> Message-ID: <65061696-1d96-4f66-bab2-2410fdfa229a@u7g2000vbq.googlegroups.com> Thanks David for great explanation. Just to be clear to David and others. As some of you might have noticed I have been asking a lot of questions starting last week. And that is because I never used rspec before. And now that I am reading the book and am trying to convert some of my tests from plain ruby style tests to rspec I am trying to engage in a conversation. No offense to anyone. Infact I salute David and other team members. It's just that I am being more vocal and bringing a perspective to the community. And ,I believe, if I have a question then others might have similar question and they might not take time to write in the forum. Either way I am learning a lot and I hope community benefits. The book is great. And conversations like this one with real example makes for great supplement. On May 27, 2:44?am, Matt Wynne wrote: > On 27 May 2010, at 04:44, David Chelimsky wrote: > > > > > > > On May 26, 2010, at 9:37 PM, Nadal wrote: > > >> Here is my spec. > > >> describe Exception2db do > >> context "attributes" do > >> ? subject { Exception2db.create(:exception => $exception_data_xml) } > > >> ? specify { subject.controller.should == 'exception2db/main' } > >> ? specify { subject.error_message.should == 'RuntimeError: 46' } > >> ? specify { subject.user_agent.should == "Mozilla/5.0 (Macintosh; U; > >> Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko) > >> Chrome/5.0.375.38 Safari/533.4" } > >> end > >> end > > >> Here is specdoc. > > >> Exception2db attributes > >> - should == "exception2db/main" > >> - should == "RuntimeError: 46" > >> - should == "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) > >> AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.38 Safari/533.4" > > >> All the tests are passing. However the specdoc message is not very > >> clean. > > >> How can I improve the message? What am I missing? The idea of wrapping > >> each of my specify inside "it" to just to have better message is not > >> very DRY. > > > I look at it the other way: accepting unclear messages just to keep things DRY is missing the point. > > > DRY is about reducing duplication of concepts, not letters. At its heart, DRY is about maintenance. Duplication can come in very sinister forms, like two methods with different names on two different objects that accomplish the same task. That's the sort of duplication that kills maintenance because a new requirement comes in and you don't even realize you have two places to change in the code base. > > > Consider the following two examples: > > > it "concats the first and last name" do > > ?first_name = "David" > > ?last_name = "Chelimsky" > > ?person = Person.new( > > ? ?:first_name => first_name, > > ? ?:last_name => last_name > > ?) > > ?person.full_name.should == "#{first_name} #{last_name}" > > end > > > it "concats the first and last name" do > > ?person = Person.new( > > ? ?:first_name => "David", > > ? ?:last_name => "Chelimsky" > > ?) > > ?person.full_name.should == "David Chelimsky" > > end > > > Which one is DRYer? You could argue the first one is, because the string literals are not repeated. You could argue that the second one is, because the variable names are not repeated. You might argue the first one is because, even though the variable names are repeated, the failure message you get if you type "frist_name" will be very informative. You might argue that typing "Chelmisky" in the second one would also give you an informative message. Also, the first one very likely duplicates the actual implementation of the full_name method. And on, and on, and on, and on. > > > Here's what I don't really think you can argue against: the second one is easier to read and understand. > > > In the example you gave, I have absolutely no idea what those specs are telling me about the Exception2db object. After some study, I _think_ I understand, but it took a minute. What I'd like to see in the specdoc output is something like: > > > Exception2db > > ?stores the controller > > ?stores the runtime error > > ?stores the user agent > > > Now I know what this thing DOES. Sure, the spec is going to have more lines in it, but the concepts expressed in the specdoc are _different_ from the concepts in the expectations. In my book, that's not a DRY violation at all. > > > HTH, > > David > > > ps - there is some irony in the fact that I keep repeating myself on this exact topic on this list. I think I need to write this up in a blog post and point people to that in the future. Now THAT would be DRY. > > Great explanation David. > > There's a slightly different point about this, which is that in the BDD world we aspire to build things from the "outside in". > > These splendid methods that automatically generate specdoc from code are great in simple cases, but very often it's advisable to start by writing a plain-english description of what you're setting out to do before you write any code. Jumping straight in to writing the code (the solution) without clearly having stated the goal can mean you miss a chance to get insights into your design. > > cheers, > Matthttp://blog.mattwynne.net > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Thu May 27 10:01:11 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 27 May 2010 09:01:11 -0500 Subject: [rspec-users] How do I improve the readability of my specs In-Reply-To: <65061696-1d96-4f66-bab2-2410fdfa229a@u7g2000vbq.googlegroups.com> References: <00AF8B8F-FFB2-4897-BB78-8144141E5226@mattwynne.net> <65061696-1d96-4f66-bab2-2410fdfa229a@u7g2000vbq.googlegroups.com> Message-ID: <0C36FF03-9B3C-4AF2-AE5F-FC71270ADB80@gmail.com> On May 27, 2010, at 8:39 AM, Nadal wrote: > Thanks David for great explanation. > > Just to be clear to David and others. As some of you might have > noticed I have been asking a lot of questions starting last week. And > that is because I never used rspec before. And now that I am reading > the book and am trying to convert some of my tests from plain ruby > style tests to rspec I am trying to engage in a conversation. > > No offense to anyone. No offense taken, and I apologize that my response appeared to direct negative energy your way. You just touched on a topic that I feel strongly about. DRY is widely misunderstood and oft misappropriated at the expense of other valuable principles that should be considered as well. > Infact I salute David and other team members. > It's just that I am being more vocal and bringing a perspective to the > community. And ,I believe, if I have a question then others might have > similar question and they might not take time to write in the forum. Absolutely! > Either way I am learning a lot and I hope community benefits. The book > is great. And conversations like this one with real example makes for > great supplement. Absolutely, again! Bring on the questions. Cheers, David > On May 27, 2:44 am, Matt Wynne wrote: >> On 27 May 2010, at 04:44, David Chelimsky wrote: >> >> >> >> >> >>> On May 26, 2010, at 9:37 PM, Nadal wrote: >> >>>> Here is my spec. >> >>>> describe Exception2db do >>>> context "attributes" do >>>> subject { Exception2db.create(:exception => $exception_data_xml) } >> >>>> specify { subject.controller.should == 'exception2db/main' } >>>> specify { subject.error_message.should == 'RuntimeError: 46' } >>>> specify { subject.user_agent.should == "Mozilla/5.0 (Macintosh; U; >>>> Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko) >>>> Chrome/5.0.375.38 Safari/533.4" } >>>> end >>>> end >> >>>> Here is specdoc. >> >>>> Exception2db attributes >>>> - should == "exception2db/main" >>>> - should == "RuntimeError: 46" >>>> - should == "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) >>>> AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.38 Safari/533.4" >> >>>> All the tests are passing. However the specdoc message is not very >>>> clean. >> >>>> How can I improve the message? What am I missing? The idea of wrapping >>>> each of my specify inside "it" to just to have better message is not >>>> very DRY. >> >>> I look at it the other way: accepting unclear messages just to keep things DRY is missing the point. >> >>> DRY is about reducing duplication of concepts, not letters. At its heart, DRY is about maintenance. Duplication can come in very sinister forms, like two methods with different names on two different objects that accomplish the same task. That's the sort of duplication that kills maintenance because a new requirement comes in and you don't even realize you have two places to change in the code base. >> >>> Consider the following two examples: >> >>> it "concats the first and last name" do >>> first_name = "David" >>> last_name = "Chelimsky" >>> person = Person.new( >>> :first_name => first_name, >>> :last_name => last_name >>> ) >>> person.full_name.should == "#{first_name} #{last_name}" >>> end >> >>> it "concats the first and last name" do >>> person = Person.new( >>> :first_name => "David", >>> :last_name => "Chelimsky" >>> ) >>> person.full_name.should == "David Chelimsky" >>> end >> >>> Which one is DRYer? You could argue the first one is, because the string literals are not repeated. You could argue that the second one is, because the variable names are not repeated. You might argue the first one is because, even though the variable names are repeated, the failure message you get if you type "frist_name" will be very informative. You might argue that typing "Chelmisky" in the second one would also give you an informative message. Also, the first one very likely duplicates the actual implementation of the full_name method. And on, and on, and on, and on. >> >>> Here's what I don't really think you can argue against: the second one is easier to read and understand. >> >>> In the example you gave, I have absolutely no idea what those specs are telling me about the Exception2db object. After some study, I _think_ I understand, but it took a minute. What I'd like to see in the specdoc output is something like: >> >>> Exception2db >>> stores the controller >>> stores the runtime error >>> stores the user agent >> >>> Now I know what this thing DOES. Sure, the spec is going to have more lines in it, but the concepts expressed in the specdoc are _different_ from the concepts in the expectations. In my book, that's not a DRY violation at all. >> >>> HTH, >>> David >> >>> ps - there is some irony in the fact that I keep repeating myself on this exact topic on this list. I think I need to write this up in a blog post and point people to that in the future. Now THAT would be DRY. >> >> Great explanation David. >> >> There's a slightly different point about this, which is that in the BDD world we aspire to build things from the "outside in". >> >> These splendid methods that automatically generate specdoc from code are great in simple cases, but very often it's advisable to start by writing a plain-english description of what you're setting out to do before you write any code. Jumping straight in to writing the code (the solution) without clearly having stated the goal can mean you miss a chance to get insights into your design. >> >> cheers, >> Matthttp://blog.mattwynne.net >> _______________________________________________ >> 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 l3moncurd at gmail.com Fri May 28 04:23:39 2010 From: l3moncurd at gmail.com (Ben Buckley) Date: Fri, 28 May 2010 09:23:39 +0100 Subject: [rspec-users] [Code Style] Is there a more 'rspec' way for me to write this test? Message-ID: Morning all, I have been playing with Ruby/RSpec on a small script to try and get to know the language and its idioms. I have got my tests working and removed some duplication, but I am conscious the code looks quite Java-like in its style. I would appreciate it if some of the seasoned rspecers on this mailing list might be able to take a look and give any suggestions on how it could be more ruby-like? Overview: TeamCalendar interacts with a Website object to determine if a person had some activity on a particular day. The Website object uses Watir to interact with a real website (pulled into a separate class because I couldn't work out how to test it). describe TeamCalendar do before do @mock_website = stub("the website").as_null_object @builder = TeamBuilder.new(@mock_website).member("Ben") @hronline = TeamCalendar.new(@mock_website,"Ben") end it "should return :normal when no calendar entries exist" do @hronline.dayType("6/27").should == :normal end it "should return :public_holiday when website shows a bank holiday" do @builder.member("Ben").withCalendarEntry("6/25","holiday.jpg") @hronline.dayType("6/25").should == :public_holiday end it "should return :public_holiday when any other team member shows bank holiday" do @builder.member("Ben").withCalendarEntry("1/4","vacation.jpg") @builder.member("Dave").withCalendarEntry("1/4","holiday.jpg") @hronline.dayType("1/4").should == :public_holiday end end class TeamBuilder def initialize(mock_website) @team = [] @website = mock_website @website.stub!(:team).and_return(@team) end def member(name) @name = name @team.push(name) if !@team.include?(name) self end def withCalendarEntry(day, type) @website.stub!(:imageShownOnDay).with(day, at name).and_return(type) end end Thanks, -Ben From mail at rodrigoflores.org Fri May 28 23:26:23 2010 From: mail at rodrigoflores.org (Rodrigo Flores) Date: Sat, 29 May 2010 00:26:23 -0300 Subject: [rspec-users] Autospec doing nothing In-Reply-To: References: Message-ID: I discovered the solution I have to put this on the .autotest file http://pastie.textmate.org/982730 On Sun, May 9, 2010 at 09:56, Rodrigo Flores wrote: > Ops > > I searched on the list archive and I found a topic from a month ago about > this. My ZenTest version is 4.3.1 > > My .autotest file is in my ~ and contains only > require "autotest/growl" > > rake spec is running succesfully. > > On Sun, May 9, 2010 at 09:45, Rodrigo Flores wrote: > >> Hi >> >> When I run autospec on a rails project I get nothing. >> >> flores at Suomi(9:41)~/Code/Sabbre/camisa10 % autospec >> (Not running features. To run features in autotest, set >> AUTOFEATURE=true.) >> (Not running features. To run features in autotest, set >> AUTOFEATURE=true.) >> loading autotest/rails_rspec >> style: RailsRspec >> >> >> >> -------------------------------------------------------------------------------- >> >> (a bunch of blank lines) >> >> flores at Suomi(9:41)~/Code/Sabbre/camisa10 % >> >> >> Any ideas ? >> >> My Operating System is Mac OS X Snow Leopard, my ruby is 1.8.7. >> >> Rspec: 1.3.0 >> Rspec-Rails: 1.3.2 >> autotest: 4.2.9 >> autotest-growl : 0.2.4, 0.2.3 >> autotest-rails: 4.1.0 >> >> >> -- >> =================== >> Rodrigo L. M. Flores >> Computer Science Msc. Student - IME - USP >> Computer Science Degree - IME - USP >> Homepage (en): http://www.rodrigoflores.org >> Blog (pt-BR): http://blog.rodrigoflores.org >> Linux User # : 351304 >> Jabber: im at rodrigoflores.org >> > > > > -- > =================== > Rodrigo L. M. Flores > Computer Science Msc. Student - IME - USP > Computer Science Degree - IME - USP > Homepage (en): http://www.rodrigoflores.org > Blog (pt-BR): http://blog.rodrigoflores.org > Linux User # : 351304 > Jabber: im at rodrigoflores.org > -- =================== Rodrigo L. M. Flores Computer Science Msc. Student - IME - USP Computer Science Degree - IME - USP Homepage (en): http://www.rodrigoflores.org Blog (pt-BR): http://blog.rodrigoflores.org Linux User # : 351304 Jabber: im at rodrigoflores.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From joseph.delcioppio at gmail.com Mon May 31 08:41:03 2010 From: joseph.delcioppio at gmail.com (Joseph DelCioppio) Date: Mon, 31 May 2010 05:41:03 -0700 (PDT) Subject: [rspec-users] Failing RSpec test and I'm starting to think it may be a bug Message-ID: Guys, I've got an RSpec test that for the life of me I can't get to work. I was hoping somebody could take a quick peek and let me know if they see something wrong here: Here is my code: http://gist.github.com/419793 Can anybody help me out here, I don't understand what RSpec is trying to tell me. Thanks, Joe From dchelimsky at gmail.com Mon May 31 08:57:15 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 31 May 2010 07:57:15 -0500 Subject: [rspec-users] Failing RSpec test and I'm starting to think it may be a bug In-Reply-To: References: Message-ID: On May 31, 2010, at 7:41 AM, Joseph DelCioppio wrote: > Guys, > > I've got an RSpec test that for the life of me I can't get to work. I > was hoping somebody could take a quick peek and let me know if they > see something wrong here: > > Here is my code: http://gist.github.com/419793 > > Can anybody help me out here, I don't understand what RSpec is trying > to tell me. Line 14 stubs with(@user.id.to_s), but line 20 passes @user.id. Try using the same in both cases. HTH, David From joseph.delcioppio at gmail.com Mon May 31 10:29:25 2010 From: joseph.delcioppio at gmail.com (Joseph DelCioppio) Date: Mon, 31 May 2010 07:29:25 -0700 (PDT) Subject: [rspec-users] Failing RSpec test and I'm starting to think it may be a bug In-Reply-To: References: Message-ID: David, Thank you, this did in fact fix it, I guess I don't understand the 'get' method anymore, since I thought that it would behave the same way a normal request would and parameterize @user.id. I feel this way because in Rails 2.3.5 I used the same methodology as I was here and it worked correctly. I wish I could figure out a better way to debug Ruby so that I might be able to answer these questions myself. Joe On May 31, 8:57?am, David Chelimsky wrote: > On May 31, 2010, at 7:41 AM, Joseph DelCioppio wrote: > > > Guys, > > > I've got an RSpec test that for the life of me I can't get to work. ?I > > was hoping somebody could take a quick peek and let me know if they > > see something wrong here: > > > Here is my code: ?http://gist.github.com/419793 > > > Can anybody help me out here, I don't understand what RSpec is trying > > to tell me. > > Line 14 stubs with(@user.id.to_s), but line 20 passes @user.id. Try using the same in both cases. > > HTH, > David > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From joseph.delcioppio at gmail.com Mon May 31 15:35:31 2010 From: joseph.delcioppio at gmail.com (Joseph DelCioppio) Date: Mon, 31 May 2010 12:35:31 -0700 (PDT) Subject: [rspec-users] Understanding how to better use stub! and stub_chain Message-ID: <92cc3c3c-31d7-4ed4-b872-151516e43897@31g2000prc.googlegroups.com> I've been looking through the RSpec source to better understand how RSpec works and I've got a question about the functionality of stub!. I noticed that you can pass a symbol to stub!, which is usually how I use it, some combination of stub!(:method).with(inputs). However, I'm noticing that you can also pass opts and a &block if you wanted to? Can somebody give me an example of this, or why you'd want to do this? Thanks, Joe From dyba.ruby at gmail.com Sat May 29 22:08:16 2010 From: dyba.ruby at gmail.com (dyba) Date: Sat, 29 May 2010 19:08:16 -0700 (PDT) Subject: [rspec-users] Adding custom directories in Rails app breaks RSpec testing Message-ID: <58957ab0-5e6e-4798-9253-30dba929b30a@h20g2000prn.googlegroups.com> Hi: I'm trying to find out why is it when I change the Rails directory structure like so (app/controllers/physical/) does RSpec no longer work? I moved all my controller files to app/controllers/physical. Everything works fine when I run the server. But now I can't test anymore: I get this message when I type the script/spec command: Paintdexter at R0M3 Sat May 29 19:05 >_ script/spec spec/controllers/ physical/home_controller_spec.rb /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/ dependencies.rb:426:in `load_missing_constant': Expected /Users/ Paintdexter/Ruby/atlas/app/controllers/physical/ application_controller.rb to define ApplicationController (LoadError) from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:80:in `const_missing' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:92:in `const_missing' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:437:in `load_missing_constant' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:80:in `const_missing' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:437:in `load_missing_constant' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:80:in `const_missing' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:437:in `load_missing_constant' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:80:in `const_missing' from /Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/ example/helper_example_group.rb:4 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:158:in `require' from /Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/ example.rb:9 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:158:in `require' from /Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails.rb: 17 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:158:in `require' from /Users/Paintdexter/Ruby/atlas/spec/spec_helper.rb:6 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:158:in `require' from ./spec/controllers/physical/home_controller_spec.rb:1 from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:147:in `load_without_new_constant_marking' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:147:in `load' from /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/ example_group_runner.rb:15:in `load_files' from /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/ example_group_runner.rb:14:in `each' from /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/ example_group_runner.rb:14:in `load_files' from /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/ options.rb:133:in `run_examples' from /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/ command_line.rb:9:in `run' from script/spec:10 Paintdexter at R0M3 Sat May 29 19:06 >_ I made sure to add the custom directories in the config/environment.rb file: ## # Adding load paths for my custom directories ## config.load_paths += %W( #{RAILS_ROOT}/app/models/logical #{RAILS_ROOT}/app/controllers/physical #{RAILS_ROOT}/app/controllers/service #{RAILS_ROOT}/app/views/physical #{RAILS_ROOT}/spec/controllers/physical #{RAILS_ROOT}/spec/views/physical ) This however doesn't work. How can I make RSpec aware that the Rails app directory structure has changed?