I''m trying to write a spec asserting that no layout should be used in a controller. My spec currently looks like this: it "should render with no layout" do controller.expect_render.with(hash_including(:layout => nil)) do_action end And this code, which should pass the spec, isn''t: class AController < ApplicationController layout nil end What am I doing wrong? Best, Scott Taylor
On Mon, Sep 29, 2008 at 2:52 PM, Scott Taylor <mailing_lists at railsnewbie.com> wrote:> > I''m trying to write a spec asserting that no layout should be used in a > controller. My spec currently looks like this: > > it "should render with no layout" do > controller.expect_render.with(hash_including(:layout => nil))pre 1.1.5 this should be: controller.expect_render(hash_including(:layout => nil)) (no with) 1.1.5 deprecates expect_render, having fixed the problem w/ should_receive: controller.should_receive(:render).with(hash_including(:layout => nil)) Cheers, David> do_action > end > > > And this code, which should pass the spec, isn''t: > > class AController < ApplicationController > layout nil > end > > What am I doing wrong? > > Best, > > Scott Taylor > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On Sep 29, 2008, at 3:54 PM, David Chelimsky wrote:> On Mon, Sep 29, 2008 at 2:52 PM, Scott Taylor > <mailing_lists at railsnewbie.com> wrote: >> >> I''m trying to write a spec asserting that no layout should be used >> in a >> controller. My spec currently looks like this: >> >> it "should render with no layout" do >> controller.expect_render.with(hash_including(:layout => nil)) > > pre 1.1.5 this should be: > > controller.expect_render(hash_including(:layout => nil)) > (no with) > > 1.1.5 deprecates expect_render, having fixed the problem w/ > should_receive: > > controller.should_receive(:render).with(hash_including(:layout => > nil))That doesn''t seem to be working for me. Will that work with only an explicit call to render :layout => nil the action? Do I need to integrate views? Scott
On Mon, Sep 29, 2008 at 3:30 PM, Scott Taylor <mailing_lists at railsnewbie.com> wrote:> > On Sep 29, 2008, at 3:54 PM, David Chelimsky wrote: > >> On Mon, Sep 29, 2008 at 2:52 PM, Scott Taylor >> <mailing_lists at railsnewbie.com> wrote: >>> >>> I''m trying to write a spec asserting that no layout should be used in a >>> controller. My spec currently looks like this: >>> >>> it "should render with no layout" do >>> controller.expect_render.with(hash_including(:layout => nil)) >> >> pre 1.1.5 this should be: >> >> controller.expect_render(hash_including(:layout => nil)) >> (no with) >> >> 1.1.5 deprecates expect_render, having fixed the problem w/ >> should_receive: >> >> controller.should_receive(:render).with(hash_including(:layout => nil)) > > That doesn''t seem to be working for me. Will that work with only an > explicit call to render :layout => nil the action? Do I need to integrate > views?Didn''t realize that layout nil was a declaration at the top. I haven''t tried this, but you probably do need to integrate views because it''s never getting past the initial render call. That''s just a guess.> > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On Sep 29, 2008, at 4:36 PM, David Chelimsky wrote:> On Mon, Sep 29, 2008 at 3:30 PM, Scott Taylor > <mailing_lists at railsnewbie.com> wrote: >> >> On Sep 29, 2008, at 3:54 PM, David Chelimsky wrote: >> >>> On Mon, Sep 29, 2008 at 2:52 PM, Scott Taylor >>> <mailing_lists at railsnewbie.com> wrote: >>>> >>>> I''m trying to write a spec asserting that no layout should be >>>> used in a >>>> controller. My spec currently looks like this: >>>> >>>> it "should render with no layout" do >>>> controller.expect_render.with(hash_including(:layout => nil)) >>> >>> pre 1.1.5 this should be: >>> >>> controller.expect_render(hash_including(:layout => nil)) >>> (no with) >>> >>> 1.1.5 deprecates expect_render, having fixed the problem w/ >>> should_receive: >>> >>> controller.should_receive(:render).with(hash_including(:layout => >>> nil)) >> >> That doesn''t seem to be working for me. Will that work with only an >> explicit call to render :layout => nil the action? Do I need to >> integrate >> views? > > Didn''t realize that layout nil was a declaration at the top. > > I haven''t tried this, but you probably do need to integrate views > because it''s never getting past the initial render call. That''s just a > guess.That didn''t work either. I had to go diving into rails ugliness, per usual: describe "default layout" do before(:each) do @layout = controller.class.inheritable_attributes["layout"] end it "should have a nil layout" do @layout.should be_nil end end Scott
On Mon, Sep 29, 2008 at 3:51 PM, Scott Taylor <mailing_lists at railsnewbie.com> wrote:> > On Sep 29, 2008, at 4:36 PM, David Chelimsky wrote: > >> On Mon, Sep 29, 2008 at 3:30 PM, Scott Taylor >> <mailing_lists at railsnewbie.com> wrote: >>> >>> On Sep 29, 2008, at 3:54 PM, David Chelimsky wrote: >>> >>>> On Mon, Sep 29, 2008 at 2:52 PM, Scott Taylor >>>> <mailing_lists at railsnewbie.com> wrote: >>>>> >>>>> I''m trying to write a spec asserting that no layout should be used in a >>>>> controller. My spec currently looks like this: >>>>> >>>>> it "should render with no layout" do >>>>> controller.expect_render.with(hash_including(:layout => nil)) >>>> >>>> pre 1.1.5 this should be: >>>> >>>> controller.expect_render(hash_including(:layout => nil)) >>>> (no with) >>>> >>>> 1.1.5 deprecates expect_render, having fixed the problem w/ >>>> should_receive: >>>> >>>> controller.should_receive(:render).with(hash_including(:layout => nil)) >>> >>> That doesn''t seem to be working for me. Will that work with only an >>> explicit call to render :layout => nil the action? Do I need to >>> integrate >>> views? >> >> Didn''t realize that layout nil was a declaration at the top. >> >> I haven''t tried this, but you probably do need to integrate views >> because it''s never getting past the initial render call. That''s just a >> guess. > > That didn''t work either. I had to go diving into rails ugliness, per usual:That''s rails beauty. It''s just testing rails in isolation ugliness :)> > describe "default layout" do > before(:each) do > @layout = controller.class.inheritable_attributes["layout"] > end > > it "should have a nil layout" do > @layout.should be_nil > end > end > > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On Sep 29, 2008, at 5:02 PM, David Chelimsky wrote:> On Mon, Sep 29, 2008 at 3:51 PM, Scott Taylor > <mailing_lists at railsnewbie.com> wrote: >> >> On Sep 29, 2008, at 4:36 PM, David Chelimsky wrote: >> >>> On Mon, Sep 29, 2008 at 3:30 PM, Scott Taylor >>> <mailing_lists at railsnewbie.com> wrote: >>>> >>>> On Sep 29, 2008, at 3:54 PM, David Chelimsky wrote: >>>> >>>>> On Mon, Sep 29, 2008 at 2:52 PM, Scott Taylor >>>>> <mailing_lists at railsnewbie.com> wrote: >>>>>> >>>>>> I''m trying to write a spec asserting that no layout should be >>>>>> used in a >>>>>> controller. My spec currently looks like this: >>>>>> >>>>>> it "should render with no layout" do >>>>>> controller.expect_render.with(hash_including(:layout => nil)) >>>>> >>>>> pre 1.1.5 this should be: >>>>> >>>>> controller.expect_render(hash_including(:layout => nil)) >>>>> (no with) >>>>> >>>>> 1.1.5 deprecates expect_render, having fixed the problem w/ >>>>> should_receive: >>>>> >>>>> controller.should_receive(:render).with(hash_including(:layout >>>>> => nil)) >>>> >>>> That doesn''t seem to be working for me. Will that work with only >>>> an >>>> explicit call to render :layout => nil the action? Do I need to >>>> integrate >>>> views? >>> >>> Didn''t realize that layout nil was a declaration at the top. >>> >>> I haven''t tried this, but you probably do need to integrate views >>> because it''s never getting past the initial render call. That''s >>> just a >>> guess. >> >> That didn''t work either. I had to go diving into rails ugliness, >> per usual: > > That''s rails beauty. It''s just testing rails in isolation ugliness :)Yeah, but it''s clear that this wasn''t test first. If it was, you''d have the following: controller.layout.should be_nil class AController set_layout nil end Scott