I have a Rails (5.2.3) application to which I'm trying to add a chat feature so the users can communicate with each other. I have not fully implemented the feature, as I am trying to write tests as I go (if I don't know how to write tests for what I'm trying to test, I often do it this way). So far, I have two regions of the relevant page of the application laid out in HTML for the sending and reception of chat messages, JavaScript that runs the rest of the page, JavaScript that is intended to run on page load that makes the regions for the chat feature fill out the correct space of the page, JavaScript that listens to the textarea
for chats to send, and JavaScript that listens for broadcast chats. The relevant test mimics what I can do at the moment in the development version: type text in the sending <textarea>
, hit return, and see the message in the <div>
that holds the chats. The development logs show that the message hits the redis server and are forwarded as expected.
The chat tool test fails. If I open the console in the browser running the tests, I see neither errors nor evidence that the JavaScript on the page is executed for this test (all of the other tests, all of which are tagged @javascript
execute correctly). If I add enough of a delay, I can see that both of the methods I've employed to send the enter
key to the textarea
appear to work (in that the cursor moves), but the expected behavior on the page (that the text is sent to the redis server for broadcast) doesn't occur.
There's no evidence in the test log that the ActionCable server fires up. I have capybara-chromedriver-logger
installed, but I see no evidence of the logging I would expect.
If there is information missing from my question that you think would be helpful in answering it, please ask.
The CoffeeScript I've written for the chat elements (which executes in development, but not in the test):
# Behavior for driving the sizing of the heckle forum window.
#= require_self
#= require common
class ChatWindowDriver
@setChatWidths: () ->
curWidth = 0
(curWidth += $('td[data-node="'+n+'"]').width() for n in ["5", "2", "1", "3", "7"])
curWidth -= 20 # Because of the margins we want
$('div[id^="chat"]').each (index, element) =>
$(element).css("width", curWidth)
$('textarea#chat-text').each (index, element) =>
$(element).css("width", curWidth)
headerHeight = 0
$('td.chat-header').each (index, element) =>
headerHeight += $(element).height()
$('div#chat-header-anchor').css('height', headerHeight)
receiptHeight = 0
$('tr.chat-receipt').each (index, element) =>
receiptHeight += $(element).height()
$('div#chats-received').css('height', receiptHeight)
sendingHeight = 0
$('tr.chat-sending').each (index, element) =>
sendingHeight += $(element).height()
$('div#chat-send').css('height', sendingHeight)
@sendChat: (event) ->
if event.keyCode is 13 # return/enter => send
Chats.forum.heckle event.target.value
event.target.value = ''
event.preventDefault()
$ ->
console.log 'can we see this message?'
ChatWindowDriver.setChatWidths()
$('#chat-text').on 'keypress', (e) => ChatWindowDriver.sendChat(e)
Gemfile.lock
:
GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.4)
actionpack (= 5.2.4)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.4)
actionpack (= 5.2.4)
actionview (= 5.2.4)
activejob (= 5.2.4)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.4)
actionview (= 5.2.4)
activesupport (= 5.2.4)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.4)
activesupport (= 5.2.4)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.4)
activesupport (= 5.2.4)
globalid (>= 0.3.6)
activemodel (5.2.4)
activesupport (= 5.2.4)
activerecord (5.2.4)
activemodel (= 5.2.4)
activesupport (= 5.2.4)
arel (>= 9.0)
activestorage (5.2.4)
actionpack (= 5.2.4)
activerecord (= 5.2.4)
marcel (~> 0.3.1)
activesupport (5.2.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
arel (9.0.0)
backports (3.15.0)
bcrypt (3.1.13)
bindex (0.8.1)
builder (3.2.4)
byebug (11.0.1)
cancancan (3.0.1)
capybara (3.29.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (~> 1.5)
xpath (~> 3.2)
capybara-chromedriver-logger (0.2.1)
capybara
colorize
capybara-screenshot (1.0.24)
capybara (>= 1.0, < 4)
launchy
childprocess (3.0.0)
coderay (1.1.2)
coffee-rails (5.0.0)
coffee-script (>= 2.2.0)
railties (>= 5.2.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.12.2)
colorize (0.8.1)
concurrent-ruby (1.1.5)
crass (1.0.5)
cucumber (3.1.2)
builder (>= 2.1.2)
cucumber-core (~> 3.2.0)
cucumber-expressions (~> 6.0.1)
cucumber-wire (~> 0.0.1)
diff-lcs (~> 1.3)
gherkin (~> 5.1.0)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.1.2)
cucumber-core (3.2.1)
backports (>= 3.8.0)
cucumber-tag_expressions (~> 1.1.0)
gherkin (~> 5.0)
cucumber-expressions (6.0.1)
cucumber-rails (2.0.0)
capybara (>= 2.12, < 4)
cucumber (>= 3.0.2, < 4)
mime-types (>= 2.0, < 4)
nokogiri (~> 1.8)
railties (>= 4.2, < 7)
cucumber-tag_expressions (1.1.1)
cucumber-wire (0.0.1)
daemons (1.3.1)
database_cleaner (1.7.0)
delayed_job (4.1.8)
activesupport (>= 3.0, < 6.1)
delayed_job_active_record (4.1.4)
activerecord (>= 3.0, < 6.1)
delayed_job (>= 3.0, < 5)
diff-lcs (1.3)
docile (1.3.2)
email_spec (2.2.0)
htmlentities (~> 4.3.3)
launchy (~> 2.1)
mail (~> 2.7)
erubi (1.9.0)
execjs (2.7.0)
factory_bot (5.1.1)
activesupport (>= 4.2.0)
factory_bot_rails (5.1.1)
factory_bot (~> 5.1.0)
railties (>= 4.2.0)
faker (2.8.1)
i18n (>= 1.6, < 1.8)
ffi (1.11.3)
formatador (0.2.5)
gherkin (5.1.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
guard (2.16.1)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (>= 1.0.12, < 2.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
guard-rspec (4.7.3)
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
htmlentities (4.3.4)
i18n (1.7.0)
concurrent-ruby (~> 1.0)
jbuilder (2.9.1)
activesupport (>= 4.2.0)
jquery-rails (4.3.5)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.3.0)
launchy (2.4.3)
addressable (~> 2.3)
lazy_priority_queue (0.1.1)
libnotify (0.9.4)
ffi (>= 1.0.11)
libv8 (3.16.14.19)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.4.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
lumberjack (1.0.13)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.9.2)
mime-types (3.3)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009)
mimemagic (0.3.3)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.13.0)
multi_json (1.14.1)
multi_test (0.1.2)
nenv (0.3.0)
nio4r (2.5.2)
nokogiri (1.10.7)
mini_portile2 (~> 2.4.0)
notiffany (0.1.3)
nenv (~> 0.1)
shellany (~> 0.0)
pg (1.1.4)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
public_suffix (4.0.1)
puma (4.3.1)
nio4r (~> 2.0)
rack (2.0.8)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.4)
actioncable (= 5.2.4)
actionmailer (= 5.2.4)
actionpack (= 5.2.4)
actionview (= 5.2.4)
activejob (= 5.2.4)
activemodel (= 5.2.4)
activerecord (= 5.2.4)
activestorage (= 5.2.4)
activesupport (= 5.2.4)
bundler (>= 1.3.0)
railties (= 5.2.4)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (5.2.4)
actionpack (= 5.2.4)
activesupport (= 5.2.4)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rake (13.0.1)
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
ffi (~> 1.0)
record_tag_helper (1.0.0)
actionview (~> 5.x)
redis (4.1.3)
ref (2.0.0)
regexp_parser (1.6.0)
responders (3.0.0)
actionpack (>= 5.0)
railties (>= 5.0)
rgl (0.5.6)
lazy_priority_queue (~> 0.1.0)
stream (~> 0.5.2)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.0)
rspec-support (~> 3.9.0)
rspec-expectations (3.9.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-rails (3.9.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.0)
ruby_dep (1.5.0)
ruby_http_client (3.3.0)
rubyzip (2.0.0)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
sassc (2.2.1)
ffi (~> 1.9)
sassc-rails (2.1.2)
railties (>= 4.0.0)
sassc (>= 2.0)
sprockets (> 3.0)
sprockets-rails
tilt
selenium-webdriver (3.142.6)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
sendgrid-ruby (6.0.0)
ruby_http_client (~> 3.3.0)
shellany (0.0.1)
shoulda (3.6.0)
shoulda-context (~> 1.0, >= 1.0.1)
shoulda-matchers (~> 3.0)
shoulda-context (1.2.2)
shoulda-matchers (3.1.3)
activesupport (>= 4.0.0)
simplecov (0.17.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
spring (2.1.0)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
spring (>= 1.2, < 3.0)
sprockets (4.0.0)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
stream (0.5.2)
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
thor (1.0.1)
thread_safe (0.3.6)
tilt (2.0.10)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
tzinfo (1.2.6)
thread_safe (~> 0.1)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
web-console (3.7.0)
actionview (>= 5.0)
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
webdrivers (4.1.3)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (>= 3.0, < 4.0)
websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4)
xpath (3.2.0)
nokogiri (~> 1.8)
PLATFORMS
ruby
DEPENDENCIES
bcrypt
byebug
cancancan
capybara
capybara-chromedriver-logger
capybara-screenshot
coffee-rails
cucumber-rails
daemons
database_cleaner
delayed_job_active_record
email_spec
factory_bot_rails
faker
guard-rspec
jbuilder
jquery-rails
launchy
libnotify
listen
nokogiri
pg
puma
rails (= 5.2.4)
rb-inotify
record_tag_helper
redis
responders
rgl
rspec
rspec-rails
sass-rails
selenium-webdriver
sendgrid-ruby
shoulda
simplecov
spring
spring-watcher-listen
sprockets (>= 4.0)
sprockets-rails
therubyracer
turbolinks
uglifier
web-console
webdrivers
RUBY VERSION
ruby 2.6.3p62
BUNDLED WITH
2.0.2
Generally one would use the async
actioncable adapter when testing (not the redis
adapter) and you'd need to configure actioncable to run in app (in the test environment) - https://guides.rubyonrails.org/action_cable_overview.html#in-app - in order for it to start up when Capybara starts the application.