Christoph Sturm
2007-Apr-17 14:08 UTC
[rspec-users] problem with rspec_on_rails and @controller.should_receive(:render) in trunk
Hey guys! I am using rspec trunk, and I am having a little problem with the latest version. (I am quite sure this worked with an older version about a week ago) heres the spec: it "should render the new user form without layout for a xhr request" do @controller.should_receive(:render).with(:layout=>false) xhr :get,:new end and the controller: def new render :layout=>false end I would have loved to create a failing testcase for this, but I couldnt get the rspec test suite running, if i do a simple "rake" in the root rspec directory i get this error: (in /Users/christophsturm/Projects/rspec/example_rails_app) ** Invoke pre_commit (first_time) ** Execute pre_commit ##################################################### running pre_commit against rails edge ##################################################### ##################################################### ruby script/generate rspec_resource purchase order_id:integer created_at:datetime amount:decimal keyword:string description:text --force ##################################################### /Users/christophsturm/Projects/rspec/example_rails_app/vendor/rails/edge/railties/lib/initializer.rb:514:in `read'': No such file or directory - /Users/christophsturm/Projects/rspec/example_rails_app/config/database.yml (Errno::ENOENT) what am I doing wrong? regards chris
David Chelimsky
2007-Apr-17 14:22 UTC
[rspec-users] problem with rspec_on_rails and @controller.should_receive(:render) in trunk
On 4/17/07, Christoph Sturm <christoph.sturm at gmail.com> wrote:> Hey guys! > > I am using rspec trunk, and I am having a little problem with the > latest version. (I am quite sure this worked with an older version > about a week ago) > > heres the spec: > it "should render the new user form without layout for a xhr request" do > @controller.should_receive(:render).with(:layout=>false) > xhr :get,:new > end > > and the controller: > def new > render :layout=>false > endI don''t know why this should be failing. Are you using edge rails? Perhaps something changed there that we don''t know about.> > I would have loved to create a failing testcase for this, but I > couldnt get the rspec test suite running, if i do a simple "rake" in > the root rspec directory i get this error: > > (in /Users/christophsturm/Projects/rspec/example_rails_app) > ** Invoke pre_commit (first_time) > ** Execute pre_commit > ##################################################### > running pre_commit against rails edge > ##################################################### > ##################################################### > ruby script/generate rspec_resource purchase order_id:integer > created_at:datetime amount:decimal keyword:string description:text > --force > ##################################################### > /Users/christophsturm/Projects/rspec/example_rails_app/vendor/rails/edge/railties/lib/initializer.rb:514:in > `read'': No such file or directory - > /Users/christophsturm/Projects/rspec/example_rails_app/config/database.yml > (Errno::ENOENT) > > > what am I doing wrong?We moved the plugin out from within the example_rails_app, so to run the specs you first must say: rake rspec:install_plugin That will copy {project_root}/rspec_on_rails to {project_root}/example_rails_app/vendor/plugins/ Thanks for looking into this. Cheers, David> > > regards > chris > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
aslak hellesoy
2007-Apr-17 14:34 UTC
[rspec-users] problem with rspec_on_rails and @controller.should_receive(:render) in trunk
Are you using the latest beta gem, trunk or the latest release? On 4/17/07, Christoph Sturm <christoph.sturm at gmail.com> wrote:> Hey guys! > > I am using rspec trunk, and I am having a little problem with the > latest version. (I am quite sure this worked with an older version > about a week ago) > > heres the spec: > it "should render the new user form without layout for a xhr request" do > @controller.should_receive(:render).with(:layout=>false) > xhr :get,:new > end > > and the controller: > def new > render :layout=>false > end > > I would have loved to create a failing testcase for this, but I > couldnt get the rspec test suite running, if i do a simple "rake" in > the root rspec directory i get this error: > > (in /Users/christophsturm/Projects/rspec/example_rails_app) > ** Invoke pre_commit (first_time) > ** Execute pre_commit > ##################################################### > running pre_commit against rails edge > ##################################################### > ##################################################### > ruby script/generate rspec_resource purchase order_id:integer > created_at:datetime amount:decimal keyword:string description:text > --force > ##################################################### > /Users/christophsturm/Projects/rspec/example_rails_app/vendor/rails/edge/railties/lib/initializer.rb:514:in > `read'': No such file or directory - > /Users/christophsturm/Projects/rspec/example_rails_app/config/database.yml > (Errno::ENOENT) > > > what am I doing wrong? > > > regards > chris > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
David Chelimsky
2007-Apr-18 16:35 UTC
[rspec-users] problem with rspec_on_rails and @controller.should_receive(:render) in trunk
On 4/17/07, aslak hellesoy <aslak.hellesoy at gmail.com> wrote:> Are you using the latest beta gem, trunk or the latest release? > > On 4/17/07, Christoph Sturm <christoph.sturm at gmail.com> wrote: > > Hey guys! > > > > I am using rspec trunk, and I am having a little problem with the > > latest version. (I am quite sure this worked with an older version > > about a week ago) > > > > heres the spec: > > it "should render the new user form without layout for a xhr request" do > > @controller.should_receive(:render).with(:layout=>false) > > xhr :get,:new > > end > > > > and the controller: > > def new > > render :layout=>false > > end > > > > I would have loved to create a failing testcase for this, but I > > couldnt get the rspec test suite running, if i do a simple "rake" in > > the root rspec directory i get this error: > > > > (in /Users/christophsturm/Projects/rspec/example_rails_app) > > ** Invoke pre_commit (first_time) > > ** Execute pre_commit > > ##################################################### > > running pre_commit against rails edge > > ##################################################### > > ##################################################### > > ruby script/generate rspec_resource purchase order_id:integer > > created_at:datetime amount:decimal keyword:string description:text > > --force > > ##################################################### > > /Users/christophsturm/Projects/rspec/example_rails_app/vendor/rails/edge/railties/lib/initializer.rb:514:in > > `read'': No such file or directory - > > /Users/christophsturm/Projects/rspec/example_rails_app/config/database.yml > > (Errno::ENOENT) > > > > > > what am I doing wrong? > > > > > > regards > > chrisFYI - Chris says the error is: <UsersController:0x323fe94> expected :render with ({:layout=>false}) but received it with (no args)> > _______________________________________________ > > 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 >
Marcus Ahnve
2007-Apr-19 06:35 UTC
[rspec-users] problem with rspec_on_rails and @controller.should_receive(:render) in trunk
On 4/18/07, David Chelimsky <dchelimsky at gmail.com> wrote:> [...] > FYI - Chris says the error is: > > <UsersController:0x323fe94> expected :render with ({:layout=>false}) > but received it with (no args)I am seeing this as well. I am running a spec like: it "should use application layout" do @controller.should_receive(:render).with(:layout => "/layouts/application") get ''index'' end If I change the spec to fail on purpose by for example changing the expected layout name, I get the correct behaviour. The ''no args'' thing appears when the spec passes. /Marcus
David Chelimsky
2007-Apr-19 14:52 UTC
[rspec-users] problem with rspec_on_rails and @controller.should_receive(:render) in trunk
On 4/19/07, Marcus Ahnve <marcus at ahnve.com> wrote:> On 4/18/07, David Chelimsky <dchelimsky at gmail.com> wrote: > > [...] > > FYI - Chris says the error is: > > > > <UsersController:0x323fe94> expected :render with ({:layout=>false}) > > but received it with (no args) > > I am seeing this as well. > > I am running a spec like: > > it "should use application layout" do > @controller.should_receive(:render).with(:layout => "/layouts/application") > get ''index'' > end > > If I change the spec to fail on purpose by for example changing the > expected layout name, I get the correct behaviour. The ''no args'' thing > appears when the spec passes.OK - I''m getting somewhere with this. What happens is that render is actually called twice. So if you do this: it "should use application layout" do controller.should_receive(:render).with(:layout => "/layouts/application") controller.should_receive(:render).with(:no_args) get ''index'' end ... then the spec will pass. The problem is really one of feedback, IMO. The mock should tell you "hey, you said I should expect a single call w/ these args, but I got another one with these other args". Right now it''s not telling you that your expectation was met AND there was a problem - just that there was a problem. Thoughts?> > /Marcus > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
David Chelimsky
2007-Apr-19 14:57 UTC
[rspec-users] problem with rspec_on_rails and @controller.should_receive(:render) in trunk
On 4/19/07, David Chelimsky <dchelimsky at gmail.com> wrote:> On 4/19/07, Marcus Ahnve <marcus at ahnve.com> wrote: > > On 4/18/07, David Chelimsky <dchelimsky at gmail.com> wrote: > > > [...] > > > FYI - Chris says the error is: > > > > > > <UsersController:0x323fe94> expected :render with ({:layout=>false}) > > > but received it with (no args) > > > > I am seeing this as well. > > > > I am running a spec like: > > > > it "should use application layout" do > > @controller.should_receive(:render).with(:layout => "/layouts/application") > > get ''index'' > > end > > > > If I change the spec to fail on purpose by for example changing the > > expected layout name, I get the correct behaviour. The ''no args'' thing > > appears when the spec passes. > > OK - I''m getting somewhere with this. What happens is that render is > actually called twice. So if you do this: > > it "should use application layout" do > controller.should_receive(:render).with(:layout => "/layouts/application") > controller.should_receive(:render).with(:no_args) > get ''index'' > end > > ... then the spec will pass. > > The problem is really one of feedback, IMO. The mock should tell you > "hey, you said I should expect a single call w/ these args, but I got > another one with these other args". Right now it''s not telling you > that your expectation was met AND there was a problem - just that > there was a problem. > > Thoughts?Afterthought - the original post in this thread said that this problem appeared recently. I''m not 100% certain, but I think this is due to a recent change to how Spec::Rails deals with #rescue_action. It used to just catch everything. Now it lets you define the rescue_action in your controller specs and ensures that mock errors are not caught regardless of what you define. So rspec was actually hiding this problem from you in the past, but is now shining a light on it (as it should have all along). Make sense?> > > > > /Marcus > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > >
Christoph Sturm
2007-Apr-19 23:51 UTC
[rspec-users] problem with rspec_on_rails and @controller.should_receive(:render) in trunk
Hey! On 4/19/07, David Chelimsky <dchelimsky at gmail.com> wrote:> > The problem is really one of feedback, IMO. The mock should tell you > > "hey, you said I should expect a single call w/ these args, but I got > > another one with these other args". Right now it''s not telling you > > that your expectation was met AND there was a problem - just that > > there was a problem. > > > > Thoughts? > > Afterthought - the original post in this thread said that this problem > appeared recently. I''m not 100% certain, but I think this is due to a > recent change to how Spec::Rails deals with #rescue_action. It used to > just catch everything. Now it lets you define the rescue_action in > your controller specs and ensures that mock errors are not caught > regardless of what you define. So rspec was actually hiding this > problem from you in the past, but is now shining a light on it (as it > should have all along). Make sense?Yeah, I agree. If the error message could be fixed all should be good. I think when an expectation failed jmock listed all the expectations and stubs on that mock, and if they were met or not. I think something like that would be great. regards chris
Marcus Ahnve
2007-Apr-20 12:41 UTC
[rspec-users] problem with rspec_on_rails and @controller.should_receive(:render) in trunk
On 4/20/07, Christoph Sturm <christoph.sturm at gmail.com> wrote:> Hey! > > On 4/19/07, David Chelimsky <dchelimsky at gmail.com> wrote: > > > The problem is really one of feedback, IMO. The mock should tell you > > > "hey, you said I should expect a single call w/ these args, but I got > > > another one with these other args". Right now it''s not telling you > > > that your expectation was met AND there was a problem - just that > > > there was a problem. > > > > > > Thoughts? > > > > Afterthought - the original post in this thread said that this problem > > appeared recently. I''m not 100% certain, but I think this is due to a > > recent change to how Spec::Rails deals with #rescue_action. It used to > > just catch everything. Now it lets you define the rescue_action in > > your controller specs and ensures that mock errors are not caught > > regardless of what you define. So rspec was actually hiding this > > problem from you in the past, but is now shining a light on it (as it > > should have all along). Make sense? > > Yeah, I agree. If the error message could be fixed all should be good. > I think when an expectation failed jmock listed all the expectations > and stubs on that mock, and if they were met or not. I think something > like that would be great.Agree. Thanks for your answer David. /Marcus -- http://marcus.ahnve.net