pan_domain 0.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +160 -0
- data/LICENSE.txt +21 -0
- data/README.md +74 -0
- data/Rakefile +21 -0
- data/app/models/pan_domain/human/blood_classification_system.rb +35 -0
- data/app/models/pan_domain/human/blood_group_name.rb +25 -0
- data/bin/console +14 -0
- data/bin/pan_domain +4 -0
- data/bin/rails +25 -0
- data/bin/setup +8 -0
- data/db/human_domain/seeds.rb +28 -0
- data/db/migrate/human_domain/0001_create_blood_classification_systems.rb +17 -0
- data/db/migrate/human_domain/0002_create_blood_group_names.rb +20 -0
- data/db/seeds.rb +21 -0
- data/lib/generators/human_domain/generate/migrations_generator.rb +49 -0
- data/lib/pan_domain.rb +6 -0
- data/lib/pan_domain/cli.rb +53 -0
- data/lib/pan_domain/engine.rb +5 -0
- data/lib/pan_domain/human/engine.rb +11 -0
- data/lib/pan_domain/version.rb +3 -0
- data/lib/tasks/human_domain.rake +45 -0
- data/lib/tasks/pan_domain.rake +23 -0
- data/pan_domain.gemspec +44 -0
- data/spec/lib/generators/test_generate_migrations_generator.rb +48 -0
- data/spec/lib/pan_domain/cli_spec.rb +53 -0
- data/spec/pan_domain_spec.rb +5 -0
- data/spec/sample_app/app/channels/application_cable/channel.rb +4 -0
- data/spec/sample_app/app/channels/application_cable/connection.rb +4 -0
- data/spec/sample_app/app/controllers/application_controller.rb +2 -0
- data/spec/sample_app/app/helpers/application_helper.rb +2 -0
- data/spec/sample_app/app/jobs/application_job.rb +2 -0
- data/spec/sample_app/app/mailers/application_mailer.rb +4 -0
- data/spec/sample_app/app/models/application_record.rb +3 -0
- data/spec/sample_app/config/application.rb +29 -0
- data/spec/sample_app/config/boot.rb +5 -0
- data/spec/sample_app/config/environment.rb +5 -0
- data/spec/sample_app/config/environments/development.rb +61 -0
- data/spec/sample_app/config/environments/production.rb +94 -0
- data/spec/sample_app/config/environments/test.rb +46 -0
- data/spec/sample_app/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/sample_app/config/initializers/assets.rb +14 -0
- data/spec/sample_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/sample_app/config/initializers/content_security_policy.rb +25 -0
- data/spec/sample_app/config/initializers/cookies_serializer.rb +5 -0
- data/spec/sample_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/sample_app/config/initializers/inflections.rb +16 -0
- data/spec/sample_app/config/initializers/mime_types.rb +4 -0
- data/spec/sample_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/sample_app/config/puma.rb +34 -0
- data/spec/sample_app/config/routes.rb +3 -0
- data/spec/sample_app/config/spring.rb +6 -0
- data/spec/sample_app/db/schema.rb +18 -0
- data/spec/sample_app/db/seeds.rb +1 -0
- data/spec/sample_app/spec/lib/tasks/human_domain_spec.rb +89 -0
- data/spec/sample_app/spec/lib/tasks/pan_domain_spec.rb +38 -0
- data/spec/sample_app/spec/models/pan_domain/human/blood_classification_system_spec.rb +46 -0
- data/spec/sample_app/spec/models/pan_domain/human/blood_group_name_spec.rb +39 -0
- data/spec/sample_app/spec/rails_helper.rb +98 -0
- data/spec/sample_app/spec/spec_helper.rb +96 -0
- data/spec/spec_helper.rb +97 -0
- metadata +244 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe 'human_domain:generate:migrations' do
|
4
|
+
subject(:task) { Rake::Task['human_domain:generate:migrations'] }
|
5
|
+
|
6
|
+
# Suppress thor messages
|
7
|
+
before { allow($stdout).to receive(:write) }
|
8
|
+
after { task.reenable }
|
9
|
+
|
10
|
+
it 'is not raise any exception' do
|
11
|
+
expect { task.invoke }.not_to raise_exception
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'runs "rails g humain_domain:generate:migrations"' do
|
15
|
+
expect_any_instance_of(Kernel).to(
|
16
|
+
receive(:system).with 'rails g human_domain:generate:migrations'
|
17
|
+
)
|
18
|
+
|
19
|
+
task.invoke
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'human_domain:db:seed' do
|
24
|
+
subject(:task) { Rake::Task['human_domain:db:seed'] }
|
25
|
+
|
26
|
+
before(:all) do
|
27
|
+
# Setup tables
|
28
|
+
Rake::Task['human_domain:generate:migrations'].invoke
|
29
|
+
Rake::Task['db:migrate'].invoke
|
30
|
+
end
|
31
|
+
|
32
|
+
# Suppress thor messages
|
33
|
+
before { allow($stdout).to receive(:write) }
|
34
|
+
after { task.reenable }
|
35
|
+
|
36
|
+
it 'is not raise any exception' do
|
37
|
+
expect { task.invoke }.not_to raise_exception
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'runs "PanDomain::Human::Engine.load_seed"' do
|
41
|
+
expect(PanDomain::Human::Engine).to receive(:load_seed)
|
42
|
+
|
43
|
+
task.invoke
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'creates 2 records in "blood_classification_systems" table' do
|
47
|
+
expect do
|
48
|
+
task.invoke
|
49
|
+
end.to change {
|
50
|
+
PanDomain::Human::BloodClassificationSystem.count
|
51
|
+
}.from(0).to(2)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'creates 6 records in "blood_group_names" table' do
|
55
|
+
expect do
|
56
|
+
task.invoke
|
57
|
+
end.to change { PanDomain::Human::BloodGroupName.count }.from(0).to(6)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'human_domain:install' do
|
62
|
+
subject(:task) { Rake::Task['human_domain:install'] }
|
63
|
+
|
64
|
+
# Suppress thor messages
|
65
|
+
before { allow($stdout).to receive(:write) }
|
66
|
+
after { task.reenable }
|
67
|
+
|
68
|
+
it 'is not raise any exception' do
|
69
|
+
expect { task.invoke }.not_to raise_exception
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'runs "rake human_domain:generate:migrations"' do
|
73
|
+
expect(Rake::Task['human_domain:generate:migrations']).to receive(:invoke)
|
74
|
+
|
75
|
+
task.invoke
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'runs "rake db:migrate"' do
|
79
|
+
expect(Rake::Task['db:migrate']).to receive(:invoke)
|
80
|
+
|
81
|
+
task.invoke
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'runs "rake human_domain:db:seed"' do
|
85
|
+
expect(Rake::Task['human_domain:db:seed']).to receive(:invoke)
|
86
|
+
|
87
|
+
task.invoke
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe 'pan_domain:install' do
|
4
|
+
subject(:task) { Rake::Task['pan_domain:install'] }
|
5
|
+
|
6
|
+
# Suppress thor messages
|
7
|
+
before { allow($stdout).to receive(:write) }
|
8
|
+
after { task.reenable }
|
9
|
+
|
10
|
+
it 'is not raise any exception' do
|
11
|
+
expect { task.invoke }.not_to raise_exception
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'runs "rake human_domain:install"' do
|
15
|
+
expect(Rake::Task['human_domain:install']).to receive(:invoke)
|
16
|
+
|
17
|
+
task.invoke
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'pan_domain:db:seed' do
|
22
|
+
subject(:task) { Rake::Task['pan_domain:db:seed'] }
|
23
|
+
|
24
|
+
# Suppress thor messages
|
25
|
+
before { allow($stdout).to receive(:write) }
|
26
|
+
after { task.reenable }
|
27
|
+
|
28
|
+
it 'is not raise any exception' do
|
29
|
+
expect { task.invoke }.not_to raise_exception
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'runs "rake human_domain:db:seed"' do
|
33
|
+
expect(Rake::Task['human_domain:db:seed']).to receive(:invoke)
|
34
|
+
|
35
|
+
task.invoke
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe PanDomain::Human::BloodClassificationSystem do
|
4
|
+
before(:all) do
|
5
|
+
# Setup tables
|
6
|
+
Rake::Task['human_domain:generate:migrations'].execute
|
7
|
+
Rake::Task['db:migrate'].execute
|
8
|
+
Rake::Task['db:seed'].execute
|
9
|
+
end
|
10
|
+
|
11
|
+
it { is_expected.to validate_presence_of :name }
|
12
|
+
it { is_expected.to validate_presence_of :description }
|
13
|
+
it { is_expected.to have_many :blood_group_names }
|
14
|
+
|
15
|
+
context 'validations' do
|
16
|
+
subject(:blood_classification_system) do
|
17
|
+
PanDomain::Human::BloodClassificationSystem.new(
|
18
|
+
name: 'TEST', description: 'A description'
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
it { is_expected.to validate_uniqueness_of(:name).ignoring_case_sensitivity }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.abo' do
|
26
|
+
before do
|
27
|
+
@abo = PanDomain::Human::BloodClassificationSystem.find_by(name: 'ABO')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'returns record correctly' do
|
31
|
+
expect(PanDomain::Human::BloodClassificationSystem.abo).to eq @abo
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '.rhesus' do
|
36
|
+
before do
|
37
|
+
@rhesus = PanDomain::Human::BloodClassificationSystem.find_by(
|
38
|
+
name: 'Rhesus'
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'returns record correctly' do
|
43
|
+
expect(PanDomain::Human::BloodClassificationSystem.rhesus).to eq @rhesus
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe PanDomain::Human::BloodGroupName do
|
4
|
+
before(:all) do
|
5
|
+
# Setup tables
|
6
|
+
Rake::Task['human_domain:generate:migrations'].execute
|
7
|
+
Rake::Task['db:migrate'].execute
|
8
|
+
Rake::Task['db:seed'].execute
|
9
|
+
end
|
10
|
+
|
11
|
+
it { is_expected.to validate_presence_of :name }
|
12
|
+
it { is_expected.to validate_presence_of :symbol }
|
13
|
+
it { is_expected.to belong_to :blood_classification_system }
|
14
|
+
|
15
|
+
context 'validations' do
|
16
|
+
subject(:blood_group_name) do
|
17
|
+
PanDomain::Human::BloodGroupName.new(
|
18
|
+
blood_classification_system: PanDomain::Human::BloodClassificationSystem.first,
|
19
|
+
name: 'TEST', symbol: 'A_SYMBOL'
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
it do
|
24
|
+
is_expected.to(
|
25
|
+
validate_uniqueness_of(:name).scoped_to(
|
26
|
+
:blood_classification_system_id
|
27
|
+
).ignoring_case_sensitivity
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
it do
|
32
|
+
is_expected.to(
|
33
|
+
validate_uniqueness_of(:symbol).scoped_to(
|
34
|
+
:blood_classification_system_id
|
35
|
+
).ignoring_case_sensitivity
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
ENV['RAILS_ENV'] ||= 'test'
|
3
|
+
require File.expand_path('../config/environment', __dir__)
|
4
|
+
# Prevent database truncation if the environment is production
|
5
|
+
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
6
|
+
|
7
|
+
require 'rspec/rails'
|
8
|
+
require 'shoulda-matchers'
|
9
|
+
# Add additional requires below this line. Rails is not loaded until this point!
|
10
|
+
|
11
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
12
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
13
|
+
# run as spec files by default. This means that files in spec/support that end
|
14
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
15
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
16
|
+
# end with _spec.rb. You can configure this pattern with the --pattern
|
17
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
18
|
+
#
|
19
|
+
# The following line is provided for convenience purposes. It has the downside
|
20
|
+
# of increasing the boot-up time by auto-requiring all files in the support
|
21
|
+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
22
|
+
# require only the support files necessary.
|
23
|
+
#
|
24
|
+
# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
|
25
|
+
|
26
|
+
# Checks for pending migrations and applies them before tests are run.
|
27
|
+
# If you are not using ActiveRecord, you can remove these lines.
|
28
|
+
begin
|
29
|
+
ActiveRecord::Migration.maintain_test_schema!
|
30
|
+
rescue ActiveRecord::PendingMigrationError => e
|
31
|
+
puts e.to_s.strip
|
32
|
+
exit 1
|
33
|
+
end
|
34
|
+
|
35
|
+
Shoulda::Matchers.configure do |config|
|
36
|
+
config.integrate do |with|
|
37
|
+
with.test_framework :rspec
|
38
|
+
with.library :rails
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
RSpec.configure do |config|
|
43
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
44
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
45
|
+
|
46
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
47
|
+
# examples within a transaction, remove the following line or assign false
|
48
|
+
# instead of true.
|
49
|
+
config.use_transactional_fixtures = true
|
50
|
+
|
51
|
+
# RSpec Rails can automatically mix in different behaviours to your tests
|
52
|
+
# based on their file location, for example enabling you to call `get` and
|
53
|
+
# `post` in specs under `spec/controllers`.
|
54
|
+
#
|
55
|
+
# You can disable this behaviour by removing the line below, and instead
|
56
|
+
# explicitly tag your specs with their type, e.g.:
|
57
|
+
#
|
58
|
+
# RSpec.describe UsersController, :type => :controller do
|
59
|
+
# # ...
|
60
|
+
# end
|
61
|
+
#
|
62
|
+
# The different available types are documented in the features, such as in
|
63
|
+
# https://relishapp.com/rspec/rspec-rails/docs
|
64
|
+
config.infer_spec_type_from_file_location!
|
65
|
+
|
66
|
+
# config.define_derived_metadata(:file_path => %r{/spec/tasks/}) do |metadata|
|
67
|
+
# metadata[:type] = :task
|
68
|
+
# end
|
69
|
+
|
70
|
+
config.before(:suite) do
|
71
|
+
Rails.application.load_tasks
|
72
|
+
|
73
|
+
# Setup database
|
74
|
+
ActiveRecord::Migration.verbose = false
|
75
|
+
|
76
|
+
Rake::Task['db:drop'].execute
|
77
|
+
Rake::Task['db:create'].execute
|
78
|
+
Rake::Task['db:schema:dump'].execute
|
79
|
+
end
|
80
|
+
|
81
|
+
config.after(:all) do
|
82
|
+
# Reset database
|
83
|
+
Rake::Task['db:drop:_unsafe'].reenable
|
84
|
+
Rake::Task['db:drop'].execute
|
85
|
+
Rake::Task['db:create'].execute
|
86
|
+
Rake::Task['db:schema:dump'].execute
|
87
|
+
|
88
|
+
# Remove migration files
|
89
|
+
Dir.glob("#{__dir__}/../db/migrate/*.rb").each do |file_path|
|
90
|
+
File.delete(file_path) if File.exist?(file_path)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Filter lines from Rails gems in backtraces.
|
95
|
+
config.filter_rails_from_backtrace!
|
96
|
+
# arbitrary gems may also be filtered via:
|
97
|
+
# config.filter_gems_from_backtrace("gem name")
|
98
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
16
|
+
RSpec.configure do |config|
|
17
|
+
# rspec-expectations config goes here. You can use an alternate
|
18
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
19
|
+
# assertions if you prefer.
|
20
|
+
config.expect_with :rspec do |expectations|
|
21
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
22
|
+
# and `failure_message` of custom matchers include text for helper methods
|
23
|
+
# defined using `chain`, e.g.:
|
24
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
25
|
+
# # => "be bigger than 2 and smaller than 4"
|
26
|
+
# ...rather than:
|
27
|
+
# # => "be bigger than 2"
|
28
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
29
|
+
end
|
30
|
+
|
31
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
32
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
33
|
+
config.mock_with :rspec do |mocks|
|
34
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
35
|
+
# a real object. This is generally recommended, and will default to
|
36
|
+
# `true` in RSpec 4.
|
37
|
+
mocks.verify_partial_doubles = true
|
38
|
+
end
|
39
|
+
|
40
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
41
|
+
# have no way to turn it off -- the option exists only for backwards
|
42
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
43
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
44
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
45
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
46
|
+
|
47
|
+
# The settings below are suggested to provide a good initial experience
|
48
|
+
# with RSpec, but feel free to customize to your heart's content.
|
49
|
+
=begin
|
50
|
+
# This allows you to limit a spec run to individual examples or groups
|
51
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
52
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
53
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
54
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
55
|
+
config.filter_run_when_matching :focus
|
56
|
+
|
57
|
+
# Allows RSpec to persist some state between runs in order to support
|
58
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
59
|
+
# you configure your source control system to ignore this file.
|
60
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
61
|
+
|
62
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
63
|
+
# recommended. For more details, see:
|
64
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
65
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
66
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
67
|
+
config.disable_monkey_patching!
|
68
|
+
|
69
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
70
|
+
# file, and it's useful to allow more verbose output when running an
|
71
|
+
# individual spec file.
|
72
|
+
if config.files_to_run.one?
|
73
|
+
# Use the documentation formatter for detailed output,
|
74
|
+
# unless a formatter has already been configured
|
75
|
+
# (e.g. via a command-line flag).
|
76
|
+
config.default_formatter = "doc"
|
77
|
+
end
|
78
|
+
|
79
|
+
# Print the 10 slowest examples and example groups at the
|
80
|
+
# end of the spec run, to help surface which specs are running
|
81
|
+
# particularly slow.
|
82
|
+
config.profile_examples = 10
|
83
|
+
|
84
|
+
# Run specs in random order to surface order dependencies. If you find an
|
85
|
+
# order dependency and want to debug it, you can fix the order by providing
|
86
|
+
# the seed, which is printed after each run.
|
87
|
+
# --seed 1234
|
88
|
+
config.order = :random
|
89
|
+
|
90
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
91
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
92
|
+
# test failures related to randomization by passing the same `--seed` value
|
93
|
+
# as the one that triggered the failure.
|
94
|
+
Kernel.srand config.seed
|
95
|
+
=end
|
96
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
16
|
+
|
17
|
+
RSpec.configure do |config|
|
18
|
+
# rspec-expectations config goes here. You can use an alternate
|
19
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
20
|
+
# assertions if you prefer.
|
21
|
+
config.expect_with :rspec do |expectations|
|
22
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
23
|
+
# and `failure_message` of custom matchers include text for helper methods
|
24
|
+
# defined using `chain`, e.g.:
|
25
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
26
|
+
# # => "be bigger than 2 and smaller than 4"
|
27
|
+
# ...rather than:
|
28
|
+
# # => "be bigger than 2"
|
29
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
30
|
+
end
|
31
|
+
|
32
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
33
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
34
|
+
config.mock_with :rspec do |mocks|
|
35
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
36
|
+
# a real object. This is generally recommended, and will default to
|
37
|
+
# `true` in RSpec 4.
|
38
|
+
mocks.verify_partial_doubles = true
|
39
|
+
end
|
40
|
+
|
41
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
42
|
+
# have no way to turn it off -- the option exists only for backwards
|
43
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
44
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
45
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
46
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
47
|
+
|
48
|
+
# The settings below are suggested to provide a good initial experience
|
49
|
+
# with RSpec, but feel free to customize to your heart's content.
|
50
|
+
=begin
|
51
|
+
# This allows you to limit a spec run to individual examples or groups
|
52
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
53
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
54
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
55
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
56
|
+
config.filter_run_when_matching :focus
|
57
|
+
|
58
|
+
# Allows RSpec to persist some state between runs in order to support
|
59
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
60
|
+
# you configure your source control system to ignore this file.
|
61
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
62
|
+
|
63
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
64
|
+
# recommended. For more details, see:
|
65
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
66
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
67
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
68
|
+
config.disable_monkey_patching!
|
69
|
+
|
70
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
71
|
+
# file, and it's useful to allow more verbose output when running an
|
72
|
+
# individual spec file.
|
73
|
+
if config.files_to_run.one?
|
74
|
+
# Use the documentation formatter for detailed output,
|
75
|
+
# unless a formatter has already been configured
|
76
|
+
# (e.g. via a command-line flag).
|
77
|
+
config.default_formatter = "doc"
|
78
|
+
end
|
79
|
+
|
80
|
+
# Print the 10 slowest examples and example groups at the
|
81
|
+
# end of the spec run, to help surface which specs are running
|
82
|
+
# particularly slow.
|
83
|
+
config.profile_examples = 10
|
84
|
+
|
85
|
+
# Run specs in random order to surface order dependencies. If you find an
|
86
|
+
# order dependency and want to debug it, you can fix the order by providing
|
87
|
+
# the seed, which is printed after each run.
|
88
|
+
# --seed 1234
|
89
|
+
config.order = :random
|
90
|
+
|
91
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
92
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
93
|
+
# test failures related to randomization by passing the same `--seed` value
|
94
|
+
# as the one that triggered the failure.
|
95
|
+
Kernel.srand config.seed
|
96
|
+
=end
|
97
|
+
end
|