检查Rails 4中不存在路由(Check a route does not exists in Rails 4)
我停用了用户注册(宝石设计),我想做一个测试,以确保路由
/users/sign_up
不存在。为此,我在
spec/features/user_spec.rb
创建了一个测试require 'spec_helper' require 'capybara/rspec' feature "Users" do scenario "could not register " do expect(:get => "/users/sign_up").not_to be_routable end end
当我运行此测试时,我有这个错误:
1) Users could not register Failure/Error: expect(:get => "/users/sign_up").not_to be_routable NoMethodError: undefined method `routable?' for {:get=>"/users/sign_up"}:Hash # ./spec/features/user_spec.rb:8:in `block (2 levels) in <top (required)>'
I deactivated the user registration (Gem Devise) and I want to make a test to be sure the route
/users/sign_up
does not exists.To do this I created a test in
spec/features/user_spec.rb
require 'spec_helper' require 'capybara/rspec' feature "Users" do scenario "could not register " do expect(:get => "/users/sign_up").not_to be_routable end end
When I run this test, I have this error :
1) Users could not register Failure/Error: expect(:get => "/users/sign_up").not_to be_routable NoMethodError: undefined method `routable?' for {:get=>"/users/sign_up"}:Hash # ./spec/features/user_spec.rb:8:in `block (2 levels) in <top (required)>'
原文:https://stackoverflow.com/questions/17337639
更新时间:2023-01-12 06:01
最满意答案
可悲的是,awk内置了一个abs()函数。 实施它:
function abs(x) { return (x<0 ? -x : x) }
测试
$ awk -v a=42 -v b=-3.14 ' function abs(x) { return (x<0 ? -x : x) } BEGIN { print abs(a) print abs(b) }' 42 3.14
Sadly, awk does come with an abs() function built-in. Implement it:
function abs(x) { return (x<0 ? -x : x) }
testing
$ awk -v a=42 -v b=-3.14 ' function abs(x) { return (x<0 ? -x : x) } BEGIN { print abs(a) print abs(b) }' 42 3.14
相关问答
更多-
ABS是由什么组成的?[2022-05-05]
“ABS”中文译为“防抱死刹车系统”.它是一种具有防滑、防锁死等优点的汽车安全控制系统。ABS是常规刹车装置基础上的改进型技术,可分机械式和电子式两种。 现代汽车上大量安装防抱死制动系统,ABS既有普通制动系统的制动功能,又能防止车轮锁死,使汽车在制动状态下仍能转向,保证汽车的制动方向稳定性,防止产生侧滑和跑偏,是目前汽车上最先进、制动效果最佳的制动装置。 普通制动系统在湿滑路面上制动,或在紧急制动的时候,车轮容易因制动力超过轮胎与地面的摩擦力而安全抱死。 定义:ABS(Anti-locked Br ... -
如果你想使用jQuery: 一旦你像你提到的那样在css中得到了计算值,就可以用var itemWidth = $('#id').innerWidth();得到它var itemWidth = $('#id').innerWidth(); 。 然后,您可以使用var bodyWidth = $('body').innerWidth();获取页面的宽度var bodyWidth = $('body').innerWidth(); 因此,您可以编写一个使用bodyWidth和itemWidth来计算百分比var ...
-
在Perl中,查看Smart :: Comments模块。 而对于经过的时间,只需要在开始和结束time()的增量。 In Perl, look at the Smart::Comments module. And for the elapsed time, simply take the delta of the time() at the beginning versus the end.
-
我会在你的选择列表的第三项中使用case语句来测试除以0的错误。 在别的做你的数学。 就这么简单。 Select num1, num2, Case num2 WHEN 0 Then 100 Else Abs(100- ( 100 * cast( cast(num1 as decimal(6,3)) / cast(num2 as decimal(10,3) ) as decimal(6,3) ) ) ) END as percentdiff From @numtable I would use ...
-
计算MDX中的百分比(calculating percentage in MDX)[2022-03-10]
我仍然不确定要求,但如果您愿意,可以添加额外的父母: WITH MEMBER [Measures].[Percent_ofSubCategory] as DIVIDE( [Measures].[Income] ,([Measures].[Income], [Towary].[Hierarchy].currentmember.parent) ) ,format_string = "percent" MEMBER [Measures].[Percent_ofCategory] a ... -
箱尺寸:边界盒 使用box-sizing:border-box,尺寸计算为,width = border + padding +内容的宽度,height = border + padding +内容的高度。 例 宽度= 100px + 2px两侧边界= 4px +填充5px两侧= 10px 总数将为100px + 4px + 10px = 114px 使用box-sizing:borderbox属性 总数将为100px因为border和padding是从内部给出的 Box-sizing:border-box ...
-
可悲的是,awk内置了一个abs()函数。 实施它: function abs(x) { return (x<0 ? -x : x) } 测试 $ awk -v a=42 -v b=-3.14 ' function abs(x) { return (x<0 ? -x : x) } BEGIN { print abs(a) print abs(b) }' 42 3.14 Sadly, awk ...
-
为了获得比Flexbox更好的支持,请使用CSS表格作为解决方案,并首先避免整个calc要求。 从IE8开始, 支持就很好 .wrapper { width: 100%; background-color: #bada55; display: table; table-layout: fixed; } .wrapper div { display: table-cell; height: 70px; background-color: rebeccapurple ...
-
您需要传递一个%单位,而不是所需的整数值 div{ background:red; height:24px; width: calc(100% * (540 / 750)); /* 72% */ } You need to pass a % unit, than the desired integer values div{ background:red; height:24px; width: calc(100% * ...
-
剩余税年的百分比(Percentage of Tax Year Remaining)[2024-01-28]
我会使用PHP的DateTime类和DateTime::diff方法 :相关文章
更多- Rails 风格指导
- Rails常用插件
- Rails中的路由功能是如何对应的?
- 用 Rails 搭建微信公众平台 API
- Rails设置环境变量
- 在Rails中如何打开一个外部URL,并得到该URL的返回结果。
- 如何在javascript中写rails的helper代码
- Rails4 已经移出了params可以解析xml的功能,拿rails4做微信API的童鞋们注意了
- 顶 使用Rails plugin weixin_rails_middleware 快速搭建微信营销平台
- rails 单元测试
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。