Sha256: cf9494f2b696e9e6c6ad502f110f2396a4f331050447cce5eec1a1c0d6c6ee07

Contents?: true

Size: 784 Bytes

Versions: 5

Compression:

Stored size: 784 Bytes

Contents

require 'rom/elasticsearch/plugins/relation/query_dsl'
require 'rom/elasticsearch/relation'

RSpec.describe ROM::Elasticsearch::Relation, '#search' do
  subject(:relation) { relations[:users] }

  include_context 'setup'

  before do
    conf.relation(:users) do
      schema do
        attribute :id, ROM::Types::Int.meta(type: "integer")
        attribute :name, ROM::Types::Int.meta(type: "text")
      end

      use :query_dsl
    end

    relation.command(:create).(id: 1, name: 'Jane')
    relation.command(:create).(id: 2, name: 'John')

    relation.refresh
  end

  it 'builds a query using a block-based DSL' do
    result = relation.search do
      query do
        match name: 'Jane'
      end
    end

    expect(result.to_a).to eql([{ id: 1, name: 'Jane' }])
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rom-elasticsearch-0.3.0 spec/unit/rom/elasticsearch/plugins/relation/query_dsl_spec.rb
rom-elasticsearch-0.2.1 spec/unit/rom/elasticsearch/plugins/relation/query_dsl_spec.rb
rom-elasticsearch-0.2.0 spec/unit/rom/elasticsearch/plugins/relation/query_dsl_spec.rb
rom-elasticsearch-0.1.1 spec/unit/rom/elasticsearch/plugins/relation/query_dsl_spec.rb
rom-elasticsearch-0.1.0 spec/unit/rom/elasticsearch/plugins/relation/query_dsl_spec.rb