Sha256: 739540678066982ad03a044d78142bb4406dd6266a4159e8b49bb2c7083a8db0

Contents?: true

Size: 851 Bytes

Versions: 4

Compression:

Stored size: 851 Bytes

Contents

require 'pathname'
require Pathname(__FILE__).dirname + "helper"

class User
  include DataMapper::Resource
  property :id, Serial
end

class Photo
  include DataMapper::Resource
  property :uuid, String, :default => lambda { `uuidgen`.chomp }, :key => true
end

describe "FerretAdapter" do
  before :each do
    @index = Pathname(__FILE__).dirname.expand_path + "index"
    DataMapper.setup :search, "ferret://#{@index}"
  end

  after :each do
    FileUtils.rm_r(@index)
  end

  it "should work with a model using id" do
    u = User.new(:id => 2)
    repository(:search).create([u])
    repository(:search).search("*").should == { User => ["2"] }
  end

  it "should work with a model using another key than id" do
    p = Photo.new
    repository(:search).create([p])
    repository(:search).search("*").should == { Photo => [p.uuid] }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dm-ferret-adapter-0.9.10 spec/adapter_spec.rb
dm-ferret-adapter-0.9.11 spec/adapter_spec.rb
dm-ferret-adapter-0.9.8 spec/adapter_spec.rb
dm-ferret-adapter-0.9.9 spec/adapter_spec.rb