I’m running this test on rspec…
it 'get email is successful' do
get :email
response.should be_success
response.should render_template('email')
end
Where the controller code looks like this..
def email
respond_to do |format|
format.js
end
end
On my terminal I’m returning with….
3) PostsController checking to see if response for post email is successful
Failure/Error: response.should be_success
expected success? to return true, got false
# ./spec/controllers/posts_controller_spec.rb:116:in `block (3 levels) in <top
(required)>'
What am I missing here to make the test work? It has to be something obvious. My view file is titled email.js.erb. This action is meant for an AJAX call.
try:
your request seems not to take into account the expected response type. In Rspec, this is the way to do it if you want to simulate AJAX (XHR) requests.