Sha256: 59f30c507f4e7e38908d0c167e43c9ad006c958098a094afc3127c468651ec25

Contents?: true

Size: 1.23 KB

Versions: 19

Compression:

Stored size: 1.23 KB

Contents

RSpec::Matchers.define :be_infix_operator do |operator|
  match { |node| node.kind_of?(ScopedSearch::QueryLanguage::AST::OperatorNode) && node.infix? && (operator.nil? || operator == node.operator) }
end

RSpec::Matchers.define :be_prefix_operator do |operator|
  match { |node| node.kind_of?(ScopedSearch::QueryLanguage::AST::OperatorNode) && node.prefix? && (operator.nil? || operator == node.operator) }
end

RSpec::Matchers.define :be_logical_operator do |operator|
  match { |node| node.kind_of?(ScopedSearch::QueryLanguage::AST::LogicalOperatorNode) && (operator.nil? || operator == node.operator) }
end

RSpec::Matchers.define :be_leaf_node do |value|
  match { |node| node.kind_of?(ScopedSearch::QueryLanguage::AST::LeafNode) && (value.nil? || value == node.value) }
end

RSpec::Matchers.define :tokenize_to do |*tokens|
  match { |str| tokens == ScopedSearch::QueryLanguage::Compiler.tokenize(str) }
end

RSpec::Matchers.define :parse_to do |tree|
  match { |str| tree == ScopedSearch::QueryLanguage::Compiler.parse(str).to_a }
end

RSpec::Matchers.define :contain do |*expected|
  match_for_should do |actual|
    expected.all? { |e| actual.include?(e) }
  end

  match_for_should_not do |actual|
    expected.none? { |e| actual.include?(e) }
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
scoped_search-2.7.1 spec/lib/matchers.rb
scoped_search-2.7.0 spec/lib/matchers.rb
scoped_search-2.6.5 spec/lib/matchers.rb
scoped_search-2.6.4 spec/lib/matchers.rb
scoped_search-2.6.3 spec/lib/matchers.rb
scoped_search-2.6.2 spec/lib/matchers.rb
scoped_search-2.6.1 spec/lib/matchers.rb
scoped_search-2.6.0 spec/lib/matchers.rb
scoped_search-2.5.1 spec/lib/matchers.rb
scoped_search-2.5.0 spec/lib/matchers.rb
scoped_search-2.4.1 spec/lib/matchers.rb
scoped_search-2.4.0 spec/lib/matchers.rb
scoped_search-2.3.7 spec/lib/matchers.rb
scoped_search-2.3.6 spec/lib/matchers.rb
scoped_search-2.3.5 spec/lib/matchers.rb
scoped_search-2.3.4 spec/lib/matchers.rb
scoped_search-2.3.3 spec/lib/matchers.rb
scoped_search-2.3.1 spec/lib/matchers.rb
scoped_search-2.3.0 spec/lib/matchers.rb