I was upgrading my rails application from Rails 4.1.9 to 4.2.2.In rails 4.1.9 rspec was green.After the upgrade when i ran the test, i got a couple of rspec failures.
Rails version = 4.2.2
Ruby version = 2.2.4
rspec = 3.0.0
Following are the gems I used for testing,
gem 'rspec-rails'
gem 'rspec_junit_formatter', require: false, git: '[email protected]:sj26/rspec_junit_formatter.git'
gem 'awesome_print'
gem 'factory_girl'
gem 'jasmine'
gem 'jasmine-jquery-rails'
gem 'quiet_assets'
gem 'sequel'
gem 'brakeman', require: false
gem 'qunit-rails'
gem 'webmock', '~> 2.3.1'
gem 'capybara'
gem 'simplecov', require: false
gem 'simplecov-rcov', require: false
gem 'cucumber-rails', require: false
gem 'rack_session_access'
gem 'poltergeist'
gem "faker"
gem 'shoulda-matchers'
gem "shoulda-callback-matchers"
After rails upgrade to 4.2.2 I am getting a failure like,
Failure/Error: response_json = JSON.parse(response.body)['credit_value_rating_types']
TypeError:
no implicit conversion of String into Integer
With rails version from 4.1.9 to 4.2.2, I am missing the key "['credit_value_rating_types']" in the response body.I am actually serializing the response using Activemodel Serializers.
I was unable to find the reason behind the failure.Any insights will be helpfull.
It seems
JSON.parse(response.body)
returns an array and not a hash.And so you get the error because arrays expect integers as indexes.
Check what you get in
JSON.parse(response.body)
.