From: Jan Provaznik <[email protected]>

Only first shoot (there will be some bigger changes in GUI, so
here are only few scenarios for adding/removing packages/groups).
---
 src/features/step_definitions/template_steps.rb |   35 +++++++++++++++++++++
 src/features/support/custom.rb                  |   11 ++++++-
 src/features/support/env.rb                     |    7 ++++
 src/features/support/paths.rb                   |    9 +++++
 src/features/template.feature                   |   37 +++++++++++++++++++++++
 5 files changed, 98 insertions(+), 1 deletions(-)
 create mode 100644 src/features/step_definitions/template_steps.rb
 create mode 100644 src/features/template.feature

diff --git a/src/features/step_definitions/template_steps.rb 
b/src/features/step_definitions/template_steps.rb
new file mode 100644
index 0000000..dd54c69
--- /dev/null
+++ b/src/features/step_definitions/template_steps.rb
@@ -0,0 +1,35 @@
+Given /^There is a mock pulp repository$/ do
+  dir = File.join(Rails.root, 'spec', 'fixtures')
+  stub_request(:any, "pulptest/repositories/").to_return(:status => 200, :body 
=> File.read(File.join(dir, 'repositories.json')))
+  stub_request(:any, 
"pulptest/repositories/jboss/packagegroups/").to_return(:status => 200, :body 
=> File.read(File.join(dir, 'packagegroups.json')))
+  stub_request(:any, 
"pulptest/repositories/jboss/packages/").to_return(:status => 200, :body => 
File.read(File.join(dir, 'packages.json')))
+end
+
+Given /^There is a "([^"]*)" template$/ do |name|
+  @descriptor = ImageDescriptor.new
+  @descriptor.xml.name = name
+  @descriptor.save_xml!
+end
+
+Given /^there is a package group$/ do
+  RepositoryManager.new.all_groups.should have_at_least(1).item
+end
+
+Given /^no package is selected$/ do
+  @descriptor.xml.packages = []
+end
+
+Given /^there is one selected package$/ do
+  pkg = RepositoryManager.new.all_packages.first
+  @descriptor.xml.packages = []
+  @descriptor.xml.add_package(pkg['name'], nil)
+  @descriptor.save_xml!
+end
+
+Given /^I jump on the "([^"]*)" template software page$/ do |name|
+  visit url_for :action => 'software', :controller => 'templates', :id => 
@descriptor
+end
+
+Then /^I should have a template named "([^"]*)"$/ do |name|
+  ImageDescriptor.first(:order => 'created_at DESC').xml.name.should eql(name)
+end
diff --git a/src/features/support/custom.rb b/src/features/support/custom.rb
index e8801ba..fdf20f4 100644
--- a/src/features/support/custom.rb
+++ b/src/features/support/custom.rb
@@ -17,4 +17,13 @@ CloudAccount.class_eval do
   def valid_credentials?
     true
   end
-end
\ No newline at end of file
+end
+
+RepositoryManager.class_eval do
+  def config
+    [{
+      'baseurl' => 'http://pulptest',
+      'type'    => 'pulp',
+    }]
+  end
+end
diff --git a/src/features/support/env.rb b/src/features/support/env.rb
index b921613..e65cdba 100644
--- a/src/features/support/env.rb
+++ b/src/features/support/env.rb
@@ -16,11 +16,18 @@ require 'cucumber/web/tableish'
 require 'webrat'
 require 'webrat/core/matchers'
 
+require 'webmock/rspec'
+
 Webrat.configure do |config|
   config.mode = :rails
   config.open_error_files = false # Set to true if you want error pages to pop 
up in the browser
 end
 
+module WebMockWorld
+  include WebMock
+  include WebMock::Matchers
+end
+World(WebMockWorld)
 
 # If you set this to false, any error raised from within your app will bubble
 # up to your step definition and out to cucumber unless you catch it somewhere
diff --git a/src/features/support/paths.rb b/src/features/support/paths.rb
index b790348..d166378 100644
--- a/src/features/support/paths.rb
+++ b/src/features/support/paths.rb
@@ -56,6 +56,15 @@ module NavigationHelpers
     when /the new permission page/
       url_for :action => 'new', :controller => 'permissions', :only_path => 
true
 
+    when /the new template page/
+      url_for :action => 'new', :controller => 'templates', :only_path => true
+
+    when /the template services page/
+      url_for :action => 'services', :controller => 'templates', :only_path => 
true
+
+    when /the template software page/
+      url_for :action => 'software', :controller => 'templates', :only_path => 
true
+
     # Add more mappings here.
     # Here is an example that pulls values out of the Regexp:
     #
diff --git a/src/features/template.feature b/src/features/template.feature
new file mode 100644
index 0000000..ed4cd68
--- /dev/null
+++ b/src/features/template.feature
@@ -0,0 +1,37 @@
+Feature: Manage Templates
+  In order to manage my cloud infrastructure
+  As a user
+  I want to manage templates
+
+  Background:
+    Given I am an authorised user
+    And I am logged in
+    And There is a mock pulp repository
+
+  Scenario: Add basic info to a new Template
+         Given I am on the homepage
+         When I follow "Create a Template"
+         Then I should be on the new template page
+         And I should see "Create a New Template"
+         When I fill in the following:
+      | xml_name         | mocktemplate  |
+      | xml_platform     | rhel          |
+      | xml_description  | mockdesc      |
+         And I press "Next"
+         Then I should be on the template services page
+         And I should have a template named "mocktemplate"
+
+  Scenario: Add a package to the template
+    Given There is a "mocktemplate" template
+    And I am on the template software page
+    And there is a package group
+    And no package is selected
+    When I follow "Select" within ".selection_list"
+    Then I should see "Remove" within "#selected_packages"
+
+  Scenario: Remove a package from the template
+    Given There is a "mocktemplate" template
+    And there is one selected package
+    And I jump on the "mocktemplate" template software page
+    When I follow "Remove" within "#selected_packages"
+    Then I should not see "Remove" within "#selected_packages"
-- 
1.7.2.1

_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to