我正在尝试使用TestUnit设置Spork和Capybara,并且遇到了test.rb配置问题.
问题是Spork要求将config.cache_classes设置为false,以便在运行测试时可以反映模型中的更改,而无需一直重置Spork.
另一方面,Capybara似乎要求将config.cache_classes设置为true,否则集成测试似乎不起作用.
我只是在寻找任何可能的解决方案/解释.这是仅存在于TestUnit中的东西,还是这可能是一个错误,我应该这样报告?任何帮助将不胜感激!
所以在Rails 3.0.9应用程序上,我在1.9.2上使用Spork/Guard/RSpec/FactoryGirl.
我想知道如何让Spork/Guard自动更新我的工厂和区域设置.
我跟着RailsCasts的"我如何测试"截屏视频,然而我遇到了spork问题
$ guard
Guard is now watching at '/Users/darth/projects/auth-before'
Starting Spork for Test::Unit & RSpec
Couldn't find a supported test framework that begins with 'testunit'
Supported test frameworks:
( ) Cucumber
(*) RSpec
Legend: ( ) - not detected in project (*) - detected
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
Spork is ready and listening on 8989!
ERROR: Could not start Spork server for Test::Unit & RSpec. Make sure you can use it manually …Run Code Online (Sandbox Code Playgroud) 根据Ryan Bates的RailsCast(在Linux Mint 12下),我已经安装了防护和spork,并且防护过程在启动后立即显示"已杀死".运行"bundle exec guard --verbose"给出:
bundle exec guard --verbose DEBUG(12:17:27):命令执行:which notify-send
Guard使用NotifySend发送通知.
警卫正在观看'path_to_project'
DEBUG(12:17:27):Hook:为Guard :: Spork执行了start_begin
DEBUG(12:17:27):命令执行:ps aux | awk'/ spork/&&!/ awk/{print $ 2;}'
DEBUG(12:17:27):使用PID:8884杀死Spork服务器
杀害
我已经尝试调整guard gem文档的"高级Linux系统配置"(max_queued_events和max_user_instances,max_users_watches)中的值.没有比所有人的默认值高得多的快乐.
有任何想法吗?如果是这样,请提前感谢.到目前为止,Google-fu对此特定问题没有任何帮助.
我遇到了一个问题,我的测试设置中的所有内容,包括Spork的prefork块,都在重新加载并在每次运行时调用.虽然这是一个新的项目,但是即使有一个SSD,我也需要5-8秒的时间才能在测试开始之后启动测试.
我才意识到一切都重装,我异型它使用由Jo利斯描述的技术在这里,我已经包括那些挂要求,但显然没有帮助,因为这一切都被重新加载反正.然而,那是我注意到的时候:
加载套件测试,测试/控制器,测试/控制器/管理,测试/工厂,测试/功能/管理,测试/帮助,测试/帮助/管理,测试/集成,测试/模型,测试/支持
我不明白为什么它会重新加载一切.这是我第一次尝试设置minitest + spork + guard(我本应该用rspec,叹气),所以我希望这是一个愚蠢的事情.我包含了一切,希望有人碰到它或者很容易发现我错过的东西.提前致谢!
我的文件包括:
test_helper.rb中
require 'spork'
Spork.prefork do
#MiniTest::Rails.override_testunit!
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'guard'
require 'guard/interactors/readline'
require 'guard/ui'
require 'guard/interactors/coolline'
require 'guard/interactor'
require 'guard/dsl'
require 'guard/notifiers/rb_notifu'
require 'guard/notifier'
require 'guard/minitest/notifier'
require 'guard/minitest/runners/default_runner'
Dir[File.expand_path('test/support/*.rb')].each { |file| require file }
require "mocha"
Spork.trap_method(Rails::Application, :reload_routes!)
Spork.trap_method(Rails::Application::RoutesReloader, :reload!)
end
Run Code Online (Sandbox Code Playgroud)
Guardfile
guard 'bundler' do
watch('Gemfile')
# Uncomment next line if Gemfile contain `gemspec' command
# watch(/^.+\.gemspec/)
end
guard 'spork', :wait => 65, :test_unit => …Run Code Online (Sandbox Code Playgroud) 几个月以来,我在rails应用程序中成功地使用了sppec和rspec.现在我尝试将茉莉添加到这个游戏中,所以我添加到我的Gemfile中
gem 'headless'
gem 'jasmine'
gem 'jasmine-rails'
Run Code Online (Sandbox Code Playgroud)
Jasmine在独立模式下运行良好,但它需要为每次运行启动firefox,这对用户不太友好,我注意到它可以与spork一起使用.但是当我发射spork:
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
No runner found, attempting to compile...
make: *** No rule to make target `clean'. Stop.
which: no gmake in (/usr/lib/ruby/gems/1.9.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/java/bin:/opt/java/db/bin:/usr/bin/core_perl:/opt/qt/bin:/home/user/.gem/ruby/1.9.1/bin/)
which: no qmake-qt4 in (/usr/lib/ruby/gems/1.9.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/java/bin:/opt/java/db/bin:/usr/bin/core_perl:/opt/qt/bin:/home/user/.gem/ruby/1.9.1/bin/)
Failure to open file: /usr/lib/ruby/gems/1.9.1/gems/jasmine-headless-webkit-0.8.4/ext/jasmine-webkit-specrunner/Makefile
Unable to generate makefile for: specrunner.pro
true
/usr/lib/ruby/1.9.1/fileutils.rb:1371:in `initialize': Permission denied - /usr/lib/ruby/gems/1.9.1/gems/jasmine-headless-webkit-0.8.4/ext/jasmine-webkit-specrunner/Makefile (Errno::EACCES)
from /usr/lib/ruby/1.9.1/fileutils.rb:1371:in `open'
from /usr/lib/ruby/1.9.1/fileutils.rb:1371:in `block in copy_file'
from /usr/lib/ruby/1.9.1/fileutils.rb:1370:in `open'
from /usr/lib/ruby/1.9.1/fileutils.rb:1370:in `copy_file'
from …Run Code Online (Sandbox Code Playgroud) ruby-on-rails spork ruby-on-rails-3 jasmine ruby-on-rails-3.2
运行规范时,我也获得了数据库事务的所有输出:
lee$ rspec spec/mailers/
Connecting to database specified by database.yml
(0.1ms) BEGIN
User Exists (0.7ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = 'user@example.name' LIMIT 1
User Exists (0.4ms) SELECT 1 AS one FROM "users" WHERE "users"."auth_token" = '8bF72xsaxsSsidLvA1uD9Q' LIMIT 1
SQL (2.3ms) INSERT INTO "users" ("auth_token", "created_at", "email", "first_name", "last_name", "password_digest", "password_reset_token", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING "id" [["auth_token", "8bF70xsaEsSsidLvA1uD9Q"], ["created_at", Fri, 21 Dec 2012 14:55:40 UTC +00:00], ["email", "michale@swift.name"], …Run Code Online (Sandbox Code Playgroud) 我目前正在使用Rspec进行测试,以及Guard和Spork以方便使用.我注意到除非我退出并重新启动Guard,否则随机种子在运行之间不会改变.虽然这不是一个主要问题,但如果确实如此,它将会很方便.
任何人都知道改变事物的方法,以便每次运行测试时都使用新的种子?
我有Exception encountered: #<SystemExit: exit>错误,当尝试通过spork运行黄瓜.
功能/支持/ env.rb:
require 'rubygems'
require 'spork'
require 'cucumber/rails'
require 'pickle/world'
require "capybara/poltergeist"
Spork.prefork do
Capybara.javascript_driver = :poltergeist
end
Spork.each_run do
ActionController::Base.allow_rescue = false
begin
DatabaseCleaner[:mongoid].strategy = :truncation
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end
DatabaseCleaner[:mongoid].clean
Cucumber::Rails::Database.javascript_strategy = :truncation
end
Run Code Online (Sandbox Code Playgroud)
没有spork运行:
vagrant@lucid32:/vagrant$ bundle exec cucumber
WARNING: No DRb server is running. Running features locally:
Rack::File headers parameter replaces cache_control after …Run Code Online (Sandbox Code Playgroud)