From 18815182839c42f7b966d83faaea433002fd93b0 Mon Sep 17 00:00:00 2001 From: Daniel Alves + Diego Araújo + Guilherme Rojas Date: Fri, 15 Feb 2013 17:56:21 -0200 Subject: [PATCH] [Mezuro] More acceptance tests for project feature. --- features/step_definitions/mezuro_steps.rb | 21 +++++++++++++-------- plugins/mezuro/features/project.feature | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/features/step_definitions/mezuro_steps.rb b/features/step_definitions/mezuro_steps.rb index e0c06e9..96f3bb5 100644 --- a/features/step_definitions/mezuro_steps.rb +++ b/features/step_definitions/mezuro_steps.rb @@ -5,10 +5,6 @@ When /^I create a Mezuro (project|configuration) with the following data$/ do |t When %{I fill in "#{name}" with "#{value}"} end - if Article.find_by_name(fields.rows_hash[:Title]) - return false - end - click_button "Save" # Does not work without selenium? Article.find_by_name(fields.rows_hash[:Title]) end @@ -25,7 +21,8 @@ Then /^I should be at the url "([^\"]*)"$/ do |url| end end -Then /^I don't fill anything$/ do +Then /^the field "([^"]*)" is empty$/ do |field_name| + find_field(field_name).value.should be_nil end Then /^I should see "([^\"]*)" inside an alert$/ do |message| @@ -34,11 +31,11 @@ Then /^I should see "([^\"]*)" inside an alert$/ do |message| end Then /^I should see "([^"]*)" in the "([^"]*)" input$/ do |content, labeltext| - find_field("#{labeltext}").value.should == content + find_field(labeltext).value.should == content end -Then /^I should see "([^"]*)" in the "([^"]*)" button$/ do |content, button_class| - find_button("#{button_class}").value.should == content +Then /^I should see "([^"]*)" button$/ do |button_name| + find_button(button_name).should_not be_nil end When /^I have a Mezuro project with the following data$/ do |fields| @@ -54,3 +51,11 @@ When /^I have a Mezuro project with the following data$/ do |fields| result.save! end +When /^I update this Mezuro project with the following data$/ do |fields| + find_field("article_name").set fields.rows_hash[:Title] + find_field("article_description").set fields.rows_hash[:Description] +end + +When /^I erase the "([^"]*)" field$/ do |field_name| + find_field(field_name).set "" +end diff --git a/plugins/mezuro/features/project.feature b/plugins/mezuro/features/project.feature index 7f5d4de..4d3a227 100644 --- a/plugins/mezuro/features/project.feature +++ b/plugins/mezuro/features/project.feature @@ -28,8 +28,26 @@ Feature: Project And I should see "Sample Description" And I should see "Add Repository" - @selenium - Scenario: I edit a Mezuro project + Scenario: I try to create a Mezuro project without title + Given I am on mycommunity's control panel + And I follow "Mezuro project" + And the field "article_name" is empty + When I press "Save" + Then I should see "Title can't be blank" + + Scenario: I try to create a Mezuro project with title already in use + Given I have a Mezuro project with the following data + | name | Sample Project | + | description | Sample Description | + | community | mycommunity | + And I am on mycommunity's control panel + When I create a Mezuro project with the following data + | Title | Sample Project | + | Description | Sample Description | + Then I should see "Slug The title (article name) is already being used by another article, please use another title." + + @selenium + Scenario: I see a Mezuro project edit form Given I have a Mezuro project with the following data | name | Sample Project | | description | Sample Description | @@ -41,7 +59,36 @@ Feature: Project And I should see "Sample Description" in the "article_description" input And I should see "Save" button + @selenium + Scenario: I edit a Mezuro project with valid attributes + Given I have a Mezuro project with the following data + | name | Sample Project | + | description | Sample Description | + | community | mycommunity | + And I am on article "Sample Project" + And I should be on /mycommunity/sample-project + And I follow "Edit" + When I update this Mezuro project with the following data + | Title | Another Project | + | Description | Another Description| + And I press "Save" + Then I should see "Another Project" + And I should see "Another Description" + And I should see "Add Repository" + @selenium + Scenario: I try to edit a Mezuro project leaving empty its title + Given I have a Mezuro project with the following data + | name | Sample Project | + | description | Sample Description | + | community | mycommunity | + And I am on article "Sample Project" + And I should be on /mycommunity/sample-project + And I follow "Edit" + When I erase the "article_name" field + And I press "Save" + Then I should see "Title can't be blank" + # @selenium # Scenario: I delete a Mezuro project that belongs to me # Given the following Mezuro project -- libgit2 0.21.2