Sha256: 3432f0fa0bd6e3fda10debd9b436ab572a1a6779aab7fbc508b7932f1f74bb5d

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

require "spec_helper"

describe Mongoid::Attributes::Projector do
  Dir[File.join(File.dirname(__FILE__), 'projector_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(:projection) do
            spec['projection']
          end

          let(:projector) do
            Mongoid::Attributes::Projector.new(projection)
          end

          spec.fetch('queries').each do |query_spec|
            context query_spec.fetch('query').inspect do
              let(:query) { query_spec['query'] }

              context 'attribute_or_path_allowed?' do
                it "is #{query_spec.fetch('allowed')}" do
                  projector.attribute_or_path_allowed?(query).should be query_spec['allowed']
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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