shoulda-matchers: `cast_type` use in rails_shim causes a problem with the serialize matcher - Rails 5
I have seen this issue in Rails 5, and shoulda-matchers 3.1.1 (along with pulling shoulda-matchers directly from master).
IntakeRequest should serialize :payload class_name => JSON
Failure/Error: should serialize(:payload).
NoMethodError:
undefined method `cast_type' for #<ActiveRecord::ConnectionAdapters::MySQL::Column:0x007f8dcc21d778>
This cast_type attribute has been removed from ActiveRecord::ConnectionAdapters::MySQL::Column per this commit
The cast_type attribute is called from within the rails_shim
I would be happy to help fix this, but could use some direction if anyone has suggestions on how best to address this.
Note: An issue was created by the cast_type change on the oracle adapter that may have useful information as they come to a resolution.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 9
- Comments: 28 (2 by maintainers)
Commits related to this issue
- Fix thoughtbot/shoulda-matchers#913 use in rails_shim causes a problem with the serialize matcher - Rails 5 — committed to fubarius/shoulda-matchers by fubarius 8 years ago
- Fix #913 for Serialize Matcher error undefined method `cast_type' in Rails 5 This patch is based on the discussed held in issue #913, and a solution that I've proposed and others have confirmed as go... — committed to bsodmike/shoulda-matchers by bsodmike 8 years ago
- Fix #913 for Serialize Matcher error undefined method `cast_type' in Rails 5 This patch is based on the discussed held in issue #913, and a solution that I've proposed and others have confirmed as go... — committed to bsodmike/shoulda-matchers by bsodmike 8 years ago
- Prepared for 3.2.x and Rails 5 Fixed Strong Parameters issue - not saving stripe keys Fixed ActionView::Template::Error (Asset was not declared to be precompiled in production. Add Rails.applicatio... — committed to vinsol-spree-contrib/spree-account-recurring by deleted user 7 years ago
- Fix #913 for Serialize Matcher error undefined method `cast_type' in Rails 5 This patch is based on the discussed held in issue #913, and a solution that I've proposed and others have confirmed as go... — committed to thoughtbot/shoulda-matchers by bsodmike 8 years ago
- Fix #913 for Serialize Matcher error undefined method `cast_type' in Rails 5 This patch is based on the discussed held in issue #913, and a solution that I've proposed and others have confirmed as go... — committed to thoughtbot/shoulda-matchers by bsodmike 8 years ago
- Bump shoulda-matchers to 4.0.1 This removes the warning when using Ruby 2.6: BigDecimal.new is deprecated; use BigDecimal() method instead. This also adds Rails 5 support, which eliminates the need... — committed to tigefa4u/gitlabhq by stanhu 5 years ago
- Bump shoulda-matchers to 4.0.1 This removes the warning when using Ruby 2.6: BigDecimal.new is deprecated; use BigDecimal() method instead. This also adds Rails 5 support, which eliminates the need... — committed to tigefa4u/gitlabhq by stanhu 5 years ago
- Bump shoulda-matchers to 4.0.1 This removes the warning when using Ruby 2.6: BigDecimal.new is deprecated; use BigDecimal() method instead. This also adds Rails 5 support, which eliminates the need... — committed to tigefa4u/gitlabhq by stanhu 5 years ago
- Upgrade shoulda-matchers to 4.0.1 This removes the warning when using Ruby 2.6: BigDecimal.new is deprecated; use BigDecimal() method instead. This also adds Rails 5 support, which eliminates the n... — committed to tigefa4u/gitlabhq by stanhu 5 years ago
@adammcfadden I had to make a small change with respect to shoulda master, and it works a treat. Thanks!
@mcmire unfortunately, yes. I’m using rspec to test a serialization field on my model but I’m facint some errors on those tests:
My model
make.rb
When I run the example
it { is_expected.to serialize(:vehicle_types).as(Array) }
I got this error:
In my
Gemfile.lock
I haveshoulda-matchers (3.1.2)
I merged @bsodmike’s fix into the
rails-5
branch in 28a43a3b6081deb65dc1a25a5cd6f9608728c467, so I’m going to close this to clean things up. We’ll have a new pre-release out soon so people can use that instead of having to use a branch in their Gemfiles.Even a .beta or .rc1 version would be very much appreciated. 😃
I can confirm this works perfectly on master.
A quick note to others, ensure you’re following the master branch of this repository:
@mcmire thanks again for the patch! It would be great to get this into an official release soon.
When will this be fixed and released?
Yep it would be nice to get a new version of shoulda-matchers out, last update was over a year ago.
https://rubygems.org/gems/shoulda-matchers/versions/3.1.2
For the record, it looks like 4.0.0.rc1 was released in Oct with Rails 5 support.
@mcmire Any progress on a pre-release? We’re still using the branch.