diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index 1d67029..6288c0a 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -3,17 +3,15 @@ on: [pull_request] jobs: danger: runs-on: ubuntu-latest - env: - BUNDLE_GEMFILE: ${{ github.workspace }}/Gemfile.danger steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - uses: ruby/setup-ruby@v1 with: - ruby-version: 2.6 + ruby-version: 2.7 bundler-cache: true - run: | - # the personal token is public, this is ok, base64 encode to avoid tripping Github - TOKEN=$(echo -n NWY1ZmM5MzEyMzNlYWY4OTZiOGU3MmI3MWQ3Mzk0MzgxMWE4OGVmYwo= | base64 --decode) - DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose + # Personal access token for dangerpr-bot - public, but base64 encoded to avoid tripping up GitHub + TOKEN=$(echo -n Z2hwX0xNQ3VmanBFeTBvYkZVTWh6NVNqVFFBOEUxU25abzBqRUVuaAo= | base64 --decode) + DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6f7a65b..c144e9d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,76 +5,65 @@ on: [push, pull_request] jobs: build: name: >- - Mongoid ${{ matrix.entry.mongoid }} - Ruby ${{ matrix.entry.ruby }} - MongoDB ${{ matrix.entry.mongodb }} + Mongoid Test with: - Ruby ${{ matrix.entry.ruby }} - MongoDB ${{ matrix.entry.mongodb }} - Gemfile ${{ matrix.entry.gemfile }}) env: CI: true - TESTOPTS: -v + TESTOPTS: "-v" + BUNDLE_GEMFILE: gemfiles/${{ matrix.entry.gemfile }}.gemfile runs-on: ubuntu-latest continue-on-error: false strategy: matrix: entry: - - { ruby: "2.1", mongoid: "3", bundler: "1", mongodb: "3.6" } - - { ruby: "2.1", mongoid: "4", bundler: "1", mongodb: "3.6" } - - { ruby: "2.2", mongoid: "4", bundler: "2", mongodb: "3.6" } - - { ruby: "2.2", mongoid: "5", bundler: "2", mongodb: "3.6" } - - { ruby: "2.3", mongoid: "5", bundler: "2", mongodb: "3.6" } - - { ruby: "2.4", mongoid: "6.1", bundler: "2", mongodb: "3.6" } - - { ruby: "2.5", mongoid: "6.2", bundler: "2", mongodb: "3.6" } - - { ruby: "2.5", mongoid: "6.4", bundler: "2", mongodb: "3.6" } - - { ruby: "2.6", mongoid: "7.4", bundler: "2", mongodb: "3.6" } - - { ruby: "2.6", mongoid: "7.5", bundler: "2", mongodb: "3.6" } - - { ruby: "2.7", mongoid: "7.5", bundler: "2", mongodb: "3.6" } - - { ruby: "3.0", mongoid: "8.0", bundler: "2", mongodb: "3.6" } - - { ruby: "3.1", mongoid: "8.0", bundler: "2", mongodb: "3.6" } - - { ruby: "2.5", mongoid: "6.4", bundler: "2", mongodb: "4.0" } - - { ruby: "2.6", mongoid: "7.4", bundler: "2", mongodb: "4.0" } - - { ruby: "2.6", mongoid: "7.5", bundler: "2", mongodb: "4.0" } - - { ruby: "2.7", mongoid: "7.5", bundler: "2", mongodb: "4.0" } - - { ruby: "3.0", mongoid: "8.0", bundler: "2", mongodb: "4.0" } - - { ruby: "3.1", mongoid: "8.0", bundler: "2", mongodb: "4.0" } - - { ruby: "2.5", mongoid: "6.4", bundler: "2", mongodb: "4.2" } - - { ruby: "2.6", mongoid: "7.4", bundler: "2", mongodb: "4.2" } - - { ruby: "2.6", mongoid: "7.5", bundler: "2", mongodb: "4.2" } - - { ruby: "2.7", mongoid: "7.5", bundler: "2", mongodb: "4.2" } - - { ruby: "3.0", mongoid: "8.0", bundler: "2", mongodb: "4.2" } - - { ruby: "3.1", mongoid: "8.0", bundler: "2", mongodb: "4.2" } - - { ruby: "2.5", mongoid: "6.4", bundler: "2", mongodb: "4.4" } - - { ruby: "2.6", mongoid: "7.4", bundler: "2", mongodb: "4.4" } - - { ruby: "2.6", mongoid: "7.5", bundler: "2", mongodb: "4.4" } - - { ruby: "2.7", mongoid: "7.5", bundler: "2", mongodb: "4.4" } - - { ruby: "3.0", mongoid: "8.0", bundler: "2", mongodb: "4.4" } - - { ruby: "3.1", mongoid: "8.0", bundler: "2", mongodb: "4.4" } - - { ruby: "2.5", mongoid: "6.4", bundler: "2", mongodb: "5.0" } - - { ruby: "2.6", mongoid: "7.4", bundler: "2", mongodb: "5.0" } - - { ruby: "2.6", mongoid: "7.5", bundler: "2", mongodb: "5.0" } - - { ruby: "2.7", mongoid: "7.5", bundler: "2", mongodb: "5.0" } - - { ruby: "3.0", mongoid: "8.0", bundler: "2", mongodb: "5.0" } - - { ruby: "3.1", mongoid: "8.0", bundler: "2", mongodb: "5.0" } + - { ruby: "2.6", gemfile: 'mongoid_3', mongodb: "3.6" } + - { ruby: "2.6", gemfile: 'mongoid_4', mongodb: "3.6" } + - { ruby: "2.6", gemfile: 'mongoid_4', mongodb: "3.6" } + - { ruby: "2.6", gemfile: 'mongoid_5', mongodb: "3.6" } + - { ruby: "2.6", gemfile: 'mongoid_5', mongodb: "3.6" } + - { ruby: "2.6", gemfile: 'mongoid_6', mongodb: "3.6" } + - { ruby: "2.6", gemfile: 'mongoid_6', mongodb: "3.6" } + - { ruby: "2.6", gemfile: 'mongoid_6', mongodb: "3.6" } + - { ruby: "2.6", gemfile: 'mongoid_7', mongodb: "3.6" } + - { ruby: "2.6", gemfile: 'mongoid_7', mongodb: "3.6" } + - { ruby: "2.7", gemfile: 'mongoid_7', mongodb: "3.6" } + - { ruby: "3.0", gemfile: 'mongoid_8', mongodb: "3.6" } + - { ruby: "3.1", gemfile: 'mongoid_8', mongodb: "3.6" } + - { ruby: "2.6", gemfile: 'mongoid_6', mongodb: "4.0" } + - { ruby: "2.6", gemfile: 'mongoid_7', mongodb: "4.0" } + - { ruby: "2.6", gemfile: 'mongoid_7', mongodb: "4.0" } + - { ruby: "2.7", gemfile: 'mongoid_7', mongodb: "4.0" } + - { ruby: "3.0", gemfile: 'mongoid_8', mongodb: "4.0" } + - { ruby: "3.1", gemfile: 'mongoid_8', mongodb: "4.0" } + - { ruby: "2.6", gemfile: 'mongoid_6', mongodb: "4.2" } + - { ruby: "2.6", gemfile: 'mongoid_7', mongodb: "4.2" } + - { ruby: "2.6", gemfile: 'mongoid_7', mongodb: "4.2" } + - { ruby: "2.7", gemfile: 'mongoid_7', mongodb: "4.2" } + - { ruby: "3.0", gemfile: 'mongoid_8', mongodb: "4.2" } + - { ruby: "3.1", gemfile: 'mongoid_8', mongodb: "4.2" } + - { ruby: "2.6", gemfile: 'mongoid_6', mongodb: "4.4" } + - { ruby: "2.6", gemfile: 'mongoid_7', mongodb: "4.4" } + - { ruby: "2.6", gemfile: 'mongoid_7', mongodb: "4.4" } + - { ruby: "2.7", gemfile: 'mongoid_7', mongodb: "4.4" } + - { ruby: "3.0", gemfile: 'mongoid_8', mongodb: "4.4" } + - { ruby: "3.1", gemfile: 'mongoid_8', mongodb: "4.4" } + - { ruby: "2.6", gemfile: 'mongoid_6', mongodb: "5.0" } + - { ruby: "2.6", gemfile: 'mongoid_7', mongodb: "5.0" } + - { ruby: "2.6", gemfile: 'mongoid_7', mongodb: "5.0" } + - { ruby: "2.7", gemfile: 'mongoid_7', mongodb: "5.0" } + - { ruby: "3.0", gemfile: 'mongoid_8', mongodb: "5.0" } + - { ruby: "3.1", gemfile: 'mongoid_8', mongodb: "5.0" } + - { ruby: "3.1", gemfile: 'mongoid_9', mongodb: "5.0" } steps: - - name: repo checkout - uses: actions/checkout@v2 - - - name: start mongodb - uses: supercharge/mongodb-github-action@1.6.0 + - name: Set up MongoDB ${{ matrix.entry.mongodb }} + uses: supercharge/mongodb-github-action@1.8.0 with: mongodb-version: ${{ matrix.entry.mongodb }} - mongodb-replica-set: rs0 - - - name: load ruby + - uses: actions/checkout@v3 + - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.entry.ruby }} - bundler: ${{ matrix.entry.bundler }} - - - name: bundle install - run: bundle install --jobs 4 --retry 3 - env: - MONGOID_VERSION: ${{ matrix.entry.mongoid }} - - - name: test - timeout-minutes: 10 - run: bundle exec rspec spec - continue-on-error: false - env: - MONGOID_VERSION: ${{ matrix.entry.mongoid }} + bundler: '2' + bundler-cache: true + - name: Run tests + run: bundle exec rake \ No newline at end of file diff --git a/.gitignore b/.gitignore index a3e145b..d7ef0ed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ Gemfile.lock pkg +gemfiles/*.gemfile.lock \ No newline at end of file diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 592b2ca..82d0159 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -11,6 +11,15 @@ Metrics/LineLength: Max: 118 +Gemspec/RequiredRubyVersion: + Exclude: + - 'mongoid-compatibility.gemspec' + +Metrics/BlockLength: + Exclude: + - 'spec/**/*' + - 'test/**/*' + # Offense count: 4 Style/Documentation: Exclude: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 946b5bc..0000000 --- a/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -services: - - mongodb - -matrix: - include: - - rvm: 2.3.1 - script: - - bundle exec danger - - rvm: 2.4.0 - env: - - MONGOID_VERSION=7 - - rvm: 2.4.0 - env: - - MONGOID_VERSION=6 - - rvm: 2.3.1 - env: - - MONGOID_VERSION=6 - - rvm: 2.3.1 - env: - - MONGOID_VERSION=5 - - rvm: 2.3.1 - env: - - MONGOID_VERSION=4 - - rvm: 2.3.1 - env: - - MONGOID_VERSION=3 - - rvm: 2.3.1 - env: - - MONGOID_VERSION=2 - - rvm: 2.3.1 - env: - - MONGOID_VERSION=HEAD - - rvm: 2.3.0 diff --git a/Appraisals b/Appraisals new file mode 100644 index 0000000..b7b2546 --- /dev/null +++ b/Appraisals @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +appraise 'mongoid-9' do + gem 'mongoid', '~> 9.0.0' +end + +appraise 'mongoid-8' do + gem 'mongoid', '~> 8.0.0' +end + +appraise 'mongoid-7' do + gem 'mongoid', '~> 7.0.0' +end + +appraise 'mongoid-6' do + gem 'mongoid', '~> 6.0.2' +end + +appraise 'mongoid-5' do + gem 'mongoid', '~> 5.0.0' +end + +appraise 'mongoid-4' do + gem 'mongoid', '~> 4.0.0' +end + +appraise 'mongoid-3' do + gem 'mongoid', '~> 3.0.0' +end + +appraise 'mongoid-2' do + gem 'mongoid', '~> 2.0.0' + gem 'bson_ext', platforms: :ruby +end diff --git a/CHANGELOG.md b/CHANGELOG.md index f53b966..84cd94b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ -### 0.6.1 (Next) +### 1.0.0 (Next) +* [#16](https://github.com/mongoid/mongoid-compatibility/pull/16): Add support for Mongoid 9 - [@saisrinivasan](https://github.com/SairamSrinivasan). * Your contribution here. ### 0.6.0 (2022/08/18) diff --git a/Dangerfile b/Dangerfile index 6248c90..de2a4a0 100644 --- a/Dangerfile +++ b/Dangerfile @@ -1 +1,3 @@ +# frozen_string_literal: true + danger.import_dangerfile(gem: 'mongoid-danger') diff --git a/Gemfile b/Gemfile index 9508cbe..f7200f1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,34 +1,5 @@ +# frozen_string_literal: true + source 'http://rubygems.org' gemspec - -case version = ENV['MONGOID_VERSION'] || '8.0.2' -when 'HEAD' - gem 'mongoid', github: 'mongodb/mongoid' -when /^8/ - gem 'mongoid', '~> 8.0' -when /^7/ - gem 'mongoid', '~> 7.0' -when /^6/ - gem 'mongoid', '~> 6.0' -when /^5/ - gem 'mongoid', '~> 5.0' -when /^4/ - gem 'mongoid', '~> 4.0' -when /^3/ - gem 'mongoid', '~> 3.1' -when /^2/ - gem 'mongoid', '~> 2.0' - gem 'bson_ext', platforms: :ruby -else - gem 'mongoid', version -end - -group :test do - gem 'rspec' -end - -group :development do - gem 'rake', '< 12' - gem 'rubocop', '0.33.0' -end diff --git a/README.md b/README.md index ff87b9b..978a6d1 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,9 @@ Mongoid::Compatibility [![Build Status](https://github.com/mongoid/mongoid-compatibility/actions/workflows/test.yml/badge.svg)](https://github.com/mongoid/mongoid-compatibility/actions) [![Code Climate](https://codeclimate.com/github/mongoid/mongoid-compatibility.svg)](https://codeclimate.com/github/mongoid/mongoid-compatibility) -Compatibility helpers for Mongoid versions 2, 3, 4, 5, 6, 7, and 8. +[Tested](https://github.com/mongoid/mongoid-compatibility/actions) against: +- MRI: `2.6.x`, `2.7.x`, `3.0.x`, `3.1.x` +- Compatibility helpers for Mongoid versions 2, 3, 4, 5, 6, 7, 8, and 9. ### Install diff --git a/Rakefile b/Rakefile index e0bc807..dd0ed12 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rubygems' require 'bundler/gem_tasks' @@ -13,4 +15,4 @@ end require 'rubocop/rake_task' RuboCop::RakeTask.new(:rubocop) -task default: [:rubocop, :spec] +task default: %i[rubocop spec] diff --git a/gemfiles/mongoid_2.gemfile b/gemfiles/mongoid_2.gemfile new file mode 100644 index 0000000..95fac4d --- /dev/null +++ b/gemfiles/mongoid_2.gemfile @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +# This file was generated by Appraisal + +source 'http://rubygems.org' + +gem 'bson_ext', platforms: :ruby +gem 'mongoid', '~> 2.0.0' + +gemspec path: '../' diff --git a/gemfiles/mongoid_3.gemfile b/gemfiles/mongoid_3.gemfile new file mode 100644 index 0000000..e0063e8 --- /dev/null +++ b/gemfiles/mongoid_3.gemfile @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +# This file was generated by Appraisal + +source 'http://rubygems.org' + +gem 'mongoid', '~> 3.0.0' + +gemspec path: '../' diff --git a/gemfiles/mongoid_4.gemfile b/gemfiles/mongoid_4.gemfile new file mode 100644 index 0000000..4d1118d --- /dev/null +++ b/gemfiles/mongoid_4.gemfile @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +# This file was generated by Appraisal + +source 'http://rubygems.org' + +gem 'mongoid', '~> 4.0.0' + +gemspec path: '../' diff --git a/gemfiles/mongoid_5.gemfile b/gemfiles/mongoid_5.gemfile new file mode 100644 index 0000000..2371eb0 --- /dev/null +++ b/gemfiles/mongoid_5.gemfile @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +# This file was generated by Appraisal + +source 'http://rubygems.org' + +gem 'mongoid', '~> 5.0.0' + +gemspec path: '../' diff --git a/gemfiles/mongoid_6.gemfile b/gemfiles/mongoid_6.gemfile new file mode 100644 index 0000000..5d2e757 --- /dev/null +++ b/gemfiles/mongoid_6.gemfile @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +# This file was generated by Appraisal + +source 'http://rubygems.org' + +gem 'mongoid', '~> 6.0.2' + +gemspec path: '../' diff --git a/gemfiles/mongoid_7.gemfile b/gemfiles/mongoid_7.gemfile new file mode 100644 index 0000000..268f273 --- /dev/null +++ b/gemfiles/mongoid_7.gemfile @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +# This file was generated by Appraisal + +source 'http://rubygems.org' + +gem 'mongoid', '~> 7.0.0' + +gemspec path: '../' diff --git a/gemfiles/mongoid_8.gemfile b/gemfiles/mongoid_8.gemfile new file mode 100644 index 0000000..98bc4d7 --- /dev/null +++ b/gemfiles/mongoid_8.gemfile @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +# This file was generated by Appraisal + +source 'http://rubygems.org' + +gem 'mongoid', '~> 8.0.0' + +gemspec path: '../' diff --git a/gemfiles/mongoid_9.gemfile b/gemfiles/mongoid_9.gemfile new file mode 100644 index 0000000..3e271b2 --- /dev/null +++ b/gemfiles/mongoid_9.gemfile @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +# This file was generated by Appraisal + +source 'http://rubygems.org' + +gem 'mongoid', '~> 9.0.0' + +gemspec path: '../' diff --git a/gemfiles/mongoid_head.gemfile b/gemfiles/mongoid_head.gemfile new file mode 100644 index 0000000..1879836 --- /dev/null +++ b/gemfiles/mongoid_head.gemfile @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +# This file was generated by Appraisal + +source 'http://rubygems.org' + +gem 'mongoid', github: 'mongodb/mongoid' + +group :development do + gem 'appraisal', '~> 2.0' + gem 'rake', '< 12' + gem 'rubocop', '0.33.0' +end + +group :test do + gem 'rspec' +end + +gemspec path: '../' diff --git a/lib/mongoid-compatibility.rb b/lib/mongoid-compatibility.rb index 02ccf09..330b1be 100644 --- a/lib/mongoid-compatibility.rb +++ b/lib/mongoid-compatibility.rb @@ -1 +1,3 @@ +# frozen_string_literal: true + require 'mongoid/compatibility' diff --git a/lib/mongoid/compatibility.rb b/lib/mongoid/compatibility.rb index dca7f6c..2fd5fe7 100644 --- a/lib/mongoid/compatibility.rb +++ b/lib/mongoid/compatibility.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'mongoid' require 'mongoid/compatibility/self' require 'mongoid/compatibility/version' diff --git a/lib/mongoid/compatibility/object_id.rb b/lib/mongoid/compatibility/object_id.rb index 2286f43..83c883a 100644 --- a/lib/mongoid/compatibility/object_id.rb +++ b/lib/mongoid/compatibility/object_id.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Mongoid module Compatibility module ObjectId diff --git a/lib/mongoid/compatibility/self.rb b/lib/mongoid/compatibility/self.rb index 1828535..3878c04 100644 --- a/lib/mongoid/compatibility/self.rb +++ b/lib/mongoid/compatibility/self.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + module Mongoid module Compatibility - VERSION = '0.6.1'.freeze + VERSION = '1.0.0' end end diff --git a/lib/mongoid/compatibility/version.rb b/lib/mongoid/compatibility/version.rb index eeebf9a..903f90f 100644 --- a/lib/mongoid/compatibility/version.rb +++ b/lib/mongoid/compatibility/version.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + module Mongoid module Compatibility module Version module ClassMethods - (2..8).each do |v| + (2..9).each do |v| const_set "V#{v}", Mongoid::VERSION =~ Regexp.new("^#{v}\.") define_method "mongoid#{v}?" do diff --git a/lib/mongoid_compatibility.rb b/lib/mongoid_compatibility.rb index 0ff1095..988aced 100644 --- a/lib/mongoid_compatibility.rb +++ b/lib/mongoid_compatibility.rb @@ -1 +1,3 @@ +# frozen_string_literal: true + require 'mongoid-compatibility' diff --git a/mongoid-compatibility.gemspec b/mongoid-compatibility.gemspec index 926e480..d1a4e0e 100644 --- a/mongoid-compatibility.gemspec +++ b/mongoid-compatibility.gemspec @@ -1,4 +1,6 @@ -$LOAD_PATH.push File.expand_path('../lib', __FILE__) +# frozen_string_literal: true + +$LOAD_PATH.push File.expand_path('lib', __dir__) require 'mongoid/compatibility/self' Gem::Specification.new do |s| @@ -13,6 +15,12 @@ Gem::Specification.new do |s| s.homepage = 'http://github.com/mongoid/mongoid-compatibility' s.licenses = ['MIT'] s.summary = 'Compatibility helpers for Mongoid.' - s.add_dependency 'mongoid', '>= 2.0' s.add_dependency 'activesupport' + s.add_dependency 'mongoid', '>= 2.0' + + s.add_development_dependency 'appraisal', '~> 2.0' + s.add_development_dependency 'mongoid-danger', '~> 0.2' + s.add_development_dependency 'rake', '< 12' + s.add_development_dependency 'rspec' + s.add_development_dependency 'rubocop', '~> 1.36.0' end diff --git a/spec/config/mongoid9.yml b/spec/config/mongoid9.yml new file mode 100644 index 0000000..c7385b7 --- /dev/null +++ b/spec/config/mongoid9.yml @@ -0,0 +1,8 @@ +test: + clients: + default: + database: mongoid-compatibility + hosts: + - localhost:27017 + options: + raise_not_found_error: false diff --git a/spec/mongoid/compatibility/object_id_spec.rb b/spec/mongoid/compatibility/object_id_spec.rb index 8f3bee3..1fdfd88 100644 --- a/spec/mongoid/compatibility/object_id_spec.rb +++ b/spec/mongoid/compatibility/object_id_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Mongoid::Compatibility::ObjectId do diff --git a/spec/mongoid/compatibility/self_spec.rb b/spec/mongoid/compatibility/self_spec.rb index e0f9e0b..9f2d82d 100644 --- a/spec/mongoid/compatibility/self_spec.rb +++ b/spec/mongoid/compatibility/self_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Mongoid::Compatibility do diff --git a/spec/mongoid/compatibility/version_spec.rb b/spec/mongoid/compatibility/version_spec.rb index a9d3737..7307e34 100644 --- a/spec/mongoid/compatibility/version_spec.rb +++ b/spec/mongoid/compatibility/version_spec.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + require 'spec_helper' describe Mongoid::Compatibility::Version do context 'mongoid? methods' do it 'only true for one version' do - expect((2..8).one? do |v| + expect((2..9).one? do |v| Mongoid::Compatibility::Version.send("mongoid#{v}?") end).to be true end @@ -31,10 +33,10 @@ expect(Mongoid::Compatibility::Version.send("mongoid#{version}_or_older?")).to be true end end - (2..8).each do |v| + (2..9).each do |v| context "mongoid #{v}" do before do - stub_const('::Mongoid::VERSION', "#{v}") + stub_const('::Mongoid::VERSION', v.to_s) stub_const("::Mongoid::Compatibility::Version::ClassMethods::V#{v}", 1) end it "responds to mongoid#{v}?" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b2fdf4c..94790a9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,7 @@ +# frozen_string_literal: true + +ENV['MONGOID_ENV'] = 'test' + $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'rubygems' diff --git a/spec/support/mongoid.rb b/spec/support/mongoid.rb index e31a91c..76da823 100644 --- a/spec/support/mongoid.rb +++ b/spec/support/mongoid.rb @@ -1,4 +1,4 @@ -ENV['MONGOID_ENV'] = 'test' +# frozen_string_literal: true if Mongoid::Compatibility::Version.mongoid2? Mongoid.load! 'spec/config/mongoid2.yml' @@ -14,8 +14,10 @@ Mongoid.load! 'spec/config/mongoid7.yml' elsif Mongoid::Compatibility::Version.mongoid8? Mongoid.load! 'spec/config/mongoid8.yml' +elsif Mongoid::Compatibility::Version.mongoid9? + Mongoid.load! 'spec/config/mongoid9.yml' else - fail "unsupported Mongoid version #{Mongoid::VERSION}" + raise "unsupported Mongoid version #{Mongoid::VERSION}" end RSpec.configure do |config|