Sha256: 68a3e4689096e19fb87403aae9d588246f2da952e2940ac662f110beceb64c62

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

require 'integration/spec_helper'

describe Ashikawa::AR::Search do
  before(:all) {
    require 'examples/person.rb'

    Ashikawa::AR.setup :default, ARANGO_HOST
    database = Ashikawa::Core::Database.new ARANGO_HOST
    @collection = database["people"]
    @collection.truncate!
    @johnny = @collection.create name: "Johnny"
    @jens = @collection.create name: "Jens"
  }

  subject { Person }

  it "should find a document by ID" do
    person = subject.find @johnny.id
    person.should be_instance_of subject
    person.name.should == "Johnny"
  end

  it "should find documents by aql query" do
    people = subject.find_by_aql "FOR u IN people RETURN u"
    people.length.should == @collection.length
    people.first.should be_instance_of subject
  end

  it "should find documents by example" do
    people = subject.by_example name: "Johnny"
    people.length.should == 1
    people.first.should be_instance_of subject
    people.first.name.should == "Johnny"
  end

  it "should find one document by example" do
    person = subject.first_example name: "Johnny"
    person.should be_instance_of subject
    person.name.should == "Johnny"
  end

  it "should return all documents" do
    people = subject.all
    people.length.should == @collection.length
    people.first.should be_instance_of subject
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ashikawa-ar-0.1.3 spec/integration/search_spec.rb
ashikawa-ar-0.1.2 spec/integration/search_spec.rb