Skip to content

Commit

Permalink
Making create_page test DRY
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaschabariberi committed Dec 4, 2019
1 parent 07307d7 commit 85445f2
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 32 deletions.
26 changes: 21 additions & 5 deletions src/app/features/003_create_page_click.feature
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
Feature: Create a new page

As a spotted page manager
As a user
I want to create a page to my educational institution
So that I can manage the page of my educational institution
So that there is a page to my educational institution on the app

Background: I am logged in
Given I logged in successfully

Scenario: spotted page manager clicks the create new page button with valid data and all fields filled except "background_image"
Scenario: User clicks the create new page button with valid data
Given I am on the create new page page
When I fill the create new page form
And I select manual approve
And I select to not request to participate
And I click the Cadastrar button
Then I should see the initial user page

Scenario: spotted page manager clicks the create new page button with invalid data
Scenario Outline: User clicks the create new page button with invalid data
Given I am on the create new page page
When I fill the create new page form with invalid data
When I fill the create new page form
And I fill in "<form field>" with "<value>"
And I select manual approve
And I select to not request to participate
And I click the Cadastrar button
Then I should see the red failed toast

Examples:
| form field | value |
| college_name | |
| college_initials | nove letras |
| college_city | |
| college_state | |
| college_state | São Paulo |
| college_country | |
| college_font_color | |
| college_background_color | |
59 changes: 32 additions & 27 deletions src/app/features/step_definitions/create_page_click_steps.rb
Original file line number Diff line number Diff line change
@@ -1,48 +1,53 @@
Given (/^I am on the create new page page$/) do
Given /^I am on the create new page page$/ do
visit new_college_path
end

When (/^I fill the create new page form$/) do
fill_in "college[name]", with: "Universidade Teste 001"
fill_in "college[initials]", with: "UT001"
fill_in "college[city]", with: "São Paulo"
fill_in "college[state]", with: "SP"
fill_in "college[country]", with: "Brasil"
fill_in "college[unit]", with: "Faculdade Teste 001"
fill_in "college[background_color]", with: "#fafafa"
fill_in "college[font_family]", with: "Arial"
fill_in "college[font_color]", with: "#000000"
select 'Manual', from: "college[admin_approves_spotted]"
select 'Não', from: "college[request_to_participate]"
When /^I fill the create new page form$/ do
steps %Q{
When I fill in "college_name" with "Universidade Teste 001"
When I fill in "college_initials" with "UT001"
When I fill in "college_city" with "São Paulo"
When I fill in "college_state" with "SP"
When I fill in "college_country" with "Brasil"
When I fill in "college_unit" with "Faculdade Teste 001"
When I fill in "college_background_color" with "#fafafa"
When I fill in "college_font_family" with "Arial"
When I fill in "college_font_color" with "#000000"
}
end

When("I fill the create new page form with invalid data") do
fill_in "college[name]", with: ""
fill_in "college[initials]", with: "UT001"
fill_in "college[city]", with: "São Paulo"
fill_in "college[state]", with: "SP"
fill_in "college[country]", with: "Brasil"
fill_in "college[unit]", with: "Faculdade Teste 001"
fill_in "college[background_color]", with: "#fafafa"
fill_in "college[font_family]", with: "Arial"
fill_in "college[font_color]", with: "#000000"
When /^I select manual approve$/ do
select 'Manual', from: "college[admin_approves_spotted]"
end

When /^I select to not request to participate$/ do
select 'Não', from: "college[request_to_participate]"
end

# - - -

Given(/^There is a college page created$/) do
Given /^There is a college page created$/ do
steps %Q{
Given There is an unregistered user
}
u = College.new(:name => "Universidade Teste 002", :initials => "UT002", :city => "São Paulo", :state => "SP", :country => "Brasil", :unit => "Faculdade Teste 002", :user_id => @user.id, :background_color => "fafafa", :font_family => "Arial", :background_image => "", :font_color => "#000000", :request_to_participate => 0)
u = College.new(:name => "Universidade Teste 002",
:initials => "UT002",
:city => "São Paulo",
:state => "SP",
:country => "Brasil",
:unit => "Faculdade Teste 002",
:user_id => @user.id,
:background_color => "fafafa",
:font_family => "Arial",
:background_image => "",
:font_color => "#000000",
:request_to_participate => 0)
u.save

@college = College.find_by(initials: "UT002")
end

Given(/^I created a college page$/) do
Given /^I created a college page$/ do
steps %Q{
Given I am on the create new page page
When I fill the create new page form
Expand All @@ -53,7 +58,7 @@

end

Given(/^There is a college page with request needed created$/) do
Given /^There is a college page with request needed created$/ do
steps %Q{
Given There is another unregistered user
}
Expand Down

0 comments on commit 85445f2

Please sign in to comment.