Skip to content

Instantly share code, notes, and snippets.

@nijitaro
Forked from ukstudio/Gemfile
Created September 7, 2010 18:06
Show Gist options
  • Save nijitaro/568754 to your computer and use it in GitHub Desktop.
Save nijitaro/568754 to your computer and use it in GitHub Desktop.
Rails 3 + rspec2 + mongoid + Factory_girl + autotest(growl)
# Include plugins
require 'autotest/fsevent'
require 'autotest/growl'
# Skip some paths
Autotest.add_hook :initialize do |autotest|
%w{.git .DS_Store ._* vendor}.each { |exception| autotest.add_exception(exception) }
false
end
#
# Rails 3 + rspec2 + mongoid + Factory_girl + autotest(growl)
#
# thanks to
# http://ukstudio.jp/2010/09/03/rspec2_rails3_autotes/
# http://d.hatena.ne.jp/tkrd/20100814/1281752294
# http://blog.madoro.org/mn/74
# http://blog.madoro.org/mn/76
# http://wiki.github.com/rspec/rspec/autotest/
#
$ mkdir demo; cd demo
$ vi Gemfile
//use Gemfile
$ bundle install vendor/bundle
$ bundle exec rails new . -T --skip-activerecord
$ rails g mongoid:config
$ rails g rspec:install
$ vi config/application.rb
- require 'rails/all'
+ require "action_controller/railtie"
+ require "action_mailer/railtie"
+ require "active_resource/railtie"
config.filter_parameters += [:password]
+ config.generators do |g|
+ g.orm :mongoid
+ g.test_framework :rspec, :fixture => true
+ g.fixture_replacement :factory_girl, :dir => "spec/factories"
+ end
+ config.mongoid.logger = Logger.new($stdout, :warn)
$ vi spec/spec_helper.rb
// use spec_helper.rb
$ vi ~/.autotest
// use .autotest
$ rails g model user
$ rake
$ autotest
source 'http://rubygems.org'
gem 'rails', '3.0.0'
gem 'mongoid', '2.0.0.beta.17'
gem 'bson_ext', '1.0.4'
gem 'rails3-generators'
group :development, :test do
gem 'rspec','>=2.0.0.beta.20'
gem 'rspec-rails','>=2.0.0.beta.20'
gem 'ZenTest'
gem 'autotest'
gem 'autotest-rails'
gem 'autotest-fsevent'
gem 'autotest-growl'
gem 'webrat'
gem 'factory_girl_rails', :require => nil
end
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'mongoid'
require 'factory_girl'
Factory.find_definitions
# 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}
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
config.mock_with :rspec
config.before :all do
Mongoid.master.collections.
select { |c| c.name != 'system.indexes' }.each(&:drop)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment