have_fields RSpec匹配器在哪里定义? [英] Where is the have_fields RSpec matcher defined?

查看:93
本文介绍了have_fields RSpec匹配器在哪里定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关使用rspec的最新问题一些带有have_fields匹配器的代码.

A recent question on using rspec featured some code with a have_fields matcher in it.

搜索表明have_fieldsmongoid-rspec gem中被引用,但是当我转到GitHub时,我只能在spec文件中找到它.

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.

对RSpec核心和相关宝石的类似搜索也为空.

Similar searches of RSpec core and related gems came up empty as well.

推荐答案

您可能正在寻找 mongoid-迷你测试宝石.

have_field.rb 它声明have_fields作为别名:

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)

这篇关于have_fields RSpec匹配器在哪里定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆