From 6f5dc5ce3333796348831601f0ff92e970b12080 Mon Sep 17 00:00:00 2001 From: David Singleton Date: Fri, 6 Mar 2015 14:34:29 +0000 Subject: [PATCH] Add component smoke testing, using fixtures https://en.wikipedia.org/wiki/Smoke_testing_(software) Each component has a set of fixture data that is used to generate examples within govuk-component-guide, and show example usage. Use this example data to run smoke test on each component, which should give us increased confidence in catching big regressions in component view logic - or broken fixture data. It only asserts that components render without exception, not that the internal logic is correct (this should be covered by view tests). --- test/govuk_component/component_smoke_test.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 test/govuk_component/component_smoke_test.rb diff --git a/test/govuk_component/component_smoke_test.rb b/test/govuk_component/component_smoke_test.rb new file mode 100644 index 000000000..87ccc4e1f --- /dev/null +++ b/test/govuk_component/component_smoke_test.rb @@ -0,0 +1,16 @@ +require 'test_helper' + +class ComponentsTest < ActionView::TestCase + test "each component fixture can be rendered without errors being raised" do + doc_files = Rails.root.join('app', 'views', 'govuk_component', 'docs', '*.yml') + components = Dir[doc_files].sort.map do |file| + { id: File.basename(file, '.yml') }.merge(YAML::load_file(file)).deep_symbolize_keys + end + + components.each do |component| + component[:fixtures].each do |_, fixture| + render file: "govuk_component/#{component[:id]}.raw", locals: fixture + end + end + end +end