Hi there, I''ve been working with RSpec for about a week now, and the process of moving from a Test::Unit + Mocha setup to an RSpec + Mocha environment has been pretty straightforward. Except, I''m having problems with using template.expect_render. I have Mocha enabled with:> config.mock_with :mochain spec_helper. And then I have a view spec which looks like this:> it "should explode messily because I have made this partial name > up" do > template.expect_render(:partial => ''does_not_exist'', :object => > "hello") > render "/a/real/template" > endIf I run this spec, it passes, which it really shouldn''t. If I comment out the config.mock_with :mocha line and re-run the spec, it fails with:> Mock ''expect_render_mock_proxy'' expected :render with > ({:partial=>"does_not_exist", :object=>"hello"}) once, but received > it 0 timesWhich is much better. So, to me, this looks like a bug in rspec_on_rails. Explanations of why I''m just doing it wrong gratefully received ;-) Matt -- Matt Patterson | Design & Code <matt at reprocessed.org> | http://www.reprocessed.org/
On 9/25/07, Matt Patterson <matt-lists at reprocessed.org> wrote:> Hi there, > > I''ve been working with RSpec for about a week now, and the process of > moving from a Test::Unit + Mocha setup to an RSpec + Mocha > environment has been pretty straightforward. > > Except, I''m having problems with using template.expect_render. > > I have Mocha enabled with:It is not documented as such, but expect_render does not work with mocha. It uses rspec''s underlying mock framework. Please feel free to submit a feature request for this. Cheers, David> > > config.mock_with :mocha > > in spec_helper. And then I have a view spec which looks like this: > > > it "should explode messily because I have made this partial name > > up" do > > template.expect_render(:partial => ''does_not_exist'', :object => > > "hello") > > render "/a/real/template" > > end > > If I run this spec, it passes, which it really shouldn''t. If I > comment out the config.mock_with :mocha line and re-run the spec, it > fails with: > > > Mock ''expect_render_mock_proxy'' expected :render with > > ({:partial=>"does_not_exist", :object=>"hello"}) once, but received > > it 0 times > > Which is much better. > > So, to me, this looks like a bug in rspec_on_rails. > > Explanations of why I''m just doing it wrong gratefully received ;-) > > Matt > > -- > Matt Patterson | Design & Code > <matt at reprocessed.org> | http://www.reprocessed.org/ > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On 25 Sep 2007, at 16:06, David Chelimsky wrote:> On 9/25/07, Matt Patterson <matt-lists at reprocessed.org> wrote: >> Hi there, >> >> I''ve been working with RSpec for about a week now, and the process of >> moving from a Test::Unit + Mocha setup to an RSpec + Mocha >> environment has been pretty straightforward. >> >> Except, I''m having problems with using template.expect_render. >> >> I have Mocha enabled with: > > It is not documented as such, but expect_render does not work with > mocha. It uses rspec''s underlying mock framework.Yes, I knew about that, but the rdoc in lib/spec/rails/dsl/behaviour/ render_observer.rb made it sound like it should still work: # Also, +expect_render+ uses parts of RSpec''s mock expectation framework. Because # it wraps only a subset of the framework, using this will create no conflict with # other mock frameworks if you choose to use them. Additionally, the object returned # by expect_render is an RSpec mock object, which means that you can call any of the # chained methods available in RSpec''s mocks.> Please feel free to submit a feature request for this.I''d be happy to have a look and see whether I could patch it myself, but I''ve been having a few problems running all the specs cleanly. Currently rake pre_commit is bailing after the first spec run with complaints from rcov (both in 1.0.8 and trunk). Can you give me some pointers on getting the tests to run cleanly? Thanks, Matt -- Matt Patterson | Design & Code <matt at reprocessed.org> | http://www.reprocessed.org/
On 9/25/07, Matt Patterson <matt-lists at reprocessed.org> wrote:> On 25 Sep 2007, at 16:06, David Chelimsky wrote: > > > On 9/25/07, Matt Patterson <matt-lists at reprocessed.org> wrote: > >> Hi there, > >> > >> I''ve been working with RSpec for about a week now, and the process of > >> moving from a Test::Unit + Mocha setup to an RSpec + Mocha > >> environment has been pretty straightforward. > >> > >> Except, I''m having problems with using template.expect_render. > >> > >> I have Mocha enabled with: > > > > It is not documented as such, but expect_render does not work with > > mocha. It uses rspec''s underlying mock framework. > > Yes, I knew about that, but the rdoc in lib/spec/rails/dsl/behaviour/ > render_observer.rb made it sound like it should still work: > > # Also, +expect_render+ uses parts of RSpec''s mock > expectation framework. Because > # it wraps only a subset of the framework, using this will > create no conflict with > # other mock frameworks if you choose to use them. > Additionally, the object returned > # by expect_render is an RSpec mock object, which means that > you can call any of the > # chained methods available in RSpec''s mocks.Oh - I forgot about that - it actually should work :)> > > Please feel free to submit a feature request for this. > > I''d be happy to have a look and see whether I could patch it myself, > but I''ve been having a few problems running all the specs cleanly. > Currently rake pre_commit is bailing after the first spec run with > complaints from rcov (both in 1.0.8 and trunk). > > Can you give me some pointers on getting the tests to run cleanly?What platform are you on?> > Thanks, > > Matt > > > -- > Matt Patterson | Design & Code > <matt at reprocessed.org> | http://www.reprocessed.org/ > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On 25 Sep 2007, at 16:57, Matt Patterson wrote:> On 25 Sep 2007, at 16:06, David Chelimsky wrote: >> >> It is not documented as such, but expect_render does not work with >> mocha. It uses rspec''s underlying mock framework. > > Yes, I knew about that, but the rdoc in lib/spec/rails/dsl/behaviour/ > render_observer.rb made it sound like it should still work:Sorry, that sounded a bit snippy - it wasn''t meant to. And I forgot to say thanks for the prompt response. Thanks! Matt -- Matt Patterson | Design & Code <matt at reprocessed.org> | http://www.reprocessed.org/
On 25 Sep 2007, at 17:00, David Chelimsky wrote:> Oh - I forgot about that - it actually should work :)Heh.>> Can you give me some pointers on getting the tests to run cleanly? > > What platform are you on?OS X, with Ruby 1.8.6 Matt -- Matt Patterson | Design & Code <matt at reprocessed org> | http://www.reprocessed.org/
On 9/25/07, Matt Patterson <matt-lists at reprocessed.org> wrote:> On 25 Sep 2007, at 17:00, David Chelimsky wrote: > > > Oh - I forgot about that - it actually should work :) > > Heh. > > >> Can you give me some pointers on getting the tests to run cleanly? > > > > What platform are you on? > > OS X, with Ruby 1.8.6Me too and I get 100% coverage. Are you just getting a coverage problem, or is it something else? Can you post the output you''re getting?> > Matt > > -- > Matt Patterson | Design & Code > <matt at reprocessed org> | http://www.reprocessed.org/ > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On 25 Sep 2007, at 17:12, David Chelimsky wrote:>> OS X, with Ruby 1.8.6 > > Me too and I get 100% coverage.I''m running the mysql.com MySQL 5.0.45 mac intel build, and the native mysql gem (2.7), if that helps> Are you just getting a coverage problem, or is it something else? Can > you post the output you''re getting?pasted below. Also, when running rake examples_with_rcov in the rspec dir of my checkout I get the headline figure: Name | Total lines | Lines of code | Total coverage | Code coverage TOTAL | 5548 | 3800 | 71.1% | 59.7% Do you want to zip up rspec/coverage and send that too? Matt ---- [~/sandbox/rspec-1.0.8] matt$ rake pre_commit (in /Users/matt/sandbox/rspec-1.0.8) (in /Users/matt/sandbox/rspec-1.0.8/rspec) ** Invoke pre_commit (first_time) ** Execute pre_commit ** Invoke verify_rcov (first_time) ** Invoke spec (first_time) ** Invoke clobber_spec (first_time) ** Execute clobber_spec ** Execute spec ........................................................................ ........................................................................ ........................................................................ ..............................................................The :any_a rgs constraint is deprecated. Use any_args() instead. .The :string constraint is deprecated. Use an_instance_of(String) instead. .The :anything constraint is deprecated. Use anything() instead. .The :numeric constraint is deprecated. Use an_instance_of(Numeric) instead. .The :numeric constraint is deprecated. Use an_instance_of(Numeric) instead. .The :boolean constraint is deprecated. Use boolean() instead. .The :boolean constraint is deprecated. Use boolean() instead. ..................................The :no_args constraint is deprecated. Use no_args() instead. .The :no_args constraint is deprecated. Use no_args() instead. .........................................................The :string constraint is deprecated. Use an_instance_of(String) instead. .The :numeric constraint is deprecated. Use an_instance_of(Numeric) instead. .The :boolean constraint is deprecated. Use boolean() instead. ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ................ Finished in 5.021135 seconds 898 examples, 0 failures ** Execute verify_rcov Coverage: 98.9% (threshold: 100.0%) rake aborted! Coverage must be at least 100.0% but was 98.9% ./lib/spec/rake/verify_rcov.rb:47:in `define'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `synchronize'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke'' /Users/matt/sandbox/rspec-1.0.8/pre_commit/lib/pre_commit/ pre_commit.rb:9:in `rake_invoke'' /Users/matt/sandbox/rspec-1.0.8/pre_commit/lib/pre_commit/core.rb: 11:in `website'' /Users/matt/sandbox/rspec-1.0.8/pre_commit/lib/pre_commit/core.rb: 3:in `pre_commit'' /Users/matt/sandbox/rspec-1.0.8/rspec/rakefile:175 /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `synchronize'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `each'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in `top_level'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in `run'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in `run'' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 /usr/local/bin/rake:16:in `load'' /usr/local/bin/rake:16 rake aborted! RSpec Core pre_commit failed /Users/matt/sandbox/rspec-1.0.8/rakefile:9 -- Matt Patterson | Design & Code <matt at reprocessed org> | http://www.reprocessed.org/
On 9/25/07, Matt Patterson <matt-lists at reprocessed.org> wrote:> > On 25 Sep 2007, at 17:12, David Chelimsky wrote: > > >> OS X, with Ruby 1.8.6 > > > > Me too and I get 100% coverage. > > I''m running the mysql.com MySQL 5.0.45 mac intel build, and the > native mysql gem (2.7), if that helps > > > Are you just getting a coverage problem, or is it something else? Can > > you post the output you''re getting? > > pasted below.Two things: 1. If you''re patching you should be working w/ trunk, not the release. 2. Do you have the latest version of rcov (0.8)?> > Also, when running rake examples_with_rcov in the rspec dir of my > checkout I get the headline figure: > Name | Total lines | Lines of code | Total coverage | Code coverage > TOTAL | 5548 | 3800 | 71.1% | 59.7% > > Do you want to zip up rspec/coverage and send that too? > > Matt > > ---- > > [~/sandbox/rspec-1.0.8] matt$ rake pre_commit > (in /Users/matt/sandbox/rspec-1.0.8) > (in /Users/matt/sandbox/rspec-1.0.8/rspec) > ** Invoke pre_commit (first_time) > ** Execute pre_commit > ** Invoke verify_rcov (first_time) > ** Invoke spec (first_time) > ** Invoke clobber_spec (first_time) > ** Execute clobber_spec > ** Execute spec > ........................................................................ > ........................................................................ > ........................................................................ > ..............................................................The :any_a > rgs constraint is deprecated. Use any_args() instead. > .The :string constraint is deprecated. Use an_instance_of(String) > instead. > .The :anything constraint is deprecated. Use anything() instead. > .The :numeric constraint is deprecated. Use an_instance_of(Numeric) > instead. > .The :numeric constraint is deprecated. Use an_instance_of(Numeric) > instead. > .The :boolean constraint is deprecated. Use boolean() instead. > .The :boolean constraint is deprecated. Use boolean() instead. > ..................................The :no_args constraint is > deprecated. Use no_args() instead. > .The :no_args constraint is deprecated. Use no_args() instead. > .........................................................The :string > constraint is deprecated. Use an_instance_of(String) instead. > .The :numeric constraint is deprecated. Use an_instance_of(Numeric) > instead. > .The :boolean constraint is deprecated. Use boolean() instead. > ........................................................................ > ........................................................................ > ........................................................................ > ........................................................................ > ........................................................................ > ........................................................................ > ........................................................................ > ................ > > Finished in 5.021135 seconds > > 898 examples, 0 failures > ** Execute verify_rcov > Coverage: 98.9% (threshold: 100.0%) > rake aborted! > Coverage must be at least 100.0% but was 98.9% > ./lib/spec/rake/verify_rcov.rb:47:in `define'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > `execute'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > `execute'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in > `synchronize'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke'' > /Users/matt/sandbox/rspec-1.0.8/pre_commit/lib/pre_commit/ > pre_commit.rb:9:in `rake_invoke'' > /Users/matt/sandbox/rspec-1.0.8/pre_commit/lib/pre_commit/core.rb: > 11:in `website'' > /Users/matt/sandbox/rspec-1.0.8/pre_commit/lib/pre_commit/core.rb: > 3:in `pre_commit'' > /Users/matt/sandbox/rspec-1.0.8/rspec/rakefile:175 > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > `execute'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in > `execute'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in > `synchronize'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in > `top_level'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `each'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in > `top_level'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in > `standard_exception_handling'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in > `top_level'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in `run'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in > `standard_exception_handling'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in `run'' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 > /usr/local/bin/rake:16:in `load'' > /usr/local/bin/rake:16 > rake aborted! > RSpec Core pre_commit failed > /Users/matt/sandbox/rspec-1.0.8/rakefile:9 > > > > -- > Matt Patterson | Design & Code > <matt at reprocessed org> | http://www.reprocessed.org/ > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On 25 Sep 2007, at 17:35, David Chelimsky wrote:> On 9/25/07, Matt Patterson <matt-lists at reprocessed.org> wrote: >> > Two things: > > 1. If you''re patching you should be working w/ trunk, not the release.Yeah, I got the same problem with trunk so I thought I''d see if I could figure out what was going on with the latest release in case it was just a trunk thing (although, judging by rake pre_commit, you guys are pretty strict :-).> 2. Do you have the latest version of rcov (0.8)?I do: 0.8.0.2. Headlines from running rake pre_commit against trunk:> Finished in 0.028033 seconds > > 92 examples, 0 failures, 3 pending> Finished in 5.320475 seconds > > 1024 examples, 0 failures, 4 pending> ** Execute verify_rcov > Coverage: 99.0% (threshold: 100.0%) > rake aborted! > Coverage must be at least 100.0% but was 99.0%I can send you the rcov HTML products if you want... Matt -- Matt Patterson | Design & Code <matt at reprocessed org> | http://www.reprocessed.org/
On 9/25/07, Matt Patterson <matt-lists at reprocessed.org> wrote:> On 25 Sep 2007, at 17:35, David Chelimsky wrote: > > > On 9/25/07, Matt Patterson <matt-lists at reprocessed.org> wrote: > >> > > Two things: > > > > 1. If you''re patching you should be working w/ trunk, not the release. > > Yeah, I got the same problem with trunk so I thought I''d see if I > could figure out what was going on with the latest release in case it > was just a trunk thing (although, judging by rake pre_commit, you > guys are pretty strict :-). > > > 2. Do you have the latest version of rcov (0.8)? > > I do: 0.8.0.2. > > Headlines from running rake pre_commit against trunk: > > > Finished in 0.028033 seconds > > > > 92 examples, 0 failures, 3 pending > > > Finished in 5.320475 seconds > > > > 1024 examples, 0 failures, 4 pending > > > ** Execute verify_rcov > > Coverage: 99.0% (threshold: 100.0%) > > rake aborted! > > Coverage must be at least 100.0% but was 99.0% > > > I can send you the rcov HTML products if you want...Zip it up!> > Matt > > -- > Matt Patterson | Design & Code > <matt at reprocessed org> | http://www.reprocessed.org/ > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On 25 Sep 2007, at 19:09, David Chelimsky wrote:>> I can send you the rcov HTML products if you want... > > Zip it up!I finally looked at the Rakefile to see where the rcov output was, had a look and... found the problem: Name | Total lines | Lines of code | Total coverage | Code coverage /Users/matt/.autotest | 133 | 103 | 48.9% | 37.9% I''ve sent the zip (direct to you) anyway, but there''s your problem... rake verify_rcov is running rcov on my ~/.autotest file for some reason... Matt -- Matt Patterson | Design & Code <matt at reprocessed org> | http://www.reprocessed.org/
On 9/25/07, Matt Patterson <matt-lists at reprocessed.org> wrote:> On 25 Sep 2007, at 19:09, David Chelimsky wrote: > > >> I can send you the rcov HTML products if you want... > > > > Zip it up! > > I finally looked at the Rakefile to see where the rcov output was, > had a look and... found the problem: > > Name | Total lines | Lines of code | Total coverage > | Code coverage > /Users/matt/.autotest | 133 | 103 | 48.9% > | 37.9%D''oh!!!!> > I''ve sent the zip (direct to you) anyway, but there''s your problem... > rake verify_rcov is running rcov on my ~/.autotest file for some > reason...> > Matt > > -- > Matt Patterson | Design & Code > <matt at reprocessed org> | http://www.reprocessed.org/ > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >