spec/integration_spec.rb in mrjoy-bundler-audit-0.3.3 vs spec/integration_spec.rb in mrjoy-bundler-audit-0.3.4
- old
+ new
@@ -2,45 +2,72 @@
describe "CLI" do
include Helpers
let(:command) do
- File.expand_path(File.join(File.dirname(__FILE__),'..','bin','bundle-audit'))
+ File.expand_path('../bundle/wrapper.rb', __FILE__)
end
context "when auditing a bundle with unpatched gems" do
let(:bundle) { 'unpatched_gems' }
let(:directory) { File.join('spec','bundle',bundle) }
- subject do
- Dir.chdir(directory) { sh(command, :fail => true) }
- end
+ context "in default display mode" do
+ subject do
+ Dir.chdir(directory) { sh(command, :fail => true) }
+ end
- it "should print a warning" do
- subject.should include("Unpatched versions found!")
- end
+ it "should print a warning" do
+ subject.should include("Unpatched versions found!")
+ end
- it "should print advisory information for the vulnerable gems" do
- advisory_pattern = /(Name: [^\n]+
+ it "should print advisory information for the vulnerable gems" do
+ advisory_pattern = /(Name: [^\n]+
Version: \d+.\d+.\d+
Advisory: OSVDB-\d+
Criticality: (High|Medium)
URL: http:\/\/(direct|www\.)?osvdb.org\/show\/osvdb\/\d+
Title: [^\n]*?
Solution: upgrade to ((~>|=>) \d+.\d+.\d+, )*(~>|=>) \d+.\d+.\d+[\s\n]*?)+/
- expect(subject).to match(advisory_pattern)
- expect(subject).to include("Unpatched versions found!")
+ expect(subject).to match(advisory_pattern)
+ expect(subject).to include("Unpatched versions found!")
+ end
end
+
+ context "in verbose display mode" do
+ subject do
+ Dir.chdir(directory) { sh(command + " --verbose", :fail => true) }
+ end
+
+ it "should print a warning" do
+ subject.should include("Unpatched versions found!")
+ end
+
+ it "should print advisory information for the vulnerable gems" do
+ advisory_pattern = /(Name: [^\n]+
+Version: \d+.\d+.\d+
+Advisory: OSVDB-\d+
+Criticality: (High|Medium)
+URL: http:\/\/(direct|www\.)?osvdb.org\/show\/osvdb\/\d+
+Description:
+
+(( .*?)?\n)+
+Solution: upgrade to ((~>|=>) \d+.\d+.\d+, )*(~>|=>) \d+.\d+.\d+[\s\n]*?)+/
+
+ expect(subject).to match(advisory_pattern)
+ expect(subject).to include("Unpatched versions found!")
+ end
+ end
end
context "when auditing a bundle with ignored gems" do
let(:bundle) { 'unpatched_gems' }
let(:directory) { File.join('spec','bundle',bundle) }
let(:command) do
- File.expand_path(File.join(File.dirname(__FILE__),'..','bin','bundle-audit -i OSVDB-89026'))
+ File.expand_path('../bundle/wrapper.rb', __FILE__) + " -i OSVDB-89026"
end
subject do
Dir.chdir(directory) { sh(command, :fail => true) }
end
@@ -68,14 +95,25 @@
context "when auditing a secure bundle" do
let(:bundle) { 'secure' }
let(:directory) { File.join('spec','bundle',bundle) }
+# Skip this test on any Ruby below 1.9.3.
+version = RUBY_VERSION.split(/\./).map(&:to_i)
+if((version[0] == 1 && version[1] >= 9 && version[2] >= 3) || (version[0] >= 2))
subject do
Dir.chdir(directory) { sh(command) }
end
- it "should print nothing when everything is fine" do
- subject.strip.should == "No unpatched versions found"
+ it "should notify us properly when everything is fine" do
+ # We check the end of the output because a DB install/update "may" (
+ # _will_, in the case of the test but _may_ in the real world) have been
+ # performed.
+ subject.strip.should =~ /No unpatched versions found\Z/
end
+else
+ it "should notify us properly when everything is fine" do
+ pending "Requires ActiveSupport 4.x, which requires Ruby >= 1.9.3."
+ end
+end
end
end