spec/gem_spec.rb in pessimize-0.1.0 vs spec/gem_spec.rb in pessimize-0.2.0
- old
+ new
@@ -1,36 +1,74 @@
require 'spec_helper'
-require 'pessimize/gem.rb'
+require 'pessimize/gem'
module Pessimize
describe Gem do
- context "creating with the name as the only parameter" do
- let(:gem) { Gem.new 'ponies' }
- subject { gem }
+ context "creating a gem with just a name" do
+ let(:gem) { Gem.new(Ripper.lex('gem "monkey"')) }
+ subject { gem }
- its(:name) { should == 'ponies' }
- its(:to_code) { should == 'gem "ponies"' }
+ its(:name) { should == "monkey" }
+ its(:version) { should be_nil }
+ its(:to_s) { should == 'gem "monkey"' }
- context "setting the version" do
- before { gem.version = '~> 3.0.0' }
+ context "after setting the version" do
+ before do
+ gem.version = "~> 2.3.5"
+ end
- its(:version) { should == '~> 3.0.0' }
- its(:to_code) { should == 'gem "ponies", "~> 3.0.0"' }
+ its(:to_s) { should == 'gem "monkey", "~> 2.3.5"' }
end
end
- context "creating with a name and version string" do
- subject { Gem.new 'trolls', '>= 3.0' }
+ context "creating a gem with a name and version" do
+ let(:gem) { Gem.new(Ripper.lex('gem "monkey", "~> 3.0"')) }
+ subject { gem }
- its(:name) { should == 'trolls' }
- its(:version) { should == '>= 3.0' }
- its(:to_code) { should == 'gem "trolls", ">= 3.0"' }
+ its(:name) { should == "monkey" }
+ its(:version) { should == "~> 3.0" }
+ its(:to_s) { should == 'gem "monkey", "~> 3.0"' }
+
+ context "after setting the version" do
+ before do
+ gem.version = "~> 1.0"
+ end
+
+ its(:to_s) { should == 'gem "monkey", "~> 1.0"' }
+ end
end
- context "creating with a name and options hash" do
- subject { Gem.new 'slow_loris', :require => false, :path => '/a/b/c' }
- its(:name) { should == 'slow_loris' }
- its(:options) { should == {:require => false, :path => '/a/b/c'} }
- its(:to_code) { should == 'gem "slow_loris", {:require=>false, :path=>"/a/b/c"}' }
+ context "creating a gem with a name and git url" do
+ let(:gem) { Gem.new(Ripper.lex('gem "something", git: git@somewhere.org:project.git')) }
+ subject { gem }
+
+ its(:name) { should == "something" }
+ its(:version) { should be_nil }
+
+ context "after setting the version" do
+ before do
+ gem.version = "~> 0.0.1"
+ end
+
+ its(:to_s) { should == 'gem "something", "~> 0.0.1", git: git@somewhere.org:project.git' }
+ end
+
+ end
+
+ context "creating a gem with a name, version and options" do
+ let(:gem) { Gem.new(Ripper.lex('gem "blah", "2.0.0beta", group: :development')) }
+ subject { gem }
+
+ its(:name) { should == "blah" }
+ its(:version) { should == "2.0.0beta" }
+
+ context "after setting the version" do
+ before do
+ gem.version = "~> 2.1"
+ end
+
+ its(:to_s) { should == 'gem "blah", "~> 2.1", group: :development' }
+ end
+
end
end
end