Module: RSpec::Rails

Defined in:
lib/rspec-rails.rb,
lib/rspec/rails/version.rb,
lib/rspec/rails/adapters.rb,
lib/rspec/rails/matchers.rb,
lib/rspec/rails/view_assigns.rb,
lib/rspec/rails/active_record.rb,
lib/rspec/rails/configuration.rb,
lib/rspec/rails/feature_check.rb,
lib/rspec/rails/view_rendering.rb,
lib/rspec/rails/fixture_support.rb,
lib/rspec/rails/matchers/be_a_new.rb,
lib/rspec/rails/matchers/be_valid.rb,
lib/rspec/rails/view_path_builder.rb,
lib/rspec/rails/view_spec_methods.rb,
lib/rspec/rails/matchers/active_job.rb,
lib/rspec/rails/file_fixture_support.rb,
lib/rspec/rails/matchers/redirect_to.rb,
lib/rspec/rails/matchers/action_cable.rb,
lib/rspec/rails/matchers/base_matcher.rb,
lib/rspec/rails/matchers/be_new_record.rb,
lib/rspec/rails/matchers/have_rendered.rb,
lib/rspec/rails/matchers/action_mailbox.rb,
lib/rspec/rails/example/job_example_group.rb,
lib/rspec/rails/example/job_example_group.rb,
lib/rspec/rails/matchers/have_http_status.rb,
lib/rspec/rails/matchers/routing_matchers.rb,
lib/rspec/rails/example/view_example_group.rb,
lib/rspec/rails/example/model_example_group.rb,
lib/rspec/rails/example/rails_example_group.rb,
lib/rspec/rails/fixture_file_upload_support.rb,
lib/rspec/rails/matchers/have_enqueued_mail.rb,
lib/rspec/rails/example/helper_example_group.rb,
lib/rspec/rails/example/mailer_example_group.rb,
lib/rspec/rails/example/mailer_example_group.rb,
lib/rspec/rails/example/system_example_group.rb,
lib/rspec/rails/example/channel_example_group.rb,
lib/rspec/rails/example/channel_example_group.rb,
lib/rspec/rails/example/feature_example_group.rb,
lib/rspec/rails/example/mailbox_example_group.rb,
lib/rspec/rails/example/request_example_group.rb,
lib/rspec/rails/example/routing_example_group.rb,
lib/rspec/rails/example/controller_example_group.rb,
lib/rspec/rails/matchers/action_cable/have_streams.rb,
lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb

Overview

Namespace for rspec-rails code.

Defined Under Namespace

Modules: ChannelExampleGroup, ControllerExampleGroup, FeatureExampleGroup, HelperExampleGroup, JobExampleGroup, MailboxExampleGroup, MailerExampleGroup, Matchers, ModelExampleGroup, RailsExampleGroup, RequestExampleGroup, RoutingExampleGroup, SystemExampleGroup, Version, ViewAssigns, ViewExampleGroup, ViewRendering, ViewSpecMethods Classes: ActiveRecordConfiguration, Configuration, Railtie, ViewPathBuilder

Constant Summary collapse

Assertions =

Constant aliased to either Minitest or TestUnit, depending on what is loaded.

Minitest::Assertions
DIRECTORY_MAPPINGS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Mappings used by infer_spec_type_from_file_location!.

{
  channel:    %w[spec channels],
  controller: %w[spec controllers],
  helper:     %w[spec helpers],
  job:        %w[spec jobs],
  mailer:     %w[spec mailers],
  model:      %w[spec models],
  request:    %w[spec (requests|integration|api)],
  routing:    %w[spec routing],
  view:       %w[spec views],
  feature:    %w[spec features],
  system:     %w[spec system],
  mailbox:    %w[spec mailboxes]
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add_test_type_configurations(config) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Sets up the different example group modules for the different spec types

45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rspec/rails/configuration.rb', line 45
def self.add_test_type_configurations(config)
  config.include RSpec::Rails::ControllerExampleGroup, type: :controller
  config.include RSpec::Rails::HelperExampleGroup,     type: :helper
  config.include RSpec::Rails::ModelExampleGroup,      type: :model
  config.include RSpec::Rails::RequestExampleGroup,    type: :request
  config.include RSpec::Rails::RoutingExampleGroup,    type: :routing
  config.include RSpec::Rails::ViewExampleGroup,       type: :view
  config.include RSpec::Rails::FeatureExampleGroup,    type: :feature
  config.include RSpec::Rails::Matchers
  config.include RSpec::Rails::SystemExampleGroup, type: :system
end

Instance Method Details

#infer_spec_type_from_file_location!Object

Automatically tag specs in conventional directories with matching type metadata so that they have relevant helpers available to them. See RSpec::Rails::DIRECTORY_MAPPINGS for details on which metadata is applied to each directory.


    
# File 'lib/rspec/rails/configuration.rb', line 6

#render_views(val) ⇒ Object

Enables view rendering for controllers specs.


    
# File 'lib/rspec/rails/configuration.rb', line 17

#render_views=(val) ⇒ Object

When set to true, controller specs will render the relevant view as well. Defaults to false.


    
# File 'lib/rspec/rails/configuration.rb', line 12

#render_views?Object

Reader for currently value of render_views setting.


    
# File 'lib/rspec/rails/configuration.rb', line 20