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 7bbd8ba
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 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
5 changes: 4 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ GEM
multipart-post (>= 1.2, < 3)
faraday_middleware (0.10.0)
faraday (>= 0.7.4, < 0.10)
flag-icons-rails (1.1.2)
sass (~> 3.2)
foreman (0.78.0)
thor (~> 0.19.1)
gherkin (2.12.2)
Expand Down Expand Up @@ -355,6 +357,7 @@ DEPENDENCIES
devise (~> 3.5.1)
exception_notification (~> 4.1.1)
factory_girl_rails (~> 4.5.0)
flag-icons-rails
foreman (~> 0.78.0)
gisdatigo
google-analytics-rails (~> 0.0.6)
Expand Down Expand Up @@ -390,4 +393,4 @@ DEPENDENCIES
web-console (~> 2.0.0)

BUNDLED WITH
1.11.2
1.14.6
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 7bbd8ba

Please sign in to comment.