class FactoryBot::Attribute::NonAttributeWriterValidator
Public Class Methods
new(method_name)
click to toggle source
# File lib/factory_bot/attribute.rb, line 36 def initialize(method_name) @method_name = method_name.to_s @method_name_setter_match = @method_name.match(/(.*)=$/) end
Public Instance Methods
validate!()
click to toggle source
# File lib/factory_bot/attribute.rb, line 41 def validate! if method_is_writer? raise AttributeDefinitionError, error_message end end
Private Instance Methods
attribute_name()
click to toggle source
# File lib/factory_bot/attribute.rb, line 53 def attribute_name @method_name_setter_match[1] end
error_message()
click to toggle source
# File lib/factory_bot/attribute.rb, line 57 def error_message "factory_bot uses '#{attribute_name} value' syntax rather than '#{attribute_name} = value'" end
method_is_writer?()
click to toggle source
# File lib/factory_bot/attribute.rb, line 49 def method_is_writer? !!@method_name_setter_match end