Skip to content

Commit

Permalink
Merge pull request #133 from projecthydra/rspec_file
Browse files Browse the repository at this point in the history
Use .rspec file for color and common spec_helper requirement
  • Loading branch information
jcoyne committed Sep 8, 2016
2 parents 96dfa13 + 0284206 commit 344433d
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 63 deletions.
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--require spec_helper
3 changes: 1 addition & 2 deletions spec/features/select_files_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'spec_helper'
require 'capybara/poltergeist'

describe "Choosing files", :type => :feature do
Expand Down Expand Up @@ -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
2 changes: 0 additions & 2 deletions spec/features/test_compiling_stylesheets_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'spec_helper'

describe "Compiling the stylesheets", :type => :feature do
it "should not raise errors" do
visit '/'
Expand Down
1 change: 0 additions & 1 deletion spec/javascripts/jasmine_spec.rb
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
3 changes: 0 additions & 3 deletions spec/unit/base_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require File.expand_path('../../spec_helper',__FILE__)

include BrowserConfigHelper

describe BrowseEverything::Driver::Base do
Expand All @@ -25,4 +23,3 @@
specify { subject.link_for('/path/to/foo.txt').should == ['/path/to/foo.txt', { file_name: 'foo.txt' }] }
end
end

9 changes: 3 additions & 6 deletions spec/unit/browse_everything_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
require File.expand_path('../../spec_helper',__FILE__)

describe BrowseEverythingHelper do

let(:test_class) {
Class.new do
include BrowseEverythingHelper
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions spec/unit/browser_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require File.expand_path('../../spec_helper',__FILE__)

include BrowserConfigHelper

describe BrowseEverything::Browser do
Expand Down
2 changes: 0 additions & 2 deletions spec/unit/dropbox_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require File.expand_path('../../spec_helper',__FILE__)

include BrowserConfigHelper

describe BrowseEverything::Driver::Dropbox, vcr: { cassette_name: 'dropbox', record: :none } do
Expand Down
25 changes: 11 additions & 14 deletions spec/unit/file_entry_spec.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
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
)
}

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
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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
2 changes: 0 additions & 2 deletions spec/unit/file_system_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require File.expand_path('../../spec_helper',__FILE__)

include BrowserConfigHelper

describe BrowseEverything::Driver::FileSystem do
Expand Down
30 changes: 14 additions & 16 deletions spec/unit/retriever_spec.rb
Original file line number Diff line number Diff line change
@@ -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__) }
Expand All @@ -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
}
}
Expand All @@ -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" => {
Expand Down Expand Up @@ -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
9 changes: 1 addition & 8 deletions spec/unit/sky_drive_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
require File.expand_path('../../spec_helper',__FILE__)



describe BrowseEverything::Driver::SkyDrive do
include BrowseEverything::Engine.routes.url_helpers

Expand All @@ -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
Expand All @@ -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
end
5 changes: 0 additions & 5 deletions spec/views/browse_everything/_file.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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)
Expand Down Expand Up @@ -73,5 +69,4 @@
end
end
end

end

0 comments on commit 344433d

Please sign in to comment.