Skip to content

Commit

Permalink
Add accceptance test to check presence of flag icons
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorbaraujo committed May 4, 2017
1 parent 2b17b95 commit 22a1ab0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
source 'https://rubygems.org'

# Use css flag icons
gem 'flag-icons-rails'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
Expand Down
1 change: 1 addition & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def t_action(action, model, options={})
t("helpers.submit.#{model.model_name.i18n_key}.#{action}", options)
end

# method used to map locale route into flag name
def map_locale(locale)
mapped_locales = {
"en": "us",
Expand Down
7 changes: 7 additions & 0 deletions features/homepage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,16 @@ Feature: Homepage
Then I should see "Entendendo Métricas de Código"
When I click the Idioma link
And I click the "en" flag
Then I should see "Understanding Code Metrics"

Scenario: Correct portuguese plural settings option
Given I am at the homepage
When I click the Language link
And I click the "pt" flag
Then I should see "Configurações"

Scenario: See flags in language dropdown
Given I am at the homepage
When I click the Language link
Then I should see "us" flag
Then I should see "br" flag
8 changes: 8 additions & 0 deletions features/step_definitions/homepage_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@
Then(/^I should see "(.*?)" only "(.*?)" times$/) do |text, times|
expect(page).to have_content(text, count: times.to_i)
end

When(/^I click the "(.*?)" flag$/) do |text|
find(:css, "a[href='/#{text}']").click
end

Then(/^I should see "(.*?)" flag$/) do |flag|
find(:css, "span[class='flag-icon flag-icon-#{flag}']")
end
4 changes: 0 additions & 4 deletions features/step_definitions/user_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
click_button text
end

When(/^I click the "(.*?)" flag$/) do |text|
find(:css, "a[href='/#{text}']").click
end

When(/^I fill the (.+) field with "(.+)"$/) do |field, text|
fill_in field, :with => text
end
Expand Down

0 comments on commit 22a1ab0

Please sign in to comment.