add pure ruby setup support

This commit is contained in:
John Bintz 2013-07-09 17:11:22 -04:00
parent afc0661343
commit 572e4019d7
6 changed files with 38 additions and 12 deletions

View File

@ -66,6 +66,10 @@ gem 'bintz-integration_testing_setup', :git => 'git://github.com/johnbintz/bintz
`bundle install`, then run `bundle exec bintz-integration_testing_setup`. It's best to do this on a pristine `bundle install`, then run `bundle exec bintz-integration_testing_setup`. It's best to do this on a pristine
project, but it may work on one that already has some stuff in it. project, but it may work on one that already has some stuff in it.
## Pure Ruby project?
Want to use this setup with something that's not Rails? Pass the `--pure-ruby` flag to `bintz-integration_testing_setup`.
## Gem setup ## Gem setup
You'll need several gems to pull this off, some of them custom gems: You'll need several gems to pull this off, some of them custom gems:

View File

@ -14,25 +14,36 @@ class BintzIntegrationTestingSetup < Thor
def gem_root def gem_root
Pathname(File.expand_path('../..', __FILE__)) Pathname(File.expand_path('../..', __FILE__))
end end
def rails
!options[:pure_ruby]
end
end end
desc 'install', 'Install my testing setup in your project' desc 'install', 'Install my testing setup in your project'
option :pure_ruby, type: :boolean
def install def install
require 'erb'
Bundler.with_clean_env do Bundler.with_clean_env do
additions = ERB.new(gem_root.join('skel/Gemfile-additions').read).result(binding)
if File.file?('Gemfile.penchant') #=> using Penchant if File.file?('Gemfile.penchant') #=> using Penchant
append_file('Gemfile.penchant', gem_root.join('skel/Gemfile-additions').read) append_file 'Gemfile.penchant', additions
system "penchant gemfile remote" system "penchant gemfile remote"
else else
append_file('Gemfile', gem_root.join('skel/Gemfile-additions').read) append_file 'Gemfile', additions
system "bundle" system "bundle"
end end
if !File.file?('features/support/env.rb') if rails && !File.file?('features/support/env.rb')
system "bundle exec rails g cucumber:install" system "bundle exec rails g cucumber:install"
end end
system 'bundle exec cuke-pack install' system 'bundle exec cuke-pack install'
FileUtils.touch 'Rakefile'
append_to_file 'Rakefile', <<-RB append_to_file 'Rakefile', <<-RB
Rake::Task['default'].clear_prerequisites Rake::Task['default'].clear_prerequisites
Rake::Task['default'].clear Rake::Task['default'].clear
@ -40,10 +51,12 @@ Rake::Task['default'].clear
task :default => :cucumber task :default => :cucumber
RB RB
if rails
system 'which phantomjs 2>/dev/null >/dev/null' system 'which phantomjs 2>/dev/null >/dev/null'
if $?.exitstatus != 0 if $?.exitstatus != 0
puts "For Poltergeist, install PhantomJS into your path: http://phantomjs.org/" puts "For Poltergeist, install PhantomJS into your path: http://phantomjs.org/"
end end
end
directory '.', '.' directory '.', '.'

View File

@ -1,18 +1,23 @@
<% if rails %>
gem 'semantic_rails_view_helpers', :git => 'git://github.com/johnbintz/semantic_rails_view_helpers.git' gem 'semantic_rails_view_helpers', :git => 'git://github.com/johnbintz/semantic_rails_view_helpers.git'
<% end %>
group :cucumber do group :cucumber do
gem 'cucumber' gem 'cucumber'
gem 'cucumber-rails'
gem 'database_cleaner'
gem 'capybara'
gem 'cuke-pack', :git => 'git://github.com/johnbintz/cuke-pack.git' gem 'cuke-pack', :git => 'git://github.com/johnbintz/cuke-pack.git'
gem 'foreman' gem 'foreman'
gem 'guard' gem 'guard'
gem 'guard-cucumber', :git => 'git://github.com/johnbintz/guard-cucumber.git', :branch => 'paths_from_profile' gem 'guard-cucumber', :git => 'git://github.com/johnbintz/guard-cucumber.git', :branch => 'paths_from_profile'
gem 'rb-fsevent' # => for mac systems gem 'rb-fsevent' # => for mac systems
gem 'rspec'
<% if rails %>
gem 'cucumber-rails'
gem 'database_cleaner'
gem 'capybara'
gem 'persistent_selenium', :git => 'git://github.com/johnbintz/persistent_selenium.git' gem 'persistent_selenium', :git => 'git://github.com/johnbintz/persistent_selenium.git'
gem 'poltergeist' gem 'poltergeist'
gem 'capybara-rails-log-inspection', :git => 'git://github.com/johnbintz/capybara-rails-log-inspection.git' gem 'capybara-rails-log-inspection', :git => 'git://github.com/johnbintz/capybara-rails-log-inspection.git'
gem 'rspec' <% end %>
end end

View File

@ -1,3 +1,4 @@
guard: guard -g wip guard: guard -g wip
<% if rails %>
ps: persistent_selenium start ps: persistent_selenium start
<% end %>

View File

@ -1,5 +1,6 @@
# capybara drivers for fast testing # capybara drivers for fast testing
# #
<% if rails %>
# this one runs your entire test suite # this one runs your entire test suite
require 'capybara/poltergeist' require 'capybara/poltergeist'
@ -22,3 +23,4 @@ class Capybara::Node::Element
end end
end end
<% end %>

View File

@ -1,3 +1,4 @@
<% if rails %>
# enable rails log inspection so you get errors in your console instead of the logs # enable rails log inspection so you get errors in your console instead of the logs
require 'capybara/rails-log-inspection/cucumber' require 'capybara/rails-log-inspection/cucumber'
<% end %>