Niklas Nson

Joined

1,190 Experience
4 Lessons Completed
1 Question Solved

Activity

Posted in Warden and System Tests are driving me insane.

I was trying to use "driven_by :rack_test" when changing to driven_by :selenium_chrome_headless it works as expected.

Posted in Warden and System Tests are driving me insane.

signin_helper.rb

module SigninHelper
  def sign_in_as(user)
    visit signin_path
    fill_in 'authentications_email', with: user.email
    fill_in 'authentications_password', with: user.password
    click_button 'Logga in'
  end

  def sign_out
    click_link "Logga ut"
  end
end

exempel testcase:

require 'rails_helper'
require 'pry'


RSpec.describe "UserEdits", type: :system do
  let(:user) { Fabricate(:confirmed_user) }

  it "should update a users email" do 
    sign_in_as(user)
    visit user_url(user.guid)
    click_link 'Ă„ndra medlemsuppgifter'
    fill_in 'user_email', with: "newusereamail@yahoo.com"
    expect {
      click_button 'Uppdatera uppgifter'
      user.reload
    }.to change { user.email }
  end
end

Posted in Warden and System Tests are driving me insane.

Im using Warden for authentication and are now trying to write system test. But when I run a system test I get the following error:

Failure/Error: if current_user.admin?
 NoMethodError: 
  undefined method `admin?' for nil:NilClass 

Meaning current_user is not set. How to fix this? I have set up so I can do controller tests with Warden and that works. But I can not figure this out and I don't find any documentation with working code.

Please help me out, I'm going crazy!

this would invoke the constructor on every page right ? is that ok or should one try to only run if the data-behavior is on the current page ?

Posted in Manage Assets With Rails Assets Discussion

great video, thanks!

great screencasts!