thoughtbot/shoulda-matchers · error · ArgumentError
need at least one attribute
Error message
need at least one attribute
What it means
Error "need at least one attribute" thrown in thoughtbot/shoulda-matchers.
Source
Thrown at lib/shoulda/matchers/active_record/normalize_matcher.rb:70
# end
#
# # RSpec
# RSpec.describe User, type: :model do
# it { should normalize(:name).from("jane doe").to("Jane Doe") }
# it { should normalize(:name).from(nil).to("Untitled") }
# end
#
# # Minitest (Shoulda)
# class User < ActiveSupport::TestCase
# should normalize(:name).from("jane doe").to("Jane Doe")
# should normalize(:name).from(nil).to("Untitled")
# end
#
# @return [NormalizeMatcher]
#
def normalize(*attributes)
if attributes.empty?
raise ArgumentError, 'need at least one attribute'
else
NormalizeMatcher.new(*attributes)
end
end
# @private
class NormalizeMatcher
attr_reader :attributes, :from_value, :to_value, :failure_message,
:failure_message_when_negated
def initialize(*attributes)
@attributes = attributes
end
def description
%(
normalize #{attributes.to_sentence(last_word_connector: ' and ')} from
‹#{from_value.inspect}› to ‹#{to_value.inspect}›View on GitHub (pinned to 79cdfbc326)
When it happens
Trigger: Thrown at lib/shoulda/matchers/active_record/normalize_matcher.rb:70 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of thoughtbot/shoulda-matchers@79cdfbc326 (2026-08-23).
Data as JSON: /api/errors/09ffc43b8ee9882a.
Report an issue: GitHub.