Skip to content
This repository was archived by the owner on May 14, 2018. It is now read-only.

Commit 8deca2e

Browse files
committed
Init specs
1 parent 2f176a3 commit 8deca2e

File tree

8 files changed

+196
-26
lines changed

8 files changed

+196
-26
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
# Ignore bundler config.
88
/.bundle
99

10+
# Ignore coverage
11+
/coverage
12+
1013
# Ignore the default SQLite database.
1114
/db/*.sqlite3
1215
/db/*.sqlite3-journal

.rspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--require spec_helper

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ group :test do
3333
gem "rubocop"
3434
gem "rubocop-rspec"
3535
gem "shoulda"
36+
gem "simplecov", require: false
3637
end
3738

3839
gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby]

Gemfile.lock

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ GEM
5050
crass (1.0.2)
5151
diff-lcs (1.3)
5252
docile (1.1.5)
53-
erubi (1.6.1)
53+
erubi (1.7.0)
5454
factory_girl (4.8.1)
5555
activesupport (>= 3.0.0)
5656
factory_girl_rails (4.8.0)
@@ -123,7 +123,7 @@ GEM
123123
rb-fsevent (0.10.2)
124124
rb-inotify (0.9.10)
125125
ffi (>= 0.5.0, < 2)
126-
redis (3.3.5)
126+
redis (4.0.1)
127127
rspec-core (3.6.0)
128128
rspec-support (~> 3.6.0)
129129
rspec-expectations (3.6.0)
@@ -158,11 +158,11 @@ GEM
158158
shoulda-context (1.2.2)
159159
shoulda-matchers (2.8.0)
160160
activesupport (>= 3.0.0)
161-
sidekiq (5.0.4)
161+
sidekiq (5.0.5)
162162
concurrent-ruby (~> 1.0)
163163
connection_pool (~> 2.2, >= 2.2.0)
164164
rack-protection (>= 1.5.0)
165-
redis (~> 3.3, >= 3.3.3)
165+
redis (>= 3.3.4, < 5)
166166
simplecov (0.13.0)
167167
docile (~> 1.1.0)
168168
json (>= 1.8, < 3)
@@ -212,6 +212,7 @@ DEPENDENCIES
212212
rubocop-rspec
213213
shoulda
214214
sidekiq (~> 5.0)
215+
simplecov
215216
spring
216217
spring-watcher-listen (~> 2.0.0)
217218
sqlite3

config/application.rb

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,24 @@
1818
# you"ve limited to :test, :development, or :production.
1919
Bundler.require(*Rails.groups)
2020

21-
class Srv::Application < Rails::Application
22-
# Initialize configuration defaults for originally generated Rails version.
23-
config.load_defaults 5.1
21+
# rubocop:disable Style/ClassAndModuleChildren
22+
module Srv
23+
class Application < Rails::Application
24+
# Initialize configuration defaults for originally generated Rails version.
25+
config.load_defaults 5.1
2426

25-
# Settings in config/environments/* take precedence over those specified here.
26-
# Application configuration should go into files in config/initializers
27-
# -- all .rb files in that directory are automatically loaded.
27+
# Settings in config/environments/* take precedence over those specified here.
28+
# Application configuration should go into files in config/initializers
29+
# -- all .rb files in that directory are automatically loaded.
2830

29-
# Only loads a smaller set of middleware suitable for API only apps.
30-
# Middleware like session, flash, cookies can be added back manually.
31-
# Skip views, helpers and assets when generating a new resource.
32-
config.api_only = true
31+
# Only loads a smaller set of middleware suitable for API only apps.
32+
# Middleware like session, flash, cookies can be added back manually.
33+
# Skip views, helpers and assets when generating a new resource.
34+
config.api_only = true
3335

34-
config.active_job.queue_adapter = :sidekiq
36+
config.active_job.queue_adapter = :sidekiq
3537

36-
config.action_dispatch.trusted_proxies = ["127.0.0.1", "::1"].map { |proxy| IPAddr.new proxy }
38+
config.action_dispatch.trusted_proxies = ["127.0.0.1", "::1"].map { |proxy| IPAddr.new proxy }
39+
end
3740
end
41+
# rubocop:enable Style/ClassAndModuleChildren
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
Brain.request(path: "/cluster-api/v1/cells/discovery",
2-
method: :post,
3-
payload: {
4-
cell: {
5-
uuid: Cell.uuid,
6-
fqdn: Cell.fqdn,
7-
volumes: Cell.storage_volumes,
8-
public_ip_address: ENV["HOST_IP_ADDRESS"]
9-
}
10-
})
1+
if Rails.env.production?
2+
Brain.request(path: "/cluster-api/v1/cells/discovery",
3+
method: :post,
4+
payload: {
5+
cell: {
6+
uuid: Cell.uuid,
7+
fqdn: Cell.fqdn,
8+
volumes: Cell.storage_volumes,
9+
public_ip_address: ENV["HOST_IP_ADDRESS"]
10+
}
11+
})
12+
end

spec/rails_helper.rb

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# This file is copied to spec/ when you run "rails generate rspec:install"
2+
require "spec_helper"
3+
ENV["RAILS_ENV"] ||= "test"
4+
require File.expand_path("../../config/environment", __FILE__)
5+
# Prevent database truncation if the environment is production
6+
abort("The Rails environment is running in production mode!") if Rails.env.production?
7+
require "rspec/rails"
8+
# Add additional requires below this line. Rails is not loaded until this point!
9+
10+
# Requires supporting ruby files with custom matchers and macros, etc, in
11+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
12+
# run as spec files by default. This means that files in spec/support that end
13+
# in _spec.rb will both be required and run as specs, causing the specs to be
14+
# run twice. It is recommended that you do not name files matching this glob to
15+
# end with _spec.rb. You can configure this pattern with the --pattern
16+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
17+
#
18+
# The following line is provided for convenience purposes. It has the downside
19+
# of increasing the boot-up time by auto-requiring all files in the support
20+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
21+
# require only the support files necessary.
22+
#
23+
# Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
24+
25+
# Checks for pending migration and applies them before tests are run.
26+
# If you are not using ActiveRecord, you can remove this line.
27+
ActiveRecord::Migration.maintain_test_schema!
28+
29+
RSpec.configure do |config|
30+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
31+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
32+
33+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
34+
# examples within a transaction, remove the following line or assign false
35+
# instead of true.
36+
config.use_transactional_fixtures = true
37+
38+
# RSpec Rails can automatically mix in different behaviours to your tests
39+
# based on their file location, for example enabling you to call `get` and
40+
# `post` in specs under `spec/controllers`.
41+
#
42+
# You can disable this behaviour by removing the line below, and instead
43+
# explicitly tag your specs with their type, e.g.:
44+
#
45+
# RSpec.describe UsersController, :type => :controller do
46+
# # ...
47+
# end
48+
#
49+
# The different available types are documented in the features, such as in
50+
# https://relishapp.com/rspec/rspec-rails/docs
51+
config.infer_spec_type_from_file_location!
52+
53+
# Filter lines from Rails gems in backtraces.
54+
config.filter_rails_from_backtrace!
55+
# arbitrary gems may also be filtered via:
56+
# config.filter_gems_from_backtrace("gem name")
57+
end

spec/spec_helper.rb

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
require "simplecov"
2+
SimpleCov.start "rails"
3+
4+
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
5+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
6+
# The generated `.rspec` file contains `--require spec_helper` which will cause
7+
# this file to always be loaded, without a need to explicitly require it in any
8+
# files.
9+
#
10+
# Given that it is always loaded, you are encouraged to keep this file as
11+
# light-weight as possible. Requiring heavyweight dependencies from this file
12+
# will add to the boot time of your test suite on EVERY test run, even for an
13+
# individual file that may not need all of that loaded. Instead, consider making
14+
# a separate helper file that requires the additional dependencies and performs
15+
# the additional setup, and require it from the spec files that actually need
16+
# it.
17+
#
18+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19+
RSpec.configure do |config|
20+
# rspec-expectations config goes here. You can use an alternate
21+
# assertion/expectation library such as wrong or the stdlib/minitest
22+
# assertions if you prefer.
23+
config.expect_with :rspec do |expectations|
24+
# This option will default to `true` in RSpec 4. It makes the `description`
25+
# and `failure_message` of custom matchers include text for helper methods
26+
# defined using `chain`, e.g.:
27+
# be_bigger_than(2).and_smaller_than(4).description
28+
# # => "be bigger than 2 and smaller than 4"
29+
# ...rather than:
30+
# # => "be bigger than 2"
31+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32+
end
33+
34+
# rspec-mocks config goes here. You can use an alternate test double
35+
# library (such as bogus or mocha) by changing the `mock_with` option here.
36+
config.mock_with :rspec do |mocks|
37+
# Prevents you from mocking or stubbing a method that does not exist on
38+
# a real object. This is generally recommended, and will default to
39+
# `true` in RSpec 4.
40+
mocks.verify_partial_doubles = true
41+
end
42+
43+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
44+
# have no way to turn it off -- the option exists only for backwards
45+
# compatibility in RSpec 3). It causes shared context metadata to be
46+
# inherited by the metadata hash of host groups and examples, rather than
47+
# triggering implicit auto-inclusion in groups with matching metadata.
48+
config.shared_context_metadata_behavior = :apply_to_host_groups
49+
50+
# The settings below are suggested to provide a good initial experience
51+
# with RSpec, but feel free to customize to your heart's content.
52+
# rubocop:disable Style/BlockComments
53+
=begin
54+
# This allows you to limit a spec run to individual examples or groups
55+
# you care about by tagging them with `:focus` metadata. When nothing
56+
# is tagged with `:focus`, all examples get run. RSpec also provides
57+
# aliases for `it`, `describe`, and `context` that include `:focus`
58+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
59+
config.filter_run_when_matching :focus
60+
61+
# Allows RSpec to persist some state between runs in order to support
62+
# the `--only-failures` and `--next-failure` CLI options. We recommend
63+
# you configure your source control system to ignore this file.
64+
config.example_status_persistence_file_path = "spec/examples.txt"
65+
66+
# Limits the available syntax to the non-monkey patched syntax that is
67+
# recommended. For more details, see:
68+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
69+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
70+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
71+
config.disable_monkey_patching!
72+
73+
# Many RSpec users commonly either run the entire suite or an individual
74+
# file, and it's useful to allow more verbose output when running an
75+
# individual spec file.
76+
if config.files_to_run.one?
77+
# Use the documentation formatter for detailed output,
78+
# unless a formatter has already been configured
79+
# (e.g. via a command-line flag).
80+
config.default_formatter = "doc"
81+
end
82+
83+
# Print the 10 slowest examples and example groups at the
84+
# end of the spec run, to help surface which specs are running
85+
# particularly slow.
86+
config.profile_examples = 10
87+
88+
# Run specs in random order to surface order dependencies. If you find an
89+
# order dependency and want to debug it, you can fix the order by providing
90+
# the seed, which is printed after each run.
91+
# --seed 1234
92+
config.order = :random
93+
94+
# Seed global randomization in this process using the `--seed` CLI option.
95+
# Setting this allows you to use `--seed` to deterministically reproduce
96+
# test failures related to randomization by passing the same `--seed` value
97+
# as the one that triggered the failure.
98+
Kernel.srand config.seed
99+
=end
100+
# rubocop:enable Style/BlockComments
101+
end

0 commit comments

Comments
 (0)