[rspec-devel] [ rspec-Bugs-6896 ] should_render fails with respond_to

noreply at rubyforge.org noreply at rubyforge.org
Sun Jan 28 23:05:22 EST 2007


Bugs item #6896, was opened at 2006-11-26 18:40
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=6896&group_id=797

Category: rails plugin
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Pat Maddox (pergesu)
Assigned to: David Chelimsky (dchelimsky)
Summary: should_render fails with respond_to

Initial Comment:
Spec:

  specify "should show the form" do
    controller.should_render :template => "people/new"
  end

Controller code:

  def new
    @person = Person.new
    
    respond_to do |format|
      format.html
    end
  end

Failure:

{:template=>"people/new"} should == {:action=>"new", :content_type=>#<Mime::Type:0x14c2c04 @synonyms=["application/xhtml+xml"], @symbol=:html, @string="text/html">}

----------------------------------------------------------------------

Comment By: François Beausoleil (fbos)
Date: 2007-01-28 23:05

Message:
On a related note:

context "A project owner" do
  controller_name :roles

  specify "can assign roles to other users" do
    post :create, :project_id => 27, :role => {:name => "user"}, :user => {:email => "jim at teksol.info"}
    response.should_redirect_to "/"
  end
end

Given this controller implementation:
class RolesController < ApplicationController
  def create
    @target = User.find_by_email!(params[:user][:email])
    @target.set_project_role(current_project, params[:role][:name])

    respond_to do |wants|
      wants.js
      wants.html { redirect_to dashboard_path }
    end
  end
end

Fails like this:
1)
'A project owner can assign roles to other users' FAILED
expected redirect to http://test.host/ but there was no redirect
/home/francois/src/smrty2/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_controller/test_response.rb:55:in `should_redirect_to'
./spec/controllers/roles_spec.rb:27:


----------------------------------------------------------------------

Comment By: David Chelimsky (dchelimsky)
Date: 2006-11-27 21:44

Message:
I committed a first step towards this in trunk (rev 1160). It now supports format.html only. So far....

----------------------------------------------------------------------

Comment By: Pat Maddox (pergesu)
Date: 2006-11-26 19:20

Message:
Edge rails, 0.7.3

----------------------------------------------------------------------

Comment By: Aslak Hellesøy (aslak_hellesoy)
Date: 2006-11-26 19:20

Message:
versions????

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=6896&group_id=797


More information about the rspec-devel mailing list