diff options
author | Brian Cobb <bcobb@uwalumni.com> | 2014-07-14 08:06:36 -0500 |
---|---|---|
committer | Brian Cobb <bcobb@uwalumni.com> | 2014-07-14 08:06:36 -0500 |
commit | ff3ff93a1cf762024169016f78dd4c45c9dd5a76 (patch) | |
tree | f52d7d213d7e742053b8a545f27c285678d71c61 | |
parent | 3ec42a522a5b40d1ef217f23831b7417bda65761 (diff) | |
download | chef-ff3ff93a1cf762024169016f78dd4c45c9dd5a76.tar.gz |
Version constraints only show patch level if one is given
-rw-r--r-- | lib/chef/version_constraint.rb | 4 | ||||
-rw-r--r-- | spec/unit/version_constraint_spec.rb | 28 |
2 files changed, 30 insertions, 2 deletions
diff --git a/lib/chef/version_constraint.rb b/lib/chef/version_constraint.rb index 7bfde41e74..eebbe8307c 100644 --- a/lib/chef/version_constraint.rb +++ b/lib/chef/version_constraint.rb @@ -50,11 +50,11 @@ class Chef end def inspect - "(#{@op} #{@version})" + "(#{to_s})" end def to_s - "#{@op} #{@version}" + "#{@op} #{@raw_version}" end def eql?(o) diff --git a/spec/unit/version_constraint_spec.rb b/spec/unit/version_constraint_spec.rb index 4184689e2b..dfa4740d51 100644 --- a/spec/unit/version_constraint_spec.rb +++ b/spec/unit/version_constraint_spec.rb @@ -148,4 +148,32 @@ describe Chef::VersionConstraint do vc.should_not include "0.3.0" end end + + describe 'to_s' do + it 'shows a patch-level if one is given' do + vc = Chef::VersionConstraint.new '~> 1.2.0' + + vc.to_s.should == '~> 1.2.0' + end + + it 'shows no patch-level if one is not given' do + vc = Chef::VersionConstraint.new '~> 1.2' + + vc.to_s.should == '~> 1.2' + end + end + + describe 'inspect' do + it 'shows a patch-level if one is given' do + vc = Chef::VersionConstraint.new '~> 1.2.0' + + vc.inspect.should == '(~> 1.2.0)' + end + + it 'shows no patch-level if one is not given' do + vc = Chef::VersionConstraint.new '~> 1.2' + + vc.inspect.should == '(~> 1.2)' + end + end end |