Skip to content

Instantly share code, notes, and snippets.

@koduki
Created October 31, 2010 03:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koduki/656091 to your computer and use it in GitHub Desktop.
Save koduki/656091 to your computer and use it in GitHub Desktop.
# dm-rails付きのrailsでプロジェクトを作成.
rails new rails_example -m http://datamapper.org/templates/rails.rb
cd rails_example
# cucumebr等を追加. 2010/10/31現在のgemはバグがあるため野良gitから取得.
cat > gemfile.patch
--- Gemfile 2010-10-31 11:25:20.286666717 +0900
+++ Gemfile 2010-10-31 11:23:19.700000054 +0900
@@ -36,8 +36,10 @@
gem 'dm-observer', DM_VERSION
group(:development, :test) do
- gem 'cucumber'
- gem 'cucumber-rails', :git => "http://github.com/robholland/cucumber-rails.git"
+
+ # Uncomment this if you want to use rspec for testing your application
+
+ # gem 'rspec-rails', '~> 2.0.1'
# To get a detailed overview about what queries get issued and how long they take
# have a look at rails_metrics. Once you bundled it, you can run
# パッチの適用
patch -p0 < gemfile.patch
rm gemfile.patch
# install gem
bundle install vendor/bundle
# initialize cucumber
ruby script/rails g cucumber:install --rspec --capybara
bundle install
# 対応してないっぽいのでコメントアウト
perl -i -p -e "s/Cucumber::Rails::World.use_transactional_fixtures = true/#Cucumber::Rails::World.use_transactional_fixtures = true/g" features/support/env.rb
# dm-rails用のトランザクション操作を追加
cat > features/support/datapapper.rb
Before do
repository(:default) do |repository|
transaction = DataMapper::Transaction.new(repository)
transaction.begin
repository.adapter.push_transaction(transaction)
end
end
After do
repository(:default).adapter.pop_transaction.rollback
end
# cucumberのcreateのジェネレータを修正
perl -i -p -e 's/<%= class_name %>.create!\(<%= plural_name %>.hashes\)/<%= plural_name %>.hashes.each do |params|\n <%= class_name %>.create params\n end/' ./vendor/bundle/ruby/1.9.1/bundler/gems/cucumber-rails-*/templates/feature/steps.erb
# db:test:prepareを追加.
cat > database.patch
--- vendor/bundle/ruby/1.9.1/gems/dm-rails-1.0.4/lib/dm-rails/railties/database.rake 2010-10-31 10:32:52.343333384 +0900
+++ vendor/bundle/ruby/1.9.1/gems/dm-rails-1.0.4/lib/dm-rails/railties/database.rake 2010-10-31 08:54:00.476666719 +0900
@@ -6,10 +6,6 @@
desc 'Create the database, load the schema, and initialize with the seed data'
task :setup => [ 'db:create', 'db:automigrate', 'db:seed' ]
- namespace :test do
- task :prepare => ['db:setup']
- end
-
namespace :create do
desc 'Create all the local databases defined in config/database.yml'
task :all => :environment do
# パッチの適用
patch -p0 < database.patch
rm database.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment