From 0284206b69090bc16515216dff002673e990712d Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Thu, 8 Sep 2016 14:13:33 -0700 Subject: [PATCH] Use .rspec file for color and common spec_helper requirement --- .rspec | 2 ++ spec/features/select_files_spec.rb | 3 +- .../test_compiling_stylesheets_spec.rb | 2 -- spec/javascripts/jasmine_spec.rb | 1 - spec/unit/base_spec.rb | 3 -- spec/unit/browse_everything_helper_spec.rb | 9 ++---- spec/unit/browser_spec.rb | 2 -- spec/unit/dropbox_spec.rb | 2 -- spec/unit/file_entry_spec.rb | 25 +++++++--------- spec/unit/file_system_spec.rb | 2 -- spec/unit/retriever_spec.rb | 30 +++++++++---------- spec/unit/sky_drive_spec.rb | 9 +----- .../browse_everything/_file.html.erb_spec.rb | 5 ---- 13 files changed, 32 insertions(+), 63 deletions(-) create mode 100644 .rspec diff --git a/.rspec b/.rspec new file mode 100644 index 00000000..83e16f80 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--require spec_helper diff --git a/spec/features/select_files_spec.rb b/spec/features/select_files_spec.rb index 20e29c21..4e945cd5 100644 --- a/spec/features/select_files_spec.rb +++ b/spec/features/select_files_spec.rb @@ -1,4 +1,3 @@ -require 'spec_helper' require 'capybara/poltergeist' describe "Choosing files", :type => :feature do @@ -32,5 +31,5 @@ context "when Turbolinks are disabled" do before { click_link('Enter Test App (No Turbolinks)') } it_behaves_like "browseable files" - end + end end diff --git a/spec/features/test_compiling_stylesheets_spec.rb b/spec/features/test_compiling_stylesheets_spec.rb index 8fb79071..48bd0912 100644 --- a/spec/features/test_compiling_stylesheets_spec.rb +++ b/spec/features/test_compiling_stylesheets_spec.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - describe "Compiling the stylesheets", :type => :feature do it "should not raise errors" do visit '/' diff --git a/spec/javascripts/jasmine_spec.rb b/spec/javascripts/jasmine_spec.rb index dff8179b..6883691a 100644 --- a/spec/javascripts/jasmine_spec.rb +++ b/spec/javascripts/jasmine_spec.rb @@ -1,4 +1,3 @@ -require 'spec_helper' require 'rake' # Run the jasmine tests by running the jasmine:ci rake command and parses the output for failures. diff --git a/spec/unit/base_spec.rb b/spec/unit/base_spec.rb index 958bce69..bca46c34 100644 --- a/spec/unit/base_spec.rb +++ b/spec/unit/base_spec.rb @@ -1,5 +1,3 @@ -require File.expand_path('../../spec_helper',__FILE__) - include BrowserConfigHelper describe BrowseEverything::Driver::Base do @@ -25,4 +23,3 @@ specify { subject.link_for('/path/to/foo.txt').should == ['/path/to/foo.txt', { file_name: 'foo.txt' }] } end end - diff --git a/spec/unit/browse_everything_helper_spec.rb b/spec/unit/browse_everything_helper_spec.rb index 30ee9429..543bdb11 100644 --- a/spec/unit/browse_everything_helper_spec.rb +++ b/spec/unit/browse_everything_helper_spec.rb @@ -1,7 +1,4 @@ -require File.expand_path('../../spec_helper',__FILE__) - describe BrowseEverythingHelper do - let(:test_class) { Class.new do include BrowseEverythingHelper @@ -13,15 +10,15 @@ def initialize params } let(:test_file) { BrowseEverything::FileEntry.new 0, '/path/to/file.mp4', 'file.mp4', 12345, Time.now, false } - + it "should match a full type" do expect(test_class.new(accept: 'video/mp4').is_acceptable?(test_file)).to eq(true) end - + it "should match a wildcard type" do expect(test_class.new(accept: 'video/*').is_acceptable?(test_file)).to eq(true) end - + it "should not match the wrong full type" do expect(test_class.new(accept: 'video/mpeg').is_acceptable?(test_file)).to eq(false) end diff --git a/spec/unit/browser_spec.rb b/spec/unit/browser_spec.rb index cd6be91c..c3a27f2a 100644 --- a/spec/unit/browser_spec.rb +++ b/spec/unit/browser_spec.rb @@ -1,5 +1,3 @@ -require File.expand_path('../../spec_helper',__FILE__) - include BrowserConfigHelper describe BrowseEverything::Browser do diff --git a/spec/unit/dropbox_spec.rb b/spec/unit/dropbox_spec.rb index 60ad134c..1764b605 100644 --- a/spec/unit/dropbox_spec.rb +++ b/spec/unit/dropbox_spec.rb @@ -1,5 +1,3 @@ -require File.expand_path('../../spec_helper',__FILE__) - include BrowserConfigHelper describe BrowseEverything::Driver::Dropbox, vcr: { cassette_name: 'dropbox', record: :none } do diff --git a/spec/unit/file_entry_spec.rb b/spec/unit/file_entry_spec.rb index addb151c..c4b8b338 100644 --- a/spec/unit/file_entry_spec.rb +++ b/spec/unit/file_entry_spec.rb @@ -1,10 +1,7 @@ -require File.expand_path('../../spec_helper',__FILE__) - describe BrowseEverything::FileEntry do - let(:mtime) { Time.now } describe "regular file" do - subject { + subject { BrowseEverything::FileEntry.new( 'file_id_01234', 'my_provider:/location/pa/th/file.m4v', 'file.m4v', '1.2 GB', mtime, false @@ -12,7 +9,7 @@ } it "should be a BrowseEverything::FileEntry" do - expect(subject).to be_a BrowseEverything::FileEntry + expect(subject).to be_a BrowseEverything::FileEntry end it "#id" do @@ -40,14 +37,14 @@ end it "#container?" do - expect(subject.container?).to be false + expect(subject.container?).to be false end - + it "#relative_parent_path?" do - expect(subject.relative_parent_path?).to be false + expect(subject.relative_parent_path?).to be false end end - + describe "directory" do subject { BrowseEverything::FileEntry.new( @@ -61,14 +58,14 @@ end it "#container?" do - expect(subject.container?).to be true + expect(subject.container?).to be true end it "#relative_parent_path?" do - expect(subject.relative_parent_path?).to be false + expect(subject.relative_parent_path?).to be false end end - + describe "parent path" do subject { BrowseEverything::FileEntry.new( @@ -82,11 +79,11 @@ end it "#container?" do - expect(subject.container?).to be true + expect(subject.container?).to be true end it "#relative_parent_path?" do - expect(subject.relative_parent_path?).to be true + expect(subject.relative_parent_path?).to be true end end end diff --git a/spec/unit/file_system_spec.rb b/spec/unit/file_system_spec.rb index 9f95340f..d642ee1a 100644 --- a/spec/unit/file_system_spec.rb +++ b/spec/unit/file_system_spec.rb @@ -1,5 +1,3 @@ -require File.expand_path('../../spec_helper',__FILE__) - include BrowserConfigHelper describe BrowseEverything::Driver::FileSystem do diff --git a/spec/unit/retriever_spec.rb b/spec/unit/retriever_spec.rb index e799f4d9..bd380b2f 100644 --- a/spec/unit/retriever_spec.rb +++ b/spec/unit/retriever_spec.rb @@ -1,5 +1,3 @@ -require File.expand_path('../../spec_helper',__FILE__) - describe BrowseEverything::Retriever, vcr: { cassette_name: 'retriever', record: :none, } do subject { BrowseEverything::Retriever.new } let(:datafile) { File.expand_path('../../fixtures/file_system/file_1.pdf',__FILE__) } @@ -10,12 +8,12 @@ context 'http://' do let(:spec) { - { + { "0" => { - "url"=>"https://retrieve.cloud.example.com/some/dir/file.pdf", - "auth_header"=>{"Authorization"=>"Bearer ya29.kQCEAHj1bwFXr2AuGQJmSGRWQXpacmmYZs4kzCiXns3d6H1ZpIDWmdM8"}, - "expires"=>(Time.now + 3600).xmlschema, - "file_name"=>"file.pdf", + "url"=>"https://retrieve.cloud.example.com/some/dir/file.pdf", + "auth_header"=>{"Authorization"=>"Bearer ya29.kQCEAHj1bwFXr2AuGQJmSGRWQXpacmmYZs4kzCiXns3d6H1ZpIDWmdM8"}, + "expires"=>(Time.now + 3600).xmlschema, + "file_name"=>"file.pdf", "file_size"=>size.to_s } } @@ -32,25 +30,25 @@ expect { |block| subject.retrieve(spec['0'], &block) }.to yield_with_args(data, data.length, data.length) end end - + context "#download" do it "content" do file = subject.download(spec['0']) expect(File.open(file,'rb',&:read)).to eq(data) end - + it "callbacks" do expect { |block| subject.download(spec['0'], &block) }.to yield_with_args(String, data.length, data.length) end end end - + context 'file://' do let(:spec) { - { + { "0" => { - "url"=>"file://#{datafile}", - "file_name"=>"file.pdf", + "url"=>"file://#{datafile}", + "file_name"=>"file.pdf", "file_size"=>size.to_s }, "1" => { @@ -84,13 +82,13 @@ file = subject.download(spec['0']) expect(File.open(file,'rb',&:read)).to eq(data) end - + it "callbacks" do expect { |block| subject.download(spec['0'], &block) }.to yield_with_args(String, data.length, data.length) end end end - + context '' - + end diff --git a/spec/unit/sky_drive_spec.rb b/spec/unit/sky_drive_spec.rb index 751f92c2..9fdc605a 100644 --- a/spec/unit/sky_drive_spec.rb +++ b/spec/unit/sky_drive_spec.rb @@ -1,7 +1,3 @@ -require File.expand_path('../../spec_helper',__FILE__) - - - describe BrowseEverything::Driver::SkyDrive do include BrowseEverything::Engine.routes.url_helpers @@ -28,7 +24,6 @@ def redirect_url :headers => { "content-type" => "application/json"}) - driver = BrowseEverything::Driver::SkyDrive.new(provider_yml) driver.connect({code:"code"},{}) driver.authorized?.should == true @@ -49,10 +44,8 @@ def redirect_url :headers => { "content-type" => "application/json"}) - driver = BrowseEverything::Driver::SkyDrive.new(provider_yml) driver.connect({code:"code"},{}) driver.authorized?.should == false end - -end \ No newline at end of file +end diff --git a/spec/views/browse_everything/_file.html.erb_spec.rb b/spec/views/browse_everything/_file.html.erb_spec.rb index 5acd4bb7..b484aac0 100644 --- a/spec/views/browse_everything/_file.html.erb_spec.rb +++ b/spec/views/browse_everything/_file.html.erb_spec.rb @@ -1,7 +1,4 @@ -require File.expand_path('../../../spec_helper',__FILE__) - describe 'browse_everything/_file.html.erb', type: :view do - let(:file) { BrowseEverything::FileEntry.new( 'file_id_01234', 'my_provider:/location/pa/th/file.m4v', @@ -17,7 +14,6 @@ let(:provider) { double("provider") } let(:page) { Capybara::Node::Simple.new(rendered) } - before do allow(view).to receive(:browse_everything_engine).and_return(BrowseEverything::Engine.routes.url_helpers) allow(view).to receive(:provider).and_return(provider) @@ -73,5 +69,4 @@ end end end - end