标签: rake-test

在单位和功能测试中使用rake的种子值

在使用rake运行单元和功能测试时,在rails应用程序中,我注意到在命令行上指定了种子值: - seed x

$ rake test
(in /code/blah)
Loaded suite /../ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.
Finished in 0.12345 seconds.

1 tests, 1 assertions, 0 failures, 0 errors, 0 skips

Test run options: --seed 20290
Run Code Online (Sandbox Code Playgroud)

我假设可以在测试中使用此值,但我无法弄清楚如何.我试过Google,Rails Guides等.但似乎无法找到答案.

编辑:

这个种子值是否可以被Minitest用来随机化测试的执行顺序?

rake ruby-on-rails rake-test

57
推荐指数
2
解决办法
1万
查看次数

将任务依赖项添加到Rake :: TestTask

如何向TestTask声明任务依赖?

在此示例中,应在集成任务之前运行"clean_database"任务

Rake::TestTask.new(:integration) do |t|
 t.libs << "test"
 t.test_files = FileList['test/**/integration/**/test*.rb']
 t.verbose = true
end

task :clean_database => [:init] do
 #...
end
Run Code Online (Sandbox Code Playgroud)

ruby rake rake-test

15
推荐指数
2
解决办法
3728
查看次数

尝试访问heroku控制台时,"您无法访问该应用程序"

我最近开始使用Ruby on Rails在Heroku上的一个项目中进行合作.我被添加为协作者并将远程添加到我的环境中.经过一些开发,我推了一些修改,没有问题:

$ git push staging
Run Code Online (Sandbox Code Playgroud)

staging是我的遥控器的名称.后来,当试图在Heroku上运行"rake test"时,我收到了一个错误:

$heroku run rake test --app staging
Running `rake test` attached to terminal... failed
 !    You do not have access to the app staging.
Run Code Online (Sandbox Code Playgroud)

这很奇怪,因为我完全能够推动自己的变化.我检查了Heroku仪表板,看到我的推送记录在那里.然后我尝试使用控制台查看日志,并出现同样的问题.

$ heroku logs --app staging
 !    You do not have access to the app staging.
Run Code Online (Sandbox Code Playgroud)

最后,我试图访问控制台,但它也失败了.

$ heroku run rails console --app staging
Running `rails console` attached to terminal... failed
 !    You do not have access to the app staging.
Run Code Online (Sandbox Code Playgroud)

此时我更新了我的Heroku工具箱安装,并使用"heroku auth"验证我的电子邮件是否显示,但错误仍然存​​在.我目前正在联系Heroku支持,但我希望有类似问题的人可以帮助我并行.

谢谢!

collaboration ruby-on-rails heroku rails-console rake-test

15
推荐指数
3
解决办法
1万
查看次数

Spring vs. Zeus性能问题:Spring在第一次运行后没有更快地运行测试?

所以我正在努力改进我的测试执行时间,并且一直在遵循一些优秀的建议(最值得注意的是,Railscasts 412).

Zeus似乎工作得很好(除了需要你输入zeus test test才能运行Minitest套件的奇怪之外.)

这是zeus的定时输出:

基线(佣金测试):

$ time rake test
Run options: --seed 62848

# Running tests:

........

Finished tests in 0.117071s, 68.3346 tests/s, 68.3346 assertions/s.

8 tests, 8 assertions, 0 failures, 0 errors, 0 skips

real    0m5.771s
user    0m4.477s
sys     0m0.872s
Run Code Online (Sandbox Code Playgroud)

和宙斯一起:

$ time zeus test test
Run options: --seed 10325

# Running tests:

........

Finished tests in 0.126365s, 63.3087 tests/s, 63.3087 assertions/s.

8 tests, 8 assertions, 0 failures, 0 errors, 0 skips

real …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails zeus minitest rake-test

6
推荐指数
1
解决办法
2516
查看次数

Rake测试 - 创建YAML错误,我该如何解决?

运行Rake测试时,我会在参考YAML文件时遇到一些错误.关于如何修复它的任何想法?

运行测试:EEEEEEEE

完成测试0.070970s,112.7237次测试/秒,0.0000断言/秒.

1) Error: test_should_create_product(ProductsControllerTest): ActiveRecord::Fixture::FormatError: a YAML error occurred parsing /Users/ka/src/ruby-test/depot/test/fixtures/products.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Please have a look at yaml.org/faq.html The exact error was: Psych::SyntaxError: (): found character that cannot start any token while scanning for the next token at line 5 column 1 /Users/ka/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/fixtures/file.rb:43:in rows' /Users/ka/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/fixtures/file.rb:29:ineach' /Users/ka/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/fixtures.rb:670:in block (2 levels) in read_fixture_files' /Users/ka/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/fixtures/file.rb:20:inopen' /Users/ka/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/fixtures.rb:669:in block in read_fixture_files' /Users/ka/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/fixtures.rb:668:in each' /Users/ka/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/fixtures.rb:668:in read_fixture_files' /Users/ka/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/fixtures.rb:548:in initialize' /Users/ka/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/fixtures.rb:482:in new' /Users/ka/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/fixtures.rb:482:in …

yaml ruby-on-rails rake-test

5
推荐指数
1
解决办法
1万
查看次数

运行rake测试和Rails'无法加载这样的文件 - rails/performance_test_help

我正在尝试进行佣金测试而我无法做到.我一直收到这个错误:ActiveRecord :: SchemaMigration Load(0.1ms)SELECT"schema_migrations".*FROM"schema_migrations"rake aborted!LoadError:无法加载此类文件 - rails/performance_test_help

我非常感谢任何见解.

ruby-on-rails rake-test

5
推荐指数
2
解决办法
2555
查看次数

Rake测试错误 - ActiveRecord :: Fixture :: FormatError:ActiveRecord :: Fixture :: FormatError

每次我做rake测试我得到12个错误都有相同的错误

8)错误:ProductTest#test_image_url:ActiveRecord :: Fixture :: FormatError:ActiveRecord :: Fixture :: FormatError

9)错误:ProductTest#test_product_attributes_must_not_be_empty:ActiveRecord :: Fixture :: FormatError:ActiveRecord :: Fixture :: FormatError

10)错误:ProductTest #test_product_is_not_valid_without_a_unique_title:ActiveRecord :: Fixture :: FormatError:ActiveRecord :: Fixture :: FormatError

11)错误:ProductTest#test_product_is_not_valid_without_a_unique_title _-_ i18n:ActiveRecord :: Fixture :: FormatError:ActiveRecord :: Fixture :: FormatError

12)错误:ProductTest#test_product_price_must_be_positive:ActiveRecord :: Fixture :: FormatError:ActiveRecord :: Fixture :: FormatError

第一行是:

syntax error, unexpected ( arg, expecting keyword_do or '{' or '('
  post :create, product_id: products (:ruby).id
Run Code Online (Sandbox Code Playgroud)

这是我的yaml文件

one:
title: MyString
description: MyText
image_url: MyString
price: 9.99

two:
title: MyString
description: …
Run Code Online (Sandbox Code Playgroud)

ruby testing activerecord ruby-on-rails rake-test

2
推荐指数
1
解决办法
2672
查看次数

Ruby on Rails Rake在将rails项目从4.1.9更新到4.2.0后抛出"不正确的表名"错误

我在过去几个月一直致力于一个项目,最初是在4.1.6开发的,我现在正在尝试将其更新到4.2.0(我已经逐步测试了4.1.6和4.2.0之间的所有版本,以及所有的4.1.x版本都没有错误,只有当我转到4.2.0时才能看到我在这里描述的问题).

在这个应用程序中,有很多共享功能是所有模型共有的,所以我创建了一个抽象类,我的所有模型都继承自这个类.

class TrackableModel < ActiveRecord::Base
  self.abstract_class = true
  ...
end

class User < TrackableModel
  ...
end
Run Code Online (Sandbox Code Playgroud)

Gemfile中唯一的变化是gem 'rails', '4.1.6'改为gem 'rails', '4.2.0'

更新过程遵循此处使用的说明,rake rails:update并按照同一文档第2部分中的升级步骤进行操作.

我用这个rake任务的默认值覆盖了所有冲突的文件,但之后审查了每个文件,并在我的修改中工作.

在更新之前,所有测试都通过,但更新后

130 runs, 0 assertions, 0 failures, 130 errors, 0 skips
Run Code Online (Sandbox Code Playgroud)

有错误

ActiveRecord::StatementInvalid: Mysql2::Error: Incorrect table name '': SHOW FULL FIELDS FROM ``

Error:
xxxTest#test_yyy:
NoMethodError: undefined method `each' for nil:NilClass
Run Code Online (Sandbox Code Playgroud)

该应用程序似乎无需更改用户体验即可运行.在我尝试执行测试之前,一切看起来都很好.

我无法让我的测试运行.

更新:

我忘了提到我在跑步

ruby 2.1.5p273 (2014-11-13 revision 48405) [i386-mingw32].
Run Code Online (Sandbox Code Playgroud)

另外,我一直在努力遵循执行路径.当它试图设置灯具时似乎失败了.它正在经历一个循环,它正在构建表的schema_cache.它查询schema_migrations和我的第一个自定义表"customers"(在此调用期间,它迭代此表上的每个似乎成功的列).

在接下来的电话中

ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.columns(table_name#String) 
Run Code Online (Sandbox Code Playgroud)

table_name的价值是零

不幸的是,我仍然足够新的ruby/rails我很难找到table_name值(schema_migrations,customers,nil,...)实际设置的位置.

有人可以帮助指出表格列表的来源,即构建schema_cache吗?

upgrade rake-test ruby-on-rails-4

2
推荐指数
1
解决办法
1390
查看次数