Ruby on Rails
Thursday, August 1, 2013
| I found the the xml_http_request or alias xhr for that test "should render js to show the change password form" do sign_in_user xhr :get, :enable_password_change assert_template :enable_password_change assert_response :ok assert assigns(:merchant_user) end |
http://jpereira.eu
On Friday, July 26, 2013 1:10:30 AM UTC+2, João Pereira wrote:
I have this controller:
class UsersController < ApplicationController def enable_password_change respond_to do |format| format.js { render :layout => false } end end end
And the following test:
test "should render js to show the change password form" do sign_in_user request_javascript get :enable_password_change assert_template :enable_password_change assert_response :ok end
And the helper method to set the request headers:
def request_javascript @request.headers["Accepts"] = "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" end
However my test reports:
Finished tests in 0.942294s, 7.4287 tests/s, 15.9186 assertions/s. 1) Error: UsersControllerTest#test_should_render_js_to_show_the_change_password_for: ActionController::UnknownFormat: ActionController::UnknownFormat app/controllers/users_controller.rb:9:in `enable_password_change' test/controllers/users_controller_test.rb:14:in `block in <class:UsersControllerTest>' 7 tests, 15 assertions, 0 failures, 1 errors, 0 skips
What am I doing wrong here?
P.S. Also posted on http://stackoverflow.com/questions/17870266/testing-if-a-controller-renders-a-js-template
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/93a5853a-5434-4545-88c7-504506bb3214%40googlegroups.com.
For more options, visit
https://groups.google.com/groups/opt_out.
No comments:
Post a Comment