spec/version_mapper_spec.rb in pessimize-0.1.0 vs spec/version_mapper_spec.rb in pessimize-0.2.0

- old
+ new

@@ -2,12 +2,18 @@ require 'pessimize/version_mapper' require 'pessimize/gem' module Pessimize describe VersionMapper do + def gem(name, version = nil) + gem_string = %Q{gem "#{name}"} + gem_string << %Q{, "#{version}"} if version + Gem.new(Ripper.lex(gem_string)) + end + context "with a gem, version hash and minor constraint" do - let(:gems) { [ Gem.new('example') ] } + let(:gems) { [ gem('example') ] } let(:versions) { { 'example' => '2.2.3' } } let(:mapper) { VersionMapper.new } before do mapper.call gems, versions, 'minor' @@ -17,11 +23,11 @@ its(:version) { should == '~> 2.2' } end context "with multiple gems, version hash and minor constraint" do - let(:gems) { [ Gem.new('example'), Gem.new('fish', '1.3.2') ] } + let(:gems) { [ gem('example'), gem('fish', '1.3.2') ] } let(:versions) { { 'example' => '1.4.9', 'fish' => '2.3.0' } } let(:mapper) { VersionMapper.new } before do mapper.call gems, versions, 'minor' @@ -39,11 +45,11 @@ its(:version) { should == '~> 2.3' } end end context "with a gem, version hash and patch constraint" do - let(:gems) { [ Gem.new('example') ] } + let(:gems) { [ gem('example') ] } let(:versions) { { 'example' => '2.2.3' } } let(:mapper) { VersionMapper.new } before do mapper.call gems, versions, 'patch' @@ -53,10 +59,10 @@ its(:version) { should == '~> 2.2.3' } end context "with multiple gems, version hash and patch constraint" do - let(:gems) { [ Gem.new('example'), Gem.new('fish', '1.3.2') ] } + let(:gems) { [ gem('example'), gem('fish', '1.3.2') ] } let(:versions) { { 'example' => '1.4.9', 'fish' => '2.3.0' } } let(:mapper) { VersionMapper.new } before do mapper.call gems, versions, 'patch'