Skip to content

Commit

Permalink
Remove rails_5_x? method
Browse files Browse the repository at this point in the history
  • Loading branch information
vsppedro committed Mar 9, 2021
1 parent f74f08c commit 59fee8a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
4 changes: 0 additions & 4 deletions spec/support/unit/helpers/rails_versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ def rails_version
Tests::Version.new(Rails::VERSION::STRING)
end

def rails_5_x?
rails_version =~ '~> 5.0'
end

def rails_gte_5_2?
rails_version >= 5.2
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1051,30 +1051,28 @@ def belonging_to_non_existent_class(model_name, assoc_name, options = {})
}.to fail_with_message(message)
end

if rails_5_x?
context 'index_errors' do
it 'accepts an association with a matching :index_errors option' do
define_model :child, parent_id: :integer
define_model :parent do
has_many :children, index_errors: true
end
expect(Parent.new).to have_many(:children).index_errors(true)
context 'index_errors' do
it 'accepts an association with a matching :index_errors option' do
define_model :child, parent_id: :integer
define_model :parent do
has_many :children, index_errors: true
end
expect(Parent.new).to have_many(:children).index_errors(true)
end

it 'rejects an association with a non-matching :index_errors option and returns the correct message' do
define_model :child, parent_id: :integer
define_model :parent do
has_many :children, autosave: false
end
it 'rejects an association with a non-matching :index_errors option and returns the correct message' do
define_model :child, parent_id: :integer
define_model :parent do
has_many :children, autosave: false
end

message =
'Expected Parent to have a has_many association called children '\
'(children should have index_errors set to true)'
message =
'Expected Parent to have a has_many association called children '\
'(children should have index_errors set to true)'

expect {
expect(Parent.new).to have_many(:children).index_errors(true)
}.to fail_with_message(message)
end
expect {
expect(Parent.new).to have_many(:children).index_errors(true)
}.to fail_with_message(message)
end
end

Expand Down

0 comments on commit 59fee8a

Please sign in to comment.