使用JavaScript的Cucumber / Capybara测试似乎不仅仅针对一个也使用ActionCable和Redis的测试执行



我有一个Rails(5.2.3(应用程序,我正试图在其中添加聊天功能,以便用户可以相互通信。我还没有完全实现这个功能,因为我正在尝试边写测试(如果我不知道如何为我要测试的内容写测试,我通常会这样做(。到目前为止,我已经在应用程序的相关页面的两个区域中用HTML进行了布局,用于发送和接收聊天消息,JavaScript用于运行页面的其余部分,JavaScript用于在页面加载时运行,使聊天功能的区域填充页面的正确空间,JavaScript用于侦听textarea以发送聊天,以及监听广播聊天的JavaScript。相关的测试模拟了我目前在开发版本中可以做的事情:在发送<textarea>中键入文本,点击return,然后在包含聊天的<div>中查看消息。开发日志显示消息到达redis服务器并按预期转发。

聊天工具测试失败。如果我在运行测试的浏览器中打开控制台,我既看不到错误,也看不到页面上的JavaScript为该测试执行的证据(所有其他测试,都标记为@javascript,执行正确(。如果添加足够的延迟,我可以看到我用来将enter键发送到textarea的两种方法似乎都有效(因为光标移动(,但页面上的预期行为(文本被发送到redis服务器进行广播(不会发生。

测试日志中没有证据表明ActionCable服务器启动。我已经安装了capybara-chromedriver-logger,但我并没有看到我所期望的日志记录的证据。

如果我的问题中缺少您认为有助于回答的信息,请询问。

我为聊天元素编写的CoffeeScript(它在开发中执行,但在测试中不执行(:

# 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

通常情况下,在测试时会使用asyncactioncable适配器(而不是redis适配器(,并且您需要配置actioncable以在应用程序中运行(在测试环境中(-https://guides.rubyonrails.org/action_cable_overview.html#in-应用程序-以便在Capybara启动应用程序时启动。

相关内容

  • 没有找到相关文章

最新更新