草庐IT

django-test-without-migrations

全部标签

ruby 公案 : test_nil_is_an_object

我最近尝试使用这个工具来提高我的Rails技能:http://github.com/edgecase/ruby_koans但我无法通过一些测试。此外,我不确定我是否正确地做了一些事情,因为目标只是通过测试,有很多方法可以通过它,我可能正在做一些不符合标准的事情。有没有办法确认我做的事情是否正确?具体例子:在about_nil中,deftest_nil_is_an_objectassert_equal__,nil.is_a?(Object),"UnlikeNULLinotherlanguages"end它是告诉我检查第二个子句是否等于一个对象(所以我可以说nil是一个对象)或者只是把as

ruby-on-rails - 为什么 'bundle install --without production' 命令在更新后不需要 '--without production'?

为什么第二个命令不$bundleinstall不需要--withoutproduction(因为这是教程中的内容,所以我认为它是正确的)不需要它背后发生了什么/原因是什么?来自http://ruby.railstutorial.org/chapters/a-demo-app#sec-demo_users_resource$bundleinstall--withoutproduction$bundleupdate$bundleinstall 最佳答案 我相信这是因为bundler在您的项目文件夹中创建了一个.bundle/config

ruby-on-rails - rake 数据库 :migration not working on travis-ci build

我正尝试在Travis-CI上从github构建我的RubyonRails项目,但我遇到了迁移问题。它运行一个用于迁移的rake任务,但它在之后提示相同的迁移步骤。它遵循我的.travis.yml文件:language:rubyrvm:-1.9.2before_script:-"rakedb:migrateRAILS_ENV=test"这是构建输出:1Usingworker:ruby4.worker.travis-ci.org:travis-ruby-32345$cd~/builds678$gitclone--depth=100--quietgit://github.com/rafae

ruby-on-rails - rails : Validation in model vs migration

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:RubyonRails:Isitbettertovalidateinthemodelorthedatabase?我看到可以在Rails模型和迁移中添加相同的约束/验证。但是哪一个是最好的方法呢?在模型和数据库级别进行验证是否是一种好的做法(以及为什么)?或者他们在rails上一样?例如我们可以在模型和迁移中对名称进行相同的验证classUsertrue,:presence=>trueendclassCreateUsertrue,:null=>falseendendend

ruby - 如何使用 lib minitest 或 Test :Unit? 为单元测试着色

我想在我的开发环境中进行单元测试输出颜色。但是,我无法让它在Linux(Debian和Ubuntu)上运行。当我包含以下库时:require'minitest/autorun'require'minitest/unit'require'minitest/pride'我得到:/usr/local/rvm/gems/ruby-1.9.2-p136/gems/minitest-2.3.1/lib/minitest/pride.rb:35:in`':undefinedmethod`output'forMiniTest::Unit:Class(NoMethodError)由代码引起:MiniTe

ruby-on-rails - 使用 Rspec 和 Rack::Test 测试 REST-API 响应

我有点难过。我有以下集成测试:require"spec_helper"describe"/foods",:type=>:apidoincludeRack::Test::Methodslet(:current_user){create_user!}let(:host){"http://www.example.com"}beforedologin(current_user)@food=FactoryGirl.create_list(:food,10,:user=>current_user)endcontext"viewingallfoodsownedbyuser"doit"asJSON"d

ruby-on-rails - Rails:PG::InsufficientPrivilege:错误:关系 schema_migrations 的权限被拒绝

我正在尝试在Rails中创建数据库。在Postgres中,我看到了开发和测试数据库,但是,我遇到了权限错误。我试过点击此链接,但对我不起作用。错误:PG::InsufficientPrivilege:错误:关系schema_migrations的权限被拒绝:SELECT"schema_migrations".*FROM"schema_migrations"Rails:permissiondeniedforrelationschema_migrationsdefault:&defaultadapter:postgresqlencoding:unicodepool:5host:localh

ruby-on-rails - Rails Migration 更改列以使用 Postgres 数组

我正在尝试更改数据库中的列,以便它可以使用Postgres数组数据类型。目前表列是字符串类型。我正在使用以下迁移来转换它:defchangechange_column:table,:dummy_column,:text,array:true,default:[]end但是我得到以下错误:bundleexecrakedb:migraterakeaborted!Anerrorhasoccurred,thisandalllatermigrationscanceled:PG::Error:ERROR:column"dummy_column"cannotbecastautomaticallyto

ruby - 获取名称错误 : `format' is not allowed as an instance variable name when testing instance variable with rspec

我有以下测试:let(:client){Descat::Client.new}describe'poblacio'doit'shouldsetformatcorrectly'doclient.poblacio('v1','json','dades')expect(client.instance_variable_get(:format)).toeq('json')endend我有以下正在测试的代码:moduleDescatclassClientBASE_URL='http://api.idescat.cat/'definitialize(attributes={})attributes

ruby-on-rails - 使用 Test::Unit 和 Shoulda 设置 Factory Girl

我正在尝试在RubyonRails中使用Test::Unit和Shoulda设置FactoryGirl。我已经安装了gem,在test/factories目录下创建了我的工厂文件,并在test/models目录下创建了我的spec文件。我得到的当前错误是“ArgumentError:没有这样的工厂:测试”,这让我相信没有加载test_factory.rb文件?关于我应该更改什么有任何想法吗?这是我的文件。#test/factories/test_factory.rbFactory.define:testdo|t|t.name'test_spotlight't.label'testspo