Using rspec-rails-3.5.2, poltergeist-1.11.0, and capybara-2.10.1
I created an audio object:
Bart.pumpAudio = new Audio("assets/audio/bart/pump.mp3");
I have a button that plays a sound when pressed
<div id="pump-button" class="button">Pump</div>
$("#pump-button").click(function() {
...
Bart.pumpAudio.play();
...
});
It works when I run on a browser, but I get errors when trying to perform tests through rspec:
Testing Code:
page.find("#pump-button").trigger('click')
Testing Error:
TypeError: 'undefined' is not a function (evaluating 'Bart.pumpAudio.play()')
Any ideas on how to solve this??
Adding this to the top of my js file seemed to solve my issue
var Audio = function() {
return {
load: function() {},
play: function() {}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.