[PATCH conductor 1/4] Feature for Provider Accounts API - show action

pblaho at redhat.com pblaho at redhat.com
Mon Jul 30 18:27:41 UTC 2012


From: Petr Blaho <pblaho at redhat.com>

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

Adds cucumber scenarios for Provider Accounts API -
show action
---
 src/features/provider_account_api.feature          |    9 +++++++++
 .../step_definitions/provider_account_api_steps.rb |   20 ++++++++++++++++++++
 .../step_definitions/provider_account_steps.rb     |    4 ++++
 .../step_definitions/provider_api_steps.rb         |   12 +++---------
 4 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/src/features/provider_account_api.feature b/src/features/provider_account_api.feature
index adff4ef..a4098b3 100644
--- a/src/features/provider_account_api.feature
+++ b/src/features/provider_account_api.feature
@@ -20,3 +20,12 @@ Feature: Manage Provider Accounts via API
     Given the specified provider does not exist in the system
     When I request a list of provider accounts for that provider returned as XML
     Then I should receive Not Found error
+
+  Scenario: Get details for provider account as XML
+    Given there is a provider account
+    When I ask for details of that provider account as XML
+    Then I should receive details of that provider account as XML
+
+  Scenario: Get details for non existing provider account
+    When I ask for details of non existing provider account
+    Then I should receive Not Found error
diff --git a/src/features/step_definitions/provider_account_api_steps.rb b/src/features/step_definitions/provider_account_api_steps.rb
index ce9b6af..4e2c682 100644
--- a/src/features/step_definitions/provider_account_api_steps.rb
+++ b/src/features/step_definitions/provider_account_api_steps.rb
@@ -26,3 +26,23 @@ Then /^I should receive list of provider accounts for that provider as XML$/ do
   xml_body.xpath('//provider_accounts/provider_account').size.should be_eql(3)
   # TODO: test that provider accounts listed is for that provider only
 end
+
+When /^I ask for details of that provider account as XML$/ do
+  header 'Accept', 'application/xml'
+  get api_provider_account_path(@provider_account)
+end
+
+Then /^I should receive details of that provider account as XML$/ do
+  response = last_response
+  response.headers['Content-Type'].should include('application/xml')
+  response.status.should be_eql(200)
+  xml_body = Nokogiri::XML(response.body)
+  xml_body.xpath('//provider_account').size.should be_eql(1)
+end
+
+When /^I ask for details of non existing provider account$/ do
+  header 'Accept', 'application/xml'
+  provider_account = ProviderAccount.find_by_id(1)
+  provider_account.delete if provider_account
+  get api_provider_account_path(1)
+end
diff --git a/src/features/step_definitions/provider_account_steps.rb b/src/features/step_definitions/provider_account_steps.rb
index e61e228..ffec799 100644
--- a/src/features/step_definitions/provider_account_steps.rb
+++ b/src/features/step_definitions/provider_account_steps.rb
@@ -57,6 +57,10 @@ Given /^there is a provider account named "([^"]*)"$/ do |label|
   @provider_account = FactoryGirl.create(:mock_provider_account, :provider => @provider, :label => label)
 end
 
+Given /^there is a provider account$/ do
+  @provider_account = FactoryGirl.create(:mock_provider_account, :provider => @provider)
+end
+
 Given /^there is a second provider account named "([^"]*)"$/ do |label|
   @provider =  FactoryGirl.create(:provider, :name => 'secondprovider')
   @provider_account = FactoryGirl.create(:provider_account, :provider => @provider, :label => label)
diff --git a/src/features/step_definitions/provider_api_steps.rb b/src/features/step_definitions/provider_api_steps.rb
index 40eb3c3..ac03d5d 100644
--- a/src/features/step_definitions/provider_api_steps.rb
+++ b/src/features/step_definitions/provider_api_steps.rb
@@ -38,14 +38,6 @@ When /^I ask for details of non existing provider as XML$/ do
   get api_provider_path(1)
 end
 
-Then /^I should receive Not Found error$/ do
-  response = last_response
-  response.headers['Content-Type'].should include('application/xml')
-  response.status.should be_eql(404)
-  xml_body = Nokogiri::XML(response.body)
-  xml_body.xpath('//error').size.should be_eql(1)
-end
-
 When /^I create provider with correct data via XML$/ do
   header 'Accept', 'application/xml'
   header 'Content-Type', 'application/xml'
@@ -104,10 +96,12 @@ When /^I attempt to delete the provider$/ do
   delete api_provider_path(@provider)
 end
 
-Then /^I should receive a Provider Not Found error$/ do
+Then /^I should received?(?: a)?(?: .+)? Not Found error$/ do
   response = last_response
   response.headers['Content-Type'].should include('application/xml')
   response.status.should be_eql(404)
+  xml_body = Nokogiri::XML(response.body)
+  xml_body.xpath('//error').size.should be_eql(1)
 end
 
 When /^I update that provider with correct data via XML$/ do
-- 
1.7.7.6




More information about the aeolus-devel mailing list