create catch-all fixture generator for all static fixtures
This commit is contained in:
parent
4cd962ec6e
commit
2373082eb0
1 changed files with 31 additions and 0 deletions
31
spec/javascripts/fixtures/static_fixtures.rb
Normal file
31
spec/javascripts/fixtures/static_fixtures.rb
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe ApplicationController, '(Static JavaScript fixtures)', type: :controller do
|
||||||
|
include JavaScriptFixturesHelpers
|
||||||
|
|
||||||
|
before(:all) do
|
||||||
|
clean_frontend_fixtures('static/')
|
||||||
|
end
|
||||||
|
|
||||||
|
fixtures_path = File.expand_path(JavaScriptFixturesHelpers::FIXTURE_PATH, Rails.root)
|
||||||
|
haml_fixtures = Dir.glob(File.expand_path('**/*.haml', fixtures_path)).map do |file_path|
|
||||||
|
file_path.sub(/\A#{fixtures_path}#{File::SEPARATOR}/, '')
|
||||||
|
end
|
||||||
|
|
||||||
|
haml_fixtures.each do |template_file_name|
|
||||||
|
it "static/#{template_file_name.sub(/\.haml\z/, '.raw')}" do |example|
|
||||||
|
fixture_file_name = example.description
|
||||||
|
rendered = render_template(template_file_name)
|
||||||
|
store_frontend_fixture(rendered, fixture_file_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def render_template(template_file_name)
|
||||||
|
fixture_path = JavaScriptFixturesHelpers::FIXTURE_PATH
|
||||||
|
controller = ApplicationController.new
|
||||||
|
controller.prepend_view_path(fixture_path)
|
||||||
|
controller.render_to_string(template: template_file_name, layout: false)
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue