forked from ManageIQ/manageiq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spec_helper.rb
116 lines (92 loc) · 3.65 KB
/
spec_helper.rb
1
2
3
4
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# This file is copied to spec/ when you run 'rails generate rspec:install'
if ENV["TRAVIS"]
require 'coveralls'
Coveralls.wear!('rails') { add_filter("/spec/") }
end
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'application_helper'
require 'rspec/rails'
require 'vcr'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
# include the gems/pending matchers
Dir[File.join(GEMS_PENDING_ROOT, "spec/support/custom_matchers/*.rb")].each { |f| require f }
RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = :expect
end
config.mock_with :rspec do |c|
c.syntax = :expect
end
config.use_transactional_fixtures = true
config.use_instantiated_fixtures = false
# From rspec-rails, infer what helpers to mix in, such as `get` and
# `post` methods in spec/controllers, without specifying type
config.infer_spec_type_from_file_location!
config.include VMDBConfigurationHelper
config.define_derived_metadata(:file_path => /spec\/lib\/miq_automation_engine\/models/) do |metadata|
metadata[:type] ||= :model
end
config.include AuthHelper, :type => :view
config.include ViewSpecHelper, :type => :view
config.include UiConstants, :type => :view
config.include ControllerSpecHelper, :type => :controller
config.include UiConstants, :type => :controller
config.include AuthHelper, :type => :controller
config.include AutomationSpecHelper, :type => :automation
config.include AutomationExampleGroup, :type => :automation
config.define_derived_metadata(:file_path => /spec\/automation/) do |metadata|
metadata[:type] ||= :automation
end
config.extend MigrationSpecHelper::DSL
config.include MigrationSpecHelper, :migrations => :up
config.include MigrationSpecHelper, :migrations => :down
config.include ApiSpecHelper, :type => :request, :rest_api => true
config.include AuthRequestHelper, :type => :request
config.define_derived_metadata(:file_path => /spec\/requests\/api/) do |metadata|
metadata[:type] ||= :request
end
config.include AuthHelper, :type => :helper
config.include PresenterSpecHelper, :type => :presenter
config.define_derived_metadata(:file_path => /spec\/presenters/) do |metadata|
metadata[:type] ||= :presenter
end
config.include RakeTaskExampleGroup, :type => :rake_task
config.include ButtonSpecHelper, :type => :button
config.define_derived_metadata(:file_path => /spec\/helpers\/application_helper\/buttons/) do |metadata|
metadata[:type] = :button
end
# config.before(:all) do
# EvmSpecHelper.log_ruby_object_usage
# end
# config.after(:all) do
# EvmSpecHelper.log_ruby_object_usage
# end
config.before(:each) do
EmsRefresh.debug_failures = true
end
config.after(:each) do
EvmSpecHelper.clear_caches
end
if ENV["TRAVIS"] && ENV["TEST_SUITE"] == "vmdb"
config.after(:suite) do
require Rails.root.join("spec/coverage_helper.rb")
end
end
if config.backtrace_exclusion_patterns.delete(%r{/lib\d*/ruby/}) ||
config.backtrace_exclusion_patterns.delete(%r{/gems/})
config.backtrace_exclusion_patterns << %r{/lib\d*/ruby/[0-9]}
config.backtrace_exclusion_patterns << %r{/gems/[0-9][^/]+/gems/}
end
end
VCR.configure do |c|
c.cassette_library_dir = 'spec/vcr_cassettes'
c.hook_into :webmock
c.allow_http_connections_when_no_cassette = false
c.default_cassette_options = {
:allow_unused_http_interactions => false
}
# c.debug_logger = File.open(Rails.root.join("log", "vcr_debug.log"), "w")
end