I want to execute some JS library in RSpec.
for example
I can execute "Payment Library" of JavaScript Library in HTML like below.
<!DOCTYPE html>
<html>
<head>
<script src="https://sample.example/payment.js"></script>
</head>
<body>
<div id="foo"></div>
</body>
<script>
$(document).ready(function(){
// Payment depends on "https://sample.example/payment.js"
Payment.init("11111");
Payment.getToken({cardNo: "1111111111111111", expired: "2001"});
});
</script>
</html>
Is it possible to load external JavaScript Library like using "script" tag in RSpec like this.
js_code = <<'EOS'
{
<script src="https://sample.example/payment.js"></script>
Payment.init("11111");
Payment.getToken({cardNo: "1111111111111111", expired: "2001"});
}
EOS
ExecJS.eval js_code
Pleas give me any advice.
Thanks.