require 'spec_helper'

describe Librarian::Puppet::Requirement do

  it 'should handle .x versions' do
    described_class.new('1.x').gem_requirement.should eq('~> 1.0')
    described_class.new('1.0.x').gem_requirement.should eq('~> 1.0.0')
  end

  it 'should handle version ranges' do
    described_class.new('>=1.1.0 <2.0.0').gem_requirement.should eq(['>=1.1.0', '<2.0.0'])
  end

  it 'should print to_s' do
    described_class.new('1.x').to_s.should eq('~> 1.0')
    described_class.new('>=1.1.0 <2.0.0').to_s.should eq("[\">=1.1.0\", \"<2.0.0\"]")
  end
end

require 'spec_helper'

describe Librarian::Puppet::Requirement do

  it 'should handle .x versions' do
    described_class.new('1.x').gem_requirement.should eq('~> 1.0')
    described_class.new('1.0.x').gem_requirement.should eq('~> 1.0.0')
  end

  it 'should handle version ranges' do
    described_class.new('>=1.1.0 <2.0.0').gem_requirement.should eq(['>=1.1.0', '<2.0.0'])
  end

  it 'should print to_s' do
    described_class.new('1.x').to_s.should eq('~> 1.0')
    expected = RUBY_VERSION =~ /^1\.8\./ ? ">=1.1.0<2.0.0" : "[\">=1.1.0\", \"<2.0.0\"]"
    described_class.new('>=1.1.0 <2.0.0').to_s.should eq(expected)
  end
end

Fix spec for ruby 1.8
Fix spec for ruby 1.8
