forked from elastic/elasticsearch-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepository_class_test.rb
51 lines (42 loc) · 1.68 KB
/
repository_class_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require 'test_helper'
class Elasticsearch::Persistence::RepositoryClassTest < Test::Unit::TestCase
context "The default repository class" do
context "when initialized" do
should "be created from the module" do
repository = Elasticsearch::Persistence::Repository.new
assert_instance_of Elasticsearch::Persistence::Repository::Class, repository
end
should "store and access the options" do
repository = Elasticsearch::Persistence::Repository::Class.new foo: 'bar'
assert_equal 'bar', repository.options[:foo]
end
should "instance eval a passed block" do
$foo = 100
repository = Elasticsearch::Persistence::Repository::Class.new() { $foo += 1 }
assert_equal 101, $foo
end
should "call a passed block with self" do
foo = 100
repository = Elasticsearch::Persistence::Repository::Class.new do |r|
assert_instance_of Elasticsearch::Persistence::Repository::Class, r
foo += 1
end
assert_equal 101, foo
end
should "configure the index name based on options" do
repository = Elasticsearch::Persistence::Repository::Class.new index: 'foobar'
assert_equal 'foobar', repository.index_name
end
end
should "include the repository methods" do
repository = Elasticsearch::Persistence::Repository::Class.new
%w( index_name document_type klass
mappings settings client client=
create_index! delete_index! refresh_index!
save delete serialize deserialize
exists? find search ).each do |method|
assert_respond_to repository, method
end
end
end
end