diff --git a/features/step_definitions/mezuro_steps.rb b/features/step_definitions/mezuro_steps.rb index af02743..d445557 100644 --- a/features/step_definitions/mezuro_steps.rb +++ b/features/step_definitions/mezuro_steps.rb @@ -74,7 +74,7 @@ Then /^I should not see "([^"]*)" button$/ do |button_name| find_button(button_name).should be_nil end -When /^I have a Mezuro (project|reading group|configuration|repository) with the following data$/ do |type,fields| +When /^I have a Mezuro (project|reading group|configuration) with the following data$/ do |type, fields| item = {} fields.rows_hash.each do |name, value| if(name=="user" or name=="community") @@ -91,15 +91,26 @@ When /^I have a Mezuro (project|reading group|configuration|repository) with the result = MezuroPlugin::ConfigurationContent.new(item) end + result.save! +end + +When /^I have a Mezuro (reading|repository) with the following data$/ do |type, fields| + item = {} + fields.rows_hash.each do |name, value| + if(name=="user" or name=="community") + item.merge!(:profile=>Profile[value]) + else + item.merge!(name => value) + end + end if (type == "repository") - puts Kalibro::Configuration.all.last.id - puts Kalibro::Project.all.last.id - item.merge(:configuration_id => Kalibro::Configuration.all.last.id) - result = Kalibro::Repository.new(item) - result.save Kalibro::Project.all.last.id - else - result.save! - end + item.merge!(:configuration_id => Kalibro::Configuration.all.last.id) + item.merge!(:project_id => Kalibro::Project.all.last.id) + Kalibro::Repository.create(item) + elsif (type == "reading") + item.merge!(:group_id => Kalibro::ReadingGroup.all.last.id) + Kalibro::Reading.create(item) + end end When /^I erase the "([^"]*)" field$/ do |field_name| @@ -110,7 +121,7 @@ When /^I fill the fields with the new following data$/ do |fields| fields.rows_hash.each do |key, value| name = key.to_s element = find_field(name) - if element.tag_name.to_s == "select" + if (element.tag_name.to_s == "select") select(value, :from => name) else element.set value @@ -130,11 +141,28 @@ When /^I have a Mezuro metric configuration with previous created configuration }) end -When /^I follow the (edit|remove) link for "([^"]*)" repository$/ do |action,repository_name| - project_id = Kalibro::Project.all.last.id - repositories = Kalibro::Repository.repositories_of project_id - repository_id = repositories.select {|option| option.name == repository_name}.first.id +When /^I follow the (edit|remove) link for "([^"]*)" (repository|reading)$/ do |action, name, type| + if (type == "repository") + project_id = Kalibro::Project.all.last.id + repositories = Kalibro::Repository.repositories_of project_id + id = repositories.select {|option| option.name == name}.first.id + elsif (type == "reading") + reading_group_id = Kalibro::ReadingGroup.all.last.id + readings = Kalibro::Reading.readings_of reading_group_id + id = readings.select {|option| option.label == name}.first.id + if (action == "edit") + action = name + end + end + elements = all('a', :text => action.capitalize) - action_link = elements.select {|element| (/repository_id=#{repository_id}/ =~ element[:href]) }.first + link = type + "_id" + action_link = elements.select {|element| (/#{link}=#{id}/ =~ element[:href]) }.first action_link.click end + +Then /^I should see the "([^"]*)" color$/ do |color_name| + elements = all('td', :text => "") + found = elements.select { |element| color_name == element[:bgcolor]}.first + assert_not_nil found +end diff --git a/plugins/mezuro/features/reading.feature b/plugins/mezuro/features/reading.feature new file mode 100644 index 0000000..2513959 --- /dev/null +++ b/plugins/mezuro/features/reading.feature @@ -0,0 +1,85 @@ +@kalibro_restart +Feature: Reading + As a Mezuro user + I want to create, edit and remove a reading + + Background: + Given the following users + | login | name | + | joaosilva | Joao Silva | + And I am logged in as "joaosilva" + And "Mezuro" plugin is enabled + And I have a Mezuro reading group with the following data + | name | Sample Reading Group | + | description | Sample Description | + | user | joaosilva | + + @selenium + Scenario: I want to see the Mezuro reading input form + Given I am on article "Sample Reading Group" + When I follow "Add Reading" + Then I should see "Sample Reading Group Reading Group" in a link + And I should see "Label" + And I should see "Grade" + And I should see "Color" + And I should see "Save" button + + @selenium + Scenario: I try to add a reading with no name + Given I am on article "Sample Reading Group" + When I follow "Add Reading" + And I fill the fields with the new following data + | reading_label | | + | reading_grade | 10.2 | + | reading_color | ABCDEF | + And I press "Save" + Then I should see "Please fill all fields marked with (*)." inside an alert + + @selenium + Scenario: I try to add a reading with no grade + Given I am on article "Sample Reading Group" + When I follow "Add Reading" + And I fill the fields with the new following data + | reading_label | Useless | + | reading_grade | | + | reading_color | f51313 | + And I press "Save" + Then I should see "Please fill all fields marked with (*)." inside an alert + + @selenium + Scenario: I try to add a reading with no color + Given I am on article "Sample Reading Group" + When I follow "Add Reading" + And I fill the fields with the new following data + | reading_label | Fantastic | + | reading_grade | 4.0 | + | reading_color | | + And I press "Save" + Then I should see "Please fill all fields marked with (*)." inside an alert + + @selenium + Scenario: I want to add a reading with no color + Given I am on article "Sample Reading Group" + When I follow "Add Reading" + And I fill the fields with the new following data + | reading_label | Normal | + | reading_grade | 1.0 | + | reading_color | 19cbd1 | + And I press "Save" + Then I should see "Normal" + And I should see "1.0" + And I should see the "#19cbd1" color + And I should see "Remove" + + @selenium + Scenario: I want to see a reading edit form + Given I have a Mezuro reading with the following data + | label | Simple | + | grade | 2.0 | + | color | 34afe2 | + And I am on article "Sample Reading Group" + When I follow the edit link for "Simple" reading + Then I should see "Simple" in the "reading_label" input + And I should see "2.0" in the "reading_grade" input + And I should see "34afe2" in the "reading_color" input + And I should see "Save" button diff --git a/plugins/mezuro/features/repository.feature b/plugins/mezuro/features/repository.feature index 4b91581..d2e1d6f 100644 --- a/plugins/mezuro/features/repository.feature +++ b/plugins/mezuro/features/repository.feature @@ -26,9 +26,9 @@ Feature: Repository | description | Sample Description | | user | joaosilva | And I have a Mezuro metric configuration with previous created configuration and reading group - And I am on article "Sample Project" Scenario: I want to see the Mezuro repository input form + Given I am on article "Sample Project" When I follow "Add Repository" Then I should see "Name" And I should see "Description" @@ -41,7 +41,8 @@ Feature: Repository @selenium Scenario: I try to add a repository with no name - Given I follow "Add Repository" + Given I am on article "Sample Project" + And I follow "Add Repository" When I fill the fields with the new following data | repository_name | | | repository_description | My Description | @@ -55,7 +56,8 @@ Feature: Repository @selenium Scenario: I try to add a repository with no address - Given I follow "Add Repository" + Given I am on article "Sample Project" + And I follow "Add Repository" When I fill the fields with the new following data | repository_name | My Name | | repository_description | My Description | @@ -69,7 +71,8 @@ Feature: Repository @selenium Scenario: I try to add a repository with a invalid address - Given I follow "Add Repository" + Given I am on article "Sample Project" + And I follow "Add Repository" When I fill the fields with the new following data | repository_name | My Name | | repository_description | My Description | @@ -83,7 +86,8 @@ Feature: Repository @selenium Scenario: I want to add a repository with valid attributes - Given I follow "Add Repository" + Given I am on article "Sample Project" + And I follow "Add Repository" When I fill the fields with the new following data | repository_name | My Name | | repository_description | My Description | @@ -102,19 +106,17 @@ Feature: Repository And I should see "Sample Configuration" And I should see "Status" - #FIXME: create the step given I have repository... + #FIXME: Check the new rule "I have a Mezuro repository" @selenium Scenario: I want to see the repository edit form - Given I follow "Add Repository" - And I fill the fields with the new following data - | repository_name | My Name | - | repository_description | My Description | - | repository_license | ISC License (ISC) | - | repository_process_period | Not Periodically | - | repository_type | GIT | - | repository_address | https://github.com/user/project.git | - | repository_configuration_id | Sample Configuration | - And I press "Add" + Given I have a Mezuro repository with the following data + | name | My Name | + | description | My Description | + | license | ISC License (ISC) | + | process_period | Not Periodically | + | type | GIT | + | address | https://github.com/user/project.git | + | configuration_id | Sample Configuration | And I am on article "Sample Project" When I follow "Edit" Then I should see "My Name" in the "repository_name" input @@ -125,9 +127,9 @@ Feature: Repository And I should see "https://github.com/user/project.git" in the "repository_address" input And I should see "Sample Configuration" in the repository configuration select field - #FIXME: create the step given I have repository... + #FIXME: Check the new rule "I have a Mezuro repository" @selenium - Scenario: I edit a Mezuro project with valid attributes + Scenario: I edit a Mezuro repository with valid attributes Given I follow "Add Repository" And I fill the fields with the new following data | repository_name | My Name | @@ -157,9 +159,9 @@ Feature: Repository And I should see "https://project.svn.sourceforge.net/svnroot/project" And I should see "Sample Configuration" - #FIXME: create the step given I have repository... + #FIXME: Check the new rule "I have a Mezuro repository" @selenium - Scenario: I try to edit a Mezuro project leaving empty its title + Scenario: I try to edit a Mezuro repository leaving empty its title Given I follow "Add Repository" And I fill the fields with the new following data | repository_name | My Name | @@ -176,9 +178,9 @@ Feature: Repository And I press "Add" Then I should see "Please fill all fields marked with (*)." inside an alert - #FIXME: create the step given I have repository... + #FIXME: Check the new rule "I have a Mezuro repository" @selenium - Scenario: I try to edit a Mezuro project leaving empty its address + Scenario: I try to edit a Mezuro repository leaving empty its address Given I follow "Add Repository" And I fill the fields with the new following data | repository_name | My Name | @@ -195,7 +197,7 @@ Feature: Repository And I press "Add" Then I should see "Please fill all fields marked with (*)." inside an alert - #FIXME: create the step given I have repository... + #FIXME: Check the new rule "I have a Mezuro repository" @selenium Scenario: I try to edit a repository with an existing repository name Given I follow "Add Repository" @@ -248,5 +250,4 @@ Feature: Repository And I press "Add" And I am on article "Sample Project" When I follow the remove link for "My Name" repository - And I should not see "My Name" - + Then I should not see "My Name" -- libgit2 0.21.2