Rails-Carrot部分参考Capybara,支持原生的测试Gem驱动,主要是供喜欢用Celerity或者原生浏览器测试Driver。
支持远程,本地,本地外部ruby运行服务器 进行集成测试。
插件地址: http://github.com/sloanwu/carrot
简要介绍,以集成Celerity(需要使用JRuby)为例
You can use carrot with celerity, or another driver.
1. Rails Gemfile
gem 'rails-carrot', :require => 'carrot'
2. add a celerity_helper
/spec/celerity_helper.rb
3. Add some code in celerity_helper
require 'database_cleaner'
require 'celerity' # You can change driver
require 'carrot'
ENV["RAILS_ENV"] = 'celerity' # You can change it with your environment.
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
4. Three test styles
If you don't use JRuby, you just can use Remote and Local.
a) Remote
Carrot.configure do |config|
config.run_server = false
config.app_host = "www.google.com"
end
Carrot.register_driver(Celerity::Browser.new)
b) Local
Carrot.configure do |config|
config.run_server = true
end
Carrot.register_driver(Celerity::Browser.new)
c) Local, server with external ruby, You should use jruby to run RSpec.
Carrot.configure do |config|
config.run_server = true
config.external_ruby = true
config.rails_command = "~/.rvm/gems/ruby-1.9.2-p0/bin/rails s -e celerity -p 3001"
config.project_path = "#{Rails.root}"
config.server_port = 3001
# config.server_debug = true
end
Carrot.register_driver(Celerity::Browser.new)
RSpec.configure do |config|
DatabaseCleaner.strategy = :truncation
config.before :each do
@browser = Carrot.driver # get native driver
DatabaseCleaner.clean
end
config.after :all do
DatabaseCleaner.clean
end
config.use_transactional_fixtures = false
end
5 Test
a) get url
Carrot.url(path)
eg:
Carrot.url('/') => http://host/
Carrot.url('/hello') => http://host/hello
b) get native browser driver
Carrot.driver
6 FAQ
a) Does Carrot support server with external ruby?
Yes, but it just supports jruby run rspec and run server using external ruby. I use jruby to create native java process to run server using external ruby.
If you want to use ruby to run rspec and run server using external ruby, you can create a new server class to support it or wait for my upgrade.
分享到:
相关推荐
rails-angular-postgres-and-bootstrap-second-edition 英文原版
rails-documentation-2-0-2
rails-documentation-1-2-1.zip
rails-documentation-1-2-0-rc1.chm
Ajax-Rails-4-AJAX-modal-form-render-JS-response-as-table-row.zip,rails 4 ajax模式表单将js响应呈现为表行,ajax代表异步javascript和xml。它是多种web技术的集合,包括html、css、json、xml和javascript。它用于...
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
ruby on rails的帮助文档,对学习和使用ror的朋友很有帮助
jquery-fileupload-rails, 用于 Rails的jQuery文件上传集成 Rails 文件上传jQuery-File-Plugin 是一个文件上传插件,由的Tschan 。 jQuery文件上传功能多文件选择。drag&拖放支持。进度栏和jQuery预览图像。 支持...
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
minitest-rails, Rails的Minitest集成 minitestRails 5的Minitest集成 安装gem install minitest-rails这将安装以下宝石:minitest配置创建一个新的Rail
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
guardrails-engine-output-schema-validator --help Usage: guardrails-engine-output-schema-validator [options] Options: -V, --version output the version number -s, --stdin Read from stdin -f, --file...
webpack-rails, 将 web pack与你的Ruby on Rails 应用程序集成 不再维护webpack-rails 不再被维护。 有关详细信息,请参阅 #90. web pack-railsweb pack 为你提供了将 web pack集成到现有的Ruby on Rails 应用程序中...
如果你想要一个新版本运行 $ rake update 并提交拉取请求 安装 将此行添加到应用程序的 Gemfile 中: gem 'ember_simple_auth-rails' 然后执行: $ bundle 或者自己安装: $ gem install ember_simple_auth-...
从 Assets Pipeline 到 Webpack,Rails 6 的前端方案们From assets pipeline to web pack,the R
rails-hackernews-reddit-producthunt-clone, 黑客 news/reddit/social 链接分享网站 用 Rails 构建 Rails 上的 Reddit-Hackernews-ProductHunt克隆演示 这是一个 readme.md的Ruby on Rails 应用程序,模仿了 Hacker...
Rails的Clojurescript集成类似于webpack-rails
2-94街机外星风格射击游戏源码On Rails Shooter Template 1.202-94街机外星风格射击游戏源码On Rails Shooter Template 1.202-94街机外星风格射击游戏源码On Rails Shooter Template 1.202-94街机外星风格射击游戏...
tinymce-rails-imageupload, 用于TinyMCE和 Rails的映像上传插件,带有资产管道 重要说明:这个版本正在改写为 TinyMCE 4. x,,目前还没有得到很好的测试。 使用你自己的风险,反馈欢迎。 对于稳定版本目标 TinyMCE ...
从头开始创建Rails API 学习目标 创建仅API的Rails构建 介绍 在最后几节课中,我们了解了如何轻松调整Rails的MVC结构来呈现JSON。 Rails足够灵活,能够响应不同的格式,并且可以立即使用。 但是,出于在JavaScript和...