fix(rubocop): Fix Layout related offenses [ci skip]
- Layout/EmptyLines - Layout/EmptyLineAfterGuardClause - Layout/TrailingEmptyLines - Layout/EmptyLinesAroundBlockBody - Layout/EmptyLinesAroundModuleBody - Layout/EmptyLineAfterMagicComment - Layout/SpaceInsidePercentLiteralDelimiters - Layout/SpaceAroundEqualsInParameterDefault - Layout/SpaceInsideArrayLiteralBrackets - Layout/LeadingCommentSpace - Layout/SpaceBeforeComment - Layout/SpaceAroundOperators - Layout/SpaceInsideRangeLiteral - Layout/SpaceInsideReferenceBrackets - Layout/SpaceInLambdaLiteral - Layout/SpaceAfterComma - Layout/SpaceInsideHashLiteralBraces - Layout/TrailingWhitespace - Layout/ArgumentAlignment - Layout/HashAlignment - Layout/DotPosition - Layout/IndentationWidth - Layout/EndAlignment - Layout/MultilineOperationIndentation - Layout/IndentationConsistency - Layout/ClosingHeredocIndentation - Layout/MultilineMethodCallBrace- Layout - Layout/ClosingParenthesisIndentation
This commit is contained in:
parent
0acc27eaac
commit
ee1008de7a
|
@ -15,6 +15,7 @@ def class_list(root = Registry.root, tree = TreeContext.new)
|
||||||
end
|
end
|
||||||
children.compact.sort_by(&:path).each do |child|
|
children.compact.sort_by(&:path).each do |child|
|
||||||
next unless child.is_a?(CodeObjects::NamespaceObject)
|
next unless child.is_a?(CodeObjects::NamespaceObject)
|
||||||
|
|
||||||
name = child.namespace.is_a?(CodeObjects::Proxy) ? child.path : child.name
|
name = child.namespace.is_a?(CodeObjects::Proxy) ? child.path : child.name
|
||||||
has_children = run_verifier(child.children).any? {|o| o.is_a?(CodeObjects::NamespaceObject) }
|
has_children = run_verifier(child.children).any? {|o| o.is_a?(CodeObjects::NamespaceObject) }
|
||||||
out << "<li id='object_#{child.path}' class='#{tree.classes.join(' ')}'>"
|
out << "<li id='object_#{child.path}' class='#{tree.classes.join(' ')}'>"
|
||||||
|
|
|
@ -183,7 +183,6 @@ module Shoulda
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def guess_controller_if_necessary(controller)
|
def guess_controller_if_necessary(controller)
|
||||||
params[:controller] ||= controller.controller_path
|
params[:controller] ||= controller.controller_path
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@ module Shoulda
|
||||||
module ActionController
|
module ActionController
|
||||||
# @private
|
# @private
|
||||||
class RouteParams
|
class RouteParams
|
||||||
PARAMS_TO_SYMBOLIZE = %i{ format }
|
PARAMS_TO_SYMBOLIZE = %i{format}
|
||||||
|
|
||||||
def initialize(args)
|
def initialize(args)
|
||||||
@args = args
|
@args = args
|
||||||
|
|
|
@ -94,8 +94,8 @@ module Shoulda
|
||||||
@failure_message_when_negated = 'no attributes were protected'
|
@failure_message_when_negated = 'no attributes were protected'
|
||||||
else
|
else
|
||||||
@failure_message_when_negated = "#{class_name} is protecting " <<
|
@failure_message_when_negated = "#{class_name} is protecting " <<
|
||||||
"#{protected_attributes.to_a.to_sentence}, " <<
|
"#{protected_attributes.to_a.to_sentence}, " <<
|
||||||
"but not #{@attribute}."
|
"but not #{@attribute}."
|
||||||
end
|
end
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
|
|
|
@ -46,7 +46,7 @@ module Shoulda
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_message(message, options={})
|
def with_message(message, options = {})
|
||||||
allow_matcher.with_message(message, options)
|
allow_matcher.with_message(message, options)
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,6 +18,7 @@ module Shoulda
|
||||||
unless numericality_matcher.respond_to? :diff_to_compare
|
unless numericality_matcher.respond_to? :diff_to_compare
|
||||||
raise ArgumentError, 'numericality_matcher is invalid'
|
raise ArgumentError, 'numericality_matcher is invalid'
|
||||||
end
|
end
|
||||||
|
|
||||||
@numericality_matcher = numericality_matcher
|
@numericality_matcher = numericality_matcher
|
||||||
@value = value
|
@value = value
|
||||||
@operator = operator
|
@operator = operator
|
||||||
|
@ -127,7 +128,7 @@ module Shoulda
|
||||||
when :<=
|
when :<=
|
||||||
[true, true, false]
|
[true, true, false]
|
||||||
when :!=
|
when :!=
|
||||||
[true, false, true]
|
[true, false, true]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ module Shoulda
|
||||||
if reflection
|
if reflection
|
||||||
obj = reflection.klass.new
|
obj = reflection.klass.new
|
||||||
if collection?
|
if collection?
|
||||||
[ obj ]
|
[obj]
|
||||||
else
|
else
|
||||||
obj
|
obj
|
||||||
end
|
end
|
||||||
|
|
|
@ -545,10 +545,10 @@ EOT
|
||||||
values = []
|
values = []
|
||||||
|
|
||||||
values << case @array
|
values << case @array
|
||||||
when [true] then false
|
when [true] then false
|
||||||
when [false] then true
|
when [false] then true
|
||||||
else raise CouldNotDetermineValueOutsideOfArray
|
else raise CouldNotDetermineValueOutsideOfArray
|
||||||
end
|
end
|
||||||
|
|
||||||
if attribute_allows_nil?
|
if attribute_allows_nil?
|
||||||
values << nil
|
values << nil
|
||||||
|
|
|
@ -372,9 +372,9 @@ module Shoulda
|
||||||
def allow_nil
|
def allow_nil
|
||||||
@expects_to_allow_nil = true
|
@expects_to_allow_nil = true
|
||||||
prepare_submatcher(
|
prepare_submatcher(
|
||||||
AllowValueMatcher.new(nil)
|
AllowValueMatcher.new(nil).
|
||||||
.for(@attribute)
|
for(@attribute).
|
||||||
.with_message(:not_a_number),
|
with_message(:not_a_number),
|
||||||
)
|
)
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Shoulda
|
||||||
class ValidationMessageFinder
|
class ValidationMessageFinder
|
||||||
include Helpers
|
include Helpers
|
||||||
|
|
||||||
def initialize(instance, attribute, context=nil)
|
def initialize(instance, attribute, context = nil)
|
||||||
@instance = instance
|
@instance = instance
|
||||||
@attribute = attribute
|
@attribute = attribute
|
||||||
@context = context
|
@context = context
|
||||||
|
@ -58,8 +58,6 @@ module Shoulda
|
||||||
@instance
|
@instance
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -421,9 +421,9 @@ module Shoulda
|
||||||
def expected_prefix
|
def expected_prefix
|
||||||
if options.include?(:prefix)
|
if options.include?(:prefix)
|
||||||
if options[:prefix] == true
|
if options[:prefix] == true
|
||||||
attribute_name#.to_sym
|
attribute_name # .to_sym
|
||||||
else
|
else
|
||||||
options[:prefix]#.to_sym
|
options[:prefix] # .to_sym
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -431,9 +431,9 @@ module Shoulda
|
||||||
def expected_suffix
|
def expected_suffix
|
||||||
if options.include?(:suffix)
|
if options.include?(:suffix)
|
||||||
if options[:suffix] == true
|
if options[:suffix] == true
|
||||||
attribute_name#.to_sym
|
attribute_name # .to_sym
|
||||||
else
|
else
|
||||||
options[:suffix]#.to_sym
|
options[:suffix] # .to_sym
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,11 +40,11 @@ module Shoulda
|
||||||
else
|
else
|
||||||
if readonly_attributes.empty?
|
if readonly_attributes.empty?
|
||||||
@failure_message = "#{class_name} attribute #{@attribute} " <<
|
@failure_message = "#{class_name} attribute #{@attribute} " <<
|
||||||
'is not read-only'
|
'is not read-only'
|
||||||
else
|
else
|
||||||
@failure_message = "#{class_name} is making " <<
|
@failure_message = "#{class_name} is making " <<
|
||||||
"#{readonly_attributes.to_a.to_sentence} " <<
|
"#{readonly_attributes.to_a.to_sentence} " <<
|
||||||
"read-only, but not #{@attribute}."
|
"read-only, but not #{@attribute}."
|
||||||
end
|
end
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
|
@ -63,12 +63,14 @@ module Shoulda
|
||||||
|
|
||||||
def failure_message
|
def failure_message
|
||||||
return if !@errors
|
return if !@errors
|
||||||
|
|
||||||
"Expected #{@subject.class} to #{description} but the following " \
|
"Expected #{@subject.class} to #{description} but the following " \
|
||||||
"errors were found: #{@errors.join(', ')}"
|
"errors were found: #{@errors.join(', ')}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def failure_message_when_negated
|
def failure_message_when_negated
|
||||||
return if !@errors
|
return if !@errors
|
||||||
|
|
||||||
"Did not expect #{@subject.class} to have secure token " \
|
"Did not expect #{@subject.class} to have secure token " \
|
||||||
":#{token_attribute}"
|
":#{token_attribute}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -795,7 +795,7 @@ module Shoulda
|
||||||
column = column_for(scope)
|
column = column_for(scope)
|
||||||
|
|
||||||
if column.respond_to?(:array) && column.array
|
if column.respond_to?(:array) && column.array
|
||||||
[ dummy_scalar_value_for(column) ]
|
[dummy_scalar_value_for(column)]
|
||||||
else
|
else
|
||||||
dummy_scalar_value_for(column)
|
dummy_scalar_value_for(column)
|
||||||
end
|
end
|
||||||
|
@ -807,7 +807,7 @@ module Shoulda
|
||||||
|
|
||||||
def next_value_for(scope, previous_value)
|
def next_value_for(scope, previous_value)
|
||||||
if previous_value.is_a?(Array)
|
if previous_value.is_a?(Array)
|
||||||
[ next_scalar_value_for(scope, previous_value[0]) ]
|
[next_scalar_value_for(scope, previous_value[0])]
|
||||||
else
|
else
|
||||||
next_scalar_value_for(scope, previous_value)
|
next_scalar_value_for(scope, previous_value)
|
||||||
end
|
end
|
||||||
|
|
|
@ -245,7 +245,7 @@ module Shoulda
|
||||||
def with_prefix(prefix = nil)
|
def with_prefix(prefix = nil)
|
||||||
@delegating_method =
|
@delegating_method =
|
||||||
:"#{build_delegating_method_prefix(prefix)}_#{delegate_method}"
|
:"#{build_delegating_method_prefix(prefix)}_#{delegate_method}"
|
||||||
delegate_method
|
delegate_method
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -446,7 +446,7 @@ module Shoulda
|
||||||
calls_on_delegate_object.each_with_index do |call, i|
|
calls_on_delegate_object.each_with_index do |call, i|
|
||||||
name = call.method_name
|
name = call.method_name
|
||||||
args = call.args.map { |arg| arg.inspect }.join(', ')
|
args = call.args.map { |arg| arg.inspect }.join(', ')
|
||||||
string << "#{i+1}) #{name}(#{args})\n"
|
string << "#{i + 1}) #{name}(#{args})\n"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
string << ' (none)'
|
string << ' (none)'
|
||||||
|
|
|
@ -20,7 +20,7 @@ Shoulda::Matchers.configure do |config|
|
||||||
with.test_framework :test_unit
|
with.test_framework :test_unit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
EOT
|
EOT
|
||||||
end
|
end
|
||||||
|
|
||||||
def include(*modules, **options); end
|
def include(*modules, **options); end
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Shoulda
|
||||||
|
|
||||||
def self.deconstantize(path)
|
def self.deconstantize(path)
|
||||||
if defined?(ActiveSupport::Inflector) &&
|
if defined?(ActiveSupport::Inflector) &&
|
||||||
ActiveSupport::Inflector.respond_to?(:deconstantize)
|
ActiveSupport::Inflector.respond_to?(:deconstantize)
|
||||||
ActiveSupport::Inflector.deconstantize(path)
|
ActiveSupport::Inflector.deconstantize(path)
|
||||||
else
|
else
|
||||||
path.to_s[0...(path.to_s.rindex('::') || 0)]
|
path.to_s[0...(path.to_s.rindex('::') || 0)]
|
||||||
|
@ -17,7 +17,7 @@ module Shoulda
|
||||||
|
|
||||||
def self.safe_constantize(camel_cased_word)
|
def self.safe_constantize(camel_cased_word)
|
||||||
if defined?(ActiveSupport::Inflector) &&
|
if defined?(ActiveSupport::Inflector) &&
|
||||||
ActiveSupport::Inflector.respond_to?(:safe_constantize)
|
ActiveSupport::Inflector.respond_to?(:safe_constantize)
|
||||||
ActiveSupport::Inflector.safe_constantize(camel_cased_word)
|
ActiveSupport::Inflector.safe_constantize(camel_cased_word)
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
@ -30,6 +30,7 @@ module Shoulda
|
||||||
|
|
||||||
def self.indent(string, width)
|
def self.indent(string, width)
|
||||||
return if !string
|
return if !string
|
||||||
|
|
||||||
indentation = ' ' * width
|
indentation = ' ' * width
|
||||||
string.split(/[\n\r]/).map { |line| indentation + line }.join("\n")
|
string.split(/[\n\r]/).map { |line| indentation + line }.join("\n")
|
||||||
end
|
end
|
||||||
|
|
|
@ -185,7 +185,7 @@ module Shoulda
|
||||||
leftover = ''
|
leftover = ''
|
||||||
else
|
else
|
||||||
fitted_line = line[0..index].rstrip
|
fitted_line = line[0..index].rstrip
|
||||||
leftover = line[index + 1 .. -1]
|
leftover = line[index + 1..-1]
|
||||||
end
|
end
|
||||||
|
|
||||||
{ fitted_line: fitted_line, leftover: leftover }
|
{ fitted_line: fitted_line, leftover: leftover }
|
||||||
|
|
|
@ -8,7 +8,7 @@ require 'rspec/core'
|
||||||
|
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
Dir[ File.join(File.expand_path('support/acceptance/**/*.rb', __dir__)) ].sort.each do |file|
|
Dir[File.join(File.expand_path('support/acceptance/**/*.rb', __dir__))].sort.each do |file|
|
||||||
require file
|
require file
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ module AcceptanceTests
|
||||||
files = []
|
files = []
|
||||||
|
|
||||||
if integrates_with_nunit_and_rails?(test_framework, libraries) ||
|
if integrates_with_nunit_and_rails?(test_framework, libraries) ||
|
||||||
integrates_with_nunit_only?(test_framework)
|
integrates_with_nunit_only?(test_framework)
|
||||||
files << 'test/test_helper.rb'
|
files << 'test/test_helper.rb'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ module AcceptanceTests
|
||||||
|
|
||||||
def failure_message
|
def failure_message
|
||||||
message = "Expected output to indicate that #{some_tests_were_run}.\n" +
|
message = "Expected output to indicate that #{some_tests_were_run}.\n" +
|
||||||
"Expected output: #{expected_output}\n"
|
"Expected output: #{expected_output}\n"
|
||||||
|
|
||||||
if actual_output.empty?
|
if actual_output.empty?
|
||||||
message << 'Actual output: (empty)'
|
message << 'Actual output: (empty)'
|
||||||
|
|
|
@ -61,7 +61,7 @@ module AcceptanceTests
|
||||||
def expected_output_for_turn
|
def expected_output_for_turn
|
||||||
full_report = series.map do |number|
|
full_report = series.map do |number|
|
||||||
"pass: #{number}, fail: 0, error: 0"
|
"pass: #{number}, fail: 0, error: 0"
|
||||||
end.join('.+')
|
end.join('.+')
|
||||||
|
|
||||||
Regexp.new(full_report, Regexp::MULTILINE)
|
Regexp.new(full_report, Regexp::MULTILINE)
|
||||||
end
|
end
|
||||||
|
|
|
@ -34,7 +34,7 @@ module Tests
|
||||||
)
|
)
|
||||||
@env = extract_env_from(@options)
|
@env = extract_env_from(@options)
|
||||||
|
|
||||||
@wrapper = ->(block) { block.call }
|
@wrapper = -> (block) { block.call }
|
||||||
@command_prefix = ''
|
@command_prefix = ''
|
||||||
self.directory = Dir.pwd
|
self.directory = Dir.pwd
|
||||||
@run_quickly = false
|
@run_quickly = false
|
||||||
|
|
|
@ -10,8 +10,7 @@ module UnitTests
|
||||||
def builder_for_record_validating_confirmation_with_18n_message(options = {})
|
def builder_for_record_validating_confirmation_with_18n_message(options = {})
|
||||||
builder = builder_for_record_validating_confirmation(options)
|
builder = builder_for_record_validating_confirmation(options)
|
||||||
RecordBuilderWithI18nValidationMessage.new(builder,
|
RecordBuilderWithI18nValidationMessage.new(builder,
|
||||||
validation_message_key: :confirmation,
|
validation_message_key: :confirmation,)
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,7 +27,7 @@ module UnitTests
|
||||||
layout false
|
layout false
|
||||||
define_method(action, &block)
|
define_method(action, &block)
|
||||||
end
|
end
|
||||||
controller_class.view_paths = [ $test_app.temp_views_directory.to_s ]
|
controller_class.view_paths = [$test_app.temp_views_directory.to_s]
|
||||||
|
|
||||||
define_routes do
|
define_routes do
|
||||||
get 'examples', to: "examples##{action}"
|
get 'examples', to: "examples##{action}"
|
||||||
|
|
|
@ -60,7 +60,7 @@ describe Shoulda::Matchers::ActionController::RenderTemplateMatcher, type: :cont
|
||||||
context 'a controller that renders a partial several times' do
|
context 'a controller that renders a partial several times' do
|
||||||
it 'accepts rendering that partial twice' do
|
it 'accepts rendering that partial twice' do
|
||||||
controller = build_fake_response(partial: '_customer') do
|
controller = build_fake_response(partial: '_customer') do
|
||||||
render partial: 'customer', collection: [1,2]
|
render partial: 'customer', collection: [1, 2]
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(controller).to render_template(partial: '_customer', count: 2)
|
expect(controller).to render_template(partial: '_customer', count: 2)
|
||||||
|
|
|
@ -23,7 +23,6 @@ describe Shoulda::Matchers::ActionController::RenderWithLayoutMatcher, type: :co
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'a controller that renders without a layout' do
|
context 'a controller that renders without a layout' do
|
||||||
|
|
||||||
it 'rejects rendering with a layout' do
|
it 'rejects rendering with a layout' do
|
||||||
controller_without_layout = build_fake_response { render layout: false }
|
controller_without_layout = build_fake_response { render layout: false }
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'unit_spec_helper'
|
||||||
|
|
||||||
describe Shoulda::Matchers::ActionController::RespondWithMatcher, type: :controller do
|
describe Shoulda::Matchers::ActionController::RespondWithMatcher, type: :controller do
|
||||||
statuses = { success: 200, redirect: 301, missing: 404, error: 500,
|
statuses = { success: 200, redirect: 301, missing: 404, error: 500,
|
||||||
not_implemented: 501, }
|
not_implemented: 501, }
|
||||||
|
|
||||||
statuses.each do |human_name, numeric_code|
|
statuses.each do |human_name, numeric_code|
|
||||||
context "a controller responding with #{human_name}" do
|
context "a controller responding with #{human_name}" do
|
||||||
|
|
|
@ -19,7 +19,7 @@ describe Shoulda::Matchers::ActionController::RouteParams, type: :controller do
|
||||||
context 'when the route params is a string' do
|
context 'when the route params is a string' do
|
||||||
it 'produces a hash of route params' do
|
it 'produces a hash of route params' do
|
||||||
expect(build_route_params('examples#index').normalize).
|
expect(build_route_params('examples#index').normalize).
|
||||||
to eq({ controller: 'examples', action: 'index'})
|
to eq({ controller: 'examples', action: 'index' })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,7 +33,7 @@ describe Shoulda::Matchers::ActiveModel::AllowMassAssignmentOfMatcher, type: :mo
|
||||||
context 'an attribute that is not whitelisted for mass-assignment' do
|
context 'an attribute that is not whitelisted for mass-assignment' do
|
||||||
it 'rejects being mass-assignable' do
|
it 'rejects being mass-assignable' do
|
||||||
model = define_model(:example, not_whitelisted: :string,
|
model = define_model(:example, not_whitelisted: :string,
|
||||||
whitelisted: :string,) do
|
whitelisted: :string,) do
|
||||||
attr_accessible :whitelisted
|
attr_accessible :whitelisted
|
||||||
end.new
|
end.new
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ describe Shoulda::Matchers::ActiveModel::AllowMassAssignmentOfMatcher, type: :mo
|
||||||
context 'an attribute not included in the mass-assignment blacklist' do
|
context 'an attribute not included in the mass-assignment blacklist' do
|
||||||
it 'accepts being mass-assignable' do
|
it 'accepts being mass-assignable' do
|
||||||
model = define_model(:example, not_blacklisted: :string,
|
model = define_model(:example, not_blacklisted: :string,
|
||||||
blacklisted: :string,) do
|
blacklisted: :string,) do
|
||||||
attr_protected :blacklisted
|
attr_protected :blacklisted
|
||||||
end.new
|
end.new
|
||||||
|
|
||||||
|
|
|
@ -464,7 +464,7 @@ indeed invalid, but it produced these validation errors instead:
|
||||||
validates_presence_of :attr
|
validates_presence_of :attr
|
||||||
validates_length_of :attr, within: 1..5
|
validates_length_of :attr, within: 1..5
|
||||||
validates_numericality_of :attr, greater_than_or_equal_to: 1,
|
validates_numericality_of :attr, greater_than_or_equal_to: 1,
|
||||||
less_than_or_equal_to: 50000
|
less_than_or_equal_to: 50000
|
||||||
end.new
|
end.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -784,7 +784,7 @@ that attribute does not exist.
|
||||||
message = <<-MESSAGE.rstrip
|
message = <<-MESSAGE.rstrip
|
||||||
The matcher attempted to set :nonexistent on the Example to "some
|
The matcher attempted to set :nonexistent on the Example to "some
|
||||||
value", but that attribute does not exist.
|
value", but that attribute does not exist.
|
||||||
MESSAGE
|
MESSAGE
|
||||||
|
|
||||||
expect(&assertion).to raise_error(
|
expect(&assertion).to raise_error(
|
||||||
described_class::AttributeDoesNotExistError,
|
described_class::AttributeDoesNotExistError,
|
||||||
|
@ -810,7 +810,7 @@ value", but that attribute does not exist.
|
||||||
message = <<-MESSAGE.rstrip
|
message = <<-MESSAGE.rstrip
|
||||||
The matcher attempted to set :nonexistent on the Example to "some
|
The matcher attempted to set :nonexistent on the Example to "some
|
||||||
value", but that attribute does not exist.
|
value", but that attribute does not exist.
|
||||||
MESSAGE
|
MESSAGE
|
||||||
|
|
||||||
expect(&assertion).to raise_error(
|
expect(&assertion).to raise_error(
|
||||||
described_class::AttributeDoesNotExistError,
|
described_class::AttributeDoesNotExistError,
|
||||||
|
|
|
@ -37,8 +37,7 @@ describe Shoulda::Matchers::ActiveModel::DisallowValueMatcher, type: :model do
|
||||||
|
|
||||||
it "delegates its failure message to its allow matcher's negative failure message" do
|
it "delegates its failure message to its allow matcher's negative failure message" do
|
||||||
allow_matcher = double('allow_matcher',
|
allow_matcher = double('allow_matcher',
|
||||||
failure_message_when_negated: 'allow matcher failure',
|
failure_message_when_negated: 'allow matcher failure',).as_null_object
|
||||||
).as_null_object
|
|
||||||
allow(Shoulda::Matchers::ActiveModel::AllowValueMatcher).
|
allow(Shoulda::Matchers::ActiveModel::AllowValueMatcher).
|
||||||
to receive(:new).
|
to receive(:new).
|
||||||
and_return(allow_matcher)
|
and_return(allow_matcher)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
require 'unit_spec_helper'
|
require 'unit_spec_helper'
|
||||||
|
|
||||||
describe Shoulda::Matchers::ActiveModel::Helpers do
|
describe Shoulda::Matchers::ActiveModel::Helpers do
|
||||||
|
@ -81,7 +82,7 @@ describe Shoulda::Matchers::ActiveModel::Helpers do
|
||||||
context 'if ActiveModel::Errors#generate_message behavior has changed' do
|
context 'if ActiveModel::Errors#generate_message behavior has changed' do
|
||||||
it 'provides the right error message for validate_presence_of' do
|
it 'provides the right error message for validate_presence_of' do
|
||||||
stub_active_model_message_generation(type: :blank,
|
stub_active_model_message_generation(type: :blank,
|
||||||
message: 'Behavior has diverged.',)
|
message: 'Behavior has diverged.',)
|
||||||
assert_presence_validation_has_correct_message
|
assert_presence_validation_has_correct_message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -101,7 +102,7 @@ describe Shoulda::Matchers::ActiveModel::Helpers do
|
||||||
expect(record).to validate_length_of(:attr).is_equal_to(40)
|
expect(record).to validate_length_of(:attr).is_equal_to(40)
|
||||||
end
|
end
|
||||||
|
|
||||||
def store_translations(options = {without: []})
|
def store_translations(options = { without: [] })
|
||||||
options[:without] = Array.wrap(options[:without] || [])
|
options[:without] = Array.wrap(options[:without] || [])
|
||||||
|
|
||||||
translations = {
|
translations = {
|
||||||
|
|
|
@ -203,7 +203,7 @@ could not be proved.
|
||||||
|
|
||||||
it 'does not raise an exception' do
|
it 'does not raise an exception' do
|
||||||
stub_translation('activerecord.errors.messages.present',
|
stub_translation('activerecord.errors.messages.present',
|
||||||
'%{attribute} must be blank in a %{model}',)
|
'%{attribute} must be blank in a %{model}',)
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
expect(validating_absence_of(:attr)).to validate_absence_of(:attr)
|
expect(validating_absence_of(:attr)).to validate_absence_of(:attr)
|
||||||
|
|
|
@ -105,7 +105,7 @@ to ‹5›, but this could not be proved.
|
||||||
it 'accepts ensuring the correct range with an interpolated variable in the message' do
|
it 'accepts ensuring the correct range with an interpolated variable in the message' do
|
||||||
matcher = validating_exclusion(in: 2..4, message: '%{value} is not good')
|
matcher = validating_exclusion(in: 2..4, message: '%{value} is not good')
|
||||||
expect(matcher).
|
expect(matcher).
|
||||||
to validate_exclusion_of(:attr).
|
to validate_exclusion_of(:attr).
|
||||||
in_range(2..4).
|
in_range(2..4).
|
||||||
with_message(/^[234] is not good$/)
|
with_message(/^[234] is not good$/)
|
||||||
end
|
end
|
||||||
|
@ -203,7 +203,7 @@ but this could not be proved.
|
||||||
this test is failing. If you've overridden the writer method for this
|
this test is failing. If you've overridden the writer method for this
|
||||||
attribute, then you may need to change it to make this test pass, or
|
attribute, then you may need to change it to make this test pass, or
|
||||||
do something else entirely.
|
do something else entirely.
|
||||||
MESSAGE
|
MESSAGE
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
model_creator: :active_model,
|
model_creator: :active_model,
|
||||||
|
|
|
@ -241,7 +241,8 @@ could not be proved.
|
||||||
before do
|
before do
|
||||||
stub_translation(
|
stub_translation(
|
||||||
'activerecord.errors.messages.too_long',
|
'activerecord.errors.messages.too_long',
|
||||||
'The %{attribute} of your %{model} is too long (maximum is %{count} characters)',)
|
'The %{attribute} of your %{model} is too long (maximum is %{count} characters)',
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not raise an exception' do
|
it 'does not raise an exception' do
|
||||||
|
@ -256,7 +257,8 @@ could not be proved.
|
||||||
before do
|
before do
|
||||||
stub_translation(
|
stub_translation(
|
||||||
'activerecord.errors.messages.too_short',
|
'activerecord.errors.messages.too_short',
|
||||||
'The %{attribute} of your %{model} is too short (minimum is %{count} characters)',)
|
'The %{attribute} of your %{model} is too short (minimum is %{count} characters)',
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not raise an exception' do
|
it 'does not raise an exception' do
|
||||||
|
@ -270,7 +272,8 @@ could not be proved.
|
||||||
before do
|
before do
|
||||||
stub_translation(
|
stub_translation(
|
||||||
'activerecord.errors.messages.wrong_length',
|
'activerecord.errors.messages.wrong_length',
|
||||||
'The %{attribute} of your %{model} is the wrong length (should be %{count} characters)',)
|
'The %{attribute} of your %{model} is the wrong length (should be %{count} characters)',
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not raise an exception' do
|
it 'does not raise an exception' do
|
||||||
|
|
|
@ -886,7 +886,8 @@ could not be proved.
|
||||||
before do
|
before do
|
||||||
stub_translation(
|
stub_translation(
|
||||||
'activerecord.errors.messages.blank',
|
'activerecord.errors.messages.blank',
|
||||||
'Please enter a %{attribute} for your %{model}',)
|
'Please enter a %{attribute} for your %{model}',
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
after { I18n.backend.reload! }
|
after { I18n.backend.reload! }
|
||||||
|
|
|
@ -858,10 +858,9 @@ describe Shoulda::Matchers::ActiveRecord::AssociationMatcher, type: :model do
|
||||||
|
|
||||||
it 'accepts a valid association with a :through option' do
|
it 'accepts a valid association with a :through option' do
|
||||||
define_model :child
|
define_model :child
|
||||||
define_model :conception, child_id: :integer,
|
define_model :conception, child_id: :integer, parent_id: :integer do
|
||||||
parent_id: :integer do
|
|
||||||
belongs_to :child
|
belongs_to :child
|
||||||
end
|
end
|
||||||
define_model :parent do
|
define_model :parent do
|
||||||
has_many :conceptions
|
has_many :conceptions
|
||||||
has_many :children, through: :conceptions
|
has_many :children, through: :conceptions
|
||||||
|
@ -877,11 +876,9 @@ describe Shoulda::Matchers::ActiveRecord::AssociationMatcher, type: :model do
|
||||||
has_many :children, through: :conceptions
|
has_many :children, through: :conceptions
|
||||||
end
|
end
|
||||||
|
|
||||||
expect { have_many(:children) }
|
expect { have_many(:children) }.not_to match_against(parent_class.new).and_fail_with(<<-MESSAGE)
|
||||||
.not_to match_against(parent_class.new)
|
|
||||||
.and_fail_with(<<-MESSAGE)
|
|
||||||
Expected Parent to have a has_many association called children through conceptions (Could not find the source association(s) "child" or :children in model Conception. Try 'has_many :children, :through => :conceptions, :source => <name>'. Is it one of ?)
|
Expected Parent to have a has_many association called children through conceptions (Could not find the source association(s) "child" or :children in model Conception. Try 'has_many :children, :through => :conceptions, :source => <name>'. Is it one of ?)
|
||||||
MESSAGE
|
MESSAGE
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'accepts a valid association with an :as option' do
|
it 'accepts a valid association with an :as option' do
|
||||||
|
@ -920,7 +917,7 @@ Expected Parent to have a has_many association called children through conceptio
|
||||||
|
|
||||||
it 'rejects an association with a bad :as option' do
|
it 'rejects an association with a bad :as option' do
|
||||||
define_model :child, caretaker_type: :string,
|
define_model :child, caretaker_type: :string,
|
||||||
caretaker_id: :integer
|
caretaker_id: :integer
|
||||||
define_model :parent do
|
define_model :parent do
|
||||||
has_many :children, as: :guardian
|
has_many :children, as: :guardian
|
||||||
end
|
end
|
||||||
|
@ -940,7 +937,7 @@ Expected Parent to have a has_many association called children through conceptio
|
||||||
define_model :child
|
define_model :child
|
||||||
|
|
||||||
define_model :conception, child_id: :integer,
|
define_model :conception, child_id: :integer,
|
||||||
parent_id: :integer do
|
parent_id: :integer do
|
||||||
belongs_to :child
|
belongs_to :child
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1251,7 +1248,7 @@ Expected Parent to have a has_many association called children through conceptio
|
||||||
|
|
||||||
it 'accepts a valid association with an :as option' do
|
it 'accepts a valid association with an :as option' do
|
||||||
define_model :detail, detailable_id: :integer,
|
define_model :detail, detailable_id: :integer,
|
||||||
detailable_type: :string
|
detailable_type: :string
|
||||||
define_model :person do
|
define_model :person do
|
||||||
has_one :detail, as: :detailable
|
has_one :detail, as: :detailable
|
||||||
end
|
end
|
||||||
|
@ -1294,7 +1291,7 @@ Expected Parent to have a has_many association called children through conceptio
|
||||||
|
|
||||||
it 'rejects an association with a bad :as option' do
|
it 'rejects an association with a bad :as option' do
|
||||||
define_model :detail, detailable_id: :integer,
|
define_model :detail, detailable_id: :integer,
|
||||||
detailable_type: :string
|
detailable_type: :string
|
||||||
define_model :person do
|
define_model :person do
|
||||||
has_one :detail, as: :describable
|
has_one :detail, as: :describable
|
||||||
end
|
end
|
||||||
|
@ -1442,7 +1439,6 @@ Expected Parent to have a has_many association called children through conceptio
|
||||||
}.to fail_with_message(message)
|
}.to fail_with_message(message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
it 'accepts an association with a through' do
|
it 'accepts an association with a through' do
|
||||||
define_model :detail
|
define_model :detail
|
||||||
|
|
||||||
|
@ -1539,7 +1535,7 @@ Expected Parent to have a has_many association called children through conceptio
|
||||||
define_model :relative
|
define_model :relative
|
||||||
define_model :person
|
define_model :person
|
||||||
define_model :people_relative, id: false, person_id: :integer,
|
define_model :people_relative, id: false, person_id: :integer,
|
||||||
relative_id: :integer
|
relative_id: :integer
|
||||||
|
|
||||||
expect(Person.new).not_to have_and_belong_to_many(:relatives)
|
expect(Person.new).not_to have_and_belong_to_many(:relatives)
|
||||||
end
|
end
|
||||||
|
@ -1967,19 +1963,17 @@ Expected Person to have a has_and_belongs_to_many association called relatives (
|
||||||
define_model :relative
|
define_model :relative
|
||||||
define_model :person do
|
define_model :person do
|
||||||
has_and_belongs_to_many :relatives,
|
has_and_belongs_to_many :relatives,
|
||||||
foreign_key: :some_foreign_key_id,
|
foreign_key: :some_foreign_key_id,
|
||||||
association_foreign_key: :custom_association_foreign_key_id
|
association_foreign_key: :custom_association_foreign_key_id
|
||||||
end
|
end
|
||||||
|
|
||||||
define_model :people_relative,
|
define_model :people_relative,
|
||||||
id: false,
|
id: false,
|
||||||
custom_association_foreign_key_id: :integer,
|
custom_association_foreign_key_id: :integer,
|
||||||
some_foreign_key_id: :integer
|
some_foreign_key_id: :integer
|
||||||
|
|
||||||
expect(Person.new).to have_and_belong_to_many(:relatives)
|
expect(Person.new).to have_and_belong_to_many(:relatives)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'rejects an association of the wrong type' do
|
it 'rejects an association of the wrong type' do
|
||||||
|
@ -1997,7 +1991,7 @@ Expected Person to have a has_and_belongs_to_many association called relatives (
|
||||||
define_association_with_conditions(model, :has_and_belongs_to_many, :relatives, adopted: true)
|
define_association_with_conditions(model, :has_and_belongs_to_many, :relatives, adopted: true)
|
||||||
end
|
end
|
||||||
define_model :people_relative, id: false, person_id: :integer,
|
define_model :people_relative, id: false, person_id: :integer,
|
||||||
relative_id: :integer
|
relative_id: :integer
|
||||||
|
|
||||||
expect(Person.new).to have_and_belong_to_many(:relatives).conditions(adopted: true)
|
expect(Person.new).to have_and_belong_to_many(:relatives).conditions(adopted: true)
|
||||||
end
|
end
|
||||||
|
@ -2008,7 +2002,7 @@ Expected Person to have a has_and_belongs_to_many association called relatives (
|
||||||
has_and_belongs_to_many :relatives
|
has_and_belongs_to_many :relatives
|
||||||
end
|
end
|
||||||
define_model :people_relative, id: false, person_id: :integer,
|
define_model :people_relative, id: false, person_id: :integer,
|
||||||
relative_id: :integer
|
relative_id: :integer
|
||||||
|
|
||||||
expect(Person.new).not_to have_and_belong_to_many(:relatives).conditions(adopted: true)
|
expect(Person.new).not_to have_and_belong_to_many(:relatives).conditions(adopted: true)
|
||||||
end
|
end
|
||||||
|
@ -2025,7 +2019,7 @@ Expected Person to have a has_and_belongs_to_many association called relatives (
|
||||||
end
|
end
|
||||||
|
|
||||||
define_model :people_person_relative, person_id: :integer,
|
define_model :people_person_relative, person_id: :integer,
|
||||||
person_relative_id: :integer
|
person_relative_id: :integer
|
||||||
|
|
||||||
expect(Person.new).to have_and_belong_to_many(:relatives).class_name('PersonRelative')
|
expect(Person.new).to have_and_belong_to_many(:relatives).class_name('PersonRelative')
|
||||||
end
|
end
|
||||||
|
@ -2141,7 +2135,7 @@ Expected Person to have a has_and_belongs_to_many association called relatives (
|
||||||
def having_and_belonging_to_many_relatives(options = {})
|
def having_and_belonging_to_many_relatives(options = {})
|
||||||
define_model :relative
|
define_model :relative
|
||||||
define_model :people_relative, id: false, person_id: :integer,
|
define_model :people_relative, id: false, person_id: :integer,
|
||||||
relative_id: :integer
|
relative_id: :integer
|
||||||
define_model :person do
|
define_model :person do
|
||||||
has_and_belongs_to_many :relatives
|
has_and_belongs_to_many :relatives
|
||||||
end.new
|
end.new
|
||||||
|
@ -2154,7 +2148,7 @@ Expected Person to have a has_and_belongs_to_many association called relatives (
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def define_association_with_conditions(model, macro, name, conditions, other_options={})
|
def define_association_with_conditions(model, macro, name, conditions, other_options = {})
|
||||||
args = []
|
args = []
|
||||||
options = {}
|
options = {}
|
||||||
if active_record_supports_relations?
|
if active_record_supports_relations?
|
||||||
|
|
|
@ -71,11 +71,11 @@ describe Shoulda::Matchers::ActiveRecord::HaveRichTextMatcher, type: :model do
|
||||||
|
|
||||||
def new_post(has_invalid_content: false, is_rich_text_association: false)
|
def new_post(has_invalid_content: false, is_rich_text_association: false)
|
||||||
columns = {}
|
columns = {}
|
||||||
|
|
||||||
if has_invalid_content
|
if has_invalid_content
|
||||||
columns[:invalid_content] = :string
|
columns[:invalid_content] = :string
|
||||||
end
|
end
|
||||||
|
|
||||||
define_model 'Post', columns do
|
define_model 'Post', columns do
|
||||||
if is_rich_text_association
|
if is_rich_text_association
|
||||||
has_rich_text :content
|
has_rich_text :content
|
||||||
|
|
|
@ -3,7 +3,6 @@ require 'unit_spec_helper'
|
||||||
# rubocop:disable Metrics/BlockLength
|
# rubocop:disable Metrics/BlockLength
|
||||||
describe Shoulda::Matchers::ActiveRecord::HaveSecureTokenMatcher,
|
describe Shoulda::Matchers::ActiveRecord::HaveSecureTokenMatcher,
|
||||||
type: :model do
|
type: :model do
|
||||||
|
|
||||||
if active_record_supports_has_secure_token?
|
if active_record_supports_has_secure_token?
|
||||||
describe '#description' do
|
describe '#description' do
|
||||||
it 'returns the message including the name of the default column' do
|
it 'returns the message including the name of the default column' do
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe Shoulda::Matchers::ActiveRecord::ValidateUniquenessOfMatcher, type: :mo
|
||||||
|
|
||||||
it 'still accepts if the scope is unset beforehand' do
|
it 'still accepts if the scope is unset beforehand' do
|
||||||
record = build_record_validating_uniqueness(
|
record = build_record_validating_uniqueness(
|
||||||
scopes: [ build_attribute(name: :scope, value: nil) ],
|
scopes: [build_attribute(name: :scope, value: nil)],
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(record).to validate_uniqueness.scoped_to(:scope)
|
expect(record).to validate_uniqueness.scoped_to(:scope)
|
||||||
|
@ -41,7 +41,7 @@ describe Shoulda::Matchers::ActiveRecord::ValidateUniquenessOfMatcher, type: :mo
|
||||||
|
|
||||||
it 'still accepts if the scope is unset beforehand' do
|
it 'still accepts if the scope is unset beforehand' do
|
||||||
record = create_record_validating_uniqueness(
|
record = create_record_validating_uniqueness(
|
||||||
scopes: [ build_attribute(name: :scope, value: nil) ],
|
scopes: [build_attribute(name: :scope, value: nil)],
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(record).to validate_uniqueness.scoped_to(:scope)
|
expect(record).to validate_uniqueness.scoped_to(:scope)
|
||||||
|
@ -55,7 +55,7 @@ describe Shoulda::Matchers::ActiveRecord::ValidateUniquenessOfMatcher, type: :mo
|
||||||
value2 = next_version_of(value1, value_type)
|
value2 = next_version_of(value1, value_type)
|
||||||
value3 = next_version_of(value2, value_type)
|
value3 = next_version_of(value2, value_type)
|
||||||
model = define_model_validating_uniqueness(
|
model = define_model_validating_uniqueness(
|
||||||
scopes: [ build_attribute(name: :scope) ],
|
scopes: [build_attribute(name: :scope)],
|
||||||
)
|
)
|
||||||
create_record_from(model, scope: value2)
|
create_record_from(model, scope: value2)
|
||||||
create_record_from(model, scope: value3)
|
create_record_from(model, scope: value3)
|
||||||
|
@ -122,7 +122,7 @@ within the scope of :scope1, but this could not be proved.
|
||||||
context 'when a different scope is specified' do
|
context 'when a different scope is specified' do
|
||||||
it 'rejects with an appropriate failure message' do
|
it 'rejects with an appropriate failure message' do
|
||||||
record = build_record_validating_uniqueness(
|
record = build_record_validating_uniqueness(
|
||||||
scopes: [ build_attribute(name: :other) ],
|
scopes: [build_attribute(name: :other)],
|
||||||
additional_attributes: [:scope],
|
additional_attributes: [:scope],
|
||||||
)
|
)
|
||||||
assertion = lambda do
|
assertion = lambda do
|
||||||
|
@ -145,7 +145,7 @@ within the scope of :scope, but this could not be proved.
|
||||||
context 'when no scope is specified' do
|
context 'when no scope is specified' do
|
||||||
it 'rejects with an appropriate failure message' do
|
it 'rejects with an appropriate failure message' do
|
||||||
record = build_record_validating_uniqueness(
|
record = build_record_validating_uniqueness(
|
||||||
scopes: [ build_attribute(name: :scope) ],
|
scopes: [build_attribute(name: :scope)],
|
||||||
)
|
)
|
||||||
|
|
||||||
assertion = lambda do
|
assertion = lambda do
|
||||||
|
@ -165,7 +165,7 @@ this could not be proved.
|
||||||
context 'if the scope attribute is unset in the record given to the matcher' do
|
context 'if the scope attribute is unset in the record given to the matcher' do
|
||||||
it 'rejects with an appropriate failure message' do
|
it 'rejects with an appropriate failure message' do
|
||||||
record = build_record_validating_uniqueness(
|
record = build_record_validating_uniqueness(
|
||||||
scopes: [ build_attribute(name: :scope, value: nil) ],
|
scopes: [build_attribute(name: :scope, value: nil)],
|
||||||
)
|
)
|
||||||
|
|
||||||
assertion = lambda do
|
assertion = lambda do
|
||||||
|
@ -188,7 +188,7 @@ this could not be proved.
|
||||||
context 'when there is more than one scope' do
|
context 'when there is more than one scope' do
|
||||||
it 'rejects with an appropriate failure message (and does not raise an error)' do
|
it 'rejects with an appropriate failure message (and does not raise an error)' do
|
||||||
record = build_record_validating_uniqueness(
|
record = build_record_validating_uniqueness(
|
||||||
scopes: [ build_attribute(name: :scope) ],
|
scopes: [build_attribute(name: :scope)],
|
||||||
)
|
)
|
||||||
|
|
||||||
assertion = lambda do
|
assertion = lambda do
|
||||||
|
@ -208,7 +208,7 @@ within the scope of :non_existent, but this could not be proved.
|
||||||
context 'when there is more than one scope' do
|
context 'when there is more than one scope' do
|
||||||
it 'rejects with an appropriate failure message (and does not raise an error)' do
|
it 'rejects with an appropriate failure message (and does not raise an error)' do
|
||||||
record = build_record_validating_uniqueness(
|
record = build_record_validating_uniqueness(
|
||||||
scopes: [ build_attribute(name: :scope) ],
|
scopes: [build_attribute(name: :scope)],
|
||||||
)
|
)
|
||||||
|
|
||||||
assertion = lambda do
|
assertion = lambda do
|
||||||
|
@ -1548,7 +1548,7 @@ this could not be proved.
|
||||||
|
|
||||||
def next_version_of(value, value_type)
|
def next_version_of(value, value_type)
|
||||||
if value.is_a?(Array)
|
if value.is_a?(Array)
|
||||||
[ next_version_of(value[0], value_type) ]
|
[next_version_of(value[0], value_type)]
|
||||||
elsif value_type == :uuid
|
elsif value_type == :uuid
|
||||||
SecureRandom.uuid
|
SecureRandom.uuid
|
||||||
elsif value.is_a?(Time)
|
elsif value.is_a?(Time)
|
||||||
|
@ -1632,7 +1632,7 @@ this could not be proved.
|
||||||
options = options.dup
|
options = options.dup
|
||||||
enum_scope_attribute =
|
enum_scope_attribute =
|
||||||
normalize_attribute(options.delete(:enum_scope)).
|
normalize_attribute(options.delete(:enum_scope)).
|
||||||
merge(value_type: :integer, column_type: :integer)
|
merge(value_type: :integer, column_type: :integer)
|
||||||
additional_scopes = options.delete(:additional_scopes) { [] }
|
additional_scopes = options.delete(:additional_scopes) { [] }
|
||||||
options[:scopes] = [enum_scope_attribute] + additional_scopes
|
options[:scopes] = [enum_scope_attribute] + additional_scopes
|
||||||
dummy_enum_values = [:foo, :bar]
|
dummy_enum_values = [:foo, :bar]
|
||||||
|
|
|
@ -186,8 +186,7 @@ module Shoulda::Matchers::Doublespeak
|
||||||
object: instance,
|
object: instance,
|
||||||
method_name: method_name,
|
method_name: method_name,
|
||||||
args: expected_args,
|
args: expected_args,
|
||||||
block: expected_block,
|
block: expected_block,)
|
||||||
)
|
|
||||||
double = described_class.new(
|
double = described_class.new(
|
||||||
world,
|
world,
|
||||||
klass,
|
klass,
|
||||||
|
|
|
@ -610,6 +610,7 @@ to account for when #country *was* nil.
|
||||||
|
|
||||||
def hello
|
def hello
|
||||||
return unless country
|
return unless country
|
||||||
|
|
||||||
country.hello
|
country.hello
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ require 'spec_helper'
|
||||||
|
|
||||||
$VERBOSE = true
|
$VERBOSE = true
|
||||||
|
|
||||||
Dir[ File.join(File.expand_path('support/unit/**/*.rb', __dir__)) ].sort.each do |file|
|
Dir[File.join(File.expand_path('support/unit/**/*.rb', __dir__))].sort.each do |file|
|
||||||
require file
|
require file
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue