@@ -96,21 +96,21 @@ class MyDocument; end
96
96
end
97
97
98
98
should "return the number of domain objects" do
99
- subject . expects ( :search )
100
- . returns ( Elasticsearch ::Persistence ::Repository ::Response ::Results . new ( subject , { 'hits' => { 'total' => 1 } } ) )
99
+ subject . client . expects ( :count ) . returns ( { 'count' => 1 } )
101
100
assert_equal 1 , subject . count
102
101
end
103
102
104
- should "pass arguments from count to search" do
105
- subject . expects ( :search )
106
- . with do |query_or_definition , options |
107
- assert_equal 'bar' , query_or_definition [ :query ] [ :match ] [ :foo ]
108
- assert_equal true , options [ :ignore_unavailable ]
103
+ should "pass arguments to count" do
104
+ subject . client . expects ( :count )
105
+ . with do |arguments |
106
+ assert_equal 'test' , arguments [ :index ]
107
+ assert_equal 'bar' , arguments [ :body ] [ :query ] [ :match ] [ :foo ]
108
+ assert_equal true , arguments [ :ignore_unavailable ]
109
109
true
110
110
end
111
- . returns ( Elasticsearch :: Persistence :: Repository :: Response :: Results . new ( subject , { 'hits ' => { 'total' => 1 } } ) )
111
+ . returns ( { 'count ' => 1 } )
112
112
113
- subject . count ( { query : { match : { foo : 'bar' } } } , { ignore_unavailable : true } )
113
+ assert_equal 1 , subject . count ( { query : { match : { foo : 'bar' } } } , { ignore_unavailable : true } )
114
114
end
115
115
end
116
116
0 commit comments