Sha256: 62458dcf4d210c50b95bd1ffbd3e07ab21f5cea93da2d8d620834aab43413624

Contents?: true

Size: 992 Bytes

Versions: 5

Compression:

Stored size: 992 Bytes

Contents

require File.expand_path('spec_helper', File.dirname(__FILE__))

describe "DSL bindings" do
  it 'should give access to calling context\'s methods in search DSL' do
    value = nil
    session.search(Post) do
      value = test_method
    end
    expect(value).to eq('value')
  end

  it 'should give access to calling context\'s id method in search DSL' do
    value = nil
    session.search(Post) do
      value = id
    end
    expect(value).to eq(16)
  end

  it 'should give access to calling context\'s methods in nested DSL block' do
    value = nil
    session.search(Post) do
      any_of do
        value = test_method
      end
    end
    expect(value).to eq('value')
  end

  it 'should give access to calling context\'s methods in double-nested DSL block' do
    value = nil
    session.search(Post) do
      any_of do
        all_of do
          value = test_method
        end
      end
    end
  end

  private

  def test_method
    'value'
  end

  def id
    16
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sunspot-2.6.0 spec/api/binding_spec.rb
sunspot-2.5.0 spec/api/binding_spec.rb
sunspot-2.4.0 spec/api/binding_spec.rb
sunspot-2.3.0 spec/api/binding_spec.rb
sunspot-2.2.8 spec/api/binding_spec.rb