diff --git a/Gemfile b/Gemfile index 69d452c..b6dd393 100644 --- a/Gemfile +++ b/Gemfile @@ -20,4 +20,5 @@ group :test do gem 'faker' gem 'factory_bot_rails' gem 'email_spec' + gem 'database_cleaner' end diff --git a/Gemfile.lock b/Gemfile.lock index 671d634..881b28c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -95,6 +95,12 @@ GEM concurrent-ruby (1.2.2) crass (1.0.6) damerau-levenshtein (1.3.3) + database_cleaner (2.0.2) + database_cleaner-active_record (>= 2, < 3) + database_cleaner-active_record (2.1.0) + activerecord (>= 5.a) + database_cleaner-core (~> 2.0.0) + database_cleaner-core (2.0.1) date (3.3.3) devise (4.9.2) bcrypt (~> 3.0) @@ -243,6 +249,7 @@ DEPENDENCIES bundler (~> 2.0) byebug capybara + database_cleaner devise-recognisable! email_spec factory_bot_rails @@ -255,4 +262,4 @@ DEPENDENCIES sqlite3 BUNDLED WITH - 2.0.1 + 2.1.4 diff --git a/bin/setup b/bin/setup index 29ae921..dce67d8 100755 --- a/bin/setup +++ b/bin/setup @@ -5,10 +5,4 @@ set -vx bundle install -cd spec/dummy-app -bundle install -./bin/rails db:setup -./bin/rails assets:precompile -cd ../../ - # Do any other automated setup that you need to do here diff --git a/spec/dummy-app/Gemfile b/spec/dummy-app/Gemfile deleted file mode 100644 index 472d063..0000000 --- a/spec/dummy-app/Gemfile +++ /dev/null @@ -1,68 +0,0 @@ -source 'https://rubygems.org' -git_source(:github) { |repo| "https://github.com/#{repo}.git" } - -ruby '2.7.7' - -# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 5.2.5' -# Use sqlite3 as the database for Active Record -gem 'sqlite3' -# Use Puma as the app server -gem 'puma', '~> 4.3' -# Use SCSS for stylesheets -gem 'sass-rails', '~> 5.0' -# Use Uglifier as compressor for JavaScript assets -gem 'uglifier', '>= 1.3.0' -# See https://github.com/rails/execjs#readme for more supported runtimes -# gem 'mini_racer', platforms: :ruby - -# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks -gem 'turbolinks', '~> 5' -# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder -gem 'jbuilder', '~> 2.5' -# Use Redis adapter to run Action Cable in production -# gem 'redis', '~> 4.0' -# Use ActiveModel has_secure_password -# gem 'bcrypt', '~> 3.1.7' - -# Use ActiveStorage variant -# gem 'mini_magick', '~> 4.8' - -# Use Capistrano for deployment -# gem 'capistrano-rails', group: :development - -# Reduces boot times through caching; required in config/boot.rb -gem 'bootsnap', '>= 1.1.0', require: false - -gem 'devise' - -# Add devise recognisable as a dependency, rather than requiring. -gem 'devise-recognisable', path: '../..' - -# Add rollbar for debugging -gem 'rollbar', '~> 2.11', '>= 2.11.5' - -group :development, :test do - # Call 'byebug' anywhere in the code to stop execution and get a debugger console - gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] - gem 'rspec-rails' -end - -group :development do - # Access an interactive console on exception pages or by calling 'console' anywhere in the code. - gem 'web-console', '>= 3.3.0' - gem 'listen', '>= 3.0.5', '< 3.2' - # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring - gem 'spring' - gem 'spring-watcher-listen', '~> 2.0.0' -end - -group :test do - gem 'capybara' - gem 'faker' - gem 'factory_bot_rails' - gem 'email_spec' -end - -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/spec/dummy-app/Gemfile.lock b/spec/dummy-app/Gemfile.lock deleted file mode 100644 index 55fd787..0000000 --- a/spec/dummy-app/Gemfile.lock +++ /dev/null @@ -1,277 +0,0 @@ -PATH - remote: ../.. - specs: - devise-recognisable (0.1.0) - damerau-levenshtein (~> 1.1) - devise - geocoder - jwt - rails (>= 5) - -GEM - remote: https://rubygems.org/ - specs: - actioncable (5.2.8.1) - actionpack (= 5.2.8.1) - nio4r (~> 2.0) - websocket-driver (>= 0.6.1) - actionmailer (5.2.8.1) - actionpack (= 5.2.8.1) - actionview (= 5.2.8.1) - activejob (= 5.2.8.1) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 2.0) - actionpack (5.2.8.1) - actionview (= 5.2.8.1) - activesupport (= 5.2.8.1) - rack (~> 2.0, >= 2.0.8) - rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.8.1) - activesupport (= 5.2.8.1) - builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.8.1) - activesupport (= 5.2.8.1) - globalid (>= 0.3.6) - activemodel (5.2.8.1) - activesupport (= 5.2.8.1) - activerecord (5.2.8.1) - activemodel (= 5.2.8.1) - activesupport (= 5.2.8.1) - arel (>= 9.0) - activestorage (5.2.8.1) - actionpack (= 5.2.8.1) - activerecord (= 5.2.8.1) - marcel (~> 1.0.0) - activesupport (5.2.8.1) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - addressable (2.7.0) - public_suffix (>= 2.0.2, < 5.0) - arel (9.0.0) - bcrypt (3.1.16) - bindex (0.8.1) - bootsnap (1.4.8) - msgpack (~> 1.0) - builder (3.2.4) - byebug (11.1.3) - capybara (3.33.0) - addressable - mini_mime (>= 0.1.3) - nokogiri (~> 1.8) - rack (>= 1.6.0) - rack-test (>= 0.6.3) - regexp_parser (~> 1.5) - xpath (~> 3.2) - concurrent-ruby (1.2.2) - crass (1.0.6) - damerau-levenshtein (1.3.3) - date (3.3.3) - devise (4.7.3) - bcrypt (~> 3.0) - orm_adapter (~> 0.1) - railties (>= 4.1.0) - responders - warden (~> 1.2.3) - diff-lcs (1.4.4) - email_spec (2.2.0) - htmlentities (~> 4.3.3) - launchy (~> 2.1) - mail (~> 2.7) - erubi (1.12.0) - execjs (2.7.0) - factory_bot (6.1.0) - activesupport (>= 5.0.0) - factory_bot_rails (6.1.0) - factory_bot (~> 6.1.0) - railties (>= 5.0.0) - faker (2.14.0) - i18n (>= 1.6, < 2) - ffi (1.13.1) - geocoder (1.6.4) - globalid (1.1.0) - activesupport (>= 5.0) - htmlentities (4.3.4) - i18n (1.13.0) - concurrent-ruby (~> 1.0) - jbuilder (2.10.1) - activesupport (>= 5.0.0) - jwt (2.2.2) - launchy (2.5.0) - addressable (~> 2.7) - listen (3.1.5) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - ruby_dep (~> 1.2) - loofah (2.21.3) - crass (~> 1.0.2) - nokogiri (>= 1.12.0) - mail (2.8.1) - mini_mime (>= 0.1.1) - net-imap - net-pop - net-smtp - marcel (1.0.2) - method_source (1.0.0) - mini_mime (1.1.2) - mini_portile2 (2.8.2) - minitest (5.18.0) - msgpack (1.3.3) - net-imap (0.3.4) - date - net-protocol - net-pop (0.1.2) - net-protocol - net-protocol (0.2.1) - timeout - net-smtp (0.3.3) - net-protocol - nio4r (2.5.9) - nokogiri (1.15.2) - mini_portile2 (~> 2.8.2) - racc (~> 1.4) - orm_adapter (0.5.0) - public_suffix (4.0.6) - puma (4.3.6) - nio4r (~> 2.0) - racc (1.6.2) - rack (2.2.7) - rack-test (2.1.0) - rack (>= 1.3) - rails (5.2.8.1) - actioncable (= 5.2.8.1) - actionmailer (= 5.2.8.1) - actionpack (= 5.2.8.1) - actionview (= 5.2.8.1) - activejob (= 5.2.8.1) - activemodel (= 5.2.8.1) - activerecord (= 5.2.8.1) - activestorage (= 5.2.8.1) - activesupport (= 5.2.8.1) - bundler (>= 1.3.0) - railties (= 5.2.8.1) - sprockets-rails (>= 2.0.0) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) - nokogiri (>= 1.6) - rails-html-sanitizer (1.6.0) - loofah (~> 2.21) - nokogiri (~> 1.14) - railties (5.2.8.1) - actionpack (= 5.2.8.1) - activesupport (= 5.2.8.1) - method_source - rake (>= 0.8.7) - thor (>= 0.19.0, < 2.0) - rake (13.0.6) - rb-fsevent (0.10.4) - rb-inotify (0.10.1) - ffi (~> 1.0) - regexp_parser (1.8.1) - responders (3.0.1) - actionpack (>= 5.0) - railties (>= 5.0) - rollbar (2.27.1) - rspec-core (3.9.3) - rspec-support (~> 3.9.3) - rspec-expectations (3.9.2) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-mocks (3.9.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-rails (4.0.1) - actionpack (>= 4.2) - activesupport (>= 4.2) - railties (>= 4.2) - rspec-core (~> 3.9) - rspec-expectations (~> 3.9) - rspec-mocks (~> 3.9) - rspec-support (~> 3.9) - rspec-support (3.9.3) - ruby_dep (1.5.0) - sass (3.7.4) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (5.1.0) - railties (>= 5.2.0) - sass (~> 3.1) - sprockets (>= 2.8, < 4.0) - sprockets-rails (>= 2.0, < 4.0) - tilt (>= 1.1, < 3) - spring (2.1.1) - spring-watcher-listen (2.0.1) - listen (>= 2.7, < 4.0) - spring (>= 1.2, < 3.0) - sprockets (3.7.2) - concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.4.2) - actionpack (>= 5.2) - activesupport (>= 5.2) - sprockets (>= 3.0.0) - sqlite3 (1.4.2) - thor (1.2.2) - thread_safe (0.3.6) - tilt (2.0.10) - timeout (0.3.2) - turbolinks (5.2.1) - turbolinks-source (~> 5.2) - turbolinks-source (5.2.0) - tzinfo (1.2.11) - thread_safe (~> 0.1) - uglifier (4.2.0) - execjs (>= 0.3.0, < 3) - warden (1.2.9) - rack (>= 2.0.9) - web-console (3.7.0) - actionview (>= 5.0) - activemodel (>= 5.0) - bindex (>= 0.4.0) - railties (>= 5.0) - websocket-driver (0.7.5) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.5) - xpath (3.2.0) - nokogiri (~> 1.8) - -PLATFORMS - ruby - -DEPENDENCIES - bootsnap (>= 1.1.0) - byebug - capybara - devise - devise-recognisable! - email_spec - factory_bot_rails - faker - jbuilder (~> 2.5) - listen (>= 3.0.5, < 3.2) - puma (~> 4.3) - rails (~> 5.2.5) - rollbar (~> 2.11, >= 2.11.5) - rspec-rails - sass-rails (~> 5.0) - spring - spring-watcher-listen (~> 2.0.0) - sqlite3 - turbolinks (~> 5) - tzinfo-data - uglifier (>= 1.3.0) - web-console (>= 3.3.0) - -RUBY VERSION - ruby 2.7.7p221 - -BUNDLED WITH - 2.1.4 diff --git a/spec/dummy-app/yarn.lock b/spec/dummy-app/yarn.lock new file mode 100644 index 0000000..fb57ccd --- /dev/null +++ b/spec/dummy-app/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index b20944b..80fc6f6 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -10,6 +10,7 @@ require "email_spec/rspec" require_relative 'support/factory_bot' +require_relative 'support/active_record' # Requires supporting ruby files with custom matchers and macros, etc, in # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are diff --git a/spec/support/active_record.rb b/spec/support/active_record.rb new file mode 100644 index 0000000..600f4ed --- /dev/null +++ b/spec/support/active_record.rb @@ -0,0 +1,13 @@ +require 'active_record' + +ActiveRecord::Migration.verbose = false +ActiveRecord::Base.logger = Logger.new(nil) + +if Rails.gem_version >= Gem::Version.new('6.0.0') + ActiveRecord::MigrationContext.new(File.expand_path('../dummy/db/migrate', __dir__), ActiveRecord::SchemaMigration).migrate +elsif Rails.gem_version >= Gem::Version.new('5.2.0') + ActiveRecord::MigrationContext.new(File.expand_path('../dummy/db/migrate', __dir__)).migrate +end + +DatabaseCleaner[:active_record].strategy = :transaction +ORMInvalidRecordException = ActiveRecord::RecordInvalid