summaryrefslogtreecommitdiff
path: root/features
diff options
context:
space:
mode:
authorBryan McLellan <btm@opscode.com>2012-04-13 14:52:56 -0700
committerBryan McLellan <btm@opscode.com>2012-04-13 14:52:56 -0700
commitebf48a8ead34b0e00bd023feb03151ee10187ff1 (patch)
treebedaa45ed91fbb5d1669b0f416b66f5339084cce /features
parent55abbd779fe9751e8a8bfd66ef5a03d2ce0aa06d (diff)
downloadchef-ebf48a8ead34b0e00bd023feb03151ee10187ff1.tar.gz
feature test fixes: search result ordering isn't garunteed
Diffstat (limited to 'features')
-rw-r--r--features/api/search/show_search.feature3
-rw-r--r--features/steps/search_steps.rb20
2 files changed, 21 insertions, 2 deletions
diff --git a/features/api/search/show_search.feature b/features/api/search/show_search.feature
index 665d6b5bca..656b63e8b2 100644
--- a/features/api/search/show_search.feature
+++ b/features/api/search/show_search.feature
@@ -128,8 +128,7 @@ Feature: Search data via the REST API
And the search index has been committed
When I authenticate as 'bobo'
And I 'GET' the path '/search/client?q=*:*'
- Then the inflated responses key 'rows' item '0' should be a kind of 'Chef::ApiClient'
- And the inflated responses key 'rows' item '0' should respond to 'name' with 'isis'
+ Then a 'Chef::ApiClient' with item name 'isis' should be in the search result
Scenario: Search for a type of object that does not exist
Given I am an administrator
diff --git a/features/steps/search_steps.rb b/features/steps/search_steps.rb
index 468cbb0f61..3dd179eebe 100644
--- a/features/steps/search_steps.rb
+++ b/features/steps/search_steps.rb
@@ -10,6 +10,26 @@ Then "there should be '$expected_count' total search results" do |expected_count
inflated_response["total"].should == expected_count
end
+Then "a '$result_item_klass' with item name '$result_item_name' should be in the search result" do |result_item_klass, result_item_name|
+ inflated_response.should respond_to(:[])
+ inflated_response.should have_key("rows")
+
+ found_match = false
+ expected_klass = eval(result_item_klass)
+
+ inflated_response['rows'].each do |item|
+ next unless item.name == result_item_name
+ found_match = true
+ item.should be_a_kind_of(expected_klass)
+ end
+
+ unless found_match
+ msg = "expected to find a #{result_item_klass} with item name #{result_item_name} in the inflated response but it's not there\n"
+ msg << "actual inflated response is #{inflated_response.inspect}"
+ raise msg
+ end
+end
+
Then "a '$result_item_klass' with id '$result_item_id' should be in the search result" do |result_item_klass, result_item_id|
inflated_response.should respond_to(:[])
inflated_response.should have_key("rows")