Hello, I''m struggling with this controller spec for a few hours now http://pastie.org/594775 which is failing with an error I can''t find any references about, neither on the list nor on the web in general: Admin::ImagesController handling PUT /images/1 with successful update should find the image requested undefined method `and_return'' for #<Proc:0x30520b4> /Users/oliver/Sites/spree/spec/controllers/admin/images_controller_spec.rb:17 /tmp/textmate-command-1859.rb:3 15 before(:each) do 16 @image = mock_model(Image, :to_param => "1") 17 Image.stub!(:find).and_return(@image) 18 end why would and_return() not be recognized, while stub!() is? has anybody experienced this problem before? I''m using rspec and rspec-rails at version 1.2.6, with Rails 2.3.2, while customizing Spree 0.8.99 thanks Oliver
On Tue, Aug 25, 2009 at 6:19 PM, Oliver Barnes<oli.azevedo.barnes at gmail.com> wrote:> Hello, > > I''m struggling with this controller spec for a few hours now > > http://pastie.org/594775 > > which is failing with an error I can''t find any references about, > neither on the list nor on the web in general: > > Admin::ImagesController handling PUT /images/1 with successful update > should find the image requested > undefined method `and_return'' for #<Proc:0x30520b4> > /Users/oliver/Sites/spree/spec/controllers/admin/images_controller_spec.rb:17 > /tmp/textmate-command-1859.rb:3 > 15 ? ? ?before(:each) do > 16 ? ? ? ?@image = mock_model(Image, :to_param => "1") > 17 ? ? ? ?Image.stub!(:find).and_return(@image) > 18 ? ? ?end > > why would and_return() not be recognized, while stub!() is? > > has anybody experienced this problem before? I''m using rspec and > rspec-rails at version 1.2.6, with Rails 2.3.2, while customizing > Spree 0.8.99Please run this spec from the command line with --backtrace so we can see the full backtrace. Thanks.> > thanks > Oliver > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
sure thing: http://pastie.org/595363 2009/8/26 David Chelimsky <dchelimsky at gmail.com>:> On Tue, Aug 25, 2009 at 6:19 PM, Oliver > Barnes<oli.azevedo.barnes at gmail.com> wrote: >> Hello, >> >> I''m struggling with this controller spec for a few hours now >> >> http://pastie.org/594775 >> >> which is failing with an error I can''t find any references about, >> neither on the list nor on the web in general: >> >> Admin::ImagesController handling PUT /images/1 with successful update >> should find the image requested >> undefined method `and_return'' for #<Proc:0x30520b4> >> /Users/oliver/Sites/spree/spec/controllers/admin/images_controller_spec.rb:17 >> /tmp/textmate-command-1859.rb:3 >> 15 ? ? ?before(:each) do >> 16 ? ? ? ?@image = mock_model(Image, :to_param => "1") >> 17 ? ? ? ?Image.stub!(:find).and_return(@image) >> 18 ? ? ?end >> >> why would and_return() not be recognized, while stub!() is? >> >> has anybody experienced this problem before? I''m using rspec and >> rspec-rails at version 1.2.6, with Rails 2.3.2, while customizing >> Spree 0.8.99 > > Please run this spec from the command line with --backtrace so we can > see the full backtrace. Thanks. > >> >> thanks >> Oliver >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
does that shed any light? 2009/8/26 Oliver Barnes <oli.azevedo.barnes at gmail.com>:> sure thing: > > http://pastie.org/595363 > > 2009/8/26 David Chelimsky <dchelimsky at gmail.com>: >> On Tue, Aug 25, 2009 at 6:19 PM, Oliver >> Barnes<oli.azevedo.barnes at gmail.com> wrote: >>> Hello, >>> >>> I''m struggling with this controller spec for a few hours now >>> >>> http://pastie.org/594775 >>> >>> which is failing with an error I can''t find any references about, >>> neither on the list nor on the web in general: >>> >>> Admin::ImagesController handling PUT /images/1 with successful update >>> should find the image requested >>> undefined method `and_return'' for #<Proc:0x30520b4> >>> /Users/oliver/Sites/spree/spec/controllers/admin/images_controller_spec.rb:17 >>> /tmp/textmate-command-1859.rb:3 >>> 15 ? ? ?before(:each) do >>> 16 ? ? ? ?@image = mock_model(Image, :to_param => "1") >>> 17 ? ? ? ?Image.stub!(:find).and_return(@image) >>> 18 ? ? ?end >>> >>> why would and_return() not be recognized, while stub!() is? >>> >>> has anybody experienced this problem before? I''m using rspec and >>> rspec-rails at version 1.2.6, with Rails 2.3.2, while customizing >>> Spree 0.8.99 >> >> Please run this spec from the command line with --backtrace so we can >> see the full backtrace. Thanks. >> >>> >>> thanks >>> Oliver >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >
Sorry, but no. The spec you showed in the original email should work exactly as you expect. Somehow, for reasons I don''t understand, stub!() appears to be returning a Proc instead of a mock proxy object. On Thu, Aug 27, 2009 at 9:35 AM, Oliver Barnes<oli.azevedo.barnes at gmail.com> wrote:> does that shed any light? > > 2009/8/26 Oliver Barnes <oli.azevedo.barnes at gmail.com>: >> sure thing: >> >> http://pastie.org/595363 >> >> 2009/8/26 David Chelimsky <dchelimsky at gmail.com>: >>> On Tue, Aug 25, 2009 at 6:19 PM, Oliver >>> Barnes<oli.azevedo.barnes at gmail.com> wrote: >>>> Hello, >>>> >>>> I''m struggling with this controller spec for a few hours now >>>> >>>> http://pastie.org/594775 >>>> >>>> which is failing with an error I can''t find any references about, >>>> neither on the list nor on the web in general: >>>> >>>> Admin::ImagesController handling PUT /images/1 with successful update >>>> should find the image requested >>>> undefined method `and_return'' for #<Proc:0x30520b4> >>>> /Users/oliver/Sites/spree/spec/controllers/admin/images_controller_spec.rb:17 >>>> /tmp/textmate-command-1859.rb:3 >>>> 15 ? ? ?before(:each) do >>>> 16 ? ? ? ?@image = mock_model(Image, :to_param => "1") >>>> 17 ? ? ? ?Image.stub!(:find).and_return(@image) >>>> 18 ? ? ?end >>>> >>>> why would and_return() not be recognized, while stub!() is? >>>> >>>> has anybody experienced this problem before? I''m using rspec and >>>> rspec-rails at version 1.2.6, with Rails 2.3.2, while customizing >>>> Spree 0.8.99 >>> >>> Please run this spec from the command line with --backtrace so we can >>> see the full backtrace. Thanks. >>> >>>> >>>> thanks >>>> Oliver >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
i guess it must be something wrong with my setup then? i''ve been messing with my gem infrastructure. going to try reinstalling rspec 2009/8/27 David Chelimsky <dchelimsky at gmail.com>:> Sorry, but no. The spec you showed in the original email should work > exactly as you expect. Somehow, for reasons I don''t understand, > stub!() appears to be returning a Proc instead of a mock proxy object. > > On Thu, Aug 27, 2009 at 9:35 AM, Oliver > Barnes<oli.azevedo.barnes at gmail.com> wrote: >> does that shed any light? >> >> 2009/8/26 Oliver Barnes <oli.azevedo.barnes at gmail.com>: >>> sure thing: >>> >>> http://pastie.org/595363 >>> >>> 2009/8/26 David Chelimsky <dchelimsky at gmail.com>: >>>> On Tue, Aug 25, 2009 at 6:19 PM, Oliver >>>> Barnes<oli.azevedo.barnes at gmail.com> wrote: >>>>> Hello, >>>>> >>>>> I''m struggling with this controller spec for a few hours now >>>>> >>>>> http://pastie.org/594775 >>>>> >>>>> which is failing with an error I can''t find any references about, >>>>> neither on the list nor on the web in general: >>>>> >>>>> Admin::ImagesController handling PUT /images/1 with successful update >>>>> should find the image requested >>>>> undefined method `and_return'' for #<Proc:0x30520b4> >>>>> /Users/oliver/Sites/spree/spec/controllers/admin/images_controller_spec.rb:17 >>>>> /tmp/textmate-command-1859.rb:3 >>>>> 15 ? ? ?before(:each) do >>>>> 16 ? ? ? ?@image = mock_model(Image, :to_param => "1") >>>>> 17 ? ? ? ?Image.stub!(:find).and_return(@image) >>>>> 18 ? ? ?end >>>>> >>>>> why would and_return() not be recognized, while stub!() is? >>>>> >>>>> has anybody experienced this problem before? I''m using rspec and >>>>> rspec-rails at version 1.2.6, with Rails 2.3.2, while customizing >>>>> Spree 0.8.99 >>>> >>>> Please run this spec from the command line with --backtrace so we can >>>> see the full backtrace. Thanks. >>>> >>>>> >>>>> thanks >>>>> Oliver >>>>> _______________________________________________ >>>>> rspec-users mailing list >>>>> rspec-users at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
sorry to bother again, but no luck even after reinstalling rspec + rspec-rails: Big-Mac:spree(product-image-updates-fix) $ spec spec/controllers/admin/images_controller_spec.rb --backtrace /Users/oliver/Sites/spree/app/controllers/products_controller.rb:41: warning: parenthesize argument(s) for future version .FFFFF 1) NoMethodError in ''Admin::ImagesController handling PUT /images/1 with successful update should find the image requested'' undefined method `and_return'' for #<Proc:0x30e1fd4> ./spec/controllers/admin/images_controller_spec.rb:17: /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:70:in `instance_eval'' /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:70:in `eval_each_fail_fast'' /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:70:in `each'' /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:70:in `eval_each_fail_fast'' /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_group_hierarchy.rb:17:in `run_before_each'' /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:103:in `run_before_each'' /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:124:in `before_each_example'' /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:39:in `execute'' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:48:in `timeout'' /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:37:in `execute'' /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_group_methods.rb:207:in `run_examples'' /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_group_methods.rb:205:in `each'' /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_group_methods.rb:205:in `run_examples'' /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_group_methods.rb:103:in `run'' /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/runner/example_group_runner.rb:23:in `run'' /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/runner/example_group_runner.rb:22:in `each'' /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/runner/example_group_runner.rb:22:in `run'' /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/runner/options.rb:127:in `run_examples'' /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/runner/command_line.rb:9:in `run'' /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/bin/spec:4: /usr/bin/spec:19:in `load'' /usr/bin/spec:19: 2009/8/27 Oliver Barnes <oli.azevedo.barnes at gmail.com>:> i guess it must be something wrong with my setup then? i''ve been > messing with my gem infrastructure. going to try reinstalling rspec > > 2009/8/27 David Chelimsky <dchelimsky at gmail.com>: >> Sorry, but no. The spec you showed in the original email should work >> exactly as you expect. Somehow, for reasons I don''t understand, >> stub!() appears to be returning a Proc instead of a mock proxy object. >> >> On Thu, Aug 27, 2009 at 9:35 AM, Oliver >> Barnes<oli.azevedo.barnes at gmail.com> wrote: >>> does that shed any light? >>> >>> 2009/8/26 Oliver Barnes <oli.azevedo.barnes at gmail.com>: >>>> sure thing: >>>> >>>> http://pastie.org/595363 >>>> >>>> 2009/8/26 David Chelimsky <dchelimsky at gmail.com>: >>>>> On Tue, Aug 25, 2009 at 6:19 PM, Oliver >>>>> Barnes<oli.azevedo.barnes at gmail.com> wrote: >>>>>> Hello, >>>>>> >>>>>> I''m struggling with this controller spec for a few hours now >>>>>> >>>>>> http://pastie.org/594775 >>>>>> >>>>>> which is failing with an error I can''t find any references about, >>>>>> neither on the list nor on the web in general: >>>>>> >>>>>> Admin::ImagesController handling PUT /images/1 with successful update >>>>>> should find the image requested >>>>>> undefined method `and_return'' for #<Proc:0x30520b4> >>>>>> /Users/oliver/Sites/spree/spec/controllers/admin/images_controller_spec.rb:17 >>>>>> /tmp/textmate-command-1859.rb:3 >>>>>> 15 ? ? ?before(:each) do >>>>>> 16 ? ? ? ?@image = mock_model(Image, :to_param => "1") >>>>>> 17 ? ? ? ?Image.stub!(:find).and_return(@image) >>>>>> 18 ? ? ?end >>>>>> >>>>>> why would and_return() not be recognized, while stub!() is? >>>>>> >>>>>> has anybody experienced this problem before? I''m using rspec and >>>>>> rspec-rails at version 1.2.6, with Rails 2.3.2, while customizing >>>>>> Spree 0.8.99 >>>>> >>>>> Please run this spec from the command line with --backtrace so we can >>>>> see the full backtrace. Thanks. >>>>> >>>>>> >>>>>> thanks >>>>>> Oliver >>>>>> _______________________________________________ >>>>>> rspec-users mailing list >>>>>> rspec-users at rubyforge.org >>>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>>> >>>>> _______________________________________________ >>>>> rspec-users mailing list >>>>> rspec-users at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>> >>>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >
I don''t usually top-post but in this case I think it works better. Is there ANY chance that Image or one of it''s superclasses has defined a stub! method which would override the one in Spec::Mocks::Methods ? On Fri, Aug 28, 2009 at 6:02 PM, Oliver Barnes<oli.azevedo.barnes at gmail.com> wrote:> sorry to bother again, but no luck even after reinstalling rspec + rspec-rails: > > Big-Mac:spree(product-image-updates-fix) $ spec > spec/controllers/admin/images_controller_spec.rb --backtrace > /Users/oliver/Sites/spree/app/controllers/products_controller.rb:41: > warning: parenthesize argument(s) for future version > .FFFFF > > 1) > NoMethodError in ''Admin::ImagesController handling PUT /images/1 with > successful update should find the image requested'' > undefined method `and_return'' for #<Proc:0x30e1fd4> > ./spec/controllers/admin/images_controller_spec.rb:17: > /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:70:in > `instance_eval'' > /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:70:in > `eval_each_fail_fast'' > /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:70:in > `each'' > /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:70:in > `eval_each_fail_fast'' > /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_group_hierarchy.rb:17:in > `run_before_each'' > /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:103:in > `run_before_each'' > /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:124:in > `before_each_example'' > /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:39:in > `execute'' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:48:in > `timeout'' > /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:37:in > `execute'' > /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_group_methods.rb:207:in > `run_examples'' > /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_group_methods.rb:205:in > `each'' > /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_group_methods.rb:205:in > `run_examples'' > /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_group_methods.rb:103:in > `run'' > /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/runner/example_group_runner.rb:23:in > `run'' > /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/runner/example_group_runner.rb:22:in > `each'' > /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/runner/example_group_runner.rb:22:in > `run'' > /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/runner/options.rb:127:in > `run_examples'' > /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/runner/command_line.rb:9:in > `run'' > /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/bin/spec:4: > /usr/bin/spec:19:in `load'' > /usr/bin/spec:19: > > > 2009/8/27 Oliver Barnes <oli.azevedo.barnes at gmail.com>: >> i guess it must be something wrong with my setup then? i''ve been >> messing with my gem infrastructure. going to try reinstalling rspec >> >> 2009/8/27 David Chelimsky <dchelimsky at gmail.com>: >>> Sorry, but no. The spec you showed in the original email should work >>> exactly as you expect. Somehow, for reasons I don''t understand, >>> stub!() appears to be returning a Proc instead of a mock proxy object. >>> >>> On Thu, Aug 27, 2009 at 9:35 AM, Oliver >>> Barnes<oli.azevedo.barnes at gmail.com> wrote: >>>> does that shed any light? >>>> >>>> 2009/8/26 Oliver Barnes <oli.azevedo.barnes at gmail.com>: >>>>> sure thing: >>>>> >>>>> http://pastie.org/595363 >>>>> >>>>> 2009/8/26 David Chelimsky <dchelimsky at gmail.com>: >>>>>> On Tue, Aug 25, 2009 at 6:19 PM, Oliver >>>>>> Barnes<oli.azevedo.barnes at gmail.com> wrote: >>>>>>> Hello, >>>>>>> >>>>>>> I''m struggling with this controller spec for a few hours now >>>>>>> >>>>>>> http://pastie.org/594775 >>>>>>> >>>>>>> which is failing with an error I can''t find any references about, >>>>>>> neither on the list nor on the web in general: >>>>>>> >>>>>>> Admin::ImagesController handling PUT /images/1 with successful update >>>>>>> should find the image requested >>>>>>> undefined method `and_return'' for #<Proc:0x30520b4> >>>>>>> /Users/oliver/Sites/spree/spec/controllers/admin/images_controller_spec.rb:17 >>>>>>> /tmp/textmate-command-1859.rb:3 >>>>>>> 15 ? ? ?before(:each) do >>>>>>> 16 ? ? ? ?@image = mock_model(Image, :to_param => "1") >>>>>>> 17 ? ? ? ?Image.stub!(:find).and_return(@image) >>>>>>> 18 ? ? ?end >>>>>>> >>>>>>> why would and_return() not be recognized, while stub!() is? >>>>>>> >>>>>>> has anybody experienced this problem before? I''m using rspec and >>>>>>> rspec-rails at version 1.2.6, with Rails 2.3.2, while customizing >>>>>>> Spree 0.8.99 >>>>>> >>>>>> Please run this spec from the command line with --backtrace so we can >>>>>> see the full backtrace. Thanks. >>>>>> >>>>>>> >>>>>>> thanks >>>>>>> Oliver >>>>>>> _______________________________________________ >>>>>>> rspec-users mailing list >>>>>>> rspec-users at rubyforge.org >>>>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>>>> >>>>>> _______________________________________________ >>>>>> rspec-users mailing list >>>>>> rspec-users at rubyforge.org >>>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>>> >>>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.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 >-- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale
I''ve done a project-wide search for stub!, and so far I haven''t found a conflicting method... but i''m brain-dead right now, will look again tomorrow with fresh eyes. thanks for the response Rick 2009/8/28 Rick DeNatale <rick.denatale at gmail.com>:> I don''t usually top-post but in this case I think it works better. > > Is there ANY chance that Image or one of it''s superclasses has defined > a stub! method which would override the one in Spec::Mocks::Methods ? > > On Fri, Aug 28, 2009 at 6:02 PM, Oliver > Barnes<oli.azevedo.barnes at gmail.com> wrote: >> sorry to bother again, but no luck even after reinstalling rspec + rspec-rails: >> >> Big-Mac:spree(product-image-updates-fix) $ spec >> spec/controllers/admin/images_controller_spec.rb --backtrace >> /Users/oliver/Sites/spree/app/controllers/products_controller.rb:41: >> warning: parenthesize argument(s) for future version >> .FFFFF >> >> 1) >> NoMethodError in ''Admin::ImagesController handling PUT /images/1 with >> successful update should find the image requested'' >> undefined method `and_return'' for #<Proc:0x30e1fd4> >> ./spec/controllers/admin/images_controller_spec.rb:17: >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:70:in >> `instance_eval'' >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:70:in >> `eval_each_fail_fast'' >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:70:in >> `each'' >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:70:in >> `eval_each_fail_fast'' >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_group_hierarchy.rb:17:in >> `run_before_each'' >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:103:in >> `run_before_each'' >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:124:in >> `before_each_example'' >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:39:in >> `execute'' >> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:48:in >> `timeout'' >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_methods.rb:37:in >> `execute'' >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_group_methods.rb:207:in >> `run_examples'' >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_group_methods.rb:205:in >> `each'' >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_group_methods.rb:205:in >> `run_examples'' >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/example/example_group_methods.rb:103:in >> `run'' >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/runner/example_group_runner.rb:23:in >> `run'' >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/runner/example_group_runner.rb:22:in >> `each'' >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/runner/example_group_runner.rb:22:in >> `run'' >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/runner/options.rb:127:in >> `run_examples'' >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/lib/spec/runner/command_line.rb:9:in >> `run'' >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.8/bin/spec:4: >> /usr/bin/spec:19:in `load'' >> /usr/bin/spec:19: >> >> >> 2009/8/27 Oliver Barnes <oli.azevedo.barnes at gmail.com>: >>> i guess it must be something wrong with my setup then? i''ve been >>> messing with my gem infrastructure. going to try reinstalling rspec >>> >>> 2009/8/27 David Chelimsky <dchelimsky at gmail.com>: >>>> Sorry, but no. The spec you showed in the original email should work >>>> exactly as you expect. Somehow, for reasons I don''t understand, >>>> stub!() appears to be returning a Proc instead of a mock proxy object. >>>> >>>> On Thu, Aug 27, 2009 at 9:35 AM, Oliver >>>> Barnes<oli.azevedo.barnes at gmail.com> wrote: >>>>> does that shed any light? >>>>> >>>>> 2009/8/26 Oliver Barnes <oli.azevedo.barnes at gmail.com>: >>>>>> sure thing: >>>>>> >>>>>> http://pastie.org/595363 >>>>>> >>>>>> 2009/8/26 David Chelimsky <dchelimsky at gmail.com>: >>>>>>> On Tue, Aug 25, 2009 at 6:19 PM, Oliver >>>>>>> Barnes<oli.azevedo.barnes at gmail.com> wrote: >>>>>>>> Hello, >>>>>>>> >>>>>>>> I''m struggling with this controller spec for a few hours now >>>>>>>> >>>>>>>> http://pastie.org/594775 >>>>>>>> >>>>>>>> which is failing with an error I can''t find any references about, >>>>>>>> neither on the list nor on the web in general: >>>>>>>> >>>>>>>> Admin::ImagesController handling PUT /images/1 with successful update >>>>>>>> should find the image requested >>>>>>>> undefined method `and_return'' for #<Proc:0x30520b4> >>>>>>>> /Users/oliver/Sites/spree/spec/controllers/admin/images_controller_spec.rb:17 >>>>>>>> /tmp/textmate-command-1859.rb:3 >>>>>>>> 15 ? ? ?before(:each) do >>>>>>>> 16 ? ? ? ?@image = mock_model(Image, :to_param => "1") >>>>>>>> 17 ? ? ? ?Image.stub!(:find).and_return(@image) >>>>>>>> 18 ? ? ?end >>>>>>>> >>>>>>>> why would and_return() not be recognized, while stub!() is? >>>>>>>> >>>>>>>> has anybody experienced this problem before? I''m using rspec and >>>>>>>> rspec-rails at version 1.2.6, with Rails 2.3.2, while customizing >>>>>>>> Spree 0.8.99 >>>>>>> >>>>>>> Please run this spec from the command line with --backtrace so we can >>>>>>> see the full backtrace. Thanks. >>>>>>> >>>>>>>> >>>>>>>> thanks >>>>>>>> Oliver >>>>>>>> _______________________________________________ >>>>>>>> rspec-users mailing list >>>>>>>> rspec-users at rubyforge.org >>>>>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>>>>> >>>>>>> _______________________________________________ >>>>>>> rspec-users mailing list >>>>>>> rspec-users at rubyforge.org >>>>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>>>> >>>>>> >>>>> _______________________________________________ >>>>> rspec-users mailing list >>>>> rspec-users at rubyforge.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 >> > > > > -- > Rick DeNatale > > Blog: http://talklikeaduck.denhaven2.com/ > Twitter: http://twitter.com/RickDeNatale > WWR: http://www.workingwithrails.com/person/9021-rick-denatale > LinkedIn: http://www.linkedin.com/in/rickdenatale > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On Fri, Aug 28, 2009 at 9:33 PM, Oliver Barnes<oli.azevedo.barnes at gmail.com> wrote:> I''ve done a project-wide search for stub!, and so far I haven''t found > a conflicting method... but i''m brain-dead right now, will look again > tomorrow with fresh eyes. thanks for the response RickI''d be tempted to run the spec under rdebug, put a breakpoint before the stub! call and step into it to see what''s going on. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale
Hi, I got the same error while writing an extension for Spree and found this thread through Google. It seems it''s caused by the jeremymcanally-stump[1] gem used by the application. You should use the syntax shown in the documentation http://github.com/jeremymcanally/stump Regards On Wed, Aug 26, 2009 at 1:19 AM, Oliver Barnes <oli.azevedo.barnes at gmail.com> wrote:> Hello, > > I''m struggling with this controller spec for a few hours now > > http://pastie.org/594775 > > which is failing with an error I can''t find any references about, > neither on the list nor on the web in general: > > Admin::ImagesController handling PUT /images/1 with successful update > should find the image requested > undefined method `and_return'' for #<Proc:0x30520b4> > > /Users/oliver/Sites/spree/spec/controllers/admin/images_controller_spec.rb:17 > /tmp/textmate-command-1859.rb:3 > 15 before(:each) do > 16 @image = mock_model(Image, :to_param => "1") > 17 Image.stub!(:find).and_return(@image) > 18 end > > why would and_return() not be recognized, while stub!() is? > > has anybody experienced this problem before? I''m using rspec and > rspec-rails at version 1.2.6, with Rails 2.3.2, while customizing > Spree 0.8.99 > > thanks > Oliver > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-- def dagi3d(me) case me when :web then "http://dagi3d.net" when :twitter then "http://twitter.com/dagi3d" end end -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090926/8c20bf53/attachment.html>
thanks! had given up on this already. changing to the new syntax Image.stub!(:find, :return => @image) did get me past the error. I still can''t get this spec to pass though: http://pastie.org/633580 updated spec: http://pastie.org/633584 and the controller being spec''ed: http://pastie.org/633586 2009/9/26 Borja Mart?n <borjam at dagi3d.net>:> Hi, > I got the same error while writing an extension for Spree and found this > thread through Google. It seems it''s caused by the jeremymcanally-stump[1] > gem used by the application. You should use the syntax shown in the > documentation > > http://github.com/jeremymcanally/stump > > Regards > > On Wed, Aug 26, 2009 at 1:19 AM, Oliver Barnes > <oli.azevedo.barnes at gmail.com> wrote: >> >> Hello, >> >> I''m struggling with this controller spec for a few hours now >> >> http://pastie.org/594775 >> >> which is failing with an error I can''t find any references about, >> neither on the list nor on the web in general: >> >> Admin::ImagesController handling PUT /images/1 with successful update >> should find the image requested >> undefined method `and_return'' for #<Proc:0x30520b4> >> >> /Users/oliver/Sites/spree/spec/controllers/admin/images_controller_spec.rb:17 >> /tmp/textmate-command-1859.rb:3 >> 15 ? ? ?before(:each) do >> 16 ? ? ? ?@image = mock_model(Image, :to_param => "1") >> 17 ? ? ? ?Image.stub!(:find).and_return(@image) >> 18 ? ? ?end >> >> why would and_return() not be recognized, while stub!() is? >> >> has anybody experienced this problem before? I''m using rspec and >> rspec-rails at version 1.2.6, with Rails 2.3.2, while customizing >> Spree 0.8.99 >> >> thanks >> Oliver >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > -- > def dagi3d(me) > ?case me > ? ?when :web then ?"http://dagi3d.net" > ? ?when :twitter then "http://twitter.com/dagi3d" > ?end > end > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On Mon, Sep 28, 2009 at 12:02 PM, Oliver Barnes <oli.azevedo.barnes at gmail.com> wrote:> thanks! had given up on this already. changing to the new syntax > > ?Image.stub!(:find, :return => @image)Not sure where you got this syntax from, but it doesn''t do anything. Options are: Image.stub(:find).and_return(@image) Image.stub(:find => @image) Image.stub(:find) { @image } You can also use stub! in all 3 forms.> > did get me past the error. > > I still can''t get this spec to pass though: > > http://pastie.org/633580 > > updated spec: > > http://pastie.org/633584 > > and the controller being spec''ed: > > http://pastie.org/633586 > > > > > > 2009/9/26 Borja Mart?n <borjam at dagi3d.net>: >> Hi, >> I got the same error while writing an extension for Spree and found this >> thread through Google. It seems it''s caused by the jeremymcanally-stump[1] >> gem used by the application. You should use the syntax shown in the >> documentation >> >> http://github.com/jeremymcanally/stump >> >> Regards >> >> On Wed, Aug 26, 2009 at 1:19 AM, Oliver Barnes >> <oli.azevedo.barnes at gmail.com> wrote: >>> >>> Hello, >>> >>> I''m struggling with this controller spec for a few hours now >>> >>> http://pastie.org/594775 >>> >>> which is failing with an error I can''t find any references about, >>> neither on the list nor on the web in general: >>> >>> Admin::ImagesController handling PUT /images/1 with successful update >>> should find the image requested >>> undefined method `and_return'' for #<Proc:0x30520b4> >>> >>> /Users/oliver/Sites/spree/spec/controllers/admin/images_controller_spec.rb:17 >>> /tmp/textmate-command-1859.rb:3 >>> 15 ? ? ?before(:each) do >>> 16 ? ? ? ?@image = mock_model(Image, :to_param => "1") >>> 17 ? ? ? ?Image.stub!(:find).and_return(@image) >>> 18 ? ? ?end >>> >>> why would and_return() not be recognized, while stub!() is? >>> >>> has anybody experienced this problem before? I''m using rspec and >>> rspec-rails at version 1.2.6, with Rails 2.3.2, while customizing >>> Spree 0.8.99 >>> >>> thanks >>> Oliver >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> >> -- >> def dagi3d(me) >> ?case me >> ? ?when :web then ?"http://dagi3d.net" >> ? ?when :twitter then "http://twitter.com/dagi3d" >> ?end >> end >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Hi David, I followed Borja''s suggestion (message before mine). he had the same problem on a spree project, and traced it down to its use of the stump gem''s helpers, which require a different syntax http://github.com/jeremymcanally/stump 2009/9/29 David Chelimsky <dchelimsky at gmail.com>:> On Mon, Sep 28, 2009 at 12:02 PM, Oliver Barnes > <oli.azevedo.barnes at gmail.com> wrote: >> thanks! had given up on this already. changing to the new syntax >> >> ?Image.stub!(:find, :return => @image) > > Not sure where you got this syntax from, but it doesn''t do anything. > Options are: > > Image.stub(:find).and_return(@image) > Image.stub(:find => @image) > Image.stub(:find) { @image } > > You can also use stub! in all 3 forms. > >> >> did get me past the error. >> >> I still can''t get this spec to pass though: >> >> http://pastie.org/633580 >> >> updated spec: >> >> http://pastie.org/633584 >> >> and the controller being spec''ed: >> >> http://pastie.org/633586 >> >> >> >> >> >> 2009/9/26 Borja Mart?n <borjam at dagi3d.net>: >>> Hi, >>> I got the same error while writing an extension for Spree and found this >>> thread through Google. It seems it''s caused by the jeremymcanally-stump[1] >>> gem used by the application. You should use the syntax shown in the >>> documentation >>> >>> http://github.com/jeremymcanally/stump >>> >>> Regards >>> >>> On Wed, Aug 26, 2009 at 1:19 AM, Oliver Barnes >>> <oli.azevedo.barnes at gmail.com> wrote: >>>> >>>> Hello, >>>> >>>> I''m struggling with this controller spec for a few hours now >>>> >>>> http://pastie.org/594775 >>>> >>>> which is failing with an error I can''t find any references about, >>>> neither on the list nor on the web in general: >>>> >>>> Admin::ImagesController handling PUT /images/1 with successful update >>>> should find the image requested >>>> undefined method `and_return'' for #<Proc:0x30520b4> >>>> >>>> /Users/oliver/Sites/spree/spec/controllers/admin/images_controller_spec.rb:17 >>>> /tmp/textmate-command-1859.rb:3 >>>> 15 ? ? ?before(:each) do >>>> 16 ? ? ? ?@image = mock_model(Image, :to_param => "1") >>>> 17 ? ? ? ?Image.stub!(:find).and_return(@image) >>>> 18 ? ? ?end >>>> >>>> why would and_return() not be recognized, while stub!() is? >>>> >>>> has anybody experienced this problem before? I''m using rspec and >>>> rspec-rails at version 1.2.6, with Rails 2.3.2, while customizing >>>> Spree 0.8.99 >>>> >>>> thanks >>>> Oliver >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> >>> >>> -- >>> def dagi3d(me) >>> ?case me >>> ? ?when :web then ?"http://dagi3d.net" >>> ? ?when :twitter then "http://twitter.com/dagi3d" >>> ?end >>> end >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.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 >