Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation for ruby 2.4 removed #1040

Closed
wants to merge 53 commits into from
Closed

Conversation

dima4p
Copy link
Contributor

@dima4p dima4p commented Jul 25, 2017

No description provided.

ojab and others added 30 commits January 5, 2016 10:01
The protected_attributes gem is not compatible for Rails 5, and we don't
need it anyway with Strong Parameters.
Create initial environment for Rails 5
Fix #tables deprecation in Rails 5.0  - Fixes thoughtbot#933
Add Rails 5 documentation in rails-5 branch
Remove TravisCI support for Ruby 2.0 and 2.1

Merge Appraisal Gemfiles for different Ruby versions

Remove unused variable in Appraisals file
…recated-ruby-and-rails-versions

Drop support for deprecated Ruby (2.0 and 2.1) and Rails (4.0 and 4.1) versions
…-versions

Update Ruby versions to 2.2.7 and 2.3.4 in TravisCI
mcmire and others added 13 commits July 24, 2017 22:24
…_type' in Rails 5

This patch is based on the discussed held in issue thoughtbot#913, and a solution
that I've proposed and others have confirmed as good to go 👏.

Ref: thoughtbot#913 (comment)
The `delegate_method` matcher uses Doublespeak internally to do its job.
The delegate object is completely stubbed using an ObjectDouble,
available from Doublespeak, which is shoulda-matchers's own test double
library. ObjectDouble is a class that responds to every
method by implementing `method_missing`.

Say you are using Ruby 2.4 and you are testing a class that uses the
Forwardable module to do some delegation, and you are using
`delegate_method` in your test. When you run your test you will a
warning that looks something like:

    Courier#deliver at ~/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/forwardable.rb:156 forwarding to private method #deliver

Why is this happening? When the code in your class gets exercised,
Forwardable will delegate the delegate method in question to
ObjectDouble, and the method will get intercepted by its
`method_missing` method. The fact that this is actually a private method
is what Forwardable is complaining about.

To fix this, all we need to do is add `respond_to_missing?` in addition
to `method_missing?`. This is explained here:

    https://bugs.ruby-lang.org/issues/13326
@@ -548,7 +548,7 @@ def value_to_attribute_type(value)
case value
when true, false then :boolean
when BigDecimal then :decimal
when Fixnum then :fixnum
when Integer then :integer

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent when as deep as case.

@@ -538,7 +538,7 @@ def attribute_column

def column_type_to_attribute_type(type)
case type
when :integer, :float then :fixnum
when :integer, :float then :integer

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent when as deep as case.

@dima4p
Copy link
Contributor Author

dima4p commented Jul 25, 2017

And, please, apply the patch to the minor versions of the gem, at least to v2.8.0 since shoulda still requires it.

@dima4p
Copy link
Contributor Author

dima4p commented Jul 25, 2017

It seems the tests failed due to the configuration not the code. If I am wrong, what happened?

@mcmire mcmire changed the base branch from master to rails-5 July 25, 2017 17:05
@mcmire
Copy link
Collaborator

mcmire commented Jul 25, 2017

Hey @dima4p. Thank you for your PR! I just changed it so that it's now based off of the rails-5 branch which also contains compatibility updates for Ruby 2.4. If you could be so kind as to rebase your branch that would be great! The build is failing right now, so don't worry about that -- we'll merge in your PR when we get that fixed.

@mcmire
Copy link
Collaborator

mcmire commented Jul 30, 2017

@dima4p No need to create a new PR. Pull down the latest changes for rails-5 and rebase your branch against it. GitHub will let you force-push your branch back up :)

@guialbuk guialbuk added this to the v4.0 milestone Jul 31, 2017
@mcmire mcmire force-pushed the rails-5 branch 2 times, most recently from ce6dbad to c288843 Compare September 17, 2017 23:28
@mcmire mcmire changed the base branch from rails-5 to master October 3, 2017 05:00
@mcmire
Copy link
Collaborator

mcmire commented Oct 3, 2017

Thanks for this PR! We've merged this in 03a1d21.

@mcmire mcmire closed this Oct 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants