forked from the-teacher/rails7-startkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72f2ef5
commit 5fd5a2c
Showing
31 changed files
with
296 additions
and
146 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--require spec_helper |
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
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
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
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 @@ | ||
# frozen_string_literal: true | ||
|
||
module Rails7StartKit | ||
class << self | ||
def rspec | ||
container_bash_exec('rails', 'rspec -f documentation') | ||
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
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,18 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe DemoMailer, type: :mailer do | ||
let(:mail) { DemoMailer.welcome_email } | ||
|
||
it 'renders the headers' do | ||
expect(mail.subject).to eq('Welcome to Rails 7. StartKit') | ||
expect(mail.to).to eq(['test@test.com']) | ||
expect(mail.from).to eq(['demo@rails7startkit.com']) | ||
end | ||
|
||
it 'renders the body' do | ||
expect(mail.body.encoded).to match('Welcome to Rails7. StartKit') | ||
expect(mail.body.encoded).to match('Thanks for using this project!') | ||
end | ||
end |
6 changes: 3 additions & 3 deletions
6
test/mailers/previews/demo_mailer_preview.rb → spec/mailers/previews/demo_preview.rb
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,45 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe Article, type: :model do | ||
it 'creates an article' do | ||
Article.create( | ||
title: 'ABC', | ||
content_raw: 'test content' | ||
) | ||
expect(Article.count).to eq(1) | ||
end | ||
|
||
it 'processes content_raw in content' do | ||
article = Article.create( | ||
title: 'Article title', | ||
content_raw: '<h1>test content<h1>' | ||
) | ||
expect(article.content).to eq('test content') | ||
end | ||
|
||
context 'negative cases' do | ||
it 'fails if title is of whitespaces ' do | ||
article = Article.create( | ||
title: ' ', | ||
content_raw: '<h1>test content<h1>' | ||
) | ||
|
||
expect( | ||
article.errors.messages[:title] | ||
).to eq(["can't be blank"]) | ||
end | ||
|
||
it 'fails if article title length less than 3 symbols' do | ||
article = Article.create( | ||
title: 'AB', | ||
content_raw: 'test content' | ||
) | ||
|
||
expect( | ||
article.errors.messages[:title] | ||
).to eq(['is too short (minimum is 3 characters)']) | ||
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,69 @@ | ||
# frozen_string_literal: true | ||
|
||
# This file is copied to spec/ when you run 'rails generate rspec:install' | ||
require 'spec_helper' | ||
ENV['RAILS_ENV'] = 'test' | ||
require_relative '../config/environment' | ||
# Prevent database truncation if the environment is production | ||
abort('The Rails environment is running in production mode!') if Rails.env.production? | ||
require 'rspec/rails' | ||
# Add additional requires below this line. Rails is not loaded until this point! | ||
|
||
# Requires supporting ruby files with custom matchers and macros, etc, in | ||
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are | ||
# run as spec files by default. This means that files in spec/support that end | ||
# in _spec.rb will both be required and run as specs, causing the specs to be | ||
# run twice. It is recommended that you do not name files matching this glob to | ||
# end with _spec.rb. You can configure this pattern with the --pattern | ||
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. | ||
# | ||
# The following line is provided for convenience purposes. It has the downside | ||
# of increasing the boot-up time by auto-requiring all files in the support | ||
# directory. Alternatively, in the individual `*_spec.rb` files, manually | ||
# require only the support files necessary. | ||
# | ||
# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f } | ||
|
||
# Checks for pending migrations and applies them before tests are run. | ||
# If you are not using ActiveRecord, you can remove these lines. | ||
begin | ||
ActiveRecord::Migration.maintain_test_schema! | ||
rescue ActiveRecord::PendingMigrationError => e | ||
abort e.to_s.strip | ||
end | ||
RSpec.configure do |config| | ||
config.before(:suite) do | ||
Chewy.strategy(:bypass) | ||
end | ||
|
||
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures | ||
config.fixture_path = Rails.root.join('spec/fixtures') | ||
|
||
# If you're not using ActiveRecord, or you'd prefer not to run each of your | ||
# examples within a transaction, remove the following line or assign false | ||
# instead of true. | ||
config.use_transactional_fixtures = true | ||
|
||
# You can uncomment this line to turn off ActiveRecord support entirely. | ||
# config.use_active_record = false | ||
|
||
# RSpec Rails can automatically mix in different behaviours to your tests | ||
# based on their file location, for example enabling you to call `get` and | ||
# `post` in specs under `spec/controllers`. | ||
# | ||
# You can disable this behaviour by removing the line below, and instead | ||
# explicitly tag your specs with their type, e.g.: | ||
# | ||
# RSpec.describe UsersController, type: :controller do | ||
# # ... | ||
# end | ||
# | ||
# The different available types are documented in the features, such as in | ||
# https://relishapp.com/rspec/rspec-rails/docs | ||
config.infer_spec_type_from_file_location! | ||
|
||
# Filter lines from Rails gems in backtraces. | ||
config.filter_rails_from_backtrace! | ||
# arbitrary gems may also be filtered via: | ||
# config.filter_gems_from_backtrace("gem name") | ||
end |
Oops, something went wrong.