Skip to content

Commit

Permalink
Merge pull request #452 from alphagov/test-component-guide
Browse files Browse the repository at this point in the history
Test component guide
  • Loading branch information
fofr authored Aug 25, 2017
2 parents ca64f1a + a806be8 commit e315baf
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ gem 'dalli'
gem 'gds-api-adapters', '~> 43.0'
gem 'govuk_ab_testing', '~> 2.0'
gem 'govuk_frontend_toolkit', '5.1.0'
gem 'govuk_publishing_components', '~> 0.7.0', require: ENV['RAILS_ENV'] != "production" || ENV['HEROKU_APP_NAME'].to_s.length.positive?
gem 'govuk_publishing_components', '~> 0.9.0', require: ENV['RAILS_ENV'] != "production" || ENV['HEROKU_APP_NAME'].to_s.length.positive?
gem 'htmlentities', '4.3.4'
gem 'logstasher', '0.6.1'
gem 'plek', '1.11'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ GEM
sass (>= 3.2.0)
govuk_navigation_helpers (6.3.0)
gds-api-adapters (>= 43.0)
govuk_publishing_components (0.7.0)
govuk_publishing_components (0.9.0)
govspeak (>= 5.0.3)
govuk_frontend_toolkit
rails (>= 5.0.0.1)
Expand Down Expand Up @@ -326,7 +326,7 @@ DEPENDENCIES
govuk_ab_testing (~> 2.0)
govuk_frontend_toolkit (= 5.1.0)
govuk_navigation_helpers (~> 6.3)
govuk_publishing_components (~> 0.7.0)
govuk_publishing_components (~> 0.9.0)
govuk_schemas
htmlentities (= 4.3.4)
jasmine-rails!
Expand Down
4 changes: 2 additions & 2 deletions app/views/components/_figure.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<%
alt ||= false
alt ||= ''
caption ||= false
%>
<figure class="app-c-figure">
<img class="app-c-figure__image" src="<%= src %>" <% if alt %>alt="<%= alt %>"<% end %>>
<img class="app-c-figure__image" src="<%= src %>" alt="<%= alt %>">
<% if caption %><figcaption class="app-c-figure__figcaption"><%= caption %></figcaption><% end %>
</figure>
7 changes: 7 additions & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,11 @@

# Raises error for missing translations
config.action_view.raise_on_missing_translations = true

# TODO: Re-enable tests to run against compiled assets with digests
# Add a performant assets compilation step before tests run
# Don't depend on precompiled JS assets. We are not currently precompiling
# javascript before tests run. Meaning failing JS will not be detected
# in integration tests.
config.assets.digest = false
end
15 changes: 15 additions & 0 deletions test/components/all_components.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'test_helper'

# TODO: Move this logic to the GOVUK Publishing Components gem
# and have the tests visit each component.
class AllComponentsTest < ActionDispatch::IntegrationTest
test "renders all component guide pages without erroring" do
visit '/component-guide'
components = all(:css, '.component-list a').map do |el|
"#{el[:href]}/preview"
end
components.each do |component|
visit component
end
end
end

0 comments on commit e315baf

Please sign in to comment.