Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Specs working again.

  • Loading branch information...
commit b18f71bd5ab876ee57b5fa1426c614d12b33bf81 1 parent 0c96ad6
@balvig authored
View
2  Rakefile
@@ -6,7 +6,7 @@ rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
-APP_RAKEFILE = File.expand_path("../spec/dummy/example_app/Rakefile", __FILE__)
+APP_RAKEFILE = File.expand_path("../spec/example_app/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'
require 'rspec/core/rake_task'
View
1  chili.gemspec
@@ -23,5 +23,4 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'jquery-rails'
gem.add_development_dependency 'capybara'
gem.add_development_dependency 'sqlite3'
- gem.add_development_dependency 'genspec'
end
View
3  spec/dummy/app/app/controllers/application_controller.rb
@@ -0,0 +1,3 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+end
View
4 spec/dummy/app/config/application.rb
@@ -4,9 +4,11 @@
Bundler.require
require "chili"
+Dir.glob(File.expand_path('../../vendor/chili/*', __FILE__)).each do |dir|
+ require File.basename(dir)
+end
module Dummy
class Application < Rails::Application
end
end
-
View
3  spec/dummy/app/config/boot.rb
@@ -6,3 +6,6 @@
require 'bundler'
Bundler.setup
end
+
+$:.unshift File.expand_path('../../../../../lib', __FILE__)
+$:.unshift File.expand_path('../../vendor/chili/blank_extension/lib', __FILE__)
View
25 spec/dummy/app/config/database.yml
@@ -0,0 +1,25 @@
+# SQLite version 3.x
+# gem install sqlite3
+#
+# Ensure the SQLite 3 gem is defined in your Gemfile
+# gem 'sqlite3'
+development:
+ adapter: sqlite3
+ database: db/development.sqlite3
+ pool: 5
+ timeout: 5000
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ adapter: sqlite3
+ database: db/test.sqlite3
+ pool: 5
+ timeout: 5000
+
+production:
+ adapter: sqlite3
+ database: db/production.sqlite3
+ pool: 5
+ timeout: 5000
View
3  .../example_app/vendor/chili/invites_extension/lib/generators/invites_extension_generator.rb
@@ -0,0 +1,3 @@
+class InvitesExtensionGenerator < Rails::Generators::Base
+ include Chili::GeneratorProxy
+end
View
3  spec/example_app/vendor/chili/social_extension/lib/generators/social_extension_generator.rb
@@ -0,0 +1,3 @@
+class SocialExtensionGenerator < Rails::Generators::Base
+ include Chili::GeneratorProxy
+end
View
8 spec/generators/chili/extension_generator_spec.rb
@@ -1,13 +1,11 @@
require 'spec_helper'
-describe 'ChiliGenerator' do
- describe 'rails g chili EXTENSION_NAME' do
+describe 'ExtensionGenerator' do
+ describe 'rails g chili:extension NAME' do
let(:app) { DummyApp.new }
let(:template_path) { File.expand_path("../../../dummy/blank_extension", __FILE__) }
- before do
- app.setup!
- end
+ before { app.setup! }
it 'creates a new extension with a correct file structure and appends it to the gemfile' do
puts `cd #{app.path} && rails g chili:extension blank`
View
34 spec/generators/chili/generator_proxy_spec.rb
@@ -1,24 +1,28 @@
require 'spec_helper'
-require 'rails/generators'
-module BlankExtension ; end #Dummy engine
-class BlankExtensionGenerator < Rails::Generators::Base
- include Chili::GeneratorProxy
-end
+describe Chili::GeneratorProxy do
+ let(:app) { DummyApp.new }
-describe BlankExtensionGenerator do
- context 'given no options' do
- before do
- ARGV.clear
- ARGV << 'scaffold'
- ARGV << 'post'
- end
+ before do
+ app.setup!
+ puts `cd #{app.path} && rails g chili:extension blank`
+ end
- it "works" do
- binding.pry
- #BlankExtensionGenerator.start#(ARGV, destination_root: '/tmp')
+
+ context 'running generator from a newly created extension' do
+ it "generates resources properly" do
+ puts `cd #{app.path} && rails g blank_extension scaffold post`
+ File.exist?(File.join(app.path, 'vendor/chili/blank_extension/app/controllers/blank_extension/posts_controller.rb')).should be_true
+ File.exist?(File.join(app.path, 'vendor/chili/blank_extension/app/assets/stylesheets/blank_extension/posts.css')).should be_true
end
+ end
+ context 'passing in options' do
+ it "passes options on to rails generator" do
+ puts `cd #{app.path} && rails g blank_extension scaffold post --stylesheets=false`
+ File.exist?(File.join(app.path, 'vendor/chili/blank_extension/app/controllers/blank_extension/posts_controller.rb')).should be_true
+ File.exist?(File.join(app.path, 'vendor/chili/blank_extension/app/assets/stylesheets/blank_extension/posts.css')).should be_false
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.