Skip to content

Commit

Permalink
Remove active_record_supports_enum? helper
Browse files Browse the repository at this point in the history
The `enum` macro was introduced in Rails 4.1, which shoulda-matchers no
longer supports, so we can always assume that enum is available.
  • Loading branch information
mcmire committed Jan 28, 2018
1 parent 6bd3fcf commit b1e11fb
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 204 deletions.
4 changes: 0 additions & 4 deletions spec/support/unit/helpers/active_record_versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ def active_record_version
Tests::Version.new(::ActiveRecord::VERSION::STRING)
end

def active_record_supports_enum?
defined?(::ActiveRecord::Enum)
end

def active_record_supports_has_secure_password?
active_record_version >= 3.1
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -815,16 +815,14 @@ def name=(value)
end
end

if active_record_supports_enum?
context 'given an ActiveRecord model' do
context 'where the attribute under test is an enum and the given value is a value in that enum' do
it 'accepts' do
model = define_model('Shipment', status: :integer) do
enum status: { pending: 1, shipped: 2, delivered: 3 }
end

expect(model.new).to allow_value(1).for(:status)
context 'given an ActiveRecord model' do
context 'where the attribute under test is an enum and the given value is a value in that enum' do
it 'accepts' do
model = define_model('Shipment', status: :integer) do
enum status: { pending: 1, shipped: 2, delivered: 3 }
end

expect(model.new).to allow_value(1).for(:status)
end
end
end
Expand Down
Loading

0 comments on commit b1e11fb

Please sign in to comment.