Some of the specs are failing While upgrading ruby, rails versions.
More often for the controller actions which are rendering JSON and XML responses.
Old versions: ruby -v (1.9.3p551), rails -v (3.0.13), rspec -v (2.4.0)
New Versions: ruby -v (2.4.4p296), rails -v (4.2.11), rspec -v (2.99.2)
I have tried by mentioning format as well.
describe "GET index" do
it "assigns all users as @users" do
get :index, params, format: :json
end
end
app/controllers/users_controller.rb
class UsersController < ApplicationController
respond_to :json,:xml, :html
def index
@users = User.where(:gciunt => params[:gciunt])
respond_to do |format|
format.json {render :json => @users, :callback => params[:callback]}
end
end
end
spec/controllers/users_controller_spec.rb
require 'spec_helper'
describe UsersController do
def mock_user(stubs={})
(@mock_user ||= mock_model(User).as_null_object).tap do |user|
user.stub(stubs) unless stubs.empty?
end
end
describe "GET index" do
it "assigns all users as @users" do
params = {:gciunt => "37"}
User.should_receive(:where).with(params) { [mock_user] }
get :index, params, format: :json
assigns(:users).should eq([mock_user])
end
end
end
Error
<b>Failure/Error: get :index, params
ActionController::UnknownFormat:
ActionController::UnknownFormat
# ./app/controllers/users_controller.rb:6:in `index'
# ./spec/controllers/users_controller_spec.rb:15:in `block (3 levels) in <top (required)>'<b>
This error is occurring only after upgrading ruby, rails, RSpec.