1.rspec
$ rails generate rspec:install
2.guard
$ bundle exec guard init rspec
3.加入默认 Guardfile
的代码,注意顶部的 require
require 'active_support/inflector' guard 'rspec', all_after_pass: false do . . . watch('config/routes.rb') # Custom Rails Tutorial specs watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb", (m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" : "spec/requests/#{m[1].singularize}_pages_spec.rb")] end watch(%r{^app/views/(.+)/}) do |m| (m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" : "spec/requests/#{m[1].singularize}_pages_spec.rb") end watch(%r{^app/controllers/sessions_controller\.rb$}) do |m| "spec/requests/authentication_pages_spec.rb" end . . . end
4.spork
$ bundle exec spork --bootstrap
5.将环境加载代码加入 Spork.prefork
代码块:spec/spec_helper.rb
require 'rubygems' require 'spork' Spork.prefork do ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'rspec/autorun' # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} # Checks for pending migrations before tests are run. # If you are not using ActiveRecord, you can remove this line. ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration) RSpec.configure do |config| # ## Mock Framework # # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: # # config.mock_with :mocha # config.mock_with :flexmock # config.mock_with :rr # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures config.fixture_path = "#{::Rails.root}/spec/fixtures" # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false # instead of true. config.use_transactional_fixtures = true # If true, the base class of anonymous controllers will be inferred # automatically. This will be the default behavior in future versions of # rspec-rails. config.infer_base_class_for_anonymous_controllers = false # Run specs in random order to surface order dependencies. If you find an # order dependency and want to debug it, you can fix the order by providing # the seed, which is printed after each run. # --seed 1234 config.order = "random" config.include Capybara::DSL end end Spork.each_run do # This code will be run each time you run your specs. end6.Guard 和 Spork 协作
$ bundle exec guard init spork7.为使用 Spork 而修改的
Guardfile
require 'active_support/inflector' guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do watch('config/application.rb') watch('config/environment.rb') watch('config/environments/test.rb') watch(%r{^config/initializers/.+\.rb$}) watch('Gemfile') watch('Gemfile.lock') watch('spec/spec_helper.rb') { :rspec } watch('test/test_helper.rb') { :test_unit } watch(%r{features/support/}) { :cucumber } end guard 'rspec', all_after_pass: false, cli: '--drb' do . . . end8.修改完之后,我们就可以通过
guard
命令同时启动 Guard 和 Spork 了:
相关推荐
Placing Bootstrap files in a Rails project 28 Bootstrap – the Sass way 33 Bootstrap through CDN 35 Summary 36 Chapter 3: Powering a Rails App with Bootstrap's Grid System 37 What is Bootstrap's grid ...
InspiniaAdmin 2.5 Rails_Seed_Project
Improve second level menu in Rails project Improve third level menu in md-skin Improve collapse-link function for nested panels Improve select2 style Improve menu style after collapse secend level ...
Build modern and progressive web applications with Vue.js and Ruby on Rails. As the Rails community embraces ... how to scaffold a Vue component in Rails, and how to configure Vue.js in a Rails project.
inspinia admin 2.5 中的 Rails_Seed_Project
rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails ...
[Pragmatic Bookshelf] Crafting Rails Applications Expert Practices for Everyday Rails Development (E-Book) ☆ 图书概要:☆ Rails 3 is a huge step forward. You can now easily extend the framework, ...
Improve second level menu in Rails project Improve third level menu in md-skin Improve collapse-link function for nested panels Improve select2 style Improve menu style after collapse secend level ...
Ruby on Rails Guides v2 - Ruby on Rails 4.2.5
《Ruby on Rails Tutorial》中文版(原书第2版,涵盖 Rails 4) Ruby 是一门很美的计算机语言,其设计原则就是“让编程人员快乐”。David Heinemeier Hansson 就是看重了这一点,才在开发 Rails 框架时选择了 Ruby...
一个用Ruby on Rails搭建的图片分享的网站项目.完整源代码
《Rails之道》按照Rails的各个子系统进行组织编排,分别介绍了Rails的环境、初始过程、配置和日志记录,Rails的分配器、控制器、页面生成和路由,REST、资源和Rails,ActiveRecord的基础、关联、验证和高级技巧,...
本资源是参照rails敏捷开发第四版书中的例子,rails的版本是rails3.2.6
adminlte-rails, AdminLTE Rails gem 将AdminLTE主题与 Rails 资产管道集成 AdminLTE Rails gem AdminLTE 是后端的高级 Bootstrap 主题。英镑 AdminLTE Rails gem 与 Rails 资产管道集成了英镑AdminLTE主题。安装将...
InspiniaAdmin 2.6.2.1 All_Seed_Project 这个包含所有的Seed Project! Angular_2_Seed_Project Angular_Seed_Project Angular_Seed_Project_Grunt ...Rails_Seed_Project ReactJS_Seed_Project Static_Seed_Project
中文世界唯一一本Rails 4.0.0 + Ruby 2.0.0 的自學書籍
使用Aptana+Rails开发Rails Web应用 有Aptana的安装配置等等,中文
rails文档 rails api 英文
Ruby on Rails helps you produce high-quality, beautiful-looking web applications quickly. You concentrate on creating the application, and Rails takes care of the details., Tens of thousands of ...