Sha256: 3c9c6998d19001d627a28776cc81e6439469a1b4fa19bca8b84b89cba302606b

Contents?: true

Size: 851 Bytes

Versions: 1

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

1 entries across 1 versions & 1 rubygems

Version Path
dm-ferret-adapter-0.9.7 spec/adapter_spec.rb