Skip to content

Instantly share code, notes, and snippets.

@DaveSanders
Last active August 10, 2023 19:47
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DaveSanders/2eefc4de3e085d38fd6901da7dd47712 to your computer and use it in GitHub Desktop.
Save DaveSanders/2eefc4de3e085d38fd6901da7dd47712 to your computer and use it in GitHub Desktop.
notes for stimulus_reflex + Rspec

Scenario

I want to use Rspec to build feature specs that test SR pages, just like normal web pages.

Therefore, I expect Capybara + Rspec to be able to do things like:

visit login_path
fill_in 'Email', with: user.email
fill_in 'Password', with: user.password + 'BAD'
expect(page).to have_content('That email or password is not correct')

Setup

After installing gems, setting up redis, etc. I wrote my first non-SR test, which worked, but outputted the following to the console, cluttering my rspec window:

WARNING: Stimulus Reflex requires caching to be enabled. Caching allows the session to be modified during ActionCable requests.
To enable caching in development, run:
    rails dev:cache

To fix, I edited two lines in test.rb:

  config.action_controller.perform_caching = true
  config.cache_store = :memory_store

Which made the error go away and let me run my spec.

@drnic
Copy link

drnic commented Feb 25, 2022

Thanks

@3773moa
Copy link

3773moa commented Aug 10, 2023

Thank you, you save me a lot of time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment