Browse files

Use rails generators with the diesel command

  • Loading branch information...
1 parent 6761c04 commit 0d053bcced97ad3febed4c93081f89027c496675 @jferris jferris committed Jan 10, 2011
View
4 bin/diesel
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+
+require 'diesel/commands'
+
View
3 diesel.gemspec
@@ -15,6 +15,9 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.test_files = Dir['features/**/*']
+ s.default_executable = 'diesel'
+ s.executables = ['diesel']
+
s.has_rdoc = false
s.authors = ["thoughtbot, inc.", "Joe Ferris"]
View
20 features/rails_rake_tasks.feature → ...s/rails_rake_tasks_and_generators.feature
@@ -11,13 +11,15 @@ Feature: use Rails rake tasks when developing a diesel application
gem "sqlite3-ruby"
"""
When I add this library as a dependency
+ And I run "bundle install --local"
And I write to "Rakefile" with:
"""
require 'rubygems'
require 'bundler/setup'
require 'diesel/tasks'
"""
- When I write to "spec/models/post_spec.rb" with:
+ When I successfully run "bundle exec diesel generate model post title:string"
+ And I write to "spec/models/post_spec.rb" with:
"""
ENV["RAILS_ENV"] ||= 'test'
require "diesel/testing"
@@ -34,22 +36,8 @@ Feature: use Rails rake tasks when developing a diesel application
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"
+ And I run "bundle exec rspec --format documentation spec"
Then it should pass with:
"""
0 failures
View
4 lib/diesel/commands.rb
@@ -0,0 +1,4 @@
+APP_PATH = "diesel/testing"
+require 'bundler/setup'
+require 'rails/commands'
+
View
2 lib/diesel/testing/application.rb
@@ -22,8 +22,6 @@ class Application < Rails::Application
config.active_support.deprecation = :stderr
config.secret_token = "DIESEL" * 5 # so diesel
- protected
-
def require_environment!
initialize!
end

0 comments on commit 0d053bc

Please sign in to comment.