Rpsec测试失败了'rspec'但没有'rspec path_of_the_file'(Rpsec tests failed with 'rspec' but not with 'rspec path_of_the_file')
如果我运行此命令“rspec ./spec/requests/api/v1/password_reset_request_spec.rb”此文件中的所有测试都通过。
但是当我运行“rspec”时,我对这个文件中的测试有了一个假设。
1) /api/v1/password_reset #request when the email match with a runner when there is no request pending create a token for reset the password Failure/Error: post("/api/v1/password_reset/request", @params) NoMethodError: undefined method `reset_password' for RunnerMailer:Class # ./app/services/password_manager.rb:35:in `reset_password' # ./app/controllers/api/v1/password_reset_controller.rb:31:in `request_new_password' # ./spec/requests/api/v1/password_reset_request_spec.rb:108:in `block (5 levels) in <top (required)>'
这是调用该方法的行:
RunnerMailer.reset_password(@identity, @identity.reset_password_token).deliver
这是RunnerMailer类:
class RunnerMailer < ActionMailer::Base default from: "no-reply@goodgym.org" def reset_password(runner, token) @link = "http://url/password_reset/request/" + token mail(to: runner.email, subject: "Goodgym -- Reset your password") end end
知道为什么测试在我执行'rspec file_path'时通过而不是在我'rspec'时通过?
编辑1
我还有一个黄瓜功能和测试通过。
谢谢
If I run this command "rspec ./spec/requests/api/v1/password_reset_request_spec.rb" all the test inside this file pass.
However when I run "rspec" I've a faillure on the tests inside this file.
1) /api/v1/password_reset #request when the email match with a runner when there is no request pending create a token for reset the password Failure/Error: post("/api/v1/password_reset/request", @params) NoMethodError: undefined method `reset_password' for RunnerMailer:Class # ./app/services/password_manager.rb:35:in `reset_password' # ./app/controllers/api/v1/password_reset_controller.rb:31:in `request_new_password' # ./spec/requests/api/v1/password_reset_request_spec.rb:108:in `block (5 levels) in <top (required)>'
This is the line where the the method is called:
RunnerMailer.reset_password(@identity, @identity.reset_password_token).deliver
And this is the RunnerMailer class:
class RunnerMailer < ActionMailer::Base default from: "no-reply@goodgym.org" def reset_password(runner, token) @link = "http://url/password_reset/request/" + token mail(to: runner.email, subject: "Goodgym -- Reset your password") end end
Any idea why the test pass when I do 'rspec file_path' and not when I do 'rspec' ?
EDIT 1
I've also a cucumber feature for that and the test pass.
Thanks
原文:https://stackoverflow.com/questions/20422856
最满意答案
注意:在Chrome中, Ctrl + W是“保留”,请使用
window.onbeforeunload
试试这个(禁用Ctrl + W和Ctrl + S ):
window.onbeforeunload = function () {//Prevent Ctrl+W return "Really want to quit the game?"; }; document.onkeydown = function (e) { e = e || window.event;//Get event if (e.ctrlKey) { var c = e.which || e.keyCode;//Get key code switch (c) { case 83://Block Ctrl+S case 87://Block Ctrl+W --Not work in Chrome e.preventDefault(); e.stopPropagation(); break; } } };
Note: In Chrome Ctrl+W is "reserved", use
window.onbeforeunload
Note: Chrome requires
event.returnValue
to be setIn this code
document.onkeydown
is used for old browsers andwindow.onbeforeunload
is used to Chrome and FirefoxTry this (disable Ctrl+W and Ctrl+S):
window.onbeforeunload = function (e) { // Cancel the event e.preventDefault(); // Chrome requires returnValue to be set e.returnValue = 'Really want to quit the game?'; }; //Prevent Ctrl+S (and Ctrl+W for old browsers and Edge) document.onkeydown = function (e) { e = e || window.event;//Get event if (!e.ctrlKey) return; var code = e.which || e.keyCode;//Get key code switch (code) { case 83://Block Ctrl+S case 87://Block Ctrl+W -- Not work in Chrome and new Firefox e.preventDefault(); e.stopPropagation(); break; } };
相关问答
更多-
这里有一个很好的报道: http : //unixpapa.com/js/key.html 至于这是否应该完成,stackoverflow的问题编辑器会覆盖好几个按键,而不会中断太多(悬停在工具栏按钮上)。 There's an excellent coverage of this here: http://unixpapa.com/js/key.html As for whether this is something that should be done, stackoverflow's questi ...
-
在Javascript中捕获Ctrl键盘事件 示例代码: $(window).keydown(function(event) { if(event.ctrlKey && event.keyCode == 84) { console.log("Hey! Ctrl+T event captured!"); event.preventDefault(); } if(event.ctrlKey && event.keyCode == 83) { console.log("H ...
-
对于特定的窗口,您可以在这里查看所有窗口快捷方式。 只是为了确保你也可以看看这个维基百科文章 。“Alt”优先于“Ctrl”或其他方式的偏好只是你认为更加实用和更加用户友好的。 我建议你考虑其他键,比如“Shift”和F键。 For windows specifically you can look here for all the windows shortcuts. Just to be sure you can also look at this wikipedia article The prefe ...
-
任何方式来防止/禁用浏览器中的CTRL + [key]快捷键?(Any way to prevent/disable CTRL + [key] shortcuts in the browser?)[2023-08-26]
注意:在Chrome中, Ctrl + W是“保留”,请使用window.onbeforeunload 试试这个(禁用Ctrl + W和Ctrl + S ): window.onbeforeunload = function () {//Prevent Ctrl+W return "Really want to quit the game?"; }; document.onkeydown = function (e) { e = e || window.event;//Get event ... -
禁用浏览器快捷键(Disable Browser Shortcut Keys)[2022-01-20]
您可以通过javascript禁用所需的任何键。 您只需要知道它们的关键代码。 You can disable any keys you want via javascript. You just need to know the key code for them. -
Chrome键盘快捷键(Chrome Keyboard shortcuts)[2022-08-07]
谢谢wOxxOm的帮助。 当你说这个问题与分配了相同热键的冲突扩展时,你是对的。 一旦我禁用扩展我的扩展工作正常。 Thank you wOxxOm for your help. You were right when you said the issue was with a conflicting extension with the same hotkey assigned. Once I disabled the extension my extension worked properly. -
我不确定你能从我读过的内容来判断。 但是,您可以使用将其传递给silverlight应用程序的页面上的javascript代码来破解它。 (参见javascript / silverlight interop ) I'm not sure you can judging by what I've read. You may be able to hack it with javascript code on the page that passes it on to the silverlight appl ...
-
在IE 8中禁用Ctrl键(Disable Ctrl key in IE 8)[2022-07-23]
function Disable_Control_C() { var keystroke = String.fromCharCode(event.keyCode).toLowerCase(); if (event.ctrlKey && (keystroke == 'c' || keystroke == 'v' || keystroke == 'p' || keystroke == 's' || keystroke == 'u')) { alert("this function is disable ... -
如何在OnKeyPress事件中翻译Ctrl + Key快捷键?(How are Ctrl + Key shortcuts translated in the OnKeyPress event?)[2022-06-22]
我不明白密钥是如何翻译的,这些代码是什么意思? 使用Ctrl + AnyKey组合获得的值是Ascii控制代码。 它们源于需要从键盘输入非打印(控制)字符。 控制字符的(典型)值低于32加del字符(127)。 有关历史和标准的更多信息可以在这里和这里找到。 I don't understand how keys are translated, what does these codes mean? The values you get with the Ctrl+AnyKey combinations a ... -
今天我了解到,当在窗口中显示所有快捷方式时,可以再次按Ctrl - Shift - L ,它会转到快捷键首选项页面,其中有一个文本框来搜索键绑定。 Today I learned that when in the window displaying all the shortcuts one can just hit Ctrl-Shift-L again and it takes you to the key shortcuts preferences page, where there is a text ...