rails_app 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.standard.yml +3 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +42 -0
- data/Rakefile +10 -0
- data/bin/rails_app +5 -0
- data/lib/rails_app/cli.rb +16 -0
- data/lib/rails_app/command.rb +41 -0
- data/lib/rails_app/error.rb +6 -0
- data/lib/rails_app/rails_app.rb +9 -0
- data/lib/rails_app/template/.rspec +3 -0
- data/lib/rails_app/template/.rubocop.yml +5 -0
- data/lib/rails_app/template/.rubocop_todo.yml +0 -0
- data/lib/rails_app/template/Brewfile +11 -0
- data/lib/rails_app/template/app_bootstrap/assets/stylesheets/_customized_bootstrap.scss +20 -0
- data/lib/rails_app/template/app_bootstrap/assets/stylesheets/application.bootstrap.scss +4 -0
- data/lib/rails_app/template/app_bootstrap/assets/stylesheets/custom.scss +140 -0
- data/lib/rails_app/template/app_bootstrap/helpers/application_helper.rb +2 -0
- data/lib/rails_app/template/app_bootstrap/helpers/bootstrap_helper.rb +10 -0
- data/lib/rails_app/template/app_bootstrap/views/devise/confirmations/new.html.erb +22 -0
- data/lib/rails_app/template/app_bootstrap/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/lib/rails_app/template/app_bootstrap/views/devise/mailer/email_changed.html.erb +7 -0
- data/lib/rails_app/template/app_bootstrap/views/devise/mailer/password_change.html.erb +3 -0
- data/lib/rails_app/template/app_bootstrap/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/lib/rails_app/template/app_bootstrap/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/lib/rails_app/template/app_bootstrap/views/devise/passwords/edit.html.erb +29 -0
- data/lib/rails_app/template/app_bootstrap/views/devise/passwords/new.html.erb +20 -0
- data/lib/rails_app/template/app_bootstrap/views/devise/registrations/edit.html.erb +45 -0
- data/lib/rails_app/template/app_bootstrap/views/devise/registrations/new.html.erb +29 -0
- data/lib/rails_app/template/app_bootstrap/views/devise/sessions/new.html.erb +32 -0
- data/lib/rails_app/template/app_bootstrap/views/devise/shared/_error_messages.html.erb +15 -0
- data/lib/rails_app/template/app_bootstrap/views/devise/shared/_links.html.erb +25 -0
- data/lib/rails_app/template/app_bootstrap/views/devise/unlocks/new.html.erb +20 -0
- data/lib/rails_app/template/app_bootstrap/views/layouts/application.html.erb +32 -0
- data/lib/rails_app/template/app_bootstrap/views/layouts/mailer.html.erb +13 -0
- data/lib/rails_app/template/app_bootstrap/views/layouts/mailer.text.erb +1 -0
- data/lib/rails_app/template/app_bootstrap/views/shared/_footer.html.erb +5 -0
- data/lib/rails_app/template/app_bootstrap/views/shared/_form_errors.html.erb +7 -0
- data/lib/rails_app/template/app_bootstrap/views/shared/_navbar.html.erb +18 -0
- data/lib/rails_app/template/app_bootstrap/views/shared/_notices.html.erb +8 -0
- data/lib/rails_app/template/app_bootstrap/views/static/home.html.erb +2 -0
- data/lib/rails_app/template/bin/ci +20 -0
- data/lib/rails_app/template/bin/setup +55 -0
- data/lib/rails_app/template/bin/yarn +18 -0
- data/lib/rails_app/template/config/gems/app.rb +16 -0
- data/lib/rails_app/template/config/gems/rspec_gemfile.rb +14 -0
- data/lib/rails_app/template/config/initializers/generators.rb +9 -0
- data/lib/rails_app/template/esbuild.config.mjs +89 -0
- data/lib/rails_app/template/spec/rails_helper.rb +56 -0
- data/lib/rails_app/template/spec/spec_helper.rb +92 -0
- data/lib/rails_app/template/spec/support/vcr_setup.rb +24 -0
- data/lib/rails_app/template/spec/support/webmock.rb +18 -0
- data/lib/rails_app/template/template.rb +146 -0
- data/lib/rails_app/version.rb +5 -0
- data/lib/rails_app.rb +10 -0
- data/rails_app.gemspec +36 -0
- metadata +159 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
<%- if controller_name != 'sessions' %>
|
2
|
+
<%= link_to "Log in", new_session_path(resource_name) %><br />
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
|
6
|
+
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
|
10
|
+
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
|
14
|
+
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
|
18
|
+
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<%- if devise_mapping.omniauthable? %>
|
22
|
+
<%- resource_class.omniauth_providers.each do |provider| %>
|
23
|
+
<%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), method: :post %><br />
|
24
|
+
<% end %>
|
25
|
+
<% end %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<div class="row">
|
2
|
+
<div class="col-lg-4 offset-lg-4">
|
3
|
+
<h1 class="text-center">Resend unlock instructions</h1>
|
4
|
+
|
5
|
+
<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
|
6
|
+
<%= render "devise/shared/error_messages", resource: resource %>
|
7
|
+
|
8
|
+
<div class="mb-3">
|
9
|
+
<%= f.label :email, class: "form-label" %>
|
10
|
+
<%= f.email_field :email, autofocus: true, autocomplete: "email", class: "form-control" %>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<div class="mb-3">
|
14
|
+
<%= f.submit "Resend unlock instructions", class: "btn btn-lg btn-primary" %>
|
15
|
+
</div>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<%= render "devise/shared/links" %>
|
19
|
+
</div>
|
20
|
+
</div>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en" class="h-100">
|
3
|
+
<head>
|
4
|
+
<title>Testapp</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<%= csrf_meta_tags %>
|
7
|
+
<%= csp_meta_tag %>
|
8
|
+
|
9
|
+
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
|
10
|
+
<%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
|
11
|
+
</head>
|
12
|
+
|
13
|
+
<body class="d-flex flex-column h-100 bg-body">
|
14
|
+
<main class="">
|
15
|
+
<%= render "shared/navbar" %>
|
16
|
+
<%= render "shared/notices" %>
|
17
|
+
|
18
|
+
<div class="container mt-5 mx-auto">
|
19
|
+
<%= yield %>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<%= content_tag :div, '', class: "container d-flex" do %>
|
23
|
+
<div class="card w-75 shadow-sm p-3">
|
24
|
+
<%= debug(params) if Rails.env.local? %>
|
25
|
+
</div>
|
26
|
+
<% end if Rails.env.local? %>
|
27
|
+
</main>
|
28
|
+
|
29
|
+
|
30
|
+
<%= render "shared/footer" %>
|
31
|
+
</body>
|
32
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
2
|
+
<div class="container">
|
3
|
+
<%= link_to "Testapp", root_path, class: "navbar-brand" %>
|
4
|
+
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
5
|
+
<span class="navbar-toggler-icon"></span>
|
6
|
+
</button>
|
7
|
+
<div class="collapse navbar-collapse" id="navbarNav">
|
8
|
+
<ul class="navbar-nav ms-auto">
|
9
|
+
<% if user_signed_in? %>
|
10
|
+
<li class="nav-item"><%= button_to "Log out", destroy_user_session_path, method: :delete, class: "nav-link" %></li>
|
11
|
+
<% else %>
|
12
|
+
<li class="nav-item"><%= link_to "Login", new_user_session_path, class: "nav-link" %></li>
|
13
|
+
<li class="nav-item"><%= link_to "Sign Up", new_user_registration_path, class: "nav-link" %></li>
|
14
|
+
<% end%>
|
15
|
+
</ul>
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
</nav>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<% flash.each do |msg_type, message| %>
|
2
|
+
<div class="container mt-4 mx-auto">
|
3
|
+
<div class="alert <%= bootstrap_class_for(msg_type) %> alert-dismissible fade show" role="alert">
|
4
|
+
<%= message %>
|
5
|
+
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
6
|
+
</div>
|
7
|
+
</div>
|
8
|
+
<% end %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
#set -e
|
4
|
+
|
5
|
+
echo "[ bin/ci ] Running tests"
|
6
|
+
bin/rails test
|
7
|
+
|
8
|
+
echo "[ bin/ci ] Analyzing code for security vulnerabilities with brakeman."
|
9
|
+
echo "[ bin/ci ] Output will be in tmp/brakeman.html, which"
|
10
|
+
echo "[ bin/ci ] can be opened in your browser."
|
11
|
+
bundle exec brakeman -q -o tmp/brakeman.html
|
12
|
+
|
13
|
+
echo "[ bin/ci ] Analyzing Ruby gems for"
|
14
|
+
echo "[ bin/ci ] security vulnerabilities with bundle audit"
|
15
|
+
bundle exec bundle-audit check --update
|
16
|
+
|
17
|
+
echo "[ bin/ci ] Linting: Running rubocop"
|
18
|
+
bin/rubocop
|
19
|
+
|
20
|
+
echo "[ bin/ci ] Done"
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = File.expand_path("..", __dir__)
|
6
|
+
|
7
|
+
def system!(*args)
|
8
|
+
system(*args, exception: true)
|
9
|
+
end
|
10
|
+
|
11
|
+
def command_available?(command)
|
12
|
+
system("command -v #{command} >/dev/null 2>&1")
|
13
|
+
end
|
14
|
+
|
15
|
+
FileUtils.chdir APP_ROOT do
|
16
|
+
# This script is a way to set up or update your development environment automatically.
|
17
|
+
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
|
18
|
+
# Add necessary setup steps to this file.
|
19
|
+
|
20
|
+
# Install system dependencies if Homebrew is installed
|
21
|
+
if command_available?("brew")
|
22
|
+
system("brew bundle check --no-lock --no-upgrade") || system!("brew bundle --no-upgrade --no-lock")
|
23
|
+
end
|
24
|
+
|
25
|
+
puts "== Installing dependencies =="
|
26
|
+
system! "gem install bundler --conservative"
|
27
|
+
system("bundle check") || system!("bundle install")
|
28
|
+
|
29
|
+
# Install foreman system wide
|
30
|
+
system! "gem install foreman"
|
31
|
+
|
32
|
+
# Install yarn system wide
|
33
|
+
system! "npm install -g yarn" unless command_available?("yarn")
|
34
|
+
|
35
|
+
# Install JavaScript dependencies if using Yarn
|
36
|
+
system("bin/yarn")
|
37
|
+
|
38
|
+
puts "\n== Compiling CSS & JS =="
|
39
|
+
system! "bin/yarn run build"
|
40
|
+
system! "bin/yarn run build:css"
|
41
|
+
|
42
|
+
# puts "\n== Copying sample files =="
|
43
|
+
# unless File.exist?("config/database.yml")
|
44
|
+
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
|
45
|
+
# end
|
46
|
+
|
47
|
+
puts "\n== Preparing database =="
|
48
|
+
system! "bin/rails db:prepare"
|
49
|
+
|
50
|
+
puts "\n== Removing old logs and tempfiles =="
|
51
|
+
system! "bin/rails log:clear tmp:clear"
|
52
|
+
|
53
|
+
puts "\n== Restarting application server =="
|
54
|
+
system! "bin/rails restart"
|
55
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
APP_ROOT = File.expand_path("..", __dir__)
|
4
|
+
Dir.chdir(APP_ROOT) do
|
5
|
+
yarn = ENV["PATH"].split(File::PATH_SEPARATOR)
|
6
|
+
.select { |dir| File.expand_path(dir) != __dir__ }
|
7
|
+
.product(["yarn", "yarnpkg", "yarn.cmd", "yarn.ps1"])
|
8
|
+
.map { |dir, file| File.expand_path(file, dir) }
|
9
|
+
.find { |file| File.executable?(file) }
|
10
|
+
|
11
|
+
if yarn
|
12
|
+
exec yarn, *ARGV
|
13
|
+
else
|
14
|
+
warn "Yarn executable was not detected in the system."
|
15
|
+
warn "Download Yarn at https://yarnpkg.com/en/docs/install"
|
16
|
+
exit 1
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
gem "devise"
|
2
|
+
|
3
|
+
group :development, :test do
|
4
|
+
gem "faker"
|
5
|
+
end
|
6
|
+
|
7
|
+
group :development do
|
8
|
+
gem "rubocop-rails-omakase", require: false
|
9
|
+
gem "bundle-audit", require: false
|
10
|
+
gem "brakeman", require: false
|
11
|
+
end
|
12
|
+
|
13
|
+
group :test do
|
14
|
+
gem "simplecov", "~> 0.21.2", require: false
|
15
|
+
gem "test-prof"
|
16
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
import * as esbuild from "esbuild"
|
4
|
+
import path from "path"
|
5
|
+
import chokidar from "chokidar"
|
6
|
+
import http from "http"
|
7
|
+
import { setTimeout } from "timers/promises"
|
8
|
+
import rails from "esbuild-rails"
|
9
|
+
|
10
|
+
const clients = []
|
11
|
+
const entryPoints = [
|
12
|
+
"application.js",
|
13
|
+
]
|
14
|
+
|
15
|
+
const watchDirectories = [
|
16
|
+
"./app/javascript/**/*.js",
|
17
|
+
"./app/views/**/*.html.erb",
|
18
|
+
"./app/assets/builds/**/*.css", // Wait for cssbundling changes
|
19
|
+
]
|
20
|
+
|
21
|
+
const config = {
|
22
|
+
absWorkingDir: path.join(process.cwd(), "app/javascript"),
|
23
|
+
bundle: true,
|
24
|
+
entryPoints: entryPoints,
|
25
|
+
minify: process.env.RAILS_ENV === "production",
|
26
|
+
outdir: path.join(process.cwd(), "app/assets/builds"),
|
27
|
+
plugins: [rails()],
|
28
|
+
sourcemap: process.env.RAILS_ENV !== "production"
|
29
|
+
}
|
30
|
+
|
31
|
+
async function buildAndReload() {
|
32
|
+
// Foreman & Overmind assign a separate PORT for each process
|
33
|
+
const port = parseInt(process.env.PORT)
|
34
|
+
const context = await esbuild.context({
|
35
|
+
...config,
|
36
|
+
banner: {
|
37
|
+
js: ` (() => new EventSource("http://localhost:${port}").onmessage = () => location.reload())();`,
|
38
|
+
}
|
39
|
+
})
|
40
|
+
|
41
|
+
// Reload uses an HTTP server as an even stream to reload the browser
|
42
|
+
http
|
43
|
+
.createServer((req, res) => {
|
44
|
+
return clients.push(
|
45
|
+
res.writeHead(200, {
|
46
|
+
"Content-Type": "text/event-stream",
|
47
|
+
"Cache-Control": "no-cache",
|
48
|
+
"Access-Control-Allow-Origin": "*",
|
49
|
+
Connection: "keep-alive",
|
50
|
+
})
|
51
|
+
)
|
52
|
+
})
|
53
|
+
.listen(port)
|
54
|
+
|
55
|
+
await context.rebuild()
|
56
|
+
console.log("[reload] initial build succeeded")
|
57
|
+
|
58
|
+
let ready = false
|
59
|
+
chokidar
|
60
|
+
.watch(watchDirectories)
|
61
|
+
.on("ready", () => {
|
62
|
+
console.log("[reload] ready")
|
63
|
+
ready = true
|
64
|
+
})
|
65
|
+
.on("all", async (event, path) => {
|
66
|
+
if (ready === false) return
|
67
|
+
|
68
|
+
if (path.includes("javascript")) {
|
69
|
+
try {
|
70
|
+
await setTimeout(20)
|
71
|
+
await context.rebuild()
|
72
|
+
console.log("[reload] build succeeded")
|
73
|
+
} catch (error) {
|
74
|
+
console.error("[reload] build failed", error)
|
75
|
+
}
|
76
|
+
}
|
77
|
+
clients.forEach((res) => res.write("data: update\n\n"))
|
78
|
+
clients.length = 0
|
79
|
+
})
|
80
|
+
}
|
81
|
+
|
82
|
+
if (process.argv.includes("--reload")) {
|
83
|
+
buildAndReload()
|
84
|
+
} else if (process.argv.includes("--watch")) {
|
85
|
+
let context = await esbuild.context({ ...config, logLevel: 'info' })
|
86
|
+
context.watch()
|
87
|
+
} else {
|
88
|
+
esbuild.build(config)
|
89
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
if ENV["RAILS_ENV"] ||= "test"
|
2
|
+
require "simplecov"
|
3
|
+
SimpleCov.start "rails" do
|
4
|
+
add_filter "/lib/"
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
require "spec_helper"
|
9
|
+
|
10
|
+
ENV["RAILS_ENV"] ||= "test"
|
11
|
+
|
12
|
+
require_relative "../config/environment"
|
13
|
+
# Prevent database truncation if the environment is production
|
14
|
+
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
15
|
+
require "rspec/rails"
|
16
|
+
require "capybara/rails"
|
17
|
+
require "capybara/rspec"
|
18
|
+
require "fuubar"
|
19
|
+
require "webmock/rspec"
|
20
|
+
|
21
|
+
Rails.root.glob("spec/support/**/*.rb").sort.each { |f| require f }
|
22
|
+
|
23
|
+
# Checks for pending migrations and applies them before tests are run.
|
24
|
+
# If you are not using ActiveRecord, you can remove these lines.
|
25
|
+
begin
|
26
|
+
ActiveRecord::Migration.maintain_test_schema!
|
27
|
+
rescue ActiveRecord::PendingMigrationError => e
|
28
|
+
abort e.to_s.strip
|
29
|
+
end
|
30
|
+
|
31
|
+
VCRSetup.configure_vcr
|
32
|
+
|
33
|
+
WebMock.disable_net_connect!(allow_localhost: true)
|
34
|
+
|
35
|
+
RSpec.configure do |config|
|
36
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
37
|
+
config.fixture_paths = [
|
38
|
+
Rails.root.join("spec/fixtures")
|
39
|
+
]
|
40
|
+
config.use_transactional_fixtures = true
|
41
|
+
config.include FactoryBot::Syntax::Methods
|
42
|
+
# config.include Warden::Test::Helpers # helpers for system tests
|
43
|
+
# config.include Devise::Test::IntegrationHelpers, type: :request
|
44
|
+
# config.include Devise::Test::IntegrationHelpers, type: :component
|
45
|
+
# config.include Devise::Test::ControllerHelpers, type: :view
|
46
|
+
config.include Turbo::FramesHelper, type: :system
|
47
|
+
config.include Turbo::StreamsHelper, type: :system
|
48
|
+
|
49
|
+
config.infer_spec_type_from_file_location!
|
50
|
+
|
51
|
+
# Filter lines from Rails gems in backtraces.
|
52
|
+
config.filter_rails_from_backtrace!
|
53
|
+
# arbitrary gems may also be filtered via:
|
54
|
+
# config.filter_gems_from_backtrace("gem name")
|
55
|
+
config.fuubar_progress_bar_options = {format: "Completed Tests <%B> %p%% %a"}
|
56
|
+
end
|
@@ -0,0 +1,92 @@
|
|
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 https://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
|
+
# # This allows you to limit a spec run to individual examples or groups
|
50
|
+
# # you care about by tagging them with `:focus` metadata. When nothing
|
51
|
+
# # is tagged with `:focus`, all examples get run. RSpec also provides
|
52
|
+
# # aliases for `it`, `describe`, and `context` that include `:focus`
|
53
|
+
# # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
54
|
+
# config.filter_run_when_matching :focus
|
55
|
+
#
|
56
|
+
# # Allows RSpec to persist some state between runs in order to support
|
57
|
+
# # the `--only-failures` and `--next-failure` CLI options. We recommend
|
58
|
+
# # you configure your source control system to ignore this file.
|
59
|
+
# config.example_status_persistence_file_path = "spec/examples.txt"
|
60
|
+
#
|
61
|
+
# # Limits the available syntax to the non-monkey patched syntax that is
|
62
|
+
# # recommended. For more details, see:
|
63
|
+
# # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/
|
64
|
+
# config.disable_monkey_patching!
|
65
|
+
#
|
66
|
+
# # Many RSpec users commonly either run the entire suite or an individual
|
67
|
+
# # file, and it's useful to allow more verbose output when running an
|
68
|
+
# # individual spec file.
|
69
|
+
# if config.files_to_run.one?
|
70
|
+
# # Use the documentation formatter for detailed output,
|
71
|
+
# # unless a formatter has already been configured
|
72
|
+
# # (e.g. via a command-line flag).
|
73
|
+
# config.default_formatter = "doc"
|
74
|
+
# end
|
75
|
+
#
|
76
|
+
# # Print the 10 slowest examples and example groups at the
|
77
|
+
# # end of the spec run, to help surface which specs are running
|
78
|
+
# # particularly slow.
|
79
|
+
# config.profile_examples = 10
|
80
|
+
#
|
81
|
+
# # Run specs in random order to surface order dependencies. If you find an
|
82
|
+
# # order dependency and want to debug it, you can fix the order by providing
|
83
|
+
# # the seed, which is printed after each run.
|
84
|
+
# # --seed 1234
|
85
|
+
# config.order = :random
|
86
|
+
#
|
87
|
+
# # Seed global randomization in this process using the `--seed` CLI option.
|
88
|
+
# # Setting this allows you to use `--seed` to deterministically reproduce
|
89
|
+
# # test failures related to randomization by passing the same `--seed` value
|
90
|
+
# # as the one that triggered the failure.
|
91
|
+
# Kernel.srand config.seed
|
92
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module VCRSetup
|
2
|
+
def self.configure_vcr
|
3
|
+
# VCR is used to 'record' HTTP interactions with
|
4
|
+
# third party services used in tests, and play em
|
5
|
+
# back. Useful for efficiency, also useful for
|
6
|
+
# testing code against API's that not everyone
|
7
|
+
# has access to -- the responses can be cached
|
8
|
+
# and re-used.
|
9
|
+
require "vcr"
|
10
|
+
require "webmock/rspec"
|
11
|
+
|
12
|
+
# To allow us to do real HTTP requests in a VCR.turned_off, we
|
13
|
+
# have to tell webmock to let us.
|
14
|
+
# WebMock.allow_net_connect!(:net_http_connect_on_start => true)
|
15
|
+
|
16
|
+
VCR.configure do |c|
|
17
|
+
c.cassette_library_dir = "spec/fixtures/vcr_cassettes"
|
18
|
+
c.hook_into :webmock
|
19
|
+
c.allow_http_connections_when_no_cassette = true
|
20
|
+
c.ignore_localhost = true
|
21
|
+
# c.filter_sensitive_data("<MY_SECRET_KEY>") { Rails.application.credentials.dig(:maxmind_api_key) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "webmock/rspec"
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.before(:all, type: :request) do
|
7
|
+
WebMock.allow_net_connect!
|
8
|
+
end
|
9
|
+
|
10
|
+
config.before(:all, type: :system) do
|
11
|
+
WebMock.allow_net_connect!
|
12
|
+
end
|
13
|
+
|
14
|
+
config.after(:all, type: :request) do
|
15
|
+
selenium_requests = %r{/((__.+__)|(hub/session.*))$}
|
16
|
+
WebMock.allow_net_connect! allow: selenium_requests
|
17
|
+
end
|
18
|
+
end
|