jjzjj

expected

全部标签

ruby - Rspec `eq` 与 `eql` 测试中的 `expect`

在rspec测试中使用eq和eql有什么区别?有区别吗:it"addsthecorrectinformationtoentries"do#book=AddressBook.new#=>Replacedbyline4book.add_entry('AdaLovelace','010.012.1815','augusta.king@lovelace.com')new_entry=book.entries[0]expect(new_entry.name).toeq('AdaLovelace')expect(new_entry.phone_number).toeq('010.012.1815'

ruby - rspec 失败错误 : expected false to respond to `false?`

我正在运行这部分测试:describeDictionarydobeforedo@d=Dictionary.newendit'cancheckwhetheragivenkeywordexists'do@d.include?('fish').shouldbe_falseend使用这段代码:classDictionarydefinitialize@hash={}enddefadd(new_entry)new_entry.class==String?@hash[new_entry]=nil:new_entry.each{|noun,definition|@hash[noun]=definiti

ruby - 我如何在 RSpec 中引发异常的 `expect`?

我有一个方法可以对Cat模型执行一些操作,如果输入不正确会引发异常:context"hungrycat"doit{expect{eat(what:nil)}.toraise_error}end我想做的是检查这个方法是否改变了猫的状态,就像那样:context"hungrycat"doit{expect{eat(what:nil)}.toraise_error}it{expect{eat(what:nil)}.not_tochange(cat,:status)}end问题在于,由于eat(what:nil)将引发异常,因此第二个it无论如何都会失败。那么,是否可以忽略异常并检查某些条件?

ruby - Rspec : expect vs expect with block - what's the difference?

刚刚学习rspec语法,我注意到这段代码有效:context"givenabadlistofplayers"dolet(:bad_players){{}}it"failstocreategivenabadplayerlist"doexpect{Team.new("Random",bad_players)}.toraise_errorendend但是这段代码没有:context"givenabadlistofplayers"dolet(:bad_players){{}}it"failstocreategivenabadplayerlist"doexpect(Team.new("Rando

ruby - RSpec allow/expect 与 just expect/and_return

在RSpec中,特别是版本>=3,有什么区别:使用allow设置带有返回测试替身的参数的消息期望,然后使用expect对返回的测试替身进行断言只需使用expect设置带有参数的期望并返回测试替身还是只是语义?我知道用expect提供/指定返回值是thesyntaxinRSpecmocks2.13,但据我所知,thesyntaxchangedinRSpecmocks3使用允许。但是,在下面的(传递的)示例代码中,使用allow/expect或仅使用expect/and_return似乎产生相同的结果。如果一种语法比另一种语法更受欢迎,也许我会期望有某种弃用通知,但由于没有,这两种语法似乎

ruby - 在 RSpec-2.11 中使用隐式 `subject` 和 `expect`

使用rspec-2.11中新的expect语法,如何使用隐式的subject?有没有比显式引用subject更好的方法,如下所示?describeUserdoit'isvalid'doexpect(subject).tobe_valid# 最佳答案 如果您将RSpec配置为禁用should语法,您仍然可以使用旧的单行语法,因为这不涉及将should添加到每个对象:describeUserdoit{shouldbe_valid}end我们brieflydiscussed一种替代的单行语法,但决定反对它,因为它不需要,我们觉得它可能会增

javascript - Auth0 授权者拒绝来自服务的 JWT token - "jwt issuer invalid. expected: https://myservice.auth0.com"

我正在浏览将auth0设置为此处列出的AWS的API网关授权方的教程:https://auth0.com/docs/integrations/aws-api-gateway/custom-authorizers我正在使用此处推荐的授权方:https://github.com/auth0-samples/jwt-rsa-aws-custom-authorizer唯一的修改是配置文件。但是,在测试授权函数时,出现如下错误:{"name":"JsonWebTokenError","message":"jwtissuerinvalid.expected:https://MYSERVICE.au

javascript - 如何封装mocha `expect()`代码?

我正在尝试测试是否存在一些我希望在所有测试中都需要的api响应属性(status和data属性)。这是一个通用测试,它断言supertest中的所需属性expect()方法:it('shouldcreateawidget',done=>{letstatus=200;request(test_url).post('/api/widgets').set('Authorization',`Bearer${token}`).send({sku:my_widget_data.sku,name:my_widget_data.name,description:''}).expect(res=>{as

javascript - React 备忘录功能给出 :- Uncaught Error: Element type is invalid: expected a string but got: object

我有以下功能组件:-importReactfrom'react'import{Dropdown}from'semantic-ui-react'constDropDownMenu=(props)=>{constoptions=[{key:'fruits',text:'fruits',value:'Fruits'},{key:'vegetables',text:'vegetables',value:'Vegetables'},{key:'home-cooked',text:'home-cooked',value:'Home-Cooked'},{key:'green-waste',text:

javascript - Angular AOT : ERROR in ng component html file : Expected 0 arguments, 但得到 1

最初我在发布angular.net核心SPA应用程序时遇到以下错误:Can'tresolverxjs/operatorsinrelease\directives我已经通过将rxjs版本更新到5.6解决了这个问题。现在在发布应用程序时出现以下错误:WARNINGinEnvironmentPlugin-NODE_ENVenvironmentvariableisundefined.Youcanpassanobjectwithdefaultvaluestosuppressthiswarning.Seehttps://webpack.js.org/plugins/environment-plug