Skip to content

Commit

Permalink
Use 1.9 style syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
drapergeek committed Sep 13, 2013
1 parent a8c6be7 commit 90364bf
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions spec/shoulda/matchers/active_model/comparison_matcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,46 @@

describe Shoulda::Matchers::ActiveModel::ComparisonMatcher do
context 'is_greater_than' do
it { instance_with_validations(:greater_than => 2).should matcher.is_greater_than(2) }
it { instance_with_validations(greater_than: 2).should matcher.is_greater_than(2) }
it { instance_without_validations.should_not matcher.is_greater_than(2) }
end

context 'greater_than_or_equal_to' do
it { instance_with_validations(:greater_than_or_equal_to => 2).should matcher.is_greater_than_or_equal_to(2) }
it { instance_with_validations(greater_than_or_equal_to: 2).should matcher.is_greater_than_or_equal_to(2) }
it { instance_without_validations.should_not matcher.is_greater_than_or_equal_to(2) }
end

context 'less_than' do
it { instance_with_validations(:less_than => 2).should matcher.is_less_than(2) }
it { instance_with_validations(less_than: 2).should matcher.is_less_than(2) }
it { instance_without_validations.should_not matcher.is_less_than(2) }
end

context 'less_than_or_equal_to' do
it { instance_with_validations(:less_than_or_equal_to => 2).should matcher.is_less_than_or_equal_to(2) }
it { instance_with_validations(less_than_or_equal_to: 2).should matcher.is_less_than_or_equal_to(2) }
it { instance_without_validations.should_not matcher.is_less_than_or_equal_to(2) }
end

context 'is_equal_to' do
it { instance_with_validations(:equal_to => 0).should matcher.is_equal_to(0) }
it { instance_with_validations(equal_to: 0).should matcher.is_equal_to(0) }
it { instance_without_validations.should_not matcher.is_equal_to(0) }
end

context 'with_message' do
it 'verifies the message for the validation' do
instance = instance_with_validations(:equal_to => 0, :message => 'Must be zero')
instance = instance_with_validations(equal_to: 0, message: 'Must be zero')
instance.should matcher.is_equal_to(0).with_message('Must be zero')
end
end

def instance_with_validations(options = {})
define_model :example, :attr => :string do
define_model :example, attr: :string do
validates_numericality_of :attr, options
attr_accessible :attr
end.new
end

def instance_without_validations
define_model :example, :attr => :string do
define_model :example, attr: :string do
attr_accessible :attr
end.new
end
Expand Down

0 comments on commit 90364bf

Please sign in to comment.