Commit 18815182839c42f7b966d83faaea433002fd93b0

Authored by Diego Camarinha
Committed by Paulo Meireles
1 parent 1b8945a7

[Mezuro] More acceptance tests for project feature.

features/step_definitions/mezuro_steps.rb
... ... @@ -5,10 +5,6 @@ When /^I create a Mezuro (project|configuration) with the following data$/ do |t
5 5 When %{I fill in "#{name}" with "#{value}"}
6 6 end
7 7  
8   - if Article.find_by_name(fields.rows_hash[:Title])
9   - return false
10   - end
11   -
12 8 click_button "Save" # Does not work without selenium?
13 9 Article.find_by_name(fields.rows_hash[:Title])
14 10 end
... ... @@ -25,7 +21,8 @@ Then /^I should be at the url "([^\"]*)"$/ do |url|
25 21 end
26 22 end
27 23  
28   -Then /^I don't fill anything$/ do
  24 +Then /^the field "([^"]*)" is empty$/ do |field_name|
  25 + find_field(field_name).value.should be_nil
29 26 end
30 27  
31 28 Then /^I should see "([^\"]*)" inside an alert$/ do |message|
... ... @@ -34,11 +31,11 @@ Then /^I should see "([^\"]*)" inside an alert$/ do |message|
34 31 end
35 32  
36 33 Then /^I should see "([^"]*)" in the "([^"]*)" input$/ do |content, labeltext|
37   - find_field("#{labeltext}").value.should == content
  34 + find_field(labeltext).value.should == content
38 35 end
39 36  
40   -Then /^I should see "([^"]*)" in the "([^"]*)" button$/ do |content, button_class|
41   - find_button("#{button_class}").value.should == content
  37 +Then /^I should see "([^"]*)" button$/ do |button_name|
  38 + find_button(button_name).should_not be_nil
42 39 end
43 40  
44 41 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|
54 51 result.save!
55 52 end
56 53  
  54 +When /^I update this Mezuro project with the following data$/ do |fields|
  55 + find_field("article_name").set fields.rows_hash[:Title]
  56 + find_field("article_description").set fields.rows_hash[:Description]
  57 +end
  58 +
  59 +When /^I erase the "([^"]*)" field$/ do |field_name|
  60 + find_field(field_name).set ""
  61 +end
... ...
plugins/mezuro/features/project.feature
... ... @@ -28,8 +28,26 @@ Feature: Project
28 28 And I should see "Sample Description"
29 29 And I should see "Add Repository"
30 30  
31   - @selenium
32   - Scenario: I edit a Mezuro project
  31 + Scenario: I try to create a Mezuro project without title
  32 + Given I am on mycommunity's control panel
  33 + And I follow "Mezuro project"
  34 + And the field "article_name" is empty
  35 + When I press "Save"
  36 + Then I should see "Title can't be blank"
  37 +
  38 + Scenario: I try to create a Mezuro project with title already in use
  39 + Given I have a Mezuro project with the following data
  40 + | name | Sample Project |
  41 + | description | Sample Description |
  42 + | community | mycommunity |
  43 + And I am on mycommunity's control panel
  44 + When I create a Mezuro project with the following data
  45 + | Title | Sample Project |
  46 + | Description | Sample Description |
  47 + Then I should see "Slug The title (article name) is already being used by another article, please use another title."
  48 +
  49 + @selenium
  50 + Scenario: I see a Mezuro project edit form
33 51 Given I have a Mezuro project with the following data
34 52 | name | Sample Project |
35 53 | description | Sample Description |
... ... @@ -41,7 +59,36 @@ Feature: Project
41 59 And I should see "Sample Description" in the "article_description" input
42 60 And I should see "Save" button
43 61  
  62 + @selenium
  63 + Scenario: I edit a Mezuro project with valid attributes
  64 + Given I have a Mezuro project with the following data
  65 + | name | Sample Project |
  66 + | description | Sample Description |
  67 + | community | mycommunity |
  68 + And I am on article "Sample Project"
  69 + And I should be on /mycommunity/sample-project
  70 + And I follow "Edit"
  71 + When I update this Mezuro project with the following data
  72 + | Title | Another Project |
  73 + | Description | Another Description|
  74 + And I press "Save"
  75 + Then I should see "Another Project"
  76 + And I should see "Another Description"
  77 + And I should see "Add Repository"
44 78  
  79 + @selenium
  80 + Scenario: I try to edit a Mezuro project leaving empty its title
  81 + Given I have a Mezuro project with the following data
  82 + | name | Sample Project |
  83 + | description | Sample Description |
  84 + | community | mycommunity |
  85 + And I am on article "Sample Project"
  86 + And I should be on /mycommunity/sample-project
  87 + And I follow "Edit"
  88 + When I erase the "article_name" field
  89 + And I press "Save"
  90 + Then I should see "Title can't be blank"
  91 +
45 92 # @selenium
46 93 # Scenario: I delete a Mezuro project that belongs to me
47 94 # Given the following Mezuro project
... ...