with_model 2.1.5 → 2.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a685dd2fcd809ce446e7dfde25b4fea90014e6bf5456d99e939f79b2ff3b18af
4
- data.tar.gz: 3966fbcbeae1bd24fbeacf1f4c53b67abd78b771e03de3f6263a989ad8e180ce
3
+ metadata.gz: 83aa1a692c521015759725b2641f53304ab13f6c3aac17550dc7b802c8e015ea
4
+ data.tar.gz: e8c44ffe440d68a3f8311f2250a2184e88fffbe1d9713f0b870a5c15fcf8ec2e
5
5
  SHA512:
6
- metadata.gz: 659fff704f44481540e91d6ebe00322dd07fec0beda3142bc2581ed02bc962b7384dacf871a43c5231cc93757a428ef857f2ea093e8b82fb0ee0b9603932793f
7
- data.tar.gz: 588cb797971b7dc861aa207a09cbddebf69c356878993d0edf98458afb83affb0cc2d5d26856a079e8bef4ae5d420698e9f65abcb636ee8990ab6178479467d2
6
+ metadata.gz: 3acf78cc398a2c3c7612a1ee534d3d11ed93f701b8cbfaa218d8b64fb5c3dc0a3a5cf23080f3853e97cf1ba72a9cc202673f058a7c784213287bf9b81e0a1e85
7
+ data.tar.gz: 0b8ccf8fa27e19880fbfdd166d3eb0974cecaecc94955c2d32204306eb3ca48f050f2b578a9042d81a34e0bfc7d6ab14e5c42b16d802e4b16cfc7efeb38bfecc
data/.bundle/config ADDED
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_BIN: bin
@@ -0,0 +1,8 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "10:00"
8
+ open-pull-requests-limit: 10
@@ -0,0 +1,44 @@
1
+ name: build
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ - github-actions
8
+ pull_request:
9
+ branches:
10
+ - master
11
+
12
+ jobs:
13
+ test:
14
+ runs-on: ubuntu-latest
15
+ env:
16
+ CI: true
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ ruby-version: ['2.7', '3.0', '3.1', '3.2']
21
+ active-record-version-env:
22
+ - ACTIVE_RECORD_VERSION="~> 6.0.0"
23
+ - ACTIVE_RECORD_VERSION="~> 6.1.0"
24
+ - ACTIVE_RECORD_VERSION="~> 7.0.0"
25
+ allow-failure: [false]
26
+ include:
27
+ - ruby-version: '3.2'
28
+ active-record-version-env: ACTIVE_RECORD_BRANCH="7-0-stable"
29
+ allow-failure: true
30
+ - ruby-version: '3.2'
31
+ active-record-version-env: ACTIVE_RECORD_BRANCH="6-1-stable"
32
+ allow-failure: true
33
+ continue-on-error: ${{ matrix.allow-failure }}
34
+ steps:
35
+ - uses: actions/checkout@v3
36
+ - name: Set up Ruby
37
+ uses: ruby/setup-ruby@v1
38
+ with:
39
+ ruby-version: ${{ matrix.ruby-version }}
40
+ bundler-cache: true
41
+ - name: Update bundle
42
+ run: ${{ matrix.active-record-version-env }} bundle update
43
+ - name: Run tests
44
+ run: ${{ matrix.active-record-version-env }} bin/rake
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  .yardoc
2
2
  Gemfile.lock
3
3
  coverage
4
+ bin/
4
5
  doc/
5
6
  pkg
data/.rubocop.yml CHANGED
@@ -3,9 +3,14 @@ inherit_from: .rubocop_todo.yml
3
3
  require:
4
4
  - rubocop-rake
5
5
  - rubocop-rspec
6
+ - rubocop-minitest
6
7
 
7
8
  AllCops:
8
9
  NewCops: enable
10
+ TargetRubyVersion: 2.7
11
+ Exclude:
12
+ - 'bin/**/*'
13
+ - 'vendor/bundle/**/*'
9
14
 
10
15
  Metrics/BlockLength:
11
16
  Exclude:
@@ -18,5 +23,11 @@ Bundler/OrderedGems:
18
23
  Bundler/DuplicatedGem:
19
24
  Enabled: false
20
25
 
26
+ RSpec/Be:
27
+ Enabled: false
28
+
29
+ RSpec/BeforeAfterAll:
30
+ Enabled: false
31
+
21
32
  Style/Documentation:
22
33
  Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -6,21 +6,6 @@
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 4
10
- RSpec/Be:
11
- Exclude:
12
- - 'spec/readme_spec.rb'
13
- - 'spec/with_model_spec.rb'
14
-
15
- # Offense count: 3
16
- RSpec/BeforeAfterAll:
17
- Exclude:
18
- - 'spec/spec_helper.rb'
19
- - 'spec/rails_helper.rb'
20
- - 'spec/support/**/*.rb'
21
- - 'spec/readme_spec.rb'
22
- - 'spec/with_model_spec.rb'
23
-
24
9
  # Offense count: 6
25
10
  # Configuration parameters: Prefixes.
26
11
  # Prefixes: when, with, without
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ### 2.1.7
2
+ - Require Ruby 2.7 or later
3
+ - Add Ruby 3.2 support
4
+ - Require Active Record 6.0 or later
5
+ - Improve minitest support (Mark Edmondson)
6
+ - Limit scope when clearing descendants tracker (idea from Jean-Baptiste Jacquinot)
7
+
8
+ ### 2.1.6
9
+ - Require Ruby 2.6 or later
10
+ - Add Ruby 3.0 and 3.1 support
11
+ - Add Active Record 6.1 and 7.0 support
12
+ - Add minitest support (Miks Miķelsons)
13
+
1
14
  ### 2.1.5
2
15
 
3
16
  - Add support for Active Record 6.1
data/Gemfile CHANGED
@@ -4,8 +4,8 @@ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
- ar_branch = ENV['ACTIVE_RECORD_BRANCH']
8
- ar_version = ENV['ACTIVE_RECORD_VERSION']
7
+ ar_branch = ENV.fetch('ACTIVE_RECORD_BRANCH', nil)
8
+ ar_version = ENV.fetch('ACTIVE_RECORD_VERSION', nil)
9
9
  is_jruby = RUBY_PLATFORM == 'java'
10
10
 
11
11
  if ar_branch
@@ -21,4 +21,13 @@ elsif ar_version
21
21
  end
22
22
  end
23
23
 
24
- gem 'sqlite3', '~> 1.4.1' unless is_jruby
24
+ gem 'bundler'
25
+ gem 'minitest'
26
+ gem 'rake'
27
+ gem 'rspec'
28
+ gem 'rubocop'
29
+ gem 'rubocop-minitest'
30
+ gem 'rubocop-rake'
31
+ gem 'rubocop-rspec'
32
+ gem 'simplecov'
33
+ gem 'sqlite3', '~> 1.6.0' unless is_jruby
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2019 Casebook, PBC <http://www.casebook.net>
1
+ Copyright (c) 2010–2022 Casebook, PBC <http://www.casebook.net>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # [with_model](https://github.com/Casecommons/with_model)
2
2
 
3
3
  [![Gem Version](https://img.shields.io/gem/v/with_model.svg?style=flat)](https://rubygems.org/gems/with_model)
4
- [![Build Status](https://secure.travis-ci.org/Casecommons/with_model.svg?branch=master)](https://travis-ci.org/Casecommons/with_model)
4
+ [![Build Status](https://github.com/Casecommons/with_model/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/Casecommons/with_model/actions/workflows/ci.yml)
5
5
  [![API Documentation](https://img.shields.io/badge/yard-api%20docs-lightgrey.svg)](https://www.rubydoc.info/gems/with_model)
6
6
 
7
7
  `with_model` dynamically builds an Active Record model (with table) before each test in a group and destroys it afterwards.
@@ -12,7 +12,7 @@
12
12
 
13
13
  ## Installation
14
14
 
15
- Install as usual: `gem install with_model` or add `gem 'with_model'` to your Gemfile. See `.travis.yml` for supported (tested) Ruby versions.
15
+ Install as usual: `gem install with_model` or add `gem 'with_model'` to your Gemfile. See [`.github/workflows/ci.yml`](./.github/workflows/ci.yml) for supported (tested) Ruby versions.
16
16
 
17
17
  ### RSpec
18
18
 
@@ -28,11 +28,13 @@ end
28
28
 
29
29
  ### minitest/spec
30
30
 
31
- Extend `WithModel` into minitest/spec:
31
+ Extend `WithModel` into minitest/spec and set the test runner explicitly:
32
32
 
33
33
  ```ruby
34
34
  require 'with_model'
35
35
 
36
+ WithModel.runner = :minitest
37
+
36
38
  class Minitest::Spec
37
39
  extend WithModel
38
40
  end
@@ -181,5 +183,5 @@ In general, `with_model` is not guaranteed to be thread-safe, but is, in certain
181
183
 
182
184
  ## License
183
185
 
184
- Copyright © 2010–2020 [Casebook PBC](https://www.casebook.net).
186
+ Copyright © 2010–2022 [Casebook PBC](https://www.casebook.net).
185
187
  Licensed under the MIT license, see [LICENSE](/LICENSE) file.
data/Rakefile CHANGED
@@ -2,19 +2,22 @@
2
2
 
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rspec/core/rake_task'
5
+ require 'rake/testtask'
5
6
  require 'rubocop/rake_task'
6
7
 
7
8
  desc 'Run specs'
8
- RSpec::Core::RakeTask.new
9
+ RSpec::Core::RakeTask.new(:spec) do |t|
10
+ t.pattern = Dir.glob('spec/**/*_spec.rb')
11
+ end
12
+
13
+ desc 'Run tests'
14
+ Rake::TestTask.new(:test) do |t|
15
+ t.libs << 'test'
16
+ t.libs << 'lib'
17
+ t.pattern = 'test/**/*_test.rb'
18
+ end
9
19
 
10
20
  desc 'Run lint'
11
21
  RuboCop::RakeTask.new
12
22
 
13
- namespace 'doc' do
14
- desc 'Generate README and preview in browser'
15
- task 'readme' do
16
- sh 'markdown README.md > README.html && open README.html'
17
- end
18
- end
19
-
20
- task default: %i[spec rubocop]
23
+ task default: %i[spec test rubocop]
@@ -55,7 +55,11 @@ module WithModel
55
55
 
56
56
  def cleanup_descendants_tracking
57
57
  if defined?(ActiveSupport::DescendantsTracker)
58
- ActiveSupport::DescendantsTracker.class_variable_get(:@@direct_descendants).delete(ActiveRecord::Base)
58
+ if ActiveSupport::VERSION::MAJOR >= 7
59
+ ActiveSupport::DescendantsTracker.clear([@model])
60
+ else
61
+ ActiveSupport::DescendantsTracker.class_variable_get(:@@direct_descendants).delete(ActiveRecord::Base)
62
+ end
59
63
  elsif @model.superclass.respond_to?(:direct_descendants)
60
64
  @model.superclass.direct_descendants.delete(@model)
61
65
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WithModel
4
- VERSION = '2.1.5'
4
+ VERSION = '2.1.7'
5
5
  end
data/lib/with_model.rb CHANGED
@@ -6,37 +6,77 @@ require 'with_model/table'
6
6
  require 'with_model/version'
7
7
 
8
8
  module WithModel
9
+ class MiniTestLifeCycle < Module
10
+ def initialize(object)
11
+ define_method :before_setup do
12
+ object.create
13
+ super() if defined?(super)
14
+ end
15
+
16
+ define_method :after_teardown do
17
+ object.destroy
18
+ super() if defined?(super)
19
+ end
20
+ end
21
+
22
+ def self.call(object)
23
+ new(object)
24
+ end
25
+ end
26
+
27
+ class << self
28
+ attr_writer :runner
29
+ end
30
+
31
+ def self.runner
32
+ @runner ||= :rspec
33
+ end
34
+
9
35
  # @param [Symbol] name The constant name to assign the model class to.
10
- # @param scope Passed to `before`/`after` in the test context.
36
+ # @param scope Passed to `before`/`after` in the test context. RSpec only.
11
37
  # @param options Passed to {WithModel::Model#initialize}.
12
38
  # @param block Yielded an instance of {WithModel::Model::DSL}.
13
39
  def with_model(name, scope: nil, **options, &block)
40
+ runner = options.delete(:runner)
14
41
  model = Model.new name, **options
15
42
  dsl = Model::DSL.new model
16
43
  dsl.instance_exec(&block) if block
17
44
 
18
- before(*scope) do
19
- model.create
20
- end
21
-
22
- after(*scope) do
23
- model.destroy
24
- end
45
+ setup_object(model, scope: scope, runner: runner)
25
46
  end
26
47
 
27
48
  # @param [Symbol] name The table name to create.
28
- # @param scope Passed to `before`/`after` in the test context.
49
+ # @param scope Passed to `before`/`after` in the test context. Rspec only.
29
50
  # @param options Passed to {WithModel::Table#initialize}.
30
51
  # @param block Passed to {WithModel::Table#initialize} (like {WithModel::Model::DSL#table}).
31
52
  def with_table(name, scope: nil, **options, &block)
53
+ runner = options.delete(:runner)
32
54
  table = Table.new name, options, &block
33
55
 
34
- before(*scope) do
35
- table.create
36
- end
56
+ setup_object(table, scope: scope, runner: runner)
57
+ end
58
+
59
+ private
60
+
61
+ # @param [Object] object The new model object instance to create
62
+ # @param scope Passed to `before`/`after` in the test context. Rspec only.
63
+ # @param [Symbol] runner The test running, either :rspec or :minitest, defaults to :rspec
64
+ def setup_object(object, scope: nil, runner: nil) # rubocop:disable Metrics/MethodLength
65
+ case runner || WithModel.runner
66
+ when :rspec
67
+ before(*scope) do
68
+ object.create
69
+ end
37
70
 
38
- after(*scope) do
39
- table.destroy
71
+ after(*scope) do
72
+ object.destroy
73
+ end
74
+ when :minitest
75
+ class_eval do
76
+ include MiniTestLifeCycle.call(object)
77
+ end
78
+ else
79
+ raise ArgumentError, 'Unsupported test runner set, expected :rspec or :minitest'
40
80
  end
41
81
  end
42
82
  end
@@ -7,6 +7,7 @@ describe 'ActiveRecord behaviors' do
7
7
  context 'that has a named scope' do
8
8
  before do
9
9
  @regular_model = Class.new ActiveRecord::Base do
10
+ self.table_name = 'regular_models'
10
11
  scope :title_is_foo, -> { where(title: 'foo') }
11
12
  end
12
13
 
@@ -104,7 +105,7 @@ describe 'ActiveRecord behaviors' do
104
105
 
105
106
  context 'in earlier examples' do
106
107
  it 'works as normal' do
107
- Province.create!(country: Country.create!)
108
+ expect { Province.create!(country: Country.create!) }.not_to raise_error
108
109
  end
109
110
  end
110
111
 
@@ -7,13 +7,12 @@ module WithModel
7
7
  it 'allows calling unstub_const multiple times' do
8
8
  stubber = described_class.new('Foo')
9
9
  stubber.stub_const(1)
10
- stubber.unstub_const
11
- stubber.unstub_const
10
+ expect { 2.times { stubber.unstub_const } }.not_to raise_error
12
11
  end
13
12
 
14
13
  it 'allows calling unstub_const without stub_const' do
15
14
  stubber = described_class.new('Foo')
16
- stubber.unstub_const
15
+ expect { stubber.unstub_const }.not_to raise_error
17
16
  end
18
17
  end
19
18
  end
data/spec/readme_spec.rb CHANGED
@@ -48,7 +48,7 @@ describe 'A blog post' do
48
48
  end
49
49
 
50
50
  it 'has the module' do
51
- expect(BlogPost.include?(MyModule)).to eq true
51
+ expect(BlogPost.include?(MyModule)).to be true
52
52
  end
53
53
 
54
54
  it 'has the class method' do
@@ -64,7 +64,7 @@ describe 'A blog post' do
64
64
  expect(record).not_to be_valid
65
65
  record.title = 'foo'
66
66
  expect(record).to be_valid
67
- expect(record.save).to eq true
67
+ expect(record.save).to be true
68
68
  expect(record.reload).to eq record
69
69
  record.comments.create!(text: 'Lorem ipsum')
70
70
  expect(record.comments.count).to eq 1
@@ -78,7 +78,7 @@ describe 'A blog post' do
78
78
  with_model :Ford, superclass: Car
79
79
 
80
80
  it 'has a specified superclass' do
81
- expect(Ford < Car).to eq true
81
+ expect(Ford < Car).to be true
82
82
  end
83
83
  end
84
84
 
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Workaround for JRuby CI failure https://github.com/jruby/jruby/issues/6547#issuecomment-774104996
4
+ if RUBY_ENGINE == 'jruby'
5
+ require 'i18n/backend'
6
+ require 'i18n/backend/simple'
7
+ end
8
+
3
9
  require 'simplecov'
4
10
  SimpleCov.start
5
11
 
@@ -36,7 +42,7 @@ if ENV['LOGGER']
36
42
  end
37
43
 
38
44
  module SpecHelper
39
- module RailsTestCompatability
45
+ module RailsTestCompatibility
40
46
  require 'minitest'
41
47
  include Minitest::Assertions
42
48
 
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
 
6
6
  shared_examples_for 'ActiveModel' do
7
7
  require 'active_model/lint'
8
- include SpecHelper::RailsTestCompatability
8
+ include SpecHelper::RailsTestCompatibility
9
9
  include ActiveModel::Lint::Tests
10
10
 
11
11
  active_model_methods = ActiveModel::Lint::Tests.public_instance_methods
@@ -13,9 +13,12 @@ shared_examples_for 'ActiveModel' do
13
13
 
14
14
  active_model_lint_tests.each do |method_name|
15
15
  friendly_name = method_name.tr('_', ' ')
16
+
17
+ # rubocop:disable RSpec/NoExpectationExample
16
18
  example friendly_name do
17
19
  public_send method_name.to_sym
18
20
  end
21
+ # rubocop:enable RSpec/NoExpectationExample
19
22
  end
20
23
 
21
24
  before { @model = subject }
@@ -73,7 +76,7 @@ describe 'a temporary ActiveRecord model created with with_model' do
73
76
 
74
77
  describe '.with_model?' do
75
78
  it 'returns true' do
76
- expect(BlogPost.with_model?).to eq true
79
+ expect(BlogPost.with_model?).to be true
77
80
  end
78
81
  end
79
82
 
@@ -84,7 +87,7 @@ describe 'a temporary ActiveRecord model created with with_model' do
84
87
 
85
88
  context 'after an example which uses with_model without shadowing an existing constant' do
86
89
  it 'returns the constant to its undefined state' do
87
- expect(non_shadowing_example_ran).to eq true
90
+ expect(non_shadowing_example_ran).to be true
88
91
  expect(defined?(BlogPost)).to be_falsy
89
92
  end
90
93
  end
@@ -108,7 +111,7 @@ describe 'a temporary ActiveRecord model created with with_model' do
108
111
 
109
112
  context 'without the with_model block' do
110
113
  it 'returns the constant to its original value' do
111
- expect(shadowing_example_ran).to eq true
114
+ expect(shadowing_example_ran).to be true
112
115
  expect(MyConst).to eq 1
113
116
  end
114
117
  end
@@ -151,8 +154,8 @@ describe 'a temporary ActiveRecord model created with with_model' do
151
154
  with_model :'Stuff::BlogPost'
152
155
 
153
156
  it 'creates the model in the namespace' do
154
- expect(defined?(::BlogPost)).to be_falsey
155
- expect(defined?(::Stuff::BlogPost)).to be_truthy
157
+ expect(defined?(BlogPost)).to be_falsey
158
+ expect(defined?(Stuff::BlogPost)).to be_truthy
156
159
  end
157
160
  end
158
161
 
@@ -182,8 +185,8 @@ describe 'a temporary ActiveRecord model created with with_model' do
182
185
  end
183
186
 
184
187
  it 'has the mixin' do
185
- expect(-> { ::WithAMixin.new.foo }).not_to raise_error
186
- expect(::WithAMixin.include?(AMixin)).to eq true
188
+ expect(-> { WithAMixin.new.foo }).not_to raise_error
189
+ expect(WithAMixin.include?(AMixin)).to be true
187
190
  end
188
191
  end
189
192
 
@@ -377,7 +380,7 @@ describe 'a temporary ActiveRecord model created with with_model' do
377
380
  end
378
381
 
379
382
  it 'is a subclass of the supplied superclass' do
380
- expect(BlogPost < BlogPostParent).to eq true
383
+ expect(BlogPost < BlogPostParent).to be true
381
384
  end
382
385
 
383
386
  it 'is its own base_class' do
@@ -385,7 +388,7 @@ describe 'a temporary ActiveRecord model created with with_model' do
385
388
  end
386
389
 
387
390
  it 'responds to .with_model? with true' do
388
- expect(BlogPost.with_model?).to eq true
391
+ expect(BlogPost.with_model?).to be true
389
392
  end
390
393
  end
391
394
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
4
+
5
+ # Workaround for JRuby CI failure https://github.com/jruby/jruby/issues/6547#issuecomment-774104996
6
+ if RUBY_ENGINE == 'jruby'
7
+ require 'i18n/backend'
8
+ require 'i18n/backend/simple'
9
+ end
10
+
11
+ require 'with_model'
12
+ require 'minitest/autorun'
13
+
14
+ WithModel.runner = :minitest
15
+
16
+ module MiniTest
17
+ class Test
18
+ extend WithModel
19
+ end
20
+ end
21
+
22
+ is_jruby = RUBY_PLATFORM == 'java'
23
+ adapter = is_jruby ? 'jdbcsqlite3' : 'sqlite3'
24
+
25
+ # WithModel requires ActiveRecord::Base.connection to be established.
26
+ # If ActiveRecord already has a connection, as in a Rails app, this is unnecessary.
27
+ require 'active_record'
28
+ ActiveRecord::Base.establish_connection(adapter: adapter, database: ':memory:')
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ class WithModelTest < MiniTest::Test
6
+ with_model :BlogPost do
7
+ table do |t|
8
+ t.string 'title'
9
+ t.text 'content'
10
+ t.timestamps null: false
11
+ end
12
+
13
+ model do
14
+ def fancy_title
15
+ "Title: #{title}"
16
+ end
17
+ end
18
+ end
19
+
20
+ def test_it_should_act_like_a_normal_active_record_model # rubocop:disable Minitest/MultipleAssertions
21
+ record = BlogPost.create!(title: 'New blog post', content: 'Hello, world!')
22
+
23
+ record.reload
24
+
25
+ assert_equal 'New blog post', record.title
26
+ assert_equal 'Hello, world!', record.content
27
+ assert record.updated_at
28
+
29
+ record.destroy
30
+
31
+ assert_raises ActiveRecord::RecordNotFound do
32
+ record.reload
33
+ end
34
+ end
35
+
36
+ def test_it_has_the_methods_defined_in_its_model_block
37
+ assert_equal 'Title: New blog post', BlogPost.new(title: 'New blog post').fancy_title
38
+ end
39
+ end
data/with_model.gemspec CHANGED
@@ -12,29 +12,13 @@ Gem::Specification.new do |spec|
12
12
  spec.summary = 'Dynamically build a model within an RSpec context'
13
13
  spec.description = spec.summary
14
14
  spec.license = 'MIT'
15
+ spec.metadata['rubygems_mfa_required'] = 'true'
15
16
 
16
- spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
+ spec.files = `git ls-files -z`.split("\x0")
17
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.required_ruby_version = '>= 2.4'
21
+ spec.required_ruby_version = '>= 2.7'
22
22
 
23
- spec.add_dependency 'activerecord', '>= 5.2'
24
-
25
- spec.add_development_dependency 'bundler', '~> 2.0'
26
- spec.add_development_dependency 'minitest'
27
- spec.add_development_dependency 'rake'
28
- spec.add_development_dependency 'rspec', '~> 3.0'
29
- spec.add_development_dependency 'rubocop'
30
- spec.add_development_dependency 'rubocop-rake'
31
- spec.add_development_dependency 'rubocop-rspec'
32
- spec.add_development_dependency 'simplecov'
33
- spec.add_development_dependency 'yard'
34
-
35
- if RUBY_PLATFORM == 'java'
36
- spec.add_development_dependency 'activerecord-jdbcsqlite3-adapter'
37
- else
38
- spec.add_development_dependency 'sqlite3'
39
- end
23
+ spec.add_dependency 'activerecord', '>= 6.0'
40
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: with_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.5
4
+ version: 2.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Case Commons, LLC
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-11-22 00:00:00.000000000 Z
13
+ date: 2023-09-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -18,154 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '5.2'
21
+ version: '6.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: '5.2'
29
- - !ruby/object:Gem::Dependency
30
- name: bundler
31
- requirement: !ruby/object:Gem::Requirement
32
- requirements:
33
- - - "~>"
34
- - !ruby/object:Gem::Version
35
- version: '2.0'
36
- type: :development
37
- prerelease: false
38
- version_requirements: !ruby/object:Gem::Requirement
39
- requirements:
40
- - - "~>"
41
- - !ruby/object:Gem::Version
42
- version: '2.0'
43
- - !ruby/object:Gem::Dependency
44
- name: minitest
45
- requirement: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: '0'
50
- type: :development
51
- prerelease: false
52
- version_requirements: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: '0'
57
- - !ruby/object:Gem::Dependency
58
- name: rake
59
- requirement: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: '0'
64
- type: :development
65
- prerelease: false
66
- version_requirements: !ruby/object:Gem::Requirement
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: '0'
71
- - !ruby/object:Gem::Dependency
72
- name: rspec
73
- requirement: !ruby/object:Gem::Requirement
74
- requirements:
75
- - - "~>"
76
- - !ruby/object:Gem::Version
77
- version: '3.0'
78
- type: :development
79
- prerelease: false
80
- version_requirements: !ruby/object:Gem::Requirement
81
- requirements:
82
- - - "~>"
83
- - !ruby/object:Gem::Version
84
- version: '3.0'
85
- - !ruby/object:Gem::Dependency
86
- name: rubocop
87
- requirement: !ruby/object:Gem::Requirement
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- version: '0'
92
- type: :development
93
- prerelease: false
94
- version_requirements: !ruby/object:Gem::Requirement
95
- requirements:
96
- - - ">="
97
- - !ruby/object:Gem::Version
98
- version: '0'
99
- - !ruby/object:Gem::Dependency
100
- name: rubocop-rake
101
- requirement: !ruby/object:Gem::Requirement
102
- requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- version: '0'
106
- type: :development
107
- prerelease: false
108
- version_requirements: !ruby/object:Gem::Requirement
109
- requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- version: '0'
113
- - !ruby/object:Gem::Dependency
114
- name: rubocop-rspec
115
- requirement: !ruby/object:Gem::Requirement
116
- requirements:
117
- - - ">="
118
- - !ruby/object:Gem::Version
119
- version: '0'
120
- type: :development
121
- prerelease: false
122
- version_requirements: !ruby/object:Gem::Requirement
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- version: '0'
127
- - !ruby/object:Gem::Dependency
128
- name: simplecov
129
- requirement: !ruby/object:Gem::Requirement
130
- requirements:
131
- - - ">="
132
- - !ruby/object:Gem::Version
133
- version: '0'
134
- type: :development
135
- prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- requirements:
138
- - - ">="
139
- - !ruby/object:Gem::Version
140
- version: '0'
141
- - !ruby/object:Gem::Dependency
142
- name: yard
143
- requirement: !ruby/object:Gem::Requirement
144
- requirements:
145
- - - ">="
146
- - !ruby/object:Gem::Version
147
- version: '0'
148
- type: :development
149
- prerelease: false
150
- version_requirements: !ruby/object:Gem::Requirement
151
- requirements:
152
- - - ">="
153
- - !ruby/object:Gem::Version
154
- version: '0'
155
- - !ruby/object:Gem::Dependency
156
- name: sqlite3
157
- requirement: !ruby/object:Gem::Requirement
158
- requirements:
159
- - - ">="
160
- - !ruby/object:Gem::Version
161
- version: '0'
162
- type: :development
163
- prerelease: false
164
- version_requirements: !ruby/object:Gem::Requirement
165
- requirements:
166
- - - ">="
167
- - !ruby/object:Gem::Version
168
- version: '0'
28
+ version: '6.0'
169
29
  description: Dynamically build a model within an RSpec context
170
30
  email:
171
31
  - casecommons-dev@googlegroups.com
@@ -175,12 +35,14 @@ executables: []
175
35
  extensions: []
176
36
  extra_rdoc_files: []
177
37
  files:
38
+ - ".bundle/config"
39
+ - ".github/dependabot.yml"
40
+ - ".github/workflows/ci.yml"
178
41
  - ".gitignore"
179
42
  - ".jrubyrc"
180
43
  - ".rspec"
181
44
  - ".rubocop.yml"
182
45
  - ".rubocop_todo.yml"
183
- - ".travis.yml"
184
46
  - ".yardopts"
185
47
  - CHANGELOG.md
186
48
  - Gemfile
@@ -200,11 +62,14 @@ files:
200
62
  - spec/readme_spec.rb
201
63
  - spec/spec_helper.rb
202
64
  - spec/with_model_spec.rb
65
+ - test/test_helper.rb
66
+ - test/with_model_test.rb
203
67
  - with_model.gemspec
204
68
  homepage: https://github.com/Casecommons/with_model
205
69
  licenses:
206
70
  - MIT
207
- metadata: {}
71
+ metadata:
72
+ rubygems_mfa_required: 'true'
208
73
  post_install_message:
209
74
  rdoc_options: []
210
75
  require_paths:
@@ -213,21 +78,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
78
  requirements:
214
79
  - - ">="
215
80
  - !ruby/object:Gem::Version
216
- version: '2.4'
81
+ version: '2.7'
217
82
  required_rubygems_version: !ruby/object:Gem::Requirement
218
83
  requirements:
219
84
  - - ">="
220
85
  - !ruby/object:Gem::Version
221
86
  version: '0'
222
87
  requirements: []
223
- rubygems_version: 3.1.4
88
+ rubygems_version: 3.4.19
224
89
  signing_key:
225
90
  specification_version: 4
226
91
  summary: Dynamically build a model within an RSpec context
227
- test_files:
228
- - spec/.rubocop.yml
229
- - spec/active_record_behaviors_spec.rb
230
- - spec/constant_stubber_spec.rb
231
- - spec/readme_spec.rb
232
- - spec/spec_helper.rb
233
- - spec/with_model_spec.rb
92
+ test_files: []
data/.travis.yml DELETED
@@ -1,44 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
-
4
- rvm:
5
- - 2.7.1
6
- - 2.6.6
7
- - 2.5.8
8
- - 2.4.10
9
- - jruby-9.2.13.0
10
-
11
- env:
12
- global:
13
- - CC_TEST_REPORTER_ID=fe5c8a8b1b951a54707c08b6fb2a9a5edf9e0522d28bccc648454f774c9ccab1
14
- matrix:
15
- - ACTIVE_RECORD_BRANCH="master"
16
- - ACTIVE_RECORD_VERSION="~> 6.1.0.rc1"
17
- - ACTIVE_RECORD_VERSION="~> 6.0.0"
18
- - ACTIVE_RECORD_VERSION="~> 5.2.0"
19
-
20
- matrix:
21
- fast_finish: true
22
- allow_failures:
23
- - env: ACTIVE_RECORD_BRANCH="master"
24
- - env: ACTIVE_RECORD_VERSION="~> 6.1.0.rc1"
25
- exclude:
26
- - rvm: 2.4.10
27
- env: ACTIVE_RECORD_BRANCH="master"
28
- - rvm: 2.4.10
29
- env: ACTIVE_RECORD_VERSION="~> 6.0.0"
30
- - rvm: 2.4.10
31
- env: ACTIVE_RECORD_VERSION="~> 6.1.0.rc1"
32
- - rvm: jruby-9.2.13.0
33
- env: ACTIVE_RECORD_VERSION="~> 6.0.0"
34
-
35
- before_install:
36
- - gem install bundler
37
-
38
- before_script:
39
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
40
- - chmod +x ./cc-test-reporter
41
- - ./cc-test-reporter before-build
42
-
43
- after_script:
44
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT