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

cmp should recognise a string being a negative int #3007

Merged
merged 1 commit into from May 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/matchers/matchers.rb
Expand Up @@ -211,7 +211,7 @@
RSpec::Matchers.define :cmp do |first_expected| # rubocop:disable Metrics/BlockLength

def integer?(value)
!(value =~ /\A0+\Z|\A[1-9]\d*\Z/).nil?
!(value =~ /\A-?0+\Z|\A-?[1-9]\d*\Z/).nil?
end

def float?(value)
Expand Down
13 changes: 13 additions & 0 deletions test/integration/default/controls/cmp_matcher_spec.rb
Expand Up @@ -71,6 +71,19 @@
it { should_not cmp >= 13 }
end

describe '-12' do
it { should cmp -12 }
it { should cmp < -11 }
it { should cmp > -13 }
it { should_not cmp < -12 }
it { should_not cmp > -12 }
it { should cmp <= -12 }
it { should cmp >= -12 }
it { should cmp >= -666 }
it { should_not cmp <= -13 }
it { should_not cmp >= -11 }
end

# versions
describe '2.4.12' do
it { should cmp == '2.4.12' }
Expand Down