-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- In #970 we added `infer_spec_type_from_file_location!` but forgot to remove the code in `lib/rspec/rails/configuration.rb` that made it always infer - so the opt-in API was there but it was always enabled. Here I've made it truly opt-in. - The logic of `infer_spec_type_from_file_location!` also setup the helper module inclusion via explicit `:type` metadata but was only intended to setup the implicit mapping of spec file location to type. Here I've made the module inclusion via `:type` always work w/o an explicit config option needed to enable it. - We used to mutate the `:type` metadata on inclusion of the helper module, but this caused bugs such as #825. The problem is that rspec-core uses a raw hash for the metadata and doesn't re-apply filtering/inclusion logic when the metadata hash is mutated. Instead, we use a new explicit `define_derived_metadata` API. Fixes #825 and closes #829.
- Loading branch information
1 parent
fd3f5ea
commit e135076
Showing
23 changed files
with
134 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,45 @@ | ||
require 'rspec/rails/without_filetype_infer' | ||
require 'rspec/rails/configuration' | ||
require 'rspec/core' | ||
require 'rspec/collection_matchers' | ||
require 'rails/version' | ||
require 'rspec/rails/extensions' | ||
require 'rspec/rails/view_rendering' | ||
require 'rspec/rails/adapters' | ||
require 'rspec/rails/matchers' | ||
require 'rspec/rails/fixture_support' | ||
require 'rspec/rails/example' | ||
require 'rspec/rails/vendor/capybara' | ||
|
||
RSpec.configure do |c| | ||
c.backtrace_exclusion_patterns << /vendor\// | ||
c.backtrace_exclusion_patterns << /lib\/rspec\/rails/ | ||
|
||
c.include RSpec::Rails::ControllerExampleGroup, :type => :controller | ||
c.include RSpec::Rails::HelperExampleGroup, :type => :helper | ||
c.include RSpec::Rails::ModelExampleGroup, :type => :model | ||
c.include RSpec::Rails::RequestExampleGroup, :type => :request | ||
c.include RSpec::Rails::RoutingExampleGroup, :type => :routing | ||
c.include RSpec::Rails::ViewExampleGroup, :type => :view | ||
c.include RSpec::Rails::FeatureExampleGroup, :type => :feature | ||
|
||
if defined?(RSpec::Rails::MailerExampleGroup) | ||
c.include RSpec::Rails::MailerExampleGroup, :type => :mailer | ||
end | ||
|
||
def c.infer_spec_type_from_file_location! | ||
{ | ||
:controller => %w[spec controllers], | ||
:helper => %w[spec helpers], | ||
: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] | ||
}.each do |type, dir_parts| | ||
escaped_path = Regexp.compile(dir_parts.join('[\\\/]') + '[\\\/]') | ||
define_derived_metadata(:file_path => escaped_path) do |metadata| | ||
metadata[:type] ||= type | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.