Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[#92] Add --webkit flag

By default, Capybara Webkit will be installed. However, Some folks don't
want/need it, and having QT as a dependency of Suspenders drastically
raises the bar in terms of ease of installation. See:

#70
  • Loading branch information...
commit 826c856516a81f6c6679a1c1e14dcc1827780d47 1 parent da91a2b
@croaky croaky authored
View
20 README.md
@@ -27,29 +27,27 @@ which will be appended to the default generated projectname/Gemfile.
It includes application gems like:
-* [Paperclip](https://github.com/thoughtbot/paperclip) for file uploads
-* [Formtastic](https://github.com/justinfrench/formtastic) for better forms
* [Airbrake](https://github.com/airbrake/airbrake) for exception notification
-* [Flutie](https://github.com/thoughtbot/flutie) for default CSS styles
* [Bourbon](https://github.com/thoughtbot/bourbon) for classy sass mixins
* [Clearance](https://github.com/thoughtbot/clearance) for authentication
+* [Flutie](https://github.com/thoughtbot/flutie) for default CSS styles
+* [Formtastic](https://github.com/justinfrench/formtastic) for better forms
+* [Paperclip](https://github.com/thoughtbot/paperclip) for file uploads
And testing gems like:
+* [Bourne](https://github.com/thoughtbot/bourne) and Mocha for stubbing and spying
* [Cucumber, Capybara, and Capybara Webkit](http://robots.thoughtbot.com/post/4583605733/capybara-webkit) for integration testing, including Javascript behavior
-* [RSpec](https://github.com/rspec/rspec) for awesome, readable isolation testing
* [Factory Girl](https://github.com/thoughtbot/factory_girl) for easier creation of test data
+* [RSpec](https://github.com/rspec/rspec) for awesome, readable isolation testing
* [Shoulda Matchers](http://github.com/thoughtbot/shoulda-matchers) for frequently needed Rails and RSpec matchers
* [Timecop](https://github.com/jtrupiano/timecop) for dealing with time
-* [Bourne](https://github.com/thoughtbot/bourne) and Mocha for stubbing and spying
-* [email_spec](https://github.com/bmabey/email-spec) for testing emails.
Other goodies
-------------
Suspenders also comes with:
-* [jQuery](https://github.com/jquery/jquery) for Javascript pleasantry
* Rails' flashes set up and in application layout.
* A few nice time formats.
@@ -72,6 +70,14 @@ You can optionally not include Clearance:
suspenders app --clearance false
+Capybara Webkit
+---------------
+
+You can optionally not include Capybara Webkit (which depends on QT being
+installed on your machine):
+
+ suspenders app --webkit false
+
Dependencies
------------
View
10 features/clearance_false.feature
@@ -0,0 +1,10 @@
+@disable-bundler
+Feature: Skipping Clearance
+
+ Scenario: --clearance=false
+ When I suspend a project called "test_project" with:
+ | argument | value |
+ | --clearance | false |
+ And I cd to the "test_project" root
+ Then "clearance" should not be installed
+ And I can cleanly rake the project
View
4 features/creating_a_heroku_app.feature → features/heroku_true.feature
@@ -1,7 +1,7 @@
@disable-bundler
-Feature: Creating a Heroku app when suspending a project
+Feature: Creating a Heroku app
- Scenario: User uses the --heroku=true command line argument
+ Scenario: --heroku=true
When I suspend a project called "test_project" with:
| argument | value |
| --heroku | true |
View
13 features/skipping_clearance.feature
@@ -1,13 +0,0 @@
-@disable-bundler
-Feature: Skipping clearance
- As a developer
- I want to suspend an app without clearance
- So that I can build apps without users, or with other authentication libraries
-
- Scenario: Passing --clearance=false
- When I suspend a project called "test_project" with:
- | argument | value |
- | --clearance | false |
- And I cd to the "test_project" root
- Then "clearance" should not be installed
- And I can cleanly rake the project
View
5 features/step_definitions/gem_steps.rb
@@ -1,5 +0,0 @@
-Then /^"(.*)" should not be installed$/ do |gem_name|
- in_current_dir do
- system("bundle show #{gem_name} 2>&1 > /dev/null").should be_false
- end
-end
View
3  features/step_definitions/heroku_steps.rb
@@ -1,3 +0,0 @@
-Then /^the "([^"]*)" heroku app should exist$/ do |app_name|
- FakeHeroku.should have_created_app(app_name)
-end
View
14 features/step_definitions/shell_steps.rb → ...ures/step_definitions/suspenders_steps.rb
@@ -53,3 +53,17 @@
Then I see a successful response in the shell
}
end
+
+Then /^"(.*)" should not be installed$/ do |gem_name|
+ in_current_dir do
+ system("bundle show #{gem_name} 2>&1 > /dev/null").should be_false
+ end
+end
+
+Then /^"(.*)" should not be included in "(.*)"$/ do |content, file_path|
+ check_file_content file_path, content, false
+end
+
+Then /^the "([^"]*)" heroku app should exist$/ do |app_name|
+ FakeHeroku.should have_created_app(app_name)
+end
View
11 features/webkit_false.feature
@@ -0,0 +1,11 @@
+@disable-bundler
+Feature: Skipping Capybara Webkit
+
+ Scenario: --webkit=false
+ When I suspend a project called "test_project" with:
+ | argument | value |
+ | --webkit | false |
+ And I cd to the "test_project" root
+ Then "capybara-webkit" should not be installed
+ And "webkit" should not be included in "features/support/env.rb"
+ And I can cleanly rake the project
View
33 lib/suspenders/app_builder.rb
@@ -55,17 +55,29 @@ def add_jquery_ui
end
def use_postgres_config_template
- template 'postgresql_database.yml.erb', 'config/database.yml', :force => true
+ template 'postgresql_database.yml.erb', 'config/database.yml',
+ :force => true
end
def create_database
bundle_command 'exec rake db:create'
end
- def include_custom_gems
+ def add_custom_gems
additions_path = find_in_source_paths 'Gemfile_additions'
new_gems = File.open(additions_path).read
- inject_into_file 'Gemfile', "\n#{new_gems}", :after => /gem 'jquery-rails'/
+ inject_into_file 'Gemfile', "\n#{new_gems}",
+ :after => /gem 'jquery-rails'/
+ end
+
+ def add_clearance_gem
+ inject_into_file 'Gemfile', "\ngem 'clearance'",
+ :after => /gem 'jquery-rails'/
+ end
+
+ def add_capybara_webkit_gem
+ inject_into_file 'Gemfile', "\n gem 'capybara-webkit', '~> 0.11.0'",
+ :after => /gem 'cucumber-rails', '1.3.0'/
end
def configure_rspec
@@ -95,11 +107,18 @@ def generate_rspec
'# config.mock_with :mocha', 'config.mock_with :mocha'
end
- def generate_cucumber
+ def generate_cucumber(options = {})
generate 'cucumber:install', '--rspec', '--capybara'
- copy_file 'features_support_env.rb', 'features/support/env.rb', :force => true
inject_into_file 'config/cucumber.yml',
' -drb -r features', :after => %{default: <%= std_opts %> features}
+ copy_file 'features_support_env.rb', 'features/support/env.rb',
+ :force => true
+
+ if options[:webkit]
+ inject_into_file 'features/support/env.rb',
+ "\n Capybara.javascript_driver = :webkit",
+ :after => /Capybara.default_selector = :css/
+ end
end
def setup_guard_spork
@@ -206,9 +225,5 @@ def setup_default_rake_task
'task(:default).clear\ntask :default => [:spec, :cucumber]'
end
end
-
- def add_clearance_gem
- inject_into_file 'Gemfile', "\ngem 'clearance'", :after => /gem 'jquery-rails'/
- end
end
end
View
21 lib/suspenders/generators/app_generator.rb
@@ -3,17 +3,20 @@
module Suspenders
class AppGenerator < Rails::Generators::AppGenerator
+ class_option :clearance, :type => :boolean, :aliases => '-C', :default => true,
+ :desc => 'Add the Clearance Rails authentication library'
+
class_option :database, :type => :string, :aliases => '-d', :default => 'postgresql',
:desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})"
- class_option :skip_test_unit, :type => :boolean, :aliases => '-T', :default => true,
- :desc => 'Skip Test::Unit files'
-
class_option :heroku, :type => :boolean, :aliases => '-H', :default => false,
:desc => 'Create staging and production heroku apps'
- class_option :clearance, :type => :boolean, :aliases => '-C', :default => true,
- :desc => 'Add the clearance Rails authentication library'
+ class_option :skip_test_unit, :type => :boolean, :aliases => '-T', :default => true,
+ :desc => 'Skip Test::Unit files'
+
+ class_option :webkit, :type => :boolean, :aliases => '-W', :default => true,
+ :desc => 'Add the Capybara Webkit Javascript integration testing library'
def finish_template
invoke :suspenders_customization
@@ -75,12 +78,16 @@ def add_jquery_ui
end
def customize_gemfile
- build :include_custom_gems
+ build :add_custom_gems
if options[:clearance]
build :add_clearance_gem
end
+ if options[:webkit]
+ build :add_capybara_webkit_gem
+ end
+
bundle_command 'install'
end
@@ -99,7 +106,7 @@ def configure_app
build :configure_rspec
build :configure_action_mailer
build :generate_rspec
- build :generate_cucumber
+ build :generate_cucumber, :webkit => options[:webkit]
build :setup_guard_spork
build :add_email_validator
build :setup_default_rake_task
View
1  templates/Gemfile_additions
@@ -19,7 +19,6 @@ end
group :test do
gem 'cucumber-rails', '1.3.0'
- gem 'capybara-webkit', '~> 0.11.0'
gem 'factory_girl_rails'
gem 'bourne'
gem 'database_cleaner'
View
1  templates/features_support_env.rb
@@ -6,7 +6,6 @@
require 'cucumber/rails'
Capybara.default_selector = :css
- Capybara.javascript_driver = :webkit
DatabaseCleaner.strategy = :truncation
end

0 comments on commit 826c856

Please sign in to comment.
Something went wrong with that request. Please try again.