diff --git a/README.md b/README.md index 775f9e7..6e25e3f 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/bin/bintz-integration_testing_setup b/bin/bintz-integration_testing_setup index 0789775..9d656c7 100755 --- a/bin/bintz-integration_testing_setup +++ b/bin/bintz-integration_testing_setup @@ -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 '.', '.' diff --git a/skel/Gemfile-additions b/skel/Gemfile-additions index 46a1d3c..357ff68 100644 --- a/skel/Gemfile-additions +++ b/skel/Gemfile-additions @@ -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 diff --git a/skel/root/Procfile.wip b/skel/root/Procfile.wip.tt similarity index 66% rename from skel/root/Procfile.wip rename to skel/root/Procfile.wip.tt index d3494f9..e816ef2 100644 --- a/skel/root/Procfile.wip +++ b/skel/root/Procfile.wip.tt @@ -1,3 +1,4 @@ guard: guard -g wip +<% if rails %> ps: persistent_selenium start - +<% end %> diff --git a/skel/root/features/support/drivers.rb b/skel/root/features/support/drivers.rb.tt similarity index 95% rename from skel/root/features/support/drivers.rb rename to skel/root/features/support/drivers.rb.tt index 08c6fcc..360f899 100644 --- a/skel/root/features/support/drivers.rb +++ b/skel/root/features/support/drivers.rb.tt @@ -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 %> diff --git a/skel/root/features/support/log_inspection.rb b/skel/root/features/support/log_inspection.rb.tt similarity index 84% rename from skel/root/features/support/log_inspection.rb rename to skel/root/features/support/log_inspection.rb.tt index 82171f3..d32f877 100644 --- a/skel/root/features/support/log_inspection.rb +++ b/skel/root/features/support/log_inspection.rb.tt @@ -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 %>