Giter Club home page Giter Club logo

Comments (3)

mikker avatar mikker commented on June 7, 2024

Hi @rickychilcott! Thank you for your example – that looks like it should work just fine.

In integration/system tests I usually try to get as close to the real thing as possible, so that's what I've been doing.

So something like:

it 'show my posts' do
  user = User.create email: '[email protected]'
  sign_in_by_email user
  expect(page).to have_content('My posts')
end

# ...

def sign_in_by_email(authenticatable)
  visit '/sign_in'
  fill_in 'Email', with: authenticatable.email
  click_button '✨ Send magic link'

  visit_magic_link_in last_email.html_part.body
end

def visit_magic_link_in(html)
  visit text.match(%r{https?://.+(/sign_in/[a-z0-9-]+)}i)[1]
end

def last_email
  ActionMailer::Base.deliveries.last
end

You're totally right about BCrypt in test. I'll skip it 👍

from passwordless.

rickychilcott avatar rickychilcott commented on June 7, 2024

I totally agree that integrations should test the whole flow, but it does seem a bit silly to test/re-test user sign when what the real intent of a test around a feature is to do some action in your app. There are also the speed gains to be had not triggering the email flow and capybara visiting.

I've always thought https://github.com/thoughtbot/clearance#testing did it nicely with their Backdoor middleware, and I'd be willing to try a PR to get something like this if you think it's worth it.

I think I see a fairly clear way of doing it.

from passwordless.

mikker avatar mikker commented on June 7, 2024

I like that approach. I wouldn't mind including something like that – a PR would be very welcome! Let me know if you hit any road bumps.

from passwordless.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.