Sha256: 6a332e80923cba76a6e954f66135a9347dd542af820c33f1dc51eea8f1e8c6fb

Contents?: true

Size: 970 Bytes

Versions: 7

Compression:

Stored size: 970 Bytes

Contents

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

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
    value.should == '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
    value.should == 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
    value.should == '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

7 entries across 7 versions & 3 rubygems

Version Path
erichummel-sunspot-1.2.1g spec/api/binding_spec.rb
erichummel-sunspot-1.2.1f spec/api/binding_spec.rb
erichummel-sunspot-1.2.1b spec/api/binding_spec.rb
erichummel-sunspot-1.2.1a spec/api/binding_spec.rb
lisausa-sunspot-1.2.1.1 spec/api/binding_spec.rb
sunspot-1.2.1 spec/api/binding_spec.rb
sunspot-1.2.0 spec/api/binding_spec.rb