Skip to content

Commit

Permalink
Clean up rspec files (#1437)
Browse files Browse the repository at this point in the history
* Cleanup and conventionalization

- Avoid `any_instance_of`.
- Single line `let` syntax.
- Cut trailing whitespace and extraneous line-breaks.
- Combine before blocks of the same scope.

* Remove obsolete, unused opts file

Our current versions of rspec use the `.rspec` options file.

* Update Devise behavior conditional

This mimics the change from spotlight:
projectblacklight/spotlight@cc9a662#diff-93830fa29d616f7c87903d08b5b1b29aR71

Without it, a developer instance could still get the failure:
```
uninitialized constant Devise::Test (NameError)
```

when using Rails 5.x and Devise `4.1.1`.  (Devise 4.2.0 resolves it, but
the point is to avoid constraining versions of Devise.)

* Cleanup blacklight_helper_spec

- Remove inline `include` statements, including for *this* class!
- Replace `def` definitions with targetted let/allow statements.
- Use common `let`/`before` blocks, with `context` grouping as needed.
- Make unimplemented test explicitly pending.

* Use .rspec advantageously

Require spec_helper once instead of 100 times.
PS: not British.

* Cleanup facets_helper_spec

- Remove class instance `@variables` (where possible)
- Make use of `let` statements for `blacklight_config`, since the top
  allow statement is already connecting it to the helper.
- Use single-quoted strings instead double-quoted escaped double-quotes.
- Rubocop friendly spaces after commas and such.
- Other common `let` statements in a few economical cases.

* Stop using fork of Deprecation in test app
  • Loading branch information
atz authored and cbeer committed Jul 12, 2016
1 parent 3655c45 commit 99507f0
Show file tree
Hide file tree
Showing 102 changed files with 240 additions and 517 deletions.
3 changes: 2 additions & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
--colour
--color
--require spec_helper
1 change: 0 additions & 1 deletion spec/controllers/alternate_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe AlternateController do
describe "the search results tools" do
Expand Down
1 change: 0 additions & 1 deletion spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe ApplicationController do

Expand Down
1 change: 0 additions & 1 deletion spec/controllers/blacklight/base_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe Blacklight::Base do
let(:controller) { (Class.new(ApplicationController) { include Blacklight::Base }).new }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe Blacklight::DefaultComponentConfiguration do
subject do
Expand Down
1 change: 0 additions & 1 deletion spec/controllers/blacklight/facet_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe Blacklight::Facet do
subject do
Expand Down
1 change: 0 additions & 1 deletion spec/controllers/blacklight/search_fields_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe Blacklight::SearchFields do

Expand Down
1 change: 0 additions & 1 deletion spec/controllers/blacklight/search_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

# check the methods that do solr requests. Note that we are not testing if
# solr gives "correct" responses, as that's out of scope (it's a part of
Expand Down
1 change: 0 additions & 1 deletion spec/controllers/blacklight/suggest_search_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe Blacklight::SuggestSearch do
let(:params) { {q: 'test'} }
Expand Down
1 change: 0 additions & 1 deletion spec/controllers/bookmarks_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe BookmarksController do
# jquery 1.9 ajax does error callback if 200 returns empty body. so use 204 instead.
Expand Down
1 change: 0 additions & 1 deletion spec/controllers/catalog_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe CatalogController do

Expand Down
1 change: 0 additions & 1 deletion spec/controllers/saved_searches_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe SavedSearchesController do
routes { Blacklight::Engine.routes }
Expand Down
1 change: 0 additions & 1 deletion spec/controllers/search_history_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe SearchHistoryController do
routes { Blacklight::Engine.routes }
Expand Down
1 change: 0 additions & 1 deletion spec/controllers/suggest_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe SuggestController do
routes { Blacklight::Engine.routes }
Expand Down
1 change: 0 additions & 1 deletion spec/features/alternate_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe "Alternate Controller Behaviors" do
it "has the correct per-page form" do
Expand Down
1 change: 0 additions & 1 deletion spec/features/bookmarks_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe "Bookmarks" do
describe "navigating from the homepage" do
Expand Down
1 change: 0 additions & 1 deletion spec/features/did_you_mean_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe "Did You Mean" do
before { visit root_path }
Expand Down
1 change: 0 additions & 1 deletion spec/features/facets_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe "Facets" do
it "shows a single facet's values" do
Expand Down
1 change: 0 additions & 1 deletion spec/features/record_view_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe "Record View" do
it "displays a normal record" do
Expand Down
1 change: 0 additions & 1 deletion spec/features/saved_searches_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe "Saved Searches" do
before do
Expand Down
1 change: 0 additions & 1 deletion spec/features/search_context_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe "Search Results context", js: true do
it "passes the current search id through" do
Expand Down
1 change: 0 additions & 1 deletion spec/features/search_filters_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe "Facets" do
it "works without a search term" do
Expand Down
1 change: 0 additions & 1 deletion spec/features/search_formats_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe "Search Formats" do
before do
Expand Down
1 change: 0 additions & 1 deletion spec/features/search_history_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe "Search History Page" do
describe "navigating from the homepage" do
Expand Down
1 change: 0 additions & 1 deletion spec/features/search_pagination_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe "Search Pagination" do
it "has results with pagination" do
Expand Down
1 change: 0 additions & 1 deletion spec/features/search_results_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe "Search Results" do
it "has for an empty query" do
Expand Down
1 change: 0 additions & 1 deletion spec/features/search_sort_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe "Search Sort" do
it "sorts on facet results with no search terms" do
Expand Down
1 change: 0 additions & 1 deletion spec/features/search_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe "Search Page" do
it "shows welcome" do
Expand Down
1 change: 0 additions & 1 deletion spec/features/sitelinks_search_box.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

feature 'Sitelinks search box' do
scenario 'is home page' do
Expand Down
Loading

0 comments on commit 99507f0

Please sign in to comment.