From f78c5fb64ee9655293a27f6eefaafeb662f09433 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Tue, 10 Mar 2020 12:33:24 +0900 Subject: [PATCH 1/4] Add manifest file for Sprockets 4.0 --- spec/rails/app/assets/config/manifest.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 spec/rails/app/assets/config/manifest.js diff --git a/spec/rails/app/assets/config/manifest.js b/spec/rails/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/spec/rails/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css From 7f8bddf62974845015336724c743fda8f90aa9f0 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Tue, 10 Mar 2020 12:36:16 +0900 Subject: [PATCH 2/4] Add `rails-controller-testing` Render_template matcher uses `assert_template` and `assert_template` has been extracted to `rails-controller-testing` gem. --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 7008f6d..085100a 100644 --- a/Gemfile +++ b/Gemfile @@ -7,3 +7,4 @@ gemspec gem 'rails' gem 'rspec-rails', '>= 3.2.0' gem 'sqlite3' +gem 'rails-controller-testing' From 57f8caf2e2b005f168c3664b0668d4e5bd6ddff4 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Tue, 10 Mar 2020 12:39:45 +0900 Subject: [PATCH 3/4] Parameter need to be wrapped by `params` key --- spec/rails/spec/requests/faml_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/rails/spec/requests/faml_spec.rb b/spec/rails/spec/requests/faml_spec.rb index 81375e2..5a10b96 100644 --- a/spec/rails/spec/requests/faml_spec.rb +++ b/spec/rails/spec/requests/faml_spec.rb @@ -61,7 +61,7 @@ end it 'works with id' do - get '/books/object_ref', id: 123 + get '/books/object_ref', params: { id: 123 } expect(response).to be_ok expect(response.body).to include("
") end From 819cff5a176d1cab26dd18b878f311c3384af1a2 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Tue, 10 Mar 2020 12:42:24 +0900 Subject: [PATCH 4/4] Fix deprecation warning on Rails 6.0 In Rails 6.0 the API for template handlers is changing, a template handler must now take two arguments [1], the template and the source, otherwise you will see the following deprecation warning: ``` DEPRECATION WARNING: Single arity template handlers are deprecated. Template handlers must now accept two parameters, the view object and the source for the view object. Change: >> #.call(template) To: >> #.call(template, source) ``` [1] https://www.github.com/rails/rails/commit/28f88e0074 --- lib/faml/rails_handler.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/faml/rails_handler.rb b/lib/faml/rails_handler.rb index d67031c..7157efe 100644 --- a/lib/faml/rails_handler.rb +++ b/lib/faml/rails_handler.rb @@ -1,12 +1,13 @@ # frozen_string_literal: true module Faml class RailsHandler - def call(template) + def call(template, source = nil) + source ||= template.source Engine.new( use_html_safe: true, generator: Temple::Generators::RailsOutputBuffer, filename: template.identifier, - ).call(template.source) + ).call(source) end end end