From lists at ruby-forum.com Thu Nov 1 06:18:51 2007 From: lists at ruby-forum.com (Jamal Soueidan) Date: Thu, 1 Nov 2007 11:18:51 +0100 Subject: [rspec-users] autotest debugger? Message-ID: <443fc7e966293b678edc6ba2ef9c7423@ruby-forum.com> Hi, I keep facing problems with autotest, and I don't know what's happening in the background, is there anyway to know what's happening while testing? Example: @user = User.new @user.email = "testcom" @user.errors.on(:email).should_not be_empty ...throws error failure - You have a nil object when you didn't expect it! - You might have expected an instance of Array. - The error occurred while evaluating nil.empty? ...but when I type this in ./script/console >> @user = User.new => # >> @user.valid? => false >> @user.email = "asd@" >> @user.errors.on 'email' => "is invalid" So how do you guys test things out and see what's happening behind? I'm lost :( Thanks in advance :) -- Posted via http://www.ruby-forum.com/. From pangel.neu at gmail.com Thu Nov 1 06:26:45 2007 From: pangel.neu at gmail.com (pangel) Date: Thu, 1 Nov 2007 03:26:45 -0700 (PDT) Subject: [rspec-users] Can't use #exactly when #and_return influences it. Message-ID: <13526196.post@talk.nabble.com> I want my class Reader to loop on the content of its Stack until false is returned. I also want an optional argument to exist that limits how many times the stack will be read, even if some elements are left. I was trying to spec this last bit but ended up on a false positive. Hope the example will be clear enough: #spec_reader.rb describe Reader do it "should stop reading items when called with a limit" do @stack = mock(Stack) Stack.should_receive(:new).and_return(@stack) @stack.should_receive(:read).exactly(3).times.and_return(2,4,1,5,3,1,false) @reader = Reader.new @reader.read_stack(3) end end # reader.rb class Reader def initialize @stack = Stack.new end def read_stack(limit = 0) #0 = read until false is returned while val = @stack.read # Not implemented on purpose! # return if limit == 0 # limit -= limit ... end end So the test should fail, because the use of the limit argument has not been implemented yet and #read gets called 7 times. But the test actually passes. I looked into it a bit and it seems that number of arguments in #and_return overrides the arguments of #exactly. Did I misunderstand the point of #exactly or should I build my code differently so that the value returned by #and_return does not influence how many times #read is called? -- View this message in context: http://www.nabble.com/Can%27t-use--exactly-when--and_return-influences-it.-tf4730412.html#a13526196 Sent from the rspec-users mailing list archive at Nabble.com. From dchelimsky at gmail.com Thu Nov 1 06:54:58 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 1 Nov 2007 05:54:58 -0500 Subject: [rspec-users] Can't use #exactly when #and_return influences it. In-Reply-To: <13526196.post@talk.nabble.com> References: <13526196.post@talk.nabble.com> Message-ID: <57c63afe0711010354h233ba7fej77a35d9c1d8553b2@mail.gmail.com> On Nov 1, 2007 5:26 AM, pangel wrote: > > I want my class Reader to loop on the content of its Stack until false is > returned. I also want an optional argument to exist that limits how many > times the stack will be read, even if some elements are left. I was trying > to spec this last bit but ended up on a false positive. > > > Hope the example will be clear enough: > > #spec_reader.rb > describe Reader do > it "should stop reading items when called with a limit" do > @stack = mock(Stack) > Stack.should_receive(:new).and_return(@stack) > > @stack.should_receive(:read).exactly(3).times.and_return(2,4,1,5,3,1,false) This should probably not be allowed. > > @reader = Reader.new > @reader.read_stack(3) > end > end > > # reader.rb > class Reader > def initialize > @stack = Stack.new > end > > def read_stack(limit = 0) #0 = read until false is returned > while val = @stack.read > # Not implemented on purpose! > # return if limit == 0 > # limit -= limit > ... > end > end > > So the test should fail, because the use of the limit argument has not been > implemented yet and #read gets called 7 times. But the test actually passes. > I looked into it a bit and it seems that number of arguments in #and_return > overrides the arguments of #exactly. > > Did I misunderstand the point of #exactly or should I build my code > differently so that the value returned by #and_return does not influence how > many times #read is called? I think this is a bug, but the question is - what is the bug? I think the mock should complain when you set exactly(n).times and then give it a different number of return values. WDYT? From tom at experthuman.com Thu Nov 1 08:33:11 2007 From: tom at experthuman.com (Tom Stuart) Date: Thu, 1 Nov 2007 12:33:11 +0000 Subject: [rspec-users] Specifying mixins Message-ID: <9B6A2746-39BB-4716-9D0B-E56DEE6A1E99@experthuman.com> Hi folks, Can anyone share some accumulated wisdom about the best way to spec mixins in general, and (Jamis Buck-style) ActiveRecord "concerns" in particular? The standard situation here is that there's a bunch of functionality, related by concept if not by implementation, that one wants to inherit in many different classes (e.g. ActiveRecord models) without having to actually use subclassing -- straightforward enough. But since BDD best practice encourages one expectation per example and no mocking in the behaviour setup, the specification for this shared functionality is often spread across many behaviours, each of which may need to do its own setup and teardown. So, how best to mix the mixin spec in with the spec for each class that uses the mixin (IYSWIM)? I've tried several permutations of helpers, spec mixins, shared-shared behaviours and so on, but can't find anything which is persuasively neat and DRY while still working reliably. One point of contention is that the mixin's behaviours might need to do things like instantiate the target class with specific arguments in before :each (or call some other class method, if the mixin provides some) so it's not really good enough for the target spec to just squirrel away a prebuilt object in an instance variable. Any advice, please? Cheers, -Tom From pangel.neu at gmail.com Thu Nov 1 08:54:45 2007 From: pangel.neu at gmail.com (pangel) Date: Thu, 1 Nov 2007 05:54:45 -0700 (PDT) Subject: [rspec-users] Can't use #exactly when #and_return influences it. In-Reply-To: <57c63afe0711010354h233ba7fej77a35d9c1d8553b2@mail.gmail.com> References: <13526196.post@talk.nabble.com> <57c63afe0711010354h233ba7fej77a35d9c1d8553b2@mail.gmail.com> Message-ID: <13528094.post@talk.nabble.com> Yes this would make sense, or the mock could just stop sending the values as soon as it does not receive messages anymore. Obviously I prefer this second behaviour because it would, I think, make my specs work correctly. But from a logical point of view as well, this works for me. If the mock complains when there's more return values than expected calls, it would reduce the amount of errors, but it's usually a one-liner so the risk is not that great. On the other hand the second possibility (just stop sending values) would introduce a flexibility that might be handy in some situations. I'm quite a beginner in both ruby and TDD/BDD concepts so I feel like there's a lot I just don't have a full grasp on anyway. Regarding my specs do you think I should structure the whole thing differently? David Chelimsky-2 wrote: > > On Nov 1, 2007 5:26 AM, pangel wrote: >> >> I want my class Reader to loop on the content of its Stack until false is >> returned. I also want an optional argument to exist that limits how many >> times the stack will be read, even if some elements are left. I was >> trying >> to spec this last bit but ended up on a false positive. >> >> >> Hope the example will be clear enough: >> >> #spec_reader.rb >> describe Reader do >> it "should stop reading items when called with a limit" do >> @stack = mock(Stack) >> Stack.should_receive(:new).and_return(@stack) >> >> @stack.should_receive(:read).exactly(3).times.and_return(2,4,1,5,3,1,false) > > This should probably not be allowed. > >> >> @reader = Reader.new >> @reader.read_stack(3) >> end >> end >> >> # reader.rb >> class Reader >> def initialize >> @stack = Stack.new >> end >> >> def read_stack(limit = 0) #0 = read until false is returned >> while val = @stack.read >> # Not implemented on purpose! >> # return if limit == 0 >> # limit -= limit >> ... >> end >> end >> >> So the test should fail, because the use of the limit argument has not >> been >> implemented yet and #read gets called 7 times. But the test actually >> passes. >> I looked into it a bit and it seems that number of arguments in >> #and_return >> overrides the arguments of #exactly. >> >> Did I misunderstand the point of #exactly or should I build my code >> differently so that the value returned by #and_return does not influence >> how >> many times #read is called? > > I think this is a bug, but the question is - what is the bug? I think > the mock should complain when you set exactly(n).times and then give > it a different number of return values. > > WDYT? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > -- View this message in context: http://www.nabble.com/Can%27t-use--exactly-when--and_return-influences-it.-tf4730412.html#a13528094 Sent from the rspec-users mailing list archive at Nabble.com. From mailing_lists at railsnewbie.com Thu Nov 1 12:53:56 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Thu, 1 Nov 2007 12:53:56 -0400 Subject: [rspec-users] autotest debugger? In-Reply-To: <443fc7e966293b678edc6ba2ef9c7423@ruby-forum.com> References: <443fc7e966293b678edc6ba2ef9c7423@ruby-forum.com> Message-ID: <50915205-C638-4FB5-9458-A76EF8600708@railsnewbie.com> On Nov 1, 2007, at 6:18 AM, Jamal Soueidan wrote: > Hi, > > I keep facing problems with autotest, and I don't know what's > happening > in the background, is there anyway to know what's happening while > testing? > > Example: > @user = User.new > @user.email = "testcom" > @user.errors.on(:email).should_not be_empty > > ...throws error failure > This is not an autotest problem, this is a test problem. Usually I start adding extra tests: it "should not raise an error with a new user (exploratory test)" do lambda { User.new }.should_not raise_error end If that one fails...then it's a problem with my setup (before (:each))...and so on. If I really have no idea what's going on, I'll insert the following snippet to the top of the spec: require 'rubygems'; require 'ruby-debug'; debugger; (I use textmate, and have a snippet setup so that I can type "debug" tab, and the full line gets inserted) The next time autotest runs, it will drop me into the debugger (make sure you have the ruby-debug gem installed). Hope that helps, Scott > - You have a nil object when you didn't expect it! > - You might have expected an instance of Array. > - The error occurred while evaluating nil.empty? > > ...but when I type this in ./script/console > >>> @user = User.new > => # logged_at: > nil, created_at: nil> >>> @user.valid? > => false >>> @user.email = "asd@" >>> @user.errors.on 'email' > => "is invalid" > > So how do you guys test things out and see what's happening behind? > I'm > lost :( > > Thanks in advance :) > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From work at ashleymoran.me.uk Thu Nov 1 15:09:34 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Thu, 1 Nov 2007 19:09:34 +0000 Subject: [rspec-users] Rspec Release Plan (was Am I missing something with Heckle?) In-Reply-To: References: <57c63afe0710310953g5ed40c26v5aecb111a227c84d@mail.gmail.com> Message-ID: <5D656B8F-505D-41BB-B277-B31DABEBB1D0@ashleymoran.me.uk> On Oct 31, 2007, at 7:33 pm, Jim Deville wrote: > Can I get that! That sounds nice... (probably simpler than i think) Sure, this is all there is to it: 2> ~/Documents/Development/bdd % cat update-rspec-gem.sh #!/usr/bin/env bash cd ~/Documents/Development/bdd/rspec-trunk svn update cd rspec rake clobber rake package sudo gem install pkg/*.gem svn update "~/Library/Application Support/TextMate/Pristine Copy/ Bundles/RSpec.tmbundle" Note it assumes your RSpec.tmbundle is checked out of trunk, and not either the MacroMates repository or the CURRENT tag, or something else. Ashley -- blog @ http://aviewfromafar.net/ linked-in @ http://www.linkedin.com/in/ashleymoran currently @ home From work at ashleymoran.me.uk Thu Nov 1 15:14:29 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Thu, 1 Nov 2007 19:14:29 +0000 Subject: [rspec-users] Rspec Release Plan (was Am I missing something with Heckle?) In-Reply-To: <57c63afe0710311246m456d13eblf9ee137ea640f6da@mail.gmail.com> References: <57c63afe0710310953g5ed40c26v5aecb111a227c84d@mail.gmail.com> <57c63afe0710311246m456d13eblf9ee137ea640f6da@mail.gmail.com> Message-ID: On Oct 31, 2007, at 7:46 pm, David Chelimsky wrote: > Interestingly enough, there is another thread today expressing > dissatisfaction with 1.x and trunk. Can't please everybody :) You could always do what Rails does and offer a beta gem repository, so you can install with --source ? That way you keep the numbering uninterrupted and still offer a pre-built latest version. Ashley -- blog @ http://aviewfromafar.net/ linked-in @ http://www.linkedin.com/in/ashleymoran currently @ home From hans at degraaff.org Thu Nov 1 15:50:41 2007 From: hans at degraaff.org (Hans de Graaff) Date: Thu, 01 Nov 2007 20:50:41 +0100 Subject: [rspec-users] Writing controller specs Message-ID: <1193402662.12714.1.camel@ip6-localhost> One thing that is bothering me about my controller specs is that sometimes I end up with a number of examples that are the same except for the example name. The reason that this happens is that I've expressed all the expected behavior with should_receive. While this does more or less work as intended it doesn't feel right. As an example, let's say I'm writing code to post a comment and record the IP address. First, let's handle the comment posting: describe 'post comment' do before do @data = {'text' => 'A comment that is posted'} @comment = mock_model(Comment) end it 'should be successful when proper input has been given' do Comment.should_receive(:new).with(@data).once.and_return(@comment) @comment.should_receive(:save).and_return(true) post :create, {:comment => @data} response.should be_success end end So far so good, although checking the response doesn't feel exactly right. Then again, the two expectations already cover the example, so checking the response could just as well be left out. Now, on to adding the recording of the IP address: it 'should record the IP address of the poster' do @comment.should_receive(:ip_address=).with('0.0.0.0') post :create, {:comment => @data} end Obviously this won't work because the @comment object has not been set up correctly. So, we should also add in that code: it 'should record the IP address of the poster' do Comment.should_receive(:new).with(@data).once.and_return(@comment) @comment.should_receive(:save).and_return(true) @comment.should_receive(:ip_address=).with('0.0.0.0') post :create, {:comment => @data} end But now the initial example won't work anymore because the mock model doesn't deal with the ip_address= method. Let's fix that as well: it 'should be successful when proper input has been given' do Comment.should_receive(:new).with(@data).once.and_return(@comment) @comment.should_receive(:save).and_return(true) @comment.should_receive(:ip_address=).with('0.0.0.0') post :create, {:comment => @data} response.should be_success end So now both methods look the same (minus the gratuitous response check) and it feels like something went wrong somewhere. It even becomes tempting to move the should_receive lines into the before-do block, but then the examples become essentially empty. Any comments on insight into this would be appreciated. Kind regards, Hans -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://rubyforge.org/pipermail/rspec-users/attachments/20071101/8b479d27/attachment.bin From hans at degraaff.org Thu Nov 1 16:25:02 2007 From: hans at degraaff.org (Hans de Graaff) Date: Thu, 01 Nov 2007 21:25:02 +0100 Subject: [rspec-users] rake spec:rcov failing In-Reply-To: References: Message-ID: <1193948702.32373.14.camel@ip6-localhost> On Sat, 2007-10-27 at 13:10 -0400, Scott Taylor wrote: > Running rails 1.2.3, rcov (0.8.0.2), rspec trunk (2865) - > > When running rake spec:rcov, I'm getting the following: > > Finished in 245.717813 seconds > > 856 examples, 0 failures, 48 pending > /usr/local/lib/ruby/1.8/rexml/text.rb:292:in `normalize': private > method `gsub' called for 0:Fixnum (NoMethodError) I guess you are using a really new version of ruby? The latest patch levels seem to include a version of rexml that isn't compatible with rcov. The rcov code thinks it can pass Fixnum's as the value of an attribute while building the HTML summary page, but apparently the latest version of rexml no longer allows this. I haven't had time to figure out if this change in rexml is intentional or not, and thus whether rexml or rcov needs fixing. Kind regards, Hans de Graaff -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://rubyforge.org/pipermail/rspec-users/attachments/20071101/b6679549/attachment.bin From jeremy.stephens at vanderbilt.edu Thu Nov 1 17:08:39 2007 From: jeremy.stephens at vanderbilt.edu (Jeremy Stephens) Date: Thu, 1 Nov 2007 16:08:39 -0500 Subject: [rspec-users] no speed up with spec_server Message-ID: <200711011608.39357.jeremy.stephens@vanderbilt.edu> Hey guys, I'm running spec_server and using --drb with my specs in Rails, and I'm seeing virtually no speed up. I'm using rspec/rspec_on_rails trunk. Is there something I'm doing wrong? TIA, Jeremy -- Jeremy Stephens Computer Systems Analyst I School of Medicine Department of Biostatistics Vanderbilt University From lists at ruby-forum.com Thu Nov 1 17:24:46 2007 From: lists at ruby-forum.com (Chris Olsen) Date: Thu, 1 Nov 2007 22:24:46 +0100 Subject: [rspec-users] Can't delete app/helpers Message-ID: <6a81e9ca41ab7dcea40355ab01652756@ruby-forum.com> I would like to remove some unused helpers from the app/helpers dir, but when I do so my specs fail. Why is this? I don't see where those helpers are referenced within the tests. Is there a way to delete these unused files? Thanks -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Thu Nov 1 19:27:10 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 2 Nov 2007 00:27:10 +0100 Subject: [rspec-users] no speed up with spec_server In-Reply-To: <200711011608.39357.jeremy.stephens@vanderbilt.edu> References: <200711011608.39357.jeremy.stephens@vanderbilt.edu> Message-ID: <8d961d900711011627n18dae788n9ec50ef83603946a@mail.gmail.com> On 11/1/07, Jeremy Stephens wrote: > Hey guys, > > I'm running spec_server and using --drb with my specs in Rails, and > I'm seeing virtually no speed up. I'm using rspec/rspec_on_rails > trunk. Is there something I'm doing wrong? > It's a regression I'm planning to fix this weekend Aslak > TIA, > Jeremy > -- > Jeremy Stephens Computer Systems Analyst I School of Medicine > Department of Biostatistics Vanderbilt University > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Thu Nov 1 19:27:50 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 2 Nov 2007 00:27:50 +0100 Subject: [rspec-users] Can't delete app/helpers In-Reply-To: <6a81e9ca41ab7dcea40355ab01652756@ruby-forum.com> References: <6a81e9ca41ab7dcea40355ab01652756@ruby-forum.com> Message-ID: <8d961d900711011627g721b9335re0de9e5a360b39ef@mail.gmail.com> A stacktrace would help On 11/1/07, Chris Olsen wrote: > I would like to remove some unused helpers from the app/helpers dir, but > when I do so my specs fail. > > Why is this? I don't see where those helpers are referenced within the > tests. Is there a way to delete these unused files? > > Thanks > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Thu Nov 1 19:30:02 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 2 Nov 2007 00:30:02 +0100 Subject: [rspec-users] Specifying mixins In-Reply-To: <9B6A2746-39BB-4716-9D0B-E56DEE6A1E99@experthuman.com> References: <9B6A2746-39BB-4716-9D0B-E56DEE6A1E99@experthuman.com> Message-ID: <8d961d900711011630i7fc4e2aerfbaf157308e666be@mail.gmail.com> just a short advice: describe MyModule do it "should do something" do # The module is automatically mixed into your spec end end Aslak On 11/1/07, Tom Stuart wrote: > Hi folks, > > Can anyone share some accumulated wisdom about the best way to spec > mixins in general, and (Jamis Buck-style) ActiveRecord "concerns" in > particular? > > The standard situation here is that there's a bunch of functionality, > related by concept if not by implementation, that one wants to inherit > in many different classes (e.g. ActiveRecord models) without having to > actually use subclassing -- straightforward enough. But since BDD best > practice encourages one expectation per example and no mocking in the > behaviour setup, the specification for this shared functionality is > often spread across many behaviours, each of which may need to do its > own setup and teardown. > > So, how best to mix the mixin spec in with the spec for each class > that uses the mixin (IYSWIM)? I've tried several permutations of > helpers, spec mixins, shared-shared behaviours and so on, but can't > find anything which is persuasively neat and DRY while still working > reliably. One point of contention is that the mixin's behaviours might > need to do things like instantiate the target class with specific > arguments in before :each (or call some other class method, if the > mixin provides some) so it's not really good enough for the target > spec to just squirrel away a prebuilt object in an instance variable. > > Any advice, please? > > Cheers, > -Tom > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Thu Nov 1 19:39:57 2007 From: lists at ruby-forum.com (Chris Olsen) Date: Fri, 2 Nov 2007 00:39:57 +0100 Subject: [rspec-users] Can't delete app/helpers In-Reply-To: <8d961d900711011627g721b9335re0de9e5a360b39ef@mail.gmail.com> References: <6a81e9ca41ab7dcea40355ab01652756@ruby-forum.com> <8d961d900711011627g721b9335re0de9e5a360b39ef@mail.gmail.com> Message-ID: > A stacktrace would help /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S script/spec -O spec/spec.opts spec/views/addresses/show.rhtml_spec.rb spec/helpers/addresses_helper_spec.rb spec/views/addresses/index.rhtml_spec.rb spec/views/addresses/edit.rhtml_spec.rb spec/views/addresses/new.rhtml_spec.rb /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:249:in `load_missing_constant': Expected /Users/chris/Documents/Projects/Rails/MyProject/trunk/config/../app/helpers/addresses_helper.rb to define AddressesHelper (LoadError) from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:452:in `const_missing' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:464:in `const_missing' from ./spec/views/addresses/show.rhtml_spec.rb:4 from /Users/chris/Documents/Projects/Rails/MyProject/trunk/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:54:in `class_eval' from /Users/chris/Documents/Projects/Rails/MyProject/trunk/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:54:in `eval_behaviour' from /Users/chris/Documents/Projects/Rails/MyProject/trunk/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:31:in `initialize' from /Users/chris/Documents/Projects/Rails/MyProject/trunk/vendor/plugins/rspec/lib/spec/dsl/behaviour_factory.rb:36:in `new' from /Users/chris/Documents/Projects/Rails/MyProject/trunk/vendor/plugins/rspec/lib/spec/dsl/behaviour_factory.rb:36:in `create' ... 21 levels... from /Users/chris/Documents/Projects/Rails/MyProject/trunk/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:155:in `parse' from /Users/chris/Documents/Projects/Rails/MyProject/trunk/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:88:in `create_behaviour_runner' from /Users/chris/Documents/Projects/Rails/MyProject/trunk/vendor/plugins/rspec/lib/spec/runner/command_line.rb:14:in `run' from script/spec:4 -- Posted via http://www.ruby-forum.com/. From mailing_lists at railsnewbie.com Thu Nov 1 21:15:13 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Thu, 1 Nov 2007 21:15:13 -0400 Subject: [rspec-users] no speed up with spec_server In-Reply-To: <200711011608.39357.jeremy.stephens@vanderbilt.edu> References: <200711011608.39357.jeremy.stephens@vanderbilt.edu> Message-ID: On Nov 1, 2007, at 5:08 PM, Jeremy Stephens wrote: > Hey guys, > > I'm running spec_server and using --drb with my specs in Rails, and > I'm seeing virtually no speed up. I'm using rspec/rspec_on_rails > trunk. Is there something I'm doing wrong? > Same here. AFAIK, all the drb server does is load up the rails environment. This should save you a good 2-3 seconds every time you run your tests, but there are other speed hits - - The test database needs to be recreated - The classes in app + lib need to be re-loaded And so on... The most obvious speed hit is actually loading data into the database, as well as reading it out, and at least for me, the 2-3 seconds for loading the environment isn't noticeable either way if I'm actually hitting the database in a model spec. Maybe that would be your case as well? Scott From mailing_lists at railsnewbie.com Thu Nov 1 21:16:21 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Thu, 1 Nov 2007 21:16:21 -0400 Subject: [rspec-users] no speed up with spec_server In-Reply-To: <8d961d900711011627n18dae788n9ec50ef83603946a@mail.gmail.com> References: <200711011608.39357.jeremy.stephens@vanderbilt.edu> <8d961d900711011627n18dae788n9ec50ef83603946a@mail.gmail.com> Message-ID: <211672AC-7C34-4D40-AD83-86C7D8D26283@railsnewbie.com> On Nov 1, 2007, at 7:27 PM, aslak hellesoy wrote: > On 11/1/07, Jeremy Stephens wrote: >> Hey guys, >> >> I'm running spec_server and using --drb with my specs in Rails, and >> I'm seeing virtually no speed up. I'm using rspec/rspec_on_rails >> trunk. Is there something I'm doing wrong? >> > > It's a regression I'm planning to fix this weekend > > Aslak Ah - didn't see your post. Scott From mailing_lists at railsnewbie.com Thu Nov 1 21:18:18 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Thu, 1 Nov 2007 21:18:18 -0400 Subject: [rspec-users] Specifying mixins In-Reply-To: <8d961d900711011630i7fc4e2aerfbaf157308e666be@mail.gmail.com> References: <9B6A2746-39BB-4716-9D0B-E56DEE6A1E99@experthuman.com> <8d961d900711011630i7fc4e2aerfbaf157308e666be@mail.gmail.com> Message-ID: On Nov 1, 2007, at 7:30 PM, aslak hellesoy wrote: > just a short advice: > > describe MyModule do > it "should do something" do > # The module is automatically mixed into your spec > end > end > > Aslak I suppose it really depends on how static/dynamic the module is. This seems to work well for a relatively static case, but how you spec out a module like Enumerable in this manner (in which a series of methods is added to class if a method is implemented in the class - in the case, #each)? Scott From hans at degraaff.org Fri Nov 2 02:31:51 2007 From: hans at degraaff.org (Hans de Graaff) Date: Fri, 02 Nov 2007 07:31:51 +0100 Subject: [rspec-users] Can't delete app/helpers In-Reply-To: References: <6a81e9ca41ab7dcea40355ab01652756@ruby-forum.com> <8d961d900711011627g721b9335re0de9e5a360b39ef@mail.gmail.com> Message-ID: <1193985111.5400.0.camel@ip6-localhost> On Fri, 2007-11-02 at 00:39 +0100, Chris Olsen wrote: > > A stacktrace would help > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S > script/spec -O spec/spec.opts spec/views/addresses/show.rhtml_spec.rb > spec/helpers/addresses_helper_spec.rb Looks like you still have a (possibly generated?) spec for this helper. Kind regards, Hans -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://rubyforge.org/pipermail/rspec-users/attachments/20071102/2f55c50a/attachment.bin From lists at ruby-forum.com Fri Nov 2 04:48:52 2007 From: lists at ruby-forum.com (Jamal Soueidan) Date: Fri, 2 Nov 2007 09:48:52 +0100 Subject: [rspec-users] autotest debugger? In-Reply-To: <50915205-C638-4FB5-9458-A76EF8600708@railsnewbie.com> References: <443fc7e966293b678edc6ba2ef9c7423@ruby-forum.com> <50915205-C638-4FB5-9458-A76EF8600708@railsnewbie.com> Message-ID: Scott Taylor wrote: > On Nov 1, 2007, at 6:18 AM, Jamal Soueidan wrote: > >> @user.errors.on(:email).should_not be_empty >> >> ...throws error failure >> > > This is not an autotest problem, this is a test problem. > > Usually I start adding extra tests: > > it "should not raise an error with a new user (exploratory test)" do > lambda { > User.new > }.should_not raise_error > end > > If that one fails...then it's a problem with my setup (before > (:each))...and so on. > > If I really have no idea what's going on, I'll insert the following > snippet to the top of the spec: > > require 'rubygems'; require 'ruby-debug'; debugger; > > (I use textmate, and have a snippet setup so that I can type "debug" > tab, and the full line gets inserted) > > The next time autotest runs, it will drop me into the debugger (make > sure you have the ruby-debug gem installed). > > Hope that helps, > > Scott I tried to insert the requiring files etc. and went into the debugger, but how do I use it ? $ autotest loading autotest/rails_rspec /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S script/spec -O spec/spec.opts spec/controllers/user_controller_spec.rb spec/models/user_spec.rb spec/helpers/user_helper_spec.rb spec/controllers/video_controller_spec.rb spec/helpers/video_helper_spec.rb ./spec/controllers/user_controller_spec.rb:5 require File.dirname(__FILE__) + '/../spec_helper' (rdb:1) user = User.new Adjusting would put us beyond the oldest (initial) frame. (rdb:1) user.email = "test" Adjusting would put us beyond the oldest (initial) frame. (rdb:1) user.should_not be_valid Adjusting would put us beyond the oldest (initial) frame. (rdb:1) -- Posted via http://www.ruby-forum.com/. From harm.aarts at innovationfactory.nl Fri Nov 2 08:27:04 2007 From: harm.aarts at innovationfactory.nl (Harm Aarts) Date: Fri, 2 Nov 2007 13:27:04 +0100 Subject: [rspec-users] RSpec, RESTful nested routes and :path_prefix Message-ID: <692D270E-F6B1-431B-933E-732B46B49010@innovationfactory.nl> Dear list, In the app we are making we have a rout something like this: map.resources :projects do |projects| projects.resources :pages, :controller =>"Wiki::Pages", :path_prefix => "/projects/:project_id/ wiki", :name_prefix => "project_wiki_" end But I can't get RSpec(I'm very new to it) to accept this. It keeps throwing errors: ActionController::RoutingError in 'Wiki::PagesController POST 'create' should be successful' No route matches {:action=>"create", :controller=>"wiki/ pages", :project_id=>1, :page => {}} I get why it throws these errors but not how to fix it. The relavant RSpec: it "GET 'create' should be successful" do post 'create', :project_id => 1, :page => {} response.should be_success end How do I modify the get request properly? Thanks in advance! From lists at ruby-forum.com Fri Nov 2 10:58:20 2007 From: lists at ruby-forum.com (Chris Olsen) Date: Fri, 2 Nov 2007 15:58:20 +0100 Subject: [rspec-users] Can't delete app/helpers In-Reply-To: <1193985111.5400.0.camel@ip6-localhost> References: <6a81e9ca41ab7dcea40355ab01652756@ruby-forum.com> <8d961d900711011627g721b9335re0de9e5a360b39ef@mail.gmail.com> <1193985111.5400.0.camel@ip6-localhost> Message-ID: <9a4133c591f0374d105f14945bbfe4df@ruby-forum.com> Hans de Graaff wrote: > Looks like you still have a (possibly generated?) spec for this helper. > > Kind regards, > > Hans I do, but the issue is that it requires the app/helpers/addresses_helper.rb file, which is that one that I am trying to delete. `load_missing_constant': Expected /Users/chris/Documents/Projects/Rails/MyProject/trunk/config/../app/helpers/addresses_helper.rb to define AddressesHelper (LoadError) I seem to remember being able to delete helpers. I would think that these auto references that exist would check if the file exists before trying to include them. Is this not possible? Thanks for the help. -- Posted via http://www.ruby-forum.com/. From mailing_lists at railsnewbie.com Fri Nov 2 13:21:49 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 2 Nov 2007 13:21:49 -0400 Subject: [rspec-users] autotest debugger? In-Reply-To: References: <443fc7e966293b678edc6ba2ef9c7423@ruby-forum.com> <50915205-C638-4FB5-9458-A76EF8600708@railsnewbie.com> Message-ID: <7AC5E890-0E72-41FF-A95F-B3A2EF941BDA@railsnewbie.com> On Nov 2, 2007, at 4:48 AM, Jamal Soueidan wrote: > Scott Taylor wrote: >> On Nov 1, 2007, at 6:18 AM, Jamal Soueidan wrote: >> >>> @user.errors.on(:email).should_not be_empty >>> >>> ...throws error failure >>> >> >> This is not an autotest problem, this is a test problem. >> >> Usually I start adding extra tests: >> >> it "should not raise an error with a new user (exploratory test)" do >> lambda { >> User.new >> }.should_not raise_error >> end >> >> If that one fails...then it's a problem with my setup (before >> (:each))...and so on. >> >> If I really have no idea what's going on, I'll insert the following >> snippet to the top of the spec: >> >> require 'rubygems'; require 'ruby-debug'; debugger; >> >> (I use textmate, and have a snippet setup so that I can type "debug" >> tab, and the full line gets inserted) >> >> The next time autotest runs, it will drop me into the debugger (make >> sure you have the ruby-debug gem installed). >> >> Hope that helps, >> >> Scott > > I tried to insert the requiring files etc. and went into the debugger, > but how do I use it ? > > $ autotest > loading autotest/rails_rspec > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S > script/spec -O spec/spec.opts spec/controllers/ > user_controller_spec.rb > spec/models/user_spec.rb spec/helpers/user_helper_spec.rb > spec/controllers/video_controller_spec.rb > spec/helpers/video_helper_spec.rb > ./spec/controllers/user_controller_spec.rb:5 require > File.dirname(__FILE__) + '/../spec_helper' > (rdb:1) user = User.new > Adjusting would put us beyond the oldest (initial) frame. > (rdb:1) user.email = "test" > Adjusting would put us beyond the oldest (initial) frame. > (rdb:1) user.should_not be_valid > Adjusting would put us beyond the oldest (initial) frame. > (rdb:1) > -- > Posted via http://www.ruby-forum.com/. Google for the ruby-debugger. The most common commands are: h - help c - continue p - print (so p user = User.new) irb - drops you into irb b - breakpoint l - list where you are in the code And so on. I would advise looking up the tutorial, though. Scott From vertebrate at gmail.com Fri Nov 2 17:59:11 2007 From: vertebrate at gmail.com (Steve) Date: Fri, 2 Nov 2007 21:59:11 +0000 (UTC) Subject: [rspec-users] Test that controller includes helpers? Message-ID: Is there an easy way to spec that a controller should include helpers other than its own? I was thinking I could just spec responds_to for methods I'm interested in in the view, but that seems like crossing a separation boundary, that the controller maybe doesn't need to know about? Thanks, Steve From nola at rubygeek.com Fri Nov 2 19:59:56 2007 From: nola at rubygeek.com (Nola Stowe) Date: Fri, 2 Nov 2007 19:59:56 -0400 Subject: [rspec-users] RSpec, RESTful nested routes and :path_prefix In-Reply-To: <692D270E-F6B1-431B-933E-732B46B49010@innovationfactory.nl> References: <692D270E-F6B1-431B-933E-732B46B49010@innovationfactory.nl> Message-ID: <43e95380711021659n73321ca1m4a28504ea2ecc7a5@mail.gmail.com> I had a problem when I used: script/generate rspec_scaffold "admin/users" it created the specs with the controller name is "admin_user" instead of "admin/user" which I think should be correct. So I had to go through all the rspec generated files and change the _ to / I actually would like to investigate to see if this is a bug and see if maybe I can write a patch... I would like to contribute! I really like rspec. :) did you use rspec_scaffolding? I don't know if this is the same issue, I would have to see more of your spec file. On 11/2/07, Harm Aarts wrote: > Dear list, > > In the app we are making we have a rout something like this: > map.resources :projects do |projects| > projects.resources :pages, :controller > =>"Wiki::Pages", :path_prefix => "/projects/:project_id/ > wiki", :name_prefix => "project_wiki_" > end > > But I can't get RSpec(I'm very new to it) to accept this. It keeps > throwing errors: > ActionController::RoutingError in 'Wiki::PagesController POST > 'create' should be successful' > No route matches {:action=>"create", :controller=>"wiki/ > pages", :project_id=>1, :page => {}} > > I get why it throws these errors but not how to fix it. The relavant > RSpec: > it "GET 'create' should be successful" do > post 'create', :project_id => 1, :page => {} > response.should be_success > end > > How do I modify the get request properly? > Thanks in advance! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- http://rubygeek.com - my blog featuring: Ruby, PHP and Perl http://DevChix.com - boys can't have all the fun From peter at netsprout.com Fri Nov 2 20:32:22 2007 From: peter at netsprout.com (Peter) Date: Fri, 2 Nov 2007 17:32:22 -0700 Subject: [rspec-users] Specs for Helpers that call render Message-ID: <9132764E-8756-4B6C-81D5-5F2B8B43DAB7@netsprout.com> The helper spec I am writing tests a helper method that calls render. ## module HelperHelper def render_partial render :partial => 'partial' end end ## The helper spec. ## describe HelperHelper do it "should render partial" do render_partial.should_not == nil end end ## The output generated ## $ spec spec/helpers/home_helper_spec.rb .F 1) NoMethodError in 'HelperHelper should render partial' You have a nil object when you didn't expect it! The error occurred while evaluating nil.render app/helpers/helper_helper.rb:4:in `render_partial' ./spec/helpers/helper_helper_spec.rb:3: Finished in 0.00000 seconds 1 example, 1 failure ## I tried adding a before(:each) to setup response, controller, and template objects that render would be called on but the error was always the same. I am still uncertain I did this correctly although I did spend some time looking at the render definition in the rails source. Is there a standard way of setting up specs for helpers that call render? - Peter (I apologize if this has already been answered. We spent a good deal of time searching around the web for a solution but came up empty so far.) From mrnicksgirl at gmail.com Fri Nov 2 19:56:22 2007 From: mrnicksgirl at gmail.com (Nola Stowe) Date: Fri, 2 Nov 2007 19:56:22 -0400 Subject: [rspec-users] RSpec, RESTful nested routes and :path_prefix In-Reply-To: <692D270E-F6B1-431B-933E-732B46B49010@innovationfactory.nl> References: <692D270E-F6B1-431B-933E-732B46B49010@innovationfactory.nl> Message-ID: <43e95380711021656y4369ecb2wf3053d30b5556c51@mail.gmail.com> I had a problem when I used: script/generate rspec_scaffold "admin/users" it created the specs with the controller name is "admin_user" instead of "admin/user" which I think should be correct. So I had to go through all the rspec generated files and change the _ to / did you use rspec_scaffolding? I don't know if this is the same issue, I would have to see more of your spec file. On 11/2/07, Harm Aarts wrote: > Dear list, > > In the app we are making we have a rout something like this: > map.resources :projects do |projects| > projects.resources :pages, :controller > =>"Wiki::Pages", :path_prefix => "/projects/:project_id/ > wiki", :name_prefix => "project_wiki_" > end > > But I can't get RSpec(I'm very new to it) to accept this. It keeps > throwing errors: > ActionController::RoutingError in 'Wiki::PagesController POST > 'create' should be successful' > No route matches {:action=>"create", :controller=>"wiki/ > pages", :project_id=>1, :page => {}} > > I get why it throws these errors but not how to fix it. The relavant > RSpec: > it "GET 'create' should be successful" do > post 'create', :project_id => 1, :page => {} > response.should be_success > end > > How do I modify the get request properly? > Thanks in advance! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- http://rubygeek.com - my blog featuring: Ruby, PHP and Perl http://DevChix.com - boys can't have all the fun From shane.wolf at zvents.com Fri Nov 2 02:36:02 2007 From: shane.wolf at zvents.com (Shane Wolf) Date: Thu, 1 Nov 2007 23:36:02 -0700 Subject: [rspec-users] stub calls to an instance method before it is created? Message-ID: <57b8de400711012336w50574d0cr71e3324c02406b8d@mail.gmail.com> I am desperately in need of functionality such as Mocha offers with their any_instance method. I see that there is an open ticket for a similar feature in RSpec, but it does not look like anything have been done. Is there any other way around this? https://rubyforge.org/tracker/index.php?func=detail&aid=6791&group_id=797&atid=3152 Here is what I am doing, and why I feel I need this (maybe my design is inherently wrong) Given a model called Foo def Foo.create_from_form foo = Foo.new # Do all kinds of crazy stuff here foo.save end In my specs I want to stub the foo.save call to return true or false depending on the case, so that it doesn't actually try and save to the DB... is there any way around this since I do not actually know the instance of the class I am trying to stub? Shane -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071101/91a75ce4/attachment.html From dchelimsky at gmail.com Sat Nov 3 01:38:50 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 3 Nov 2007 01:38:50 -0400 Subject: [rspec-users] stub calls to an instance method before it is created? In-Reply-To: <57b8de400711012336w50574d0cr71e3324c02406b8d@mail.gmail.com> References: <57b8de400711012336w50574d0cr71e3324c02406b8d@mail.gmail.com> Message-ID: <57c63afe0711022238l8361d49q90063f8b5a380fc8@mail.gmail.com> On Nov 2, 2007 2:36 AM, Shane Wolf wrote: > I am desperately in need of functionality such as Mocha offers with their > any_instance method. I see that there is an open ticket for a similar > feature in RSpec, but it does not look like anything have been done. Is > there any other way around this? > > https://rubyforge.org/tracker/index.php?func=detail&aid=6791&group_id=797&atid=3152 > > Here is what I am doing, and why I feel I need this (maybe my design is > inherently wrong) > > Given a model called Foo > > def Foo.create_from_form > foo = Foo.new > # Do all kinds of crazy stuff here > foo.save > end > > In my specs I want to stub the foo.save call to return true or false > depending on the case, so that it doesn't actually try and save to the DB... > is there any way around this since I do not actually know the instance of > the class I am trying to stub? foo = mock("foo") Foo.stub!(:new).and_return(foo) foo.should_receive(:all_kinds_of_crazy_stuff) Foo.create_from_form(arg, arg, arg).should equal(foo) From dchelimsky at gmail.com Sat Nov 3 01:46:38 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 3 Nov 2007 01:46:38 -0400 Subject: [rspec-users] Specs for Helpers that call render In-Reply-To: <9132764E-8756-4B6C-81D5-5F2B8B43DAB7@netsprout.com> References: <9132764E-8756-4B6C-81D5-5F2B8B43DAB7@netsprout.com> Message-ID: <57c63afe0711022246q566c3ed0p1607ff22589a3bd3@mail.gmail.com> On Nov 2, 2007 8:32 PM, Peter wrote: > The helper spec I am writing tests a helper method that calls render. > > ## > module HelperHelper > def render_partial > render :partial => 'partial' > end > end > ## > > The helper spec. > > ## > describe HelperHelper do > it "should render partial" do > render_partial.should_not == nil > end > end > ## > > The output generated > > ## > $ spec spec/helpers/home_helper_spec.rb > .F > > 1) > NoMethodError in 'HelperHelper should render partial' > You have a nil object when you didn't expect it! > The error occurred while evaluating nil.render > app/helpers/helper_helper.rb:4:in `render_partial' > ./spec/helpers/helper_helper_spec.rb:3: > > Finished in 0.00000 seconds > > 1 example, 1 failure > ## > > I tried adding a before(:each) to setup response, controller, and > template objects that render would be called on but the error was > always the same. I am still uncertain I did this correctly although > I did spend some time looking at the render definition in the rails > source. > > Is there a standard way of setting up specs for helpers that call > render? Helper specs create an object to run in and include a standard set of helpers and the helper you are spec'ing. There is no access to services that come from the controllers or views the helper gets mixed into when the app is running. I would just set a message expectation on self, like this: describe HelperHelper do it "should render partial" do self.should_receive(:render).with(:partial => 'partial') render_partial end end HTH, David From dchelimsky at gmail.com Sat Nov 3 02:00:56 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 3 Nov 2007 02:00:56 -0400 Subject: [rspec-users] Test that controller includes helpers? In-Reply-To: References: Message-ID: <57c63afe0711022300r8ecf4c1o30b5501764b438b2@mail.gmail.com> On Nov 2, 2007 5:59 PM, Steve wrote: > Is there an easy way to spec that a controller should include helpers > other than its own? I was thinking I could just spec responds_to for > methods I'm interested in in the view, but that seems like crossing a > separation boundary, that the controller maybe doesn't need to know about? FWIW, by asking you to declare helpers in controllers so that views can access their goodness, Rails is already forcing you to cross that boundary. So whatever you do here is a compromise and you just need to find the lesser of evils. I think the most pragmatic thing to do would be to use a controller spec with integrate_views and describe what the view should look like when it uses one of the included methods. Alternatively could load the file and expect the declaration (but that's somewhat controversial on this list). HTH, David From hans at degraaff.org Sat Nov 3 08:51:16 2007 From: hans at degraaff.org (Hans de Graaff) Date: Sat, 03 Nov 2007 13:51:16 +0100 Subject: [rspec-users] Can't delete app/helpers In-Reply-To: <9a4133c591f0374d105f14945bbfe4df@ruby-forum.com> References: <6a81e9ca41ab7dcea40355ab01652756@ruby-forum.com> <8d961d900711011627g721b9335re0de9e5a360b39ef@mail.gmail.com> <1193985111.5400.0.camel@ip6-localhost> <9a4133c591f0374d105f14945bbfe4df@ruby-forum.com> Message-ID: <1194094276.22355.3.camel@ip6-localhost> On Fri, 2007-11-02 at 15:58 +0100, Chris Olsen wrote: > Hans de Graaff wrote: > > Looks like you still have a (possibly generated?) spec for this helper. > > > > Kind regards, > > > > Hans > > I do, but the issue is that it requires the > app/helpers/addresses_helper.rb file, which is that one that I am trying > to delete. If there is still a spec file that references the helper then it can't be removed without causing spec failures. You should also remove the spec for the helper for the specs to run without problems. If that sounds obvious then you might be trying to do something more complicated in which case some more explanation of what you are trying to achieve would be helpful. Kind regards, Hans -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://rubyforge.org/pipermail/rspec-users/attachments/20071103/16c08807/attachment.bin From vertebrate at gmail.com Sat Nov 3 11:25:26 2007 From: vertebrate at gmail.com (Steve) Date: Sat, 3 Nov 2007 15:25:26 +0000 (UTC) Subject: [rspec-users] Test that controller includes helpers? References: <57c63afe0711022300r8ecf4c1o30b5501764b438b2@mail.gmail.com> Message-ID: On Sat, 03 Nov 2007 02:00:56 -0400, David Chelimsky wrote: > FWIW, by asking you to declare helpers in controllers so that views > can access their goodness, Rails is already forcing you to cross that > boundary. So whatever you do here is a compromise and you just need to > find the lesser of evils. > > I think the most pragmatic thing to do would be to use a controller > spec with integrate_views and describe what the view should look like > when it uses one of the included methods. Alternatively could load the > file and expect the declaration (but that's somewhat controversial on > this list). > > HTH, > David Yeah, I'm not terribly interested in the reloading of the file. That was too much of a pain last time with my models and I opted not to do it. I'd rather not integrate the view if I can avoid it. Is there a way to get at the controller instance that was called though? If I could do that, I could simply check for a responds_to at the very least, right? I understand what you mean by blurring the lines though. Steve From raasdnil at gmail.com Sun Nov 4 04:55:54 2007 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Sun, 4 Nov 2007 20:55:54 +1100 Subject: [rspec-users] Specing raising error, handling, and then not raising error Message-ID: <57a815bf0711040155o1cbfd10dj907db6a7623eefa4@mail.gmail.com> Hey guys and gals, I have a snippet of code: Net::SMTP(@host, @port, @from_domain) do |smtp| @emails.each do |email| begin smtp.send_message email.encoded, email.from, email.destinations @emails_sent += 1 rescue Exception => e # blah end end end What I want to do is: Say there are 4 emails. First email is sent OK On the second email smtp raises a IOError error The third and fourth emails are sent OK I want to spec: That the second iteration raises an error. That the total emails sent count changed by 3 I can't seem to figure out how to stub/mock the smtp object to return an email on the 1, 3, and 4th iteration and raise an error on the 2nd iteration. I thought something like this, but it doesn't work: it "should only increase the sent emails counter if the email was sent" do @smtp = mock(Net::SMTP) @smtp.should_receive(:send_message).exactly(4).times.and_return(true, IOError, true, true) Net::SMTP.stub!(:start).and_yield(@smtp) @sender = Mailer::Sender.new(valid_args(:emails => @emails)) @sender.sent_emails.should == 3 end If anyone has any pointers, that would be great. I am using rSpec trunk - today's release. Mikel From harm.aarts at innovationfactory.nl Sun Nov 4 09:46:13 2007 From: harm.aarts at innovationfactory.nl (Harm Aarts) Date: Sun, 4 Nov 2007 15:46:13 +0100 Subject: [rspec-users] RSpec, RESTful nested routes and :path_prefix In-Reply-To: References: Message-ID: I do not believe that is the case here. I used 'script/genereate rspec_controller wiki::pages' and that generated spec files in 'spec/ controllers/wiki/pages_controller_spec.rb'. So that seemed to be in order. Excerpt: require File.dirname(__FILE__) + '/../../spec_helper' describe Wiki::PagesController do fixtures :projects #Delete these examples and add some real ones it "should use Wiki::PagesController" do controller.should be_an_instance_of(Wiki::PagesController) end it "GET 'index' should be successful" do get 'index', :project_id => 1 response.should be_success end end Seems OK right? Does RSpec not support nested routes with :path_prefix? Harm > ------------------------------ > > Message: 11 > Date: Fri, 2 Nov 2007 19:56:22 -0400 > From: "Nola Stowe" > Subject: Re: [rspec-users] RSpec, RESTful nested routes and > :path_prefix > To: rspec-users > Message-ID: > <43e95380711021656y4369ecb2wf3053d30b5556c51 at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > I had a problem when I used: > > script/generate rspec_scaffold "admin/users" > > it created the specs with the controller name is "admin_user" instead > of "admin/user" which I think should be correct. So I had to go > through all the rspec generated files and change the _ to / > > did you use rspec_scaffolding? > > I don't know if this is the same issue, I would have to see more of > your spec file. > > > > On 11/2/07, Harm Aarts wrote: >> Dear list, >> >> In the app we are making we have a rout something like this: >> map.resources :projects do |projects| >> projects.resources :pages, :controller >> =>"Wiki::Pages", :path_prefix => "/projects/:project_id/ >> wiki", :name_prefix => "project_wiki_" >> end >> >> But I can't get RSpec(I'm very new to it) to accept this. It keeps >> throwing errors: >> ActionController::RoutingError in 'Wiki::PagesController POST >> 'create' should be successful' >> No route matches {:action=>"create", :controller=>"wiki/ >> pages", :project_id=>1, :page => {}} >> >> I get why it throws these errors but not how to fix it. The relavant >> RSpec: >> it "GET 'create' should be successful" do >> post 'create', :project_id => 1, :page => {} >> response.should be_success >> end >> >> How do I modify the get request properly? >> Thanks in advance! >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > -- > http://rubygeek.com - my blog featuring: Ruby, PHP and Perl > http://DevChix.com - boys can't have all the fun > > > ------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > End of rspec-users Digest, Vol 17, Issue 3 > ****************************************** From work at ashleymoran.me.uk Sun Nov 4 10:20:15 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Sun, 4 Nov 2007 15:20:15 +0000 Subject: [rspec-users] Specing raising error, handling, and then not raising error In-Reply-To: <57a815bf0711040155o1cbfd10dj907db6a7623eefa4@mail.gmail.com> References: <57a815bf0711040155o1cbfd10dj907db6a7623eefa4@mail.gmail.com> Message-ID: On Nov 04, 2007, at 9:55 am, Mikel Lindsaar wrote: > it "should only increase the sent emails counter if the email was > sent" do > @smtp = mock(Net::SMTP) > > @smtp > .should_receive(:send_message).exactly(4).times.and_return(true, > IOError, true, true) > Net::SMTP.stub!(:start).and_yield(@smtp) > @sender = Mailer::Sender.new(valid_args(:emails => @emails)) > @sender.sent_emails.should == 3 > end Mikel, It looks like you are doing too much here. You are specifying sending with the SMTP object in the same block you are specifying the algorithm for counting the sent emails. Also, the way it interrogates the email object to extract data looks fragile. I would prefer to make the Email object responsible for sending itself, although I will await the approval of an expert before I tell you my solution is better! I had a go at this, and my solution is MUCH longer, but it breaks the behaviour down to a finer level. (As you didn't show the code for Mailer::Sender, I wrote a quick implementation myself, possibly similar to yours.) Also, I'm never quite sure how best to use "before" blocks, so don't take mine as a canonical example. Anyway here is what I came up with: class Email def initialize(encoded_message, from, destination) @encoded_message, @from, @destination = encoded_message, from, destination end def send_via(smtp) begin smtp.send_message(@encoded_message, @from, @destination) rescue IOError => e 0 else 1 end end end describe Email, :shared => true do before(:each) do @smtp = mock("Net::SMTP") @email = Email.new("message", "from at mydomain", "to at destination") end it "send_via: should send :send_message to the SMTP object with the email details" do @smtp.should_receive(:send_message). with("message", "from at mydomain", "to at destination") @email.send_via(@smtp) end end describe Email, "sent via a working SMTP" do it_should_behave_like "Email" before(:each) do @smtp.stub!(:send_message) end it "send_via: should return 1 if the email sent successfully" do @email.send_via(@smtp).should == 1 end end describe Email, "sent via a faulty SMTP" do it_should_behave_like "Email" before(:each) do @smtp.stub!(:send_message).and_raise(IOError.new) end it "send_via: should return 1 if the email sent successfully" do @email.send_via(@smtp).should == 0 end end class Spammer def initialize(smtp) @smtp = smtp end def send(emails) emails.inject(0) { |success_count, email| success_count + email.send_via(@smtp) } end end describe Spammer, "created with an SMTP" do before(:each) do @email_successful_1 = mock(Email) @email_successful_1.stub!(:send_via).and_return(1) @email_successful_2 = mock(Email) @email_successful_2.stub!(:send_via).and_return(1) @email_unsuccessful_1 = mock(Email) @email_unsuccessful_1.stub!(:send_via).and_return(0) @emails = [ @email_successful_1, @email_successful_2, @email_unsuccessful_1] @spammer = Spammer.new(:smtp) end it "send: should send each email in turn with the SMTP and return the successful count" do @email_successful_1.should_receive(:send_via).with(:smtp).and_return(1) @email_successful_2.should_receive(:send_via).with(:smtp).and_return(1) @email_unsuccessful_1 .should_receive(:send_via).with(:smtp).and_return(2) @spammer.send(@emails) end it "send: should return the count of successful emails" do @spammer.send(@emails).should == 2 end end Let me know if this is helpful Regards Ashley -- blog @ http://aviewfromafar.net/ linked-in @ http://www.linkedin.com/in/ashleymoran currently @ home From nola at rubygeek.com Sun Nov 4 10:53:34 2007 From: nola at rubygeek.com (Nola Stowe) Date: Sun, 4 Nov 2007 10:53:34 -0500 Subject: [rspec-users] RSpec, RESTful nested routes and :path_prefix In-Reply-To: References: Message-ID: <43e95380711040753x32f3cebev85c46118e5eff3c9@mail.gmail.com> Hmm.. I do do have a controller with path_prefix that works. I wrote about a problem I am having in this thread, http://rubyforge.org/pipermail/rspec-users/2007-October/004202.html They do work, but for some reason I can get one of the named routes to work. If you want, email me the full page_controller_spec .. and paste On 11/4/07, Harm Aarts wrote: > I do not believe that is the case here. I used 'script/genereate > rspec_controller wiki::pages' and that generated spec files in 'spec/ > controllers/wiki/pages_controller_spec.rb'. So that seemed to be in > order. Excerpt: > > require File.dirname(__FILE__) + '/../../spec_helper' > > describe Wiki::PagesController do > fixtures :projects > > #Delete these examples and add some real ones > it "should use Wiki::PagesController" do > controller.should be_an_instance_of(Wiki::PagesController) > end > > it "GET 'index' should be successful" do > get 'index', :project_id => 1 > response.should be_success > end > end > > Seems OK right? Does RSpec not support nested routes with :path_prefix? > > Harm > > > ------------------------------ > > > > Message: 11 > > Date: Fri, 2 Nov 2007 19:56:22 -0400 > > From: "Nola Stowe" > > Subject: Re: [rspec-users] RSpec, RESTful nested routes and > > :path_prefix > > To: rspec-users > > Message-ID: > > <43e95380711021656y4369ecb2wf3053d30b5556c51 at mail.gmail.com> > > Content-Type: text/plain; charset=ISO-8859-1 > > > > I had a problem when I used: > > > > script/generate rspec_scaffold "admin/users" > > > > it created the specs with the controller name is "admin_user" instead > > of "admin/user" which I think should be correct. So I had to go > > through all the rspec generated files and change the _ to / > > > > did you use rspec_scaffolding? > > > > I don't know if this is the same issue, I would have to see more of > > your spec file. > > > > > > > > On 11/2/07, Harm Aarts wrote: > >> Dear list, > >> > >> In the app we are making we have a rout something like this: > >> map.resources :projects do |projects| > >> projects.resources :pages, :controller > >> =>"Wiki::Pages", :path_prefix => "/projects/:project_id/ > >> wiki", :name_prefix => "project_wiki_" > >> end > >> > >> But I can't get RSpec(I'm very new to it) to accept this. It keeps > >> throwing errors: > >> ActionController::RoutingError in 'Wiki::PagesController POST > >> 'create' should be successful' > >> No route matches {:action=>"create", :controller=>"wiki/ > >> pages", :project_id=>1, :page => {}} > >> > >> I get why it throws these errors but not how to fix it. The relavant > >> RSpec: > >> it "GET 'create' should be successful" do > >> post 'create', :project_id => 1, :page => {} > >> response.should be_success > >> end > >> > >> How do I modify the get request properly? > >> Thanks in advance! > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > >> > > > > > > -- > > http://rubygeek.com - my blog featuring: Ruby, PHP and Perl > > http://DevChix.com - boys can't have all the fun > > > > > > ------------------------------ > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > End of rspec-users Digest, Vol 17, Issue 3 > > ****************************************** > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- http://rubygeek.com - my blog featuring: Ruby, PHP and Perl http://DevChix.com - boys can't have all the fun From lists at ruby-forum.com Sun Nov 4 17:51:22 2007 From: lists at ruby-forum.com (Hugh Watkins) Date: Sun, 4 Nov 2007 23:51:22 +0100 Subject: [rspec-users] RSpec Texmate Bundle errors In-Reply-To: <8A058D5F-7407-4FB5-9DB0-966727F52AFD@railsnewbie.com> References: <43B902A0-D43C-4330-AFA6-7191EFCC7C42@bolloretelecom.eu> <57c63afe0710300936m1eb514cbj20d64a55bf87cc6f@mail.gmail.com> <8A058D5F-7407-4FB5-9DB0-966727F52AFD@railsnewbie.com> Message-ID: <8220d51602c2e4074d5ab58e5a72aa96@ruby-forum.com> This worked for me #From my rails project rm -rf vendor/plugins/rspec rm -rf vendor/plugins/rspec_on_rails ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec_on_rails ruby script/generate rspec #I installed the bundle in the global directory cd /Library/Application\ Support /TextMate/Bundles sudo svn co svn://rubyforge.org/var/svn/rspec/trunk/RSpec.tmbundle #I had ended up with 2 ruby directories after the leopard install (so 2 gem directories) /usr/bin/ruby -v ruby 1.8.6 (2007-06-07 patchlevel 36) [universal-darwin9.0] /usr/bin/gem -v 0.9.4 /opt/local/bin/ruby -v ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.10.3] /opt/local/bin/gem -v 0.9.4 #I just went ahead nd installed the latest rspec gem in both, at so point I need to delete the /opt/local installation bt not right now cd ~ svn checkout svn://rubyforge.org/var/svn/rspec/trunk rspec_trunk cd rspec_trunk/rspec rake gem sudo /usr/bin/gem install pkg/rspec*.gem sudo /opt/local/bin/gem install pkg/rspec*.gem -- Posted via http://www.ruby-forum.com/. From raasdnil at gmail.com Sun Nov 4 18:51:54 2007 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Mon, 5 Nov 2007 10:51:54 +1100 Subject: [rspec-users] Specing raising error, handling, and then not raising error In-Reply-To: References: <57a815bf0711040155o1cbfd10dj907db6a7623eefa4@mail.gmail.com> Message-ID: <57a815bf0711041551j1d0dc158jdceb4ff4b426b405@mail.gmail.com> On 11/5/07, Ashley Moran wrote: > Mikel, > > It looks like you are doing too much here. You are specifying sending > with the SMTP object in the same block you are specifying the > algorithm for counting the sent emails. Also, the way it interrogates > the email object to extract data looks fragile. I would prefer to > make the Email object responsible for sending itself, although I will > await the approval of an expert before I tell you my solution is better! HOLYCOMPLETESOLUTIONBATMAN! :) Definately helpful... especially the bit on "trying to do too much". The problem I was trying to solve with the mass sender is I only want to open one connection to the SMTP server, not multiple. But your code definatley gave me some good ideas. All this to get some email from one computer on the internet to another that is not :) Anyway, speak soon, thanks again! Mikel From rsl at swimcommunity.org Mon Nov 5 08:33:05 2007 From: rsl at swimcommunity.org (Russell Norris) Date: Mon, 5 Nov 2007 08:33:05 -0500 Subject: [rspec-users] Writing controller specs In-Reply-To: <1193402662.12714.1.camel@ip6-localhost> References: <1193402662.12714.1.camel@ip6-localhost> Message-ID: <1d2f8d6f0711050533lecd5277rfec5559999ab67e7@mail.gmail.com> Howdy. I've been handling this by simply stubbing out the methods as needed in the before(:each) block and then stating should_receive(:foo) when i'm actually writing spec for their behavior. RSL On 11/1/07, Hans de Graaff wrote: > One thing that is bothering me about my controller specs is that > sometimes I end up with a number of examples that are the same except > for the example name. > > The reason that this happens is that I've expressed all the expected > behavior with should_receive. While this does more or less work as > intended it doesn't feel right. > > As an example, let's say I'm writing code to post a comment and record > the IP address. First, let's handle the comment posting: > > > describe 'post comment' do > > before do > @data = {'text' => 'A comment that is posted'} > @comment = mock_model(Comment) > end > > it 'should be successful when proper input has been given' do > Comment.should_receive(:new).with(@data).once.and_return(@comment) > @comment.should_receive(:save).and_return(true) > > post :create, {:comment => @data} > response.should be_success > end > end > > > So far so good, although checking the response doesn't feel exactly > right. > Then again, the two expectations already cover the example, so checking > the > response could just as well be left out. > > Now, on to adding the recording of the IP address: > > it 'should record the IP address of the poster' do > @comment.should_receive(:ip_address=).with('0.0.0.0') > > post :create, {:comment => @data} > end > > Obviously this won't work because the @comment object has not been set > up correctly. So, we should also add in that code: > > it 'should record the IP address of the poster' do > Comment.should_receive(:new).with(@data).once.and_return(@comment) > @comment.should_receive(:save).and_return(true) > @comment.should_receive(:ip_address=).with('0.0.0.0') > > post :create, {:comment => @data} > end > > But now the initial example won't work anymore because the mock model > doesn't deal with the ip_address= method. Let's fix that as well: > > it 'should be successful when proper input has been given' do > Comment.should_receive(:new).with(@data).once.and_return(@comment) > @comment.should_receive(:save).and_return(true) > @comment.should_receive(:ip_address=).with('0.0.0.0') > > post :create, {:comment => @data} > response.should be_success > end > > So now both methods look the same (minus the gratuitous response > check) and it feels like something went wrong somewhere. It even > becomes tempting to move the should_receive lines into the before-do > block, but then the examples become essentially empty. > > Any comments on insight into this would be appreciated. > > Kind regards, > > Hans > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From pergesu at gmail.com Mon Nov 5 10:14:36 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 5 Nov 2007 10:14:36 -0500 Subject: [rspec-users] Writing controller specs In-Reply-To: <1193402662.12714.1.camel@ip6-localhost> References: <1193402662.12714.1.camel@ip6-localhost> Message-ID: <810a540e0711050714k2ccdedfdl5034fed76e255470@mail.gmail.com> Take a look at before(:each) - http://rspec.rubyforge.org/documentation/index.html Pat From work at ashleymoran.me.uk Mon Nov 5 10:53:22 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Mon, 5 Nov 2007 15:53:22 +0000 Subject: [rspec-users] Specing raising error, handling, and then not raising error In-Reply-To: <57a815bf0711041551j1d0dc158jdceb4ff4b426b405@mail.gmail.com> References: <57a815bf0711040155o1cbfd10dj907db6a7623eefa4@mail.gmail.com> <57a815bf0711041551j1d0dc158jdceb4ff4b426b405@mail.gmail.com> Message-ID: On 4 Nov 2007, at 23:51, Mikel Lindsaar wrote: > The problem I was trying to solve with the mass sender is I only want > to open one connection to the SMTP server, not multiple. I thought I covered that. I didn't mock out the bit that wrapped your existing code: Net::SMTP(@host, @port, @from_domain) do |smtp| # ... previous implementation end So at some point you still need that one connection that gets passed through the rest of the code. Class Spammer holds onto the SMTP but it's a transient object really - I pictured it being made in the Net::SMTP block and discarded, eg: Net::SMTP(@host, @port, @from_domain) do |smtp| Spammer.new(smtp).send(@emails) end Does this help? Ashley -- blog @ http://aviewfromafar.net/ linked-in @ http://www.linkedin.com/in/ashleymoran currently @ work From jimlindley at gmail.com Mon Nov 5 21:00:51 2007 From: jimlindley at gmail.com (Jim Lindley) Date: Mon, 5 Nov 2007 21:00:51 -0500 Subject: [rspec-users] Specifying mixins In-Reply-To: References: <9B6A2746-39BB-4716-9D0B-E56DEE6A1E99@experthuman.com> <8d961d900711011630i7fc4e2aerfbaf157308e666be@mail.gmail.com> Message-ID: <1b165db00711051800g5141228drfedcdac793d93aa3@mail.gmail.com> > > just a short advice: > > > > describe MyModule do > > it "should do something" do > > # The module is automatically mixed into your spec > > end > > end > > > > Aslak > > I suppose it really depends on how static/dynamic the module is. Add an additional describe block for the class that you're including the module into, and then setup a genericly named object in the before block and then include the shared behaviours from the module's spec module. Like this: # page_spec.rb describe Page, "should include publishing features" do include PublishableSpec before(:each) do @model = Page.new(:title => "title", :content => "content", :published => false) end it_should_behave_like "Publishable" # include the shared tests end # post_spec.rb describe Post, "should include publishing features" do include PublishableSpec before(:each) do @model = Post.new(:title => "title", :content => "content", :published => false) end it_should_behave_like "Publishable" # include the shared spec end # publishable_spec.rb module PublishableSpec describe "Publishable", :shared => true do it "should have a published marker" do @model.save! @model.should_not be_published end it "should be publishable" do @model.save.publish! @model.should be_published end end end I can post more if that's unclear (showing the actual AR classes and mixin), but it seems to work well and eliminates duplication. I hope the formatting on this comes through... Jim Lindley http://jimlindley.com From lists at ruby-forum.com Tue Nov 6 03:51:47 2007 From: lists at ruby-forum.com (Karni Karni) Date: Tue, 6 Nov 2007 09:51:47 +0100 Subject: [rspec-users] Test case for file import Message-ID: Hi Friends, I need to write the testcase for fileimport. Pls give me any idea -- Posted via http://www.ruby-forum.com/. From jimlindley at gmail.com Tue Nov 6 07:51:55 2007 From: jimlindley at gmail.com (Jim Lindley) Date: Tue, 6 Nov 2007 07:51:55 -0500 Subject: [rspec-users] Test case for file import In-Reply-To: References: Message-ID: <1b165db00711060451s6d7fdc44he2fffb12c1f74bd7@mail.gmail.com> > > I need to write the testcase for fileimport. > Can you show some of your code that needs to be tested? From dchelimsky at gmail.com Tue Nov 6 08:02:33 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 6 Nov 2007 07:02:33 -0600 Subject: [rspec-users] Test case for file import In-Reply-To: <1b165db00711060451s6d7fdc44he2fffb12c1f74bd7@mail.gmail.com> References: <1b165db00711060451s6d7fdc44he2fffb12c1f74bd7@mail.gmail.com> Message-ID: <57c63afe0711060502m6c92ccdaye78ce6846175fe3f@mail.gmail.com> On Nov 6, 2007 6:51 AM, Jim Lindley wrote: > > > > I need to write the testcase for fileimport. > > > > Can you show some of your code that needs to be tested? Actually, we'd hope that the code doesn't exist yet. This is Behaviour DRIVEN Development, after all. Can you tell us what fileimport is supposed to do? From jimlindley at gmail.com Tue Nov 6 08:54:14 2007 From: jimlindley at gmail.com (Jim Lindley) Date: Tue, 6 Nov 2007 08:54:14 -0500 Subject: [rspec-users] Test case for file import In-Reply-To: <57c63afe0711060502m6c92ccdaye78ce6846175fe3f@mail.gmail.com> References: <1b165db00711060451s6d7fdc44he2fffb12c1f74bd7@mail.gmail.com> <57c63afe0711060502m6c92ccdaye78ce6846175fe3f@mail.gmail.com> Message-ID: <1b165db00711060554m6afc3418q34703319b5e5e8c4@mail.gmail.com> > > Can you show some of your code that needs to be tested? > > Actually, we'd hope that the code doesn't exist yet. This is Behaviour > DRIVEN Development, after all. >  Old habits, my apologies. From tom at experthuman.com Tue Nov 6 09:11:00 2007 From: tom at experthuman.com (Tom Stuart) Date: Tue, 6 Nov 2007 14:11:00 +0000 Subject: [rspec-users] Specifying mixins In-Reply-To: <1b165db00711051800g5141228drfedcdac793d93aa3@mail.gmail.com> References: <9B6A2746-39BB-4716-9D0B-E56DEE6A1E99@experthuman.com> <8d961d900711011630i7fc4e2aerfbaf157308e666be@mail.gmail.com> <1b165db00711051800g5141228drfedcdac793d93aa3@mail.gmail.com> Message-ID: On 6 Nov 2007, at 02:00, Jim Lindley wrote: > Add an additional describe block for the class that you're including > the module into, and then setup a genericly named object in the before > block [...] > > # page_spec.rb > describe Page, "should include publishing features" do > include PublishableSpec > > before(:each) do > @model = Page.new(:title => "title", :content => "content", > :published => false) > end Yeah, this is fine for a simple mixin with only one shared behaviour, but the problem is that a real chunk of mixed-in functionality will probably need many behaviours that correspond to different initial states (provided you're behaving yourself and not doing too much state setup within the individual examples). So, firstly, perhaps I'll have ten shared behaviours to specify my mixin -- do I have ten calls to it_should_behave_like in the spec for each target class? And secondly, perhaps each of those shared behaviours is talking about an object with different initial state, e.g. constructed with different arguments (a published thing, an unpublished thing, a published but deleted thing) -- how do I arrange for that to happen? Ten corresponding behaviours each containing the appropriate before(:each) and a call to it_should_behave_like? Or arrange for the shared behaviours to somehow do the initialisation themselves, e.g. by doing some kind of parameterized helper gymnastics where you pass in the child class object and the shared behaviour calls #new on it? None of this is impossible to do, it's just that it all feels very repetitious and difficult in contrast to the elegant solutions that people often post here. I'm hoping that this sort of "okay, you understand the basics, but NOW what?" issue is the kind of thing that the hotly-anticipated RSpec book will address, because any information about best practice in this area is really lacking, but I fear it might not be that kind of book! Cheers, -Tom From dchelimsky at gmail.com Tue Nov 6 09:39:19 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 6 Nov 2007 08:39:19 -0600 Subject: [rspec-users] Specifying mixins In-Reply-To: References: <9B6A2746-39BB-4716-9D0B-E56DEE6A1E99@experthuman.com> <8d961d900711011630i7fc4e2aerfbaf157308e666be@mail.gmail.com> <1b165db00711051800g5141228drfedcdac793d93aa3@mail.gmail.com> Message-ID: <57c63afe0711060639g3d642b59j96be1986cc286b4d@mail.gmail.com> On Nov 6, 2007 8:11 AM, Tom Stuart wrote: > On 6 Nov 2007, at 02:00, Jim Lindley wrote: > > Add an additional describe block for the class that you're including > > the module into, and then setup a genericly named object in the before > > block > [...] > > > > # page_spec.rb > > describe Page, "should include publishing features" do > > include PublishableSpec > > > > before(:each) do > > @model = Page.new(:title => "title", :content => "content", > > :published => false) > > end > > Yeah, this is fine for a simple mixin with only one shared behaviour, > but the problem is that a real chunk of mixed-in functionality will > probably need many behaviours that correspond to different initial > states (provided you're behaving yourself and not doing too much state > setup within the individual examples). > > So, firstly, perhaps I'll have ten shared behaviours to specify my > mixin -- do I have ten calls to it_should_behave_like in the spec for > each target class? > > And secondly, perhaps each of those shared behaviours is talking about > an object with different initial state, e.g. constructed with > different arguments (a published thing, an unpublished thing, a > published but deleted thing) -- how do I arrange for that to happen? > Ten corresponding behaviours each containing the appropriate > before(:each) and a call to it_should_behave_like? Or arrange for the > shared behaviours to somehow do the initialisation themselves, e.g. by > doing some kind of parameterized helper gymnastics where you pass in > the child class object and the shared behaviour calls #new on it? > > None of this is impossible to do, it's just that it all feels very > repetitious and difficult in contrast to the elegant solutions that > people often post here. There really isn't a great solution for this problem right now, but there are a few initiatives that will be helpful in getting us there. Nested specs, classes/methods (as an alternative to describe/it), turning examples into methods (so they can get overridden), etc, etc. > I'm hoping that this sort of "okay, you > understand the basics, but NOW what?" issue is the kind of thing that > the hotly-anticipated RSpec book will address, because any information > about best practice in this area is really lacking, but I fear it > might not be that kind of book! Well - there will be some of that, and we'll certainly consider including something about this issue. It's fairly common. Cheers, David > > Cheers, > -Tom > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jimlindley at gmail.com Tue Nov 6 09:40:19 2007 From: jimlindley at gmail.com (Jim Lindley) Date: Tue, 6 Nov 2007 09:40:19 -0500 Subject: [rspec-users] Specifying mixins In-Reply-To: References: <9B6A2746-39BB-4716-9D0B-E56DEE6A1E99@experthuman.com> <8d961d900711011630i7fc4e2aerfbaf157308e666be@mail.gmail.com> <1b165db00711051800g5141228drfedcdac793d93aa3@mail.gmail.com> Message-ID: <1b165db00711060640h51330b63kad626119ef02f71a@mail.gmail.com> > Yeah, this is fine for a simple mixin with only one shared behaviour, > but the problem is that a real chunk of mixed-in functionality will > probably need many behaviours that correspond to different initial > states (provided you're behaving yourself and not doing too much state > setup within the individual examples). > Tom, there is likely a better path then the one I'm going down, and I would love to hear it. I am no RSpec expert. How big are the modules you're including? For the modules I do this with it doesn't seem to get out of hand. The example I gave above was a simplifed version of a module spec, not the whole thing. The real one has many more behaviour blocks, and in the before block a couple hashes for use inside the module spec for creating other scenarios. I'm not doing much setup inside the module spec. If the module has a couple aspects to its behaviour I usually end up with just 2 or 3 describe blocks each with about 20 it blocks, and testing its inclusion into AR classes just needs a before block setting up a half dozen objects. If it's getting too complicated to spec out maybe the module is doing too much and should be split up? Jim From tom at experthuman.com Tue Nov 6 10:21:05 2007 From: tom at experthuman.com (Tom Stuart) Date: Tue, 6 Nov 2007 15:21:05 +0000 Subject: [rspec-users] Specifying mixins In-Reply-To: <57c63afe0711060639g3d642b59j96be1986cc286b4d@mail.gmail.com> References: <9B6A2746-39BB-4716-9D0B-E56DEE6A1E99@experthuman.com> <8d961d900711011630i7fc4e2aerfbaf157308e666be@mail.gmail.com> <1b165db00711051800g5141228drfedcdac793d93aa3@mail.gmail.com> <57c63afe0711060639g3d642b59j96be1986cc286b4d@mail.gmail.com> Message-ID: On 6 Nov 2007, at 14:39, David Chelimsky wrote: >> I'm hoping that this sort of "okay, you >> understand the basics, but NOW what?" issue is the kind of thing that >> the hotly-anticipated RSpec book will address, because any >> information >> about best practice in this area is really lacking > Well - there will be some of that, and we'll certainly consider > including something about this issue. It's fairly common. Great! My personal experience has been that the nuts and bolts of RSpec are pretty easy to pick up from the really rather good online documentation -- it's the details of how to actually apply this stuff to real projects that gets people confused about what "the right way" is. (Witness the many discussions about how to spec ActiveRecord validations, etc.) Obviously a lot of this stuff is a matter of opinion and design preference rather than cold mathematical fact, but someone putting a stake in the ground and proclaiming a few best practices (at the right level of abstraction, i.e. general enough to be applicable but concrete enough to be useful) would be incredibly welcome. Can't wait! Cheers, -Tom From tom at experthuman.com Tue Nov 6 10:30:46 2007 From: tom at experthuman.com (Tom Stuart) Date: Tue, 6 Nov 2007 15:30:46 +0000 Subject: [rspec-users] Specifying mixins In-Reply-To: <1b165db00711060640h51330b63kad626119ef02f71a@mail.gmail.com> References: <9B6A2746-39BB-4716-9D0B-E56DEE6A1E99@experthuman.com> <8d961d900711011630i7fc4e2aerfbaf157308e666be@mail.gmail.com> <1b165db00711051800g5141228drfedcdac793d93aa3@mail.gmail.com> <1b165db00711060640h51330b63kad626119ef02f71a@mail.gmail.com> Message-ID: <728976E2-6744-4A52-AE96-3B6E8E0AF2CE@experthuman.com> On 6 Nov 2007, at 14:40, Jim Lindley wrote: > Tom, there is likely a better path then the one I'm going down, and I > would love to hear it. I am no RSpec expert. Neither am I! From David's response it sounds as though there isn't a particularly tidy way to solve this problem at the moment, so I guess we just need to muddle along in whatever way works. > How big are the modules you're including? > For the modules I do this with it doesn't seem to get out of hand. > If it's getting too complicated to spec out maybe the module is doing > too much and should be split up? Possibly, but the proliferation of behaviours is mostly due to following Dave Astels' "one expectation per example" guideline (http://daveastels.com/2006/08/26/one-expectation-per-example-a-remake-of-one-assertion-per-test/ ), which actually works out really well for regular specs, making them easier to write and understand. It's just the impedance mismatch between this particular practice (i.e. split up big behaviours into lots of smaller ones) and RSpec's limited support for sharing behaviours (i.e. you can't group them together or supply parameters when referencing them) that causes the hassle, rather than (necessarily) a large or complicated mixin module. Cheers, -Tom From lists at ruby-forum.com Tue Nov 6 13:56:58 2007 From: lists at ruby-forum.com (Chris Olsen) Date: Tue, 6 Nov 2007 19:56:58 +0100 Subject: [rspec-users] Why is this view spec failing? Message-ID: <4d6e9be9e8b5d88afc6f23de1a46e489@ruby-forum.com> I can't figure out why I am getting a failure. It renders out fine in the browser.

New member

<%= error_messages_for :member %> <% form_for(:member, :url => members_path) do |f| %>
Member Info

<%= f.text_field :first_name %>

<%= f.text_field :last_name %>

<%= submit_tag "Create" %>

<% end %> <%= link_to 'Back', members_path %> ************* ActionView::TemplateError in '/members/new.rhtml should render new form' Mock 'Member_1002' received unexpected message :first_name with (no args) On line #9 of app/views/members/new.rhtml 6: 7:
8: Member Info 9:

<%= f.text_field :first_name %>

10:

<%= f.text_field :last_name %>

11:
12: #{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/mocks/error_generator.rb:52:in `__raise' #{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/mocks/error_generator.rb:16:in `raise_unexpected_message_error' #{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/mocks/proxy.rb:83:in `raise_unexpected_message_error' #{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/mocks/mock.rb:20:in `method_missing' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_helper.rb:356:in `send' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_helper.rb:356:in `value_before_type_cast' *************** This is using the auto-created test it "should render new form" do render "/members/new.rhtml" response.should have_tag("form[action=?][method=post]", members_path) do end end Thanks for the help -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Tue Nov 6 14:24:16 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 6 Nov 2007 13:24:16 -0600 Subject: [rspec-users] Why is this view spec failing? In-Reply-To: <4d6e9be9e8b5d88afc6f23de1a46e489@ruby-forum.com> References: <4d6e9be9e8b5d88afc6f23de1a46e489@ruby-forum.com> Message-ID: <57c63afe0711061124y3b5000b8y82207d943a0a8a86@mail.gmail.com> On Nov 6, 2007 12:56 PM, Chris Olsen wrote: > I can't figure out why I am getting a failure. It renders out fine in > the browser. > >

New member

> > <%= error_messages_for :member %> > > <% form_for(:member, :url => members_path) do |f| %> > >
> Member Info >

<%= > f.text_field :first_name %>

>

<%= > f.text_field :last_name %>

>
> >

> <%= submit_tag "Create" %> >

> <% end %> > <%= link_to 'Back', members_path %> > > ************* > ActionView::TemplateError in '/members/new.rhtml should render new form' > Mock 'Member_1002' received unexpected message :first_name with (no > args) This error is telling you exactly why it's failing. The mock name "Member_1002" that I'm assuming gets created in the spec (please post before(:each) in the future for clarity) is being sent :first_name by the code invoked by t.text_field. Assuming (again) that it is called @member: @member.stub!(:first_name).and_return("Chris") should solve the problem. Cheers, David > On line #9 of app/views/members/new.rhtml > > 6: > 7:
> 8: Member Info > 9:

<%= > f.text_field :first_name %>

> 10:

<%= > f.text_field :last_name %>

> 11:
> 12: > > #{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/mocks/error_generator.rb:52:in > `__raise' > #{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/mocks/error_generator.rb:16:in > `raise_unexpected_message_error' > #{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/mocks/proxy.rb:83:in > `raise_unexpected_message_error' > #{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/mocks/mock.rb:20:in > `method_missing' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_helper.rb:356:in > `send' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_helper.rb:356:in > `value_before_type_cast' > > *************** > This is using the auto-created test > > it "should render new form" do > render "/members/new.rhtml" > > response.should have_tag("form[action=?][method=post]", > members_path) do > end > end > > Thanks for the help > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Tue Nov 6 14:56:33 2007 From: lists at ruby-forum.com (Chris Olsen) Date: Tue, 6 Nov 2007 20:56:33 +0100 Subject: [rspec-users] Why is this view spec failing? In-Reply-To: <57c63afe0711061124y3b5000b8y82207d943a0a8a86@mail.gmail.com> References: <4d6e9be9e8b5d88afc6f23de1a46e489@ruby-forum.com> <57c63afe0711061124y3b5000b8y82207d943a0a8a86@mail.gmail.com> Message-ID: <615be70b54cc9c37e6b5581fbbbd80ab@ruby-forum.com> Thanks for the help David. -- Posted via http://www.ruby-forum.com/. From sross at calicowebdev.com Tue Nov 6 17:18:23 2007 From: sross at calicowebdev.com (Steve Ross) Date: Tue, 6 Nov 2007 14:18:23 -0800 Subject: [rspec-users] Keeping Up with Trunk Message-ID: I have a project with rspec installed as a plugin using svn:externals. Here are my externals: rspec_on_rails svn://rubyforge.org/var/svn/rspec/trunk/ rspec_on_rails rspec svn://rubyforge.org/var/svn/rspec/trunk/ rspec I just did an svn up on both and now have a version mismatch: ######################################################################## #### Your RSpec on Rails plugin is incompatible with your installed RSpec. RSpec : 1.1.0 (r2804) RSpec on Rails : r2817 Make sure your RSpec on Rails plugin is compatible with your RSpec gem. See http://rspec.rubyforge.org/documentation/rails/install.html for details. ######################################################################## #### Any idea why this might be happening? From sross at calicowebdev.com Tue Nov 6 17:18:23 2007 From: sross at calicowebdev.com (Steve Ross) Date: Tue, 6 Nov 2007 14:18:23 -0800 Subject: [rspec-users] Keeping Up with Trunk Message-ID: I have a project with rspec installed as a plugin using svn:externals. Here are my externals: rspec_on_rails svn://rubyforge.org/var/svn/rspec/trunk/ rspec_on_rails rspec svn://rubyforge.org/var/svn/rspec/trunk/ rspec I just did an svn up on both and now have a version mismatch: ######################################################################## #### Your RSpec on Rails plugin is incompatible with your installed RSpec. RSpec : 1.1.0 (r2804) RSpec on Rails : r2817 Make sure your RSpec on Rails plugin is compatible with your RSpec gem. See http://rspec.rubyforge.org/documentation/rails/install.html for details. ######################################################################## #### Any idea why this might be happening? From dchelimsky at gmail.com Tue Nov 6 18:01:19 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 6 Nov 2007 17:01:19 -0600 Subject: [rspec-users] Keeping Up with Trunk In-Reply-To: References: Message-ID: <57c63afe0711061501i648dd58bv39679293c0865094@mail.gmail.com> On Nov 6, 2007 4:18 PM, Steve Ross wrote: > I have a project with rspec installed as a plugin using > svn:externals. Here are my externals: > > rspec_on_rails svn://rubyforge.org/var/svn/rspec/trunk/ > rspec_on_rails > rspec svn://rubyforge.org/var/svn/rspec/trunk/ > rspec > > I just did an svn up on both and now have a version mismatch: > > ######################################################################## > #### > Your RSpec on Rails plugin is incompatible with your installed RSpec. > > RSpec : 1.1.0 (r2804) > RSpec on Rails : r2817 > > Make sure your RSpec on Rails plugin is compatible with your RSpec gem. > See http://rspec.rubyforge.org/documentation/rails/install.html for > details. > ######################################################################## > #### > > Any idea why this might be happening? I get 2817 for both. Not sure why you're experiencing this. From cwdinfo at gmail.com Tue Nov 6 18:06:29 2007 From: cwdinfo at gmail.com (s.ross) Date: Tue, 6 Nov 2007 15:06:29 -0800 Subject: [rspec-users] Keeping Up with Trunk In-Reply-To: <57c63afe0711061501i648dd58bv39679293c0865094@mail.gmail.com> References: <57c63afe0711061501i648dd58bv39679293c0865094@mail.gmail.com> Message-ID: <6248655C-284B-45AA-ADFB-42A001E890BB@gmail.com> I've been having good luck with this up to now, but then got a mismatch today. It seems the svn servers on Rubyforge have been a bit spotty -- or at least that's how it seems. They have been closing connections and maybe that's how I got out of sync. Thx On Nov 6, 2007, at 3:01 PM, David Chelimsky wrote: > On Nov 6, 2007 4:18 PM, Steve Ross wrote: >> I have a project with rspec installed as a plugin using >> svn:externals. Here are my externals: >> >> rspec_on_rails svn://rubyforge.org/var/svn/rspec/ >> trunk/ >> rspec_on_rails >> rspec svn://rubyforge.org/var/svn/rspec/ >> trunk/ >> rspec >> >> I just did an svn up on both and now have a version mismatch: >> >> ##################################################################### >> ### >> #### >> Your RSpec on Rails plugin is incompatible with your installed RSpec. >> >> RSpec : 1.1.0 (r2804) >> RSpec on Rails : r2817 >> >> Make sure your RSpec on Rails plugin is compatible with your RSpec >> gem. >> See http://rspec.rubyforge.org/documentation/rails/install.html for >> details. >> ##################################################################### >> ### >> #### >> >> Any idea why this might be happening? > > I get 2817 for both. Not sure why you're experiencing this. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Wed Nov 7 00:39:00 2007 From: lists at ruby-forum.com (Chris Olsen) Date: Wed, 7 Nov 2007 06:39:00 +0100 Subject: [rspec-users] Unexplainable failure...at least for me Message-ID: <923c372bc0abecd7fd5365deaa687634@ruby-forum.com> I have an address model with country_id and province_id fields There is also a full_address method that returns an address that is in a format that the google maps api will be able to return a long-lat coords. Within the full_address method there is a call to obtain the province/state and country name. --------- def full_address ... full_address = [city, self.province.name, self.country.name].join(",").chomp(",") .. end When I run this in the console it works fine >> a = Address.new => #nil, "latitude"=>nil, "region_code"=>nil, "province_id"=>nil, "country_id"=>nil, "location_type"=>nil, "location_id"=>nil, "address_1"=>nil, "address_2"=>nil, "longitude"=>nil, "address_3"=>nil, "address_4"=>nil}> >> a.country_id = 1 => 1 >> a.country.name => "Canada" >> a.province_id = 1 => 1 >> a.full_address => ",,Alberta,Canada" but when the specs are run I get errors saying that the country and province object properties are null 11) NoMethodError in 'Address additional properties should ensure spacing between the st/ave on the address' You have a nil object when you didn't expect it! The error occurred while evaluating nil.name /Users/chris/Documents/Projects/Rails/MyProject/trunk/config/../app/models/address.rb:25:in `full_address' ./spec/models/address_spec.rb:66: script/spec:4: Here is one of the tests that fail: describe Address, "additional properties" do before(:each) do @address = Address.new(valid_params) end def valid_params { :country_id => 1, :province_id => 1, :region_code => "T5Z3J4", :address_1 => "13245-56 st", :address_2 => "NW", :city => "Edmonton" } end it "should return the full address format" do @address.country_id.should == 1 #this passes @address.province_id.should == 1 #this passes @address.province.name.should == "Alberta" #this fails @address.country.name.should == "Canada" #this fails @address.full_address.should == "13245-56 st NW,Edmonton,Alberta,Canada" #and this fails if you remove the ones above end class Address < ActiveRecord::Base belongs_to :province belongs_to :country class Country < ActiveRecord::Base has_one :address If I wasn't able to make it happen in the console, it would make more sense, but seeing as I can I am totally lost. Thanks for the help -- Posted via http://www.ruby-forum.com/. From hans at degraaff.org Wed Nov 7 01:49:17 2007 From: hans at degraaff.org (Hans de Graaff) Date: Wed, 07 Nov 2007 07:49:17 +0100 Subject: [rspec-users] Unexplainable failure...at least for me In-Reply-To: <923c372bc0abecd7fd5365deaa687634@ruby-forum.com> References: <923c372bc0abecd7fd5365deaa687634@ruby-forum.com> Message-ID: <1194418157.4461.5.camel@ip6-localhost> On Wed, 2007-11-07 at 06:39 +0100, Chris Olsen wrote: > but when the specs are run I get errors saying that the country and > province object properties are null > 11) > NoMethodError in 'Address additional properties should ensure spacing > between the st/ave on the address' > You have a nil object when you didn't expect it! > The error occurred while evaluating nil.name > /Users/chris/Documents/Projects/Rails/MyProject/trunk/config/../app/models/address.rb:25:in > `full_address' > ./spec/models/address_spec.rb:66: > script/spec:4: > > Here is one of the tests that fail: > describe Address, "additional properties" do > > before(:each) do > @address = Address.new(valid_params) > end > > def valid_params > { > :country_id => 1, > :province_id => 1, > :region_code => "T5Z3J4", > :address_1 => "13245-56 st", > :address_2 => "NW", > :city => "Edmonton" > } > end The question is where this country and province with id 1 are defined. I don't see anything in your spec to indicate that they are ever created. If you are using fixtures then you'll need to explicitly include them. Otherwise they may or may not still be loaded in the test database and at best you'll get a clear failure and at worst inconsistent results. describe Address do fixtures :provinces, countries before ... etc Kind regards, Hans -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://rubyforge.org/pipermail/rspec-users/attachments/20071107/3f85bb78/attachment.bin From peter_marklund at fastmail.fm Wed Nov 7 04:33:58 2007 From: peter_marklund at fastmail.fm (Peter Marklund) Date: Wed, 7 Nov 2007 10:33:58 +0100 Subject: [rspec-users] Helper methods starting with should_ get picked up as examples? Message-ID: <952F1F72-0F69-4A30-AC10-724F66857C4C@fastmail.fm> Hi! I recently updated my rspec and rspec_on_rails plugins to the tip of the trunk and ran into an issue with helper methods with names starting with should_ in my describe blocks. Fictive example to show what I'm talking about: describe Order do it "Can be paid for" do ... should_have_paid(user) end def should_have_paid(user) end end I know in some places I should (ah, there is that word again...) be using custom matchers when I'm being lazy and instead just defining methods. Anyway, it seems RSpec picks up methods starting with should_ as examples. Here is some debug output that I generated for a method called should_have_emailed: #, @from="/Users/peter/src/gear/specialist/ vendor/plugins/rspec/lib/spec/dsl/example.rb:22:in `each'", @description="should_have_emailed", @options={}> Is this itentional behaviour by RSpec or some weird side effect? Cheers Peter ---------------------------- Peter Marklund Garvar Lundins Gr?nd 7 11220 Stockholm Sweden Mobile Phone: +46-(0)70-4164857 Home Phone: +46-(0)8-50091315 Skype: peter_marklund IM: AIM - petermarklund, MSN - peter_marklund at hotmail.com, Yahoo - peter_marklund2002 http://marklunds.com ---------------------------- From dchelimsky at gmail.com Wed Nov 7 09:35:46 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 7 Nov 2007 08:35:46 -0600 Subject: [rspec-users] Helper methods starting with should_ get picked up as examples? In-Reply-To: <952F1F72-0F69-4A30-AC10-724F66857C4C@fastmail.fm> References: <952F1F72-0F69-4A30-AC10-724F66857C4C@fastmail.fm> Message-ID: <57c63afe0711070635m9af1bfegb71307154cc3d64f@mail.gmail.com> On Nov 7, 2007 3:33 AM, Peter Marklund wrote: > Hi! > I recently updated my rspec and rspec_on_rails plugins to the tip of > the trunk and ran into an issue with helper methods with names > starting with should_ in my describe blocks. Fictive example to show > what I'm talking about: > > describe Order do > it "Can be paid for" do > ... > should_have_paid(user) > end > > def should_have_paid(user) > > end > end > > I know in some places I should (ah, there is that word again...) be > using custom matchers when I'm being lazy and instead just defining > methods. Anyway, it seems RSpec picks up methods starting with > should_ as examples. Here is some debug output that I generated for a > method called should_have_emailed: > > # 0x003f0250@/Users/peter/src/gear/specialist/vendor/plugins/rspec/lib/ > spec/dsl/example.rb:27>, @from="/Users/peter/src/gear/specialist/ > vendor/plugins/rspec/lib/spec/dsl/example.rb:22:in `each'", > @description="should_have_emailed", @options={}> > > Is this itentional behaviour by RSpec or some weird side effect? That's actually by design. There are many projects that would like to move to rspec but don't because the transition cost is too high. There are also a number of people who have said the lack of a clear class/method structure keeps them away. Supporting methods that start with should_ is part of an effort to resolve these conflicts. As things stand in trunk today, you can more or less use your choices from the following class FooTest < Test::Unit::TestCase class FooExamples < Spec::ExampleGroup describe Foo do def test_should_bar def should_bar it "should bar" do assert_equal "baz", foo.bar foo.bar.should == "baz" Sorry about the trouble w/ existing helper methods, but we feel this is the best path forward. Cheers, David From lists at ruby-forum.com Wed Nov 7 09:49:12 2007 From: lists at ruby-forum.com (Chris Olsen) Date: Wed, 7 Nov 2007 15:49:12 +0100 Subject: [rspec-users] Unexplainable failure...at least for me In-Reply-To: <1194418157.4461.5.camel@ip6-localhost> References: <923c372bc0abecd7fd5365deaa687634@ruby-forum.com> <1194418157.4461.5.camel@ip6-localhost> Message-ID: <993c0936bdf4e744ba105558327cd8de@ruby-forum.com> That is the problem, which is clear now that I tested it with the script/console in test mode rather than development. So now the question is, why does the data not exist in the test database. The country and province data inserts exist within the migration files, ex for countries: class CreateCountries < ActiveRecord::Migration def self.up create_table :countries do |t| t.column :country_id, :integer t.column :name2, :string, :limit => 2 t.column :name3, :string, :limit => 3 t.column :name, :string t.column :district_name, :string t.column :code_name, :string t.column :strength, :integer end country_data = [ [124, 'CA', 'CAN', 'Canada', 'Province', 'Postal Code', 100], [840, 'US', 'USA', 'United States', 'State', 'ZipCode', 50], #along with many other countries ].each do |c| insert_params = { :country_id => c[0], :name2 => c[1], :name3 => c[2], :name => c[3], :district_name => c[4], :code_name => c[5], :strength => c[6] } Country.create(insert_params) end end Thanks for the help. > The question is where this country and province with id 1 are defined. I > don't see anything in your spec to indicate that they are ever created. > If you are using fixtures then you'll need to explicitly include them. > Otherwise they may or may not still be loaded in the test database and > at best you'll get a clear failure and at worst inconsistent results. > > describe Address do > fixtures :provinces, countries > > before ... etc > > Kind regards, > > Hans -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Nov 7 09:54:23 2007 From: lists at ruby-forum.com (Chris Olsen) Date: Wed, 7 Nov 2007 15:54:23 +0100 Subject: [rspec-users] Unexplainable failure...at least for me In-Reply-To: <993c0936bdf4e744ba105558327cd8de@ruby-forum.com> References: <923c372bc0abecd7fd5365deaa687634@ruby-forum.com> <1194418157.4461.5.camel@ip6-localhost> <993c0936bdf4e744ba105558327cd8de@ruby-forum.com> Message-ID: <5cc30e942a2f9b9c8aa5154043a7bc20@ruby-forum.com> Chris Olsen wrote: > That is the problem, which is clear now that I tested it with the > script/console in test mode rather than development. > > So now the question is, why does the data not exist in the test > database. The country and province data inserts exist within the > migration files, ex for countries: > > class CreateCountries < ActiveRecord::Migration > def self.up > create_table :countries do |t| > t.column :country_id, :integer > t.column :name2, :string, :limit => 2 > t.column :name3, :string, :limit => 3 > t.column :name, :string > t.column :district_name, :string > t.column :code_name, :string > t.column :strength, :integer > end > > country_data = [ > [124, 'CA', 'CAN', 'Canada', 'Province', 'Postal Code', 100], > [840, 'US', 'USA', 'United States', 'State', 'ZipCode', 50], > #along with many other countries > ].each do |c| > > insert_params = { > :country_id => c[0], > :name2 => c[1], > :name3 => c[2], > :name => c[3], > :district_name => c[4], > :code_name => c[5], > :strength => c[6] > } > > Country.create(insert_params) > end > end > > Thanks for the help. I should mention that the test database is cloned properly with the script: task :reset_databases do system "mysqladmin -u root drop MyDB_development" system "mysqladmin -u root drop MyDB_test" system "mysqladmin -u root create MyDB_development" system "mysqladmin -u root create MyDB_test" system "rake db:migrate" system "rake db:test:clone_structure" end script/console test >> Country.find(:all) => [] -- Posted via http://www.ruby-forum.com/. From tom at experthuman.com Wed Nov 7 09:54:36 2007 From: tom at experthuman.com (Tom Stuart) Date: Wed, 7 Nov 2007 14:54:36 +0000 Subject: [rspec-users] Unexplainable failure...at least for me In-Reply-To: <993c0936bdf4e744ba105558327cd8de@ruby-forum.com> References: <923c372bc0abecd7fd5365deaa687634@ruby-forum.com> <1194418157.4461.5.camel@ip6-localhost> <993c0936bdf4e744ba105558327cd8de@ruby-forum.com> Message-ID: <59386BD2-0B53-4B08-8348-DF536497B5C1@experthuman.com> On 7 Nov 2007, at 14:49, Chris Olsen wrote: > So now the question is, why does the data not exist in the test > database. The country and province data inserts exist within the > migration files, ex for countries: As someone who knows literally nothing about how this all works, I still feel confident enough to guess that RSpec doesn't actually run any migrations, but rather just clones the schema of the existing development database -- so you get something that looks the same but contains no data. As the previous poster mentioned, you need to put the data into fixtures and include them; see http://rspec.rubyforge.org/documentation/rails/writing/models.html for examples. Cheers, -Tom From lists at ruby-forum.com Wed Nov 7 10:00:04 2007 From: lists at ruby-forum.com (Chris Olsen) Date: Wed, 7 Nov 2007 16:00:04 +0100 Subject: [rspec-users] Unexplainable failure...at least for me In-Reply-To: <59386BD2-0B53-4B08-8348-DF536497B5C1@experthuman.com> References: <923c372bc0abecd7fd5365deaa687634@ruby-forum.com> <1194418157.4461.5.camel@ip6-localhost> <993c0936bdf4e744ba105558327cd8de@ruby-forum.com> <59386BD2-0B53-4B08-8348-DF536497B5C1@experthuman.com> Message-ID: <945b9ee49d2df973702f9c1f5b6b88b2@ruby-forum.com> That would make sense. Thanks for the help. -- Posted via http://www.ruby-forum.com/. From harmaarts at gmail.com Wed Nov 7 11:25:02 2007 From: harmaarts at gmail.com (Harm Aarts) Date: Wed, 7 Nov 2007 17:25:02 +0100 Subject: [rspec-users] RSpec, RESTful nested routes and :path_prefix Message-ID: <8B60AB1F-449C-4AD8-BE95-4E6C4D60A477@gmail.com> I think I did not express myself clear enough. The problem is that in my spec I can not get the 'post' and 'get' methods to correctly contact(by lack of a better word) the corresponding actions. I believe this has to do with the fact that I use a :path_prefix. So I would like this: > it "GET 'index' should be successful" do > get 'index', :project_id => 1 > response.should be_success > end To become something like: > it "GET 'index' should be successful" do > get 'index', :project_id => , :path_prefix => '/wiki' > response.should be_success > end But that obviously does not work. More importantly I do not believe I should be repeating myself with these path_prefixes. I suspect that RSpec is ignoring the :path_prefix in my routes.rb file. With kind regards, Harm From ben at benmabey.com Wed Nov 7 12:31:45 2007 From: ben at benmabey.com (Ben Mabey) Date: Wed, 07 Nov 2007 10:31:45 -0700 Subject: [rspec-users] LoadError when upgraded to latest rspec trunk Message-ID: <4731F681.2010900@benmabey.com> I just moved my rspec and rspec_on_rails plugin from r2691 to r2822. After that I upgraded both of them I regenerated all things rspec with the rspec generator. I was running on rails r2691 but upgraded to the latest at r2822 when I was getting errors but that still didn't help things. I get the following when I try to run a spec with either rake spec or ./script/spec: /app/trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:249:in `load_missing_constant': Expected /app/trunk/vendor/plugins/rspec/lib/spec/test.rb to define Spec::Test (LoadError) from /app/trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:453:in `const_missing' from /app/trunk/vendor/plugins/rspec_on_rails_old/lib/spec/rails/dsl/behaviour/rails_example.rb:6 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from /app/trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' from /app/trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in' from /app/trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' from /app/trunk/vendor/plugins/rspec_on_rails_old/lib/spec/rails/dsl/behaviour.rb:2 ... 24 levels... from /app/trunk/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:13:in `load_files' from /app/trunk/vendor/plugins/rspec/lib/spec/runner/options.rb:75:in `run_examples' from /app/trunk/vendor/plugins/rspec/lib/spec/runner/command_line.rb:21:in `run' from ./script/spec:4 Any ideas on what might be wrong? I looked at that file and all it seems to be doing is requiring other files. I'm going to start a project from scratch to see if I can reproduce the error and see if I can narrow it down to being app specidic.. But has anyone had similar problems? Thanks, Ben From dchelimsky at gmail.com Wed Nov 7 12:46:15 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 7 Nov 2007 11:46:15 -0600 Subject: [rspec-users] LoadError when upgraded to latest rspec trunk In-Reply-To: <4731F681.2010900@benmabey.com> References: <4731F681.2010900@benmabey.com> Message-ID: <57c63afe0711070946i490dc52ewb54483ac0410eab1@mail.gmail.com> On Nov 7, 2007 11:31 AM, Ben Mabey wrote: > I just moved my rspec and rspec_on_rails plugin from r2691 to r2822. > After that I upgraded both of them I regenerated all things rspec with > the rspec generator. I was running on rails r2691 but upgraded to the > latest at r2822 when I was getting errors but that still didn't help things. I'm on rspec 2822 and rails 8111 and do not have this trouble. > > I get the following when I try to run a spec with either rake spec or > ./script/spec: > > /app/trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:249:in > `load_missing_constant': Expected > /app/trunk/vendor/plugins/rspec/lib/spec/test.rb to define Spec::Test > (LoadError) > from > /app/trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:453:in > `const_missing' > from > /app/trunk/vendor/plugins/rspec_on_rails_old/lib/spec/rails/dsl/behaviour/rails_example.rb:6 > from > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require' > from > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' > from > /app/trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in > `require' > from > /app/trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in > `new_constants_in' > from > /app/trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in > `require' > from > /app/trunk/vendor/plugins/rspec_on_rails_old/lib/spec/rails/dsl/behaviour.rb:2 > ... 24 levels... > from > /app/trunk/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:13:in > `load_files' > from > /app/trunk/vendor/plugins/rspec/lib/spec/runner/options.rb:75:in > `run_examples' > from > /app/trunk/vendor/plugins/rspec/lib/spec/runner/command_line.rb:21:in `run' > from ./script/spec:4 > > > Any ideas on what might be wrong? I looked at that file and all it > seems to be doing is requiring other files. I'm going to start a > project from scratch to see if I can reproduce the error and see if I > can narrow it down to being app specidic.. But has anyone had similar > problems? > > Thanks, > Ben > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mailing_lists at railsnewbie.com Wed Nov 7 14:21:19 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 7 Nov 2007 14:21:19 -0500 Subject: [rspec-users] Named routes raising nil.rewrite error Message-ID: <439456E7-AB76-434C-8052-34EFBC38C269@railsnewbie.com> Hi all. I'm having a little problem with named routes. I have the following named route: map.with_options :controller => 'snippets' do |map| map.snippets 'faq/', :action => 'index' map.new_snippet 'faq/ new', :action => 'new' map.snippet_text 'faq/ get/:id', :action => 'get_snippet_text' map.set_snippet 'faq/ set/:id', :action => 'set_snippet_text' map.snippet 'faq/:id', :action => 'show' map.snippet_version 'faq/:id/version/:version', :action => 'version' map.revert_snippet 'faq/:id/version/:version/revert', :action => 'revert' end When trying to write the following spec (a regression), I get the error: ======================================== describe SnippetsController, "routes" do it "should route the snippet_version_url to the version action" do snippet_version_url(:id => "1", :version => "41").should == "/foo" end end ======================================== escher: ./script/spec spec/controllers/regressions/ 2007_11_07_snippets_route_spec.rb F 1) NoMethodError in 'SnippetsController routes should route the snippet_version_url to the version action' You have a nil object when you didn't expect it! The error occurred while evaluating nil.rewrite (eval):19:in `snippet_version_url' ./spec/controllers/regressions/2007_11_07_snippets_route_spec.rb:277: ./script/spec:4: Finished in 0.029341 seconds 1 example, 1 failure ======================================== Should I be using route_for here? I've noticed that the following spec fails: ======================================== describe SnippetsController, "routes" do it "should not raise an error with the snippet_version_url route" do lambda { snippet_version_url }.should_not raise_error end end escher: ./script/spec spec/controllers/regressions/ 2007_11_07_snippets_route_spec.rb F 1) 'SnippetsController routes should not raise an error with the snippet_version_url route' FAILED expected no Exception, got # ./spec/controllers/regressions/2007_11_07_snippets_route_spec.rb:281: ./script/spec:4: Finished in 0.029503 seconds 1 example, 1 failure ======================================== Thanks for any help, Scott PS: Running on Rspec edge, rails 1.2.3 From ben at benmabey.com Wed Nov 7 18:21:30 2007 From: ben at benmabey.com (Ben Mabey) Date: Wed, 07 Nov 2007 16:21:30 -0700 Subject: [rspec-users] Plain Text Story example Message-ID: <4732487A.5060309@benmabey.com> Hey all, Does anyone have an example(s) of the plain text story runner for rails? I have read David's blog (http://blog.davidchelimsky.net/articles/2007/10/22/plain-text-stories-on-rails) about it but I would like to see some examples with all of the step matchers included... I couldn't find any more examples on google talking about the plain text stories and the example rails app in trunk seems to still be using the other format. Does anyone have any links or pasties for me? Thanks, Ben From ben at benmabey.com Wed Nov 7 23:18:55 2007 From: ben at benmabey.com (Ben Mabey) Date: Wed, 07 Nov 2007 21:18:55 -0700 Subject: [rspec-users] Plain Text Story example In-Reply-To: <4732487A.5060309@benmabey.com> References: <4732487A.5060309@benmabey.com> Message-ID: <47328E2F.1090103@benmabey.com> I just ran across this blog which helped me out a lot in answering some of my questions about the plain text story runner: http://www.kerrybuckley.com/2007/11/07/driving-selenium-from-the-rspec-story-runner-rbehave/ The Selenium integration is also an interesting idea that you might want to read about if you haven't seen this post. I'm still trying to decided if using Selenium is worth the extra effort (my main goal would be to test the JS during the acceptance tests) and if the regular rails integration testing is good enough. I'd be interested to hear what other user's on this list think in terms of Selenium or any other browser based framework and there experience with them. -Ben Ben Mabey wrote: > Hey all, > Does anyone have an example(s) of the plain text story runner for > rails? I have read David's blog > (http://blog.davidchelimsky.net/articles/2007/10/22/plain-text-stories-on-rails) > about it but I would like to see some examples with all of the step > matchers included... I couldn't find any more examples on google > talking about the plain text stories and the example rails app in trunk > seems to still be using the other format. Does anyone have any links or > pasties for me? Thanks, > Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Nov 8 00:12:28 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 7 Nov 2007 23:12:28 -0600 Subject: [rspec-users] Plain Text Story example In-Reply-To: <47328E2F.1090103@benmabey.com> References: <4732487A.5060309@benmabey.com> <47328E2F.1090103@benmabey.com> Message-ID: <57c63afe0711072112u285a13ecgb56fc416cc300bb7@mail.gmail.com> On Nov 7, 2007 10:18 PM, Ben Mabey wrote: > I just ran across this blog which helped me out a lot in answering some > of my questions about the plain text story runner: > http://www.kerrybuckley.com/2007/11/07/driving-selenium-from-the-rspec-story-runner-rbehave/ It's great to see this conversation advancing so quickly, however please keep in mind that this is all very young and just because someone blog's something (including ME) doesn't mean that it's "the way". While Kerry's example is very clean and obviously works well for him, it does go against the grain of the philosohy that Dan is espousing: expressing stories in the business domain rather than the UI domain (btw Dan, that was brilliantly put). In my own experience with tools like FitNesse, I've seen success and failure regardless of the level or focus of abstraction. In the end, what I think drives the success of tools in this (Acceptance Testing) space is the level of commitment and interaction that customers have with the tools and the stories they are expressing. These are called CUSTOMER Acceptance Tests, after all. And just as TDD is *for* developers, and you're probably doing TDD right if it keeps you productive throughout the life of a project (including the years of maintenance), the same goes for Stories - if the customer gets the way the stories are expressed and you are not finding yourself battling the environment or wasting time debugging your way through a labyrinth of test fixtures every time something changes, then you're probably on to something useful. > > The Selenium integration is also an interesting idea that you might want > to read about if you haven't seen this post. I'm still trying to > decided if using Selenium is worth the extra effort (my main goal would > be to test the JS during the acceptance tests) One cool thing about having the steps disconnected from the expression of the stories is that you can have more than one implementation of any given step and use the one you want based on any arbitrary runtime conditions. There is no direct support for making this decision built into the Story Framework, but this IS Ruby after all. This would theoretically allow you to write stories at an abstract level and decide whether to run each scenario in memory or in a browser based on whether or not there is additional business value in running them in browser. > and if the regular rails > integration testing is good enough. I'd be interested to hear what > other user's on this list think in terms of Selenium or any other > browser based framework and there experience with them. Generally speaking, in-browser tests tend to be incredibly brittle and run dog-slow. They simply have no choice but to be tied directly to low-level implementation details like html structure and element IDs. So I'd recommend only testing what you absolutely must in-browser. But given our ajax-laden world, "what you absolutely must" may well turn out to be a lot! FWIW, David > > -Ben > > > > Ben Mabey wrote: > > Hey all, > > Does anyone have an example(s) of the plain text story runner for > > rails? I have read David's blog > > (http://blog.davidchelimsky.net/articles/2007/10/22/plain-text-stories-on-rails) > > about it but I would like to see some examples with all of the step > > matchers included... I couldn't find any more examples on google > > talking about the plain text stories and the example rails app in trunk > > seems to still be using the other format. Does anyone have any links or > > pasties for me? Thanks, > > Ben > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Thu Nov 8 01:17:55 2007 From: ben at benmabey.com (Ben Mabey) Date: Wed, 07 Nov 2007 23:17:55 -0700 Subject: [rspec-users] Plain Text Story example In-Reply-To: <57c63afe0711072112u285a13ecgb56fc416cc300bb7@mail.gmail.com> References: <4732487A.5060309@benmabey.com> <47328E2F.1090103@benmabey.com> <57c63afe0711072112u285a13ecgb56fc416cc300bb7@mail.gmail.com> Message-ID: <4732AA13.7090107@benmabey.com> David Chelimsky wrote: > On Nov 7, 2007 10:18 PM, Ben Mabey wrote: > >> I just ran across this blog which helped me out a lot in answering some >> of my questions about the plain text story runner: >> http://www.kerrybuckley.com/2007/11/07/driving-selenium-from-the-rspec-story-runner-rbehave/ >> > > It's great to see this conversation advancing so quickly, however > please keep in mind that this is all very young and just because > someone blog's something (including ME) doesn't mean that it's "the > way". While Kerry's example is very clean and obviously works well for > him, it does go against the grain of the philosohy that Dan is > espousing: expressing stories in the business domain rather than the > UI domain (btw Dan, that was brilliantly put). What exactly do you and Dan mean when you say that the stories should be expressed in the business domain rather than the UI domain? (BTW, is there a link to a Dan North post abou that?) From my understanding you are saying that the steps that say "user types in such and such" and user "hits the login button" are too UI specific and don't really have much to do with the business domain. Is that correct? I think that this is a part of writing stories that I am somewhat struggling with, meaning how specific should these stories be in explaining the view? At RubyConf during your presentation (great job, BTW!) you mentioned how you like to spec out your views first. I agree that is is a really nice way to drive the development process. Now with the introduction of the story runner we are now letting the stories drive the process. So my thinking is that you let the stories drive all of the development, including that of the views. Is this assumption wrong? This feels right in one way because I will not be adding a form to a view unless the story specifies it and thereby drives BDD... On the other hand this level of granularity seems a bit overkill and clutters the stories a bit. Where is the happy medium, in your opinion, between keeping the stories concise and letting them drive every aspect of the development? Maybe I am wrong in saying that the stories should drive EVERY aspect of the development? >> The Selenium integration is also an interesting idea that you might want >> to read about if you haven't seen this post. I'm still trying to >> decided if using Selenium is worth the extra effort (my main goal would >> be to test the JS during the acceptance tests) >> > > One cool thing about having the steps disconnected from the expression > of the stories is that you can have more than one implementation of > any given step and use the one you want based on any arbitrary runtime > conditions. There is no direct support for making this decision built > into the Story Framework, but this IS Ruby after all. > > This would theoretically allow you to write stories at an abstract > level and decide whether to run each scenario in memory or in a > browser based on whether or not there is additional business value in > running them in browser. > Yes, good point. The step matchers really do open up a whole new world of possibilities. >> and if the regular rails >> integration testing is good enough. I'd be interested to hear what >> other user's on this list think in terms of Selenium or any other >> browser based framework and there experience with them. >> > > Generally speaking, in-browser tests tend to be incredibly brittle and > run dog-slow. They simply have no choice but to be tied directly to > low-level implementation details like html structure and element IDs. > > So I'd recommend only testing what you absolutely must in-browser. But > given our ajax-laden world, "what you absolutely must" may well turn > out to be a lot! > > FWIW, > David > > > I have heard that Selenium suites can become out of hand and end of being more hassle than what there worth. Thanks for the recommendation, I think that sounds like a sensible one. Thanks for taking the time to discuss this, Ben From dchelimsky at gmail.com Thu Nov 8 06:58:47 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 8 Nov 2007 05:58:47 -0600 Subject: [rspec-users] Plain Text Story example In-Reply-To: <4732AA13.7090107@benmabey.com> References: <4732487A.5060309@benmabey.com> <47328E2F.1090103@benmabey.com> <57c63afe0711072112u285a13ecgb56fc416cc300bb7@mail.gmail.com> <4732AA13.7090107@benmabey.com> Message-ID: <57c63afe0711080358h14379674h5312027beacee697@mail.gmail.com> On Nov 8, 2007 12:17 AM, Ben Mabey wrote: > David Chelimsky wrote: > > ... the philosohy that Dan is > > espousing: expressing stories in the business domain rather than the > > UI domain (btw Dan, that was brilliantly put). > What exactly do you and Dan mean when you say that the stories should be > expressed in the business domain rather than the UI domain? (BTW, is > there a link to a Dan North post abou that?) Sorry - there are two different threads going on about this topic right now - the other one is on the rspec-devel list and that was where Dan posted that statement: http://rubyforge.org/pipermail/rspec-devel/2007-November/004259.html Keep in mind that User Stories are oft described as "a token for a conversation", and that even with acceptance criteria spelled out, whether the button says "Create New Account" or "Enter" is rarely of sufficient business value to express that in a story. That's the sort of detail that comes out when you say to your customer "the entry form is done, why don't you come by so I can show it to you," as opposed to in the iteration planning meeting. In the end it really does boil down to what the customer feels is necessary in order to accept the software. If the customer really DOES care about what the button says, he or she may want that expressed in a story. But even then, saying "And I press Create New Account" still leaves things flexible enough so that you could be describing a web app, a GUI app, a touch-screen app, etc. The only thing this doesn't work for would be a command line app. So maybe "And I tell the system to Create New Account" would leave room for that as well. Or maybe, "And I fold my arms and command the system to Create New Account." I kinda like that one! > From my understanding you > are saying that the steps that say "user types in such and such" and > user "hits the login button" are too UI specific and don't really have > much to do with the business domain. Is that correct? Unless the business IS software, like a text editor, yes. > I think that this is a part of writing stories that I am somewhat > struggling with, meaning how specific should these stories be in > explaining the view? At RubyConf during your presentation (great job, > BTW!) you mentioned how you like to spec out your views first. Ah - confusion. I DO like to spec my views first - when I get down to the Spec Framework. In our example at RailsConf EU, we talked about a Cup Tracker (as in Rugby, which was going on at the time). Take a look at the example story: http://rspec.rubyforge.org/svn/branches/railsconfeu2007/tags/chapter1/stories/plan_cup.rb This story really rides this whole line very nicely. We're describing software that presents a view of something abstract, and we do so with some detail about what it presents - but there is nothing in it that says "when I click this button" or "when I enter this text." Now look at this version (same story, w/ the steps filled in): http://rspec.rubyforge.org/svn/branches/railsconfeu2007/tags/chapter4/stories/plan_cup.rb Note how the implementations of the steps are starting to get into the views. That's where that level of detail starts to play out. Now look at this: http://rspec.rubyforge.org/svn/branches/railsconfeu2007/tags/chapter4/spec/views/cups/show.rhtml_spec.rb That spec was arrived at with the very granular red-green-refactor process of TDD with a focus, naturally, on behaviour, design and documentation (It just occurs to me that behaviour, design and documentation are B, D and D - interesting ...). Now some people look at that spec and scream "holy crap - look at all the duplication - all that mocking - so brittle!." I won't disagree that there is lots of duplication with other parts of the system, a lot of mocking, and changes to the views would require changes to this spec (brittle). And, looking back at this, I might want to break that spec up into more granular examples. While it speaks very well looking at the code, running it would only tell you that "/cups/show.rhtml should display the chart." But check this out! The implementation of that spec, with all that mocking, IS the spec for the controller and model. That single spec tells us about the structure that the model should expose (NOT the actual structure necessarily - just what it should expose to things like views that want the models to be easy to use) and what the controller should provide for the view. So this is all about discovery - starting from the outside and moving in. Implementing the steps that describe domain concepts help us to discover some details of the views. Implementing the view specs help us to discover the services we want from our controller and the APIs we want from our model. I find that to be very compelling. > Where is the happy medium, in your opinion, between > keeping the stories concise and letting them drive every aspect of the > development? Maybe I am wrong in saying that the stories should drive > EVERY aspect of the development? Well, they should drive every aspect, but not directly. You're not going to describe database table structure in your stories, but in the end those structures end up as they do because of the stories. > >> The Selenium integration is also an interesting idea that you might want > >> to read about if you haven't seen this post. I'm still trying to > >> decided if using Selenium is worth the extra effort (my main goal would > >> be to test the JS during the acceptance tests) > > Generally speaking, in-browser tests tend to be incredibly brittle and > > run dog-slow. They simply have no choice but to be tied directly to > > low-level implementation details like html structure and element IDs. > > > > So I'd recommend only testing what you absolutely must in-browser. But > > given our ajax-laden world, "what you absolutely must" may well turn > > out to be a lot! > I have heard that Selenium suites can become out of hand and end of > being more hassle than what there worth. Thanks for the recommendation, > I think that sounds like a sensible one. > > Thanks for taking the time to discuss this, My pleasure! Cheers, David > > Ben From patcito at gmail.com Thu Nov 8 10:22:55 2007 From: patcito at gmail.com (Patrick Aljord) Date: Thu, 8 Nov 2007 16:22:55 +0100 Subject: [rspec-users] error on migration Message-ID: <6b6419750711080722o600d694keb1a7b7e98151451@mail.gmail.com> Hi all, I'm just getting started with rspec. I'm using trunk rspec with edge rails. I get an error on migration though, here it is: rake db:migrate RAILS_ENV="test" --trace (in /home/pat/railsapp) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment rake aborted! undefined method `failure_message' for class `Spec::Matchers::Have' /home/pat/railsapp/vendor/plugins/rspec_on_rails/lib/spec/matchers/have.rb:4:in `alias_method' /home/pat/railsapp/vendor/plugins/rspec_on_rails/lib/spec/matchers/have.rb:4 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' /home/pat/railsapp/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' /home/pat/railsapp/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in' /home/pat/railsapp/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' /home/pat/railsapp/vendor/plugins/rspec_on_rails/lib/spec/matchers.rb:3 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' /home/pat/railsapp/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' /home/pat/railsapp/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in' /home/pat/railsapp/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' /home/pat/railsapp/vendor/plugins/rspec/lib/spec.rb:3 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' /home/pat/railsapp/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' /home/pat/railsapp/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in' /home/pat/railsapp/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' /home/pat/railsapp/vendor/plugins/rspec/init.rb:2:in `evaluate_init_rb' /home/pat/railsapp/config/../vendor/rails/railties/lib/rails/plugin.rb:78:in `evaluate_init_rb' /home/pat/railsapp/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings' /home/pat/railsapp/config/../vendor/rails/railties/lib/rails/plugin.rb:74:in `evaluate_init_rb' /home/pat/railsapp/config/../vendor/rails/railties/lib/rails/plugin.rb:38:in `load' /home/pat/railsapp/config/../vendor/rails/railties/lib/rails/plugin/loader.rb:33:in `load_plugins' /home/pat/railsapp/config/../vendor/rails/railties/lib/rails/plugin/loader.rb:32:in `each' /home/pat/railsapp/config/../vendor/rails/railties/lib/rails/plugin/loader.rb:32:in `load_plugins' /home/pat/railsapp/config/../vendor/rails/railties/lib/initializer.rb:189:in `load_plugins' /home/pat/railsapp/config/../vendor/rails/railties/lib/initializer.rb:105:in `process' /home/pat/railsapp/config/../vendor/rails/railties/lib/initializer.rb:49:in `send' /home/pat/railsapp/config/../vendor/rails/railties/lib/initializer.rb:49:in `run' /home/pat/railsapp/config/environment.rb:13 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' /home/pat/railsapp/vendor/rails/railties/lib/tasks/misc.rake:3 /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `synchronize' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:369:in `invoke_prerequisites' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1003:in `each' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1003:in `send' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1003:in `each' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:368:in `invoke_prerequisites' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:361:in `invoke' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `synchronize' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `each' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in `top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in `run' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in `run' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 /usr/bin/rake:16:in `load' /usr/bin/rake:16 any idea how to fix this? thanks in advance Pat From glenn at aldenta.com Thu Nov 8 11:01:41 2007 From: glenn at aldenta.com (Glenn Ford) Date: Thu, 8 Nov 2007 11:01:41 -0500 Subject: [rspec-users] Plain Text Story example In-Reply-To: <57c63afe0711080358h14379674h5312027beacee697@mail.gmail.com> References: <4732487A.5060309@benmabey.com> <47328E2F.1090103@benmabey.com> <57c63afe0711072112u285a13ecgb56fc416cc300bb7@mail.gmail.com> <4732AA13.7090107@benmabey.com> <57c63afe0711080358h14379674h5312027beacee697@mail.gmail.com> Message-ID: <5BF7CFD7-560B-434C-8AAB-C063AE03AB8A@aldenta.com> It seems that what I'm coming to understand of the direction of this story concept is that there is a lot of emphasis being put on ensuring we keep things at the business level. I can appreciate the elegance of it certainly, but when I think of what I would really want to gain from this story-based testing process, I feel like it cuts out room for some really cool ideas. Maybe you can help me see where they would fit. I have in mind a scenario where a customer says "I tried to log in and it blew up!" I take what they say with a business perspective and check my story and say "hey I've got a login story and it works" but that doesn't leave room for the fact that, slighty away from the norm of the usual login procedure, this particular user clicked another link in the middle of the process that changed some background variable, breaking the process at the final login step. I would then want to write a story similar to the usual login, but with the ACTUAL details of what the customer did to ensure I could duplicate, fix, and then never have this problem creep up again. My story, in order to be of use to me, would HAVE to have steps like "click this button" because, quite frankly, as a developer I find that's the sort of thing that can break my code and so I would want a story to account for it. A user following my intended user-flow, then deviating in a way I didn't predict. From the business end, they still followed the login process, they just had one little different quirk along the way. Is there a way to get this kind of thing but still keep to the ideal business perspective? Would I just simply "word" it in a way that the simple little thing they did had a business description? Or is that an indication that I have stupid things on my page that shouldn't even be an option? Or is there a "happy medium" here as well between business and ui perspectives of stories? Glenn On Nov 8, 2007, at 6:58 AM, David Chelimsky wrote: > On Nov 8, 2007 12:17 AM, Ben Mabey wrote: >> David Chelimsky wrote: > > > >>> ... the philosohy that Dan is >>> espousing: expressing stories in the business domain rather than the >>> UI domain (btw Dan, that was brilliantly put). >> What exactly do you and Dan mean when you say that the stories >> should be >> expressed in the business domain rather than the UI domain? (BTW, is >> there a link to a Dan North post abou that?) > > Sorry - there are two different threads going on about this topic > right now - the other one is on the rspec-devel list and that was > where Dan posted that statement: > > http://rubyforge.org/pipermail/rspec-devel/2007-November/004259.html > > Keep in mind that User Stories are oft described as "a token for a > conversation", and that even with acceptance criteria spelled out, > whether the button says "Create New Account" or "Enter" is rarely of > sufficient business value to express that in a story. That's the sort > of detail that comes out when you say to your customer "the entry form > is done, why don't you come by so I can show it to you," as opposed to > in the iteration planning meeting. > > In the end it really does boil down to what the customer feels is > necessary in order to accept the software. If the customer really DOES > care about what the button says, he or she may want that expressed in > a story. But even then, saying "And I press Create New Account" still > leaves things flexible enough so that you could be describing a web > app, a GUI app, a touch-screen app, etc. The only thing this doesn't > work for would be a command line app. So maybe "And I tell the system > to Create New Account" would leave room for that as well. Or maybe, > "And I fold my arms and command the system to Create New Account." I > kinda like that one! > >> From my understanding you >> are saying that the steps that say "user types in such and such" and >> user "hits the login button" are too UI specific and don't really >> have >> much to do with the business domain. Is that correct? > > Unless the business IS software, like a text editor, yes. > >> I think that this is a part of writing stories that I am somewhat >> struggling with, meaning how specific should these stories be in >> explaining the view? At RubyConf during your presentation (great >> job, >> BTW!) you mentioned how you like to spec out your views first. > > Ah - confusion. I DO like to spec my views first - when I get down to > the Spec Framework. > > In our example at RailsConf EU, we talked about a Cup Tracker (as in > Rugby, which was going on at the time). Take a look at the example > story: > > http://rspec.rubyforge.org/svn/branches/railsconfeu2007/tags/chapter1/stories/plan_cup.rb > > This story really rides this whole line very nicely. We're describing > software that presents a view of something abstract, and we do so with > some detail about what it presents - but there is nothing in it that > says "when I click this button" or "when I enter this text." > > Now look at this version (same story, w/ the steps filled in): > > http://rspec.rubyforge.org/svn/branches/railsconfeu2007/tags/chapter4/stories/plan_cup.rb > > Note how the implementations of the steps are starting to get into the > views. That's where that level of detail starts to play out. > > Now look at this: > > http://rspec.rubyforge.org/svn/branches/railsconfeu2007/tags/chapter4/spec/views/cups/show.rhtml_spec.rb > > That spec was arrived at with the very granular red-green-refactor > process of TDD with a focus, naturally, on behaviour, design and > documentation (It just occurs to me that behaviour, design and > documentation are B, D and D - interesting ...). > > Now some people look at that spec and scream "holy crap - look at all > the duplication - all that mocking - so brittle!." I won't disagree > that there is lots of duplication with other parts of the system, a > lot of mocking, and changes to the views would require changes to this > spec (brittle). And, looking back at this, I might want to break that > spec up into more granular examples. While it speaks very well looking > at the code, running it would only tell you that "/cups/show.rhtml > should display the chart." > > But check this out! The implementation of that spec, with all that > mocking, IS the spec for the controller and model. That single spec > tells us about the structure that the model should expose (NOT the > actual structure necessarily - just what it should expose to things > like views that want the models to be easy to use) and what the > controller should provide for the view. > > So this is all about discovery - starting from the outside and moving > in. Implementing the steps that describe domain concepts help us to > discover some details of the views. Implementing the view specs help > us to discover the services we want from our controller and the APIs > we want from our model. I find that to be very compelling. > > > >> Where is the happy medium, in your opinion, between >> keeping the stories concise and letting them drive every aspect of >> the >> development? Maybe I am wrong in saying that the stories should >> drive >> EVERY aspect of the development? > > Well, they should drive every aspect, but not directly. You're not > going to describe database table structure in your stories, but in the > end those structures end up as they do because of the stories. > >>>> The Selenium integration is also an interesting idea that you >>>> might want >>>> to read about if you haven't seen this post. I'm still trying to >>>> decided if using Selenium is worth the extra effort (my main goal >>>> would >>>> be to test the JS during the acceptance tests) > > > >>> Generally speaking, in-browser tests tend to be incredibly brittle >>> and >>> run dog-slow. They simply have no choice but to be tied directly to >>> low-level implementation details like html structure and element >>> IDs. >>> >>> So I'd recommend only testing what you absolutely must in-browser. >>> But >>> given our ajax-laden world, "what you absolutely must" may well turn >>> out to be a lot! > > > >> I have heard that Selenium suites can become out of hand and end of >> being more hassle than what there worth. Thanks for the >> recommendation, >> I think that sounds like a sensible one. >> >> Thanks for taking the time to discuss this, > > My pleasure! > > Cheers, > David > >> >> Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Thu Nov 8 11:18:36 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 8 Nov 2007 10:18:36 -0600 Subject: [rspec-users] Plain Text Story example In-Reply-To: <5BF7CFD7-560B-434C-8AAB-C063AE03AB8A@aldenta.com> References: <4732487A.5060309@benmabey.com> <47328E2F.1090103@benmabey.com> <57c63afe0711072112u285a13ecgb56fc416cc300bb7@mail.gmail.com> <4732AA13.7090107@benmabey.com> <57c63afe0711080358h14379674h5312027beacee697@mail.gmail.com> <5BF7CFD7-560B-434C-8AAB-C063AE03AB8A@aldenta.com> Message-ID: <57c63afe0711080818s38a43135te656297b2d67597c@mail.gmail.com> On Nov 8, 2007 10:01 AM, Glenn Ford wrote: > It seems that what I'm coming to understand of the direction of this > story concept is that there is a lot of emphasis being put on ensuring > we keep things at the business level. I can appreciate the elegance > of it certainly, but when I think of what I would really want to gain > from this story-based testing process, I feel like it cuts out room > for some really cool ideas. Maybe you can help me see where they > would fit. > > I have in mind a scenario where a customer says "I tried to log in and > it blew up!" I take what they say with a business perspective and > check my story and say "hey I've got a login story and it works" but > that doesn't leave room for the fact that, slighty away from the norm > of the usual login procedure, this particular user clicked another > link in the middle of the process that changed some background > variable, breaking the process at the final login step. I would then > want to write a story similar to the usual login, but with the ACTUAL > details of what the customer did to ensure I could duplicate, fix, and > then never have this problem creep up again. My story, in order to be > of use to me, would HAVE to have steps like "click this button" > because, quite frankly, as a developer I find that's the sort of thing > that can break my code and so I would want a story to account for it. > A user following my intended user-flow, then deviating in a way I > didn't predict. From the business end, they still followed the login > process, they just had one little different quirk along the way. > > Is there a way to get this kind of thing but still keep to the ideal > business perspective? Ideals are just that - ideals. While we're exploring the boundaries of this and trying to understand pragmatic use, keep in mind that it is just a tool. The Story Framework is never going to say to you "no, no, no - you can't use the word 'button' in a story." Nor will the Story Police come around and arrest you. That said, if the thing that the user did can be expressed in business terms, that might be more useful in the end because the story becomes more portable. Say, for example, you start with a web app but eventually the business invests in making it a desktop app or a kiosk app. It'd be nice to make sure the new version doesn't have the same problem you are trying to expose with this story. > Would I just simply "word" it in a way that the > simple little thing they did had a business description? Or is that > an indication that I have stupid things on my page that shouldn't even > be an option? Or is there a "happy medium" here as well between > business and ui perspectives of stories? > > Glenn > > > On Nov 8, 2007, at 6:58 AM, David Chelimsky wrote: > > > On Nov 8, 2007 12:17 AM, Ben Mabey wrote: > >> David Chelimsky wrote: > > > > > > > >>> ... the philosohy that Dan is > >>> espousing: expressing stories in the business domain rather than the > >>> UI domain (btw Dan, that was brilliantly put). > >> What exactly do you and Dan mean when you say that the stories > >> should be > >> expressed in the business domain rather than the UI domain? (BTW, is > >> there a link to a Dan North post abou that?) > > > > Sorry - there are two different threads going on about this topic > > right now - the other one is on the rspec-devel list and that was > > where Dan posted that statement: > > > > http://rubyforge.org/pipermail/rspec-devel/2007-November/004259.html > > > > Keep in mind that User Stories are oft described as "a token for a > > conversation", and that even with acceptance criteria spelled out, > > whether the button says "Create New Account" or "Enter" is rarely of > > sufficient business value to express that in a story. That's the sort > > of detail that comes out when you say to your customer "the entry form > > is done, why don't you come by so I can show it to you," as opposed to > > in the iteration planning meeting. > > > > In the end it really does boil down to what the customer feels is > > necessary in order to accept the software. If the customer really DOES > > care about what the button says, he or she may want that expressed in > > a story. But even then, saying "And I press Create New Account" still > > leaves things flexible enough so that you could be describing a web > > app, a GUI app, a touch-screen app, etc. The only thing this doesn't > > work for would be a command line app. So maybe "And I tell the system > > to Create New Account" would leave room for that as well. Or maybe, > > "And I fold my arms and command the system to Create New Account." I > > kinda like that one! > > > >> From my understanding you > >> are saying that the steps that say "user types in such and such" and > >> user "hits the login button" are too UI specific and don't really > >> have > >> much to do with the business domain. Is that correct? > > > > Unless the business IS software, like a text editor, yes. > > > >> I think that this is a part of writing stories that I am somewhat > >> struggling with, meaning how specific should these stories be in > >> explaining the view? At RubyConf during your presentation (great > >> job, > >> BTW!) you mentioned how you like to spec out your views first. > > > > Ah - confusion. I DO like to spec my views first - when I get down to > > the Spec Framework. > > > > In our example at RailsConf EU, we talked about a Cup Tracker (as in > > Rugby, which was going on at the time). Take a look at the example > > story: > > > > http://rspec.rubyforge.org/svn/branches/railsconfeu2007/tags/chapter1/stories/plan_cup.rb > > > > This story really rides this whole line very nicely. We're describing > > software that presents a view of something abstract, and we do so with > > some detail about what it presents - but there is nothing in it that > > says "when I click this button" or "when I enter this text." > > > > Now look at this version (same story, w/ the steps filled in): > > > > http://rspec.rubyforge.org/svn/branches/railsconfeu2007/tags/chapter4/stories/plan_cup.rb > > > > Note how the implementations of the steps are starting to get into the > > views. That's where that level of detail starts to play out. > > > > Now look at this: > > > > http://rspec.rubyforge.org/svn/branches/railsconfeu2007/tags/chapter4/spec/views/cups/show.rhtml_spec.rb > > > > That spec was arrived at with the very granular red-green-refactor > > process of TDD with a focus, naturally, on behaviour, design and > > documentation (It just occurs to me that behaviour, design and > > documentation are B, D and D - interesting ...). > > > > Now some people look at that spec and scream "holy crap - look at all > > the duplication - all that mocking - so brittle!." I won't disagree > > that there is lots of duplication with other parts of the system, a > > lot of mocking, and changes to the views would require changes to this > > spec (brittle). And, looking back at this, I might want to break that > > spec up into more granular examples. While it speaks very well looking > > at the code, running it would only tell you that "/cups/show.rhtml > > should display the chart." > > > > But check this out! The implementation of that spec, with all that > > mocking, IS the spec for the controller and model. That single spec > > tells us about the structure that the model should expose (NOT the > > actual structure necessarily - just what it should expose to things > > like views that want the models to be easy to use) and what the > > controller should provide for the view. > > > > So this is all about discovery - starting from the outside and moving > > in. Implementing the steps that describe domain concepts help us to > > discover some details of the views. Implementing the view specs help > > us to discover the services we want from our controller and the APIs > > we want from our model. I find that to be very compelling. > > > > > > > >> Where is the happy medium, in your opinion, between > >> keeping the stories concise and letting them drive every aspect of > >> the > >> development? Maybe I am wrong in saying that the stories should > >> drive > >> EVERY aspect of the development? > > > > Well, they should drive every aspect, but not directly. You're not > > going to describe database table structure in your stories, but in the > > end those structures end up as they do because of the stories. > > > >>>> The Selenium integration is also an interesting idea that you > >>>> might want > >>>> to read about if you haven't seen this post. I'm still trying to > >>>> decided if using Selenium is worth the extra effort (my main goal > >>>> would > >>>> be to test the JS during the acceptance tests) > > > > > > > >>> Generally speaking, in-browser tests tend to be incredibly brittle > >>> and > >>> run dog-slow. They simply have no choice but to be tied directly to > >>> low-level implementation details like html structure and element > >>> IDs. > >>> > >>> So I'd recommend only testing what you absolutely must in-browser. > >>> But > >>> given our ajax-laden world, "what you absolutely must" may well turn > >>> out to be a lot! > > > > > > > >> I have heard that Selenium suites can become out of hand and end of > >> being more hassle than what there worth. Thanks for the > >> recommendation, > >> I think that sounds like a sensible one. > >> > >> Thanks for taking the time to discuss this, > > > > My pleasure! > > > > Cheers, > > David > > > >> > >> Ben > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Thu Nov 8 12:17:25 2007 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 8 Nov 2007 09:17:25 -0800 Subject: [rspec-users] Plain Text Story example In-Reply-To: <5BF7CFD7-560B-434C-8AAB-C063AE03AB8A@aldenta.com> References: <4732487A.5060309@benmabey.com> <47328E2F.1090103@benmabey.com> <57c63afe0711072112u285a13ecgb56fc416cc300bb7@mail.gmail.com> <4732AA13.7090107@benmabey.com> <57c63afe0711080358h14379674h5312027beacee697@mail.gmail.com> <5BF7CFD7-560B-434C-8AAB-C063AE03AB8A@aldenta.com> Message-ID: <810a540e0711080917u7f3db94dwd9d9fd4c53d9eb7@mail.gmail.com> On Nov 8, 2007 8:01 AM, Glenn Ford wrote: > I have in mind a scenario where a customer says "I tried to log in and > it blew up!" I take what they say with a business perspective and > check my story and say "hey I've got a login story and it works" but > that doesn't leave room for the fact that, slighty away from the norm > of the usual login procedure, this particular user clicked another > link in the middle of the process that changed some background > variable, breaking the process at the final login step. I would then > want to write a story similar to the usual login, but with the ACTUAL > details of what the customer did to ensure I could duplicate, fix, and > then never have this problem creep up again. My story, in order to be > of use to me, would HAVE to have steps like "click this button" > because, quite frankly, as a developer I find that's the sort of thing > that can break my code and so I would want a story to account for it. > A user following my intended user-flow, then deviating in a way I > didn't predict. From the business end, they still followed the login > process, they just had one little different quirk along the way. Hey Glenn, Halted/canceled business processes are sometimes just as, or even more, interesting than completed business processes. So for example, in your login story you could have a "canceled login" scenario. Scenario user canceled the login process Given the user goes to the login screen And the user canceled login When the user submits his credentials Then ...... So now you have a story that captures what's going on in business terms. Maybe you don't want the behavior of them canceling it, and perhaps you call it "suspends the login process" so that when he finally submits his credentials the authentication goes as expected. If you have a bunch of ways in which the user can suspend the login process, you could create a separate "suspend login" story. Put each way the user can suspend the process in its own scenario. Of course, if you have many ways that the user can suspend logging in, your authentication is probably too tightly coupled to the rest of your app anyway. Pat From ben at benmabey.com Thu Nov 8 12:30:57 2007 From: ben at benmabey.com (Ben Mabey) Date: Thu, 08 Nov 2007 10:30:57 -0700 Subject: [rspec-users] Plain Text Story example In-Reply-To: <57c63afe0711080358h14379674h5312027beacee697@mail.gmail.com> References: <4732487A.5060309@benmabey.com> <47328E2F.1090103@benmabey.com> <57c63afe0711072112u285a13ecgb56fc416cc300bb7@mail.gmail.com> <4732AA13.7090107@benmabey.com> <57c63afe0711080358h14379674h5312027beacee697@mail.gmail.com> Message-ID: <473347D1.6090004@benmabey.com> Thanks a lot David, this helps a lot. I have been trying to do just as you recommended and letting the stories drive every aspect implicitly without me explicitly defining the model methods in it. The confusion I was having was that when you say you are going to follow the failing stories to drive the process the first thing that usually will fail will be in a model.. Meaning, you usually have a given clause that uses the model to set up the DB. Pat Maddox, in his Story Runner screencast, showed how to effectively stub out the model in the story runner with a "class ModelName; end" type approach. However, this does not always work depending on the type of methods you will be calling on the model... Hmm.. actually I guess you could just add something like this, that would make that class/object act like a mock that receives anything: #Top of story file that uses UndefinedModel class UndefinedModel def initialize(*args); end def method_missing #I eat all methods end end So stuff like this should work just fine: Given.... u = UndefinedModel.new(:some_attribute => "value" u.some_other_method Doing this I suppose would allow the story runner to pass all of the steps until it hit the view steps which in that case, like you suggested, you could drop down to the view specs and then work your way towards defining the real model. I'll play around this approach and see where it takes me. It should be easy to leverage the current mocking/stubbing framework and create some helpers to allow for such a process to be relatively painless. Thanks again! -Ben David Chelimsky wrote: > On Nov 8, 2007 12:17 AM, Ben Mabey wrote: > >> David Chelimsky wrote: >> > > > > >>> ... the philosohy that Dan is >>> espousing: expressing stories in the business domain rather than the >>> UI domain (btw Dan, that was brilliantly put). >>> >> What exactly do you and Dan mean when you say that the stories should be >> expressed in the business domain rather than the UI domain? (BTW, is >> there a link to a Dan North post abou that?) >> > > Sorry - there are two different threads going on about this topic > right now - the other one is on the rspec-devel list and that was > where Dan posted that statement: > > http://rubyforge.org/pipermail/rspec-devel/2007-November/004259.html > > Keep in mind that User Stories are oft described as "a token for a > conversation", and that even with acceptance criteria spelled out, > whether the button says "Create New Account" or "Enter" is rarely of > sufficient business value to express that in a story. That's the sort > of detail that comes out when you say to your customer "the entry form > is done, why don't you come by so I can show it to you," as opposed to > in the iteration planning meeting. > > In the end it really does boil down to what the customer feels is > necessary in order to accept the software. If the customer really DOES > care about what the button says, he or she may want that expressed in > a story. But even then, saying "And I press Create New Account" still > leaves things flexible enough so that you could be describing a web > app, a GUI app, a touch-screen app, etc. The only thing this doesn't > work for would be a command line app. So maybe "And I tell the system > to Create New Account" would leave room for that as well. Or maybe, > "And I fold my arms and command the system to Create New Account." I > kinda like that one! > > >> From my understanding you >> are saying that the steps that say "user types in such and such" and >> user "hits the login button" are too UI specific and don't really have >> much to do with the business domain. Is that correct? >> > > Unless the business IS software, like a text editor, yes. > > >> I think that this is a part of writing stories that I am somewhat >> struggling with, meaning how specific should these stories be in >> explaining the view? At RubyConf during your presentation (great job, >> BTW!) you mentioned how you like to spec out your views first. >> > > Ah - confusion. I DO like to spec my views first - when I get down to > the Spec Framework. > > In our example at RailsConf EU, we talked about a Cup Tracker (as in > Rugby, which was going on at the time). Take a look at the example > story: > > http://rspec.rubyforge.org/svn/branches/railsconfeu2007/tags/chapter1/stories/plan_cup.rb > > This story really rides this whole line very nicely. We're describing > software that presents a view of something abstract, and we do so with > some detail about what it presents - but there is nothing in it that > says "when I click this button" or "when I enter this text." > > Now look at this version (same story, w/ the steps filled in): > > http://rspec.rubyforge.org/svn/branches/railsconfeu2007/tags/chapter4/stories/plan_cup.rb > > Note how the implementations of the steps are starting to get into the > views. That's where that level of detail starts to play out. > > Now look at this: > > http://rspec.rubyforge.org/svn/branches/railsconfeu2007/tags/chapter4/spec/views/cups/show.rhtml_spec.rb > > That spec was arrived at with the very granular red-green-refactor > process of TDD with a focus, naturally, on behaviour, design and > documentation (It just occurs to me that behaviour, design and > documentation are B, D and D - interesting ...). > > Now some people look at that spec and scream "holy crap - look at all > the duplication - all that mocking - so brittle!." I won't disagree > that there is lots of duplication with other parts of the system, a > lot of mocking, and changes to the views would require changes to this > spec (brittle). And, looking back at this, I might want to break that > spec up into more granular examples. While it speaks very well looking > at the code, running it would only tell you that "/cups/show.rhtml > should display the chart." > > But check this out! The implementation of that spec, with all that > mocking, IS the spec for the controller and model. That single spec > tells us about the structure that the model should expose (NOT the > actual structure necessarily - just what it should expose to things > like views that want the models to be easy to use) and what the > controller should provide for the view. > > So this is all about discovery - starting from the outside and moving > in. Implementing the steps that describe domain concepts help us to > discover some details of the views. Implementing the view specs help > us to discover the services we want from our controller and the APIs > we want from our model. I find that to be very compelling. > > > > >> Where is the happy medium, in your opinion, between >> keeping the stories concise and letting them drive every aspect of the >> development? Maybe I am wrong in saying that the stories should drive >> EVERY aspect of the development? >> > > Well, they should drive every aspect, but not directly. You're not > going to describe database table structure in your stories, but in the > end those structures end up as they do because of the stories. > > >>>> The Selenium integration is also an interesting idea that you might want >>>> to read about if you haven't seen this post. I'm still trying to >>>> decided if using Selenium is worth the extra effort (my main goal would >>>> be to test the JS during the acceptance tests) >>>> > > > > >>> Generally speaking, in-browser tests tend to be incredibly brittle and >>> run dog-slow. They simply have no choice but to be tied directly to >>> low-level implementation details like html structure and element IDs. >>> >>> So I'd recommend only testing what you absolutely must in-browser. But >>> given our ajax-laden world, "what you absolutely must" may well turn >>> out to be a lot! >>> > > > > >> I have heard that Selenium suites can become out of hand and end of >> being more hassle than what there worth. Thanks for the recommendation, >> I think that sounds like a sensible one. >> >> Thanks for taking the time to discuss this, >> > > My pleasure! > > Cheers, > David > > >> Ben >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From a.schur at nucleus.com Thu Nov 8 13:07:17 2007 From: a.schur at nucleus.com (Alvin Schur) Date: Thu, 08 Nov 2007 11:07:17 -0700 Subject: [rspec-users] Running specs in reverse In-Reply-To: References: Message-ID: <47335055.6060206@nucleus.com> There is an option "--reverse" to run examples in the reverse order which is good for detecting inter-dependencies between examples. Is it feasible for rspec to automatically switch between "forward" and "reverse" order each time a spec is run? My goal is to detect inter-dependencies sooner than later... Thanks Alvin. From lists at ruby-forum.com Thu Nov 8 19:56:02 2007 From: lists at ruby-forum.com (Mark McG.) Date: Fri, 9 Nov 2007 01:56:02 +0100 Subject: [rspec-users] RSpec on Rails 2.0 Message-ID: I have a project on edge rails that I'm trying to convert from Test:Unit to rspec. I have the rspec gem version 2338, the rspec and rsepc_on_rails version 2831 in vendor/plugins, and rails version 8117 in vendor/rails. I've been able to get a few specs passing, have gotten the specs running from autotest, and am able to do "rake spec:doc" and get the basic command line spec printout. I'd like be able to generate the html spec printout, so I tried "spec spec --format html" but got the "undefined method `before' for Spec::Rails::DSL::RailsExample:Class (NoMethodError)" mentioned in the "Autotest busted with Rspec/Rails trunk" thread from this forum. I was wondering if anyone else has been able to get the spec printouts working with edge rails and if so what versions of rails/rspec/rspec_on_rails were used. Thanks for your help, - Mark -- Posted via http://www.ruby-forum.com/. From patcito at gmail.com Thu Nov 8 20:06:51 2007 From: patcito at gmail.com (Patrick Aljord) Date: Fri, 9 Nov 2007 02:06:51 +0100 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: References: Message-ID: <6b6419750711081706y212824fcm9bf7003e5f8eb99c@mail.gmail.com> I can't get rspec to work with rails edge either, when I do "rake db:migrate RAILS_ENV=test" I get: undefined method `failure_message' for class `Spec::Matchers::Have' So I can't even start working on my project :/ It works without rspec. From dchelimsky at gmail.com Thu Nov 8 20:28:45 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 8 Nov 2007 19:28:45 -0600 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <6b6419750711081706y212824fcm9bf7003e5f8eb99c@mail.gmail.com> References: <6b6419750711081706y212824fcm9bf7003e5f8eb99c@mail.gmail.com> Message-ID: <57c63afe0711081728q1028cc05m5484d28f40fec2be@mail.gmail.com> On Nov 8, 2007 7:06 PM, Patrick Aljord wrote: > I can't get rspec to work with rails edge either, when I do > "rake db:migrate RAILS_ENV=test" > > I get: > > undefined method `failure_message' for class `Spec::Matchers::Have' That was due to a change in edge rails 8115, which broke rspec. It is now fixed - just update rspec to the current trunk. > > So I can't even start working on my project :/ It works without rspec. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From patcito at gmail.com Thu Nov 8 20:38:51 2007 From: patcito at gmail.com (Patrick Aljord) Date: Fri, 9 Nov 2007 02:38:51 +0100 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <57c63afe0711081728q1028cc05m5484d28f40fec2be@mail.gmail.com> References: <6b6419750711081706y212824fcm9bf7003e5f8eb99c@mail.gmail.com> <57c63afe0711081728q1028cc05m5484d28f40fec2be@mail.gmail.com> Message-ID: <6b6419750711081738g4e3fe039o81c232d20ebbedbe@mail.gmail.com> Ive just svn up and I still get the same error. From ben at benmabey.com Thu Nov 8 20:45:56 2007 From: ben at benmabey.com (Ben Mabey) Date: Thu, 08 Nov 2007 18:45:56 -0700 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <6b6419750711081738g4e3fe039o81c232d20ebbedbe@mail.gmail.com> References: <6b6419750711081706y212824fcm9bf7003e5f8eb99c@mail.gmail.com> <57c63afe0711081728q1028cc05m5484d28f40fec2be@mail.gmail.com> <6b6419750711081738g4e3fe039o81c232d20ebbedbe@mail.gmail.com> Message-ID: <4733BBD4.7060200@benmabey.com> Patrick Aljord wrote: > Ive just svn up and I still get the same error. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Did you svn up rspec_on_rails as well? From dchelimsky at gmail.com Thu Nov 8 20:49:42 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 8 Nov 2007 19:49:42 -0600 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <6b6419750711081738g4e3fe039o81c232d20ebbedbe@mail.gmail.com> References: <6b6419750711081706y212824fcm9bf7003e5f8eb99c@mail.gmail.com> <57c63afe0711081728q1028cc05m5484d28f40fec2be@mail.gmail.com> <6b6419750711081738g4e3fe039o81c232d20ebbedbe@mail.gmail.com> Message-ID: <57c63afe0711081749m1697b78dr6c3c2663e9eb0b77@mail.gmail.com> On Nov 8, 2007 7:38 PM, Patrick Aljord wrote: > Ive just svn up and I still get the same error. I don't know what to tell you - I just blew away vendor/rails, vendor/plugins/rspec and vendor/plugins/rspec_on_rails, reinstalled all three from their respective trunks and all is well. The problem was being caused by two files in the same location on the path: vendor/plugins/rspec/lib/spec/matchers/have.rb vendor/plugins/rspec_on_rails/lib/spec/matchers/have.rb The were both being seen as spec/matchers/have.rb. I moved the one in rspec_on_rails to a different location. Any chance the old one is still sitting around? > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From patcito at gmail.com Thu Nov 8 20:58:35 2007 From: patcito at gmail.com (Patrick Aljord) Date: Fri, 9 Nov 2007 02:58:35 +0100 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <4733BBD4.7060200@benmabey.com> References: <6b6419750711081706y212824fcm9bf7003e5f8eb99c@mail.gmail.com> <57c63afe0711081728q1028cc05m5484d28f40fec2be@mail.gmail.com> <6b6419750711081738g4e3fe039o81c232d20ebbedbe@mail.gmail.com> <4733BBD4.7060200@benmabey.com> Message-ID: <6b6419750711081758m3bbf7438maadef258d78b2619@mail.gmail.com> I did rm -rf both and now I get this: superclass mismatch for class TestResponse From dchelimsky at gmail.com Thu Nov 8 21:05:13 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 8 Nov 2007 20:05:13 -0600 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <6b6419750711081758m3bbf7438maadef258d78b2619@mail.gmail.com> References: <6b6419750711081706y212824fcm9bf7003e5f8eb99c@mail.gmail.com> <57c63afe0711081728q1028cc05m5484d28f40fec2be@mail.gmail.com> <6b6419750711081738g4e3fe039o81c232d20ebbedbe@mail.gmail.com> <4733BBD4.7060200@benmabey.com> <6b6419750711081758m3bbf7438maadef258d78b2619@mail.gmail.com> Message-ID: <57c63afe0711081805u1e8deb6dmeb60b6954f7eb919@mail.gmail.com> On Nov 8, 2007 7:58 PM, Patrick Aljord wrote: > I did rm -rf both and now I get this: > superclass mismatch for class TestResponse Can you provide a tiny bit more context than that? What command are you using? Stack trace? From patcito at gmail.com Thu Nov 8 21:07:41 2007 From: patcito at gmail.com (Patrick Aljord) Date: Fri, 9 Nov 2007 03:07:41 +0100 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <57c63afe0711081805u1e8deb6dmeb60b6954f7eb919@mail.gmail.com> References: <6b6419750711081706y212824fcm9bf7003e5f8eb99c@mail.gmail.com> <57c63afe0711081728q1028cc05m5484d28f40fec2be@mail.gmail.com> <6b6419750711081738g4e3fe039o81c232d20ebbedbe@mail.gmail.com> <4733BBD4.7060200@benmabey.com> <6b6419750711081758m3bbf7438maadef258d78b2619@mail.gmail.com> <57c63afe0711081805u1e8deb6dmeb60b6954f7eb919@mail.gmail.com> Message-ID: <6b6419750711081807q2f5b4237p5b7db8caf4d3cd9e@mail.gmail.com> sorry: rake db:migrate RAILS_ENV=test --trace (in /home/pat/catalogr) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment rake aborted! superclass mismatch for class TestResponse /home/pat/catalogr/vendor/rails/actionpack/lib/action_controller/test_process.rb:286 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' /home/pat/catalogr/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' /home/pat/catalogr/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in' /home/pat/catalogr/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' /home/pat/catalogr/vendor/plugins/rspec_on_rails/lib/spec/rails.rb:5 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' /home/pat/catalogr/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' /home/pat/catalogr/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in' /home/pat/catalogr/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' /home/pat/catalogr/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:104:in `require_or_load' /home/pat/catalogr/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:248:in `load_missing_constant' /home/pat/catalogr/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:453:in `const_missing' /home/pat/catalogr/vendor/plugins/rspec_on_rails/lib/spec/extensions/action_view/base.rb:3 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' /home/pat/catalogr/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' /home/pat/catalogr/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in' /home/pat/catalogr/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' /home/pat/catalogr/vendor/plugins/rspec_on_rails/lib/spec/extensions.rb:10 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' /home/pat/catalogr/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' /home/pat/catalogr/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in' /home/pat/catalogr/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' /home/pat/catalogr/vendor/plugins/rspec/lib/spec.rb:7 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' /home/pat/catalogr/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' /home/pat/catalogr/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in' /home/pat/catalogr/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' /home/pat/catalogr/vendor/plugins/rspec/init.rb:2:in `evaluate_init_rb' /home/pat/catalogr/config/../vendor/rails/railties/lib/rails/plugin.rb:79:in `evaluate_init_rb' /home/pat/catalogr/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings' /home/pat/catalogr/config/../vendor/rails/railties/lib/rails/plugin.rb:75:in `evaluate_init_rb' /home/pat/catalogr/config/../vendor/rails/railties/lib/rails/plugin.rb:39:in `load' /home/pat/catalogr/config/../vendor/rails/railties/lib/rails/plugin/loader.rb:33:in `load_plugins' /home/pat/catalogr/config/../vendor/rails/railties/lib/rails/plugin/loader.rb:32:in `each' /home/pat/catalogr/config/../vendor/rails/railties/lib/rails/plugin/loader.rb:32:in `load_plugins' /home/pat/catalogr/config/../vendor/rails/railties/lib/initializer.rb:189:in `load_plugins' /home/pat/catalogr/config/../vendor/rails/railties/lib/initializer.rb:105:in `process' /home/pat/catalogr/config/../vendor/rails/railties/lib/initializer.rb:49:in `send' /home/pat/catalogr/config/../vendor/rails/railties/lib/initializer.rb:49:in `run' /home/pat/catalogr/config/environment.rb:13 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' /home/pat/catalogr/vendor/rails/railties/lib/tasks/misc.rake:3 /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `synchronize' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:369:in `invoke_prerequisites' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1003:in `each' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1003:in `send' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1003:in `each' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:368:in `invoke_prerequisites' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:361:in `invoke' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `synchronize' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `each' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in `top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in `run' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in `run' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 /usr/bin/rake:16:in `load' /usr/bin/rake:16 From dchelimsky at gmail.com Thu Nov 8 21:14:24 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 8 Nov 2007 20:14:24 -0600 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <6b6419750711081807q2f5b4237p5b7db8caf4d3cd9e@mail.gmail.com> References: <6b6419750711081706y212824fcm9bf7003e5f8eb99c@mail.gmail.com> <57c63afe0711081728q1028cc05m5484d28f40fec2be@mail.gmail.com> <6b6419750711081738g4e3fe039o81c232d20ebbedbe@mail.gmail.com> <4733BBD4.7060200@benmabey.com> <6b6419750711081758m3bbf7438maadef258d78b2619@mail.gmail.com> <57c63afe0711081805u1e8deb6dmeb60b6954f7eb919@mail.gmail.com> <6b6419750711081807q2f5b4237p5b7db8caf4d3cd9e@mail.gmail.com> Message-ID: <57c63afe0711081814k288f4048j9c95d68832207677@mail.gmail.com> On Nov 8, 2007 8:07 PM, Patrick Aljord wrote: > sorry: > > rake db:migrate RAILS_ENV=test --trace > (in /home/pat/catalogr) > ** Invoke db:migrate (first_time) > ** Invoke environment (first_time) > ** Execute environment > rake aborted! > superclass mismatch for class TestResponse > /home/pat/catalogr/vendor/rails/actionpack/lib/action_controller/test_process.rb:286 That line reads like this: class TestResponse < AbstractResponse So it seems like there's some other loading problem. Try and blow away the rspec plugins and run this migration and see if you still have trouble. From patcito at gmail.com Thu Nov 8 21:18:06 2007 From: patcito at gmail.com (Patrick Aljord) Date: Fri, 9 Nov 2007 03:18:06 +0100 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <57c63afe0711081814k288f4048j9c95d68832207677@mail.gmail.com> References: <6b6419750711081706y212824fcm9bf7003e5f8eb99c@mail.gmail.com> <57c63afe0711081728q1028cc05m5484d28f40fec2be@mail.gmail.com> <6b6419750711081738g4e3fe039o81c232d20ebbedbe@mail.gmail.com> <4733BBD4.7060200@benmabey.com> <6b6419750711081758m3bbf7438maadef258d78b2619@mail.gmail.com> <57c63afe0711081805u1e8deb6dmeb60b6954f7eb919@mail.gmail.com> <6b6419750711081807q2f5b4237p5b7db8caf4d3cd9e@mail.gmail.com> <57c63afe0711081814k288f4048j9c95d68832207677@mail.gmail.com> Message-ID: <6b6419750711081818h1f644147he6df85b110dfdb10@mail.gmail.com> if I nuke the plugin i works: rake db:migrate RAILS_ENV=test (in /home/pat/catalogr) == 2 CreateBrands: migrating ================================================== -- create_table(:brands) -> 0.2779s == 2 CreateBrands: migrated (0.2782s) ========================================= From dchelimsky at gmail.com Thu Nov 8 21:20:21 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 8 Nov 2007 20:20:21 -0600 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <6b6419750711081818h1f644147he6df85b110dfdb10@mail.gmail.com> References: <6b6419750711081706y212824fcm9bf7003e5f8eb99c@mail.gmail.com> <57c63afe0711081728q1028cc05m5484d28f40fec2be@mail.gmail.com> <6b6419750711081738g4e3fe039o81c232d20ebbedbe@mail.gmail.com> <4733BBD4.7060200@benmabey.com> <6b6419750711081758m3bbf7438maadef258d78b2619@mail.gmail.com> <57c63afe0711081805u1e8deb6dmeb60b6954f7eb919@mail.gmail.com> <6b6419750711081807q2f5b4237p5b7db8caf4d3cd9e@mail.gmail.com> <57c63afe0711081814k288f4048j9c95d68832207677@mail.gmail.com> <6b6419750711081818h1f644147he6df85b110dfdb10@mail.gmail.com> Message-ID: <57c63afe0711081820s7cdefd53y1e9a5f3741ffb6f4@mail.gmail.com> On Nov 8, 2007 8:18 PM, Patrick Aljord wrote: > if I nuke the plugin i works: > > rake db:migrate RAILS_ENV=test > (in /home/pat/catalogr) > == 2 CreateBrands: migrating ================================================== > -- create_table(:brands) > -> 0.2779s > == 2 CreateBrands: migrated (0.2782s) ========================================= That's hosed!!!! What other plugins do you have installed? > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From patcito at gmail.com Thu Nov 8 21:21:51 2007 From: patcito at gmail.com (Patrick Aljord) Date: Fri, 9 Nov 2007 03:21:51 +0100 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <57c63afe0711081820s7cdefd53y1e9a5f3741ffb6f4@mail.gmail.com> References: <57c63afe0711081728q1028cc05m5484d28f40fec2be@mail.gmail.com> <6b6419750711081738g4e3fe039o81c232d20ebbedbe@mail.gmail.com> <4733BBD4.7060200@benmabey.com> <6b6419750711081758m3bbf7438maadef258d78b2619@mail.gmail.com> <57c63afe0711081805u1e8deb6dmeb60b6954f7eb919@mail.gmail.com> <6b6419750711081807q2f5b4237p5b7db8caf4d3cd9e@mail.gmail.com> <57c63afe0711081814k288f4048j9c95d68832207677@mail.gmail.com> <6b6419750711081818h1f644147he6df85b110dfdb10@mail.gmail.com> <57c63afe0711081820s7cdefd53y1e9a5f3741ffb6f4@mail.gmail.com> Message-ID: <6b6419750711081821r1d0a2b09l97895b6490bc8daf@mail.gmail.com> Nothing its a fresh project with latest rails edge that i started to learn rspec. From dchelimsky at gmail.com Thu Nov 8 21:36:01 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 8 Nov 2007 20:36:01 -0600 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <6b6419750711081821r1d0a2b09l97895b6490bc8daf@mail.gmail.com> References: <6b6419750711081738g4e3fe039o81c232d20ebbedbe@mail.gmail.com> <4733BBD4.7060200@benmabey.com> <6b6419750711081758m3bbf7438maadef258d78b2619@mail.gmail.com> <57c63afe0711081805u1e8deb6dmeb60b6954f7eb919@mail.gmail.com> <6b6419750711081807q2f5b4237p5b7db8caf4d3cd9e@mail.gmail.com> <57c63afe0711081814k288f4048j9c95d68832207677@mail.gmail.com> <6b6419750711081818h1f644147he6df85b110dfdb10@mail.gmail.com> <57c63afe0711081820s7cdefd53y1e9a5f3741ffb6f4@mail.gmail.com> <6b6419750711081821r1d0a2b09l97895b6490bc8daf@mail.gmail.com> Message-ID: <57c63afe0711081836g45af9160x59a06d1f243a3da5@mail.gmail.com> On Nov 8, 2007 8:21 PM, Patrick Aljord wrote: > Nothing its a fresh project with latest rails edge that i started to > learn rspec. Rails edge or 2.0 preview? From patcito at gmail.com Thu Nov 8 21:39:44 2007 From: patcito at gmail.com (Patrick Aljord) Date: Fri, 9 Nov 2007 03:39:44 +0100 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <57c63afe0711081836g45af9160x59a06d1f243a3da5@mail.gmail.com> References: <4733BBD4.7060200@benmabey.com> <6b6419750711081758m3bbf7438maadef258d78b2619@mail.gmail.com> <57c63afe0711081805u1e8deb6dmeb60b6954f7eb919@mail.gmail.com> <6b6419750711081807q2f5b4237p5b7db8caf4d3cd9e@mail.gmail.com> <57c63afe0711081814k288f4048j9c95d68832207677@mail.gmail.com> <6b6419750711081818h1f644147he6df85b110dfdb10@mail.gmail.com> <57c63afe0711081820s7cdefd53y1e9a5f3741ffb6f4@mail.gmail.com> <6b6419750711081821r1d0a2b09l97895b6490bc8daf@mail.gmail.com> <57c63afe0711081836g45af9160x59a06d1f243a3da5@mail.gmail.com> Message-ID: <6b6419750711081839s7a968763k5fe19caa95113c87@mail.gmail.com> > Rails edge or 2.0 preview? edge at revision 8117. From dchelimsky at gmail.com Thu Nov 8 21:40:49 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 8 Nov 2007 20:40:49 -0600 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <57c63afe0711081836g45af9160x59a06d1f243a3da5@mail.gmail.com> References: <4733BBD4.7060200@benmabey.com> <6b6419750711081758m3bbf7438maadef258d78b2619@mail.gmail.com> <57c63afe0711081805u1e8deb6dmeb60b6954f7eb919@mail.gmail.com> <6b6419750711081807q2f5b4237p5b7db8caf4d3cd9e@mail.gmail.com> <57c63afe0711081814k288f4048j9c95d68832207677@mail.gmail.com> <6b6419750711081818h1f644147he6df85b110dfdb10@mail.gmail.com> <57c63afe0711081820s7cdefd53y1e9a5f3741ffb6f4@mail.gmail.com> <6b6419750711081821r1d0a2b09l97895b6490bc8daf@mail.gmail.com> <57c63afe0711081836g45af9160x59a06d1f243a3da5@mail.gmail.com> Message-ID: <57c63afe0711081840i65506f11i4de93f516a1a6c40@mail.gmail.com> On Nov 8, 2007 8:36 PM, David Chelimsky wrote: > On Nov 8, 2007 8:21 PM, Patrick Aljord wrote: > > Nothing its a fresh project with latest rails edge that i started to > > learn rspec. > > Rails edge or 2.0 preview? > I just did this: rails foo cd foo rake rails:freeze:edge ruby script/plugin install svn://rubyforge.org/var/svn/rspec/trunk/rspec ruby script/plugin install svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails script/generate rspec rake db:create:all script/generate rspec_scaffold Thing name:string rake db:migrate rake spec All ran perfectly well. I really don't know what's going on on your machine. From patcito at gmail.com Thu Nov 8 21:47:40 2007 From: patcito at gmail.com (Patrick Aljord) Date: Fri, 9 Nov 2007 03:47:40 +0100 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <57c63afe0711081840i65506f11i4de93f516a1a6c40@mail.gmail.com> References: <6b6419750711081758m3bbf7438maadef258d78b2619@mail.gmail.com> <57c63afe0711081805u1e8deb6dmeb60b6954f7eb919@mail.gmail.com> <6b6419750711081807q2f5b4237p5b7db8caf4d3cd9e@mail.gmail.com> <57c63afe0711081814k288f4048j9c95d68832207677@mail.gmail.com> <6b6419750711081818h1f644147he6df85b110dfdb10@mail.gmail.com> <57c63afe0711081820s7cdefd53y1e9a5f3741ffb6f4@mail.gmail.com> <6b6419750711081821r1d0a2b09l97895b6490bc8daf@mail.gmail.com> <57c63afe0711081836g45af9160x59a06d1f243a3da5@mail.gmail.com> <57c63afe0711081840i65506f11i4de93f516a1a6c40@mail.gmail.com> Message-ID: <6b6419750711081847i67b5ad03v55e0bcdd43d3777e@mail.gmail.com> ok works great :) maybe because I did the scaffold with an old version rspec? (the one from this morning), sounds weird though. anyway, Thanks a lot! From lesliefreeman3 at gmail.com Fri Nov 9 00:25:12 2007 From: lesliefreeman3 at gmail.com (Leslie Freeman) Date: Thu, 8 Nov 2007 22:25:12 -0700 Subject: [rspec-users] fixture_file_upload and edge rspec? Message-ID: Hi all, I had some specs that were using fixture_file_upload that were passing just fine. Then I froze edge rails to get some 2.0 functionality, then a I upgraded to trunk rspec to deal with uninitialized constant ActionView::Helpers::JavaScriptMacrosHelper After a couple other of tribulations, I have now gotten down to just a couple of not passing specs, all using the fixture_file_upload. Here's an example it "should be invalid if uploaded file is not an image" do @image.attributes = valid_image_attributes.merge({:uploaded_data => fixture_file_upload('/textfile.txt', 'text/plain')}) @image.should_not be_valid # content_type: is not included in the list @image.should have(1).error_on(:content_type) end which fails with: 2) NoMethodError in 'Image unsaved should be invalid if uploaded file is not an image' You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.+ ./spec/models/image_spec.rb:25: A less than helpful error message. Any insight into what might be causing this? Thanks, Les From dchelimsky at gmail.com Fri Nov 9 07:09:17 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 9 Nov 2007 06:09:17 -0600 Subject: [rspec-users] fixture_file_upload and edge rspec? In-Reply-To: References: Message-ID: <57c63afe0711090409v5e5b6e52l82856bedb76008c6@mail.gmail.com> On Nov 8, 2007 11:25 PM, Leslie Freeman wrote: > Hi all, > I had some specs that were using fixture_file_upload that were > passing just fine. Then I froze edge rails to get some 2.0 > functionality, then a I upgraded to trunk rspec to deal with > > uninitialized constant ActionView::Helpers::JavaScriptMacrosHelper > > After a couple other of tribulations, I have now gotten down to just > a couple of not passing specs, all using the fixture_file_upload. > Here's an example > > it "should be invalid if uploaded file is not an image" do > @image.attributes = valid_image_attributes.merge({:uploaded_data > => fixture_file_upload('/textfile.txt', > > 'text/plain')}) > @image.should_not be_valid > # content_type: is not included in the list > @image.should have(1).error_on(:content_type) > end > > which fails with: > 2) > NoMethodError in 'Image unsaved should be invalid if uploaded file is > not an image' > You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.+ > ./spec/models/image_spec.rb:25: What's on line 25? > > A less than helpful error message. Any insight into what might be > causing this? > > Thanks, > Les > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From patcito at gmail.com Fri Nov 9 10:02:00 2007 From: patcito at gmail.com (Patrick Aljord) Date: Fri, 9 Nov 2007 16:02:00 +0100 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <57c63afe0711081840i65506f11i4de93f516a1a6c40@mail.gmail.com> References: <6b6419750711081758m3bbf7438maadef258d78b2619@mail.gmail.com> <57c63afe0711081805u1e8deb6dmeb60b6954f7eb919@mail.gmail.com> <6b6419750711081807q2f5b4237p5b7db8caf4d3cd9e@mail.gmail.com> <57c63afe0711081814k288f4048j9c95d68832207677@mail.gmail.com> <6b6419750711081818h1f644147he6df85b110dfdb10@mail.gmail.com> <57c63afe0711081820s7cdefd53y1e9a5f3741ffb6f4@mail.gmail.com> <6b6419750711081821r1d0a2b09l97895b6490bc8daf@mail.gmail.com> <57c63afe0711081836g45af9160x59a06d1f243a3da5@mail.gmail.com> <57c63afe0711081840i65506f11i4de93f516a1a6c40@mail.gmail.com> Message-ID: <6b6419750711090702j27f8e0dbk24f38033368393b3@mail.gmail.com> On Nov 9, 2007 3:40 AM, David Chelimsky wrote: > rails foo > cd foo > rake rails:freeze:edge > ruby script/plugin install svn://rubyforge.org/var/svn/rspec/trunk/rspec > ruby script/plugin install > svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails > script/generate rspec > rake db:create:all > script/generate rspec_scaffold Thing name:string > rake db:migrate > rake spec > > All ran perfectly well. I really don't know what's going on on your machine. > but did you try to run 'rake db:migrate RAILS_ENV=test' in your foo app? doesn't work here. From dchelimsky at gmail.com Fri Nov 9 10:06:26 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 9 Nov 2007 09:06:26 -0600 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <6b6419750711090702j27f8e0dbk24f38033368393b3@mail.gmail.com> References: <57c63afe0711081805u1e8deb6dmeb60b6954f7eb919@mail.gmail.com> <6b6419750711081807q2f5b4237p5b7db8caf4d3cd9e@mail.gmail.com> <57c63afe0711081814k288f4048j9c95d68832207677@mail.gmail.com> <6b6419750711081818h1f644147he6df85b110dfdb10@mail.gmail.com> <57c63afe0711081820s7cdefd53y1e9a5f3741ffb6f4@mail.gmail.com> <6b6419750711081821r1d0a2b09l97895b6490bc8daf@mail.gmail.com> <57c63afe0711081836g45af9160x59a06d1f243a3da5@mail.gmail.com> <57c63afe0711081840i65506f11i4de93f516a1a6c40@mail.gmail.com> <6b6419750711090702j27f8e0dbk24f38033368393b3@mail.gmail.com> Message-ID: <57c63afe0711090706i38f9c04bq2b752befc90bf8f5@mail.gmail.com> On Nov 9, 2007 9:02 AM, Patrick Aljord wrote: > On Nov 9, 2007 3:40 AM, David Chelimsky wrote: > > rails foo > > cd foo > > rake rails:freeze:edge > > ruby script/plugin install svn://rubyforge.org/var/svn/rspec/trunk/rspec > > ruby script/plugin install > > svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails > > script/generate rspec > > rake db:create:all > > script/generate rspec_scaffold Thing name:string > > rake db:migrate > > rake spec > > > > All ran perfectly well. I really don't know what's going on on your machine. > > > > but did you try to run 'rake db:migrate RAILS_ENV=test' in your foo > app? doesn't work here. Ah - why are you doing that? rake spec takes care of setting up your test db. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From patcito at gmail.com Fri Nov 9 10:26:23 2007 From: patcito at gmail.com (Patrick Aljord) Date: Fri, 9 Nov 2007 16:26:23 +0100 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <57c63afe0711090706i38f9c04bq2b752befc90bf8f5@mail.gmail.com> References: <6b6419750711081807q2f5b4237p5b7db8caf4d3cd9e@mail.gmail.com> <57c63afe0711081814k288f4048j9c95d68832207677@mail.gmail.com> <6b6419750711081818h1f644147he6df85b110dfdb10@mail.gmail.com> <57c63afe0711081820s7cdefd53y1e9a5f3741ffb6f4@mail.gmail.com> <6b6419750711081821r1d0a2b09l97895b6490bc8daf@mail.gmail.com> <57c63afe0711081836g45af9160x59a06d1f243a3da5@mail.gmail.com> <57c63afe0711081840i65506f11i4de93f516a1a6c40@mail.gmail.com> <6b6419750711090702j27f8e0dbk24f38033368393b3@mail.gmail.com> <57c63afe0711090706i38f9c04bq2b752befc90bf8f5@mail.gmail.com> Message-ID: <6b6419750711090726g4ba9e62dv4cd0b136361cecfe@mail.gmail.com> ok then sorry. it's all fine. From tastapod at gmail.com Fri Nov 9 10:59:40 2007 From: tastapod at gmail.com (Dan North) Date: Fri, 9 Nov 2007 15:59:40 +0000 Subject: [rspec-users] Plain Text Story example In-Reply-To: <5BF7CFD7-560B-434C-8AAB-C063AE03AB8A@aldenta.com> References: <4732487A.5060309@benmabey.com> <47328E2F.1090103@benmabey.com> <57c63afe0711072112u285a13ecgb56fc416cc300bb7@mail.gmail.com> <4732AA13.7090107@benmabey.com> <57c63afe0711080358h14379674h5312027beacee697@mail.gmail.com> <5BF7CFD7-560B-434C-8AAB-C063AE03AB8A@aldenta.com> Message-ID: Hi Glenn. On Nov 8, 2007 4:01 PM, Glenn Ford wrote: > It seems that what I'm coming to understand of the direction of this > story concept is that there is a lot of emphasis being put on ensuring > we keep things at the business level. I can appreciate the elegance > of it certainly, but when I think of what I would really want to gain > from this story-based testing process, I feel like it cuts out room > for some really cool ideas. Maybe you can help me see where they > would fit. > > I have in mind a scenario where a customer says "I tried to log in and > it blew up!" I take what they say with a business perspective and > check my story and say "hey I've got a login story and it works" but > that doesn't leave room for the fact that, slighty away from the norm > of the usual login procedure, this particular user clicked another > link in the middle of the process that changed some background > variable, breaking the process at the final login step. I would then > want to write a story similar to the usual login, but with the ACTUAL > details of what the customer did to ensure I could duplicate, fix, and > then never have this problem creep up again. I completely agree. > My story, in order to be > of use to me, would HAVE to have steps like "click this button" > because, quite frankly, as a developer I find that's the sort of thing > that can break my code and so I would want a story to account for it. Yes, exactly. In this example, the UI domain *is *the most useful domain to express the (bogus) behaviour, so it's the right thing to do. The scenario might be something like: Scenario: press the Explode button whilst filling in form Given I navigate to the *Submit order* page *[I'm loving these infix parameters!]* And I set first name to *Dan* and second name to *North* When I click the Explode button Then nothing should happen And the current page title should be *Submit order* Now, the whole of this scenario is in UI domain terms. It doesn't matter what business function I'm trying to achieve here - the description is about some bogus behaviour in my implementation (the Explode button should be disabled whilst I'm capturing data) So it's fine to express scenarios in either business domain terms to describe actual business flow, or UI terms to describe the user's interactions with the application. The confusion starts when you mix the two domains in the same story or at least in the same scenario. > A user following my intended user-flow, then deviating in a way I > didn't predict. From the business end, they still followed the login > process, they just had one little different quirk along the way. Yes, and it's that quirk *in this particular UI* that you want to capture with this scenario. Is there a way to get this kind of thing but still keep to the ideal > business perspective? You're trying to do a different thing here. The audience is different (probably a tester or UI designer rather than a business stakeholder) and they'll be using a different vocabulary. > Would I just simply "word" it in a way that the > simple little thing they did had a business description? Or is that > an indication that I have stupid things on my page that shouldn't even > be an option? Or is there a "happy medium" here as well between > business and ui perspectives of stories? See above - as long as you keep the distinction between domains when you are describing a scenario, you'll probably be ok. Glenn Cheers, Dan > > > On Nov 8, 2007, at 6:58 AM, David Chelimsky wrote: > > > On Nov 8, 2007 12:17 AM, Ben Mabey wrote: > >> David Chelimsky wrote: > > > > > > > >>> ... the philosohy that Dan is > >>> espousing: expressing stories in the business domain rather than the > >>> UI domain (btw Dan, that was brilliantly put). > >> What exactly do you and Dan mean when you say that the stories > >> should be > >> expressed in the business domain rather than the UI domain? (BTW, is > >> there a link to a Dan North post abou that?) > > > > Sorry - there are two different threads going on about this topic > > right now - the other one is on the rspec-devel list and that was > > where Dan posted that statement: > > > > http://rubyforge.org/pipermail/rspec-devel/2007-November/004259.html > > > > Keep in mind that User Stories are oft described as "a token for a > > conversation", and that even with acceptance criteria spelled out, > > whether the button says "Create New Account" or "Enter" is rarely of > > sufficient business value to express that in a story. That's the sort > > of detail that comes out when you say to your customer "the entry form > > is done, why don't you come by so I can show it to you," as opposed to > > in the iteration planning meeting. > > > > In the end it really does boil down to what the customer feels is > > necessary in order to accept the software. If the customer really DOES > > care about what the button says, he or she may want that expressed in > > a story. But even then, saying "And I press Create New Account" still > > leaves things flexible enough so that you could be describing a web > > app, a GUI app, a touch-screen app, etc. The only thing this doesn't > > work for would be a command line app. So maybe "And I tell the system > > to Create New Account" would leave room for that as well. Or maybe, > > "And I fold my arms and command the system to Create New Account." I > > kinda like that one! > > > >> From my understanding you > >> are saying that the steps that say "user types in such and such" and > >> user "hits the login button" are too UI specific and don't really > >> have > >> much to do with the business domain. Is that correct? > > > > Unless the business IS software, like a text editor, yes. > > > >> I think that this is a part of writing stories that I am somewhat > >> struggling with, meaning how specific should these stories be in > >> explaining the view? At RubyConf during your presentation (great > >> job, > >> BTW!) you mentioned how you like to spec out your views first. > > > > Ah - confusion. I DO like to spec my views first - when I get down to > > the Spec Framework. > > > > In our example at RailsConf EU, we talked about a Cup Tracker (as in > > Rugby, which was going on at the time). Take a look at the example > > story: > > > > > http://rspec.rubyforge.org/svn/branches/railsconfeu2007/tags/chapter1/stories/plan_cup.rb > > > > This story really rides this whole line very nicely. We're describing > > software that presents a view of something abstract, and we do so with > > some detail about what it presents - but there is nothing in it that > > says "when I click this button" or "when I enter this text." > > > > Now look at this version (same story, w/ the steps filled in): > > > > > http://rspec.rubyforge.org/svn/branches/railsconfeu2007/tags/chapter4/stories/plan_cup.rb > > > > Note how the implementations of the steps are starting to get into the > > views. That's where that level of detail starts to play out. > > > > Now look at this: > > > > > http://rspec.rubyforge.org/svn/branches/railsconfeu2007/tags/chapter4/spec/views/cups/show.rhtml_spec.rb > > > > That spec was arrived at with the very granular red-green-refactor > > process of TDD with a focus, naturally, on behaviour, design and > > documentation (It just occurs to me that behaviour, design and > > documentation are B, D and D - interesting ...). > > > > Now some people look at that spec and scream "holy crap - look at all > > the duplication - all that mocking - so brittle!." I won't disagree > > that there is lots of duplication with other parts of the system, a > > lot of mocking, and changes to the views would require changes to this > > spec (brittle). And, looking back at this, I might want to break that > > spec up into more granular examples. While it speaks very well looking > > at the code, running it would only tell you that "/cups/show.rhtml > > should display the chart." > > > > But check this out! The implementation of that spec, with all that > > mocking, IS the spec for the controller and model. That single spec > > tells us about the structure that the model should expose (NOT the > > actual structure necessarily - just what it should expose to things > > like views that want the models to be easy to use) and what the > > controller should provide for the view. > > > > So this is all about discovery - starting from the outside and moving > > in. Implementing the steps that describe domain concepts help us to > > discover some details of the views. Implementing the view specs help > > us to discover the services we want from our controller and the APIs > > we want from our model. I find that to be very compelling. > > > > > > > >> Where is the happy medium, in your opinion, between > >> keeping the stories concise and letting them drive every aspect of > >> the > >> development? Maybe I am wrong in saying that the stories should > >> drive > >> EVERY aspect of the development? > > > > Well, they should drive every aspect, but not directly. You're not > > going to describe database table structure in your stories, but in the > > end those structures end up as they do because of the stories. > > > >>>> The Selenium integration is also an interesting idea that you > >>>> might want > >>>> to read about if you haven't seen this post. I'm still trying to > >>>> decided if using Selenium is worth the extra effort (my main goal > >>>> would > >>>> be to test the JS during the acceptance tests) > > > > > > > >>> Generally speaking, in-browser tests tend to be incredibly brittle > >>> and > >>> run dog-slow. They simply have no choice but to be tied directly to > >>> low-level implementation details like html structure and element > >>> IDs. > >>> > >>> So I'd recommend only testing what you absolutely must in-browser. > >>> But > >>> given our ajax-laden world, "what you absolutely must" may well turn > >>> out to be a lot! > > > > > > > >> I have heard that Selenium suites can become out of hand and end of > >> being more hassle than what there worth. Thanks for the > >> recommendation, > >> I think that sounds like a sensible one. > >> > >> Thanks for taking the time to discuss this, > > > > My pleasure! > > > > Cheers, > > David > > > >> > >> Ben > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071109/70dc5175/attachment.html From leslief at sunquake.net Fri Nov 9 10:25:04 2007 From: leslief at sunquake.net (Leslie Freeman) Date: Fri, 9 Nov 2007 08:25:04 -0700 Subject: [rspec-users] fixture_file_upload and edge rspec? In-Reply-To: <57c63afe0711090409v5e5b6e52l82856bedb76008c6@mail.gmail.com> References: <57c63afe0711090409v5e5b6e52l82856bedb76008c6@mail.gmail.com> Message-ID: <581F0596-A4E6-427C-A129-411BBF99F9FB@sunquake.net> On Nov 9, 2007, at 5:09 AM, David Chelimsky wrote: > On Nov 8, 2007 11:25 PM, Leslie Freeman > wrote: >> Hi all, >> I had some specs that were using fixture_file_upload that were >> passing just fine. Then I froze edge rails to get some 2.0 >> functionality, then a I upgraded to trunk rspec to deal with >> >> uninitialized constant ActionView::Helpers::JavaScriptMacrosHelper >> >> After a couple other of tribulations, I have now gotten down to just >> a couple of not passing specs, all using the fixture_file_upload. >> Here's an example >> >> it "should be invalid if uploaded file is not an image" do >> @image.attributes = valid_image_attributes.merge({:uploaded_data >> => fixture_file_upload('/textfile.txt', >> >> 'text/plain')}) >> @image.should_not be_valid >> # content_type: is not included in the list >> @image.should have(1).error_on(:content_type) >> end >> >> which fails with: >> 2) >> NoMethodError in 'Image unsaved should be invalid if uploaded file is >> not an image' >> You have a nil object when you didn't expect it! >> You might have expected an instance of Array. >> The error occurred while evaluating nil.+ >> ./spec/models/image_spec.rb:25: > > What's on line 25? Sorry about that confusion. Line 25 is: @image.attributes = valid_image_attributes.merge({:uploaded_data => fixture_file_upload('/textfile.txt',text/plain')}) (textfile.txt is located in my /spec/fixtures/ dir.) That line doesn't throw the error if I change it to something like: @image.attributes = valid_image_attributes.merge({:uploaded_data => "foo"}) But of course the spec fails. :) Leslie > >> >> A less than helpful error message. Any insight into what might be >> causing this? >> >> Thanks, >> Les >> _______________________________________________ >> 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 work at ashleymoran.me.uk Fri Nov 9 18:03:01 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Fri, 9 Nov 2007 23:03:01 +0000 Subject: [rspec-users] Running specs in reverse In-Reply-To: <47335055.6060206@nucleus.com> References: <47335055.6060206@nucleus.com> Message-ID: On Nov 08, 2007, at 6:07 pm, Alvin Schur wrote: > My goal is to detect inter-dependencies sooner than later... I have to say I've NEVER run specs backwards. Am I sitting on a time bomb? Are there subtle traps that can create inter-dependencies between specs? To look at my specs I would not assume that running order matters - I don't think I've ever used before(:all) for example. Ashkey -- blog @ http://aviewfromafar.net/ linked-in @ http://www.linkedin.com/in/ashleymoran currently @ home From ben at benburkert.com Sat Nov 10 02:15:39 2007 From: ben at benburkert.com (Ben Burkert) Date: Sat, 10 Nov 2007 01:15:39 -0600 Subject: [rspec-users] autometric gem Message-ID: I'm working on tool to automatically run code metrics in the same way as autotest. It's runs rcov, flog, and saikuro right now, and works with rspec and rails. It's hosted at rubyforge: http://rubyforge.org/projects/autometric/ I've got a post on how to configure it with growl: http://benburkert.com/2007/11/9/introducing-autometric I'm hoping to get Heckle working soon. -Ben From pergesu at gmail.com Sat Nov 10 02:18:58 2007 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 9 Nov 2007 23:18:58 -0800 Subject: [rspec-users] autometric gem In-Reply-To: References: Message-ID: <810a540e0711092318r1ffbffb8g138a9dca5954dfb1@mail.gmail.com> Very nice! Can't wait to check this out. Pat On 11/9/07, Ben Burkert wrote: > I'm working on tool to automatically run code metrics in the same way > as autotest. It's runs rcov, flog, and saikuro right now, and works > with rspec and rails. It's hosted at rubyforge: > > http://rubyforge.org/projects/autometric/ > > I've got a post on how to configure it with growl: > > http://benburkert.com/2007/11/9/introducing-autometric > > I'm hoping to get Heckle working soon. > > -Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From work at ashleymoran.me.uk Sat Nov 10 04:26:18 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Sat, 10 Nov 2007 09:26:18 +0000 Subject: [rspec-users] autometric gem In-Reply-To: References: Message-ID: <53E3EDE9-6D0D-4C80-9B57-3D1886F0B631@ashleymoran.me.uk> On Nov 10, 2007, at 7:15 am, Ben Burkert wrote: > I'm hoping to get Heckle working soon. It all looks great! Don't wait a microsecond before announcing Heckle support! Will you do heckling on a spec -> class one-to-one mapping? I recently hacked up (and dumped on my blog) a quick Rake task for heckling but it was pretty limited, to heckle an entire codebase it needs to all sit inside one module. Ok for me, but not much good for Rails. Ashley -- blog @ http://aviewfromafar.net/ linked-in @ http://www.linkedin.com/in/ashleymoran currently @ home From aslak.hellesoy at gmail.com Sat Nov 10 08:45:13 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 10 Nov 2007 14:45:13 +0100 Subject: [rspec-users] autometric gem In-Reply-To: References: Message-ID: <8d961d900711100545r61a00bb8s3bf69b178d285ef4@mail.gmail.com> On 11/10/07, Ben Burkert wrote: > I'm working on tool to automatically run code metrics in the same way > as autotest. It's runs rcov, flog, and saikuro right now, and works > with rspec and rails. It's hosted at rubyforge: > > http://rubyforge.org/projects/autometric/ > > I've got a post on how to configure it with growl: > > http://benburkert.com/2007/11/9/introducing-autometric > > I'm hoping to get Heckle working soon. > This looks like a neat tool - all in one and easy to set up. Aslak > -Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From vertebrate at gmail.com Sat Nov 10 11:31:13 2007 From: vertebrate at gmail.com (Steve) Date: Sat, 10 Nov 2007 16:31:13 +0000 (UTC) Subject: [rspec-users] be_success misleading Message-ID: Just wondering if anyone else thinks that 'response.should be_success' is potentially misleading. If you're writing a spec for an action that is failing in some way it can still have a status 200. So while the HTTP request was technically successful, something in the action was not. Perhaps something like 'response.should have_success_status'? Steve From aslak.hellesoy at gmail.com Sat Nov 10 12:12:25 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 10 Nov 2007 18:12:25 +0100 Subject: [rspec-users] be_success misleading In-Reply-To: References: Message-ID: <8d961d900711100912w6f0435b2ye75287cef3ad166e@mail.gmail.com> be_success has the same semantics (and uses) Response#success? and that's not our API, but Rails' If you don't like Rails' semantics you can make your own matcher, but I don't want to invent a whole new API on top of Rails in the official Spec::Rails. Aslak On Nov 10, 2007 5:31 PM, Steve wrote: > Just wondering if anyone else thinks that 'response.should be_success' is > potentially misleading. If you're writing a spec for an action that is > failing in some way it can still have a status 200. So while the > HTTP request was technically successful, something in the action > was not. Perhaps something like 'response.should have_success_status'? > > Steve > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From caiomoritz at gmail.com Sat Nov 10 16:03:38 2007 From: caiomoritz at gmail.com (Caio Moritz Ronchi) Date: Sat, 10 Nov 2007 19:03:38 -0200 Subject: [rspec-users] Problem with view spec - works inside the browser but spec fails with nil object Message-ID: Hi, I've been trying to find an answer for this problem in the last couple hours, but I think no discussion was about this exact same thing. So here it goes, hope someone can help. I'm trying to spec a view which works correctly on the browser, but that generates the following error when I run "rake spec:views". ActionView::TemplateError in '/survey/show should display the "question 4" heading correctly' You have a nil object when you didn't expect it! The error occurred while evaluating nil.position On line #1 of app/views/survey/_question_for_candidate.rhtml 1:
2:

3: <%= question.position %>. 4: <%= question.description %> RSpec is telling me that the "question" object is nil. I can't figure it out why. Here's the spec that generates the error (the "it" block should test some tags inside the "response" object): require File.dirname(__FILE__) + '/../../spec_helper' describe '/survey/show' do fixtures 'questions', 'alternatives' before(:each) do assigns[:configurations] = {:survey_name => 'Whatever'} assigns[:questions] = Array.new assigns[:questions][4] = questions(:faixa_etaria) @faixa_etaria = questions(:faixa_etaria) end it 'should display the "question 4" heading correctly' do render 'survey/show' end end Here's the :faixa_etaria Question fixture I'm using: faixa_etaria: id: 1 question_type_id: 1 description: 'Em qual das faixas et?rias abaixo voc? se inclui?' position: 4 (The description value is in Portuguese). Here's the "show" method inside the SurveyController: def show @configurations = {} Configuration.find(:all).each { |c| @configurations[c.name.to_sym] = c.value } @questions = {} Question.find(:all).each { |q| @questions[q.position] = q } end Here's the piece of code inside the "show.rhtml" template that's calling the helper method that will cause that error: <%= render_question(@questions[4]) %> Here's the "render_question" method implementation, inside the SurveyHelper class (invoking "render" seems to be the problem, but I don't know why): def render_question(question) render(:partial => 'question_for_candidate', :locals => {:question => question}) end The :locals Hash has :question as a key, and that is the variable that RSpec is complaining about inside the partial. Finally, here's the "question_for_candidate" partial:

<%= question.position %>. <%= question.description %>

<% for alternative in question.alternatives -%> <%= radio_button 'candidate', "question_#{question.id}", alternative.id%>
<% end -%>
I'm not that experienced with Rails nor RSpec, so I'm totally lost about this problem. -- Caio Moritz Ronchi -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071110/0b7523d1/attachment.html From lesliefreeman3 at gmail.com Sun Nov 11 00:25:47 2007 From: lesliefreeman3 at gmail.com (Leslie Freeman) Date: Sat, 10 Nov 2007 22:25:47 -0700 Subject: [rspec-users] fixture_file_upload and edge rspec? In-Reply-To: <581F0596-A4E6-427C-A129-411BBF99F9FB@sunquake.net> References: <57c63afe0711090409v5e5b6e52l82856bedb76008c6@mail.gmail.com> <581F0596-A4E6-427C-A129-411BBF99F9FB@sunquake.net> Message-ID: To follow up on this a little more, I created a new project, froze rails to edge (REVISION_8125), and installed rspec/rspec on rails from trunk. Then I generated an rspec_model for Asset with the following spec: require File.dirname(__FILE__) + '/../spec_helper' describe Asset do before(:each) do @asset = Asset.new end it "should be valid" do @asset.should be_valid end it "should allow me to use fixture_file_upload" do @asset.attributes = {:uploaded_data => fixture_file_upload ('images/florence.jpg', 'image/jpeg')} end end I created an images directory in my spec/fixtures dir and added florence.jpg to it. Then, when I run rake spec I get this error: NoMethodError in 'Asset should allow me to use fixture_file_upload' You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.+ /Users/leslief/Sites/tmp/testapp/vendor/rails/actionpack/lib/ action_controller/test_process.rb:480:in `fixture_file_upload' ./spec/models/asset_spec.rb:13: /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ example_group_methods.rb:40:in `instance_eval' /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ example_group_methods.rb:40:in `run_example' /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ example_runner.rb:63:in `run_example' /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ example_runner.rb:24:in `run' /opt/local/lib/ruby/1.8/timeout.rb:48:in `timeout' /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ example_runner.rb:22:in `run' /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ example_suite.rb:26:in `rspec_run' /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ example_suite.rb:22:in `each' /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ example_suite.rb:22:in `rspec_run' /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/test/ unit/example_suite.rb:7:in `run' /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/runner/ behaviour_runner.rb:22:in `run' /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/runner/ behaviour_runner.rb:21:in `each' /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/runner/ behaviour_runner.rb:21:in `run' /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/runner/ options.rb:80:in `run_examples' /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/runner/ command_line.rb:19:in `run' /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/bin/spec:3: line 13 of asset_spec.rb is @asset.attributes = {:uploaded_data => fixture_file_upload('images/florence.jpg', 'image/jpeg')} the offending line in test_process.rb is: Test::Unit::TestCase.respond_to?(:fixture_path) ? Test::Unit::TestCase.fixture_path + path : path, mime_type, binary From the full function: def fixture_file_upload(path, mime_type = nil, binary = false) ActionController::TestUploadedFile.new( Test::Unit::TestCase.respond_to?(:fixture_path) ? Test::Unit::TestCase.fixture_path + path : path, mime_type, binary ) end so it seems like Test::Unit::TestCase.fixture_path is returning nil. I tried to do a little digging to find where this should be getting set, but quickly got way out to sea. My spec_helper does have this line: config.fixture_path = RAILS_ROOT + '/spec/fixtures/' which seems right. I am hoping someone that knows more about the inner gears of rspec has some insight as to why Test::Unit::TestCase.fixture_path is nil. Thanks, Les On Nov 9, 2007, at 8:25 AM, Leslie Freeman wrote: > > On Nov 9, 2007, at 5:09 AM, David Chelimsky wrote: > >> On Nov 8, 2007 11:25 PM, Leslie Freeman >> wrote: >>> Hi all, >>> I had some specs that were using fixture_file_upload that were >>> passing just fine. Then I froze edge rails to get some 2.0 >>> functionality, then a I upgraded to trunk rspec to deal with >>> >>> uninitialized constant ActionView::Helpers::JavaScriptMacrosHelper >>> >>> After a couple other of tribulations, I have now gotten down to just >>> a couple of not passing specs, all using the fixture_file_upload. >>> Here's an example >>> >>> it "should be invalid if uploaded file is not an image" do >>> @image.attributes = valid_image_attributes.merge >>> ({:uploaded_data >>> => fixture_file_upload('/textfile.txt', >>> >>> 'text/plain')}) >>> @image.should_not be_valid >>> # content_type: is not included in the list >>> @image.should have(1).error_on(:content_type) >>> end >>> >>> which fails with: >>> 2) >>> NoMethodError in 'Image unsaved should be invalid if uploaded >>> file is >>> not an image' >>> You have a nil object when you didn't expect it! >>> You might have expected an instance of Array. >>> The error occurred while evaluating nil.+ >>> ./spec/models/image_spec.rb:25: >> >> What's on line 25? > > Sorry about that confusion. Line 25 is: > > @image.attributes = valid_image_attributes.merge({:uploaded_data => > fixture_file_upload('/textfile.txt',text/plain')}) > > (textfile.txt is located in my /spec/fixtures/ dir.) > > That line doesn't throw the error if I change it to something like: > @image.attributes = valid_image_attributes.merge({:uploaded_data => > "foo"}) > > But of course the spec fails. :) > > Leslie > >> >>> >>> A less than helpful error message. Any insight into what might be >>> causing this? >>> >>> Thanks, >>> Les >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ben at benmabey.com Sun Nov 11 00:38:47 2007 From: ben at benmabey.com (Ben Mabey) Date: Sat, 10 Nov 2007 22:38:47 -0700 Subject: [rspec-users] Autotest with rspec HTML output Message-ID: <47369567.3010601@benmabey.com> Hey all, I was just wondering if any one has played around with getting autotest's rspec integration working with rspec's HTML output. I really like how in the rspec textmate bundle the context of the failing code is inlined with the failing spec along with the exact line highlighted and a link to the exact spot in reference. However, I rarely use this nice output since autotest is so convenient... So, I was thinking wouldn't it be great to have the best of both worlds? What do you think? And before I try and do this, has anyone else already done it? -Ben From hans at degraaff.org Sun Nov 11 03:01:27 2007 From: hans at degraaff.org (Hans de Graaff) Date: Sun, 11 Nov 2007 09:01:27 +0100 Subject: [rspec-users] Problem with view spec - works inside the browser but spec fails with nil object In-Reply-To: References: Message-ID: <1194768087.4837.11.camel@ip6-localhost> You are trying to test a lot of things at the same time, which is one of the reasons that it is now hard to diagnose a problem. I would tackle this by a) writing a separate spec for the partial _question_for_candidate b) write a separate spec for the helper that renders the question b) in the view spec for /survey/show use should_receive to determine that the helper is actually being called c) not use any fixtures in the view specs but instead use mocks for that: it's faster and you can check exactly what needs to happen instead of relying on what happens to be in the fixture. I'm afraid that I don't see immediately why your current setup won't work, but untangling things along the lines sketched above should hopefully get you to a situation where it becomes easier to see what happens. > before(:each) do > assigns[:configurations] = {:survey_name => 'Whatever'} > assigns[:questions] = Array.new > assigns[:questions][4] = questions(:faixa_etaria) I am a little bit suspicious about this construction, though. I'm not sure whether assigns is a normal Array in this case, so I'd create the Array and populate it before handing it to assigns: @questions = Array.new @questions[4] = ... assigns[:questions] = @questions Kind regards, Hans -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://rubyforge.org/pipermail/rspec-users/attachments/20071111/a479f059/attachment.bin From aslak.hellesoy at gmail.com Sun Nov 11 07:29:44 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 11 Nov 2007 13:29:44 +0100 Subject: [rspec-users] Autotest with rspec HTML output In-Reply-To: <47369567.3010601@benmabey.com> References: <47369567.3010601@benmabey.com> Message-ID: <8d961d900711110429q4c62eb90y4ac581bd97ab3d97@mail.gmail.com> Where would the HTML report be displayed? On Nov 11, 2007 6:38 AM, Ben Mabey wrote: > Hey all, > I was just wondering if any one has played around with getting > autotest's rspec integration working with rspec's HTML output. I really > like how in the rspec textmate bundle the context of the failing code > is inlined with the failing spec along with the exact line highlighted > and a link to the exact spot in reference. However, I rarely use this > nice output since autotest is so convenient... So, I was thinking > wouldn't it be great to have the best of both worlds? What do you > think? And before I try and do this, has anyone else already done it? > > > -Ben > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From work at ashleymoran.me.uk Sun Nov 11 08:07:08 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Sun, 11 Nov 2007 13:07:08 +0000 Subject: [rspec-users] Autotest with rspec HTML output In-Reply-To: <8d961d900711110429q4c62eb90y4ac581bd97ab3d97@mail.gmail.com> References: <47369567.3010601@benmabey.com> <8d961d900711110429q4c62eb90y4ac581bd97ab3d97@mail.gmail.com> Message-ID: On Nov 11, 2007, at 12:29 pm, aslak hellesoy wrote: > Where would the HTML report be displayed? The Quick Look feature in Leopard can be controlled from the command line using qlmanage, if that is worth looking into. Obviously, no good to non-Mac users though Ashley -- blog @ http://aviewfromafar.net/ linked-in @ http://www.linkedin.com/in/ashleymoran currently @ home From dchelimsky at gmail.com Sun Nov 11 08:45:14 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 11 Nov 2007 07:45:14 -0600 Subject: [rspec-users] be_success misleading In-Reply-To: <8d961d900711100912w6f0435b2ye75287cef3ad166e@mail.gmail.com> References: <8d961d900711100912w6f0435b2ye75287cef3ad166e@mail.gmail.com> Message-ID: <57c63afe0711110545g71ff9b83q99f400e7681acea3@mail.gmail.com> On Nov 10, 2007 11:12 AM, aslak hellesoy wrote: > be_success has the same semantics (and uses) Response#success? and > that's not our API, but Rails' > > If you don't like Rails' semantics you can make your own matcher, but > I don't want to invent a whole new API on top of Rails in the official > Spec::Rails. +1 David ps - Aslak, what gives w/ the top posting? > > Aslak > > > On Nov 10, 2007 5:31 PM, Steve wrote: > > Just wondering if anyone else thinks that 'response.should be_success' is > > potentially misleading. If you're writing a spec for an action that is > > failing in some way it can still have a status 200. So while the > > HTTP request was technically successful, something in the action > > was not. Perhaps something like 'response.should have_success_status'? > > > > Steve From dchelimsky at gmail.com Sun Nov 11 08:51:26 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 11 Nov 2007 07:51:26 -0600 Subject: [rspec-users] fixture_file_upload and edge rspec? In-Reply-To: References: <57c63afe0711090409v5e5b6e52l82856bedb76008c6@mail.gmail.com> <581F0596-A4E6-427C-A129-411BBF99F9FB@sunquake.net> Message-ID: <57c63afe0711110551o33ae85d7u2292f953fafad2a@mail.gmail.com> On Nov 10, 2007 11:25 PM, Leslie Freeman wrote: > To follow up on this a little more, I created a new project, froze > rails to edge (REVISION_8125), and installed rspec/rspec on rails > from trunk. Then I generated an rspec_model for Asset with the > following spec: > > require File.dirname(__FILE__) + '/../spec_helper' > > describe Asset do > before(:each) do > @asset = Asset.new > end > > it "should be valid" do > @asset.should be_valid > end > > it "should allow me to use fixture_file_upload" do > @asset.attributes = {:uploaded_data => fixture_file_upload > ('images/florence.jpg', 'image/jpeg')} > end > end > > I created an images directory in my spec/fixtures dir and added > florence.jpg to it. Then, when I run rake spec I get this error: > > NoMethodError in 'Asset should allow me to use fixture_file_upload' I am not familiar w/ fixture_file_upload myself. Is there anyone else on this list who is who can help Les debug this situation? Thanks, David > You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.+ > /Users/leslief/Sites/tmp/testapp/vendor/rails/actionpack/lib/ > action_controller/test_process.rb:480:in `fixture_file_upload' > ./spec/models/asset_spec.rb:13: > /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > example_group_methods.rb:40:in `instance_eval' > /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > example_group_methods.rb:40:in `run_example' > /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > example_runner.rb:63:in `run_example' > /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > example_runner.rb:24:in `run' > /opt/local/lib/ruby/1.8/timeout.rb:48:in `timeout' > /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > example_runner.rb:22:in `run' > /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > example_suite.rb:26:in `rspec_run' > /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > example_suite.rb:22:in `each' > /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > example_suite.rb:22:in `rspec_run' > /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/test/ > unit/example_suite.rb:7:in `run' > /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/runner/ > behaviour_runner.rb:22:in `run' > /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/runner/ > behaviour_runner.rb:21:in `each' > /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/runner/ > behaviour_runner.rb:21:in `run' > /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/runner/ > options.rb:80:in `run_examples' > /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/runner/ > command_line.rb:19:in `run' > /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/bin/spec:3: > > line 13 of asset_spec.rb is @asset.attributes = {:uploaded_data => > fixture_file_upload('images/florence.jpg', 'image/jpeg')} > > the offending line in test_process.rb is: > Test::Unit::TestCase.respond_to?(:fixture_path) ? > Test::Unit::TestCase.fixture_path + path : path, mime_type, binary > > From the full function: > def fixture_file_upload(path, mime_type = nil, binary = false) > ActionController::TestUploadedFile.new( > Test::Unit::TestCase.respond_to?(:fixture_path) ? > Test::Unit::TestCase.fixture_path + path : path, > mime_type, > binary > ) > end > > so it seems like Test::Unit::TestCase.fixture_path is returning nil. > I tried to do a little digging to find where this should be getting > set, but quickly got way out to sea. > > My spec_helper does have this line: > config.fixture_path = RAILS_ROOT + '/spec/fixtures/' > > which seems right. I am hoping someone that knows more about the > inner gears of rspec has some insight as to why > Test::Unit::TestCase.fixture_path is nil. > > Thanks, > Les > > > > On Nov 9, 2007, at 8:25 AM, Leslie Freeman wrote: > > > > > On Nov 9, 2007, at 5:09 AM, David Chelimsky wrote: > > > >> On Nov 8, 2007 11:25 PM, Leslie Freeman > >> wrote: > >>> Hi all, > >>> I had some specs that were using fixture_file_upload that were > >>> passing just fine. Then I froze edge rails to get some 2.0 > >>> functionality, then a I upgraded to trunk rspec to deal with > >>> > >>> uninitialized constant ActionView::Helpers::JavaScriptMacrosHelper > >>> > >>> After a couple other of tribulations, I have now gotten down to just > >>> a couple of not passing specs, all using the fixture_file_upload. > >>> Here's an example > >>> > >>> it "should be invalid if uploaded file is not an image" do > >>> @image.attributes = valid_image_attributes.merge > >>> ({:uploaded_data > >>> => fixture_file_upload('/textfile.txt', > >>> > >>> 'text/plain')}) > >>> @image.should_not be_valid > >>> # content_type: is not included in the list > >>> @image.should have(1).error_on(:content_type) > >>> end > >>> > >>> which fails with: > >>> 2) > >>> NoMethodError in 'Image unsaved should be invalid if uploaded > >>> file is > >>> not an image' > >>> You have a nil object when you didn't expect it! > >>> You might have expected an instance of Array. > >>> The error occurred while evaluating nil.+ > >>> ./spec/models/image_spec.rb:25: > >> > >> What's on line 25? > > > > Sorry about that confusion. Line 25 is: > > > > @image.attributes = valid_image_attributes.merge({:uploaded_data => > > fixture_file_upload('/textfile.txt',text/plain')}) > > > > (textfile.txt is located in my /spec/fixtures/ dir.) > > > > That line doesn't throw the error if I change it to something like: > > @image.attributes = valid_image_attributes.merge({:uploaded_data => > > "foo"}) > > > > But of course the spec fails. :) > > > > Leslie > > > >> > >>> > >>> A less than helpful error message. Any insight into what might be > >>> causing this? > >>> > >>> Thanks, > >>> Les > >>> _______________________________________________ > >>> rspec-users mailing list > >>> rspec-users at rubyforge.org > >>> http://rubyforge.org/mailman/listinfo/rspec-users > >>> > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Sun Nov 11 10:33:50 2007 From: ben at benmabey.com (Ben Mabey) Date: Sun, 11 Nov 2007 08:33:50 -0700 Subject: [rspec-users] Autotest with rspec HTML output In-Reply-To: <8d961d900711110429q4c62eb90y4ac581bd97ab3d97@mail.gmail.com> References: <47369567.3010601@benmabey.com> <8d961d900711110429q4c62eb90y4ac581bd97ab3d97@mail.gmail.com> Message-ID: <473720DE.7000500@benmabey.com> I was thinking that a little window(cocoa) or maybe just a browser window could display the summary of the test run like autotest does and then the failed specs in HTML format. Not the entire HTML report would be generated/displayed- only the failing ones would be so it would be manageable on projects with large test suites. So, instead of having a terminal window open with autotest it would just be a stand alone window. aslak hellesoy wrote: > Where would the HTML report be displayed? > > On Nov 11, 2007 6:38 AM, Ben Mabey wrote: > >> Hey all, >> I was just wondering if any one has played around with getting >> autotest's rspec integration working with rspec's HTML output. I really >> like how in the rspec textmate bundle the context of the failing code >> is inlined with the failing spec along with the exact line highlighted >> and a link to the exact spot in reference. However, I rarely use this >> nice output since autotest is so convenient... So, I was thinking >> wouldn't it be great to have the best of both worlds? What do you >> think? And before I try and do this, has anyone else already done it? >> >> >> -Ben >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Sun Nov 11 10:34:46 2007 From: ben at benmabey.com (Ben Mabey) Date: Sun, 11 Nov 2007 08:34:46 -0700 Subject: [rspec-users] Autotest with rspec HTML output In-Reply-To: References: <47369567.3010601@benmabey.com> <8d961d900711110429q4c62eb90y4ac581bd97ab3d97@mail.gmail.com> Message-ID: <47372116.1040406@benmabey.com> Ashley Moran wrote: > On Nov 11, 2007, at 12:29 pm, aslak hellesoy wrote: > > >> Where would the HTML report be displayed? >> > > The Quick Look feature in Leopard can be controlled from the command > line using qlmanage, if that is worth looking into. Obviously, no > good to non-Mac users though > > Ashley > > > > Thanks for the tip Ashley! I'll look into it! -Bne From aslak.hellesoy at gmail.com Sun Nov 11 11:21:34 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 11 Nov 2007 17:21:34 +0100 Subject: [rspec-users] Autotest with rspec HTML output In-Reply-To: <473720DE.7000500@benmabey.com> References: <47369567.3010601@benmabey.com> <8d961d900711110429q4c62eb90y4ac581bd97ab3d97@mail.gmail.com> <473720DE.7000500@benmabey.com> Message-ID: <8d961d900711110821v5f1d5626gc83d573be01cfb59@mail.gmail.com> On Nov 11, 2007 4:33 PM, Ben Mabey wrote: > > I was thinking that a little window(cocoa) or maybe just a browser > window could display the summary of the test run like autotest does and > then the failed specs in HTML format. Not the entire HTML report would > be generated/displayed- only the failing ones would be so it would be > manageable on projects with large test suites. So, instead of having a > terminal window open with autotest it would just be a stand alone window. > I think the simplest and best thing here would be a pure browser solution with autorefresh. It should only be a matter of tweaking the HTML output a little to: * Implement autorefresh. Ajax based would require a lite server (webrick). Or just META refresh would work on the file system. * Tweak the HTML output to only output the red specs, not the green ones. I don't like the cocoa idea - too proprietary. The qlmanage wouldn't provide much value beyond growl bubbles. You wanted to click on the HTML and go to the editor right? Aslak > > aslak hellesoy wrote: > > Where would the HTML report be displayed? > > > > On Nov 11, 2007 6:38 AM, Ben Mabey wrote: > > > >> Hey all, > >> I was just wondering if any one has played around with getting > >> autotest's rspec integration working with rspec's HTML output. I really > >> like how in the rspec textmate bundle the context of the failing code > >> is inlined with the failing spec along with the exact line highlighted > >> and a link to the exact spot in reference. However, I rarely use this > >> nice output since autotest is so convenient... So, I was thinking > >> wouldn't it be great to have the best of both worlds? What do you > >> think? And before I try and do this, has anyone else already done it? > >> > >> > >> -Ben > >> > >> > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > >> > >> > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From leslief at sunquake.net Sun Nov 11 11:29:20 2007 From: leslief at sunquake.net (Leslie Freeman) Date: Sun, 11 Nov 2007 09:29:20 -0700 Subject: [rspec-users] fixture_file_upload and edge rspec? In-Reply-To: <57c63afe0711110551o33ae85d7u2292f953fafad2a@mail.gmail.com> References: <57c63afe0711090409v5e5b6e52l82856bedb76008c6@mail.gmail.com> <581F0596-A4E6-427C-A129-411BBF99F9FB@sunquake.net> <57c63afe0711110551o33ae85d7u2292f953fafad2a@mail.gmail.com> Message-ID: <9BFE53AE-9473-4D55-80E5-030F7005B3F7@sunquake.net> Slowly digging to the bottom of this one. If I add Test::Unit::TestCase.fixture_path = RAILS_ROOT + '/spec/fixtures/' to my spec_helper.rb, then everything runs fine. So presumably there is somewhere that config.fixture_path from the Spec::Runner.configure block is supposed to get put into Test::Unit::TestCase.fixture_path, and for some reason that is no longer happening. I will continue to dig into this problem, but if anyone is familiar with this part of the rspec system and can help me get to the right place faster, I'd sure appreciate it. Les On Nov 11, 2007, at 6:51 AM, David Chelimsky wrote: > On Nov 10, 2007 11:25 PM, Leslie Freeman > wrote: >> To follow up on this a little more, I created a new project, froze >> rails to edge (REVISION_8125), and installed rspec/rspec on rails >> from trunk. Then I generated an rspec_model for Asset with the >> following spec: >> >> require File.dirname(__FILE__) + '/../spec_helper' >> >> describe Asset do >> before(:each) do >> @asset = Asset.new >> end >> >> it "should be valid" do >> @asset.should be_valid >> end >> >> it "should allow me to use fixture_file_upload" do >> @asset.attributes = {:uploaded_data => fixture_file_upload >> ('images/florence.jpg', 'image/jpeg')} >> end >> end >> >> I created an images directory in my spec/fixtures dir and added >> florence.jpg to it. Then, when I run rake spec I get this error: >> >> NoMethodError in 'Asset should allow me to use fixture_file_upload' > > I am not familiar w/ fixture_file_upload myself. Is there anyone else > on this list who is who can help Les debug this situation? > > Thanks, > David > >> You have a nil object when you didn't expect it! >> You might have expected an instance of Array. >> The error occurred while evaluating nil.+ >> /Users/leslief/Sites/tmp/testapp/vendor/rails/actionpack/lib/ >> action_controller/test_process.rb:480:in `fixture_file_upload' >> ./spec/models/asset_spec.rb:13: >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ >> example_group_methods.rb:40:in `instance_eval' >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ >> example_group_methods.rb:40:in `run_example' >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ >> example_runner.rb:63:in `run_example' >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ >> example_runner.rb:24:in `run' >> /opt/local/lib/ruby/1.8/timeout.rb:48:in `timeout' >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ >> example_runner.rb:22:in `run' >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ >> example_suite.rb:26:in `rspec_run' >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ >> example_suite.rb:22:in `each' >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ >> example_suite.rb:22:in `rspec_run' >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/test/ >> unit/example_suite.rb:7:in `run' >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >> runner/ >> behaviour_runner.rb:22:in `run' >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >> runner/ >> behaviour_runner.rb:21:in `each' >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >> runner/ >> behaviour_runner.rb:21:in `run' >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >> runner/ >> options.rb:80:in `run_examples' >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >> runner/ >> command_line.rb:19:in `run' >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/bin/spec:3: >> >> line 13 of asset_spec.rb is @asset.attributes = {:uploaded_data => >> fixture_file_upload('images/florence.jpg', 'image/jpeg')} >> >> the offending line in test_process.rb is: >> Test::Unit::TestCase.respond_to?(:fixture_path) ? >> Test::Unit::TestCase.fixture_path + path : path, mime_type, binary >> >> From the full function: >> def fixture_file_upload(path, mime_type = nil, binary = false) >> ActionController::TestUploadedFile.new( >> Test::Unit::TestCase.respond_to?(:fixture_path) ? >> Test::Unit::TestCase.fixture_path + path : path, >> mime_type, >> binary >> ) >> end >> >> so it seems like Test::Unit::TestCase.fixture_path is returning nil. >> I tried to do a little digging to find where this should be getting >> set, but quickly got way out to sea. >> >> My spec_helper does have this line: >> config.fixture_path = RAILS_ROOT + '/spec/fixtures/' >> >> which seems right. I am hoping someone that knows more about the >> inner gears of rspec has some insight as to why >> Test::Unit::TestCase.fixture_path is nil. >> >> Thanks, >> Les >> >> >> >> On Nov 9, 2007, at 8:25 AM, Leslie Freeman wrote: >> >>> >>> On Nov 9, 2007, at 5:09 AM, David Chelimsky wrote: >>> >>>> On Nov 8, 2007 11:25 PM, Leslie Freeman >>>> wrote: >>>>> Hi all, >>>>> I had some specs that were using fixture_file_upload that were >>>>> passing just fine. Then I froze edge rails to get some 2.0 >>>>> functionality, then a I upgraded to trunk rspec to deal with >>>>> >>>>> uninitialized constant ActionView::Helpers::JavaScriptMacrosHelper >>>>> >>>>> After a couple other of tribulations, I have now gotten down to >>>>> just >>>>> a couple of not passing specs, all using the fixture_file_upload. >>>>> Here's an example >>>>> >>>>> it "should be invalid if uploaded file is not an image" do >>>>> @image.attributes = valid_image_attributes.merge >>>>> ({:uploaded_data >>>>> => fixture_file_upload('/textfile.txt', >>>>> >>>>> 'text/plain')}) >>>>> @image.should_not be_valid >>>>> # content_type: is not included in the list >>>>> @image.should have(1).error_on(:content_type) >>>>> end >>>>> >>>>> which fails with: >>>>> 2) >>>>> NoMethodError in 'Image unsaved should be invalid if uploaded >>>>> file is >>>>> not an image' >>>>> You have a nil object when you didn't expect it! >>>>> You might have expected an instance of Array. >>>>> The error occurred while evaluating nil.+ >>>>> ./spec/models/image_spec.rb:25: >>>> >>>> What's on line 25? >>> >>> Sorry about that confusion. Line 25 is: >>> >>> @image.attributes = valid_image_attributes.merge({:uploaded_data => >>> fixture_file_upload('/textfile.txt',text/plain')}) >>> >>> (textfile.txt is located in my /spec/fixtures/ dir.) >>> >>> That line doesn't throw the error if I change it to something like: >>> @image.attributes = valid_image_attributes.merge({:uploaded_data => >>> "foo"}) >>> >>> But of course the spec fails. :) >>> >>> Leslie >>> >>>> >>>>> >>>>> A less than helpful error message. Any insight into what might be >>>>> causing this? >>>>> >>>>> Thanks, >>>>> Les >>>>> _______________________________________________ >>>>> rspec-users mailing list >>>>> rspec-users at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From a.schur at nucleus.com Sun Nov 11 12:01:04 2007 From: a.schur at nucleus.com (Alvin Schur) Date: Sun, 11 Nov 2007 10:01:04 -0700 Subject: [rspec-users] Running specs in reverse In-Reply-To: References: Message-ID: <47373550.5090801@nucleus.com> > On Nov 08, 2007, at 6:07 pm, Alvin Schur wrote: > > >> My goal is to detect inter-dependencies sooner than later... >> > > > I have to say I've NEVER run specs backwards. Am I sitting on a time > bomb? Are there subtle traps that can create inter-dependencies > between specs? To look at my specs I would not assume that running > order matters - I don't think I've ever used before(:all) for example. > > Ashkey > Our team uses Test::Unit and numerous inter-dependencies have crept in. Our team is also slowly moving to rspec. Part of resolving the inter-dependencies is: 1) education 2) early detection I don't want to be the "dependency police" particularly if rspec can do the job automatically for everyone on the team. Alvin. From dchelimsky at gmail.com Sun Nov 11 12:47:34 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 11 Nov 2007 11:47:34 -0600 Subject: [rspec-users] Running specs in reverse In-Reply-To: <47373550.5090801@nucleus.com> References: <47373550.5090801@nucleus.com> Message-ID: <57c63afe0711110947m573c9708pb0bc01ce433a3112@mail.gmail.com> On Nov 11, 2007 11:01 AM, Alvin Schur wrote: > > > On Nov 08, 2007, at 6:07 pm, Alvin Schur wrote: > > > > > >> My goal is to detect inter-dependencies sooner than later... > >> > > > > > > I have to say I've NEVER run specs backwards. Am I sitting on a time > > bomb? Are there subtle traps that can create inter-dependencies > > between specs? To look at my specs I would not assume that running > > order matters - I don't think I've ever used before(:all) for example. > > > > Ashkey > > > Our team uses Test::Unit and numerous inter-dependencies have crept in. > Our team is also slowly moving to rspec. > > Part of resolving the inter-dependencies is: > > 1) education > 2) early detection > > I don't want to be the "dependency police" particularly if rspec can do > the job automatically for everyone on the team. Well - I don't think rspec should do this implicitly - that might cause quite a bit of confusion for unsuspecting devs trying to debug. I command line arg like --toggle_reverse might work - but you'll have to submit a feature request in the tracker and probably a patch if you want to see it any time soon. Very low priority on my list. > > Alvin. > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From brian.takita at gmail.com Sun Nov 11 15:36:23 2007 From: brian.takita at gmail.com (Brian Takita) Date: Sun, 11 Nov 2007 12:36:23 -0800 Subject: [rspec-users] fixture_file_upload and edge rspec? In-Reply-To: <9BFE53AE-9473-4D55-80E5-030F7005B3F7@sunquake.net> References: <57c63afe0711090409v5e5b6e52l82856bedb76008c6@mail.gmail.com> <581F0596-A4E6-427C-A129-411BBF99F9FB@sunquake.net> <57c63afe0711110551o33ae85d7u2292f953fafad2a@mail.gmail.com> <9BFE53AE-9473-4D55-80E5-030F7005B3F7@sunquake.net> Message-ID: <1d7ddd110711111236m2bb56654q9b099d95e04f34e1@mail.gmail.com> On Nov 11, 2007 8:29 AM, Leslie Freeman wrote: > Slowly digging to the bottom of this one. > > If I add > > Test::Unit::TestCase.fixture_path = RAILS_ROOT + '/spec/fixtures/' > > to my spec_helper.rb, then everything runs fine. So presumably there > is somewhere that config.fixture_path from the Spec::Runner.configure > block is supposed to get put into Test::Unit::TestCase.fixture_path, > and for some reason that is no longer happening. I will continue to > dig into this problem, but if anyone is familiar with this part of > the rspec system and can help me get to the right place faster, I'd > sure appreciate it. It looks like rails changed. For now just set Test::Unit::TestCase.fixture_path. Ill come up with a fix in rspec core. > > Les > > > > On Nov 11, 2007, at 6:51 AM, David Chelimsky wrote: > > > On Nov 10, 2007 11:25 PM, Leslie Freeman > > wrote: > >> To follow up on this a little more, I created a new project, froze > >> rails to edge (REVISION_8125), and installed rspec/rspec on rails > >> from trunk. Then I generated an rspec_model for Asset with the > >> following spec: > >> > >> require File.dirname(__FILE__) + '/../spec_helper' > >> > >> describe Asset do > >> before(:each) do > >> @asset = Asset.new > >> end > >> > >> it "should be valid" do > >> @asset.should be_valid > >> end > >> > >> it "should allow me to use fixture_file_upload" do > >> @asset.attributes = {:uploaded_data => fixture_file_upload > >> ('images/florence.jpg', 'image/jpeg')} > >> end > >> end > >> > >> I created an images directory in my spec/fixtures dir and added > >> florence.jpg to it. Then, when I run rake spec I get this error: > >> > >> NoMethodError in 'Asset should allow me to use fixture_file_upload' > > > > I am not familiar w/ fixture_file_upload myself. Is there anyone else > > on this list who is who can help Les debug this situation? > > > > Thanks, > > David > > > >> You have a nil object when you didn't expect it! > >> You might have expected an instance of Array. > >> The error occurred while evaluating nil.+ > >> /Users/leslief/Sites/tmp/testapp/vendor/rails/actionpack/lib/ > >> action_controller/test_process.rb:480:in `fixture_file_upload' > >> ./spec/models/asset_spec.rb:13: > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > >> example_group_methods.rb:40:in `instance_eval' > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > >> example_group_methods.rb:40:in `run_example' > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > >> example_runner.rb:63:in `run_example' > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > >> example_runner.rb:24:in `run' > >> /opt/local/lib/ruby/1.8/timeout.rb:48:in `timeout' > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > >> example_runner.rb:22:in `run' > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > >> example_suite.rb:26:in `rspec_run' > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > >> example_suite.rb:22:in `each' > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > >> example_suite.rb:22:in `rspec_run' > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/test/ > >> unit/example_suite.rb:7:in `run' > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ > >> runner/ > >> behaviour_runner.rb:22:in `run' > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ > >> runner/ > >> behaviour_runner.rb:21:in `each' > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ > >> runner/ > >> behaviour_runner.rb:21:in `run' > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ > >> runner/ > >> options.rb:80:in `run_examples' > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ > >> runner/ > >> command_line.rb:19:in `run' > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/bin/spec:3: > >> > >> line 13 of asset_spec.rb is @asset.attributes = {:uploaded_data => > >> fixture_file_upload('images/florence.jpg', 'image/jpeg')} > >> > >> the offending line in test_process.rb is: > >> Test::Unit::TestCase.respond_to?(:fixture_path) ? > >> Test::Unit::TestCase.fixture_path + path : path, mime_type, binary > >> > >> From the full function: > >> def fixture_file_upload(path, mime_type = nil, binary = false) > >> ActionController::TestUploadedFile.new( > >> Test::Unit::TestCase.respond_to?(:fixture_path) ? > >> Test::Unit::TestCase.fixture_path + path : path, > >> mime_type, > >> binary > >> ) > >> end > >> > >> so it seems like Test::Unit::TestCase.fixture_path is returning nil. > >> I tried to do a little digging to find where this should be getting > >> set, but quickly got way out to sea. > >> > >> My spec_helper does have this line: > >> config.fixture_path = RAILS_ROOT + '/spec/fixtures/' > >> > >> which seems right. I am hoping someone that knows more about the > >> inner gears of rspec has some insight as to why > >> Test::Unit::TestCase.fixture_path is nil. > >> > >> Thanks, > >> Les > >> > >> > >> > >> On Nov 9, 2007, at 8:25 AM, Leslie Freeman wrote: > >> > >>> > >>> On Nov 9, 2007, at 5:09 AM, David Chelimsky wrote: > >>> > >>>> On Nov 8, 2007 11:25 PM, Leslie Freeman > >>>> wrote: > >>>>> Hi all, > >>>>> I had some specs that were using fixture_file_upload that were > >>>>> passing just fine. Then I froze edge rails to get some 2.0 > >>>>> functionality, then a I upgraded to trunk rspec to deal with > >>>>> > >>>>> uninitialized constant ActionView::Helpers::JavaScriptMacrosHelper > >>>>> > >>>>> After a couple other of tribulations, I have now gotten down to > >>>>> just > >>>>> a couple of not passing specs, all using the fixture_file_upload. > >>>>> Here's an example > >>>>> > >>>>> it "should be invalid if uploaded file is not an image" do > >>>>> @image.attributes = valid_image_attributes.merge > >>>>> ({:uploaded_data > >>>>> => fixture_file_upload('/textfile.txt', > >>>>> > >>>>> 'text/plain')}) > >>>>> @image.should_not be_valid > >>>>> # content_type: is not included in the list > >>>>> @image.should have(1).error_on(:content_type) > >>>>> end > >>>>> > >>>>> which fails with: > >>>>> 2) > >>>>> NoMethodError in 'Image unsaved should be invalid if uploaded > >>>>> file is > >>>>> not an image' > >>>>> You have a nil object when you didn't expect it! > >>>>> You might have expected an instance of Array. > >>>>> The error occurred while evaluating nil.+ > >>>>> ./spec/models/image_spec.rb:25: > >>>> > >>>> What's on line 25? > >>> > >>> Sorry about that confusion. Line 25 is: > >>> > >>> @image.attributes = valid_image_attributes.merge({:uploaded_data => > >>> fixture_file_upload('/textfile.txt',text/plain')}) > >>> > >>> (textfile.txt is located in my /spec/fixtures/ dir.) > >>> > >>> That line doesn't throw the error if I change it to something like: > >>> @image.attributes = valid_image_attributes.merge({:uploaded_data => > >>> "foo"}) > >>> > >>> But of course the spec fails. :) > >>> > >>> Leslie > >>> > >>>> > >>>>> > >>>>> A less than helpful error message. Any insight into what might be > >>>>> causing this? > >>>>> > >>>>> Thanks, > >>>>> Les > >>>>> _______________________________________________ > >>>>> rspec-users mailing list > >>>>> rspec-users at rubyforge.org > >>>>> http://rubyforge.org/mailman/listinfo/rspec-users > >>>>> > >>>> _______________________________________________ > >>>> rspec-users mailing list > >>>> rspec-users at rubyforge.org > >>>> http://rubyforge.org/mailman/listinfo/rspec-users > >>> > >>> _______________________________________________ > >>> rspec-users mailing list > >>> rspec-users at rubyforge.org > >>> http://rubyforge.org/mailman/listinfo/rspec-users > >> > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > >> > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From badcarl at gmail.com Sun Nov 11 16:42:53 2007 From: badcarl at gmail.com (Carl Porth) Date: Sun, 11 Nov 2007 13:42:53 -0800 Subject: [rspec-users] fixture_file_upload and edge rspec? In-Reply-To: <9BFE53AE-9473-4D55-80E5-030F7005B3F7@sunquake.net> References: <57c63afe0711090409v5e5b6e52l82856bedb76008c6@mail.gmail.com> <581F0596-A4E6-427C-A129-411BBF99F9FB@sunquake.net> <57c63afe0711110551o33ae85d7u2292f953fafad2a@mail.gmail.com> <9BFE53AE-9473-4D55-80E5-030F7005B3F7@sunquake.net> Message-ID: On Nov 11, 2007, at 8:29 AM, Leslie Freeman wrote: > Slowly digging to the bottom of this one. > > If I add > > Test::Unit::TestCase.fixture_path = RAILS_ROOT + '/spec/fixtures/' > > to my spec_helper.rb, then everything runs fine. So presumably there > is somewhere that config.fixture_path from the Spec::Runner.configure > block is supposed to get put into Test::Unit::TestCase.fixture_path, > and for some reason that is no longer happening. I will continue to > dig into this problem, but if anyone is familiar with this part of > the rspec system and can help me get to the right place faster, I'd > sure appreciate it. > > Les fixture_file_upload is just a convenience method to call ActionController::TestUploadedFile.new. I just call ActionController::TestUploadedFile.new directly in my own helper method with the complete path to the file. This avoids any need to mess with fixture_path. Carl > > > > On Nov 11, 2007, at 6:51 AM, David Chelimsky wrote: > >> On Nov 10, 2007 11:25 PM, Leslie Freeman >> wrote: >>> To follow up on this a little more, I created a new project, froze >>> rails to edge (REVISION_8125), and installed rspec/rspec on rails >>> from trunk. Then I generated an rspec_model for Asset with the >>> following spec: >>> >>> require File.dirname(__FILE__) + '/../spec_helper' >>> >>> describe Asset do >>> before(:each) do >>> @asset = Asset.new >>> end >>> >>> it "should be valid" do >>> @asset.should be_valid >>> end >>> >>> it "should allow me to use fixture_file_upload" do >>> @asset.attributes = {:uploaded_data => fixture_file_upload >>> ('images/florence.jpg', 'image/jpeg')} >>> end >>> end >>> >>> I created an images directory in my spec/fixtures dir and added >>> florence.jpg to it. Then, when I run rake spec I get this error: >>> >>> NoMethodError in 'Asset should allow me to use fixture_file_upload' >> >> I am not familiar w/ fixture_file_upload myself. Is there anyone else >> on this list who is who can help Les debug this situation? >> >> Thanks, >> David >> >>> You have a nil object when you didn't expect it! >>> You might have expected an instance of Array. >>> The error occurred while evaluating nil.+ >>> /Users/leslief/Sites/tmp/testapp/vendor/rails/actionpack/lib/ >>> action_controller/test_process.rb:480:in `fixture_file_upload' >>> ./spec/models/asset_spec.rb:13: >>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ >>> example_group_methods.rb:40:in `instance_eval' >>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ >>> example_group_methods.rb:40:in `run_example' >>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ >>> example_runner.rb:63:in `run_example' >>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ >>> example_runner.rb:24:in `run' >>> /opt/local/lib/ruby/1.8/timeout.rb:48:in `timeout' >>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ >>> example_runner.rb:22:in `run' >>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ >>> example_suite.rb:26:in `rspec_run' >>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ >>> example_suite.rb:22:in `each' >>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ >>> example_suite.rb:22:in `rspec_run' >>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/test/ >>> unit/example_suite.rb:7:in `run' >>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >>> runner/ >>> behaviour_runner.rb:22:in `run' >>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >>> runner/ >>> behaviour_runner.rb:21:in `each' >>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >>> runner/ >>> behaviour_runner.rb:21:in `run' >>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >>> runner/ >>> options.rb:80:in `run_examples' >>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >>> runner/ >>> command_line.rb:19:in `run' >>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/bin/spec:3: >>> >>> line 13 of asset_spec.rb is @asset.attributes = {:uploaded_data => >>> fixture_file_upload('images/florence.jpg', 'image/jpeg')} >>> >>> the offending line in test_process.rb is: >>> Test::Unit::TestCase.respond_to?(:fixture_path) ? >>> Test::Unit::TestCase.fixture_path + path : path, mime_type, binary >>> >>> From the full function: >>> def fixture_file_upload(path, mime_type = nil, binary = false) >>> ActionController::TestUploadedFile.new( >>> Test::Unit::TestCase.respond_to?(:fixture_path) ? >>> Test::Unit::TestCase.fixture_path + path : path, >>> mime_type, >>> binary >>> ) >>> end >>> >>> so it seems like Test::Unit::TestCase.fixture_path is returning nil. >>> I tried to do a little digging to find where this should be getting >>> set, but quickly got way out to sea. >>> >>> My spec_helper does have this line: >>> config.fixture_path = RAILS_ROOT + '/spec/fixtures/' >>> >>> which seems right. I am hoping someone that knows more about the >>> inner gears of rspec has some insight as to why >>> Test::Unit::TestCase.fixture_path is nil. >>> >>> Thanks, >>> Les >>> >>> >>> >>> On Nov 9, 2007, at 8:25 AM, Leslie Freeman wrote: >>> >>>> >>>> On Nov 9, 2007, at 5:09 AM, David Chelimsky wrote: >>>> >>>>> On Nov 8, 2007 11:25 PM, Leslie Freeman >>>>> wrote: >>>>>> Hi all, >>>>>> I had some specs that were using fixture_file_upload that were >>>>>> passing just fine. Then I froze edge rails to get some 2.0 >>>>>> functionality, then a I upgraded to trunk rspec to deal with >>>>>> >>>>>> uninitialized constant >>>>>> ActionView::Helpers::JavaScriptMacrosHelper >>>>>> >>>>>> After a couple other of tribulations, I have now gotten down to >>>>>> just >>>>>> a couple of not passing specs, all using the fixture_file_upload. >>>>>> Here's an example >>>>>> >>>>>> it "should be invalid if uploaded file is not an image" do >>>>>> @image.attributes = valid_image_attributes.merge >>>>>> ({:uploaded_data >>>>>> => fixture_file_upload('/textfile.txt', >>>>>> >>>>>> 'text/plain')}) >>>>>> @image.should_not be_valid >>>>>> # content_type: is not included in the list >>>>>> @image.should have(1).error_on(:content_type) >>>>>> end >>>>>> >>>>>> which fails with: >>>>>> 2) >>>>>> NoMethodError in 'Image unsaved should be invalid if uploaded >>>>>> file is >>>>>> not an image' >>>>>> You have a nil object when you didn't expect it! >>>>>> You might have expected an instance of Array. >>>>>> The error occurred while evaluating nil.+ >>>>>> ./spec/models/image_spec.rb:25: >>>>> >>>>> What's on line 25? >>>> >>>> Sorry about that confusion. Line 25 is: >>>> >>>> @image.attributes = valid_image_attributes.merge({:uploaded_data => >>>> fixture_file_upload('/textfile.txt',text/plain')}) >>>> >>>> (textfile.txt is located in my /spec/fixtures/ dir.) >>>> >>>> That line doesn't throw the error if I change it to something like: >>>> @image.attributes = valid_image_attributes.merge({:uploaded_data => >>>> "foo"}) >>>> >>>> But of course the spec fails. :) >>>> >>>> Leslie >>>> >>>>> >>>>>> >>>>>> A less than helpful error message. Any insight into what might be >>>>>> causing this? >>>>>> >>>>>> Thanks, >>>>>> Les >>>>>> _______________________________________________ >>>>>> rspec-users mailing list >>>>>> rspec-users at rubyforge.org >>>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>>> >>>>> _______________________________________________ >>>>> rspec-users mailing list >>>>> rspec-users at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 1561 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20071111/1058900f/attachment-0001.bin From mailing_lists at railsnewbie.com Sun Nov 11 16:50:17 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 11 Nov 2007 16:50:17 -0500 Subject: [rspec-users] Running specs in reverse In-Reply-To: <57c63afe0711110947m573c9708pb0bc01ce433a3112@mail.gmail.com> References: <47373550.5090801@nucleus.com> <57c63afe0711110947m573c9708pb0bc01ce433a3112@mail.gmail.com> Message-ID: <7634B059-D446-4535-8B71-3F4F4CBD8CD2@railsnewbie.com> On Nov 11, 2007, at 12:47 PM, David Chelimsky wrote: > On Nov 11, 2007 11:01 AM, Alvin Schur wrote: >> >>> On Nov 08, 2007, at 6:07 pm, Alvin Schur wrote: >>> >>> >>>> My goal is to detect inter-dependencies sooner than later... >>>> >>> >>> >>> I have to say I've NEVER run specs backwards. Am I sitting on a >>> time >>> bomb? Are there subtle traps that can create inter-dependencies >>> between specs? To look at my specs I would not assume that running >>> order matters - I don't think I've ever used before(:all) for >>> example. >>> >>> Ashkey >>> >> Our team uses Test::Unit and numerous inter-dependencies have >> crept in. >> Our team is also slowly moving to rspec. >> >> Part of resolving the inter-dependencies is: >> >> 1) education >> 2) early detection >> >> I don't want to be the "dependency police" particularly if rspec >> can do >> the job automatically for everyone on the team. > > Well - I don't think rspec should do this implicitly - that might > cause quite a bit of confusion for unsuspecting devs trying to debug. > > I command line arg like --toggle_reverse might work - but you'll have > to submit a feature request in the tracker and probably a patch if you > want to see it any time soon. Very low priority on my list. I really like this idea, especially having had the following experience: My coworker had no failing tests with rake spec, but I was having failing tests with Autotest. He had introduced something into before (:all) which stored some data into the database. Oddly enough - the tests weren't failing for him, although they were failing in reverse for me- showing a dependency between the specs. The worst part is that he was convinced this was a non-problem (because they were passing for him). I would implement this patch, if I had some good idea where I should store the state of the last test run (without adding an extra text file to my project). Scott From dchelimsky at gmail.com Sun Nov 11 16:56:10 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 11 Nov 2007 15:56:10 -0600 Subject: [rspec-users] Running specs in reverse In-Reply-To: <7634B059-D446-4535-8B71-3F4F4CBD8CD2@railsnewbie.com> References: <47373550.5090801@nucleus.com> <57c63afe0711110947m573c9708pb0bc01ce433a3112@mail.gmail.com> <7634B059-D446-4535-8B71-3F4F4CBD8CD2@railsnewbie.com> Message-ID: <57c63afe0711111356g51a4ce31g89058f9255105393@mail.gmail.com> On Nov 11, 2007 3:50 PM, Scott Taylor wrote: > > > On Nov 11, 2007, at 12:47 PM, David Chelimsky wrote: > > > On Nov 11, 2007 11:01 AM, Alvin Schur wrote: > >> > >>> On Nov 08, 2007, at 6:07 pm, Alvin Schur wrote: > >>> > >>> > >>>> My goal is to detect inter-dependencies sooner than later... > >>>> > >>> > >>> > >>> I have to say I've NEVER run specs backwards. Am I sitting on a > >>> time > >>> bomb? Are there subtle traps that can create inter-dependencies > >>> between specs? To look at my specs I would not assume that running > >>> order matters - I don't think I've ever used before(:all) for > >>> example. > >>> > >>> Ashkey > >>> > >> Our team uses Test::Unit and numerous inter-dependencies have > >> crept in. > >> Our team is also slowly moving to rspec. > >> > >> Part of resolving the inter-dependencies is: > >> > >> 1) education > >> 2) early detection > >> > >> I don't want to be the "dependency police" particularly if rspec > >> can do > >> the job automatically for everyone on the team. > > > > Well - I don't think rspec should do this implicitly - that might > > cause quite a bit of confusion for unsuspecting devs trying to debug. > > > > I command line arg like --toggle_reverse might work - but you'll have > > to submit a feature request in the tracker and probably a patch if you > > want to see it any time soon. Very low priority on my list. > > I really like this idea, especially having had the following experience: > > My coworker had no failing tests with rake spec, but I was having > failing tests with Autotest. He had introduced something into before > (:all) which stored some data into the database. Oddly enough - the > tests weren't failing for him, although they were failing in reverse > for me- showing a dependency between the specs. The worst part is > that he was convinced this was a non-problem (because they were > passing for him). > > I would implement this patch, if I had some good idea where I should > store the state of the last test run (without adding an extra text > file to my project). You've got to maintain state between processes. How else would you do it besides a text file? > > Scott > > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From rspec-users at donpetersen.net Sun Nov 11 16:56:51 2007 From: rspec-users at donpetersen.net (rspec-users mailing-list) Date: Sun, 11 Nov 2007 15:56:51 -0600 Subject: [rspec-users] Autotest with rspec HTML output In-Reply-To: <473720DE.7000500@benmabey.com> References: <47369567.3010601@benmabey.com> <8d961d900711110429q4c62eb90y4ac581bd97ab3d97@mail.gmail.com> <473720DE.7000500@benmabey.com> Message-ID: <9a51456a0711111356v736598a4y92696db763e2ee53@mail.gmail.com> I've always secretly thought that Adobe Air might be a good candidate for something like this, I just never got around to actually trying to do something about it. Air runs on Windows/Linux/OSX, can render HTML just fine, and can interact with the local filesystem to an extent. Last time I checked it's not able to run any commands on the target system, so you can't have it trigger tests... but if Autotest was running and writing results to a file, you should be able to rig something together. Don On 11/11/07, Ben Mabey wrote: > > > I was thinking that a little window(cocoa) or maybe just a browser > window could display the summary of the test run like autotest does and > then the failed specs in HTML format. Not the entire HTML report would > be generated/displayed- only the failing ones would be so it would be > manageable on projects with large test suites. So, instead of having a > terminal window open with autotest it would just be a stand alone window. > > aslak hellesoy wrote: > > Where would the HTML report be displayed? > > > > On Nov 11, 2007 6:38 AM, Ben Mabey wrote: > > > >> Hey all, > >> I was just wondering if any one has played around with getting > >> autotest's rspec integration working with rspec's HTML output. I > really > >> like how in the rspec textmate bundle the context of the failing code > >> is inlined with the failing spec along with the exact line highlighted > >> and a link to the exact spot in reference. However, I rarely use this > >> nice output since autotest is so convenient... So, I was thinking > >> wouldn't it be great to have the best of both worlds? What do you > >> think? And before I try and do this, has anyone else already done it? > >> > >> > >> -Ben > >> > >> > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > >> > >> > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071111/a95db0b5/attachment.html From aslak.hellesoy at gmail.com Sun Nov 11 18:39:06 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 12 Nov 2007 00:39:06 +0100 Subject: [rspec-users] Who's using --format rdoc Message-ID: <8d961d900711111539l7bdd1433h2492287839f3e92a@mail.gmail.com> I'm doing some housekeeping and just realised that the rdoc formatter produces gibberish: http://rspec.rubyforge.org/rdoc/files/EXAMPLES_rd.html Will anyone protest if I just go ahead and remove it? (I can't imagine anyone using it, especially with the much better HTML formatter) Aslak From cwdinfo at gmail.com Sun Nov 11 18:45:41 2007 From: cwdinfo at gmail.com (s.ross) Date: Sun, 11 Nov 2007 15:45:41 -0800 Subject: [rspec-users] Who's using --format rdoc In-Reply-To: <8d961d900711111539l7bdd1433h2492287839f3e92a@mail.gmail.com> References: <8d961d900711111539l7bdd1433h2492287839f3e92a@mail.gmail.com> Message-ID: <820C6B22-3BC1-4637-A46B-6985235C816C@gmail.com> does this mean that: rake spec:doc will not produce plain text specdocs? On Nov 11, 2007, at 3:39 PM, aslak hellesoy wrote: > I'm doing some housekeeping and just realised that the rdoc formatter > produces gibberish: > http://rspec.rubyforge.org/rdoc/files/EXAMPLES_rd.html > > Will anyone protest if I just go ahead and remove it? (I can't imagine > anyone using it, especially with the much better HTML formatter) > > Aslak > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Sun Nov 11 18:49:39 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 12 Nov 2007 00:49:39 +0100 Subject: [rspec-users] Who's using --format rdoc In-Reply-To: <820C6B22-3BC1-4637-A46B-6985235C816C@gmail.com> References: <8d961d900711111539l7bdd1433h2492287839f3e92a@mail.gmail.com> <820C6B22-3BC1-4637-A46B-6985235C816C@gmail.com> Message-ID: <8d961d900711111549k5a68fb86t772e18358f2f7604@mail.gmail.com> On Nov 12, 2007 12:45 AM, s.ross wrote: > does this mean that: > > rake spec:doc > > will not produce plain text specdocs? > No, spec:doc will remain untouched. I'm not talking about --format specdoc (which the spec:doc task uses), but --format rdoc, which is supposed to create RDoc - a file you can include in your RDocs. Since it's not producing what RDoc needs, I'd like to retire it. Aslak > > > On Nov 11, 2007, at 3:39 PM, aslak hellesoy wrote: > > > I'm doing some housekeeping and just realised that the rdoc formatter > > produces gibberish: > > http://rspec.rubyforge.org/rdoc/files/EXAMPLES_rd.html > > > > Will anyone protest if I just go ahead and remove it? (I can't imagine > > anyone using it, especially with the much better HTML formatter) > > > > Aslak > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From work at ashleymoran.me.uk Sun Nov 11 19:13:15 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Mon, 12 Nov 2007 00:13:15 +0000 Subject: [rspec-users] Who's using --format rdoc In-Reply-To: <8d961d900711111549k5a68fb86t772e18358f2f7604@mail.gmail.com> References: <8d961d900711111539l7bdd1433h2492287839f3e92a@mail.gmail.com> <820C6B22-3BC1-4637-A46B-6985235C816C@gmail.com> <8d961d900711111549k5a68fb86t772e18358f2f7604@mail.gmail.com> Message-ID: On Nov 11, 2007, at 11:49 pm, aslak hellesoy wrote: > I'm not talking about --format specdoc (which the spec:doc task uses), > but --format rdoc, which is supposed to create RDoc - a file you can > include in your RDocs. Since it's not producing what RDoc needs, I'd > like to retire it. I didn't even know it could do that, so I won't miss it. I live off autotest + HTML (via TM). Ashley -- blog @ http://aviewfromafar.net/ linked-in @ http://www.linkedin.com/in/ashleymoran currently @ home From luislavena at gmail.com Sun Nov 11 19:22:44 2007 From: luislavena at gmail.com (Luis Lavena) Date: Sun, 11 Nov 2007 21:22:44 -0300 Subject: [rspec-users] Who's using --format rdoc In-Reply-To: <8d961d900711111539l7bdd1433h2492287839f3e92a@mail.gmail.com> References: <8d961d900711111539l7bdd1433h2492287839f3e92a@mail.gmail.com> Message-ID: <71166b3b0711111622w54c971e6u99bd96fba5827fe9@mail.gmail.com> On Nov 11, 2007 8:39 PM, aslak hellesoy wrote: > I'm doing some housekeeping and just realised that the rdoc formatter > produces gibberish: > http://rspec.rubyforge.org/rdoc/files/EXAMPLES_rd.html > > Will anyone protest if I just go ahead and remove it? (I can't imagine > anyone using it, especially with the much better HTML formatter) > Go ahead, I didn't know was there :-P HTML output is more fancy than RDoc ;-) -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From brian.takita at gmail.com Sun Nov 11 19:40:21 2007 From: brian.takita at gmail.com (Brian Takita) Date: Sun, 11 Nov 2007 16:40:21 -0800 Subject: [rspec-users] fixture_file_upload and edge rspec? In-Reply-To: <1d7ddd110711111236m2bb56654q9b099d95e04f34e1@mail.gmail.com> References: <57c63afe0711090409v5e5b6e52l82856bedb76008c6@mail.gmail.com> <581F0596-A4E6-427C-A129-411BBF99F9FB@sunquake.net> <57c63afe0711110551o33ae85d7u2292f953fafad2a@mail.gmail.com> <9BFE53AE-9473-4D55-80E5-030F7005B3F7@sunquake.net> <1d7ddd110711111236m2bb56654q9b099d95e04f34e1@mail.gmail.com> Message-ID: <1d7ddd110711111640mb173d0aye81c5017a2f4fa69@mail.gmail.com> On Nov 11, 2007 12:36 PM, Brian Takita wrote: > On Nov 11, 2007 8:29 AM, Leslie Freeman wrote: > > Slowly digging to the bottom of this one. > > > > If I add > > > > Test::Unit::TestCase.fixture_path = RAILS_ROOT + '/spec/fixtures/' > > > > to my spec_helper.rb, then everything runs fine. So presumably there > > is somewhere that config.fixture_path from the Spec::Runner.configure > > block is supposed to get put into Test::Unit::TestCase.fixture_path, > > and for some reason that is no longer happening. I will continue to > > dig into this problem, but if anyone is familiar with this part of > > the rspec system and can help me get to the right place faster, I'd > > sure appreciate it. > It looks like rails changed. > For now just set Test::Unit::TestCase.fixture_path. Ill come up with a > fix in rspec core. It should be fixed now in trunk. > > > > > Les > > > > > > > > On Nov 11, 2007, at 6:51 AM, David Chelimsky wrote: > > > > > On Nov 10, 2007 11:25 PM, Leslie Freeman > > > wrote: > > >> To follow up on this a little more, I created a new project, froze > > >> rails to edge (REVISION_8125), and installed rspec/rspec on rails > > >> from trunk. Then I generated an rspec_model for Asset with the > > >> following spec: > > >> > > >> require File.dirname(__FILE__) + '/../spec_helper' > > >> > > >> describe Asset do > > >> before(:each) do > > >> @asset = Asset.new > > >> end > > >> > > >> it "should be valid" do > > >> @asset.should be_valid > > >> end > > >> > > >> it "should allow me to use fixture_file_upload" do > > >> @asset.attributes = {:uploaded_data => fixture_file_upload > > >> ('images/florence.jpg', 'image/jpeg')} > > >> end > > >> end > > >> > > >> I created an images directory in my spec/fixtures dir and added > > >> florence.jpg to it. Then, when I run rake spec I get this error: > > >> > > >> NoMethodError in 'Asset should allow me to use fixture_file_upload' > > > > > > I am not familiar w/ fixture_file_upload myself. Is there anyone else > > > on this list who is who can help Les debug this situation? > > > > > > Thanks, > > > David > > > > > >> You have a nil object when you didn't expect it! > > >> You might have expected an instance of Array. > > >> The error occurred while evaluating nil.+ > > >> /Users/leslief/Sites/tmp/testapp/vendor/rails/actionpack/lib/ > > >> action_controller/test_process.rb:480:in `fixture_file_upload' > > >> ./spec/models/asset_spec.rb:13: > > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > > >> example_group_methods.rb:40:in `instance_eval' > > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > > >> example_group_methods.rb:40:in `run_example' > > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > > >> example_runner.rb:63:in `run_example' > > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > > >> example_runner.rb:24:in `run' > > >> /opt/local/lib/ruby/1.8/timeout.rb:48:in `timeout' > > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > > >> example_runner.rb:22:in `run' > > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > > >> example_suite.rb:26:in `rspec_run' > > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > > >> example_suite.rb:22:in `each' > > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/dsl/ > > >> example_suite.rb:22:in `rspec_run' > > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/test/ > > >> unit/example_suite.rb:7:in `run' > > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ > > >> runner/ > > >> behaviour_runner.rb:22:in `run' > > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ > > >> runner/ > > >> behaviour_runner.rb:21:in `each' > > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ > > >> runner/ > > >> behaviour_runner.rb:21:in `run' > > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ > > >> runner/ > > >> options.rb:80:in `run_examples' > > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ > > >> runner/ > > >> command_line.rb:19:in `run' > > >> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/bin/spec:3: > > >> > > >> line 13 of asset_spec.rb is @asset.attributes = {:uploaded_data => > > >> fixture_file_upload('images/florence.jpg', 'image/jpeg')} > > >> > > >> the offending line in test_process.rb is: > > >> Test::Unit::TestCase.respond_to?(:fixture_path) ? > > >> Test::Unit::TestCase.fixture_path + path : path, mime_type, binary > > >> > > >> From the full function: > > >> def fixture_file_upload(path, mime_type = nil, binary = false) > > >> ActionController::TestUploadedFile.new( > > >> Test::Unit::TestCase.respond_to?(:fixture_path) ? > > >> Test::Unit::TestCase.fixture_path + path : path, > > >> mime_type, > > >> binary > > >> ) > > >> end > > >> > > >> so it seems like Test::Unit::TestCase.fixture_path is returning nil. > > >> I tried to do a little digging to find where this should be getting > > >> set, but quickly got way out to sea. > > >> > > >> My spec_helper does have this line: > > >> config.fixture_path = RAILS_ROOT + '/spec/fixtures/' > > >> > > >> which seems right. I am hoping someone that knows more about the > > >> inner gears of rspec has some insight as to why > > >> Test::Unit::TestCase.fixture_path is nil. > > >> > > >> Thanks, > > >> Les > > >> > > >> > > >> > > >> On Nov 9, 2007, at 8:25 AM, Leslie Freeman wrote: > > >> > > >>> > > >>> On Nov 9, 2007, at 5:09 AM, David Chelimsky wrote: > > >>> > > >>>> On Nov 8, 2007 11:25 PM, Leslie Freeman > > >>>> wrote: > > >>>>> Hi all, > > >>>>> I had some specs that were using fixture_file_upload that were > > >>>>> passing just fine. Then I froze edge rails to get some 2.0 > > >>>>> functionality, then a I upgraded to trunk rspec to deal with > > >>>>> > > >>>>> uninitialized constant ActionView::Helpers::JavaScriptMacrosHelper > > >>>>> > > >>>>> After a couple other of tribulations, I have now gotten down to > > >>>>> just > > >>>>> a couple of not passing specs, all using the fixture_file_upload. > > >>>>> Here's an example > > >>>>> > > >>>>> it "should be invalid if uploaded file is not an image" do > > >>>>> @image.attributes = valid_image_attributes.merge > > >>>>> ({:uploaded_data > > >>>>> => fixture_file_upload('/textfile.txt', > > >>>>> > > >>>>> 'text/plain')}) > > >>>>> @image.should_not be_valid > > >>>>> # content_type: is not included in the list > > >>>>> @image.should have(1).error_on(:content_type) > > >>>>> end > > >>>>> > > >>>>> which fails with: > > >>>>> 2) > > >>>>> NoMethodError in 'Image unsaved should be invalid if uploaded > > >>>>> file is > > >>>>> not an image' > > >>>>> You have a nil object when you didn't expect it! > > >>>>> You might have expected an instance of Array. > > >>>>> The error occurred while evaluating nil.+ > > >>>>> ./spec/models/image_spec.rb:25: > > >>>> > > >>>> What's on line 25? > > >>> > > >>> Sorry about that confusion. Line 25 is: > > >>> > > >>> @image.attributes = valid_image_attributes.merge({:uploaded_data => > > >>> fixture_file_upload('/textfile.txt',text/plain')}) > > >>> > > >>> (textfile.txt is located in my /spec/fixtures/ dir.) > > >>> > > >>> That line doesn't throw the error if I change it to something like: > > >>> @image.attributes = valid_image_attributes.merge({:uploaded_data => > > >>> "foo"}) > > >>> > > >>> But of course the spec fails. :) > > >>> > > >>> Leslie > > >>> > > >>>> > > >>>>> > > >>>>> A less than helpful error message. Any insight into what might be > > >>>>> causing this? > > >>>>> > > >>>>> Thanks, > > >>>>> Les > > >>>>> _______________________________________________ > > >>>>> rspec-users mailing list > > >>>>> rspec-users at rubyforge.org > > >>>>> http://rubyforge.org/mailman/listinfo/rspec-users > > >>>>> > > >>>> _______________________________________________ > > >>>> rspec-users mailing list > > >>>> rspec-users at rubyforge.org > > >>>> http://rubyforge.org/mailman/listinfo/rspec-users > > >>> > > >>> _______________________________________________ > > >>> rspec-users mailing list > > >>> rspec-users at rubyforge.org > > >>> http://rubyforge.org/mailman/listinfo/rspec-users > > >> > > >> _______________________________________________ > > >> rspec-users mailing list > > >> rspec-users at rubyforge.org > > >> http://rubyforge.org/mailman/listinfo/rspec-users > > >> > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > From caiomoritz at gmail.com Sun Nov 11 20:10:40 2007 From: caiomoritz at gmail.com (Caio Moritz Ronchi) Date: Sun, 11 Nov 2007 23:10:40 -0200 Subject: [rspec-users] Problem with view spec - works inside the browser but spec fails with nil object In-Reply-To: <1194768087.4837.11.camel@ip6-localhost> References: <1194768087.4837.11.camel@ip6-localhost> Message-ID: Hi Hans, I rewrote my specs the way you suggested and now everything works! For those who are interested, here's how the code looks like now (after following Hans' tips). > a) writing a separate spec for the partial _question_for_candidate require File.dirname(__FILE__) + '/../../spec_helper' module QuestionForCandidatePartialHelper def get_question_type_mock(type) mock_model(QuestionType, {:name => type}) end def render_question_for_candidate_partial render(:partial => 'survey/question_for_candidate', :locals => {:question => @question}) end end describe 'partial survey/_question_for_candidate.rhtml' do include QuestionForCandidatePartialHelper before(:each) do @question = mock_model(Question, { :id => 1, :description => 'The description', :position => 4, :alternatives => [mock_model(Alternative, {:id => 1, :description => 'Alternative 1 Description'})], }) @question_type_exclusive = get_question_type_mock('exclusive') @question_type_multiple = get_question_type_mock('multiple') end it 'should render the top of the template no matter the question type' do @question.stub!(:question_type).and_return(@question_type_exclusive) render_question_for_candidate_partial response.should have_tag('div.question.question-4') do with_tag('.heading .number', '4.') with_tag('.heading .description', @question.description) end end it 'should render an exclusive-answer question' do @question.stub!(:question_type).and_return(@question_type_exclusive) render_question_for_candidate_partial response.should have_tag('div.question.question-4') do with_tag('input[type=?]', 'radio') without_tag('input[type=?]', 'checkbox') end end it 'should render a multiple-answer question' do @question.stub!(:question_type).and_return(@question_type_multiple) render_question_for_candidate_partial response.should have_tag('div.question.question-4') do with_tag('input[type=?]', 'checkbox') without_tag('input[type=?]', 'radio') end end end > b) write a separate spec for the helper that renders the question require File.dirname(__FILE__) + '/../spec_helper' describe SurveyHelper do before(:each) do @question = mock_model(Question) end it 'should render a question using the question_for_candidate partial' do self.should_receive(:render).with(:partial => 'question_for_candidate', :locals => {:question => @question}) render_question(@question) end end > b) in the view spec for /survey/show use should_receive to determine that the helper is actually being called require File.dirname(__FILE__) + '/../../spec_helper' describe '/survey/show' do before(:each) do assigns[:configurations] = {:survey_name => 'Whatever'} @positions = [4, (9..22).to_a].flatten @questions = Array.new @positions.each do |position| @questions[position] = mock_model(Question, { :id => 1, :description => 'The description', :position => 4, :alternatives => [mock_model(Alternative, {:id => 1, :description => 'Description'})], :question_type => mock_model(QuestionType, {:name => 'exclusive'}) }) end assigns[:questions] = @questions end it "should render the 'survey/question_for_candidate' partial" do args = {:partial => 'question_for_candidate', :locals => {:question => an_instance_of(Question)}} template.should_receive(:render).with(args).exactly(@questions.nitems ).times render 'survey/show' end end c) not use any fixtures in the view specs but instead use mocks for that: it's faster and you can check exactly what needs to happen instead of relying on what happens to be in the fixture. As you can see mocks are now all over the place. No fixtures were used ;) Thanks a lot, Caio On Nov 11, 2007 6:01 AM, Hans de Graaff wrote: > You are trying to test a lot of things at the same time, which is one of > the reasons that it is now hard to diagnose a problem. > > I would tackle this by > a) writing a separate spec for the partial _question_for_candidate > b) write a separate spec for the helper that renders the question > b) in the view spec for /survey/show use should_receive to determine > that the helper is actually being called > c) not use any fixtures in the view specs but instead use mocks for > that: it's faster and you can check exactly what needs to happen instead > of relying on what happens to be in the fixture. > > I'm afraid that I don't see immediately why your current setup won't > work, but untangling things along the lines sketched above should > hopefully get you to a situation where it becomes easier to see what > happens. > > > before(:each) do > > assigns[:configurations] = {:survey_name => 'Whatever'} > > assigns[:questions] = Array.new > > assigns[:questions][4] = questions(:faixa_etaria) > > I am a little bit suspicious about this construction, though. I'm not > sure whether assigns is a normal Array in this case, so I'd create the > Array and populate it before handing it to assigns: > > @questions = Array.new > @questions[4] = ... > assigns[:questions] = @questions > > Kind regards, > > Hans > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Caio Moritz Ronchi -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071111/caa9da66/attachment.html From glenn at aldenta.com Fri Nov 9 14:29:59 2007 From: glenn at aldenta.com (Glenn Ford) Date: Fri, 9 Nov 2007 14:29:59 -0500 Subject: [rspec-users] Plain Text Story example In-Reply-To: References: <4732487A.5060309@benmabey.com> <47328E2F.1090103@benmabey.com> <57c63afe0711072112u285a13ecgb56fc416cc300bb7@mail.gmail.com> <4732AA13.7090107@benmabey.com> <57c63afe0711080358h14379674h5312027beacee697@mail.gmail.com> <5BF7CFD7-560B-434C-8AAB-C063AE03AB8A@aldenta.com> Message-ID: <97F7431D-72D5-4AFB-B82D-2ADDC15D3C5C@aldenta.com> That was exactly what I needed, thanks a lot! Glenn On Nov 9, 2007, at 10:59 AM, Dan North wrote: > Hi Glenn. > > On Nov 8, 2007 4:01 PM, Glenn Ford wrote: > It seems that what I'm coming to understand of the direction of this > story concept is that there is a lot of emphasis being put on ensuring > we keep things at the business level. I can appreciate the elegance > of it certainly, but when I think of what I would really want to gain > from this story-based testing process, I feel like it cuts out room > for some really cool ideas. Maybe you can help me see where they > would fit. > > I have in mind a scenario where a customer says "I tried to log in and > it blew up!" I take what they say with a business perspective and > check my story and say "hey I've got a login story and it works" but > that doesn't leave room for the fact that, slighty away from the norm > of the usual login procedure, this particular user clicked another > link in the middle of the process that changed some background > variable, breaking the process at the final login step. I would then > want to write a story similar to the usual login, but with the ACTUAL > details of what the customer did to ensure I could duplicate, fix, and > then never have this problem creep up again. > > I completely agree. > > My story, in order to be > of use to me, would HAVE to have steps like "click this button" > because, quite frankly, as a developer I find that's the sort of thing > that can break my code and so I would want a story to account for it. > > Yes, exactly. In this example, the UI domain is the most useful > domain to express the (bogus) behaviour, so it's the right thing to > do. The scenario might be something like: > > Scenario: press the Explode button whilst filling in form > > Given I navigate to the Submit order page [I'm loving these infix > parameters!] > And I set first name to Dan and second name to North > When I click the Explode button > Then nothing should happen > And the current page title should be Submit order > > Now, the whole of this scenario is in UI domain terms. It doesn't > matter what business function I'm trying to achieve here - the > description is about some bogus behaviour in my implementation (the > Explode button should be disabled whilst I'm capturing data) > > So it's fine to express scenarios in either business domain terms to > describe actual business flow, or UI terms to describe the user's > interactions with the application. The confusion starts when you mix > the two domains in the same story or at least in the same scenario. > > > A user following my intended user-flow, then deviating in a way I > didn't predict. From the business end, they still followed the login > process, they just had one little different quirk along the way. > > Yes, and it's that quirk in this particular UI that you want to > capture with this scenario. > > Is there a way to get this kind of thing but still keep to the ideal > business perspective? > > You're trying to do a different thing here. The audience is > different (probably a tester or UI designer rather than a business > stakeholder) and they'll be using a different vocabulary. > > Would I just simply "word" it in a way that the > simple little thing they did had a business description? Or is that > an indication that I have stupid things on my page that shouldn't even > be an option? Or is there a "happy medium" here as well between > business and ui perspectives of stories? > > See above - as long as you keep the distinction between domains when > you are describing a scenario, you'll probably be ok. > > Glenn > > Cheers, > Dan > > > > On Nov 8, 2007, at 6:58 AM, David Chelimsky wrote: > > > On Nov 8, 2007 12:17 AM, Ben Mabey wrote: > >> David Chelimsky wrote: > > > > > > > >>> ... the philosohy that Dan is > >>> espousing: expressing stories in the business domain rather than > the > >>> UI domain (btw Dan, that was brilliantly put). > >> What exactly do you and Dan mean when you say that the stories > >> should be > >> expressed in the business domain rather than the UI domain? > (BTW, is > >> there a link to a Dan North post abou that?) > > > > Sorry - there are two different threads going on about this topic > > right now - the other one is on the rspec-devel list and that was > > where Dan posted that statement: > > > > http://rubyforge.org/pipermail/rspec-devel/2007-November/004259.html > > > > Keep in mind that User Stories are oft described as "a token for a > > conversation", and that even with acceptance criteria spelled out, > > whether the button says "Create New Account" or "Enter" is rarely of > > sufficient business value to express that in a story. That's the > sort > > of detail that comes out when you say to your customer "the entry > form > > is done, why don't you come by so I can show it to you," as > opposed to > > in the iteration planning meeting. > > > > In the end it really does boil down to what the customer feels is > > necessary in order to accept the software. If the customer really > DOES > > care about what the button says, he or she may want that expressed > in > > a story. But even then, saying "And I press Create New Account" > still > > leaves things flexible enough so that you could be describing a web > > app, a GUI app, a touch-screen app, etc. The only thing this doesn't > > work for would be a command line app. So maybe "And I tell the > system > > to Create New Account" would leave room for that as well. Or maybe, > > "And I fold my arms and command the system to Create New Account." I > > kinda like that one! > > > >> From my understanding you > >> are saying that the steps that say "user types in such and such" > and > >> user "hits the login button" are too UI specific and don't really > >> have > >> much to do with the business domain. Is that correct? > > > > Unless the business IS software, like a text editor, yes. > > > >> I think that this is a part of writing stories that I am somewhat > >> struggling with, meaning how specific should these stories be in > >> explaining the view? At RubyConf during your presentation (great > >> job, > >> BTW!) you mentioned how you like to spec out your views first. > > > > Ah - confusion. I DO like to spec my views first - when I get down > to > > the Spec Framework. > > > > In our example at RailsConf EU, we talked about a Cup Tracker (as in > > Rugby, which was going on at the time). Take a look at the example > > story: > > > > http://rspec.rubyforge.org/svn/branches/railsconfeu2007/tags/chapter1/stories/plan_cup.rb > > > > This story really rides this whole line very nicely. We're > describing > > software that presents a view of something abstract, and we do so > with > > some detail about what it presents - but there is nothing in it that > > says "when I click this button" or "when I enter this text." > > > > Now look at this version (same story, w/ the steps filled in): > > > > http://rspec.rubyforge.org/svn/branches/railsconfeu2007/tags/chapter4/stories/plan_cup.rb > > > > Note how the implementations of the steps are starting to get into > the > > views. That's where that level of detail starts to play out. > > > > Now look at this: > > > > http://rspec.rubyforge.org/svn/branches/railsconfeu2007/tags/chapter4/spec/views/cups/show.rhtml_spec.rb > > > > That spec was arrived at with the very granular red-green-refactor > > process of TDD with a focus, naturally, on behaviour, design and > > documentation (It just occurs to me that behaviour, design and > > documentation are B, D and D - interesting ...). > > > > Now some people look at that spec and scream "holy crap - look at > all > > the duplication - all that mocking - so brittle!." I won't disagree > > that there is lots of duplication with other parts of the system, a > > lot of mocking, and changes to the views would require changes to > this > > spec (brittle). And, looking back at this, I might want to break > that > > spec up into more granular examples. While it speaks very well > looking > > at the code, running it would only tell you that "/cups/show.rhtml > > should display the chart." > > > > But check this out! The implementation of that spec, with all that > > mocking, IS the spec for the controller and model. That single spec > > tells us about the structure that the model should expose (NOT the > > actual structure necessarily - just what it should expose to things > > like views that want the models to be easy to use) and what the > > controller should provide for the view. > > > > So this is all about discovery - starting from the outside and > moving > > in. Implementing the steps that describe domain concepts help us to > > discover some details of the views. Implementing the view specs help > > us to discover the services we want from our controller and the APIs > > we want from our model. I find that to be very compelling. > > > > > > > >> Where is the happy medium, in your opinion, between > >> keeping the stories concise and letting them drive every aspect of > >> the > >> development? Maybe I am wrong in saying that the stories should > >> drive > >> EVERY aspect of the development? > > > > Well, they should drive every aspect, but not directly. You're not > > going to describe database table structure in your stories, but in > the > > end those structures end up as they do because of the stories. > > > >>>> The Selenium integration is also an interesting idea that you > >>>> might want > >>>> to read about if you haven't seen this post. I'm still trying to > >>>> decided if using Selenium is worth the extra effort (my main goal > >>>> would > >>>> be to test the JS during the acceptance tests) > > > > > > > >>> Generally speaking, in-browser tests tend to be incredibly brittle > >>> and > >>> run dog-slow. They simply have no choice but to be tied directly > to > >>> low-level implementation details like html structure and element > >>> IDs. > >>> > >>> So I'd recommend only testing what you absolutely must in-browser. > >>> But > >>> given our ajax-laden world, "what you absolutely must" may well > turn > >>> out to be a lot! > > > > > > > >> I have heard that Selenium suites can become out of hand and end of > >> being more hassle than what there worth. Thanks for the > >> recommendation, > >> I think that sounds like a sensible one. > >> > >> Thanks for taking the time to discuss this, > > > > My pleasure! > > > > Cheers, > > David > > > >> > >> Ben > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071109/9fbc7260/attachment-0001.html From brian.takita at gmail.com Mon Nov 12 12:39:23 2007 From: brian.takita at gmail.com (Brian Takita) Date: Mon, 12 Nov 2007 09:39:23 -0800 Subject: [rspec-users] it "should [action] ..." vs it with an active voice Message-ID: <1d7ddd110711120939k779bbd67m4f1bb768d7da34b6@mail.gmail.com> I'd like to start gathering information/debating on the advantages/disadvantages of using it "should ..." vs other techniques. Dan North explained why we should use should: http://dannorth.net/introducing-bdd/ I used to use it "should ..." for the projects I was on, until I was challenged by a fellow developer who started using it with an active voice. For example instead of: it "should go to the park" An active voice would be: it "goes to the park" After a few days of reluctance (or stubbornly hanging on to the rspec "convention"), I eventually adopted and grown to love using the active voice. Here are the main reasons that I prefer an active voice because: * using it "should ..." over and over renders should meaningless (I have grown this barely conscience aversion to the word 'should') * less less words are needed * the differentiating information of the 'it' statement is in the front, rather than hidden behind should (space to the left is at a premium) * it describes what the software will do and what it does (both from the Test Driven Design and Regression verification lifecycles of the test) * you still have a good "sentence template" that "should" provides (you have to make a coherent sentence) So here it my initial stab. Lets discuss :) Thanks, Brian From Amit_Kumar at external.mckinsey.com Sun Nov 11 20:47:58 2007 From: Amit_Kumar at external.mckinsey.com (Amit_Kumar at external.mckinsey.com) Date: Sun, 11 Nov 2007 20:47:58 -0500 Subject: [rspec-users] Getting 'block not supplied' with Rspec Message-ID: Hi, I am usinh RoR w/ Oracle as my DB. For one my example in spec I get 'block not supplied error: Here is the sample code: Engagements::Engagement.find(:first).project_id I tried to google but did not find any substantial result other than http://www.nabble.com/Rspec-+-Oracle-t3756739.html where someone has faced such an issues. Wonder what could be the work around. Cheers, Amit +=========================================================+ This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. +=========================================================+ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071111/0d9b0b8e/attachment.html From revurikarna at gmail.com Mon Nov 12 05:36:23 2007 From: revurikarna at gmail.com (KarniRevuri) Date: Mon, 12 Nov 2007 02:36:23 -0800 (PST) Subject: [rspec-users] Test case for file import In-Reply-To: <1b165db00711060554m6afc3418q34703319b5e5e8c4@mail.gmail.com> References: <1b165db00711060451s6d7fdc44he2fffb12c1f74bd7@mail.gmail.com> <57c63afe0711060502m6c92ccdaye78ce6846175fe3f@mail.gmail.com> <1b165db00711060554m6afc3418q34703319b5e5e8c4@mail.gmail.com> Message-ID: <13703316.post@talk.nabble.com> I want to write below specs specify "The system allows users to import a pre-formatted CSV file into project." specify "Each row in the spreadsheet is imported as one new Task." specify "The import WILL NOT update existing tasks." specify "If the import file has any records that fail due to errors, NONE of the records in the import file will be imported." specify"The system will allow users to browse to the import file using typical windows file open controls." Please give me any ideas Jim Lindley wrote: > >> > Can you show some of your code that needs to be tested? >> >> Actually, we'd hope that the code doesn't exist yet. This is Behaviour >> DRIVEN Development, after all. >> >  > Old habits, my apologies. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > -- View this message in context: http://www.nabble.com/Test-case-for-file-import-tf4756785.html#a13703316 Sent from the rspec-users mailing list archive at Nabble.com. From dchelimsky at gmail.com Mon Nov 12 12:42:51 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 12 Nov 2007 11:42:51 -0600 Subject: [rspec-users] Getting 'block not supplied' with Rspec In-Reply-To: References: Message-ID: <57c63afe0711120942m783b6153vb0e3adab821c701c@mail.gmail.com> On Nov 11, 2007 7:47 PM, wrote: > > Hi, > > I am usinh RoR w/ Oracle as my DB. > > For one my example in spec I get 'block not supplied error: > > Here is the sample code: > > Engagements::Engagement.find(:first).project_id I think this is a rails question - have you tried the rails list? > > I tried to google but did not find any substantial result other than > http://www.nabble.com/Rspec-+-Oracle-t3756739.html where someone has faced > such an issues. > > Wonder what could be the work around. > > Cheers, > Amit > > > +=========================================================+ > This message may contain confidential and/or privileged > information. If you are not the addressee or authorized to > receive this for the addressee, you must not use, copy, > disclose or take any action based on this message or any > information herein. If you have received this message in > error, please advise the sender immediately by reply e-mail > and delete this message. Thank you for your cooperation. > +=========================================================+ > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From philodespotos at gmail.com Mon Nov 12 14:51:19 2007 From: philodespotos at gmail.com (Kyle Hargraves) Date: Mon, 12 Nov 2007 13:51:19 -0600 Subject: [rspec-users] it "should [action] ..." vs it with an active voice In-Reply-To: <1d7ddd110711120939k779bbd67m4f1bb768d7da34b6@mail.gmail.com> References: <1d7ddd110711120939k779bbd67m4f1bb768d7da34b6@mail.gmail.com> Message-ID: <60f3810c0711121151o2d08004bn52aef49ba5ebc53b@mail.gmail.com> On Nov 12, 2007 11:39 AM, Brian Takita wrote: > Here are the main reasons that I prefer an active voice because: > * using it "should ..." over and over renders should meaningless (I > have grown this barely conscience aversion to the word 'should') > * less less words are needed > * the differentiating information of the 'it' statement is in the > front, rather than hidden behind should (space to the left is at a > premium) > * it describes what the software will do and what it does (both from > the Test Driven Design and Regression verification lifecycles of the > test) > * you still have a good "sentence template" that "should" provides > (you have to make a coherent sentence) > > So here it my initial stab. Lets discuss :) I definitely agree that the active voice is nice in spec strings. A coworker, when he first saw the use of 'should', said something along the lines of "I thought you were writing specifications, not recommendations." I fumbled and tried to explain that away, but the objection has stuck with me. I've also noticed on Rubinius' spec style guide that the use of should is discouraged: http://rubinius.lighthouseapp.com/projects/5089/specs-style-guide There are still some places that I use 'should', and if I'm working in a project that tends to use it, I'll stick with it. But in my own work, I prefer 'it has 4 entries' to 'it should have 4 entries'. (Though, in the code, the use of 'should' to express the expectation, does make sense, as the Rubinius page explains). Thanks for bringing this up, I'd been thinking about it lately. Kyle From pergesu at gmail.com Mon Nov 12 14:56:37 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 12 Nov 2007 11:56:37 -0800 Subject: [rspec-users] it "should [action] ..." vs it with an active voice In-Reply-To: <1d7ddd110711120939k779bbd67m4f1bb768d7da34b6@mail.gmail.com> References: <1d7ddd110711120939k779bbd67m4f1bb768d7da34b6@mail.gmail.com> Message-ID: <810a540e0711121156t4782c439hb82e3381da94059c@mail.gmail.com> On Nov 12, 2007 9:39 AM, Brian Takita wrote: > > I'd like to start gathering information/debating on the > advantages/disadvantages of using it "should ..." vs other techniques. > > Dan North explained why we should use should: > http://dannorth.net/introducing-bdd/ > > I used to use it "should ..." for the projects I was on, until I was > challenged by a fellow developer who started using it with an active > voice. > For example instead of: > it "should go to the park" > An active voice would be: > it "goes to the park" > > After a few days of reluctance (or stubbornly hanging on to the rspec > "convention"), I eventually adopted and grown to love using the active > voice. > > Here are the main reasons that I prefer an active voice because: > * using it "should ..." over and over renders should meaningless (I > have grown this barely conscience aversion to the word 'should') > * less less words are needed > * the differentiating information of the 'it' statement is in the > front, rather than hidden behind should (space to the left is at a > premium) > * it describes what the software will do and what it does (both from > the Test Driven Design and Regression verification lifecycles of the > test) > * you still have a good "sentence template" that "should" provides > (you have to make a coherent sentence) > > So here it my initial stab. Lets discuss :) > > Thanks, > Brian > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > At first glance I think this will be an awkward style for me to adopt. It'll take a bit to break out of my current mentality. That said, I think it makes a lot of sense. I'm going to try it out this week, and hopefully I'll fall in love with it. Pat From ben at benmabey.com Mon Nov 12 15:31:46 2007 From: ben at benmabey.com (Ben Mabey) Date: Mon, 12 Nov 2007 13:31:46 -0700 Subject: [rspec-users] Using the mock framework in story runner Message-ID: <4738B832.2000601@benmabey.com> Hey all, What is the easiest way to include rpec's mocking framework into a story so I can use it? I want to use it to stub out a Net::HTTP method so I'm not making API calls every time I run my story. :) Thanks, Ben From ben at benmabey.com Mon Nov 12 15:37:50 2007 From: ben at benmabey.com (Ben Mabey) Date: Mon, 12 Nov 2007 13:37:50 -0700 Subject: [rspec-users] Using the mock framework in story runner In-Reply-To: <4738B832.2000601@benmabey.com> References: <4738B832.2000601@benmabey.com> Message-ID: <4738B99E.4090803@benmabey.com> Just requiring the lib/specs/mocks.rb doesn't seem to do the trick... Ben Mabey wrote: > Hey all, > What is the easiest way to include rpec's mocking framework into a story > so I can use it? I want to use it to stub out a Net::HTTP method so I'm > not making API calls every time I run my story. :) > > Thanks, > Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Nov 12 16:03:06 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 12 Nov 2007 15:03:06 -0600 Subject: [rspec-users] Using the mock framework in story runner In-Reply-To: <4738B99E.4090803@benmabey.com> References: <4738B832.2000601@benmabey.com> <4738B99E.4090803@benmabey.com> Message-ID: <57c63afe0711121303k50d4a72cw24a6bdf07de762a5@mail.gmail.com> On Nov 12, 2007 2:37 PM, Ben Mabey wrote: > Just requiring the lib/specs/mocks.rb doesn't seem to do the trick... > > > Ben Mabey wrote: > > Hey all, > > What is the easiest way to include rpec's mocking framework into a story > > so I can use it? I want to use it to stub out a Net::HTTP method so I'm > > not making API calls every time I run my story. :) I think what you're asking for is more of a stub than a mock - you're not going to be verifying calls to Net::HTTP, right? We have no plan to integrate the mocking framework into the story runner. What I'd do is just write a custom stub of Net::HTTP and include that in your stories. Although, you may want to have one Story that does make a real call - just to verify that you've got the protocol right, etc. HTH, David > > > > Thanks, > > Ben > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Mon Nov 12 18:24:54 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 13 Nov 2007 00:24:54 +0100 Subject: [rspec-users] Test case for file import In-Reply-To: <13703316.post@talk.nabble.com> References: <1b165db00711060451s6d7fdc44he2fffb12c1f74bd7@mail.gmail.com> <57c63afe0711060502m6c92ccdaye78ce6846175fe3f@mail.gmail.com> <1b165db00711060554m6afc3418q34703319b5e5e8c4@mail.gmail.com> <13703316.post@talk.nabble.com> Message-ID: <8d961d900711121524v72ba62datf2deec52852beff4@mail.gmail.com> On Nov 12, 2007 11:36 AM, KarniRevuri wrote: > > I want to write below specs > > specify "The system allows users to import a pre-formatted CSV file into > project." > specify "Each row in the spreadsheet is imported as one new Task." > specify "The import WILL NOT update existing tasks." > specify "If the import file has any records that fail due to errors, NONE > of the records in the import file will be imported." > specify"The system will allow users to browse to the import file using > typical windows file open controls." > > > Please give me any ideas > Is this related to the post that you replied to? Your question is too vague. Can you be more specific about what you need help with? Aslak > > Jim Lindley wrote: > > > >> > Can you show some of your code that needs to be tested? > >> > >> Actually, we'd hope that the code doesn't exist yet. This is Behaviour > >> DRIVEN Development, after all. > >> > > > > Old habits, my apologies. > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > View this message in context: http://www.nabble.com/Test-case-for-file-import-tf4756785.html#a13703316 > Sent from the rspec-users mailing list archive at Nabble.com. > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Nov 12 20:22:18 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 12 Nov 2007 19:22:18 -0600 Subject: [rspec-users] it "should [action] ..." vs it with an active voice In-Reply-To: <60f3810c0711121151o2d08004bn52aef49ba5ebc53b@mail.gmail.com> References: <1d7ddd110711120939k779bbd67m4f1bb768d7da34b6@mail.gmail.com> <60f3810c0711121151o2d08004bn52aef49ba5ebc53b@mail.gmail.com> Message-ID: <57c63afe0711121722y4756866fg440c949e4021cf9@mail.gmail.com> On Nov 12, 2007 1:51 PM, Kyle Hargraves wrote: > On Nov 12, 2007 11:39 AM, Brian Takita wrote: > > Here are the main reasons that I prefer an active voice because: > > * using it "should ..." over and over renders should meaningless (I > > have grown this barely conscience aversion to the word 'should') > > * less less words are needed > > * the differentiating information of the 'it' statement is in the > > front, rather than hidden behind should (space to the left is at a > > premium) > > * it describes what the software will do and what it does (both from > > the Test Driven Design and Regression verification lifecycles of the > > test) > > * you still have a good "sentence template" that "should" provides > > (you have to make a coherent sentence) > > > > So here it my initial stab. Lets discuss :) > > I definitely agree that the active voice is nice in spec strings. > > A coworker, when he first saw the use of 'should', said something > along the lines of "I thought you were writing specifications, not > recommendations." Unfortunately, as we tried to get away from the word "test" and all the baggage it brings along with it, we landed on another word, "specification," which bears its own baggage. In most cases, we are not writing specifications in the traditional sense. Sure, we are specifying how our objects should behave, but that notion changes daily as new requirements enter the system and we mercilessly refactor. It's not the same kind of "specification." > I fumbled and tried to explain that away, but the > objection has stuck with me. I've also noticed on Rubinius' spec style > guide that the use of should is discouraged: > > http://rubinius.lighthouseapp.com/projects/5089/specs-style-guide That rationale seems a bit arbitrary to me. Why should there be anything different between the doc strings and the code in the examples? They're both talking about how the objects should behave. Not how they do behave, but how we expect them to behave. The examples can fail, in which case the objects are not behaving as they should, nor are they behaving as the doc strings state that they unequivocally *are* when you use imperative or active voice. Secondly, while the Rubinius team is using RSpec (which is great) and they are writing executable specifications (which is even greater!), writing a complete specification for an existing language is not really what BDD is all about. And so while they may be doing something akin to BDD, or the "language specification flavor" of BDD, it is really unrelated to the BDD process that the word "should" was chosen to support. The process I'm talking about is an iterative process. Not just iterative in terms of developing the software, but in terms of *discovering* requirements of the software as well. The idea is to be able to respond to change, to check assumptions, and to constantly redesign the system to align with the requirements as they are understood to be right at that moment. The Rubinius specs are a language specification. The team is not going to learn during iteration 27 that String#eql should return true for Strings that are the same except for one character. The spec is actually a *spec*. It'll take the CEO's signature to change it. All of this to say that I think "should" works well when what should happen can (should???) change from time to time as we learn more about the system. > There are still some places that I use 'should' What is the criteria for you? When would you choose "should" and when would you choose active voice? > and if I'm working in > a project that tends to use it, I'll stick with it. But in my own > work, I prefer 'it has 4 entries' But it DOESN'T have 4 entries when you write that example. Then it does when you get the example to pass. But what if the example fails later on? The example says "it has 4 entries", but that is wrong. What is correct in that context is that it "should have 4 entries," but doesn't. And recognizing that gives you some flexibility to ask yourself whether the object is wrong, or the example is wrong. That was one of the motivating factors behind the choice of "should", and I personally find it quite compelling. > to 'it should have 4 entries'. > (Though, in the code, the use of 'should' to express the expectation, > does make sense, as the Rubinius page explains). > > Thanks for bringing this up, I'd been thinking about it lately. Hear, hear! I have my not-so-subtle opinions about this, but I'm glad to see the notion being challenged and look forward to other opinions. Cheers, David From vgraupera at gmail.com Mon Nov 12 20:38:29 2007 From: vgraupera at gmail.com (Vidal Graupera) Date: Mon, 12 Nov 2007 17:38:29 -0800 Subject: [rspec-users] More Rails Pattern Examples? Message-ID: Hi, I have been reading the documentation and examples on the rspec site. There are two "patterns" from Rails that I am not clear how to implement that are kind of related, and so I am not sure how to start. Does anyone have any examples of how to write rspecs for these? 1/ Nested resources. 2/ Resources that are specific to the current_user. In other words, I only want to "CRUD" the items that belong to current_user and no others. Yes, I am using restful_authentication. Are there any open source Rails projects that make good use of rspec? Thanks in advance, Vidal. From pergesu at gmail.com Mon Nov 12 21:09:34 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 12 Nov 2007 18:09:34 -0800 Subject: [rspec-users] it "should [action] ..." vs it with an active voice In-Reply-To: <57c63afe0711121722y4756866fg440c949e4021cf9@mail.gmail.com> References: <1d7ddd110711120939k779bbd67m4f1bb768d7da34b6@mail.gmail.com> <60f3810c0711121151o2d08004bn52aef49ba5ebc53b@mail.gmail.com> <57c63afe0711121722y4756866fg440c949e4021cf9@mail.gmail.com> Message-ID: <810a540e0711121809t4552d66fhabcc558dbf8b939e@mail.gmail.com> I'm going to flip some of your stuff around, and hopefully I arrive at a point. On Nov 12, 2007 5:22 PM, David Chelimsky wrote: > On Nov 12, 2007 1:51 PM, Kyle Hargraves wrote: > > and if I'm working in > > a project that tends to use it, I'll stick with it. But in my own > > work, I prefer 'it has 4 entries' > > But it DOESN'T have 4 entries when you write that example. Then it > does when you get the example to pass. But what if the example fails > later on? The example says "it has 4 entries", but that is wrong. What > is correct in that context is that it "should have 4 entries," but > doesn't. And recognizing that gives you some flexibility to ask > yourself whether the object is wrong, or the example is wrong. That > was one of the motivating factors behind the choice of "should", and I > personally find it quite compelling. It probably doesn't matter much. In fact, if you make an imperative statement and the example fails, then the contradiction produces a nasty, noisy, "LOOK AT ME! LOOK AT ME! SOMETHING IS BROKEN! FIX IT" which is generally what you want with unit tests. However... > Secondly, while the Rubinius team is using RSpec (which is great) and > they are writing executable specifications (which is even greater!), > writing a complete specification for an existing language is not > really what BDD is all about. And so while they may be doing something > akin to BDD, or the "language specification flavor" of BDD, it is > really unrelated to the BDD process that the word "should" was chosen > to support. > > The process I'm talking about is an iterative process. Not just > iterative in terms of developing the software, but in terms of > *discovering* requirements of the software as well. The idea is to be > able to respond to change, to check assumptions, and to constantly > redesign the system to align with the requirements as they are > understood to be right at that moment. > > The Rubinius specs are a language specification. The team is not going > to learn during iteration 27 that String#eql should return true for > Strings that are the same except for one character. The spec is > actually a *spec*. It'll take the CEO's signature to change it. In BDD, the unit tests are not the final authority on how the system should behave. I think this is a fundamental difference from traditional TDD. If your specs are failing, that might suck, or it might not. It doesn't necessarily mean anything is broken. Stories are the final authority and let you know when something is broken. But our specs are just a tool to help us design, and sometimes they are a bit more useful by helping us localize issues. (btw, I think that because of that, specs != unit tests. They're very similar, but I'll be so bold as to claim that there are no unit tests in BDD) So, in that sense, I think this ought to be the combination of spec/story for the simple account withdrawal example: Given my savings account balance is $100 And my cash account balance is $10 When I transfer $20 Then my savings account balance is $80 And my cash account balance is $30 (if you look at http://dannorth.net/2007/06/introducing-rbehave you'll see that he uses "should be" for the Then clauses) describe Account do before(:each) do @savings = Account.new 100 @cash = Account.new 10 end it "should transfer $20 to another account" do @savings.transfer_to @cash, 20 @savings.balance.should == 80 end it "accept a $20 transfer from another account" do @savings.transfer_to @cash, 20 @cash.balance.should == 30 end end The description uses "should," thus is gentle and fluid. If an example fails, the developer can choose how to handle it however he wants. The story, on the other hand, must use imperative statements. If it fails, the developer must either fix the code so it passes, or have a conversation with a customer if he feels the requirements may have changed. I hope I didn't muddle anything by using such a simple example. In fact I'm sort of hoping that it gets the point across better...under the hood, the description and spec have virtually identical implementations. The difference is that the story is an authoritative spec of how the system should behave, and the description has no authority at all. Pat From pergesu at gmail.com Mon Nov 12 21:11:42 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 12 Nov 2007 18:11:42 -0800 Subject: [rspec-users] it "should [action] ..." vs it with an active voice In-Reply-To: <810a540e0711121809t4552d66fhabcc558dbf8b939e@mail.gmail.com> References: <1d7ddd110711120939k779bbd67m4f1bb768d7da34b6@mail.gmail.com> <60f3810c0711121151o2d08004bn52aef49ba5ebc53b@mail.gmail.com> <57c63afe0711121722y4756866fg440c949e4021cf9@mail.gmail.com> <810a540e0711121809t4552d66fhabcc558dbf8b939e@mail.gmail.com> Message-ID: <810a540e0711121811me0b6fa4yc2b76af5d548599c@mail.gmail.com> On Nov 12, 2007 6:09 PM, Pat Maddox wrote: > (btw, I think that because of that, specs != unit tests. They're very > similar, but I'll be so bold as to claim that there are no unit tests > in BDD) To preempt any snarkiness... :) Of course there are no unit tests in BDD, because there are no tests in BDD! What I really mean is that there is nothing in BDD which maps directly to the traditional concept of "unit test." Pat From pergesu at gmail.com Mon Nov 12 21:18:17 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 12 Nov 2007 18:18:17 -0800 Subject: [rspec-users] More Rails Pattern Examples? In-Reply-To: References: Message-ID: <810a540e0711121818s5364534biaafb5ed571632690@mail.gmail.com> On Nov 12, 2007 5:38 PM, Vidal Graupera wrote: > Hi, > > I have been reading the documentation and examples on the rspec site. > There are two "patterns" from Rails that I am not clear how to > implement that are kind of related, and so I am not sure how to start. > > Does anyone have any examples of how to write rspecs for these? > > 1/ Nested resources. > > 2/ Resources that are specific to the current_user. In other words, I > only want to "CRUD" the items that belong to current_user and no > others. Yes, I am using restful_authentication. > > Are there any open source Rails projects that make good use of rspec? > > Thanks in advance, > > Vidal. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > # Nested resources describe MessagesController, " requesting /users/pat/messages using GET" do before(:each) do @mock_user = mock_model(User, :messages => :pats_messages) User.stub!(:find_by_nickname).and_return @mock_user end def do_get get :index, :user_id => "pat" end it "should find the user" do User.should_receive(:find_by_nickname).with("pat").and_return @mock_user do_get end # verified a bit indirectly because the only way to get # :pats_messages is by calling @mock_user.messages # so the controller would have to be # user = User.find_by_nickname params[:user_id] # @messages = user.messages it "should assign the user's messages to the view" do do_get assigns[:messages].should == :pats_messages end end # current user describe MessagesController, " requesting /messages while logged in" do before(:each) do @mock_user = mock_model(User, :messages => :user_messages) controller.stub!(:current_user).and_return @mock_user end def do_get get :index end # Same idea as above...the only way to get this result would be with # @messages = current_user.messages it "should get the logged in user's messages" do do_get assigns[:messages].should == :user_messages end end Please keep in mind that I just whipped these up so there may be typos :) but you ought to get the idea. hth Pat From dchelimsky at gmail.com Mon Nov 12 21:39:28 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 12 Nov 2007 20:39:28 -0600 Subject: [rspec-users] it "should [action] ..." vs it with an active voice In-Reply-To: <810a540e0711121809t4552d66fhabcc558dbf8b939e@mail.gmail.com> References: <1d7ddd110711120939k779bbd67m4f1bb768d7da34b6@mail.gmail.com> <60f3810c0711121151o2d08004bn52aef49ba5ebc53b@mail.gmail.com> <57c63afe0711121722y4756866fg440c949e4021cf9@mail.gmail.com> <810a540e0711121809t4552d66fhabcc558dbf8b939e@mail.gmail.com> Message-ID: <57c63afe0711121839k1f79614fgbbf560809653a0b3@mail.gmail.com> On Nov 12, 2007 8:09 PM, Pat Maddox wrote: > The difference is that the story is an authoritative > spec of how the system should behave, and the description has no > authority at all. I don't have that sense at all. Where do you get that from? From pergesu at gmail.com Mon Nov 12 22:03:28 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 12 Nov 2007 19:03:28 -0800 Subject: [rspec-users] it "should [action] ..." vs it with an active voice In-Reply-To: <57c63afe0711121839k1f79614fgbbf560809653a0b3@mail.gmail.com> References: <1d7ddd110711120939k779bbd67m4f1bb768d7da34b6@mail.gmail.com> <60f3810c0711121151o2d08004bn52aef49ba5ebc53b@mail.gmail.com> <57c63afe0711121722y4756866fg440c949e4021cf9@mail.gmail.com> <810a540e0711121809t4552d66fhabcc558dbf8b939e@mail.gmail.com> <57c63afe0711121839k1f79614fgbbf560809653a0b3@mail.gmail.com> Message-ID: <810a540e0711121903l502bc6fbgf902ab42ae6200bd@mail.gmail.com> On 11/12/07, David Chelimsky wrote: > On Nov 12, 2007 8:09 PM, Pat Maddox wrote: > > The difference is that the story is an authoritative > > spec of how the system should behave, and the description has no > > authority at all. > > I don't have that sense at all. Where do you get that from? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > >From the belief that the customer is the ultimate authority on what it means for the system to behave acceptably, and the fact that stories are customer-facing and specs are developer-facing. Pat From dchelimsky at gmail.com Mon Nov 12 22:12:54 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 12 Nov 2007 21:12:54 -0600 Subject: [rspec-users] it "should [action] ..." vs it with an active voice In-Reply-To: <810a540e0711121903l502bc6fbgf902ab42ae6200bd@mail.gmail.com> References: <1d7ddd110711120939k779bbd67m4f1bb768d7da34b6@mail.gmail.com> <60f3810c0711121151o2d08004bn52aef49ba5ebc53b@mail.gmail.com> <57c63afe0711121722y4756866fg440c949e4021cf9@mail.gmail.com> <810a540e0711121809t4552d66fhabcc558dbf8b939e@mail.gmail.com> <57c63afe0711121839k1f79614fgbbf560809653a0b3@mail.gmail.com> <810a540e0711121903l502bc6fbgf902ab42ae6200bd@mail.gmail.com> Message-ID: <57c63afe0711121912m2e03e99fob3cc11280eee1452@mail.gmail.com> On Nov 12, 2007 9:03 PM, Pat Maddox wrote: > > On 11/12/07, David Chelimsky wrote: > > On Nov 12, 2007 8:09 PM, Pat Maddox wrote: > > > The difference is that the story is an authoritative > > > spec of how the system should behave, and the description has no > > > authority at all. > > > > I don't have that sense at all. Where do you get that from? > > >From the belief that the customer is the ultimate authority on what it > means for the system to behave acceptably, and the fact that stories > are customer-facing and specs are developer-facing. I totally agree that the customer is the authority - however, the customer has just as much right to change her mind about a story as I do about a spec! So why should stories be any more locked down than specs? From badcarl at gmail.com Mon Nov 12 22:40:28 2007 From: badcarl at gmail.com (Carl Porth) Date: Mon, 12 Nov 2007 19:40:28 -0800 Subject: [rspec-users] More Rails Pattern Examples? In-Reply-To: <810a540e0711121818s5364534biaafb5ed571632690@mail.gmail.com> References: <810a540e0711121818s5364534biaafb5ed571632690@mail.gmail.com> Message-ID: On Nov 12, 2007, at 6:18 PM, Pat Maddox wrote: > On Nov 12, 2007 5:38 PM, Vidal Graupera wrote: >> Hi, >> >> I have been reading the documentation and examples on the rspec site. >> There are two "patterns" from Rails that I am not clear how to >> implement that are kind of related, and so I am not sure how to >> start. >> >> Does anyone have any examples of how to write rspecs for these? >> >> 1/ Nested resources. >> >> 2/ Resources that are specific to the current_user. In other words, I >> only want to "CRUD" the items that belong to current_user and no >> others. Yes, I am using restful_authentication. >> >> Are there any open source Rails projects that make good use of rspec? >> >> Thanks in advance, >> >> Vidal. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > # Nested resources > describe MessagesController, " requesting /users/pat/messages using > GET" do > before(:each) do > @mock_user = mock_model(User, :messages => :pats_messages) > User.stub!(:find_by_nickname).and_return @mock_user > end > > def do_get > get :index, :user_id => "pat" > end > > it "should find the user" do > User.should_receive(:find_by_nickname).with("pat").and_return > @mock_user > do_get > end > > # verified a bit indirectly because the only way to get > # :pats_messages is by calling @mock_user.messages > # so the controller would have to be > # user = User.find_by_nickname params[:user_id] > # @messages = user.messages > it "should assign the user's messages to the view" do > do_get > assigns[:messages].should == :pats_messages > end > end > > # current user > describe MessagesController, " requesting /messages while logged in" > do > before(:each) do > @mock_user = mock_model(User, :messages => :user_messages) > controller.stub!(:current_user).and_return @mock_user > end > > def do_get > get :index > end > > # Same idea as above...the only way to get this result would be with > # @messages = current_user.messages > it "should get the logged in user's messages" do > do_get > assigns[:messages].should == :user_messages > end > end > > > > Please keep in mind that I just whipped these up so there may be typos > :) but you ought to get the idea. hth > > Pat > _____________________ You can also check out http://blog.caboo.se/pages/sample-rails-application Carl -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 1561 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20071112/5b30584a/attachment-0001.bin From leslief at sunquake.net Mon Nov 12 23:45:35 2007 From: leslief at sunquake.net (Leslie Freeman) Date: Mon, 12 Nov 2007 21:45:35 -0700 Subject: [rspec-users] fixture_file_upload and edge rspec? In-Reply-To: <1d7ddd110711111640mb173d0aye81c5017a2f4fa69@mail.gmail.com> References: <57c63afe0711090409v5e5b6e52l82856bedb76008c6@mail.gmail.com> <581F0596-A4E6-427C-A129-411BBF99F9FB@sunquake.net> <57c63afe0711110551o33ae85d7u2292f953fafad2a@mail.gmail.com> <9BFE53AE-9473-4D55-80E5-030F7005B3F7@sunquake.net> <1d7ddd110711111236m2bb56654q9b099d95e04f34e1@mail.gmail.com> <1d7ddd110711111640mb173d0aye81c5017a2f4fa69@mail.gmail.com> Message-ID: On Nov 11, 2007, at 5:40 PM, Brian Takita wrote: > On Nov 11, 2007 12:36 PM, Brian Takita wrote: >> On Nov 11, 2007 8:29 AM, Leslie Freeman wrote: >>> Slowly digging to the bottom of this one. >>> >>> If I add >>> >>> Test::Unit::TestCase.fixture_path = RAILS_ROOT + '/spec/fixtures/' >>> >>> to my spec_helper.rb, then everything runs fine. So presumably there >>> is somewhere that config.fixture_path from the >>> Spec::Runner.configure >>> block is supposed to get put into Test::Unit::TestCase.fixture_path, >>> and for some reason that is no longer happening. I will continue to >>> dig into this problem, but if anyone is familiar with this part of >>> the rspec system and can help me get to the right place faster, I'd >>> sure appreciate it. >> It looks like rails changed. >> For now just set Test::Unit::TestCase.fixture_path. Ill come up >> with a >> fix in rspec core. > It should be fixed now in trunk. Finally got the chance to upgrade to the new trunk tonight. Everything works again without needing to explicitly set Test::Unit::TestCase.fixture_path. Thanks! Les >> >>> >>> Les >>> >>> >>> >>> On Nov 11, 2007, at 6:51 AM, David Chelimsky wrote: >>> >>>> On Nov 10, 2007 11:25 PM, Leslie Freeman >>>> wrote: >>>>> To follow up on this a little more, I created a new project, froze >>>>> rails to edge (REVISION_8125), and installed rspec/rspec on rails >>>>> from trunk. Then I generated an rspec_model for Asset with the >>>>> following spec: >>>>> >>>>> require File.dirname(__FILE__) + '/../spec_helper' >>>>> >>>>> describe Asset do >>>>> before(:each) do >>>>> @asset = Asset.new >>>>> end >>>>> >>>>> it "should be valid" do >>>>> @asset.should be_valid >>>>> end >>>>> >>>>> it "should allow me to use fixture_file_upload" do >>>>> @asset.attributes = {:uploaded_data => fixture_file_upload >>>>> ('images/florence.jpg', 'image/jpeg')} >>>>> end >>>>> end >>>>> >>>>> I created an images directory in my spec/fixtures dir and added >>>>> florence.jpg to it. Then, when I run rake spec I get this error: >>>>> >>>>> NoMethodError in 'Asset should allow me to use >>>>> fixture_file_upload' >>>> >>>> I am not familiar w/ fixture_file_upload myself. Is there anyone >>>> else >>>> on this list who is who can help Les debug this situation? >>>> >>>> Thanks, >>>> David >>>> >>>>> You have a nil object when you didn't expect it! >>>>> You might have expected an instance of Array. >>>>> The error occurred while evaluating nil.+ >>>>> /Users/leslief/Sites/tmp/testapp/vendor/rails/actionpack/lib/ >>>>> action_controller/test_process.rb:480:in `fixture_file_upload' >>>>> ./spec/models/asset_spec.rb:13: >>>>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >>>>> dsl/ >>>>> example_group_methods.rb:40:in `instance_eval' >>>>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >>>>> dsl/ >>>>> example_group_methods.rb:40:in `run_example' >>>>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >>>>> dsl/ >>>>> example_runner.rb:63:in `run_example' >>>>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >>>>> dsl/ >>>>> example_runner.rb:24:in `run' >>>>> /opt/local/lib/ruby/1.8/timeout.rb:48:in `timeout' >>>>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >>>>> dsl/ >>>>> example_runner.rb:22:in `run' >>>>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >>>>> dsl/ >>>>> example_suite.rb:26:in `rspec_run' >>>>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >>>>> dsl/ >>>>> example_suite.rb:22:in `each' >>>>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >>>>> dsl/ >>>>> example_suite.rb:22:in `rspec_run' >>>>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >>>>> test/ >>>>> unit/example_suite.rb:7:in `run' >>>>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >>>>> runner/ >>>>> behaviour_runner.rb:22:in `run' >>>>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >>>>> runner/ >>>>> behaviour_runner.rb:21:in `each' >>>>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >>>>> runner/ >>>>> behaviour_runner.rb:21:in `run' >>>>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >>>>> runner/ >>>>> options.rb:80:in `run_examples' >>>>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/lib/spec/ >>>>> runner/ >>>>> command_line.rb:19:in `run' >>>>> /Users/leslief/Sites/tmp/testapp/vendor/plugins/rspec/bin/spec:3: >>>>> >>>>> line 13 of asset_spec.rb is @asset.attributes = >>>>> {:uploaded_data => >>>>> fixture_file_upload('images/florence.jpg', 'image/jpeg')} >>>>> >>>>> the offending line in test_process.rb is: >>>>> Test::Unit::TestCase.respond_to?(:fixture_path) ? >>>>> Test::Unit::TestCase.fixture_path + path : path, mime_type, binary >>>>> >>>>> From the full function: >>>>> def fixture_file_upload(path, mime_type = nil, binary = false) >>>>> ActionController::TestUploadedFile.new( >>>>> Test::Unit::TestCase.respond_to?(:fixture_path) ? >>>>> Test::Unit::TestCase.fixture_path + path : path, >>>>> mime_type, >>>>> binary >>>>> ) >>>>> end >>>>> >>>>> so it seems like Test::Unit::TestCase.fixture_path is returning >>>>> nil. >>>>> I tried to do a little digging to find where this should be >>>>> getting >>>>> set, but quickly got way out to sea. >>>>> >>>>> My spec_helper does have this line: >>>>> config.fixture_path = RAILS_ROOT + '/spec/fixtures/' >>>>> >>>>> which seems right. I am hoping someone that knows more about the >>>>> inner gears of rspec has some insight as to why >>>>> Test::Unit::TestCase.fixture_path is nil. >>>>> >>>>> Thanks, >>>>> Les >>>>> >>>>> >>>>> >>>>> On Nov 9, 2007, at 8:25 AM, Leslie Freeman wrote: >>>>> >>>>>> >>>>>> On Nov 9, 2007, at 5:09 AM, David Chelimsky wrote: >>>>>> >>>>>>> On Nov 8, 2007 11:25 PM, Leslie Freeman >>>>>>> >>>>>>> wrote: >>>>>>>> Hi all, >>>>>>>> I had some specs that were using fixture_file_upload that were >>>>>>>> passing just fine. Then I froze edge rails to get some 2.0 >>>>>>>> functionality, then a I upgraded to trunk rspec to deal with >>>>>>>> >>>>>>>> uninitialized constant >>>>>>>> ActionView::Helpers::JavaScriptMacrosHelper >>>>>>>> >>>>>>>> After a couple other of tribulations, I have now gotten down to >>>>>>>> just >>>>>>>> a couple of not passing specs, all using the >>>>>>>> fixture_file_upload. >>>>>>>> Here's an example >>>>>>>> >>>>>>>> it "should be invalid if uploaded file is not an image" do >>>>>>>> @image.attributes = valid_image_attributes.merge >>>>>>>> ({:uploaded_data >>>>>>>> => fixture_file_upload('/textfile.txt', >>>>>>>> >>>>>>>> 'text/plain')}) >>>>>>>> @image.should_not be_valid >>>>>>>> # content_type: is not included in the list >>>>>>>> @image.should have(1).error_on(:content_type) >>>>>>>> end >>>>>>>> >>>>>>>> which fails with: >>>>>>>> 2) >>>>>>>> NoMethodError in 'Image unsaved should be invalid if uploaded >>>>>>>> file is >>>>>>>> not an image' >>>>>>>> You have a nil object when you didn't expect it! >>>>>>>> You might have expected an instance of Array. >>>>>>>> The error occurred while evaluating nil.+ >>>>>>>> ./spec/models/image_spec.rb:25: >>>>>>> >>>>>>> What's on line 25? >>>>>> >>>>>> Sorry about that confusion. Line 25 is: >>>>>> >>>>>> @image.attributes = valid_image_attributes.merge >>>>>> ({:uploaded_data => >>>>>> fixture_file_upload('/textfile.txt',text/plain')}) >>>>>> >>>>>> (textfile.txt is located in my /spec/fixtures/ dir.) >>>>>> >>>>>> That line doesn't throw the error if I change it to something >>>>>> like: >>>>>> @image.attributes = valid_image_attributes.merge >>>>>> ({:uploaded_data => >>>>>> "foo"}) >>>>>> >>>>>> But of course the spec fails. :) >>>>>> >>>>>> Leslie >>>>>> >>>>>>> >>>>>>>> >>>>>>>> A less than helpful error message. Any insight into what >>>>>>>> might be >>>>>>>> causing this? >>>>>>>> >>>>>>>> Thanks, >>>>>>>> Les >>>>>>>> _______________________________________________ >>>>>>>> rspec-users mailing list >>>>>>>> rspec-users at rubyforge.org >>>>>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>>>>> >>>>>>> _______________________________________________ >>>>>>> rspec-users mailing list >>>>>>> rspec-users at rubyforge.org >>>>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>>> >>>>>> _______________________________________________ >>>>>> rspec-users mailing list >>>>>> rspec-users at rubyforge.org >>>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>> >>>>> _______________________________________________ >>>>> rspec-users mailing list >>>>> rspec-users at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> _______________________________________________ >>> 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 pergesu at gmail.com Mon Nov 12 23:47:58 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 12 Nov 2007 20:47:58 -0800 Subject: [rspec-users] it "should [action] ..." vs it with an active voice In-Reply-To: <57c63afe0711121912m2e03e99fob3cc11280eee1452@mail.gmail.com> References: <1d7ddd110711120939k779bbd67m4f1bb768d7da34b6@mail.gmail.com> <60f3810c0711121151o2d08004bn52aef49ba5ebc53b@mail.gmail.com> <57c63afe0711121722y4756866fg440c949e4021cf9@mail.gmail.com> <810a540e0711121809t4552d66fhabcc558dbf8b939e@mail.gmail.com> <57c63afe0711121839k1f79614fgbbf560809653a0b3@mail.gmail.com> <810a540e0711121903l502bc6fbgf902ab42ae6200bd@mail.gmail.com> <57c63afe0711121912m2e03e99fob3cc11280eee1452@mail.gmail.com> Message-ID: <810a540e0711122047j2feb4f86ie2755c4ec6fb0d7b@mail.gmail.com> On Nov 12, 2007 7:12 PM, David Chelimsky wrote: > On Nov 12, 2007 9:03 PM, Pat Maddox wrote: > > > > On 11/12/07, David Chelimsky wrote: > > > On Nov 12, 2007 8:09 PM, Pat Maddox wrote: > > > > The difference is that the story is an authoritative > > > > spec of how the system should behave, and the description has no > > > > authority at all. > > > > > > I don't have that sense at all. Where do you get that from? > > > > >From the belief that the customer is the ultimate authority on what it > > means for the system to behave acceptably, and the fact that stories > > are customer-facing and specs are developer-facing. > > I totally agree that the customer is the authority - however, the > customer has just as much right to change her mind about a story as I > do about a spec! So why should stories be any more locked down than > specs? Stories represent a bridge between the customer's and the developer's minds, a snapshot of the shared understanding at a given point in time. They do not obviate the need for customer-developer communication. A customer should be able to change her stories as much as she wants, but all but the very simplest changes ought to spur a discussion and reevaluation of assumptions. Pat From pergesu at gmail.com Mon Nov 12 23:56:16 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 12 Nov 2007 20:56:16 -0800 Subject: [rspec-users] it "should [action] ..." vs it with an active voice In-Reply-To: <810a540e0711122047j2feb4f86ie2755c4ec6fb0d7b@mail.gmail.com> References: <1d7ddd110711120939k779bbd67m4f1bb768d7da34b6@mail.gmail.com> <60f3810c0711121151o2d08004bn52aef49ba5ebc53b@mail.gmail.com> <57c63afe0711121722y4756866fg440c949e4021cf9@mail.gmail.com> <810a540e0711121809t4552d66fhabcc558dbf8b939e@mail.gmail.com> <57c63afe0711121839k1f79614fgbbf560809653a0b3@mail.gmail.com> <810a540e0711121903l502bc6fbgf902ab42ae6200bd@mail.gmail.com> <57c63afe0711121912m2e03e99fob3cc11280eee1452@mail.gmail.com> <810a540e0711122047j2feb4f86ie2755c4ec6fb0d7b@mail.gmail.com> Message-ID: <810a540e0711122056t2cf464b5n157a626239fd62c2@mail.gmail.com> On Nov 12, 2007 8:47 PM, Pat Maddox wrote: > On Nov 12, 2007 7:12 PM, David Chelimsky wrote: > > On Nov 12, 2007 9:03 PM, Pat Maddox wrote: > > > > > > On 11/12/07, David Chelimsky wrote: > > > > On Nov 12, 2007 8:09 PM, Pat Maddox wrote: > > > > > The difference is that the story is an authoritative > > > > > spec of how the system should behave, and the description has no > > > > > authority at all. > > > > > > > > I don't have that sense at all. Where do you get that from? > > > > > > >From the belief that the customer is the ultimate authority on what it > > > means for the system to behave acceptably, and the fact that stories > > > are customer-facing and specs are developer-facing. > > > > I totally agree that the customer is the authority - however, the > > customer has just as much right to change her mind about a story as I > > do about a spec! So why should stories be any more locked down than > > specs? > > Stories represent a bridge between the customer's and the developer's > minds, a snapshot of the shared understanding at a given point in > time. They do not obviate the need for customer-developer > communication. A customer should be able to change her stories as > much as she wants, but all but the very simplest changes ought to spur > a discussion and reevaluation of assumptions. > > Pat > Also, I don't think this approach poses an obstacle to creative tools like a Story Builder. If anything, I'd say it enhances those tools. A customer can play with the tool and build various stories without committing to anything, building stories and then tossing them away on a whim. Then when she finds a few stories she likes - perhaps it's very valuable, or 80% of the steps are already done - she can bring them up with the developer. That would allow the customer to take a more active role in exploring potential stories, and make more efficient use of direct customer-developer collaboration because less time is wasted sifting through half-hearted stories. Pat From dchelimsky at gmail.com Tue Nov 13 00:00:58 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 12 Nov 2007 23:00:58 -0600 Subject: [rspec-users] it "should [action] ..." vs it with an active voice In-Reply-To: <810a540e0711122047j2feb4f86ie2755c4ec6fb0d7b@mail.gmail.com> References: <1d7ddd110711120939k779bbd67m4f1bb768d7da34b6@mail.gmail.com> <60f3810c0711121151o2d08004bn52aef49ba5ebc53b@mail.gmail.com> <57c63afe0711121722y4756866fg440c949e4021cf9@mail.gmail.com> <810a540e0711121809t4552d66fhabcc558dbf8b939e@mail.gmail.com> <57c63afe0711121839k1f79614fgbbf560809653a0b3@mail.gmail.com> <810a540e0711121903l502bc6fbgf902ab42ae6200bd@mail.gmail.com> <57c63afe0711121912m2e03e99fob3cc11280eee1452@mail.gmail.com> <810a540e0711122047j2feb4f86ie2755c4ec6fb0d7b@mail.gmail.com> Message-ID: <57c63afe0711122100w26dca430sa02805985cbc2073@mail.gmail.com> On Nov 12, 2007 10:47 PM, Pat Maddox wrote: > > On Nov 12, 2007 7:12 PM, David Chelimsky wrote: > > On Nov 12, 2007 9:03 PM, Pat Maddox wrote: > > > > > > On 11/12/07, David Chelimsky wrote: > > > > On Nov 12, 2007 8:09 PM, Pat Maddox wrote: > > > > > The difference is that the story is an authoritative > > > > > spec of how the system should behave, and the description has no > > > > > authority at all. > > > > > > > > I don't have that sense at all. Where do you get that from? > > > > > > >From the belief that the customer is the ultimate authority on what it > > > means for the system to behave acceptably, and the fact that stories > > > are customer-facing and specs are developer-facing. > > > > I totally agree that the customer is the authority - however, the > > customer has just as much right to change her mind about a story as I > > do about a spec! So why should stories be any more locked down than > > specs? > > Stories represent a bridge between the customer's and the developer's > minds, a snapshot of the shared understanding at a given point in > time. They do not obviate the need for customer-developer > communication. A customer should be able to change her stories as > much as she wants, but all but the very simplest changes ought to spur > a discussion and reevaluation of assumptions. We are in violent agreement! But, as irony would have it, this agreement seems to lead us to different conclusions. My thinking is that "should" actually works well in stories for all the same reasons it works well in specs. You seem to take that in a different direction, no? From dchelimsky at gmail.com Tue Nov 13 00:01:47 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 12 Nov 2007 23:01:47 -0600 Subject: [rspec-users] it "should [action] ..." vs it with an active voice In-Reply-To: <810a540e0711122056t2cf464b5n157a626239fd62c2@mail.gmail.com> References: <1d7ddd110711120939k779bbd67m4f1bb768d7da34b6@mail.gmail.com> <60f3810c0711121151o2d08004bn52aef49ba5ebc53b@mail.gmail.com> <57c63afe0711121722y4756866fg440c949e4021cf9@mail.gmail.com> <810a540e0711121809t4552d66fhabcc558dbf8b939e@mail.gmail.com> <57c63afe0711121839k1f79614fgbbf560809653a0b3@mail.gmail.com> <810a540e0711121903l502bc6fbgf902ab42ae6200bd@mail.gmail.com> <57c63afe0711121912m2e03e99fob3cc11280eee1452@mail.gmail.com> <810a540e0711122047j2feb4f86ie2755c4ec6fb0d7b@mail.gmail.com> <810a540e0711122056t2cf464b5n157a626239fd62c2@mail.gmail.com> Message-ID: <57c63afe0711122101l3fff044cg1ad280e07e482166@mail.gmail.com> On Nov 12, 2007 10:56 PM, Pat Maddox wrote: > On Nov 12, 2007 8:47 PM, Pat Maddox wrote: > > On Nov 12, 2007 7:12 PM, David Chelimsky wrote: > > > On Nov 12, 2007 9:03 PM, Pat Maddox wrote: > > > > > > > > On 11/12/07, David Chelimsky wrote: > > > > > On Nov 12, 2007 8:09 PM, Pat Maddox wrote: > > > > > > The difference is that the story is an authoritative > > > > > > spec of how the system should behave, and the description has no > > > > > > authority at all. > > > > > > > > > > I don't have that sense at all. Where do you get that from? > > > > > > > > >From the belief that the customer is the ultimate authority on what it > > > > means for the system to behave acceptably, and the fact that stories > > > > are customer-facing and specs are developer-facing. > > > > > > I totally agree that the customer is the authority - however, the > > > customer has just as much right to change her mind about a story as I > > > do about a spec! So why should stories be any more locked down than > > > specs? > > > > Stories represent a bridge between the customer's and the developer's > > minds, a snapshot of the shared understanding at a given point in > > time. They do not obviate the need for customer-developer > > communication. A customer should be able to change her stories as > > much as she wants, but all but the very simplest changes ought to spur > > a discussion and reevaluation of assumptions. > > > > Pat > > > > Also, I don't think this approach poses an obstacle to creative tools > like a Story Builder. If anything, I'd say it enhances those tools. > A customer can play with the tool and build various stories without > committing to anything, building stories and then tossing them away on > a whim. Then when she finds a few stories she likes - perhaps it's > very valuable, or 80% of the steps are already done - she can bring > them up with the developer. That would allow the customer to take a > more active role in exploring potential stories, and make more > efficient use of direct customer-developer collaboration because less > time is wasted sifting through half-hearted stories. More violent agreement! Although are we still talking about "should"? I think that got lost somewhere. From pergesu at gmail.com Tue Nov 13 00:15:54 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 12 Nov 2007 21:15:54 -0800 Subject: [rspec-users] it "should [action] ..." vs it with an active voice In-Reply-To: <57c63afe0711122100w26dca430sa02805985cbc2073@mail.gmail.com> References: <1d7ddd110711120939k779bbd67m4f1bb768d7da34b6@mail.gmail.com> <60f3810c0711121151o2d08004bn52aef49ba5ebc53b@mail.gmail.com> <57c63afe0711121722y4756866fg440c949e4021cf9@mail.gmail.com> <810a540e0711121809t4552d66fhabcc558dbf8b939e@mail.gmail.com> <57c63afe0711121839k1f79614fgbbf560809653a0b3@mail.gmail.com> <810a540e0711121903l502bc6fbgf902ab42ae6200bd@mail.gmail.com> <57c63afe0711121912m2e03e99fob3cc11280eee1452@mail.gmail.com> <810a540e0711122047j2feb4f86ie2755c4ec6fb0d7b@mail.gmail.com> <57c63afe0711122100w26dca430sa02805985cbc2073@mail.gmail.com> Message-ID: <810a540e0711122115ue2a1579x76455f14c45b530c@mail.gmail.com> On Nov 12, 2007 9:00 PM, David Chelimsky wrote: > > On Nov 12, 2007 10:47 PM, Pat Maddox wrote: > > > > On Nov 12, 2007 7:12 PM, David Chelimsky wrote: > > > On Nov 12, 2007 9:03 PM, Pat Maddox wrote: > > > > > > > > On 11/12/07, David Chelimsky wrote: > > > > > On Nov 12, 2007 8:09 PM, Pat Maddox wrote: > > > > > > The difference is that the story is an authoritative > > > > > > spec of how the system should behave, and the description has no > > > > > > authority at all. > > > > > > > > > > I don't have that sense at all. Where do you get that from? > > > > > > > > >From the belief that the customer is the ultimate authority on what it > > > > means for the system to behave acceptably, and the fact that stories > > > > are customer-facing and specs are developer-facing. > > > > > > I totally agree that the customer is the authority - however, the > > > customer has just as much right to change her mind about a story as I > > > do about a spec! So why should stories be any more locked down than > > > specs? > > > > Stories represent a bridge between the customer's and the developer's > > minds, a snapshot of the shared understanding at a given point in > > time. They do not obviate the need for customer-developer > > communication. A customer should be able to change her stories as > > much as she wants, but all but the very simplest changes ought to spur > > a discussion and reevaluation of assumptions. > > We are in violent agreement! > > But, as irony would have it, this agreement seems to lead us to > different conclusions. My thinking is that "should" actually works > well in stories for all the same reasons it works well in specs. You > seem to take that in a different direction, no? Right. I think that "should" leaves a lot of wiggle room. While I believe that the customer should be allowed to change her stories, I don't think those changes should be finalized without a convo between customer and developer. "should" allows you to make a judgment call and move on, which is the flexibility you want in specs, whereas a slightly more rigid structure makes it clear that new discussion is required. Pat From pergesu at gmail.com Tue Nov 13 00:17:59 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 12 Nov 2007 21:17:59 -0800 Subject: [rspec-users] it "should [action] ..." vs it with an active voice In-Reply-To: <57c63afe0711122101l3fff044cg1ad280e07e482166@mail.gmail.com> References: <1d7ddd110711120939k779bbd67m4f1bb768d7da34b6@mail.gmail.com> <60f3810c0711121151o2d08004bn52aef49ba5ebc53b@mail.gmail.com> <57c63afe0711121722y4756866fg440c949e4021cf9@mail.gmail.com> <810a540e0711121809t4552d66fhabcc558dbf8b939e@mail.gmail.com> <57c63afe0711121839k1f79614fgbbf560809653a0b3@mail.gmail.com> <810a540e0711121903l502bc6fbgf902ab42ae6200bd@mail.gmail.com> <57c63afe0711121912m2e03e99fob3cc11280eee1452@mail.gmail.com> <810a540e0711122047j2feb4f86ie2755c4ec6fb0d7b@mail.gmail.com> <810a540e0711122056t2cf464b5n157a626239fd62c2@mail.gmail.com> <57c63afe0711122101l3fff044cg1ad280e07e482166@mail.gmail.com> Message-ID: <810a540e0711122117h457c2cfale8603c21fffa9714@mail.gmail.com> On Nov 12, 2007 9:01 PM, David Chelimsky wrote: > > On Nov 12, 2007 10:56 PM, Pat Maddox wrote: > > On Nov 12, 2007 8:47 PM, Pat Maddox wrote: > > > On Nov 12, 2007 7:12 PM, David Chelimsky wrote: > > > > On Nov 12, 2007 9:03 PM, Pat Maddox wrote: > > > > > > > > > > On 11/12/07, David Chelimsky wrote: > > > > > > On Nov 12, 2007 8:09 PM, Pat Maddox wrote: > > > > > > > The difference is that the story is an authoritative > > > > > > > spec of how the system should behave, and the description has no > > > > > > > authority at all. > > > > > > > > > > > > I don't have that sense at all. Where do you get that from? > > > > > > > > > > >From the belief that the customer is the ultimate authority on what it > > > > > means for the system to behave acceptably, and the fact that stories > > > > > are customer-facing and specs are developer-facing. > > > > > > > > I totally agree that the customer is the authority - however, the > > > > customer has just as much right to change her mind about a story as I > > > > do about a spec! So why should stories be any more locked down than > > > > specs? > > > > > > Stories represent a bridge between the customer's and the developer's > > > minds, a snapshot of the shared understanding at a given point in > > > time. They do not obviate the need for customer-developer > > > communication. A customer should be able to change her stories as > > > much as she wants, but all but the very simplest changes ought to spur > > > a discussion and reevaluation of assumptions. > > > > > > Pat > > > > > > > Also, I don't think this approach poses an obstacle to creative tools > > like a Story Builder. If anything, I'd say it enhances those tools. > > A customer can play with the tool and build various stories without > > committing to anything, building stories and then tossing them away on > > a whim. Then when she finds a few stories she likes - perhaps it's > > very valuable, or 80% of the steps are already done - she can bring > > them up with the developer. That would allow the customer to take a > > more active role in exploring potential stories, and make more > > efficient use of direct customer-developer collaboration because less > > time is wasted sifting through half-hearted stories. > > More violent agreement! Although are we still talking about "should"? > I think that got lost somewhere. No, I went down a separate path there. I figured that someone could read my thoughts and ask, "But doesn't that mean less flexibility for the customer? She always has to strike up a convo with the developer" to which the reply is "only when she needs to." Pat From win at wincent.com Tue Nov 13 04:59:55 2007 From: win at wincent.com (Wincent Colaiuta) Date: Tue, 13 Nov 2007 10:59:55 +0100 Subject: [rspec-users] it "should [action] ..." vs it with an active voice In-Reply-To: References: Message-ID: (Coming in a little late on this thread...) Although I use "should" in basically all of my examples I share some of Brian's objections to it. IMO, the strongest argument against it is that it is repetitive, and the strongest argument in its favor is that it perfectly captures the discrepancy between expected and actual behaviour in the case of failed or pending examples. In an ideal world we'd be able to omit all those "shoulds", avoiding the repetition, and have RSpec automatically add them back in when needed (like when outputting failed or pending examples). In other words, we'd be able to write things like: it 'returns true if other has the same length' And in the case of a failed or pending example have RSpec automatically convert this to: 'should return true if other has the same length' This would require some sort of intelligent heuristic along the lines of wait Rails does with pluralization using inflectors. I am not sure if this is realistic, as the grammar involved goes somewhat beyond what's required by simple pluralization. In most cases, like the one above, examples take the form of "should [verb]" and would need to be transformed into "[verb]+s". Slightly more complicated are verbs in the passive voice: "should be substituted into the output" Would become: "is substituted into the output" Or cases like this one: "should be able to round trip" Whose counterpart is: "can round trip" Trickier are ones where "should" is not the first word in the example. Looking in my own specs I occasionally have ones worded like this: "line and column end should reflect last succesfully scanned position prior to failure" This one highlights a potential problem: that any automated translation would impose strict requirements on the form that examples could take, and the loss in flexibility may make it not worth it (in the example above I would have to move the "line and column end" up into the "describe" parameter, and doing that would require me to split the existing block up into two separate blocks). It's clear that there will be cases in which the freedom to write flexible "it" parameters will make your specs more natural, readable, and less awkward. Another problem, this would (obviously) only work for English. Anyway, just an idea to throw out there. Cheers, Wincent From lists at ruby-forum.com Tue Nov 13 09:47:54 2007 From: lists at ruby-forum.com (Karni Karni) Date: Tue, 13 Nov 2007 15:47:54 +0100 Subject: [rspec-users] Test case for file import In-Reply-To: <8d961d900711121524v72ba62datf2deec52852beff4@mail.gmail.com> References: <1b165db00711060451s6d7fdc44he2fffb12c1f74bd7@mail.gmail.com> <57c63afe0711060502m6c92ccdaye78ce6846175fe3f@mail.gmail.com> <1b165db00711060554m6afc3418q34703319b5e5e8c4@mail.gmail.com> <13703316.post@talk.nabble.com> <8d961d900711121524v72ba62datf2deec52852beff4@mail.gmail.com> Message-ID: aslak hellesoy wrote: > On Nov 12, 2007 11:36 AM, KarniRevuri wrote: >> typical windows file open controls." >> >> >> Please give me any ideas >> > > Is this related to the post that you replied to? > Your question is too vague. Can you be more specific about what you > need help with? > > Aslak Sorry, I need write a script for file import in the below situation specify "The import WILL NOT update existing tasks." Precondtions : I'm explain about tasks view in my requirment There are already some tasks in the database Process: there is file import functionality. I need to test it. if we import any records from CSV file it wont effect the previous tasks(records) Plesase give me u r ideas -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Tue Nov 13 10:39:44 2007 From: ben at benmabey.com (Ben Mabey) Date: Tue, 13 Nov 2007 08:39:44 -0700 Subject: [rspec-users] Autotest with rspec HTML output In-Reply-To: <8d961d900711110821v5f1d5626gc83d573be01cfb59@mail.gmail.com> References: <47369567.3010601@benmabey.com> <8d961d900711110429q4c62eb90y4ac581bd97ab3d97@mail.gmail.com> <473720DE.7000500@benmabey.com> <8d961d900711110821v5f1d5626gc83d573be01cfb59@mail.gmail.com> Message-ID: <4739C540.3060807@benmabey.com> Thanks for the suggestions Aslak. I ended up doing pretty much what you said. I added a custom formatter that added a little functionality onto the HTML formatter. Instead of using a server all I did was use prototype/lowpro to refresh the page until all the specs were complete. I then used an autotest hook to have the browser refresh using applescript. Except for the last part it is all works on any machine with a browser. I have some ideas of how to work in the story runner in my tool... I know you were working on the HTML docs/ little app for plain text stories. Have you make any progress since your blog post about it? Thanks, Ben aslak hellesoy wrote: > On Nov 11, 2007 4:33 PM, Ben Mabey wrote: > >> I was thinking that a little window(cocoa) or maybe just a browser >> window could display the summary of the test run like autotest does and >> then the failed specs in HTML format. Not the entire HTML report would >> be generated/displayed- only the failing ones would be so it would be >> manageable on projects with large test suites. So, instead of having a >> terminal window open with autotest it would just be a stand alone window. >> >> > > I think the simplest and best thing here would be a pure browser > solution with autorefresh. > It should only be a matter of tweaking the HTML output a little to: > * Implement autorefresh. Ajax based would require a lite server > (webrick). Or just META refresh would work on the file system. > * Tweak the HTML output to only output the red specs, not the green ones. > > I don't like the cocoa idea - too proprietary. The qlmanage wouldn't > provide much value beyond growl bubbles. You wanted to click on the > HTML and go to the editor right? > > Aslak > > >> aslak hellesoy wrote: >> >>> Where would the HTML report be displayed? >>> >>> On Nov 11, 2007 6:38 AM, Ben Mabey wrote: >>> >>> >>>> Hey all, >>>> I was just wondering if any one has played around with getting >>>> autotest's rspec integration working with rspec's HTML output. I really >>>> like how in the rspec textmate bundle the context of the failing code >>>> is inlined with the failing spec along with the exact line highlighted >>>> and a link to the exact spot in reference. However, I rarely use this >>>> nice output since autotest is so convenient... So, I was thinking >>>> wouldn't it be great to have the best of both worlds? What do you >>>> think? And before I try and do this, has anyone else already done it? >>>> >>>> >>>> -Ben >>>> >>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>>> >>>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Tue Nov 13 11:37:21 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 13 Nov 2007 17:37:21 +0100 Subject: [rspec-users] Test case for file import In-Reply-To: References: <1b165db00711060451s6d7fdc44he2fffb12c1f74bd7@mail.gmail.com> <57c63afe0711060502m6c92ccdaye78ce6846175fe3f@mail.gmail.com> <1b165db00711060554m6afc3418q34703319b5e5e8c4@mail.gmail.com> <13703316.post@talk.nabble.com> <8d961d900711121524v72ba62datf2deec52852beff4@mail.gmail.com> Message-ID: <8d961d900711130837t7dbe37cao7675d6c20e6417c7@mail.gmail.com> look at the RDoc for should change... describe Task do fixtures :tasks # should put 2 tasks in the database it "should not import twice from CSV" do csv = File.dirname(__FILE__) + '/sample.csv' # It should have 4 new tasks lambda do Task.import_from_csv(csv) end.should change {Task.count}.from(2).to(6) lambda do Task.import_from_csv(csv) end.should_not change {Task.count} end end HTH, Aslak On 11/13/07, Karni Karni wrote: > aslak hellesoy wrote: > > On Nov 12, 2007 11:36 AM, KarniRevuri wrote: > >> typical windows file open controls." > >> > >> > >> Please give me any ideas > >> > > > > Is this related to the post that you replied to? > > Your question is too vague. Can you be more specific about what you > > need help with? > > > > Aslak > > Sorry, > > I need write a script for file import in the below situation > > > specify "The import WILL NOT update existing tasks." > > Precondtions : > > I'm explain about tasks view in my requirment > > There are already some tasks in the database > > > Process: there is file import functionality. > > I need to test it. if we import any records from CSV file it wont > effect the previous tasks(records) > > Plesase give me u r ideas > > > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From rspec.user at gmail.com Tue Nov 13 12:05:53 2007 From: rspec.user at gmail.com (sinclair bain) Date: Tue, 13 Nov 2007 12:05:53 -0500 Subject: [rspec-users] Story problem if parenthesis used in Given, When, Then or And Message-ID: <2ca660dd0711130905m35abc2e5h947720f2b0acadf8@mail.gmail.com> VERSION: rspec rails plugin current edge version XP/Cygwin on XP Hi, I hit this when trying to use parenthesis in my stories ... (that'll teach me!). If a scenario looks like the following: Story "User has story with parentheses", %{ As a user I want parenthesis So that ... well I just do }, :type => RailsStory do Scenario "the Given has parentheses" do Given "parenthesis () in the given " do end When "anything" do end Then "The error occurred while evaluating nil.perform " do end end end This fails with the following: The error occurred while evaluating nil.perform /cygdrive/c/development/sandbox/prototypes/proj/config/../vendor/plugins/rspec/lib/spec/story/world.rb: 60:in `store_and_call' /cygdrive/c/development/sandbox/prototypes/proj/config/../vendor/plugins/rspec/lib/spec/story/world.rb: 92:in `Given' stories/parenthesis_error_story.rb:10 Looks like the problem is in the Step#matches? method since "abc (re) def".match /abc (re) def/ returns nil however "abc (re) def".match /abc \(re\) def/ returns the match The Step#assign_expression method when modifed as follows def assign_expression(name) expression = name.dup if String === expression while expression =~ /(\$\w*)/ expression.gsub!($1, "(.*)") end expression.gsub! '(', '\(' # here expression.gsub! ')', '\)' # here end @expression = Regexp.new("^#{expression}$") end Then the specs pass. This has been here for a couple of weeks just got round to debugging. HTH heers! sinclair -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071113/772bad2b/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: parenthesis_error_story.rb Type: application/octet-stream Size: 893 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20071113/772bad2b/attachment.obj From jarkko at jlaine.net Tue Nov 13 11:52:29 2007 From: jarkko at jlaine.net (Jarkko Laine) Date: Tue, 13 Nov 2007 18:52:29 +0200 Subject: [rspec-users] Spec slowdown Message-ID: <53AEF18C-BC83-4FBE-86E6-62CA848AC3D7@jlaine.net> Is there something currently going on on the rspec trunk that causes a massive slowdown when running rake spec and autotest (without spec_server)? I updated to the latest trunk yesterday and the time needed to run the specs of my app jumped from ~20 seconds to more than a minute. The weird thing is that if I run the rake spec tasks separately (controllers, models, views, helpers), they still take about 20 seconds in total: http://pastie.caboo.se/117362 //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi From dchelimsky at gmail.com Tue Nov 13 12:16:09 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 13 Nov 2007 11:16:09 -0600 Subject: [rspec-users] Story problem if parenthesis used in Given, When, Then or And In-Reply-To: <2ca660dd0711130905m35abc2e5h947720f2b0acadf8@mail.gmail.com> References: <2ca660dd0711130905m35abc2e5h947720f2b0acadf8@mail.gmail.com> Message-ID: <57c63afe0711130916k2b8dac07vd95e70082bc07d18@mail.gmail.com> On Nov 13, 2007 11:05 AM, sinclair bain wrote: > VERSION: rspec rails plugin current edge version > XP/Cygwin on XP > > Hi, > I hit this when trying to use parenthesis in my stories ... (that'll teach > me!). > > If a scenario looks like the following: > > Story "User has story with parentheses", %{ > As a user > I want parenthesis > So that ... well I just do > }, :type => RailsStory do > > Scenario "the Given has parentheses" do > Given "parenthesis () in the given " do > end > > When "anything" do > end > > Then "The error occurred while evaluating nil.perform " do > end > > end > end > > This fails with the following: > > The error occurred while evaluating nil.perform > > /cygdrive/c/development/sandbox/prototypes/proj/config/../vendor/plugins/rspec/lib/spec/story/world.rb: > 60:in `store_and_call' > /cygdrive/c/development/sandbox/prototypes/proj/config/../vendor/plugins/rspec/lib/spec/story/world.rb: > 92:in `Given' > stories/parenthesis_error_story.rb:10 > > > Looks like the problem is in the Step#matches? method > since > "abc (re) def".match /abc (re) def/ > returns nil > however > "abc (re) def".match /abc \(re\) def/ > returns the match > > The Step#assign_expression method when modifed as follows > > def assign_expression(name) > expression = name.dup > if String === expression > while expression =~ /(\$\w*)/ > expression.gsub!($1, "(.*)") > end > > expression.gsub! '(', '\(' # here > expression.gsub! ')', '\)' # here > > end > @expression = Regexp.new ("^#{expression}$") > end > > Then the specs pass. > > This has been here for a couple of weeks just got round to debugging. Please do not use this list for patches if you expect them to be incorporated. http://rspec.rubyforge.org/community/contribute.html http://rubyforge.org/tracker/?group_id=797 Cheers, David From dchelimsky at gmail.com Tue Nov 13 12:21:19 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 13 Nov 2007 11:21:19 -0600 Subject: [rspec-users] Spec slowdown In-Reply-To: <53AEF18C-BC83-4FBE-86E6-62CA848AC3D7@jlaine.net> References: <53AEF18C-BC83-4FBE-86E6-62CA848AC3D7@jlaine.net> Message-ID: <57c63afe0711130921l3c871e31w907d7796517186ad@mail.gmail.com> On Nov 13, 2007 10:52 AM, Jarkko Laine wrote: > Is there something currently going on on the rspec trunk that causes > a massive slowdown when running rake spec and autotest (without > spec_server)? I updated to the latest trunk yesterday and the time > needed to run the specs of my app jumped from ~20 seconds to more > than a minute. The weird thing is that if I run the rake spec tasks > separately (controllers, models, views, helpers), they still take > about 20 seconds in total: http://pastie.caboo.se/117362 That's really weird. We are doing some refactoring and it is admittedly still mid-stream, but I'm stumped as to why it would only have a negative impact when you run all the examples. Also - I'm using the latest and do not see this drop in speed. So, for the moment, please keep an eye on it and let us know if changes over the next few days resolve this or not. If not, we'll take a closer look before the release. Thanks, David ps - in case you didn't notice: config.breakpoint_server has been deprecated and has no effect. From rspec.user at gmail.com Tue Nov 13 12:54:23 2007 From: rspec.user at gmail.com (sinclair bain) Date: Tue, 13 Nov 2007 12:54:23 -0500 Subject: [rspec-users] Story problem if parenthesis used in Given, When, Then or And In-Reply-To: <57c63afe0711130916k2b8dac07vd95e70082bc07d18@mail.gmail.com> References: <2ca660dd0711130905m35abc2e5h947720f2b0acadf8@mail.gmail.com> <57c63afe0711130916k2b8dac07vd95e70082bc07d18@mail.gmail.com> Message-ID: <2ca660dd0711130954k4027a3b7p98ea8279d76c9e87@mail.gmail.com> Submitted error #15608. On Nov 13, 2007 12:16 PM, David Chelimsky wrote: > On Nov 13, 2007 11:05 AM, sinclair bain wrote: > > VERSION: rspec rails plugin current edge version > > XP/Cygwin on XP > > > > Hi, > > I hit this when trying to use parenthesis in my stories ... (that'll > teach > > me!). > > > > If a scenario looks like the following: > > > > Story "User has story with parentheses", %{ > > As a user > > I want parenthesis > > So that ... well I just do > > }, :type => RailsStory do > > > > Scenario "the Given has parentheses" do > > Given "parenthesis () in the given " do > > end > > > > When "anything" do > > end > > > > Then "The error occurred while evaluating nil.perform " do > > end > > > > end > > end > > > > This fails with the following: > > > > The error occurred while evaluating nil.perform > > > > > /cygdrive/c/development/sandbox/prototypes/proj/config/../vendor/plugins/rspec/lib/spec/story/world.rb: > > 60:in `store_and_call' > > > /cygdrive/c/development/sandbox/prototypes/proj/config/../vendor/plugins/rspec/lib/spec/story/world.rb: > > 92:in `Given' > > stories/parenthesis_error_story.rb:10 > > > > > > Looks like the problem is in the Step#matches? method > > since > > "abc (re) def".match /abc (re) def/ > > returns nil > > however > > "abc (re) def".match /abc \(re\) def/ > > returns the match > > > > The Step#assign_expression method when modifed as follows > > > > def assign_expression(name) > > expression = name.dup > > if String === expression > > while expression =~ /(\$\w*)/ > > expression.gsub!($1, "(.*)") > > end > > > > expression.gsub! '(', '\(' # here > > expression.gsub! ')', '\)' # here > > > > end > > @expression = Regexp.new ("^#{expression}$") > > end > > > > Then the specs pass. > > > > This has been here for a couple of weeks just got round to debugging. > > Please do not use this list for patches if you expect them to be > incorporated. > > http://rspec.rubyforge.org/community/contribute.html > http://rubyforge.org/tracker/?group_id=797 > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Cheers! sinclair -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071113/2f9fb2be/attachment.html From dchelimsky at gmail.com Tue Nov 13 12:58:12 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 13 Nov 2007 11:58:12 -0600 Subject: [rspec-users] Story problem if parenthesis used in Given, When, Then or And In-Reply-To: <2ca660dd0711130954k4027a3b7p98ea8279d76c9e87@mail.gmail.com> References: <2ca660dd0711130905m35abc2e5h947720f2b0acadf8@mail.gmail.com> <57c63afe0711130916k2b8dac07vd95e70082bc07d18@mail.gmail.com> <2ca660dd0711130954k4027a3b7p98ea8279d76c9e87@mail.gmail.com> Message-ID: <57c63afe0711130958j2edff922n8e95b456c38f600@mail.gmail.com> On Nov 13, 2007 11:54 AM, sinclair bain wrote: > Submitted error #15608. Thanks! From pergesu at gmail.com Tue Nov 13 14:10:38 2007 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 13 Nov 2007 11:10:38 -0800 Subject: [rspec-users] Role of stories vs specs Message-ID: <810a540e0711131110t73149f26r50fd6dadbe20ae90@mail.gmail.com> I've been thinking about the role that stories played compared to specs, and that "should we use should" thread brought those thoughts up again. First I want to discuss whether or not specs are authoritative regarding the desired behavior of a system. I would say they're a good approximation of how the system currently runs according to the developer's understanding. I say they're an approximation because if you use mocks everywhere (as I believe you ought to) then you're not performing integrations and the specs are necessarily incomplete. Why does that idea matter? Traditionally, we've leaned heavily on a suite of unit tests to perform refactorings. In fact, Fowler says the first thing you have to do in order to refactor is grow a set of comprehensive unit tests. Refactoring, by definition, is changing the structure without changing the observable behavior. Implicit in using tests to enable refactoring is the idea that those tests precisely define what the behavior of a system should be. If we say that our specs are not actual specifications of desired behavior, then specs aren't sufficient safety nets for refactoring. This mostly comes from my experience that refactoring is often a PITA when using mocks. Mocks isolate dependencies, which is great, and makes it easy to change code without affecting parts of the system that really shouldn't be affected. However they make simple, standard refactorings like "move method" more difficult. If I say that stories are authoritative and specs aren't, then that means I ought to rely on stories to provide the safety net for my refactoring. When taking those baby steps, it's important to keep the stories green rather than the specs. Another result of this thinking is that more specification should be done in stories than I originally thought. Edge cases are my prime example. I used to think I should write a story that expresses the general desired behavior, and then cover any edge cases in specs. However edge cases should be covered by stories because stories define the desired behavior of the system. Also, edge cases presumably represent some business value to the customer. Finally, it's better to keep all of the desired behavior specs in one place. Stories are naturally more verbose than specs though. That paragraph feels awkward to me, because I think I'm missing some vocabulary. It suggests to me that the collection of all user stories is the app specification - "spec" for short. What is the collection of all descriptions, the object-level specs? I've always just said "specs," but I don't think that really fits anymore with my current thinking. Not to mention it's just confusing if I also use "spec" to mean the collection of all user stories. I know that an individual describe block is a "description," but maybe the whole suite should be called "descriptions" instead of "specs?" What do you guys think? Is it useful to draw a line and say that stories are authoritative and specs aren't? Do you think it becomes less crucial to use object-level specs to enable refactoring, and instead lean on stories more? Pat From barjunk at attglobal.net Tue Nov 13 14:45:40 2007 From: barjunk at attglobal.net (barsalou) Date: Tue, 13 Nov 2007 10:45:40 -0900 Subject: [rspec-users] testing scripts Message-ID: <20071113104540.dr41p6lxz44w0c88@lcgalaska.com> So in the past I've written a script that query's a remote DB, takes the data, validates it, then does some processing, producing a new file with the data in a completely different format. Since this is a script with it's own set of methods, etc, how do I go about testing the pieces parts? It seems like it should be no different than doing the rails testing I have been doing, but I think I'm missing something fundamental about ruby. What I'm doing now is wrapping the methods in a module, then including the module at the top of the script. I'm thinking this will allow me test those methods independently of the script itself. There still the problem of testing the logic of the script, but I'll keep banging away, and report back. Are there other ways one might do testing against a script like this? Mike B. ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. From dchelimsky at gmail.com Tue Nov 13 14:51:53 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 13 Nov 2007 13:51:53 -0600 Subject: [rspec-users] Role of stories vs specs In-Reply-To: <810a540e0711131110t73149f26r50fd6dadbe20ae90@mail.gmail.com> References: <810a540e0711131110t73149f26r50fd6dadbe20ae90@mail.gmail.com> Message-ID: <57c63afe0711131151w733c7b70id8cd59a5d64cd196@mail.gmail.com> On Nov 13, 2007 1:10 PM, Pat Maddox wrote: > I've been thinking about the role that stories played compared to > specs, and that "should we use should" thread brought those thoughts > up again. > > First I want to discuss whether or not specs are authoritative > regarding the desired behavior of a system. I would say they're a > good approximation of how the system currently runs according to the > developer's understanding. I say they're an approximation because if > you use mocks everywhere (as I believe you ought to) then you're not > performing integrations and the specs are necessarily incomplete. > > Why does that idea matter? Traditionally, we've leaned heavily on a > suite of unit tests to perform refactorings. In fact, Fowler says the > first thing you have to do in order to refactor is grow a set of > comprehensive unit tests. > > Refactoring, by definition, is changing the structure without changing > the observable behavior. IMO, that definition refers to a system, not individual objects. When you change objects, you usually have to change the examples. Keep in mind that that goes nearly unnoticed in java or .NET because of the refactoring tools available on those platforms. Change a method name once and it changes it everywhere, *including the examples*. Move a method from one object to another and you get a dialog that let's you opt to leave the existing method in place delegating to the new location, or change all the consumers of that method in the system, *including the examples*, to use the new location. > Implicit in using tests to enable > refactoring is the idea that those tests precisely define what the > behavior of a system should be. Not so much about precision as it is about comprehensiveness. > If we say that our specs are not > actual specifications of desired behavior, then specs aren't > sufficient safety nets for refactoring. Again - this word "specification" is causing trouble. Examples have three different roles. When you first write them, they are examples of how you want an object to behave. After you get them to pass, they become both executable documents of the system as it is and regression tests. In their role as regression tests, they serve the same role as unit tests do in refactoring. > This mostly comes from my experience that refactoring is often a PITA > when using mocks. Mocks isolate dependencies, which is great, and > makes it easy to change code without affecting parts of the system > that really shouldn't be affected. However they make simple, standard > refactorings like "move method" more difficult. Again - this is a solved problem in other platforms and will eventually be solved in ours. > If I say that stories are authoritative and specs aren't, then that > means I ought to rely on stories to provide the safety net for my > refactoring. When taking those baby steps, it's important to keep the > stories green rather than the specs. On some level that makes sense - but it's going to slow you down quite a bit when you start building up a significant suite of stories. The way I've always dealt with this was to rely on the examples to get me through a refactoring, and then run the stories before committing. That allows me to stay focused on small problems and progress steadily. By the way, when I say "always dealt with this", I'm talking about some years of experience using FitNesse for stories and xUnit for examples. So although the Story Runner is new, the idea of having two separate environments - one for system-level examples and one for object-level examples - has been around for a while. > Another result of this thinking is that more specification should be > done in stories than I originally thought. Edge cases are my prime > example. I used to think I should write a story that expresses the > general desired behavior, and then cover any edge cases in specs. I think they should be covered in both stories and examples. The thing is that they get covered in different ways. For one, the language in which they are expressed is different - because the stories are about the system and the examples are about the objects in the system. And there will be some duplicated effort between the stories and the examples - and that is a GOOD thing. Additionally, when dealing with stories, you may specify that a particular error message shows up on the screen. However, when you get down to the individual objects, you would likely have a single example showing that the screen will show whatever error message you throw at it, and then move down to the model to generate this particular edge case message. > However edge cases should be covered by stories because stories define > the desired behavior of the system. Definitely! > Also, edge cases presumably > represent some business value to the customer. Definitely! > Finally, it's better > to keep all of the desired behavior specs in one place. Here's where we disagree. I think that it's a matter of who the audience is for the different tools. > Stories are > naturally more verbose than specs though. > > That paragraph feels awkward to me, because I think I'm missing some > vocabulary. It suggests to me that the collection of all user stories > is the app specification - "spec" for short. What is the collection > of all descriptions, the object-level specs? I've always just said > "specs," but I don't think that really fits anymore with my current > thinking. Not to mention it's just confusing if I also use "spec" to > mean the collection of all user stories. I know that an individual > describe block is a "description," but maybe the whole suite should be > called "descriptions" instead of "specs?" The vocabulary that we seem to be moving to in the trunk is this: Story Framework - Stories - Scenarios - Steps Example Framework - ExampleGroups (what you referred to as descriptions) - Examples I'm not completely comfortable with this yet in terms of being able to talk about it, so suggestions are welcome. The problem with using Spec or Example is that either can easily refer to the coarse grained stories or the fine grained object level examples. Maybe we should call them Coarse Grained Examples and Fine Grained Examples :) Seriously - I welcome other thoughts on this. > > What do you guys think? Is it useful to draw a line and say that > stories are authoritative and specs aren't? I don't find this useful. To me they are two completely separate animals that work together to describe the behaviour of a system. They are equally authoritative (or not). They both have a life cycle in which they move from examples of what we'd like to examples of what we have. > Do you think it becomes > less crucial to use object-level specs to enable refactoring, and > instead lean on stories more? I think it's useful to use the stories as a periodic sanity check (as I mentioned above), but I think that if you start using stories as your safety net while you're in the rapid flow of refactoring, you're begging for a significant drop in productivity. They're just going to take to long to run and won't help you to isolate problems as they arise. Thanks for the thought provoking post! Cheers, David From hans at degraaff.org Tue Nov 13 15:14:32 2007 From: hans at degraaff.org (Hans de Graaff) Date: Tue, 13 Nov 2007 21:14:32 +0100 Subject: [rspec-users] Autotest with rspec HTML output In-Reply-To: <8d961d900711110821v5f1d5626gc83d573be01cfb59@mail.gmail.com> References: <47369567.3010601@benmabey.com> <8d961d900711110429q4c62eb90y4ac581bd97ab3d97@mail.gmail.com> <473720DE.7000500@benmabey.com> <8d961d900711110821v5f1d5626gc83d573be01cfb59@mail.gmail.com> Message-ID: <1194984872.8435.4.camel@ip6-localhost> On Sun, 2007-11-11 at 17:21 +0100, aslak hellesoy wrote: > I think the simplest and best thing here would be a pure browser > solution with autorefresh. > It should only be a matter of tweaking the HTML output a little to: > * Implement autorefresh. Ajax based would require a lite server > (webrick). Or just META refresh would work on the file system. I've been using this approach on and off for a while, using the META refresh technique both off of the file system and through a web server. I don't right now because it was taking up a bit too much screen space. Now that I've got a second monitor to hook up that may change again. I've been using a refresh rate of 30s, but that's actually already too slow. I guess a better solution would be to be able to trigger an action after specs have run. The actual command could just be a shell command defined in the spec.opts file, so that people can do whatever is the right thing for their platform and environment. > * Tweak the HTML output to only output the red specs, not the green ones. That would be useful. Kind regards, Hans -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://rubyforge.org/pipermail/rspec-users/attachments/20071113/1a554750/attachment.bin From joshknowles at gmail.com Tue Nov 13 15:23:20 2007 From: joshknowles at gmail.com (Josh Knowles) Date: Tue, 13 Nov 2007 15:23:20 -0500 Subject: [rspec-users] rails story runner returning a nil response code Message-ID: Has anyone noticed any problems with the Rails story runner returning a response code of "0" when doing get/post/etc methods? I just grabbed the latest rails/rspec and just started noticing this problem, http://pastie.caboo.se/117497 Regular controller specs pass as expected. -- Josh Knowles phone: 509-979-1593 email: joshknowles at gmail.com web: http://joshknowles.com From mlins at webinforem.com Tue Nov 13 15:23:29 2007 From: mlins at webinforem.com (Matthew Lins) Date: Tue, 13 Nov 2007 14:23:29 -0600 Subject: [rspec-users] Trouble stubbing a method Message-ID: Hey guys, I'll try to explain this without the model code at first, since there is so much, but if need be, I'll pastie it. I have an Order model that makes API calls to a payment gateway(TrustCommerce) during validation(to verify the credit card information). I'd like to stub this behavior to avoid thousands of calls to TrustCommerce a day(autotest). All the calls are made in one method: Order#payment_authorize. This is called from ActiveRecord#validate. So, my thinking was just to stub out Order#payment_authorize. So here is one of my specs: describe Order, "placed via the web" do include OrderSpecHelper before(:each) do @order = generate_valid_web_order @order.should_receive(:payment_authorize) end it do @order.should be_valid end end I'm using a mock for now, just to verify it does get called, once it's working I'll change it to a stub. (I want to explicitly test it on another spec) Anyhow, this doesn't work, but sure enough, the calls out to TrustCommerce are being made. I also tried this: describe Order, "placed via the web" do include OrderSpecHelper before(:each) do @order = generate_valid_web_order Order.should_receive(:payment_authorize) end it do @order.should be_valid end end However, this didn't work either. Just for clarity, this is how it's being called in the model: validate :payment_authorize How can I stub this method? Thanks, Matt Lins From mlins at webinforem.com Tue Nov 13 15:26:39 2007 From: mlins at webinforem.com (Matthew Lins) Date: Tue, 13 Nov 2007 14:26:39 -0600 Subject: [rspec-users] Trouble stubbing a method In-Reply-To: Message-ID: BTW...When I say, "this doesn't work" I mean the spec fails on the mock, saying the method was never called. But, indeed it was, I can verify it by the TrustCommerce logs. On 11/13/07 2:23 PM, "Matthew Lins" wrote: > Hey guys, > > I'll try to explain this without the model code at first, since there is so > much, but if need be, I'll pastie it. > > I have an Order model that makes API calls to a payment > gateway(TrustCommerce) during validation(to verify the credit card > information). I'd like to stub this behavior to avoid thousands of calls to > TrustCommerce a day(autotest). > > All the calls are made in one method: Order#payment_authorize. This is > called from ActiveRecord#validate. > > So, my thinking was just to stub out Order#payment_authorize. So here is one > of my specs: > > describe Order, "placed via the web" do > > include OrderSpecHelper > > before(:each) do > @order = generate_valid_web_order > @order.should_receive(:payment_authorize) > end > > it do > @order.should be_valid > end > > end > > I'm using a mock for now, just to verify it does get called, once it's > working I'll change it to a stub. (I want to explicitly test it on another > spec) > > Anyhow, this doesn't work, but sure enough, the calls out to TrustCommerce > are being made. I also tried this: > > describe Order, "placed via the web" do > > include OrderSpecHelper > > before(:each) do > @order = generate_valid_web_order > Order.should_receive(:payment_authorize) > end > > it do > @order.should be_valid > end > > end > > However, this didn't work either. Just for clarity, this is how it's being > called in the model: > > validate :payment_authorize > > How can I stub this method? > > Thanks, > > Matt Lins > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mailing_lists at railsnewbie.com Tue Nov 13 15:36:38 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 13 Nov 2007 15:36:38 -0500 Subject: [rspec-users] Trouble stubbing a method In-Reply-To: References: Message-ID: <0708F76F-D8FA-4C46-9108-448F2E1444E8@railsnewbie.com> On Nov 13, 2007, at 3:23 PM, Matthew Lins wrote: > Hey guys, > > I'll try to explain this without the model code at first, since > there is so > much, but if need be, I'll pastie it. > > I have an Order model that makes API calls to a payment > gateway(TrustCommerce) during validation(to verify the credit card > information). I'd like to stub this behavior to avoid thousands of > calls to > TrustCommerce a day(autotest). > > All the calls are made in one method: Order#payment_authorize. This is > called from ActiveRecord#validate. > > So, my thinking was just to stub out Order#payment_authorize. So > here is one > of my specs: > > describe Order, "placed via the web" do > > include OrderSpecHelper > > before(:each) do > @order = generate_valid_web_order > @order.should_receive(:payment_authorize) > end You probably want @order.stub!(:payment_authorize) - should_receive is an assertion. It doesn't belong in a before(:each)/setup block. If you want to test that the payment_authorize is called, you'll want to pull the assertion that you gave below into your spec: describe Order, "placed via the web" do include OrderSpecHelper before(:each) do @order = generate_valid_web_order @order.stub!(:payment_authorize).and_return true end it "should try to authorize the payment when validating the record" do @order.should_receive(:payment_authorize).and_return true @order.should be_valid end end Scott From dchelimsky at gmail.com Tue Nov 13 15:43:19 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 13 Nov 2007 14:43:19 -0600 Subject: [rspec-users] rails story runner returning a nil response code In-Reply-To: References: Message-ID: <57c63afe0711131243r5017bcacma424c08841d0d37e@mail.gmail.com> On Nov 13, 2007 2:23 PM, Josh Knowles wrote: > Has anyone noticed any problems with the Rails story runner returning > a response code of "0" when doing get/post/etc methods? I just > grabbed the latest rails/rspec and just started noticing this problem, > http://pastie.caboo.se/117497 > > Regular controller specs pass as expected. RailsStory just wraps ActionController::IntegrationTest, so you're getting what you would get from an IntegrationTest. Controller examples override rescue_action for you, but RailsStory does not yet. I suppose we should add that. > > > > > -- > Josh Knowles > phone: 509-979-1593 > email: joshknowles at gmail.com > web: http://joshknowles.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From work at ashleymoran.me.uk Tue Nov 13 15:43:53 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Tue, 13 Nov 2007 20:43:53 +0000 Subject: [rspec-users] testing scripts In-Reply-To: <20071113104540.dr41p6lxz44w0c88@lcgalaska.com> References: <20071113104540.dr41p6lxz44w0c88@lcgalaska.com> Message-ID: <84ECF846-4D27-428D-BCEA-785E60E02AA7@ashleymoran.me.uk> On Nov 13, 2007, at 7:45 pm, barsalou wrote: > What I'm doing now is wrapping the methods in a module, then including > the module at the top of the script. Can you post some examples of the modules, classes and methods you have? Every script I've written is basically just a little object-oriented app that's got a bit at the end to fire off some "main" class with the command line args. Testing one is no different than testing, say, lib code in Rails. Ideally you want each bit of functionality in a class (and therefore file) of its own, so it can be tested in isolation. But without seeing what you've got, it's hard to guess where the problem lies. Ashley -- blog @ http://aviewfromafar.net/ linked-in @ http://www.linkedin.com/in/ashleymoran currently @ home From joshknowles at gmail.com Tue Nov 13 16:33:24 2007 From: joshknowles at gmail.com (Josh Knowles) Date: Tue, 13 Nov 2007 16:33:24 -0500 Subject: [rspec-users] rails story runner returning a nil response code In-Reply-To: <57c63afe0711131243r5017bcacma424c08841d0d37e@mail.gmail.com> References: <57c63afe0711131243r5017bcacma424c08841d0d37e@mail.gmail.com> Message-ID: On 11/13/07, David Chelimsky wrote: > RailsStory just wraps ActionController::IntegrationTest, so you're > getting what you would get from an IntegrationTest. You are correct. I was getting a stack-level-too-deep caused by a problem with how IntegrationTest was overwriting url_for which wasn't getting properly propagated up. Sorry for the noise. -- Josh Knowles phone: 509-979-1593 email: joshknowles at gmail.com web: http://joshknowles.com From dchelimsky at gmail.com Tue Nov 13 16:57:34 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 13 Nov 2007 15:57:34 -0600 Subject: [rspec-users] rails story runner returning a nil response code In-Reply-To: References: <57c63afe0711131243r5017bcacma424c08841d0d37e@mail.gmail.com> Message-ID: <57c63afe0711131357u37a8493el4966cbdcdbd10338@mail.gmail.com> On Nov 13, 2007 3:33 PM, Josh Knowles wrote: > On 11/13/07, David Chelimsky wrote: > > RailsStory just wraps ActionController::IntegrationTest, so you're > > getting what you would get from an IntegrationTest. > > You are correct. I was getting a stack-level-too-deep caused by a > problem with how IntegrationTest was overwriting url_for which wasn't > getting properly propagated up. > > Sorry for the noise. No worries - what do you think about treating controllers the same way in stories that we do in controller examples? > > -- > > Josh Knowles > phone: 509-979-1593 > email: joshknowles at gmail.com > web: http://joshknowles.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From joshknowles at gmail.com Tue Nov 13 17:02:12 2007 From: joshknowles at gmail.com (Josh Knowles) Date: Tue, 13 Nov 2007 17:02:12 -0500 Subject: [rspec-users] rails story runner returning a nil response code In-Reply-To: <57c63afe0711131357u37a8493el4966cbdcdbd10338@mail.gmail.com> References: <57c63afe0711131243r5017bcacma424c08841d0d37e@mail.gmail.com> <57c63afe0711131357u37a8493el4966cbdcdbd10338@mail.gmail.com> Message-ID: On 11/13/07, David Chelimsky wrote: > No worries - what do you think about treating controllers the same way > in stories that we do in controller examples? I think that makes sense. Currently you have to view the test.log file to see the exceptions, I'd like to see these re-raised. I can patch tonight if you're in agreement. From dchelimsky at gmail.com Tue Nov 13 17:17:59 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 13 Nov 2007 16:17:59 -0600 Subject: [rspec-users] rails story runner returning a nil response code In-Reply-To: References: <57c63afe0711131243r5017bcacma424c08841d0d37e@mail.gmail.com> <57c63afe0711131357u37a8493el4966cbdcdbd10338@mail.gmail.com> Message-ID: <57c63afe0711131417v10bc03a5h751f1c2fd2ecf2e1@mail.gmail.com> On Nov 13, 2007 4:02 PM, Josh Knowles wrote: > On 11/13/07, David Chelimsky wrote: > > No worries - what do you think about treating controllers the same way > > in stories that we do in controller examples? > > I think that makes sense. Currently you have to view the test.log > file to see the exceptions, I'd like to see these re-raised. > > I can patch tonight if you're in agreement. That would be awesome. Take a look at how it's done in the spec/dsl dir. There's a file that monkey patches AR::Base so the default behaviour is that you'll see the failures, but if you decide to override rescue_action on your own, you get that instead. Cool? Thanks man. Cheers, David > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From chris at edendevelopment.co.uk Tue Nov 13 17:30:25 2007 From: chris at edendevelopment.co.uk (Chris Parsons) Date: Tue, 13 Nov 2007 22:30:25 +0000 Subject: [rspec-users] rails story runner returning a nil response code In-Reply-To: <57c63afe0711131417v10bc03a5h751f1c2fd2ecf2e1@mail.gmail.com> References: <57c63afe0711131243r5017bcacma424c08841d0d37e@mail.gmail.com> <57c63afe0711131357u37a8493el4966cbdcdbd10338@mail.gmail.com> <57c63afe0711131417v10bc03a5h751f1c2fd2ecf2e1@mail.gmail.com> Message-ID: <0503AA9C-7079-456C-B11E-5D05BED2436B@edendevelopment.co.uk> On 13 Nov 2007, at 22:17, David Chelimsky wrote: > On Nov 13, 2007 4:02 PM, Josh Knowles wrote: >> On 11/13/07, David Chelimsky wrote: >>> No worries - what do you think about treating controllers the same >>> way >>> in stories that we do in controller examples? >> >> I think that makes sense. Currently you have to view the test.log >> file to see the exceptions, I'd like to see these re-raised. >> >> I can patch tonight if you're in agreement. > > That would be awesome. Take a look at how it's done in the spec/dsl > dir. There's a file that monkey patches AR::Base so the default > behaviour is that you'll see the failures, but if you decide to > override rescue_action on your own, you get that instead. +1 for this one - would be great to be able to see the exceptions when running the story. Thanks! Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071113/557e2cd2/attachment.html From pergesu at gmail.com Tue Nov 13 18:17:27 2007 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 13 Nov 2007 15:17:27 -0800 Subject: [rspec-users] Role of stories vs specs In-Reply-To: <57c63afe0711131151w733c7b70id8cd59a5d64cd196@mail.gmail.com> References: <810a540e0711131110t73149f26r50fd6dadbe20ae90@mail.gmail.com> <57c63afe0711131151w733c7b70id8cd59a5d64cd196@mail.gmail.com> Message-ID: <810a540e0711131517q733097a9y73a77ecf591737ec@mail.gmail.com> On Nov 13, 2007 11:51 AM, David Chelimsky wrote: > On Nov 13, 2007 1:10 PM, Pat Maddox wrote: > > I've been thinking about the role that stories played compared to > > specs, and that "should we use should" thread brought those thoughts > > up again. > > > > First I want to discuss whether or not specs are authoritative > > regarding the desired behavior of a system. I would say they're a > > good approximation of how the system currently runs according to the > > developer's understanding. I say they're an approximation because if > > you use mocks everywhere (as I believe you ought to) then you're not > > performing integrations and the specs are necessarily incomplete. > > > > Why does that idea matter? Traditionally, we've leaned heavily on a > > suite of unit tests to perform refactorings. In fact, Fowler says the > > first thing you have to do in order to refactor is grow a set of > > comprehensive unit tests. > > > > Refactoring, by definition, is changing the structure without changing > > the observable behavior. > > IMO, that definition refers to a system, not individual objects. When > you change objects, you usually have to change the examples. I agree completely. That opinion is what spurred this line of thought. > Keep in mind that that goes nearly unnoticed in java or .NET because > of the refactoring tools available on those platforms. Change a method > name once and it changes it everywhere, *including the examples*. Move > a method from one object to another and you get a dialog that let's > you opt to leave the existing method in place delegating to the new > location, or change all the consumers of that method in the system, > *including the examples*, to use the new location. Which is fantastic, but what strategies should Ruby dudes use in the mean time? > > If I say that stories are authoritative and specs aren't, then that > > means I ought to rely on stories to provide the safety net for my > > refactoring. When taking those baby steps, it's important to keep the > > stories green rather than the specs. > > On some level that makes sense - but it's going to slow you down quite > a bit when you start building up a significant suite of stories. That was my main concern. You can get 1200 examples running in under 5 seconds. Probably can't do that with stories. > The way I've always dealt with this was to rely on the examples to get > me through a refactoring, and then run the stories before committing. > That allows me to stay focused on small problems and progress > steadily. Herein lies the (my) problem. I find that when I refactor the examples break. You've already said that it's okay, because tools ought to change the examples appropriately. I don't personally have an issue with breaking specs as I refactor...but that's because I've learned to deal with it, and know what kind of breaking changes I'm comfortable with. My main point is that if I have to go in and manually change specs, then in general I don't consider the specs to be my comfortable safety net. They'll get there when we have better tool support, but I have to do stuff today. I suppose the *real* problem is that I can't quantify what impact that all has on my velocity. So I just end up focusing on the pain that it causes me. But, I think getting rid of the pain is a very worthwhile endeavor on its own. > > Another result of this thinking is that more specification should be > > done in stories than I originally thought. Edge cases are my prime > > example. I used to think I should write a story that expresses the > > general desired behavior, and then cover any edge cases in specs. > > I think they should be covered in both stories and examples. The thing > is that they get covered in different ways. > > For one, the language in which they are expressed is different - > because the stories are about the system and the examples are about > the objects in the system. And there will be some duplicated effort > between the stories and the examples - and that is a GOOD thing. Agreed. The more-than-occasional-less-than-frequent duplication between stories and examples doesn't bother me. In my mind they're completely separate systems, it's just that sometimes I happen to be working on such a simple level that they appear to be the same. > Additionally, when dealing with stories, you may specify that a > particular error message shows up on the screen. However, when you get > down to the individual objects, you would likely have a single example > showing that the screen will show whatever error message you throw at > it, and then move down to the model to generate this particular edge > case message. > > > Finally, it's better > > to keep all of the desired behavior specs in one place. > > Here's where we disagree. I think that it's a matter of who the > audience is for the different tools. Let's say in some banking software we have a transfer screen, and there are three possible errors: insufficient funds, source account frozen, target account frozen. Would you write a scenario for each of the possible errors, and an example for each? This probably isn't a good example because I think you should :) but it's easy to see how it would lead to more duplication than I'm comfortable with. Every time you need to specify business value you have to stick it in a story and an example. > The vocabulary that we seem to be moving to in the trunk is this: > > Story Framework > - Stories > - Scenarios > - Steps > > Example Framework > - ExampleGroups (what you referred to as descriptions) > - Examples > > I'm not completely comfortable with this yet in terms of being able to > talk about it, so suggestions are welcome. The problem with using Spec > or Example is that either can easily refer to the coarse grained > stories or the fine grained object level examples. Maybe we should > call them Coarse Grained Examples and Fine Grained Examples :) > Seriously - I welcome other thoughts on this. There's another part missing, which is the set of all stories, and the set of all example groups. > > What do you guys think? Is it useful to draw a line and say that > > stories are authoritative and specs aren't? > > I don't find this useful. To me they are two completely separate > animals that work together to describe the behaviour of a system. They > are equally authoritative (or not). They both have a life cycle in > which they move from examples of what we'd like to examples of what we > have. I agree that they're completely separate beasts. I have a feeling we'll disagree on the point of what is authoritative. I think that stories clearly define how much of the system is done, and examples don't do that at all. However, I'm not sure yet if it's an important distinction to make, and hopefully over the next few months I'll gain deeper insight. > Thanks for the thought provoking post! Thanks so much for your reply. Cheers, Pat From dan at catolabs.org Tue Nov 13 18:37:38 2007 From: dan at catolabs.org (Dan Aronson) Date: Tue, 13 Nov 2007 15:37:38 -0800 Subject: [rspec-users] new to rspec, error running "rake rspec" on debian/etch Message-ID: <473A3542.3070608@catolabs.org> I have the latest version of rspec and rails-rspec installed. I'm using the debian versions of ruby and rails. On a new project after a generate an "rspec_model" and then try to run "rake spec", I get the following error: dan at dan-server:~/projects/cw/registration$ rake spec (in /home/dan/projects/cw/registration) /home/dan/projects/cw/registration/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_controller/rescue.rb:19: undefined method `alias_method_chai\n' for \ ActionController::Rescue:Module (NoMethodError) from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require' from /home/dan/projects/cw/registration/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:147:in `require\ ' from /home/dan/projects/cw/registration/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions.rb:6 from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require' from /home/dan/projects/cw/registration/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:147:in `require\ ' from /home/dan/projects/cw/registration/config/../vendor/plugins/rspec_on_rails/lib/spec/rails.rb:17 ... 22 levels... from /home/dan/projects/cw/registration/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:155:in `parse' from /home/dan/projects/cw/registration/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:88:in `create_behaviour_runner' from /home/dan/projects/cw/registration/vendor/plugins/rspec/lib/spec/runner/command_line.rb:14:in `run' from /home/dan/projects/cw/registration/vendor/plugins/rspec/bin/spec:3rake aborted! Command ruby -I"/home/dan/projects/cw/registration/vendor/plugins/rspec/lib" "/home/dan/projects/cw/registration/vendor/plugins/rspec/bin/spec" "spec/\ models/user_spec.rb" --options "/home/dan/projects/cw/registration/config/../spec/spec.opts" failed (See full trace by running task with --trace) Any suggestions on how to get around this? --dan From barjunk at attglobal.net Tue Nov 13 18:52:19 2007 From: barjunk at attglobal.net (barsalou) Date: Tue, 13 Nov 2007 14:52:19 -0900 Subject: [rspec-users] testing scripts Message-ID: <20071113145219.xje1kybz4gkkk008@lcgalaska.com> Ashley said: Message: 7 Date: Tue, 13 Nov 2007 20:43:53 +0000 From: Ashley Moran Subject: Re: [rspec-users] testing scripts To: rspec-users Message-ID: <84ECF846-4D27-428D-BCEA-785E60E02AA7 at ashleymoran.me.uk> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes On Nov 13, 2007, at 7:45 pm, barsalou wrote: > What I'm doing now is wrapping the methods in a module, then including > the module at the top of the script. Can you post some examples of the modules, classes and methods you have? Every script I've written is basically just a little object-oriented app that's got a bit at the end to fire off some "main" class with the command line args. Testing one is no different than testing, say, lib code in Rails. Ideally you want each bit of functionality in a class (and therefore file) of its own, so it can be tested in isolation. But without seeing what you've got, it's hard to guess where the problem lies. Ashley ------ Ashley, I think what I've come to realize is that I need to refactor what I've done. A quick example would be: def exists?(device) # do device validation end device = Device.find(1) if exists?(device) then # do my thing end I realize that exists? should really be part of Device and doing testing on this script is helping me look at the objects differently and I'm starting to refactor. So I think my initial problem with testing my script is that it's not really OO in the first place. You've confirmed for me what I had been thinking and I'll work to that end. Thanks for the feedback. Mike B. ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. From dchelimsky at gmail.com Tue Nov 13 19:00:08 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 13 Nov 2007 18:00:08 -0600 Subject: [rspec-users] Role of stories vs specs In-Reply-To: <810a540e0711131517q733097a9y73a77ecf591737ec@mail.gmail.com> References: <810a540e0711131110t73149f26r50fd6dadbe20ae90@mail.gmail.com> <57c63afe0711131151w733c7b70id8cd59a5d64cd196@mail.gmail.com> <810a540e0711131517q733097a9y73a77ecf591737ec@mail.gmail.com> Message-ID: <57c63afe0711131600n5807f7f2ja782610ac78e5c13@mail.gmail.com> On Nov 13, 2007 5:17 PM, Pat Maddox wrote: > On Nov 13, 2007 11:51 AM, David Chelimsky wrote: > > Keep in mind that that goes nearly unnoticed in java or .NET because > > of the refactoring tools available on those platforms. Change a method > > name once and it changes it everywhere, *including the examples*. Move > > a method from one object to another and you get a dialog that let's > > you opt to leave the existing method in place delegating to the new > > location, or change all the consumers of that method in the system, > > *including the examples*, to use the new location. > > Which is fantastic, but what strategies should Ruby dudes use in the mean time? I won't speak for all, or say what one should use. But what I do is I change things one step at a time with autotest running in the background. When autotest tells me something failed, I look at it. When it tells me nothing failed and I expected something to, I look at that. Whether or not you have tool support, refactoring is its own world of study - taking steps that move you in the right direction and keep the bar green as much as possible. > > > If I say that stories are authoritative and specs aren't, then that > > > means I ought to rely on stories to provide the safety net for my > > > refactoring. When taking those baby steps, it's important to keep the > > > stories green rather than the specs. > > > > On some level that makes sense - but it's going to slow you down quite > > a bit when you start building up a significant suite of stories. > > That was my main concern. You can get 1200 examples running in under > 5 seconds. Probably can't do that with stories. Exactly > > The way I've always dealt with this was to rely on the examples to get > > me through a refactoring, and then run the stories before committing. > > That allows me to stay focused on small problems and progress > > steadily. > > Herein lies the (my) problem. I find that when I refactor the > examples break. You've already said that it's okay, because tools > ought to change the examples appropriately. I don't personally have > an issue with breaking specs as I refactor...but that's because I've > learned to deal with it, and know what kind of breaking changes I'm > comfortable with. My main point is that if I have to go in and > manually change specs, then in general I don't consider the specs to > be my comfortable safety net. They'll get there when we have better > tool support, but I have to do stuff today. Actually, if I change something and it causes an example to fail, that suggests to me that the examples ARE a good safety net! Just as in the TDD cycle, the failures actually give you confidence that you're touching the code you think you're touching. > I suppose the *real* problem is that I can't quantify what impact that > all has on my velocity. So I just end up focusing on the pain that it > causes me. But, I think getting rid of the pain is a very worthwhile > endeavor on its own. You may just have to will it away. I find that this does not slow me down. I'm slower on a step by step basis than I am with powerful tools, but since I can solve the same problems with so much less code in Ruby, it sort of balances itself out. > Let's say in some banking software we have a transfer screen, and > there are three possible errors: insufficient funds, source account > frozen, target account frozen. Would you write a scenario for each of > the possible errors, and an example for each? Without even batting an eye! The scenario is going to reflect how things look from the outside. The example is going to be targeted right at the part of the system that is responsible for producing the correct error message. > This probably isn't a > good example because I think you should :) but it's easy to see how > it would lead to more duplication than I'm comfortable with. Every > time you need to specify business value you have to stick it in a > story and an example. This used to bother me too, but that was a long time ago. The thing is that you want the examples to be comprehensive so you can refactor. You also want the stories to be comprehensive, so you know what the system does. And so you can refactor ;) > > The vocabulary that we seem to be moving to in the trunk is this: > > > > Story Framework > > - Stories > > - Scenarios > > - Steps > > > > Example Framework > > - ExampleGroups (what you referred to as descriptions) > > - Examples > > > > I'm not completely comfortable with this yet in terms of being able to > > talk about it, so suggestions are welcome. The problem with using Spec > > or Example is that either can easily refer to the coarse grained > > stories or the fine grained object level examples. Maybe we should > > call them Coarse Grained Examples and Fine Grained Examples :) > > Seriously - I welcome other thoughts on this. > > There's another part missing, which is the set of all stories, and the > set of all example groups. Anybody got any ideas? Cheers, David From dchelimsky at gmail.com Tue Nov 13 19:02:16 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 13 Nov 2007 18:02:16 -0600 Subject: [rspec-users] new to rspec, error running "rake rspec" on debian/etch In-Reply-To: <473A3542.3070608@catolabs.org> References: <473A3542.3070608@catolabs.org> Message-ID: <57c63afe0711131602v7b894e9dgca4637f7f611603@mail.gmail.com> On Nov 13, 2007 5:37 PM, Dan Aronson wrote: > I have the latest version of rspec and rails-rspec installed. What specifically did you install? Also what version of rails? Include revision numbers if you can. > I'm using > the debian versions of ruby and rails. On a new project after a > generate an "rspec_model" and then try to run "rake spec", I get the > following error: > > dan at dan-server:~/projects/cw/registration$ rake spec > > (in /home/dan/projects/cw/registration) > > /home/dan/projects/cw/registration/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_controller/rescue.rb:19: undefined method `alias_method_chai\n' for \ > > ActionController::Rescue:Module (NoMethodError) > > from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' > > from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require' > > from /home/dan/projects/cw/registration/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:147:in `require\ > > ' > > from /home/dan/projects/cw/registration/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions.rb:6 > > from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' > > from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require' > > from /home/dan/projects/cw/registration/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:147:in `require\ > > ' > > from /home/dan/projects/cw/registration/config/../vendor/plugins/rspec_on_rails/lib/spec/rails.rb:17 > > ... 22 levels... > > from /home/dan/projects/cw/registration/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:155:in `parse' from /home/dan/projects/cw/registration/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:88:in `create_behaviour_runner' > > from /home/dan/projects/cw/registration/vendor/plugins/rspec/lib/spec/runner/command_line.rb:14:in `run' > > from /home/dan/projects/cw/registration/vendor/plugins/rspec/bin/spec:3rake aborted! > > Command ruby -I"/home/dan/projects/cw/registration/vendor/plugins/rspec/lib" "/home/dan/projects/cw/registration/vendor/plugins/rspec/bin/spec" "spec/\ > > models/user_spec.rb" --options "/home/dan/projects/cw/registration/config/../spec/spec.opts" failed > > (See full trace by running task with --trace) > > > > Any suggestions on how to get around this? > > --dan > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From zach.dennis at gmail.com Wed Nov 14 00:14:13 2007 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 14 Nov 2007 00:14:13 -0500 Subject: [rspec-users] rspec_on_rails, receive_and_render experiment Message-ID: <85d99afe0711132114u7989927x521db7d04b0f8a57@mail.gmail.com> A recent exploration on receive_and_render to assist with some common view spec'ing can be found at http://www.continuousthinking.com/2007/11/14/rspec_on_rails-render_and_receive_matcher Suggestions and feedback are welcome. Thanks, -- Zach Dennis http://www.continuousthinking.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071114/8c36c64f/attachment.html From lists at ruby-forum.com Wed Nov 14 04:03:18 2007 From: lists at ruby-forum.com (Karni Karni) Date: Wed, 14 Nov 2007 10:03:18 +0100 Subject: [rspec-users] Test case for file import In-Reply-To: <8d961d900711130837t7dbe37cao7675d6c20e6417c7@mail.gmail.com> References: <1b165db00711060451s6d7fdc44he2fffb12c1f74bd7@mail.gmail.com> <57c63afe0711060502m6c92ccdaye78ce6846175fe3f@mail.gmail.com> <1b165db00711060554m6afc3418q34703319b5e5e8c4@mail.gmail.com> <13703316.post@talk.nabble.com> <8d961d900711121524v72ba62datf2deec52852beff4@mail.gmail.com> <8d961d900711130837t7dbe37cao7675d6c20e6417c7@mail.gmail.com> Message-ID: aslak hellesoy wrote: Could u pls give any URL form u written this code? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Nov 14 04:51:32 2007 From: lists at ruby-forum.com (Karni Karni) Date: Wed, 14 Nov 2007 10:51:32 +0100 Subject: [rspec-users] Test case for file import In-Reply-To: References: <1b165db00711060451s6d7fdc44he2fffb12c1f74bd7@mail.gmail.com> <57c63afe0711060502m6c92ccdaye78ce6846175fe3f@mail.gmail.com> <1b165db00711060554m6afc3418q34703319b5e5e8c4@mail.gmail.com> <13703316.post@talk.nabble.com> <8d961d900711121524v72ba62datf2deec52852beff4@mail.gmail.com> <8d961d900711130837t7dbe37cao7675d6c20e6417c7@mail.gmail.com> Message-ID: Karni Karni wrote: > aslak hellesoy wrote: > > Could u pls give any URL form u written this code? Thanks for ur reply. But in my case the total code is in the controller. I' submitting the from to a specific action with CSV file. Hoew can I pass my CSV file to that specific action -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Wed Nov 14 05:20:31 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 14 Nov 2007 11:20:31 +0100 Subject: [rspec-users] Test case for file import In-Reply-To: References: <1b165db00711060451s6d7fdc44he2fffb12c1f74bd7@mail.gmail.com> <57c63afe0711060502m6c92ccdaye78ce6846175fe3f@mail.gmail.com> <1b165db00711060554m6afc3418q34703319b5e5e8c4@mail.gmail.com> <13703316.post@talk.nabble.com> <8d961d900711121524v72ba62datf2deec52852beff4@mail.gmail.com> <8d961d900711130837t7dbe37cao7675d6c20e6417c7@mail.gmail.com> Message-ID: <8d961d900711140220k78ae8ed0gb203c7bfc340c568@mail.gmail.com> On 11/14/07, Karni Karni wrote: > Karni Karni wrote: > > aslak hellesoy wrote: > > > > Could u pls give any URL form u written this code? > > Thanks for ur reply. But in my case the total code is in the controller. It shouldn't be. Put business logic in the model. http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model > I' submitting the from to a specific action with CSV file. Right. Then ask the model to pupulate rows with that CSV. > > Hoew can I pass my CSV file to that specific action post :my_action, :csv => <<-EOF this,is,some very,nice,csv EOF Also, take a look at this: http://www.catb.org/~esr/faqs/smart-questions.html (You're asking for the whole solution - you're likely to be ignored if you don't ask more specific ones. For example show us some spec code) Aslak > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jarkko at jlaine.net Wed Nov 14 06:35:20 2007 From: jarkko at jlaine.net (Jarkko Laine) Date: Wed, 14 Nov 2007 13:35:20 +0200 Subject: [rspec-users] Spec slowdown In-Reply-To: <57c63afe0711130921l3c871e31w907d7796517186ad@mail.gmail.com> References: <53AEF18C-BC83-4FBE-86E6-62CA848AC3D7@jlaine.net> <57c63afe0711130921l3c871e31w907d7796517186ad@mail.gmail.com> Message-ID: <6D6AF4A3-7FD5-4E4B-9273-496412A04EF9@jlaine.net> On 13.11.2007, at 19.21, David Chelimsky wrote: > On Nov 13, 2007 10:52 AM, Jarkko Laine wrote: >> Is there something currently going on on the rspec trunk that causes >> a massive slowdown when running rake spec and autotest (without >> spec_server)? I updated to the latest trunk yesterday and the time >> needed to run the specs of my app jumped from ~20 seconds to more >> than a minute. The weird thing is that if I run the rake spec tasks >> separately (controllers, models, views, helpers), they still take >> about 20 seconds in total: http://pastie.caboo.se/117362 > > That's really weird. We are doing some refactoring and it is > admittedly still mid-stream, but I'm stumped as to why it would only > have a negative impact when you run all the examples. > > Also - I'm using the latest and do not see this drop in speed. Interesting. This happens both on my laptop and the CI server, though, so it can't just be my box. > > So, for the moment, please keep an eye on it and let us know if > changes over the next few days resolve this or not. If not, we'll take > a closer look before the release. Thanks, I'll keep you posted. > > Thanks, > David > > ps - in case you didn't notice: config.breakpoint_server has been > deprecated and has no effect. :-) //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi From mailing_lists at railsnewbie.com Wed Nov 14 10:00:18 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 14 Nov 2007 10:00:18 -0500 Subject: [rspec-users] new to rspec, error running "rake rspec" on debian/etch In-Reply-To: <57c63afe0711131602v7b894e9dgca4637f7f611603@mail.gmail.com> References: <473A3542.3070608@catolabs.org> <57c63afe0711131602v7b894e9dgca4637f7f611603@mail.gmail.com> Message-ID: <5FC35D44-7D69-43B5-A2B6-186E9C1ECAF0@railsnewbie.com> On Nov 13, 2007, at 7:02 PM, David Chelimsky wrote: > On Nov 13, 2007 5:37 PM, Dan Aronson wrote: >> I have the latest version of rspec and rails-rspec installed. > > What specifically did you install? Also what version of rails? Include > revision numbers if you can. Also - did you install ruby & rubygems from source, or did you use a package manager like dpkg/apt-get ? Debian is notorious for splitting up the ruby packages unnecessarily. Scott > >> I'm using >> the debian versions of ruby and rails. On a new project after a >> generate an "rspec_model" and then try to run "rake spec", I get the >> following error: >> >> dan at dan-server:~/projects/cw/registration$ rake spec >> >> (in /home/dan/projects/cw/registration) >> >> /home/dan/projects/cw/registration/vendor/plugins/rspec_on_rails/ >> lib/spec/rails/extensions/action_controller/rescue.rb:19: >> undefined method `alias_method_chai\n' for \ >> >> ActionController::Rescue:Module (NoMethodError) >> >> from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in >> `gem_original_require' >> >> from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in >> `require' >> >> from /home/dan/projects/cw/registration/config/../vendor/ >> rails/activerecord/lib/../../activesupport/lib/active_support/ >> dependencies.rb:147:in `require\ >> >> ' >> >> from /home/dan/projects/cw/registration/vendor/plugins/ >> rspec_on_rails/lib/spec/rails/extensions.rb:6 >> >> from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in >> `gem_original_require' >> >> from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in >> `require' >> >> from /home/dan/projects/cw/registration/config/../vendor/ >> rails/activerecord/lib/../../activesupport/lib/active_support/ >> dependencies.rb:147:in `require\ >> >> ' >> >> from /home/dan/projects/cw/registration/config/../vendor/ >> plugins/rspec_on_rails/lib/spec/rails.rb:17 >> >> ... 22 levels... >> >> from /home/dan/projects/cw/registration/vendor/plugins/ >> rspec/lib/spec/runner/option_parser.rb:155:in `parse' from / >> home/dan/projects/cw/registration/vendor/plugins/rspec/lib/spec/ >> runner/option_parser.rb:88:in `create_behaviour_runner' >> >> from /home/dan/projects/cw/registration/vendor/plugins/ >> rspec/lib/spec/runner/command_line.rb:14:in `run' >> >> from /home/dan/projects/cw/registration/vendor/plugins/ >> rspec/bin/spec:3rake aborted! >> >> Command ruby -I"/home/dan/projects/cw/registration/vendor/plugins/ >> rspec/lib" "/home/dan/projects/cw/registration/vendor/plugins/ >> rspec/bin/spec" "spec/\ >> >> models/user_spec.rb" --options "/home/dan/projects/cw/registration/ >> config/../spec/spec.opts" failed >> >> (See full trace by running task with --trace) >> >> >> >> Any suggestions on how to get around this? >> >> --dan >> >> >> >> _______________________________________________ >> 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 mlins at webinforem.com Wed Nov 14 11:35:31 2007 From: mlins at webinforem.com (Matthew Lins) Date: Wed, 14 Nov 2007 10:35:31 -0600 Subject: [rspec-users] Stubbing out required associated models Message-ID: Hello, As I'm becoming more and more familiar with mocking/stubbing, I'm going back to some of my model specs and revaluating how I wrote them. I have certain models in which validation requires the presence of an associated model, which itself needs to be valid(validates_presence_of and validates_associated). When I wrote the specs, I wrote helpers for the attributes instead of fixtures, like so: module UserSpecHelper def valid_user_attributes { :email => "test at here.com", :password => "tttttt", :password_confirmation => "tttttt" } end end If the model had a required associated model, I'd also add some valid attribute helpers to make the associated model pass as well: module UserSpecHelper def valid_user_attributes { :email => "test at here.com", :password => "tttttt", :password_confirmation => "tttttt" } end def valid_shipping_address_attributes { :street => "blah street", :city => "blah", :state => "CA", :zip => "54455" } end end Now, I've been thinking, I should probably just stub out the associated models in order to focus my specs on one model, the model being tested. Would that be better practice? Thanks, Matt Lins From glenn at aldenta.com Wed Nov 14 11:37:14 2007 From: glenn at aldenta.com (Glenn Ford) Date: Wed, 14 Nov 2007 11:37:14 -0500 Subject: [rspec-users] Interdependency between RSpec files Message-ID: <3DD9024D-7EEF-41DF-8E26-A3EF2B5D362B@aldenta.com> I run my suite of tests, one test fails. I run that one test file, no tests fail. Something is carrying over between files and I can't figure out what. I tracked down the problem to the very line it's occurring on, with printouts before and after every call to make sure I know exactly what is being reached. In this spec I have 0 fixtures/mocks/stubs. The objects in this file do not live anywhere outside of the file. This is a model spec and I'm using all real objects to test it. In the "before" block I set up some models, and in my spec itself I, in each test, make a couple changes then call a model's save method. That model has an "after_create" method which calls a method in a child model that it has. It is THIS method which is not being called. I have printouts before and after everything, like I said, and the lines before and after the method call work, which leads me to believe that method IS getting called. However I have a "puts 'foo'" at the top of that method and it doesn't get printed. The object is not nil, and it has even been successfully saved previously in the code, and all of its necessary attributes have been set. Why on earth is it not getting called? Keep in mind, it DOES get called if I run "spec" on that specific file. If I run it among my other spec files (I've got lots) it DOES NOT get called. I need some ideas on how to chase this one down? I stuck printouts everywhere to track the issue down as narrowly as I have but I'm down to a single line and it's doing something I didn't even know was physically possible in this language. It seems I must be overlooking something but I just can't seem to see outside of the box on this issue. Any ideas would be great, thanks! Glenn From vertebrate at gmail.com Wed Nov 14 12:23:23 2007 From: vertebrate at gmail.com (Steve) Date: Wed, 14 Nov 2007 17:23:23 +0000 (UTC) Subject: [rspec-users] Should receive field_for failing Message-ID: I have a spec that's not behaving as I'm thinking it should. Here's the code: http://pastie.caboo.se/117931 it's failing with: ActionView::TemplateError in 'customers/new should receive fields_for' Mock 'ActionView::Base' expected :form_for with ("address", #
) but received it with (:customer, #, {:url=>"/customers"}) Since the specs don't seem to follow subsequent render calls, is there a way to verify that addresses/_form.html.haml is being called properly? I recall a similar discussion some weeks back, and the desire was to spec for the end output of the view, and not the individual parts. My problem comes from the fact that fields_for will happily create fields even if the passed in object doesn't have attrs for them. I had 'fields_for :address', and it output the whole form, and even though @address was nil my specs passed, because I just checked for the presence of the various form fields. However, since the form was rendered as a partial, the fields weren't populating with values on the postback, because what I needed to have was 'fields_for "address", address'. Is there a way to check for this through the primary view, or should I just spec the partial individually? Thanks, Steve From mailing_lists at railsnewbie.com Wed Nov 14 12:28:07 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 14 Nov 2007 12:28:07 -0500 Subject: [rspec-users] Interdependency between RSpec files In-Reply-To: <3DD9024D-7EEF-41DF-8E26-A3EF2B5D362B@aldenta.com> References: <3DD9024D-7EEF-41DF-8E26-A3EF2B5D362B@aldenta.com> Message-ID: <72ACA421-112B-4E9F-9E6D-052A501AA5E5@railsnewbie.com> On Nov 14, 2007, at 11:37 AM, Glenn Ford wrote: > I run my suite of tests, one test fails. > I run that one test file, no tests fail. > > Something is carrying over between files and I can't figure out what. > I tracked down the problem to the very line it's occurring on, with > printouts before and after every call to make sure I know exactly what > is being reached. First of all - make sure you don't have any after(:create) or before (:create) specs. If an AR object is created in one of these, it *IS NOT* going to be rolled back. You might also try the following: rake db:migrate; rake db:test:prepare Log into mysql (or whatever database) - inspect it to see that no records are present in your test database (if you really aren't using fixtures at all). > > In this spec I have 0 fixtures/mocks/stubs. The objects in this file > do not live anywhere outside of the file. This is a model spec and > I'm using all real objects to test it. In the "before" block I set up > some models, and in my spec itself I, in each test, make a couple > changes then call a model's save method. That model has an > "after_create" method which calls a method in a child model that it > has. It is THIS method which is not being called. I have printouts > before and after everything, like I said, and the lines before and > after the method call work, which leads me to believe that method IS > getting called. However I have a "puts 'foo'" at the top of that > method and it doesn't get printed. You might want to try running that one spec with the following snippet stuck into the top of your after_create method: require 'rubygems'; require 'ruby-debug'; debugger; When the spec runs, you will be dropped down into the ruby debugger, so you can inspect what is *actually* going on. (You will need to know how to use a debugger, and have the ruby-debug gem installed). If that doesn't yield any helpful information, then remove that snippet and put it at the top of the failing test (the first line of the example ("it") block). Then run the full test suite, and again, you will be dropped down into the debugger. Hope that helps, Scott From lists at ruby-forum.com Wed Nov 14 13:28:43 2007 From: lists at ruby-forum.com (Anton Kuzmin) Date: Wed, 14 Nov 2007 19:28:43 +0100 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <57c63afe0711081840i65506f11i4de93f516a1a6c40@mail.gmail.com> References: <6b6419750711081706y212824fcm9bf7003e5f8eb99c@mail.gmail.com> <57c63afe0711081728q1028cc05m5484d28f40fec2be@mail.gmail.com> <6b6419750711081738g4e3fe039o81c232d20ebbedbe@mail.gmail.com> <4733BBD4.7060200@benmabey.com> <6b6419750711081758m3bbf7438maadef258d78b2619@mail.gmail.com> <57c63afe0711081805u1e8deb6dmeb60b6954f7eb919@mail.gmail.com> <6b6419750711081807q2f5b4237p5b7db8caf4d3cd9e@mail.gmail.com> <57c63afe0711081814k288f4048j9c95d68832207677@mail.gmail.com> <6b6419750711081818h1f644147he6df85b110dfdb10@mail.gmail.com> <57c63afe0711081820s7cdefd53y1e9a5f3741ffb6f4@mail.gmail.com> <6b6419750711081821r1d0a2b09l97895b6490bc8daf@mail.gmail.com> <57c63afe0711081836g45af9160x59a06d1f243a3da5@mail.gmail.com> <57c63afe0711081840i65506f11i4de93f516a1a6c40@mail.gmail.com> Message-ID: David Chelimsky wrote: > On Nov 8, 2007 8:36 PM, David Chelimsky wrote: >> On Nov 8, 2007 8:21 PM, Patrick Aljord wrote: >> > Nothing its a fresh project with latest rails edge that i started to >> > learn rspec. >> >> Rails edge or 2.0 preview? >> > > I just did this: > > rails foo > cd foo > rake rails:freeze:edge > ruby script/plugin install svn://rubyforge.org/var/svn/rspec/trunk/rspec > ruby script/plugin install > svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails > script/generate rspec > rake db:create:all > script/generate rspec_scaffold Thing name:string > rake db:migrate > rake spec > > All ran perfectly well. I really don't know what's going on on your > machine. Installing plugin from the url you provided fixed the issue. I had "undefined method `failure_message'" problem with plugin installed today from this url: svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec_on_rails -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed Nov 14 13:32:45 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 14 Nov 2007 12:32:45 -0600 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: References: <57c63afe0711081805u1e8deb6dmeb60b6954f7eb919@mail.gmail.com> <6b6419750711081807q2f5b4237p5b7db8caf4d3cd9e@mail.gmail.com> <57c63afe0711081814k288f4048j9c95d68832207677@mail.gmail.com> <6b6419750711081818h1f644147he6df85b110dfdb10@mail.gmail.com> <57c63afe0711081820s7cdefd53y1e9a5f3741ffb6f4@mail.gmail.com> <6b6419750711081821r1d0a2b09l97895b6490bc8daf@mail.gmail.com> <57c63afe0711081836g45af9160x59a06d1f243a3da5@mail.gmail.com> <57c63afe0711081840i65506f11i4de93f516a1a6c40@mail.gmail.com> Message-ID: <57c63afe0711141032n825af53hdf12f6a37afd5c4b@mail.gmail.com> On Nov 14, 2007 12:28 PM, Anton Kuzmin wrote: > > David Chelimsky wrote: > > On Nov 8, 2007 8:36 PM, David Chelimsky wrote: > >> On Nov 8, 2007 8:21 PM, Patrick Aljord wrote: > >> > Nothing its a fresh project with latest rails edge that i started to > >> > learn rspec. > >> > >> Rails edge or 2.0 preview? > >> > > > > I just did this: > > > > rails foo > > cd foo > > rake rails:freeze:edge > > ruby script/plugin install svn://rubyforge.org/var/svn/rspec/trunk/rspec > > ruby script/plugin install > > svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails > > script/generate rspec > > rake db:create:all > > script/generate rspec_scaffold Thing name:string > > rake db:migrate > > rake spec > > > > All ran perfectly well. I really don't know what's going on on your > > machine. > > Installing plugin from the url you provided fixed the issue. I had > "undefined method `failure_message'" problem with plugin installed today > from this url: > svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec_on_rails http://rspec.rubyforge.org/documentation/rails/install.html CURRENT means the latest release, not the trunk. 1.0.8 was out months ago - obviously not compatible with subsequent changes to rails. Cheers, David From glenn at aldenta.com Wed Nov 14 14:07:11 2007 From: glenn at aldenta.com (Glenn Ford) Date: Wed, 14 Nov 2007 14:07:11 -0500 Subject: [rspec-users] Interdependency between RSpec files In-Reply-To: <72ACA421-112B-4E9F-9E6D-052A501AA5E5@railsnewbie.com> References: <3DD9024D-7EEF-41DF-8E26-A3EF2B5D362B@aldenta.com> <72ACA421-112B-4E9F-9E6D-052A501AA5E5@railsnewbie.com> Message-ID: <8F3ED097-0F58-49A3-989C-B9B628A98E7F@aldenta.com> Your suggestion put me on the right track. I looked back to where I had I ran into a case where I was trying to stub an instance I couldn't get ahold of in the scope of my spec and since I was having trouble with some mocha bugs, I resorted to a Model.class_eval do alias_method :original_method, :old_method end Unfortunately I didn't set the alias back at the end of the spec. That was my problem. Thanks a ton! Glenn On Nov 14, 2007, at 12:28 PM, Scott Taylor wrote: > > On Nov 14, 2007, at 11:37 AM, Glenn Ford wrote: > >> I run my suite of tests, one test fails. >> I run that one test file, no tests fail. >> >> Something is carrying over between files and I can't figure out what. >> I tracked down the problem to the very line it's occurring on, with >> printouts before and after every call to make sure I know exactly >> what >> is being reached. > > > First of all - make sure you don't have any after(:create) or before > (:create) specs. If an AR object is created in one of these, it *IS > NOT* going to be rolled back. > > You might also try the following: > > rake db:migrate; rake db:test:prepare > > Log into mysql (or whatever database) - inspect it to see that no > records are present in your test database (if you really aren't using > fixtures at all). > > >> >> In this spec I have 0 fixtures/mocks/stubs. The objects in this file >> do not live anywhere outside of the file. This is a model spec and >> I'm using all real objects to test it. In the "before" block I set >> up >> some models, and in my spec itself I, in each test, make a couple >> changes then call a model's save method. That model has an >> "after_create" method which calls a method in a child model that it >> has. It is THIS method which is not being called. I have printouts >> before and after everything, like I said, and the lines before and >> after the method call work, which leads me to believe that method IS >> getting called. However I have a "puts 'foo'" at the top of that >> method and it doesn't get printed. > > You might want to try running that one spec with the following > snippet stuck into the top of your after_create method: > > require 'rubygems'; require 'ruby-debug'; debugger; > > When the spec runs, you will be dropped down into the ruby debugger, > so you can inspect what is *actually* going on. (You will need to > know how to use a debugger, and have the ruby-debug gem installed). > > If that doesn't yield any helpful information, then remove that > snippet and put it at the top of the failing test (the first line of > the example ("it") block). Then run the full test suite, and again, > you will be dropped down into the debugger. > > Hope that helps, > > Scott > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Wed Nov 14 14:14:03 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 14 Nov 2007 13:14:03 -0600 Subject: [rspec-users] Interdependency between RSpec files In-Reply-To: <8F3ED097-0F58-49A3-989C-B9B628A98E7F@aldenta.com> References: <3DD9024D-7EEF-41DF-8E26-A3EF2B5D362B@aldenta.com> <72ACA421-112B-4E9F-9E6D-052A501AA5E5@railsnewbie.com> <8F3ED097-0F58-49A3-989C-B9B628A98E7F@aldenta.com> Message-ID: <57c63afe0711141114i9916514y7405b55e0030300c@mail.gmail.com> On Nov 14, 2007 1:07 PM, Glenn Ford wrote: > Your suggestion put me on the right track. I looked back to where I > had I ran into a case where I was trying to stub an instance I > couldn't get ahold of in the scope of my spec and since I was having > trouble with some mocha bugs, I resorted to a > Model.class_eval do > alias_method :original_method, :old_method > end Try doing that on the instance instead. model = Model.new (class << model).class_eval do alias_method :original_method, :old_method end That way it can't leak to other instances of the same model. > > Unfortunately I didn't set the alias back at the end of the spec. > That was my problem. Thanks a ton! > > Glenn > > > On Nov 14, 2007, at 12:28 PM, Scott Taylor wrote: > > > > > On Nov 14, 2007, at 11:37 AM, Glenn Ford wrote: > > > >> I run my suite of tests, one test fails. > >> I run that one test file, no tests fail. > >> > >> Something is carrying over between files and I can't figure out what. > >> I tracked down the problem to the very line it's occurring on, with > >> printouts before and after every call to make sure I know exactly > >> what > >> is being reached. > > > > > > First of all - make sure you don't have any after(:create) or before > > (:create) specs. If an AR object is created in one of these, it *IS > > NOT* going to be rolled back. > > > > You might also try the following: > > > > rake db:migrate; rake db:test:prepare > > > > Log into mysql (or whatever database) - inspect it to see that no > > records are present in your test database (if you really aren't using > > fixtures at all). > > > > > >> > >> In this spec I have 0 fixtures/mocks/stubs. The objects in this file > >> do not live anywhere outside of the file. This is a model spec and > >> I'm using all real objects to test it. In the "before" block I set > >> up > >> some models, and in my spec itself I, in each test, make a couple > >> changes then call a model's save method. That model has an > >> "after_create" method which calls a method in a child model that it > >> has. It is THIS method which is not being called. I have printouts > >> before and after everything, like I said, and the lines before and > >> after the method call work, which leads me to believe that method IS > >> getting called. However I have a "puts 'foo'" at the top of that > >> method and it doesn't get printed. > > > > You might want to try running that one spec with the following > > snippet stuck into the top of your after_create method: > > > > require 'rubygems'; require 'ruby-debug'; debugger; > > > > When the spec runs, you will be dropped down into the ruby debugger, > > so you can inspect what is *actually* going on. (You will need to > > know how to use a debugger, and have the ruby-debug gem installed). > > > > If that doesn't yield any helpful information, then remove that > > snippet and put it at the top of the failing test (the first line of > > the example ("it") block). Then run the full test suite, and again, > > you will be dropped down into the debugger. > > > > Hope that helps, > > > > Scott > > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From philodespotos at gmail.com Wed Nov 14 14:37:19 2007 From: philodespotos at gmail.com (Kyle Hargraves) Date: Wed, 14 Nov 2007 13:37:19 -0600 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <57c63afe0711141032n825af53hdf12f6a37afd5c4b@mail.gmail.com> References: <6b6419750711081807q2f5b4237p5b7db8caf4d3cd9e@mail.gmail.com> <57c63afe0711081814k288f4048j9c95d68832207677@mail.gmail.com> <6b6419750711081818h1f644147he6df85b110dfdb10@mail.gmail.com> <57c63afe0711081820s7cdefd53y1e9a5f3741ffb6f4@mail.gmail.com> <6b6419750711081821r1d0a2b09l97895b6490bc8daf@mail.gmail.com> <57c63afe0711081836g45af9160x59a06d1f243a3da5@mail.gmail.com> <57c63afe0711081840i65506f11i4de93f516a1a6c40@mail.gmail.com> <57c63afe0711141032n825af53hdf12f6a37afd5c4b@mail.gmail.com> Message-ID: <60f3810c0711141137u3e33dad9p96b6a73faefb0c97@mail.gmail.com> On Nov 14, 2007 12:32 PM, David Chelimsky wrote: > http://rspec.rubyforge.org/documentation/rails/install.html > > CURRENT means the latest release, not the trunk. 1.0.8 was out months > ago - obviously not compatible with subsequent changes to rails. > > Cheers, > David I see people make this mistake fairly often. Is there any reason the tag shouldn't be renamed to something less counter-intuitive? Thinking of FreeBSD's tags, RELEASE perhaps? Kyle From pergesu at gmail.com Wed Nov 14 14:39:41 2007 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 14 Nov 2007 11:39:41 -0800 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <60f3810c0711141137u3e33dad9p96b6a73faefb0c97@mail.gmail.com> References: <57c63afe0711081814k288f4048j9c95d68832207677@mail.gmail.com> <6b6419750711081818h1f644147he6df85b110dfdb10@mail.gmail.com> <57c63afe0711081820s7cdefd53y1e9a5f3741ffb6f4@mail.gmail.com> <6b6419750711081821r1d0a2b09l97895b6490bc8daf@mail.gmail.com> <57c63afe0711081836g45af9160x59a06d1f243a3da5@mail.gmail.com> <57c63afe0711081840i65506f11i4de93f516a1a6c40@mail.gmail.com> <57c63afe0711141032n825af53hdf12f6a37afd5c4b@mail.gmail.com> <60f3810c0711141137u3e33dad9p96b6a73faefb0c97@mail.gmail.com> Message-ID: <810a540e0711141139x56016d1l28bb12281df1db8b@mail.gmail.com> On Nov 14, 2007 11:37 AM, Kyle Hargraves wrote: > On Nov 14, 2007 12:32 PM, David Chelimsky wrote: > > http://rspec.rubyforge.org/documentation/rails/install.html > > > > CURRENT means the latest release, not the trunk. 1.0.8 was out months > > ago - obviously not compatible with subsequent changes to rails. > > > > Cheers, > > David > > I see people make this mistake fairly often. Is there any reason the > tag shouldn't be renamed to something less counter-intuitive? > > Thinking of FreeBSD's tags, RELEASE perhaps? +1 From rspec.user at gmail.com Wed Nov 14 16:08:17 2007 From: rspec.user at gmail.com (sinclair bain) Date: Wed, 14 Nov 2007 16:08:17 -0500 Subject: [rspec-users] Stubbing out required associated models In-Reply-To: References: Message-ID: <2ca660dd0711141308l68bea5e0xffa5627d3ebd7983@mail.gmail.com> Matthew, If your intent is to test the behaviour of your model(s), then yes mocking and stubbing are a good [_the_] way to go. > > Cheers! sinclair -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071114/7bd49a79/attachment.html From mailing_lists at railsnewbie.com Wed Nov 14 16:27:11 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 14 Nov 2007 16:27:11 -0500 Subject: [rspec-users] Stubbing out required associated models In-Reply-To: <2ca660dd0711141308l68bea5e0xffa5627d3ebd7983@mail.gmail.com> References: <2ca660dd0711141308l68bea5e0xffa5627d3ebd7983@mail.gmail.com> Message-ID: <353FE289-8D71-482E-B519-69B6ED61A5D0@railsnewbie.com> On Nov 14, 2007, at 4:08 PM, sinclair bain wrote: > Matthew, > > If your intent is to test the behaviour of your model(s), then yes > mocking and > stubbing are a good [_the_] way to go. Except, of course, that you are no longer really validating the associated models - only your mocks. Scott From fowlduck at gmail.com Wed Nov 14 18:25:43 2007 From: fowlduck at gmail.com (Nathan Sutton) Date: Wed, 14 Nov 2007 17:25:43 -0600 Subject: [rspec-users] ETA to Stories Message-ID: <18BCB118-57EC-46C2-9EBC-6444FFF55F13@gmail.com> Hey guys, just poppin in to ask if anyone knows when stories will be somewhat stable? We're starting to use integration tests at work, we're already using rspec, and I'd like to avoid integration tests if possible. Thanks, Nate "fowlduck" Sutton From dchelimsky at gmail.com Wed Nov 14 18:33:03 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 14 Nov 2007 17:33:03 -0600 Subject: [rspec-users] ETA to Stories In-Reply-To: <18BCB118-57EC-46C2-9EBC-6444FFF55F13@gmail.com> References: <18BCB118-57EC-46C2-9EBC-6444FFF55F13@gmail.com> Message-ID: <57c63afe0711141533h3d110cc8t6241d8c273a06ca@mail.gmail.com> On Nov 14, 2007 5:25 PM, Nathan Sutton wrote: > Hey guys, just poppin in to ask if anyone knows when stories will be > somewhat stable? Are you serious? Stories haven't even been released yet :) Realistically, names like Story, Scenario, Given, When and Then are not likely to change. Methods like steps_for and with_steps_for *might* change, but if they do it'll be a simple search and replace for you. So, while I can guarantee you that there WILL be changes, I can tell you that I'm using stories (and I'm not alone) and I expect that whatever churn is in store should be relatively benign. That said - I'll reiterate - it is not even released yet. Use at your own risk. Cheers, David From fowlduck at gmail.com Wed Nov 14 18:40:04 2007 From: fowlduck at gmail.com (Nathan Sutton) Date: Wed, 14 Nov 2007 17:40:04 -0600 Subject: [rspec-users] ETA to Stories In-Reply-To: <57c63afe0711141533h3d110cc8t6241d8c273a06ca@mail.gmail.com> References: <18BCB118-57EC-46C2-9EBC-6444FFF55F13@gmail.com> <57c63afe0711141533h3d110cc8t6241d8c273a06ca@mail.gmail.com> Message-ID: <27D6EBEB-4DDD-4EA5-B5C1-8055C5D87B2C@gmail.com> Aw, you both cautioned me and calmed me, I don't know what to think now! ;) Seriously though, I'd love to use it over integration tests. When is the next release? Are you on a scheduled release cycle? Nate On Nov 14, 2007, at 5:33 PM, David Chelimsky wrote: > On Nov 14, 2007 5:25 PM, Nathan Sutton wrote: >> Hey guys, just poppin in to ask if anyone knows when stories will be >> somewhat stable? > > Are you serious? Stories haven't even been released yet :) > > Realistically, names like Story, Scenario, Given, When and Then are > not likely to change. Methods like steps_for and with_steps_for > *might* change, but if they do it'll be a simple search and replace > for you. > > So, while I can guarantee you that there WILL be changes, I can tell > you that I'm using stories (and I'm not alone) and I expect that > whatever churn is in store should be relatively benign. > > That said - I'll reiterate - it is not even released yet. Use at > your own risk. > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Wed Nov 14 18:43:56 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 14 Nov 2007 17:43:56 -0600 Subject: [rspec-users] ETA to Stories In-Reply-To: <27D6EBEB-4DDD-4EA5-B5C1-8055C5D87B2C@gmail.com> References: <18BCB118-57EC-46C2-9EBC-6444FFF55F13@gmail.com> <57c63afe0711141533h3d110cc8t6241d8c273a06ca@mail.gmail.com> <27D6EBEB-4DDD-4EA5-B5C1-8055C5D87B2C@gmail.com> Message-ID: <57c63afe0711141543u6ffc9f15p2adcc6c443e62265@mail.gmail.com> On Nov 14, 2007 5:40 PM, Nathan Sutton wrote: > Aw, you both cautioned me and calmed me, I don't know what to think > now! ;) > > Seriously though, I'd love to use it over integration tests. When is > the next release? Are you on a scheduled release cycle? We're hoping to have a release out within a week or two. We'd like to wait for Rails 2.0.0 to be released and then close any holes (we're passing against 2.0.0-RC1 and edge, so that shouldn't be a big deal). We've also been doing quite a bit of refactoring as you're likely aware - and there are a few regressions that have occurred that we're trying to resolve before we release. So it'll be soon. But probably not this week. Cheers, David From pergesu at gmail.com Wed Nov 14 18:50:26 2007 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 14 Nov 2007 15:50:26 -0800 Subject: [rspec-users] Role of stories vs specs In-Reply-To: <57c63afe0711131600n5807f7f2ja782610ac78e5c13@mail.gmail.com> References: <810a540e0711131110t73149f26r50fd6dadbe20ae90@mail.gmail.com> <57c63afe0711131151w733c7b70id8cd59a5d64cd196@mail.gmail.com> <810a540e0711131517q733097a9y73a77ecf591737ec@mail.gmail.com> <57c63afe0711131600n5807f7f2ja782610ac78e5c13@mail.gmail.com> Message-ID: <810a540e0711141550s3831e144t1f14429d549b3486@mail.gmail.com> On Nov 13, 2007 4:00 PM, David Chelimsky wrote: > On Nov 13, 2007 5:17 PM, Pat Maddox wrote: > > Let's say in some banking software we have a transfer screen, and > > there are three possible errors: insufficient funds, source account > > frozen, target account frozen. Would you write a scenario for each of > > the possible errors, and an example for each? > > Without even batting an eye! > > The scenario is going to reflect how things look from the outside. The > example is going to be targeted right at the part of the system that > is responsible for producing the correct error message. When I gave that example I thought it sucked, because I would write a story and example for each too. But I guess I can say it served as a bit of a sanity check. Anyway, a more gray-area example (imo) is Rails validations. We've got a user registration page, and it requires the user to fill in their name, email address, and a password. Would you write a scenario where nothing is filled in? Where everything but the name is filled in? And so on for each attribute. How about combinations of missing stuff? It seems to me like that story is on a VERY high level and all we really care about is verifying that the plumbing works (so maybe I need to think of this as a story for the UI domain instead of the business domain?). If the user fills in everything, make sure there's a new record. If they don't fill it in, make sure they're shown the registration page again. It's cumbersome to try to cover every possible scenario even though you "should." Would you write a story at a lower level, which actually tries to save the objects to the db and verifies that nothing changes? That *definitely* duplicates what's going on in the model-level specs. Hopefully this thread hasn't died... Cheers, Pat From aslak.hellesoy at gmail.com Wed Nov 14 19:09:01 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 15 Nov 2007 01:09:01 +0100 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: <60f3810c0711141137u3e33dad9p96b6a73faefb0c97@mail.gmail.com> References: <57c63afe0711081814k288f4048j9c95d68832207677@mail.gmail.com> <6b6419750711081818h1f644147he6df85b110dfdb10@mail.gmail.com> <57c63afe0711081820s7cdefd53y1e9a5f3741ffb6f4@mail.gmail.com> <6b6419750711081821r1d0a2b09l97895b6490bc8daf@mail.gmail.com> <57c63afe0711081836g45af9160x59a06d1f243a3da5@mail.gmail.com> <57c63afe0711081840i65506f11i4de93f516a1a6c40@mail.gmail.com> <57c63afe0711141032n825af53hdf12f6a37afd5c4b@mail.gmail.com> <60f3810c0711141137u3e33dad9p96b6a73faefb0c97@mail.gmail.com> Message-ID: <8d961d900711141609w4ad9f5fbw4d66c5c6550b9d60@mail.gmail.com> On Nov 14, 2007 8:37 PM, Kyle Hargraves wrote: > On Nov 14, 2007 12:32 PM, David Chelimsky wrote: > > http://rspec.rubyforge.org/documentation/rails/install.html > > > > CURRENT means the latest release, not the trunk. 1.0.8 was out months > > ago - obviously not compatible with subsequent changes to rails. > > > > Cheers, > > David > > I see people make this mistake fairly often. Is there any reason the > tag shouldn't be renamed to something less counter-intuitive? > > Thinking of FreeBSD's tags, RELEASE perhaps? > LATEST_RELEASE would speak more for itself. > Kyle > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From johnwlong2000 at gmail.com Wed Nov 14 19:26:26 2007 From: johnwlong2000 at gmail.com (John W. Long) Date: Wed, 14 Nov 2007 19:26:26 -0500 Subject: [rspec-users] ETA to Stories In-Reply-To: <18BCB118-57EC-46C2-9EBC-6444FFF55F13@gmail.com> References: <18BCB118-57EC-46C2-9EBC-6444FFF55F13@gmail.com> Message-ID: On Nov 14, 2007, at 6:25 PM, Nathan Sutton wrote: > Hey guys, just poppin in to ask if anyone knows when stories will be > somewhat stable? We're starting to use integration tests at work, > we're already using rspec, and I'd like to avoid integration tests if > possible. Here's a plugin a friend and I developed for doing Rails-style integration testing with Rspec: http://faithfulcode.rubyforge.org/svn/plugins/trunk/spec_integration/ It might be more up your alley. -- John Long http://wiseheartdesign.com From fowlduck at gmail.com Wed Nov 14 19:28:16 2007 From: fowlduck at gmail.com (Nathan Sutton) Date: Wed, 14 Nov 2007 18:28:16 -0600 Subject: [rspec-users] ETA to Stories In-Reply-To: References: <18BCB118-57EC-46C2-9EBC-6444FFF55F13@gmail.com> Message-ID: <39C8983D-D5C9-4CA9-A120-C28CFADC918B@gmail.com> Woo, nice docs in there, ha! ;) How is it intended to be used? Thanks, Nate On Nov 14, 2007, at 6:26 PM, John W. Long wrote: > On Nov 14, 2007, at 6:25 PM, Nathan Sutton wrote: >> Hey guys, just poppin in to ask if anyone knows when stories will be >> somewhat stable? We're starting to use integration tests at work, >> we're already using rspec, and I'd like to avoid integration tests if >> possible. > > > Here's a plugin a friend and I developed for doing Rails-style > integration testing with Rspec: > > http://faithfulcode.rubyforge.org/svn/plugins/trunk/spec_integration/ > > It might be more up your alley. > > -- > John Long > http://wiseheartdesign.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Wed Nov 14 20:10:39 2007 From: lists at ruby-forum.com (Mark McG.) Date: Thu, 15 Nov 2007 02:10:39 +0100 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: References: Message-ID: Mark McG. wrote: > I have a project on edge rails that I'm trying to convert from Test:Unit > to rspec. I have the rspec gem version 2338, the rspec and > rsepc_on_rails version 2831 in vendor/plugins, and rails version 8117 in > vendor/rails. > > I've been able to get a few specs passing, have gotten the specs running > from autotest, and am able to do "rake spec:doc" and get the basic > command line spec printout. I'd like be able to generate the html spec > printout, so I tried "spec spec --format html" but got the "undefined > method `before' for Spec::Rails::DSL::RailsExample:Class > (NoMethodError)" mentioned in the "Autotest busted with Rspec/Rails > trunk" thread from this forum. > > I was wondering if anyone else has been able to get the spec printouts > working with edge rails and if so what versions of > rails/rspec/rspec_on_rails were used. > > Thanks for your help, > - Mark I found in the rdocs that I can use: rake spec:doc SPEC_OPTS="--format html" > spec_doc.html I hope that helps someone, - Mark -- Posted via http://www.ruby-forum.com/. From fowlduck at gmail.com Wed Nov 14 20:12:57 2007 From: fowlduck at gmail.com (Nathan Sutton) Date: Wed, 14 Nov 2007 19:12:57 -0600 Subject: [rspec-users] RSpec on Rails 2.0 In-Reply-To: References: Message-ID: <1ED68679-F448-4BE6-865E-0125BE031E9E@gmail.com> much better: script/spec spec -fh > spec_doc.html Nate On Nov 14, 2007, at 7:10 PM, Mark McG. wrote: > Mark McG. wrote: >> I have a project on edge rails that I'm trying to convert from >> Test:Unit >> to rspec. I have the rspec gem version 2338, the rspec and >> rsepc_on_rails version 2831 in vendor/plugins, and rails version >> 8117 in >> vendor/rails. >> >> I've been able to get a few specs passing, have gotten the specs >> running >> from autotest, and am able to do "rake spec:doc" and get the basic >> command line spec printout. I'd like be able to generate the html >> spec >> printout, so I tried "spec spec --format html" but got the "undefined >> method `before' for Spec::Rails::DSL::RailsExample:Class >> (NoMethodError)" mentioned in the "Autotest busted with Rspec/Rails >> trunk" thread from this forum. >> >> I was wondering if anyone else has been able to get the spec >> printouts >> working with edge rails and if so what versions of >> rails/rspec/rspec_on_rails were used. >> >> Thanks for your help, >> - Mark > > I found in the rdocs that I can use: > rake spec:doc SPEC_OPTS="--format html" > spec_doc.html > > I hope that helps someone, > - Mark > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From fowlduck at gmail.com Wed Nov 14 22:01:34 2007 From: fowlduck at gmail.com (Nathan Sutton) Date: Wed, 14 Nov 2007 21:01:34 -0600 Subject: [rspec-users] Plain Text Stories Chaining Scenarios Message-ID: I'm writing a plain text story (testing the waters) and I have scenarios that I need to chain in my specs. Here is what I have so far: Story: User purchasing tshirts As a user I want to checkout So that I can purchase shirts Scenario: User goes to checkout with nothing in cart Given a user And user has an empty cart When user goes to checkout Then user should see the page: site index And page should include the text: you have nothing in your cart Scenario: Logged-in user goes to checkout Given a logged-in user And user has a cart with items in it When user goes to checkout Then user should see the page: address entry Scenario: Anonymous user goes to checkout Given an anonymous user And user has a cart with items in it When user goes to checkout Then user should see the who are you page Scenario: Anonymous user continues as guest from 'who are you' page Given an anonymous user And user has a cart with items in it And user is at the page: who are you When user continues as a guest Then user should see the page: address entry And page should include the text: guest Scenario: Anonymous user decides to sign-up at 'who are you' page Given an anonymous user And user has a cart with items in it And user is at the page: who are you When user goes to sign-up Then user should see the page: sign-up Scenario: Registered user decides to login at 'who are you' page Given an anonymous user And user has a cart with items in it And user is at the page: who are you When user goes to login Then user should see the page: login Scenario: Registered user logs in and is returned to checkout Given an anonymous user And user has a cart with items in it and user is at the page: login When user logs in Then user should see the page: address entry Scenario: Anonymous user signs-up and is returned to checkout Given an anonymous user And user has a cart with items in it And user is at the page: sign-up When user signs-up Then user should see the page: address entry The parts that I need to chain are the last four scenarios. I want to make sure that when they leave to signup and log in that they're returned to the next step in checkout. How would I go about doing this in the stories? Would that just be another given? Also, how do the rest look, sane? Thanks, Nate From court3nay at gmail.com Wed Nov 14 22:29:47 2007 From: court3nay at gmail.com (Courtenay) Date: Wed, 14 Nov 2007 19:29:47 -0800 Subject: [rspec-users] Plain Text Stories Chaining Scenarios In-Reply-To: References: Message-ID: <99FE0299-B3BE-46AC-96FA-82FCD0344924@gmail.com> Reads like haiku :p On Nov 14, 2007, at 7:01 PM, Nathan Sutton wrote: > I'm writing a plain text story (testing the waters) and I have > scenarios that I need to chain in my specs. > > Here is what I have so far: > > Story: User purchasing tshirts > As a user > I want to checkout > So that I can purchase shirts > > Scenario: User goes to checkout with nothing in cart > Given a user > And user has an empty cart > When user goes to checkout > Then user should see the page: site index > And page should include the text: you have nothing in your cart > > Scenario: Logged-in user goes to checkout > Given a logged-in user > And user has a cart with items in it > When user goes to checkout > Then user should see the page: address entry > > Scenario: Anonymous user goes to checkout > Given an anonymous user > And user has a cart with items in it > When user goes to checkout > Then user should see the who are you page > > Scenario: Anonymous user continues as guest from 'who are you' page > Given an anonymous user > And user has a cart with items in it > And user is at the page: who are you > When user continues as a guest > Then user should see the page: address entry > And page should include the text: guest > > Scenario: Anonymous user decides to sign-up at 'who are you' page > Given an anonymous user > And user has a cart with items in it > And user is at the page: who are you > When user goes to sign-up > Then user should see the page: sign-up > > Scenario: Registered user decides to login at 'who are you' page > Given an anonymous user > And user has a cart with items in it > > And user is at the page: who are you > When user goes to login > Then user should see the page: login > > Scenario: Registered user logs in and is returned to checkout > Given an anonymous user > And user has a cart with items in it > and user is at the page: login > When user logs in > Then user should see the page: address entry > > Scenario: Anonymous user signs-up and is returned to checkout > Given an anonymous user > And user has a cart with items in it > And user is at the page: sign-up > When user signs-up > Then user should see the page: address entry > > The parts that I need to chain are the last four scenarios. I want to > make sure that when they leave to signup and log in that they're > returned to the next step in checkout. How would I go about doing > this in the stories? Would that just be another given? > > Also, how do the rest look, sane? > > Thanks, > > Nate > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ingo at ingoweiss.com Thu Nov 15 04:59:04 2007 From: ingo at ingoweiss.com (Ingo Weiss) Date: Thu, 15 Nov 2007 11:59:04 +0200 Subject: [rspec-users] 'lazy' url generation in view specs Message-ID: <1EF6C673-A8B0-42F6-A569-6A240DC78497@ingoweiss.com> Hi, I would like to use the 'lazy' style of url generation in my views, omitting parameters from my calls to url_for (and named route methods) that are then filled in from the current request parameters. Example: url_for(:action => 'index') will fill in (:controller => 'posts') if params[:controller] is 'posts' However, this breaks my view specs because when they render the view there is no request from which to fill in the missing parameters. How can I stub/mock the request so that the 'lazy' url-generation works in view spec? I tried a number of things, none of them working, including this: @controller.stub!(:params).and_return({:controller => 'posts', :action => 'show'}) Ingo From mlins at webinforem.com Thu Nov 15 08:44:35 2007 From: mlins at webinforem.com (Matthew Lins) Date: Thu, 15 Nov 2007 07:44:35 -0600 Subject: [rspec-users] Stubbing out required associated models In-Reply-To: <353FE289-8D71-482E-B519-69B6ED61A5D0@railsnewbie.com> Message-ID: But, that should be okay, since my intent is not to test the associated models. I have a separate spec file for those models. On 11/14/07 3:27 PM, "Scott Taylor" wrote: > > On Nov 14, 2007, at 4:08 PM, sinclair bain wrote: > >> Matthew, >> >> If your intent is to test the behaviour of your model(s), then yes >> mocking and >> stubbing are a good [_the_] way to go. > > Except, of course, that you are no longer really validating the > associated models - only your mocks. > > Scott > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From glenn at aldenta.com Thu Nov 15 10:55:27 2007 From: glenn at aldenta.com (Glenn Ford) Date: Thu, 15 Nov 2007 10:55:27 -0500 Subject: [rspec-users] Interdependency between RSpec files In-Reply-To: <57c63afe0711141114i9916514y7405b55e0030300c@mail.gmail.com> References: <3DD9024D-7EEF-41DF-8E26-A3EF2B5D362B@aldenta.com> <72ACA421-112B-4E9F-9E6D-052A501AA5E5@railsnewbie.com> <8F3ED097-0F58-49A3-989C-B9B628A98E7F@aldenta.com> <57c63afe0711141114i9916514y7405b55e0030300c@mail.gmail.com> Message-ID: <98CCCCD8-FBDC-489F-9033-E6CF082D9C32@aldenta.com> On Nov 14, 2007, at 2:14 PM, David Chelimsky wrote: > On Nov 14, 2007 1:07 PM, Glenn Ford wrote: >> Your suggestion put me on the right track. I looked back to where I >> had I ran into a case where I was trying to stub an instance I >> couldn't get ahold of in the scope of my spec and since I was having >> trouble with some mocha bugs, I resorted to a >> Model.class_eval do >> alias_method :original_method, :old_method >> end > > Try doing that on the instance instead. > > model = Model.new > > (class << model).class_eval do > alias_method :original_method, :old_method > end > > That way it can't leak to other instances of the same model. That's what I had hoped to do, but as I stated in my description, the difficult situation involved a model I couldn't get ahold of in the scope of my spec. If I was able to instantiate it somehow myself I would have just stubbed the method. This probably means I've got some code in the controller that shouldn't live in the controller, however. If I refactor it properly I doubt I'll need any more fancy tricks like this. Thanks! > > >> >> Unfortunately I didn't set the alias back at the end of the spec. >> That was my problem. Thanks a ton! >> >> Glenn >> >> >> On Nov 14, 2007, at 12:28 PM, Scott Taylor wrote: >> >>> >>> On Nov 14, 2007, at 11:37 AM, Glenn Ford wrote: >>> >>>> I run my suite of tests, one test fails. >>>> I run that one test file, no tests fail. >>>> >>>> Something is carrying over between files and I can't figure out >>>> what. >>>> I tracked down the problem to the very line it's occurring on, with >>>> printouts before and after every call to make sure I know exactly >>>> what >>>> is being reached. >>> >>> >>> First of all - make sure you don't have any after(:create) or before >>> (:create) specs. If an AR object is created in one of these, it *IS >>> NOT* going to be rolled back. >>> >>> You might also try the following: >>> >>> rake db:migrate; rake db:test:prepare >>> >>> Log into mysql (or whatever database) - inspect it to see that no >>> records are present in your test database (if you really aren't >>> using >>> fixtures at all). >>> >>> >>>> >>>> In this spec I have 0 fixtures/mocks/stubs. The objects in this >>>> file >>>> do not live anywhere outside of the file. This is a model spec and >>>> I'm using all real objects to test it. In the "before" block I set >>>> up >>>> some models, and in my spec itself I, in each test, make a couple >>>> changes then call a model's save method. That model has an >>>> "after_create" method which calls a method in a child model that it >>>> has. It is THIS method which is not being called. I have >>>> printouts >>>> before and after everything, like I said, and the lines before and >>>> after the method call work, which leads me to believe that method >>>> IS >>>> getting called. However I have a "puts 'foo'" at the top of that >>>> method and it doesn't get printed. >>> >>> You might want to try running that one spec with the following >>> snippet stuck into the top of your after_create method: >>> >>> require 'rubygems'; require 'ruby-debug'; debugger; >>> >>> When the spec runs, you will be dropped down into the ruby debugger, >>> so you can inspect what is *actually* going on. (You will need to >>> know how to use a debugger, and have the ruby-debug gem installed). >>> >>> If that doesn't yield any helpful information, then remove that >>> snippet and put it at the top of the failing test (the first line of >>> the example ("it") block). Then run the full test suite, and again, >>> you will be dropped down into the debugger. >>> >>> Hope that helps, >>> >>> Scott >>> >>> >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ed.howland at gmail.com Thu Nov 15 11:56:55 2007 From: ed.howland at gmail.com (Ed Howland) Date: Thu, 15 Nov 2007 10:56:55 -0600 Subject: [rspec-users] What command to run all stories? Message-ID: <3df642dd0711150856y570487b2x84903d0fcb10fd8c@mail.gmail.com> Hi, I've been following this thread and I can get the example stories to run with the ruby command. But I've been unable to get the example from http://blog.davidchelimsky.net/articles/2007/10/25/plain-text-stories-part-iii to run with all.rb ruby stories/all.rb /home/edh/story/stories/additions/steps/addition_steps.rb:2: undefined method `steps_for' for main:Object (NoMethodError) from /home/edh/story/stories/all.rb:3:in `require' from /home/edh/story/stories/all.rb:3 from /home/edh/story/stories/all.rb:2:in `each' from /home/edh/story/stories/all.rb:2 from stories/all.rb:3:in `require' from stories/all.rb:3 from stories/all.rb:2:in `each' from stories/all.rb:2 The examples seem older than the version on David's blog. Am I missing some parts from David's blog? My directory looks like: stories/ |-- additions | |-- adder.rb | |-- addition | |-- addition.rb | `-- steps | `-- addition_steps.rb |-- all.rb `-- helper.rb If I run the story stand-alone, I get: ruby stories/additions/addition.rb Running 2 scenarios: Story: simple addition As an accountant I want to add numbers So that I can count beans Scenario: add one plus one Given an addend of 1 (PENDING) And an addend of 1 (PENDING) When the addends are added (PENDING) Then the sum should be 2 (PENDING) And the corks should be popped/usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/errors.rb:94:in `check': SQL logic error or missing database (SQLite3::SQLException) from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/resultset.rb:76:in `check' from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/resultset.rb:68:in `commence' from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/resultset.rb:61:in `initialize' from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/statement.rb:163:in `new' from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/statement.rb:163:in `execute' from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/database.rb:212:in `execute' from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/database.rb:187:in `prepare' from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/database.rb:211:in `execute' ... 13 levels... from /home/edh/story/vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:39:in `each' from /home/edh/story/vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:39:in `run_stories' from /home/edh/story/vendor/plugins/rspec/lib/spec/story/runner.rb:41:in `register_exit_hook' from stories/additions/addition.rb:3 This last part is happening in the at_exit part of Test:Unit Also, I don't understand why the scenario's are pending. Thanks Ed -- Ed Howland http://greenprogrammer.blogspot.com "The information transmitted is intended only for the person or entity to which it is addressed and may contain proprietary, confidential and/or legally privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers." From court3nay at gmail.com Thu Nov 15 12:46:51 2007 From: court3nay at gmail.com (Courtenay) Date: Thu, 15 Nov 2007 09:46:51 -0800 Subject: [rspec-users] Stubbing out required associated models In-Reply-To: References: <353FE289-8D71-482E-B519-69B6ED61A5D0@railsnewbie.com> Message-ID: <4b430c8f0711150946i35d321e8w70802a99e3a47dbf@mail.gmail.com> of course, you do both. you need to unit test in isolation, as well as integration test the stack. On Nov 15, 2007 5:44 AM, Matthew Lins wrote: > But, that should be okay, since my intent is not to test the associated > models. I have a separate spec file for those models. > > > > On 11/14/07 3:27 PM, "Scott Taylor" wrote: > > > > > On Nov 14, 2007, at 4:08 PM, sinclair bain wrote: > > > >> Matthew, > >> > >> If your intent is to test the behaviour of your model(s), then yes > >> mocking and > >> stubbing are a good [_the_] way to go. > > > > Except, of course, that you are no longer really validating the > > associated models - only your mocks. > > > > Scott > > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ed.howland at gmail.com Thu Nov 15 12:58:39 2007 From: ed.howland at gmail.com (Ed Howland) Date: Thu, 15 Nov 2007 11:58:39 -0600 Subject: [rspec-users] Story adapter and SQLite Was:What command to run all stories? Message-ID: <3df642dd0711150958g35a3c4aew28a101c3c155d2ed@mail.gmail.com> Hi, by switching to MySQL from SQLite, it fixed the problem. I ran rdebug on it and it is trying to call I ActiveRecord::Base.connection.begin_db_transaction. from ActiveRecordSafetyListener.scenario_started. I don't think SQLLite likes transactions. Ed On Nov 15, 2007 10:56 AM, Ed Howland wrote: > If I run the story stand-alone, I get: > ruby stories/additions/addition.rb > Running 2 scenarios: > > Story: simple addition > > As an accountant > I want to add numbers > So that I can count beans > > Scenario: add one plus one > > Given an addend of 1 (PENDING) > And an addend of 1 (PENDING) > > When the addends are added (PENDING) > > Then the sum should be 2 (PENDING) > And the corks should be > popped/usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/errors.rb:94:in > `check': SQL logic error or missing database (SQLite3::SQLException) > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/resultset.rb:76:in > `check' > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/resultset.rb:68:in > `commence' > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/resultset.rb:61:in > `initialize' > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/statement.rb:163:in > `new' > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/statement.rb:163:in > `execute' > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/database.rb:212:in > `execute' > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/database.rb:187:in > `prepare' > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/database.rb:211:in > `execute' > ... 13 levels... > from /home/edh/story/vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:39:in > `each' > from /home/edh/story/vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:39:in > `run_stories' > from /home/edh/story/vendor/plugins/rspec/lib/spec/story/runner.rb:41:in > `register_exit_hook' > from stories/additions/addition.rb:3 > This last part is happening in the at_exit part of Test:Unit > > Also, I don't understand why the scenario's are pending. > > Thanks > Ed > > > > -- > Ed Howland > http://greenprogrammer.blogspot.com > "The information transmitted is intended only for the person or entity > to which it is addressed and may contain proprietary, confidential > and/or legally privileged material. Any review, retransmission, > dissemination or other use of, or taking of any action in reliance > upon, this information by persons or entities other than the intended > recipient is prohibited. If you received this in error, please contact > the sender and delete the material from all computers." > -- Ed Howland http://greenprogrammer.blogspot.com "The information transmitted is intended only for the person or entity to which it is addressed and may contain proprietary, confidential and/or legally privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers." From epugh at opensourceconnections.com Thu Nov 15 13:19:07 2007 From: epugh at opensourceconnections.com (Eric Pugh) Date: Thu, 15 Nov 2007 13:19:07 -0500 Subject: [rspec-users] What command to run all stories? In-Reply-To: <3df642dd0711150856y570487b2x84903d0fcb10fd8c@mail.gmail.com> References: <3df642dd0711150856y570487b2x84903d0fcb10fd8c@mail.gmail.com> Message-ID: <786AEE09-BE94-44E0-8E98-F51151FA799D@opensourceconnections.com> When I copied the addition example into my test rails app, things worked... The "popping the cork" was the only pending action, and was expected. I've only be able to run via ruby as well. Eric On Nov 15, 2007, at 11:56 AM, Ed Howland wrote: > Hi, I've been following this thread and I can get the example stories > to run with the ruby command. But I've been unable to get the example > from http://blog.davidchelimsky.net/articles/2007/10/25/plain-text- > stories-part-iii > to run with all.rb > > > ruby stories/all.rb > /home/edh/story/stories/additions/steps/addition_steps.rb:2: undefined > method `steps_for' for main:Object (NoMethodError) > from /home/edh/story/stories/all.rb:3:in `require' > from /home/edh/story/stories/all.rb:3 > from /home/edh/story/stories/all.rb:2:in `each' > from /home/edh/story/stories/all.rb:2 > from stories/all.rb:3:in `require' > from stories/all.rb:3 > from stories/all.rb:2:in `each' > from stories/all.rb:2 > > The examples seem older than the version on David's blog. Am I missing > some parts from David's blog? > > My directory looks like: > stories/ > |-- additions > | |-- adder.rb > | |-- addition > | |-- addition.rb > | `-- steps > | `-- addition_steps.rb > |-- all.rb > `-- helper.rb > > If I run the story stand-alone, I get: > ruby stories/additions/addition.rb > Running 2 scenarios: > > Story: simple addition > > As an accountant > I want to add numbers > So that I can count beans > > Scenario: add one plus one > > Given an addend of 1 (PENDING) > And an addend of 1 (PENDING) > > When the addends are added (PENDING) > > Then the sum should be 2 (PENDING) > And the corks should be > popped/usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/ > sqlite3/errors.rb:94:in > `check': SQL logic error or missing database (SQLite3::SQLException) > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > lib/sqlite3/resultset.rb:76:in > `check' > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > lib/sqlite3/resultset.rb:68:in > `commence' > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > lib/sqlite3/resultset.rb:61:in > `initialize' > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > lib/sqlite3/statement.rb:163:in > `new' > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > lib/sqlite3/statement.rb:163:in > `execute' > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > lib/sqlite3/database.rb:212:in > `execute' > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > lib/sqlite3/database.rb:187:in > `prepare' > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > lib/sqlite3/database.rb:211:in > `execute' > ... 13 levels... > from /home/edh/story/vendor/plugins/rspec/lib/spec/story/ > runner/story_runner.rb:39:in > `each' > from /home/edh/story/vendor/plugins/rspec/lib/spec/story/ > runner/story_runner.rb:39:in > `run_stories' > from /home/edh/story/vendor/plugins/rspec/lib/spec/story/ > runner.rb:41:in > `register_exit_hook' > from stories/additions/addition.rb:3 > This last part is happening in the at_exit part of Test:Unit > > Also, I don't understand why the scenario's are pending. > > Thanks > Ed > > > > -- > Ed Howland > http://greenprogrammer.blogspot.com > "The information transmitted is intended only for the person or entity > to which it is addressed and may contain proprietary, confidential > and/or legally privileged material. Any review, retransmission, > dissemination or other use of, or taking of any action in reliance > upon, this information by persons or entities other than the intended > recipient is prohibited. If you received this in error, please contact > the sender and delete the material from all computers." > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users ----------------------------------------------------- Eric Pugh | Principal | OpenSource Connections, LLC | 434.466.1467 | http://www.opensourceconnections.com From dchelimsky at gmail.com Thu Nov 15 13:22:11 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 15 Nov 2007 12:22:11 -0600 Subject: [rspec-users] Story adapter and SQLite Was:What command to run all stories? In-Reply-To: <3df642dd0711150958g35a3c4aew28a101c3c155d2ed@mail.gmail.com> References: <3df642dd0711150958g35a3c4aew28a101c3c155d2ed@mail.gmail.com> Message-ID: <57c63afe0711151022r2b8a5d83n5c8461cdcc2b163f@mail.gmail.com> On Nov 15, 2007 11:58 AM, Ed Howland wrote: > Hi, by switching to MySQL from SQLite, it fixed the problem. I ran > rdebug on it and it is trying to call > I ActiveRecord::Base.connection.begin_db_transaction. from > ActiveRecordSafetyListener.scenario_started. I don't think SQLLite > likes transactions. Why is this example engaging any sort of database? It shouldn't need to. > > Ed > > On Nov 15, 2007 10:56 AM, Ed Howland wrote: > > If I run the story stand-alone, I get: > > ruby stories/additions/addition.rb > > Running 2 scenarios: > > > > Story: simple addition > > > > As an accountant > > I want to add numbers > > So that I can count beans > > > > Scenario: add one plus one > > > > Given an addend of 1 (PENDING) > > And an addend of 1 (PENDING) > > > > When the addends are added (PENDING) > > > > Then the sum should be 2 (PENDING) > > And the corks should be > > popped/usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/errors.rb:94:in > > `check': SQL logic error or missing database (SQLite3::SQLException) > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/resultset.rb:76:in > > `check' > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/resultset.rb:68:in > > `commence' > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/resultset.rb:61:in > > `initialize' > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/statement.rb:163:in > > `new' > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/statement.rb:163:in > > `execute' > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/database.rb:212:in > > `execute' > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/database.rb:187:in > > `prepare' > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/database.rb:211:in > > `execute' > > ... 13 levels... > > from /home/edh/story/vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:39:in > > `each' > > from /home/edh/story/vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:39:in > > `run_stories' > > from /home/edh/story/vendor/plugins/rspec/lib/spec/story/runner.rb:41:in > > `register_exit_hook' > > from stories/additions/addition.rb:3 > > This last part is happening in the at_exit part of Test:Unit > > > > Also, I don't understand why the scenario's are pending. > > > > Thanks > > Ed > > > > > > > > -- > > Ed Howland > > http://greenprogrammer.blogspot.com > > "The information transmitted is intended only for the person or entity > > to which it is addressed and may contain proprietary, confidential > > and/or legally privileged material. Any review, retransmission, > > dissemination or other use of, or taking of any action in reliance > > upon, this information by persons or entities other than the intended > > recipient is prohibited. If you received this in error, please contact > > the sender and delete the material from all computers." > > > > > > -- > Ed Howland > http://greenprogrammer.blogspot.com > "The information transmitted is intended only for the person or entity > to which it is addressed and may contain proprietary, confidential > and/or legally privileged material. Any review, retransmission, > dissemination or other use of, or taking of any action in reliance > upon, this information by persons or entities other than the intended > recipient is prohibited. If you received this in error, please contact > the sender and delete the material from all computers." > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ed.howland at gmail.com Thu Nov 15 13:26:24 2007 From: ed.howland at gmail.com (Ed Howland) Date: Thu, 15 Nov 2007 12:26:24 -0600 Subject: [rspec-users] What command to run all stories? In-Reply-To: <786AEE09-BE94-44E0-8E98-F51151FA799D@opensourceconnections.com> References: <3df642dd0711150856y570487b2x84903d0fcb10fd8c@mail.gmail.com> <786AEE09-BE94-44E0-8E98-F51151FA799D@opensourceconnections.com> Message-ID: <3df642dd0711151026oa24f1e2w3655200545b309b5@mail.gmail.com> Yeah, I got the stand-alone story to work. The trick was to mv stories/additions/steps to stories/steps. My stories/helper.rb looks like this: ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'spec/rails/story_adapter' Dir[File.join(File.dirname(__FILE__), "steps/*.rb")].each do |file| require file end I personally think that steps should be isolated from other stories. This seems to requre all steps in every story. all.rb is still giving me the same error. Ed On Nov 15, 2007 12:19 PM, Eric Pugh wrote: > When I copied the addition example into my test rails app, thing > worked... The "popping the cork" was the only pending action, and > was expected. I've only be able to run via ruby as well. > > Eric > > > > > On Nov 15, 2007, at 11:56 AM, Ed Howland wrote: > > > Hi, I've been following this thread and I can get the example stories > > to run with the ruby command. But I've been unable to get the example > > from http://blog.davidchelimsky.net/articles/2007/10/25/plain-text- > > stories-part-iii > > to run with all.rb > > > > > > ruby stories/all.rb > > /home/edh/story/stories/additions/steps/addition_steps.rb:2: undefined > > method `steps_for' for main:Object (NoMethodError) > > from /home/edh/story/stories/all.rb:3:in `require' > > from /home/edh/story/stories/all.rb:3 > > from /home/edh/story/stories/all.rb:2:in `each' > > from /home/edh/story/stories/all.rb:2 > > from stories/all.rb:3:in `require' > > from stories/all.rb:3 > > from stories/all.rb:2:in `each' > > from stories/all.rb:2 > > > > The examples seem older than the version on David's blog. Am I missing > > some parts from David's blog? > > > > My directory looks like: > > stories/ > > |-- additions > > | |-- adder.rb > > | |-- addition > > | |-- addition.rb > > | `-- steps > > | `-- addition_steps.rb > > |-- all.rb > > `-- helper.rb > > > > If I run the story stand-alone, I get: > > ruby stories/additions/addition.rb > > Running 2 scenarios: > > > > Story: simple addition > > > > As an accountant > > I want to add numbers > > So that I can count beans > > > > Scenario: add one plus one > > > > Given an addend of 1 (PENDING) > > And an addend of 1 (PENDING) > > > > When the addends are added (PENDING) > > > > Then the sum should be 2 (PENDING) > > And the corks should be > > popped/usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/ > > sqlite3/errors.rb:94:in > > `check': SQL logic error or missing database (SQLite3::SQLException) > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > > lib/sqlite3/resultset.rb:76:in > > `check' > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > > lib/sqlite3/resultset.rb:68:in > > `commence' > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > > lib/sqlite3/resultset.rb:61:in > > `initialize' > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > > lib/sqlite3/statement.rb:163:in > > `new' > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > > lib/sqlite3/statement.rb:163:in > > `execute' > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > > lib/sqlite3/database.rb:212:in > > `execute' > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > > lib/sqlite3/database.rb:187:in > > `prepare' > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > > lib/sqlite3/database.rb:211:in > > `execute' > > ... 13 levels... > > from /home/edh/story/vendor/plugins/rspec/lib/spec/story/ > > runner/story_runner.rb:39:in > > `each' > > from /home/edh/story/vendor/plugins/rspec/lib/spec/story/ > > runner/story_runner.rb:39:in > > `run_stories' > > from /home/edh/story/vendor/plugins/rspec/lib/spec/story/ > > runner.rb:41:in > > `register_exit_hook' > > from stories/additions/addition.rb:3 > > This last part is happening in the at_exit part of Test:Unit > > > > Also, I don't understand why the scenario's are pending. > > > > Thanks > > Ed > > > > > > > > -- > > Ed Howland > > http://greenprogrammer.blogspot.com > > "The information transmitted is intended only for the person or entity > > to which it is addressed and may contain proprietary, confidential > > and/or legally privileged material. Any review, retransmission, > > dissemination or other use of, or taking of any action in reliance > > upon, this information by persons or entities other than the intended > > recipient is prohibited. If you received this in error, please contact > > the sender and delete the material from all computers." > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > ----------------------------------------------------- > Eric Pugh | Principal | OpenSource Connections, LLC | 434.466.1467 | > http://www.opensourceconnections.com > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Ed Howland http://greenprogrammer.blogspot.com "The information transmitted is intended only for the person or entity to which it is addressed and may contain proprietary, confidential and/or legally privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers." From dchelimsky at gmail.com Thu Nov 15 13:30:03 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 15 Nov 2007 12:30:03 -0600 Subject: [rspec-users] What command to run all stories? In-Reply-To: <3df642dd0711151026oa24f1e2w3655200545b309b5@mail.gmail.com> References: <3df642dd0711150856y570487b2x84903d0fcb10fd8c@mail.gmail.com> <786AEE09-BE94-44E0-8E98-F51151FA799D@opensourceconnections.com> <3df642dd0711151026oa24f1e2w3655200545b309b5@mail.gmail.com> Message-ID: <57c63afe0711151030l3d42303fxc891a022cf55ceb5@mail.gmail.com> On Nov 15, 2007 12:26 PM, Ed Howland wrote: > Yeah, I got the stand-alone story to work. The trick was to mv > stories/additions/steps to stories/steps. My stories/helper.rb > looks like this: > > ENV["RAILS_ENV"] = "test" > require File.expand_path(File.dirname(__FILE__) + "/../config/environment") > require 'spec/rails/story_adapter' > Dir[File.join(File.dirname(__FILE__), "steps/*.rb")].each do |file| > require file > end > > I personally think that steps should be isolated from other stories. > This seems to requre all steps in every story. It requires them all but doesn't expose them all in your story. Agreed that each story should be limited in what it sees. > > all.rb is still giving me the same error. > > Ed > > > On Nov 15, 2007 12:19 PM, Eric Pugh wrote: > > When I copied the addition example into my test rails app, thing > > > worked... The "popping the cork" was the only pending action, and > > was expected. I've only be able to run via ruby as well. > > > > Eric > > > > > > > > > > On Nov 15, 2007, at 11:56 AM, Ed Howland wrote: > > > > > Hi, I've been following this thread and I can get the example stories > > > to run with the ruby command. But I've been unable to get the example > > > from http://blog.davidchelimsky.net/articles/2007/10/25/plain-text- > > > stories-part-iii > > > to run with all.rb > > > > > > > > > ruby stories/all.rb > > > /home/edh/story/stories/additions/steps/addition_steps.rb:2: undefined > > > method `steps_for' for main:Object (NoMethodError) > > > from /home/edh/story/stories/all.rb:3:in `require' > > > from /home/edh/story/stories/all.rb:3 > > > from /home/edh/story/stories/all.rb:2:in `each' > > > from /home/edh/story/stories/all.rb:2 > > > from stories/all.rb:3:in `require' > > > from stories/all.rb:3 > > > from stories/all.rb:2:in `each' > > > from stories/all.rb:2 > > > > > > The examples seem older than the version on David's blog. Am I missing > > > some parts from David's blog? > > > > > > My directory looks like: > > > stories/ > > > |-- additions > > > | |-- adder.rb > > > | |-- addition > > > | |-- addition.rb > > > | `-- steps > > > | `-- addition_steps.rb > > > |-- all.rb > > > `-- helper.rb > > > > > > If I run the story stand-alone, I get: > > > ruby stories/additions/addition.rb > > > Running 2 scenarios: > > > > > > Story: simple addition > > > > > > As an accountant > > > I want to add numbers > > > So that I can count beans > > > > > > Scenario: add one plus one > > > > > > Given an addend of 1 (PENDING) > > > And an addend of 1 (PENDING) > > > > > > When the addends are added (PENDING) > > > > > > Then the sum should be 2 (PENDING) > > > And the corks should be > > > popped/usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/ > > > sqlite3/errors.rb:94:in > > > `check': SQL logic error or missing database (SQLite3::SQLException) > > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > > > lib/sqlite3/resultset.rb:76:in > > > `check' > > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > > > lib/sqlite3/resultset.rb:68:in > > > `commence' > > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > > > lib/sqlite3/resultset.rb:61:in > > > `initialize' > > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > > > lib/sqlite3/statement.rb:163:in > > > `new' > > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > > > lib/sqlite3/statement.rb:163:in > > > `execute' > > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > > > lib/sqlite3/database.rb:212:in > > > `execute' > > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > > > lib/sqlite3/database.rb:187:in > > > `prepare' > > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ > > > lib/sqlite3/database.rb:211:in > > > `execute' > > > ... 13 levels... > > > from /home/edh/story/vendor/plugins/rspec/lib/spec/story/ > > > runner/story_runner.rb:39:in > > > `each' > > > from /home/edh/story/vendor/plugins/rspec/lib/spec/story/ > > > runner/story_runner.rb:39:in > > > `run_stories' > > > from /home/edh/story/vendor/plugins/rspec/lib/spec/story/ > > > runner.rb:41:in > > > `register_exit_hook' > > > from stories/additions/addition.rb:3 > > > This last part is happening in the at_exit part of Test:Unit > > > > > > Also, I don't understand why the scenario's are pending. > > > > > > Thanks > > > Ed > > > > > > > > > > > > -- > > > Ed Howland > > > http://greenprogrammer.blogspot.com > > > "The information transmitted is intended only for the person or entity > > > to which it is addressed and may contain proprietary, confidential > > > and/or legally privileged material. Any review, retransmission, > > > dissemination or other use of, or taking of any action in reliance > > > upon, this information by persons or entities other than the intended > > > recipient is prohibited. If you received this in error, please contact > > > the sender and delete the material from all computers." > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > ----------------------------------------------------- > > Eric Pugh | Principal | OpenSource Connections, LLC | 434.466.1467 | > > http://www.opensourceconnections.com > > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > Ed Howland > http://greenprogrammer.blogspot.com > "The information transmitted is intended only for the person or entity > to which it is addressed and may contain proprietary, confidential > and/or legally privileged material. Any review, retransmission, > dissemination or other use of, or taking of any action in reliance > upon, this information by persons or entities other than the intended > recipient is prohibited. If you received this in error, please contact > the sender and delete the material from all computers." > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From glenn at aldenta.com Thu Nov 15 13:50:34 2007 From: glenn at aldenta.com (Glenn Ford) Date: Thu, 15 Nov 2007 13:50:34 -0500 Subject: [rspec-users] Trouble using should_receive Message-ID: <177138E7-4317-46F2-BC29-EBEF12DB805E@aldenta.com> I have this code trying to ensure my reset method works. I want to make sure all the participants have their destroy method called. # in my spec for Room r = Room.new(:name => 'bob') r.save p = Participant.new(:login => 'a', :password => 'b', :password_confirmation => 'b') p.room = r p.save! p.should_receive(:destroy) r.reset #in room.rb def reset participants.each { |p| p.destroy } save! end Unfortunately it fails. I print out "p" in both locations and while they have all the same data, they have different memory addresses. I don't know if this is the explanation for the issue but it's all I can find so far. How do I fix this? Thanks! Glenn -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071115/e5bee540/attachment.html From ed.howland at gmail.com Thu Nov 15 14:00:58 2007 From: ed.howland at gmail.com (Ed Howland) Date: Thu, 15 Nov 2007 13:00:58 -0600 Subject: [rspec-users] What command to run all stories? In-Reply-To: <57c63afe0711151030l3d42303fxc891a022cf55ceb5@mail.gmail.com> References: <3df642dd0711150856y570487b2x84903d0fcb10fd8c@mail.gmail.com> <786AEE09-BE94-44E0-8E98-F51151FA799D@opensourceconnections.com> <3df642dd0711151026oa24f1e2w3655200545b309b5@mail.gmail.com> <57c63afe0711151030l3d42303fxc891a022cf55ceb5@mail.gmail.com> Message-ID: <3df642dd0711151100s1952deddh39c88864bbcb652b@mail.gmail.com> On Nov 15, 2007 12:30 PM, David Chelimsky wrote: > > ENV["RAILS_ENV"] = "test" > > require File.expand_path(File.dirname(__FILE__) + "/../config/environment") > > require 'spec/rails/story_adapter' > > Dir[File.join(File.dirname(__FILE__), "steps/*.rb")].each do |file| > > require file > > end > > > > I personally think that steps should be isolated from other stories. > > This seems to requre all steps in every story. > > It requires them all but doesn't expose them all in your story. Agreed > that each story should be limited in what it sees. David, Thanks for the info. Any directions you can point me to make : ruby stories/all.rb work? I think I am missing some require there. It is the stock one from trunk. Thanks Ed From pergesu at gmail.com Thu Nov 15 14:03:59 2007 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 15 Nov 2007 11:03:59 -0800 Subject: [rspec-users] Trouble using should_receive In-Reply-To: <177138E7-4317-46F2-BC29-EBEF12DB805E@aldenta.com> References: <177138E7-4317-46F2-BC29-EBEF12DB805E@aldenta.com> Message-ID: <810a540e0711151103l376a7965sdc9ffd1f567351c0@mail.gmail.com> On Nov 15, 2007 10:50 AM, Glenn Ford wrote: > > I have this code trying to ensure my reset method works. I want to make sure > all the participants have their destroy method called. > > # in my spec for Room r = Room.new(:name => 'bob') r.save p = > Participant.new(:login => 'a', :password => 'b', :password_confirmation => > 'b') p.room = r p.save! p.should_receive(:destroy) r.reset #in room.rb def > reset participants.each { |p| p.destroy } save! end > > Unfortunately it fails. I print out "p" in both locations and while they > have all the same data, they have different memory addresses. I don't know > if this is the explanation for the issue but it's all I can find so far. > > How do I fix this? Thanks! > > Glenn > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Hey Glenn, The problem, as you mentioned, is that the objects loaded by #participants don't include the object you created. Rails does a "SELECT * FROM participates WHERE room_id=?" and instantiates new objects. The first option is to use participants#<< instead of setting the room. So instead of p.room = r you would have r.partipants << p And then it ought to work. Alternatively, since you're actually hitting the database, you can just do lambda { r.reset }.should change(Participant, :count).by(-1) And as a side note, AR gives you #destroy_all, so instead of iterating through the participants you can just do participants.destroy_all hth Pat From glenn at aldenta.com Thu Nov 15 14:24:30 2007 From: glenn at aldenta.com (Glenn Ford) Date: Thu, 15 Nov 2007 14:24:30 -0500 Subject: [rspec-users] Trouble using should_receive In-Reply-To: <810a540e0711151103l376a7965sdc9ffd1f567351c0@mail.gmail.com> References: <177138E7-4317-46F2-BC29-EBEF12DB805E@aldenta.com> <810a540e0711151103l376a7965sdc9ffd1f567351c0@mail.gmail.com> Message-ID: On Nov 15, 2007, at 2:03 PM, Pat Maddox wrote: > On Nov 15, 2007 10:50 AM, Glenn Ford wrote: >> >> I have this code trying to ensure my reset method works. I want to >> make sure >> all the participants have their destroy method called. >> >> # in my spec for Room r = Room.new(:name => 'bob') r.save p = >> Participant.new(:login => 'a', :password => >> 'b', :password_confirmation => >> 'b') p.room = r p.save! p.should_receive(:destroy) r.reset #in >> room.rb def >> reset participants.each { |p| p.destroy } save! end >> >> Unfortunately it fails. I print out "p" in both locations and while >> they >> have all the same data, they have different memory addresses. I >> don't know >> if this is the explanation for the issue but it's all I can find so >> far. >> >> How do I fix this? Thanks! >> >> Glenn >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > Hey Glenn, > > The problem, as you mentioned, is that the objects loaded by > #participants don't include the object you created. Rails does a > "SELECT * FROM participates WHERE room_id=?" and instantiates new > objects. > > The first option is to use participants#<< instead of setting the > room. So instead of > p.room = r > > you would have > r.partipants << p > > And then it ought to work. > > Alternatively, since you're actually hitting the database, you can > just do > > lambda { r.reset }.should change(Participant, :count).by(-1) > > And as a side note, AR gives you #destroy_all, so instead of iterating > through the participants you can just do > participants.destroy_all > > hth > > Pat r.participants << p didn't do it, but the "should change" did and I like that solution best. Court3nay also suggested "r.stub! (:participants).and_return([p])" which works also. Thanks for your help, and thanks for the extra destroy_all trick too! Glenn > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ed.howland at gmail.com Thu Nov 15 14:38:33 2007 From: ed.howland at gmail.com (Ed Howland) Date: Thu, 15 Nov 2007 13:38:33 -0600 Subject: [rspec-users] Story adapter and SQLite Was:What command to run all stories? In-Reply-To: <57c63afe0711151022r2b8a5d83n5c8461cdcc2b163f@mail.gmail.com> References: <3df642dd0711150958g35a3c4aew28a101c3c155d2ed@mail.gmail.com> <57c63afe0711151022r2b8a5d83n5c8461cdcc2b163f@mail.gmail.com> Message-ID: <3df642dd0711151138x6d30c455t303fe301d0969bc1@mail.gmail.com> On Nov 15, 2007 12:22 PM, David Chelimsky wrote: > On Nov 15, 2007 11:58 AM, Ed Howland wrote: > > Hi, by switching to MySQL from SQLite, it fixed the problem. I ran > > rdebug on it and it is trying to call > > I ActiveRecord::Base.connection.begin_db_transaction. from > > ActiveRecordSafetyListener.scenario_started. I don't think SQLLite > > likes transactions. > > Why is this example engaging any sort of database? It shouldn't need to. No db is used. I don't know why ActiveRecordSafetyListener is registered. > > > > > > Ed > > > > On Nov 15, 2007 10:56 AM, Ed Howland wrote: > > > If I run the story stand-alone, I get: > > > ruby stories/additions/addition.rb > > > Running 2 scenarios: > > > > > > Story: simple addition > > > > > > As an accountant > > > I want to add numbers > > > So that I can count beans > > > > > > Scenario: add one plus one > > > > > > Given an addend of 1 (PENDING) > > > And an addend of 1 (PENDING) > > > > > > When the addends are added (PENDING) > > > > > > Then the sum should be 2 (PENDING) > > > And the corks should be > > > popped/usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/errors.rb:94:in > > > `check': SQL logic error or missing database (SQLite3::SQLException) > > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/resultset.rb:76:in > > > `check' > > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/resultset.rb:68:in > > > `commence' > > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/resultset.rb:61:in > > > `initialize' > > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/statement.rb:163:in > > > `new' > > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/statement.rb:163:in > > > `execute' > > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/database.rb:212:in > > > `execute' > > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/database.rb:187:in > > > `prepare' > > > from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/database.rb:211:in > > > `execute' > > > ... 13 levels... > > > from /home/edh/story/vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:39:in > > > `each' > > > from /home/edh/story/vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb:39:in > > > `run_stories' > > > from /home/edh/story/vendor/plugins/rspec/lib/spec/story/runner.rb:41:in > > > `register_exit_hook' > > > from stories/additions/addition.rb:3 > > > This last part is happening in the at_exit part of Test:Unit > > > > > > Also, I don't understand why the scenario's are pending. > > > > > > Thanks > > > Ed > > > > > > > > > > > > -- > > > Ed Howland > > > http://greenprogrammer.blogspot.com > > > "The information transmitted is intended only for the person or entity > > > to which it is addressed and may contain proprietary, confidential > > > and/or legally privileged material. Any review, retransmission, > > > dissemination or other use of, or taking of any action in reliance > > > upon, this information by persons or entities other than the intended > > > recipient is prohibited. If you received this in error, please contact > > > the sender and delete the material from all computers." > > > > > > > > > > > -- > > Ed Howland > > http://greenprogrammer.blogspot.com > > "The information transmitted is intended only for the person or entity > > to which it is addressed and may contain proprietary, confidential > > and/or legally privileged material. Any review, retransmission, > > dissemination or other use of, or taking of any action in reliance > > upon, this information by persons or entities other than the intended > > recipient is prohibited. If you received this in error, please contact > > the sender and delete the material from all computers." > > _______________________________________________ > > 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 > -- Ed Howland http://greenprogrammer.blogspot.com "The information transmitted is intended only for the person or entity to which it is addressed and may contain proprietary, confidential and/or legally privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers." From tastapod at gmail.com Thu Nov 15 15:04:24 2007 From: tastapod at gmail.com (Dan North) Date: Thu, 15 Nov 2007 20:04:24 +0000 Subject: [rspec-users] Plain Text Stories Chaining Scenarios In-Reply-To: References: Message-ID: Hi Nathan. You can reuse a scenario as a given in another scenario: Scenario "passing go" Given "I am not in jail" When "I pass go" Then "I collect $200" Scenario "landing on someone's hotel after passing go" * GivenScenario* "passing go" *# matches the scenario name* When "I land on someone's hotel" Then "I receive the $200 before I have to pay out for the hotel" For the second scenario, the story runner reruns the whole first scenario and keeps the same object instance for running the remaining steps. This means that any state you set up (@variables, mixins, etc.) are available for the other steps. It's useful for incrementally building up something like a workflow or a state engine. Cheers, Dan On Nov 15, 2007 3:01 AM, Nathan Sutton wrote: > I'm writing a plain text story (testing the waters) and I have > scenarios that I need to chain in my specs. > > Here is what I have so far: > > Story: User purchasing tshirts > As a user > I want to checkout > So that I can purchase shirts > > Scenario: User goes to checkout with nothing in cart > Given a user > And user has an empty cart > When user goes to checkout > Then user should see the page: site index > And page should include the text: you have nothing in your cart > > Scenario: Logged-in user goes to checkout > Given a logged-in user > And user has a cart with items in it > When user goes to checkout > Then user should see the page: address entry > > Scenario: Anonymous user goes to checkout > Given an anonymous user > And user has a cart with items in it > When user goes to checkout > Then user should see the who are you page > > Scenario: Anonymous user continues as guest from 'who are you' page > Given an anonymous user > And user has a cart with items in it > And user is at the page: who are you > When user continues as a guest > Then user should see the page: address entry > And page should include the text: guest > > Scenario: Anonymous user decides to sign-up at 'who are you' page > Given an anonymous user > And user has a cart with items in it > And user is at the page: who are you > When user goes to sign-up > Then user should see the page: sign-up > > Scenario: Registered user decides to login at 'who are you' page > Given an anonymous user > And user has a cart with items in it > > And user is at the page: who are you > When user goes to login > Then user should see the page: login > > Scenario: Registered user logs in and is returned to checkout > Given an anonymous user > And user has a cart with items in it > and user is at the page: login > When user logs in > Then user should see the page: address entry > > Scenario: Anonymous user signs-up and is returned to checkout > Given an anonymous user > And user has a cart with items in it > And user is at the page: sign-up > When user signs-up > Then user should see the page: address entry > > The parts that I need to chain are the last four scenarios. I want to > make sure that when they leave to signup and log in that they're > returned to the next step in checkout. How would I go about doing > this in the stories? Would that just be another given? > > Also, how do the rest look, sane? > > Thanks, > > Nate > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071115/ee4e84a8/attachment.html From dchelimsky at gmail.com Thu Nov 15 15:19:18 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 15 Nov 2007 14:19:18 -0600 Subject: [rspec-users] Plain Text Stories Chaining Scenarios In-Reply-To: References: Message-ID: <57c63afe0711151219n7fd0467bmc29e09f31456b4e2@mail.gmail.com> On Nov 15, 2007 2:04 PM, Dan North wrote: > Hi Nathan. > > You can reuse a scenario as a given in another scenario: > > Scenario "passing go" > Given "I am not in jail" > When "I pass go" > Then "I collect $200" > > Scenario "landing on someone's hotel after passing go" > GivenScenario "passing go" # matches the scenario name > When "I land on someone's hotel" > Then "I receive the $200 before I have to pay out for the hotel" > > > For the second scenario, the story runner reruns the whole first scenario > and keeps the same object instance for running the remaining steps. This > means that any state you set up (@variables, mixins, etc.) are available for > the other steps. It's useful for incrementally building up something like a > workflow or a state engine. FYI - this is not yet supported in Plain Text Stories. You can do it as Dan suggests above, but not in plain text. Just an oversight that will get addressed before the release. Cheers, David > > Cheers, > Dan > > > > On Nov 15, 2007 3:01 AM, Nathan Sutton wrote: > > I'm writing a plain text story (testing the waters) and I have > > scenarios that I need to chain in my specs. > > > > Here is what I have so far: > > > > Story: User purchasing tshirts > > As a user > > I want to checkout > > So that I can purchase shirts > > > > Scenario: User goes to checkout with nothing in cart > > Given a user > > And user has an empty cart > > When user goes to checkout > > Then user should see the page: site index > > And page should include the text: you have nothing in your cart > > > > Scenario: Logged-in user goes to checkout > > Given a logged-in user > > And user has a cart with items in it > > When user goes to checkout > > Then user should see the page: address entry > > > > Scenario: Anonymous user goes to checkout > > Given an anonymous user > > And user has a cart with items in it > > When user goes to checkout > > Then user should see the who are you page > > > > Scenario: Anonymous user continues as guest from 'who are you' page > > Given an anonymous user > > And user has a cart with items in it > > And user is at the page: who are you > > When user continues as a guest > > Then user should see the page: address entry > > And page should include the text: guest > > > > Scenario: Anonymous user decides to sign-up at 'who are you' page > > Given an anonymous user > > And user has a cart with items in it > > And user is at the page: who are you > > When user goes to sign-up > > Then user should see the page: sign-up > > > > Scenario: Registered user decides to login at 'who are you' page > > Given an anonymous user > > And user has a cart with items in it > > > > And user is at the page: who are you > > When user goes to login > > Then user should see the page: login > > > > Scenario: Registered user logs in and is returned to checkout > > Given an anonymous user > > And user has a cart with items in it > > and user is at the page: login > > When user logs in > > Then user should see the page: address entry > > > > Scenario: Anonymous user signs-up and is returned to checkout > > Given an anonymous user > > And user has a cart with items in it > > And user is at the page: sign-up > > When user signs-up > > Then user should see the page: address entry > > > > The parts that I need to chain are the last four scenarios. I want to > > make sure that when they leave to signup and log in that they're > > returned to the next step in checkout. How would I go about doing > > this in the stories? Would that just be another given? > > > > Also, how do the rest look, sane? > > > > Thanks, > > > > Nate > > _______________________________________________ > > 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 nathan.sutton at gmail.com Thu Nov 15 15:07:52 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Thu, 15 Nov 2007 14:07:52 -0600 Subject: [rspec-users] Plain Text Stories Chaining Scenarios In-Reply-To: References: Message-ID: Oh yeah, Dave shared that with me last night. This is VERY cool and should be shouted about from the hilltops. It allows reusing of paths through the environment when it forks at steps. I love it. Thanks, Nate On Nov 15, 2007, at 2:04 PM, Dan North wrote: > Hi Nathan. > > You can reuse a scenario as a given in another scenario: > > Scenario "passing go" > Given "I am not in jail" > When "I pass go" > Then "I collect $200" > > Scenario "landing on someone's hotel after passing go" > GivenScenario "passing go" # matches the scenario name > When "I land on someone's hotel" > Then "I receive the $200 before I have to pay out for the hotel" > > > For the second scenario, the story runner reruns the whole first > scenario and keeps the same object instance for running the > remaining steps. This means that any state you set up (@variables, > mixins, etc.) are available for the other steps. It's useful for > incrementally building up something like a workflow or a state engine. > > Cheers, > Dan > > On Nov 15, 2007 3:01 AM, Nathan Sutton wrote: > I'm writing a plain text story (testing the waters) and I have > scenarios that I need to chain in my specs. > > Here is what I have so far: > > Story: User purchasing tshirts > As a user > I want to checkout > So that I can purchase shirts > > Scenario: User goes to checkout with nothing in cart > Given a user > And user has an empty cart > When user goes to checkout > Then user should see the page: site index > And page should include the text: you have nothing in your cart > > Scenario: Logged-in user goes to checkout > Given a logged-in user > And user has a cart with items in it > When user goes to checkout > Then user should see the page: address entry > > Scenario: Anonymous user goes to checkout > Given an anonymous user > And user has a cart with items in it > When user goes to checkout > Then user should see the who are you page > > Scenario: Anonymous user continues as guest from 'who are you' page > Given an anonymous user > And user has a cart with items in it > And user is at the page: who are you > When user continues as a guest > Then user should see the page: address entry > And page should include the text: guest > > Scenario: Anonymous user decides to sign-up at 'who are you' page > Given an anonymous user > And user has a cart with items in it > And user is at the page: who are you > When user goes to sign-up > Then user should see the page: sign-up > > Scenario: Registered user decides to login at 'who are you' page > Given an anonymous user > And user has a cart with items in it > > And user is at the page: who are you > When user goes to login > Then user should see the page: login > > Scenario: Registered user logs in and is returned to checkout > Given an anonymous user > And user has a cart with items in it > and user is at the page: login > When user logs in > Then user should see the page: address entry > > Scenario: Anonymous user signs-up and is returned to checkout > Given an anonymous user > And user has a cart with items in it > And user is at the page: sign-up > When user signs-up > Then user should see the page: address entry > > The parts that I need to chain are the last four scenarios. I want to > make sure that when they leave to signup and log in that they're > returned to the next step in checkout. How would I go about doing > this in the stories? Would that just be another given? > > Also, how do the rest look, sane? > > Thanks, > > Nate > _______________________________________________ > 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: http://rubyforge.org/pipermail/rspec-users/attachments/20071115/2c64d34f/attachment-0001.html From barjunk at attglobal.net Thu Nov 15 17:46:51 2007 From: barjunk at attglobal.net (barsalou) Date: Thu, 15 Nov 2007 13:46:51 -0900 Subject: [rspec-users] MissingSourceFile spec/rails/story_adapter.rb Message-ID: <20071115134651.bpt8l8x40gw8g8ss@lcgalaska.com> I can see that the file story_adapter.rb isn't where it is supposed to be, however, I don't know where it comes from in the first place. Can someone give me a hint here? I installed using: ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec_on_rails The above is all on one line. This is a new machine I'm building out...rspec hasn't yet worked on this machine. Ruby 1.8.4, rails 1.2.5 Thanks for any direction. Mike B. ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. From dchelimsky at gmail.com Thu Nov 15 17:48:13 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 15 Nov 2007 16:48:13 -0600 Subject: [rspec-users] MissingSourceFile spec/rails/story_adapter.rb In-Reply-To: <20071115134651.bpt8l8x40gw8g8ss@lcgalaska.com> References: <20071115134651.bpt8l8x40gw8g8ss@lcgalaska.com> Message-ID: <57c63afe0711151448x6a64657fv9176c39cb7154863@mail.gmail.com> CURRENT is the 1.0.8 release. Try getting the trunk instead: http://rspec.rubyforge.org/documentation/rails/install.html Cheers, David On Nov 15, 2007 4:46 PM, barsalou wrote: > I can see that the file story_adapter.rb isn't where it is supposed to > be, however, I don't know where it comes from in the first place. > > Can someone give me a hint here? > > I installed using: > > > ruby script/plugin install > svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec > > ruby script/plugin install > svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec_on_rails > > The above is all on one line. > > This is a new machine I'm building out...rspec hasn't yet worked on > this machine. > > Ruby 1.8.4, rails 1.2.5 > > Thanks for any direction. > > Mike B. > > ---------------------------------------------------------------- > This message was sent using IMP, the Internet Messaging Program. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From fowlduck at gmail.com Thu Nov 15 17:22:55 2007 From: fowlduck at gmail.com (Nathan Sutton) Date: Thu, 15 Nov 2007 16:22:55 -0600 Subject: [rspec-users] How to Run Rails Stories Message-ID: <63707D63-B5D9-4AD0-91D7-42F0037E21B9@gmail.com> I have non non-plain-text story without any steps_for, can it be run? If so, how? Thanks, Nate From dchelimsky at gmail.com Thu Nov 15 18:57:24 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 15 Nov 2007 17:57:24 -0600 Subject: [rspec-users] How to Run Rails Stories In-Reply-To: <63707D63-B5D9-4AD0-91D7-42F0037E21B9@gmail.com> References: <63707D63-B5D9-4AD0-91D7-42F0037E21B9@gmail.com> Message-ID: <57c63afe0711151557w66c35accg20bece99b01e61e6@mail.gmail.com> On Nov 15, 2007 4:22 PM, Nathan Sutton wrote: > I have non non-plain-text story without any steps_for, can it be run? > If so, how? ruby path/to/my/story.rb From fowlduck at gmail.com Thu Nov 15 19:02:39 2007 From: fowlduck at gmail.com (Nathan Sutton) Date: Thu, 15 Nov 2007 18:02:39 -0600 Subject: [rspec-users] How to Run Rails Stories In-Reply-To: <57c63afe0711151557w66c35accg20bece99b01e61e6@mail.gmail.com> References: <63707D63-B5D9-4AD0-91D7-42F0037E21B9@gmail.com> <57c63afe0711151557w66c35accg20bece99b01e61e6@mail.gmail.com> Message-ID: <0DF37494-F15E-4406-B80B-7F0982FCE96E@gmail.com> I was trying to run it from all.rb, but having no luck. I can run them individually. Nathan Sutton fowlduck at gmail.com rspec edge revision 2894 rspec_on_rails edge revision 2894 rails edge revision 8146 On Nov 15, 2007, at 5:57 PM, David Chelimsky wrote: > On Nov 15, 2007 4:22 PM, Nathan Sutton wrote: >> I have non non-plain-text story without any steps_for, can it be run? >> If so, how? > > ruby path/to/my/story.rb > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Thu Nov 15 19:05:10 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 15 Nov 2007 18:05:10 -0600 Subject: [rspec-users] How to Run Rails Stories In-Reply-To: <0DF37494-F15E-4406-B80B-7F0982FCE96E@gmail.com> References: <63707D63-B5D9-4AD0-91D7-42F0037E21B9@gmail.com> <57c63afe0711151557w66c35accg20bece99b01e61e6@mail.gmail.com> <0DF37494-F15E-4406-B80B-7F0982FCE96E@gmail.com> Message-ID: <57c63afe0711151605j7a57f6c5u81e9c6b0aa31043@mail.gmail.com> On Nov 15, 2007 6:02 PM, Nathan Sutton wrote: > I was trying to run it from all.rb, but having no luck. I can run > them individually. You should be able to just require them from all.rb and run `ruby all.rb`. > > Nathan Sutton > fowlduck at gmail.com > rspec edge revision 2894 > rspec_on_rails edge revision 2894 > rails edge revision 8146 > > > > > > On Nov 15, 2007, at 5:57 PM, David Chelimsky wrote: > > > On Nov 15, 2007 4:22 PM, Nathan Sutton wrote: > >> I have non non-plain-text story without any steps_for, can it be run? > >> If so, how? > > > > ruby path/to/my/story.rb > > > _______________________________________________ > > 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 fowlduck at gmail.com Thu Nov 15 20:17:05 2007 From: fowlduck at gmail.com (Nathan Sutton) Date: Thu, 15 Nov 2007 19:17:05 -0600 Subject: [rspec-users] Plain Text Stories Chaining Scenarios In-Reply-To: References: Message-ID: You mentioned on your blog when talking about stories: http://dannorth.net/whats-in-a-story That you can chain events like this: Scenario Given When Then When Then When Then etc... Is this possible in rspec? Nathan Sutton fowlduck at gmail.com rspec edge revision 2894 rspec_on_rails edge revision 2894 rails edge revision 8146 On Nov 15, 2007, at 2:04 PM, Dan North wrote: > Hi Nathan. > > You can reuse a scenario as a given in another scenario: > > Scenario "passing go" > Given "I am not in jail" > When "I pass go" > Then "I collect $200" > > Scenario "landing on someone's hotel after passing go" > GivenScenario "passing go" # matches the scenario name > When "I land on someone's hotel" > Then "I receive the $200 before I have to pay out for the hotel" > > > For the second scenario, the story runner reruns the whole first > scenario and keeps the same object instance for running the > remaining steps. This means that any state you set up (@variables, > mixins, etc.) are available for the other steps. It's useful for > incrementally building up something like a workflow or a state engine. > > Cheers, > Dan > > On Nov 15, 2007 3:01 AM, Nathan Sutton wrote: > I'm writing a plain text story (testing the waters) and I have > scenarios that I need to chain in my specs. > > Here is what I have so far: > > Story: User purchasing tshirts > As a user > I want to checkout > So that I can purchase shirts > > Scenario: User goes to checkout with nothing in cart > Given a user > And user has an empty cart > When user goes to checkout > Then user should see the page: site index > And page should include the text: you have nothing in your cart > > Scenario: Logged-in user goes to checkout > Given a logged-in user > And user has a cart with items in it > When user goes to checkout > Then user should see the page: address entry > > Scenario: Anonymous user goes to checkout > Given an anonymous user > And user has a cart with items in it > When user goes to checkout > Then user should see the who are you page > > Scenario: Anonymous user continues as guest from 'who are you' page > Given an anonymous user > And user has a cart with items in it > And user is at the page: who are you > When user continues as a guest > Then user should see the page: address entry > And page should include the text: guest > > Scenario: Anonymous user decides to sign-up at 'who are you' page > Given an anonymous user > And user has a cart with items in it > And user is at the page: who are you > When user goes to sign-up > Then user should see the page: sign-up > > Scenario: Registered user decides to login at 'who are you' page > Given an anonymous user > And user has a cart with items in it > > And user is at the page: who are you > When user goes to login > Then user should see the page: login > > Scenario: Registered user logs in and is returned to checkout > Given an anonymous user > And user has a cart with items in it > and user is at the page: login > When user logs in > Then user should see the page: address entry > > Scenario: Anonymous user signs-up and is returned to checkout > Given an anonymous user > And user has a cart with items in it > And user is at the page: sign-up > When user signs-up > Then user should see the page: address entry > > The parts that I need to chain are the last four scenarios. I want to > make sure that when they leave to signup and log in that they're > returned to the next step in checkout. How would I go about doing > this in the stories? Would that just be another given? > > Also, how do the rest look, sane? > > Thanks, > > Nate > _______________________________________________ > 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: http://rubyforge.org/pipermail/rspec-users/attachments/20071115/1ae43cea/attachment.html From dchelimsky at gmail.com Fri Nov 16 02:03:22 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 16 Nov 2007 01:03:22 -0600 Subject: [rspec-users] Plain Text Stories Chaining Scenarios In-Reply-To: References: Message-ID: <57c63afe0711152303n78679990r2b2a23eb5ed9560c@mail.gmail.com> On Nov 15, 2007 7:17 PM, Nathan Sutton wrote: > > You mentioned on your blog when talking about stories: > http://dannorth.net/whats-in-a-story > > That you can chain events like this: > Scenario > Given > When > Then > When > Then > When > Then > etc... > > Is this possible in rspec? Totally! > > > Nathan Sutton > fowlduck at gmail.com > rspec edge revision 2894 > rspec_on_rails edge revision 2894 > rails edge revision 8146 > > > > > > On Nov 15, 2007, at 2:04 PM, Dan North wrote: > > > Hi Nathan. > > You can reuse a scenario as a given in another scenario: > > Scenario "passing go" > Given "I am not in jail" > When "I pass go" > Then "I collect $200" > > Scenario "landing on someone's hotel after passing go" > GivenScenario "passing go" # matches the scenario name > When "I land on someone's hotel" > Then "I receive the $200 before I have to pay out for the hotel" > > > For the second scenario, the story runner reruns the whole first scenario > and keeps the same object instance for running the remaining steps. This > means that any state you set up (@variables, mixins, etc.) are available for > the other steps. It's useful for incrementally building up something like a > workflow or a state engine. > > Cheers, > Dan > > On Nov 15, 2007 3:01 AM, Nathan Sutton wrote: > > I'm writing a plain text story (testing the waters) and I have > > scenarios that I need to chain in my specs. > > > > Here is what I have so far: > > > > Story: User purchasing tshirts > > As a user > > I want to checkout > > So that I can purchase shirts > > > > Scenario: User goes to checkout with nothing in cart > > Given a user > > And user has an empty cart > > When user goes to checkout > > Then user should see the page: site index > > And page should include the text: you have nothing in your cart > > > > Scenario: Logged-in user goes to checkout > > Given a logged-in user > > And user has a cart with items in it > > When user goes to checkout > > Then user should see the page: address entry > > > > Scenario: Anonymous user goes to checkout > > Given an anonymous user > > And user has a cart with items in it > > When user goes to checkout > > Then user should see the who are you page > > > > Scenario: Anonymous user continues as guest from 'who are you' page > > Given an anonymous user > > And user has a cart with items in it > > And user is at the page: who are you > > When user continues as a guest > > Then user should see the page: address entry > > And page should include the text: guest > > > > Scenario: Anonymous user decides to sign-up at 'who are you' page > > Given an anonymous user > > And user has a cart with items in it > > And user is at the page: who are you > > When user goes to sign-up > > Then user should see the page: sign-up > > > > Scenario: Registered user decides to login at 'who are you' page > > Given an anonymous user > > And user has a cart with items in it > > > > And user is at the page: who are you > > When user goes to login > > Then user should see the page: login > > > > Scenario: Registered user logs in and is returned to checkout > > Given an anonymous user > > And user has a cart with items in it > > and user is at the page: login > > When user logs in > > Then user should see the page: address entry > > > > Scenario: Anonymous user signs-up and is returned to checkout > > Given an anonymous user > > And user has a cart with items in it > > And user is at the page: sign-up > > When user signs-up > > Then user should see the page: address entry > > > > The parts that I need to chain are the last four scenarios. I want to > > make sure that when they leave to signup and log in that they're > > returned to the next step in checkout. How would I go about doing > > this in the stories? Would that just be another given? > > > > Also, how do the rest look, sane? > > > > Thanks, > > > > Nate > > _______________________________________________ > > 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 nathan.sutton at gmail.com Fri Nov 16 02:06:25 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Fri, 16 Nov 2007 01:06:25 -0600 Subject: [rspec-users] Plain Text Stories Chaining Scenarios In-Reply-To: <57c63afe0711152303n78679990r2b2a23eb5ed9560c@mail.gmail.com> References: <57c63afe0711152303n78679990r2b2a23eb5ed9560c@mail.gmail.com> Message-ID: <8DAF8347-9A23-4049-952D-CCC33569C497@gmail.com> Very very cool. So while GivenScenario is useful for chaining scenarios, if you want to spec out a process you can also do it this way. Very cool. Nathan Sutton fowlduck at gmail.com rspec edge revision 2894 rspec_on_rails edge revision 2894 rails edge revision 8146 On Nov 16, 2007, at 1:03 AM, David Chelimsky wrote: > On Nov 15, 2007 7:17 PM, Nathan Sutton wrote: >> >> You mentioned on your blog when talking about stories: >> http://dannorth.net/whats-in-a-story >> >> That you can chain events like this: >> Scenario >> Given >> When >> Then >> When >> Then >> When >> Then >> etc... >> >> Is this possible in rspec? > > Totally! > >> >> >> Nathan Sutton >> fowlduck at gmail.com >> rspec edge revision 2894 >> rspec_on_rails edge revision 2894 >> rails edge revision 8146 >> >> >> >> >> >> On Nov 15, 2007, at 2:04 PM, Dan North wrote: >> >> >> Hi Nathan. >> >> You can reuse a scenario as a given in another scenario: >> >> Scenario "passing go" >> Given "I am not in jail" >> When "I pass go" >> Then "I collect $200" >> >> Scenario "landing on someone's hotel after passing go" >> GivenScenario "passing go" # matches the scenario name >> When "I land on someone's hotel" >> Then "I receive the $200 before I have to pay out for the hotel" >> >> >> For the second scenario, the story runner reruns the whole first >> scenario >> and keeps the same object instance for running the remaining steps. >> This >> means that any state you set up (@variables, mixins, etc.) are >> available for >> the other steps. It's useful for incrementally building up >> something like a >> workflow or a state engine. >> >> Cheers, >> Dan >> >> On Nov 15, 2007 3:01 AM, Nathan Sutton wrote: >>> I'm writing a plain text story (testing the waters) and I have >>> scenarios that I need to chain in my specs. >>> >>> Here is what I have so far: >>> >>> Story: User purchasing tshirts >>> As a user >>> I want to checkout >>> So that I can purchase shirts >>> >>> Scenario: User goes to checkout with nothing in cart >>> Given a user >>> And user has an empty cart >>> When user goes to checkout >>> Then user should see the page: site index >>> And page should include the text: you have nothing in your cart >>> >>> Scenario: Logged-in user goes to checkout >>> Given a logged-in user >>> And user has a cart with items in it >>> When user goes to checkout >>> Then user should see the page: address entry >>> >>> Scenario: Anonymous user goes to checkout >>> Given an anonymous user >>> And user has a cart with items in it >>> When user goes to checkout >>> Then user should see the who are you page >>> >>> Scenario: Anonymous user continues as guest from 'who are you' page >>> Given an anonymous user >>> And user has a cart with items in it >>> And user is at the page: who are you >>> When user continues as a guest >>> Then user should see the page: address entry >>> And page should include the text: guest >>> >>> Scenario: Anonymous user decides to sign-up at 'who are you' page >>> Given an anonymous user >>> And user has a cart with items in it >>> And user is at the page: who are you >>> When user goes to sign-up >>> Then user should see the page: sign-up >>> >>> Scenario: Registered user decides to login at 'who are you' page >>> Given an anonymous user >>> And user has a cart with items in it >>> >>> And user is at the page: who are you >>> When user goes to login >>> Then user should see the page: login >>> >>> Scenario: Registered user logs in and is returned to checkout >>> Given an anonymous user >>> And user has a cart with items in it >>> and user is at the page: login >>> When user logs in >>> Then user should see the page: address entry >>> >>> Scenario: Anonymous user signs-up and is returned to checkout >>> Given an anonymous user >>> And user has a cart with items in it >>> And user is at the page: sign-up >>> When user signs-up >>> Then user should see the page: address entry >>> >>> The parts that I need to chain are the last four scenarios. I >>> want to >>> make sure that when they leave to signup and log in that they're >>> returned to the next step in checkout. How would I go about doing >>> this in the stories? Would that just be another given? >>> >>> Also, how do the rest look, sane? >>> >>> Thanks, >>> >>> Nate >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From joshknowles at gmail.com Fri Nov 16 12:03:07 2007 From: joshknowles at gmail.com (Josh Knowles) Date: Fri, 16 Nov 2007 12:03:07 -0500 Subject: [rspec-users] rails story runner returning a nil response code In-Reply-To: <57c63afe0711131417v10bc03a5h751f1c2fd2ecf2e1@mail.gmail.com> References: <57c63afe0711131243r5017bcacma424c08841d0d37e@mail.gmail.com> <57c63afe0711131357u37a8493el4966cbdcdbd10338@mail.gmail.com> <57c63afe0711131417v10bc03a5h751f1c2fd2ecf2e1@mail.gmail.com> Message-ID: On 11/13/07, David Chelimsky wrote: > That would be awesome. Take a look at how it's done in the spec/dsl > dir. There's a file that monkey patches AR::Base so the default > behaviour is that you'll see the failures, but if you decide to > override rescue_action on your own, you get that instead. So I've taken a first stab at this, but keep running into stack-level too deep problems. Not sure if its the project I'm testing this on or something to do with the way that integration tests are run. Either way I'm going to bring up a fresh environment over the weekend and give it another shot. -- Josh Knowles phone: 509-979-1593 email: joshknowles at gmail.com web: http://joshknowles.com From barjunk at attglobal.net Fri Nov 16 12:42:57 2007 From: barjunk at attglobal.net (barsalou) Date: Fri, 16 Nov 2007 08:42:57 -0900 Subject: [rspec-users] MissingSourceFile spec/rails/story_adapter.rb In-Reply-To: References: Message-ID: <20071116084257.jneomsatc0g0o8wg@lcgalaska.com> Quoting rspec-users-request at rubyforge.org: > I can see that the file story_adapter.rb isn't where it is supposed to > be, however, I don't know where it comes from in the first place. > > Can someone give me a hint here? > > I installed using: > > > ruby script/plugin install > svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec > > ruby script/plugin install > svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec_on_rails > > The above is all on one line. > > > CURRENT is the 1.0.8 release. > > Try getting the trunk instead: > > http://rspec.rubyforge.org/documentation/rails/install.html > And of course this works as you'd expect, DOH! :) Thanks David. Mike B. ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. From madcowley at gmail.com Fri Nov 16 16:14:36 2007 From: madcowley at gmail.com (Matt Cowley) Date: Fri, 16 Nov 2007 16:14:36 -0500 Subject: [rspec-users] problem with scope_out Message-ID: Hi folks, I've got a plugin question: recently started using scope_out, which I dig. It broke my specs, though -- now I get an "undefined method scope_out" error when running specs. I can run script/console and use the scope_out calls with no problem. Anything special I need to do to include the scope_out code in the rspec world? I've tried including the lib file in my spec file, but that didn't seem to help. Thanks much matt From mlangenberg at gmail.com Sat Nov 17 16:19:31 2007 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Sat, 17 Nov 2007 22:19:31 +0100 Subject: [rspec-users] Using RSpec to drive the design of a GUI desktop application Message-ID: <27c0ac6d0711171319p11e81a8dn92ff4530ac5b4360@mail.gmail.com> Hello everybody, I've been using RSpec as a tool to create web applications for some time now, in Rails, and using plain Ruby with WEBrick as well. The tool suits my needs and the story runner is great. Now there are things that aren't solvable on the web, you'll need a _real_ desktop application for those problems. So I've toyed a bit around with various GUI libraries as wxRuby and RubyCocoa, to get a feeling on how these libraries work and I love to create native OS X applications using cocoa. Of course, the next question that arose in my head was:"How do I drive the design of an application using a BDD framework like RSpec?". When writing a web application, it is relatively easy to simulate a HTTP request to the app and crawl through the returned HTML, but for a desktop application it's different, right? The format (html) handled between the application, and the toolkit drawing the actual screen isn't that open for a desktop application as it is for a web application. So, since we don't want to test the inner workings of the gui toolkit and we only want to specify the behaviour of the code we write self, we must plug a framework somewhere, to capture the actual calls to this toolkit to know if our code is doing the right thing. At least, that's how I see it currently. But how could that be done? Regards, Matthijs Langenberg -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071117/412ed0e7/attachment.html From michael.s.klishin.lists at gmail.com Sat Nov 17 16:31:26 2007 From: michael.s.klishin.lists at gmail.com (Michael Klishin) Date: Sat, 17 Nov 2007 23:31:26 +0200 Subject: [rspec-users] spec.opts default --load-by and observers Message-ID: <85D75318-31BE-4C15-89A4-DE58AA01B729@gmail.com> When specing observers I usually put them into models directory under / spec. Then, when specs are run observer class can't be found unless I remove --load-by mtime from spec.opts. My question is what's the Big Idea behind loading specs in that order by default? Shouldn't default spec.opts contain just formatting options? Because as you see it DOES cause problems and though it's ok for me, some RSpec users may be pissed off after first trial of testing observers with RSpec. WDYT, David, Aslak, others? MK From znmeb at cesmail.net Sat Nov 17 16:51:18 2007 From: znmeb at cesmail.net (M. Edward (Ed) Borasky) Date: Sat, 17 Nov 2007 13:51:18 -0800 Subject: [rspec-users] Using RSpec to drive the design of a GUI desktop application In-Reply-To: <27c0ac6d0711171319p11e81a8dn92ff4530ac5b4360@mail.gmail.com> References: <27c0ac6d0711171319p11e81a8dn92ff4530ac5b4360@mail.gmail.com> Message-ID: <473F6256.4000806@cesmail.net> Matthijs Langenberg wrote: > Hello everybody, > > I've been using RSpec as a tool to create web applications for some time > now, in Rails, and using plain Ruby with WEBrick as well. The tool suits > my needs and the story runner is great. > Now there are things that aren't solvable on the web, you'll need a > _real_ desktop application for those problems. Well ... given a large enough monitor and a minimal set of toolbars and menus on your browser, I'm not convinced there's much of a difference between a "desktop" application and a "web" application from the point of view of a user sitting at a KVM portal. Of course, there is over a decade of convergence between the two user interfaces, so that's not a great surprise. What do you think you couldn't do with a browser and a web application framework/database running on the same machine as the browser and contacted via "localhost"? From lists at ruby-forum.com Sat Nov 17 18:40:33 2007 From: lists at ruby-forum.com (Steven Garcia) Date: Sun, 18 Nov 2007 00:40:33 +0100 Subject: [rspec-users] Down with Lambda!! Message-ID: <0444c73bc10306af8bedd5da057c7c9c@ruby-forum.com> Rspec is all about using natural language to define behavior. In this context, I feel that lambda is sorely out of place. I was chatting on #irc and a pal of mine (wycats) proposed an interesting alternative: alias_method :doing, :lambda so instead of something like lambda {post :create, {:title => nil}}.should raise_error(ActiveRecord::RecordInvalid) we get doing {post :create, {:title => nil}}.should raise_error(ActiveRecord::RecordInvalid) Now it reads like a sentence..much cleaner and less abstract to those of us who are not Ruby wizards (yet) Chatting with other folks and they are hyped on the idea. What do you guys think? Any chance we could get something like this into trunk? -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Sat Nov 17 18:59:51 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 18 Nov 2007 00:59:51 +0100 Subject: [rspec-users] Down with Lambda!! In-Reply-To: <0444c73bc10306af8bedd5da057c7c9c@ruby-forum.com> References: <0444c73bc10306af8bedd5da057c7c9c@ruby-forum.com> Message-ID: <8d961d900711171559p3c72d260gb116165d7073853c@mail.gmail.com> On Nov 18, 2007 12:40 AM, Steven Garcia wrote: > Rspec is all about using natural language to define behavior. In this > context, I feel that lambda is sorely out of place. I was chatting on > #irc and a pal of mine (wycats) proposed an interesting alternative: > > alias_method :doing, :lambda > > so instead of something like > > lambda {post :create, {:title => nil}}.should > raise_error(ActiveRecord::RecordInvalid) > > we get > > doing {post :create, {:title => nil}}.should > raise_error(ActiveRecord::RecordInvalid) > > Now it reads like a sentence..much cleaner and less abstract to those of > us who are not Ruby wizards (yet) > > Chatting with other folks and they are hyped on the idea. > > What do you guys think? > > Any chance we could get something like this into trunk? Probably not. There was a longer discussion of it here: http://rubyforge.org/tracker/index.php?func=detail&aid=13837&group_id=797&atid=3152 As you point out, creating an alias is a one-liner. The main reason I don't want to add it is that lambda is a common idiom, and I don't want to set precedence of aliasing core Ruby idioms just because some people don't like the ones in Ruby. Aslak > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sat Nov 17 19:01:47 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 17 Nov 2007 18:01:47 -0600 Subject: [rspec-users] Down with Lambda!! In-Reply-To: <0444c73bc10306af8bedd5da057c7c9c@ruby-forum.com> References: <0444c73bc10306af8bedd5da057c7c9c@ruby-forum.com> Message-ID: <57c63afe0711171601v552a8d57m43643c6f3e6e7e3c@mail.gmail.com> On Nov 17, 2007 5:40 PM, Steven Garcia wrote: > Rspec is all about using natural language to define behavior. In this > context, I feel that lambda is sorely out of place. I was chatting on > #irc and a pal of mine (wycats) proposed an interesting alternative: > > alias_method :doing, :lambda > > so instead of something like > > lambda {post :create, {:title => nil}}.should > raise_error(ActiveRecord::RecordInvalid) > > we get > > doing {post :create, {:title => nil}}.should > raise_error(ActiveRecord::RecordInvalid) > > Now it reads like a sentence..much cleaner and less abstract to those of > us who are not Ruby wizards (yet) > > Chatting with other folks and they are hyped on the idea. > > What do you guys think? > > Any chance we could get something like this into trunk? We've been through this a few times on this list. There's a fundamental difference between replacing "assert_equal" with "should equal" and replacing lambda with anything at all. assert_equal is a method that a Ruby programmer wrote into a library. lambda is part of the Ruby language. We're still writing Ruby here, aren't we? Of course, you're free to alias whatever you like in your own projects. We're still writing Ruby here, aren't we!!! Cheers, David > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sat Nov 17 19:02:18 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 17 Nov 2007 18:02:18 -0600 Subject: [rspec-users] Down with Lambda!! In-Reply-To: <8d961d900711171559p3c72d260gb116165d7073853c@mail.gmail.com> References: <0444c73bc10306af8bedd5da057c7c9c@ruby-forum.com> <8d961d900711171559p3c72d260gb116165d7073853c@mail.gmail.com> Message-ID: <57c63afe0711171602s2a6142act7c924139315353bd@mail.gmail.com> On Nov 17, 2007 5:59 PM, aslak hellesoy wrote: > On Nov 18, 2007 12:40 AM, Steven Garcia wrote: > > Rspec is all about using natural language to define behavior. In this > > context, I feel that lambda is sorely out of place. I was chatting on > > #irc and a pal of mine (wycats) proposed an interesting alternative: > > > > alias_method :doing, :lambda > > > > so instead of something like > > > > lambda {post :create, {:title => nil}}.should > > raise_error(ActiveRecord::RecordInvalid) > > > > we get > > > > doing {post :create, {:title => nil}}.should > > raise_error(ActiveRecord::RecordInvalid) > > > > Now it reads like a sentence..much cleaner and less abstract to those of > > us who are not Ruby wizards (yet) > > > > Chatting with other folks and they are hyped on the idea. > > > > What do you guys think? > > > > Any chance we could get something like this into trunk? > > Probably not. There was a longer discussion of it here: > http://rubyforge.org/tracker/index.php?func=detail&aid=13837&group_id=797&atid=3152 > > As you point out, creating an alias is a one-liner. > The main reason I don't want to add it is that lambda is a common > idiom, and I don't want to set precedence of aliasing core Ruby idioms > just because some people don't like the ones in Ruby. +1 David > > Aslak > > > -- > > > Posted via http://www.ruby-forum.com/. > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mlangenberg at gmail.com Sat Nov 17 19:48:31 2007 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Sun, 18 Nov 2007 01:48:31 +0100 Subject: [rspec-users] Using RSpec to drive the design of a GUI desktop application In-Reply-To: <473F6256.4000806@cesmail.net> References: <27c0ac6d0711171319p11e81a8dn92ff4530ac5b4360@mail.gmail.com> <473F6256.4000806@cesmail.net> Message-ID: <27c0ac6d0711171648y2a871c37o3af6f0f010196ac0@mail.gmail.com> Well that's just cumbersome, and actually not the point of my discussion. I rather discuss about the ways we could use RSpec to create an application based on RubyCocoa (for example), instead of discussing about what types of software can't work on the web, alright? On Nov 17, 2007 10:51 PM, M. Edward (Ed) Borasky wrote: > Matthijs Langenberg wrote: > > Hello everybody, > > > > I've been using RSpec as a tool to create web applications for some time > > now, in Rails, and using plain Ruby with WEBrick as well. The tool suits > > my needs and the story runner is great. > > Now there are things that aren't solvable on the web, you'll need a > > _real_ desktop application for those problems. > > Well ... given a large enough monitor and a minimal set of toolbars and > menus on your browser, I'm not convinced there's much of a difference > between a "desktop" application and a "web" application from the point > of view of a user sitting at a KVM portal. Of course, there is over a > decade of convergence between the two user interfaces, so that's not a > great surprise. What do you think you couldn't do with a browser and a > web application framework/database running on the same machine as the > browser and contacted via "localhost"? > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071118/0ca5ec38/attachment.html From mailing_lists at railsnewbie.com Sat Nov 17 22:49:07 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 17 Nov 2007 22:49:07 -0500 Subject: [rspec-users] Down with Lambda!! In-Reply-To: <8d961d900711171559p3c72d260gb116165d7073853c@mail.gmail.com> References: <0444c73bc10306af8bedd5da057c7c9c@ruby-forum.com> <8d961d900711171559p3c72d260gb116165d7073853c@mail.gmail.com> Message-ID: <4AAFA9B7-2FD9-49EB-A258-4D983EE9D8A6@railsnewbie.com> On Nov 17, 2007, at 6:59 PM, aslak hellesoy wrote: > On Nov 18, 2007 12:40 AM, Steven Garcia wrote: >> Rspec is all about using natural language to define behavior. In this >> context, I feel that lambda is sorely out of place. I was chatting on >> #irc and a pal of mine (wycats) proposed an interesting alternative: >> >> alias_method :doing, :lambda >> >> so instead of something like >> >> lambda {post :create, {:title => nil}}.should >> raise_error(ActiveRecord::RecordInvalid) >> >> we get >> >> doing {post :create, {:title => nil}}.should >> raise_error(ActiveRecord::RecordInvalid) >> >> Now it reads like a sentence..much cleaner and less abstract to >> those of >> us who are not Ruby wizards (yet) >> >> Chatting with other folks and they are hyped on the idea. >> >> What do you guys think? >> >> Any chance we could get something like this into trunk? > > Probably not. There was a longer discussion of it here: > http://rubyforge.org/tracker/index.php? > func=detail&aid=13837&group_id=797&atid=3152 > > As you point out, creating an alias is a one-liner. > The main reason I don't want to add it is that lambda is a common > idiom, and I don't want to set precedence of aliasing core Ruby idioms > just because some people don't like the ones in Ruby. > Couldn't agree more with the reasoning (as per the last time). One thing that has been circulating around my mind is an aliasing "it" with "he", which makes a lot of sense when you write specs from a User's perspective: describe "A", User do he "should receiving an extra 2 dollars when he passes go" end Anyway - would it be reasonable for this to go into rspec core? It seems too specific to *my* needs, and not central enough to specs in general. Plus, if this were added, should "she" also be added? Just another thing - I've never understood why so many find lambda to be an unusual construction - a block *is* a lambda, and it *is* a Proc (more or less), and those are used everywhere in the language. Scott From lists at ruby-forum.com Sat Nov 17 22:52:36 2007 From: lists at ruby-forum.com (Chris Olsen) Date: Sun, 18 Nov 2007 04:52:36 +0100 Subject: [rspec-users] Not sure why this is failing Message-ID: <54636237041d18e034d720b3002ed528@ruby-forum.com> I am not sure why the tests don't see the call of the new method for the Address class. It can be seen in the controller method where the Address.new is called. >> @address = Address.new(params[:address]) What am I doing wrong? Thanks for the help. Here is the error message: Spec::Mocks::MockExpectationError in 'UsersController handling POST /users should create a new user' Mock 'Class' expected :new with ({}) once, but received it 0 times ./spec/controllers/users_controller_spec.rb:245: script/spec:4: ################################### describe UsersController, "handling POST /users" do before do @address = mock_model(Address, :to_param => "1") @user = mock_model(User, :to_param => "1", :address => @address, :address= => nil) User.stub!(:new).and_return(@user) Address.stub!(:new).and_return(@address) end def post_with_successful_save @user.should_receive(:save).and_return(true) post :create, :user => {} end it "should create a new user" do User.should_receive(:new).with({}).and_return(@user) Address.should_receive(:new).with({}).and_return(@address) <-- Line 245 post_with_successful_save end end ################################### class UsersController < ApplicationController def create @user = User.new(params[:user]) @address = Address.new(params[:address]) @user.address = @address respond_to do |format| if @user.save flash[:notice] = 'User was successfully created.' format.html { redirect_to user_url(@user) } format.xml { head :created, :location => user_url(@user) } else format.html { render :action => "new" } format.xml { render :xml => @user.errors.to_xml } end end end end -- Posted via http://www.ruby-forum.com/. From mailing_lists at railsnewbie.com Sat Nov 17 23:06:47 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 17 Nov 2007 23:06:47 -0500 Subject: [rspec-users] Not sure why this is failing In-Reply-To: <54636237041d18e034d720b3002ed528@ruby-forum.com> References: <54636237041d18e034d720b3002ed528@ruby-forum.com> Message-ID: <5FACB97D-77B2-4407-A3C3-BAE040321059@railsnewbie.com> On Nov 17, 2007, at 10:52 PM, Chris Olsen wrote: > I am not sure why the tests don't see the call of the new method > for the > Address class. It can be seen in the controller method where the > Address.new is called. >>> @address = Address.new(params[:address]) > > What am I doing wrong? > You probably want Address.should_receive(:new).with(no_args).and_return @address Generally, if you have these sorts of mock expectation errors you can write a more simple test by removing the "with" clause to see if the is the message is being received with any arguments. Scott > Thanks for the help. > > Here is the error message: > Spec::Mocks::MockExpectationError in 'UsersController handling POST > /users should create a new user' > Mock 'Class' expected :new with ({}) once, but received it 0 times > ./spec/controllers/users_controller_spec.rb:245: > script/spec:4: > > ################################### > > describe UsersController, "handling POST /users" do > > before do > @address = mock_model(Address, :to_param => "1") > @user = mock_model(User, :to_param => "1", :address => @address, > :address= => nil) > User.stub!(:new).and_return(@user) > Address.stub!(:new).and_return(@address) > end > > def post_with_successful_save > @user.should_receive(:save).and_return(true) > post :create, :user => {} > end > > it "should create a new user" do > User.should_receive(:new).with({}).and_return(@user) > Address.should_receive(:new).with({}).and_return(@address) <-- > Line 245 > post_with_successful_save > end > > end > > ################################### > > class UsersController < ApplicationController > > def create > @user = User.new(params[:user]) > @address = Address.new(params[:address]) > @user.address = @address > > respond_to do |format| > if @user.save > flash[:notice] = 'User was successfully created.' > format.html { redirect_to user_url(@user) } > format.xml { head :created, :location => user_url(@user) } > else > format.html { render :action => "new" } > format.xml { render :xml => @user.errors.to_xml } > end > end > end > end > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Sat Nov 17 23:18:25 2007 From: lists at ruby-forum.com (__iso __) Date: Sun, 18 Nov 2007 05:18:25 +0100 Subject: [rspec-users] Not sure why this is failing In-Reply-To: <5FACB97D-77B2-4407-A3C3-BAE040321059@railsnewbie.com> References: <54636237041d18e034d720b3002ed528@ruby-forum.com> <5FACB97D-77B2-4407-A3C3-BAE040321059@railsnewbie.com> Message-ID: >> Address.should_receive(:new).with(no_args).and_return @address That doesn't seem to work either. I had also tried with :any and that failed as well. It does seem to work when removing the .with() call though. -- Posted via http://www.ruby-forum.com/. From cwdinfo at gmail.com Sat Nov 17 23:50:06 2007 From: cwdinfo at gmail.com (s.ross) Date: Sat, 17 Nov 2007 20:50:06 -0800 Subject: [rspec-users] Not sure why this is failing In-Reply-To: References: <54636237041d18e034d720b3002ed528@ruby-forum.com> <5FACB97D-77B2-4407-A3C3-BAE040321059@railsnewbie.com> Message-ID: <195A5C8B-2D53-45FC-8E91-8AD1DB5FE064@gmail.com> Try with(nil) I think params[:user] will return nil. On Nov 17, 2007, at 8:18 PM, __iso __ wrote: >>> Address.should_receive(:new).with(no_args).and_return @address > > That doesn't seem to work either. I had also tried with :any and that > failed as well. > > It does seem to work when removing the .with() call though. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Sun Nov 18 00:04:26 2007 From: lists at ruby-forum.com (Chris Olsen) Date: Sun, 18 Nov 2007 06:04:26 +0100 Subject: [rspec-users] Not sure why this is failing In-Reply-To: <195A5C8B-2D53-45FC-8E91-8AD1DB5FE064@gmail.com> References: <54636237041d18e034d720b3002ed528@ruby-forum.com> <5FACB97D-77B2-4407-A3C3-BAE040321059@railsnewbie.com> <195A5C8B-2D53-45FC-8E91-8AD1DB5FE064@gmail.com> Message-ID: Steve Ross wrote: > Try with(nil) > > I think params[:user] will return nil. yip that works, after fooling with it I also found that :any_args works as well as any (I guess this one is more than just a symbol) Thanks for the help. -- Posted via http://www.ruby-forum.com/. From mailing_lists at railsnewbie.com Sun Nov 18 00:12:56 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 18 Nov 2007 00:12:56 -0500 Subject: [rspec-users] Not sure why this is failing In-Reply-To: References: <54636237041d18e034d720b3002ed528@ruby-forum.com> <5FACB97D-77B2-4407-A3C3-BAE040321059@railsnewbie.com> <195A5C8B-2D53-45FC-8E91-8AD1DB5FE064@gmail.com> Message-ID: <0EBBD28F-2C46-42CC-BDA7-44E1827868C5@railsnewbie.com> On Nov 18, 2007, at 12:04 AM, Chris Olsen wrote: > Steve Ross wrote: >> Try with(nil) >> >> I think params[:user] will return nil. > > yip that works, after fooling with it I also found that :any_args > works > as well as any (I guess this one is more than just a symbol) > > Thanks for the help. > I think :any_args is deprecated, and you should use any_args() instead (just FYI). Glad you figured it out. Scott From dchelimsky at gmail.com Sun Nov 18 05:43:40 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 18 Nov 2007 04:43:40 -0600 Subject: [rspec-users] Role of stories vs specs In-Reply-To: <810a540e0711141550s3831e144t1f14429d549b3486@mail.gmail.com> References: <810a540e0711131110t73149f26r50fd6dadbe20ae90@mail.gmail.com> <57c63afe0711131151w733c7b70id8cd59a5d64cd196@mail.gmail.com> <810a540e0711131517q733097a9y73a77ecf591737ec@mail.gmail.com> <57c63afe0711131600n5807f7f2ja782610ac78e5c13@mail.gmail.com> <810a540e0711141550s3831e144t1f14429d549b3486@mail.gmail.com> Message-ID: <57c63afe0711180243t49a3729ci59a8c6affcf828a@mail.gmail.com> On Nov 14, 2007 5:50 PM, Pat Maddox wrote: > On Nov 13, 2007 4:00 PM, David Chelimsky wrote: > > On Nov 13, 2007 5:17 PM, Pat Maddox wrote: > > > Let's say in some banking software we have a transfer screen, and > > > there are three possible errors: insufficient funds, source account > > > frozen, target account frozen. Would you write a scenario for each of > > > the possible errors, and an example for each? > > > > Without even batting an eye! > > > > The scenario is going to reflect how things look from the outside. The > > example is going to be targeted right at the part of the system that > > is responsible for producing the correct error message. > > When I gave that example I thought it sucked, because I would write a > story and example for each too. But I guess I can say it served as a > bit of a sanity check. > > Anyway, a more gray-area example (imo) is Rails validations. We've > got a user registration page, and it requires the user to fill in > their name, email address, and a password. > > Would you write a scenario where nothing is filled in? Where > everything but the name is filled in? And so on for each attribute. > How about combinations of missing stuff? > > It seems to me like that story is on a VERY high level and all we > really care about is verifying that the plumbing works (so maybe I > need to think of this as a story for the UI domain instead of the > business domain?). If the user fills in everything, make sure there's > a new record. If they don't fill it in, make sure they're shown the > registration page again. It's cumbersome to try to cover every > possible scenario even though you "should." > > Would you write a story at a lower level, which actually tries to save > the objects to the db and verifies that nothing changes? That > *definitely* duplicates what's going on in the model-level specs. Keep in mind that stories/scenarios and specs each play multiple roles. Scenarios start off as a collaboration tool for the whole team to understand what's about to be developed. Then code is developed, the scenarios pass, and now they serve two new purposes. Assuming they are well maintained (they are kept well organized and passing), scenarios document the system as it actually is and they are system-level regression tests. Similarly, examples start as a means of designing subsets of the system at a very granular level. Then the become documentation of your objects as they really are, and object-level regression tests. Also consider that both levels have a red/green/refactor life cycle, though less apparent at the higher levels. So they are both constantly subject to change in response to new and changing requirements. But they have subtly different forces of change. At a high level, they are both changing because the business rules grow or change. But specs change much more frequently as the design changes. In the end, it's about finding a process that works for you and your team throughout the lifecycle of a project. For me, the duplication between stories and specs helps me to stay productive all the time. It is faith in combination of the two alerting me of behaviour-breaking changes that keeps me moving. If on your team you find it more pragmatic to express things in one place or the other, and you find that doing so keeps you agile (remember - agility is not only about speed - it's about responding to change) throughout the project, then that's OK. My experience tells me that I'm a happier person when I've got robust sets of stories and specs that live independently and both cover the entire system from their unique perspective. FWIW. > Hopefully this thread hasn't died... No - it was just on vacation. Though I would welcome more voices in it if anybody else has an opinion to express. Cheers, David > > > Cheers, > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From eloy.de.enige at gmail.com Sun Nov 18 07:36:10 2007 From: eloy.de.enige at gmail.com (Eloy Duran) Date: Sun, 18 Nov 2007 13:36:10 +0100 Subject: [rspec-users] Using RSpec to drive the design of a GUI desktop application Message-ID: <67974203-EDC9-419E-A3EC-8ECD72CDCDD8@gmail.com> Hey Mathijs, Someone pinged me that you were interested in BDD with RubyCocoa (RC), so I thought I'd just chip in. I write my RC apps in a BDD way and as such support for it is included with Rucola. When we release 0.0.2 I will also release a screencast on how I use BDD with RC. But the bottom-line is, like with so many other BDD code, to make extensive use of mocking. Because most of the times you don't want to test IF a NSTextField works, you just want to test the behaviour of your code IF a text field returns a specific value. This is easily done with mocking. Atm I don't use rSpec but rather test/spec. So there are probably some hurdles to overcome if you really wish to use rSpec. Hope this helps. Cheers, Eloy Duran =============================================================== Hello everybody, I've been using RSpec as a tool to create web applications for some time now, in Rails, and using plain Ruby with WEBrick as well. The tool suits my needs and the story runner is great. Now there are things that aren't solvable on the web, you'll need a _real_ desktop application for those problems. So I've toyed a bit around with various GUI libraries as wxRuby and RubyCocoa, to get a feeling on how these libraries work and I love to create native OS X applications using cocoa. Of course, the next question that arose in my head was:"How do I drive the design of an application using a BDD framework like RSpec?". When writing a web application, it is relatively easy to simulate a HTTP request to the app and crawl through the returned HTML, but for a desktop application it's different, right? The format (html) handled between the application, and the toolkit drawing the actual screen isn't that open for a desktop application as it is for a web application. So, since we don't want to test the inner workings of the gui toolkit and we only want to specify the behaviour of the code we write self, we must plug a framework somewhere, to capture the actual calls to this toolkit to know if our code is doing the right thing. At least, that's how I see it currently. But how could that be done? Regards, Matthijs Langenberg From dchelimsky at gmail.com Sun Nov 18 09:56:10 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 18 Nov 2007 08:56:10 -0600 Subject: [rspec-users] Using RSpec to drive the design of a GUI desktop application In-Reply-To: <67974203-EDC9-419E-A3EC-8ECD72CDCDD8@gmail.com> References: <67974203-EDC9-419E-A3EC-8ECD72CDCDD8@gmail.com> Message-ID: <57c63afe0711180656j2e797b07s1c853c487877c5f4@mail.gmail.com> On Nov 18, 2007 6:36 AM, Eloy Duran wrote: > Atm I don't use rSpec but rather test/spec. > So there are probably some hurdles to overcome if you really wish to > use rSpec. What hurdles would you anticipate? From dchelimsky at gmail.com Sun Nov 18 10:15:13 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 18 Nov 2007 09:15:13 -0600 Subject: [rspec-users] 'lazy' url generation in view specs In-Reply-To: <1EF6C673-A8B0-42F6-A569-6A240DC78497@ingoweiss.com> References: <1EF6C673-A8B0-42F6-A569-6A240DC78497@ingoweiss.com> Message-ID: <57c63afe0711180715y237f1e0ds59a4bfa53af59aea@mail.gmail.com> On Nov 15, 2007 3:59 AM, Ingo Weiss wrote: > Hi, > > I would like to use the 'lazy' style of url generation in my views, > omitting parameters from my calls to url_for (and named route > methods) that are then filled in from the current request parameters. > > Example: > url_for(:action => 'index') will fill in (:controller => 'posts') if > params[:controller] is 'posts' > > However, this breaks my view specs because when they render the view > there is no request from which to fill in the missing parameters. How > can I stub/mock the request so that the 'lazy' url-generation works > in view spec? I tried a number of things, none of them working, > including this: > > @controller.stub!(:params).and_return({:controller => > 'posts', :action => 'show'}) I don't think there is any way to do this yet. There is an open ticket in the tracker: http://rubyforge.org/tracker/index.php?func=detail&aid=12963&group_id=797&atid=3149 > > Ingo > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sun Nov 18 10:22:06 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 18 Nov 2007 09:22:06 -0600 Subject: [rspec-users] What command to run all stories? In-Reply-To: <3df642dd0711151100s1952deddh39c88864bbcb652b@mail.gmail.com> References: <3df642dd0711150856y570487b2x84903d0fcb10fd8c@mail.gmail.com> <786AEE09-BE94-44E0-8E98-F51151FA799D@opensourceconnections.com> <3df642dd0711151026oa24f1e2w3655200545b309b5@mail.gmail.com> <57c63afe0711151030l3d42303fxc891a022cf55ceb5@mail.gmail.com> <3df642dd0711151100s1952deddh39c88864bbcb652b@mail.gmail.com> Message-ID: <57c63afe0711180722w6e97cbb4o3e06d49624284ce3@mail.gmail.com> On Nov 15, 2007 1:00 PM, Ed Howland wrote: > On Nov 15, 2007 12:30 PM, David Chelimsky wrote: > > > ENV["RAILS_ENV"] = "test" > > > require File.expand_path(File.dirname(__FILE__) + "/../config/environment") > > > require 'spec/rails/story_adapter' > > > Dir[File.join(File.dirname(__FILE__), "steps/*.rb")].each do |file| > > > require file > > > end > > > > > > I personally think that steps should be isolated from other stories. > > > This seems to requre all steps in every story. > > > > It requires them all but doesn't expose them all in your story. Agreed > > that each story should be limited in what it sees. > > David, > > Thanks for the info. Any directions you can point me to make : > > ruby stories/all.rb > > work? I think I am missing some require there. It is the stock one from trunk. The one that gets generated by script/generate rspec should just work. It requires every ruby file in the stories directory and any of its subdirectories. As long as each file is also doing the requiring that it needs (i.e. each file that runs specific stories requires stories/helper.rb and helper.rb requires all the step definitions) you should be fine. David > > Thanks > Ed > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sun Nov 18 10:59:39 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 18 Nov 2007 09:59:39 -0600 Subject: [rspec-users] helper methods starting with should Message-ID: <57c63afe0711180759l6348dd6eh375b328f4f6d9657@mail.gmail.com> Hi all, As an experiment in playing nice with others, we've added the ability in rspec's trunk to do this: class ThingExamples < Spec::ExampleGroup def should_do_stuff ... end end This is how rspec 0.1 worked, and for people already comfortable with the classes/methods approach of Test::Unit, it is a more comfortable entry point to rspec. For others, however, it has created a problem: you can't write helper methods that start with should_ because rspec treats them as examples. Quick show of hands, please: +1 (with comments please) for keeping the ability to write examples using should_ -1 (with comments please) for bagging it because you think you should be able to write helper methods that start with should_. You may want to peek at the conversation on this ticket before you respond: http://rubyforge.org/tracker/?func=detail&atid=3149&aid=15638&group_id=797 Thanks for playing, Cheers, David ps - In the interest of full disclosure, this is not going to be a majority vote. My interest is in making rspec more accessible to people who are likely not on this list and whose voices will not be heard. I'm just looking to take a pulse from a wider group than the few that have commented on the ticket. pps - One suggestion that came up was to make this a configuration option. I don't love that because it makes rspec more complicated, but it's a possibility. From jonathan at parkerhill.com Sun Nov 18 11:10:25 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Sun, 18 Nov 2007 11:10:25 -0500 Subject: [rspec-users] Not sure why this is failing In-Reply-To: <195A5C8B-2D53-45FC-8E91-8AD1DB5FE064@gmail.com> References: <54636237041d18e034d720b3002ed528@ruby-forum.com> <5FACB97D-77B2-4407-A3C3-BAE040321059@railsnewbie.com> <195A5C8B-2D53-45FC-8E91-8AD1DB5FE064@gmail.com> Message-ID: personally I find this to be one of the most frustrating things about rspec, well, rspec's stubs and wish the error messages could be much more helpful, rather than just telling that an expected method was not called, tell me if/when it was called with some other args instead (if this causes excessive overhead, perhaps a runtime option like, -- trace "Address.new" ) --linoj On Nov 17, 2007, at 11:50 PM, s.ross wrote: > Try with(nil) > > I think params[:user] will return nil. > > > On Nov 17, 2007, at 8:18 PM, __iso __ wrote: > >>>> Address.should_receive(:new).with(no_args).and_return @address >> >> That doesn't seem to work either. I had also tried with :any and >> that >> failed as well. >> >> It does seem to work when removing the .with() call though. >> >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From chris at octopod.info Sun Nov 18 10:45:26 2007 From: chris at octopod.info (Chris McGrath) Date: Sun, 18 Nov 2007 15:45:26 +0000 Subject: [rspec-users] Using RSpec to drive the design of a GUI desktop application In-Reply-To: <57c63afe0711180656j2e797b07s1c853c487877c5f4@mail.gmail.com> References: <67974203-EDC9-419E-A3EC-8ECD72CDCDD8@gmail.com> <57c63afe0711180656j2e797b07s1c853c487877c5f4@mail.gmail.com> Message-ID: On 18 Nov 2007, at 14:56, David Chelimsky wrote: > On Nov 18, 2007 6:36 AM, Eloy Duran wrote: >> Atm I don't use rSpec but rather test/spec. >> So there are probably some hurdles to overcome if you really wish to >> use rSpec. > > What hurdles would you anticipate? I don't think there are any insurmountable ones, we just need to make sure rucola is testing framework agnostic like merb. I'm going to have a go at integrating rspec tests later this evening as I want to use rspec with rubycocoa. Cheers, Chris From dchelimsky at gmail.com Sun Nov 18 11:16:41 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 18 Nov 2007 10:16:41 -0600 Subject: [rspec-users] Not sure why this is failing In-Reply-To: References: <54636237041d18e034d720b3002ed528@ruby-forum.com> <5FACB97D-77B2-4407-A3C3-BAE040321059@railsnewbie.com> <195A5C8B-2D53-45FC-8E91-8AD1DB5FE064@gmail.com> Message-ID: <57c63afe0711180816r1c0e786ema25e4ed0b9da674e@mail.gmail.com> On Nov 18, 2007 10:10 AM, Jonathan Linowes wrote: > personally I find this to be one of the most frustrating things about > rspec, well, rspec's stubs > and wish the error messages could be much more helpful, > rather than just telling that an expected method was not called, tell > me if/when it was called with some other args instead > (if this causes excessive overhead, perhaps a runtime option like, -- > trace "Address.new" ) This sounds reasonable. Please submit a ticket to the tracker. A patch would be best, but a bug report would be fine to get it on the radar. Cheers, David > > --linoj > > > > On Nov 17, 2007, at 11:50 PM, s.ross wrote: > > > Try with(nil) > > > > I think params[:user] will return nil. > > > > > > On Nov 17, 2007, at 8:18 PM, __iso __ wrote: > > > >>>> Address.should_receive(:new).with(no_args).and_return @address > >> > >> That doesn't seem to work either. I had also tried with :any and > >> that > >> failed as well. > >> > >> It does seem to work when removing the .with() call though. > >> > >> -- > >> Posted via http://www.ruby-forum.com/. > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sun Nov 18 11:19:08 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 18 Nov 2007 10:19:08 -0600 Subject: [rspec-users] Using RSpec to drive the design of a GUI desktop application In-Reply-To: References: <67974203-EDC9-419E-A3EC-8ECD72CDCDD8@gmail.com> <57c63afe0711180656j2e797b07s1c853c487877c5f4@mail.gmail.com> Message-ID: <57c63afe0711180819k1193926drbca9d2baeb55c098@mail.gmail.com> On Nov 18, 2007 9:45 AM, Chris McGrath wrote: > > > On 18 Nov 2007, at 14:56, David Chelimsky wrote: > > > On Nov 18, 2007 6:36 AM, Eloy Duran wrote: > >> Atm I don't use rSpec but rather test/spec. > >> So there are probably some hurdles to overcome if you really wish to > >> use rSpec. > > > > What hurdles would you anticipate? > > I don't think there are any insurmountable ones, we just need to make > sure rucola is testing framework agnostic like merb. I'm going to have > a go at integrating rspec tests later this evening as I want to use > rspec with rubycocoa. Great! If you find anything that needs to change in rspec, please let us know. Obviously, patches are preferred as we've got a lot on our plates these days, but a bug report or feature request would be just as useful. Cheers, David > > Cheers, > > Chris > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tastapod at gmail.com Sun Nov 18 11:29:24 2007 From: tastapod at gmail.com (Dan North) Date: Sun, 18 Nov 2007 16:29:24 +0000 Subject: [rspec-users] helper methods starting with should In-Reply-To: <57c63afe0711180759l6348dd6eh375b328f4f6d9657@mail.gmail.com> References: <57c63afe0711180759l6348dd6eh375b328f4f6d9657@mail.gmail.com> Message-ID: +1 for keeping should prefix given the number of people who write helper methods starting with "should" (at last count, one person) versus the number of people who find it useful starting test methods with the word "should" in xunit testing frameworks (nearly everyone I know). Obviously my world is skewed because I am part of the problem, getting people to value "should" in the first place. I think supporting should is more in the spirit of playing nice with others (junit and test::unit folks) than not. Cheers, Dan On Nov 18, 2007 3:59 PM, David Chelimsky wrote: > Hi all, > > As an experiment in playing nice with others, we've added the ability > in rspec's trunk to do this: > > class ThingExamples < Spec::ExampleGroup > > def should_do_stuff > ... > end > > end > > This is how rspec 0.1 worked, and for people already comfortable with > the classes/methods approach of Test::Unit, it is a more comfortable > entry point to rspec. > > For others, however, it has created a problem: you can't write helper > methods that start with should_ because rspec treats them as examples. > > Quick show of hands, please: > > +1 (with comments please) for keeping the ability to write examples > using should_ > -1 (with comments please) for bagging it because you think you should > be able to write helper methods that start with should_. > > You may want to peek at the conversation on this ticket before you > respond: > http://rubyforge.org/tracker/?func=detail&atid=3149&aid=15638&group_id=797 > > Thanks for playing, > Cheers, > David > > ps - In the interest of full disclosure, this is not going to be a > majority vote. My interest is in making rspec more accessible to > people who are likely not on this list and whose voices will not be > heard. I'm just looking to take a pulse from a wider group than the > few that have commented on the ticket. > > pps - One suggestion that came up was to make this a configuration > option. I don't love that because it makes rspec more complicated, but > it's a possibility. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071118/e5d3e1d8/attachment.html From aslak.hellesoy at gmail.com Sun Nov 18 11:29:54 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 18 Nov 2007 17:29:54 +0100 Subject: [rspec-users] helper methods starting with should In-Reply-To: <57c63afe0711180759l6348dd6eh375b328f4f6d9657@mail.gmail.com> References: <57c63afe0711180759l6348dd6eh375b328f4f6d9657@mail.gmail.com> Message-ID: <8d961d900711180829x3272dfc8nb0d66b1da4a415f8@mail.gmail.com> On Nov 18, 2007 4:59 PM, David Chelimsky wrote: > Hi all, > > As an experiment in playing nice with others, we've added the ability > in rspec's trunk to do this: > > class ThingExamples < Spec::ExampleGroup > > def should_do_stuff > ... > end > > end > > This is how rspec 0.1 worked, and for people already comfortable with > the classes/methods approach of Test::Unit, it is a more comfortable > entry point to rspec. > > For others, however, it has created a problem: you can't write helper > methods that start with should_ because rspec treats them as examples. > > Quick show of hands, please: > > +1 (with comments please) for keeping the ability to write examples > using should_ > -1 (with comments please) for bagging it because you think you should > be able to write helper methods that start with should_. -1. I don't want to encourage a third style for examples (#test_* and RSpec #it is enough). It doesn't bring anything new to the table, especially when #it can be used inside TestCase classes. Aslak > > You may want to peek at the conversation on this ticket before you > respond: http://rubyforge.org/tracker/?func=detail&atid=3149&aid=15638&group_id=797 > > Thanks for playing, > Cheers, > David > > ps - In the interest of full disclosure, this is not going to be a > majority vote. My interest is in making rspec more accessible to > people who are likely not on this list and whose voices will not be > heard. I'm just looking to take a pulse from a wider group than the > few that have commented on the ticket. > > pps - One suggestion that came up was to make this a configuration > option. I don't love that because it makes rspec more complicated, but > it's a possibility. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sun Nov 18 11:39:19 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 18 Nov 2007 10:39:19 -0600 Subject: [rspec-users] helper methods starting with should In-Reply-To: <8d961d900711180829x3272dfc8nb0d66b1da4a415f8@mail.gmail.com> References: <57c63afe0711180759l6348dd6eh375b328f4f6d9657@mail.gmail.com> <8d961d900711180829x3272dfc8nb0d66b1da4a415f8@mail.gmail.com> Message-ID: <57c63afe0711180839x29f880cdmfb67a129ebb64241@mail.gmail.com> On Nov 18, 2007 10:29 AM, aslak hellesoy wrote: > On Nov 18, 2007 4:59 PM, David Chelimsky wrote: > > Hi all, > > > > As an experiment in playing nice with others, we've added the ability > > in rspec's trunk to do this: > > > > class ThingExamples < Spec::ExampleGroup > > > > def should_do_stuff > > ... > > end > > > > end > > > > This is how rspec 0.1 worked, and for people already comfortable with > > the classes/methods approach of Test::Unit, it is a more comfortable > > entry point to rspec. > > > > For others, however, it has created a problem: you can't write helper > > methods that start with should_ because rspec treats them as examples. > > > > Quick show of hands, please: > > > > +1 (with comments please) for keeping the ability to write examples > > using should_ > > -1 (with comments please) for bagging it because you think you should > > be able to write helper methods that start with should_. > > -1. I don't want to encourage a third style for examples (#test_* and > RSpec #it is enough). It doesn't bring anything new to the table, Your -1 noted, however I disagree with the rationale. I think it *does* bring something new to the table. If you are one who prefers classes/methods, you'd be stuck with this: class SomeExamples << Test::Unit::TestCase::ExampleGroup def test_foo ... end end While this might be a useful transition from as T::U suite (just add ::ExampleGroup to the base class name), it feels like a transition point, not and end. We want to encourage "should" over "test". > especially > when #it can be used inside TestCase classes. #it doesn't really speak well inside a class definition: class SomeExamples << Test::Unit::TestCase::ExampleGroup it "foo" do ... end end WDYT? David > > Aslak > > > > > You may want to peek at the conversation on this ticket before you > > respond: http://rubyforge.org/tracker/?func=detail&atid=3149&aid=15638&group_id=797 > > > > Thanks for playing, > > Cheers, > > David > > > > ps - In the interest of full disclosure, this is not going to be a > > majority vote. My interest is in making rspec more accessible to > > people who are likely not on this list and whose voices will not be > > heard. I'm just looking to take a pulse from a wider group than the > > few that have commented on the ticket. > > > > pps - One suggestion that came up was to make this a configuration > > option. I don't love that because it makes rspec more complicated, but > > it's a possibility. > > > _______________________________________________ > > 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 nathan.sutton at gmail.com Sun Nov 18 11:05:14 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Sun, 18 Nov 2007 10:05:14 -0600 Subject: [rspec-users] helper methods starting with should In-Reply-To: <57c63afe0711180759l6348dd6eh375b328f4f6d9657@mail.gmail.com> References: <57c63afe0711180759l6348dd6eh375b328f4f6d9657@mail.gmail.com> Message-ID: <4AC9A066-9632-4955-B1A4-45FBA884F6F7@gmail.com> 0 Keep it, but make it a configuration option with default-off. Nathan Sutton fowlduck at gmail.com rspec edge revision 2894 rspec_on_rails edge revision 2894 rails edge revision 8146 On Nov 18, 2007, at 9:59 AM, David Chelimsky wrote: > Hi all, > > As an experiment in playing nice with others, we've added the ability > in rspec's trunk to do this: > > class ThingExamples < Spec::ExampleGroup > > def should_do_stuff > ... > end > > end > > This is how rspec 0.1 worked, and for people already comfortable with > the classes/methods approach of Test::Unit, it is a more comfortable > entry point to rspec. > > For others, however, it has created a problem: you can't write helper > methods that start with should_ because rspec treats them as examples. > > Quick show of hands, please: > > +1 (with comments please) for keeping the ability to write examples > using should_ > -1 (with comments please) for bagging it because you think you should > be able to write helper methods that start with should_. > > You may want to peek at the conversation on this ticket before you > respond: http://rubyforge.org/tracker/?func=detail&atid=3149&aid=15638&group_id=797 > > Thanks for playing, > Cheers, > David > > ps - In the interest of full disclosure, this is not going to be a > majority vote. My interest is in making rspec more accessible to > people who are likely not on this list and whose voices will not be > heard. I'm just looking to take a pulse from a wider group than the > few that have commented on the ticket. > > pps - One suggestion that came up was to make this a configuration > option. I don't love that because it makes rspec more complicated, but > it's a possibility. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From nathan.sutton at gmail.com Sun Nov 18 11:16:56 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Sun, 18 Nov 2007 10:16:56 -0600 Subject: [rspec-users] helper methods starting with should In-Reply-To: <57c63afe0711180759l6348dd6eh375b328f4f6d9657@mail.gmail.com> References: <57c63afe0711180759l6348dd6eh375b328f4f6d9657@mail.gmail.com> Message-ID: <3B7A6AB8-7167-4F0E-A3AF-A263969D342C@gmail.com> 0 Should be able to turn on or off. don't know if the first went through. Nathan Sutton fowlduck at gmail.com rspec edge revision 2894 rspec_on_rails edge revision 2894 rails edge revision 8146 On Nov 18, 2007, at 9:59 AM, David Chelimsky wrote: > Hi all, > > As an experiment in playing nice with others, we've added the ability > in rspec's trunk to do this: > > class ThingExamples < Spec::ExampleGroup > > def should_do_stuff > ... > end > > end > > This is how rspec 0.1 worked, and for people already comfortable with > the classes/methods approach of Test::Unit, it is a more comfortable > entry point to rspec. > > For others, however, it has created a problem: you can't write helper > methods that start with should_ because rspec treats them as examples. > > Quick show of hands, please: > > +1 (with comments please) for keeping the ability to write examples > using should_ > -1 (with comments please) for bagging it because you think you should > be able to write helper methods that start with should_. > > You may want to peek at the conversation on this ticket before you > respond: http://rubyforge.org/tracker/?func=detail&atid=3149&aid=15638&group_id=797 > > Thanks for playing, > Cheers, > David > > ps - In the interest of full disclosure, this is not going to be a > majority vote. My interest is in making rspec more accessible to > people who are likely not on this list and whose voices will not be > heard. I'm just looking to take a pulse from a wider group than the > few that have commented on the ticket. > > pps - One suggestion that came up was to make this a configuration > option. I don't love that because it makes rspec more complicated, but > it's a possibility. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From jonathan at parkerhill.com Sun Nov 18 12:15:27 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Sun, 18 Nov 2007 12:15:27 -0500 Subject: [rspec-users] rubyforge (was Re: Not sure why this is failing) In-Reply-To: <57c63afe0711180816r1c0e786ema25e4ed0b9da674e@mail.gmail.com> References: <54636237041d18e034d720b3002ed528@ruby-forum.com> <5FACB97D-77B2-4407-A3C3-BAE040321059@railsnewbie.com> <195A5C8B-2D53-45FC-8E91-8AD1DB5FE064@gmail.com> <57c63afe0711180816r1c0e786ema25e4ed0b9da674e@mail.gmail.com> Message-ID: OT I am so frustrated with Rubyforge. It refuses to let me log in. I know I have an account as I can change my password, and go through the login form, but it just returns with no cookie and not logged in and no messages. Although I'm behind a proxy I do not have any similar problems with any other sites, including ecommerce ones with https. (osx, ff and safari) Perhaps its some lameness on my part, but I'm at a loss how to further diagnose my problem. If anyone would like to help me, I'll be in #rubyforge as linoj. Nonetheless I am not able to submit to tracker. On Nov 18, 2007, at 11:16 AM, David Chelimsky wrote: > On Nov 18, 2007 10:10 AM, Jonathan Linowes > wrote: >> personally I find this to be one of the most frustrating things about >> rspec, well, rspec's stubs >> and wish the error messages could be much more helpful, >> rather than just telling that an expected method was not called, tell >> me if/when it was called with some other args instead >> (if this causes excessive overhead, perhaps a runtime option like, -- >> trace "Address.new" ) > > This sounds reasonable. Please submit a ticket to the tracker. A patch > would be best, but a bug report would be fine to get it on the radar. > > Cheers, > David > >> >> --linoj >> >> >> >> On Nov 17, 2007, at 11:50 PM, s.ross wrote: >> >>> Try with(nil) >>> >>> I think params[:user] will return nil. >>> >>> >>> On Nov 17, 2007, at 8:18 PM, __iso __ wrote: >>> >>>>>> Address.should_receive(:new).with(no_args).and_return @address >>>> >>>> That doesn't seem to work either. I had also tried with :any and >>>> that >>>> failed as well. >>>> >>>> It does seem to work when removing the .with() call though. >>>> >>>> -- >>>> Posted via http://www.ruby-forum.com/. >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sun Nov 18 12:36:19 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 18 Nov 2007 11:36:19 -0600 Subject: [rspec-users] rubyforge (was Re: Not sure why this is failing) In-Reply-To: References: <54636237041d18e034d720b3002ed528@ruby-forum.com> <5FACB97D-77B2-4407-A3C3-BAE040321059@railsnewbie.com> <195A5C8B-2D53-45FC-8E91-8AD1DB5FE064@gmail.com> <57c63afe0711180816r1c0e786ema25e4ed0b9da674e@mail.gmail.com> Message-ID: <57c63afe0711180936u1fffa4e6l34cd4fd29b5438e0@mail.gmail.com> On Nov 18, 2007 11:15 AM, Jonathan Linowes wrote: > OT I am so frustrated with Rubyforge. It refuses to let me log in. I > know I have an account as I can change my password, and go through > the login form, but it just returns with no cookie and not logged in > and no messages. Although I'm behind a proxy I do not have any > similar problems with any other sites, including ecommerce ones with > https. (osx, ff and safari) Perhaps its some lameness on my part, but > I'm at a loss how to further diagnose my problem. If anyone would > like to help me, I'll be in #rubyforge as linoj. Nonetheless I am not > able to submit to tracker. Hey Jonathan, You'll be happy to know that we'll soon be moving ticket tracking to lighthouse. In the mean time, I added http://rubyforge.org/tracker/index.php?group_id=797&atid=3149. Cheers, David > > > > > On Nov 18, 2007, at 11:16 AM, David Chelimsky wrote: > > > On Nov 18, 2007 10:10 AM, Jonathan Linowes > > wrote: > >> personally I find this to be one of the most frustrating things about > >> rspec, well, rspec's stubs > >> and wish the error messages could be much more helpful, > >> rather than just telling that an expected method was not called, tell > >> me if/when it was called with some other args instead > >> (if this causes excessive overhead, perhaps a runtime option like, -- > >> trace "Address.new" ) > > > > This sounds reasonable. Please submit a ticket to the tracker. A patch > > would be best, but a bug report would be fine to get it on the radar. > > > > Cheers, > > David > > > >> > >> --linoj > >> > >> > >> > >> On Nov 17, 2007, at 11:50 PM, s.ross wrote: > >> > >>> Try with(nil) > >>> > >>> I think params[:user] will return nil. > >>> > >>> > >>> On Nov 17, 2007, at 8:18 PM, __iso __ wrote: > >>> > >>>>>> Address.should_receive(:new).with(no_args).and_return @address > >>>> > >>>> That doesn't seem to work either. I had also tried with :any and > >>>> that > >>>> failed as well. > >>>> > >>>> It does seem to work when removing the .with() call though. > >>>> > >>>> -- > >>>> Posted via http://www.ruby-forum.com/. > >>>> _______________________________________________ > >>>> rspec-users mailing list > >>>> rspec-users at rubyforge.org > >>>> http://rubyforge.org/mailman/listinfo/rspec-users > >>> > >>> _______________________________________________ > >>> rspec-users mailing list > >>> rspec-users at rubyforge.org > >>> http://rubyforge.org/mailman/listinfo/rspec-users > >> > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > >> > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From smingins at elctech.com Sun Nov 18 13:52:39 2007 From: smingins at elctech.com (Shane Mingins) Date: Mon, 19 Nov 2007 07:52:39 +1300 Subject: [rspec-users] helper methods starting with should In-Reply-To: <4AC9A066-9632-4955-B1A4-45FBA884F6F7@gmail.com> References: <57c63afe0711180759l6348dd6eh375b328f4f6d9657@mail.gmail.com> <4AC9A066-9632-4955-B1A4-45FBA884F6F7@gmail.com> Message-ID: On 19/11/2007, at 5:05 AM, Nathan Sutton wrote: > 0 > > Keep it, but make it a configuration option with default-off. > > Nathan Sutton > fowlduck at gmail.com > rspec edge revision 2894 > rspec_on_rails edge revision 2894 > rails edge revision 8146 > > I agree. +1 configuration with default being current behaviour. Cheers Shane From eloy.de.enige at gmail.com Sun Nov 18 13:57:38 2007 From: eloy.de.enige at gmail.com (Eloy Duran) Date: Sun, 18 Nov 2007 19:57:38 +0100 Subject: [rspec-users] Using RSpec to drive the design of a GUI desktop application In-Reply-To: References: <67974203-EDC9-419E-A3EC-8ECD72CDCDD8@gmail.com> <57c63afe0711180656j2e797b07s1c853c487877c5f4@mail.gmail.com> Message-ID: <14FD1A9D-F498-4187-B363-E270E1B21117@gmail.com> Yes sorry I meant that rucola isn't fine tuned for rspec yet. :) But apperantly Chris is going to work on this. Eloy On 18-nov-2007, at 16:45, Chris McGrath wrote: > > On 18 Nov 2007, at 14:56, David Chelimsky wrote: > >> On Nov 18, 2007 6:36 AM, Eloy Duran wrote: >>> Atm I don't use rSpec but rather test/spec. >>> So there are probably some hurdles to overcome if you really wish to >>> use rSpec. >> >> What hurdles would you anticipate? > > I don't think there are any insurmountable ones, we just need to make > sure rucola is testing framework agnostic like merb. I'm going to have > a go at integrating rspec tests later this evening as I want to use > rspec with rubycocoa. > > Cheers, > > Chris > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From smingins at elctech.com Sun Nov 18 14:07:44 2007 From: smingins at elctech.com (Shane Mingins) Date: Mon, 19 Nov 2007 08:07:44 +1300 Subject: [rspec-users] Down with Lambda!! In-Reply-To: <57c63afe0711171601v552a8d57m43643c6f3e6e7e3c@mail.gmail.com> References: <0444c73bc10306af8bedd5da057c7c9c@ruby-forum.com> <57c63afe0711171601v552a8d57m43643c6f3e6e7e3c@mail.gmail.com> Message-ID: On 18/11/2007, at 1:01 PM, David Chelimsky wrote: > We're still writing Ruby here, aren't we!!! > > Cheers, > David > > Wanted to share my initial reaction to your Ruby statement. Are we writing Ruby here? Or are we writing specifications? Are we not using the power of the Ruby language to construct a DSL that allows us to construct specifications about the behaviour of our code? Wouldn't the ideal be that I could create Behaviour specifications using RSpec or JSpec or CSpec (or whatever) using language that is natural to writing specifications? So something like lambda ... which is a word I always have trouble typing ;-) ... would not seem natural to the domain of BDD? These were just my initial thoughts :-) On the actual implementation side ... if I really wanted doing in my specs I would add the one line and not really care too much that this is what I need to do. Cheers Shane From win at wincent.com Sun Nov 18 14:19:40 2007 From: win at wincent.com (Wincent Colaiuta) Date: Sun, 18 Nov 2007 20:19:40 +0100 Subject: [rspec-users] Down with Lambda!! In-Reply-To: References: Message-ID: <0B1A88CA-3234-4EB3-AD92-916BBF282782@wincent.com> El 18/11/2007, a las 0:59, aslak.hellesoy at gmail.com escribi?: > Probably not. There was a longer discussion of it here: > http://rubyforge.org/tracker/index.php?func=detail&aid=13837&group_id=797&atid=3152 > > As you point out, creating an alias is a one-liner. > The main reason I don't want to add it is that lambda is a common > idiom, and I don't want to set precedence of aliasing core Ruby idioms > just because some people don't like the ones in Ruby. But it could be argued that RSpec is a Domain Specific Language of its own, and it's not Ruby; it just happens to be implemented in Ruby. Having said that, I'm fine with using "lambda" and even if I wasn't adding an alias to my spec_helper.rb would be no problem if I felt strongly about it. Cheers, Wincent From jonathan at parkerhill.com Sun Nov 18 15:59:21 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Sun, 18 Nov 2007 15:59:21 -0500 Subject: [rspec-users] Down with Lambda!! In-Reply-To: References: <0444c73bc10306af8bedd5da057c7c9c@ruby-forum.com> <57c63afe0711171601v552a8d57m43643c6f3e6e7e3c@mail.gmail.com> Message-ID: <934B9FD3-C32C-4AFB-8DAF-A026C43CE7EB@parkerhill.com> # for readability alias :running :lambda Q.E.D. On Nov 18, 2007, at 2:07 PM, Shane Mingins wrote: > > On 18/11/2007, at 1:01 PM, David Chelimsky wrote: >> We're still writing Ruby here, aren't we!!! >> >> Cheers, >> David >> >> > > > Wanted to share my initial reaction to your Ruby statement. > > Are we writing Ruby here? Or are we writing specifications? Are we > not using the power of the Ruby language to construct a DSL that > allows us to construct specifications about the behaviour of our code? > > Wouldn't the ideal be that I could create Behaviour specifications > using RSpec or JSpec or CSpec (or whatever) using language that is > natural to writing specifications? So something like lambda ... > which is a word I always have trouble typing ;-) ... would not seem > natural to the domain of BDD? > > These were just my initial thoughts :-) > > On the actual implementation side ... if I really wanted doing in my > specs I would add the one line and not really care too much that this > is what I need to do. > > Cheers > Shane > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sun Nov 18 16:10:58 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 18 Nov 2007 15:10:58 -0600 Subject: [rspec-users] [ANN] Lighthouse and Engine Yard sponsorships Message-ID: <57c63afe0711181310i7d6c08e2ib6f826221b837af8@mail.gmail.com> Hey all, I'm very happy to announce that ActiveReload[1] has generously offered to sponsor a lighthouse[2] account for rspec. We'll be moving ticket tracking there. We've already got the account set up and will soon make it public. We're also going to be getting a sponsored slice at Engine Yard[3] to host source control, which will be either mercurial or git (TBD but we're leaning towards mercurial). We'll continue to push source to svn at rubyforge, so those of you who prefer to stay with svn can do so, but those changes will likely be pushed once daily as opposed to every commit. It's going to take some time before we get these new systems up and operational. We'll make additional announcements as we get closer to actually making the moves. Cheers, David [1] http://activereload.net [2] http://lighthouseapp.com/ [3] http://engineyard.com From dchelimsky at gmail.com Sun Nov 18 16:16:41 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 18 Nov 2007 15:16:41 -0600 Subject: [rspec-users] help anyone? Message-ID: <57c63afe0711181316l7875bcdcsda1927b9e61f6b0e@mail.gmail.com> Hi everybody. Per http://rubyforge.org/pipermail/rspec-users/2007-November/004572.html, we're going to be moving ticket tracking over to lighthouse. We'd like to get this rolling sooner than later, but we're fairly well occupied getting ready for the 1.1 release and writing rspec books :) We've got the lighthouse account set up. The thing we need to do to start using it is to get all the open tickets at rubyforge copied over to lighthouse. As of today, lighthouse does not offer any sort of automated means of doing that. If any of you are interested in helping out by either manually copying tickets over or devising an automated means of doing so, please speak up. It would be a big help to the both the rspec community and the rspec development team. Cheers, David From mailing_lists at railsnewbie.com Sun Nov 18 16:24:26 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 18 Nov 2007 16:24:26 -0500 Subject: [rspec-users] [ANN] Lighthouse and Engine Yard sponsorships In-Reply-To: <57c63afe0711181310i7d6c08e2ib6f826221b837af8@mail.gmail.com> References: <57c63afe0711181310i7d6c08e2ib6f826221b837af8@mail.gmail.com> Message-ID: <79F32A2C-23A9-4911-B292-60ACBDDBFD71@railsnewbie.com> On Nov 18, 2007, at 4:10 PM, David Chelimsky wrote: > Hey all, > > I'm very happy to announce that ActiveReload[1] has generously offered > to sponsor a lighthouse[2] account for rspec. We'll be moving ticket > tracking there. We've already got the account set up and will soon > make it public. > > We're also going to be getting a sponsored slice at Engine Yard[3] to > host source control, which will be either mercurial or git (TBD but > we're leaning towards mercurial). We'll continue to push source to svn > at rubyforge, so those of you who prefer to stay with svn can do so, > but those changes will likely be pushed once daily as opposed to every > commit. > > It's going to take some time before we get these new systems up and > operational. We'll make additional announcements as we get closer to > actually making the moves. Out of curiosity, is there a way for subversion to check out from a git or mercurial repository? Also - why are you favoring mercurial over git? Scott From jonathan at parkerhill.com Sun Nov 18 17:16:43 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Sun, 18 Nov 2007 17:16:43 -0500 Subject: [rspec-users] help anyone? In-Reply-To: <57c63afe0711181316l7875bcdcsda1927b9e61f6b0e@mail.gmail.com> References: <57c63afe0711181316l7875bcdcsda1927b9e61f6b0e@mail.gmail.com> Message-ID: David, If no one else offers a more efficient solution, I'm willing to manually copy the open tickets. (I count 37 of them) I have read access to Rubyforge and see this as an opportunity to get familiar with lighthouse Jonathan On Nov 18, 2007, at 4:16 PM, David Chelimsky wrote: > Hi everybody. > > Per http://rubyforge.org/pipermail/rspec-users/2007-November/ > 004572.html, > we're going to be moving ticket tracking over to lighthouse. We'd like > to get this rolling sooner than later, but we're fairly well occupied > getting ready for the 1.1 release and writing rspec books :) > > We've got the lighthouse account set up. The thing we need to do to > start using it is to get all the open tickets at rubyforge copied over > to lighthouse. As of today, lighthouse does not offer any sort of > automated means of doing that. > > If any of you are interested in helping out by either manually copying > tickets over or devising an automated means of doing so, please speak > up. It would be a big help to the both the rspec community and the > rspec development team. > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sun Nov 18 17:26:17 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 18 Nov 2007 16:26:17 -0600 Subject: [rspec-users] help anyone? In-Reply-To: References: <57c63afe0711181316l7875bcdcsda1927b9e61f6b0e@mail.gmail.com> Message-ID: <57c63afe0711181426m10730239g3b8c7f4c52c390e3@mail.gmail.com> On Nov 18, 2007 4:16 PM, Jonathan Linowes wrote: > David, > > If no one else offers a more efficient solution, I'm willing to > manually copy the open tickets. (I count 37 of them) > I have read access to Rubyforge > and see this as an opportunity to get familiar with lighthouse Thanks Jonathan, but Chad Humpries has already offered to do this (on the rspec-devel list). Also - there are 37 but there are also 9 patches and 77 feature requests. We need them all to get moved over. If you want to coordinate w/ Chad and Scott (who also volunteered), perhaps you guys can divide and conquer. Cheers, David > > Jonathan > > > On Nov 18, 2007, at 4:16 PM, David Chelimsky wrote: > > > > Hi everybody. > > > > Per http://rubyforge.org/pipermail/rspec-users/2007-November/ > > 004572.html, > > we're going to be moving ticket tracking over to lighthouse. We'd like > > to get this rolling sooner than later, but we're fairly well occupied > > getting ready for the 1.1 release and writing rspec books :) > > > > We've got the lighthouse account set up. The thing we need to do to > > start using it is to get all the open tickets at rubyforge copied over > > to lighthouse. As of today, lighthouse does not offer any sort of > > automated means of doing that. > > > > If any of you are interested in helping out by either manually copying > > tickets over or devising an automated means of doing so, please speak > > up. It would be a big help to the both the rspec community and the > > rspec development team. > > > > Cheers, > > David > > _______________________________________________ > > 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 Sun Nov 18 17:34:30 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 18 Nov 2007 16:34:30 -0600 Subject: [rspec-users] help anyone? In-Reply-To: <57c63afe0711181316l7875bcdcsda1927b9e61f6b0e@mail.gmail.com> References: <57c63afe0711181316l7875bcdcsda1927b9e61f6b0e@mail.gmail.com> Message-ID: <57c63afe0711181434o7d948049p490d32378c38147a@mail.gmail.com> On Nov 18, 2007 3:16 PM, David Chelimsky wrote: > Hi everybody. > > Per http://rubyforge.org/pipermail/rspec-users/2007-November/004572.html, > we're going to be moving ticket tracking over to lighthouse. We'd like > to get this rolling sooner than later, but we're fairly well occupied > getting ready for the 1.1 release and writing rspec books :) > > We've got the lighthouse account set up. The thing we need to do to > start using it is to get all the open tickets at rubyforge copied over > to lighthouse. As of today, lighthouse does not offer any sort of > automated means of doing that. > > If any of you are interested in helping out by either manually copying > tickets over or devising an automated means of doing so, please speak > up. It would be a big help to the both the rspec community and the > rspec development team. A few people have offered on the two different lists (rspec-users and rspec-devel), so it looks like this might happen sooner than later. Some ground rules: We need to get all of the open tickets at rubyforge in all three trackers: bugs, patches and feature requests. Right now there are 123 in total. There is only one tracker at lighthouse, and tickets are grouped via tags. So tickets that come from the bug tracker should be tagged 'bug'. From Feature Requests: 'featurerequest'. From Patches: 'patch'. Simple? The LH ticket should either include all of the commentary from the RF ticket or at least a link back to the old ticket for reference. Do not worry about assigning responsibility. We will grab tickets that we want to work on. When they get moved over, they should get closed on rubyforge with a message saying "This ticket was moved to" with a link to the new ticket. I'll put up a notice on Rubyforge that we are moving to lighthouse and new tickets should go there with a cutoff (i.e. any ticket above 15719 on rubyforge will be ignored). I don't know yet if I can archive those trackers. I'll look into that this week. Questions? Cheers, David > > Cheers, > David > From omen.king at gmail.com Sun Nov 18 17:58:37 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 18 Nov 2007 17:58:37 -0500 Subject: [rspec-users] help anyone? In-Reply-To: <57c63afe0711181434o7d948049p490d32378c38147a@mail.gmail.com> References: <57c63afe0711181316l7875bcdcsda1927b9e61f6b0e@mail.gmail.com> <57c63afe0711181434o7d948049p490d32378c38147a@mail.gmail.com> Message-ID: If you want help moving them over give me a shout. On Nov 18, 2007 5:34 PM, David Chelimsky wrote: > On Nov 18, 2007 3:16 PM, David Chelimsky wrote: > > Hi everybody. > > > > Per http://rubyforge.org/pipermail/rspec-users/2007-November/004572.html > , > > we're going to be moving ticket tracking over to lighthouse. We'd like > > to get this rolling sooner than later, but we're fairly well occupied > > getting ready for the 1.1 release and writing rspec books :) > > > > We've got the lighthouse account set up. The thing we need to do to > > start using it is to get all the open tickets at rubyforge copied over > > to lighthouse. As of today, lighthouse does not offer any sort of > > automated means of doing that. > > > > If any of you are interested in helping out by either manually copying > > tickets over or devising an automated means of doing so, please speak > > up. It would be a big help to the both the rspec community and the > > rspec development team. > > A few people have offered on the two different lists (rspec-users and > rspec-devel), so it looks like this might happen sooner than later. > > Some ground rules: > > We need to get all of the open tickets at rubyforge in all three > trackers: bugs, patches and feature requests. Right now there are 123 > in total. > > There is only one tracker at lighthouse, and tickets are grouped via > tags. So tickets that come from the bug tracker should be tagged > 'bug'. From Feature Requests: 'featurerequest'. From Patches: 'patch'. > Simple? > > The LH ticket should either include all of the commentary from the RF > ticket or at least a link back to the old ticket for reference. > > Do not worry about assigning responsibility. We will grab tickets that > we want to work on. > > When they get moved over, they should get closed on rubyforge with a > message saying "This ticket was moved to" with a link to the new > ticket. > > I'll put up a notice on Rubyforge that we are moving to lighthouse and > new tickets should go there with a cutoff (i.e. any ticket above 15719 > on rubyforge will be ignored). I don't know yet if I can archive those > trackers. I'll look into that this week. > > Questions? > > Cheers, > David > > > > > Cheers, > > David > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071118/7952289e/attachment.html From has.sox at gmail.com Sun Nov 18 18:17:38 2007 From: has.sox at gmail.com (Daniel N) Date: Mon, 19 Nov 2007 10:17:38 +1100 Subject: [rspec-users] [ANN] Lighthouse and Engine Yard sponsorships In-Reply-To: <79F32A2C-23A9-4911-B292-60ACBDDBFD71@railsnewbie.com> References: <57c63afe0711181310i7d6c08e2ib6f826221b837af8@mail.gmail.com> <79F32A2C-23A9-4911-B292-60ACBDDBFD71@railsnewbie.com> Message-ID: <2fff50390711181517l418f6387k3ca560602df370f6@mail.gmail.com> On Nov 19, 2007 8:24 AM, Scott Taylor wrote: > > On Nov 18, 2007, at 4:10 PM, David Chelimsky wrote: > > > Hey all, > > > > I'm very happy to announce that ActiveReload[1] has generously offered > > to sponsor a lighthouse[2] account for rspec. We'll be moving ticket > > tracking there. We've already got the account set up and will soon > > make it public. > > > > We're also going to be getting a sponsored slice at Engine Yard[3] to > > host source control, which will be either mercurial or git (TBD but > > we're leaning towards mercurial). We'll continue to push source to svn > > at rubyforge, so those of you who prefer to stay with svn can do so, > > but those changes will likely be pushed once daily as opposed to every > > commit. > > > > It's going to take some time before we get these new systems up and > > operational. We'll make additional announcements as we get closer to > > actually making the moves. > > Out of curiosity, is there a way for subversion to check out from a > git or mercurial repository? > > Also - why are you favoring mercurial over git? > > Scott > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Please use Git. I've just got to know it ;) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071119/81336474/attachment.html From geoffrey.wiseman at gmail.com Sun Nov 18 18:28:50 2007 From: geoffrey.wiseman at gmail.com (Geoffrey Wiseman) Date: Sun, 18 Nov 2007 18:28:50 -0500 Subject: [rspec-users] [ANN] Lighthouse and Engine Yard sponsorships In-Reply-To: <2fff50390711181517l418f6387k3ca560602df370f6@mail.gmail.com> References: <57c63afe0711181310i7d6c08e2ib6f826221b837af8@mail.gmail.com> <79F32A2C-23A9-4911-B292-60ACBDDBFD71@railsnewbie.com> <2fff50390711181517l418f6387k3ca560602df370f6@mail.gmail.com> Message-ID: <835d522e0711181528u74f86cf1h77c5cf282e9b165b@mail.gmail.com> On Nov 18, 2007 6:17 PM, Daniel N wrote: > Please use Git. I've just got to know it ;) > Please use Mercurial. I've just got to know it. ;) (Actually, I don't much mind; I have Mercurial installed, but I don't have to interact with rspec source control often enough to mind so much what you use. It's far more important for the committers to pick the tool that works for them.) - Geoffrey -- Geoffrey Wiseman -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071118/4e38ef9a/attachment.html From kevwil at gmail.com Sun Nov 18 19:57:17 2007 From: kevwil at gmail.com (Kevin Williams) Date: Sun, 18 Nov 2007 17:57:17 -0700 Subject: [rspec-users] [ANN] Lighthouse and Engine Yard sponsorships In-Reply-To: <835d522e0711181528u74f86cf1h77c5cf282e9b165b@mail.gmail.com> References: <57c63afe0711181310i7d6c08e2ib6f826221b837af8@mail.gmail.com> <79F32A2C-23A9-4911-B292-60ACBDDBFD71@railsnewbie.com> <2fff50390711181517l418f6387k3ca560602df370f6@mail.gmail.com> <835d522e0711181528u74f86cf1h77c5cf282e9b165b@mail.gmail.com> Message-ID: <683a886f0711181657v3225df8ar2972be1c78f2a9ae@mail.gmail.com> I don't intend to use RSpec source either, but I suspect the most people would be satisfied with a main Subversion repository. Git users can check out from / in to a Subversion repository just fine. On Nov 18, 2007 4:28 PM, Geoffrey Wiseman wrote: > On Nov 18, 2007 6:17 PM, Daniel N wrote: > > > > > > > Please use Git. I've just got to know it ;) > > > > Please use Mercurial. I've just got to know it. ;) > > (Actually, I don't much mind; I have Mercurial installed, but I don't have > to interact with rspec source control often enough to mind so much what you > use. It's far more important for the committers to pick the tool that works > for them.) > > - Geoffrey > -- > Geoffrey Wiseman > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From luislavena at gmail.com Sun Nov 18 20:12:59 2007 From: luislavena at gmail.com (Luis Lavena) Date: Sun, 18 Nov 2007 22:12:59 -0300 Subject: [rspec-users] [ANN] Lighthouse and Engine Yard sponsorships In-Reply-To: <683a886f0711181657v3225df8ar2972be1c78f2a9ae@mail.gmail.com> References: <57c63afe0711181310i7d6c08e2ib6f826221b837af8@mail.gmail.com> <79F32A2C-23A9-4911-B292-60ACBDDBFD71@railsnewbie.com> <2fff50390711181517l418f6387k3ca560602df370f6@mail.gmail.com> <835d522e0711181528u74f86cf1h77c5cf282e9b165b@mail.gmail.com> <683a886f0711181657v3225df8ar2972be1c78f2a9ae@mail.gmail.com> Message-ID: <71166b3b0711181712o39010985w148445da88953e9f@mail.gmail.com> On Nov 18, 2007 9:57 PM, Kevin Williams wrote: > I don't intend to use RSpec source either, but I suspect the most > people would be satisfied with a main Subversion repository. Git users > can check out from / in to a Subversion repository just fine. > That poses a problem for the poor souls trapped in Windows. Yeah, there is mingw-git, but not so fancy and powerful like the *nix users could enjoy. Mercurial, like Bazaar play nice with windows, so I'll not have a problem with that. Regarding use of packages vs. code is a problem when you need to "update" your plugins (rspec and rspec_on_rails) if a bug you found with the release got fixed in the repository. -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From kevwil at gmail.com Sun Nov 18 23:21:21 2007 From: kevwil at gmail.com (Kevin Williams) Date: Sun, 18 Nov 2007 21:21:21 -0700 Subject: [rspec-users] [ANN] Lighthouse and Engine Yard sponsorships In-Reply-To: <71166b3b0711181712o39010985w148445da88953e9f@mail.gmail.com> References: <57c63afe0711181310i7d6c08e2ib6f826221b837af8@mail.gmail.com> <79F32A2C-23A9-4911-B292-60ACBDDBFD71@railsnewbie.com> <2fff50390711181517l418f6387k3ca560602df370f6@mail.gmail.com> <835d522e0711181528u74f86cf1h77c5cf282e9b165b@mail.gmail.com> <683a886f0711181657v3225df8ar2972be1c78f2a9ae@mail.gmail.com> <71166b3b0711181712o39010985w148445da88953e9f@mail.gmail.com> Message-ID: <683a886f0711182021jabb3922s21f17398bd4e4426@mail.gmail.com> On 11/18/07, Luis Lavena wrote: > On Nov 18, 2007 9:57 PM, Kevin Williams wrote: > > I don't intend to use RSpec source either, but I suspect the most > > people would be satisfied with a main Subversion repository. Git users > > can check out from / in to a Subversion repository just fine. > > > > That poses a problem for the poor souls trapped in Windows. No it doesn't. Subversion works great on Windows. Windows users can try to use Git in Cygwin if they really want to, but they can also just use TortoiseSVN or whatever favorite Subversion client they want. With a Subversion repository, you can choose between Subversion as a client or Git as a client (yes, it's actually a local clone of the repository, but a client of the main svn repo as well). http://git.or.cz/course/svn.html http://blog.nbwd.co.uk/2007/8/16/using-git-for-rails-development Mercurial is a great system. I love the x-platform nature, and it works great. I love the svn-like aliases such as "hg up" or "hg ci -m 'foo'". I've used it on a number of projects. I've since switched to Git because I like the branching/merging behavior much better and because you can clone from and commit back to a Subversion repository. Choosing Mercurial is fine, but choosing a Subversion repository might please more people in the long run. Just an idea, not my religion. :) From nathan.sutton at gmail.com Sun Nov 18 23:57:44 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Sun, 18 Nov 2007 22:57:44 -0600 Subject: [rspec-users] Stories and Pending Actions Message-ID: I can't get my plain text stories to show pending actions like the example addition plain text story. Any tips? (See below) http://pastie.caboo.se/119627 Nathan Sutton fowlduck at gmail.com rspec edge revision 2910 rspec_on_rails edge revision 2909 rails edge revision 8167 From glenn at aldenta.com Mon Nov 19 00:13:44 2007 From: glenn at aldenta.com (Glenn Ford) Date: Mon, 19 Nov 2007 00:13:44 -0500 Subject: [rspec-users] helper methods starting with should In-Reply-To: References: <57c63afe0711180759l6348dd6eh375b328f4f6d9657@mail.gmail.com> <4AC9A066-9632-4955-B1A4-45FBA884F6F7@gmail.com> Message-ID: <379CA125-027B-428D-B4B9-DC6A82C9AE8D@aldenta.com> -1 I, as a new rspec user, did not find the switch between test_ and it "blah" do to be even a small challenge compared to other things I had to convert and learn. I only feel like it would be one more thing to keep up with that would cause problems. I can certainly see someone writing a helper method with should_ and saying "what the heck is going on" because they didn't fully read all the documentation. It was plenty easy in my conversion to say "oh ok, find and replace test_ and put it "should" in place of that". I would have certainly been frustrated to find a hidden "feature" causing problems that I didn't understand. Keeping in mind my original n00b perspective, I feel like if in my first impression I had the option of turning on a baby-step feature that I might have either, A - not known about it because I didn't see it in my first tutorial, or, B - skipped it feeling that I could handle making that transition into the "accepted" way. I can see how some people might find use for it, but I believe overall the complexity would cause more confusion than it would prevent. There's my 2 cents. Glenn On Nov 18, 2007, at 1:52 PM, Shane Mingins wrote: > > On 19/11/2007, at 5:05 AM, Nathan Sutton wrote: > >> 0 >> >> Keep it, but make it a configuration option with default-off. >> >> Nathan Sutton >> fowlduck at gmail.com >> rspec edge revision 2894 >> rspec_on_rails edge revision 2894 >> rails edge revision 8146 >> >> > > I agree. +1 configuration with default being current behaviour. > > Cheers > Shane > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From chad at spicycode.com Mon Nov 19 00:41:53 2007 From: chad at spicycode.com (Chad Humphries) Date: Mon, 19 Nov 2007 00:41:53 -0500 Subject: [rspec-users] [rspec-devel] help anyone? In-Reply-To: <57c63afe0711181426m10730239g3b8c7f4c52c390e3@mail.gmail.com> References: <57c63afe0711181316l7875bcdcsda1927b9e61f6b0e@mail.gmail.com> <57c63afe0711181426m10730239g3b8c7f4c52c390e3@mail.gmail.com> Message-ID: David, The move should be complete now. -Chad On Nov 18, 2007, at 5:26 PM, David Chelimsky wrote: > On Nov 18, 2007 4:16 PM, Jonathan Linowes > wrote: >> David, >> >> If no one else offers a more efficient solution, I'm willing to >> manually copy the open tickets. (I count 37 of them) >> I have read access to Rubyforge >> and see this as an opportunity to get familiar with lighthouse > > Thanks Jonathan, but Chad Humpries has already offered to do this (on > the rspec-devel list). > > Also - there are 37 but there are also 9 patches and 77 feature > requests. We need them all to get moved over. > > If you want to coordinate w/ Chad and Scott (who also volunteered), > perhaps you guys can divide and conquer. > > Cheers, > David > >> >> Jonathan >> >> >> On Nov 18, 2007, at 4:16 PM, David Chelimsky wrote: >> >> >>> Hi everybody. >>> >>> Per http://rubyforge.org/pipermail/rspec-users/2007-November/ >>> 004572.html, >>> we're going to be moving ticket tracking over to lighthouse. We'd >>> like >>> to get this rolling sooner than later, but we're fairly well >>> occupied >>> getting ready for the 1.1 release and writing rspec books :) >>> >>> We've got the lighthouse account set up. The thing we need to do to >>> start using it is to get all the open tickets at rubyforge copied >>> over >>> to lighthouse. As of today, lighthouse does not offer any sort of >>> automated means of doing that. >>> >>> If any of you are interested in helping out by either manually >>> copying >>> tickets over or devising an automated means of doing so, please >>> speak >>> up. It would be a big help to the both the rspec community and the >>> rspec development team. >>> >>> Cheers, >>> David >>> _______________________________________________ >>> 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-devel mailing list > rspec-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-devel From dchelimsky at gmail.com Mon Nov 19 04:23:16 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 19 Nov 2007 03:23:16 -0600 Subject: [rspec-users] Stories and Pending Actions In-Reply-To: References: Message-ID: <57c63afe0711190123y211f66foe6955facc1e26206@mail.gmail.com> On Nov 18, 2007 10:57 PM, Nathan Sutton wrote: > I can't get my plain text stories to show pending actions like the > example addition plain text story. Any tips? (See below) > > http://pastie.caboo.se/119627 Given, When, Then and And don't take a colon because they are the first words of sentences: # this will get processed Given a space shuttle # this will not (treated as a comment) Given: A space shuttle That kinda sucks. And so ... http://rspec.lighthouseapp.com/projects/5645/tickets/132 > > Nathan Sutton > fowlduck at gmail.com > rspec edge revision 2910 > rspec_on_rails edge revision 2909 > rails edge revision 8167 > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Nov 19 04:30:25 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 19 Nov 2007 03:30:25 -0600 Subject: [rspec-users] [rspec-devel] help anyone? In-Reply-To: References: <57c63afe0711181316l7875bcdcsda1927b9e61f6b0e@mail.gmail.com> <57c63afe0711181426m10730239g3b8c7f4c52c390e3@mail.gmail.com> Message-ID: <57c63afe0711190130m78955fe2t92d1268c991458a2@mail.gmail.com> On Nov 18, 2007 11:41 PM, Chad Humphries wrote: > David, > > The move should be complete now. Thank you, thank you, thank you. Great effort. Much appreciated! Cheers, David > > -Chad > > > On Nov 18, 2007, at 5:26 PM, David Chelimsky wrote: > > > On Nov 18, 2007 4:16 PM, Jonathan Linowes > > wrote: > >> David, > >> > >> If no one else offers a more efficient solution, I'm willing to > >> manually copy the open tickets. (I count 37 of them) > >> I have read access to Rubyforge > >> and see this as an opportunity to get familiar with lighthouse > > > > Thanks Jonathan, but Chad Humpries has already offered to do this (on > > the rspec-devel list). > > > > Also - there are 37 but there are also 9 patches and 77 feature > > requests. We need them all to get moved over. > > > > If you want to coordinate w/ Chad and Scott (who also volunteered), > > perhaps you guys can divide and conquer. > > > > Cheers, > > David > > > >> > >> Jonathan > >> > >> > >> On Nov 18, 2007, at 4:16 PM, David Chelimsky wrote: > >> > >> > >>> Hi everybody. > >>> > >>> Per http://rubyforge.org/pipermail/rspec-users/2007-November/ > >>> 004572.html, > >>> we're going to be moving ticket tracking over to lighthouse. We'd > >>> like > >>> to get this rolling sooner than later, but we're fairly well > >>> occupied > >>> getting ready for the 1.1 release and writing rspec books :) > >>> > >>> We've got the lighthouse account set up. The thing we need to do to > >>> start using it is to get all the open tickets at rubyforge copied > >>> over > >>> to lighthouse. As of today, lighthouse does not offer any sort of > >>> automated means of doing that. > >>> > >>> If any of you are interested in helping out by either manually > >>> copying > >>> tickets over or devising an automated means of doing so, please > >>> speak > >>> up. It would be a big help to the both the rspec community and the > >>> rspec development team. > >>> > >>> Cheers, > >>> David > >>> _______________________________________________ > >>> 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-devel mailing list > > rspec-devel at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-devel > > _______________________________________________ > rspec-devel mailing list > rspec-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-devel > From dchelimsky at gmail.com Mon Nov 19 04:37:38 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 19 Nov 2007 03:37:38 -0600 Subject: [rspec-users] [ANN] Ticket tracking moved to lighthouse Message-ID: <57c63afe0711190137y15d237car6f64454428fde53e@mail.gmail.com> Hi everyone, We've moved ticket tracking for the rspec project to http://rspec.lighthouseapp.com! Thanks to a valiant effort from Chad Humphries, the move was done in an evening. For those of you on the rspec-devel list, apologies for the wealth of noise in this process. I set the trackers to stop sending email and they apparently didn't listen. For those of you who submitted tickets and were keeping an eye on them at rubyforge, you'll need to set yourself up as a Watcher on the ticket. Please go to http://rspec.lighthouseapp.com, search for your ticket and click on the Watch This Ticket button on your ticket (you'll need to sign up to do this). Cheers, David From yura at brainhouse.ru Mon Nov 19 09:04:42 2007 From: yura at brainhouse.ru (Yury Kotlyarov) Date: Mon, 19 Nov 2007 17:04:42 +0300 Subject: [rspec-users] Spec::Rails::DSL::HelperEvalContextController: missing defau In-Reply-To: <57c63afe0710151042q2973dbb6had4b7511dc3df252@mail.gmail.com> References: <1b9e62c091d5b8ea17b6a2698d3f3c52@ruby-forum.com> <57c63afe0710151042q2973dbb6had4b7511dc3df252@mail.gmail.com> Message-ID: <474197FA.5050709@brainhouse.ru> got the same by running autotest. fixed by adding following files to rspec_on_rails: lib/spec/rails/example/helper_behaviour_helper.rb lib/spec/rails/example/view_example_helper.rb --Yury David Chelimsky wrote: > On 10/15/07, Chris Olsen wrote: > >> Just created a new project and this is the error that I am getting when >> I try to run my rspec tests: >> > > Please just call them "specs" :) > > What command are you using here? > > >> Spec::Rails::DSL::HelperEvalContextController: missing default helper >> path spec/rails/dsl/helper_eval_context_helper >> Spec::Rails::DSL::ViewExampleController: missing default helper path >> spec/rails/dsl/view_example_helper >> [4;36;1mSQL (0.000138) [0m [0;1mSET SQL_AUTO_IS_NULL=0 [0m >> [4;35;1mSQL (0.000095) [0m [0mBEGIN [0m >> [4;36;1mSite Columns (0.003708) [0m [0;1mSHOW FIELDS FROM >> sites [0m >> [4;35;1mSQL (0.000174) [0m [0mROLLBACK [0m >> >> Here is the portion for the test database from the database.yml file: >> test: >> adapter: mysql >> database: mydb_test >> username: root >> password: >> socket: /tmp/mysql.sock >> >> I have run the rake tmp:clear command (was mentioned by someone else >> with this same problem) >> >> Thanks for the help. >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From mailing_lists at railsnewbie.com Mon Nov 19 10:15:51 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Mon, 19 Nov 2007 10:15:51 -0500 Subject: [rspec-users] [rspec-devel] help anyone? In-Reply-To: <57c63afe0711190130m78955fe2t92d1268c991458a2@mail.gmail.com> References: <57c63afe0711181316l7875bcdcsda1927b9e61f6b0e@mail.gmail.com> <57c63afe0711181426m10730239g3b8c7f4c52c390e3@mail.gmail.com> <57c63afe0711190130m78955fe2t92d1268c991458a2@mail.gmail.com> Message-ID: <7B21A428-7987-43E3-93EC-74754D737AC1@railsnewbie.com> On Nov 19, 2007, at 4:30 AM, David Chelimsky wrote: > On Nov 18, 2007 11:41 PM, Chad Humphries wrote: >> David, >> >> The move should be complete now. > > Thank you, thank you, thank you. Great effort. Much appreciated! > Yes - another thanks. Sorry I couldn't help out. Had to take a trip to ER after my girlfriend's dog bit her in the lip. Scott From luislavena at gmail.com Mon Nov 19 10:55:59 2007 From: luislavena at gmail.com (Luis Lavena) Date: Mon, 19 Nov 2007 12:55:59 -0300 Subject: [rspec-users] [ANN] Lighthouse and Engine Yard sponsorships In-Reply-To: <683a886f0711182021jabb3922s21f17398bd4e4426@mail.gmail.com> References: <57c63afe0711181310i7d6c08e2ib6f826221b837af8@mail.gmail.com> <79F32A2C-23A9-4911-B292-60ACBDDBFD71@railsnewbie.com> <2fff50390711181517l418f6387k3ca560602df370f6@mail.gmail.com> <835d522e0711181528u74f86cf1h77c5cf282e9b165b@mail.gmail.com> <683a886f0711181657v3225df8ar2972be1c78f2a9ae@mail.gmail.com> <71166b3b0711181712o39010985w148445da88953e9f@mail.gmail.com> <683a886f0711182021jabb3922s21f17398bd4e4426@mail.gmail.com> Message-ID: <71166b3b0711190755xe810625x2b9ab724c08e7ccb@mail.gmail.com> On Nov 19, 2007 1:21 AM, Kevin Williams wrote: > On 11/18/07, Luis Lavena wrote: > > On Nov 18, 2007 9:57 PM, Kevin Williams wrote: > > > I don't intend to use RSpec source either, but I suspect the most > > > people would be satisfied with a main Subversion repository. Git users > > > can check out from / in to a Subversion repository just fine. > > > > > > > That poses a problem for the poor souls trapped in Windows. > > No it doesn't. Subversion works great on Windows. Windows users can > try to use Git in Cygwin if they really want to, but they can also > just use TortoiseSVN or whatever favorite Subversion client they want. > I wasn't talking about the svn clone, was talking about the sync policy "will be synch'ed one time at day"... That in combination with Git, make difficult to be "out of the box" useful. the use of cygwin git is a bit problematic, and sometimes eol styles mixes don't like the different interpreters (unix eol against windows eol) with ruby-mswin32 and ruby cygwin. > With a Subversion repository, you can choose between Subversion as a > client or Git as a client (yes, it's actually a local clone of the > repository, but a client of the main svn repo as well). > > http://git.or.cz/course/svn.html > http://blog.nbwd.co.uk/2007/8/16/using-git-for-rails-development > Again, was talking about that the git-to-svn sync. > Mercurial is a great system. I love the x-platform nature, and it > works great. I love the svn-like aliases such as "hg up" or "hg ci -m > 'foo'". I've used it on a number of projects. I've since switched to > Git because I like the branching/merging behavior much better and > because you can clone from and commit back to a Subversion repository. > Choosing Mercurial is fine, but choosing a Subversion repository might > please more people in the long run. Just an idea, not my religion. :) Bazaar also allow you repositories that share revision information between branches. I use it to patch upstream projects until they commit the fixes I sent to them :-) The git/mercurial over svn without a proper sync solution will be a problem for those users using script/plugin to install and use rspec on Rails applications -- since rails is highly integrated with svn for these commands. Anyway, just my comments :-) -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From nathan.sutton at gmail.com Mon Nov 19 12:00:16 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Mon, 19 Nov 2007 11:00:16 -0600 Subject: [rspec-users] Stories and Pending Actions In-Reply-To: <57c63afe0711190123y211f66foe6955facc1e26206@mail.gmail.com> References: <57c63afe0711190123y211f66foe6955facc1e26206@mail.gmail.com> Message-ID: <1E2C9C55-45FB-4FE4-B3E7-A63A530FFCC1@gmail.com> Perfect, thanks Dave. I can make a patch tonight, if ya want. Nathan Sutton fowlduck at gmail.com rspec edge revision 2910 rspec_on_rails edge revision 2909 rails edge revision 8167 On Nov 19, 2007, at 3:23 AM, David Chelimsky wrote: > On Nov 18, 2007 10:57 PM, Nathan Sutton > wrote: >> I can't get my plain text stories to show pending actions like the >> example addition plain text story. Any tips? (See below) >> >> http://pastie.caboo.se/119627 > > Given, When, Then and And don't take a colon because they are the > first words of sentences: > > # this will get processed > Given a space shuttle > > # this will not (treated as a comment) > Given: A space shuttle > > That kinda sucks. And so ... > > http://rspec.lighthouseapp.com/projects/5645/tickets/132 > >> >> Nathan Sutton >> fowlduck at gmail.com >> rspec edge revision 2910 >> rspec_on_rails edge revision 2909 >> rails edge revision 8167 >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Mon Nov 19 12:02:18 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 19 Nov 2007 11:02:18 -0600 Subject: [rspec-users] Stories and Pending Actions In-Reply-To: <1E2C9C55-45FB-4FE4-B3E7-A63A530FFCC1@gmail.com> References: <57c63afe0711190123y211f66foe6955facc1e26206@mail.gmail.com> <1E2C9C55-45FB-4FE4-B3E7-A63A530FFCC1@gmail.com> Message-ID: <57c63afe0711190902u589badbfrad95fb150f9104b1@mail.gmail.com> On Nov 19, 2007 11:00 AM, Nathan Sutton wrote: > Perfect, thanks Dave. I can make a patch tonight, if ya want. Great. Just attach it to the ticket. Thx > > Nathan Sutton > fowlduck at gmail.com > rspec edge revision 2910 > rspec_on_rails edge revision 2909 > rails edge revision 8167 > > > > > > > On Nov 19, 2007, at 3:23 AM, David Chelimsky wrote: > > > On Nov 18, 2007 10:57 PM, Nathan Sutton > > wrote: > >> I can't get my plain text stories to show pending actions like the > >> example addition plain text story. Any tips? (See below) > >> > >> http://pastie.caboo.se/119627 > > > > Given, When, Then and And don't take a colon because they are the > > first words of sentences: > > > > # this will get processed > > Given a space shuttle > > > > # this will not (treated as a comment) > > Given: A space shuttle > > > > That kinda sucks. And so ... > > > > http://rspec.lighthouseapp.com/projects/5645/tickets/132 > > > >> > >> Nathan Sutton > >> fowlduck at gmail.com > >> rspec edge revision 2910 > >> rspec_on_rails edge revision 2909 > >> rails edge revision 8167 > >> > >> > >> _______________________________________________ > >> 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 znmeb at cesmail.net Mon Nov 19 13:55:12 2007 From: znmeb at cesmail.net (M. Edward (Ed) Borasky) Date: Mon, 19 Nov 2007 10:55:12 -0800 Subject: [rspec-users] [ANN] Lighthouse and Engine Yard sponsorships In-Reply-To: <71166b3b0711190755xe810625x2b9ab724c08e7ccb@mail.gmail.com> References: <57c63afe0711181310i7d6c08e2ib6f826221b837af8@mail.gmail.com> <79F32A2C-23A9-4911-B292-60ACBDDBFD71@railsnewbie.com> <2fff50390711181517l418f6387k3ca560602df370f6@mail.gmail.com> <835d522e0711181528u74f86cf1h77c5cf282e9b165b@mail.gmail.com> <683a886f0711181657v3225df8ar2972be1c78f2a9ae@mail.gmail.com> <71166b3b0711181712o39010985w148445da88953e9f@mail.gmail.com> <683a886f0711182021jabb3922s21f17398bd4e4426@mail.gmail.com> <71166b3b0711190755xe810625x2b9ab724c08e7ccb@mail.gmail.com> Message-ID: <4741DC10.1020700@cesmail.net> Luis Lavena wrote: > the use of cygwin git is a bit problematic, and sometimes eol styles > mixes don't like the different interpreters (unix eol against windows > eol) with ruby-mswin32 and ruby cygwin. Yeah, I'll echo this. I do a lot of work with Perl, and it's a real bear to port Cygwin Perl scripts to ActiveState Perl because of this end-of-line nonsense. As far as I'm concerned, if you want to run Linux on a Windows machine, buy VMWare Workstation or download the free VMWare Server. From kevwil at gmail.com Mon Nov 19 16:57:08 2007 From: kevwil at gmail.com (Kevin Williams) Date: Mon, 19 Nov 2007 14:57:08 -0700 Subject: [rspec-users] [ANN] Lighthouse and Engine Yard sponsorships In-Reply-To: <71166b3b0711190755xe810625x2b9ab724c08e7ccb@mail.gmail.com> References: <57c63afe0711181310i7d6c08e2ib6f826221b837af8@mail.gmail.com> <79F32A2C-23A9-4911-B292-60ACBDDBFD71@railsnewbie.com> <2fff50390711181517l418f6387k3ca560602df370f6@mail.gmail.com> <835d522e0711181528u74f86cf1h77c5cf282e9b165b@mail.gmail.com> <683a886f0711181657v3225df8ar2972be1c78f2a9ae@mail.gmail.com> <71166b3b0711181712o39010985w148445da88953e9f@mail.gmail.com> <683a886f0711182021jabb3922s21f17398bd4e4426@mail.gmail.com> <71166b3b0711190755xe810625x2b9ab724c08e7ccb@mail.gmail.com> Message-ID: <683a886f0711191357o1260f95ew40e24c666f31914c@mail.gmail.com> On Nov 19, 2007 8:55 AM, Luis Lavena wrote: > On Nov 19, 2007 1:21 AM, Kevin Williams wrote: > > On 11/18/07, Luis Lavena wrote: > > > On Nov 18, 2007 9:57 PM, Kevin Williams wrote: > > > > I don't intend to use RSpec source either, but I suspect the most > > > > people would be satisfied with a main Subversion repository. Git users > > > > can check out from / in to a Subversion repository just fine. > > > > > > > > > > That poses a problem for the poor souls trapped in Windows. > > > > No it doesn't. Subversion works great on Windows. Windows users can > > try to use Git in Cygwin if they really want to, but they can also > > just use TortoiseSVN or whatever favorite Subversion client they want. > > > > I wasn't talking about the svn clone, was talking about the sync > policy "will be synch'ed one time at day"... I was suggesting to have only one main Subversion repository rather than two different repositories, so there would be no sync. If there are two repositories (one Git/Mercurial at EngineYard, one Subversion at Rubyforge) then certainly getting the sync right is important. > > That in combination with Git, make difficult to be "out of the box" useful. I'm not aware of anything special in Mercurial that would make this easier than Git out of the box. It seems Git would be easier, with full two-way sync with Subversion built in, but if Mercurial has this as well then I'd say they are about equal in this regard. > > the use of cygwin git is a bit problematic, and sometimes eol styles > mixes don't like the different interpreters (unix eol against windows > eol) with ruby-mswin32 and ruby cygwin. Yes, git on cygwin is a pain, and is only for the brave. The problem of Git for Windows users goes away if the main repository is Subversion. > > > With a Subversion repository, you can choose between Subversion as a > > client or Git as a client (yes, it's actually a local clone of the > > repository, but a client of the main svn repo as well). > > > > http://git.or.cz/course/svn.html > > http://blog.nbwd.co.uk/2007/8/16/using-git-for-rails-development > > > > Again, was talking about that the git-to-svn sync. http://blog.fallingsnow.net/2007/08/17/maintaining-an-svn-mirror-directly-from-git/ Mercurial can be used by Tailor in the same manner that Evan describes here, so I'd say they are equal in syncing. > The git/mercurial over svn without a proper sync solution will be a > problem for those users using script/plugin to install and use rspec > on Rails applications -- since rails is highly integrated with svn for > these commands. It wouldn't be a technical problem, as it would be business as usual for the "script/plugin install" process to pull from Rubyforge svn. The only problem I see might be a timing issue, but that could be fixed by sync'ing every commit. > > Anyway, just my comments :-) A fun discussion to have, I think. :) The switch to distributed version control is a paradigm shift for many, and I'm curious to see how this one turns out. From ed.howland at gmail.com Mon Nov 19 20:44:55 2007 From: ed.howland at gmail.com (Ed Howland) Date: Mon, 19 Nov 2007 19:44:55 -0600 Subject: [rspec-users] How to represent Story of Life grid in Then clause Message-ID: <3df642dd0711191744lbb250f5pdf0113f88f63223f@mail.gmail.com> In this story from Dan's Game of Life: Scenario: the grid has three cells Given 3 x 3 grid When I create a cell at 0, 0 And I create a cell at 0, 1 And I create a cell at 2, 2 Then the grid should look like: XX. ... ..X How do you set up matchers for the grid at the end. Are all the indented lines after a Then passed to the Then matcher as separate strings with multiple Then()s getting called or a single string separated by new lines? Thanks Ed -- Ed Howland http://greenprogrammer.blogspot.com "The information transmitted is intended only for the person or entity to which it is addressed and may contain proprietary, confidential and/or legally privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers." From jonathan at parkerhill.com Tue Nov 20 00:25:13 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 20 Nov 2007 00:25:13 -0500 Subject: [rspec-users] rake spec default environment In-Reply-To: <185323BC-A712-4763-92EC-0034C5A4A513@railsnewbie.com> References: <185323BC-A712-4763-92EC-0034C5A4A513@railsnewbie.com> Message-ID: <43AA75DA-1F5C-490B-8A3C-729F09830387@parkerhill.com> Hey scott, I'm running into this again What I'm trying to do is avoid 2 database.yml files -- one for my dev machine, one for the deploy server -- by adding a new "staging" environment that is like "test" but on the server Since the server doesnt have a "development" env or db, the rake spec fails Is there a way to force the rake task to copy the schema from "production" rather than "development"? linoj On Oct 29, 2007, at 10:55 AM, Scott Taylor wrote: > > On Oct 29, 2007, at 9:04 AM, Jonathan Linowes wrote: > >> hi, >> >> When I run rake spec , it seems to be starting with my default >> environment (development or production) and connects to that >> database, before actually connecting to the test one and proceeding >> with the tests. When I remove the development database, the specs >> wont run. How do i initiate rspec to be test environment from the >> start? I dont see this when i run using script/spec > > Well, usually the schema of the development database is copied to the > test one (you wouldn't want to run 100 migrations just because you > fired up your test now, would you?) > > Scott > >> >> linoj >> >> _______________________________________________ >> 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 hotfusionman at yahoo.com Tue Nov 20 01:00:37 2007 From: hotfusionman at yahoo.com (Al Chou) Date: Mon, 19 Nov 2007 22:00:37 -0800 (PST) Subject: [rspec-users] confirming that a model instance was correctly created from POST params Message-ID: <596768.80191.qm@web58712.mail.re1.yahoo.com> I'm wondering whether I'm wasting my time trying to verify that an addition I've made to legacy code is in fact setting a new attribute on a model. Substruct's (http://dev.subimage.com/projects/substruct) OrderHelper contains this method: 1 def create_order_from_post 2 @use_separate_shipping_address = params[:use_separate_shipping_address] 3 4 @order_user = OrderUser.find_or_create_by_email_address( 5 params[:order_user][:email_address] 6 ) 7 @order_user.valid? 8 9 @order = Order.new(params[:order]) 10 @order.valid? 11 12 # Look up billing address and update if customer is logged in. 13 if @customer 14 @billing_address = @customer.billing_address 15 @billing_address.attributes = params[:billing_address] 16 @shipping_address = @customer.billing_address 17 @shipping_address.attributes = params[:shipping_address] 18 else 19 @billing_address = OrderAddress.new(params[:billing_address]) 20 @shipping_address = OrderAddress.new(params[:shipping_address]) 21 end 22 @billing_address.valid? 23 24 if @use_separate_shipping_address 25 @shipping_address.valid? 26 end 27 28 @order_account = OrderAccount.new(params[:order_account]) 29 @order_account.valid? 30 31 OrderUser.transaction do 32 @order_user.save! 33 Order.transaction do 34 @order = @order_user.orders.build(params[:order]) 35 @order.order_number = Order.generate_order_number 36 @order.save! 37 end 38 OrderAddress.transaction do 39 # Addresses 40 @billing_address = @order_user.order_addresses.create(params[:billing_address]) 41 @billing_address.order_id = @order.id 42 @billing_address.is_shipping = true 43 @billing_address.save! 44 if @use_separate_shipping_address then 45 @shipping_address = @order_user.order_addresses.create(params[:shipping_address]) 46 @shipping_address.is_shipping = true 47 @billing_address.is_shipping = false 48 @billing_address.save! 49 @shipping_address.order_id = @order.id 50 @shipping_address.save! 51 end 52 end 53 OrderAccount.transaction do 54 @order_account = OrderAccount.new(params[:order_account]) 55 @order_account.order_id = @order.id 56 @order_account.order_user_id = @order_user.id 57 @order_account.order_address_id = @billing_address.id 58 @order_account.save! 59 end 60 end 61 end I am adding to the OrderAddress model the concept of whether an address is a business address (as opposed to a home/residential address): describe OrderHelper do it 'should record the fact that the address is a business address' do 1 order = mock_model( Order, :null_object => TRUE ) 2 order.stub!( :valid? ).and_return( TRUE ) 3 Order.stub!( :new ).and_return( order ) 4 order.stub!( :order_number= ) 5 order.stub!( :save! ) 6 7 params[:order_user] = Hash.new 8 params[:order_user][:email_address] = '' 9 order_user = mock_model( OrderUser ) 10 order_user.stub!( :valid? ).and_return( TRUE ) 11 order_user.stub!( :save! ) 12 orders = mock( 'orders' ) 13 orders.stub!( :build ).and_return( order ) 14 order_user.stub!( :orders ).and_return( orders ) 15 OrderUser.stub!( :find_or_create_by_email_address ).and_return( order_user ) 16 order_user.stub!( :order_addresses ).and_return( OrderAddress ) 17 18 order_address = mock_model( OrderAddress ) #, :null_object => TRUE ) 19 order_address.stub!( :valid? ).and_return( TRUE ) 20 OrderAddress.stub!( :new ).and_return( order_address ) 21 order_address.stub!( :order_id= ) 22 order_address.stub!( :is_shipping= ) 23 order_address.stub!( :save! ) 24 order_address.should_receive( :save ) 25 26 order_account = mock_model( OrderAccount ) 27 order_account.stub!( :valid? ).and_return( TRUE ) 28 order_account.stub!( :order_id= ) 29 order_account.stub!( :order_user_id= ) 30 order_account.stub!( :order_address_id= ) 31 order_account.stub!( :save! ) 32 OrderAccount.stub!( :new ).and_return( order_account ) 33 34 assigns[:use_separate_shipping_address] = FALSE 35 params[:is_business_address] = TRUE 36 create_order_from_post 37 38 assigns[:billing_address].is_business_address.should be_true end end What I am trying to demonstrate to myself is that the addition of a boolean "is_business_address" column to the order_addresses table via a migration allows line 40 of the create_order_from_post method to set this property when an OrderAddress instance is created. But my example as shown tells me that assigns[:billing_address] is nil when I run it. Also, I realize that line 16 of the example isn't returning the right thing; it should be an AssociationCollection of OrderAddress. That's where I'm starting to wonder if I'm spending too much time on something that is probably simple enough that it's already working but disproportionately hard to write an RSpec example for (because the existing create_order_from_post method has no tests or examples and thus isn't easy to test -- witness the 32 lines, modulo blank lines, of stubbing just to get the example to run). Suggestions on how to write the example, or advice on whether to continue to try, are requested. Al ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071119/cf3f5baf/attachment-0001.html From jarkko at jlaine.net Tue Nov 20 03:04:13 2007 From: jarkko at jlaine.net (Jarkko Laine) Date: Tue, 20 Nov 2007 10:04:13 +0200 Subject: [rspec-users] confirming that a model instance was correctly created from POST params In-Reply-To: <596768.80191.qm@web58712.mail.re1.yahoo.com> References: <596768.80191.qm@web58712.mail.re1.yahoo.com> Message-ID: <3A5E9DD3-A10D-4B23-AA73-3A3FEA9EA68B@jlaine.net> On 20.11.2007, at 8.00, Al Chou wrote: > What I am trying to demonstrate to myself is that the addition of a > boolean "is_business_address" column to the order_addresses table > via a migration allows line 40 of the create_order_from_post method > to set this property when an OrderAddress instance is created. But > my example as shown tells me that assigns[:billing_address] is nil > when I run it. Also, I realize that line 16 of the example isn't > returning the right thing; it should be an AssociationCollection of > OrderAddress. That's where I'm starting to wonder if I'm spending > too much time on something that is probably simple enough that it's > already working but disproportionately hard to write an RSpec > example for (because the existing create_order_from_post method has > no tests or examples and thus isn't easy to test -- witness the 32 > lines, modulo blank lines, of stubbing just to get the example to > run). > > Suggestions on how to write the example, or advice on whether to > continue to try, are requested. A couple of points: * I have a similar situation with shipping and billing addresses. I solved it by adding attr_accessor :single_address to the customer model. That gives you the option of using "check_box :single_address" in the form for the customer and it will automatically be passed to the model when you update its attributes. I've noticed it cleans up the controller code a lot. * for line 16 in the spec, you need to do something like this: order_addresses = [] order_addresses.stub!(:create).and_return(order_address) # order_address must be created before this order_user.stub!( :order_addresses ).and_return( order_addresses ) * You should put all the stubbing and mocking in a before(:each) block, they don't really belong to the actual spec. * What you have in your helper is basically business domain stuff. Helpers in Rails are meant for streamlining view code. I just refactored some code that does similar things that yours does, and noticed that it fits perfectly in the model. So in your case, you could add e.g. a class method Order.create_with_addresses_and_user (params[:order], params[:order_user], params[:billing_address], params [:shipping_address], params[:order_account]). In that case, all you'd have to spec in the controller is that the class method is called with correct params. All the other spec'ing would go into the model's specs. * Unless your db supports nested transactions (very few do), there's no point in putting nested transaction blocks in your code. * You can shorten your mocks a bit by defining the stubbed methods already in the mock_model call: order_account = mock_model( OrderAccount, :valid? => true, :order_id= => true, :save! => true ) and so on. Also, once your specs are more than just the one, you start finding patterns there and you can easily refactor the stubbing into spec helpers so that you only need a line or two to create a comprehensive mock model in your specs. HTH, //jarkko P.S. in Ruby true and false are normally written in lower case. -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi From nathan.sutton at gmail.com Tue Nov 20 03:08:56 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Tue, 20 Nov 2007 02:08:56 -0600 Subject: [rspec-users] Stories and Pending Actions In-Reply-To: <57c63afe0711190902u589badbfrad95fb150f9104b1@mail.gmail.com> References: <57c63afe0711190123y211f66foe6955facc1e26206@mail.gmail.com> <1E2C9C55-45FB-4FE4-B3E7-A63A530FFCC1@gmail.com> <57c63afe0711190902u589badbfrad95fb150f9104b1@mail.gmail.com> Message-ID: Didn't have time tonight, stand-by for something tomorrow. Nathan Sutton fowlduck at gmail.com rspec edge revision 2910 rspec_on_rails edge revision 2909 rails edge revision 8167 On Nov 19, 2007, at 11:02 AM, David Chelimsky wrote: > On Nov 19, 2007 11:00 AM, Nathan Sutton > wrote: >> Perfect, thanks Dave. I can make a patch tonight, if ya want. > > Great. Just attach it to the ticket. > > Thx > >> >> Nathan Sutton >> fowlduck at gmail.com >> rspec edge revision 2910 >> rspec_on_rails edge revision 2909 >> rails edge revision 8167 >> >> >> >> >> >> >> On Nov 19, 2007, at 3:23 AM, David Chelimsky wrote: >> >>> On Nov 18, 2007 10:57 PM, Nathan Sutton >>> wrote: >>>> I can't get my plain text stories to show pending actions like the >>>> example addition plain text story. Any tips? (See below) >>>> >>>> http://pastie.caboo.se/119627 >>> >>> Given, When, Then and And don't take a colon because they are the >>> first words of sentences: >>> >>> # this will get processed >>> Given a space shuttle >>> >>> # this will not (treated as a comment) >>> Given: A space shuttle >>> >>> That kinda sucks. And so ... >>> >>> http://rspec.lighthouseapp.com/projects/5645/tickets/132 >>> >>>> >>>> Nathan Sutton >>>> fowlduck at gmail.com >>>> rspec edge revision 2910 >>>> rspec_on_rails edge revision 2909 >>>> rails edge revision 8167 >>>> >>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From jarkko at jlaine.net Tue Nov 20 03:11:05 2007 From: jarkko at jlaine.net (Jarkko Laine) Date: Tue, 20 Nov 2007 10:11:05 +0200 Subject: [rspec-users] How to represent Story of Life grid in Then clause In-Reply-To: <3df642dd0711191744lbb250f5pdf0113f88f63223f@mail.gmail.com> References: <3df642dd0711191744lbb250f5pdf0113f88f63223f@mail.gmail.com> Message-ID: <517B1C5F-29C8-4182-B49D-059F8B0BC11A@jlaine.net> On 20.11.2007, at 3.44, Ed Howland wrote: > In this story from Dan's Game of Life: > > Scenario: the grid has three cells > Given 3 x 3 grid > When I create a cell at 0, 0 > And I create a cell at 0, 1 > And I create a cell at 2, 2 > Then the grid should look like: > XX. > ... > ..X > > How do you set up matchers for the grid at the end. Are all the > indented lines after a Then passed to the Then matcher as separate > strings with multiple Then()s getting called or a single string > separated by new lines? No, they aren't (see http://rspec.lighthouseapp.com/projects/5645/ tickets/132-plain-text-stories-should-support-given-and-given). However, multiline parameters aren't supported in plain text story steps yet, either. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi From voodoorai2000 at gmail.com Tue Nov 20 07:57:35 2007 From: voodoorai2000 at gmail.com (Raimond Garcia) Date: Tue, 20 Nov 2007 13:57:35 +0100 Subject: [rspec-users] Testing Models without fixtures Message-ID: Hi, I would like to test a sorting method that is in the user model, it's a class method called search. What I would like to do is create 2 users and load the test database with just those 2 users, so that I can call User.search("john") and it would return those two users. Not sure how to clear the test database and populate it just with these 2 users for that specific spec. Thanks in advance! Rai From dchelimsky at gmail.com Tue Nov 20 09:40:06 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 20 Nov 2007 08:40:06 -0600 Subject: [rspec-users] Testing Models without fixtures In-Reply-To: References: Message-ID: <57c63afe0711200640h4bae627bt980ded61b2fdf127@mail.gmail.com> On Nov 20, 2007 6:57 AM, Raimond Garcia wrote: > Hi, > > I would like to test a sorting method that is in the user model, it's > a class method called search. > What I would like to do is create 2 users and load the test database > with just those 2 users, so that I can call > User.search("john") and it would return those two users. > > Not sure how to clear the test database and populate it just with > these 2 users for that specific spec. User.delete_all User.create!(:name => "John") User.create!(:name => "George") > > Thanks in advance! > > Rai > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From voodoorai2000 at gmail.com Tue Nov 20 09:59:57 2007 From: voodoorai2000 at gmail.com (Raimond Garcia) Date: Tue, 20 Nov 2007 15:59:57 +0100 Subject: [rspec-users] Testing Models without fixtures In-Reply-To: <57c63afe0711200640h4bae627bt980ded61b2fdf127@mail.gmail.com> References: <57c63afe0711200640h4bae627bt980ded61b2fdf127@mail.gmail.com> Message-ID: <6FF3D77A-21E1-4018-B47F-E4CD8D629B8C@gmail.com> Wow, Thanks Dave, that worked :) I had tried before deleting all users and creating a couple of new ones, was wondering why it didn't work. The problem was that I was using the create method instead of create!, thus, my users where silently being validated and not saved, as I was missing the password parameters and the such. Thanks again! Keep up the great work with rSpec! Rai On Nov 20, 2007, at 3:40 PM, David Chelimsky wrote: > On Nov 20, 2007 6:57 AM, Raimond Garcia > wrote: >> Hi, >> >> I would like to test a sorting method that is in the user model, it's >> a class method called search. >> What I would like to do is create 2 users and load the test database >> with just those 2 users, so that I can call >> User.search("john") and it would return those two users. >> >> Not sure how to clear the test database and populate it just with >> these 2 users for that specific spec. > > User.delete_all > User.create!(:name => "John") > User.create!(:name => "George") > >> >> Thanks in advance! >> >> Rai >> _______________________________________________ >> 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 nathan.sutton at gmail.com Tue Nov 20 11:18:17 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Tue, 20 Nov 2007 10:18:17 -0600 Subject: [rspec-users] Testing Models without fixtures In-Reply-To: <6FF3D77A-21E1-4018-B47F-E4CD8D629B8C@gmail.com> References: <57c63afe0711200640h4bae627bt980ded61b2fdf127@mail.gmail.com> <6FF3D77A-21E1-4018-B47F-E4CD8D629B8C@gmail.com> Message-ID: <9CD826FB-0246-4870-9A6E-9A9EA70B36EE@gmail.com> You may want to create a factory method to create users with valid parameters, overriding any parameters by passing in options. ALPHA = ('a'..'z').to_a + ('A'..'Z').to_a def random_text txt = "" 10.times do txt << ALPHA[rand(52)] end txt # maybe a returning block? can't remember if that works here end def create_user(options={}) User.create!({ :name => random_text, :password => random_text}.merge(options)) end Nathan Sutton fowlduck at gmail.com rspec edge revision 2910 rspec_on_rails edge revision 2909 rails edge revision 8167 On Nov 20, 2007, at 8:59 AM, Raimond Garcia wrote: > Wow, > > Thanks Dave, that worked :) > I had tried before deleting all users and creating a couple of new > ones, was wondering why it didn't work. > The problem was that I was using the create method instead of create!, > thus, my users where silently being validated and not saved, as I was > missing the password parameters and the such. > > Thanks again! > Keep up the great work with rSpec! > > Rai > > On Nov 20, 2007, at 3:40 PM, David Chelimsky wrote: > >> On Nov 20, 2007 6:57 AM, Raimond Garcia >> wrote: >>> Hi, >>> >>> I would like to test a sorting method that is in the user model, >>> it's >>> a class method called search. >>> What I would like to do is create 2 users and load the test database >>> with just those 2 users, so that I can call >>> User.search("john") and it would return those two users. >>> >>> Not sure how to clear the test database and populate it just with >>> these 2 users for that specific spec. >> >> User.delete_all >> User.create!(:name => "John") >> User.create!(:name => "George") >> >>> >>> Thanks in advance! >>> >>> Rai >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Tue Nov 20 11:20:16 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 20 Nov 2007 10:20:16 -0600 Subject: [rspec-users] Testing Models without fixtures In-Reply-To: <9CD826FB-0246-4870-9A6E-9A9EA70B36EE@gmail.com> References: <57c63afe0711200640h4bae627bt980ded61b2fdf127@mail.gmail.com> <6FF3D77A-21E1-4018-B47F-E4CD8D629B8C@gmail.com> <9CD826FB-0246-4870-9A6E-9A9EA70B36EE@gmail.com> Message-ID: <57c63afe0711200820h16e64c5hf6c908728cced65f@mail.gmail.com> On Nov 20, 2007 10:18 AM, Nathan Sutton wrote: > You may want to create a factory method to create users with valid > parameters, overriding any parameters by passing in options. > > ALPHA = ('a'..'z').to_a + ('A'..'Z').to_a > > def random_text > txt = "" > 10.times do > txt << ALPHA[rand(52)] > end > txt # maybe a returning block? can't remember if that works here > end > > def create_user(options={}) > User.create!({ :name => random_text, > :password => random_text}.merge(options)) > end There are also tools that will do this for you: Exemplar, ModelStubbing to name two. > > Nathan Sutton > fowlduck at gmail.com > rspec edge revision 2910 > rspec_on_rails edge revision 2909 > rails edge revision 8167 > > > > > > > On Nov 20, 2007, at 8:59 AM, Raimond Garcia wrote: > > > Wow, > > > > Thanks Dave, that worked :) > > I had tried before deleting all users and creating a couple of new > > ones, was wondering why it didn't work. > > The problem was that I was using the create method instead of create!, > > thus, my users where silently being validated and not saved, as I was > > missing the password parameters and the such. > > > > Thanks again! > > Keep up the great work with rSpec! > > > > Rai > > > > On Nov 20, 2007, at 3:40 PM, David Chelimsky wrote: > > > >> On Nov 20, 2007 6:57 AM, Raimond Garcia > >> wrote: > >>> Hi, > >>> > >>> I would like to test a sorting method that is in the user model, > >>> it's > >>> a class method called search. > >>> What I would like to do is create 2 users and load the test database > >>> with just those 2 users, so that I can call > >>> User.search("john") and it would return those two users. > >>> > >>> Not sure how to clear the test database and populate it just with > >>> these 2 users for that specific spec. > >> > >> User.delete_all > >> User.create!(:name => "John") > >> User.create!(:name => "George") > >> > >>> > >>> Thanks in advance! > >>> > >>> Rai > >>> _______________________________________________ > >>> rspec-users mailing list > >>> rspec-users at rubyforge.org > >>> http://rubyforge.org/mailman/listinfo/rspec-users > >>> > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Tue Nov 20 11:20:55 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 20 Nov 2007 10:20:55 -0600 Subject: [rspec-users] Testing Models without fixtures In-Reply-To: <57c63afe0711200820h16e64c5hf6c908728cced65f@mail.gmail.com> References: <57c63afe0711200640h4bae627bt980ded61b2fdf127@mail.gmail.com> <6FF3D77A-21E1-4018-B47F-E4CD8D629B8C@gmail.com> <9CD826FB-0246-4870-9A6E-9A9EA70B36EE@gmail.com> <57c63afe0711200820h16e64c5hf6c908728cced65f@mail.gmail.com> Message-ID: <57c63afe0711200820i4ffdb085xfb26efef1601a274@mail.gmail.com> On Nov 20, 2007 10:20 AM, David Chelimsky wrote: > On Nov 20, 2007 10:18 AM, Nathan Sutton wrote: > > You may want to create a factory method to create users with valid > > parameters, overriding any parameters by passing in options. > > > > ALPHA = ('a'..'z').to_a + ('A'..'Z').to_a > > > > def random_text > > txt = "" > > 10.times do > > txt << ALPHA[rand(52)] > > end > > txt # maybe a returning block? can't remember if that works here > > end > > > > def create_user(options={}) > > User.create!({ :name => random_text, > > :password => random_text}.merge(options)) > > end > > There are also tools that will do this for you: Exemplar, > ModelStubbing to name two. Actually - those are geared towards avoiding the DB. What you'd want is Scenarios and FixtureScenarios (and others similar). > > > > > > Nathan Sutton > > fowlduck at gmail.com > > rspec edge revision 2910 > > rspec_on_rails edge revision 2909 > > rails edge revision 8167 > > > > > > > > > > > > > > On Nov 20, 2007, at 8:59 AM, Raimond Garcia wrote: > > > > > Wow, > > > > > > Thanks Dave, that worked :) > > > I had tried before deleting all users and creating a couple of new > > > ones, was wondering why it didn't work. > > > The problem was that I was using the create method instead of create!, > > > thus, my users where silently being validated and not saved, as I was > > > missing the password parameters and the such. > > > > > > Thanks again! > > > Keep up the great work with rSpec! > > > > > > Rai > > > > > > On Nov 20, 2007, at 3:40 PM, David Chelimsky wrote: > > > > > >> On Nov 20, 2007 6:57 AM, Raimond Garcia > > >> wrote: > > >>> Hi, > > >>> > > >>> I would like to test a sorting method that is in the user model, > > >>> it's > > >>> a class method called search. > > >>> What I would like to do is create 2 users and load the test database > > >>> with just those 2 users, so that I can call > > >>> User.search("john") and it would return those two users. > > >>> > > >>> Not sure how to clear the test database and populate it just with > > >>> these 2 users for that specific spec. > > >> > > >> User.delete_all > > >> User.create!(:name => "John") > > >> User.create!(:name => "George") > > >> > > >>> > > >>> Thanks in advance! > > >>> > > >>> Rai > > >>> _______________________________________________ > > >>> rspec-users mailing list > > >>> rspec-users at rubyforge.org > > >>> http://rubyforge.org/mailman/listinfo/rspec-users > > >>> > > >> _______________________________________________ > > >> rspec-users mailing list > > >> rspec-users at rubyforge.org > > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > From mailing_lists at railsnewbie.com Tue Nov 20 11:22:03 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 20 Nov 2007 11:22:03 -0500 Subject: [rspec-users] Testing Models without fixtures In-Reply-To: <57c63afe0711200820i4ffdb085xfb26efef1601a274@mail.gmail.com> References: <57c63afe0711200640h4bae627bt980ded61b2fdf127@mail.gmail.com> <6FF3D77A-21E1-4018-B47F-E4CD8D629B8C@gmail.com> <9CD826FB-0246-4870-9A6E-9A9EA70B36EE@gmail.com> <57c63afe0711200820h16e64c5hf6c908728cced65f@mail.gmail.com> <57c63afe0711200820i4ffdb085xfb26efef1601a274@mail.gmail.com> Message-ID: <3773558D-6BFC-4C02-A9A3-38A8FCC3BFE7@railsnewbie.com> On Nov 20, 2007, at 11:20 AM, David Chelimsky wrote: > On Nov 20, 2007 10:20 AM, David Chelimsky > wrote: >> On Nov 20, 2007 10:18 AM, Nathan Sutton >> wrote: >>> You may want to create a factory method to create users with valid >>> parameters, overriding any parameters by passing in options. >>> >>> ALPHA = ('a'..'z').to_a + ('A'..'Z').to_a >>> >>> def random_text >>> txt = "" >>> 10.times do >>> txt << ALPHA[rand(52)] >>> end >>> txt # maybe a returning block? can't remember if that >>> works here >>> end >>> >>> def create_user(options={}) >>> User.create!({ :name => random_text, >>> :password => random_text}.merge >>> (options)) >>> end >> >> There are also tools that will do this for you: Exemplar, >> ModelStubbing to name two. > > Actually - those are geared towards avoiding the DB. What you'd want > is Scenarios and FixtureScenarios (and others similar). > How about giving FixtureReplacement some love? Scott From nathan.sutton at gmail.com Tue Nov 20 11:26:15 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Tue, 20 Nov 2007 10:26:15 -0600 Subject: [rspec-users] Testing Models without fixtures In-Reply-To: <3773558D-6BFC-4C02-A9A3-38A8FCC3BFE7@railsnewbie.com> References: <57c63afe0711200640h4bae627bt980ded61b2fdf127@mail.gmail.com> <6FF3D77A-21E1-4018-B47F-E4CD8D629B8C@gmail.com> <9CD826FB-0246-4870-9A6E-9A9EA70B36EE@gmail.com> <57c63afe0711200820h16e64c5hf6c908728cced65f@mail.gmail.com> <57c63afe0711200820i4ffdb085xfb26efef1601a274@mail.gmail.com> <3773558D-6BFC-4C02-A9A3-38A8FCC3BFE7@railsnewbie.com> Message-ID: Err, Scenarios Nathan Sutton fowlduck at gmail.com rspec edge revision 2910 rspec_on_rails edge revision 2909 rails edge revision 8167 On Nov 20, 2007, at 10:22 AM, Scott Taylor wrote: > > On Nov 20, 2007, at 11:20 AM, David Chelimsky wrote: > >> On Nov 20, 2007 10:20 AM, David Chelimsky >> wrote: >>> On Nov 20, 2007 10:18 AM, Nathan Sutton >>> wrote: >>>> You may want to create a factory method to create users with valid >>>> parameters, overriding any parameters by passing in options. >>>> >>>> ALPHA = ('a'..'z').to_a + ('A'..'Z').to_a >>>> >>>> def random_text >>>> txt = "" >>>> 10.times do >>>> txt << ALPHA[rand(52)] >>>> end >>>> txt # maybe a returning block? can't remember if that >>>> works here >>>> end >>>> >>>> def create_user(options={}) >>>> User.create!({ :name => random_text, >>>> :password => random_text}.merge >>>> (options)) >>>> end >>> >>> There are also tools that will do this for you: Exemplar, >>> ModelStubbing to name two. >> >> Actually - those are geared towards avoiding the DB. What you'd want >> is Scenarios and FixtureScenarios (and others similar). >> > > How about giving FixtureReplacement some love? > > Scott > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From nathan.sutton at gmail.com Tue Nov 20 11:27:54 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Tue, 20 Nov 2007 10:27:54 -0600 Subject: [rspec-users] Testing Models without fixtures In-Reply-To: <3773558D-6BFC-4C02-A9A3-38A8FCC3BFE7@railsnewbie.com> References: <57c63afe0711200640h4bae627bt980ded61b2fdf127@mail.gmail.com> <6FF3D77A-21E1-4018-B47F-E4CD8D629B8C@gmail.com> <9CD826FB-0246-4870-9A6E-9A9EA70B36EE@gmail.com> <57c63afe0711200820h16e64c5hf6c908728cced65f@mail.gmail.com> <57c63afe0711200820i4ffdb085xfb26efef1601a274@mail.gmail.com> <3773558D-6BFC-4C02-A9A3-38A8FCC3BFE7@railsnewbie.com> Message-ID: Ok, if you want to do it messy and uninformed, do it my way. ;) I've heard of Fixture Scenarios but I heard they were broken with edge rspec, but I'll check out Exemplar, ModelStubbing, and FixtureReplacement. Nathan Sutton fowlduck at gmail.com rspec edge revision 2910 rspec_on_rails edge revision 2909 rails edge revision 8167 On Nov 20, 2007, at 10:22 AM, Scott Taylor wrote: > > On Nov 20, 2007, at 11:20 AM, David Chelimsky wrote: > >> On Nov 20, 2007 10:20 AM, David Chelimsky >> wrote: >>> On Nov 20, 2007 10:18 AM, Nathan Sutton >>> wrote: >>>> You may want to create a factory method to create users with valid >>>> parameters, overriding any parameters by passing in options. >>>> >>>> ALPHA = ('a'..'z').to_a + ('A'..'Z').to_a >>>> >>>> def random_text >>>> txt = "" >>>> 10.times do >>>> txt << ALPHA[rand(52)] >>>> end >>>> txt # maybe a returning block? can't remember if that >>>> works here >>>> end >>>> >>>> def create_user(options={}) >>>> User.create!({ :name => random_text, >>>> :password => random_text}.merge >>>> (options)) >>>> end >>> >>> There are also tools that will do this for you: Exemplar, >>> ModelStubbing to name two. >> >> Actually - those are geared towards avoiding the DB. What you'd want >> is Scenarios and FixtureScenarios (and others similar). >> > > How about giving FixtureReplacement some love? > > Scott > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From voodoorai2000 at gmail.com Tue Nov 20 11:48:21 2007 From: voodoorai2000 at gmail.com (Raimond Garcia) Date: Tue, 20 Nov 2007 17:48:21 +0100 Subject: [rspec-users] Testing Models without fixtures In-Reply-To: References: <57c63afe0711200640h4bae627bt980ded61b2fdf127@mail.gmail.com> <6FF3D77A-21E1-4018-B47F-E4CD8D629B8C@gmail.com> <9CD826FB-0246-4870-9A6E-9A9EA70B36EE@gmail.com> <57c63afe0711200820h16e64c5hf6c908728cced65f@mail.gmail.com> <57c63afe0711200820i4ffdb085xfb26efef1601a274@mail.gmail.com> <3773558D-6BFC-4C02-A9A3-38A8FCC3BFE7@railsnewbie.com> Message-ID: <1DA6E932-B1CA-41BB-B78F-4F9833110766@gmail.com> Hi guys, Thanks for the help, will check out Exemplar and ModelStubbing, for the moment this screencast about FixtureReplacement looks very useful. http://railsnewbie.com/files/fixture_replacement_demo.mov Rai On Nov 20, 2007, at 5:27 PM, Nathan Sutton wrote: > Ok, if you want to do it messy and uninformed, do it my way. ;) > > I've heard of Fixture Scenarios but I heard they were broken with edge > rspec, but I'll check out Exemplar, ModelStubbing, and > FixtureReplacement. > > Nathan Sutton > fowlduck at gmail.com > rspec edge revision 2910 > rspec_on_rails edge revision 2909 > rails edge revision 8167 > > > > > > On Nov 20, 2007, at 10:22 AM, Scott Taylor wrote: > >> >> On Nov 20, 2007, at 11:20 AM, David Chelimsky wrote: >> >>> On Nov 20, 2007 10:20 AM, David Chelimsky >>> wrote: >>>> On Nov 20, 2007 10:18 AM, Nathan Sutton >>>> wrote: >>>>> You may want to create a factory method to create users with valid >>>>> parameters, overriding any parameters by passing in options. >>>>> >>>>> ALPHA = ('a'..'z').to_a + ('A'..'Z').to_a >>>>> >>>>> def random_text >>>>> txt = "" >>>>> 10.times do >>>>> txt << ALPHA[rand(52)] >>>>> end >>>>> txt # maybe a returning block? can't remember if that >>>>> works here >>>>> end >>>>> >>>>> def create_user(options={}) >>>>> User.create!({ :name => random_text, >>>>> :password => random_text}.merge >>>>> (options)) >>>>> end >>>> >>>> There are also tools that will do this for you: Exemplar, >>>> ModelStubbing to name two. >>> >>> Actually - those are geared towards avoiding the DB. What you'd want >>> is Scenarios and FixtureScenarios (and others similar). >>> >> >> How about giving FixtureReplacement some love? >> >> Scott >> >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mailing_lists at railsnewbie.com Tue Nov 20 12:00:47 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 20 Nov 2007 12:00:47 -0500 Subject: [rspec-users] rake spec default environment In-Reply-To: <43AA75DA-1F5C-490B-8A3C-729F09830387@parkerhill.com> References: <185323BC-A712-4763-92EC-0034C5A4A513@railsnewbie.com> <43AA75DA-1F5C-490B-8A3C-729F09830387@parkerhill.com> Message-ID: <40D245D6-26F9-4981-BD7B-E12F0D066394@railsnewbie.com> On Nov 20, 2007, at 12:25 AM, Jonathan Linowes wrote: > Hey scott, > I'm running into this again > > What I'm trying to do is avoid 2 database.yml files -- one for my dev > machine, one for the deploy server -- > by adding a new "staging" environment that is like "test" but on the > server > Since the server doesnt have a "development" env or db, the rake spec > fails > Is there a way to force the rake task to copy the schema from > "production" rather than "development"? Well, you could run the migrations with: rake db:migrate RAILS_ENV="staging". Check out capistrano to automate this stuff for you (and especially the excellent capistrano-ext gem for deploying to different environments). Not sure why you would want to run your specs in another environment called staging - but, if you really want to, you should look into modifying spec_helper.rb to be less restrictive (currently it sets RAILS_ENV = "test"). FixtureReplacement (which I know you are using), also isn't being included, which is something I've been meaning to make configurable. (Patches welcome, as always). Scott From lists at ruby-forum.com Tue Nov 20 12:23:33 2007 From: lists at ruby-forum.com (Brad Carson) Date: Tue, 20 Nov 2007 18:23:33 +0100 Subject: [rspec-users] Autotest rspec issues Message-ID: <257aa9e1ca069148abdb30cc5c1dbb73@ruby-forum.com> I'm having trouble getting autotest to run "out of the box" with rspec. I've got a Leopard setup with Zentest 3.5.0, rspec on trunk, and rails 2.0PR. No ".autotest" file. There are a couple of issues: 1. Running 'autotest' inititally yields a command not found for "spec --diff unified etc etc". This seems to be an old issue but I can fix it by creating a "~/.autotest" file and attaching a hook to autotest initialize to explicity set the spec_command to script/spec. Fine. 2. Regardless of #1, restarting autotest once loaded makes it crap out with an initialize error, complaining about wrong arguments (0 for 1) or somesuch - the exact stack trace and error I can post when home again tonight. 3. I can live with the first two, but autotest isn't picking up any changes to any view specs. I've tried index.rhtml_spec.rb and index.html.erb_spec.rb but nothing does the trick. Controller spec changes are detected just fine. Haven't tried model specs yet. I'd love to hear any suggestions you may have and thank you kindly in advance. Brad -- Posted via http://www.ruby-forum.com/. From hotfusionman at yahoo.com Tue Nov 20 12:33:09 2007 From: hotfusionman at yahoo.com (Al Chou) Date: Tue, 20 Nov 2007 09:33:09 -0800 (PST) Subject: [rspec-users] confirming that a model instance was correctly created from POST params Message-ID: <365597.85700.qm@web58705.mail.re1.yahoo.com> Thanks, Jarkko. Substruct is not my code, so I don't know how OrderHelper got to be so big. I'm not sure I want to refactor its contents into Order just to make it easier to write the examples for my addition, but at least I have that option because the project is open source! I'll have a detailed look at your suggestions later today, hopefully. Rails programming is not my day job, unfortunately! Al ----- Original Message ---- From: Jarkko Laine To: rspec-users Sent: Tuesday, November 20, 2007 12:04:13 AM Subject: Re: [rspec-users] confirming that a model instance was correctly created from POST params On 20.11.2007, at 8.00, Al Chou wrote: > What I am trying to demonstrate to myself is that the addition of a > boolean "is_business_address" column to the order_addresses table > via a migration allows line 40 of the create_order_from_post method > to set this property when an OrderAddress instance is created. But > my example as shown tells me that assigns[:billing_address] is nil > when I run it. Also, I realize that line 16 of the example isn't > returning the right thing; it should be an AssociationCollection of > OrderAddress. That's where I'm starting to wonder if I'm spending > too much time on something that is probably simple enough that it's > already working but disproportionately hard to write an RSpec > example for (because the existing create_order_from_post method has > no tests or examples and thus isn't easy to test -- witness the 32 > lines, modulo blank lines, of stubbing just to get the example to > run). > > Suggestions on how to write the example, or advice on whether to > continue to try, are requested. A couple of points: * I have a similar situation with shipping and billing addresses. I solved it by adding attr_accessor :single_address to the customer model. That gives you the option of using "check_box :single_address" in the form for the customer and it will automatically be passed to the model when you update its attributes. I've noticed it cleans up the controller code a lot. * for line 16 in the spec, you need to do something like this: order_addresses = [] order_addresses.stub!(:create).and_return(order_address) # order_address must be created before this order_user.stub!( :order_addresses ).and_return( order_addresses ) * You should put all the stubbing and mocking in a before(:each) block, they don't really belong to the actual spec. * What you have in your helper is basically business domain stuff. Helpers in Rails are meant for streamlining view code. I just refactored some code that does similar things that yours does, and noticed that it fits perfectly in the model. So in your case, you could add e.g. a class method Order.create_with_addresses_and_user (params[:order], params[:order_user], params[:billing_address], params [:shipping_address], params[:order_account]). In that case, all you'd have to spec in the controller is that the class method is called with correct params. All the other spec'ing would go into the model's specs. * Unless your db supports nested transactions (very few do), there's no point in putting nested transaction blocks in your code. * You can shorten your mocks a bit by defining the stubbed methods already in the mock_model call: order_account = mock_model( OrderAccount, :valid? => true, :order_id= => true, :save! => true ) and so on. Also, once your specs are more than just the one, you start finding patterns there and you can easily refactor the stubbing into spec helpers so that you only need a line or two to create a comprehensive mock model in your specs. HTH, //jarkko P.S. in Ruby true and false are normally written in lower case. -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ____________________________________________________________________________________ Get easy, one-click access to your favorites. Make Yahoo! your homepage. http://www.yahoo.com/r/hs -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071120/5bb8f732/attachment-0001.html From mailing_lists at railsnewbie.com Tue Nov 20 12:35:03 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 20 Nov 2007 12:35:03 -0500 Subject: [rspec-users] Autotest rspec issues In-Reply-To: <257aa9e1ca069148abdb30cc5c1dbb73@ruby-forum.com> References: <257aa9e1ca069148abdb30cc5c1dbb73@ruby-forum.com> Message-ID: <9A77CC22-76B1-48B2-B0C3-B4B61D46789E@railsnewbie.com> On Nov 20, 2007, at 12:23 PM, Brad Carson wrote: > I'm having trouble getting autotest to run "out of the box" with > rspec. > I've got a Leopard setup with Zentest 3.5.0, rspec on trunk, and rails > 2.0PR. No ".autotest" file. > First off, I assume you have rspec 1.0.8, and ZenTest 3.6.1 > There are a couple of issues: > 1. Running 'autotest' inititally yields a command not found for "spec > --diff unified etc etc". This seems to be an old issue but I can fix > it by creating a "~/.autotest" file and attaching a hook to autotest > initialize to explicity set the spec_command to script/spec. Fine. > And you have diff-lcs gem installed, correct? What version are you on? If you run script/spec, is everything working just fine? > 2. Regardless of #1, restarting autotest once loaded makes it crap out > with an initialize error, complaining about wrong arguments (0 for > 1) or > somesuch - the exact stack trace and error I can post when home again > tonight. You'll probably need to ./script/generate rspec. (You should do this every time you get changes from rspec - I'm assuming your running off of rspec's trunk on externals in a rails project). > > 3. I can live with the first two, but autotest isn't picking up any > changes to any view specs. I've tried index.rhtml_spec.rb and > index.html.erb_spec.rb but nothing does the trick. Controller spec > changes are detected just fine. Haven't tried model specs yet. Here's the relevant mapping: %r%^app/views/(.*)$% => proc { |_, m| files_matching %r%^spec/views/#{m[1]}_spec.rb$% }, So if you have app/views/foo/template.rhtml, you'll want spec/views/ foo/template.rhtml_spec.rb Let us know how it goes (I know technoweenie has been having problems with autotest as well - so maybe it's some sort of Leopard bug). Scott From mailing_lists at railsnewbie.com Tue Nov 20 12:36:15 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 20 Nov 2007 12:36:15 -0500 Subject: [rspec-users] Autotest rspec issues In-Reply-To: <257aa9e1ca069148abdb30cc5c1dbb73@ruby-forum.com> References: <257aa9e1ca069148abdb30cc5c1dbb73@ruby-forum.com> Message-ID: <3E231DCD-FAB4-4151-A5D7-1EE65D5C36C7@railsnewbie.com> On Nov 20, 2007, at 12:23 PM, Brad Carson wrote: > I'm having trouble getting autotest to run "out of the box" with > rspec. > I've got a Leopard setup with Zentest 3.5.0, rspec on trunk, and rails > 2.0PR. No ".autotest" file. Oops. Didn't read your info very well ;). You'll want to upgrade to the latest Zentest - 3.6.1. That should fix you right up. Scott From tbnini at gmail.com Tue Nov 20 17:02:24 2007 From: tbnini at gmail.com (Troy Nini) Date: Tue, 20 Nov 2007 16:02:24 -0600 Subject: [rspec-users] How to test views with Nested Resources and Partials Message-ID: <967a91150711201402j63f8fe05x33e67e6797d9ad72@mail.gmail.com> Hi everyone, I am relatively new to rspec and I am running into a wall in testing my views. I have a RESTful resource Contracts with a nested resource of Line_items. I am trying to figure out how to test the "edit" form of the Line_items. What complicates this is the nested routing and how to account for it, and that there is a partial form (_form.haml) that both the edit.haml and new.haml views use (app/views/line_items). My spec keeps failing and it seems to be from a routing issue. I'm pretty sure template.expect_render/template.stub_render should be in there somewhere, but that just generates more errors. I am running edge rails and edge rspec. My other spec's are working fine. See the output from running the spec and the associated files below (edit.haml_spec.rb, edit.haml, _form.haml) Thanks for your help, Troy ######## Output from running edit.haml_spec.r ######## F 1) ActionView::TemplateError in '/line_items/edit.haml should render edit form' contract_line_item_url failed to generate from {:contract_id=>"1", :action=>"show", :controller=>"line_items"}, expected: {:action=>"show", :controller=>"line_items"}, diff: {:contract_id=>"1"} On line #6 of app/views/line_items/edit.haml 3: 4: #section1 5: = error_messages_for :line_item 6: - form_for(:line_item, :url => contract_line_item_path(@contract.id), :html => { :method => :put }) do |f| 7: = render :partial => "form", :locals => { :f => f } 8: 9: %p app/views/line_items/edit.haml:6 vendor/rails/actionpack/lib/action_controller/routing.rb:1406:in `raise_named_route_error' vendor/rails/actionpack/lib/action_controller/routing.rb:1370:in `generate' vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:124:in `rewrite_path' vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:103:in `rewrite_url' vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:81:in `rewrite' vendor/rails/actionpack/lib/action_controller/base.rb:605:in `url_for' vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:71:in `send' vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:71:in `url_for' (eval):17:in `contract_line_item_path' (eval):15:in `_render_haml_1' vendor/plugins/stable/lib/haml/engine.rb:435:in `send' vendor/plugins/stable/lib/haml/engine.rb:435:in `compile' vendor/plugins/stable/lib/haml/engine.rb:186:in `to_html' vendor/plugins/stable/lib/haml/template.rb:69:in `render' vendor/rails/actionpack/lib/action_view/base.rb:529:in `delegate_render' vendor/rails/actionpack/lib/action_view/base.rb:351:in `render_template_old' vendor/plugins/stable/lib/haml/template.rb:96:in `render_template' vendor/rails/actionpack/lib/action_view/base.rb:303:in `render_file' vendor/rails/actionpack/lib/action_controller/base.rb:1079:in `render_for_file' vendor/rails/actionpack/lib/action_controller/base.rb:831:in `render_with_no_layout' vendor/rails/actionpack/lib/action_controller/layout.rb:269:in `render_without_benchmark' vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render' /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure' vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render' vendor/plugins/rspec_on_rails/lib/spec/rails/example/behaviour/view_example.rb:129:in `send' vendor/plugins/rspec_on_rails/lib/spec/rails/example/behaviour/view_example.rb:129:in `render' spec/views/line_items/edit.haml_spec.rb:57 vendor/plugins/rspec/lib/spec/example/example_methods.rb:14:in `instance_eval' vendor/plugins/rspec/lib/spec/example/example_methods.rb:14:in `run' vendor/plugins/rspec/lib/spec/example/example_runner.rb:57:in `run_example' vendor/plugins/rspec/lib/spec/example/example_runner.rb:23:in `run' /usr/local/lib/ruby/1.8/timeout.rb:48:in `timeout' vendor/plugins/rspec/lib/spec/example/example_runner.rb:21:in `run' vendor/plugins/rspec/lib/spec/example/example_suite.rb:28:in `rspec_run' vendor/plugins/rspec/lib/spec/example/example_suite.rb:24:in `each' vendor/plugins/rspec/lib/spec/example/example_suite.rb:24:in `rspec_run' vendor/plugins/rspec/lib/spec/extensions/test/unit/example_suite.rb:7:in `run' vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in `run' vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:21:in `each' vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:21:in `run' vendor/plugins/rspec/lib/spec/runner/options.rb:77:in `run_examples' vendor/plugins/rspec/lib/spec/runner/command_line.rb:19:in `run' vendor/plugins/rspec/bin/spec:3 Finished in 0.081986 seconds 1 example, 1 failure ######## edit.haml_spec.rb ######## require File.dirname(__FILE__) + '/../../spec_helper' describe "/line_items/edit.haml" do include LineItemsHelper before do @contract = mock_model(Contract) @contract.stub!(:id).and_return("1") @contract.stub!(:sdc_ref).and_return("MyString") @contract.stub!(:description).and_return("MyString") @contract.stub!(:sales_rep_id).and_return("1") @contract.stub!(:office_id).and_return("1") @contract.stub!(:account_id).and_return("MyString") @contract.stub!(:cust_po_num).and_return("MyString") @contract.stub!(:payment_terms).and_return("MyString") @contract.stub!(:hp3000).and_return(false) @contract.stub!(:revenue).and_return("MyString") @contract.stub!(:annual_hw_rev).and_return("1.5") @contract.stub!(:annual_sw_rev).and_return("1.5") @contract.stub!(:annual_ce_rev).and_return("1.5") @contract.stub!(:annual_sa_rev).and_return("1.5") @contract.stub!(:annual_dr_rev).and_return("1.5") @contract.stub!(:start_date).and_return(Date.today) @contract.stub!(:end_date).and_return(Date.today) @contract.stub!(:multiyr_end).and_return(Date.today) @contract.stub!(:expired).and_return("MyString") @contract.stub!(:hw_support_level_id).and_return("1") @contract.stub!(:sw_support_level_id).and_return("1") @contract.stub!(:updates).and_return("MyString") @contract.stub!(:ce_days).and_return("1") @contract.stub!(:sa_days).and_return("1") @contract.stub!(:discount_pref_hw).and_return("1.5") @contract.stub!(:discount_pref_sw).and_return("1.5") @contract.stub!(:discount_prepay).and_return("1.5") @contract.stub!(:discount_multiyear).and_return("1.5") @contract.stub!(:discount_ce_day).and_return("1.5") @contract.stub!(:discount_sa_day).and_return("1.5") @contract.stub!(:primary_office).and_return("MyString") @contract.stub!(:replacement_sdc_ref).and_return("MyString") assigns[:contract] = @contract @line_item = mock_model(LineItem) @line_item.stub!(:contract_id).and_return("1") @line_item.stub!(:support_type).and_return("MyString") @line_item.stub!(:product_num).and_return("MyString") @line_item.stub!(:serial_num).and_return("MyString") @line_item.stub!(:description).and_return("MyString") @line_item.stub!(:begins).and_return(Date.today) @line_item.stub!(:ends).and_return(Date.today) @line_item.stub!(:qty).and_return("1") @line_item.stub!(:list_price).and_return("1") assigns[:line_item] = @line_item end it "should render edit form" do render "line_items/edit.haml" response.should have_tag("form[action=#{contract_line_item_path(@contract.id, at line_item.id)}][method=post]") do with_tag('input#line_item_support_type[name=?]', "line_item[support_type]") with_tag('input#line_item_product_num[name=?]', "line_item[product_num]") with_tag('input#line_item_serial_num[name=?]', "line_item[serial_num]") with_tag('input#line_item_description[name=?]', "line_item[description]") with_tag('input#line_item_qty[name=?]', "line_item[qty]") with_tag('input#line_item_list_price[name=?]', "line_item[list_price]") end end end ######## edit.haml ######## - content_for :subtitle do Edit Line Item #section1 = error_messages_for :line_item - form_for(:line_item, :url => contract_line_item_path(@contract.id), :html => { :method => :put }) do |f| = render :partial => "form", :locals => { :f => f } %p = submit_tag "Update" #section2 = link_to('Show', contract_path(@contract)) + ' | ' + link_to('Back', contracts_path) ######## _form.haml ######## #section1 #results.boxed %h2 Details %p %label{:for => "line_item_support_type"} Type = f.text_field :support_type %p %label{:for => "line_item_product_num"} Product num = f.text_field :product_num %p %label{:for => "line_item_serial_num"} Serial num = f.text_field :serial_num %p %label{:for => "line_item_description"} Description = f.text_field :description %p %label{:for => "line_item_begins"} Begins = f.text_field :begins %p %label{:for => "line_item_ends"} Ends = f.text_field :ends %p %label{:for => "line_item_qty"} Qty = f.text_field :qty %p %label{:for => "line_list_price"} List Price = f.text_field :list_price From tnini at sourcedirect.com Tue Nov 20 15:21:55 2007 From: tnini at sourcedirect.com (Troy Nini) Date: Tue, 20 Nov 2007 14:21:55 -0600 Subject: [rspec-users] How to test views with Nested Resources and Partials Message-ID: <1195590115.8121.54.camel@tnini2.sourcedirect.com> Hi everyone, I am relatively new to rspec and I am running into a wall in testing my views. I have a RESTful resource Contracts with a nested resource of Line_items. I am trying to figure out how to test the "edit" form of the Line_items. What complicates this is the nested routing and how to account for it, and that there is a partial form (_form.haml) that both the edit.haml and new.haml views use (app/views/line_items). My spec keeps failing and it seems to be from a routing issue. I'm pretty sure template.expect_render/template.stub_render should be in there somewhere, but that just generates more errors. I am running edge rails and edge rspec. My other spec's are working fine. See the output from running the spec and the associated files below (edit.haml_spec.rb, edit.haml, _form.haml) Thanks for your help, Troy ######## Output from running edit.haml_spec.r ######## F 1) ActionView::TemplateError in '/line_items/edit.haml should render edit form' contract_line_item_url failed to generate from {:contract_id=>"1", :action=>"show", :controller=>"line_items"}, expected: {:action=>"show", :controller=>"line_items"}, diff: {:contract_id=>"1"} On line #6 of app/views/line_items/edit.haml 3: 4: #section1 5: = error_messages_for :line_item 6: - form_for(:line_item, :url => contract_line_item_path(@contract.id), :html => { :method => :put }) do |f| 7: = render :partial => "form", :locals => { :f => f } 8: 9: %p app/views/line_items/edit.haml:6 vendor/rails/actionpack/lib/action_controller/routing.rb:1406:in `raise_named_route_error' vendor/rails/actionpack/lib/action_controller/routing.rb:1370:in `generate' vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:124:in `rewrite_path' vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:103:in `rewrite_url' vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:81:in `rewrite' vendor/rails/actionpack/lib/action_controller/base.rb:605:in `url_for' vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:71:in `send' vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:71:in `url_for' (eval):17:in `contract_line_item_path' (eval):15:in `_render_haml_1' vendor/plugins/stable/lib/haml/engine.rb:435:in `send' vendor/plugins/stable/lib/haml/engine.rb:435:in `compile' vendor/plugins/stable/lib/haml/engine.rb:186:in `to_html' vendor/plugins/stable/lib/haml/template.rb:69:in `render' vendor/rails/actionpack/lib/action_view/base.rb:529:in `delegate_render' vendor/rails/actionpack/lib/action_view/base.rb:351:in `render_template_old' vendor/plugins/stable/lib/haml/template.rb:96:in `render_template' vendor/rails/actionpack/lib/action_view/base.rb:303:in `render_file' vendor/rails/actionpack/lib/action_controller/base.rb:1079:in `render_for_file' vendor/rails/actionpack/lib/action_controller/base.rb:831:in `render_with_no_layout' vendor/rails/actionpack/lib/action_controller/layout.rb:269:in `render_without_benchmark' vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render' /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure' vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render' vendor/plugins/rspec_on_rails/lib/spec/rails/example/behaviour/view_example.rb:129:in `send' vendor/plugins/rspec_on_rails/lib/spec/rails/example/behaviour/view_example.rb:129:in `render' spec/views/line_items/edit.haml_spec.rb:57 vendor/plugins/rspec/lib/spec/example/example_methods.rb:14:in `instance_eval' vendor/plugins/rspec/lib/spec/example/example_methods.rb:14:in `run' vendor/plugins/rspec/lib/spec/example/example_runner.rb:57:in `run_example' vendor/plugins/rspec/lib/spec/example/example_runner.rb:23:in `run' /usr/local/lib/ruby/1.8/timeout.rb:48:in `timeout' vendor/plugins/rspec/lib/spec/example/example_runner.rb:21:in `run' vendor/plugins/rspec/lib/spec/example/example_suite.rb:28:in `rspec_run' vendor/plugins/rspec/lib/spec/example/example_suite.rb:24:in `each' vendor/plugins/rspec/lib/spec/example/example_suite.rb:24:in `rspec_run' vendor/plugins/rspec/lib/spec/extensions/test/unit/example_suite.rb:7:in `run' vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in `run' vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:21:in `each' vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:21:in `run' vendor/plugins/rspec/lib/spec/runner/options.rb:77:in `run_examples' vendor/plugins/rspec/lib/spec/runner/command_line.rb:19:in `run' vendor/plugins/rspec/bin/spec:3 Finished in 0.081986 seconds 1 example, 1 failure ######## edit.haml_spec.rb ######## require File.dirname(__FILE__) + '/../../spec_helper' describe "/line_items/edit.haml" do include LineItemsHelper before do @contract = mock_model(Contract) @contract.stub!(:id).and_return("1") @contract.stub!(:sdc_ref).and_return("MyString") @contract.stub!(:description).and_return("MyString") @contract.stub!(:sales_rep_id).and_return("1") @contract.stub!(:office_id).and_return("1") @contract.stub!(:account_id).and_return("MyString") @contract.stub!(:cust_po_num).and_return("MyString") @contract.stub!(:payment_terms).and_return("MyString") @contract.stub!(:hp3000).and_return(false) @contract.stub!(:revenue).and_return("MyString") @contract.stub!(:annual_hw_rev).and_return("1.5") @contract.stub!(:annual_sw_rev).and_return("1.5") @contract.stub!(:annual_ce_rev).and_return("1.5") @contract.stub!(:annual_sa_rev).and_return("1.5") @contract.stub!(:annual_dr_rev).and_return("1.5") @contract.stub!(:start_date).and_return(Date.today) @contract.stub!(:end_date).and_return(Date.today) @contract.stub!(:multiyr_end).and_return(Date.today) @contract.stub!(:expired).and_return("MyString") @contract.stub!(:hw_support_level_id).and_return("1") @contract.stub!(:sw_support_level_id).and_return("1") @contract.stub!(:updates).and_return("MyString") @contract.stub!(:ce_days).and_return("1") @contract.stub!(:sa_days).and_return("1") @contract.stub!(:discount_pref_hw).and_return("1.5") @contract.stub!(:discount_pref_sw).and_return("1.5") @contract.stub!(:discount_prepay).and_return("1.5") @contract.stub!(:discount_multiyear).and_return("1.5") @contract.stub!(:discount_ce_day).and_return("1.5") @contract.stub!(:discount_sa_day).and_return("1.5") @contract.stub!(:primary_office).and_return("MyString") @contract.stub!(:replacement_sdc_ref).and_return("MyString") assigns[:contract] = @contract @line_item = mock_model(LineItem) @line_item.stub!(:contract_id).and_return("1") @line_item.stub!(:support_type).and_return("MyString") @line_item.stub!(:product_num).and_return("MyString") @line_item.stub!(:serial_num).and_return("MyString") @line_item.stub!(:description).and_return("MyString") @line_item.stub!(:begins).and_return(Date.today) @line_item.stub!(:ends).and_return(Date.today) @line_item.stub!(:qty).and_return("1") @line_item.stub!(:list_price).and_return("1") assigns[:line_item] = @line_item end it "should render edit form" do render "line_items/edit.haml" response.should have_tag("form[action=#{contract_line_item_path(@contract.id, at line_item.id)}][method=post]") do with_tag('input#line_item_support_type[name=?]', "line_item[support_type]") with_tag('input#line_item_product_num[name=?]', "line_item[product_num]") with_tag('input#line_item_serial_num[name=?]', "line_item[serial_num]") with_tag('input#line_item_description[name=?]', "line_item[description]") with_tag('input#line_item_qty[name=?]', "line_item[qty]") with_tag('input#line_item_list_price[name=?]', "line_item[list_price]") end end end ######## edit.haml ######## - content_for :subtitle do Edit Line Item #section1 = error_messages_for :line_item - form_for(:line_item, :url => contract_line_item_path(@contract.id), :html => { :method => :put }) do |f| = render :partial => "form", :locals => { :f => f } %p = submit_tag "Update" #section2 = link_to('Show', contract_path(@contract)) + ' | ' + link_to('Back', contracts_path) ######## _form.haml ######## #section1 #results.boxed %h2 Details %p %label{:for => "line_item_support_type"} Type = f.text_field :support_type %p %label{:for => "line_item_product_num"} Product num = f.text_field :product_num %p %label{:for => "line_item_serial_num"} Serial num = f.text_field :serial_num %p %label{:for => "line_item_description"} Description = f.text_field :description %p %label{:for => "line_item_begins"} Begins = f.text_field :begins %p %label{:for => "line_item_ends"} Ends = f.text_field :ends %p %label{:for => "line_item_qty"} Qty = f.text_field :qty %p %label{:for => "line_list_price"} List Price = f.text_field :list_price -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071120/6a71aa4f/attachment-0001.html From jonathan at parkerhill.com Tue Nov 20 17:55:20 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 20 Nov 2007 17:55:20 -0500 Subject: [rspec-users] cap deploy:spec Message-ID: fyi, I just posted this http://www.vaporbase.com/postings/Running_rspec_after_you_deploy - linoj From lists at ruby-forum.com Tue Nov 20 18:36:36 2007 From: lists at ruby-forum.com (Brad Carson) Date: Wed, 21 Nov 2007 00:36:36 +0100 Subject: [rspec-users] Autotest rspec issues In-Reply-To: <3E231DCD-FAB4-4151-A5D7-1EE65D5C36C7@railsnewbie.com> References: <257aa9e1ca069148abdb30cc5c1dbb73@ruby-forum.com> <3E231DCD-FAB4-4151-A5D7-1EE65D5C36C7@railsnewbie.com> Message-ID: <6cdaa6a73bfdbbc977dae286bfa2ba34@ruby-forum.com> Scott Taylor wrote: > On Nov 20, 2007, at 12:23 PM, Brad Carson wrote: > >> I'm having trouble getting autotest to run "out of the box" with >> rspec. >> I've got a Leopard setup with Zentest 3.5.0, rspec on trunk, and rails >> 2.0PR. No ".autotest" file. > > > Oops. Didn't read your info very well ;). > > You'll want to upgrade to the latest Zentest - 3.6.1. That should > fix you right up. > You were absolutely right. My gem configuration is kind of mangled (Leopard thing) and ZenTest would only update to 3.5.0 so I thought it was the most recent version. Manually downloading and installing the gem fixed every one of the issues for me, using some instructions from one of David's posts (but for ZenTest 3.6.1): http://blog.davidchelimsky.net/articles/2007/05/01/rspec-0-9-1-and-autotest-zentest-3-5-2 At that point I had two versions of ZenTest installed and did a targetted uninstall of 3.5.0. Many thanks, Scott. I could've saved hours of frustration had I only come here first! Brad -- Posted via http://www.ruby-forum.com/. From mailing_lists at railsnewbie.com Tue Nov 20 19:24:27 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 20 Nov 2007 19:24:27 -0500 Subject: [rspec-users] Autotest rspec issues In-Reply-To: <6cdaa6a73bfdbbc977dae286bfa2ba34@ruby-forum.com> References: <257aa9e1ca069148abdb30cc5c1dbb73@ruby-forum.com> <3E231DCD-FAB4-4151-A5D7-1EE65D5C36C7@railsnewbie.com> <6cdaa6a73bfdbbc977dae286bfa2ba34@ruby-forum.com> Message-ID: On Nov 20, 2007, at 6:36 PM, Brad Carson wrote: > Scott Taylor wrote: >> On Nov 20, 2007, at 12:23 PM, Brad Carson wrote: >> >>> I'm having trouble getting autotest to run "out of the box" with >>> rspec. >>> I've got a Leopard setup with Zentest 3.5.0, rspec on trunk, and >>> rails >>> 2.0PR. No ".autotest" file. >> >> >> Oops. Didn't read your info very well ;). >> >> You'll want to upgrade to the latest Zentest - 3.6.1. That should >> fix you right up. >> > > > You were absolutely right. My gem configuration is kind of mangled > (Leopard thing) and ZenTest would only update to 3.5.0 so I thought it > was the most recent version. Strange. Are you using the rubygems which comes with leopard? I wonder if it's a bug... Scott From pergesu at gmail.com Tue Nov 20 20:07:05 2007 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 20 Nov 2007 17:07:05 -0800 Subject: [rspec-users] cap deploy:spec In-Reply-To: References: Message-ID: <810a540e0711201707m12404490u363b8b7aea2d6888@mail.gmail.com> On Nov 20, 2007 2:55 PM, Jonathan Linowes wrote: > fyi, I just posted this > > http://www.vaporbase.com/postings/Running_rspec_after_you_deploy > > - linoj > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > I'm kind of confused. You say that you're not running the specs against the production database, but it looks like that's exactly what's going on. What am I missing? Pat From lancecarlson at gmail.com Tue Nov 20 20:12:18 2007 From: lancecarlson at gmail.com (Lance Carlson) Date: Tue, 20 Nov 2007 20:12:18 -0500 Subject: [rspec-users] failing rake task Message-ID: <49f64a900711201712j222abddeg74cc872ddcedd64c@mail.gmail.com> I'm running rspec and rspec on rails in svn external so I am running the latest version of the trunk. Recently the rake spec task started braking the continuous integration server because the rake aborted. I checked my local and it ran with the same behavior.. and all of the devs on my team are now experiencing the same problem. All the spec's are passing, but the rake task is aborting. Anyone know why this could be happening? Finished in 8.396101 seconds 422 examples, 0 failures, 25 pending rake aborted! Command ruby etc. etc. " --options "/Users/lance/Sites/feedvuz/spec/spec.opts" failed (See full trace by running task with --trace) The trace produced the following results: " --options "/Users/lance/Sites/feedvuz/spec/spec.opts" failed /Users/lance/Sites/feedvuz/vendor/plugins/rspec/lib/spec/rake/spectask.rb:173:in `define' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:823:in `verbose' /Users/lance/Sites/feedvuz/vendor/plugins/rspec/lib/spec/rake/spectask.rb:142:in `define' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `synchronize' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `each' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in `top_level' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in `run' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in `run' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 /usr/bin/rake:16:in `load' /usr/bin/rake:16 Thanks in advance! -L From jonathan at parkerhill.com Tue Nov 20 20:36:25 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 20 Nov 2007 20:36:25 -0500 Subject: [rspec-users] cap deploy:spec In-Reply-To: <810a540e0711201707m12404490u363b8b7aea2d6888@mail.gmail.com> References: <810a540e0711201707m12404490u363b8b7aea2d6888@mail.gmail.com> Message-ID: <271AA87E-7958-4053-96F1-9C99780DDA10@parkerhill.com> On Nov 20, 2007, at 8:07 PM, Pat Maddox wrote: > On Nov 20, 2007 2:55 PM, Jonathan Linowes > wrote: >> fyi, I just posted this >> >> http://www.vaporbase.com/postings/Running_rspec_after_you_deploy >> >> - linoj >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > I'm kind of confused. You say that you're not running the specs > against the production database, but it looks like that's exactly > what's going on. What am I missing? > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users It confused me too. I assume you're referring to the rake spec command. I've not followed the code, but what it does is connect to the development database first (or production one if you say RAILS_ENV=production) before getting to spec_helper which in turn specifies ENV["RAILS_ENV"] = "test" to connect to the test one before running the specs. In my case the development: section in database.yml defines the one on my development machine, so the spec fails when run on the server with an error cannot connect to the database unless I say RAILS_ENV=production Not this only occurs on rake spec, not when running script/spec see thread http://rubyforge.org/pipermail/rspec-users/2007-October/ 004206.html --linoj From jonathan at parkerhill.com Tue Nov 20 20:46:42 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 20 Nov 2007 20:46:42 -0500 Subject: [rspec-users] cap deploy:spec In-Reply-To: <271AA87E-7958-4053-96F1-9C99780DDA10@parkerhill.com> References: <810a540e0711201707m12404490u363b8b7aea2d6888@mail.gmail.com> <271AA87E-7958-4053-96F1-9C99780DDA10@parkerhill.com> Message-ID: On Nov 20, 2007, at 8:36 PM, Jonathan Linowes wrote: > > On Nov 20, 2007, at 8:07 PM, Pat Maddox wrote: > >> On Nov 20, 2007 2:55 PM, Jonathan Linowes >> wrote: >>> fyi, I just posted this >>> >>> http://www.vaporbase.com/postings/Running_rspec_after_you_deploy >>> >>> - linoj >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> I'm kind of confused. You say that you're not running the specs >> against the production database, but it looks like that's exactly >> what's going on. What am I missing? >> >> Pat >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > It confused me too. I assume you're referring to the rake spec > command. > I've not followed the code, but what it does is connect to the > development database first (or production one if you say > RAILS_ENV=production) before getting to spec_helper which in turn > specifies ENV["RAILS_ENV"] = "test" to connect to the test one before > running the specs. > > In my case the development: section in database.yml defines the one > on my development machine, so the spec fails when run on the server > with an error cannot connect to the database unless I say > RAILS_ENV=production > > Not this only occurs on rake spec, not when running script/spec typo: NOTE: this only occurs on rake spec... > > see thread http://rubyforge.org/pipermail/rspec-users/2007-October/ > 004206.html > > --linoj > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From pergesu at gmail.com Tue Nov 20 21:28:30 2007 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 20 Nov 2007 18:28:30 -0800 Subject: [rspec-users] cap deploy:spec In-Reply-To: <271AA87E-7958-4053-96F1-9C99780DDA10@parkerhill.com> References: <810a540e0711201707m12404490u363b8b7aea2d6888@mail.gmail.com> <271AA87E-7958-4053-96F1-9C99780DDA10@parkerhill.com> Message-ID: <810a540e0711201828l3f53bdcobcc2c2c4c047c9fc@mail.gmail.com> On Nov 20, 2007 5:36 PM, Jonathan Linowes wrote: > It confused me too. I assume you're referring to the rake spec command. > I've not followed the code, but what it does is connect to the > development database first (or production one if you say > RAILS_ENV=production) before getting to spec_helper which in turn > specifies ENV["RAILS_ENV"] = "test" to connect to the test one before > running the specs. Okay, that makes sense. I was unaware that rake db:test:prepare always used the test env as the target database to migrate. Seems like it could be dangerous :) Looks pretty cool. Though I'll add that you should use cruisecontrol.rb so you know your specs are all passing before you deploy ;) Pat From mattaimonetti at gmail.com Tue Nov 20 20:19:51 2007 From: mattaimonetti at gmail.com (Matt Aimonetti) Date: Tue, 20 Nov 2007 17:19:51 -0800 Subject: [rspec-users] failing rake task In-Reply-To: <49f64a900711201712j222abddeg74cc872ddcedd64c@mail.gmail.com> References: <49f64a900711201712j222abddeg74cc872ddcedd64c@mail.gmail.com> Message-ID: Try re generating the rspec files: ruby script/generate rspec -Matt -- -------- http://railsontherun.com On 11/20/07, Lance Carlson wrote: > > I'm running rspec and rspec on rails in svn external so I am running > the latest version of the trunk. Recently the rake spec task started > braking the continuous integration server because the rake aborted. I > checked my local and it ran with the same behavior.. and all of the > devs on my team are now experiencing the same problem. All the spec's > are passing, but the rake task is aborting. Anyone know why this could > be happening? > > Finished in 8.396101 seconds > > 422 examples, 0 failures, 25 pending > rake aborted! > Command ruby etc. etc. > > " --options "/Users/lance/Sites/feedvuz/spec/spec.opts" failed > > (See full trace by running task with --trace) > > The trace produced the following results: > > " --options "/Users/lance/Sites/feedvuz/spec/spec.opts" failed > > /Users/lance/Sites/feedvuz/vendor/plugins/rspec/lib/spec/rake/spectask.rb:173:in > `define' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:823:in > `verbose' > > /Users/lance/Sites/feedvuz/vendor/plugins/rspec/lib/spec/rake/spectask.rb:142:in > `define' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:392:in > `call' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:392:in > `execute' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:392:in > `each' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:392:in > `execute' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:362:in > `invoke' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:355:in > `synchronize' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:355:in > `invoke' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:1739:in > `top_level' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:1739:in > `each' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:1739:in > `top_level' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:1761:in > `standard_exception_handling' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:1733:in > `top_level' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:1711:in > `run' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:1761:in > `standard_exception_handling' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:1708:in > `run' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/bin/rake:7 > /usr/bin/rake:16:in `load' > /usr/bin/rake:16 > > Thanks in advance! > -L > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071120/a5c1a1fd/attachment-0001.html From jarkko at jlaine.net Wed Nov 21 02:12:04 2007 From: jarkko at jlaine.net (Jarkko Laine) Date: Wed, 21 Nov 2007 09:12:04 +0200 Subject: [rspec-users] How to test views with Nested Resources and Partials In-Reply-To: <1195590115.8121.54.camel@tnini2.sourcedirect.com> References: <1195590115.8121.54.camel@tnini2.sourcedirect.com> Message-ID: Hi Troy, On 20.11.2007, at 22.21, Troy Nini wrote: > ######## Output from running edit.haml_spec.r ######## > > F > > 1) > ActionView::TemplateError in '/line_items/edit.haml should render > edit form' > contract_line_item_url failed to generate from > {:contract_id=>"1", :action=>"show", :controller=>"line_items"}, > expected: {:action=>"show", :controller=>"line_items"}, diff: > {:contract_id=>"1"} > On line #6 of app/views/line_items/edit.haml > > 3: > 4: #section1 > 5: = error_messages_for :line_item > 6: - form_for(:line_item, :url => contract_line_item_path > (@contract.id) contract_line_item_path (and _url) expects two parameters, contract and line item (or their ids). The errors the routing code outputs are often pretty cryptic. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi From osahyoun at gmail.com Wed Nov 21 02:42:46 2007 From: osahyoun at gmail.com (Sahyoun) Date: Wed, 21 Nov 2007 08:42:46 +0100 Subject: [rspec-users] describe AddressesController, "handling GET /addresses" do Message-ID: Hello, I'm working with scaffold generated controller test code for handling GET requests. Address is the model being tested. Address belongs_to Company, Company has_many addresses. In my addresses_controller I have: before_filter :get_company def index @addresses = @company.addresses.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @addresses } end end private def get_company @company = Company.find_by_id(params[:company_id]) end My controller spec code for handling GET /addresses: before do @company = mock_model(Company) @addresses = mock("addresses") @company.stub!(:addresses).and_return(@addresses) Company.stub!(:find).and_return(@company) end def do_get get :index, :company_id => 1 end it "should be successful" do do_get response.should be_success end ............. All of my tests (4) fail: 4) NoMethodError in 'AddressesController handling GET /addresses should be successful' You have a nil object when you didn't expect it! The error occurred while evaluating nil.addresses Please, can someone explain why i'm getting nil.addresses? Cheers! Omar -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071121/75903cbf/attachment.html From jarkko at jlaine.net Wed Nov 21 03:12:40 2007 From: jarkko at jlaine.net (Jarkko Laine) Date: Wed, 21 Nov 2007 10:12:40 +0200 Subject: [rspec-users] Stories and Pending Actions In-Reply-To: References: <57c63afe0711190123y211f66foe6955facc1e26206@mail.gmail.com> <1E2C9C55-45FB-4FE4-B3E7-A63A530FFCC1@gmail.com> <57c63afe0711190902u589badbfrad95fb150f9104b1@mail.gmail.com> Message-ID: <5C7036C0-EA56-4928-A8F5-AAA632DE8095@jlaine.net> On 20.11.2007, at 10.08, Nathan Sutton wrote: > Didn't have time tonight, stand-by for something tomorrow. Done: http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/132- plain-text-stories-should-support-given-and-given -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi From jarkko at jlaine.net Wed Nov 21 03:19:02 2007 From: jarkko at jlaine.net (Jarkko Laine) Date: Wed, 21 Nov 2007 10:19:02 +0200 Subject: [rspec-users] describe AddressesController, "handling GET /addresses" do In-Reply-To: References: Message-ID: On 21.11.2007, at 9.42, Sahyoun wrote: > Hello, > > I'm working with scaffold generated controller test code for > handling GET requests. Address is the model being tested. Address > belongs_to Company, Company has_many addresses. > In my addresses_controller I have: > > before_filter :get_company > > def index > @addresses = @company.addresses.find(:all) > respond_to do |format| > format.html # index.html.erb > format.xml { render :xml => @addresses } > end > end > > private > def get_company > @company = Company.find_by_id(params[:company_id]) > end > > > My controller spec code for handling GET /addresses: > > before do > @company = mock_model(Company) > @addresses = mock("addresses") > @company.stub!(:addresses).and_return(@addresses) > Company.stub!(:find).and_return(@company) > end > > def do_get > get :index, :company_id => 1 > end > > it "should be successful" do > do_get > response.should be_success > end > ............. > > > All of my tests (4) fail: > > 4) NoMethodError in 'AddressesController handling GET /addresses > should be successful' > You have a nil object when you didn't expect it! > The error occurred while evaluating nil.addresses > > > Please, can someone explain why i'm getting nil.addresses? Since you haven't stubbed Company.find_by_id, it goes to the database, doesn't find a matching row, and returns nil. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi From dsisnero at gmail.com Wed Nov 21 03:48:43 2007 From: dsisnero at gmail.com (Dominic Sisneros) Date: Wed, 21 Nov 2007 01:48:43 -0700 Subject: [rspec-users] [ANN] Lighthouse and Engine Yard sponsorships In-Reply-To: <683a886f0711191357o1260f95ew40e24c666f31914c@mail.gmail.com> References: <57c63afe0711181310i7d6c08e2ib6f826221b837af8@mail.gmail.com> <79F32A2C-23A9-4911-B292-60ACBDDBFD71@railsnewbie.com> <2fff50390711181517l418f6387k3ca560602df370f6@mail.gmail.com> <835d522e0711181528u74f86cf1h77c5cf282e9b165b@mail.gmail.com> <683a886f0711181657v3225df8ar2972be1c78f2a9ae@mail.gmail.com> <71166b3b0711181712o39010985w148445da88953e9f@mail.gmail.com> <683a886f0711182021jabb3922s21f17398bd4e4426@mail.gmail.com> <71166b3b0711190755xe810625x2b9ab724c08e7ccb@mail.gmail.com> <683a886f0711191357o1260f95ew40e24c666f31914c@mail.gmail.com> Message-ID: There is a msys branch of git that is extremely easy to install in windows from this url: http://code.google.com/p/msysgit/ I tried it and it seems to work pretty well On Nov 19, 2007 2:57 PM, Kevin Williams wrote: > On Nov 19, 2007 8:55 AM, Luis Lavena wrote: > > On Nov 19, 2007 1:21 AM, Kevin Williams wrote: > > > On 11/18/07, Luis Lavena wrote: > > > > On Nov 18, 2007 9:57 PM, Kevin Williams wrote: > > > > > I don't intend to use RSpec source either, but I suspect the most > > > > > people would be satisfied with a main Subversion repository. Git users > > > > > can check out from / in to a Subversion repository just fine. > > > > > > > > > > > > > That poses a problem for the poor souls trapped in Windows. > > > > > > No it doesn't. Subversion works great on Windows. Windows users can > > > try to use Git in Cygwin if they really want to, but they can also > > > just use TortoiseSVN or whatever favorite Subversion client they want. > > > > > > > I wasn't talking about the svn clone, was talking about the sync > > policy "will be synch'ed one time at day"... > > I was suggesting to have only one main Subversion repository rather > than two different repositories, so there would be no sync. If there > are two repositories (one Git/Mercurial at EngineYard, one Subversion > at Rubyforge) then certainly getting the sync right is important. > > > > > That in combination with Git, make difficult to be "out of the box" useful. > > I'm not aware of anything special in Mercurial that would make this > easier than Git out of the box. It seems Git would be easier, with > full two-way sync with Subversion built in, but if Mercurial has this > as well then I'd say they are about equal in this regard. > > > > > the use of cygwin git is a bit problematic, and sometimes eol styles > > mixes don't like the different interpreters (unix eol against windows > > eol) with ruby-mswin32 and ruby cygwin. > > Yes, git on cygwin is a pain, and is only for the brave. The problem > of Git for Windows users goes away if the main repository is > Subversion. > > > > > > With a Subversion repository, you can choose between Subversion as a > > > client or Git as a client (yes, it's actually a local clone of the > > > repository, but a client of the main svn repo as well). > > > > > > http://git.or.cz/course/svn.html > > > http://blog.nbwd.co.uk/2007/8/16/using-git-for-rails-development > > > > > > > Again, was talking about that the git-to-svn sync. > > http://blog.fallingsnow.net/2007/08/17/maintaining-an-svn-mirror-directly-from-git/ > Mercurial can be used by Tailor in the same manner that Evan describes > here, so I'd say they are equal in syncing. > > > The git/mercurial over svn without a proper sync solution will be a > > problem for those users using script/plugin to install and use rspec > > on Rails applications -- since rails is highly integrated with svn for > > these commands. > > It wouldn't be a technical problem, as it would be business as usual > for the "script/plugin install" process to pull from Rubyforge svn. > The only problem I see might be a timing issue, but that could be > fixed by sync'ing every commit. > > > > > Anyway, just my comments :-) > > A fun discussion to have, I think. :) The switch to distributed > version control is a paradigm shift for many, and I'm curious to see > how this one turns out. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From osahyoun at gmail.com Wed Nov 21 04:15:48 2007 From: osahyoun at gmail.com (Sahyoun) Date: Wed, 21 Nov 2007 10:15:48 +0100 Subject: [rspec-users] describe AddressesController, "handling GET /addresses" do In-Reply-To: References: Message-ID: Thanks. That helped. I now have: before do @address = mock_model(Address) @company = mock_model(Company) Company.stub!(:find_by_id).and_return(@company) @company.stub!(:addresses).and_return(@addresses) end with only one error remaining: 'AddressesController handling GET /addresses should assign the found addresses for the view' FAILED expected: [nil], got: nil (using ==) Spec: it "should assign the found addresses for the view" do do_get assigns[:addresses].should == [@addresses] end I thought @company.stub!(:addresses).and_return(@addresses) would be sufficient for the above to pass. My understanding of mocking and stubbing is sketchy at the moment. Any explanation on how to get this to pass would be appreciated. Many thanks, Omar On 21/11/2007, Jarkko Laine wrote: > > > On 21.11.2007, at 9.42, Sahyoun wrote: > > > Hello, > > > > I'm working with scaffold generated controller test code for > > handling GET requests. Address is the model being tested. Address > > belongs_to Company, Company has_many addresses. > > In my addresses_controller I have: > > > > before_filter :get_company > > > > def index > > @addresses = @company.addresses.find(:all) > > respond_to do |format| > > format.html # index.html.erb > > format.xml { render :xml => @addresses } > > end > > end > > > > private > > def get_company > > @company = Company.find_by_id(params[:company_id]) > > end > > > > > > My controller spec code for handling GET /addresses: > > > > before do > > @company = mock_model(Company) > > @addresses = mock("addresses") > > @company.stub!(:addresses).and_return(@addresses) > > Company.stub!(:find).and_return(@company) > > end > > > > def do_get > > get :index, :company_id => 1 > > end > > > > it "should be successful" do > > do_get > > response.should be_success > > end > > ............. > > > > > > All of my tests (4) fail: > > > > 4) NoMethodError in 'AddressesController handling GET /addresses > > should be successful' > > You have a nil object when you didn't expect it! > > The error occurred while evaluating nil.addresses > > > > > > Please, can someone explain why i'm getting nil.addresses? > > Since you haven't stubbed Company.find_by_id, it goes to the > database, doesn't find a matching row, and returns nil. > > //jarkko > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071121/fe363802/attachment.html From pergesu at gmail.com Wed Nov 21 04:35:05 2007 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 21 Nov 2007 01:35:05 -0800 Subject: [rspec-users] describe AddressesController, "handling GET /addresses" do In-Reply-To: References: Message-ID: <810a540e0711210135x7c8372bbh74ece122299d35cf@mail.gmail.com> On Nov 21, 2007 1:15 AM, Sahyoun wrote: > Thanks. That helped. I now have: > > before do > @address = mock_model(Address) > @company = mock_model(Company) > Company.stub!(:find_by_id).and_return(@company) > > @company.stub!(:addresses).and_return(@addresses) > end > > > with only one error remaining: > > 'AddressesController handling GET /addresses should assign the found > addresses for the view' FAILED > expected: [nil], > got: nil (using ==) > > Spec: > it "should assign the found addresses for the view" do > do_get > assigns[:addresses].should == [@addresses] > end > > > I thought @company.stub!(:addresses).and_return(@addresses) would be > sufficient for the above to pass. My understanding of mocking and stubbing > is sketchy at the moment. Any explanation on how to get this to pass would > be appreciated. @company.stub!(:addresses).and_return([@addresses]) If you're expecting an array, then you need the stub to return an array. Pat From pergesu at gmail.com Wed Nov 21 04:35:48 2007 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 21 Nov 2007 01:35:48 -0800 Subject: [rspec-users] describe AddressesController, "handling GET /addresses" do In-Reply-To: <810a540e0711210135x7c8372bbh74ece122299d35cf@mail.gmail.com> References: <810a540e0711210135x7c8372bbh74ece122299d35cf@mail.gmail.com> Message-ID: <810a540e0711210135g6c2da0ebpe03d462ad5b4ecfa@mail.gmail.com> On Nov 21, 2007 1:35 AM, Pat Maddox wrote: > On Nov 21, 2007 1:15 AM, Sahyoun wrote: > > Thanks. That helped. I now have: > > > > before do > > @address = mock_model(Address) > > @company = mock_model(Company) > > Company.stub!(:find_by_id).and_return(@company) > > > > @company.stub!(:addresses).and_return(@addresses) > > end > > > > > > with only one error remaining: > > > > 'AddressesController handling GET /addresses should assign the found > > addresses for the view' FAILED > > expected: [nil], > > got: nil (using ==) > > > > Spec: > > it "should assign the found addresses for the view" do > > do_get > > assigns[:addresses].should == [@addresses] > > end > > > > > > I thought @company.stub!(:addresses).and_return(@addresses) would be > > sufficient for the above to pass. My understanding of mocking and stubbing > > is sketchy at the moment. Any explanation on how to get this to pass would > > be appreciated. > > @company.stub!(:addresses).and_return([@addresses]) > > If you're expecting an array, then you need the stub to return an array. > > Pat > Guh, sorry, should have looked a bit more closely: @company.stub!(:addresses).and_return([@address]) Pat From jarkko at jlaine.net Wed Nov 21 07:06:57 2007 From: jarkko at jlaine.net (Jarkko Laine) Date: Wed, 21 Nov 2007 14:06:57 +0200 Subject: [rspec-users] Testing transactional updates in story runner Message-ID: <6BCCFC87-56A5-483C-8823-19403EA79EB0@jlaine.net> How do you guys test transactional updates with story runner? I have an action that needs to update four different models: Enrollment.transaction do @contact.update_addresses(params[:contact_address], params [:billing_address]) @enrollment.update_attributes!(params[:enrollment]) end The last update_attributes! will raise ActiveRecord::RecordNotValid if anything was invalid (it cascades to contact and further to addresses), and thus cause a rollback, so either all the updates go through or none of them. This works fine in development and production. However, in story runner the whole story is put inside a big transaction and further attempts to create or rollback transactions are ignored. This is of course nice from the performance point of view, but if you have code that depends on actual transactions in the app, you're screwed. In my example the addresses would stay updated in the story runner's eyes even though in real life the changes would be rolled back, thus making stories not what they're supposed to be, end-to-end tests for the application stack. Has anyone found an elegant way to circumvent this with story runner? Cheers, //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi From mvyver at gmail.com Wed Nov 21 02:07:38 2007 From: mvyver at gmail.com (Mark Van De Vyver) Date: Wed, 21 Nov 2007 18:07:38 +1100 Subject: [rspec-users] describe scope Message-ID: <389c43e40711202307s46207eafwf0be267b6ad5df74@mail.gmail.com> Hi, Googling 'RSpec describe scope' didn't yield much, so apologies if this question has been dealt with. It seem well known that a ruby class is 'visible' between describes, and if this is a problem then you should use some counter as prefix or suffix: 'class Item_001; ... end' Is there any work underway, or sheduled release where classes will exist only in the scope they are defined? Writing spec's for Og is where this becomes an issue because Og will grab _all_ manageble objects it can 'see'... all sorts of PITA can arise. Thanks for all the great work, T/BDD definitely is a brilliant way to work, and RSpec makes it painless, esp for us amatuers :) Mark From aslak.hellesoy at gmail.com Wed Nov 21 09:14:12 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 21 Nov 2007 15:14:12 +0100 Subject: [rspec-users] describe scope In-Reply-To: <389c43e40711202307s46207eafwf0be267b6ad5df74@mail.gmail.com> References: <389c43e40711202307s46207eafwf0be267b6ad5df74@mail.gmail.com> Message-ID: <8d961d900711210614r268b2427v641aefb2d9698e1@mail.gmail.com> On 11/21/07, Mark Van De Vyver wrote: > Hi, > Googling 'RSpec describe scope' didn't yield much, so apologies if > this question has been dealt with. > > It seem well known that a ruby class is 'visible' between describes, > and if this is a problem then you should use some counter as prefix or > suffix: > 'class Item_001; ... end' > > Is there any work underway, or sheduled release where classes will > exist only in the scope they are defined? > > Writing spec's for Og is where this becomes an issue because Og will > grab _all_ manageble objects it can 'see'... all sorts of PITA can > arise. > try something like this: before do @la_classe = Class.new(the_superclass) # or if you need to reload the class load 'file/with/class.rb' end after do # undefine the class (don't remember off the top of my head - #undef or something) end Aslak > Thanks for all the great work, T/BDD definitely is a brilliant way to > work, and RSpec makes it painless, esp for us amatuers :) > > Mark > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Nov 21 09:18:26 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 21 Nov 2007 08:18:26 -0600 Subject: [rspec-users] describe scope In-Reply-To: <389c43e40711202307s46207eafwf0be267b6ad5df74@mail.gmail.com> References: <389c43e40711202307s46207eafwf0be267b6ad5df74@mail.gmail.com> Message-ID: <57c63afe0711210618w8066c81s77a71372bff22f1@mail.gmail.com> On Nov 21, 2007 1:07 AM, Mark Van De Vyver wrote: > Hi, > Googling 'RSpec describe scope' didn't yield much, so apologies if > this question has been dealt with. > > It seem well known that a ruby class is 'visible' between describes, > and if this is a problem then you should use some counter as prefix or > suffix: > 'class Item_001; ... end' > > Is there any work underway, or sheduled release where classes will > exist only in the scope they are defined? This has never been brought up before. Feel free to submit a feature request at http://rspec.lighthouseapp.com/. > Writing spec's for Og is where this becomes an issue because Og will > grab _all_ manageble objects it can 'see'... all sorts of PITA can > arise. I found this: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/6924 So you could, in theory, monkey patch ExampleGroupMethods (in trunk 2937 - these names are changing a bit, so keep an eye out) to remove the defined constant > > Thanks for all the great work, T/BDD definitely is a brilliant way to > work, and RSpec makes it painless, esp for us amatuers :) That's what we want to hear! Thanks. Cheers, David > > Mark > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tbnini at gmail.com Wed Nov 21 09:58:58 2007 From: tbnini at gmail.com (Troy Nini) Date: Wed, 21 Nov 2007 08:58:58 -0600 Subject: [rspec-users] How to test views with Nested Resources and Partials In-Reply-To: References: <1195590115.8121.54.camel@tnini2.sourcedirect.com> Message-ID: <967a91150711210658ib392f94yd1ab49721d90fc0d@mail.gmail.com> Thanks Jarkko! OK that was embarrassingly simple. Maybe, I was just testing you, or not. On Nov 21, 2007 1:12 AM, Jarkko Laine wrote: > Hi Troy, > > On 20.11.2007, at 22.21, Troy Nini wrote: > > ######## Output from running edit.haml_spec.r ######## > > > > F > > > > 1) > > ActionView::TemplateError in '/line_items/edit.haml should render > > edit form' > > contract_line_item_url failed to generate from > > {:contract_id=>"1", :action=>"show", :controller=>"line_items"}, > > expected: {:action=>"show", :controller=>"line_items"}, diff: > > {:contract_id=>"1"} > > On line #6 of app/views/line_items/edit.haml > > > > 3: > > 4: #section1 > > 5: = error_messages_for :line_item > > 6: - form_for(:line_item, :url => contract_line_item_path > > (@contract.id) > > contract_line_item_path (and _url) expects two parameters, contract > and line item (or their ids). The errors the routing code outputs are > often pretty cryptic. > > //jarkko > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > From lancecarlson at gmail.com Wed Nov 21 11:24:30 2007 From: lancecarlson at gmail.com (Lance Carlson) Date: Wed, 21 Nov 2007 11:24:30 -0500 Subject: [rspec-users] failing rake task In-Reply-To: References: <49f64a900711201712j222abddeg74cc872ddcedd64c@mail.gmail.com> Message-ID: <49f64a900711210824r4ab41b26i70f081b4bcfe2b18@mail.gmail.com> Yea I tried that already, I will try again, but i replaced my local files and checked the diff on the repo. I didn't see any changes in the new files that would have any effect on the rake task. It updated spec.opts and spec_helper.. I have stuff in spec_helper that is application specific that showed in the svn diff (but nothing else) and there were subtle changes in spec.opts .. I will try again but, I remember still having problems. -L On Nov 20, 2007 8:19 PM, Matt Aimonetti wrote: > Try re generating the rspec files: > > ruby script/generate rspec > > -Matt > > -- > -------- > http://railsontherun.com > > > > On 11/20/07, Lance Carlson wrote: > > > > > > > > I'm running rspec and rspec on rails in svn external so I am running > > the latest version of the trunk. Recently the rake spec task started > > braking the continuous integration server because the rake aborted. I > > checked my local and it ran with the same behavior.. and all of the > > devs on my team are now experiencing the same problem. All the spec's > > are passing, but the rake task is aborting. Anyone know why this could > > be happening? > > > > Finished in 8.396101 seconds > > > > 422 examples, 0 failures, 25 pending > > rake aborted! > > Command ruby etc. etc. > > > > " --options "/Users/lance/Sites/feedvuz/spec/spec.opts" failed > > > > (See full trace by running task with --trace) > > > > The trace produced the following results: > > > > " --options "/Users/lance/Sites/feedvuz/spec/spec.opts" failed > > > /Users/lance/Sites/feedvuz/vendor/plugins/rspec/lib/spec/rake/spectask.rb:173:in > > `define' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:823:in > > `verbose' > > > /Users/lance/Sites/feedvuz/vendor/plugins/rspec/lib/spec/rake/spectask.rb:142:in > > `define' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > > `call' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:392:in > > `execute' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > > `each' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:392:in > > `execute' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in > > `invoke' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:355:in > > `synchronize' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in > > `invoke' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:1739:in > > `top_level' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in > > `each' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:1739:in > > `top_level' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in > > `standard_exception_handling' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:1733:in > > `top_level' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in > > `run' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/rake.rb:1761:in > > `standard_exception_handling' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in > > `run' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > 0.7.3/bin/rake:7 > > /usr/bin/rake:16:in `load' > > /usr/bin/rake:16 > > > > Thanks in advance! > > -L > > _______________________________________________ > > 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 lancecarlson at gmail.com Wed Nov 21 11:55:32 2007 From: lancecarlson at gmail.com (Lance Carlson) Date: Wed, 21 Nov 2007 11:55:32 -0500 Subject: [rspec-users] failing rake task In-Reply-To: <49f64a900711210824r4ab41b26i70f081b4bcfe2b18@mail.gmail.com> References: <49f64a900711201712j222abddeg74cc872ddcedd64c@mail.gmail.com> <49f64a900711210824r4ab41b26i70f081b4bcfe2b18@mail.gmail.com> Message-ID: <49f64a900711210855y7c6bbe28hf126b019f429517d@mail.gmail.com> Looks like a bunch of updates were made overnight to the rake task and it works now. Serves me right for wanting to be on the edge. :) On Nov 21, 2007 11:24 AM, Lance Carlson wrote: > Yea I tried that already, I will try again, but i replaced my local > files and checked the diff on the repo. I didn't see any changes in > the new files that would have any effect on the rake task. It updated > spec.opts and spec_helper.. I have stuff in spec_helper that is > application specific that showed in the svn diff (but nothing else) > and there were subtle changes in spec.opts .. I will try again but, I > remember still having problems. > > -L > > > On Nov 20, 2007 8:19 PM, Matt Aimonetti wrote: > > Try re generating the rspec files: > > > > ruby script/generate rspec > > > > -Matt > > > > -- > > -------- > > http://railsontherun.com > > > > > > > > On 11/20/07, Lance Carlson wrote: > > > > > > > > > > > > I'm running rspec and rspec on rails in svn external so I am running > > > the latest version of the trunk. Recently the rake spec task started > > > braking the continuous integration server because the rake aborted. I > > > checked my local and it ran with the same behavior.. and all of the > > > devs on my team are now experiencing the same problem. All the spec's > > > are passing, but the rake task is aborting. Anyone know why this could > > > be happening? > > > > > > Finished in 8.396101 seconds > > > > > > 422 examples, 0 failures, 25 pending > > > rake aborted! > > > Command ruby etc. etc. > > > > > > " --options "/Users/lance/Sites/feedvuz/spec/spec.opts" failed > > > > > > (See full trace by running task with --trace) > > > > > > The trace produced the following results: > > > > > > " --options "/Users/lance/Sites/feedvuz/spec/spec.opts" failed > > > > > /Users/lance/Sites/feedvuz/vendor/plugins/rspec/lib/spec/rake/spectask.rb:173:in > > > `define' > > > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:823:in > > > `verbose' > > > > > /Users/lance/Sites/feedvuz/vendor/plugins/rspec/lib/spec/rake/spectask.rb:142:in > > > `define' > > > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > > > `call' > > > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > > 0.7.3/lib/rake.rb:392:in > > > `execute' > > > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > > > `each' > > > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > > 0.7.3/lib/rake.rb:392:in > > > `execute' > > > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in > > > `invoke' > > > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > > 0.7.3/lib/rake.rb:355:in > > > `synchronize' > > > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in > > > `invoke' > > > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > > 0.7.3/lib/rake.rb:1739:in > > > `top_level' > > > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in > > > `each' > > > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > > 0.7.3/lib/rake.rb:1739:in > > > `top_level' > > > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in > > > `standard_exception_handling' > > > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > > 0.7.3/lib/rake.rb:1733:in > > > `top_level' > > > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in > > > `run' > > > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > > 0.7.3/lib/rake.rb:1761:in > > > `standard_exception_handling' > > > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in > > > `run' > > > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake- > > 0.7.3/bin/rake:7 > > > /usr/bin/rake:16:in `load' > > > /usr/bin/rake:16 > > > > > > Thanks in advance! > > > -L > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > From aslak.hellesoy at gmail.com Wed Nov 21 12:08:31 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 21 Nov 2007 18:08:31 +0100 Subject: [rspec-users] failing rake task In-Reply-To: <49f64a900711201712j222abddeg74cc872ddcedd64c@mail.gmail.com> References: <49f64a900711201712j222abddeg74cc872ddcedd64c@mail.gmail.com> Message-ID: <8d961d900711210908n58ab3d3agc9ba413936c5ca1@mail.gmail.com> On Nov 21, 2007 2:12 AM, Lance Carlson wrote: > I'm running rspec and rspec on rails in svn external so I am running > the latest version of the trunk. revision? > Recently the rake spec task started > braking the continuous integration server because the rake aborted. I > checked my local and it ran with the same behavior.. and all of the > devs on my team are now experiencing the same problem. All the spec's > are passing, but the rake task is aborting. Anyone know why this could > be happening? > > Finished in 8.396101 seconds > > 422 examples, 0 failures, 25 pending > rake aborted! > Command ruby etc. etc. > > " --options "/Users/lance/Sites/feedvuz/spec/spec.opts" failed > > (See full trace by running task with --trace) > > The trace produced the following results: > > " --options "/Users/lance/Sites/feedvuz/spec/spec.opts" failed > /Users/lance/Sites/feedvuz/vendor/plugins/rspec/lib/spec/rake/spectask.rb:173:in > `define' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:823:in > `verbose' > /Users/lance/Sites/feedvuz/vendor/plugins/rspec/lib/spec/rake/spectask.rb:142:in > `define' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > `call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > `execute' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > `each' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > `execute' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in > `invoke' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in > `synchronize' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in > `invoke' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in > `top_level' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in > `each' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in > `top_level' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in > `standard_exception_handling' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in > `top_level' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in > `run' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in > `standard_exception_handling' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in > `run' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 > /usr/bin/rake:16:in `load' > /usr/bin/rake:16 > > Thanks in advance! > -L > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lancecarlson at gmail.com Wed Nov 21 12:11:45 2007 From: lancecarlson at gmail.com (Lance Carlson) Date: Wed, 21 Nov 2007 12:11:45 -0500 Subject: [rspec-users] failing rake task In-Reply-To: <8d961d900711210908n58ab3d3agc9ba413936c5ca1@mail.gmail.com> References: <49f64a900711201712j222abddeg74cc872ddcedd64c@mail.gmail.com> <8d961d900711210908n58ab3d3agc9ba413936c5ca1@mail.gmail.com> Message-ID: <49f64a900711210911g20a840d2l7c3e4565e622b606@mail.gmail.com> I'm at the very latest, not sure what that is, but I just updated and pulled down a bunch of new files related to the rake task and everything is working fine now. On Nov 21, 2007 12:08 PM, aslak hellesoy wrote: > On Nov 21, 2007 2:12 AM, Lance Carlson wrote: > > I'm running rspec and rspec on rails in svn external so I am running > > the latest version of the trunk. > > revision? > > > > Recently the rake spec task started > > braking the continuous integration server because the rake aborted. I > > checked my local and it ran with the same behavior.. and all of the > > devs on my team are now experiencing the same problem. All the spec's > > are passing, but the rake task is aborting. Anyone know why this could > > be happening? > > > > Finished in 8.396101 seconds > > > > 422 examples, 0 failures, 25 pending > > rake aborted! > > Command ruby etc. etc. > > > > " --options "/Users/lance/Sites/feedvuz/spec/spec.opts" failed > > > > (See full trace by running task with --trace) > > > > The trace produced the following results: > > > > " --options "/Users/lance/Sites/feedvuz/spec/spec.opts" failed > > /Users/lance/Sites/feedvuz/vendor/plugins/rspec/lib/spec/rake/spectask.rb:173:in > > `define' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:823:in > > `verbose' > > /Users/lance/Sites/feedvuz/vendor/plugins/rspec/lib/spec/rake/spectask.rb:142:in > > `define' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > > `call' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > > `execute' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > > `each' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > > `execute' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in > > `invoke' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in > > `synchronize' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in > > `invoke' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in > > `top_level' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in > > `each' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in > > `top_level' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in > > `standard_exception_handling' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in > > `top_level' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in > > `run' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in > > `standard_exception_handling' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in > > `run' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 > > /usr/bin/rake:16:in `load' > > /usr/bin/rake:16 > > > > Thanks in advance! > > -L > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Wed Nov 21 12:23:45 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 21 Nov 2007 18:23:45 +0100 Subject: [rspec-users] failing rake task In-Reply-To: <49f64a900711210911g20a840d2l7c3e4565e622b606@mail.gmail.com> References: <49f64a900711201712j222abddeg74cc872ddcedd64c@mail.gmail.com> <8d961d900711210908n58ab3d3agc9ba413936c5ca1@mail.gmail.com> <49f64a900711210911g20a840d2l7c3e4565e622b606@mail.gmail.com> Message-ID: <8d961d900711210923n50daf7c0p19c8969d57fd5ccc@mail.gmail.com> On Nov 21, 2007 6:11 PM, Lance Carlson wrote: > I'm at the very latest, not sure what that is, but I just updated and > pulled down a bunch of new files related to the rake task and > everything is working fine now. > For the future: svn info vendor/plugins/rspec > > On Nov 21, 2007 12:08 PM, aslak hellesoy wrote: > > On Nov 21, 2007 2:12 AM, Lance Carlson wrote: > > > I'm running rspec and rspec on rails in svn external so I am running > > > the latest version of the trunk. > > > > revision? > > > > > > > Recently the rake spec task started > > > braking the continuous integration server because the rake aborted. I > > > checked my local and it ran with the same behavior.. and all of the > > > devs on my team are now experiencing the same problem. All the spec's > > > are passing, but the rake task is aborting. Anyone know why this could > > > be happening? > > > > > > Finished in 8.396101 seconds > > > > > > 422 examples, 0 failures, 25 pending > > > rake aborted! > > > Command ruby etc. etc. > > > > > > " --options "/Users/lance/Sites/feedvuz/spec/spec.opts" failed > > > > > > (See full trace by running task with --trace) > > > > > > The trace produced the following results: > > > > > > " --options "/Users/lance/Sites/feedvuz/spec/spec.opts" failed > > > /Users/lance/Sites/feedvuz/vendor/plugins/rspec/lib/spec/rake/spectask.rb:173:in > > > `define' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:823:in > > > `verbose' > > > /Users/lance/Sites/feedvuz/vendor/plugins/rspec/lib/spec/rake/spectask.rb:142:in > > > `define' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > > > `call' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > > > `execute' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > > > `each' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > > > `execute' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in > > > `invoke' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in > > > `synchronize' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in > > > `invoke' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in > > > `top_level' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in > > > `each' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in > > > `top_level' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in > > > `standard_exception_handling' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in > > > `top_level' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in > > > `run' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in > > > `standard_exception_handling' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in > > > `run' > > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 > > > /usr/bin/rake:16:in `load' > > > /usr/bin/rake:16 > > > > > > Thanks in advance! > > > -L > > > > > _______________________________________________ > > > 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 mailing_lists at railsnewbie.com Wed Nov 21 13:12:48 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 21 Nov 2007 13:12:48 -0500 Subject: [rspec-users] 'it' duplicate example: BUG Message-ID: <95A4BD3A-C34F-497A-976F-BD52CB26F415@railsnewbie.com> I svn up'ed this morning, to get the following message with rake spec: /Users/smt/src/web/urbis/trunk/vendor/plugins/rspec/lib/spec/example/ example_group_methods.rb:96:in `it': Duplicate example: 'should contain the total number of messages' (RuntimeError) Anyone have any ideas why this might be going on? My specs were all passing last night. Let me know if I should put this in the tracker. Scott From lists at ruby-forum.com Wed Nov 21 13:22:51 2007 From: lists at ruby-forum.com (Chris Olsen) Date: Wed, 21 Nov 2007 19:22:51 +0100 Subject: [rspec-users] How thorough do you test? Message-ID: <9f0720265988617b020f52266300c330@ruby-forum.com> Testing models is great and would not be able to create anything without it, but I am finding testing the controllers and views is a pain. Rest based controllers don't seem to change that much when compared to the auto-generated code that obviously works. As for views I fail to see why testing it with a mock model does anything. Nothing is ensuring that when changes are made to the model that they will also be done to the mocks then causing the test to break. If anything, having the false security when all tests pass is worse, in that it may prevent you from double checking something crucial. I think tests for views makes sense when there is a condition that must be tested, ex. if a new member must fill in additional fields that are made visible only when they are from a certain country. A test may then make sense to ensure that the fields exist. I am still a noob, so if anyone can enlighten me I would appreciate it. Thanks -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Wed Nov 21 13:38:29 2007 From: ben at benmabey.com (Ben Mabey) Date: Wed, 21 Nov 2007 11:38:29 -0700 Subject: [rspec-users] How thorough do you test? In-Reply-To: <9f0720265988617b020f52266300c330@ruby-forum.com> References: <9f0720265988617b020f52266300c330@ruby-forum.com> Message-ID: <47447B25.40105@benmabey.com> Hey Chris, I used to have the same thinking as you currently do. I found that my view specs were brittle and offered false security. However, I actually totally disagree with those statements now. The difference is how I have been going about BDD. Before I would spec out my controllers then move down to my models. I would then only test my views when some logic mandated it. However, recently I have been letting my views drive my entire development process (via the story runner as well, but that is besides the point.) Starting from the view and working my way in has made me really appreciate the place for view specing. Remember, BDD is not just about "testing", but rather is a design process in and of itself. The point of using mocks in the view is not all for speed reasons.. by using mocks you can drive your entire design process from the view. So, if you need to make a change to a model that would in end effect the view you should really be changing the view spec first, have it fail, make it pass, and move down to the model level. There was good post about this outside-in approach the other day you might want to look at: http://kinderman.net/articles/2007/11/18/testing-on-high-bottom-up-versus-top-down-test-driven-development I hope this helps. I'm just learning myself. :) -Ben Chris Olsen wrote: > Testing models is great and would not be able to create anything without > it, but I am finding testing the controllers and views is a pain. > > Rest based controllers don't seem to change that much when compared to > the auto-generated code that obviously works. > > As for views I fail to see why testing it with a mock model does > anything. Nothing is ensuring that when changes are made to the model > that they will also be done to the mocks then causing the test to break. > If anything, having the false security when all tests pass is worse, in > that it may prevent you from double checking something crucial. > > I think tests for views makes sense when there is a condition that must > be tested, ex. if a new member must fill in additional fields that are > made visible only when they are from a certain country. A test may then > make sense to ensure that the fields exist. > > I am still a noob, so if anyone can enlighten me I would appreciate it. > > Thanks > From chad at spicycode.com Wed Nov 21 13:39:30 2007 From: chad at spicycode.com (Chad Humphries) Date: Wed, 21 Nov 2007 13:39:30 -0500 Subject: [rspec-users] 'it' duplicate example: BUG In-Reply-To: <95A4BD3A-C34F-497A-976F-BD52CB26F415@railsnewbie.com> References: <95A4BD3A-C34F-497A-976F-BD52CB26F415@railsnewbie.com> Message-ID: One of the recent trunk changesets modified the default behaviour to fail fast if duplicate examples are detected within a single behaviour/ example group. This is basically letting you know you have to "it" blocks in the behaviour with the same description. Note: You may have this issue rise up if you have one in a shared behaviour and accidental duplication in the file (that was my case when I updated this morning). - Chad On Nov 21, 2007, at 1:12 PM, Scott Taylor wrote: > I svn up'ed this morning, to get the following message with rake spec: > > /Users/smt/src/web/urbis/trunk/vendor/plugins/rspec/lib/spec/example/ > example_group_methods.rb:96:in `it': Duplicate example: 'should > contain the total number of messages' (RuntimeError) > > Anyone have any ideas why this might be going on? My specs were all > passing last night. > > Let me know if I should put this in the tracker. > > Scott > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lancecarlson at gmail.com Wed Nov 21 13:42:20 2007 From: lancecarlson at gmail.com (Lance Carlson) Date: Wed, 21 Nov 2007 13:42:20 -0500 Subject: [rspec-users] 'it' duplicate example: BUG In-Reply-To: <95A4BD3A-C34F-497A-976F-BD52CB26F415@railsnewbie.com> References: <95A4BD3A-C34F-497A-976F-BD52CB26F415@railsnewbie.com> Message-ID: <49f64a900711211042o30f77071n4759c1f9f27c5b42@mail.gmail.com> Check what spec is having problems, and look for duplicate it "should etc." descriptions. I had this problem this morning too and found some duplicate it "should " blocks. -L On Nov 21, 2007 1:12 PM, Scott Taylor wrote: > I svn up'ed this morning, to get the following message with rake spec: > > /Users/smt/src/web/urbis/trunk/vendor/plugins/rspec/lib/spec/example/ > example_group_methods.rb:96:in `it': Duplicate example: 'should > contain the total number of messages' (RuntimeError) > > Anyone have any ideas why this might be going on? My specs were all > passing last night. > > Let me know if I should put this in the tracker. > > Scott > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mailing_lists at railsnewbie.com Wed Nov 21 14:02:42 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 21 Nov 2007 14:02:42 -0500 Subject: [rspec-users] How thorough do you test? In-Reply-To: <9f0720265988617b020f52266300c330@ruby-forum.com> References: <9f0720265988617b020f52266300c330@ruby-forum.com> Message-ID: On Nov 21, 2007, at 1:22 PM, Chris Olsen wrote: > Testing models is great and would not be able to create anything > without > it, but I am finding testing the controllers and views is a pain. > > Rest based controllers don't seem to change that much when compared to > the auto-generated code that obviously works. > > As for views I fail to see why testing it with a mock model does > anything. Nothing is ensuring that when changes are made to the model > that they will also be done to the mocks then causing the test to > break. > If anything, having the false security when all tests pass is > worse, in > that it may prevent you from double checking something crucial. > > I think tests for views makes sense when there is a condition that > must > be tested, ex. if a new member must fill in additional fields that are > made visible only when they are from a certain country. A test may > then > make sense to ensure that the fields exist. > > I am still a noob, so if anyone can enlighten me I would appreciate > it. Personally, I find view specs to be very brittle. I avoid them like the plague. Occasionally, I'll integrate_views, but only for a regression, and in that case I'll usually use real model objects. As for controller specs - your experiencing the problems that all do with mocking/stubbing. I'm sure better tools are out there, on the way, which will tell you when a stub goes out of date (maybe you've changed the name of the method, and so on). For now, though, such things don't exist. For the most part, I think the reason people are using mocks in testing a rails projects is their speed. Speed is not some secondary factor - if your test run slow, you won't run them very often. I've already experienced this on current project, where I much more apt to run the whole suite of controller specs (which exclusively use mocks) than the whole suite of model specs (which takes around 200 seconds). Scott From pergesu at gmail.com Wed Nov 21 14:02:51 2007 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 21 Nov 2007 11:02:51 -0800 Subject: [rspec-users] How thorough do you test? In-Reply-To: <9f0720265988617b020f52266300c330@ruby-forum.com> References: <9f0720265988617b020f52266300c330@ruby-forum.com> Message-ID: <810a540e0711211102q5ad781dar98fc9e8d285cb1fd@mail.gmail.com> On Nov 21, 2007 10:22 AM, Chris Olsen wrote: > As for views I fail to see why testing it with a mock model does > anything. Nothing is ensuring that when changes are made to the model > that they will also be done to the mocks then causing the test to break. > If anything, having the false security when all tests pass is worse, in > that it may prevent you from double checking something crucial. Keep in mind that testing is about design, rather than testing. When your specs are all green, it means that your code is in a more-or-less stable state, not that it's correct. Rails encourages you to do funky stuff like user.company.sites.build params[:site] That's going to be a PITA to write a spec for. In my experience, if something is hard to spec, it's probably not the best design. Compare describe SitesController, " POST /companies/acme/sites" do include UserSpecHelpers before(:each) do login_as mock_user @mock_company = mock_model(Company) Company.stub!(:find_by_nickname).and_return @mock_company mock_user.stub!(:company).and_return @mock_company @sites_proxy = mock("sites proxy") @mock_company.stub!(:sites).and_return @sites_proxy @mock_site = mock_model(Site) @sites_proxy.stub!(:build).and_return @mock_site end def do_post post :create, :company_id => "acme", :site => {"name" => "foo"} end it "should find the company" do Company.should_receive(:find_by_nickname).with("acme").and_return @mock_company do_post end # assume that we do something like found_company == user.company # implicitly checking call because we've stubbed all the associations it "should build a site" do @sites_proxy.should_receive(:build).with("name" => "foo").and_return @mock_site do_post end it "should save the site" do @mock_site.should_receive(:save).and_return true do_post end end to describe SitesController " POST /companies/acme/sites" do include UserSpecHelpers before(:each) do login_as mock_user @mock_company = mock_model(Company, :add_site => true) Company.stub!(:find_by_nickname).and_return @mock_company mock_user.stub!(:access_company?).and_return true Site.stub!(:new).and_return :mock_site end def do_post post :create, :company_id => "acme", :site => {"name" => "foo"} end it "should find the company" do Company.should_receive(:find_by_nickname).with("acme").and_return @mock_company do_post end it "should see if the user has access to the company" do @mock_user.should_receive(:access_company?).with(@mock_company).and_return true do_post end it "should create a site" do Site.should_receive(:new).with("name" => "foo").and_return :mock_site do_post end it "should add the site to the company" do @mock_company.should_receive(:add_site).with(:mock_site).and_return true do_post end end The first one works, but it's ugly. We have to do a lot of setup, and then the specs just aren't very expressive. The controller is going to be coupled to the low-level model structure, and we didn't really do anything to help ourselves. The second one is much, much nicer. First of all, there's less setup, and the setup that's there is much more clear. We're just stubbing out some methods, rather than hooking up a bunch of relationships. The specs themselves are actually valuable. They read well, and, assuming that we wrote the spec and controller before the underlying model, they helped us discover a nice API. I think that #access_company? and #add_site will prove to be quite useful. It's really easy to fall into the trap of writing controller code that would lead to the first spec I showed. I even wrote those kinds of specs when I first started! I was thinking too much about what I "knew" to be the final implementation, rather than focusing on just writing the specs in a fluid, natural way, guiding me towards the final implementation. Eventually after writing all those ugly, painful specs you realize that there's probably a better way, and you come on this list asking for help. People offer alternative approaches and hopefully it snaps. > I think tests for views makes sense when there is a condition that must > be tested, ex. if a new member must fill in additional fields that are > made visible only when they are from a certain country. A test may then > make sense to ensure that the fields exist. I didn't do view specs for the longest time. Recently though I've learned that they are important. I have a bad habit of working hard to make the controller and model clean and well-designed, and then just jamming a bunch of stuff in the view. I mean, it's just the view, right? There's not a lot going on, and the designers are supposed to deal with that stuff anyway. As it turns out, it's incredibly easy to write trainwreck code in the view too! So writing view specs helps you avoid that, again. Just like controller specs, view specs will help guide you to push more things down into the model. Also, I think the combo of view + controller specs help you make design decisions like when to refactor to a Presenter. For example, you've got a controller which pulls a couple things out of an order object - the user, shipping address, billing address, and the line items. As your app grows, you might end up with 5 or 6 specs, where you have to stub out all of that stuff. You could refactor the specs themselves, writing little helper methods to hook all of that up for you. Or you could refactor the production code so you do something like "@presenter = OrderPresenter.new(order)". Then you can replace those 5 slightly different specs with one generic spec that uses a Presenter, and let the Presenter handle any details. I've done this several times, and I don't think I'd arrive at that solution if I didn't use the test style that I do. There are no hard-and-fast rules, but as a general rule, I find that if something is hard to spec then it's probably not a great design. Ultimately good design is about being able to easily use your code, and change it when needed. Thorough testing, using mocks, helps you first by defining how your code will be used, and second by pointing out sources of pain when you try to make changes. Pat From patcito at gmail.com Wed Nov 21 15:05:03 2007 From: patcito at gmail.com (Patrick Aljord) Date: Wed, 21 Nov 2007 21:05:03 +0100 Subject: [rspec-users] [ANN] Lighthouse and Engine Yard sponsorships In-Reply-To: References: <57c63afe0711181310i7d6c08e2ib6f826221b837af8@mail.gmail.com> <79F32A2C-23A9-4911-B292-60ACBDDBFD71@railsnewbie.com> <2fff50390711181517l418f6387k3ca560602df370f6@mail.gmail.com> <835d522e0711181528u74f86cf1h77c5cf282e9b165b@mail.gmail.com> <683a886f0711181657v3225df8ar2972be1c78f2a9ae@mail.gmail.com> <71166b3b0711181712o39010985w148445da88953e9f@mail.gmail.com> <683a886f0711182021jabb3922s21f17398bd4e4426@mail.gmail.com> <71166b3b0711190755xe810625x2b9ab724c08e7ccb@mail.gmail.com> <683a886f0711191357o1260f95ew40e24c666f31914c@mail.gmail.com> Message-ID: <6b6419750711211205w4ff4b087p75cfec0a29545a98@mail.gmail.com> > There is a msys branch of git that is extremely easy to install in > windows from this url: http://code.google.com/p/msysgit/ I tried it > and it seems to work pretty well > +1 With this, Git is perfectly usable on Windows now, there is no reason for not using it on this platform. From aslak.hellesoy at gmail.com Wed Nov 21 15:17:22 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 21 Nov 2007 21:17:22 +0100 Subject: [rspec-users] 'it' duplicate example: BUG In-Reply-To: References: <95A4BD3A-C34F-497A-976F-BD52CB26F415@railsnewbie.com> Message-ID: <8d961d900711211217k4e4e77a6tb524b417e751527e@mail.gmail.com> On 11/21/07, Chad Humphries wrote: > One of the recent trunk changesets modified the default behaviour to > fail fast if duplicate examples are detected within a single behaviour/ > example group. This is basically letting you know you have to "it" > blocks in the behaviour with the same description. > This is correct. It's not a bug - it's by design and documented in CHANGES. The reason I put it in has an interesting explanation. Over the past few days our coverage dropped from 100% to 99.9% and we couldn't understand why. RCov reported that some code wasn't being covered, but I *knew* there were examples covering it. Something was fishy. Then I remembered that Brian a few days ago did a change to the internals - every it block now creates a method with the same name as the description, and later calls that method to run the example. Nothing wrong with that, but it had some sideeffects we didn't think about: If there were duplicates, the last one would simply overwrite (monkey patch!) the previous one with the same name. And as a result never get run. Since I'm a fail fast kind of guy I made RSpec do that. And then I had to go and fix a dozen or so duplicates in our own code. Damn CMD-C/CMD-V keys. I realise the error message you're getting now isn't exactly easy to grok, but as always - we're glad to take patches to make it speak nicer to you. Cheers, Aslak > Note: You may have this issue rise up if you have one in a shared > behaviour and accidental duplication in the file (that was my case > when I updated this morning). > > - Chad > > On Nov 21, 2007, at 1:12 PM, Scott Taylor wrote: > > > I svn up'ed this morning, to get the following message with rake spec: > > > > /Users/smt/src/web/urbis/trunk/vendor/plugins/rspec/lib/spec/example/ > > example_group_methods.rb:96:in `it': Duplicate example: 'should > > contain the total number of messages' (RuntimeError) > > > > Anyone have any ideas why this might be going on? My specs were all > > passing last night. > > > > Let me know if I should put this in the tracker. > > > > Scott > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From luislavena at gmail.com Wed Nov 21 15:22:15 2007 From: luislavena at gmail.com (Luis Lavena) Date: Wed, 21 Nov 2007 17:22:15 -0300 Subject: [rspec-users] [ANN] Lighthouse and Engine Yard sponsorships In-Reply-To: <6b6419750711211205w4ff4b087p75cfec0a29545a98@mail.gmail.com> References: <57c63afe0711181310i7d6c08e2ib6f826221b837af8@mail.gmail.com> <2fff50390711181517l418f6387k3ca560602df370f6@mail.gmail.com> <835d522e0711181528u74f86cf1h77c5cf282e9b165b@mail.gmail.com> <683a886f0711181657v3225df8ar2972be1c78f2a9ae@mail.gmail.com> <71166b3b0711181712o39010985w148445da88953e9f@mail.gmail.com> <683a886f0711182021jabb3922s21f17398bd4e4426@mail.gmail.com> <71166b3b0711190755xe810625x2b9ab724c08e7ccb@mail.gmail.com> <683a886f0711191357o1260f95ew40e24c666f31914c@mail.gmail.com> <6b6419750711211205w4ff4b087p75cfec0a29545a98@mail.gmail.com> Message-ID: <71166b3b0711211222v73a301ocb8c341881b523f5@mail.gmail.com> On Nov 21, 2007 5:05 PM, Patrick Aljord wrote: > > There is a msys branch of git that is extremely easy to install in > > windows from this url: http://code.google.com/p/msysgit/ I tried it > > and it seems to work pretty well > > > > +1 > > With this, Git is perfectly usable on Windows now, there is no reason > for not using it on this platform. msys means *nix eol (end of line) styles, which sometimes don't work quite as expected under ruby-windows. I commented about this previously. Git don't over the eol-style property like svn do (svn:eol-style). The eol style was discussed on Git list way back, and they said the SCM shouldn't care about it :-P (I agree). The thing is like I said, with languages like Python or Ruby, sometimes eol does harm and make things crash. Anyway, as long there is a up-to-date repository "cross-platform accessible" I'll be happy. -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From smingins at elctech.com Wed Nov 21 15:31:25 2007 From: smingins at elctech.com (Shane Mingins) Date: Thu, 22 Nov 2007 09:31:25 +1300 Subject: [rspec-users] When you sometimes wonder how to test this?? Message-ID: <8DA804A4-E010-4A74-BD07-11967E2FDBA0@elctech.com> Hi Just something that I have been finding very helpful sometimes when I am stuck with "how could I test this?" moments is looking at the Rails test suite. At the moment I am working on testing our custom error_messages_for methods and I have found looking at how the Rails tests in active_record_helper work helpful :-) So just thought I'd share that. Have other's done the same? Cheers Shane Shane Mingins ELC Technologies (TM) 1921 State Street Santa Barbara, CA 93101 Phone: +64 4 568 6684 Mobile: +64 21 435 586 Email: smingins at elctech.com AIM: ShaneMingins Skype: shane.mingins (866) 863-7365 Tel - Santa Barbara Office (866) 893-1902 Fax - Santa Barbara Office +44 020 7504 1346 Tel - London Office +44 020 7504 1347 Fax - London Office http://www.elctech.com -------------------------------------------------------------------- Privacy and Confidentiality Notice: The information contained in this electronic mail message is intended for the named recipient(s) only. It may contain privileged and confidential information. If you are not an intended recipient, you must not copy, forward, distribute or take any action in reliance on it. If you have received this electronic mail message in error, please notify the sender immediately. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071122/28f38707/attachment-0001.html From lists at ruby-forum.com Wed Nov 21 15:33:06 2007 From: lists at ruby-forum.com (Chris Olsen) Date: Wed, 21 Nov 2007 21:33:06 +0100 Subject: [rspec-users] How thorough do you test? In-Reply-To: <47447B25.40105@benmabey.com> References: <9f0720265988617b020f52266300c330@ruby-forum.com> <47447B25.40105@benmabey.com> Message-ID: Thanks for the info. @Ben I like the top down approach that you mentioned. It definitely makes more sense to why I would test the views and how it will better define the model parameters. @Scott I think that I am currently on the same page as you. Right now I don't use a mock model in my create tests seeing as I have a perfectly good model with all the properties that I need to test. My tests are not at the numbers that it takes as long as yours take to run, but I can see how that would be an issue at a later time. @Pat When you said that, testing helps you by defining how our code will be used, seems to be close with Ben's mention of Kinderman's post which has already started me looking at things from a different angle, which is a good thing. When you start testing from the view to model, do you still use the scaffolded tests. I am not sure if it is just me, but when I have all these tests auto-created I find it somewhat distracting. I can see where writing them from scratch would eliminate that and allow me to guide the tests instead of having the auto-generated tests guide me. What do you guys think about that? Thanks again for all the advice. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed Nov 21 15:41:04 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 21 Nov 2007 14:41:04 -0600 Subject: [rspec-users] How thorough do you test? In-Reply-To: References: <9f0720265988617b020f52266300c330@ruby-forum.com> <47447B25.40105@benmabey.com> Message-ID: <57c63afe0711211241i3f50be0an4d715869aa03b910@mail.gmail.com> On Nov 21, 2007 2:33 PM, Chris Olsen wrote: > When you start testing from the view to model, do you still use the > scaffolded tests. I am not sure if it is just me, but when I have all > these tests auto-created I find it somewhat distracting. I can see > where writing them from scratch would eliminate that and allow me to > guide the tests instead of having the auto-generated tests guide me. > What do you guys think about that? Nobody says you have to use the auto-generated stuff, but if you are auto-generating code, you're asking for a world of hurt if you don't also use the autogenerated tests that come along with it. From pergesu at gmail.com Wed Nov 21 15:42:50 2007 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 21 Nov 2007 12:42:50 -0800 Subject: [rspec-users] How thorough do you test? In-Reply-To: References: <9f0720265988617b020f52266300c330@ruby-forum.com> <47447B25.40105@benmabey.com> Message-ID: <810a540e0711211242v10401060mf65548342957964e@mail.gmail.com> On Nov 21, 2007 12:33 PM, Chris Olsen wrote: > When you said that, testing helps you by defining how our code will be > used, seems to be close with Ben's mention of Kinderman's post which has > already started me looking at things from a different angle, which is a > good thing. Exactly. My main problem with a bottom-up approach is that you're basically speculating how code will be used. I've seen people argue that as long as you have good design skills it really isn't an issue. However, I much prefer to let my actual usage drive the design, and then use my design skills to shape it even further. Simply put, you have more information, allowing you to make better decisions. > When you start testing from the view to model, do you still use the > scaffolded tests. I am not sure if it is just me, but when I have all > these tests auto-created I find it somewhat distracting. I can see > where writing them from scratch would eliminate that and allow me to > guide the tests instead of having the auto-generated tests guide me. > What do you guys think about that? I don't use the scaffolded tests at all. I'm sure a part of it is Not-Invented-Here syndrome. Ruby is so lightweight and expressive that I think it's acceptable to write that stuff from scratch rather than use scaffolding. More importantly though, I'm addicted to building up behavior in tiny steps. Pat From nathan.sutton at gmail.com Wed Nov 21 15:43:40 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Wed, 21 Nov 2007 14:43:40 -0600 Subject: [rspec-users] When you sometimes wonder how to test this?? In-Reply-To: <8DA804A4-E010-4A74-BD07-11967E2FDBA0@elctech.com> References: <8DA804A4-E010-4A74-BD07-11967E2FDBA0@elctech.com> Message-ID: <140F6034-D08E-4D8F-96A5-85CFCE5AE249@gmail.com> One good idea is to add all your custom error messages to rails' default hash so you can change the wording of it whenever you want and the key can remain the same. That way if you need to change it you don't need to dive into your specs but can just change it in an initializer or environment. Nathan Sutton fowlduck at gmail.com rspec edge revision 2910 rspec_on_rails edge revision 2909 rails edge revision 8175 On Nov 21, 2007, at 2:31 PM, Shane Mingins wrote: > Hi > > Just something that I have been finding very helpful sometimes when > I am stuck with "how could I test this?" moments is looking at the > Rails test suite. > > At the moment I am working on testing our custom error_messages_for > methods and I have found looking at how the Rails tests in > active_record_helper work helpful :-) > > So just thought I'd share that. Have other's done the same? > > Cheers > Shane > > Shane Mingins > ELC Technologies (TM) > 1921 State Street > Santa Barbara, CA 93101 > > > Phone: +64 4 568 6684 > Mobile: +64 21 435 586 > Email: smingins at elctech.com > AIM: ShaneMingins > Skype: shane.mingins > > (866) 863-7365 Tel - Santa Barbara Office > (866) 893-1902 Fax - Santa Barbara Office > > +44 020 7504 1346 Tel - London Office > +44 020 7504 1347 Fax - London Office > > http://www.elctech.com > > -------------------------------------------------------------------- > Privacy and Confidentiality Notice: > The information contained in this electronic mail message is > intended for the named recipient(s) only. It may contain privileged > and confidential information. If you are not an intended recipient, > you > must not copy, forward, distribute or take any action in reliance on > it. If you have received this electronic mail message in error, > please notify the sender immediately. > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071121/7dec1a62/attachment.html From dchelimsky at gmail.com Wed Nov 21 15:50:52 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 21 Nov 2007 14:50:52 -0600 Subject: [rspec-users] When you sometimes wonder how to test this?? In-Reply-To: <140F6034-D08E-4D8F-96A5-85CFCE5AE249@gmail.com> References: <8DA804A4-E010-4A74-BD07-11967E2FDBA0@elctech.com> <140F6034-D08E-4D8F-96A5-85CFCE5AE249@gmail.com> Message-ID: <57c63afe0711211250t703f589ew71195b8421d720cd@mail.gmail.com> On Nov 21, 2007 2:43 PM, Nathan Sutton wrote: > One good idea is to add all your custom error messages to rails' default > hash so you can change the wording of it whenever you want and the key can > remain the same. That way if you need to change it you don't need to dive > into your specs but can just change it in an initializer or environment. That's how java frameworks like struts and spring work - you have a Resource Bundle, which is a fancy name for a hash stored in a file :) Also helps w/ i18n because you can just swap out files but use the same keys. > > > > > Nathan Sutton > fowlduck at gmail.com > rspec edge revision 2910 > rspec_on_rails edge revision 2909 > rails edge revision 8175 > > > > > > On Nov 21, 2007, at 2:31 PM, Shane Mingins wrote: > > > Hi > > Just something that I have been finding very helpful sometimes when I am > stuck with "how could I test this?" moments is looking at the Rails test > suite. > > At the moment I am working on testing our custom error_messages_for methods > and I have found looking at how the Rails tests in active_record_helper work > helpful :-) > > So just thought I'd share that. Have other's done the same? > > Cheers > Shane > > > Shane Mingins > ELC Technologies (TM) > 1921 State Street > Santa Barbara, CA 93101 > > > Phone: +64 4 568 6684 > Mobile: +64 21 435 586 > Email: smingins at elctech.com > AIM: ShaneMingins > Skype: shane.mingins > > (866) 863-7365 Tel - Santa Barbara Office > (866) 893-1902 Fax - Santa Barbara Office > > +44 020 7504 1346 Tel - London Office > +44 020 7504 1347 Fax - London Office > > http://www.elctech.com > > -------------------------------------------------------------------- > Privacy and Confidentiality Notice: > The information contained in this electronic mail message is intended for > the named recipient(s) only. It may contain privileged and confidential > information. If you are not an intended recipient, you > must not copy, forward, distribute or take any action in reliance on it. If > you have received this electronic mail message in error, please notify the > sender immediately. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Wed Nov 21 16:10:56 2007 From: lists at ruby-forum.com (Chris Olsen) Date: Wed, 21 Nov 2007 22:10:56 +0100 Subject: [rspec-users] route_for and nested resources Message-ID: <91d2eb6caae733507e424d06a168fe56@ruby-forum.com> I can't figure out how to make the updates to allow for the route_form method to return a url that matches the expected. Here is a sample route_for(:controller => :task, :action => :new).should == "/task/new" If a task has to be created for a user, how exactly do I do this. The following doesn't work: route_for(:controller => :task, :action => :new, :user_id => 1).should == "/users/1/task/new" (fails) route_for(:controller => :task, :action => :new, :user_id => 1).should == "/task/new?user_id=1" (passes) Or do you just use: new_user_task(1,1).should == "/users/1/task/new" I haven't been able to find that much documentation on the route_for method that lists any ways of creating the nested route url. Thanks. -- Posted via http://www.ruby-forum.com/. From has.sox at gmail.com Wed Nov 21 16:14:29 2007 From: has.sox at gmail.com (Daniel N) Date: Thu, 22 Nov 2007 08:14:29 +1100 Subject: [rspec-users] Getting Class in Shared Behaviours Message-ID: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> Hi, I want to be able to get at the described class in my shared behaviour. I'm sure an example will say it better than my words describe "my shared", :shared => true do it "should tell me what the class is its describing" do how_do_i_get_the_user_class_here end end describe User do it_should_behave_like "my shared" #... end So in my shared behaviour, how do I get access to the User class? Cheers Daniel -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071122/3036e7c6/attachment-0001.html From nathan.sutton at gmail.com Wed Nov 21 16:15:23 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Wed, 21 Nov 2007 15:15:23 -0600 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> Message-ID: <3C2663D4-B1CC-493D-822B-61A0FB9A815D@gmail.com> Did you try self.class ?? Nathan Sutton fowlduck at gmail.com rspec edge revision 2910 rspec_on_rails edge revision 2909 rails edge revision 8175 On Nov 21, 2007, at 3:14 PM, Daniel N wrote: > Hi, > > I want to be able to get at the described class in my shared > behaviour. I'm sure an example will say it better than my words > > describe "my shared", :shared => true do > > it "should tell me what the class is its describing" do > how_do_i_get_the_user_class_here > end > > end > > describe User do > it_should_behave_like "my shared" > > #... > end > > So in my shared behaviour, how do I get access to the User class? > > Cheers > Daniel > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From has.sox at gmail.com Wed Nov 21 16:18:49 2007 From: has.sox at gmail.com (Daniel N) Date: Thu, 22 Nov 2007 08:18:49 +1100 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: <3C2663D4-B1CC-493D-822B-61A0FB9A815D@gmail.com> References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> <3C2663D4-B1CC-493D-822B-61A0FB9A815D@gmail.com> Message-ID: <2fff50390711211318j19d550e7l31befbc0664c7dd7@mail.gmail.com> yep should == User expected: User, got: # (using ==) On Nov 22, 2007 8:15 AM, Nathan Sutton wrote: > Did you try self.class > > ?? > Nathan Sutton > fowlduck at gmail.com > rspec edge revision 2910 > rspec_on_rails edge revision 2909 > rails edge revision 8175 > > > > On Nov 21, 2007, at 3:14 PM, Daniel N wrote: > > > Hi, > > > > I want to be able to get at the described class in my shared > > behaviour. I'm sure an example will say it better than my words > > > > describe "my shared", :shared => true do > > > > it "should tell me what the class is its describing" do > > how_do_i_get_the_user_class_here > > end > > > > end > > > > describe User do > > it_should_behave_like "my shared" > > > > #... > > end > > > > So in my shared behaviour, how do I get access to the User class? > > > > Cheers > > Daniel > > _______________________________________________ > > 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: http://rubyforge.org/pipermail/rspec-users/attachments/20071122/fbf63a2a/attachment.html From dchelimsky at gmail.com Wed Nov 21 16:22:39 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 21 Nov 2007 15:22:39 -0600 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> Message-ID: <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> On Nov 21, 2007 3:14 PM, Daniel N wrote: > Hi, > > I want to be able to get at the described class in my shared behaviour. I'm > sure an example will say it better than my words > > describe "my shared", :shared => true do > > it "should tell me what the class is its describing" do > how_do_i_get_the_user_class_here > end > > end > > describe User do > it_should_behave_like "my shared" > > #... > end > > So in my shared behaviour, how do I get access to the User class? There's no way to do this implicitly. i.e. rspec does not expose the class. You'd have to have a method like described_class or something: describe "my shared", :shared => true do it "should tell me what the class is its describing" do described_class.should do_something_I_care_about end end describe User do def described_class User end ... end > > Cheers > Daniel > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From has.sox at gmail.com Wed Nov 21 16:26:05 2007 From: has.sox at gmail.com (Daniel N) Date: Thu, 22 Nov 2007 08:26:05 +1100 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> Message-ID: <2fff50390711211326l30e0fffcybd291296e2931e8b@mail.gmail.com> On Nov 22, 2007 8:22 AM, David Chelimsky wrote: > On Nov 21, 2007 3:14 PM, Daniel N wrote: > > Hi, > > > > I want to be able to get at the described class in my shared behaviour. > I'm > > sure an example will say it better than my words > > > > describe "my shared", :shared => true do > > > > it "should tell me what the class is its describing" do > > how_do_i_get_the_user_class_here > > end > > > > end > > > > describe User do > > it_should_behave_like "my shared" > > > > #... > > end > > > > So in my shared behaviour, how do I get access to the User class? > > There's no way to do this implicitly. i.e. rspec does not expose the > class. You'd have to have a method like described_class or something: > > describe "my shared", :shared => true do > > it "should tell me what the class is its describing" do > described_class.should do_something_I_care_about > end > > end > > describe User do > def described_class > User > end > ... > end > > > > K thanx David > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071122/df24bb24/attachment.html From nathan.sutton at gmail.com Wed Nov 21 16:27:56 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Wed, 21 Nov 2007 15:27:56 -0600 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> Message-ID: David to the rescue! :) Nathan Sutton fowlduck at gmail.com rspec edge revision 2910 rspec_on_rails edge revision 2909 rails edge revision 8175 On Nov 21, 2007, at 3:22 PM, David Chelimsky wrote: > On Nov 21, 2007 3:14 PM, Daniel N wrote: >> Hi, >> >> I want to be able to get at the described class in my shared >> behaviour. I'm >> sure an example will say it better than my words >> >> describe "my shared", :shared => true do >> >> it "should tell me what the class is its describing" do >> how_do_i_get_the_user_class_here >> end >> >> end >> >> describe User do >> it_should_behave_like "my shared" >> >> #... >> end >> >> So in my shared behaviour, how do I get access to the User class? > > There's no way to do this implicitly. i.e. rspec does not expose the > class. You'd have to have a method like described_class or something: > > describe "my shared", :shared => true do > > it "should tell me what the class is its describing" do > described_class.should do_something_I_care_about > end > > end > > describe User do > def described_class > User > end > ... > end > > > > >> >> Cheers >> Daniel >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Wed Nov 21 16:31:58 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 21 Nov 2007 22:31:58 +0100 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> Message-ID: <8d961d900711211331r43604bcdj43165b88653da672@mail.gmail.com> On Nov 21, 2007 10:22 PM, David Chelimsky wrote: > > On Nov 21, 2007 3:14 PM, Daniel N wrote: > > Hi, > > > > I want to be able to get at the described class in my shared behaviour. I'm > > sure an example will say it better than my words > > > > describe "my shared", :shared => true do > > > > it "should tell me what the class is its describing" do > > how_do_i_get_the_user_class_here > > end > > > > end > > > > describe User do > > it_should_behave_like "my shared" > > > > #... > > end > > > > So in my shared behaviour, how do I get access to the User class? > > There's no way to do this implicitly. i.e. rspec does not expose the > class. You'd have to have a method like described_class or something: > > describe "my shared", :shared => true do > > it "should tell me what the class is its describing" do > described_class.should do_something_I_care_about > end > > end > > describe User do > def described_class > User > end > ... > end > > However, if you do this: describe MyModule do # MyModule has a #hello method it "should be polite" do hello.should == 'How do you do' end end Modules are automatically mixed into your examples Aslak > > > > > > > Cheers > > Daniel > > > > _______________________________________________ > > 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 has.sox at gmail.com Wed Nov 21 16:37:47 2007 From: has.sox at gmail.com (Daniel N) Date: Thu, 22 Nov 2007 08:37:47 +1100 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: <8d961d900711211331r43604bcdj43165b88653da672@mail.gmail.com> References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> <8d961d900711211331r43604bcdj43165b88653da672@mail.gmail.com> Message-ID: <2fff50390711211337g30b2d28cqa35523ecbd4ebab@mail.gmail.com> On Nov 22, 2007 8:31 AM, aslak hellesoy wrote: > On Nov 21, 2007 10:22 PM, David Chelimsky wrote: > > > > On Nov 21, 2007 3:14 PM, Daniel N wrote: > > > Hi, > > > > > > I want to be able to get at the described class in my shared > behaviour. I'm > > > sure an example will say it better than my words > > > > > > describe "my shared", :shared => true do > > > > > > it "should tell me what the class is its describing" do > > > how_do_i_get_the_user_class_here > > > end > > > > > > end > > > > > > describe User do > > > it_should_behave_like "my shared" > > > > > > #... > > > end > > > > > > So in my shared behaviour, how do I get access to the User class? > > > > There's no way to do this implicitly. i.e. rspec does not expose the > > class. You'd have to have a method like described_class or something: > > > > describe "my shared", :shared => true do > > > > it "should tell me what the class is its describing" do > > described_class.should do_something_I_care_about > > end > > > > end > > > > describe User do > > def described_class > > User > > end > > ... > > end > > > > > > However, if you do this: > > describe MyModule do # MyModule has a #hello method > it "should be polite" do > hello.should == 'How do you do' > end > end > > Modules are automatically mixed into your examples > > Aslak > > > > > > > > > > > > Cheers > > > Daniel > > > > Aslak Thanx. I was aware of that behaviour, but this module is being mixed into AR classes and relies on there being methods available to AR models. I really want to implemnet these specs as a shared behaviour on each implementing model. That way I can check to make sure that the model has the correct attributes for the mixin to function properly etc. Thanx again. Daniel -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071122/b2b6fe11/attachment.html From nathan.sutton at gmail.com Wed Nov 21 16:39:40 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Wed, 21 Nov 2007 15:39:40 -0600 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: <8d961d900711211331r43604bcdj43165b88653da672@mail.gmail.com> References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> <8d961d900711211331r43604bcdj43165b88653da672@mail.gmail.com> Message-ID: <87F0B4D1-3C75-4CC3-8CB3-4CB1B3FCE985@gmail.com> Some of this clears up my issues around sharing behaviors that you can pass parameters to. I was doing a hackish solution before by including a module then calling a method it provides, but now I can have shared behaviors and just have them call specific methods which then become a convention to define. It still feels hackish, but not nearly as much. Is there another way? Nathan Sutton fowlduck at gmail.com rspec edge revision 2910 rspec_on_rails edge revision 2909 rails edge revision 8175 On Nov 21, 2007, at 3:31 PM, aslak hellesoy wrote: > On Nov 21, 2007 10:22 PM, David Chelimsky > wrote: >> >> On Nov 21, 2007 3:14 PM, Daniel N wrote: >>> Hi, >>> >>> I want to be able to get at the described class in my shared >>> behaviour. I'm >>> sure an example will say it better than my words >>> >>> describe "my shared", :shared => true do >>> >>> it "should tell me what the class is its describing" do >>> how_do_i_get_the_user_class_here >>> end >>> >>> end >>> >>> describe User do >>> it_should_behave_like "my shared" >>> >>> #... >>> end >>> >>> So in my shared behaviour, how do I get access to the User class? >> >> There's no way to do this implicitly. i.e. rspec does not expose the >> class. You'd have to have a method like described_class or something: >> >> describe "my shared", :shared => true do >> >> it "should tell me what the class is its describing" do >> described_class.should do_something_I_care_about >> end >> >> end >> >> describe User do >> def described_class >> User >> end >> ... >> end >> >> > > However, if you do this: > > describe MyModule do # MyModule has a #hello method > it "should be polite" do > hello.should == 'How do you do' > end > end > > Modules are automatically mixed into your examples > > Aslak >> >> >> >>> >>> Cheers >>> Daniel >>> >>> _______________________________________________ >>> 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 mailing_lists at railsnewbie.com Wed Nov 21 16:42:20 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 21 Nov 2007 16:42:20 -0500 Subject: [rspec-users] 'it' duplicate example: BUG In-Reply-To: <8d961d900711211217k4e4e77a6tb524b417e751527e@mail.gmail.com> References: <95A4BD3A-C34F-497A-976F-BD52CB26F415@railsnewbie.com> <8d961d900711211217k4e4e77a6tb524b417e751527e@mail.gmail.com> Message-ID: <60ABAE69-1A7A-4B41-AEF5-5F730270CE58@railsnewbie.com> On Nov 21, 2007, at 3:17 PM, aslak hellesoy wrote: > On 11/21/07, Chad Humphries wrote: >> One of the recent trunk changesets modified the default behaviour to >> fail fast if duplicate examples are detected within a single >> behaviour/ >> example group. This is basically letting you know you have to "it" >> blocks in the behaviour with the same description. >> > > This is correct. It's not a bug - it's by design and documented in > CHANGES. > > The reason I put it in has an interesting explanation. Over the past > few days our coverage dropped from 100% to 99.9% and we couldn't > understand why. RCov reported that some code wasn't being covered, but > I *knew* there were examples covering it. > > Something was fishy. > > Then I remembered that Brian a few days ago did a change to the > internals - every it block now creates a method with the same name as > the description, and later calls that method to run the example. > Nothing wrong with that, but it had some sideeffects we didn't think > about: If there were duplicates, the last one would simply overwrite > (monkey patch!) the previous one with the same name. And as a result > never get run. > > Since I'm a fail fast kind of guy I made RSpec do that. Yep, me too. > > And then I had to go and fix a dozen or so duplicates in our own code. > Damn CMD-C/CMD-V keys. > > I realise the error message you're getting now isn't exactly easy to > grok, but as always - we're glad to take patches to make it speak > nicer to you. Actually the error was rather clear - I just wasn't expecting it to happen over night (literally). But then again, that's running on trunk for you! (I'll make sure to check the CHANGELOG nextime). On the same topic - has the following been deprecated? it do .. end ? Wouldn't double example names creed up pretty quickly with this sort of syntax? This actually helped me clear out a few duplicate examples that I had going on. Thanks for the info, Scott From dchelimsky at gmail.com Wed Nov 21 16:46:52 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 21 Nov 2007 15:46:52 -0600 Subject: [rspec-users] 'it' duplicate example: BUG In-Reply-To: <60ABAE69-1A7A-4B41-AEF5-5F730270CE58@railsnewbie.com> References: <95A4BD3A-C34F-497A-976F-BD52CB26F415@railsnewbie.com> <8d961d900711211217k4e4e77a6tb524b417e751527e@mail.gmail.com> <60ABAE69-1A7A-4B41-AEF5-5F730270CE58@railsnewbie.com> Message-ID: <57c63afe0711211346t324f439br1b70435a16f5c72e@mail.gmail.com> On Nov 21, 2007 3:42 PM, Scott Taylor wrote: > > On Nov 21, 2007, at 3:17 PM, aslak hellesoy wrote: > > > On 11/21/07, Chad Humphries wrote: > >> One of the recent trunk changesets modified the default behaviour to > >> fail fast if duplicate examples are detected within a single > >> behaviour/ > >> example group. This is basically letting you know you have to "it" > >> blocks in the behaviour with the same description. > >> > > > > This is correct. It's not a bug - it's by design and documented in > > CHANGES. > > > > The reason I put it in has an interesting explanation. Over the past > > few days our coverage dropped from 100% to 99.9% and we couldn't > > understand why. RCov reported that some code wasn't being covered, but > > I *knew* there were examples covering it. > > > > Something was fishy. > > > > Then I remembered that Brian a few days ago did a change to the > > internals - every it block now creates a method with the same name as > > the description, and later calls that method to run the example. > > Nothing wrong with that, but it had some sideeffects we didn't think > > about: If there were duplicates, the last one would simply overwrite > > (monkey patch!) the previous one with the same name. And as a result > > never get run. > > > > Since I'm a fail fast kind of guy I made RSpec do that. > > Yep, me too. > > > > > And then I had to go and fix a dozen or so duplicates in our own code. > > Damn CMD-C/CMD-V keys. > > > > I realise the error message you're getting now isn't exactly easy to > > grok, but as always - we're glad to take patches to make it speak > > nicer to you. > > Actually the error was rather clear - I just wasn't expecting it to > happen over night (literally). But then again, that's running on > trunk for you! (I'll make sure to check the CHANGELOG nextime). > > On the same topic - has the following been deprecated? > > it do > .. > end No it hasn't, and that presents an interesting dilemma. Need to give that some thought. > > ? Wouldn't double example names creed up pretty quickly with this > sort of syntax? We'd have to keep track and rename them. Not pretty. > > > > This actually helped me clear out a few duplicate examples that I had > going on. > > Thanks for the info, > > > Scott > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mvyver at gmail.com Wed Nov 21 16:53:05 2007 From: mvyver at gmail.com (Mark Van De Vyver) Date: Thu, 22 Nov 2007 08:53:05 +1100 Subject: [rspec-users] describe scope In-Reply-To: <57c63afe0711210618w8066c81s77a71372bff22f1@mail.gmail.com> References: <389c43e40711202307s46207eafwf0be267b6ad5df74@mail.gmail.com> <57c63afe0711210618w8066c81s77a71372bff22f1@mail.gmail.com> Message-ID: <389c43e40711211353n3fe73e4cr4e97d2840b23c094@mail.gmail.com> Hi, Thanks for the prompt responses... On Nov 22, 2007 1:18 AM, David Chelimsky wrote: > On Nov 21, 2007 1:07 AM, Mark Van De Vyver wrote: > > Hi, > > Googling 'RSpec describe scope' didn't yield much, so apologies if > > this question has been dealt with. > > > > It seem well known that a ruby class is 'visible' between describes, > > and if this is a problem then you should use some counter as prefix or > > suffix: > > 'class Item_001; ... end' > > > > Is there any work underway, or sheduled release where classes will > > exist only in the scope they are defined? > > This has never been brought up before. Feel free to submit a feature > request at http://rspec.lighthouseapp.com/. > > > Writing spec's for Og is where this becomes an issue because Og will > > grab _all_ manageble objects it can 'see'... all sorts of PITA can > > arise. > > I found this: > > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/6924 I thought to make a feature request with a spec, any comments on why the following fails # rspec example require 'spec' module Example describe "RSpec " do before(:each) do class ::Item attr_accessor :name end end it "should not raise error on defined?" do lambda{defined?("Item")}.should_not raise_error end it "should be defined after being removed" do defined?("Item").should == "constant" end after(:each) do Kernel.remove_const("Item") end end end # rspec example Appreciate any comments. Mark > So you could, in theory, monkey patch ExampleGroupMethods (in trunk > 2937 - these names are changing a bit, so keep an eye out) to remove > the defined constant > > > > > Thanks for all the great work, T/BDD definitely is a brilliant way to > > work, and RSpec makes it painless, esp for us amatuers :) > > That's what we want to hear! Thanks. > > Cheers, > David > > > > > > Mark > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > From mailing_lists at railsnewbie.com Wed Nov 21 16:53:27 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 21 Nov 2007 16:53:27 -0500 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> Message-ID: <0A6DC38C-3016-48B9-987B-86542B941E4A@railsnewbie.com> On Nov 21, 2007, at 4:22 PM, David Chelimsky wrote: > On Nov 21, 2007 3:14 PM, Daniel N wrote: >> Hi, >> >> I want to be able to get at the described class in my shared >> behaviour. I'm >> sure an example will say it better than my words >> >> describe "my shared", :shared => true do >> >> it "should tell me what the class is its describing" do >> how_do_i_get_the_user_class_here >> end >> >> end >> >> describe User do >> it_should_behave_like "my shared" >> >> #... >> end >> >> So in my shared behaviour, how do I get access to the User class? > > There's no way to do this implicitly. i.e. rspec does not expose the > class. You'd have to have a method like described_class or something: > > describe "my shared", :shared => true do > > it "should tell me what the class is its describing" do > described_class.should do_something_I_care_about > end > > end > > describe User do > def described_class > User > end > ... > end Or you could just set up instance variables in your before :each block: describe "an object which has to_s", :shared => true do it "should work!" do :foo.send(@method).should == "foo" end end describe Symbol do before :each do @method = :to_s end it_should_behave_like "an object which has to_s" end On another note, I've been poking around Rubinius' source, which uses a scaled down version of rspec, and they already have shared examples with parameters: shared :symbol_id2name do |cmd| describe "Symbol\##{cmd}" do it "returns the string corresponding to self" do :rubinius.send(cmd).should == "rubinius" :squash.send(cmd).should == "squash" :[].send(cmd).should == "[]" :@ruby.send(cmd).should == "@ruby" :@@ruby.send(cmd).should == "@@ruby" end end end require File.dirname(__FILE__) + '/../../spec_helper' describe "Symbol#to_s" do it_behaves_like(:symbol_id2name, :to_s) end This doesn't seem that hard to implement. Is there some reason a patch has been created yet? Scott From mvyver at gmail.com Wed Nov 21 16:57:43 2007 From: mvyver at gmail.com (Mark Van De Vyver) Date: Thu, 22 Nov 2007 08:57:43 +1100 Subject: [rspec-users] describe scope In-Reply-To: <389c43e40711211353n3fe73e4cr4e97d2840b23c094@mail.gmail.com> References: <389c43e40711202307s46207eafwf0be267b6ad5df74@mail.gmail.com> <57c63afe0711210618w8066c81s77a71372bff22f1@mail.gmail.com> <389c43e40711211353n3fe73e4cr4e97d2840b23c094@mail.gmail.com> Message-ID: <389c43e40711211357i4873fadaubc5c6244cdcec0a0@mail.gmail.com> On Nov 22, 2007 8:53 AM, Mark Van De Vyver wrote: > Hi, > Thanks for the prompt responses... > > On Nov 22, 2007 1:18 AM, David Chelimsky wrote: > > On Nov 21, 2007 1:07 AM, Mark Van De Vyver wrote: > > > Hi, > > > Googling 'RSpec describe scope' didn't yield much, so apologies if > > > this question has been dealt with. > > > > > > It seem well known that a ruby class is 'visible' between describes, > > > and if this is a problem then you should use some counter as prefix or > > > suffix: > > > 'class Item_001; ... end' > > > > > > Is there any work underway, or sheduled release where classes will > > > exist only in the scope they are defined? > > > > This has never been brought up before. Feel free to submit a feature > > request at http://rspec.lighthouseapp.com/. > > > > > Writing spec's for Og is where this becomes an issue because Og will > > > grab _all_ manageble objects it can 'see'... all sorts of PITA can > > > arise. > > > > I found this: > > > > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/6924 > > I thought to make a feature request with a spec, any comments on why > the following fails > OK, even if you remove quotes to have defined?(Item) I get: # puzzled. Mark > # rspec example > require 'spec' > > module Example > describe "RSpec " do > before(:each) do > class ::Item > attr_accessor :name > end > end > > it "should not raise error on defined?" do > lambda{defined?("Item")}.should_not raise_error > end > it "should be defined after being removed" do > defined?("Item").should == "constant" > end > > after(:each) do > Kernel.remove_const("Item") > end > end > end # rspec example > > > Appreciate any comments. > Mark > > > > So you could, in theory, monkey patch ExampleGroupMethods (in trunk > > 2937 - these names are changing a bit, so keep an eye out) to remove > > the defined constant > > > > > > > > Thanks for all the great work, T/BDD definitely is a brilliant way to > > > work, and RSpec makes it painless, esp for us amatuers :) > > > > That's what we want to hear! Thanks. > > > > Cheers, > > David > > > > > > > > > > Mark > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > From aslak.hellesoy at gmail.com Wed Nov 21 17:01:35 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 21 Nov 2007 23:01:35 +0100 Subject: [rspec-users] describe scope In-Reply-To: <389c43e40711211353n3fe73e4cr4e97d2840b23c094@mail.gmail.com> References: <389c43e40711202307s46207eafwf0be267b6ad5df74@mail.gmail.com> <57c63afe0711210618w8066c81s77a71372bff22f1@mail.gmail.com> <389c43e40711211353n3fe73e4cr4e97d2840b23c094@mail.gmail.com> Message-ID: <8d961d900711211401w14bb0b6et84f5ce7066bcfc6e@mail.gmail.com> On 11/21/07, Mark Van De Vyver wrote: > Hi, > Thanks for the prompt responses... > > On Nov 22, 2007 1:18 AM, David Chelimsky wrote: > > On Nov 21, 2007 1:07 AM, Mark Van De Vyver wrote: > > > Hi, > > > Googling 'RSpec describe scope' didn't yield much, so apologies if > > > this question has been dealt with. > > > > > > It seem well known that a ruby class is 'visible' between describes, > > > and if this is a problem then you should use some counter as prefix or > > > suffix: > > > 'class Item_001; ... end' > > > > > > Is there any work underway, or sheduled release where classes will > > > exist only in the scope they are defined? > > > > This has never been brought up before. Feel free to submit a feature > > request at http://rspec.lighthouseapp.com/. > > > > > Writing spec's for Og is where this becomes an issue because Og will > > > grab _all_ manageble objects it can 'see'... all sorts of PITA can > > > arise. > > > > I found this: > > > > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/6924 > > I thought to make a feature request with a spec, any comments on why > the following fails > No idea, because you forgot to attach any output from RSpec ;-) > # rspec example > require 'spec' > > module Example > describe "RSpec " do > before(:each) do > class ::Item > attr_accessor :name > end > end > > it "should not raise error on defined?" do > lambda{defined?("Item")}.should_not raise_error > end > it "should be defined after being removed" do > defined?("Item").should == "constant" > end > > after(:each) do > Kernel.remove_const("Item") > end > end > end # rspec example > > > Appreciate any comments. > Mark > > > So you could, in theory, monkey patch ExampleGroupMethods (in trunk > > 2937 - these names are changing a bit, so keep an eye out) to remove > > the defined constant > > > > > > > > Thanks for all the great work, T/BDD definitely is a brilliant way to > > > work, and RSpec makes it painless, esp for us amatuers :) > > > > That's what we want to hear! Thanks. > > > > Cheers, > > David > > > > > > > > > > Mark > > > _______________________________________________ > > > 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 mvyver at gmail.com Wed Nov 21 17:08:05 2007 From: mvyver at gmail.com (Mark Van De Vyver) Date: Thu, 22 Nov 2007 09:08:05 +1100 Subject: [rspec-users] describe scope In-Reply-To: <8d961d900711211401w14bb0b6et84f5ce7066bcfc6e@mail.gmail.com> References: <389c43e40711202307s46207eafwf0be267b6ad5df74@mail.gmail.com> <57c63afe0711210618w8066c81s77a71372bff22f1@mail.gmail.com> <389c43e40711211353n3fe73e4cr4e97d2840b23c094@mail.gmail.com> <8d961d900711211401w14bb0b6et84f5ce7066bcfc6e@mail.gmail.com> Message-ID: <389c43e40711211408y68ecd21doa49bc5d2127d604a@mail.gmail.com> On Nov 22, 2007 9:01 AM, aslak hellesoy wrote: > On 11/21/07, Mark Van De Vyver wrote: > > Hi, > > Thanks for the prompt responses... > > > > On Nov 22, 2007 1:18 AM, David Chelimsky wrote: > > > On Nov 21, 2007 1:07 AM, Mark Van De Vyver wrote: > > > > Hi, > > > > Googling 'RSpec describe scope' didn't yield much, so apologies if > > > > this question has been dealt with. > > > > > > > > It seem well known that a ruby class is 'visible' between describes, > > > > and if this is a problem then you should use some counter as prefix or > > > > suffix: > > > > 'class Item_001; ... end' > > > > > > > > Is there any work underway, or sheduled release where classes will > > > > exist only in the scope they are defined? > > > > > > This has never been brought up before. Feel free to submit a feature > > > request at http://rspec.lighthouseapp.com/. > > > > > > > Writing spec's for Og is where this becomes an issue because Og will > > > > grab _all_ manageble objects it can 'see'... all sorts of PITA can > > > > arise. > > > > > > I found this: > > > > > > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/6924 > > > > I thought to make a feature request with a spec, any comments on why > > the following fails > > > > No idea, because you forgot to attach any output from RSpec ;-) > Apologies, the spec and output: require 'spec' module Example describe "RSpec " do before(:each) do class ::Item attr_accessor :name end end it "should not raise error on defined?" do lambda{ defined?(Item)}.should_not raise_error end it "should be defined as a constant" do defined?(Item).should == "constant" end after(:each) do remove_const("Item") end end end # spec # The output FF 1) NoMethodError in 'RSpec should not raise error on defined?' undefined method `remove_const' for [RSpec example]:# /usr/src/nitro-repo/og/test/rspec_example_spec.rb:19: 2) NoMethodError in 'RSpec should be defined as a constant' undefined method `remove_const' for [RSpec example]:# /usr/src/nitro-repo/og/test/rspec_example_spec.rb:19: Finished in 0.006203 seconds 2 examples, 2 failures > > # rspec example > > require 'spec' > > > > module Example > > describe "RSpec " do > > before(:each) do > > class ::Item > > attr_accessor :name > > end > > end > > > > it "should not raise error on defined?" do > > lambda{defined?("Item")}.should_not raise_error > > end > > it "should be defined after being removed" do > > defined?("Item").should == "constant" > > end > > > > after(:each) do > > Kernel.remove_const("Item") > > end > > end > > end # rspec example > > > > > > Appreciate any comments. > > Mark > > > > > So you could, in theory, monkey patch ExampleGroupMethods (in trunk > > > 2937 - these names are changing a bit, so keep an eye out) to remove > > > the defined constant > > > > > > > > > > > Thanks for all the great work, T/BDD definitely is a brilliant way to > > > > work, and RSpec makes it painless, esp for us amatuers :) > > > > > > That's what we want to hear! Thanks. > > > > > > Cheers, > > > David > > > > > > > > > > > > > > Mark > > > > _______________________________________________ > > > > 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 Nov 21 17:13:51 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 21 Nov 2007 16:13:51 -0600 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: <0A6DC38C-3016-48B9-987B-86542B941E4A@railsnewbie.com> References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> <0A6DC38C-3016-48B9-987B-86542B941E4A@railsnewbie.com> Message-ID: <57c63afe0711211413i330b1829m7bb063414179bfa6@mail.gmail.com> On Nov 21, 2007 3:53 PM, Scott Taylor wrote: > > On Nov 21, 2007, at 4:22 PM, David Chelimsky wrote: > > > > On Nov 21, 2007 3:14 PM, Daniel N wrote: > >> Hi, > >> > >> I want to be able to get at the described class in my shared > >> behaviour. I'm > >> sure an example will say it better than my words > >> > >> describe "my shared", :shared => true do > >> > >> it "should tell me what the class is its describing" do > >> how_do_i_get_the_user_class_here > >> end > >> > >> end > >> > >> describe User do > >> it_should_behave_like "my shared" > >> > >> #... > >> end > >> > >> So in my shared behaviour, how do I get access to the User class? > > > > There's no way to do this implicitly. i.e. rspec does not expose the > > class. You'd have to have a method like described_class or something: > > > > describe "my shared", :shared => true do > > > > it "should tell me what the class is its describing" do > > described_class.should do_something_I_care_about > > end > > > > end > > > > describe User do > > def described_class > > User > > end > > ... > > end > > Or you could just set up instance variables in your before :each block: > > describe "an object which has to_s", :shared => true do > it "should work!" do > :foo.send(@method).should == "foo" > end > end > > describe Symbol do > before :each do > @method = :to_s > end > > it_should_behave_like "an object which has to_s" > end > > > On another note, I've been poking around Rubinius' source, which uses > a scaled down version of rspec, and they already have shared examples > with parameters: > > shared :symbol_id2name do |cmd| > describe "Symbol\##{cmd}" do > it "returns the string corresponding to self" do > :rubinius.send(cmd).should == "rubinius" > :squash.send(cmd).should == "squash" > :[].send(cmd).should == "[]" > :@ruby.send(cmd).should == "@ruby" > :@@ruby.send(cmd).should == "@@ruby" > end > end > end > > require File.dirname(__FILE__) + '/../../spec_helper' > > describe "Symbol#to_s" do > it_behaves_like(:symbol_id2name, :to_s) > end > > > This doesn't seem that hard to implement. Is there some reason a > patch has been created yet? Yes. You haven't submitted it. > > Scott > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From nathan.sutton at gmail.com Wed Nov 21 17:16:54 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Wed, 21 Nov 2007 16:16:54 -0600 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: <57c63afe0711211413i330b1829m7bb063414179bfa6@mail.gmail.com> References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> <0A6DC38C-3016-48B9-987B-86542B941E4A@railsnewbie.com> <57c63afe0711211413i330b1829m7bb063414179bfa6@mail.gmail.com> Message-ID: Ooh, I totally want to do this, I'll work on it this week along with my other patch i have yet to submit this week, unless Scott is partial to doing it. Do you want it, Scott? Nathan Sutton fowlduck at gmail.com rspec edge revision 2910 rspec_on_rails edge revision 2909 rails edge revision 8175 On Nov 21, 2007, at 4:13 PM, David Chelimsky wrote: > On Nov 21, 2007 3:53 PM, Scott Taylor > wrote: >> >> On Nov 21, 2007, at 4:22 PM, David Chelimsky wrote: >> >> >>> On Nov 21, 2007 3:14 PM, Daniel N wrote: >>>> Hi, >>>> >>>> I want to be able to get at the described class in my shared >>>> behaviour. I'm >>>> sure an example will say it better than my words >>>> >>>> describe "my shared", :shared => true do >>>> >>>> it "should tell me what the class is its describing" do >>>> how_do_i_get_the_user_class_here >>>> end >>>> >>>> end >>>> >>>> describe User do >>>> it_should_behave_like "my shared" >>>> >>>> #... >>>> end >>>> >>>> So in my shared behaviour, how do I get access to the User class? >>> >>> There's no way to do this implicitly. i.e. rspec does not expose the >>> class. You'd have to have a method like described_class or >>> something: >>> >>> describe "my shared", :shared => true do >>> >>> it "should tell me what the class is its describing" do >>> described_class.should do_something_I_care_about >>> end >>> >>> end >>> >>> describe User do >>> def described_class >>> User >>> end >>> ... >>> end >> >> Or you could just set up instance variables in your before :each >> block: >> >> describe "an object which has to_s", :shared => true do >> it "should work!" do >> :foo.send(@method).should == "foo" >> end >> end >> >> describe Symbol do >> before :each do >> @method = :to_s >> end >> >> it_should_behave_like "an object which has to_s" >> end >> >> >> On another note, I've been poking around Rubinius' source, which uses >> a scaled down version of rspec, and they already have shared examples >> with parameters: >> >> shared :symbol_id2name do |cmd| >> describe "Symbol\##{cmd}" do >> it "returns the string corresponding to self" do >> :rubinius.send(cmd).should == "rubinius" >> :squash.send(cmd).should == "squash" >> :[].send(cmd).should == "[]" >> :@ruby.send(cmd).should == "@ruby" >> :@@ruby.send(cmd).should == "@@ruby" >> end >> end >> end >> >> require File.dirname(__FILE__) + '/../../spec_helper' >> >> describe "Symbol#to_s" do >> it_behaves_like(:symbol_id2name, :to_s) >> end >> >> >> This doesn't seem that hard to implement. Is there some reason a >> patch has been created yet? > > Yes. You haven't submitted it. > >> >> Scott >> >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Wed Nov 21 17:31:12 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 21 Nov 2007 16:31:12 -0600 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> <0A6DC38C-3016-48B9-987B-86542B941E4A@railsnewbie.com> <57c63afe0711211413i330b1829m7bb063414179bfa6@mail.gmail.com> Message-ID: <57c63afe0711211431w20645206n71f5474bf11864a9@mail.gmail.com> On Nov 21, 2007 4:16 PM, Nathan Sutton wrote: > Nathan Sutton > fowlduck at gmail.com > rspec edge revision 2910 > rspec_on_rails edge revision 2909 > rails edge revision 8175 Have you added this to your signature???? From mailing_lists at railsnewbie.com Wed Nov 21 17:31:29 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 21 Nov 2007 17:31:29 -0500 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> <0A6DC38C-3016-48B9-987B-86542B941E4A@railsnewbie.com> <57c63afe0711211413i330b1829m7bb063414179bfa6@mail.gmail.com> Message-ID: On Nov 21, 2007, at 5:16 PM, Nathan Sutton wrote: > Ooh, I totally want to do this, I'll work on it this week along with > my other patch i have yet to submit this week, unless Scott is partial > to doing it. Do you want it, Scott? Go for it. Let me know if you don't want it. What is the syntax your thinking of? Scott From nathan.sutton at gmail.com Wed Nov 21 17:32:36 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Wed, 21 Nov 2007 16:32:36 -0600 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: <57c63afe0711211431w20645206n71f5474bf11864a9@mail.gmail.com> References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> <0A6DC38C-3016-48B9-987B-86542B941E4A@railsnewbie.com> <57c63afe0711211413i330b1829m7bb063414179bfa6@mail.gmail.com> <57c63afe0711211431w20645206n71f5474bf11864a9@mail.gmail.com> Message-ID: Yeah, I'm currently doing it manually though, and this email is only for mailing lists. Nathan Sutton fowlduck at gmail.com rspec edge revision 2910 rspec_on_rails edge revision 2909 rails edge revision 8175 On Nov 21, 2007, at 4:31 PM, David Chelimsky wrote: > On Nov 21, 2007 4:16 PM, Nathan Sutton > wrote: >> Nathan Sutton >> fowlduck at gmail.com >> rspec edge revision 2910 >> rspec_on_rails edge revision 2909 >> rails edge revision 8175 > > Have you added this to your signature???? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From nathan.sutton at gmail.com Wed Nov 21 17:33:59 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Wed, 21 Nov 2007 16:33:59 -0600 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: <57c63afe0711211431w20645206n71f5474bf11864a9@mail.gmail.com> References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> <0A6DC38C-3016-48B9-987B-86542B941E4A@railsnewbie.com> <57c63afe0711211413i330b1829m7bb063414179bfa6@mail.gmail.com> <57c63afe0711211431w20645206n71f5474bf11864a9@mail.gmail.com> Message-ID: <1AD6C20D-CC8A-43A7-9E15-C03EBBEAC18D@gmail.com> Oh, and the reason I include this is because it's always a question when discussing things, and this makes it always available, both to those reading now and those who may read these conversations in the future. Nathan Sutton fowlduck at gmail.com rspec edge revision 2910 rspec_on_rails edge revision 2909 rails edge revision 8175 On Nov 21, 2007, at 4:31 PM, David Chelimsky wrote: > On Nov 21, 2007 4:16 PM, Nathan Sutton > wrote: >> Nathan Sutton >> fowlduck at gmail.com >> rspec edge revision 2910 >> rspec_on_rails edge revision 2909 >> rails edge revision 8175 > > Have you added this to your signature???? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Wed Nov 21 17:36:06 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 21 Nov 2007 23:36:06 +0100 Subject: [rspec-users] describe scope In-Reply-To: <389c43e40711211408y68ecd21doa49bc5d2127d604a@mail.gmail.com> References: <389c43e40711202307s46207eafwf0be267b6ad5df74@mail.gmail.com> <57c63afe0711210618w8066c81s77a71372bff22f1@mail.gmail.com> <389c43e40711211353n3fe73e4cr4e97d2840b23c094@mail.gmail.com> <8d961d900711211401w14bb0b6et84f5ce7066bcfc6e@mail.gmail.com> <389c43e40711211408y68ecd21doa49bc5d2127d604a@mail.gmail.com> Message-ID: <8d961d900711211436x38709812q311adbf06a25f5e3@mail.gmail.com> On Nov 21, 2007 11:08 PM, Mark Van De Vyver wrote: > > On Nov 22, 2007 9:01 AM, aslak hellesoy wrote: > > On 11/21/07, Mark Van De Vyver wrote: > > > Hi, > > > Thanks for the prompt responses... > > > > > > On Nov 22, 2007 1:18 AM, David Chelimsky wrote: > > > > On Nov 21, 2007 1:07 AM, Mark Van De Vyver wrote: > > > > > Hi, > > > > > Googling 'RSpec describe scope' didn't yield much, so apologies if > > > > > this question has been dealt with. > > > > > > > > > > It seem well known that a ruby class is 'visible' between describes, > > > > > and if this is a problem then you should use some counter as prefix or > > > > > suffix: > > > > > 'class Item_001; ... end' > > > > > > > > > > Is there any work underway, or sheduled release where classes will > > > > > exist only in the scope they are defined? > > > > > > > > This has never been brought up before. Feel free to submit a feature > > > > request at http://rspec.lighthouseapp.com/. > > > > > > > > > Writing spec's for Og is where this becomes an issue because Og will > > > > > grab _all_ manageble objects it can 'see'... all sorts of PITA can > > > > > arise. > > > > > > > > I found this: > > > > > > > > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/6924 > > > > > > I thought to make a feature request with a spec, any comments on why > > > the following fails > > > > > > > No idea, because you forgot to attach any output from RSpec ;-) > > > > Apologies, the spec and output: > > require 'spec' > > module Example > describe "RSpec " do > before(:each) do > class ::Item > attr_accessor :name > end > end > > it "should not raise error on defined?" do > lambda{ defined?(Item)}.should_not raise_error > end > it "should be defined as a constant" do > defined?(Item).should == "constant" > end > > after(:each) do > remove_const("Item") > end > end > end # spec > Try this: module Example describe "A class defined in before" do before do class Item @@var ||= 0 @@var += 1 def self.var @@var end end end it "should be redefined the first time" do Item.var.should == 1 end it "should be redefined the second time" do Item.var.should == 1 end after do Example.send(:remove_const, 'Item') end end end It will fail without the after, so the after definitely undefines the class so it can be redefined completely the next time. HTH, Aslak > # The output > FF > > 1) > NoMethodError in 'RSpec should not raise error on defined?' > undefined method `remove_const' for [RSpec example]:# > /usr/src/nitro-repo/og/test/rspec_example_spec.rb:19: > > 2) > NoMethodError in 'RSpec should be defined as a constant' > undefined method `remove_const' for [RSpec example]:# > /usr/src/nitro-repo/og/test/rspec_example_spec.rb:19: > > Finished in 0.006203 seconds > > 2 examples, 2 failures > > > > > # rspec example > > > require 'spec' > > > > > > module Example > > > describe "RSpec " do > > > before(:each) do > > > class ::Item > > > attr_accessor :name > > > end > > > end > > > > > > it "should not raise error on defined?" do > > > lambda{defined?("Item")}.should_not raise_error > > > end > > > it "should be defined after being removed" do > > > defined?("Item").should == "constant" > > > end > > > > > > after(:each) do > > > Kernel.remove_const("Item") > > > end > > > end > > > end # rspec example > > > > > > > > > Appreciate any comments. > > > Mark > > > > > > > So you could, in theory, monkey patch ExampleGroupMethods (in trunk > > > > 2937 - these names are changing a bit, so keep an eye out) to remove > > > > the defined constant > > > > > > > > > > > > > > Thanks for all the great work, T/BDD definitely is a brilliant way to > > > > > work, and RSpec makes it painless, esp for us amatuers :) > > > > > > > > That's what we want to hear! Thanks. > > > > > > > > Cheers, > > > > David > > > > > > > > > > > > > > > > > > Mark > > > > > _______________________________________________ > > > > > 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 mailing_lists at railsnewbie.com Wed Nov 21 17:36:27 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 21 Nov 2007 17:36:27 -0500 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: <57c63afe0711211431w20645206n71f5474bf11864a9@mail.gmail.com> References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> <0A6DC38C-3016-48B9-987B-86542B941E4A@railsnewbie.com> <57c63afe0711211413i330b1829m7bb063414179bfa6@mail.gmail.com> <57c63afe0711211431w20645206n71f5474bf11864a9@mail.gmail.com> Message-ID: <9508370A-F8EC-42FD-A382-30D93E280931@railsnewbie.com> On Nov 21, 2007, at 5:31 PM, David Chelimsky wrote: > On Nov 21, 2007 4:16 PM, Nathan Sutton > wrote: >> Nathan Sutton >> fowlduck at gmail.com >> rspec edge revision 2910 >> rspec_on_rails edge revision 2909 >> rails edge revision 8175 > > Have you added this to your signature???? Haha. Probably not a bad option. From nathan.sutton at gmail.com Wed Nov 21 17:42:28 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Wed, 21 Nov 2007 16:42:28 -0600 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> <0A6DC38C-3016-48B9-987B-86542B941E4A@railsnewbie.com> <57c63afe0711211413i330b1829m7bb063414179bfa6@mail.gmail.com> Message-ID: <1215C18B-728C-4B49-A966-A484EF27ECCD@gmail.com> Not even sure, what are your thoughts? Nathan Sutton fowlduck at gmail.com rspec edge revision 2910 rspec_on_rails edge revision 2909 rails edge revision 8175 On Nov 21, 2007, at 4:31 PM, Scott Taylor wrote: > > On Nov 21, 2007, at 5:16 PM, Nathan Sutton wrote: > >> Ooh, I totally want to do this, I'll work on it this week along with >> my other patch i have yet to submit this week, unless Scott is >> partial >> to doing it. Do you want it, Scott? > > Go for it. Let me know if you don't want it. > > What is the syntax your thinking of? > > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mailing_lists at railsnewbie.com Wed Nov 21 17:58:48 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 21 Nov 2007 17:58:48 -0500 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: <1215C18B-728C-4B49-A966-A484EF27ECCD@gmail.com> References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> <0A6DC38C-3016-48B9-987B-86542B941E4A@railsnewbie.com> <57c63afe0711211413i330b1829m7bb063414179bfa6@mail.gmail.com> <1215C18B-728C-4B49-A966-A484EF27ECCD@gmail.com> Message-ID: <437D7854-B6F6-439A-B102-498557ADF13E@railsnewbie.com> On Nov 21, 2007, at 5:42 PM, Nathan Sutton wrote: > Not even sure, what are your thoughts? > > Nathan Sutton > fowlduck at gmail.com > rspec edge revision 2910 > rspec_on_rails edge revision 2909 > rails edge revision 8175 > I'd like to see something like this: it_should_behave_like "a foo", :variables => { :bar => "bar", :baz => "baz", :class => Object } describe "a foo", :shared => true do it "should have the variable bar there, equal to bar" do bar.should == "bar" end end Conceivably, you could do some metaprogramming to define methods "bar" and "baz" in the ExampleGroupClass (or whatever that thing is called now) to return the values give in the hash. Scott > > > On Nov 21, 2007, at 4:31 PM, Scott Taylor wrote: > >> >> On Nov 21, 2007, at 5:16 PM, Nathan Sutton wrote: >> >>> Ooh, I totally want to do this, I'll work on it this week along with >>> my other patch i have yet to submit this week, unless Scott is >>> partial >>> to doing it. Do you want it, Scott? >> >> Go for it. Let me know if you don't want it. >> >> What is the syntax your thinking of? >> >> Scott >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Wed Nov 21 18:05:41 2007 From: lists at ruby-forum.com (Brad Carson) Date: Thu, 22 Nov 2007 00:05:41 +0100 Subject: [rspec-users] Autotest rspec issues In-Reply-To: References: <257aa9e1ca069148abdb30cc5c1dbb73@ruby-forum.com> <3E231DCD-FAB4-4151-A5D7-1EE65D5C36C7@railsnewbie.com> <6cdaa6a73bfdbbc977dae286bfa2ba34@ruby-forum.com> Message-ID: <0f2613ed48bb688aa8e2182a0a51a172@ruby-forum.com> Scott Taylor wrote: >> You were absolutely right. My gem configuration is kind of mangled >> (Leopard thing) and ZenTest would only update to 3.5.0 so I thought it >> was the most recent version. > > Strange. Are you using the rubygems which comes with leopard? I > wonder if it's a bug... I am. First thing I did at the terminal was a 'gem update --system' which, as it now turns out, is a no-no, since the gem directories get mixed up. I've recently since explicitly set the GEM_PATH and GEM_HOME to point to the Leopard defaults to avoid further confusion. Some gems were being written to /usr/lib/ruby/gems/1.8 More details here: http://www.luisdelarosa.com/2007/11/10/ruby-bugs-on-leopard/ In any case, rspec and zentest are working wonderfully now. Thanks again. Brad -- Posted via http://www.ruby-forum.com/. From nathan.sutton at gmail.com Wed Nov 21 23:00:30 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Wed, 21 Nov 2007 22:00:30 -0600 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: <437D7854-B6F6-439A-B102-498557ADF13E@railsnewbie.com> References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> <0A6DC38C-3016-48B9-987B-86542B941E4A@railsnewbie.com> <57c63afe0711211413i330b1829m7bb063414179bfa6@mail.gmail.com> <1215C18B-728C-4B49-A966-A484EF27ECCD@gmail.com> <437D7854-B6F6-439A-B102-498557ADF13E@railsnewbie.com> Message-ID: Anyone else have any opinions on this? I'd like to get some more input. Thanks, Nathan Sutton fowlduck at gmail.com rspec edge revision 2910 rspec_on_rails edge revision 2909 rails edge revision 8175 On Nov 21, 2007, at 4:58 PM, Scott Taylor wrote: > > On Nov 21, 2007, at 5:42 PM, Nathan Sutton wrote: > >> Not even sure, what are your thoughts? >> >> Nathan Sutton >> fowlduck at gmail.com >> rspec edge revision 2910 >> rspec_on_rails edge revision 2909 >> rails edge revision 8175 >> > > I'd like to see something like this: > > > it_should_behave_like "a foo", :variables => { > :bar => "bar", > :baz => "baz", > :class => Object > } > > > describe "a foo", :shared => true do > > it "should have the variable bar there, equal to bar" do > bar.should == "bar" > end > > end > > Conceivably, you could do some metaprogramming to define methods > "bar" and "baz" in the ExampleGroupClass (or whatever that thing is > called now) to return the values give in the hash. > > Scott > > > > >> >> >> On Nov 21, 2007, at 4:31 PM, Scott Taylor wrote: >> >>> >>> On Nov 21, 2007, at 5:16 PM, Nathan Sutton wrote: >>> >>>> Ooh, I totally want to do this, I'll work on it this week along >>>> with >>>> my other patch i have yet to submit this week, unless Scott is >>>> partial >>>> to doing it. Do you want it, Scott? >>> >>> Go for it. Let me know if you don't want it. >>> >>> What is the syntax your thinking of? >>> >>> Scott >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ben at benmabey.com Wed Nov 21 23:14:12 2007 From: ben at benmabey.com (Ben Mabey) Date: Wed, 21 Nov 2007 21:14:12 -0700 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> <0A6DC38C-3016-48B9-987B-86542B941E4A@railsnewbie.com> <57c63afe0711211413i330b1829m7bb063414179bfa6@mail.gmail.com> <1215C18B-728C-4B49-A966-A484EF27ECCD@gmail.com> <437D7854-B6F6-439A-B102-498557ADF13E@railsnewbie.com> Message-ID: <47450214.4050501@benmabey.com> I like what Scott suggested. it_should_behave_like "a foo", :with => { ... } Might read a little better. But I like the idea of it just taking a hash. -Ben Nathan Sutton wrote: > Anyone else have any opinions on this? I'd like to get some more input. > > Thanks, > > Nathan Sutton > fowlduck at gmail.com > rspec edge revision 2910 > rspec_on_rails edge revision 2909 > rails edge revision 8175 > > > > On Nov 21, 2007, at 4:58 PM, Scott Taylor wrote: > > >> On Nov 21, 2007, at 5:42 PM, Nathan Sutton wrote: >> >> >>> Not even sure, what are your thoughts? >>> >>> Nathan Sutton >>> fowlduck at gmail.com >>> rspec edge revision 2910 >>> rspec_on_rails edge revision 2909 >>> rails edge revision 8175 >>> >>> >> I'd like to see something like this: >> >> >> it_should_behave_like "a foo", :variables => { >> :bar => "bar", >> :baz => "baz", >> :class => Object >> } >> >> >> describe "a foo", :shared => true do >> >> it "should have the variable bar there, equal to bar" do >> bar.should == "bar" >> end >> >> end >> >> Conceivably, you could do some metaprogramming to define methods >> "bar" and "baz" in the ExampleGroupClass (or whatever that thing is >> called now) to return the values give in the hash. >> >> Scott >> >> >> >> >> >>> On Nov 21, 2007, at 4:31 PM, Scott Taylor wrote: >>> >>> >>>> On Nov 21, 2007, at 5:16 PM, Nathan Sutton wrote: >>>> >>>> >>>>> Ooh, I totally want to do this, I'll work on it this week along >>>>> with >>>>> my other patch i have yet to submit this week, unless Scott is >>>>> partial >>>>> to doing it. Do you want it, Scott? >>>>> >>>> Go for it. Let me know if you don't want it. >>>> >>>> What is the syntax your thinking of? >>>> >>>> Scott >>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> 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 mailing_lists at railsnewbie.com Wed Nov 21 23:25:31 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 21 Nov 2007 23:25:31 -0500 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: <47450214.4050501@benmabey.com> References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> <0A6DC38C-3016-48B9-987B-86542B941E4A@railsnewbie.com> <57c63afe0711211413i330b1829m7bb063414179bfa6@mail.gmail.com> <1215C18B-728C-4B49-A966-A484EF27ECCD@gmail.com> <437D7854-B6F6-439A-B102-498557ADF13E@railsnewbie.com> <47450214.4050501@benmabey.com> Message-ID: On Nov 21, 2007, at 11:14 PM, Ben Mabey wrote: > I like what Scott suggested. > > it_should_behave_like "a foo", :with => { ... } > > Might read a little better. But I like the idea of it just taking > a hash. > The obvious problem with this approach is that it will crowd the namespace (declaring methods in the shared example object might lead to some hard to track down bugs). The other suggestion, as proposed in IRC (for those who may not have been in the room). [11:06pm] smtlaissezfaire: So I was thinking of another way to do this - with the shared specs [11:06pm] fowlduck: elaborate [11:06pm] smtlaissezfaire: It could be block/lambda based [11:06pm] fowlduck: that's actually what I was going to suggest [11:06pm] smtlaissezfaire: So you might say it_should_behave_like "foo", var1, var2 and so on [11:07pm] fowlduck: *args, &proc [11:07pm] fowlduck: or something [11:07pm] smtlaissezfaire: and then describe "a shared example", :shared => true do |var1, var2| I'm interested in other's opinions (or other suggestions). Scott From dchelimsky at gmail.com Thu Nov 22 05:14:54 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 22 Nov 2007 04:14:54 -0600 Subject: [rspec-users] changes to spec_helper in trunk r2952 Message-ID: <57c63afe0711220214u4a007b34qc97debdad3033742@mail.gmail.com> If you're keeping up to date with trunk, don't forget to run script/generate rspec. Revision 2952 includes a small change to spec/spec_helper.rb. Cheers, David From osahyoun at gmail.com Thu Nov 22 06:24:58 2007 From: osahyoun at gmail.com (Sahyoun) Date: Thu, 22 Nov 2007 12:24:58 +0100 Subject: [rspec-users] describe AddressesController, "handling GET /addresses" do In-Reply-To: <810a540e0711210135g6c2da0ebpe03d462ad5b4ecfa@mail.gmail.com> References: <810a540e0711210135x7c8372bbh74ece122299d35cf@mail.gmail.com> <810a540e0711210135g6c2da0ebpe03d462ad5b4ecfa@mail.gmail.com> Message-ID: Pat, thanks. That helped. I'm now trying to get my head around the error: Spec::Mocks::MockExpectationError in 'AddressesController handling GET /addresses/1 should be successful' Mock 'Address_1006' received unexpected message :find with ("1") My show method in the addresses controller: def show @address = @company.addresses.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @address } end end In the controller spec: describe AddressesController, "handling GET /addresses/1" do before do @address = mock_model(Address) @company = mock_model(Company) Company.stub!(:find_by_id).and_return(@company) @company.stub!(:addresses).and_return(@address) end def do_get get :show, :id => "1", :company_id => "1" end it "should be successful" do do_get response.should be_success end .... I know that @company.stub!(:addresses).and_return(@address) is incorrect. I'm trying to work out how I can stub out: @address = @company.addresses.find(params[:id]) Thanks for any pointers. Omar On 21/11/2007, Pat Maddox wrote: > > On Nov 21, 2007 1:35 AM, Pat Maddox wrote: > > On Nov 21, 2007 1:15 AM, Sahyoun wrote: > > > Thanks. That helped. I now have: > > > > > > before do > > > @address = mock_model(Address) > > > @company = mock_model(Company) > > > Company.stub!(:find_by_id).and_return(@company) > > > > > > @company.stub!(:addresses).and_return(@addresses) > > > end > > > > > > > > > with only one error remaining: > > > > > > 'AddressesController handling GET /addresses should assign the found > > > addresses for the view' FAILED > > > expected: [nil], > > > got: nil (using ==) > > > > > > Spec: > > > it "should assign the found addresses for the view" do > > > do_get > > > assigns[:addresses].should == [@addresses] > > > end > > > > > > > > > I thought @company.stub!(:addresses).and_return(@addresses) would > be > > > sufficient for the above to pass. My understanding of mocking and > stubbing > > > is sketchy at the moment. Any explanation on how to get this to pass > would > > > be appreciated. > > > > @company.stub!(:addresses).and_return([@addresses]) > > > > If you're expecting an array, then you need the stub to return an array. > > > > Pat > > > > Guh, sorry, should have looked a bit more closely: > > @company.stub!(:addresses).and_return([@address]) > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071122/b3f937d1/attachment.html From nathan.sutton at gmail.com Thu Nov 22 06:41:47 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Thu, 22 Nov 2007 05:41:47 -0600 Subject: [rspec-users] describe AddressesController, "handling GET /addresses" do In-Reply-To: References: <810a540e0711210135x7c8372bbh74ece122299d35cf@mail.gmail.com> <810a540e0711210135g6c2da0ebpe03d462ad5b4ecfa@mail.gmail.com> Message-ID: <3E79FD70-AB82-4FC7-879B-AEB02A3DB591@gmail.com> Where does @company come from initially in the show controller? Is there a before_filter? describe AddressesController, "handling GET /addresses/1" do before do @address = mock_model(Address) @company = mock_model(Company) Company.stub!(:find_by_id).and_return(@company) @company.stub!(:addresses) @company.addresses.stub!(:find).with("1").and_return(@address) end end Give that a shot, you might want to make some of those expectations instead of stubs, depending on your style. Nathan Sutton fowlduck at gmail.com rspec edge revision 2944 rspec_on_rails edge revision 2944 rails edge revision 8186 On Nov 22, 2007, at 5:24 AM, Sahyoun wrote: > Pat, thanks. That helped. I'm now trying to get my head around the > error: > > Spec::Mocks::MockExpectationError in 'AddressesController handling > GET /addresses/1 should be successful' > Mock 'Address_1006' received unexpected message :find with ("1") > > My show method in the addresses controller: > def show > @address = @company.addresses.find(params[:id]) > > respond_to do |format| > format.html # show.html.erb > format.xml { render :xml => @address } > end > end > > In the controller spec: > > describe AddressesController, "handling GET /addresses/1" do > before do > @address = mock_model(Address) > @company = mock_model(Company) > > Company.stub!(:find_by_id).and_return(@company) > @company.stub!(:addresses).and_return(@address) > end > > def do_get > get :show, :id => "1", :company_id => "1" > end > > it "should be successful" do > do_get > response.should be_success > end > > .... > > > I know that @company.stub!(:addresses).and_return(@address) is > incorrect. I'm trying to work out how I can stub out: > @address = @company.addresses.find(params[:id]) > > Thanks for any pointers. > > Omar > > > On 21/11/2007, Pat Maddox < pergesu at gmail.com> wrote: > On Nov 21, 2007 1:35 AM, Pat Maddox < pergesu at gmail.com> wrote: > > On Nov 21, 2007 1:15 AM, Sahyoun wrote: > > > Thanks. That helped. I now have: > > > > > > before do > > > @address = mock_model(Address) > > > @company = mock_model(Company) > > > Company.stub!(:find_by_id).and_return(@company) > > > > > > @company.stub!(:addresses).and_return(@addresses) > > > end > > > > > > > > > with only one error remaining: > > > > > > 'AddressesController handling GET /addresses should assign the > found > > > addresses for the view' FAILED > > > expected: [nil], > > > got: nil (using ==) > > > > > > Spec: > > > it "should assign the found addresses for the view" do > > > do_get > > > assigns[:addresses].should == [@addresses] > > > end > > > > > > > > > I thought @company.stub!(:addresses).and_return(@addresses) > would be > > > sufficient for the above to pass. My understanding of mocking > and stubbing > > > is sketchy at the moment. Any explanation on how to get this to > pass would > > > be appreciated. > > > > @company.stub!(:addresses).and_return([@addresses]) > > > > If you're expecting an array, then you need the stub to return an > array. > > > > Pat > > > > Guh, sorry, should have looked a bit more closely: > > @company.stub!(:addresses).and_return([@address]) > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071122/4d8d2c76/attachment-0001.html From stefan.landro at gmail.com Thu Nov 22 10:50:56 2007 From: stefan.landro at gmail.com (=?ISO-8859-1?Q?Stefan_Magnus_Landr=F8?=) Date: Thu, 22 Nov 2007 16:50:56 +0100 Subject: [rspec-users] Issues related to jruby 1.0.2/edge rails and rspec head Message-ID: <921ca2f80711220750t3a56acbfld7e9ba5547913464@mail.gmail.com> Hi, We just spent half an afternoon figuring out why "jruby -S rake spec" didn't generate any output at all (no warnings) on an edge rails app. We were seeing different behaviour on different boxes, and after a while figured out that it was related to a missing diff-lcs gem on one box. HTH, Stefan -- Bekk Open Source http://boss.bekk.no -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071122/ae16e5d1/attachment.html From pergesu at gmail.com Thu Nov 22 11:48:37 2007 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 22 Nov 2007 08:48:37 -0800 Subject: [rspec-users] describe AddressesController, "handling GET /addresses" do In-Reply-To: References: <810a540e0711210135x7c8372bbh74ece122299d35cf@mail.gmail.com> <810a540e0711210135g6c2da0ebpe03d462ad5b4ecfa@mail.gmail.com> Message-ID: <810a540e0711220848n21247086v2d906ae31ba8f785@mail.gmail.com> On Nov 22, 2007 3:24 AM, Sahyoun wrote: > Pat, thanks. That helped. I'm now trying to get my head around the error: > > Spec::Mocks::MockExpectationError in 'AddressesController handling GET > /addresses/1 should be successful' > Mock 'Address_1006' received unexpected message :find with ("1") > > My show method in the addresses controller: > def show > @address = @company.addresses.find(params[:id]) > > respond_to do |format| > format.html # show.html.erb > > format.xml { render :xml => @address } > end > end > > In the controller spec: > > describe AddressesController, "handling GET /addresses/1" do > > before do > @address = mock_model(Address) > @company = mock_model(Company) > > Company.stub!(:find_by_id).and_return(@company) > @company.stub!(:addresses).and_return(@address) > end > > def do_get > get :show, :id => "1", :company_id => "1" > > end > > it "should be successful" do > do_get > response.should be_success > end > > .... > > > I know that @company.stub!(:addresses).and_return(@address) is incorrect. > I'm trying to work out how I can stub out: > @address = @company.addresses.find(params[:id]) > > Thanks for any pointers. > > Omar The problem is that you didn't stub #find on the addresses proxy. Here's how I'd write it: describe AddressesController, "handling GET /addresses/1" do before do @address_proxy = mock("address proxy", :find => :address) @company = mock_model(Company) Company.stub!(:find_by_id).and_return(@company) @company.stub!(:addresses).and_return(@address_proxy) end def do_get get :show, :id => "2", :company_id => "1" end it "should be successful" do do_get response.should be_success end it "should find the company" do Company.should_receive(:find_by_id).with("1").and_return @company do_get end it "should find the address" do @address_proxy.should_receive(:find).with("2").and_return :address do_get end it "should assign the address to the view" do do_get assigns[:address].should == :address end it "should render show.rhtml" do do_get response.should render_template(:show) end end hth Pat From aslak.hellesoy at gmail.com Thu Nov 22 13:52:17 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 22 Nov 2007 19:52:17 +0100 Subject: [rspec-users] Issues related to jruby 1.0.2/edge rails and rspec head In-Reply-To: <921ca2f80711220750t3a56acbfld7e9ba5547913464@mail.gmail.com> References: <921ca2f80711220750t3a56acbfld7e9ba5547913464@mail.gmail.com> Message-ID: <8d961d900711221052x76479867q55087192f841aa9e@mail.gmail.com> On Nov 22, 2007 4:50 PM, Stefan Magnus Landr? wrote: > Hi, > > We just spent half an afternoon figuring out why "jruby -S rake spec" didn't > generate any output at all (no warnings) on an edge rails app. We were > seeing different behaviour on different boxes, and after a while figured out > that it was related to a missing diff-lcs gem on one box. > Hey man, Could you please file a bug report so it stays on our radar? http://rspec.lighthouseapp.com/ Aslak > HTH, > > Stefan > > -- > Bekk Open Source > http://boss.bekk.no > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From byrnejb at harte-lyne.ca Thu Nov 22 16:29:24 2007 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Thu, 22 Nov 2007 16:29:24 -0500 (EST) Subject: [rspec-users] Initial run of RSpec 1.0.8 on MS-WinXPproSP2 Message-ID: <1638.216.185.71.90.1195766964.squirrel@webmail.harte-lyne.ca> ENV Rails 1.2.5 Ruby 1.8.6 Rake 0.7.3 RSpec 1.0.8 PostgreSQL 8.2.5 MicroSoft Windows XP pro SP2 I am experiencing a problem with the "rake spec spec\models" task on an initialtrial of rspec. After creating the rails app I installed rspec and rspec_on_rails in the vendor\plugins subdirectory from svn. I then used ruby script\generate rspec_model product. I next manually created the database instances depot_development and depot_test via pgAdmin III. I then confirmed rails configuration connectivity by running rake db:migrate from the app root. However, when I run rake spec spec\models for the first time, without modifying the product_rspec.rb file, I get this: C:\Documents and Settings\byrnejb\My Documents\ My Projects\ca.harte-lyne.system\pragdepot >rake spec spec\models --trace (in C:/Documents and Settings/byrnejb/ My Documents/MyProjects/ca.harte-lyne.system/pragdepot) ** Invoke spec (first_time) ** Invoke db:test:prepare (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:test:prepare ** Invoke db:test:clone (first_time) ** Invoke db:schema:dump (first_time) ** Invoke environment ** Execute db:schema:dump ** Invoke db:test:purge (first_time) ** Invoke environment ** Execute db:test:purge ** Execute db:test:clone ** Invoke db:schema:load (first_time) ** Invoke environment ** Execute db:schema:load rake aborted! PGError: ERROR: relation "pg_ts_cfg" already exists : CREATE TABLE pg_ts_cfg ("ts_name" text NOT NULL, "prs_name" text NOT NULL, "locale" text DEFAULT NULL) C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/connection_adapters/abstract_adapter.rb:128:in `log' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/connection_adapters/postgresql_adapter.rb:152:in `execute' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/connection_adapters/abstract/ schema_statements.rb:104:in `create_table' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/migration.rb:275:in `send' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/migration.rb:275:in `method_missing' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/migration.rb:259:in `say_with_time' C:/usr/local/bin/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/migration.rb:259:in `say_with_time' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/migration.rb:273:in `method_missing' ./db/schema.rb:7 C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/schema.rb:43:in `instance_eval' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/schema.rb:43:in `define' ./db/schema.rb:5 C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/ active_support/dependencies.rb:488:in `load' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/ active_support/dependencies.rb:488:in `load' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/ active_support/dependencies.rb:342:in `new_constants_in' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/ active_support/dependencies.rb:488:in `load' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/ tasks/databases.rake:31 C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `call' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `execute' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `each' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `execute' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:362:in `invoke' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:355:in `synchronize' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:355:in `invoke' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/ tasks/databases.rake:76 C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `call' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `execute' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `each' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `execute' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:362:in `invoke' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:355:in `synchronize' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:355:in `invoke' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/ tasks/databases.rake:153 C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `call' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `execute' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `each' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `execute' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:362:in `invoke' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:355:in `synchronize' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:355:in `invoke' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:369:in `invoke_prerequisites' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1003:in `each' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1003:in `send' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1003:in `each' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:368:in `invoke_prerequisites' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:361:in `invoke' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:355:in `synchronize' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:355:in `invoke' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1739:in `top_level' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1739:in `each' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1739:in `top_level' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1761:in `standard_exception_handling' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1733:in `top_level' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1711:in `run' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1761:in `standard_exception_handling' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1708:in `run' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 C:/usr/local/bin/ruby/bin/rake.bat:20:in `load' C:/usr/local/bin/ruby/bin/rake.bat:20 C:\Documents and Settings\byrnejb\My Documents\My Projects\ca.harte-lyne.system\pragdepot> Running rake spec:models gives the same results. I get this error whether or not the RSpec gem is installed. Is this a problem with the ruby postgresql adapter and this version of pstgreSQL? Have I missed some critical setup item? Any help would be greatly appreciated. Regards, -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From dchelimsky at gmail.com Thu Nov 22 16:31:19 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 22 Nov 2007 15:31:19 -0600 Subject: [rspec-users] Initial run of RSpec 1.0.8 on MS-WinXPproSP2 In-Reply-To: <1638.216.185.71.90.1195766964.squirrel@webmail.harte-lyne.ca> References: <1638.216.185.71.90.1195766964.squirrel@webmail.harte-lyne.ca> Message-ID: <57c63afe0711221331j5b5b35c9i6a4bb7ebc7ac3aa2@mail.gmail.com> On Nov 22, 2007 3:29 PM, James B. Byrne wrote: > ENV > > Rails 1.2.5 > Ruby 1.8.6 > Rake 0.7.3 > RSpec 1.0.8 RSpec 1.0.8 supports rails 1.2.3 or earlier. If you want to work w/ anything later than Rails 1.2.3 you'll need rspec's trunk. From byrnejb at harte-lyne.ca Thu Nov 22 16:19:18 2007 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Thu, 22 Nov 2007 16:19:18 -0500 (EST) Subject: [rspec-users] Initial run of RSpec 1.0.8 on MS-WinXPproSP2 Message-ID: <1589.216.185.71.90.1195766358.squirrel@webmail.harte-lyne.ca> Rails 1.2.5 Ruby 1.8.6 Rake 0.7.3 RSpec 1.0.8 PostgreSQL 8.2.5 I am experiencing a problem with the "rake spec spec" task on an initial trial of rspec. After creating the rails app I installed rspec and rspec_on_rails in the vendor\plugins subdirectory from svn. I then used ruby script\generate rspec_model product. I next manually created the database instances depot_development and depot_test via pgAdmin III. I then confirmed rails configuration connectivity by running rake db:migrate from the app root. When I run rake spec spec\models for the first time, without modifying the product_rspec.rb file, I get this: C:\Documents and Settings\byrnejb\My Documents\ My Projects\ca.harte-lyne.system\pragdepot >rake spec spec\models --trace (in C:/Documents and Settings/byrnejb/ My Documents/MyProjects/ca.harte-lyne.system/pragdepot) ** Invoke spec (first_time) ** Invoke db:test:prepare (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:test:prepare ** Invoke db:test:clone (first_time) ** Invoke db:schema:dump (first_time) ** Invoke environment ** Execute db:schema:dump ** Invoke db:test:purge (first_time) ** Invoke environment ** Execute db:test:purge ** Execute db:test:clone ** Invoke db:schema:load (first_time) ** Invoke environment ** Execute db:schema:load rake aborted! PGError: ERROR: relation "pg_ts_cfg" already exists : CREATE TABLE pg_ts_cfg ("ts_name" text NOT NULL, "prs_name" text NOT NULL, "locale" text DEFAULT NULL) C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/connection_adapters/abstract_adapter.rb:128:in `log' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/connection_adapters/postgresql_adapter.rb:152:in `execute' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/connection_adapters/abstract/ schema_statements.rb:104:in `create_table' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/migration.rb:275:in `send' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/migration.rb:275:in `method_missing' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/migration.rb:259:in `say_with_time' C:/usr/local/bin/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/migration.rb:259:in `say_with_time' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/migration.rb:273:in `method_missing' ./db/schema.rb:7 C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/schema.rb:43:in `instance_eval' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/schema.rb:43:in `define' ./db/schema.rb:5 C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/ active_support/dependencies.rb:488:in `load' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/ active_support/dependencies.rb:488:in `load' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/ active_support/dependencies.rb:342:in `new_constants_in' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/ active_support/dependencies.rb:488:in `load' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/ tasks/databases.rake:31 C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `call' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `execute' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `each' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `execute' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:362:in `invoke' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:355:in `synchronize' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:355:in `invoke' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/ tasks/databases.rake:76 C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `call' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `execute' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `each' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `execute' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:362:in `invoke' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:355:in `synchronize' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:355:in `invoke' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/ tasks/databases.rake:153 C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `call' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `execute' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `each' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `execute' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:362:in `invoke' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:355:in `synchronize' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:355:in `invoke' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:369:in `invoke_prerequisites' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1003:in `each' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1003:in `send' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1003:in `each' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:368:in `invoke_prerequisites' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:361:in `invoke' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:355:in `synchronize' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:355:in `invoke' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1739:in `top_level' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1739:in `each' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1739:in `top_level' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1761:in `standard_exception_handling' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1733:in `top_level' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1711:in `run' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1761:in `standard_exception_handling' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1708:in `run' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 C:/usr/local/bin/ruby/bin/rake.bat:20:in `load' C:/usr/local/bin/ruby/bin/rake.bat:20 C:\Documents and Settings\byrnejb\My Documents\My Projects\ca.harte-lyne.system\pragdepot> Have I missed some critical setup item? Running rake spec:models gives the same results. I get this error whether or not the RSpec gem is installed. Any help would be greatly appreciated. Regards, -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From byrnejb at harte-lyne.ca Thu Nov 22 17:06:46 2007 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Thu, 22 Nov 2007 17:06:46 -0500 (EST) Subject: [rspec-users] Initial run of RSpec 1.0.8 on MS-WinXPproSP2 In-Reply-To: <57c63afe0711221331j5b5b35c9i6a4bb7ebc7ac3aa2@mail.gmail.com> References: <1638.216.185.71.90.1195766964.squirrel@webmail.harte-lyne.ca> <57c63afe0711221331j5b5b35c9i6a4bb7ebc7ac3aa2@mail.gmail.com> Message-ID: <1738.216.185.71.90.1195769206.squirrel@webmail.harte-lyne.ca> On Thu, November 22, 2007 16:31, David Chelimsky wrote: > > RSpec 1.0.8 supports rails 1.2.3 or earlier. If you want to work w/ > anything later than Rails 1.2.3 you'll need rspec's trunk. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > I deleted the rpsec gem and the rspec and rpec_on_rails plugins. I then installed rspec from the trunk (svn://rubyforge.org/var/svn/rspec/trunk) via Tortoise SVN. I deleted the ./spec directory tree from the app root and ran ruby script/generate rspec_model product. When I run rake spec:models I get the same error. Regards, P.S. rake doc:plugins produces no output for the trunk version of rspec. Is this expected behaviour or does it indicate a problem? C:\Documents and Settings\byrnejb\My Documents\My Projects\ca.harte-lyne.system\pragdepot>rake doc:plugins (in C:/Documents and Settings/byrnejb/My Documents/ My Projects/ca.harte-lyne.system/pragdepot) rdoc.bat -o doc/plugins/rspec --title 'Rspec Plugin Documentation' --line-numbers --inline-source -T html --main 'vendor/plugins/rspec/ README' vendor/plugins/rspec/README README: Generating HTML... Files: 1 Classes: 0 Modules: 0 Methods: 0 Elapsed: 0.313s ?? -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From dchelimsky at gmail.com Thu Nov 22 17:42:43 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 22 Nov 2007 16:42:43 -0600 Subject: [rspec-users] Initial run of RSpec 1.0.8 on MS-WinXPproSP2 In-Reply-To: <1738.216.185.71.90.1195769206.squirrel@webmail.harte-lyne.ca> References: <1638.216.185.71.90.1195766964.squirrel@webmail.harte-lyne.ca> <57c63afe0711221331j5b5b35c9i6a4bb7ebc7ac3aa2@mail.gmail.com> <1738.216.185.71.90.1195769206.squirrel@webmail.harte-lyne.ca> Message-ID: <57c63afe0711221442v71e12f63l235e4fa4fe481143@mail.gmail.com> On Nov 22, 2007 4:06 PM, James B. Byrne wrote: > > On Thu, November 22, 2007 16:31, David Chelimsky wrote: > > > > > RSpec 1.0.8 supports rails 1.2.3 or earlier. If you want to work w/ > > anything later than Rails 1.2.3 you'll need rspec's trunk. > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > I deleted the rpsec gem and the rspec and rpec_on_rails plugins. I then > installed rspec from the trunk (svn://rubyforge.org/var/svn/rspec/trunk) > via Tortoise SVN. I deleted the ./spec directory tree from the app root > and ran ruby script/generate rspec_model product. When I run rake > spec:models I get the same error. Did you run this? ruby script/generate rspec Here's the order of things: rails pragdepot cd pragdepot ruby script/plugin install http://rspec.rubyforge.org/svn/trunk/rspec ruby script/plugin install http://rspec.rubyforge.org/svn/trunk/rspec_on_rails ruby script/generate rspec ruby script/generate rspec_model product rake db:migrate rake spec:models The db creation should happen some time before running rake db:migrate. HTH, David > > Regards, > > > P.S. > > rake doc:plugins produces no output for the trunk version of rspec. Is > this expected behaviour or does it indicate a problem? > > C:\Documents and Settings\byrnejb\My Documents\My > Projects\ca.harte-lyne.system\pragdepot>rake doc:plugins > (in C:/Documents and Settings/byrnejb/My Documents/ > My Projects/ca.harte-lyne.system/pragdepot) > rdoc.bat -o doc/plugins/rspec --title 'Rspec Plugin Documentation' > --line-numbers --inline-source -T html --main 'vendor/plugins/rspec/ > README' vendor/plugins/rspec/README > > README: > Generating HTML... > > Files: 1 > Classes: 0 > Modules: 0 > Methods: 0 > Elapsed: 0.313s > > ?? > > > -- > *** E-Mail is NOT a SECURE channel *** > James B. Byrne mailto:ByrneJB at Harte-Lyne.ca > Harte & Lyne Limited http://www.harte-lyne.ca > 9 Brockley Drive vox: +1 905 561 1241 > Hamilton, Ontario fax: +1 905 561 0757 > Canada L8E 3C3 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From byrnejb at harte-lyne.ca Thu Nov 22 18:22:12 2007 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Thu, 22 Nov 2007 18:22:12 -0500 (EST) Subject: [rspec-users] Initial run of RSpec 1.0.8 on MS-WinXPproSP2 Message-ID: <1915.216.185.71.90.1195773732.squirrel@webmail.harte-lyne.ca> On Thu, November 22, 2007 17:42, David Chelimsky wrote: > > Did you run this? > > ruby script/generate rspec > Yes I did. I forgot to report this however. > Here's the order of things: > > rails pragdepot > cd pragdepot > ruby script/plugin install http://rspec.rubyforge.org/svn/trunk/rspec > ruby script/plugin install > http://rspec.rubyforge.org/svn/trunk/rspec_on_rails > ruby script/generate rspec > ruby script/generate rspec_model product > rake db:migrate > rake spec:models > > The db creation should happen some time before running rake db:migrate. > > HTH, > David > > I have this working now but I had to install the win32console gem and I had to remove and reinstall postgresql 8.2.5, removing the text search module from the default schema. Many thanks. Regards, -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From nathan.sutton at gmail.com Thu Nov 22 20:45:58 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Thu, 22 Nov 2007 19:45:58 -0600 Subject: [rspec-users] Getting Class in Shared Behaviours In-Reply-To: References: <2fff50390711211314x7afd87cblef2f5815d4e74f71@mail.gmail.com> <57c63afe0711211322n4cacab7cm4ea82ae7f367c9d4@mail.gmail.com> <0A6DC38C-3016-48B9-987B-86542B941E4A@railsnewbie.com> <57c63afe0711211413i330b1829m7bb063414179bfa6@mail.gmail.com> <1215C18B-728C-4B49-A966-A484EF27ECCD@gmail.com> <437D7854-B6F6-439A-B102-498557ADF13E@railsnewbie.com> <47450214.4050501@benmabey.com> Message-ID: Bah, I won't have time to do this anytime soon, you can feel free, Scott. Nathan Sutton fowlduck at gmail.com rspec edge revision 2944 rspec_on_rails edge revision 2944 rails edge revision 8186 On Nov 21, 2007, at 10:25 PM, Scott Taylor wrote: > > On Nov 21, 2007, at 11:14 PM, Ben Mabey wrote: > >> I like what Scott suggested. >> >> it_should_behave_like "a foo", :with => { ... } >> >> Might read a little better. But I like the idea of it just taking >> a hash. >> > > The obvious problem with this approach is that it will crowd the > namespace (declaring methods in the shared example object might lead > to some hard to track down bugs). > > > The other suggestion, as proposed in IRC (for those who may not have > been in the room). > > [11:06pm] smtlaissezfaire: So I was thinking of another way to do > this - with the shared specs > [11:06pm] fowlduck: elaborate > [11:06pm] smtlaissezfaire: It could be block/lambda based > [11:06pm] fowlduck: that's actually what I was going to suggest > [11:06pm] smtlaissezfaire: So you might say it_should_behave_like > "foo", var1, var2 and so on > [11:07pm] fowlduck: *args, &proc > [11:07pm] fowlduck: or something > [11:07pm] smtlaissezfaire: and then describe "a shared > example", :shared => true do |var1, var2| > > I'm interested in other's opinions (or other suggestions). > > Scott > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Fri Nov 23 00:47:00 2007 From: lists at ruby-forum.com (Chris Olsen) Date: Fri, 23 Nov 2007 06:47:00 +0100 Subject: [rspec-users] Creation of spec.opts spec_helper etc Message-ID: <40cd6dc096245d56a3303678d01edf98@ruby-forum.com> When do these files, along with lib/spec and lib/spec_server get created? I tried to create a quick test project and can't remember how they were created in a previous project. Thanks -- Posted via http://www.ruby-forum.com/. From mailing_lists at railsnewbie.com Fri Nov 23 01:21:58 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 23 Nov 2007 01:21:58 -0500 Subject: [rspec-users] Creation of spec.opts spec_helper etc In-Reply-To: <40cd6dc096245d56a3303678d01edf98@ruby-forum.com> References: <40cd6dc096245d56a3303678d01edf98@ruby-forum.com> Message-ID: On Nov 23, 2007, at 12:47 AM, Chris Olsen wrote: > When do these files, along with lib/spec and lib/spec_server get > created? > > I tried to create a quick test project and can't remember how they > were > created in a previous project. > With script/generate rspec Scott From nathan.sutton at gmail.com Fri Nov 23 01:27:34 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Fri, 23 Nov 2007 00:27:34 -0600 Subject: [rspec-users] Creation of spec.opts spec_helper etc In-Reply-To: References: <40cd6dc096245d56a3303678d01edf98@ruby-forum.com> Message-ID: <5D3698D8-3982-4777-AE99-A4B642132F92@gmail.com> Dang scott, your website is messed up ;) Also, did you get my email about the rspec shared behaviors with parameters? I won't have time to do it this weekend, so feel free. Nathan Sutton fowlduck at gmail.com rspec edge revision 2944 rspec_on_rails edge revision 2944 rails edge revision 8186 On Nov 23, 2007, at 12:21 AM, Scott Taylor wrote: > > On Nov 23, 2007, at 12:47 AM, Chris Olsen wrote: > >> When do these files, along with lib/spec and lib/spec_server get >> created? >> >> I tried to create a quick test project and can't remember how they >> were >> created in a previous project. >> > > With script/generate rspec > > Scott > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Fri Nov 23 01:31:27 2007 From: lists at ruby-forum.com (Chris Olsen) Date: Fri, 23 Nov 2007 07:31:27 +0100 Subject: [rspec-users] Creation of spec.opts spec_helper etc In-Reply-To: References: <40cd6dc096245d56a3303678d01edf98@ruby-forum.com> Message-ID: Thanks Scott. And of course after you tell me, I now see it sitting on the rspec documentation page ever so elegantly. -- Posted via http://www.ruby-forum.com/. From byrnejb at harte-lyne.ca Fri Nov 23 10:07:53 2007 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Fri, 23 Nov 2007 10:07:53 -0500 (EST) Subject: [rspec-users] Initial run of RSpec 1.0.8 on MS-WinXPproSP2 In-Reply-To: <57c63afe0711221442v71e12f63l235e4fa4fe481143@mail.gmail.com> References: <1638.216.185.71.90.1195766964.squirrel@webmail.harte-lyne.ca> <57c63afe0711221331j5b5b35c9i6a4bb7ebc7ac3aa2@mail.gmail.com> <1738.216.185.71.90.1195769206.squirrel@webmail.harte-lyne.ca> <57c63afe0711221442v71e12f63l235e4fa4fe481143@mail.gmail.com> Message-ID: <47992.216.185.71.22.1195830473.squirrel@webmail.harte-lyne.ca> On Thu, November 22, 2007 17:42, David Chelimsky wrote: model product. When I run rake >> spec:models I get the same error. > > Did you run this? > > ruby script/generate rspec > > Here's the order of things: > > rails pragdepot > cd pragdepot > ruby script/plugin install http://rspec.rubyforge.org/svn/trunk/rspec > ruby script/plugin install > http://rspec.rubyforge.org/svn/trunk/rspec_on_rails > ruby script/generate rspec > ruby script/generate rspec_model product > rake db:migrate > rake spec:models > > The db creation should happen some time before running rake db:migrate. > I installed the rspec and rspec_on_rails plugins from this url and I now get an error in script/generate rspec_models that was not present in the version that I installed them via svn from the trunk. The error is: $ rake spec:models --trace (in /home/byrnejb/Software/Development/Projects/rspectest) ** Invoke spec:models (first_time) ** Invoke db:test:prepare (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:test:prepare ** Invoke db:test:clone (first_time) ** Invoke db:schema:dump (first_time) ** Invoke environment ** Execute db:schema:dump ** Invoke db:test:purge (first_time) ** Invoke environment ** Execute db:test:purge ** Execute db:test:clone ** Invoke db:schema:load (first_time) ** Invoke environment ** Execute db:schema:load NOTICE: CREATE TABLE will create implicit sequence "movements_id_seq" for serial column "movements.id" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "movements_pkey" for table "movements" NOTICE: CREATE TABLE will create implicit sequence "products_id_seq" for serial column "products.id" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "products_pkey" for table "products" ** Execute spec:models /home/byrnejb/Software/Development/Projects/rspectest/vendor/plugins/rspec/lib/spec/version.rb:10: undefined method `[]' for nil:NilClass (NoMethodError) from /home/byrnejb/Software/Development/Projects/rspectest/vendor/plugins/rspec/lib/spec.rb:1:in `require' from /home/byrnejb/Software/Development/Projects/rspectest/vendor/plugins/rspec/lib/spec.rb:1 from /home/byrnejb/Software/Development/Projects/rspectest/vendor/plugins/rspec/bin/spec:2:in `require' from /home/byrnejb/Software/Development/Projects/rspectest/vendor/plugins/rspec/bin/spec:2 rake aborted! Command ruby -I"/home/byrnejb/Software/Development/Projects/rspectest/vendor/plugins/rspec/lib" "/home/byrnejb/Software/Development/Projects/rspectest/vendor/plugins/rspec/bin/spec" "spec/models/product_spec.rb" --options "/home/byrnejb/Software/Development/Projects/rspectest/config/../spec/spec.opts" failed /home/byrnejb/Software/Development/Projects/rspectest/vendor/plugins/rspec/lib/spec/rake/spectask.rb:173:in `define' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:823:in `verbose' /home/byrnejb/Software/Development/Projects/rspectest/vendor/plugins/rspec/lib/spec/rake/spectask.rb:142:in `define' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke' /usr/lib/ruby/1.8/thread.rb:135:in `synchronize' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `each' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in `top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in `run' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in `run' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 /usr/bin/rake:16:in `load' /usr/bin/rake:16 the code is: --> module Spec module VERSION unless defined? MAJOR MAJOR = 1 MINOR = 1 TINY = 0 RELEASE_CANDIDATE = nil # RANDOM_TOKEN: 0.885013695004692 REV = "$LastChangedRevision$".match(/LastChangedRevision: (\d+)/)[1] STRING = [MAJOR, MINOR, TINY].join('.') TAG = "REL_#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('_')}".upcase.gsub(/\.|-/, '_') FULL_VERSION = "#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('.')} (r#{REV})" NAME = "RSpec" URL = "http://rspec.rubyforge.org/" DESCRIPTION = "#{NAME}-#{FULL_VERSION} - BDD for Ruby\n#{URL}" end end end <--- The same error occurs on both Linux CentOS 5 and MicroSoft Windows XP pro. Rails 1.2.5/1.2.5 Ruby 1.8.5/1.8.5 PostgreSQL 8.1.9 / 8.2.5 -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From dchelimsky at gmail.com Fri Nov 23 10:18:10 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 23 Nov 2007 09:18:10 -0600 Subject: [rspec-users] Initial run of RSpec 1.0.8 on MS-WinXPproSP2 In-Reply-To: <47992.216.185.71.22.1195830473.squirrel@webmail.harte-lyne.ca> References: <1638.216.185.71.90.1195766964.squirrel@webmail.harte-lyne.ca> <57c63afe0711221331j5b5b35c9i6a4bb7ebc7ac3aa2@mail.gmail.com> <1738.216.185.71.90.1195769206.squirrel@webmail.harte-lyne.ca> <57c63afe0711221442v71e12f63l235e4fa4fe481143@mail.gmail.com> <47992.216.185.71.22.1195830473.squirrel@webmail.harte-lyne.ca> Message-ID: <57c63afe0711230718p66444951i53a844a8a8a85b69@mail.gmail.com> On Nov 23, 2007 9:07 AM, James B. Byrne wrote: > The same error occurs on both Linux CentOS 5 and MicroSoft Windows XP pro. > Rails 1.2.5/1.2.5 Ruby 1.8.5/1.8.5 PostgreSQL 8.1.9 / 8.2.5 Unfortunately, I don't have these environments set up so somebody else is going to have to help here. Anybody else w/ the same configuration able to help James out here? From lists at ruby-forum.com Fri Nov 23 11:54:31 2007 From: lists at ruby-forum.com (Andrew Edwards) Date: Fri, 23 Nov 2007 17:54:31 +0100 Subject: [rspec-users] Textmate Bundle Errors Message-ID: Hi, Running #rake spec seems to work as expected, however using cmd+r in textmate does not. I assume Textmate has some specific references to rails or ruby which I have not set. I have set the TM_RUBY to /usr/local/bin/ruby as suggested in the RSpec docs. I am running OS X 10.5 with a manually compiled ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.10.1] and gem 0.9.4. This was installed prior to upgrading to 10.5 which I hear includes its own version of ruby and gems. I am using rspec and rspec_on_rails rev 2962 (trunk) and have installed RSpec.tmbundle from the same revision. I am using using the trunk version as my project is using Rails RC1 (installed as the system version of Rails as opposed to frozen to the project, reported as version 1.99.0). When viewing a _spec.rb file and using cmd+r I get the following error: Cannot find gem for Rails ~>1.99.0: Install the missing gem with 'gem install -v=1.99 rails', or change environment.rb to define RAILS_GEM_VERSION with your desired version. Thanks for any pointers, Andrew -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Nov 23 11:56:20 2007 From: lists at ruby-forum.com (Andrew Edwards) Date: Fri, 23 Nov 2007 17:56:20 +0100 Subject: [rspec-users] Textmate Bundle Errors In-Reply-To: References: Message-ID: <49133da0b2506e68cc637fc8c10eb22e@ruby-forum.com> Sorry, I should add that environment.rb is set as advised in the error message: RAILS_GEM_VERSION = '1.99' unless defined? RAILS_GEM_VERSION -- Posted via http://www.ruby-forum.com/. From mailing_lists at railsnewbie.com Fri Nov 23 16:48:05 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 23 Nov 2007 16:48:05 -0500 Subject: [rspec-users] namespaced controllers Message-ID: Out of curiosity, I've seen the following fail: module Admin describe MyController ... end end But this works fine: describe Admin::MyController .. end Why? Scott From philodespotos at gmail.com Fri Nov 23 17:27:33 2007 From: philodespotos at gmail.com (Kyle Hargraves) Date: Fri, 23 Nov 2007 16:27:33 -0600 Subject: [rspec-users] namespaced controllers In-Reply-To: References: Message-ID: <60f3810c0711231427w1c6804b2v5e1575012c885431@mail.gmail.com> On Nov 23, 2007 3:48 PM, Scott Taylor wrote: > > Out of curiosity, I've seen the following fail: > > module Admin > describe MyController > ... > end > end > > But this works fine: > > describe Admin::MyController > .. > end How has the top one failed? I use it exclusively and haven't ever noticed a problem. Kyle From byrnejb at harte-lyne.ca Fri Nov 23 23:08:16 2007 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Fri, 23 Nov 2007 23:08:16 -0500 (EST) Subject: [rspec-users] Initial run of RSpec 1.0.8 on MS-WinXPproSP2 In-Reply-To: <47992.216.185.71.22.1195830473.squirrel@webmail.harte-lyne.ca> References: <1638.216.185.71.90.1195766964.squirrel@webmail.harte-lyne.ca> <57c63afe0711221331j5b5b35c9i6a4bb7ebc7ac3aa2@mail.gmail.com> <1738.216.185.71.90.1195769206.squirrel@webmail.harte-lyne.ca> <57c63afe0711221442v71e12f63l235e4fa4fe481143@mail.gmail.com> <47992.216.185.71.22.1195830473.squirrel@webmail.harte-lyne.ca> Message-ID: <60870.67.71.38.238.1195877296.squirrel@webmail.harte-lyne.ca> I found this message: ---> aslak hellesoy aslak.hellesoy at gmail.com Wed Nov 1 14:00:03 EST 2006 * Previous message: [rspec-devel] [ rspec-Bugs-6411 ] Can't run Rails specs with ruby * Next message: [rspec-devel] script/generate rspec issue on trunk (rev 1021) * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] The short version: Developers *must* run pre_commit prior to committing - it's more important than before. The longer version: Several people are experiencing problems because they have an RSpec on Rails plugin that is incompatible with their installed RSpec gem. Because I'm lazy I made RSpec on Rails able to detect incompatibilities on its own. There are now two files in our codebase that store the current svn revision in their source (via the svn:externals feature - http://svnbook.red-bean.com/en/1.0/ch07s02.html): lib/spec/version.rb vendor/rspec_on_rails/vendor/plugins/rspec/lib/spec/rails/version.rb The latter, when loaded (it's required by rspec_on_rails.rb) will check that the rev numbers are the same in those two files. If they are not, an exception is thrown with a message to the user describing what to do. In order to ensure that these two files get updated with the current svn revision numbers during a commit it is MANDATORY that rake pre_commit be run prior to a commit. This will modify those files with a random comment, which will in turn cause svn to update the $LastChangedRevision tokens in those files during the next commit. (Without this random modification svn will *not* update the $LastChangedRevision tokens in those files). It's a little bit of magic, but it will help us in the long run. Aslak <--- and this one: ---> Re: Incompatibility Issues after updating CURRENT Posted by David Chelimsky (Guest) on 11.10.2007 20:01 (Received via mailing list) On 10/11/07, George Anderson wrote: > ---- > Fetching remote repository's latest revision and UUID > unchanged from revision 2338 > ############################################################################ > Your RSpec on Rails plugin is incompatible with your installed RSpec. > > RSpec : 1.0.7 (r2332) > RSpec on Rails : r2331 > > Make sure your RSpec on Rails plugin is compatible with your RSpec gem. > See > http://rspec.rubyforge.org/documentation/rails/install.html > for details. > ############################################################################ That is VERY odd. That was a bug in the 1.0.7 release, which is why we released 1.0.8 right on its heels. But that was over a month ago. I see this in CURRENT/rspec/lib/spec/version.rb: MAJOR = 1 MINOR = 0 TINY = 8 ... REV = "$LastChangedRevision: 2338 $".match(/LastChangedRevision: (\d+)/)[1] ... and this in CURRENT/rspec_on_rails/lib/spec/rails/version.rb REV = "$LastChangedRevision: 2338 $".match(/LastChangedRevision: (\d+)/)[1] So they should be aligning just fine. Sounds like something's wrong when you update from piston. Not sure how or why. <--- Now, the version.rb that is loaded from http://rspec.rubyforge.org/svn/trunk/rspec has only this: ---> module Spec module VERSION unless defined? MAJOR MAJOR = 1 MINOR = 1 TINY = 0 RELEASE_CANDIDATE = nil # RANDOM_TOKEN: 0.885013695004692 REV = "$LastChangedRevision$".match(/LastChangedRevision: (\d+)/)[1] <--- One cannot but notice the absence of any digits in the REV = string. Is this the source (sink) of the [] nil object? Regards, -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From byrnejb at harte-lyne.ca Fri Nov 23 23:20:47 2007 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Fri, 23 Nov 2007 23:20:47 -0500 (EST) Subject: [rspec-users] Initial run of RSpec 1.0.8 on MS-WinXPproSP2 In-Reply-To: <60870.67.71.38.238.1195877296.squirrel@webmail.harte-lyne.ca> References: <1638.216.185.71.90.1195766964.squirrel@webmail.harte-lyne.ca> <57c63afe0711221331j5b5b35c9i6a4bb7ebc7ac3aa2@mail.gmail.com> <1738.216.185.71.90.1195769206.squirrel@webmail.harte-lyne.ca> <57c63afe0711221442v71e12f63l235e4fa4fe481143@mail.gmail.com> <47992.216.185.71.22.1195830473.squirrel@webmail.harte-lyne.ca> <60870.67.71.38.238.1195877296.squirrel@webmail.harte-lyne.ca> Message-ID: <61148.67.71.38.238.1195878047.squirrel@webmail.harte-lyne.ca> On Fri, November 23, 2007 23:08, James B. Byrne wrote: > I found this message: > > Now, the version.rb that is loaded from > http://rspec.rubyforge.org/svn/trunk/rspec > has only this: > > ---> > module Spec > module VERSION > unless defined? MAJOR > MAJOR = 1 > MINOR = 1 > TINY = 0 > RELEASE_CANDIDATE = nil > > # RANDOM_TOKEN: 0.885013695004692 > REV = "$LastChangedRevision$".match(/LastChangedRevision: (\d+)/)[1] > <--- > > One cannot but notice the absence of any digits in the REV = string. Is > this the source (sink) of the [] nil object? > So. I went to the rubyforge trac site and found what the svn version.rb said and from that information I manually changed my copies in rspec and rspec_on_rails to have this: REV = "$LastChangedRevision: 2757 $".match(/LastChangedRevision: (\d+)/)[1] and now all is good. -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From dchelimsky at gmail.com Fri Nov 23 23:24:02 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 23 Nov 2007 22:24:02 -0600 Subject: [rspec-users] Initial run of RSpec 1.0.8 on MS-WinXPproSP2 In-Reply-To: <60870.67.71.38.238.1195877296.squirrel@webmail.harte-lyne.ca> References: <1638.216.185.71.90.1195766964.squirrel@webmail.harte-lyne.ca> <57c63afe0711221331j5b5b35c9i6a4bb7ebc7ac3aa2@mail.gmail.com> <1738.216.185.71.90.1195769206.squirrel@webmail.harte-lyne.ca> <57c63afe0711221442v71e12f63l235e4fa4fe481143@mail.gmail.com> <47992.216.185.71.22.1195830473.squirrel@webmail.harte-lyne.ca> <60870.67.71.38.238.1195877296.squirrel@webmail.harte-lyne.ca> Message-ID: <57c63afe0711232024t7377c0fah6bfe10e256743145@mail.gmail.com> On Nov 23, 2007 10:08 PM, James B. Byrne wrote: > I found this message: > > ---> > aslak hellesoy aslak.hellesoy at gmail.com > Wed Nov 1 14:00:03 EST 2006 > > * Previous message: [rspec-devel] [ rspec-Bugs-6411 ] Can't run Rails > specs with ruby > * Next message: [rspec-devel] script/generate rspec issue on trunk > (rev 1021) > * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > The short version: Developers *must* run pre_commit prior to > committing - it's more important than before. > > The longer version: > > Several people are experiencing problems because they have an RSpec on > Rails plugin that is incompatible with their installed RSpec gem. > Because I'm lazy I made RSpec on Rails able to detect > incompatibilities on its own. > > There are now two files in our codebase that store the current svn > revision in their source (via the svn:externals feature - > http://svnbook.red-bean.com/en/1.0/ch07s02.html): > > lib/spec/version.rb > vendor/rspec_on_rails/vendor/plugins/rspec/lib/spec/rails/version.rb > > The latter, when loaded (it's required by rspec_on_rails.rb) will > check that the rev numbers are the same in those two files. If they > are not, an exception is thrown with a message to the user describing > what to do. > > In order to ensure that these two files get updated with the current > svn revision numbers during a commit it is MANDATORY that rake > pre_commit be run prior to a commit. This will modify those files with > a random comment, which will in turn cause svn to update the > $LastChangedRevision tokens in those files during the next commit. > (Without this random modification svn will *not* update the > $LastChangedRevision tokens in those files). > > It's a little bit of magic, but it will help us in the long run. > > Aslak > <--- > > and this one: > > ---> > Re: Incompatibility Issues after updating CURRENT > Posted by David Chelimsky (Guest) > on 11.10.2007 20:01 > (Received via mailing list) > > On 10/11/07, George Anderson wrote: > > ---- > > Fetching remote repository's latest revision and UUID > > unchanged from revision 2338 > > > > > ############################################################################ > > Your RSpec on Rails plugin is incompatible with your installed RSpec. > > > > RSpec : 1.0.7 (r2332) > > RSpec on Rails : r2331 > > > > Make sure your RSpec on Rails plugin is compatible with your RSpec gem. > > See > > http://rspec.rubyforge.org/documentation/rails/install.html > > for details. > > ############################################################################ > > That is VERY odd. That was a bug in the 1.0.7 release, which is why we > released 1.0.8 right on its heels. But that was over a month ago. > > I see this in CURRENT/rspec/lib/spec/version.rb: > > MAJOR = 1 > MINOR = 0 > TINY = 8 > ... > REV = "$LastChangedRevision: 2338 $".match(/LastChangedRevision: > (\d+)/)[1] > > ... and this in CURRENT/rspec_on_rails/lib/spec/rails/version.rb > > REV = "$LastChangedRevision: 2338 > $".match(/LastChangedRevision: (\d+)/)[1] > > So they should be aligning just fine. Sounds like something's wrong > when you update from piston. Not sure how or why. > > > <--- > > Now, the version.rb that is loaded from > http://rspec.rubyforge.org/svn/trunk/rspec > has only this: > > ---> > module Spec > module VERSION > unless defined? MAJOR > MAJOR = 1 > MINOR = 1 > TINY = 0 > RELEASE_CANDIDATE = nil > > # RANDOM_TOKEN: 0.885013695004692 > REV = "$LastChangedRevision$".match(/LastChangedRevision: (\d+)/)[1] > <--- > > One cannot but notice the absence of any digits in the REV = string. Is > this the source (sink) of the [] nil object? That's a bug. Please report bugs to http://rspec.lighthouseapp.com/. > > Regards, > > > -- > *** E-Mail is NOT a SECURE channel *** > James B. Byrne mailto:ByrneJB at Harte-Lyne.ca > Harte & Lyne Limited http://www.harte-lyne.ca > 9 Brockley Drive vox: +1 905 561 1241 > Hamilton, Ontario fax: +1 905 561 0757 > Canada L8E 3C3 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From byrnejb at harte-lyne.ca Fri Nov 23 23:34:33 2007 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Fri, 23 Nov 2007 23:34:33 -0500 (EST) Subject: [rspec-users] Initial run of RSpec 1.0.8 on MS-WinXPproSP2 In-Reply-To: <57c63afe0711232024t7377c0fah6bfe10e256743145@mail.gmail.com> References: <1638.216.185.71.90.1195766964.squirrel@webmail.harte-lyne.ca> <57c63afe0711221331j5b5b35c9i6a4bb7ebc7ac3aa2@mail.gmail.com> <1738.216.185.71.90.1195769206.squirrel@webmail.harte-lyne.ca> <57c63afe0711221442v71e12f63l235e4fa4fe481143@mail.gmail.com> <47992.216.185.71.22.1195830473.squirrel@webmail.harte-lyne.ca> <60870.67.71.38.238.1195877296.squirrel@webmail.harte-lyne.ca> <57c63afe0711232024t7377c0fah6bfe10e256743145@mail.gmail.com> Message-ID: <61629.67.71.38.238.1195878873.squirrel@webmail.harte-lyne.ca> On Fri, November 23, 2007 23:24, David Chelimsky wrote: > > That's a bug. Please report bugs to http://rspec.lighthouseapp.com/. Your bug sir: Ticket #139 James B. Byrne version.rb in trunk missing svn last changed number Regards, -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From mailing_lists at railsnewbie.com Sat Nov 24 00:53:46 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 24 Nov 2007 00:53:46 -0500 Subject: [rspec-users] namespaced controllers In-Reply-To: <60f3810c0711231427w1c6804b2v5e1575012c885431@mail.gmail.com> References: <60f3810c0711231427w1c6804b2v5e1575012c885431@mail.gmail.com> Message-ID: On Nov 23, 2007, at 5:27 PM, Kyle Hargraves wrote: > On Nov 23, 2007 3:48 PM, Scott Taylor > wrote: >> >> Out of curiosity, I've seen the following fail: >> >> module Admin >> describe MyController >> ... >> end >> end >> >> But this works fine: >> >> describe Admin::MyController >> .. >> end > > How has the top one failed? I use it exclusively and haven't ever > noticed a problem. > I got an "unknown action foo" error message (wasn't getting it before today - running on trunk). Scott From byrnejb at harte-lyne.ca Sat Nov 24 18:12:11 2007 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Sat, 24 Nov 2007 18:12:11 -0500 (EST) Subject: [rspec-users] rspec.opts Message-ID: <60096.65.92.50.109.1195945931.squirrel@webmail.harte-lyne.ca> Where can I find a list of the options and their usage and meanings for the contents of this file? Regards, -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From byrnejb at harte-lyne.ca Sat Nov 24 18:16:45 2007 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Sat, 24 Nov 2007 18:16:45 -0500 (EST) Subject: [rspec-users] rspec.opts In-Reply-To: <60096.65.92.50.109.1195945931.squirrel@webmail.harte-lyne.ca> References: <60096.65.92.50.109.1195945931.squirrel@webmail.harte-lyne.ca> Message-ID: <60108.65.92.50.109.1195946205.squirrel@webmail.harte-lyne.ca> On Sat, November 24, 2007 18:12, James B. Byrne wrote: > > Where can I find a list of the options and their usage and meanings for > the contents of this file? > From here I guess... ./vendor/plugins/rspec/lib/spec/runner/option_parser.rb -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From dchelimsky at gmail.com Sat Nov 24 18:42:45 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 24 Nov 2007 17:42:45 -0600 Subject: [rspec-users] rspec.opts In-Reply-To: <60108.65.92.50.109.1195946205.squirrel@webmail.harte-lyne.ca> References: <60096.65.92.50.109.1195945931.squirrel@webmail.harte-lyne.ca> <60108.65.92.50.109.1195946205.squirrel@webmail.harte-lyne.ca> Message-ID: <57c63afe0711241542n778064aatcf0ed706b31c9a67@mail.gmail.com> On Nov 24, 2007 5:16 PM, James B. Byrne wrote: > > On Sat, November 24, 2007 18:12, James B. Byrne wrote: > > > > Where can I find a list of the options and their usage and meanings for > > the contents of this file? > > > > From here I guess... > > ./vendor/plugins/rspec/lib/spec/runner/option_parser.rb Easier to just do this: spec --help > > > -- > *** E-Mail is NOT a SECURE channel *** > James B. Byrne mailto:ByrneJB at Harte-Lyne.ca > Harte & Lyne Limited http://www.harte-lyne.ca > 9 Brockley Drive vox: +1 905 561 1241 > Hamilton, Ontario fax: +1 905 561 0757 > Canada L8E 3C3 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From byrnejb at harte-lyne.ca Sat Nov 24 19:48:13 2007 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Sat, 24 Nov 2007 19:48:13 -0500 (EST) Subject: [rspec-users] Possible Problem with RSpec and Message-ID: <60213.65.92.50.109.1195951693.squirrel@webmail.harte-lyne.ca> Sorry to be such a pest but I am trying to learn Ruby, Rails and RSpec all at one go and it is a bit overwhelming. I have previously completed the depot tutorial in the Agile Web Dev with rails book and now I am trying do do it again using RSpec. What I would like to know now is why I am getting a rake failure error at the end of every spec:models run. Is this the expected behaviour when a test / expectation fails? ---> C:\var\RSpec\depot>rake spec:models (in C:/var/RSpec/depot) NOTICE: CREATE TABLE will create implicit sequence "products_id_seq" for serial column "products.id" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "products_pkey" f or table "products" Product - should have a valid image uri (PENDING: Not Yet Implemented) - should have a description - should have a title (FAILED - 1) Pending: Product should have a valid image uri (Not Yet Implemented) 1) 'Product should have a title' FAILED expected valid? to return true, got false ./spec/models/product_spec.rb:11: Finished in 0.75 seconds 3 examples, 1 failure, 1 pending rake aborted! Command ruby -I "C:/var/RSpec/depot/vendor/plugins/rspec/lib" "C:/var/RSpec/depot/vendor/plugins/rspec/bin/spec" "spec/models/product_spec.rb" --options "C:/var/RSpec/depot/config/../spec/spec.opts" failed (See full trace by running task with --trace) C:\var\RSpec\depot>rake spec:models --trace (in C:/var/RSpec/depot) ** Invoke spec:models (first_time) ** Invoke db:test:prepare (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:test:prepare ** Invoke db:test:clone (first_time) ** Invoke db:schema:dump (first_time) ** Invoke environment ** Execute db:schema:dump ** Invoke db:test:purge (first_time) ** Invoke environment ** Execute db:test:purge ** Execute db:test:clone ** Invoke db:schema:load (first_time) ** Invoke environment ** Execute db:schema:load NOTICE: CREATE TABLE will create implicit sequence "products_id_seq" for serial column "products.id" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "products_pkey" for table "products" ** Execute spec:models Product - should have a valid image uri (PENDING: Not Yet Implemented) - should have a description - should have a title (FAILED - 1) Pending: Product should have a valid image uri (Not Yet Implemented) 1) 'Product should have a title' FAILED expected valid? to return true, got false ./spec/models/product_spec.rb:11: Finished in 0.563 seconds 3 examples, 1 failure, 1 pending rake aborted! Command ruby -I"C:/var/RSpec/depot/vendor/plugins/rspec/lib" "C:/var/RSpec/depot/vendor/plugins/rspec/bin/spec" "spec/models/ product_spec.rb" --options "C:/var/RSpec/depot/config/../spec/spec.opts" failed C:/var/RSpec/depot/vendor/plugins/rspec/lib/spec/rake/ spectask.rb:173:in `define' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:823:in `verbose' C:/var/RSpec/depot/vendor/plugins/rspec/lib/spec/rake/ spectask.rb:142:in `define' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `call' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `execute' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `each' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `execute' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:362:in `invoke' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:355:in `synchronize' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:355:in `invoke' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1739:in `top_level' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1739:in `each' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1739:in `top_level' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1761:in `standard_exception_handling' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1733:in `top_level' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1711:in `run' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1761:in `standard_exception_handling' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1708:in `run' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 C:/usr/local/bin/ruby/bin/rake.bat:20:in `load' C:/usr/local/bin/ruby/bin/rake.bat:20 C:\var\RSpec\depot> <--- -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From byrnejb at harte-lyne.ca Sat Nov 24 19:56:26 2007 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Sat, 24 Nov 2007 19:56:26 -0500 (EST) Subject: [rspec-users] rspec.opts In-Reply-To: <57c63afe0711241542n778064aatcf0ed706b31c9a67@mail.gmail.com> References: <60096.65.92.50.109.1195945931.squirrel@webmail.harte-lyne.ca> <60108.65.92.50.109.1195946205.squirrel@webmail.harte-lyne.ca> <57c63afe0711241542n778064aatcf0ed706b31c9a67@mail.gmail.com> Message-ID: <60226.65.92.50.109.1195952186.squirrel@webmail.harte-lyne.ca> On Sat, November 24, 2007 18:42, David Chelimsky wrote: > Easier to just do this: > > spec --help C:\var\RSpec\depot>spec --help 'spec' is not recognized as an internal or external command, operable program or batch file. C:\var\RSpec\depot>ruby script/spec --help # works better Thanks, -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From mailing_lists at railsnewbie.com Sat Nov 24 20:20:45 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 24 Nov 2007 20:20:45 -0500 Subject: [rspec-users] Possible Problem with RSpec and In-Reply-To: <60213.65.92.50.109.1195951693.squirrel@webmail.harte-lyne.ca> References: <60213.65.92.50.109.1195951693.squirrel@webmail.harte-lyne.ca> Message-ID: <959C8B92-5C58-40C9-870A-11CDA975236E@railsnewbie.com> On Nov 24, 2007, at 7:48 PM, James B. Byrne wrote: > Sorry to be such a pest but I am trying to learn Ruby, Rails and > RSpec all > at one go and it is a bit overwhelming. I have previously > completed the > depot tutorial in the Agile Web Dev with rails book and now I am > trying do > do it again using RSpec. > > What I would like to know now is why I am getting a rake failure > error at > the end of every spec:models run. Is this the expected behaviour > when a > test / expectation fails? What database are you using? What verison of: rails, ruby, database engine (mysql, sqlite...), rspec? What version of windows are you running? It would probably also help if we could see your code, as well as your failing spec. Scott. > > ---> > > C:\var\RSpec\depot>rake spec:models > (in C:/var/RSpec/depot) > NOTICE: CREATE TABLE will create implicit sequence > "products_id_seq" for > serial > column "products.id" > NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index > "products_pkey" f > or table "products" > > Product > - should have a valid image uri (PENDING: Not Yet Implemented) > - should have a description > - should have a title (FAILED - 1) > > Pending: > Product should have a valid image uri (Not Yet Implemented) > > 1) > 'Product should have a title' FAILED > expected valid? to return true, got false > ./spec/models/product_spec.rb:11: > > Finished in 0.75 seconds > > 3 examples, 1 failure, 1 pending > rake aborted! > Command ruby -I > "C:/var/RSpec/depot/vendor/plugins/rspec/lib" > "C:/var/RSpec/depot/vendor/plugins/rspec/bin/spec" > "spec/models/product_spec.rb" > --options > "C:/var/RSpec/depot/config/../spec/spec.opts" failed > > (See full trace by running task with --trace) > > C:\var\RSpec\depot>rake spec:models --trace > (in C:/var/RSpec/depot) > ** Invoke spec:models (first_time) > ** Invoke db:test:prepare (first_time) > ** Invoke environment (first_time) > ** Execute environment > ** Execute db:test:prepare > ** Invoke db:test:clone (first_time) > ** Invoke db:schema:dump (first_time) > ** Invoke environment > ** Execute db:schema:dump > ** Invoke db:test:purge (first_time) > ** Invoke environment > ** Execute db:test:purge > ** Execute db:test:clone > ** Invoke db:schema:load (first_time) > ** Invoke environment > ** Execute db:schema:load > NOTICE: CREATE TABLE will create implicit sequence > "products_id_seq" for > serial column "products.id" > NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index > "products_pkey" for table "products" > ** Execute spec:models > > Product > - should have a valid image uri (PENDING: Not Yet Implemented) > - should have a description > - should have a title (FAILED - 1) > > Pending: > Product should have a valid image uri (Not Yet Implemented) > > 1) > 'Product should have a title' FAILED > expected valid? to return true, got false > ./spec/models/product_spec.rb:11: > > Finished in 0.563 seconds > > 3 examples, 1 failure, 1 pending > rake aborted! > Command ruby -I"C:/var/RSpec/depot/vendor/plugins/rspec/lib" > "C:/var/RSpec/depot/vendor/plugins/rspec/bin/spec" "spec/models/ > product_spec.rb" --options "C:/var/RSpec/depot/config/../spec/ > spec.opts" > failed > C:/var/RSpec/depot/vendor/plugins/rspec/lib/spec/rake/ > spectask.rb:173:in `define' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:823:in `verbose' > C:/var/RSpec/depot/vendor/plugins/rspec/lib/spec/rake/ > spectask.rb:142:in `define' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:392:in `call' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:392:in `execute' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:392:in `each' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:392:in `execute' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:362:in `invoke' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:355:in `synchronize' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:355:in `invoke' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1739:in `top_level' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1739:in `each' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1739:in `top_level' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1761:in `standard_exception_handling' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1733:in `top_level' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1711:in `run' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1761:in `standard_exception_handling' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1708:in `run' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 > C:/usr/local/bin/ruby/bin/rake.bat:20:in `load' > C:/usr/local/bin/ruby/bin/rake.bat:20 > > C:\var\RSpec\depot> > <--- > > > -- > *** E-Mail is NOT a SECURE channel *** > James B. Byrne mailto:ByrneJB at Harte-Lyne.ca > Harte & Lyne Limited http://www.harte-lyne.ca > 9 Brockley Drive vox: +1 905 561 1241 > Hamilton, Ontario fax: +1 905 561 0757 > Canada L8E 3C3 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From luislavena at gmail.com Sat Nov 24 20:25:49 2007 From: luislavena at gmail.com (Luis Lavena) Date: Sat, 24 Nov 2007 22:25:49 -0300 Subject: [rspec-users] Possible Problem with RSpec and In-Reply-To: <60213.65.92.50.109.1195951693.squirrel@webmail.harte-lyne.ca> References: <60213.65.92.50.109.1195951693.squirrel@webmail.harte-lyne.ca> Message-ID: <71166b3b0711241725r47f8a649o8ccc0ec0ca433592@mail.gmail.com> On Nov 24, 2007 9:48 PM, James B. Byrne wrote: > Sorry to be such a pest but I am trying to learn Ruby, Rails and RSpec all > at one go and it is a bit overwhelming. I have previously completed the > depot tutorial in the Agile Web Dev with rails book and now I am trying do > do it again using RSpec. > > What I would like to know now is why I am getting a rake failure error at > the end of every spec:models run. Is this the expected behaviour when a > test / expectation fails? > You didn't pasted the code of your specs... only the backtrace... Please include the spec/models/product_spec.rb code here so we can see your problem. Also, it seems your validations aren't right, since you're evaluating "be_valid" for product after title being set, but #valid? is returning false. Maybe you're "asking" the wrong question to your model? (not tested code) it "should have a title" do @product = Product.new(:title => nil) @product.should_not be_valid @product.should have_at_least(1).errors_on(:title) end also, versions of ruby, rails, rspec and database engine are helpful too ;-) -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From luislavena at gmail.com Sat Nov 24 20:27:04 2007 From: luislavena at gmail.com (Luis Lavena) Date: Sat, 24 Nov 2007 22:27:04 -0300 Subject: [rspec-users] rspec.opts In-Reply-To: <60226.65.92.50.109.1195952186.squirrel@webmail.harte-lyne.ca> References: <60096.65.92.50.109.1195945931.squirrel@webmail.harte-lyne.ca> <60108.65.92.50.109.1195946205.squirrel@webmail.harte-lyne.ca> <57c63afe0711241542n778064aatcf0ed706b31c9a67@mail.gmail.com> <60226.65.92.50.109.1195952186.squirrel@webmail.harte-lyne.ca> Message-ID: <71166b3b0711241727n7dd210e1y35302b32febd420e@mail.gmail.com> On Nov 24, 2007 9:56 PM, James B. Byrne wrote: > > On Sat, November 24, 2007 18:42, David Chelimsky wrote: > > > Easier to just do this: > > > > spec --help > > C:\var\RSpec\depot>spec --help > 'spec' is not recognized as an internal or external command, > operable program or batch file. > > C:\var\RSpec\depot>ruby script/spec --help # works better > That's because you didn't installed rspec as 'gem' beside as plugin: gem install rspec that will enable the 'spec' command for you. HTH, -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From mailing_lists at railsnewbie.com Sat Nov 24 20:33:20 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 24 Nov 2007 20:33:20 -0500 Subject: [rspec-users] rspec.opts In-Reply-To: <71166b3b0711241727n7dd210e1y35302b32febd420e@mail.gmail.com> References: <60096.65.92.50.109.1195945931.squirrel@webmail.harte-lyne.ca> <60108.65.92.50.109.1195946205.squirrel@webmail.harte-lyne.ca> <57c63afe0711241542n778064aatcf0ed706b31c9a67@mail.gmail.com> <60226.65.92.50.109.1195952186.squirrel@webmail.harte-lyne.ca> <71166b3b0711241727n7dd210e1y35302b32febd420e@mail.gmail.com> Message-ID: <9660DCAA-732A-487F-8A04-C9B2C0852387@railsnewbie.com> On Nov 24, 2007, at 8:27 PM, Luis Lavena wrote: > On Nov 24, 2007 9:56 PM, James B. Byrne wrote: >> >> On Sat, November 24, 2007 18:42, David Chelimsky wrote: >> >>> Easier to just do this: >>> >>> spec --help >> >> C:\var\RSpec\depot>spec --help >> 'spec' is not recognized as an internal or external command, >> operable program or batch file. >> >> C:\var\RSpec\depot>ruby script/spec --help # works better >> > > That's because you didn't installed rspec as 'gem' beside as plugin: > > gem install rspec > > that will enable the 'spec' command for you. > Although - watch out. The gem spec is different from the script/spec (if you're running on trunk). The options may also be different. Scott From mailing_lists at railsnewbie.com Sat Nov 24 20:47:08 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 24 Nov 2007 20:47:08 -0500 Subject: [rspec-users] 'it' duplicate example: BUG In-Reply-To: <8d961d900711211217k4e4e77a6tb524b417e751527e@mail.gmail.com> References: <95A4BD3A-C34F-497A-976F-BD52CB26F415@railsnewbie.com> <8d961d900711211217k4e4e77a6tb524b417e751527e@mail.gmail.com> Message-ID: <31D37238-DCE6-409F-B205-1125089ED321@railsnewbie.com> On Nov 21, 2007, at 3:17 PM, aslak hellesoy wrote: > On 11/21/07, Chad Humphries wrote: >> One of the recent trunk changesets modified the default behaviour to >> fail fast if duplicate examples are detected within a single >> behaviour/ >> example group. This is basically letting you know you have to "it" >> blocks in the behaviour with the same description. >> > > This is correct. It's not a bug - it's by design and documented in > CHANGES. > > The reason I put it in has an interesting explanation. Over the past > few days our coverage dropped from 100% to 99.9% and we couldn't > understand why. RCov reported that some code wasn't being covered, but > I *knew* there were examples covering it. > > Something was fishy. > > Then I remembered that Brian a few days ago did a change to the > internals - every it block now creates a method with the same name as > the description, and later calls that method to run the example. > Nothing wrong with that, but it had some sideeffects we didn't think > about: If there were duplicates, the last one would simply overwrite > (monkey patch!) the previous one with the same name. And as a result > never get run. > > Since I'm a fail fast kind of guy I made RSpec do that. In light of the duplicate examples which would come about with the following: it do foo.should == bar end - how about providing the behaviour described above as an option to the runner? Scott From byrnejb at harte-lyne.ca Sat Nov 24 20:48:39 2007 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Sat, 24 Nov 2007 20:48:39 -0500 (EST) Subject: [rspec-users] [SOLVED] Possible Problem with RSpec In-Reply-To: <60213.65.92.50.109.1195951693.squirrel@webmail.harte-lyne.ca> References: <60213.65.92.50.109.1195951693.squirrel@webmail.harte-lyne.ca> Message-ID: <60333.65.92.50.109.1195955319.squirrel@webmail.harte-lyne.ca> On Sat, November 24, 2007 19:48, James B. Byrne wrote: > What I would like to know now is why I am getting a rake failure error at > the end of every spec:models run. Is this the expected behaviour when a > test / expectation fails? Sorry about my delay in replying. I am a digest subscriber ordinarily and did not switch my list preferences when I posted as I usually do. Thanks for the suggestions. The problem was that I left out a column from the product migration that I referred to in the spec. Regards, -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From byrnejb at harte-lyne.ca Sat Nov 24 21:22:59 2007 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Sat, 24 Nov 2007 21:22:59 -0500 (EST) Subject: [rspec-users] [UNSOLVED] Possible Problem with RSpec In-Reply-To: <60333.65.92.50.109.1195955319.squirrel@webmail.harte-lyne.ca> References: <60213.65.92.50.109.1195951693.squirrel@webmail.harte-lyne.ca> <60333.65.92.50.109.1195955319.squirrel@webmail.harte-lyne.ca> Message-ID: <60364.65.92.50.109.1195957379.squirrel@webmail.harte-lyne.ca> On Sat, November 24, 2007 20:48, James B. Byrne wrote: > > The problem was that I left out a column from the product migration that I > referred to in the spec. > Sorry, but I need to revisit this again. If the specs pass then I get no rake error. If one spec fails then after the test reports I get a rake error and back trace. Why? OS = MS XP pro SP2 Ruby = 1.8.6 Rails = 1.2.5 RSpec = TRUNK d.20071123 product_spec.rb ---> require File.dirname(__FILE__) + '/../spec_helper' module ProductSpecHelper def valid_product_attributes { :code => 'PROD1234CODE', :description => 'a short description', :image_url => 'http://imageserver.tld.com/images/image.jpg', :price => 1234.56, :title => 'a test product' } end end describe Product do include ProductSpecHelper before(:each) do @product = Product.new end it "should have a title" do @product.attributes = valid_product_attributes.except(:title) @product.should have(1).error_on(:title) @product.title = 'a test product' @product.should be_valid end it "should have a description" do @product.attributes = valid_product_attributes.except(:description) @product.should have(1).error_on(:description) @product.description = 'a short description' @product.should be_valid end it "should have a valid image uri" end <--- app/models/product.rb ---> class Product < ActiveRecord::Base validates_presence_of :title validates_presence_of :description end <--- Specs pass: ---> C:\var\RSpec\depot>rake spec:models (in C:/var/RSpec/depot) NOTICE: CREATE TABLE will create implicit sequence "products_id_seq" for serial column "products.id" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "products_pkey" for table "products" Product - should have a valid image uri (PENDING: Not Yet Implemented) - should have a description - should have a title Pending: Product should have a valid image uri (Not Yet Implemented) Finished in 0.985 seconds 3 examples, 0 failures, 1 pending <--- Spec fails: (I changed the .should be_valid to .should_not be_valid) ---> C:\var\RSpec\depot>rake spec:models --trace (in C:/var/RSpec/depot) ** Invoke spec:models (first_time) ** Invoke db:test:prepare (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:test:prepare ** Invoke db:test:clone (first_time) ** Invoke db:schema:dump (first_time) ** Invoke environment ** Execute db:schema:dump ** Invoke db:test:purge (first_time) ** Invoke environment ** Execute db:test:purge ** Execute db:test:clone ** Invoke db:schema:load (first_time) ** Invoke environment ** Execute db:schema:load NOTICE: CREATE TABLE will create implicit sequence "products_id_seq" for serial column "products.id" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "products_pkey" for table "products" ** Execute spec:models Product - should have a valid image uri (PENDING: Not Yet Implemented) - should have a description (FAILED - 1) - should have a title Pending: Product should have a valid image uri (Not Yet Implemented) 1) 'Product should have a description' FAILED expected valid? to return false, got true ./spec/models/product_spec.rb:35: Finished in 1.266 seconds 3 examples, 1 failure, 1 pending rake aborted! Command ruby -I "C:/var/RSpec/depot/vendor/plugins/rspec/lib" "C:/var/RSpec/depot/vendor/plugins/rspec/bin/spec" "spec/models/product_spec.rb" --options "C:/var/RSpec/depot/config/../spec/spec.opts" failed C:/var/RSpec/depot/vendor/plugins/rspec/lib/spec/rake/ spectask.rb:173:in `define' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:823:in `verbose' C:/var/RSpec/depot/vendor/plugins/rspec/lib/spec/rake/ spectask.rb:142:in `define' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `call' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `execute' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `each' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:392:in `execute' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:362:in `invoke' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:355:in `synchronize' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:355:in `invoke' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1739:in `top_level' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1739:in `each' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1739:in `top_level' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1761:in `standard_exception_handling' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1733:in `top_level' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1711:in `run' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1761:in `standard_exception_handling' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ rake.rb:1708:in `run' C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 C:/usr/local/bin/ruby/bin/rake.bat:20:in `load' C:/usr/local/bin/ruby/bin/rake.bat:20 C:\var\RSpec\depot> <--- -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From pergesu at gmail.com Sat Nov 24 21:54:58 2007 From: pergesu at gmail.com (Pat Maddox) Date: Sat, 24 Nov 2007 18:54:58 -0800 Subject: [rspec-users] [UNSOLVED] Possible Problem with RSpec In-Reply-To: <60364.65.92.50.109.1195957379.squirrel@webmail.harte-lyne.ca> References: <60213.65.92.50.109.1195951693.squirrel@webmail.harte-lyne.ca> <60333.65.92.50.109.1195955319.squirrel@webmail.harte-lyne.ca> <60364.65.92.50.109.1195957379.squirrel@webmail.harte-lyne.ca> Message-ID: <810a540e0711241854q61b12c97pf71f9618a2c93c2d@mail.gmail.com> On Nov 24, 2007 6:22 PM, James B. Byrne wrote: > > On Sat, November 24, 2007 20:48, James B. Byrne wrote: > > > > > The problem was that I left out a column from the product migration that I > > referred to in the spec. > > > > Sorry, but I need to revisit this again. If the specs pass then I get no > rake error. If one spec fails then after the test reports I get a rake > error and back trace. Why? > > OS = MS XP pro SP2 > Ruby = 1.8.6 > Rails = 1.2.5 > RSpec = TRUNK d.20071123 > > product_spec.rb > > ---> > require File.dirname(__FILE__) + '/../spec_helper' > > module ProductSpecHelper > > def valid_product_attributes > { > :code => 'PROD1234CODE', > :description => 'a short description', > :image_url => 'http://imageserver.tld.com/images/image.jpg', > :price => 1234.56, > :title => 'a test product' > } > end > end > > describe Product do > > include ProductSpecHelper > > before(:each) do > @product = Product.new > end > > it "should have a title" do > @product.attributes = valid_product_attributes.except(:title) > @product.should have(1).error_on(:title) > @product.title = 'a test product' > @product.should be_valid > end > > it "should have a description" do > @product.attributes = valid_product_attributes.except(:description) > @product.should have(1).error_on(:description) > @product.description = 'a short description' > @product.should be_valid > end > > it "should have a valid image uri" > > end > <--- > > app/models/product.rb > > ---> > class Product < ActiveRecord::Base > > validates_presence_of :title > validates_presence_of :description > > end > <--- > > Specs pass: > ---> > C:\var\RSpec\depot>rake spec:models > (in C:/var/RSpec/depot) > NOTICE: CREATE TABLE will create implicit sequence "products_id_seq" for > serial column "products.id" > NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index > "products_pkey" for table "products" > > Product > - should have a valid image uri (PENDING: Not Yet Implemented) > - should have a description > - should have a title > > Pending: > Product should have a valid image uri (Not Yet Implemented) > > Finished in 0.985 seconds > > 3 examples, 0 failures, 1 pending > <--- > > Spec fails: (I changed the .should be_valid to .should_not be_valid) > > ---> > C:\var\RSpec\depot>rake spec:models --trace > (in C:/var/RSpec/depot) > ** Invoke spec:models (first_time) > ** Invoke db:test:prepare (first_time) > ** Invoke environment (first_time) > ** Execute environment > ** Execute db:test:prepare > ** Invoke db:test:clone (first_time) > ** Invoke db:schema:dump (first_time) > ** Invoke environment > ** Execute db:schema:dump > ** Invoke db:test:purge (first_time) > ** Invoke environment > ** Execute db:test:purge > ** Execute db:test:clone > ** Invoke db:schema:load (first_time) > ** Invoke environment > ** Execute db:schema:load > NOTICE: CREATE TABLE will create implicit sequence "products_id_seq" for > serial column "products.id" > NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index > "products_pkey" for table "products" > ** Execute spec:models > > Product > - should have a valid image uri (PENDING: Not Yet Implemented) > - should have a description (FAILED - 1) > - should have a title > > Pending: > Product should have a valid image uri (Not Yet Implemented) > > 1) > 'Product should have a description' FAILED > expected valid? to return false, got true > ./spec/models/product_spec.rb:35: > > Finished in 1.266 seconds > > 3 examples, 1 failure, 1 pending > rake aborted! > Command ruby -I > "C:/var/RSpec/depot/vendor/plugins/rspec/lib" > "C:/var/RSpec/depot/vendor/plugins/rspec/bin/spec" > "spec/models/product_spec.rb" > --options > "C:/var/RSpec/depot/config/../spec/spec.opts" > failed > > C:/var/RSpec/depot/vendor/plugins/rspec/lib/spec/rake/ > spectask.rb:173:in `define' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:823:in `verbose' > C:/var/RSpec/depot/vendor/plugins/rspec/lib/spec/rake/ > spectask.rb:142:in `define' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:392:in `call' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:392:in `execute' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:392:in `each' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:392:in `execute' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:362:in `invoke' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:355:in `synchronize' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:355:in `invoke' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1739:in `top_level' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1739:in `each' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1739:in `top_level' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1761:in `standard_exception_handling' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1733:in `top_level' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1711:in `run' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1761:in `standard_exception_handling' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1708:in `run' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 > C:/usr/local/bin/ruby/bin/rake.bat:20:in `load' > C:/usr/local/bin/ruby/bin/rake.bat:20 Failed expectations are implemented using exceptions, so naturally if you use --trace then rake will print a backtrace. If you don't want it, don't use --trace. Pat From byrnejb at harte-lyne.ca Sat Nov 24 23:15:26 2007 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Sat, 24 Nov 2007 23:15:26 -0500 (EST) Subject: [rspec-users] [UNSOLVED] Possible Problem with RSpec In-Reply-To: <60364.65.92.50.109.1195957379.squirrel@webmail.harte-lyne.ca> References: <60213.65.92.50.109.1195951693.squirrel@webmail.harte-lyne.ca> <60333.65.92.50.109.1195955319.squirrel@webmail.harte-lyne.ca> <60364.65.92.50.109.1195957379.squirrel@webmail.harte-lyne.ca> Message-ID: <61572.65.92.50.109.1195964126.squirrel@webmail.harte-lyne.ca> On Sat Nov 24 21:54:58 EST 2007, Pat Maddox pergesu at gmail.com wrote: > Failed expectations are implemented using exceptions, so naturally > if you use --trace then rake will print a backtrace. If you don't > want it, don't use --trace. I do not care about the presence or absence of a trace. What I want to know is why I get a rake failure if one of the specs fail. Surely a specification failure is an expected outcome for at last some of the trials. RSpec should just report that fact and let rake exit cleanly. I ran the previous trial with --trace just to avoid having someone write "please provide a trace". ---> C:\var\RSpec\depot>rake spec:models (in C:/var/RSpec/depot) NOTICE: CREATE TABLE will create implicit sequence "products_id_seq" for serial column "products.id" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "products_pkey" f or table "products" Product - should have a valid image url (FAILED - 1) - should have a description - should have a title 1) 'Product should have a valid image url' FAILED expected 1 error on :image_url, got 0 ./spec/models/product_spec.rb:40: Finished in 0.922 seconds 3 examples, 1 failure rake aborted! Command ruby -I"C:/var/RSpec/depot/vendor/plugins/rspec/lib" "C:/var/RSpec/depot/vendor/plugins/rspec/bin/spec" "spec/models/product_spec.rb" --options "C:/var/RSpec/depot/config/../spec/spec.opts" failed (See full trace by running task with --trace) <--- -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From byrnejb at harte-lyne.ca Sat Nov 24 23:24:25 2007 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Sat, 24 Nov 2007 23:24:25 -0500 (EST) Subject: [rspec-users] [UNSOLVED] Possible Problem with RSpec In-Reply-To: <61572.65.92.50.109.1195964126.squirrel@webmail.harte-lyne.ca> References: <60213.65.92.50.109.1195951693.squirrel@webmail.harte-lyne.ca> <60333.65.92.50.109.1195955319.squirrel@webmail.harte-lyne.ca> <60364.65.92.50.109.1195957379.squirrel@webmail.harte-lyne.ca> <61572.65.92.50.109.1195964126.squirrel@webmail.harte-lyne.ca> Message-ID: <61654.65.92.50.109.1195964665.squirrel@webmail.harte-lyne.ca> On Sat, November 24, 2007 23:15, James B. Byrne wrote: > I do not care about the presence or absence of a trace. What I want to > know is why I get a rake failure if one of the specs fail. Surely a > specification failure is an expected outcome for at last some of the > trials. RSpec should just report that fact and let rake exit cleanly. I > ran the previous trial with --trace just to avoid having someone write > "please provide a trace". > Anyhow, This is the code that is causing rake to whine at me. So where does fail_on_error get set? Is this a configurable option? spectask.rb ---> 171 unless system(cmd) 172 STDERR.puts failure_message if failure_message 173 raise("Command #{cmd} failed") if fail_on_error 174 end <--- -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From byrnejb at harte-lyne.ca Sat Nov 24 23:31:50 2007 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Sat, 24 Nov 2007 23:31:50 -0500 (EST) Subject: [rspec-users] [UNSOLVED] Possible Problem with RSpec In-Reply-To: <61654.65.92.50.109.1195964665.squirrel@webmail.harte-lyne.ca> References: <60213.65.92.50.109.1195951693.squirrel@webmail.harte-lyne.ca> <60333.65.92.50.109.1195955319.squirrel@webmail.harte-lyne.ca> <60364.65.92.50.109.1195957379.squirrel@webmail.harte-lyne.ca> <61572.65.92.50.109.1195964126.squirrel@webmail.harte-lyne.ca> <61654.65.92.50.109.1195964665.squirrel@webmail.harte-lyne.ca> Message-ID: <61925.65.92.50.109.1195965110.squirrel@webmail.harte-lyne.ca> On Sat, November 24, 2007 23:24, James B. Byrne wrote: > > > Anyhow, This is the code that is causing rake to whine at me. So where > does fail_on_error get set? Is this a configurable option? > This entire issue is discussed at length here: http://rubyforge.org/pipermail/rspec-devel/2007-June/003048.html Rake's exit is the expected behaviour if a test fails. I presume this allows automated build systems to detect a failing test suite since it provides no evident value for a human observer. Regards, -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From dchelimsky at gmail.com Sun Nov 25 07:35:03 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 25 Nov 2007 06:35:03 -0600 Subject: [rspec-users] 'it' duplicate example: BUG In-Reply-To: <31D37238-DCE6-409F-B205-1125089ED321@railsnewbie.com> References: <95A4BD3A-C34F-497A-976F-BD52CB26F415@railsnewbie.com> <8d961d900711211217k4e4e77a6tb524b417e751527e@mail.gmail.com> <31D37238-DCE6-409F-B205-1125089ED321@railsnewbie.com> Message-ID: <57c63afe0711250435h472db4b4hef28fe7aad73d4be@mail.gmail.com> On Nov 24, 2007 7:47 PM, Scott Taylor wrote: > > On Nov 21, 2007, at 3:17 PM, aslak hellesoy wrote: > > > On 11/21/07, Chad Humphries wrote: > >> One of the recent trunk changesets modified the default behaviour to > >> fail fast if duplicate examples are detected within a single > >> behaviour/ > >> example group. This is basically letting you know you have to "it" > >> blocks in the behaviour with the same description. > >> > > > > This is correct. It's not a bug - it's by design and documented in > > CHANGES. > > > > The reason I put it in has an interesting explanation. Over the past > > few days our coverage dropped from 100% to 99.9% and we couldn't > > understand why. RCov reported that some code wasn't being covered, but > > I *knew* there were examples covering it. > > > > Something was fishy. > > > > Then I remembered that Brian a few days ago did a change to the > > internals - every it block now creates a method with the same name as > > the description, and later calls that method to run the example. > > Nothing wrong with that, but it had some sideeffects we didn't think > > about: If there were duplicates, the last one would simply overwrite > > (monkey patch!) the previous one with the same name. And as a result > > never get run. > > > > Since I'm a fail fast kind of guy I made RSpec do that. > > In light of the duplicate examples which would come about with the > following: > > it do > foo.should == bar > end > > - how about providing the behaviour described above as an option to > the runner? I'm not sure what you mean. Please give an example. > > > Scott > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sun Nov 25 07:49:36 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 25 Nov 2007 06:49:36 -0600 Subject: [rspec-users] 'it' duplicate example: BUG In-Reply-To: <8d961d900711211217k4e4e77a6tb524b417e751527e@mail.gmail.com> References: <95A4BD3A-C34F-497A-976F-BD52CB26F415@railsnewbie.com> <8d961d900711211217k4e4e77a6tb524b417e751527e@mail.gmail.com> Message-ID: <57c63afe0711250449y221a2db5w7ef11757cd59588c@mail.gmail.com> On Nov 21, 2007 2:17 PM, aslak hellesoy wrote: > Then I remembered that Brian a few days ago did a change to the > internals - every it block now creates a method with the same name as > the description, and later calls that method to run the example. FYI - this ended up causing a couple of problems so we undid it. One problem was that it broke auto-generated names: it { @result.should == 37 } The other problem has to do with nested example groups, which is a feature that we are adding for 1.1.0. Cheers, David From philodespotos at gmail.com Sun Nov 25 10:23:38 2007 From: philodespotos at gmail.com (Kyle Hargraves) Date: Sun, 25 Nov 2007 09:23:38 -0600 Subject: [rspec-users] namespaced controllers In-Reply-To: References: <60f3810c0711231427w1c6804b2v5e1575012c885431@mail.gmail.com> Message-ID: <60f3810c0711250723l114cc668rffa93396f8ace9c3@mail.gmail.com> On Nov 23, 2007 11:53 PM, Scott Taylor wrote: > I got an "unknown action foo" error message (wasn't getting it before > today - running on trunk). > > > Scott Can you reproduce it reliably? I had an Admin::SomeController controller, and the specs were passing fine. I went to add ::SomeController, and the new specs for it passed, but Admin::SomeController started raising UnknownAction (for all the actions that weren't defined in the non-admin controller). But once I restarted autotest, they're passing cleanly, and now I can't seem to reproduce it at all. Kyle From philodespotos at gmail.com Sun Nov 25 11:48:38 2007 From: philodespotos at gmail.com (Kyle Hargraves) Date: Sun, 25 Nov 2007 10:48:38 -0600 Subject: [rspec-users] namespaced controllers In-Reply-To: <60f3810c0711250723l114cc668rffa93396f8ace9c3@mail.gmail.com> References: <60f3810c0711231427w1c6804b2v5e1575012c885431@mail.gmail.com> <60f3810c0711250723l114cc668rffa93396f8ace9c3@mail.gmail.com> Message-ID: <60f3810c0711250848wc4afd59v18f6d0c1a8657de5@mail.gmail.com> On Nov 25, 2007 9:23 AM, Kyle Hargraves wrote: > On Nov 23, 2007 11:53 PM, Scott Taylor wrote: > > I got an "unknown action foo" error message (wasn't getting it before > > today - running on trunk). > > > > > > Scott > > Can you reproduce it reliably? > > I had an Admin::SomeController controller, and the specs were passing > fine. I went to add ::SomeController, and the new specs for it passed, > but Admin::SomeController started raising UnknownAction (for all the > actions that weren't defined in the non-admin controller). > > But once I restarted autotest, they're passing cleanly, and now I > can't seem to reproduce it at all. Figured out how to reproduce it. It depends on load order, I guess. Given the files: spec/controllers/foo_controller_spec.rb spec/controllers/admin/foo_controller_spec.rb The specs do nothing but hit the FooController#show and Admin::FooController#index actions and expect the right render. If I touch admin/foo_controller_spec.rb, the specs pass. If I touch foo_controller_spec.rb, the specs for Admin::FooController fail with UnknownAction exceptions, since ::FooController has no index action defined. Problem occurs with autotest and rake spec, but not with ./script/spec spec. This is happening with the current latest trunk versions, rails r8200 and rspec r2980. Kyle From daniel.ruby at tenner.org Sun Nov 25 12:41:38 2007 From: daniel.ruby at tenner.org (Daniel Tenner) Date: Sun, 25 Nov 2007 17:41:38 +0000 Subject: [rspec-users] Rails sessions in plain text stories Message-ID: Ok, maybe I'm being particularly thick, but I've been trying to find the solution to this for a couple of hours now and I just can't seem to be able to do it... I'm trying to write a step as such: Given("user $email is logged in") do |email| user = User.find_by_email(email) session[:user_id] = user.id end This is the way it would look in specs... but all I seem to be getting, depending on whether I write it as @session, @controller.session, session, request.session, @request.session, etc... is errors like: NoMethodError: You have a nil object when you didn't expect it! The error occurred while evaluating nil.session ./matchers/navigation_steps.rb:4:in `user $email is logged in' Or variations such as: NoMethodError: 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.[]= ./matchers/navigation_steps.rb:4:in `user $email is logged in' ... What am I doing wrong? I've for the time being gotten around this problem (thanks to pd's suggestion on #rspec) by making the spec run through the sign up and email confirmation process, which does sign in the user into the session... but that seems a little over-verbose?) Any help would be most welcome. Daniel From jarkko at jlaine.net Sun Nov 25 12:52:35 2007 From: jarkko at jlaine.net (Jarkko Laine) Date: Sun, 25 Nov 2007 19:52:35 +0200 Subject: [rspec-users] Rails sessions in plain text stories In-Reply-To: References: Message-ID: <2FD7AD1D-7ECD-4109-980A-337FB7930580@jlaine.net> On 25.11.2007, at 19.41, Daniel Tenner wrote: > ... What am I doing wrong? > > I've for the time being gotten around this problem (thanks to pd's > suggestion on #rspec) by making the spec run through the sign up and > email confirmation process, which does sign in the user into the > session... but that seems a little over-verbose?) Why through the whole process, wouldn't logging in be enough, since you create the user in the story code? I currently do that, because I want to test the whole stack in my stories, including the login process. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi From dchelimsky at gmail.com Sun Nov 25 13:21:42 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 25 Nov 2007 12:21:42 -0600 Subject: [rspec-users] Rails sessions in plain text stories In-Reply-To: References: Message-ID: <57c63afe0711251021t1dde252dxf55490504c165f45@mail.gmail.com> On Nov 25, 2007 11:41 AM, Daniel Tenner wrote: > Ok, maybe I'm being particularly thick, but I've been trying to find > the solution to this for a couple of hours now and I just can't seem > to be able to do it... > > I'm trying to write a step as such: > > Given("user $email is logged in") do |email| > user = User.find_by_email(email) > session[:user_id] = user.id > end > > This is the way it would look in specs... but all I seem to be > getting, depending on whether I write it as @session, > @controller.session, session, request.session, @request.session, > etc... is errors like: > > NoMethodError: You have a nil object when you didn't expect it! > The error occurred while evaluating nil.session > ./matchers/navigation_steps.rb:4:in `user $email is logged in' > > Or variations such as: > > NoMethodError: 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.[]= > ./matchers/navigation_steps.rb:4:in `user $email is logged in' > > ... What am I doing wrong? You are trying to access something to which you have no direct access. RailsStory wraps rails integration tests. You can read more about them here: http://weblog.jamisbuck.org/2006/3/9/integration-testing-in-rails-1-1. > > I've for the time being gotten around this problem (thanks to pd's > suggestion on #rspec) by making the spec run through the sign up and > email confirmation process, which does sign in the user into the > session... but that seems a little over-verbose?) > > Any help would be most welcome. > > Daniel > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mailing_lists at railsnewbie.com Sun Nov 25 13:43:28 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 25 Nov 2007 13:43:28 -0500 Subject: [rspec-users] namespaced controllers In-Reply-To: <60f3810c0711250848wc4afd59v18f6d0c1a8657de5@mail.gmail.com> References: <60f3810c0711231427w1c6804b2v5e1575012c885431@mail.gmail.com> <60f3810c0711250723l114cc668rffa93396f8ace9c3@mail.gmail.com> <60f3810c0711250848wc4afd59v18f6d0c1a8657de5@mail.gmail.com> Message-ID: <2BC42D14-A430-4C78-8A0E-2CAD4A8CAED4@railsnewbie.com> > > Figured out how to reproduce it. It depends on load order, I guess. > > Given the files: > spec/controllers/foo_controller_spec.rb > spec/controllers/admin/foo_controller_spec.rb > > The specs do nothing but hit the FooController#show and > Admin::FooController#index actions and expect the right render. > > If I touch admin/foo_controller_spec.rb, the specs pass. > > If I touch foo_controller_spec.rb, the specs for Admin::FooController > fail with UnknownAction exceptions, since ::FooController has no index > action defined. > > Problem occurs with autotest and rake spec, but not with ./script/ > spec spec. > > This is happening with the current latest trunk versions, rails r8200 > and rspec r2980. Can you put this in the tracker? I'm likely to forget about it otherwise. Scott From mailing_lists at railsnewbie.com Sun Nov 25 13:54:18 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 25 Nov 2007 13:54:18 -0500 Subject: [rspec-users] 'it' duplicate example: BUG In-Reply-To: <57c63afe0711250435h472db4b4hef28fe7aad73d4be@mail.gmail.com> References: <95A4BD3A-C34F-497A-976F-BD52CB26F415@railsnewbie.com> <8d961d900711211217k4e4e77a6tb524b417e751527e@mail.gmail.com> <31D37238-DCE6-409F-B205-1125089ED321@railsnewbie.com> <57c63afe0711250435h472db4b4hef28fe7aad73d4be@mail.gmail.com> Message-ID: <6460EDBD-6257-4C09-9C15-F0761249EFFA@railsnewbie.com> On Nov 25, 2007, at 7:35 AM, David Chelimsky wrote: > On Nov 24, 2007 7:47 PM, Scott Taylor > wrote: >> >> On Nov 21, 2007, at 3:17 PM, aslak hellesoy wrote: >> >>> On 11/21/07, Chad Humphries wrote: >>>> One of the recent trunk changesets modified the default >>>> behaviour to >>>> fail fast if duplicate examples are detected within a single >>>> behaviour/ >>>> example group. This is basically letting you know you have to >>>> "it" >>>> blocks in the behaviour with the same description. >>>> >>> >>> This is correct. It's not a bug - it's by design and documented in >>> CHANGES. >>> >>> The reason I put it in has an interesting explanation. Over the past >>> few days our coverage dropped from 100% to 99.9% and we couldn't >>> understand why. RCov reported that some code wasn't being >>> covered, but >>> I *knew* there were examples covering it. >>> >>> Something was fishy. >>> >>> Then I remembered that Brian a few days ago did a change to the >>> internals - every it block now creates a method with the same >>> name as >>> the description, and later calls that method to run the example. >>> Nothing wrong with that, but it had some sideeffects we didn't think >>> about: If there were duplicates, the last one would simply overwrite >>> (monkey patch!) the previous one with the same name. And as a result >>> never get run. >>> >>> Since I'm a fail fast kind of guy I made RSpec do that. >> >> In light of the duplicate examples which would come about with the >> following: >> >> it do >> foo.should == bar >> end >> >> - how about providing the behaviour described above as an option to >> the runner? > > I'm not sure what you mean. Please give an example. I was saying that we should have the --no-duplicate options to the runner, which would raise an error when it encountered a duplicate example. It might be useful occasionally (for my test suite of 1400 specs, it found three duplicates, which would be pretty hard to fish out otherwise). Scott From brian.takita at gmail.com Sun Nov 25 19:20:28 2007 From: brian.takita at gmail.com (Brian Takita) Date: Sun, 25 Nov 2007 16:20:28 -0800 Subject: [rspec-users] Renaming RailsExample to RailsExampleGroup Message-ID: <1d7ddd110711251620qc365774vf90d55987421d414@mail.gmail.com> Fyi, I made the following renames: * RailsExample -> RailsExampleGroup * FunctionalExample -> FunctionalExampleGroup * ControllerExample -> ControllerExampleGroup * ViewExample -> ViewExampleGroup * HelperExample -> HelperExampleGroup * ModelExample -> ModelExampleGroup This was done to keep the naming consistent with ExampleGroup. From lists at ruby-forum.com Mon Nov 26 04:52:19 2007 From: lists at ruby-forum.com (Brad Umbaugh) Date: Mon, 26 Nov 2007 10:52:19 +0100 Subject: [rspec-users] rSpec (rev 2996), Rails (rev 8214): TextMate bundle problems Message-ID: <8b56784f6b31a0b0a5a7f53b251d78be@ruby-forum.com> Hey guys, I'm trying to get rSpec (rev 2996) working with Rails 2 (rev 8214). Running the tests from the command line works, no problem. I installed the RSpec.tmbundle (also rev 2996), and would like to see the HTML test results in TextMate. When I run the "Run examples in selected files/directories" command in TextMate, I get the following dump: ----------------------------------- RubyMate r8136 running Ruby r1.8.5 (/usr/local/bin/ruby) >>> tiger_spec.rb /usr/local/lib/ruby/gems/1.8/gems/builder-2.1.2/lib/blankslate.rb:84:in `blank_slate_method_added': stack level too deep (SystemStackError) from /usr/local/lib/ruby/gems/1.8/gems/builder-2.1.2/lib/blankslate.rb:84:in `blank_slate_method_added' from /Applications/TextMate.app/Contents/SharedSupport/Support/lib/builder.rb:86:in `method_added' from /Applications/TextMate.app/Contents/SharedSupport/Support/lib/builder.rb:111 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from /Users/Brad/dev/ws/fb3ws/test/bradtest/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/array/conversions.rb:1 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' ... 19 levels... from /Users/Brad/dev/ws/fb3ws/test/bradtest/spec/models/../spec_helper.rb:4:in `require' from /Users/Brad/dev/ws/fb3ws/test/bradtest/spec/models/../spec_helper.rb:4 from /Users/Brad/dev/ws/fb3ws/test/bradtest/spec/models/tiger_spec.rb:1:in `require' from /Users/Brad/dev/ws/fb3ws/test/bradtest/spec/models/tiger_spec.rb:1 /usr/local/lib/ruby/gems/1.8/gems/builder-2.1.2/lib/blankslate.rb:84:in `blank_slate_method_added': stack level too deep (SystemStackError) from /usr/local/lib/ruby/gems/1.8/gems/builder-2.1.2/lib/blankslate.rb:84:in `blank_slate_method_added' from /Applications/TextMate.app/Contents/SharedSupport/Support/lib/builder.rb:86:in `method_added' from /Applications/TextMate.app/Contents/SharedSupport/Support/lib/builder.rb:111 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from /Users/Brad/dev/ws/fb3ws/test/bradtest/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/array/conversions.rb:1 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' ... 19 levels... from /Users/Brad/dev/ws/fb3ws/test/bradtest/spec/models/../spec_helper.rb:4:in `require' from /Users/Brad/dev/ws/fb3ws/test/bradtest/spec/models/../spec_helper.rb:4 from /Users/Brad/dev/ws/fb3ws/test/bradtest/spec/models/tiger_spec.rb:1:in `require' from /Users/Brad/dev/ws/fb3ws/test/bradtest/spec/models/tiger_spec.rb:1 Program exited. ----------------------------------- Anybody know why this is? I did see this post on the Macromates site: http://macromates.com/ticket/show?ticket_id=F4DA8B03 Adding his suggested "$:.reject! { |e| e.include? 'TextMate' }" line at the top of my tiger_spec.rb document yields the following errors when the same TextMate command is run: ----------------------------------- RubyMate r8136 running Ruby r1.8.5 (/usr/local/bin/ruby) >>> tiger_spec.rb /Users/Brad/dev/ws/fb3ws/test/bradtest/vendor/plugins/rspec/lib/spec/runner/options.rb:208:in `files_to_load': File or directory not found: [, (RuntimeError) from /Users/Brad/dev/ws/fb3ws/test/bradtest/vendor/plugins/rspec/lib/spec/runner/options.rb:202:in `each' from /Users/Brad/dev/ws/fb3ws/test/bradtest/vendor/plugins/rspec/lib/spec/runner/options.rb:202:in `files_to_load' from /Users/Brad/dev/ws/fb3ws/test/bradtest/vendor/plugins/rspec/lib/spec/runner/options.rb:81:in `run_examples' from /Users/Brad/dev/ws/fb3ws/test/bradtest/vendor/plugins/rspec/lib/spec.rb:22:in `run' from /Users/Brad/dev/ws/fb3ws/test/bradtest/vendor/plugins/rspec/lib/spec.rb:36 from /Users/Brad/dev/ws/fb3ws/test/bradtest/spec/models/tiger_spec.rb:5 RuntimeError: File or directory not found: [, method files_to_load in options.rb at line 208 method each in options.rb at line 202 method files_to_load in options.rb at line 202 method run_examples in options.rb at line 81 method run in spec.rb at line 22 at top level in spec.rb at line 36 at top level in tiger_spec.rb at line 5 Program exited. ----------------------------------- Anyone know how to get this working? Thanks for any help... Brad -- Posted via http://www.ruby-forum.com/. From daniel.ruby at tenner.org Mon Nov 26 12:50:50 2007 From: daniel.ruby at tenner.org (Daniel Tenner) Date: Mon, 26 Nov 2007 17:50:50 +0000 Subject: [rspec-users] Latest update - broken be_matchers? In-Reply-To: <1d7ddd110711251620qc365774vf90d55987421d414@mail.gmail.com> References: <1d7ddd110711251620qc365774vf90d55987421d414@mail.gmail.com> Message-ID: <464A13D3-2956-4FBF-9498-23714DD2CC1F@tenner.org> Just seven upped the latest rspec update, and suddenly all my be_matchers don't work anymore (they worked just before I updated): User.find_by_email(email).should_not be_confirmed User.find_by_email(email).confirmation_code.should_not be_nil >> FAILURES: 1) confirmation (Receives confirmation link) FAILED NoMethodError: undefined method `be_nil' for # 3) confirmation (Clicks correct confirmation link) FAILED NoMethodError: undefined method `be_confirmed' for # Anyone else getting that? Daniel From byrnejb at harte-lyne.ca Mon Nov 26 12:56:30 2007 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Mon, 26 Nov 2007 12:56:30 -0500 (EST) Subject: [rspec-users] Setting fail_on_error Message-ID: <47821.216.185.71.22.1196099790.squirrel@webmail.harte-lyne.ca> For the default setup of RSpec is there a way to set the fail_on_error instance variable to false from outside of spectask.rb? I am not familiar enough with either ruby or rails to figure this out from the information provided. I realize that there is a fail_on_error= method but I do not know what to call the receiver. I would like to do this globally without having to modify spectask.rb locally. Regards, -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From joshknowles at gmail.com Mon Nov 26 12:57:37 2007 From: joshknowles at gmail.com (Josh Knowles) Date: Mon, 26 Nov 2007 12:57:37 -0500 Subject: [rspec-users] Latest update - broken be_matchers? In-Reply-To: <464A13D3-2956-4FBF-9498-23714DD2CC1F@tenner.org> References: <1d7ddd110711251620qc365774vf90d55987421d414@mail.gmail.com> <464A13D3-2956-4FBF-9498-23714DD2CC1F@tenner.org> Message-ID: On 11/26/07, Daniel Tenner wrote: > Just seven upped the latest rspec update, and suddenly all my > be_matchers don't work anymore (they worked just before I updated): > Anyone else getting that? All of my controller specs are passing, but my stories are failing with the same error. This works: response.success?.should == true This doesn't: response.should be_success -- Josh Knowles phone: 509-979-1593 email: joshknowles at gmail.com web: http://joshknowles.com From dchelimsky at gmail.com Mon Nov 26 13:27:59 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 26 Nov 2007 12:27:59 -0600 Subject: [rspec-users] Latest update - broken be_matchers? In-Reply-To: References: <1d7ddd110711251620qc365774vf90d55987421d414@mail.gmail.com> <464A13D3-2956-4FBF-9498-23714DD2CC1F@tenner.org> Message-ID: <57c63afe0711261027x3ca447b6q9715f7981768f35a@mail.gmail.com> On Nov 26, 2007 11:57 AM, Josh Knowles wrote: > On 11/26/07, Daniel Tenner wrote: > > Just seven upped the latest rspec update, and suddenly all my > > be_matchers don't work anymore (they worked just before I updated): > > > > > Anyone else getting that? > > All of my controller specs are passing, but my stories are failing > with the same error. > > This works: > response.success?.should == true > > This doesn't: > response.should be_success Actually I'm surprised these were ever working as RailsStory doesn't include Spec::Matchers - just Spec::Rails::Matchers. The matchers must have been making their way in through the back door. I won't have time to look at this until tonight, but feel free to submit a patch in the mean time if you can figure it out. Cheers, David > > -- > Josh Knowles > phone: 509-979-1593 > email: joshknowles at gmail.com > web: http://joshknowles.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From daniel.ruby at tenner.org Mon Nov 26 14:09:26 2007 From: daniel.ruby at tenner.org (Daniel Tenner) Date: Mon, 26 Nov 2007 19:09:26 +0000 Subject: [rspec-users] Latest update - broken be_matchers? In-Reply-To: <57c63afe0711261027x3ca447b6q9715f7981768f35a@mail.gmail.com> References: <1d7ddd110711251620qc365774vf90d55987421d414@mail.gmail.com> <464A13D3-2956-4FBF-9498-23714DD2CC1F@tenner.org> <57c63afe0711261027x3ca447b6q9715f7981768f35a@mail.gmail.com> Message-ID: First time I have a look inside the RSpec codebase (let alone the Story Runner), and not much luck this time. But, counter-intuitively enough, I think it's probably nothing to do with RailsStory itself since that didn't change in the last update. Trying to add an include Spec::Matchers in there also didn't help. Couldn't quite figure it out though. Too much to absorb in a single sitting. I'd love to know what it was when someone figures it out though. Daniel On 26 Nov 2007, at 18:27 26 Nov 2007, David Chelimsky wrote: > On Nov 26, 2007 11:57 AM, Josh Knowles wrote: >> On 11/26/07, Daniel Tenner wrote: >>> Just seven upped the latest rspec update, and suddenly all my >>> be_matchers don't work anymore (they worked just before I updated): >> >> >> >>> Anyone else getting that? >> >> All of my controller specs are passing, but my stories are failing >> with the same error. >> >> This works: >> response.success?.should == true >> >> This doesn't: >> response.should be_success > > Actually I'm surprised these were ever working as RailsStory doesn't > include Spec::Matchers - just Spec::Rails::Matchers. The matchers must > have been making their way in through the back door. > > I won't have time to look at this until tonight, but feel free to > submit a patch in the mean time if you can figure it out. > > Cheers, > David > >> >> -- >> Josh Knowles >> phone: 509-979-1593 >> email: joshknowles at gmail.com >> web: http://joshknowles.com >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From daniel.ruby at tenner.org Mon Nov 26 14:15:36 2007 From: daniel.ruby at tenner.org (Daniel Tenner) Date: Mon, 26 Nov 2007 19:15:36 +0000 Subject: [rspec-users] Latest update - broken be_matchers? In-Reply-To: References: <1d7ddd110711251620qc365774vf90d55987421d414@mail.gmail.com> <464A13D3-2956-4FBF-9498-23714DD2CC1F@tenner.org> <57c63afe0711261027x3ca447b6q9715f7981768f35a@mail.gmail.com> Message-ID: <539B49A8-2021-4657-BB48-41A1147B62E0@tenner.org> These are the files that got modified in between. Revision 2994 has the matchers working. Reversing to 2994 highlighted these files: danieltenner at danbook:~/Sites/xxx.local/xxx/rails/trunk/vendor/plugins/ rspec$ svn up -r 2995 D stories/example_groups/nested_groups D stories/resources/spec/nested_group_spec.rb U stories/resources/steps/running_rspec.rb Updated to revision 2995. danieltenner at danbook:~/Sites/xxx.local/xxx/rails/trunk/vendor/plugins/ rspec$ cd .. danieltenner at danbook:~/Sites/xxx.local/xxx/rails/trunk/vendor/plugins $ cd rspec_on_rails/ danieltenner at danbook:~/Sites/xxx.local/xxx/rails/trunk/vendor/plugins/ rspec_on_rails$ svn up -r 2995 At revision 2995. danieltenner at danbook:~/Sites/xxx.local/xxx/rails/trunk/vendor/plugins/ rspec_on_rails$ svn up -r 2994 U lib/spec/rails/version.rb A lib/spec/rails/example/behaviour/functional_example.rb A lib/spec/rails/example/behaviour/controller_example.rb U lib/spec/rails/example/behaviour/rails_example_group.rb A lib/spec/rails/example/behaviour/rails_example.rb A lib/spec/rails/example/behaviour/view_example.rb A lib/spec/rails/example/behaviour/helper_example.rb A lib/spec/rails/example/behaviour/model_example.rb Updated to revision 2994. danieltenner at danbook:~/Sites/xxx.local/xxx/rails/trunk/vendor/plugins/ rspec_on_rails$ cd ../rspec danieltenner at danbook:~/Sites/xxx.local/xxx/rails/trunk/vendor/plugins/ rspec$ svn up -r 2994 U stories/resources/test/test_case_with_should_methods.rb U stories/resources/test/spec_and_test_together.rb D lib/spec/interop/test/unit/testcase.rb A lib/spec/interop/test/unit/example_group.rb U lib/spec/interop/test.rb U lib/spec/version.rb U lib/spec.rb Updated to revision 2994. After svn-down-ing to 2994, be_nil works in my stories again. Hope this helps someone :-) Daniel On 26 Nov 2007, at 19:09 26 Nov 2007, Daniel Tenner wrote: > First time I have a look inside the RSpec codebase (let alone the > Story Runner), and not much luck this time. But, counter-intuitively > enough, I think it's probably nothing to do with RailsStory itself > since that didn't change in the last update. Trying to add an include > Spec::Matchers in there also didn't help. > > Couldn't quite figure it out though. Too much to absorb in a single > sitting. > > I'd love to know what it was when someone figures it out though. > > Daniel > > On 26 Nov 2007, at 18:27 26 Nov 2007, David Chelimsky wrote: > >> On Nov 26, 2007 11:57 AM, Josh Knowles wrote: >>> On 11/26/07, Daniel Tenner wrote: >>>> Just seven upped the latest rspec update, and suddenly all my >>>> be_matchers don't work anymore (they worked just before I updated): >>> >>> >>> >>>> Anyone else getting that? >>> >>> All of my controller specs are passing, but my stories are failing >>> with the same error. >>> >>> This works: >>> response.success?.should == true >>> >>> This doesn't: >>> response.should be_success >> >> Actually I'm surprised these were ever working as RailsStory doesn't >> include Spec::Matchers - just Spec::Rails::Matchers. The matchers >> must >> have been making their way in through the back door. >> >> I won't have time to look at this until tonight, but feel free to >> submit a patch in the mean time if you can figure it out. >> >> Cheers, >> David >> >>> >>> -- >>> Josh Knowles >>> phone: 509-979-1593 >>> email: joshknowles at gmail.com >>> web: http://joshknowles.com >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Mon Nov 26 14:16:43 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 26 Nov 2007 13:16:43 -0600 Subject: [rspec-users] Latest update - broken be_matchers? In-Reply-To: References: <1d7ddd110711251620qc365774vf90d55987421d414@mail.gmail.com> <464A13D3-2956-4FBF-9498-23714DD2CC1F@tenner.org> <57c63afe0711261027x3ca447b6q9715f7981768f35a@mail.gmail.com> Message-ID: <57c63afe0711261116y631d299dtf18c2d0cd4f37d6@mail.gmail.com> On Nov 26, 2007 1:09 PM, Daniel Tenner wrote: > First time I have a look inside the RSpec codebase (let alone the > Story Runner), and not much luck this time. But, counter-intuitively > enough, I think it's probably nothing to do with RailsStory itself > since that didn't change in the last update. Trying to add an include > Spec::Matchers in there also didn't help. > > Couldn't quite figure it out though. Too much to absorb in a single > sitting. > > I'd love to know what it was when someone figures it out though. I can tell you that what's been changing is the relationship between rspec and T/U. We're moving towards an interop model where rspec can run "pure" or can co-exist w/ Test::Unit when it is loaded. This will make it easier for us to also support miniunit when it ships w/ Ruby 1.9. My guess is that IntegrationTest, which I believe derives from Test::Unit::TestCase, was implicitly inheriting all of the matchers, but is not any longer due to something that changed under the hood. Since there were no stories or examples of rails stories, nothing broke. We'll have to add some of those :) Again - I'll look at this tonight and get it working. Cheers, David > > Daniel > > > On 26 Nov 2007, at 18:27 26 Nov 2007, David Chelimsky wrote: > > > On Nov 26, 2007 11:57 AM, Josh Knowles wrote: > >> On 11/26/07, Daniel Tenner wrote: > >>> Just seven upped the latest rspec update, and suddenly all my > >>> be_matchers don't work anymore (they worked just before I updated): > >> > >> > >> > >>> Anyone else getting that? > >> > >> All of my controller specs are passing, but my stories are failing > >> with the same error. > >> > >> This works: > >> response.success?.should == true > >> > >> This doesn't: > >> response.should be_success > > > > Actually I'm surprised these were ever working as RailsStory doesn't > > include Spec::Matchers - just Spec::Rails::Matchers. The matchers must > > have been making their way in through the back door. > > > > I won't have time to look at this until tonight, but feel free to > > submit a patch in the mean time if you can figure it out. > > > > Cheers, > > David > > > >> > >> -- > >> Josh Knowles > >> phone: 509-979-1593 > >> email: joshknowles at gmail.com > >> web: http://joshknowles.com > >> > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > >> > > _______________________________________________ > > 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 joshknowles at gmail.com Mon Nov 26 15:02:45 2007 From: joshknowles at gmail.com (Josh Knowles) Date: Mon, 26 Nov 2007 15:02:45 -0500 Subject: [rspec-users] Latest update - broken be_matchers? In-Reply-To: <57c63afe0711261116y631d299dtf18c2d0cd4f37d6@mail.gmail.com> References: <1d7ddd110711251620qc365774vf90d55987421d414@mail.gmail.com> <464A13D3-2956-4FBF-9498-23714DD2CC1F@tenner.org> <57c63afe0711261027x3ca447b6q9715f7981768f35a@mail.gmail.com> <57c63afe0711261116y631d299dtf18c2d0cd4f37d6@mail.gmail.com> Message-ID: On 11/26/07, David Chelimsky wrote: > Again - I'll look at this tonight and get it working. http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/147-patch-allow-stories-to-use-spec-matchers -- Josh Knowles phone: 509-979-1593 email: joshknowles at gmail.com web: http://joshknowles.com From dchelimsky at gmail.com Mon Nov 26 15:35:44 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 26 Nov 2007 14:35:44 -0600 Subject: [rspec-users] Latest update - broken be_matchers? In-Reply-To: References: <1d7ddd110711251620qc365774vf90d55987421d414@mail.gmail.com> <464A13D3-2956-4FBF-9498-23714DD2CC1F@tenner.org> <57c63afe0711261027x3ca447b6q9715f7981768f35a@mail.gmail.com> <57c63afe0711261116y631d299dtf18c2d0cd4f37d6@mail.gmail.com> Message-ID: <57c63afe0711261235j252f65b2q31ad42d3a4a60e9a@mail.gmail.com> On Nov 26, 2007 2:02 PM, Josh Knowles wrote: > On 11/26/07, David Chelimsky wrote: > > Again - I'll look at this tonight and get it working. > > http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/147-patch-allow-stories-to-use-spec-matchers Applied - thanks Josh! 7-up everyone. Cheers, David > > -- > > Josh Knowles > phone: 509-979-1593 > email: joshknowles at gmail.com > web: http://joshknowles.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From bryan at osesm.com Mon Nov 26 18:34:08 2007 From: bryan at osesm.com (Bryan Liles) Date: Mon, 26 Nov 2007 18:34:08 -0500 Subject: [rspec-users] custom matcher tutorial Message-ID: <5CD761B2-D476-4887-AE9A-D68EB5833DB3@osesm.com> I wrote some quick notes up on a custom matcher I wrote around a pattern that I am using constantly. http://smartic.us/2007/11/26/rspec-matcher-for-active-record-associations You could use it as a custom matcher tutorial for the uninitiated or as a possible solution for validations specs for the more advanced. Or you could use it to school me, and explain why my code sucks :) bryanl From daniel.ruby at tenner.org Tue Nov 27 11:13:38 2007 From: daniel.ruby at tenner.org (Daniel Tenner) Date: Tue, 27 Nov 2007 16:13:38 +0000 Subject: [rspec-users] Assumption tests In-Reply-To: <3BB7599A-01B5-47EF-8A14-62AB33BB7B23@tenner.org> References: <57c63afe0710190745j1c9f8846tfd5c7411f2941f0c@mail.gmail.com> <810a540e0710190929o7af20283s91216400fe69ccea@mail.gmail.com> <810a540e0710200909o1c65928dh923deaf3a7d7a7b7@mail.gmail.com> <57c63afe0710200934l5a910780y78580e5ba495c98d@mail.gmail.com> <72C6E5B6-F3B1-493A-BF11-4AB9C68E0754@tenner.org> <810a540e0710201154g42543607v12400f00ba121555@mail.gmail.com> <3BB7599A-01B5-47EF-8A14-62AB33BB7B23@tenner.org> Message-ID: <1B2240B4-5BAE-45E8-8509-AAA173D911D9@tenner.org> Just thought I'd post an update on this, since I promised Pat that I would :-) Ultra-detailed, "pure behaviour/interaction" specs the way I wanted to do them has turned out to be unproductive in the long run. The specs are too complex to write, and too hard to read, and the lack of refactoring tools that understand rspec means they actually hinder refactoring. Basically, they become essentially useless and a time- consuming hindrance. (yikes!) So, I'm now using a pragmatic middle-ground... I start off with the idea that the spec *is* actually an outcome test, but I use a lot of mocking whenever I feel I want it (for isolation purposes or when the object doesn't exist yet). This means a fair bit of "behaviour/ interaction" specification seeps in, but not so much as to take over completely like with my previous approach. In conclusion, you were right - my approach didn't work out. The extreme, "pure" approach doesn't work, and the best (quickest to write, easiest to read, and most useful to execute) I've found is a middle ground based on intuition and experience. Well, at least I'm definitely not afraid of mocking now :-) Thanks for the discussion last month! Daniel #swombat On 20 Oct 2007, at 23:49 20 Oct 2007, Daniel Tenner wrote: > On 20 Oct 2007, at 19:54 20 Oct 2007, Pat Maddox wrote: >> You seem to believe that the only way to define behavior is in terms >> of interactions with other objects. That is flat-out wrong. Please >> read http://martinfowler.com/articles/mocksArentStubs.html. > > Thanks for that excellent link. I hadn't read it yet. I need to think > some more :-) > > I think one of the reasons I've tended towards all-out behaviour > mocking is that when you start mocking expectations, you often break > outcome-based testing. As a good example, using another variation of > that Account object... > > class Account > def initialize(balance_holder) > @balance_holder = balance_holder > end > > def balance > @balance_holder.calculate_balance > end > > def withdraw(amount) > @balance_holder.decrease_by amount > end > end > > Now if @balance_holder is a pretty complex, slow object that cries > out to be mocked, trying to test in the way that you suggested breaks > down: > > it "should decrease the balance when an amount is withdrawn" do > @mock_balance_holder.should_receive(:decrease_by).with(100) > account = Account.new(@mock_balance_holder) > account.withdraw(100) > end > > In a case like this, it seems to me impossible to avoid specifying > only behaviour, unless you actually create a full-on fake object to > fake the behaviour of the balance_holder (which could be a bit less > trivial than this). But if you've mocked the balance_holder like > that, it is impossible to then test the state of the Account. > > I guess the issue comes from situations where the apparently internal > state of an object is dependent on the state of another object. In my > case, I have this happen fairly often when my facebook users, which > depend on a nasty, bug-eyed facebook_session object that I definitely > don't want to interact with in my specs (at least not with the real > version, which is horrendously slow and bug-prone due to various > facebook peculiarities). I don't think that's wrong design, but it > does mean that in those cases you can't use outcome-testing at all > (unless you are writing an integration test). > > I'm all for pragmatism but it kind of irks me that I'd have to test > behaviours in some cases and outcomes in others. I suppose neither of > them is black nor white, and David's suggestion that it's all down to > balancing design forces on a case-by-case basis... > > Maybe I should get back into maths, so I can have some absolute > truths again ;-) > > Thanks to everyone for the very useful discussion, by the way. This > is very helpful, and I'll try to summarize this thought progression > on my blog so that it's not lost... > > Daniel > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From cwdinfo at gmail.com Tue Nov 27 15:13:32 2007 From: cwdinfo at gmail.com (s.ross) Date: Tue, 27 Nov 2007 12:13:32 -0800 Subject: [rspec-users] Expectations on Class Methods Message-ID: <5D339716-2890-4793-A125-0FF88B905104@gmail.com> Sorry about the non-specific subject. Here's what I'm trying to do. I have a method: DataMapper::Database.setup That I want to create an expectation on. I wrote: DataMapper::Database.should_receive(:setup).once.and_return (connection_hash) The call to setup is invoked in the "Object" namespace. I.e., it is setup code, and not in any method or class. I can see that the class method is being called rather than the expectation. Is there something obvious I'm missing? Thanks, --s From mailing_lists at railsnewbie.com Tue Nov 27 15:23:33 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 27 Nov 2007 15:23:33 -0500 Subject: [rspec-users] Expectations on Class Methods In-Reply-To: <5D339716-2890-4793-A125-0FF88B905104@gmail.com> References: <5D339716-2890-4793-A125-0FF88B905104@gmail.com> Message-ID: On Nov 27, 2007, at 3:13 PM, s.ross wrote: > Sorry about the non-specific subject. Here's what I'm trying to do. I > have a method: > > DataMapper::Database.setup > > That I want to create an expectation on. I wrote: > > DataMapper::Database.should_receive(:setup).once.and_return > (connection_hash) > > The call to setup is invoked in the "Object" namespace. I.e., it is > setup code, and not in any method or class. Try using "load" to load the file *after* the expectation (not with require, before the expectation, as you would usually do). (see this blog post by Jay Fields, which is about validations, but uses the load trick: http://blog.jayfields.com/2006/12/rails-unit-testing- activerecord.html) Or, you could also do some sort of behaviour verification. What do you expect this DatabaseMapper setup should do? Why is it in your code? If you can answer these questions, then you can probably write a test for it (but without stubbing) Scott From cwdinfo at gmail.com Tue Nov 27 15:36:54 2007 From: cwdinfo at gmail.com (s.ross) Date: Tue, 27 Nov 2007 12:36:54 -0800 Subject: [rspec-users] Expectations on Class Methods In-Reply-To: References: <5D339716-2890-4793-A125-0FF88B905104@gmail.com> Message-ID: <15BEEA27-22DC-43C2-ABDF-7242EFF2292E@gmail.com> On Nov 27, 2007, at 12:23 PM, Scott Taylor wrote: > Or, you could also do some sort of behaviour verification. What do > you expect this DatabaseMapper setup should do? Why is it in your > code? If you can answer these questions, then you can probably write > a test for it (but without stubbing) Boy, don't I wish. Not my code, but I'd like to have a spec before I submit a patch. The DataMapper project is doing a great job of keeping specs parallel to their development, but the one thing they do is prepopulate a sqlite database prior to running all the tests. The bug I'm submitting a patch for is mysql-specific, and I'm at a loss how to un-sqliteize the environment without breaking all the other tests. I know tests should run in isolation, but again, not my specification suite. They optimized for quick runs of the specs, I guess. So, rather than spec the behavior, I'm opting to check whether setup is called with the right parameters. What I'd prefer is to do something more like: DataMapper::Database[:default].socket.should eql('/tmp/mysql.sock') which is the *behavior* I want. I'm not seeing how to get from here to there. The following is pretty much where I'm at, except that the expectation for :setup has a with(). I put out a ping to the DataMapper list, but so far no responses. module DataMapper class Database end end describe "setting up datamapper from a database.yml" do it "should look for database.yml" do File.stub!(:exists?).and_return(true) YAML.stub!(:load_file).and_return( "development"=>{ "socket"=>"/tmp/mysql.sock", "username"=>"root", "adapter"=>"mysql", "password"=>nil, "database"=>"fakedb_development"} ) DataMapper::Database.should_receive(:setup) Kernel::load File.dirname(__FILE__) + '/../lib/data_mapper.rb' end end From rps at salas.com Tue Nov 27 19:58:52 2007 From: rps at salas.com (Pito Salas) Date: Tue, 27 Nov 2007 19:58:52 -0500 Subject: [rspec-users] Newbie question Message-ID: I installed Rspec and am getting the following failure: $ sudo gem install rspec Successfully installed rspec-1.0.8 Installing ri documentation for rspec-1.0.8... Installing RDoc documentation for rspec-1.0.8... $ spec -v RSpec-1.0.8 (r2338) - BDD for Ruby http://rspec.rubyforge.org/ $ cat acct.rb describe Account, " when first created" do it "should have a balance of $0" do ... end end $ spec acct.rb /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/runner/ behaviour_runner.rb:106:in `load': ./acct.rb:3: syntax error, unexpected tDOT3 (SyntaxError) from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/ runner/behaviour_runner.rb:106:in `load_specs' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/ runner/behaviour_runner.rb:105:in `each' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/ runner/behaviour_runner.rb:105:in `load_specs' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/ runner/behaviour_runner.rb:49:in `prepare!' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/ runner/behaviour_runner.rb:19:in `run' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/ runner/command_line.rb:17:in `run' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/bin/spec:3 from /opt/local/bin/spec:16:in `load' from /opt/local/bin/spec:16 Must be a version or other config problem. Can anyone point me in the right direction? Thanks, Pito From has.sox at gmail.com Tue Nov 27 20:02:45 2007 From: has.sox at gmail.com (Daniel N) Date: Wed, 28 Nov 2007 12:02:45 +1100 Subject: [rspec-users] Newbie question In-Reply-To: References: Message-ID: <2fff50390711271702w500fff53h739180da37406348@mail.gmail.com> On Nov 28, 2007 11:58 AM, Pito Salas wrote: > I installed Rspec and am getting the following failure: > > $ sudo gem install rspec > Successfully installed rspec-1.0.8 > Installing ri documentation for rspec-1.0.8... > Installing RDoc documentation for rspec-1.0.8... > > $ spec -v > RSpec-1.0.8 (r2338) - BDD for Ruby > http://rspec.rubyforge.org/ > > $ cat acct.rb > describe Account, " when first created" do > it "should have a balance of $0" do > ... > end > end > $ spec acct.rb > /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/runner/ > behaviour_runner.rb:106:in `load': ./acct.rb:3: syntax error, > unexpected tDOT3 (SyntaxError) > from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/ > runner/behaviour_runner.rb:106:in `load_specs' > from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/ > runner/behaviour_runner.rb:105:in `each' > from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/ > runner/behaviour_runner.rb:105:in `load_specs' > from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/ > runner/behaviour_runner.rb:49:in `prepare!' > from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/ > runner/behaviour_runner.rb:19:in `run' > from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/ > runner/command_line.rb:17:in `run' > from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/bin/spec:3 > from /opt/local/bin/spec:16:in `load' > from /opt/local/bin/spec:16 > > Must be a version or other config problem. Can anyone point me in the > right direction? > > Thanks, > > Pito > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > it's saying you have a syntax error.. Can you post your whole file? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071128/a2210782/attachment.html From rps at salas.com Tue Nov 27 20:33:01 2007 From: rps at salas.com (Pito Salas) Date: Tue, 27 Nov 2007 20:33:01 -0500 Subject: [rspec-users] Newbie question In-Reply-To: <2fff50390711271702w500fff53h739180da37406348@mail.gmail.com> References: <2fff50390711271702w500fff53h739180da37406348@mail.gmail.com> Message-ID: That *was* the whole file. And I think therein lies the problem. I didn't realize that I needed a class def for Acct. So this, now, works: class Account end describe Account, " when first created" do it "should have a balance of $0" do end end (as I said: newbie :) Thanks! Pito From pergesu at gmail.com Tue Nov 27 21:05:28 2007 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 27 Nov 2007 18:05:28 -0800 Subject: [rspec-users] Newbie question In-Reply-To: References: <2fff50390711271702w500fff53h739180da37406348@mail.gmail.com> Message-ID: <810a540e0711271805h71fc2484nc53c92622e81c10f@mail.gmail.com> On 11/27/07, Pito Salas wrote: > That *was* the whole file. And I think therein lies the problem. Wait, so your file had "..." in it? Yes, that would indeed be a syntax error. Pat From stefan.landro at gmail.com Wed Nov 28 03:38:23 2007 From: stefan.landro at gmail.com (=?ISO-8859-1?Q?Stefan_Magnus_Landr=F8?=) Date: Wed, 28 Nov 2007 09:38:23 +0100 Subject: [rspec-users] Possible Problem with RSpec and In-Reply-To: <60213.65.92.50.109.1195951693.squirrel@webmail.harte-lyne.ca> References: <60213.65.92.50.109.1195951693.squirrel@webmail.harte-lyne.ca> Message-ID: <921ca2f80711280038i652e88c5he255603a12038e72@mail.gmail.com> We saw some annoying behavior related to pending tests. Maybe you could delete it and rerun your specs? An error typically indicates that you have some sort of error in your code - failing tests should not cause rake to abort. Stefan 2007/11/25, James B. Byrne : > > Sorry to be such a pest but I am trying to learn Ruby, Rails and RSpec all > at one go and it is a bit overwhelming. I have previously completed the > depot tutorial in the Agile Web Dev with rails book and now I am trying do > do it again using RSpec. > > What I would like to know now is why I am getting a rake failure error at > the end of every spec:models run. Is this the expected behaviour when a > test / expectation fails? > > ---> > > C:\var\RSpec\depot>rake spec:models > (in C:/var/RSpec/depot) > NOTICE: CREATE TABLE will create implicit sequence "products_id_seq" for > serial > column "products.id" > NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index > "products_pkey" f > or table "products" > > Product > - should have a valid image uri (PENDING: Not Yet Implemented) > - should have a description > - should have a title (FAILED - 1) > > Pending: > Product should have a valid image uri (Not Yet Implemented) > > 1) > 'Product should have a title' FAILED > expected valid? to return true, got false > ./spec/models/product_spec.rb:11: > > Finished in 0.75 seconds > > 3 examples, 1 failure, 1 pending > rake aborted! > Command ruby -I > "C:/var/RSpec/depot/vendor/plugins/rspec/lib" > "C:/var/RSpec/depot/vendor/plugins/rspec/bin/spec" > "spec/models/product_spec.rb" > --options > "C:/var/RSpec/depot/config/../spec/spec.opts" failed > > (See full trace by running task with --trace) > > C:\var\RSpec\depot>rake spec:models --trace > (in C:/var/RSpec/depot) > ** Invoke spec:models (first_time) > ** Invoke db:test:prepare (first_time) > ** Invoke environment (first_time) > ** Execute environment > ** Execute db:test:prepare > ** Invoke db:test:clone (first_time) > ** Invoke db:schema:dump (first_time) > ** Invoke environment > ** Execute db:schema:dump > ** Invoke db:test:purge (first_time) > ** Invoke environment > ** Execute db:test:purge > ** Execute db:test:clone > ** Invoke db:schema:load (first_time) > ** Invoke environment > ** Execute db:schema:load > NOTICE: CREATE TABLE will create implicit sequence "products_id_seq" for > serial column "products.id" > NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index > "products_pkey" for table "products" > ** Execute spec:models > > Product > - should have a valid image uri (PENDING: Not Yet Implemented) > - should have a description > - should have a title (FAILED - 1) > > Pending: > Product should have a valid image uri (Not Yet Implemented) > > 1) > 'Product should have a title' FAILED > expected valid? to return true, got false > ./spec/models/product_spec.rb:11: > > Finished in 0.563 seconds > > 3 examples, 1 failure, 1 pending > rake aborted! > Command ruby -I"C:/var/RSpec/depot/vendor/plugins/rspec/lib" > "C:/var/RSpec/depot/vendor/plugins/rspec/bin/spec" "spec/models/ > product_spec.rb" --options "C:/var/RSpec/depot/config/../spec/spec.opts" > failed > C:/var/RSpec/depot/vendor/plugins/rspec/lib/spec/rake/ > spectask.rb:173:in `define' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:823:in `verbose' > C:/var/RSpec/depot/vendor/plugins/rspec/lib/spec/rake/ > spectask.rb:142:in `define' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:392:in `call' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:392:in `execute' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:392:in `each' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:392:in `execute' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:362:in `invoke' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:355:in `synchronize' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:355:in `invoke' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1739:in `top_level' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1739:in `each' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1739:in `top_level' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1761:in `standard_exception_handling' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1733:in `top_level' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1711:in `run' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1761:in `standard_exception_handling' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > rake.rb:1708:in `run' > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 > C:/usr/local/bin/ruby/bin/rake.bat:20:in `load' > C:/usr/local/bin/ruby/bin/rake.bat:20 > > C:\var\RSpec\depot> > <--- > > > -- > *** E-Mail is NOT a SECURE channel *** > James B. Byrne mailto:ByrneJB at Harte-Lyne.ca > Harte & Lyne Limited http://www.harte-lyne.ca > 9 Brockley Drive vox: +1 905 561 1241 > Hamilton, Ontario fax: +1 905 561 0757 > Canada L8E 3C3 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Bekk Open Source http://boss.bekk.no -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071128/c5cd7d52/attachment.html From aslak.hellesoy at gmail.com Wed Nov 28 07:47:00 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 28 Nov 2007 13:47:00 +0100 Subject: [rspec-users] Possible Problem with RSpec and In-Reply-To: <921ca2f80711280038i652e88c5he255603a12038e72@mail.gmail.com> References: <60213.65.92.50.109.1195951693.squirrel@webmail.harte-lyne.ca> <921ca2f80711280038i652e88c5he255603a12038e72@mail.gmail.com> Message-ID: <8d961d900711280447pc66da23vd30d1bfdadd316af@mail.gmail.com> On 11/28/07, Stefan Magnus Landr? wrote: > We saw some annoying behavior related to pending tests. Maybe you could > delete it and rerun your specs? > > An error typically indicates that you have some sort of error in your code - > failing tests should not cause rake to abort. > It does, and it should. Failures are just as fatal as errors, and should make rake exit with a non-0. Aslak > Stefan > > 2007/11/25, James B. Byrne : > > Sorry to be such a pest but I am trying to learn Ruby, Rails and RSpec all > > at one go and it is a bit overwhelming. I have previously completed the > > depot tutorial in the Agile Web Dev with rails book and now I am trying do > > do it again using RSpec. > > > > What I would like to know now is why I am getting a rake failure error at > > the end of every spec:models run. Is this the expected behaviour when a > > test / expectation fails? > > > > ---> > > > > C:\var\RSpec\depot>rake spec:models > > (in C:/var/RSpec/depot) > > NOTICE: CREATE TABLE will create implicit sequence "products_id_seq" for > > serial > > column " products.id" > > NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index > > "products_pkey" f > > or table "products" > > > > Product > > - should have a valid image uri (PENDING: Not Yet Implemented) > > - should have a description > > - should have a title (FAILED - 1) > > > > Pending: > > Product should have a valid image uri (Not Yet Implemented) > > > > 1) > > 'Product should have a title' FAILED > > expected valid? to return true, got false > > ./spec/models/product_spec.rb:11: > > > > Finished in 0.75 seconds > > > > 3 examples, 1 failure, 1 pending > > rake aborted! > > Command ruby -I > > "C:/var/RSpec/depot/vendor/plugins/rspec/lib" > > "C:/var/RSpec/depot/vendor/plugins/rspec/bin/spec" > > "spec/models/product_spec.rb" > > --options > > "C:/var/RSpec/depot/config/../spec/spec.opts" failed > > > > (See full trace by running task with --trace) > > > > C:\var\RSpec\depot>rake spec:models --trace > > (in C:/var/RSpec/depot) > > ** Invoke spec:models (first_time) > > ** Invoke db:test:prepare (first_time) > > ** Invoke environment (first_time) > > ** Execute environment > > ** Execute db:test:prepare > > ** Invoke db:test:clone (first_time) > > ** Invoke db:schema:dump (first_time) > > ** Invoke environment > > ** Execute db:schema:dump > > ** Invoke db:test:purge (first_time) > > ** Invoke environment > > ** Execute db:test:purge > > ** Execute db:test:clone > > ** Invoke db:schema:load (first_time) > > ** Invoke environment > > ** Execute db:schema:load > > NOTICE: CREATE TABLE will create implicit sequence "products_id_seq" for > > serial column "products.id" > > NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index > > "products_pkey" for table "products" > > ** Execute spec:models > > > > Product > > - should have a valid image uri (PENDING: Not Yet Implemented) > > - should have a description > > - should have a title (FAILED - 1) > > > > Pending: > > Product should have a valid image uri (Not Yet Implemented) > > > > 1) > > 'Product should have a title' FAILED > > expected valid? to return true, got false > > ./spec/models/product_spec.rb:11: > > > > Finished in 0.563 seconds > > > > 3 examples, 1 failure, 1 pending > > rake aborted! > > Command ruby > -I"C:/var/RSpec/depot/vendor/plugins/rspec/lib" > > "C:/var/RSpec/depot/vendor/plugins/rspec/bin/spec" > "spec/models/ > > product_spec.rb" --options > "C:/var/RSpec/depot/config/../spec/spec.opts" > > failed > > C:/var/RSpec/depot/vendor/plugins/rspec/lib/spec/rake/ > > spectask.rb:173:in `define' > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/ > > rake.rb:823:in `verbose' > > C:/var/RSpec/depot/vendor/plugins/rspec/lib/spec/rake/ > > spectask.rb:142:in `define' > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > rake.rb:392:in `call' > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > rake.rb:392:in `execute' > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > rake.rb:392:in `each' > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/ > > rake.rb:392:in `execute' > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > rake.rb:362:in `invoke' > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > rake.rb:355:in `synchronize' > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > rake.rb:355:in `invoke' > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > rake.rb:1739:in `top_level' > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/ > > rake.rb:1739:in `each' > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > rake.rb:1739:in `top_level' > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > rake.rb:1761:in `standard_exception_handling' > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > rake.rb:1733:in `top_level' > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > rake.rb:1711:in `run' > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake- > 0.7.3/lib/ > > rake.rb:1761:in `standard_exception_handling' > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > rake.rb:1708:in `run' > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 > > C:/usr/local/bin/ruby/bin/rake.bat:20:in `load' > > C:/usr/local/bin/ruby/bin/rake.bat:20 > > > > C:\var\RSpec\depot> > > <--- > > > > > > -- > > *** E-Mail is NOT a SECURE channel *** > > James B. Byrne mailto: ByrneJB at Harte-Lyne.ca > > Harte & Lyne Limited http://www.harte-lyne.ca > > 9 Brockley Drive vox: +1 905 561 1241 > > Hamilton, Ontario fax: +1 905 561 0757 > > Canada L8E 3C3 > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > Bekk Open Source > http://boss.bekk.no > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From stefan.landro at gmail.com Wed Nov 28 08:16:44 2007 From: stefan.landro at gmail.com (=?ISO-8859-1?Q?Stefan_Magnus_Landr=F8?=) Date: Wed, 28 Nov 2007 14:16:44 +0100 Subject: [rspec-users] Possible Problem with RSpec and In-Reply-To: <8d961d900711280447pc66da23vd30d1bfdadd316af@mail.gmail.com> References: <60213.65.92.50.109.1195951693.squirrel@webmail.harte-lyne.ca> <921ca2f80711280038i652e88c5he255603a12038e72@mail.gmail.com> <8d961d900711280447pc66da23vd30d1bfdadd316af@mail.gmail.com> Message-ID: <921ca2f80711280516k23426122pc532fd46c9df3551@mail.gmail.com> I believe I was a bit quick on this one.... Of course, if you can't run your tests, the build should fail and return non-0 as fast as possible. However, it would be nice to distinguish between errors and failures. I initially thought rake would output "rake aborted!" only when you have errors - not just failing tests, and as a ruby newbie I sometimes found it hard to know if I had an error or just a failing test. Does this make more sense? Stefan 2007/11/28, aslak hellesoy : > > On 11/28/07, Stefan Magnus Landr? wrote: > > We saw some annoying behavior related to pending tests. Maybe you could > > delete it and rerun your specs? > > > > An error typically indicates that you have some sort of error in your > code - > > failing tests should not cause rake to abort. > > > > It does, and it should. Failures are just as fatal as errors, and > should make rake exit with a non-0. > > Aslak > > > Stefan > > > > 2007/11/25, James B. Byrne : > > > Sorry to be such a pest but I am trying to learn Ruby, Rails and RSpec > all > > > at one go and it is a bit overwhelming. I have previously completed > the > > > depot tutorial in the Agile Web Dev with rails book and now I am > trying do > > > do it again using RSpec. > > > > > > What I would like to know now is why I am getting a rake failure error > at > > > the end of every spec:models run. Is this the expected behaviour when > a > > > test / expectation fails? > > > > > > ---> > > > > > > C:\var\RSpec\depot>rake spec:models > > > (in C:/var/RSpec/depot) > > > NOTICE: CREATE TABLE will create implicit sequence "products_id_seq" > for > > > serial > > > column " products.id" > > > NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index > > > "products_pkey" f > > > or table "products" > > > > > > Product > > > - should have a valid image uri (PENDING: Not Yet Implemented) > > > - should have a description > > > - should have a title (FAILED - 1) > > > > > > Pending: > > > Product should have a valid image uri (Not Yet Implemented) > > > > > > 1) > > > 'Product should have a title' FAILED > > > expected valid? to return true, got false > > > ./spec/models/product_spec.rb:11: > > > > > > Finished in 0.75 seconds > > > > > > 3 examples, 1 failure, 1 pending > > > rake aborted! > > > Command ruby -I > > > "C:/var/RSpec/depot/vendor/plugins/rspec/lib" > > > "C:/var/RSpec/depot/vendor/plugins/rspec/bin/spec" > > > "spec/models/product_spec.rb" > > > --options > > > "C:/var/RSpec/depot/config/../spec/spec.opts" failed > > > > > > (See full trace by running task with --trace) > > > > > > C:\var\RSpec\depot>rake spec:models --trace > > > (in C:/var/RSpec/depot) > > > ** Invoke spec:models (first_time) > > > ** Invoke db:test:prepare (first_time) > > > ** Invoke environment (first_time) > > > ** Execute environment > > > ** Execute db:test:prepare > > > ** Invoke db:test:clone (first_time) > > > ** Invoke db:schema:dump (first_time) > > > ** Invoke environment > > > ** Execute db:schema:dump > > > ** Invoke db:test:purge (first_time) > > > ** Invoke environment > > > ** Execute db:test:purge > > > ** Execute db:test:clone > > > ** Invoke db:schema:load (first_time) > > > ** Invoke environment > > > ** Execute db:schema:load > > > NOTICE: CREATE TABLE will create implicit sequence "products_id_seq" > for > > > serial column "products.id" > > > NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index > > > "products_pkey" for table "products" > > > ** Execute spec:models > > > > > > Product > > > - should have a valid image uri (PENDING: Not Yet Implemented) > > > - should have a description > > > - should have a title (FAILED - 1) > > > > > > Pending: > > > Product should have a valid image uri (Not Yet Implemented) > > > > > > 1) > > > 'Product should have a title' FAILED > > > expected valid? to return true, got false > > > ./spec/models/product_spec.rb:11: > > > > > > Finished in 0.563 seconds > > > > > > 3 examples, 1 failure, 1 pending > > > rake aborted! > > > Command ruby > > -I"C:/var/RSpec/depot/vendor/plugins/rspec/lib" > > > "C:/var/RSpec/depot/vendor/plugins/rspec/bin/spec" > > "spec/models/ > > > product_spec.rb" --options > > "C:/var/RSpec/depot/config/../spec/spec.opts" > > > failed > > > C:/var/RSpec/depot/vendor/plugins/rspec/lib/spec/rake/ > > > spectask.rb:173:in `define' > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake- > > 0.7.3/lib/ > > > rake.rb:823:in `verbose' > > > C:/var/RSpec/depot/vendor/plugins/rspec/lib/spec/rake/ > > > spectask.rb:142:in `define' > > > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > > rake.rb:392:in `call' > > > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > > rake.rb:392:in `execute' > > > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > > rake.rb:392:in `each' > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake- > > 0.7.3/lib/ > > > rake.rb:392:in `execute' > > > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > > rake.rb:362:in `invoke' > > > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > > rake.rb:355:in `synchronize' > > > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > > rake.rb:355:in `invoke' > > > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > > rake.rb:1739:in `top_level' > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake- > > 0.7.3/lib/ > > > rake.rb:1739:in `each' > > > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > > rake.rb:1739:in `top_level' > > > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > > rake.rb:1761:in `standard_exception_handling' > > > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > > rake.rb:1733:in `top_level' > > > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > > rake.rb:1711:in `run' > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake- > > 0.7.3/lib/ > > > rake.rb:1761:in `standard_exception_handling' > > > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/ > > > rake.rb:1708:in `run' > > > > > C:/usr/local/bin/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 > > > C:/usr/local/bin/ruby/bin/rake.bat:20:in `load' > > > C:/usr/local/bin/ruby/bin/rake.bat:20 > > > > > > C:\var\RSpec\depot> > > > <--- > > > > > > > > > -- > > > *** E-Mail is NOT a SECURE channel *** > > > James B. Byrne mailto: ByrneJB at Harte-Lyne.ca > > > Harte & Lyne Limited http://www.harte-lyne.ca > > > 9 Brockley Drive vox: +1 905 561 1241 > > > Hamilton, Ontario fax: +1 905 561 0757 > > > Canada L8E 3C3 > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > -- > > Bekk Open Source > > http://boss.bekk.no > > _______________________________________________ > > 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 > -- Bekk Open Source http://boss.bekk.no -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071128/c416f04a/attachment.html From dchelimsky at gmail.com Wed Nov 28 08:17:50 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 28 Nov 2007 07:17:50 -0600 Subject: [rspec-users] Possible Problem with RSpec and In-Reply-To: <921ca2f80711280038i652e88c5he255603a12038e72@mail.gmail.com> References: <60213.65.92.50.109.1195951693.squirrel@webmail.harte-lyne.ca> <921ca2f80711280038i652e88c5he255603a12038e72@mail.gmail.com> Message-ID: <57c63afe0711280517l521918sef90c00e522093ab@mail.gmail.com> On Nov 28, 2007 2:38 AM, Stefan Magnus Landr? wrote: > We saw some annoying behavior related to pending tests. Can you be more specific? From dchelimsky at gmail.com Wed Nov 28 08:50:01 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 28 Nov 2007 07:50:01 -0600 Subject: [rspec-users] Possible Problem with RSpec and In-Reply-To: <921ca2f80711280516k23426122pc532fd46c9df3551@mail.gmail.com> References: <60213.65.92.50.109.1195951693.squirrel@webmail.harte-lyne.ca> <921ca2f80711280038i652e88c5he255603a12038e72@mail.gmail.com> <8d961d900711280447pc66da23vd30d1bfdadd316af@mail.gmail.com> <921ca2f80711280516k23426122pc532fd46c9df3551@mail.gmail.com> Message-ID: <57c63afe0711280550t2cf09663s4085189af2131dd3@mail.gmail.com> On Nov 28, 2007 7:16 AM, Stefan Magnus Landr? wrote: > However, it would be nice to distinguish between errors and failures. I > initially thought rake would output "rake aborted!" only when you have > errors - not just failing tests, and as a ruby newbie I sometimes found it > hard to know if I had an error or just a failing test. > > Does this make more sense? It does from the perspective of a human being, but keep in mind that people are not the only consumers of rake. As for distinguishing between errors and failures, RSpec is admittedly riding both sides of this fence. I just added a ticket to address this: http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/152 Please feel free to comment in the ticket. Cheers, David From daniel.ruby at tenner.org Wed Nov 28 09:29:34 2007 From: daniel.ruby at tenner.org (Daniel Tenner) Date: Wed, 28 Nov 2007 14:29:34 +0000 Subject: [rspec-users] Broken edge Message-ID: <117AEC6F-8FE5-4E03-8609-9B70521BBB2F@tenner.org> Hi all, Not sure if I'm the only one with this problem... We're on edge for both rails and rspec, and i just did an update... Some apparently innocuous rails stuff was updated, and then half my specs broke due to an error in rspec_on_rails: ArgumentError in 'UserController without logged in user should show the index page' wrong number of arguments (2 for 1) ..../vendor/plugins/rspec_on_rails/lib/spec/rails/example/behaviour/ controller_example_group.rb:188:in `render' I tried backtracking to an earlier version of rails with no luck. Can anyone provide some version numbers (for rspec, rspec on rails, and rails itself) that I can downgrade back to so my specs work again? Thanks a lot! Daniel From dchelimsky at gmail.com Wed Nov 28 09:36:48 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 28 Nov 2007 08:36:48 -0600 Subject: [rspec-users] Broken edge In-Reply-To: <117AEC6F-8FE5-4E03-8609-9B70521BBB2F@tenner.org> References: <117AEC6F-8FE5-4E03-8609-9B70521BBB2F@tenner.org> Message-ID: <57c63afe0711280636g75956a35x33a7624f239d618@mail.gmail.com> On Nov 28, 2007 8:29 AM, Daniel Tenner wrote: > Hi all, > > Not sure if I'm the only one with this problem... > > We're on edge for both rails and rspec, and i just did an update... > Some apparently innocuous rails stuff was updated, and then half my > specs broke due to an error in rspec_on_rails: > ArgumentError in 'UserController without logged in user should show > the index page' > wrong number of arguments (2 for 1) > ..../vendor/plugins/rspec_on_rails/lib/spec/rails/example/behaviour/ > controller_example_group.rb:188:in `render' > > I tried backtracking to an earlier version of rails with no luck. > > Can anyone provide some version numbers (for rspec, rspec on rails, > and rails itself) that I can downgrade back to so my specs work again? I just updated to edge rails 8228 and it runs fine with rspec at rev 2997 (current trunk) What revisions are you using? > > Thanks a lot! > > Daniel > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From stefan.landro at gmail.com Wed Nov 28 09:38:14 2007 From: stefan.landro at gmail.com (=?ISO-8859-1?Q?Stefan_Magnus_Landr=F8?=) Date: Wed, 28 Nov 2007 15:38:14 +0100 Subject: [rspec-users] Broken edge In-Reply-To: <117AEC6F-8FE5-4E03-8609-9B70521BBB2F@tenner.org> References: <117AEC6F-8FE5-4E03-8609-9B70521BBB2F@tenner.org> Message-ID: <921ca2f80711280638o598c5f1dy2135407669d8f8f2@mail.gmail.com> To avoid this sort of issue, I recommend using piston. With piston you can check in revision combinations that actually work in your source tree without using svn externals. Stefan 2007/11/28, Daniel Tenner : > > Hi all, > > Not sure if I'm the only one with this problem... > > We're on edge for both rails and rspec, and i just did an update... > Some apparently innocuous rails stuff was updated, and then half my > specs broke due to an error in rspec_on_rails: > ArgumentError in 'UserController without logged in user should show > the index page' > wrong number of arguments (2 for 1) > ..../vendor/plugins/rspec_on_rails/lib/spec/rails/example/behaviour/ > controller_example_group.rb:188:in `render' > > I tried backtracking to an earlier version of rails with no luck. > > Can anyone provide some version numbers (for rspec, rspec on rails, > and rails itself) that I can downgrade back to so my specs work again? > > Thanks a lot! > > Daniel > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Bekk Open Source http://boss.bekk.no -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071128/9a4e9b2f/attachment-0001.html From daniel.ruby at tenner.org Wed Nov 28 09:44:21 2007 From: daniel.ruby at tenner.org (Daniel Tenner) Date: Wed, 28 Nov 2007 14:44:21 +0000 Subject: [rspec-users] Broken edge In-Reply-To: <57c63afe0711280636g75956a35x33a7624f239d618@mail.gmail.com> References: <117AEC6F-8FE5-4E03-8609-9B70521BBB2F@tenner.org> <57c63afe0711280636g75956a35x33a7624f239d618@mail.gmail.com> Message-ID: <39FAFCDC-185A-4C32-B7FD-8374116AD1C7@tenner.org> 8228 and 2997! :-( Dang.. what else could it be? It looks like basically, "render" is what's broken... all the pages with redirect_to are working fine in the specs. When I take one of the broken actions and make it redirect_to instead of rendering, the number of failures goes down, and the line that's breaking in controller_example_group.rb is: super(options, deprecated_status, &block) in the render method of the ControllerInstanceMethods module. No idea why it breaks though (or why it's breaking only for me!)... Daniel On 28 Nov 2007, at 14:36 28 Nov 2007, David Chelimsky wrote: > On Nov 28, 2007 8:29 AM, Daniel Tenner wrote: >> Hi all, >> >> Not sure if I'm the only one with this problem... >> >> We're on edge for both rails and rspec, and i just did an update... >> Some apparently innocuous rails stuff was updated, and then half my >> specs broke due to an error in rspec_on_rails: >> ArgumentError in 'UserController without logged in user should show >> the index page' >> wrong number of arguments (2 for 1) >> ..../vendor/plugins/rspec_on_rails/lib/spec/rails/example/behaviour/ >> controller_example_group.rb:188:in `render' >> >> I tried backtracking to an earlier version of rails with no luck. >> >> Can anyone provide some version numbers (for rspec, rspec on rails, >> and rails itself) that I can downgrade back to so my specs work >> again? > > I just updated to edge rails 8228 and it runs fine with rspec at rev > 2997 (current trunk) > > What revisions are you using? > >> >> Thanks a lot! >> >> Daniel >> _______________________________________________ >> 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 Nov 28 09:49:16 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 28 Nov 2007 08:49:16 -0600 Subject: [rspec-users] Broken edge In-Reply-To: <39FAFCDC-185A-4C32-B7FD-8374116AD1C7@tenner.org> References: <117AEC6F-8FE5-4E03-8609-9B70521BBB2F@tenner.org> <57c63afe0711280636g75956a35x33a7624f239d618@mail.gmail.com> <39FAFCDC-185A-4C32-B7FD-8374116AD1C7@tenner.org> Message-ID: <57c63afe0711280649x130b13aaqe080dc64ec829549@mail.gmail.com> On Nov 28, 2007 8:44 AM, Daniel Tenner wrote: > 8228 and 2997! :-( > > Dang.. what else could it be? It looks like basically, "render" is > what's broken... all the pages with redirect_to are working fine in > the specs. When I take one of the broken actions and make it > redirect_to instead of rendering, the number of failures goes down, > and the line that's breaking in controller_example_group.rb is: > super(options, deprecated_status, &block) > > in the render method of the ControllerInstanceMethods module. > > No idea why it breaks though (or why it's breaking only for me!)... Did you do a clean install of edge rails, rspec and rspec_on_rails? If not, I'd recommend it. Perhaps it's an update problem (as Stefan proposed) as opposed to a code problem. > > Daniel > > > On 28 Nov 2007, at 14:36 28 Nov 2007, David Chelimsky wrote: > > > On Nov 28, 2007 8:29 AM, Daniel Tenner wrote: > >> Hi all, > >> > >> Not sure if I'm the only one with this problem... > >> > >> We're on edge for both rails and rspec, and i just did an update... > >> Some apparently innocuous rails stuff was updated, and then half my > >> specs broke due to an error in rspec_on_rails: > >> ArgumentError in 'UserController without logged in user should show > >> the index page' > >> wrong number of arguments (2 for 1) > >> ..../vendor/plugins/rspec_on_rails/lib/spec/rails/example/behaviour/ > >> controller_example_group.rb:188:in `render' > >> > >> I tried backtracking to an earlier version of rails with no luck. > >> > >> Can anyone provide some version numbers (for rspec, rspec on rails, > >> and rails itself) that I can downgrade back to so my specs work > >> again? > > > > I just updated to edge rails 8228 and it runs fine with rspec at rev > > 2997 (current trunk) > > > > What revisions are you using? > > > >> > >> Thanks a lot! > >> > >> Daniel > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > >> > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From zach.dennis at gmail.com Wed Nov 28 10:43:36 2007 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 28 Nov 2007 10:43:36 -0500 Subject: [rspec-users] textmate bundle Message-ID: <85d99afe0711280743r3216f4a3r8ddf8437ecf49a93@mail.gmail.com> Does anyone else have issues running rspec textmate bundle? I've got revision 2997, but the blasted thing just won't run. It is checked out to my /Users/zdennis/Library/Application Support/TextMate/Bundles/RSpec.tmbundle When it runs I get the below error... "textmate" is not a valid class name /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/runner/options.rb:173:in `load_class': "textmate" is not a valid class name (RuntimeError) from /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/runner/options.rb:137:in `parse_format' from /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:93:in `initialize' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/optparse.rb:1260:in `call' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/optparse.rb:1260:in `parse_in_order' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/optparse.rb:1247:in `catch' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/optparse.rb:1247:in `parse_in_order' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/optparse.rb:1241:in `order!' from /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:118:in `order!' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/optparse.rb:1332:in `permute!' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/optparse.rb:1353:in `parse!' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/optparse.rb:1343:in `parse' from /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:10:in `parse' from /Users/zdennis/Library/Application Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:34:in `run' from /Users/zdennis/Library/Application Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:33:in `chdir' from /Users/zdennis/Library/Application Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:33:in `run' from /Users/zdennis/Library/Application Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:12:in `run_file' from /tmp/temp_textmate.AZtCnz:4 -- Zach Dennis http://www.continuousthinking.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071128/3b0cb43f/attachment.html From daniel.ruby at tenner.org Wed Nov 28 11:39:49 2007 From: daniel.ruby at tenner.org (Daniel Tenner) Date: Wed, 28 Nov 2007 16:39:49 +0000 Subject: [rspec-users] Broken edge In-Reply-To: <57c63afe0711280649x130b13aaqe080dc64ec829549@mail.gmail.com> References: <117AEC6F-8FE5-4E03-8609-9B70521BBB2F@tenner.org> <57c63afe0711280636g75956a35x33a7624f239d618@mail.gmail.com> <39FAFCDC-185A-4C32-B7FD-8374116AD1C7@tenner.org> <57c63afe0711280649x130b13aaqe080dc64ec829549@mail.gmail.com> Message-ID: <4A8A0E9A-C0C5-40F6-AAF1-93B0F30238A9@tenner.org> Ok, I've ditched externals and switched to piston... wiped out all the plugins and reinstalled them... And still I'm getting that error. No one else is getting this? Daniel On 28 Nov 2007, at 14:49 28 Nov 2007, David Chelimsky wrote: > On Nov 28, 2007 8:44 AM, Daniel Tenner wrote: >> 8228 and 2997! :-( >> >> Dang.. what else could it be? It looks like basically, "render" is >> what's broken... all the pages with redirect_to are working fine in >> the specs. When I take one of the broken actions and make it >> redirect_to instead of rendering, the number of failures goes down, >> and the line that's breaking in controller_example_group.rb is: >> super(options, deprecated_status, &block) >> >> in the render method of the ControllerInstanceMethods module. >> >> No idea why it breaks though (or why it's breaking only for me!)... > > Did you do a clean install of edge rails, rspec and rspec_on_rails? If > not, I'd recommend it. Perhaps it's an update problem (as Stefan > proposed) as opposed to a code problem. > >> >> Daniel >> >> >> On 28 Nov 2007, at 14:36 28 Nov 2007, David Chelimsky wrote: >> >>> On Nov 28, 2007 8:29 AM, Daniel Tenner >>> wrote: >>>> Hi all, >>>> >>>> Not sure if I'm the only one with this problem... >>>> >>>> We're on edge for both rails and rspec, and i just did an update... >>>> Some apparently innocuous rails stuff was updated, and then half my >>>> specs broke due to an error in rspec_on_rails: >>>> ArgumentError in 'UserController without logged in user should show >>>> the index page' >>>> wrong number of arguments (2 for 1) >>>> ..../vendor/plugins/rspec_on_rails/lib/spec/rails/example/ >>>> behaviour/ >>>> controller_example_group.rb:188:in `render' >>>> >>>> I tried backtracking to an earlier version of rails with no luck. >>>> >>>> Can anyone provide some version numbers (for rspec, rspec on rails, >>>> and rails itself) that I can downgrade back to so my specs work >>>> again? >>> >>> I just updated to edge rails 8228 and it runs fine with rspec at rev >>> 2997 (current trunk) >>> >>> What revisions are you using? >>> >>>> >>>> Thanks a lot! >>>> >>>> Daniel >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From brian.takita at gmail.com Wed Nov 28 11:56:25 2007 From: brian.takita at gmail.com (Brian Takita) Date: Wed, 28 Nov 2007 08:56:25 -0800 Subject: [rspec-users] textmate bundle In-Reply-To: <85d99afe0711280743r3216f4a3r8ddf8437ecf49a93@mail.gmail.com> References: <85d99afe0711280743r3216f4a3r8ddf8437ecf49a93@mail.gmail.com> Message-ID: <1d7ddd110711280856j67140e2dme36d619928e40aaa@mail.gmail.com> On Nov 28, 2007 7:43 AM, Zach Dennis wrote: > Does anyone else have issues running rspec textmate bundle? I've got > revision 2997, but the blasted thing just won't run. > > It is checked out to my /Users/zdennis/Library/Application > Support/TextMate/Bundles/RSpec.tmbundle > > When it runs I get the below error... > > "textmate" is not a valid class name > /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/runner/options.rb:173:in > `load_class': "textmate" is not a valid class name (RuntimeError) from > /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/runner/options.rb:137:in > `parse_format' from > /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:93:in > `initialize' from > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/optparse.rb:1260:in > `call' from > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/optparse.rb:1260:in > `parse_in_order' from > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/optparse.rb:1247:in > `catch' from > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/optparse.rb:1247:in > `parse_in_order' from > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/optparse.rb:1241:in > `order!' from > /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:118:in > `order!' from > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/optparse.rb:1332:in > `permute!' from > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/optparse.rb:1353:in > `parse!' from > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/optparse.rb:1343:in > `parse' from > /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:10:in > `parse' from /Users/zdennis/Library/Application > Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:34:in > `run' from /Users/zdennis/Library/Application > Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:33:in > `chdir' from /Users/zdennis/Library/Application > Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:33:in > `run' from /Users/zdennis/Library/Application > Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:12:in > `run_file' from /tmp/temp_textmate.AZtCnz:4 Hello Zach. Are you running Rspec 1.0.8 with the Trunk version of the Textmate Bundle? > > > -- > Zach Dennis > http://www.continuousthinking.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From daniel.ruby at tenner.org Wed Nov 28 12:10:23 2007 From: daniel.ruby at tenner.org (Daniel Tenner) Date: Wed, 28 Nov 2007 17:10:23 +0000 Subject: [rspec-users] Broken edge In-Reply-To: <4A8A0E9A-C0C5-40F6-AAF1-93B0F30238A9@tenner.org> References: <117AEC6F-8FE5-4E03-8609-9B70521BBB2F@tenner.org> <57c63afe0711280636g75956a35x33a7624f239d618@mail.gmail.com> <39FAFCDC-185A-4C32-B7FD-8374116AD1C7@tenner.org> <57c63afe0711280649x130b13aaqe080dc64ec829549@mail.gmail.com> <4A8A0E9A-C0C5-40F6-AAF1-93B0F30238A9@tenner.org> Message-ID: <9D67549B-1A9E-48FF-B9C9-281DC26A5946@tenner.org> Found the culprit. It was RubyAMF. We've emailed them about it. In the meantime, for anyone else who might encounter this problem, changing line 188 of controller_example_group from: super(options, deprecated_status, &block) to: super(options, &block) Makes all the specs pass. Obviously not a desirable permanent change... but at least until RubyAMF gets fixed. Thanks for the help all! Daniel On 28 Nov 2007, at 16:39 28 Nov 2007, Daniel Tenner wrote: > Ok, I've ditched externals and switched to piston... wiped out all > the plugins and reinstalled them... > > And still I'm getting that error. > > No one else is getting this? > > Daniel > > On 28 Nov 2007, at 14:49 28 Nov 2007, David Chelimsky wrote: > >> On Nov 28, 2007 8:44 AM, Daniel Tenner >> wrote: >>> 8228 and 2997! :-( >>> >>> Dang.. what else could it be? It looks like basically, "render" is >>> what's broken... all the pages with redirect_to are working fine in >>> the specs. When I take one of the broken actions and make it >>> redirect_to instead of rendering, the number of failures goes down, >>> and the line that's breaking in controller_example_group.rb is: >>> super(options, deprecated_status, &block) >>> >>> in the render method of the ControllerInstanceMethods module. >>> >>> No idea why it breaks though (or why it's breaking only for me!)... >> >> Did you do a clean install of edge rails, rspec and >> rspec_on_rails? If >> not, I'd recommend it. Perhaps it's an update problem (as Stefan >> proposed) as opposed to a code problem. >> >>> >>> Daniel >>> >>> >>> On 28 Nov 2007, at 14:36 28 Nov 2007, David Chelimsky wrote: >>> >>>> On Nov 28, 2007 8:29 AM, Daniel Tenner >>>> wrote: >>>>> Hi all, >>>>> >>>>> Not sure if I'm the only one with this problem... >>>>> >>>>> We're on edge for both rails and rspec, and i just did an >>>>> update... >>>>> Some apparently innocuous rails stuff was updated, and then >>>>> half my >>>>> specs broke due to an error in rspec_on_rails: >>>>> ArgumentError in 'UserController without logged in user should >>>>> show >>>>> the index page' >>>>> wrong number of arguments (2 for 1) >>>>> ..../vendor/plugins/rspec_on_rails/lib/spec/rails/example/ >>>>> behaviour/ >>>>> controller_example_group.rb:188:in `render' >>>>> >>>>> I tried backtracking to an earlier version of rails with no luck. >>>>> >>>>> Can anyone provide some version numbers (for rspec, rspec on >>>>> rails, >>>>> and rails itself) that I can downgrade back to so my specs work >>>>> again? >>>> >>>> I just updated to edge rails 8228 and it runs fine with rspec at >>>> rev >>>> 2997 (current trunk) >>>> >>>> What revisions are you using? >>>> >>>>> >>>>> Thanks a lot! >>>>> >>>>> Daniel >>>>> _______________________________________________ >>>>> rspec-users mailing list >>>>> rspec-users at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From zach.dennis at gmail.com Wed Nov 28 14:16:09 2007 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 28 Nov 2007 14:16:09 -0500 Subject: [rspec-users] textmate bundle In-Reply-To: <1d7ddd110711280856j67140e2dme36d619928e40aaa@mail.gmail.com> References: <85d99afe0711280743r3216f4a3r8ddf8437ecf49a93@mail.gmail.com> <1d7ddd110711280856j67140e2dme36d619928e40aaa@mail.gmail.com> Message-ID: <85d99afe0711281116s77b1801ge8d190dc26827ff2@mail.gmail.com> On Nov 28, 2007 11:56 AM, Brian Takita wrote: > > Hello Zach. Are you running Rspec 1.0.8 with the Trunk version of the > Textmate Bundle? > > > > It wasn't 1.0.8, but it was a revision from about a month ago, give or take a few days. I've updated to trunk and that problem has gone away. Running all examples works, but running focused examples blows up with the below error. This appears under the green "RSpec Results" header: /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:108:in `run': You have a nil object when you didn't expect it! (NoMethodError) You might have expected an instance of Array. The error occurred while evaluating nil.empty? from /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:22:in `run' from /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in `each' from /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in `run' from /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/runner/options.rb:85:in `run_examples' from /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/runner/command_line.rb:19:in `run' from /Users/zdennis/Library/Application Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:34:in `run' from /Users/zdennis/Library/Application Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:33:in `chdir' from /Users/zdennis/Library/Application Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:33:in `run' from /Users/zdennis/Library/Application Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:17:in `run_focussed' from /tmp/temp_textmate.zWPVDL:4 -- Zach Dennis http://www.continuousthinking.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071128/5b93d549/attachment-0001.html From odupuis at uottawa.ca Wed Nov 28 13:52:08 2007 From: odupuis at uottawa.ca (Olivier Dupuis) Date: Wed, 28 Nov 2007 13:52:08 -0500 Subject: [rspec-users] Testing cookies Message-ID: <933386AA8A11C643AF045580E1BF9907043F8F6A@MSMAIL1.uottawa.o.univ> Hello, Here's a test I wrote for cookies: it "should change language when params[:id] is present" do cookies[:thothle_language] = 'e' get 'index', :id => 'f' response.cookies["thothle_language"].should equal('f') end The error I get is the following: ...expected "f", got ["f"] (using .equal?) Any help would be appreciated. Thank you Olivier Dupuis -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071128/63f7e63b/attachment.html From dchelimsky at gmail.com Wed Nov 28 16:33:40 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 28 Nov 2007 15:33:40 -0600 Subject: [rspec-users] Testing cookies In-Reply-To: <933386AA8A11C643AF045580E1BF9907043F8F6A@MSMAIL1.uottawa.o.univ> References: <933386AA8A11C643AF045580E1BF9907043F8F6A@MSMAIL1.uottawa.o.univ> Message-ID: <57c63afe0711281333w67ffd1aevce68db3c6969f447@mail.gmail.com> On Nov 28, 2007 12:52 PM, Olivier Dupuis wrote: > > > > > Hello, > > > > Here's a test I wrote for cookies: > > > > it "should change language when params[:id] is present" do > > cookies[:thothle_language] = 'e' > > get 'index', :id => 'f' > > response.cookies["thothle_language"].should equal('f') Two things here: 1 - equal is object identity, so you probably want == instead 2 - cookies[key] is returning an Array Try this: response.cookies["thothle_language"].should == ["f"] Cheers, David > > end > > > > The error I get is the following: > > > > ?expected "f", got ["f"] (using .equal?) > > > > Any help would be appreciated. > > > > Thank you > > > > Olivier Dupuis > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From odupuis at uottawa.ca Wed Nov 28 16:49:59 2007 From: odupuis at uottawa.ca (Olivier Dupuis) Date: Wed, 28 Nov 2007 16:49:59 -0500 Subject: [rspec-users] Testing cookies In-Reply-To: <57c63afe0711281333w67ffd1aevce68db3c6969f447@mail.gmail.com> References: <933386AA8A11C643AF045580E1BF9907043F8F6A@MSMAIL1.uottawa.o.univ> <57c63afe0711281333w67ffd1aevce68db3c6969f447@mail.gmail.com> Message-ID: <933386AA8A11C643AF045580E1BF9907043F91F5@MSMAIL1.uottawa.o.univ> That works! Thanks! Olivier Dupuis -----Message d'origine----- De?: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] De la part de David Chelimsky Envoy??: Wednesday, November 28, 2007 4:34 PM ??: rspec-users Objet?: Re: [rspec-users] Testing cookies On Nov 28, 2007 12:52 PM, Olivier Dupuis wrote: > > > > > Hello, > > > > Here's a test I wrote for cookies: > > > > it "should change language when params[:id] is present" do > > cookies[:thothle_language] = 'e' > > get 'index', :id => 'f' > > response.cookies["thothle_language"].should equal('f') Two things here: 1 - equal is object identity, so you probably want == instead 2 - cookies[key] is returning an Array Try this: response.cookies["thothle_language"].should == ["f"] Cheers, David > > end > > > > The error I get is the following: > > > > ...expected "f", got ["f"] (using .equal?) > > > > Any help would be appreciated. > > > > Thank you > > > > Olivier Dupuis > > > _______________________________________________ > 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 pitosalas at gmail.com Wed Nov 28 16:15:19 2007 From: pitosalas at gmail.com (R. Pito Salas) Date: Wed, 28 Nov 2007 16:15:19 -0500 Subject: [rspec-users] textmate bundle In-Reply-To: <85d99afe0711281116s77b1801ge8d190dc26827ff2@mail.gmail.com> References: <85d99afe0711280743r3216f4a3r8ddf8437ecf49a93@mail.gmail.com> <1d7ddd110711280856j67140e2dme36d619928e40aaa@mail.gmail.com> <85d99afe0711281116s77b1801ge8d190dc26827ff2@mail.gmail.com> Message-ID: <9CDD8277-722C-4205-A2EF-91098DF24EC9@gmail.com> I am having a (probably much more elementary) problem with the bundle. When I try and "run Behavior Description" (shift-ctrl-option R) I get an error from TextMate: /Library/Application Support/TextMate/Bundles/Ruby RSpec.tmbundle/ Support/lib/spec_mate.rb:2:in `require': No such file to load -- rubygems (LoadError) from /Library/Application Support/TextMate/ Bundles/Ruby RSpec.tmbundle/Support/lib/spec_mate.rb:2 from /tmp/ temp_textmate.b2MJZi:3:in `require' from /tmp/temp_textmate.b2MJZi:3 Some kind of path or config problem I am pretty sure... TM_RUBY is set up correctly in TextMate/Preferences/Advanced: TM_RUBY=/opt/local/bin/ruby Any quick idea? Thanks, -- Pito From brian.takita at gmail.com Thu Nov 29 03:08:54 2007 From: brian.takita at gmail.com (Brian Takita) Date: Thu, 29 Nov 2007 00:08:54 -0800 Subject: [rspec-users] textmate bundle In-Reply-To: <85d99afe0711281116s77b1801ge8d190dc26827ff2@mail.gmail.com> References: <85d99afe0711280743r3216f4a3r8ddf8437ecf49a93@mail.gmail.com> <1d7ddd110711280856j67140e2dme36d619928e40aaa@mail.gmail.com> <85d99afe0711281116s77b1801ge8d190dc26827ff2@mail.gmail.com> Message-ID: <1d7ddd110711290008w5cb3c697h2aaddb7e7b35a106@mail.gmail.com> On Nov 28, 2007 11:16 AM, Zach Dennis wrote: > > On Nov 28, 2007 11:56 AM, Brian Takita wrote: > > > > > > > > > > Hello Zach. Are you running Rspec 1.0.8 with the Trunk version of the > > Textmate Bundle? > > > > > > > > It wasn't 1.0.8, but it was a revision from about a month ago, give or take > a few days. I've updated to trunk and that problem has gone away. Running > all examples works, but running focused examples blows up with the below > error. This appears under the green "RSpec Results" header: > > /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:108:in > `run': You have a nil object when you didn't expect it! (NoMethodError) You > might have expected an instance of Array. The error occurred while > evaluating nil.empty? from > /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:22:in > `run' from > /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in > `each' from > /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in > `run' from > /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/runner/options.rb:85:in > `run_examples' from > /Users/zdennis/source/ao_projects/circlebuilder/vendor/plugins/rspec/lib/spec/runner/command_line.rb:19:in > `run' from /Users/zdennis/Library/Application > Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:34:in > `run' from /Users/zdennis/Library/Application > Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:33:in > `chdir' from /Users/zdennis/Library/Application > Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:33:in > `run' from /Users/zdennis/Library/Application > Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:17:in > `run_focussed' from /tmp/temp_textmate.zWPVDL:4 I think this was just fixed. Try updating again. > > > -- > > > Zach Dennis > http://www.continuousthinking.com From brian.takita at gmail.com Thu Nov 29 03:09:42 2007 From: brian.takita at gmail.com (Brian Takita) Date: Thu, 29 Nov 2007 00:09:42 -0800 Subject: [rspec-users] textmate bundle In-Reply-To: <9CDD8277-722C-4205-A2EF-91098DF24EC9@gmail.com> References: <85d99afe0711280743r3216f4a3r8ddf8437ecf49a93@mail.gmail.com> <1d7ddd110711280856j67140e2dme36d619928e40aaa@mail.gmail.com> <85d99afe0711281116s77b1801ge8d190dc26827ff2@mail.gmail.com> <9CDD8277-722C-4205-A2EF-91098DF24EC9@gmail.com> Message-ID: <1d7ddd110711290009k5bee8f76oe2def405028a634c@mail.gmail.com> On Nov 28, 2007 1:15 PM, R. Pito Salas wrote: > I am having a (probably much more elementary) problem with the > bundle. When I try and "run Behavior Description" (shift-ctrl-option > R) I get an error from TextMate: > > /Library/Application Support/TextMate/Bundles/Ruby RSpec.tmbundle/ > Support/lib/spec_mate.rb:2:in `require': No such file to load -- > rubygems (LoadError) from /Library/Application Support/TextMate/ > Bundles/Ruby RSpec.tmbundle/Support/lib/spec_mate.rb:2 from /tmp/ > temp_textmate.b2MJZi:3:in `require' from /tmp/temp_textmate.b2MJZi:3 > > Some kind of path or config problem I am pretty sure... > > TM_RUBY is set up correctly in TextMate/Preferences/Advanced: > TM_RUBY=/opt/local/bin/ruby > > Any quick idea? Pito, have you updated your Textmate Bundle? > > Thanks, > > -- Pito > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From stefan.landro at gmail.com Thu Nov 29 05:23:38 2007 From: stefan.landro at gmail.com (=?ISO-8859-1?Q?Stefan_Magnus_Landr=F8?=) Date: Thu, 29 Nov 2007 11:23:38 +0100 Subject: [rspec-users] Possible Problem with RSpec and In-Reply-To: <57c63afe0711280517l521918sef90c00e522093ab@mail.gmail.com> References: <60213.65.92.50.109.1195951693.squirrel@webmail.harte-lyne.ca> <921ca2f80711280038i652e88c5he255603a12038e72@mail.gmail.com> <57c63afe0711280517l521918sef90c00e522093ab@mail.gmail.com> Message-ID: <921ca2f80711290223u68301e67v8f2f5da7fe028731@mail.gmail.com> It seems like setting up expectations in before blocks, in combination with a pending example, makes rake return non-0 We had code similar to this: describe Model do before do OtherModel.should_receive(:some_method) end it "should whatever" do pending "whatever" end end Removing the expectation from the before block, fixed our problem. Stefan 2007/11/28, David Chelimsky : > > On Nov 28, 2007 2:38 AM, Stefan Magnus Landr? > wrote: > > We saw some annoying behavior related to pending tests. > > Can you be more specific? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Bekk Open Source http://boss.bekk.no -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071129/82f88a2e/attachment.html From aslak.hellesoy at gmail.com Thu Nov 29 05:53:00 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 29 Nov 2007 11:53:00 +0100 Subject: [rspec-users] Possible Problem with RSpec and In-Reply-To: <921ca2f80711290223u68301e67v8f2f5da7fe028731@mail.gmail.com> References: <60213.65.92.50.109.1195951693.squirrel@webmail.harte-lyne.ca> <921ca2f80711280038i652e88c5he255603a12038e72@mail.gmail.com> <57c63afe0711280517l521918sef90c00e522093ab@mail.gmail.com> <921ca2f80711290223u68301e67v8f2f5da7fe028731@mail.gmail.com> Message-ID: <8d961d900711290253s1dc38e3eydac453876c0e4115@mail.gmail.com> On Nov 29, 2007 11:23 AM, Stefan Magnus Landr? wrote: > It seems like setting up expectations in before blocks, in combination with > a pending example, makes rake return non-0 > > We had code similar to this: > > describe Model do > before do > OtherModel.should_receive (:some_method) > end > > it "should whatever" do > pending "whatever" > end > end > > Removing the expectation from the before block, fixed our problem. > Interesting. pending actually raises a special exception that RSpec catches and reports as a P. But your OtherModel never got the expected message, so RSpec changes its mind and reports an F instead. Perhaps we should never report failures for pending examples? Aslak > Stefan > > > > 2007/11/28, David Chelimsky : > > > On Nov 28, 2007 2:38 AM, Stefan Magnus Landr? > wrote: > > > We saw some annoying behavior related to pending tests. > > > > Can you be more specific? > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > -- > Bekk Open Source > http://boss.bekk.no > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From daniel.ruby at tenner.org Thu Nov 29 05:54:44 2007 From: daniel.ruby at tenner.org (Daniel Tenner) Date: Thu, 29 Nov 2007 10:54:44 +0000 Subject: [rspec-users] Stylistic preferences Message-ID: What are people's opinions on which of these two styles is better to use? 1) before --------------------------- module UserSpecHelper include GenericSpecHelper def valid_sms_attributes(phone_number="12345") { :phone_number => phone_number } end end describe User, "with phone number" do include UserSpecHelper before(:each) do @user = User.new(valid_sms_attributes) end it "should be valid" do @user.should be_valid end it "should reject duplicate phone number" do @user.save @user_2 = User.new(valid_sms_attributes) @user_2.should_not be_valid end it "should be possible to disable the number" do @user.save @user.disable_number @user.should be_disabled end end ------------------------ 2) given/yield --------------------------- module GenericSpecHelper def given(thing) yield thing if block_given? thing end end module UserSpecHelper include GenericSpecHelper def valid_sms_attributes(phone_number="12345") { :phone_number => phone_number } end def valid_sms_user(phone_number="12345") User.new(valid_sms_attributes(phone_number)) end end describe User, "unconfirmed" do include UserSpecHelper it "should be valid" do valid_sms_user.should be_valid end it "should reject duplicate phone number" do valid_sms_user("1").save valid_sms_user("1").should_not be_valid end it "should be possible to disable the number" do given(valid_sms_user) do |user| user.save user.disable_number user.should be_disabled end end end ------------------- My thoughts: the second style is more readable sometimes, less other times. More importantly, with the first style, my specs tend to be split alongside the lines of whether they can use the same before (:each), rather than whether they belong together, whereas with the second one, one "description" can have several different "starting points", and I group them by whether I feel they belong together logically. So at the moment I'm more comfortable with the second style. What do you think? Daniel PS: I know these specs themselves are trivial... I've used both approaches in less trivial specs, I hope these illustrate the idea though From pitosalas at gmail.com Thu Nov 29 08:41:22 2007 From: pitosalas at gmail.com (R. Pito Salas) Date: Thu, 29 Nov 2007 08:41:22 -0500 Subject: [rspec-users] textmate bundle In-Reply-To: <1d7ddd110711290009k5bee8f76oe2def405028a634c@mail.gmail.com> References: <85d99afe0711280743r3216f4a3r8ddf8437ecf49a93@mail.gmail.com> <1d7ddd110711280856j67140e2dme36d619928e40aaa@mail.gmail.com> <85d99afe0711281116s77b1801ge8d190dc26827ff2@mail.gmail.com> <9CDD8277-722C-4205-A2EF-91098DF24EC9@gmail.com> <1d7ddd110711290009k5bee8f76oe2def405028a634c@mail.gmail.com> Message-ID: <4F23DC57-EF25-4164-BB41-BCBAB06E96A2@gmail.com> Hi Brian >> Any quick idea? > Pito, have you updated your Textmate Bundle? I got it from svn yesterday... Should I get it again? Thanks, - Pito From rspec.user at gmail.com Thu Nov 29 11:55:13 2007 From: rspec.user at gmail.com (sinclair bain) Date: Thu, 29 Nov 2007 11:55:13 -0500 Subject: [rspec-users] Rollbacks, Sqlite3 bug. Has this been reintroduced ? Message-ID: <2ca660dd0711290855j53979b01w208ddef559869813@mail.gmail.com> Hey, I just updated from the edge and it looks like this _issue_ has resurfaced. Yesterday things were working (stories and specs). No code base changes, only rspec and rspec_on_rails After updating today I now need to set to false in the spec_helper.rb to get the specs running, the stories are fine. Looks like the fixture loading is trying to start a txn. I will look around a bit more and see. Cheers! sinclair On Oct 24, 2007 10:58 PM, Scott Taylor wrote: > > Okay - so the sqlite bug reported a day or so ago on the list is real > bug. I'm going to file something in the tracker for that... > > I also learned that before(:all)...after(:all) is not wrapped in a > transaction, the way before(:each)...after(:each) is. Is there some > reason behind this? Can you not wrap transactions inside transactions? > > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Cheers! sinclair -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071129/0e062bbb/attachment.html From dchelimsky at gmail.com Thu Nov 29 12:06:46 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 29 Nov 2007 11:06:46 -0600 Subject: [rspec-users] Rollbacks, Sqlite3 bug. Has this been reintroduced ? In-Reply-To: <2ca660dd0711290855j53979b01w208ddef559869813@mail.gmail.com> References: <2ca660dd0711290855j53979b01w208ddef559869813@mail.gmail.com> Message-ID: <57c63afe0711290906u148362e2q30de504414eda23b@mail.gmail.com> On Nov 29, 2007 10:55 AM, sinclair bain wrote: > Hey,I just updated from the edge and it looks like this _issue_ has > resurfaced. > > Yesterday things were working (stories and specs). > No code base changes, only rspec and rspec_on_rails > > After updating today I now need to set to false in > the spec_helper.rb > to get the specs running, the stories are fine. Looks like the fixture > loading is trying to start a txn. > > > I will look around a bit more and see. I'm on it - will have a fix in about 5 minutes. > > > > Cheers! > sinclair > > > > On Oct 24, 2007 10:58 PM, Scott Taylor > wrote: > > > > Okay - so the sqlite bug reported a day or so ago on the list is real > > bug. I'm going to file something in the tracker for that... > > > > I also learned that before(:all)...after(:all) is not wrapped in a > > transaction, the way before(:each)...after(:each) is. Is there some > > reason behind this? Can you not wrap transactions inside transactions? > > > > Scott > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > > > Cheers! > sinclair > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From luislavena at gmail.com Thu Nov 29 12:08:35 2007 From: luislavena at gmail.com (Luis Lavena) Date: Thu, 29 Nov 2007 14:08:35 -0300 Subject: [rspec-users] Rollbacks, Sqlite3 bug. Has this been reintroduced ? In-Reply-To: <2ca660dd0711290855j53979b01w208ddef559869813@mail.gmail.com> References: <2ca660dd0711290855j53979b01w208ddef559869813@mail.gmail.com> Message-ID: <71166b3b0711290908r10fcbf63i6b341a7ea37771e8@mail.gmail.com> On Nov 29, 2007 1:55 PM, sinclair bain wrote: > Hey,I just updated from the edge and it looks like this _issue_ has > resurfaced. > > Yesterday things were working (stories and specs). > No code base changes, only rspec and rspec_on_rails > > After updating today I now need to set to false in > the spec_helper.rb > to get the specs running, the stories are fine. Looks like the fixture > loading is trying to start a txn. > > > I will look around a bit more and see. > If you are talking about sqlite3-ruby adapter [1] I have submitted a issue regarding the rollbacks without transactions (#10765) [2] A few things of the sqlite3 adapter seems not working as expected... but it didn't got updated since... a bit. I ended switching to mysql for testing too, a bit too much, but at least works. [1] http://rubyforge.org/projects/sqlite-ruby/ [2] http://rubyforge.org/tracker/index.php?func=detail&aid=10765&group_id=254&atid=1043 -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From dchelimsky at gmail.com Thu Nov 29 12:12:38 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 29 Nov 2007 11:12:38 -0600 Subject: [rspec-users] Rollbacks, Sqlite3 bug. Has this been reintroduced ? In-Reply-To: <57c63afe0711290906u148362e2q30de504414eda23b@mail.gmail.com> References: <2ca660dd0711290855j53979b01w208ddef559869813@mail.gmail.com> <57c63afe0711290906u148362e2q30de504414eda23b@mail.gmail.com> Message-ID: <57c63afe0711290912g29654025kd9d6d62176738ae1@mail.gmail.com> On Nov 29, 2007 11:06 AM, David Chelimsky wrote: > On Nov 29, 2007 10:55 AM, sinclair bain wrote: > > Hey,I just updated from the edge and it looks like this _issue_ has > > resurfaced. > > > > Yesterday things were working (stories and specs). > > No code base changes, only rspec and rspec_on_rails > > > > After updating today I now need to set to false in > > the spec_helper.rb > > to get the specs running, the stories are fine. Looks like the fixture > > loading is trying to start a txn. > > > > > > I will look around a bit more and see. > > I'm on it - will have a fix in about 5 minutes. OK - this is fixed in r3014. Basically, we've been moving some responsibilities around as we improve interoperability w/ Test::Unit. A side effect was that setup was getting called twice. Running the pre_commit task against mysql didn't show this problem because mysql is happy to run transactions inside transactions. Should be all good now. Cheers, David > > > > > > > > > > Cheers! > > sinclair > > > > > > > > On Oct 24, 2007 10:58 PM, Scott Taylor > > wrote: > > > > > > Okay - so the sqlite bug reported a day or so ago on the list is real > > > bug. I'm going to file something in the tracker for that... > > > > > > I also learned that before(:all)...after(:all) is not wrapped in a > > > transaction, the way before(:each)...after(:each) is. Is there some > > > reason behind this? Can you not wrap transactions inside transactions? > > > > > > Scott > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > -- > > > > > > Cheers! > > sinclair > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > From rspec.user at gmail.com Thu Nov 29 12:39:35 2007 From: rspec.user at gmail.com (sinclair bain) Date: Thu, 29 Nov 2007 12:39:35 -0500 Subject: [rspec-users] Rollbacks, Sqlite3 bug. Has this been reintroduced ? In-Reply-To: <57c63afe0711290912g29654025kd9d6d62176738ae1@mail.gmail.com> References: <2ca660dd0711290855j53979b01w208ddef559869813@mail.gmail.com> <57c63afe0711290906u148362e2q30de504414eda23b@mail.gmail.com> <57c63afe0711290912g29654025kd9d6d62176738ae1@mail.gmail.com> Message-ID: <2ca660dd0711290939g6f5fa265t4a3bca4ba3a61bc0@mail.gmail.com> Great ! As always thanks! Cheers! sinclair On Nov 29, 2007 12:12 PM, David Chelimsky wrote: > On Nov 29, 2007 11:06 AM, David Chelimsky wrote: > > On Nov 29, 2007 10:55 AM, sinclair bain wrote: > > > Hey,I just updated from the edge and it looks like this _issue_ has > > > resurfaced. > > > > > > Yesterday things were working (stories and specs). > > > No code base changes, only rspec and rspec_on_rails > > > > > > After updating today I now need to set to > false in > > > the spec_helper.rb > > > to get the specs running, the stories are fine. Looks like the fixture > > > loading is trying to start a txn. > > > > > > > > > I will look around a bit more and see. > > > > I'm on it - will have a fix in about 5 minutes. > > OK - this is fixed in r3014. > > Basically, we've been moving some responsibilities around as we > improve interoperability w/ Test::Unit. A side effect was that setup > was getting called twice. Running the pre_commit task against mysql > didn't show this problem because mysql is happy to run transactions > inside transactions. > > Should be all good now. > > Cheers, > David > > > > > > > > > > > > > > > > > Cheers! > > > sinclair > > > > > > > > > > > > On Oct 24, 2007 10:58 PM, Scott Taylor > > > wrote: > > > > > > > > Okay - so the sqlite bug reported a day or so ago on the list is > real > > > > bug. I'm going to file something in the tracker for that... > > > > > > > > I also learned that before(:all)...after(:all) is not wrapped in a > > > > transaction, the way before(:each)...after(:each) is. Is there some > > > > reason behind this? Can you not wrap transactions inside > transactions? > > > > > > > > Scott > > > > > > > > _______________________________________________ > > > > rspec-users mailing list > > > > rspec-users at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > > > > > > -- > > > > > > > > > Cheers! > > > sinclair > > > _______________________________________________ > > > 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 > -- Cheers! sinclair -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071129/1fcec716/attachment.html From bryan at brynary.com Thu Nov 29 12:44:10 2007 From: bryan at brynary.com (Bryan Helmkamp) Date: Thu, 29 Nov 2007 12:44:10 -0500 Subject: [rspec-users] [ANN] Webrat 0.1.0 released - Ruby Acceptance Testing for Web applications Message-ID: Hey guys, We developed this plugin while writing my first real set of RSpec stories. It's still missing a lot of functionality, but it's useful to us as is, so I'm shipping 0.1.0. (Patches welcome. :) ) Code is available at: http://svn.eastmedia.net/public/plugins/webrat/ What do you think? -Bryan Here's the README: ----------------------------------------------------------- = Webrat - Ruby Acceptance Testing for Web applications by Bryan Helmkamp and Seth Fitzsimmons . Initial development sponsored by EastMedia (http://www.eastmedia.com). == DESCRIPTION: Webrat lets you quickly write robust and thorough acceptance tests for a Ruby web application. By leveraging the DOM, it can run tests similarly to an in-browser testing solution without the associated performance hit (and browser dependency). The result is tests that are less fragile and more effective at verifying that the app will respond properly to users. When comparing Webrat with an in-browser testing solution like Watir or Selenium, the primary consideration should be how much JavaScript the application uses. In-browser testing is currently the only way to test JS, and that may make it a requirement for your project. If JavaScript is not central to your application, Webrat is a simpler, effective solution that will let you run your tests much faster and more frequently. (Benchmarks forthcoming.) == SYNOPSIS: def test_sign_up visits "/" clicks_link "Sign up" fills_in "Email", :with => "good at example.com" select "Free account" clicks_button "Register" ... end Behind the scenes, this will perform the following work: 1. Verify that loading the home page is successful 2. Verify that a "Sign up" link exists on the home page 3. Verify that loading the URL pointed to by the "Sign up" link leads to a successful page 4. Verify that there is an "Email" input field on the Sign Up page 5. Verify that there is an select field on the Sign Up page with an option for "Free account" 6. Verify that there is a "Register" submit button on the page 7. Verify that submitting the Sign Up form with the values "good at example.com" and "Free account" leads to a successful page Take special note of the things _not_ specified in that test, that might cause tests to break unnecessarily as your application evolves: * The input field IDs or names (e.g. "user_email" or "user[email]"), which could change if you rename a model * The ID of the form element (Webrat can do a good job of guessing, even if there are multiple forms on the page.) * The URLs of links followed * The URL the form submission should be sent to, which could change if you adjust your routes or controllers * The HTTP method for the login request A test written with Webrat can handle these changes smoothly. == REQUIREMENTS: * Rails >= 1.2.6 * Hpricot >= 0.6 * Rails integration tests in Test::Unit _or_ * RSpec stories (using an RSpec version >= revision 2997) == INSTALL: $ ruby script/plugin install http://svn.eastmedia.net/public/plugins/webrat/ == HISTORY: See CHANGELOG in this directory. == LICENSE: Copyright (c) 2007 Bryan Helmkamp, Seth Fitzsimmons. See MIT-LICENSE in this directory. ----------------------------------------------------------- -- http://brynary.com -- My blog From pergesu at gmail.com Thu Nov 29 14:55:25 2007 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 29 Nov 2007 11:55:25 -0800 Subject: [rspec-users] [ANN] Webrat 0.1.0 released - Ruby Acceptance Testing for Web applications In-Reply-To: References: Message-ID: <810a540e0711291155g14b4c992g5cf8176af10f8f9@mail.gmail.com> On 11/29/07, Bryan Helmkamp wrote: > Hey guys, > > We developed this plugin while writing my first real set of RSpec > stories. It's still missing a lot of functionality, but it's useful to > us as is, so I'm shipping 0.1.0. (Patches welcome. :) ) > > Code is available at: http://svn.eastmedia.net/public/plugins/webrat/ > > What do you think? Nice! I'm really excited to try this out. Pat From johnwlong2000 at gmail.com Thu Nov 29 15:52:04 2007 From: johnwlong2000 at gmail.com (John W. Long) Date: Thu, 29 Nov 2007 15:52:04 -0500 Subject: [rspec-users] [ANN] Webrat 0.1.0 released - Ruby Acceptance Testing for Web applications In-Reply-To: References: Message-ID: <08EF9211-ACEF-4B52-9FE4-AE4FB072CF87@gmail.com> We've been putting something similar together here: http://faithfulcode.rubyforge.org/svn/plugins/trunk/spec_integration/ It's for integration testing. The README talks about the navigate_to, submit_form, and be_showing methods. -- John Long http://wiseheartdesign.com On Nov 29, 2007, at 12:44 PM, Bryan Helmkamp wrote: > Hey guys, > > We developed this plugin while writing my first real set of RSpec > stories. It's still missing a lot of functionality, but it's useful to > us as is, so I'm shipping 0.1.0. (Patches welcome. :) ) > > Code is available at: http://svn.eastmedia.net/public/plugins/webrat/ > > What do you think? > > -Bryan > > Here's the README: > > ----------------------------------------------------------- > > = Webrat - Ruby Acceptance Testing for Web applications > > by Bryan Helmkamp and Seth Fitzsimmons >. > > Initial development sponsored by EastMedia (http://www.eastmedia.com). > > == DESCRIPTION: > > Webrat lets you quickly write robust and thorough acceptance tests > for a Ruby > web application. By leveraging the DOM, it can run tests similarly > to an > in-browser testing solution without the associated performance hit > (and > browser dependency). The result is tests that are less fragile and > more > effective at verifying that the app will respond properly to users. > > When comparing Webrat with an in-browser testing solution like Watir > or > Selenium, the primary consideration should be how much JavaScript the > application uses. In-browser testing is currently the only way to > test JS, and > that may make it a requirement for your project. If JavaScript is > not central > to your application, Webrat is a simpler, effective solution that > will let you > run your tests much faster and more frequently. (Benchmarks > forthcoming.) > > == SYNOPSIS: > > def test_sign_up > visits "/" > clicks_link "Sign up" > fills_in "Email", :with => "good at example.com" > select "Free account" > clicks_button "Register" > ... > end > > Behind the scenes, this will perform the following work: > > 1. Verify that loading the home page is successful > 2. Verify that a "Sign up" link exists on the home page > 3. Verify that loading the URL pointed to by the "Sign up" link > leads to a > successful page > 4. Verify that there is an "Email" input field on the Sign Up page > 5. Verify that there is an select field on the Sign Up page with an > option for > "Free account" > 6. Verify that there is a "Register" submit button on the page > 7. Verify that submitting the Sign Up form with the values "good at example.com > " > and "Free account" leads to a successful page > > Take special note of the things _not_ specified in that test, that > might cause > tests to break unnecessarily as your application evolves: > > * The input field IDs or names (e.g. "user_email" or "user[email]"), > which > could change if you rename a model > * The ID of the form element (Webrat can do a good job of guessing, > even if > there are multiple forms on the page.) > * The URLs of links followed > * The URL the form submission should be sent to, which could change > if you > adjust your routes or controllers > * The HTTP method for the login request > > A test written with Webrat can handle these changes smoothly. > > == REQUIREMENTS: > > * Rails >= 1.2.6 > * Hpricot >= 0.6 > * Rails integration tests in Test::Unit _or_ > * RSpec stories (using an RSpec version >= revision 2997) > > == INSTALL: > > $ ruby script/plugin install http://svn.eastmedia.net/public/plugins/webrat/ > > == HISTORY: > > See CHANGELOG in this directory. > > == LICENSE: > > Copyright (c) 2007 Bryan Helmkamp, Seth Fitzsimmons. > See MIT-LICENSE in this directory. > > ----------------------------------------------------------- > > -- > http://brynary.com -- My blog > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From jonathan at parkerhill.com Thu Nov 29 16:06:11 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Thu, 29 Nov 2007 16:06:11 -0500 Subject: [rspec-users] [ANN] Webrat 0.1.0 released - Ruby Acceptance Testing for Web applications In-Reply-To: References: Message-ID: <2FC933D3-F7CE-4C9D-8A1E-ED94DAB608CD@parkerhill.com> /me in love :) On Nov 29, 2007, at 12:44 PM, Bryan Helmkamp wrote: > Hey guys, > > We developed this plugin while writing my first real set of RSpec > stories. It's still missing a lot of functionality, but it's useful to > us as is, so I'm shipping 0.1.0. (Patches welcome. :) ) > > Code is available at: http://svn.eastmedia.net/public/plugins/webrat/ > > What do you think? > > -Bryan > > Here's the README: > > ----------------------------------------------------------- > > = Webrat - Ruby Acceptance Testing for Web applications > > by Bryan Helmkamp and Seth Fitzsimmons > . > > Initial development sponsored by EastMedia (http://www.eastmedia.com). > > == DESCRIPTION: > > Webrat lets you quickly write robust and thorough acceptance tests > for a Ruby > web application. By leveraging the DOM, it can run tests similarly > to an > in-browser testing solution without the associated performance hit > (and > browser dependency). The result is tests that are less fragile and > more > effective at verifying that the app will respond properly to users. > > When comparing Webrat with an in-browser testing solution like > Watir or > Selenium, the primary consideration should be how much JavaScript the > application uses. In-browser testing is currently the only way to > test JS, and > that may make it a requirement for your project. If JavaScript is > not central > to your application, Webrat is a simpler, effective solution that > will let you > run your tests much faster and more frequently. (Benchmarks > forthcoming.) > > == SYNOPSIS: > > def test_sign_up > visits "/" > clicks_link "Sign up" > fills_in "Email", :with => "good at example.com" > select "Free account" > clicks_button "Register" > ... > end > > Behind the scenes, this will perform the following work: > > 1. Verify that loading the home page is successful > 2. Verify that a "Sign up" link exists on the home page > 3. Verify that loading the URL pointed to by the "Sign up" link > leads to a > successful page > 4. Verify that there is an "Email" input field on the Sign Up page > 5. Verify that there is an select field on the Sign Up page with an > option for > "Free account" > 6. Verify that there is a "Register" submit button on the page > 7. Verify that submitting the Sign Up form with the values > "good at example.com" > and "Free account" leads to a successful page > > Take special note of the things _not_ specified in that test, that > might cause > tests to break unnecessarily as your application evolves: > > * The input field IDs or names (e.g. "user_email" or "user > [email]"), which > could change if you rename a model > * The ID of the form element (Webrat can do a good job of guessing, > even if > there are multiple forms on the page.) > * The URLs of links followed > * The URL the form submission should be sent to, which could change > if you > adjust your routes or controllers > * The HTTP method for the login request > > A test written with Webrat can handle these changes smoothly. > > == REQUIREMENTS: > > * Rails >= 1.2.6 > * Hpricot >= 0.6 > * Rails integration tests in Test::Unit _or_ > * RSpec stories (using an RSpec version >= revision 2997) > > == INSTALL: > > $ ruby script/plugin install http://svn.eastmedia.net/public/ > plugins/webrat/ > > == HISTORY: > > See CHANGELOG in this directory. > > == LICENSE: > > Copyright (c) 2007 Bryan Helmkamp, Seth Fitzsimmons. > See MIT-LICENSE in this directory. > > ----------------------------------------------------------- > > -- > http://brynary.com -- My blog > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From odupuis at uottawa.ca Thu Nov 29 21:29:09 2007 From: odupuis at uottawa.ca (Olivier Dupuis) Date: Thu, 29 Nov 2007 21:29:09 -0500 Subject: [rspec-users] Rendering a view and passing a variable Message-ID: <933386AA8A11C643AF045580E1BF99073E804D@MSMAIL1.uottawa.o.univ> Hello all, I have a view which display html based on the value of a variable. Here's the code : <% if @language == 'e' %> <%= link_to "Français", :action => :index, :id => "f" %> <% end %> In my test, I'm trying to set the value of the variable first, but that just doesn't seem to work : it "should display in english when @language is equal to 'E'" do @language = "e" render "/search/index" response.should have_tag("a[href=?]", "/search/index/f") end I get the error message saying that no tag was found. Any help would be appreciated Thank you in advance Olivier Dupuis -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071129/72a905bc/attachment.html From dchelimsky at gmail.com Thu Nov 29 21:29:13 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 29 Nov 2007 20:29:13 -0600 Subject: [rspec-users] Rendering a view and passing a variable In-Reply-To: <933386AA8A11C643AF045580E1BF99073E804D@MSMAIL1.uottawa.o.univ> References: <933386AA8A11C643AF045580E1BF99073E804D@MSMAIL1.uottawa.o.univ> Message-ID: <57c63afe0711291829x55139eacx5fa7b056207e100f@mail.gmail.com> On Nov 29, 2007 8:29 PM, Olivier Dupuis wrote: > > > > > Hello all, > > I have a view which display html based on the value of a variable. Here's > the code : > > <% if @language == 'e' %> > <%= link_to "Français", :action => :index, :id => "f" %> > <% end %> > > In my test, I'm trying to set the value of the variable first, but that > just doesn't seem to work : > > it "should display in english when @language is equal to 'E'" do > @language = "e" > render "/search/index" > response.should have_tag("a[href=?]", "/search/index/f") > end > > I get the error message saying that no tag was found. > > Any help would be appreciated http://rspec.rubyforge.org/documentation/rails/writing/views.html assigns[:language] = "e" Cheers, David > > Thank you in advance > > Olivier Dupuis > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From smingins at elctech.com Thu Nov 29 21:33:19 2007 From: smingins at elctech.com (Shane Mingins) Date: Fri, 30 Nov 2007 15:33:19 +1300 Subject: [rspec-users] Rendering a view and passing a variable In-Reply-To: <933386AA8A11C643AF045580E1BF99073E804D@MSMAIL1.uottawa.o.univ> References: <933386AA8A11C643AF045580E1BF99073E804D@MSMAIL1.uottawa.o.univ> Message-ID: <07775932-31BD-4676-809F-7D98B85F17A9@elctech.com> don't you have to do ... assigns[:language] = @language On 30/11/2007, at 3:29 PM, Olivier Dupuis wrote: > > Hello all, > > I have a view which display html based on the value of a variable. > Here's the code : > > <% if @language == 'e' %> > <%= link_to "Français", :action => :index, :id => "f" %> > <% end %> > > In my test, I'm trying to set the value of the variable first, but > that just doesn't seem to work : > > it "should display in english when @language is equal to 'E'" do > @language = "e" > render "/search/index" > response.should have_tag("a[href=?]", "/search/index/f") > end > > I get the error message saying that no tag was found. > > Any help would be appreciated > > Thank you in advance > > Olivier Dupuis > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Shane Mingins ELC Technologies (TM) 1921 State Street Santa Barbara, CA 93101 Phone: +64 4 568 6684 Mobile: +64 21 435 586 Email: smingins at elctech.com AIM: ShaneMingins Skype: shane.mingins (866) 863-7365 Tel - Santa Barbara Office (866) 893-1902 Fax - Santa Barbara Office +44 020 7504 1346 Tel - London Office +44 020 7504 1347 Fax - London Office http://www.elctech.com -------------------------------------------------------------------- Privacy and Confidentiality Notice: The information contained in this electronic mail message is intended for the named recipient(s) only. It may contain privileged and confidential information. If you are not an intended recipient, you must not copy, forward, distribute or take any action in reliance on it. If you have received this electronic mail message in error, please notify the sender immediately. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071130/02091455/attachment-0001.html From odupuis at uottawa.ca Thu Nov 29 21:44:45 2007 From: odupuis at uottawa.ca (Olivier Dupuis) Date: Thu, 29 Nov 2007 21:44:45 -0500 Subject: [rspec-users] Rendering a view and passing a variable References: <933386AA8A11C643AF045580E1BF99073E804D@MSMAIL1.uottawa.o.univ> <57c63afe0711291829x55139eacx5fa7b056207e100f@mail.gmail.com> Message-ID: <933386AA8A11C643AF045580E1BF99073E804E@MSMAIL1.uottawa.o.univ> Thanks again David! Sorry for the easy question. I should have looked more carefully at the documentation. Olivier -----Original Message----- From: rspec-users-bounces at rubyforge.org on behalf of David Chelimsky Sent: Thu 11/29/2007 9:29 PM To: rspec-users Subject: Re: [rspec-users] Rendering a view and passing a variable On Nov 29, 2007 8:29 PM, Olivier Dupuis wrote: > > > > > Hello all, > > I have a view which display html based on the value of a variable. Here's > the code : > > <% if @language == 'e' %> > <%= link_to "Français", :action => :index, :id => "f" %> > <% end %> > > In my test, I'm trying to set the value of the variable first, but that > just doesn't seem to work : > > it "should display in english when @language is equal to 'E'" do > @language = "e" > render "/search/index" > response.should have_tag("a[href=?]", "/search/index/f") > end > > I get the error message saying that no tag was found. > > Any help would be appreciated http://rspec.rubyforge.org/documentation/rails/writing/views.html assigns[:language] = "e" Cheers, David > > Thank you in advance > > Olivier Dupuis > _______________________________________________ > 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 -------------- A non-text attachment was scrubbed... Name: not available Type: application/ms-tnef Size: 3414 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20071129/7e3cc1f5/attachment.bin From dchelimsky at gmail.com Thu Nov 29 21:46:33 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 29 Nov 2007 20:46:33 -0600 Subject: [rspec-users] Rendering a view and passing a variable In-Reply-To: <933386AA8A11C643AF045580E1BF99073E804E@MSMAIL1.uottawa.o.univ> References: <933386AA8A11C643AF045580E1BF99073E804D@MSMAIL1.uottawa.o.univ> <57c63afe0711291829x55139eacx5fa7b056207e100f@mail.gmail.com> <933386AA8A11C643AF045580E1BF99073E804E@MSMAIL1.uottawa.o.univ> Message-ID: <57c63afe0711291846jed7d7b5mac461ae5615b414e@mail.gmail.com> On Nov 29, 2007 8:44 PM, Olivier Dupuis wrote: > Thanks again David! > > Sorry for the easy question. I should have looked more carefully at the documentation. Please, no apologies. The docs aren't perfect, so while it's good to know they're there, you should always feel free to ask. Cheers, David > > Olivier > > > > -----Original Message----- > From: rspec-users-bounces at rubyforge.org on behalf of David Chelimsky > Sent: Thu 11/29/2007 9:29 PM > To: rspec-users > Subject: Re: [rspec-users] Rendering a view and passing a variable > > On Nov 29, 2007 8:29 PM, Olivier Dupuis wrote: > > > > > > > > > > Hello all, > > > > I have a view which display html based on the value of a variable. Here's > > the code : > > > > <% if @language == 'e' %> > > <%= link_to "Français", :action => :index, :id => "f" %> > > <% end %> > > > > In my test, I'm trying to set the value of the variable first, but that > > just doesn't seem to work : > > > > it "should display in english when @language is equal to 'E'" do > > @language = "e" > > render "/search/index" > > response.should have_tag("a[href=?]", "/search/index/f") > > end > > > > I get the error message saying that no tag was found. > > > > Any help would be appreciated > > http://rspec.rubyforge.org/documentation/rails/writing/views.html > > assigns[:language] = "e" > > Cheers, > David > > > > > Thank you in advance > > > > Olivier Dupuis > > _______________________________________________ > > 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 rick.denatale at gmail.com Fri Nov 30 10:21:38 2007 From: rick.denatale at gmail.com (Rick DeNatale) Date: Fri, 30 Nov 2007 10:21:38 -0500 Subject: [rspec-users] Autotest'ing specs on non-rails app Message-ID: I'm having trouble using autotest with rspec on a non-rails project. my Rspec gem is version 1.0.8, ZenTest is 3.6.2 project structure $ ls * lib: parser.rb spec: parser_spec.rb autotest finds and runs the spec, but it won't detect changes to lib/parser.rb I know it's something stupid, but... help? -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From rick.denatale at gmail.com Fri Nov 30 12:43:06 2007 From: rick.denatale at gmail.com (Rick DeNatale) Date: Fri, 30 Nov 2007 12:43:06 -0500 Subject: [rspec-users] Autotest'ing specs on non-rails app In-Reply-To: References: Message-ID: On Nov 30, 2007 10:21 AM, Rick DeNatale wrote: > I'm having trouble using autotest with rspec on a non-rails project. Bad diagnosis, It's not that it's not detecting, it's that I'm not getting growl notifications, although I do get them for autotesting specs in rails projects. Hmmmmm -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From nathan.sutton at gmail.com Fri Nov 30 13:10:12 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Fri, 30 Nov 2007 12:10:12 -0600 Subject: [rspec-users] Autotest'ing specs on non-rails app In-Reply-To: References: Message-ID: Thought I'd share that growlnotify has issues on leopard, it's touch and go as to if it will work or not. Nathan Sutton fowlduck at gmail.com rspec edge revision 3014 rspec_on_rails edge revision 3014 rails edge revision 8238 On Nov 30, 2007, at 11:43 AM, Rick DeNatale wrote: > On Nov 30, 2007 10:21 AM, Rick DeNatale > wrote: >> I'm having trouble using autotest with rspec on a non-rails project. > > Bad diagnosis, It's not that it's not detecting, it's that I'm not > getting growl notifications, although I do get them for autotesting > specs in rails projects. Hmmmmm > > -- > Rick DeNatale > > My blog on Ruby > http://talklikeaduck.denhaven2.com/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From rick.denatale at gmail.com Fri Nov 30 13:18:26 2007 From: rick.denatale at gmail.com (Rick DeNatale) Date: Fri, 30 Nov 2007 13:18:26 -0500 Subject: [rspec-users] Autotest'ing specs on non-rails app In-Reply-To: References: Message-ID: Yes, but I'm still on tiger On Nov 30, 2007 1:10 PM, Nathan Sutton wrote: > Thought I'd share that growlnotify has issues on leopard, it's touch > and go as to if it will work or not. > > Nathan Sutton > fowlduck at gmail.com > rspec edge revision 3014 > rspec_on_rails edge revision 3014 > rails edge revision 8238 > > > > > > On Nov 30, 2007, at 11:43 AM, Rick DeNatale wrote: > > > On Nov 30, 2007 10:21 AM, Rick DeNatale > > wrote: > >> I'm having trouble using autotest with rspec on a non-rails project. > > > > Bad diagnosis, It's not that it's not detecting, it's that I'm not > > getting growl notifications, although I do get them for autotesting > > specs in rails projects. Hmmmmm > > > > -- > > Rick DeNatale > > > > My blog on Ruby > > http://talklikeaduck.denhaven2.com/ > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From nathan.sutton at gmail.com Fri Nov 30 13:33:45 2007 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Fri, 30 Nov 2007 12:33:45 -0600 Subject: [rspec-users] Autotest'ing specs on non-rails app In-Reply-To: References: Message-ID: <7B94F625-2BD3-4B89-944B-A4F3CA0D5DF5@gmail.com> Yeah, should work, but wanted to note it as I've had endless issues with it on leopard. My boss' growlnotify doesn't work, mine works perfectly since I installed Office 2004, and the forums say it doesn't work at all... Nathan Sutton fowlduck at gmail.com rspec edge revision 3014 rspec_on_rails edge revision 3014 rails edge revision 8238 On Nov 30, 2007, at 12:18 PM, Rick DeNatale wrote: > Yes, but I'm still on tiger > > On Nov 30, 2007 1:10 PM, Nathan Sutton > wrote: >> Thought I'd share that growlnotify has issues on leopard, it's touch >> and go as to if it will work or not. >> >> Nathan Sutton >> fowlduck at gmail.com >> rspec edge revision 3014 >> rspec_on_rails edge revision 3014 >> rails edge revision 8238 >> >> >> >> >> >> On Nov 30, 2007, at 11:43 AM, Rick DeNatale wrote: >> >>> On Nov 30, 2007 10:21 AM, Rick DeNatale >>> wrote: >>>> I'm having trouble using autotest with rspec on a non-rails >>>> project. >>> >>> Bad diagnosis, It's not that it's not detecting, it's that I'm not >>> getting growl notifications, although I do get them for autotesting >>> specs in rails projects. Hmmmmm >>> >>> -- >>> Rick DeNatale >>> >>> My blog on Ruby >>> http://talklikeaduck.denhaven2.com/ >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Rick DeNatale > > My blog on Ruby > http://talklikeaduck.denhaven2.com/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From jcfischer.lists at gmail.com Fri Nov 30 16:28:38 2007 From: jcfischer.lists at gmail.com (Jens-Christian Fischer) Date: Fri, 30 Nov 2007 22:28:38 +0100 Subject: [rspec-users] [ANN] Webrat 0.1.0 released - Ruby Acceptance Testing for Web applications In-Reply-To: References: Message-ID: > > Code is available at: http://svn.eastmedia.net/public/plugins/webrat/ > * Rails integration tests in Test::Unit _or_ > * RSpec stories (using an RSpec version >= revision 2997) I had to add: require 'cgi' require "cgi/session" require 'cgi/session/pstore' require 'action_controller/cgi_ext/cgi_methods' in the beginning of lib/webrat/session.rb to get rid of the following error: NameError: uninitialized constant ActionController::Integration::Session::CGIMethods /Users/jcf/dev/work/quevita/vendor/rails/activerecord/lib/../../ activesupport/lib/active_support/dependencies.rb:478:in `const_missing' /Users/jcf/dev/work/quevita/vendor/plugins/webrat/lib/webrat/ session.rb:107:in `add_form_data' /Users/jcf/dev/work/quevita/vendor/plugins/webrat/lib/webrat/ session.rb:175:in `add_default_params_for' nice work! Jens-Christian