summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDennis Suratna <dennis.suratna@gmail.com>2017-03-17 14:07:36 -0700
committerDennis Suratna <dennis.suratna@gmail.com>2017-04-11 18:33:29 +0700
commit520f477c364a61a27069bece9169ed362cb6ae8b (patch)
tree9e938db01fea2ec8e8e9ce51205c603aa26c76a8 /spec
parent95f770231bc1d3db8672cba61c567fc974faa8a7 (diff)
downloadbundler-520f477c364a61a27069bece9169ed362cb6ae8b.tar.gz
Handle and test gemspec. Add platform to message
Diffstat (limited to 'spec')
-rw-r--r--spec/commands/pristine_spec.rb42
1 files changed, 37 insertions, 5 deletions
diff --git a/spec/commands/pristine_spec.rb b/spec/commands/pristine_spec.rb
index 02cb204da1..5b63ec257c 100644
--- a/spec/commands/pristine_spec.rb
+++ b/spec/commands/pristine_spec.rb
@@ -4,17 +4,25 @@ require "fileutils"
RSpec.describe "bundle pristine" do
before :each do
+ build_lib "baz", :path => bundled_app do |s|
+ s.version = "1.0.0"
+ s.add_development_dependency "baz-dev", "=1.0.0"
+ end
+
build_repo2 do
build_gem "weakling"
+ build_gem "baz-dev", "1.0.0"
build_git "foo", :path => lib_path("foo")
build_lib "bar", :path => lib_path("bar")
end
- install_gemfile <<-G
+ install_gemfile! <<-G
source "file://#{gem_repo2}"
gem "weakling"
gem "foo", :git => "#{lib_path("foo")}"
gem "bar", :path => "#{lib_path("bar")}"
+
+ gemspec
G
bundle "install"
@@ -39,10 +47,34 @@ RSpec.describe "bundle pristine" do
changed_file = Pathname.new(spec.full_gem_path).join("lib/foo.rb")
diff = "#Pristine spec changes"
- File.open(changed_file, 'a') do |f|
- f.puts '#Pristine spec changes'
- end
+ File.open(changed_file, 'a') { |f| f.puts '#Pristine spec changes' }
+ expect(File.read(changed_file)).to include(diff)
+
+ bundle "pristine"
+ expect(File.read(changed_file)).to_not include(diff)
+ end
+ end
+
+ context "when sourced from gemspec" do
+ it "displays warning and ignores changes when sourced from gemspec" do
+ spec = Bundler.definition.specs["baz"].first
+ changed_file = Pathname.new(spec.full_gem_path).join("lib/baz.rb")
+ diff = "#Pristine spec changes"
+
+ File.open(changed_file, 'a') { |f| f.puts '#Pristine spec changes' }
+ expect(File.read(changed_file)).to include(diff)
+
+ bundle "pristine"
+ expect(File.read(changed_file)).to include(diff)
+ expect(out).to include("Cannot pristine #{spec.name} (#{spec.version}#{spec.git_version}). Gem is sourced from local path.")
+ end
+
+ it "reinstall gemspec dependency" do
+ spec = Bundler.definition.specs["baz-dev"].first
+ changed_file = Pathname.new(spec.full_gem_path).join("lib/baz-dev.rb")
+ diff = "#Pristine spec changes"
+ File.open(changed_file, 'a') { |f| f.puts '#Pristine spec changes' }
expect(File.read(changed_file)).to include(diff)
bundle "pristine"
@@ -51,7 +83,7 @@ RSpec.describe "bundle pristine" do
end
context "when sourced from path" do
- it "displays warning and ignores changes sourced from local path" do
+ it "displays warning and ignores changes when sourced from local path" do
spec = Bundler.definition.specs["bar"].first
changes_txt = Pathname.new(spec.full_gem_path).join("lib/changes.txt")
FileUtils.touch(changes_txt)