Sha256: ca514bfaa2eafaddf9ab57f9b1647c3643dad15477847eb2db76ab814684d1ca

Contents?: true

Size: 979 Bytes

Versions: 8

Compression:

Stored size: 979 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe 'Matcher.extract_attribute' do
  Dir[File.join(File.dirname(__FILE__), 'extract_attribute_data', '*.yml')].sort.each do |path|
    context File.basename(path) do
      specs = if RUBY_VERSION.start_with?("2.5")
                YAML.safe_load(File.read(path), [], [], true)
              else
                YAML.safe_load(File.read(path), aliases: true)
              end

      specs.each do |spec|
        context spec['name'] do

          if spec['pending']
            pending spec['pending'].to_s
          end

          let(:document) do
            spec['document']
          end

          let(:key) { spec['key'] }

          let(:actual) do
            Mongoid::Matcher.extract_attribute(document, key)
          end

          let(:expected) { spec.fetch('result') }

          it 'has the expected result' do
            actual.should == expected
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mongoid-7.5.4 spec/mongoid/matcher/extract_attribute_spec.rb
mongoid-7.5.3 spec/mongoid/matcher/extract_attribute_spec.rb
mongoid-7.5.2 spec/mongoid/matcher/extract_attribute_spec.rb
mongoid-7.5.1 spec/mongoid/matcher/extract_attribute_spec.rb
mongoid-7.4.3 spec/mongoid/matcher/extract_attribute_spec.rb
mongoid-7.5.0 spec/mongoid/matcher/extract_attribute_spec.rb
mongoid-7.4.1 spec/mongoid/matcher/extract_attribute_spec.rb
mongoid-7.4.0 spec/mongoid/matcher/extract_attribute_spec.rb