Reputation: 333
I started a simple project with rails 6 and haml-rails and rspec and my basic tests are failing on a basic get :home pointing to a simple haml template - I don't really know if it's a haml-rails, haml or rspec problem.
the errors I got
# rspec spec/controllers/static_pages_controller_spec.rb
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:
>> Class#call(template)
To:
>> Class#call(template, source)
(called from <top (required)> at /home/kuku/Projects/Permission/config/application.rb:22)
DEPRECATION WARNING: action_view.finalize_compiled_template_methods is deprecated and has no effect (called from <top (required)> at /home/kuku/Projects/Permission/config/environment.rb:7)
DEPRECATION WARNING: formats is deprecated and will be removed from Rails 6.1 (called from block (3 levels) in <top (required)> at /home/kuku/Projects/Permission/spec/controllers/static_pages_controller_spec.rb:8)
DEPRECATION WARNING: formats is deprecated and will be removed from Rails 6.1 (called from block (3 levels) in <top (required)> at /home/kuku/Projects/Permission/spec/controllers/static_pages_controller_spec.rb:8)
DEPRECATION WARNING: formats is deprecated and will be removed from Rails 6.1 (called from block (3 levels) in <top (required)> at /home/kuku/Projects/Permission/spec/controllers/static_pages_controller_spec.rb:8)
F
Failures:
1) StaticPagesController GET #home returns http success
Failure/Error: get :home
ActionView::Template::Error:
wrong number of arguments (given 2, expected 1)
# ./spec/controllers/static_pages_controller_spec.rb:8:in `block (3 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# ArgumentError:
# wrong number of arguments (given 2, expected 1)
# ./spec/controllers/static_pages_controller_spec.rb:8:in `block (3 levels) in <top (required)>'
Finished in 0.01728 seconds (files took 0.9926 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec/controllers/static_pages_controller_spec.rb:7 # StaticPagesController GET #home returns http success
my test - get :home
is line 8
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe StaticPagesController, type: :controller do
describe 'GET #home' do
it 'returns http success' do
get :home
expect(response).to have_http_status(:success)
end
end
end
and my controller
class StaticPagesController < ApplicationController
def home; end
end
routes.rb
Rails.application.routes.draw do
root to: 'static_pages#home'
end
I tried to use haml-rails and haml from master branch which seems to have some rails6 fixes but the errors I got are the same errors:
gem 'haml', github: 'haml/haml', branch: 'master'
gem 'haml-rails', github: 'indirect/haml-rails', branch: 'master'
Any suggestions that I may try or maybe is there any easy way to rollback from rails-haml to erb ?
Upvotes: 0
Views: 1060
Reputation: 333
I updated rspec and now it passes - it seems that rspec is not ready for rails 6
gem 'rspec-rails', github: 'rspec/rspec-rails', branch: '4-0-dev'
gem 'rspec', github: 'rspec/rspec', branch: 'master'
gem 'rspec-core', github: 'rspec/rspec-core', branch: 'master'
gem 'rspec-mocks', github: 'rspec/rspec-mocks', branch: 'master'
gem 'rspec-expectations', github: 'rspec/rspec-expectations', branch: 'master'
gem 'rspec-support', github: 'rspec/rspec-support', branch: 'master'
Upvotes: 2