草庐IT

rspec-given

全部标签

ruby-on-rails - 使用 Redis 和 Rails 的 Rspec 测试失败

我重构了我的Rails代码,将用户关系存储在Redis而不是Postgres数据库中。之前的代码:#user.rbhas_many:relationships,foreign_key:"follower_id",dependent::destroyhas_many:following,through::relationships,source::followeddeffollow!(other_user)relationships.create!(followed_id:other_user.id)end重构后的代码:#user.rbdeffollow!(other_user)rdb.

RSPEC 2.3 +设计1.0.11

我有一个非常旧的轨道2.3.18,Ruby1.9.3,RSPEC1.x应用程序,我们正在升级,并且其中有静止的认证。因此,我已经用设计1.0.11代替了。我可以登录到应用程序,但是我的测试不会运行;这是所讨论的测试require'spec_helper'describeCategoriesControllerdocontext"Asaloggedinuser"dobeforedologin_usercurrent_firm=mock_model(Firm,:id=>1)controller.stub!(:current_firm).and_return(current_firm)enddesc

node.js - 防止 NoSQL 注入(inject) : Isn't mongoose supposed to convert inputs based on given schema?

希望使用mongodb防止对node.js应用程序的NoSQL注入(inject)攻击。varmongoose=require('mongoose');//"^5.5.9"varSchema=mongoose.Schema;varhistorySchema=newSchema({userId:{type:String,index:true,},message:{},date:{type:Date,default:Date.now,}});varhistory=mongoose.model('history',historySchema);//thefollowingistoillust

ruby-on-rails - rails +MongoDB : Find ObjectId bigger than given value

我正在尝试在MongoDB中查找下一个(最新的)文档:Article.find({'_id'=>{"$gt"=>Moped::BSON::ObjectId(id_from_database)}})但是每次我运行这个查询,我都会得到Problem:Document(s)notfoundforclassArticlewithid(s){"_id"=>{"$gt"=>"givenvalue"}}.我已经安装了这些gem:gem'mongoid'gem'bson'gem'bson_ext'但还是找不到问题...我将不胜感激!谢谢 最佳答案

ruby-on-rails - 如何处理 Rspec 中的 Mongoid::Errors::DocumentNotFound?

我有一个带有以下代码的ArticleController:defedit@article=current_user.articles.find(params[:id])end以及以下测试:describe"GET'edit'"doit"shouldfailwhensignedinandeditinganotheruserarticle"dosign_in@userget:edit,:id=>@another_user_article.idresponse.should_notbe_successendend但是,当我开始测试时,出现以下错误(这是正常的),但我想知道如何处理才能让我的测

java - MongoDB : find matching elements in an array with given attributes using java driver

试图将我的游戏迁移到mongodb(linux-i686-2.4.6)但到目前为止有很多困难:(一个是那个;我有一个名为gamesTable的集合,其中包含以下元素,我想在playerHistories数组中进行搜索。{"_id":{"$oid":"52307b8fe4b0fc612dea2c70"},"id":"52307b8fe4b0fc612dea2c70","name":"poker","initTime":1378909071070,"startTime":1378909071098,"endTime":1378909071134,"playerHistories":[{"p

ruby-on-rails - 使用 Rspec 和 Mongoid 5.0 on Rails 4 清理或重置测试数据库

当我运行我的rspec测试时,由于我的mongodb数据库中的数据过时,很多测试都失败了。据我所知,使用干净的数据库进行测试要好得多。如何在每次测试前清理和/或重新植入数据库? 最佳答案 您可以使用database_cleanergem来完成这个任务。来自他们的文档:RSpec.configuredo|config|config.use_transactional_fixtures=falseconfig.before(:suite)doDatabaseCleaner.clean_with(:truncation)endconfig

【Nginx异常】无法加载响应数据:No data found for resource with given identifier,后端服务报Caused by: java.io.IOExcepti

无法加载响应数据:Nodatafoundforresourcewithgivenidentifier一、问题描述二、问题原因三、解决方案一、问题描述前后端服务为B/S架构模式,通过Nginx代理转发。同时升级三个SpringBoot后端服务。现象是正常一个SpringBoot项目升级后,后端服务一直在报错org.apache.catalina.connector.ClientAbortException:java.io.IOException:Brokenpipe而浏览器页面也在报错提示:无法加载响应数据:Nodatafoundforresourcewithgivenidentifier刚开始

mysql - 来自 NDBCLUSTER 的错误 4239 'Trigger with given name already exists'

我们正在运行MySQL集群版本:mysql>SELECTVERSION();+------------------------------+|VERSION()|+------------------------------+|5.6.15-ndb-7.3.4-cluster-gpl|+------------------------------+尝试创建一个表CREATETABLExy(xaVARCHAR(36)NOTNULLDEFAULT'',xbVARCHAR(255)NOTNULL,xcTIMESTAMPNOTNULL,xdVARCHAR(36)DEFAULTNULL,xeVA

c# - 惊人的错误 "The given key was not present in the dictionary."

我使用SqlCe作为我的数据库,但是当我将所有表复制到MySql数据库时,这个异常开始了!我的代码:using(MySqlConnectionconSQL=newMySqlConnection(conSQLSTR)){try{conSQL.Open();}catch(MySqlExceptione){stringerrMsg=e.Message;MessageBox.Show(errMsg,"error",MessageBoxButtons.OK,MessageBoxIcon.Error);returnfalse;}using(MySqlCommandcomSQL=conSQL.Cre