Sha256: c78dbbcf2575b0a2a7c116b6ed050f2cab5422f32c3f4a389daf43cd40f7f70a

Contents?: true

Size: 1.43 KB

Versions: 17

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

require_relative './operators/eq'
require_relative './operators/ne'
require_relative './operators/in'
require_relative './operators/nin'

(WCC::Contentful::Store::Query::Interface::OPERATORS -
  %i[eq ne in nin]).each do |op|
    RSpec.shared_examples "supports :#{op} operator" do
      it 'TODO'
    end
  end

RSpec.shared_examples 'operators' do |feature_set|
  supported_operators =
    if feature_set.nil?
      WCC::Contentful::Store::Query::Interface::OPERATORS
        .each_with_object({}) { |k, h| h[k] = 'pending' }
    elsif feature_set.is_a?(Array)
      WCC::Contentful::Store::Query::Interface::OPERATORS
        .each_with_object({}) { |k, h| h[k] = feature_set.include?(k.to_sym) }
    elsif feature_s.is_a?(Hash)
      feature_set
    else
      raise ArgumentError, 'Please provide a hash or array of operators to test'
    end

  supported_operators.each do |op, value|
    next if value

    it "does not support :#{op}" do
      expect {
        subject.find_all(content_type: 'test')
          .apply('name' => { op => 'test' })
          .to_a
      }.to raise_error do |ex|
        expect(ex.to_s).to match(/not supported/)
      end
    end
  end

  supported_operators.each do |op, value| # rubocop:disable Style/CombinableLoops
    next unless value

    it_behaves_like "supports :#{op} operator" do
      before { pending(":#{op} operator to be implemented") } if value == 'pending'
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
wcc-contentful-1.7.2 lib/wcc/contentful/store/rspec_examples/operators.rb
wcc-contentful-1.7.1 lib/wcc/contentful/store/rspec_examples/operators.rb
wcc-contentful-1.7.0 lib/wcc/contentful/store/rspec_examples/operators.rb
wcc-contentful-1.6.2 lib/wcc/contentful/store/rspec_examples/operators.rb
wcc-contentful-1.6.1 lib/wcc/contentful/store/rspec_examples/operators.rb
wcc-contentful-1.6.0 lib/wcc/contentful/store/rspec_examples/operators.rb
wcc-contentful-1.5.1 lib/wcc/contentful/store/rspec_examples/operators.rb
wcc-contentful-1.5.0 lib/wcc/contentful/store/rspec_examples/operators.rb
wcc-contentful-1.5.0.rc1 lib/wcc/contentful/store/rspec_examples/operators.rb
wcc-contentful-1.4.0 lib/wcc/contentful/store/rspec_examples/operators.rb
wcc-contentful-1.4.0.rc3 lib/wcc/contentful/store/rspec_examples/operators.rb
wcc-contentful-1.4.0.rc2 lib/wcc/contentful/store/rspec_examples/operators.rb
wcc-contentful-1.3.2 lib/wcc/contentful/store/rspec_examples/operators.rb
wcc-contentful-1.4.0.rc1 lib/wcc/contentful/store/rspec_examples/operators.rb
wcc-contentful-1.3.1 lib/wcc/contentful/store/rspec_examples/operators.rb
wcc-contentful-1.3.0 lib/wcc/contentful/store/rspec_examples/operators.rb
wcc-contentful-1.2.1 lib/wcc/contentful/store/rspec_examples/operators.rb