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

View File

@ -1,18 +1,23 @@
<% if rails %>
gem 'semantic_rails_view_helpers', :git => 'git://github.com/johnbintz/semantic_rails_view_helpers.git'
<% end %>
group :cucumber do
gem 'cucumber'
gem 'cucumber-rails'
gem 'database_cleaner'
gem 'capybara'
gem 'cuke-pack', :git => 'git://github.com/johnbintz/cuke-pack.git'
gem 'foreman'
gem 'guard'
gem 'guard-cucumber', :git => 'git://github.com/johnbintz/guard-cucumber.git', :branch => 'paths_from_profile'
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 'poltergeist'
gem 'capybara-rails-log-inspection', :git => 'git://github.com/johnbintz/capybara-rails-log-inspection.git'
gem 'rspec'
<% end %>
end

View File

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

View File

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