rspec-activemodel-mocks 1.1.0 → 1.2.0

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: 7aad23d1dddfba78f66030c7f0cae1ac0e27d4985af0f4802ea8580b794148b7
4
- data.tar.gz: 9857de724a896288463b66e8beb94c65a9f9c30ab7e66ec35fd2405b26db9c3c
3
+ metadata.gz: 7c03088fe7611777d052655997f79e7394142634a18c47f12ef2b62d21c1225d
4
+ data.tar.gz: 59d467700bd06b7246d40282f73bf9f374574c951455f3400e7ec47e3e0dedc5
5
5
  SHA512:
6
- metadata.gz: b9bcd1324168510eee65b4f7a8e80efe9c463ce00f2bde09a3f479b94b63f3a23c990d14bc21b07197c33fee237e4ff9deabf10381c3afc1f483c512da1958f1
7
- data.tar.gz: 68cd5a0eb7e7f7bed0c48a2d9b8fb9e137e4899dd2264770f66837fc19f3927e84c33743e61fd2ce46f64ac98cca0425a2ea7ab9b7fd13d6395ed9d12580aa15
6
+ metadata.gz: 19ddf1bdf625c89ae9908c504af7ba69204d9e07dcaffddf7baafc4401fcd5b90a1c0e9b747b63be4bf05e10017976dd63a9c3c435626344469a05542d401282
7
+ data.tar.gz: fddd4cf43f973358d3b04762aaedebcc629a7e714bbcf0e82f13f875e6fb6f5c3eb2bf4b328c7227ea55c1b03e12e047420b92463277e47e5a284f551eabfad6
checksums.yaml.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # RSpec::ActiveModel::Mocks [![Build Status](https://secure.travis-ci.org/rspec/rspec-activemodel-mocks.png?branch=master)](http://travis-ci.org/rspec/rspec-activemodel-mocks)
1
+ # RSpec::ActiveModel::Mocks [![RSpec CI](https://github.com/rspec/rspec-activemodel-mocks/actions/workflows/ci.yml/badge.svg)](https://github.com/rspec/rspec-activemodel-mocks/actions/workflows/ci.yml)
2
2
 
3
3
  RSpec::ActiveModel::Mocks provides tools for testing `ActiveModel` classes.
4
4
 
@@ -14,12 +14,8 @@ And then execute:
14
14
 
15
15
  $ bundle
16
16
 
17
- If you are using [rspec-rails](https://github.com/rspec/rspec-rails) and have
18
- followed the installation instructions there, you're all set to use `stub_model`
19
- and `mock_model`.
20
-
21
- To use `stub_model` and `mock_model` without rspec-rails, require the
22
- following file:
17
+ To finish the installation and start using `stub_model` and `mock_model`, require the
18
+ following file in your `spec_helper.rb` or `rails_helper.rb`.
23
19
 
24
20
  require 'rspec/active_model/mocks'
25
21
 
@@ -1,4 +1,5 @@
1
- Then /^the example(s)? should( all)? pass$/ do |_, _|
2
- step %q{the output should contain "0 failures"}
3
- step %q{the exit status should be 0}
1
+ # frozen_string_literal: true
2
+ Then(/^the example(s)? should( all)? pass$/) do |_, _|
3
+ step 'the output should contain "0 failures"'
4
+ step 'the exit status should be 0'
4
5
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'aruba/cucumber'
2
3
 
3
4
  module ArubaExt
@@ -17,7 +18,7 @@ unless File.directory?('./tmp/sample')
17
18
  end
18
19
 
19
20
  def aruba_path(file_or_dir)
20
- File.expand_path("../../../#{file_or_dir.sub('sample','aruba')}", __FILE__)
21
+ File.expand_path("../../../#{file_or_dir.sub('sample', 'aruba')}", __FILE__)
21
22
  end
22
23
 
23
24
  def sample_path(file_or_dir)
@@ -37,12 +38,12 @@ def copy(file_or_dir)
37
38
  end
38
39
 
39
40
  Before do
40
- steps %Q{
41
+ steps %(
41
42
  Given a directory named "spec"
42
- }
43
+ )
43
44
 
44
45
  Dir['tmp/sample/*'].each do |file_or_dir|
45
- if !(file_or_dir =~ /spec$/)
46
+ if file_or_dir !~ /spec$/
46
47
  write_symlink(file_or_dir)
47
48
  end
48
49
  end
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
1
2
  # Required until https://github.com/rubinius/rubinius/issues/2430 is resolved
2
- ENV['RBXOPT'] = "#{ENV["RBXOPT"]} -Xcompiler.no_rbc"
3
+ ENV['RBXOPT'] = "#{ENV.fetch("RBXOPT", nil)} -Xcompiler.no_rbc"
3
4
 
4
- Around "@unsupported-on-rbx" do |scenario, block|
5
+ Around "@unsupported-on-rbx" do |_scenario, block|
5
6
  block.call unless defined?(Rubinius)
6
7
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'active_support'
2
3
  require 'active_support/core_ext/object/to_param'
3
4
  require 'active_model'
@@ -5,7 +6,6 @@ require 'active_model'
5
6
  module RSpec::ActiveModel::Mocks
6
7
  class IllegalDataAccessException < StandardError; end
7
8
  module Mocks
8
-
9
9
  module ActiveModelInstanceMethods
10
10
  # Stubs `persisted?` to return false and `id` to return nil
11
11
  # @return self
@@ -74,6 +74,8 @@ module RSpec::ActiveModel::Mocks
74
74
  end
75
75
  end
76
76
 
77
+ # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
78
+
77
79
  # Creates a test double representing `string_or_model_class` with common
78
80
  # ActiveModel methods stubbed out. Additional methods may be easily
79
81
  # stubbed (via add_stubs) if `stubs` is passed. This is most useful for
@@ -91,14 +93,23 @@ module RSpec::ActiveModel::Mocks
91
93
  # * A String representing a Class that does not exist
92
94
  # * A String representing a Class that extends ActiveModel::Naming
93
95
  # * A Class that extends ActiveModel::Naming
94
- def mock_model(string_or_model_class, stubs = {})
96
+ def mock_model(string_or_model_class, stubs={})
95
97
  if String === string_or_model_class
96
98
  if Object.const_defined?(string_or_model_class)
97
99
  model_class = Object.const_get(string_or_model_class)
98
100
  else
99
101
  model_class = Object.const_set(string_or_model_class, Class.new do
102
+ # rubocop:disable Style/SingleLineMethods
100
103
  extend ::ActiveModel::Naming
101
104
  def self.primary_key; :id; end
105
+
106
+ # For detection of being a valid association in 7+
107
+ def self.<(other); other == ActiveRecord::Base; end
108
+ def self._reflect_on_association(_other); nil; end
109
+ def self.composite_primary_key?; false; end
110
+ def self.has_query_constraints?; false; end
111
+ def self.param_delimiter; "-"; end
112
+ # rubocop:enable Style/SingleLineMethods
102
113
  end)
103
114
  end
104
115
  else
@@ -106,24 +117,29 @@ module RSpec::ActiveModel::Mocks
106
117
  end
107
118
 
108
119
  unless model_class.kind_of? ::ActiveModel::Naming
109
- raise ArgumentError.new <<-EOM
120
+ raise ArgumentError, <<-EOM
110
121
  The mock_model method can only accept as its first argument:
111
122
  * A String representing a Class that does not exist
112
123
  * A String representing a Class that extends ActiveModel::Naming
113
124
  * A Class that extends ActiveModel::Naming
114
125
 
115
126
  It received #{model_class.inspect}
116
- EOM
127
+ EOM
117
128
  end
118
129
 
119
- stubs = {:id => next_id}.merge(stubs)
120
- stubs = {:persisted? => !!stubs[:id],
121
- :destroyed? => false,
122
- :marked_for_destruction? => false,
123
- :valid? => true,
124
- :blank? => false}.merge(stubs)
130
+ stubs = { :id => next_id }.merge(stubs)
131
+ stubs = { :persisted? => !!stubs[:id],
132
+ :destroyed? => false,
133
+ :marked_for_destruction? => false,
134
+ :valid? => true,
135
+ :blank? => false }.merge(stubs)
125
136
 
126
137
  double("#{model_class.name}_#{stubs[:id]}", stubs).tap do |m|
138
+ if model_class.method(:===).owner == Module && !stubs.key?(:===)
139
+ allow(model_class).to receive(:===).and_wrap_original do |original, other|
140
+ m === other || original.call(other)
141
+ end
142
+ end
127
143
  msingleton = class << m; self; end
128
144
  msingleton.class_eval do
129
145
  include ActiveModelInstanceMethods
@@ -131,25 +147,22 @@ EOM
131
147
  include ActiveModel::Conversion
132
148
  include ActiveModel::Validations
133
149
  end
134
- if defined?(ActiveRecord)
135
- [:save, :update_attributes, :update].each do |key|
136
- if stubs[key] == false
137
- RSpec::Mocks.allow_message(m.errors, :empty?).and_return(false)
138
- end
139
- end
150
+ if defined?(ActiveRecord) && stubs.values_at(:save, :update_attributes, :update).include?(false)
151
+ RSpec::Mocks.allow_message(m.errors, :empty?).and_return(false)
152
+ RSpec::Mocks.allow_message(m.errors, :blank?).and_return(false)
140
153
  end
141
154
 
142
155
  msingleton.__send__(:define_method, :is_a?) do |other|
143
156
  model_class.ancestors.include?(other)
144
- end unless stubs.has_key?(:is_a?)
157
+ end unless stubs.key?(:is_a?)
145
158
 
146
159
  msingleton.__send__(:define_method, :kind_of?) do |other|
147
160
  model_class.ancestors.include?(other)
148
- end unless stubs.has_key?(:kind_of?)
161
+ end unless stubs.key?(:kind_of?)
149
162
 
150
163
  msingleton.__send__(:define_method, :instance_of?) do |other|
151
164
  other == model_class
152
- end unless stubs.has_key?(:instance_of?)
165
+ end unless stubs.key?(:instance_of?)
153
166
 
154
167
  msingleton.__send__(:define_method, :__model_class_has_column?) do |method_name|
155
168
  model_class.respond_to?(:column_names) && model_class.column_names.include?(method_name.to_s)
@@ -157,28 +170,33 @@ EOM
157
170
 
158
171
  msingleton.__send__(:define_method, :has_attribute?) do |attr_name|
159
172
  __model_class_has_column?(attr_name)
160
- end unless stubs.has_key?(:has_attribute?)
173
+ end unless stubs.key?(:has_attribute?)
161
174
 
162
175
  msingleton.__send__(:define_method, :respond_to?) do |method_name, *args|
163
- include_private = args.first || false
176
+ include_private = args.first || false
164
177
  __model_class_has_column?(method_name) ? true : super(method_name, include_private)
165
- end unless stubs.has_key?(:respond_to?)
178
+ end unless stubs.key?(:respond_to?)
166
179
 
167
- msingleton.__send__(:define_method, :method_missing) do |m, *a, &b|
168
- respond_to?(m) ? null_object? ? self : nil : super(m, *a, &b)
180
+ msingleton.__send__(:define_method, :method_missing) do |missing_m, *a, &b|
181
+ if respond_to?(missing_m)
182
+ null_object? ? self : nil
183
+ else
184
+ super(missing_m, *a, &b)
185
+ end
169
186
  end
170
187
 
171
188
  msingleton.__send__(:define_method, :class) do
172
189
  model_class
173
- end unless stubs.has_key?(:class)
190
+ end unless stubs.key?(:class)
174
191
 
175
192
  mock_param = to_param
176
193
  msingleton.__send__(:define_method, :to_s) do
177
194
  "#{model_class.name}_#{mock_param}"
178
- end unless stubs.has_key?(:to_s)
195
+ end unless stubs.key?(:to_s)
179
196
  yield m if block_given?
180
197
  end
181
198
  end
199
+ # rubocop:enable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
182
200
 
183
201
  module ActiveModelStubExtensions
184
202
  # Stubs `persisted` to return false and `id` to return nil
@@ -197,7 +215,7 @@ EOM
197
215
  module ActiveRecordStubExtensions
198
216
  # Stubs `id` (or other primary key method) to return nil
199
217
  def as_new_record
200
- self.__send__("#{self.class.primary_key}=", nil)
218
+ __send__("#{self.class.primary_key}=", nil)
201
219
  super
202
220
  end
203
221
 
@@ -209,10 +227,13 @@ EOM
209
227
  # Raises an IllegalDataAccessException (stubbed models are not allowed to access the database)
210
228
  # @raises IllegalDataAccessException
211
229
  def connection
212
- raise RSpec::ActiveModel::Mocks::IllegalDataAccessException.new("stubbed models are not allowed to access the database")
230
+ raise RSpec::ActiveModel::Mocks::IllegalDataAccessException,
231
+ "stubbed models are not allowed to access the database"
213
232
  end
214
233
  end
215
234
 
235
+ # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
236
+
216
237
  # Creates an instance of `Model` with `to_param` stubbed using a
217
238
  # generated value that is unique to each object. If `Model` is an
218
239
  # `ActiveRecord` model, it is prohibited from accessing the database.
@@ -246,17 +267,21 @@ EOM
246
267
  if defined?(ActiveRecord) && model_class < ActiveRecord::Base && model_class.primary_key
247
268
  m.extend ActiveRecordStubExtensions
248
269
  primary_key = model_class.primary_key.to_sym
249
- stubs = {primary_key => next_id}.merge(stubs)
250
- stubs = {:persisted? => !!stubs[primary_key]}.merge(stubs)
270
+ stubs = { primary_key => next_id }.merge(stubs)
271
+ stubs = { :persisted? => !!stubs[primary_key] }.merge(stubs)
251
272
  else
252
- stubs = {:id => next_id}.merge(stubs)
253
- stubs = {:persisted? => !!stubs[:id]}.merge(stubs)
273
+ stubs = { :id => next_id }.merge(stubs)
274
+ stubs = { :persisted? => !!stubs[:id] }.merge(stubs)
254
275
  end
255
- stubs = {:blank? => false}.merge(stubs)
276
+ stubs = { :blank? => false }.merge(stubs)
256
277
 
257
278
  stubs.each do |message, return_value|
258
279
  if m.respond_to?("#{message}=")
259
- m.__send__("#{message}=", return_value)
280
+ begin
281
+ m.__send__("#{message}=", return_value)
282
+ rescue ActiveModel::MissingAttributeError
283
+ RSpec::Mocks.allow_message(m, message).and_return(return_value)
284
+ end
260
285
  else
261
286
  RSpec::Mocks.allow_message(m, message).and_return(return_value)
262
287
  end
@@ -265,15 +290,17 @@ EOM
265
290
  yield m if block_given?
266
291
  end
267
292
  end
293
+ # rubocop:enable Metrics/AbcSize,Metrics/MethodLength
268
294
 
269
- private
295
+ private
270
296
 
297
+ # rubocop:disable Style/ClassVars
271
298
  @@model_id = 1000
272
299
 
273
300
  def next_id
274
301
  @@model_id += 1
275
302
  end
276
-
303
+ # rubocop:enable Style/ClassVars
277
304
  end
278
305
  end
279
306
 
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
1
2
  module RSpec
2
3
  module ActiveModel
3
4
  module Mocks
4
5
  module Version
5
- STRING = '1.1.0'
6
+ STRING = '1.2.0'
6
7
  end
7
8
  end
8
9
  end
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
1
2
  require 'rspec/core'
2
3
 
3
- RSpec::configure do |c|
4
+ RSpec.configure do |c|
4
5
  c.backtrace_exclusion_patterns << /lib\/rspec\/active_model\/mocks/
5
6
  end
6
7
 
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  require 'rspec/active_model/mocks'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "mock_model(RealModel)" do
@@ -81,6 +82,7 @@ describe "mock_model(RealModel)" do
81
82
  it "is empty" do
82
83
  model = mock_model(MockableModel)
83
84
  expect(model.errors).to be_empty
85
+ expect(model.errors).to be_blank
84
86
  end
85
87
  end
86
88
 
@@ -88,6 +90,7 @@ describe "mock_model(RealModel)" do
88
90
  it "is not empty" do
89
91
  model = mock_model(MockableModel, :save => false)
90
92
  expect(model.errors).not_to be_empty
93
+ expect(model.errors).not_to be_blank
91
94
  end
92
95
  end
93
96
 
@@ -95,15 +98,16 @@ describe "mock_model(RealModel)" do
95
98
  it "is not empty" do
96
99
  model = mock_model(MockableModel, :save => false)
97
100
  expect(model.errors).not_to be_empty
101
+ expect(model.errors).not_to be_blank
98
102
  end
99
103
  end
100
104
  end
101
105
 
102
106
  describe "with params" do
103
107
  it "does not mutate its parameters" do
104
- params = {:a => 'b'}
108
+ params = { :a => 'b' }
105
109
  mock_model(MockableModel, params)
106
- expect(params).to eq({:a => 'b'})
110
+ expect(params).to eq({ :a => 'b' })
107
111
  end
108
112
  end
109
113
 
@@ -157,6 +161,56 @@ describe "mock_model(RealModel)" do
157
161
  end
158
162
  end
159
163
 
164
+ describe "#===" do
165
+ it "works with a case statement" do
166
+ case mock_model(MockableModel)
167
+ when MockableModel then true
168
+ else
169
+ raise
170
+ end
171
+
172
+ # rubocop:disable Lint/LiteralAsCondition
173
+ case :not_mockable_model
174
+ when MockableModel then raise
175
+ else
176
+ true
177
+ end
178
+ # rubocop:enable Lint/LiteralAsCondition
179
+ end
180
+
181
+ it "won't break previous stubs" do
182
+ allow(MockableModel).to receive(:===).with("string") { true }
183
+ mock_model(MockableModel)
184
+
185
+ # rubocop:disable Lint/LiteralAsCondition
186
+ case "string"
187
+ when MockableModel then true
188
+ else
189
+ raise
190
+ end
191
+ # rubocop:enable Lint/LiteralAsCondition
192
+ end
193
+
194
+ it "won't override class definitions" do
195
+ another_mockable_model =
196
+ Class.new(MockableModel) do
197
+ def self.===(_other)
198
+ true
199
+ end
200
+ end
201
+
202
+ mock_model(another_mockable_model)
203
+
204
+ # rubocop:disable Lint/LiteralAsCondition
205
+ case "string"
206
+ when another_mockable_model then true
207
+ else
208
+ raise
209
+ end
210
+ # rubocop:enable Lint/LiteralAsCondition
211
+ end
212
+ end
213
+
160
214
  describe "#kind_of?" do
161
215
  before(:each) do
162
216
  @model = mock_model(SubMockableModel)
@@ -196,7 +250,7 @@ describe "mock_model(RealModel)" do
196
250
  describe "#has_attribute?" do
197
251
  context "with an ActiveRecord model" do
198
252
  before(:each) do
199
- MockableModel.stub(:column_names).and_return(["column_a", "column_b"])
253
+ MockableModel.stub(:column_names).and_return(%w[column_a column_b])
200
254
  @model = mock_model(MockableModel)
201
255
  end
202
256
 
@@ -223,7 +277,7 @@ describe "mock_model(RealModel)" do
223
277
  describe "#respond_to?" do
224
278
  context "with an ActiveRecord model" do
225
279
  before(:each) do
226
- allow(MockableModel).to receive(:column_names).and_return(["column_a", "column_b"])
280
+ allow(MockableModel).to receive(:column_names).and_return(%w[column_a column_b])
227
281
  @model = mock_model(MockableModel)
228
282
  end
229
283
 
@@ -416,6 +470,7 @@ describe "mock_model(RealModel)" do
416
470
  end
417
471
 
418
472
  describe "ActiveModel Lint tests" do
473
+ # rubocop:disable Lint/EmptyExpression,Metrics/BlockNesting
419
474
  begin
420
475
  require 'minitest/assertions'
421
476
  include Minitest::Assertions
@@ -451,9 +506,9 @@ describe "mock_model(RealModel)" do
451
506
  ERR
452
507
  end
453
508
  include Test::Unit::Assertions
454
- if defined?(Test::Unit::AutoRunner.need_auto_run = ())
509
+ if defined?((Test::Unit::AutoRunner.need_auto_run = ()))
455
510
  Test::Unit::AutoRunner.need_auto_run = false
456
- elsif defined?(Test::Unit.run = ())
511
+ elsif defined?((Test::Unit.run = ()))
457
512
  Test::Unit.run = false
458
513
  end
459
514
  else
@@ -464,20 +519,21 @@ describe "mock_model(RealModel)" do
464
519
  else
465
520
  require 'test/unit/assertions'
466
521
  include Test::Unit::Assertions
467
- if defined?(Test::Unit::AutoRunner.need_auto_run = ())
522
+ if defined?((Test::Unit::AutoRunner.need_auto_run = ()))
468
523
  Test::Unit::AutoRunner.need_auto_run = false
469
- elsif defined?(Test::Unit.run = ())
524
+ elsif defined?((Test::Unit.run = ()))
470
525
  Test::Unit.run = false
471
526
  end
472
527
  end
473
528
  end
529
+ # rubocop:enable Lint/EmptyExpression,Metrics/BlockNesting
474
530
 
475
531
  require 'active_model/lint'
476
532
  include ActiveModel::Lint::Tests
477
533
 
478
534
  # to_s is to support ruby-1.9
479
- ActiveModel::Lint::Tests.public_instance_methods.map{|m| m.to_s}.grep(/^test/).each do |m|
480
- example m.gsub('_',' ') do
535
+ ActiveModel::Lint::Tests.public_instance_methods.map {|m| m.to_s}.grep(/^test/).each do |m|
536
+ example m.gsub('_', ' ') do
481
537
  send m
482
538
  end
483
539
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "stub_model" do
@@ -89,7 +90,8 @@ describe "stub_model" do
89
90
  it "raises when hitting the db" do
90
91
  expect do
91
92
  stub_model(MockableModel).connection
92
- end.to raise_error(RSpec::ActiveModel::Mocks::IllegalDataAccessException, /stubbed models are not allowed to access the database/)
93
+ end.to raise_error(RSpec::ActiveModel::Mocks::IllegalDataAccessException,
94
+ /stubbed models are not allowed to access the database/)
93
95
  end
94
96
 
95
97
  it "increments the id" do
@@ -161,6 +163,23 @@ describe "stub_model" do
161
163
  end
162
164
  expect(model).to be(@block_arg)
163
165
  end
166
+ end
167
+
168
+ describe "#===" do
169
+ it "works with a case statement" do
170
+ case stub_model(MockableModel)
171
+ when MockableModel then true
172
+ else
173
+ raise
174
+ end
164
175
 
176
+ # rubocop:disable Lint/LiteralAsCondition
177
+ case :not_stub_model
178
+ when MockableModel then raise
179
+ else
180
+ true
181
+ end
182
+ # rubocop:enable Lint/LiteralAsCondition
183
+ end
165
184
  end
166
185
  end
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,16 @@
1
+ # frozen_string_literal: true
1
2
  require 'rspec/active_model/mocks'
2
3
  require 'active_record'
3
4
 
4
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
5
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each {|f| require f}
5
6
 
6
- class RSpec::Core::ExampleGroup
7
- def self.run_all(reporter=nil)
8
- run(reporter || RSpec::Mocks::Mock.new('reporter').as_null_object)
7
+ module RSpec
8
+ module Core
9
+ class ExampleGroup
10
+ def self.run_all(reporter=nil)
11
+ run(reporter || RSpec::Mocks::Mock.new('reporter').as_null_object)
12
+ end
13
+ end
9
14
  end
10
15
  end
11
16
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ActiveRecord::Base.establish_connection(
2
3
  :adapter => 'sqlite3',
3
4
  :database => ':memory:'
@@ -5,31 +6,31 @@ ActiveRecord::Base.establish_connection(
5
6
 
6
7
  module Connections
7
8
  def self.extended(host)
8
- host.connection.execute <<-eosql
9
+ host.connection.execute <<-EOSQL
9
10
  CREATE TABLE #{host.table_name} (
10
11
  #{host.primary_key} integer PRIMARY KEY AUTOINCREMENT,
11
12
  associated_model_id integer,
12
13
  mockable_model_id integer,
13
14
  nonexistent_model_id integer
14
15
  )
15
- eosql
16
+ EOSQL
16
17
  end
17
18
  end
18
19
 
19
20
  module ConnectionsView
20
21
  def self.extended(host)
21
- host.connection.execute <<-eosql
22
+ host.connection.execute <<-EOSQL
22
23
  CREATE TABLE some_table (
23
24
  associated_model_id integer,
24
25
  mockable_model_id integer,
25
26
  nonexistent_model_id integer
26
27
  )
27
- eosql
28
+ EOSQL
28
29
 
29
- host.connection.execute <<-eosql
30
+ host.connection.execute <<-EOSQL
30
31
  CREATE VIEW #{host.table_name} AS
31
32
  select * from some_table;
32
- eosql
33
+ EOSQL
33
34
  end
34
35
  end
35
36
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Helpers
2
3
  def stub_metadata(additional_metadata)
3
4
  stub_metadata = metadata_with(additional_metadata)
@@ -1,7 +1,8 @@
1
- RSpec::Matchers::define :be_included_in_files_in do |path|
1
+ # frozen_string_literal: true
2
+ RSpec::Matchers.define :be_included_in_files_in do |path|
2
3
  match do |mod|
3
4
  stub_metadata(
4
- :example_group => {:file_path => "#{path}whatever_spec.rb:15"}
5
+ :example_group => { :file_path => "#{path}whatever_spec.rb:15" }
5
6
  )
6
7
  group = RSpec::Core::ExampleGroup.describe
7
8
  group.included_modules.include?(mod)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Minitest requires you provide an assertions ivar for the context
2
3
  # it is running within. We need this so that ActiveModel::Lint tests
3
4
  # can successfully be run.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class NullObject
2
3
  private
3
4
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-activemodel-mocks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chelimsky
8
8
  - Andy Lindeman
9
9
  - Thomas Holmes
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain:
13
13
  - |
@@ -45,10 +45,10 @@ cert_chain:
45
45
  ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
46
46
  F3MdtaDehhjC
47
47
  -----END CERTIFICATE-----
48
- date: 2018-09-17 00:00:00.000000000 Z
48
+ date: 2023-12-10 00:00:00.000000000 Z
49
49
  dependencies:
50
50
  - !ruby/object:Gem::Dependency
51
- name: activesupport
51
+ name: activemodel
52
52
  requirement: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - ">="
@@ -62,7 +62,7 @@ dependencies:
62
62
  - !ruby/object:Gem::Version
63
63
  version: '3.0'
64
64
  - !ruby/object:Gem::Dependency
65
- name: activemodel
65
+ name: activesupport
66
66
  requirement: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - ">="
@@ -95,76 +95,6 @@ dependencies:
95
95
  - - "<"
96
96
  - !ruby/object:Gem::Version
97
97
  version: '4.0'
98
- - !ruby/object:Gem::Dependency
99
- name: rake
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - "~>"
103
- - !ruby/object:Gem::Version
104
- version: 10.0.0
105
- type: :development
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - "~>"
110
- - !ruby/object:Gem::Version
111
- version: 10.0.0
112
- - !ruby/object:Gem::Dependency
113
- name: cucumber
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - "~>"
117
- - !ruby/object:Gem::Version
118
- version: 1.3.5
119
- type: :development
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - "~>"
124
- - !ruby/object:Gem::Version
125
- version: 1.3.5
126
- - !ruby/object:Gem::Dependency
127
- name: aruba
128
- requirement: !ruby/object:Gem::Requirement
129
- requirements:
130
- - - "~>"
131
- - !ruby/object:Gem::Version
132
- version: 0.4.11
133
- type: :development
134
- prerelease: false
135
- version_requirements: !ruby/object:Gem::Requirement
136
- requirements:
137
- - - "~>"
138
- - !ruby/object:Gem::Version
139
- version: 0.4.11
140
- - !ruby/object:Gem::Dependency
141
- name: ZenTest
142
- requirement: !ruby/object:Gem::Requirement
143
- requirements:
144
- - - "~>"
145
- - !ruby/object:Gem::Version
146
- version: 4.9.5
147
- type: :development
148
- prerelease: false
149
- version_requirements: !ruby/object:Gem::Requirement
150
- requirements:
151
- - - "~>"
152
- - !ruby/object:Gem::Version
153
- version: 4.9.5
154
- - !ruby/object:Gem::Dependency
155
- name: activerecord
156
- requirement: !ruby/object:Gem::Requirement
157
- requirements:
158
- - - ">="
159
- - !ruby/object:Gem::Version
160
- version: '3.0'
161
- type: :development
162
- prerelease: false
163
- version_requirements: !ruby/object:Gem::Requirement
164
- requirements:
165
- - - ">="
166
- - !ruby/object:Gem::Version
167
- version: '3.0'
168
98
  description: RSpec test doubles for ActiveModel and ActiveRecord
169
99
  email: rspec@googlegroups.com
170
100
  executables: []
@@ -177,7 +107,6 @@ files:
177
107
  - features/mocks/mock_model.feature
178
108
  - features/mocks/stub_model.feature
179
109
  - features/step_definitions/additional_cli_steps.rb
180
- - features/step_definitions/model_steps.rb
181
110
  - features/support/env.rb
182
111
  - features/support/rubinius.rb
183
112
  - lib/rspec-activemodel-mocks.rb
@@ -195,8 +124,13 @@ files:
195
124
  homepage: https://github.com/rspec/rspec-activemodel-mocks
196
125
  licenses:
197
126
  - MIT
198
- metadata: {}
199
- post_install_message:
127
+ metadata:
128
+ bug_tracker_uri: https://github.com/rspec/rspec-activemodel-mocks/issues
129
+ documentation_uri: https://rspec.info/documentation/
130
+ mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
131
+ source_code_uri: https://github.com/rspec/rspec-activemodel-mocks
132
+ rubygems_mfa_required: 'true'
133
+ post_install_message:
200
134
  rdoc_options:
201
135
  - "--charset=UTF-8"
202
136
  require_paths:
@@ -212,16 +146,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
146
  - !ruby/object:Gem::Version
213
147
  version: '0'
214
148
  requirements: []
215
- rubyforge_project:
216
- rubygems_version: 2.7.6
217
- signing_key:
149
+ rubygems_version: 3.4.10
150
+ signing_key:
218
151
  specification_version: 4
219
- summary: rspec-activemodel-mocks-1.1.0
152
+ summary: rspec-activemodel-mocks-1.2.0
220
153
  test_files:
221
154
  - features/mocks/mock_model.feature
222
155
  - features/mocks/stub_model.feature
223
156
  - features/step_definitions/additional_cli_steps.rb
224
- - features/step_definitions/model_steps.rb
225
157
  - features/support/env.rb
226
158
  - features/support/rubinius.rb
227
159
  - spec/rspec/active_model/mocks/mock_model_spec.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,3 +0,0 @@
1
- Given /a (\w+) model/ do |model_class_name|
2
- puts eval(model_class_name)
3
- end