spec/papers_spec.rb in papers-2.4.1 vs spec/papers_spec.rb in papers-2.4.2
- old
+ new
@@ -119,10 +119,31 @@
'Gem baz-1.2 is included in the application, but not in the manifest',
'Gem baz is included in the manifest, but not in the application'
])
end
+ it 'is OK with whitelisting specific gems' do
+ allow_any_instance_of(Papers::Configuration).to receive(:package_whitelist).and_return(['foo-1.2'])
+ allow_any_instance_of(Papers::LicenseValidator).to receive(:manifest).and_return({
+ 'javascripts' => {},
+ 'gems' => {
+ 'foo-1.2' => { 'license' => 'GPL' },
+ 'baz-1.3' => { 'license' => 'GPL' }
+ }
+ })
+ allow(Bundler).to receive_message_chain(:load, :specs).and_return([
+ double(name: 'foo', version: '1.2', licenses: ['GPL']),
+ double(name: 'baz', version: '1.3', licenses: ['GPL'])
+ ])
+
+ expect(validator).not_to be_valid
+
+ expect(validator.errors).to eq([
+ 'Gem baz-1.3 is licensed under GPL, which is not whitelisted'
+ ])
+ end
+
it 'is OK with matching gem sets but complain about a license issue' do
allow_any_instance_of(Papers::LicenseValidator).to receive(:manifest).and_return({
'javascripts' => {},
'gems' => {
'foo-1.2' => { 'license' => 'MIT' },
@@ -409,9 +430,34 @@
# whitelist this directory
allow_any_instance_of(Papers::Configuration).to receive(:whitelist_javascript_paths).and_return(['app/javascripts/node_modules'])
expect(Papers::Javascript.introspected).to_not include('app/javascripts/node_modules/should_be_whitelisted.js')
expect(validator).to be_valid
+ end
+
+ describe "Command Line" do
+ def silently
+ vblevel = $VERBOSE
+ $VERBOSE = nil
+ yield
+ ensure
+ $VERBOSE = vblevel
+ end
+
+ before do
+ @old_argv = ARGV
+ end
+ after do
+ silently { ARGV = @old_argv }
+ end
+ it "runs the papers command and prints out help" do
+ silently { ARGV = %w[-h] }
+ cli = Papers::CLI.new
+ expect(cli).to receive(:puts) do |opts|
+ expect(opts.to_s).to match /^Usage: papers.*/
+ end
+ cli.run
+ end
end
end