Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rubocop_rspec_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Style/PercentLiteralDelimiters:

# We have too many special cases where we allow generator methods or prefer a
# prefixed predicate due to it's improved readability.
Naming/PredicateName:
Naming/PredicatePrefix:
Enabled: false

# On 1.8 `proc` is `lambda`, so we use `Proc.new` to ensure we get real procs on all supported versions.
Expand Down
1 change: 1 addition & 0 deletions lib/rspec/active_model/mocks/mocks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def mock_model(string_or_model_class, stubs={})
model_class = Object.const_set(string_or_model_class, Class.new do
# rubocop:disable Style/SingleLineMethods
extend ::ActiveModel::Naming

def self.primary_key; :id; end

# For detection of being a valid association in 7+
Expand Down
2 changes: 2 additions & 0 deletions spec/rspec/active_model/mocks/mock_model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ def self.===(_other)
ERR
end
include Test::Unit::Assertions

if defined?((Test::Unit::AutoRunner.need_auto_run = ()))
Test::Unit::AutoRunner.need_auto_run = false
elsif defined?((Test::Unit.run = ()))
Expand All @@ -532,6 +533,7 @@ def self.===(_other)
else
require 'test/unit/assertions'
include Test::Unit::Assertions

if defined?((Test::Unit::AutoRunner.need_auto_run = ()))
Test::Unit::AutoRunner.need_auto_run = false
elsif defined?((Test::Unit.run = ()))
Expand Down
3 changes: 3 additions & 0 deletions spec/support/ar_classes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class NonActiveRecordModel

class MockableModel < ActiveRecord::Base
extend Connections

has_one :associated_model
end

Expand All @@ -54,12 +55,14 @@ class SubMockableModel < MockableModel

class AssociatedModel < ActiveRecord::Base
extend Connections

belongs_to :mockable_model
belongs_to :nonexistent_model, :class_name => "Other"
end

class AlternatePrimaryKeyModel < ActiveRecord::Base
self.primary_key = :my_id
extend Connections

attr_accessor :my_id
end