spec/gemfile_spec.rb in pessimize-0.3.0 vs spec/gemfile_spec.rb in pessimize-0.4.0

- old
+ new

@@ -184,7 +184,71 @@ } its(:to_s) { should == expected_defn } end end + + context "with multiple gem definitions separated with comments" do + + let(:gem_defn) { <<-GEM +source "https://rubygems.org" + +gem "monkey", "2.0.0" # a comment to throw things off + +gem "thor", ">= 1.3.0" +GEM + } + + subject(:gemfile) { Gemfile.new(gem_defn) } + + its(:to_s) { should == gem_defn } + + describe "#gems" do + subject(:gems) { gemfile.gems } + + its(:length) { should == 2 } + + describe "the first gem" do + subject(:gem) { gems[0] } + + its(:name) { should == "monkey" } + its(:version) { should == "2.0.0" } + its(:to_s) { should == ' "monkey", "2.0.0" ' } + + context "setting the version" do + before do + gem.version = "~> 2.0.0" + end + + its(:to_s) { should == ' "monkey", "~> 2.0.0" ' } + end + end + + describe "the second gem" do + subject { gems[1] } + + its(:name) { should == "thor" } + its(:version) { should == ">= 1.3.0" } + end + end + + context "after setting the gem versions" do + before do + gemfile.gems.each do |gem| + gem.version = "~> 1.0.0" + end + end + + let(:expected_defn) { <<-GEM +source "https://rubygems.org" + +gem "monkey", "~> 1.0.0" # a comment to throw things off + +gem "thor", "~> 1.0.0" +GEM + } + + its(:to_s) { should == expected_defn } + end + end end end