spec/integration_spec.rb in pessimize-0.0.3 vs spec/integration_spec.rb in pessimize-0.1.0
- old
+ new
@@ -1,26 +1,26 @@
require 'spec_helper'
describe "running pessimize" do
include IntegrationHelper
- shared_examples "a working pessimizer" do |gemfile, lockfile, result|
+ shared_examples "a working pessimizer" do |gemfile, lockfile, result, cli_args = ""|
before do
write_gemfile(gemfile)
write_gemfile_lock(lockfile)
- run
+ run(cli_args)
end
context "after execution" do
context "the stderr" do
subject { stderr }
it { should == "" }
end
# exclude from jruby
- context "the return code" do
+ context "the return code", platform: :jruby do
subject { $?.exitstatus }
it { should == 0 }
end
context "the Gemfile.backup" do
@@ -39,18 +39,112 @@
it { should == result }
end
end
end
+ shared_examples "a working pessimizer without backups" do |gemfile, lockfile, result, cli_args = ""|
+ before do
+ write_gemfile(gemfile)
+ write_gemfile_lock(lockfile)
+ run(cli_args)
+ end
+
+ context "after execution" do
+
+ context "the stderr" do
+ subject { stderr }
+ it { should == "" }
+ end
+
+ # exclude from jruby
+ context "the return code", platform: :jruby do
+ subject { $?.exitstatus }
+ it { should == 0 }
+ end
+
+ context "the Gemfile.backup" do
+ it "should not exist" do
+ File.exists?(tmp_path + 'Gemfile.backup').should be_false
+ end
+ end
+
+ context "the Gemfile.lock.backup" do
+ it "should not exist" do
+ File.exists?(tmp_path + 'Gemfile.lock.backup').should be_false
+ end
+ end
+
+ context "the Gemfile" do
+ subject { gemfile_contents }
+
+ it { should == result }
+ end
+ end
+ end
+
before do
setup
end
after do
tear_down
end
+ context "with the help option" do
+ before do
+ run('--help')
+ end
+
+ context "the exit status", :platform => :java do
+ subject { status.exitstatus }
+
+ it { should == 0 }
+ end
+
+ context "the output" do
+ subject { stdout }
+
+ it { should include("Usage:") }
+ end
+ end
+
+ context "with the version option" do
+ before do
+ run('--version')
+ end
+
+ context "the exit status", :platform => :java do
+ subject { status.exitstatus }
+
+ it { should == 0 }
+ end
+
+ context "the output" do
+ subject { stdout }
+
+ it { should include(Pessimize::VERSION) }
+ end
+ end
+
+ context "with the version option" do
+ before do
+ run('-c rubbish')
+ end
+
+ context "the exit status", :platform => :java do
+ subject { status.exitstatus }
+
+ it { should == 255 }
+ end
+
+ context "the error output" do
+ subject { stderr }
+
+ it { should include("--version-constraint must be one of minor|patch") }
+ end
+ end
+
context "with no Gemfile" do
before do
run
end
@@ -145,12 +239,12 @@
EOD
result = <<-EOD
source "https://rubygems.org"
-gem "json", "~> 1.8.0"
-gem "rake", "~> 10.0.4"
+gem "json", "~> 1.8"
+gem "rake", "~> 10.0"
EOD
it_behaves_like "a working pessimizer", gemfile, lockfile, result
end
@@ -173,27 +267,27 @@
GEM
remote: https://rubygems.org/
specs:
json (1.8.0)
rake (10.0.4)
- pg (>= 0.15.0)
- sqlite3 (>= 1.3.7)
+ pg (0.15.0)
+ sqlite3 (1.3.7)
EOD
result = <<-EOD
source "https://rubygems.org"
group :development do
- gem "sqlite3", "~> 1.3.7"
+ gem "sqlite3", "~> 1.3"
end
group :production do
- gem "pg", "~> 0.15.0"
+ gem "pg", "~> 0.15"
end
-gem "json", "~> 1.8.0"
-gem "rake", "~> 10.0.4"
+gem "json", "~> 1.8"
+gem "rake", "~> 10.0"
EOD
it_behaves_like "a working pessimizer", gemfile, lockfile, result
end
@@ -212,26 +306,26 @@
GEM
remote: https://rubygems.org/
specs:
json (1.8.0)
rake (10.0.4)
- sqlite3 (>= 1.3.7)
+ sqlite3 (1.3.7)
EOD
result = <<-EOD
source "https://rubygems.org"
group :development do
- gem "sqlite3", "~> 1.3.7"
+ gem "sqlite3", "~> 1.3"
end
group :test do
- gem "sqlite3", "~> 1.3.7"
+ gem "sqlite3", "~> 1.3"
end
-gem "json", "~> 1.8.0"
-gem "rake", "~> 10.0.4"
+gem "json", "~> 1.8"
+gem "rake", "~> 10.0"
EOD
it_behaves_like "a working pessimizer", gemfile, lockfile, result
end
@@ -250,26 +344,26 @@
GEM
remote: https://rubygems.org/
specs:
json (1.8.0)
rake (10.0.4)
- sqlite3 (>= 1.3.7)
+ sqlite3 (1.3.7)
EOD
result = <<-EOD
source "https://rubygems.org"
group :development do
- gem "sqlite3", "~> 1.3.7"
+ gem "sqlite3", "~> 1.3"
end
group :test do
- gem "sqlite3", "~> 1.3.7"
+ gem "sqlite3", "~> 1.3"
end
-gem "json", "~> 1.8.0"
-gem "rake", "~> 10.0.4"
+gem "json", "~> 1.8"
+gem "rake", "~> 10.0"
EOD
it_behaves_like "a working pessimizer", gemfile, lockfile, result
end
@@ -308,21 +402,21 @@
GIT
remote: https://github.com/joonty/metric_fu.git
revision: 8c481090ac928c78ed1f794b4e76b178e1ccf713
specs:
bf4-metric_fu (2.1.3.1)
- activesupport (>= 2.0.0)
+ activesupport (2.0.0)
arrayfields (= 4.7.4)
bluff
chronic (= 0.2.3)
churn (= 0.0.7)
coderay
fattr (= 2.2.1)
flay (= 1.2.1)
flog (= 2.3.0)
googlecharts
- japgolly-Saikuro (>= 1.1.1.0)
+ japgolly-Saikuro (1.1.1.0)
main (= 4.7.1)
map (= 6.2.0)
rails_best_practices (~> 0.6)
rcov (~> 0.8)
reek (= 1.2.12)
@@ -336,11 +430,11 @@
result = <<-EOD
source "https://somewhere-else.org"
gem "metric_fu", {:git=>"https://github.com/joonty/metric_fu.git", :branch=>"master"}
-gem "kaminari", "~> 0.14.1", {:require=>false}
+gem "kaminari", "~> 0.14", {:require=>false}
EOD
it_behaves_like "a working pessimizer", gemfile, lockfile, result
end
@@ -356,21 +450,21 @@
GIT
remote: https://github.com/joonty/metric_fu.git
revision: 8c481090ac928c78ed1f794b4e76b178e1ccf713
specs:
bf4-metric_fu (2.1.3.1)
- activesupport (>= 2.0.0)
+ activesupport (2.0.0)
arrayfields (= 4.7.4)
bluff
chronic (= 0.2.3)
churn (= 0.0.7)
coderay
fattr (= 2.2.1)
flay (= 1.2.1)
flog (= 2.3.0)
googlecharts
- japgolly-Saikuro (>= 1.1.1.0)
+ japgolly-Saikuro (1.1.1.0)
main (= 4.7.1)
map (= 6.2.0)
rails_best_practices (~> 0.6)
rcov (~> 0.8)
reek (= 1.2.12)
@@ -384,11 +478,87 @@
result = <<-EOD
source "https://somewhere-else.org"
gem "metric_fu", {:git=>"https://github.com/joonty/metric_fu.git", :branch=>"master"}
-gem "kaminari", "~> 0.14.1", {:require=>false}
+gem "kaminari", "~> 0.14", {:require=>false}
EOD
it_behaves_like "a working pessimizer", gemfile, lockfile, result
+ end
+
+ context "with the option to use patch level constraints" do
+ gemfile = <<-EOD
+source "https://rubygems.org"
+gem 'json'
+gem 'rake'
+
+group :development, :test do
+ gem 'sqlite3', '>= 1.3.7'
+end
+ EOD
+
+ lockfile = <<-EOD
+GEM
+ remote: https://rubygems.org/
+ specs:
+ json (1.8.0)
+ rake (10.0.4)
+ sqlite3 (1.3.7)
+ EOD
+
+ result = <<-EOD
+source "https://rubygems.org"
+
+group :development do
+ gem "sqlite3", "~> 1.3.7"
+end
+
+group :test do
+ gem "sqlite3", "~> 1.3.7"
+end
+
+gem "json", "~> 1.8.0"
+gem "rake", "~> 10.0.4"
+ EOD
+
+ it_behaves_like "a working pessimizer", gemfile, lockfile, result, '-c patch'
+ end
+
+ context "with the option to not have backups" do
+ gemfile = <<-EOD
+source "https://rubygems.org"
+gem 'json'
+gem 'rake'
+
+group :development, :test do
+ gem 'sqlite3', '>= 1.3.7'
+end
+ EOD
+
+ lockfile = <<-EOD
+GEM
+ remote: https://rubygems.org/
+ specs:
+ json (1.8.0)
+ rake (10.0.4)
+ sqlite3 (1.3.7)
+ EOD
+
+ result = <<-EOD
+source "https://rubygems.org"
+
+group :development do
+ gem "sqlite3", "~> 1.3"
+end
+
+group :test do
+ gem "sqlite3", "~> 1.3"
+end
+
+gem "json", "~> 1.8"
+gem "rake", "~> 10.0"
+ EOD
+
+ it_behaves_like "a working pessimizer without backups", gemfile, lockfile, result, '--no-backup'
end
end