summaryrefslogtreecommitdiff
path: root/features/steps
diff options
context:
space:
mode:
authorNuo Yan <nuo@opscode.com>2010-11-07 17:15:19 -0800
committerDaniel DeLeo <dan@opscode.com>2011-02-02 12:20:37 -0800
commitf6a82394b9e012fe64b608eea81a9573788cdd1c (patch)
tree36fca0f1007737e923a4c546e0735687a3bba897 /features/steps
parentf50475eebd4d687fcc1439049d6e22eb5c63324f (diff)
downloadchef-f6a82394b9e012fe64b608eea81a9573788cdd1c.tar.gz
add @oss_only tag to appropriate tests and refactor some search tests
Diffstat (limited to 'features/steps')
-rw-r--r--features/steps/response_steps.rb12
-rw-r--r--features/steps/search_steps.rb26
2 files changed, 32 insertions, 6 deletions
diff --git a/features/steps/response_steps.rb b/features/steps/response_steps.rb
index 66df5bb6e4..989099d78d 100644
--- a/features/steps/response_steps.rb
+++ b/features/steps/response_steps.rb
@@ -48,7 +48,7 @@ end
Then /^the inflated responses key '(.+)' should match '(.+)'$/ do |key, regex|
puts self.inflated_response.inspect if ENV['DEBUG']
- self.inflated_response[key].should =~ /#{regex}/m
+ self.inflated_response[key].should =~ /#{regex}/m
end
Then /^the inflated responses key '(.+)' should be literally '(.+)'$/ do |key, literal|
@@ -60,7 +60,7 @@ Then /^the inflated responses key '(.+)' should be literally '(.+)'$/ do |key, l
false
end
- self.inflated_response[key].should == to_check
+ self.inflated_response[key].should == to_check
end
Then /^the inflated response should match '(.+)' as json$/ do |regex|
@@ -89,7 +89,7 @@ Then /^the inflated responses key '(.+)' sub-key '(.+)' should be an empty hash$
inflated_response[key][sub_key].should == {}
end
-Then /^the inflated responses key '(.+)' should be '(\d+)' items long$/ do |key, length|
+Then /^the inflated responses key '(.+)' should be '(\d+)' items long$/ do |key, length|
inflated_response[key].length.should == length.to_i
end
@@ -98,7 +98,7 @@ Then /^the inflated responses key '(.+)' should not exist$/ do |key|
end
Then /^the inflated responses key '(.+)' should exist$/ do |key|
- self.inflated_response.has_key?(key).should == true
+ self.inflated_response.has_key?(key).should == true
end
Then /^the inflated responses key '(.+)'.to_s should be '(.+)'$/ do |key, expected_value|
@@ -110,7 +110,7 @@ Then /^the inflated response should be an empty array$/ do
end
Then /^the inflated response should be an empty hash$/ do
- self.inflated_response.should == {}
+ self.inflated_response.should == {}
end
Then /^the inflated response should include '(.+)'$/ do |entry|
@@ -163,7 +163,7 @@ Then /^the inflated response should respond to '(.+)' with '(.+)'$/ do |method,
to_match = Chef::JSON.from_json(to_match) if to_match =~ /^\[|\{/
to_match = true if to_match == 'true'
to_match = false if to_match == 'false'
- self.inflated_response.to_hash[method].should == to_match
+ self.inflated_response.to_hash[method].should == to_match
end
Then /^the inflated response should respond to '(.+)' and match '(.+)'$/ do |method, to_match|
diff --git a/features/steps/search_steps.rb b/features/steps/search_steps.rb
new file mode 100644
index 0000000000..1d165abc97
--- /dev/null
+++ b/features/steps/search_steps.rb
@@ -0,0 +1,26 @@
+Given "the search index has been committed" do
+ sleep 1 # allow time for the objects to transit rabbitmq and opscode-expander.
+ RestClient.get("http://localhost:8983/solr/update?commit=true&waitFlush=true")
+end
+
+Then "there should be '$expected_count' total search results" do |expected_count|
+ expected_count = expected_count.to_i
+ inflated_response.should respond_to(:[])
+ inflated_response.should have_key("total")
+ inflated_response["total"].should == expected_count
+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")
+
+ result_item = inflated_response["rows"].find {|item| item["id"] == result_item_id }
+ unless result_item
+ msg = "expected to find a #{result_item_klass} with 'id' #{result_item_id} in the inflated response but it's not there\n"
+ msg << "actual inflated response is #{inflated_response.inspect}"
+ raise msg
+ end
+ expected_klass = eval(result_item_klass)
+
+ result_item.should be_a_kind_of(expected_klass)
+end \ No newline at end of file