Skip to content

Commit

Permalink
Clean up specs with rubocop-guided tweaks to whitespace and order
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Nov 10, 2017
1 parent a9c696d commit 9ba6540
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 17 deletions.
1 change: 1 addition & 0 deletions spec/controllers/login_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

describe LoginController do
let(:user) { create(:curator) }

before do
allow(controller).to receive_messages(current_user: user)
end
Expand Down
1 change: 0 additions & 1 deletion spec/features/canvas_resource_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
# frozen_string_literal: true

require 'rails_helper'
Expand Down
1 change: 0 additions & 1 deletion spec/features/manuscript_display_bibliography_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
# frozen_string_literal: true

require 'rails_helper'
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/catalog_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

describe '#render_thumbnail_tag' do
before do
expect(helper).to receive_messages(
allow(helper).to receive_messages(
blacklight_config: CatalogController.blacklight_config,
current_search_session: {},
document_index_view_type: :list,
Expand Down
5 changes: 5 additions & 0 deletions spec/models/bibliography_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@

context 'sorting bibliography' do
let(:bibtex) { `cat spec/fixtures/bibliography/*.bib` }

it '#bibliography (unsorted)' do # rubocop: disable RSpec/ExampleLength
expect(bibliography.bibliography.count).to eq 15
expect(bibliography.bibliography.collect(&:id)).to include(
Expand All @@ -77,24 +78,28 @@
context 'initializer support for different forms' do
context 'a BibTeX::Bibliography' do
let(:bibtex) { BibTeX.open('spec/fixtures/bibliography/phdthesis.bib') }

it '#bibliography' do
expect(bibliography.bibliography).to be_a(BibTeX::Bibliography)
end
end
context 'a Pathname' do
let(:bibtex) { Pathname('spec/fixtures/bibliography/phdthesis.bib') }

it '#bibliography' do
expect(bibliography.bibliography).to be_a(BibTeX::Bibliography)
end
end
context 'a String (data)' do
let(:bibtex) { Pathname('spec/fixtures/bibliography/phdthesis.bib').read }

it '#bibliography' do
expect(bibliography.bibliography).to be_a(BibTeX::Bibliography)
end
end
context 'an unsupported form' do
let(:bibtex) { nil }

it '#bibliography' do
expect { bibliography.bibliography }.to raise_error(ArgumentError, /Unsupported type/)
end
Expand Down
14 changes: 7 additions & 7 deletions spec/models/dor_harvester_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def sidecar

context 'with an unpublished druid' do
let(:exists_bool) { false }

it 'excludes missing resources' do
expect(subject).to be_empty
end
Expand All @@ -163,6 +164,12 @@ def sidecar
items: [])
end
let(:druid) { 'abc123' }
let(:solr_data) do
[{ id: 'abc123',
spotlight_resource_id_ssim: subject.to_global_id.to_s,
spotlight_resource_type_ssim: 'dor_harvesters',
upstream: true }]
end

before do
subject.save!
Expand All @@ -174,13 +181,6 @@ def sidecar
allow(subject).to receive(:commit)
end

let(:solr_data) do
[{ id: 'abc123',
spotlight_resource_id_ssim: subject.to_global_id.to_s,
spotlight_resource_type_ssim: 'dor_harvesters',
upstream: true }]
end

it 'adds a document to solr' do
subject.reindex

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
let(:exhibit) { create(:exhibit) }

before do
expect(view).to receive_messages(
allow(view).to receive_messages(
current_exhibit: exhibit,
document: document,
document_counter: 0,
Expand Down
10 changes: 5 additions & 5 deletions spec/views/shared/_site_sidebar.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

context 'with a non-admin user' do
before do
allow(view).to receive(:can?).with(:create, Spotlight::Exhibit) { false }
allow(view).to receive(:can?).with(:manage, Spotlight::Site.instance) { false }
allow(view).to receive(:can?).with(:create, Spotlight::Exhibit).and_return(false)
allow(view).to receive(:can?).with(:manage, Spotlight::Site.instance).and_return(false)
render
end
it { is_expected.to have_link('Request an exhibit') }
Expand All @@ -13,9 +13,9 @@

context 'with an admin user' do
before do
allow(view).to receive(:can?).with(:create, Spotlight::Exhibit) { true }
allow(view).to receive(:can?).with(:manage, Spotlight::Exhibit) { true }
allow(view).to receive(:can?).with(:manage, Spotlight::Site.instance) { true }
allow(view).to receive(:can?).with(:create, Spotlight::Exhibit).and_return(true)
allow(view).to receive(:can?).with(:manage, Spotlight::Exhibit).and_return(true)
allow(view).to receive(:can?).with(:manage, Spotlight::Site.instance).and_return(true)
render
end
it { is_expected.to have_link('Create a new exhibit') }
Expand Down
2 changes: 1 addition & 1 deletion spec/views/viewers/edit.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
before do
assign(:viewer, viewer)
assign(:exhibit, exhibit)
expect(view).to receive_messages(configuration_page_title: 'Viewers')
allow(view).to receive_messages(configuration_page_title: 'Viewers')
stub_template 'spotlight/shared/_exhibit_sidebar.html.erb' => 'ignore'
render
end
Expand Down

0 comments on commit 9ba6540

Please sign in to comment.