问题
A recent question on using rspec featured some code with a have_fields
matcher in it.
A search indicated that have_fields
was referenced in the mongoid-rspec
gem, but when I went to GitHub, I could only find it referenced in the spec files.
Similar searches of RSpec core and related gems came up empty as well.
回答1:
You might be looking for the mongoid-minitest gem.
In have_field.rb it declares have_fields
as an alias:
module Mongoid
module Matchers
module Document
# TODO: Add documentation.
def have_field *fields
HaveFieldMatcher.new(*fields)
end
alias :have_fields :have_field
private
class HaveFieldMatcher < Matcher
attr_reader :fields, :klass, :type, :default, :errors
def initialize *fields
@fields = fields.collect(&:to_s)
@errors = []
end
def of_type type
@type = type
self
end
... (rest of file omitted)
来源:https://stackoverflow.com/questions/18152278/where-is-the-have-fields-rspec-matcher-defined