Module: Parliament::Utils::TestHelpers::RailsHelper

Included in:
Parliament::Utils::TestHelpers
Defined in:
lib/parliament/utils/test_helpers/rails_helper.rb

Class Method Summary collapse

Class Method Details

.load_rspec_config(config) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/parliament/utils/test_helpers/rails_helper.rb', line 5

def self.load_rspec_config(config)
  Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
  #           # RSpec Rails can automatically mix in different behaviours to your tests
  #           # based on their file location, for example enabling you to call `get` and
  #           # `post` in specs under `spec/controllers`.
  #           #
  #           # You can disable this behaviour by removing the line below, and instead
  #           # explicitly tag your specs with their type, e.g.:
  #           #
  #           #     RSpec.describe UsersController, :type => :controller do
  #           #       # ...
  #           #     end
  #           #
  #           # The different available types are documented in the features, such as in
  #           # https://relishapp.com/rspec/rspec-rails/docs
  config.infer_spec_type_from_file_location!
  #
  #           # Filter lines from Rails gems in backtraces.
  config.filter_rails_from_backtrace!
  #           # arbitrary gems may also be filtered via:
  #           # config.filter_gems_from_backtrace("gem name")
  config.include Parliament::Utils::Helpers::ApplicationHelper
  #
  #           # Set Parliament::Utils::Helpers::HousesHelper#set_ids instance variables to nil after each spec.
  #           # Calling certain Parliament::Utils::Helpers::HousesHelper methods (e.g. Parliament::Utils::Helpers::HousesHelper#commons?) causes
  #           # Parliament::Utils::Helpers::HousesHelper#set_ids to be called which sets @commons_id and @lords_id.
  #           # Setting these to nil causes each spec that requires them to make another
  #           # Parliament::Utils::Helpers::ParliamentHelper request and generate a VCR cassette and stops any RSpec
  #           # ordering issues where they may or may not have been set by the previous spec.
  config.after(:each) do
    Parliament::Utils::Helpers::HousesHelper.instance_variable_set(:@commons_id, nil)
    Parliament::Utils::Helpers::HousesHelper.instance_variable_set(:@lords_id, nil)
  end
end