Skip to content

Commit

Permalink
test: πŸ’ RSpec γ‚’ε°Žε…₯γ—γŸ (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikukyugamer authored Jun 9, 2022
1 parent 58f47a0 commit e3e3727
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper --format documentation
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ gem 'sqlite3'

group :development, :test do
gem 'debug', platforms: %i[mri mingw x64_mingw]
gem 'rspec-rails', require: false
gem 'rubocop-rails', require: false
end
19 changes: 19 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ GEM
debug (1.5.0)
irb (>= 1.3.6)
reline (>= 0.2.7)
diff-lcs (1.5.0)
digest (3.1.0)
erubi (1.10.0)
globalid (1.0.0)
Expand Down Expand Up @@ -152,6 +153,23 @@ GEM
reline (0.3.1)
io-console (~> 0.5)
rexml (3.2.5)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-rails (5.1.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
railties (>= 5.2)
rspec-core (~> 3.10)
rspec-expectations (~> 3.10)
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.11.0)
rubocop (1.30.1)
parallel (~> 1.10)
parser (>= 3.1.0.0)
Expand Down Expand Up @@ -188,6 +206,7 @@ DEPENDENCIES
debug
puma
rails
rspec-rails
rubocop-rails
sqlite3

Expand Down
7 changes: 7 additions & 0 deletions spec/misc/foo_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'rails_helper'

RSpec.describe do
it 'Bar' do
expect(1 + 1).to eq 2
end
end
20 changes: 20 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'spec_helper'
ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'

abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'rspec/rails'

begin
ActiveRecord::Migration.maintain_test_schema!
rescue ActiveRecord::PendingMigrationError => e
puts e.to_s.strip
exit 1
end

RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
config.infer_spec_type_from_file_location!
config.filter_rails_from_backtrace!
end
11 changes: 11 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
RSpec.configure do |config|
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

0 comments on commit e3e3727

Please sign in to comment.