Last active
June 9, 2020 15:25
-
-
Save dabit/e55775a3fa67ec55ae6ae486b6b8bcf0 to your computer and use it in GitHub Desktop.
reflex testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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