diff --git a/.rspec b/.rspec new file mode 100644 index 00000000..aae9b46f --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--require spec_helper --format documentation diff --git a/Gemfile b/Gemfile index dd4c9541..00d5c3dc 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index 44cc3667..9d51c19e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -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) @@ -188,6 +206,7 @@ DEPENDENCIES debug puma rails + rspec-rails rubocop-rails sqlite3 diff --git a/spec/misc/foo_spec.rb b/spec/misc/foo_spec.rb new file mode 100644 index 00000000..40fe5591 --- /dev/null +++ b/spec/misc/foo_spec.rb @@ -0,0 +1,7 @@ +require 'rails_helper' + +RSpec.describe do + it 'Bar' do + expect(1 + 1).to eq 2 + end +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 00000000..ef5891fc --- /dev/null +++ b/spec/rails_helper.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 00000000..06e09a30 --- /dev/null +++ b/spec/spec_helper.rb @@ -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