search for: expect_render

Displaying 20 results from an estimated 23 matches for "expect_render".

2007 Aug 13
8
How to use expect_render?
Hi: I am a rspec beginner. I have scratched my head for the whole afternoon, trying to figure out a way of writing render expectation in controller spec. However, I failed. It kept telling me that the ''expect_render'' was an undefined method. I have installed rspec 1.0.8 and rspec_on_rails as well. Below is the controller to be tested. Controller def index pre = Array.new render :partial=>''index'', :layout=>false, :locals=>{:pre=>pre} end My cont...
2007 Jul 14
3
expect_render twice in views
I found this: controller.expect_render(:partial => ''thing'', :collection => things).once but I am trying to expect_render twice in my view spec: template.expect_render(:partial => ''order_details'').twice This doesn''t work as the template.expect_render call seems to be returning an...
2007 Sep 14
5
controller.expect_render has me beat!
...:action => :edit, :id => params[:id] # this line here* end ... end The example has the following it ''should render the "edit" config url on an unsuccessful save'' do @config.should_receive(:update_attributes).once.and_return(false) c*ontroller.expect_render( :action => :edit, :id => 1 ).once # my prob* do_update end This fails with Mock ''expect_render_mock_proxy'' expected :render with ({:action=>:edit, :id=>1}) once, but received it 0 times I have tried controller.expect_render( :action => :edit...
2007 Aug 14
12
expect_render, why does there need to be a warning
There is a warning on the web site about expect_render and stub_render: "WARNING: expect_render and stub_render, while very useful, act differently from standard Message Expectations (a.k.a. mock expectations), which would never pass calls through to the real object. This can be very confusing when there are failures if you''re not aware...
2008 Mar 12
2
RSpec view test for :partial with :locals?
I''m currently working on some RSpec view tests and I''m having problems with expect_render. Most of the expect_render''s work fine, but in one of my views I have: <%= render :partial => "user_cloud", :locals => {:user => @featured_user} %> I see that expect_render supports ":object" or ":collection" for the second parameter, b...
2008 Jan 23
4
expect_render(...).and_return(''x'')
Hi, I''m trying to spec a controller method which renders some rjs as part of a render :update block. The problem I''m having is that stub_render or expect_render don''t seem to allow and_return to work. The controller method does: if @thing.save render :update do |page| page.insert_html :bottom, ''x_thing_list'', :partial => ''thing'', :object => @thing...
2007 Jun 27
3
template.expect_render
...t added a couple of methods to ActionView::Base in Spec::Rails (as of r2136) that lets you do this in view examples: describe ''/things/index.html.erb'' do it "should render _thing with a collection of things" do assigns[:things] = things = [Object.new] template.expect_render(:partial => ''thing'', :collection => things) render ''/things/index.html.erb'' end end This solves two big problems - mocking nested partials and mocking :object and :collection in partials. template.expect_render wraps part of ''spec/mocks'...
2008 Aug 08
2
template.expect_render fails when partial is rendered from a helper
...template.stub!(:logged_in?).and_return(true) template.stub! (:current_profile).at_least(:once).and_return(mock_profile) end def do_render render "/homepages/show.html.erb" end it "should render the logged in partial for homepages" do template.expect_render(:partial => ''shared/subnav/home'', :locals => {:active => :home}) do_render end end passes if I render the partial directly in the view, render :partial => ''shared/subnav/home'', :locals => {:active => :home} but it fails if the pa...
2007 Sep 25
12
Problems with expect_render
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 :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'...
2007 Aug 13
1
expect_render not?
hi, I have a template that conditionally renders a partial. Is there a way to test that a partial is NOT rendered? :)
2008 Mar 05
3
having trouble specing an ajax request
..."should list all deals" do controller.stub!(:prepare_search_conditions).and_return(true) Deal.should_receive(:paginate).with(:all, {:conditions=>true, :order=>"created_at DESC", :page=>nil}).and_return(@deals) get :list controller.expect_render(:partial => ''/deals/cms/list'') end Thanks, Namrata. -- Posted via http://www.ruby-forum.com/.
2007 Sep 08
3
template.expects_render?
Hi All, I''m trying to make use of template.expects_render, is outlined in David''s post(http://blog.davidchelimsky.net/articles/2007/06/28/ template-expects_render). I get an undefined method error on expects_render. I made sure I had the 1.0.8 gem as well as reinstalling the plugin and redoing the bootstrap. Still no luck. So I created a clean project, installed the
2008 Jan 22
0
Trying to spec ExceptionNotifiable behavior
...er customized error 500 pages based on browser agents. For this, I''ve created a fake controller that inherits directly from ActionController::Base: class FooExceptionController < ActionController::Base include ExceptionNotifiable # this action should not fail, used for controller.expect_render(...) checking def ok_action render(:file => "#{RAILS_ROOT}/public/ok.html") end # this action should raise an unexpected exception def fail_action raise StandardError.new("manually raised exception") end end I''m running with RSpec 1.0.8 (pistoned...
2007 Jul 28
2
specing a call to render :layout => "some_layout"
I''m trying to specify that an action should be rendered with a given layout one particular spec. What I''ve got at the moment is this. it "should render with the grabber layout" do controller.should_receive( :render ).with( :layout => "my_layout" ) do_get end This doesnt work even though this call to render is being executed. render :layout
2007 Oct 01
15
how to spec views
I''m trying to spec a view but haven''t done much view specing. This view render different partials depending on authentication of the user: annon, admin, player So I I''ll write if conditionals in the view with the partials it "should render signup propaganda for annon users trying to view games" do render "/games/index.rhtml"
2008 May 03
4
silly partial qu
hi all, i''m just trying to check a partial has been rendered, by using: response.template.should_receive(:render).with(:partial => "tasks/list") this passes, even if I put something bogus in the partial name, such as: response.template.should_receive(:render).with(:partial => "___tassdfsdfks/list") does anyone know why this doesn''t fail? is this the
2008 Jun 02
1
Cherry-picking mocks?!
...tions but this was getting messy. What he really wanted was some kind of paired mock and stub, so that the expectation that the method would be invoked with the given arguments could be verified, but the other calls would just be stubbed. Now after today''s question, and understanding how expect_render and mock_render differ from normal expectations, these seem to be related. Maybe we should be able to say something like: something.expects(:foo).with(someArguments).with(otherArguments).otherwise(:stub) something_else.expects(:bar).with(arguments).otherwise(:pass) # if the arguments don...
2007 Aug 13
3
RSpec-1.0.8
The RSpec Development Team is pleased to announce the release of RSpec-1.0.8. RSpec 1.0.6 is the "holy cow, batman, it''s been a long time since we released and there are a ton of bug fixes, patches and even new features" release. RSpec 1.0.7 and 1.0.8 deal with a regression introduced in 1.0.6 and a hiccup in releasing 1.0.7, respectively. == RSpec RSpec is a Behaviour Driven
2008 Oct 24
4
Correct way to spec partials
Hi everybody, 1) Does anybody have full working example of how to test partial templates? 2) What the correct place to test partials: controller or view spec? If controller correct place, should I use integrate_views? 3) Is it true that expect_render is deprecated and I have to use should_receive(:render) 4) How to test that partial''s locals hash is correct? Thx -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081023/b29f4e84/attachment.html&g...
2007 Oct 25
0
How to spec a render:update call
...ate'' } end We used to test this with something like: response.should render_template("_form") response.should have_rjs(:replace_html, ''edit'') ... which works, but doesn''t validate the parameters. Then I discovered we could do: controller.expect_render(:partial => ''form'', :locals => { :operation => ''edit'', :submit_button_value => ''Update'' }) This will check the parameters, but doesn''t confirm *how* the response was rendered - there is no checking of '':replace_html...