Skip to content

Commit 42bc9de

Browse files
committed
Split spec helper and Rails specific helper apart
This simply separates the RSpec configuration into base RSpec, `spec_helper.rb`, and the Rails related details, `rails_helper.rb`. All existing specs are updated to use the `rails_helper` to ensure they do not break.
1 parent 6cfc630 commit 42bc9de

11 files changed

+81
-36
lines changed

spec/kracken/authenticator_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'spec_helper'
1+
require 'rails_helper'
22

33
module Kracken
44
RSpec.describe Authenticator do

spec/kracken/config_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'spec_helper'
1+
require 'rails_helper'
22

33
module Kracken
44
RSpec.describe Config do

spec/kracken/controllers/authenticatable_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'spec_helper'
1+
require 'rails_helper'
22

33

44
module Kracken

spec/kracken/credential_authenticator_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'spec_helper'
1+
require 'rails_helper'
22

33
module Kracken
44
RSpec.describe CredentialAuthenticator do

spec/kracken/token_authenticator_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'spec_helper'
1+
require 'rails_helper'
22

33
module Kracken
44
RSpec.describe TokenAuthenticator do

spec/kracken_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'spec_helper'
1+
require 'rails_helper'
22

33
RSpec.describe Kracken do
44
it "#setup yields the config block" do

spec/rails_helper.rb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This file is copied to spec/ when you run 'rails generate rspec:install'
2+
ENV['RAILS_ENV'] ||= 'test'
3+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
4+
require 'spec_helper'
5+
require 'rspec/rails'
6+
# Add additional requires below this line. Rails is not loaded until this point!
7+
require 'webmock/rspec'
8+
9+
Rails.backtrace_cleaner.remove_silencers!
10+
11+
# Requires supporting ruby files with custom matchers and macros, etc, in
12+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
13+
# run as spec files by default. This means that files in spec/support that end
14+
# in _spec.rb will both be required and run as specs, causing the specs to be
15+
# run twice. It is recommended that you do not name files matching this glob to
16+
# end with _spec.rb. You can configure this pattern with the --pattern
17+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
18+
#
19+
# The following line is provided for convenience purposes. It has the downside
20+
# of increasing the boot-up time by auto-requiring all files in the support
21+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
22+
# require only the support files necessary.
23+
#
24+
#Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
25+
Dir["#{__dir__}/support/**/*.rb"].each { |f| require f }
26+
27+
RSpec.configure do |config|
28+
# Filter lines from Rails gems in backtraces.
29+
config.filter_rails_from_backtrace!
30+
# arbitrary gems may also be filtered via:
31+
# config.filter_gems_from_backtrace("gem name")
32+
33+
# If true, the base class of anonymous controllers will be inferred
34+
# automatically. This will be the default behavior in future versions of
35+
# rspec-rails.
36+
config.infer_base_class_for_anonymous_controllers = false
37+
end

spec/requests/api_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'spec_helper'
1+
require 'rails_helper'
22

33
module Kracken
44
RSpec.describe 'token authenticatable resource requests', type: :request do

spec/requests/authentication_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'spec_helper'
1+
require 'rails_helper'
22

33
module Kracken
44
RSpec.describe "authenticatable resource requests", type: :request do

spec/routing/oauth_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'spec_helper'
1+
require 'rails_helper'
22

33
module Kracken
44
RSpec.describe "Kracken OAuth Routes", type: :routing do

0 commit comments

Comments
 (0)