Permalink
Browse files

Enable Rails rake tasks in Diesel engines

  • Loading branch information...
1 parent 7ceb123 commit 6761c04dfd3b3d1e852872c9bec4ae3b9d83b812 @jferris jferris committed Jan 10, 2011
@@ -0,0 +1,58 @@
+@disable-bundler
+Feature: use Rails rake tasks when developing a diesel application
+
+ Scenario: create a disel engine and use Rails rake tasks
+ Given a directory named "testengine"
+ When I cd to "testengine"
+ And I write to "Gemfile" with:
+ """
+ gem "rspec-rails", "~> 2.3.0"
+ gem "rails", "~> 3.0.3"
+ gem "sqlite3-ruby"
+ """
+ When I add this library as a dependency
+ And I write to "Rakefile" with:
+ """
+ require 'rubygems'
+ require 'bundler/setup'
+ require 'diesel/tasks'
+ """
+ When I write to "spec/models/post_spec.rb" with:
+ """
+ ENV["RAILS_ENV"] ||= 'test'
+ require "diesel/testing"
+ require 'rspec/rails'
+
+ describe Post do
+ it "has a title" do
+ Post.new.should respond_to(:title)
+ end
+ end
+ """
+ When I write to "app/models/post.rb" with:
+ """
+ class Post < ActiveRecord::Base
+ end
+ """
+ When I write to "db/migrate/001_create_posts.rb" with:
+ """
+ class CreatePosts < ActiveRecord::Migration
+ def self.up
+ create_table :posts do |table|
+ table.string :title
+ end
+ end
+
+ def self.down
+ drop_table :posts
+ end
+ end
+ """
+ When I successfully run "rake db:create db:migrate db:schema:dump db:test:prepare"
+ When I run "bundle exec rspec --format documentation spec"
+ Then it should pass with:
+ """
+ 0 failures
+ """
+ Then at least one example should have run
+
View
@@ -0,0 +1,4 @@
+require 'rake'
+require 'diesel/testing/application'
+
+Diesel::Testing::Application.load_tasks
@@ -21,6 +21,17 @@ class Application < Rails::Application
config.action_mailer.delivery_method = :test
config.active_support.deprecation = :stderr
config.secret_token = "DIESEL" * 5 # so diesel
+
+ protected
+
+ def require_environment!
+ initialize!
+ end
+
+ def initialize!
+ FileUtils.mkdir_p(Rails.root.join("db").to_s)
+ super
+ end
end
end
end
@@ -1,6 +1,12 @@
-test: &test
+development:
adapter: sqlite3
- database: tmp/test.sqlite3
+ database: db/development.sqlite3
+ pool: 5
+ timeout: 5000
+
+test:
+ adapter: sqlite3
+ database: db/test.sqlite3
pool: 5
timeout: 5000

0 comments on commit 6761c04

Please sign in to comment.