-
-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use `touch` test helper instead of directly working with the `File` class during the setup phase. Also create [file_fixtures][] to simplify test setup. Because the newly added file fixtures are processed with standard, I needed to adjust the testing generator to account for a minor violation. [file_fixtures]: https://api.rubyonrails.org/classes/ActiveSupport/Testing/FileFixtures.html#method-i-file_fixture
- Loading branch information
1 parent
56b316c
commit e53a42b
Showing
31 changed files
with
244 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require_relative "config/application" | ||
require "bundler/audit/task" | ||
Bundler::Audit::Task.new | ||
|
||
Rails.application.load_tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<% if flash.any? %> | ||
<div class="flashes"> | ||
<% flash.each do |type, message| -%> | ||
<div class="flash-<%= type %>"><%= message %></div> | ||
<% end -%> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
RSpec.configure do |config| | ||
config.before(:each) do | ||
ActionMailer::Base.deliveries.clear | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require "active_job/logging" | ||
require "active_job/log_subscriber" | ||
|
||
ActiveSupport::Notifications.unsubscribe("enqueue.active_job") | ||
|
||
module ActiveJob | ||
module Logging | ||
class EnqueueLogSubscriber < LogSubscriber | ||
define_method :enqueue, instance_method(:enqueue) | ||
end | ||
end | ||
end | ||
|
||
ActiveJob::Logging::EnqueueLogSubscriber.attach_to(:active_job) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Rails.configuration.to_prepare do | ||
if Rails.env.test? | ||
require "better_html" | ||
|
||
BetterHtml.config = BetterHtml::Config.new(Rails.configuration.x.better_html) | ||
|
||
BetterHtml.config.template_exclusion_filter = proc { |filename| !filename.start_with?(Rails.root.to_s) } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
RSpec.configure do |config| | ||
config.before(:each, type: :system) do | ||
driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class EmailInterceptor | ||
include ActiveSupport::Configurable | ||
|
||
config_accessor :interceptor_addresses, default: [] | ||
|
||
def self.delivering_email(message) | ||
to = interceptor_addresses | ||
|
||
message.to = to if to.any? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Rails.application.configure do | ||
if ENV["INTERCEPTOR_ADDRESSES"].present? | ||
config.action_mailer.interceptors = %w[EmailInterceptor] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
glob: "app/views/**/*.{html,turbo_stream}{+*,}.erb" | ||
|
||
linters: | ||
AllowedScriptType: | ||
enabled: true | ||
allowed_types: | ||
- "module" | ||
- "text/javascript" | ||
ErbSafety: | ||
enabled: true | ||
better_html_config: "config/better_html.yml" | ||
GitHub::Accessibility::AvoidBothDisabledAndAriaDisabledCounter: | ||
enabled: true | ||
GitHub::Accessibility::AvoidGenericLinkTextCounter: | ||
enabled: true | ||
GitHub::Accessibility::DisabledAttributeCounter: | ||
enabled: true | ||
GitHub::Accessibility::IframeHasTitleCounter: | ||
enabled: true | ||
GitHub::Accessibility::ImageHasAltCounter: | ||
enabled: true | ||
GitHub::Accessibility::LandmarkHasLabelCounter: | ||
enabled: true | ||
GitHub::Accessibility::LinkHasHrefCounter: | ||
enabled: true | ||
GitHub::Accessibility::NestedInteractiveElementsCounter: | ||
enabled: true | ||
GitHub::Accessibility::NoAriaLabelMisuseCounter: | ||
enabled: true | ||
GitHub::Accessibility::NoPositiveTabIndexCounter: | ||
enabled: true | ||
GitHub::Accessibility::NoRedundantImageAltCounter: | ||
enabled: true | ||
GitHub::Accessibility::NoTitleAttributeCounter: | ||
enabled: true | ||
GitHub::Accessibility::SvgHasAccessibleTextCounter: | ||
enabled: true | ||
Rubocop: | ||
enabled: true | ||
rubocop_config: | ||
inherit_from: | ||
- .rubocop.yml | ||
|
||
Lint/EmptyBlock: | ||
Enabled: false | ||
Layout/InitialIndentation: | ||
Enabled: false | ||
Layout/TrailingEmptyLines: | ||
Enabled: false | ||
Layout/TrailingWhitespace: | ||
Enabled: false | ||
Layout/LeadingEmptyLines: | ||
Enabled: false | ||
Style/FrozenStringLiteralComment: | ||
Enabled: false | ||
Style/MultilineTernaryOperator: | ||
Enabled: false | ||
Lint/UselessAssignment: | ||
Exclude: | ||
- "app/views/**/*" | ||
|
||
EnableDefaultLinters: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": ["@thoughtbot/eslint-config/prettier"], | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FactoryBot.define do | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe "Factories" do | ||
it "has valid factoties" do | ||
FactoryBot.lint traits: true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require "test_helper" | ||
|
||
class FactoryBotsTest < ActiveSupport::TestCase | ||
class FactoryLintingTest < FactoryBotsTest | ||
test "linting of factories" do | ||
FactoryBot.lint traits: true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
RSpec.configure do |config| | ||
config.include ActionView::Helpers::TranslationHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
InlineSvg.configure do |config| | ||
config.raise_on_file_not_found = true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
vendor/bundle/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"singleQuote": true, | ||
"overrides": [ | ||
{ | ||
"files": ["**/*.css", "**/*.scss", "**/*.html"], | ||
"options": { | ||
"singleQuote": false | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Shoulda::Matchers.configure do |config| | ||
config.integrate do |with| | ||
with.test_framework :rspec | ||
with.library :rails | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require "webmock/rspec" | ||
|
||
RSpec.configure do |config| | ||
config.example_status_persistence_file_path = "tmp/rspec_examples.txt" | ||
config.order = :random | ||
|
||
config.expect_with :rspec do |expectations| | ||
expectations.include_chain_clauses_in_custom_matcher_descriptions = true | ||
end | ||
|
||
config.mock_with :rspec do |mocks| | ||
mocks.verify_partial_doubles = true | ||
end | ||
config.shared_context_metadata_behavior = :apply_to_host_groups | ||
end | ||
|
||
WebMock.disable_net_connect!( | ||
allow_localhost: true, | ||
allow: [ | ||
/(chromedriver|storage).googleapis.com/, | ||
"googlechromelabs.github.io" | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "@thoughtbot/stylelint-config" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ENV["RAILS_ENV"] ||= "test" | ||
require_relative "../config/environment" | ||
require "rails/test_help" | ||
|
||
module ActiveSupport | ||
class TestCase | ||
# Run tests in parallel with specified workers | ||
parallelize(workers: :number_of_processors) | ||
|
||
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. | ||
fixtures :all | ||
|
||
# Add more helper methods to be used by all tests here... | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.