Saturday, 4 November 2017

[Solved] Deprecation warnings Devise::TestHelpers

Another entry in the series of 'notes to myself' here.
A simple fix for the Deprecation warning saying that Devise::TestHelpers will be removed.
The fix is to replace the
 config.include Devise::Test::Helpers, :type => :controller  
with
config.include Devise::Test::ControllerHelpers, :type => :controller  
in spec/rails_helper.rb.
Unlike many of the suggested solutions, I don't have the devise configuration in the rails_helper file.
I have a separate set of helper functions, and the relevant location is 
spec/support/devise.rb.
 RSpec.configure do |config|  
  config.include Devise::Test::ControllerHelpers, :type => :controller  
 end  



You can stop reading now and go do something more productive instead.

Thursday, 19 January 2017

RSpec failing after a new Rails Composer project



RSpec issues

Add
require 'rails_helper.rb'
into the spec files to allow the tests to run as expected.

spec/features/visitors/sign_up_spec.rb

The minimum password length is set to be 6 characters, but the 'expected fail' password was set to 'please', causing the test to fail.

Changed password to 'short' and test passes.

spec/features/users/sign_in_spec.rb

The tests were looking for an authentication_key of 'email'. Changed to 'Email' to match the results from Devise.

Tuesday, 10 January 2017

Getting Puma to listen for all hosts with the Guardfile

This has been bugging me for a while, and I've finally had time to track down how to configure Guardfile in order to have Puma listen to all ip addresses.

guard 'rails', :host => '0.0.0.0' do
  watch('Gemfile.lock')
  watch(%r{^(config|lib)/.*})
end

Adding the :host => '0.0.0.0' gets puma to listen for all addresses.