From: Jan Provaznik <jprov...@redhat.com> --- src/features/step_definitions/template_steps.rb | 43 +++++++++++++++++++++++ src/features/support/custom.rb | 10 +++++ src/features/support/paths.rb | 9 +++++ src/features/template.feature | 37 +++++++++++++++++++ 4 files changed, 99 insertions(+), 0 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..c708fce --- /dev/null +++ b/src/features/step_definitions/template_steps.rb @@ -0,0 +1,43 @@ +Given /^There is a mock pulp repository$/ do + dir = File.join(Rails.root, 'spec', 'fixtures') + hydra = Typhoeus::Hydra.hydra + hydra.stub(:get, "http://pulptest/repositories/").and_return( + Typhoeus::Response.new(:code => 200, + :body => File.read(File.join(dir, 'repositories.json')))) + hydra.stub(:get, "http://pulptest/repositories/jboss/packagegroups/").and_return( + Typhoeus::Response.new(:code => 200, + :body => File.read(File.join(dir, 'packagegroups.json')))) + hydra.stub(:get, "http://pulptest/repositories/jboss/packages/").and_return( + Typhoeus::Response.new(:code => 200, + :body => File.read(File.join(dir, 'packages.json')))) + +end + +Given /^There is a "([^"]*)" template$/ do |name| + @template = Template.new + @template.xml.name = name + @template.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 + @template.xml.packages = [] +end + +Given /^there is one selected package$/ do + pkg = RepositoryManager.new.all_packages.first + @template.xml.packages = [] + @template.xml.add_package(pkg['name'], nil) + @template.save_xml! +end + +Given /^I jump on the "([^"]*)" template software page$/ do |name| + visit url_for :action => 'software', :controller => 'templates', :id => @template +end + +Then /^I should have a template named "([^"]*)"$/ do |name| + Template.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 446aa89..515b8dd 100644 --- a/src/features/support/custom.rb +++ b/src/features/support/custom.rb @@ -31,3 +31,13 @@ CloudAccount.class_eval do true end end + +RepositoryManager.class_eval do + def config + [{ + 'baseurl' => 'http://pulptest', + 'yumurl' => 'http://pulptest', + 'type' => 'pulp', + }] + end +end diff --git a/src/features/support/paths.rb b/src/features/support/paths.rb index 537dd31..6b45674 100644 --- a/src/features/support/paths.rb +++ b/src/features/support/paths.rb @@ -65,6 +65,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.2 _______________________________________________ deltacloud-devel mailing list deltacloud-devel@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/deltacloud-devel