summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-02-24 11:01:43 -0600
committerSamuel Giddins <segiddins@segiddins.me>2016-02-24 18:09:40 -0600
commit825a6d9887385c9829567b0c25e760019949c3bf (patch)
treef7b56f9fc4e6403969afdb0b81289708abf7eb0e
parentac7410355a2d199f6f7bfea8a49bd23d9397bb94 (diff)
downloadbundler-825a6d9887385c9829567b0c25e760019949c3bf.tar.gz
Update validation specs for old rubygems
-rw-r--r--spec/bundler/bundler_spec.rb43
-rw-r--r--spec/bundler/rubygems_integration_spec.rb33
2 files changed, 51 insertions, 25 deletions
diff --git a/spec/bundler/bundler_spec.rb b/spec/bundler/bundler_spec.rb
index 828a682559..9b1cca5f12 100644
--- a/spec/bundler/bundler_spec.rb
+++ b/spec/bundler/bundler_spec.rb
@@ -75,32 +75,31 @@ describe Bundler do
end
end
- context "validate is true" do
- subject { Bundler.load_gemspec_uncached(app_gemspec_path, true) }
-
- context "and there are gemspec validation errors" do
- let(:ui_shell) { double(:ui_shell) }
+ it "sets loaded_from" do
+ app_gemspec_path.open("w") do |f|
+ f.puts <<-GEMSPEC
+ Gem::Specification.new do |gem|
+ gem.name = "validated"
+ end
+ GEMSPEC
+ end
- before do
- allow(Bundler::UI::Shell).to receive(:new).and_return(ui_shell)
- allow_any_instance_of(Gem::Specification).to receive(:validate) {
- raise Gem::InvalidSpecificationException.new("TODO is not an author")
- }
- end
+ expect(subject.loaded_from).to eq(app_gemspec_path)
+ end
- it "should raise a Gem::InvalidSpecificationException and produce a helpful warning message" do
- File.open(app_gemspec_path, "wb") do |file|
- file.puts <<-GEMSPEC.gsub(/^\s+/, "")
- Gem::Specification.new do |gem|
- gem.author = "TODO"
- end
- GEMSPEC
- end
+ context "validate is true" do
+ subject { Bundler.load_gemspec_uncached(app_gemspec_path, true) }
- expect { subject }.to raise_error(Gem::InvalidSpecificationException,
- "The gemspec at #{app_gemspec_path} is not valid. "\
- "Please fix this gemspec.\nThe validation error was 'TODO is not an author'\n")
+ it "validates the specification" do
+ app_gemspec_path.open("w") do |f|
+ f.puts <<-GEMSPEC
+ Gem::Specification.new do |gem|
+ gem.name = "validated"
+ end
+ GEMSPEC
end
+ expect(Bundler.rubygems).to receive(:validate).with have_attributes(:name => "validated")
+ subject
end
end
end
diff --git a/spec/bundler/rubygems_integration_spec.rb b/spec/bundler/rubygems_integration_spec.rb
index 917d673b51..fbc49c414c 100644
--- a/spec/bundler/rubygems_integration_spec.rb
+++ b/spec/bundler/rubygems_integration_spec.rb
@@ -7,16 +7,43 @@ describe Bundler::RubygemsIntegration do
end
context "#validate" do
- let(:spec) { double("spec", :summary => "") }
+ let(:spec) do
+ Gem::Specification.new do |s|
+ s.name = "to-validate"
+ s.version = "1.0.0"
+ s.loaded_from = __FILE__
+ end
+ end
+ subject { Bundler.rubygems.validate(spec) }
it "skips overly-strict gemspec validation", :rubygems => "< 1.7" do
expect(spec).to_not receive(:validate)
- Bundler.rubygems.validate(spec)
+ subject
end
it "validates with packaging mode disabled", :rubygems => "1.7" do
expect(spec).to receive(:validate).with(false)
- Bundler.rubygems.validate(spec)
+ subject
+ end
+
+ it "should set a summary to avoid an overly-strict error", :rubygems => "~> 1.7.0" do
+ spec.summary = nil
+ expect { subject }.not_to raise_error
+ expect(spec.summary).to eq("")
+ end
+
+ context "with an invalid spec" do
+ before do
+ expect(spec).to receive(:validate).with(false).
+ and_raise(Gem::InvalidSpecificationException.new("TODO is not an author"))
+ end
+
+ it "should raise a Gem::InvalidSpecificationException and produce a helpful warning message",
+ :rubygems => "1.7" do
+ expect { subject }.to raise_error(Gem::InvalidSpecificationException,
+ "The gemspec at #{__FILE__} is not valid. "\
+ "Please fix this gemspec.\nThe validation error was 'TODO is not an author'\n")
+ end
end
end