草庐IT

jasmine-matchers

全部标签

ruby-on-rails - 测试我的 Ruby gem:Shoulda::Matchers:Module (NoMethodError) 的未定义方法 `configure'

我正在开发我的第一个Rubygem,并捆绑了cucumber、rspec和shoulda-matches进行测试。当我运行rspec时,出现以下错误:/app/my_gem/spec/spec_helper.rb:6:in`':undefinedmethod`configure'forShoulda::Matchers:Module(NoMethodError)这是我的gem规范:#my_gem.gemspec...Gem::Specification.newdo|spec|......spec.add_development_dependency"activemodel"spec.a

ruby-on-rails - 如何将 CoffeeScript 规范与 Jasmine-Rails 一起使用

我正在使用Ruby版本2.0.0-p195运行Rails3.2.13。我正在使用启用了Assets管道的Jasmine-Railsgem版本0.4.5。我想在CoffeeScript中编写我的规范,但我一直无法弄清楚如何命名文件和配置jasmine.yml,以便规范能够被正确地提取和解析。这是我的jasmine.yml文件的内容:src_dir:"app/assets/javascripts"src_files:-"application.{js,coffee}"spec_dir:spec/javascriptshelpers:-"helpers/**/*.{js,coffee}"sp

ruby - rspec expect语法不支持operator matchers,所以必须传一个matcher给 `#to`

使用新的expect语法:expect(@line.filter_results_and_display_them).to==@processed出现此错误:ArgumentError:Theexpectsyntaxdoesnotsupportoperatormatchers,soyoumustpassamatcherto'#to' 最佳答案 此语法有效:expect(@line.filter_results_and_display_them).toeq@processed 关于ruby

javascript - 如何使用嵌套函数(javascript、jasmine)为第 3 方库编写 mock

我是TDD的新手,我正在尝试编写使用第三方库(跨平台移动开发)的可测试代码。我想进行测试以仅检查我们的业务逻辑。不用担心它们的实现。此外,他们的库仅在native包装器中公开。由于使用js作为开发语言,我想使用jasmine进行测试并运行测试以仅在浏览器中检查我的业务逻辑。以下是我想在测试时忽略/模拟的方法模式。com.companyname.net.checkInternetAvailable(url)com.companyname.store.getValue(key)com.companyname.someother.name(whateverObj,callback)etc.,

javascript - Jasmine Spy 根据参数返回不同的值

我正在监视一个JS方法。我想根据方法的实际参数返回不同的东西。我试过callFake并尝试使用arguments[0]访问参数,但它说arguments[0]未定义。这是代码-spyOn(testService,'testParam').and.callFake(function(){varrValue={};if(arguments[0].indexOf("foo")!==-1){returnrValue;}else{return{1};}})这里建议-AnywaytomodifyJasminespiesbasedonarguments?但这对我不起作用。

javascript - Chutzpah 和 Jasmine 2.0 以及 RequrieJs

我在让Chutzpah与requireJs/jasmine2.0一起工作时遇到了一些麻烦。此方法适用于版本1.3,但现在对于jasmine版本2.0,chutzpah已停止接受测试。我也将chutzpah升级到3.1.1以支持jasmine2.0。我确实需要做一个小改动来从requireJs加载jasmine以使其工作,但我认为这不应该影响chutzpah,因为它只是加载html。这是我为chutzpah运行的命令。chutzpah.console.exepath/to/SpecRunner.html控制台现在无法获取测试===0total,0failed,took0.25second

javascript - Karma/Jasmine 测试自定义指令 Controller

我正在尝试使用Karma+Jasmine测试AngularJS自定义指令。我找到了一种方法来检查网络上的许多引用资料。但解决方案似乎不是正确的方法。让我们先看一个例子,这是test.js:angular.module("app",[]).directive("test",function(){return{restrict:'E',scope:{defined:'='},templateFile:"test.html",controller:function($scope){$scope.isDefined=function(){return$scope.defined;};}};})

javascript - 使用 $httpBackend、jasmine 测试 $http 请求中特定 header 的 Angular 项目服务

我想检查请求中是否存在特定header。这篇文章帮助我找到了标题。http://jbavari.github.io/blog/2014/06/20/testing-interceptor-headers-in-angularjs/以下是我测试的片段。这让我可以访问header,但问题是(将会),当我刷新请求时,它期望header作为一个函数,这隐含地使我的测试失败。$httpBackend.expect('POST','https://www.someurl.com/login',userObj,function(headers){expect(headers['content-typ

javascript - 使用 Jasmine 测试 Angular Controller 中的非作用域函数

Jasmine是使用最广泛的测试框架之一,以BDD方式对javascript代码进行单元测试。我试图将它用于AngularJS组件测试。AngularJS文档提供了以下示例代码describe('PasswordController',function(){beforeEach(module('app'));var$controller;beforeEach(inject(function(_$controller_){$controller=_$controller_;}));describe('$scope.grade',function(){it('setsthestrength

javascript - Angular Karma Jasmine - 测试功能

基本上我必须测试下面这个函数,我正在从文本文件中读取$window.resolveLocalFileSystemURL(cordova.file.dataDirectory,function(dir){varpath='somefile.txt';dir.getFile(path,{create:true},function(file){file.file(function(file){varreader=newFileReader();reader.onloadend=function(){resolve(this.result);}reader.readAsText(file);}