Sha256: 2793cb89b8f0216c5d971be763540dbe74f559f5ced37096a6f2848cb3fe50ea

Contents?: true

Size: 1.09 KB

Versions: 8

Compression:

Stored size: 1.09 KB

Contents

require "#{File.dirname(__FILE__)}/spec_helper"


shared_examples_for 'a queriable object' do

  # clazz and seed_arguments must be defined by the calling file

  let(:object) { (defined? seed_arguments) ? clazz.new(seed_arguments) : clazz.new }


  it 'has a query root' do
    expect(object).to respond_to(:query_root)
  end

  it 'can change its query root' do
    expect(object).to respond_to(:query_root=)

    object.query_root = :some_query_root
    expect(object.query_root).to eq(:some_query_root)
    object.query_root = :some_other_query_root
    expect(object.query_root).to eq(:some_other_query_root)
  end

  it 'can be queried' do
    expect(object).to respond_to(:query)
  end

  it 'complains if a query is attempted without a query root being set' do
    object.query_root = nil

    expect {

      object.query do
        select :model
        from :all
      end

    }.to raise_error(ArgumentError, 'Query cannot be run. No query root has been set.')
  end

  it 'starts with a query root' do
    expect(object.query_root).to_not be_nil
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cql-1.7.0 testing/rspec/spec/queriable_specs.rb
cql-1.6.0 testing/rspec/spec/queriable_specs.rb
cql-1.5.1 testing/rspec/spec/queriable_specs.rb
cql-1.5.0 testing/rspec/spec/queriable_specs.rb
cql-1.4.2 testing/rspec/spec/queriable_specs.rb
cql-1.4.1 testing/rspec/spec/queriable_specs.rb
cql-1.4.0 testing/rspec/spec/queriable_specs.rb
cql-1.3.0 testing/rspec/spec/queriable_specs.rb