|
1
|
|
|
# frozen_string_literal: true |
|
2
|
|
|
|
|
3
|
|
|
# This file was generated by the `rspec --init` command. Conventionally, all |
|
4
|
|
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. |
|
5
|
|
|
# The generated `.rspec` file contains `--require spec_helper` which will cause |
|
6
|
|
|
# this file to always be loaded, without a need to explicitly require it in any |
|
7
|
|
|
# files. |
|
8
|
|
|
# |
|
9
|
|
|
# Given that it is always loaded, you are encouraged to keep this file as |
|
10
|
|
|
# light-weight as possible. Requiring heavyweight dependencies from this file |
|
11
|
|
|
# will add to the boot time of your test suite on EVERY test run, even for an |
|
12
|
|
|
# individual file that may not need all of that loaded. Instead, consider making |
|
13
|
|
|
# a separate helper file that requires the additional dependencies and performs |
|
14
|
|
|
# the additional setup, and require it from the spec files that actually need |
|
15
|
|
|
# it. |
|
16
|
|
|
# |
|
17
|
|
|
require 'coveralls' |
|
18
|
|
|
Coveralls.wear! |
|
19
|
|
|
|
|
20
|
|
|
require 'simplecov' |
|
21
|
|
|
require 'simplecov-console' |
|
22
|
|
|
require 'scrutinizer/ocular' |
|
23
|
|
|
require 'scrutinizer/ocular/formatter' |
|
24
|
|
|
|
|
25
|
|
|
Scrutinizer::Ocular.watch! 'app' |
|
26
|
|
|
|
|
27
|
|
|
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new( |
|
28
|
|
|
[ |
|
29
|
|
|
SimpleCov::Formatter::Console, |
|
30
|
|
|
SimpleCov::Formatter::HTMLFormatter, |
|
31
|
|
|
Coveralls::SimpleCov::Formatter, |
|
32
|
|
|
Scrutinizer::Ocular::UploadingFormatter |
|
33
|
|
|
] |
|
34
|
|
|
) |
|
35
|
|
|
|
|
36
|
|
|
SimpleCov.start 'app' do |
|
37
|
|
|
track_files 'app.rb' |
|
38
|
|
|
end |
|
39
|
|
|
|
|
40
|
|
|
ENV['RACK_ENV'] = 'test' |
|
41
|
|
|
|
|
42
|
|
|
require 'rack/test' |
|
43
|
|
|
require 'rspec' |
|
44
|
|
|
require_relative 'shared_context_specs' |
|
45
|
|
|
require_relative 'shared_example_specs' |
|
46
|
|
|
require './app/app_constants' |
|
47
|
|
|
require './config/db' |
|
48
|
|
|
require 'database_cleaner' |
|
49
|
|
|
require 'ralyxa' |
|
50
|
|
|
require 'factory_bot' |
|
51
|
|
|
require 'test_constants' |
|
52
|
|
|
require 'faker' |
|
53
|
|
|
require_relative 'test_factory' |
|
54
|
|
|
require './app/services/init' |
|
55
|
|
|
require './app/models/init' |
|
56
|
|
|
require './intents/init' |
|
57
|
|
|
|
|
58
|
|
|
ActiveRecord::Migrator.migrate(File.join('../', 'db/migrate')) |
|
59
|
|
|
|
|
60
|
|
|
# Sinatra testing |
|
61
|
|
|
module RSpecMixin |
|
62
|
|
|
include Rack::Test::Methods |
|
63
|
|
|
def app |
|
64
|
|
|
described_class |
|
65
|
|
|
end |
|
66
|
|
|
end |
|
67
|
|
|
|
|
68
|
|
|
RSpec.configure { |c| c.include RSpecMixin } |
|
69
|
|
|
|
|
70
|
|
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration |
|
71
|
|
|
RSpec.configure do |config| |
|
72
|
|
|
# cleanup database and reload seeds |
|
73
|
|
|
config.before(:suite) do |
|
74
|
|
|
DatabaseCleaner.strategy = :transaction |
|
75
|
|
|
DatabaseCleaner.clean_with(:truncation) |
|
76
|
|
|
require './db/seeds' |
|
77
|
|
|
end |
|
78
|
|
|
|
|
79
|
|
|
config.before(:each) do |
|
80
|
|
|
allow_any_instance_of(ValidEmail2::Address).to receive(:valid_mx?) { true } |
|
81
|
|
|
end |
|
82
|
|
|
|
|
83
|
|
|
config.before :each, timecop: :freeze do |
|
84
|
|
|
Timecop.freeze |
|
85
|
|
|
end |
|
86
|
|
|
|
|
87
|
|
|
config.after :each, timecop: :freeze do |
|
88
|
|
|
Timecop.return |
|
89
|
|
|
end |
|
90
|
|
|
|
|
91
|
|
|
# Disable validation of Alexa requests as |
|
92
|
|
|
# these will fail when running under rspec |
|
93
|
|
|
config.before :each do |
|
94
|
|
|
Ralyxa.configure do |c| |
|
95
|
|
|
c.validate_requests = false |
|
96
|
|
|
end |
|
97
|
|
|
end |
|
98
|
|
|
|
|
99
|
|
|
config.expect_with :rspec do |c| |
|
100
|
|
|
c.syntax = :expect |
|
101
|
|
|
end |
|
102
|
|
|
|
|
103
|
|
|
config.include FactoryBot::Syntax::Methods |
|
104
|
|
|
|
|
105
|
|
|
config.before(:suite) do |
|
106
|
|
|
FactoryBot.find_definitions |
|
107
|
|
|
end |
|
108
|
|
|
|
|
109
|
|
|
# rspec-expectations config goes here. You can use an alternate |
|
110
|
|
|
# assertion/expectation library such as wrong or the stdlib/minitest |
|
111
|
|
|
# assertions if you prefer. |
|
112
|
|
|
config.expect_with :rspec do |expectations| |
|
113
|
|
|
# This option will default to `true` in RSpec 4. It makes the `description` |
|
114
|
|
|
# and `failure_message` of custom matchers include text for helper methods |
|
115
|
|
|
# defined using `chain`, e.g.: |
|
116
|
|
|
# be_bigger_than(2).and_smaller_than(4).description |
|
117
|
|
|
# # => "be bigger than 2 and smaller than 4" |
|
118
|
|
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true |
|
119
|
|
|
end |
|
120
|
|
|
|
|
121
|
|
|
# rspec-mocks config goes here. You can use an alternate test double |
|
122
|
|
|
# library (such as bogus or mocha) by changing the `mock_with` option here. |
|
123
|
|
|
config.mock_with :rspec do |mocks| |
|
124
|
|
|
# Prevents you from mocking or stubbing a method that does not exist on |
|
125
|
|
|
# a real object. This is generally recommended, and will default to |
|
126
|
|
|
# `true` in RSpec 4. |
|
127
|
|
|
mocks.verify_partial_doubles = true |
|
128
|
|
|
|
|
129
|
|
|
# This option should be set when all dependencies are being loaded |
|
130
|
|
|
# before a spec run, as is the case in a typical spec helper. It will |
|
131
|
|
|
# cause any verifying double instantiation for a class that does not |
|
132
|
|
|
# exist to raise, protecting against incorrectly spelt names. |
|
133
|
|
|
mocks.verify_doubled_constant_names = true |
|
134
|
|
|
end |
|
135
|
|
|
|
|
136
|
|
|
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will |
|
137
|
|
|
# have no way to turn it off -- the option exists only for backwards |
|
138
|
|
|
# compatibility in RSpec 3). It causes shared context metadata to be |
|
139
|
|
|
# inherited by the metadata hash of host groups and examples, rather than |
|
140
|
|
|
# triggering implicit auto-inclusion in groups with matching metadata. |
|
141
|
|
|
config.shared_context_metadata_behavior = :apply_to_host_groups |
|
142
|
|
|
|
|
143
|
|
|
# This allows you to limit a spec run to individual examples or groups |
|
144
|
|
|
# you care about by tagging them with `:focus` metadata. When nothing |
|
145
|
|
|
# is tagged with `:focus`, all examples get run. RSpec also provides |
|
146
|
|
|
# aliases for `it`, `describe`, and `context` that include `:focus` |
|
147
|
|
|
# metadata: `fit`, `fdescribe` and `fcontext`, respectively. |
|
148
|
|
|
config.filter_run_when_matching :focus |
|
149
|
|
|
|
|
150
|
|
|
# Allows RSpec to persist some state between runs in order to support |
|
151
|
|
|
# the `--only-failures` and `--next-failure` CLI options. We recommend |
|
152
|
|
|
# you configure your source control system to ignore this file. |
|
153
|
|
|
config.example_status_persistence_file_path = 'spec/examples.txt' |
|
154
|
|
|
|
|
155
|
|
|
# Limits the available syntax to the non-monkey patched syntax that is |
|
156
|
|
|
# recommended. For more details, see: |
|
157
|
|
|
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ |
|
158
|
|
|
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ |
|
159
|
|
|
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode |
|
160
|
|
|
config.disable_monkey_patching! |
|
161
|
|
|
|
|
162
|
|
|
# This setting enables warnings. It's recommended, but in some cases may |
|
163
|
|
|
# be too noisy due to issues in dependencies. |
|
164
|
|
|
config.warnings = true |
|
165
|
|
|
|
|
166
|
|
|
# Many RSpec users commonly either run the entire suite or an individual |
|
167
|
|
|
# file, and it's useful to allow more verbose output when running an |
|
168
|
|
|
# individual spec file. |
|
169
|
|
|
if config.files_to_run.one? |
|
170
|
|
|
# Use the documentation formatter for detailed output, |
|
171
|
|
|
# unless a formatter has already been configured |
|
172
|
|
|
# (e.g. via a command-line flag). |
|
173
|
|
|
config.default_formatter = 'doc' |
|
174
|
|
|
end |
|
175
|
|
|
|
|
176
|
|
|
# Print the 10 slowest examples and example groups at the |
|
177
|
|
|
# end of the spec run, to help surface which specs are running |
|
178
|
|
|
# particularly slow. |
|
179
|
|
|
config.profile_examples = 10 |
|
180
|
|
|
|
|
181
|
|
|
# Run specs in random order to surface order dependencies. If you find an |
|
182
|
|
|
# order dependency and want to debug it, you can fix the order by providing |
|
183
|
|
|
# the seed, which is printed after each run. |
|
184
|
|
|
# --seed 1234 |
|
185
|
|
|
# config.order = :random |
|
186
|
|
|
|
|
187
|
|
|
# Seed global randomization in this process using the `--seed` CLI option. |
|
188
|
|
|
# Setting this allows you to use `--seed` to deterministically reproduce |
|
189
|
|
|
# test failures related to randomization by passing the same `--seed` value |
|
190
|
|
|
# as the one that triggered the failure. |
|
191
|
|
|
Kernel.srand config.seed |
|
192
|
|
|
end |
|
193
|
|
|
|