Skip to content

Instantly share code, notes, and snippets.

@dabit
Last active June 9, 2020 15:25
Show Gist options
  • Save dabit/e55775a3fa67ec55ae6ae486b6b8bcf0 to your computer and use it in GitHub Desktop.
Save dabit/e55775a3fa67ec55ae6ae486b6b8bcf0 to your computer and use it in GitHub Desktop.
reflex testing
require 'test_helper'
class SomeReflexTest < StimulusReflex::TestCase
setup do
@user = users(:john)
cookies.encrypted[:user_id] = @user.id
end
test '#create creates a Model' do
name = "This is a test"
assert_difference -> { Model.count } do
reflex.create(name)
end
end
end
class StimulusReflex::TestCase < ActionCable::Connection::TestCase
tests ApplicationCable::Connection
def channel
@channel = StimulusReflex::Channel.new connect, "test"
end
def reflex_class
self.class.determine_constant_from_test_name(self.class_name) { |constant| constant }
end
def reflex
@reflex ||= reflex_class.new channel
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment