[PATCH conductor 15/20] Feature for Providers API - destroy action

pblaho at redhat.com pblaho at redhat.com
Fri Jun 8 00:38:08 UTC 2012


From: Petr Blaho <pblaho at redhat.com>

https://www.aeolusproject.org/redmine/issues/3250

This commit contains cucumber feature and step
definitions
---
 src/features/provider_api.feature                  |   24 ++++++++++----------
 .../step_definitions/provider_api_steps.rb         |   18 +++++++++++++++
 src/features/step_definitions/provider_steps.rb    |   19 +++++++++++++++
 3 files changed, 49 insertions(+), 12 deletions(-)

diff --git a/src/features/provider_api.feature b/src/features/provider_api.feature
index c11cb83..9db07e5 100644
--- a/src/features/provider_api.feature
+++ b/src/features/provider_api.feature
@@ -59,15 +59,15 @@ Feature: Manage Providers via API
 #    When I update that provider with incorrect data
 #    Then I should receive Bad Request message
 #    And the provider should not be updated
-#
-#  Scenario: Delete Provider
-#    Given there is a provider
-#    When I delete that provider via XML
-#    Then I should received an OK message
-#    And the provider should be deleted
-#
-#  Scenario: Attempt to delete non-existant provider
-#    Given the specified provider does not exist in the system
-#    When I attempt to delete the provider
-#    Then I should receive a Provider Not Found error
-#    And the provider should not be deleted
+
+  Scenario: Delete Provider
+    Given there is a provider
+    When I delete that provider via XML
+    Then I should received an OK message
+    And the provider should be deleted
+
+  Scenario: Attempt to delete non-existant provider
+    Given the specified provider does not exist in the system
+    When I attempt to delete the provider
+    Then I should receive a Provider Not Found error
+    And no provider should be deleted
diff --git a/src/features/step_definitions/provider_api_steps.rb b/src/features/step_definitions/provider_api_steps.rb
index 5b7f5fd..0ac4ec5 100644
--- a/src/features/step_definitions/provider_api_steps.rb
+++ b/src/features/step_definitions/provider_api_steps.rb
@@ -90,3 +90,21 @@ Then /^I should receive Bad Request message$/ do
   response.headers['Content-Type'].should include('application/xml')
   response.status.should be_eql(400)
 end
+
+When /^I delete that provider via XML$/ do
+  header 'Accept', 'application/xml'
+
+  delete api_provider_path(@provider)
+end
+
+When /^I attempt to delete the provider$/ do
+  header 'Accept', 'application/xml'
+
+  delete api_provider_path(@provider)
+end
+
+Then /^I should receive a Provider Not Found error$/ do
+  response = last_response
+  response.headers['Content-Type'].should include('application/xml')
+  response.status.should be_eql(404)
+end
diff --git a/src/features/step_definitions/provider_steps.rb b/src/features/step_definitions/provider_steps.rb
index 37b686f..39c6f15 100644
--- a/src/features/step_definitions/provider_steps.rb
+++ b/src/features/step_definitions/provider_steps.rb
@@ -39,10 +39,29 @@ Then /^the provider should not be created$/ do
   Provider.find_by_name_and_url(@provider.name, @provider.url).should be_nil
 end
 
+Then /^the provider should be deleted$/ do
+  Provider.find_by_name_and_url(@provider.name, @provider.url).should be_nil
+end
+
+Then /^no provider should be deleted$/ do
+  # FIXME better way to test this?
+  Provider.count.should be_eql(@provider_count)
+end
+
+Then /^the provider should not be deleted$/ do
+  Provider.find_by_name_and_url(@provider.name, @provider.url).should_not be_nil
+end
+
 Given /^there should not exist a provider named "([^\"]*)"$/ do |name|
   Provider.find_by_name(name).should be_nil
 end
 
+Given /^the specified provider does not exist in the system$/ do
+  @provider = FactoryGirl.create(:mock_provider)
+  Provider.delete(@provider.id)
+  @provider_count = Provider.count
+end
+
 Given /^there is not a provider named "([^"]*)"$/ do |name|
   destroy_provider(name)
 end
-- 
1.7.7.6




More information about the aeolus-devel mailing list