|
1 | | -require 'rspec/rails/without_filetype_infer' |
2 | | -require 'rspec/rails/configuration' |
| 1 | +require 'rspec/core' |
| 2 | +require 'rspec/collection_matchers' |
| 3 | +require 'rails/version' |
| 4 | +require 'rspec/rails/extensions' |
| 5 | +require 'rspec/rails/view_rendering' |
| 6 | +require 'rspec/rails/adapters' |
| 7 | +require 'rspec/rails/matchers' |
| 8 | +require 'rspec/rails/fixture_support' |
| 9 | +require 'rspec/rails/example' |
| 10 | +require 'rspec/rails/vendor/capybara' |
| 11 | + |
| 12 | +RSpec.configure do |c| |
| 13 | + c.backtrace_exclusion_patterns << /vendor\// |
| 14 | + c.backtrace_exclusion_patterns << /lib\/rspec\/rails/ |
| 15 | + |
| 16 | + c.include RSpec::Rails::ControllerExampleGroup, :type => :controller |
| 17 | + c.include RSpec::Rails::HelperExampleGroup, :type => :helper |
| 18 | + c.include RSpec::Rails::ModelExampleGroup, :type => :model |
| 19 | + c.include RSpec::Rails::RequestExampleGroup, :type => :request |
| 20 | + c.include RSpec::Rails::RoutingExampleGroup, :type => :routing |
| 21 | + c.include RSpec::Rails::ViewExampleGroup, :type => :view |
| 22 | + c.include RSpec::Rails::FeatureExampleGroup, :type => :feature |
| 23 | + |
| 24 | + if defined?(RSpec::Rails::MailerExampleGroup) |
| 25 | + c.include RSpec::Rails::MailerExampleGroup, :type => :mailer |
| 26 | + end |
| 27 | + |
| 28 | + def c.infer_spec_type_from_file_location! |
| 29 | + { |
| 30 | + :controller => %w[spec controllers], |
| 31 | + :helper => %w[spec helpers], |
| 32 | + :mailer => %w[spec mailers], |
| 33 | + :model => %w[spec models], |
| 34 | + :request => %w[spec (requests|integration|api)], |
| 35 | + :routing => %w[spec routing], |
| 36 | + :view => %w[spec views], |
| 37 | + :feature => %w[spec features] |
| 38 | + }.each do |type, dir_parts| |
| 39 | + escaped_path = Regexp.compile(dir_parts.join('[\\\/]') + '[\\\/]') |
| 40 | + define_derived_metadata(:file_path => escaped_path) do |metadata| |
| 41 | + metadata[:type] ||= type |
| 42 | + end |
| 43 | + end |
| 44 | + end |
| 45 | +end |
0 commit comments