Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove support for Rails2

  • Loading branch information...
commit ea033b2053143ca610b61a3165fb724a4f57ce51 1 parent 79f943c
@aslakhellesoy aslakhellesoy authored
Showing with 171 additions and 496 deletions.
  1. +0 −22 HACKING.rdoc
  2. +3 −2 History.txt
  3. +74 −0 README.md
  4. +0 −68 README.rdoc
  5. +0 −1  VERSION
  6. +18 −19 cucumber-rails.gemspec
  7. +1 −0  features/no_database.feature
  8. +0 −13 generators/cucumber/USAGE
  9. +0 −46 generators/cucumber/cucumber_generator.rb
  10. +0 −12 generators/feature/USAGE
  11. +0 −47 generators/feature/feature_generator.rb
  12. +1 −5 lib/cucumber/rails.rb
  13. +0 −23 lib/cucumber/rails/version.rb
  14. +0 −16 lib/cucumber/rails2.rb
  15. +0 −29 lib/cucumber/rails2/action_controller.rb
  16. +0 −31 lib/generators/cucumber/feature/feature_base.rb
  17. +7 −16 lib/generators/cucumber/feature/feature_generator.rb
  18. 0  {templates/feature → lib/generators/cucumber/feature/templates}/feature.erb
  19. 0  {templates/feature → lib/generators/cucumber/feature/templates}/steps.erb
  20. +0 −133 lib/generators/cucumber/install/install_base.rb
  21. +67 −13 lib/generators/cucumber/install/install_generator.rb
  22. 0  {templates/install → lib/generators/cucumber/install/templates}/config/cucumber.yml.erb
  23. 0  {templates/install → lib/generators/cucumber/install/templates}/environments/cucumber.rb.erb
  24. 0  {templates/install → lib/generators/cucumber/install/templates}/script/cucumber
  25. 0  ...ns/capybara_steps.rb.erb → lib/generators/cucumber/install/templates/step_definitions/web_steps.rb.erb
  26. 0  {templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_cs.rb.erb
  27. 0  {templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_da.rb.erb
  28. 0  {templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_de.rb.erb
  29. 0  {templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_es.rb.erb
  30. 0  {templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_ja.rb.erb
  31. 0  {templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_ko.rb.erb
  32. 0  {templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_no.rb.erb
  33. 0  {templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_pt-BR.rb.erb
  34. 0  {templates/install → lib/generators/cucumber/install/templates}/support/_rails_each_run.rb.erb
  35. 0  {templates/install → lib/generators/cucumber/install/templates}/support/_rails_prefork.rb.erb
  36. 0  {templates/install → lib/generators/cucumber/install/templates}/support/capybara.rb
  37. 0  {templates/install → lib/generators/cucumber/install/templates}/support/edit_warning.txt
  38. 0  {templates/install → lib/generators/cucumber/install/templates}/support/paths.rb
  39. 0  {templates/install → lib/generators/cucumber/install/templates}/support/rails.rb.erb
  40. 0  {templates/install → lib/generators/cucumber/install/templates}/support/rails_spork.rb.erb
  41. 0  {templates/install → lib/generators/cucumber/install/templates}/support/selectors.rb
  42. 0  {templates/install → lib/generators/cucumber/install/templates}/support/web_steps_warning.txt
  43. 0  {templates/install → lib/generators/cucumber/install/templates}/tasks/cucumber.rake.erb
View
22 HACKING.rdoc
@@ -1,22 +0,0 @@
-= Hacking on Cucumber-Rails
-
-If you have a bugfix or a new feature you want to contribute, please fork on Github and make your own feature branch:
-
- git clone git@github.com:you/cucumber-rails.git
- git checkout -b 87-my-awesome-bugfix
-
-The feature branch should contain a ticket number (if appliccable) and a descriptive name that aligns with the ticket name.
-When you think you're done send a pull request.
-
-== Setting up your environment
-
-I strongly recommend rvm and ruby 1.9.2. When you have that, cd into your cucumber-rails repository and:
-
- gem install bundler
- bundle install
-
-== Running all features
-
- rake cucumber
-
-One of the features uses MongoDB, which needs to be running in order to make features/mongoid.feature to pass.
View
5 History.txt
@@ -1,7 +1,8 @@
-== In Git
+== 0.5.0.beta1
-* Removed database cleaner strategy overrides (#134 Daniel Morrison, Daniel Duvall)
+* Dropped support for Rails 2 (Aslak Hellesøy)
* Dropped support for Webrat (Aslak Hellesøy)
+* Removed database cleaner strategy overrides (#134 Daniel Morrison, Daniel Duvall)
* Upgrade to Capybara 1.0.0.beta1 or newer (#130 Simon Menke, Klaus Hartl, Aslak Hellesøy)
* Generated paths.rb cleanup (#133 Tim Pope)
* Allow css pseudo-classes in scopers (#122 twalpole)
View
74 README.md
@@ -0,0 +1,74 @@
+# Cucumber-Rails
+
+Cucumber-Rails brings Cucumber to Rails3. It contains 2 generators - one
+for bootstrapping your Rails app for Cucumber, and a second one for generating features.
+
+Cucumber-Rails also contains Cucumber Step Definitions that wrap Capybara,
+giving you a head start for writing Cucumber features against your Rails app.
+
+## Installation
+
+Before you can use the generator, add the gem to your project's Gemfile as follows:
+
+ group :test do
+ gem 'cucumber-rails'
+ # database_cleaner is not required, but highly recommended
+ gem 'database_cleaner'
+ end
+
+Then install it by running:
+
+ bundle install
+
+Learn about the various options:
+
+ ruby rails generate cucumber:install --help
+
+Finally, bootstrap your Rails app, for example:
+
+ rails generate cucumber:install
+
+## Generating a Cucumber feature
+
+IMPORTANT: Only do this if you are new to Cucumber. We recommend you write your
+Cucumber features by hand once you get the hang of it.
+
+Example:
+
+ ruby rails generate cucumber:feature post title:string body:text published:boolean
+ ruby rails generate scaffold post title:string body:text published:boolean
+ rake db:migrate
+ rake cucumber
+
+## Running Cucumber
+
+With Rake:
+
+ rake cucumber
+
+Without Rake:
+
+ [bundle exec] cucumber
+
+## Hacking on Cucumber-Rails
+
+If you have a bugfix or a new feature you want to contribute, please fork on Github and make your own feature branch:
+
+ git clone git@github.com:you/cucumber-rails.git
+ git checkout -b 87-my-awesome-bugfix
+
+The feature branch should contain a ticket number (if applicable) and a descriptive name that aligns with the ticket name.
+When you think you're done send a pull request.
+
+### Setting up your environment
+
+I strongly recommend rvm and ruby 1.9.2. When you have that, cd into your cucumber-rails repository and:
+
+ gem install bundler
+ bundle install
+
+### Running all features
+
+ rake cucumber
+
+One of the features uses MongoDB, which needs to be running in order to make features/mongoid.feature to pass.
View
68 README.rdoc
@@ -1,68 +0,0 @@
-= Cucumber-Rails
-
-Cucumber-Rails brings Cucumber to Rails2 and Rails3. It contains 2 generators - one
-for bootstrapping your Rails app for Cucumber, and a second one for generating features.
-
-Cucumber-Rails also contains Cucumber Step Definitions that wrap Capybara or Webrat,
-giving you a head start for writing Cucumber features against your Rails app.
-
-== Installation
-
-=== Rails 3:
-
-Before you can use the generator, add the gem to your project's Gemfile as follows:
-
- group :test do
- gem 'cucumber-rails'
- gem 'capybara'
- gem 'database_cleaner'
- end
-
-Then install it by running:
-
- bundle install
-
-Learn about the various options:
-
- ruby script/rails generate cucumber:install --help
-
-Finally, bootstrap your Rails app, for example:
-
- rails generate cucumber:install
-
-=== Rails 2.x:
-
-Before you can use the generator, install the gem by running:
-
- gem install cucumber-rails
-
-Learn about the various options:
-
- ruby script/generate cucumber --help
-
-Finally, bootstrap your Rails app, for example:
-
- ruby script/generate cucumber --rspec --capybara
-
-== Generating a Cucumber feature
-
-IMPORTANT: Only do this if you are new to Cucumber. We recommend you write your
-Cucumber features by hand once you get the hang of it.
-
-=== Rails 3:
-
-Example:
-
- ruby script/rails generate cucumber:feature post title:string body:text published:boolean
- ruby script/rails generate scaffold post title:string body:text published:boolean
- rake db:migrate
- rake cucumber
-
-=== Rails 2:
-
-Example:
-
- ruby script/generate feature post title:string body:text published:boolean
- ruby script/generate scaffold post title:string body:text published:boolean
- rake db:migrate
- rake cucumber
View
1  VERSION
@@ -1 +0,0 @@
-0.3.2
View
37 cucumber-rails.gemspec
@@ -1,37 +1,36 @@
# -*- encoding: utf-8 -*-
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
-require 'cucumber/rails/version'
Gem::Specification.new do |s|
s.name = 'cucumber-rails'
- s.version = Cucumber::Rails::VERSION
+ s.version = '0.5.0.beta1'
s.authors = ["Aslak Hellesøy", "Dennis Blöte", "Rob Holland"]
s.description = "Cucumber Generators and Runtime for Rails"
- s.summary = "cucumber-rails-#{s.version}"
+ s.summary = "#{s.name}-#{s.version}"
s.email = 'cukes@googlegroups.com'
s.homepage = "http://cukes.info"
- s.add_dependency('cucumber', Cucumber::Rails::DEPS['cucumber'])
- s.add_dependency('rack-test', Cucumber::Rails::DEPS['rack-test'])
- s.add_dependency('nokogiri', Cucumber::Rails::DEPS['nokogiri'])
- s.add_dependency('capybara', Cucumber::Rails::DEPS['capybara'])
- s.add_development_dependency('bundler', Cucumber::Rails::DEPS['bundler'])
- s.add_development_dependency('aruba', Cucumber::Rails::DEPS['aruba'])
- s.add_development_dependency('rails', Cucumber::Rails::DEPS['rails'])
- s.add_development_dependency('sqlite3-ruby', Cucumber::Rails::DEPS['sqlite3-ruby'])
- s.add_development_dependency('rspec', Cucumber::Rails::DEPS['rspec'])
- s.add_development_dependency('rspec-rails', Cucumber::Rails::DEPS['rspec-rails'])
- s.add_development_dependency('factory_girl', Cucumber::Rails::DEPS['capybara'])
- s.add_development_dependency('database_cleaner', Cucumber::Rails::DEPS['database_cleaner'])
- s.add_development_dependency('mongoid', Cucumber::Rails::DEPS['mongoid'])
- s.add_development_dependency('bson_ext', Cucumber::Rails::DEPS['bson_ext'])
- # s.add_development_dependency('akephalos', Cucumber::Rails::DEPS['akephalos'])
+ s.add_dependency('cucumber', '>= 0.10.2')
+ s.add_dependency('rack-test', '>= 0.5.7')
+ s.add_dependency('nokogiri', '>= 1.4.4')
+ s.add_dependency('capybara', '>= 1.0.0.beta1')
+ s.add_development_dependency('bundler', '>= 1.0.12')
+ s.add_development_dependency('aruba', '>= 0.3.6')
+ s.add_development_dependency('rails', '>= 3.0.7')
+ s.add_development_dependency('sqlite3-ruby', '>= 1.3.3')
+ s.add_development_dependency('rspec', '>= 2.6.0.rc6')
+ s.add_development_dependency('rspec-rails', '>= 2.2.0')
+ s.add_development_dependency('factory_girl', '>= 2.0.0.beta2')
+ s.add_development_dependency('database_cleaner', '>= 0.6.7')
+ s.add_development_dependency('mongoid', '>= 2.0.1')
+ s.add_development_dependency('bson_ext', '>= 1.3.0')
+ # s.add_development_dependency('akephalos', '>= 0.2.5')
s.rubygems_version = ">= 1.6.1"
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
- s.extra_rdoc_files = ["LICENSE", "README.rdoc", "History.txt"]
+ s.extra_rdoc_files = ["LICENSE", "README.md", "History.txt"]
s.rdoc_options = ["--charset=UTF-8"]
s.require_path = "lib"
end
View
1  features/no_database.feature
@@ -1,3 +1,4 @@
+@announce
Feature: No Database
Allow Cucumber to work with a Rails app without a database
View
13 generators/cucumber/USAGE
@@ -1,13 +0,0 @@
-Description:
- Sets up Cucumber in your Rails project. After running this generator you will
- get a new rake task called features.
-
- This also generates the necessary files in the features directory.
-
- Also see the feature generator
-
-Examples:
- `./script/generate cucumber`
-
-You can also provide a language argument for localized capybara_steps:
- `./script/generate cucumber de`
View
46 generators/cucumber/cucumber_generator.rb
@@ -1,46 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), '../../lib/generators/cucumber/install/install_base'))
-
-# This generator bootstraps a Rails project for use with Cucumber
-class CucumberGenerator < Rails::Generator::Base
- include Cucumber::Generators::InstallBase
-
- attr_reader :language, :template_dir
-
- def initialize(runtime_args, runtime_options = {})
- super
- @language = @args.empty? ? 'en' : @args.first
- end
-
- def manifest
- record do |m|
- install_cucumber_rails(m)
- end
- end
-
- def self.gem_root
- File.expand_path('../../../', __FILE__)
- end
-
- def self.source_root
- File.join(gem_root, 'templates', 'install')
- end
-
- def source_root
- self.class.source_root
- end
-
- private
-
- def banner
- "Usage: #{$0} cucumber (language)"
- end
-
- def add_options!(opt)
- opt.separator ''
- opt.separator 'Options:'
- opt.on('--spork', 'Use Spork to run features') do
- options[:spork] = true
- end
- end
-
-end
View
12 generators/feature/USAGE
@@ -1,12 +0,0 @@
-Description:
- Generates a skeleton for a new feature. Both a simple .feature file and
- a steps.rb file is generated. This generator should be used with moderation.
- See http://github.com/aslakhellesoy/cucumber/wikis/feature-coupled-steps-antipattern
- for details about the dangers involved.
-
- This generator can take an optional list of attribute pairs similar to Rails'
- built-in resource generator.
-
-Examples:
- `./script/generate feature post` # no attributes
- `./script/generate feature post title:string body:text published:boolean`
View
47 generators/feature/feature_generator.rb
@@ -1,47 +0,0 @@
-require File.join(File.dirname(__FILE__), '../../lib/generators/cucumber/feature/named_arg')
-require File.join(File.dirname(__FILE__), '../../lib/generators/cucumber/feature/feature_base')
-
-# This generator generates a baic feature.
-class FeatureGenerator < Rails::Generator::NamedBase
-
- include Cucumber::Generators::FeatureBase
-
- def manifest
- record do |m|
- create_directory(m, true)
- create_feature_file(m)
- create_steps_file(m)
- create_support_file(m)
- end
- end
-
- def self.gem_root
- File.expand_path('../../../', __FILE__)
- end
-
- def self.source_root
- File.join(gem_root, 'templates', 'feature')
- end
-
- def source_root
- self.class.source_root
- end
-
- def named_args
- args.map { |arg| NamedArg.new(arg) }
- end
-
- private
-
- def banner
- "Usage: #{$0} feature ModelName [field:type, field:type]"
- end
-
- def add_options!(opt)
- opt.separator ''
- opt.separator 'Options:'
- opt.on('--capybara=BACKEND', 'Generate a feature that uses a particular Capybara backend') do |backend|
- options[:capybara] = backend
- end
- end
-end
View
6 lib/cucumber/rails.rb
@@ -1,9 +1,5 @@
require 'rails'
-if Rails.version.to_f < 3.0
- require 'cucumber/rails2'
-else
- require 'cucumber/rails3'
-end
+require 'cucumber/rails3'
require 'cucumber/rails/world'
require 'cucumber/rails/hooks'
View
23 lib/cucumber/rails/version.rb
@@ -1,23 +0,0 @@
-module Cucumber
- module Rails
- VERSION = '0.4.1'
- DEPS = {
- 'aruba' => '>= 0.3.6',
- 'cucumber' => '>= 0.10.2',
-
- 'bundler' => '>= 1.0.12',
- 'rack-test' => '>= 0.5.7',
- 'nokogiri' => '>= 1.4.4',
- 'rails' => '>= 3.0.7',
- 'capybara' => '>= 1.0.0.beta1',
- 'factory_girl' => '>= 2.0.0.beta2',
- 'rspec' => '>= 2.6.0.rc6',
- 'rspec-rails' => '>= 2.2.0',
- 'database_cleaner' => '>= 0.6.7',
- 'sqlite3-ruby' => '>= 1.3.3',
- 'mongoid' => '>= 2.0.1',
- 'bson_ext' => '>= 1.3.0',
- 'akephalos' => '>= 0.2.5'
- }
- end
-end
View
16 lib/cucumber/rails2.rb
@@ -1,16 +0,0 @@
-require 'cucumber/rails2/action_controller'
-ENV["RAILS_ENV"] ||= "cucumber"
-env = caller.detect{|f| f =~ /\/env\.rb:/}
-require File.expand_path(File.dirname(env) + '/../../config/environment')
-
-
-if defined?(ActiveRecord::Base)
- require 'test_help'
-else
- require 'action_dispatch/testing/test_process'
- require 'action_dispatch/testing/integration'
-end
-
-if !Rails.configuration.cache_classes
- warn "WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/cucumber.rb). This setting is known to cause problems with database transactions. Set config.cache_classes to true if you want to use transactions. For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165."
-end
View
29 lib/cucumber/rails2/action_controller.rb
@@ -1,29 +0,0 @@
-ActionController::Base.class_eval do
- cattr_accessor :allow_rescue
-
- alias_method :rescue_action_without_bypass, :rescue_action
-
- def rescue_action(exception)
- if ActionController::Base.allow_rescue
- rescue_action_without_bypass(exception)
- else
- raise exception
- end
- end
-end
-
-begin
- ActionController::Failsafe.class_eval do
- alias_method :failsafe_response_without_bypass, :failsafe_response
-
- def failsafe_response(exception)
- raise exception
- end
- end
-rescue NameError # Failsafe was introduced in Rails 2.3.2
- ActionController::Dispatcher.class_eval do
- def self.failsafe_response(output, status, exception = nil)
- raise exception
- end
- end
-end
View
31 lib/generators/cucumber/feature/feature_base.rb
@@ -1,31 +0,0 @@
-module Cucumber
- module Generators
- module FeatureBase
-
- def create_directory(m = self, rails2 = false)
- dir = 'features/step_definitions'
-
- if rails2
- m.directory dir
- else
- m.empty_directory dir unless File.directory?(dir)
- end
- end
-
- def create_feature_file(m = self)
- m.template 'feature.erb', "features/manage_#{plural_name}.feature"
- end
-
- def create_steps_file(m = self)
- m.template 'steps.erb', "features/step_definitions/#{singular_name}_steps.rb"
- end
-
- def create_support_file(m = self)
- m.gsub_file 'features/support/paths.rb', /'\/'/mi do |match|
- "#{match}\n when /the new #{singular_name} page/\n new_#{singular_name}_path\n"
- end
- end
-
- end
- end
-end
View
23 lib/generators/cucumber/feature/feature_generator.rb
@@ -1,11 +1,9 @@
require File.join(File.dirname(__FILE__), 'named_arg')
-require File.join(File.dirname(__FILE__), 'feature_base')
module Cucumber
class FeatureGenerator < ::Rails::Generators::NamedBase
+ source_root File.expand_path("../templates", __FILE__)
- include Cucumber::Generators::FeatureBase
-
argument :fields, :optional => true, :type => :array, :banner => "[field:type, field:type]"
attr_reader :named_args
@@ -15,23 +13,16 @@ def parse_fields
end
def generate
- create_directory
- create_feature_file
- create_steps_file
- create_support_file
+ empty_directory 'features/step_definitions'
+ template 'feature.erb', "features/manage_#{plural_name}.feature"
+ template 'steps.erb', "features/step_definitions/#{singular_name}_steps.rb"
+ gsub_file 'features/support/paths.rb', /'\/'/mi do |match|
+ "#{match}\n when /the new #{singular_name} page/\n new_#{singular_name}_path\n"
+ end
end
def self.banner
"#{$0} cucumber:feature ModelName [field:type, field:type]"
end
-
- def self.gem_root
- File.expand_path("../../../../../", __FILE__)
- end
-
- def self.source_root
- File.join(gem_root, 'templates', 'feature')
- end
-
end
end
View
0  templates/feature/feature.erb → ...generators/cucumber/feature/templates/feature.erb
File renamed without changes
View
0  templates/feature/steps.erb → lib/generators/cucumber/feature/templates/steps.erb
File renamed without changes
View
133 lib/generators/cucumber/install/install_base.rb
@@ -1,133 +0,0 @@
-require 'rbconfig'
-require 'cucumber/rails/version'
-
-module Cucumber
- module Generators
- module InstallBase
- DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
-
- def install_cucumber_rails(m)
- create_templates(m)
- create_scripts(m)
- create_step_definitions(m)
- create_feature_support(m)
- create_tasks(m)
- create_database(m) unless options[:skip_database]
- end
-
- # Creates templates
- def create_templates(m)
- m.template 'config/cucumber.yml.erb', 'config/cucumber.yml'
- if rails2?
- m.template 'environments/cucumber.rb.erb', 'config/environments/cucumber.rb'
- end
- end
-
- def create_scripts(m)
- if rails2?
- m.file 'script/cucumber', 'script/cucumber', {
- :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang]
- }
- else
- m.copy_file 'script/cucumber', 'script/cucumber'
- m.chmod 'script/cucumber', 0755
- end
- end
-
- def create_step_definitions(m)
- if rails2?
- m.directory 'features/step_definitions'
- else
- m.empty_directory 'features/step_definitions'
- end
-
- m.template "step_definitions/capybara_steps.rb.erb", 'features/step_definitions/web_steps.rb'
- if language != 'en'
- m.template "step_definitions/web_steps_#{language}.rb.erb", "features/step_definitions/web_steps_#{language}.rb"
- end
- end
-
- def create_feature_support(m)
- if rails2?
- m.directory 'features/support'
- m.file 'support/paths.rb', 'features/support/paths.rb'
- m.file 'support/selectors.rb', 'features/support/selectors.rb'
- else
- m.empty_directory 'features/support'
- m.copy_file 'support/paths.rb', 'features/support/paths.rb'
- m.copy_file 'support/selectors.rb', 'features/support/selectors.rb'
- end
-
- if spork?
- m.template 'support/rails_spork.rb.erb', 'features/support/env.rb'
- else
- m.template 'support/rails.rb.erb', 'features/support/env.rb'
- end
- end
-
- def create_tasks(m)
- if rails2?
- m.directory 'lib/tasks'
- else
- m.empty_directory 'lib/tasks'
- end
-
- m.template 'tasks/cucumber.rake.erb', 'lib/tasks/cucumber.rake'
- end
-
- def create_database(m)
- return unless File.exist?('config/database.yml')
- unless File.read('config/database.yml').include? 'cucumber:'
- m.gsub_file 'config/database.yml', /^test:.*\n/, "test: &test\n"
- m.gsub_file 'config/database.yml', /\z/, "\ncucumber:\n <<: *test"
-
- # Since gsub_file doesn't ask the user, just inform user that the file was overwritten.
- puts " force config/database.yml"
- end
- end
-
- protected
-
- def add_gem(*args)
- if rails2?
- else
- self.gem(*args)
- end
- end
-
- def spork?
- options[:spork]
- end
-
- def rails2?
- defined?(Rails::Generator::Base) # In Rails3 it's Rails::Generators::Base (plural s)
- end
-
- def embed_file(source, indent='')
- IO.read(File.join(self.class.source_root, source)).gsub(/^/, indent)
- end
-
- def embed_template(source, indent='')
- template = File.join(self.class.source_root, source)
- ERB.new(IO.read(template), nil, '-').result(binding).gsub(/^/, indent)
- end
-
- def version
- IO.read(File.join(self.class.gem_root, 'VERSION')).chomp
- end
-
- def detect_in_env(choices)
- return nil unless File.file?("features/support/env.rb")
-
- env = IO.read("features/support/env.rb")
-
- choices.each do |choice|
- detected = choice[1] if env =~ /#{choice[0]}/n
- return detected if detected
- end
-
- nil
- end
- end
- end
-end
View
80 lib/generators/cucumber/install/install_generator.rb
@@ -1,9 +1,10 @@
require 'rbconfig'
-require File.join(File.dirname(__FILE__), 'install_base')
module Cucumber
class InstallGenerator < ::Rails::Generators::Base
- include Cucumber::Generators::InstallBase
+ source_root File.expand_path("../templates", __FILE__)
+
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
argument :language, :type => :string, :banner => "LANG", :optional => true
@@ -14,21 +15,74 @@ class InstallGenerator < ::Rails::Generators::Base
attr_reader :framework
- def configure_defaults
- @language ||= 'en'
- @framework = framework_from_options || detect_current_framework || detect_default_framework
+ def generate
+ create_templates
+ create_scripts
+ create_step_definitions
+ create_feature_support
+ create_tasks
+ create_database unless options[:skip_database]
end
- def generate
- install_cucumber_rails(self)
+ def create_templates
+ template 'config/cucumber.yml.erb', 'config/cucumber.yml'
+ end
+
+ def create_scripts
+ copy_file 'script/cucumber', 'script/cucumber'
+ chmod 'script/cucumber', 0755
+ end
+
+ def create_step_definitions
+ empty_directory 'features/step_definitions'
+
+ template "step_definitions/web_steps.rb.erb", 'features/step_definitions/web_steps.rb'
+ if language
+ template "step_definitions/web_steps_#{language}.rb.erb", "features/step_definitions/web_steps_#{language}.rb"
+ end
+ end
+
+ def create_feature_support
+ empty_directory 'features/support'
+ copy_file 'support/paths.rb', 'features/support/paths.rb'
+ copy_file 'support/selectors.rb', 'features/support/selectors.rb'
+
+ if spork?
+ template 'support/rails_spork.rb.erb', 'features/support/env.rb'
+ else
+ template 'support/rails.rb.erb', 'features/support/env.rb'
+ end
+ end
+
+ def create_tasks
+ empty_directory 'lib/tasks'
+ template 'tasks/cucumber.rake.erb', 'lib/tasks/cucumber.rake'
+ end
+
+ def create_database
+ return unless File.exist?('config/database.yml')
+ unless File.read('config/database.yml').include? 'cucumber:'
+ gsub_file 'config/database.yml', /^test:.*\n/, "test: &test\n"
+ gsub_file 'config/database.yml', /\z/, "\ncucumber:\n <<: *test"
+
+ # Since gsub_file doesn't ask the user, just inform user that the file was overwritten.
+ puts " force config/database.yml"
+ end
end
-
- def self.gem_root
- File.expand_path("../../../../../", __FILE__)
+
+ protected
+
+ def spork?
+ options[:spork]
end
-
- def self.source_root
- File.join(gem_root, 'templates/install')
+
+ def embed_file(source, indent='')
+ IO.read(File.join(self.class.source_root, source)).gsub(/^/, indent)
+ end
+
+ def embed_template(source, indent='')
+ template = File.join(self.class.source_root, source)
+ ERB.new(IO.read(template), nil, '-').result(binding).gsub(/^/, indent)
end
private
View
0  templates/install/config/cucumber.yml.erb → ...ucumber/install/templates/config/cucumber.yml.erb
File renamed without changes
View
0  templates/install/environments/cucumber.rb.erb → ...er/install/templates/environments/cucumber.rb.erb
File renamed without changes
View
0  templates/install/script/cucumber → ...rators/cucumber/install/templates/script/cucumber
File renamed without changes
View
0  ...es/install/step_definitions/capybara_steps.rb.erb → ...stall/templates/step_definitions/web_steps.rb.erb
File renamed without changes
View
0  ...ates/install/step_definitions/web_steps_cs.rb.erb → ...ll/templates/step_definitions/web_steps_cs.rb.erb
File renamed without changes
View
0  ...ates/install/step_definitions/web_steps_da.rb.erb → ...ll/templates/step_definitions/web_steps_da.rb.erb
File renamed without changes
View
0  ...ates/install/step_definitions/web_steps_de.rb.erb → ...ll/templates/step_definitions/web_steps_de.rb.erb
File renamed without changes
View
0  ...ates/install/step_definitions/web_steps_es.rb.erb → ...ll/templates/step_definitions/web_steps_es.rb.erb
File renamed without changes
View
0  ...ates/install/step_definitions/web_steps_ja.rb.erb → ...ll/templates/step_definitions/web_steps_ja.rb.erb
File renamed without changes
View
0  ...ates/install/step_definitions/web_steps_ko.rb.erb → ...ll/templates/step_definitions/web_steps_ko.rb.erb
File renamed without changes
View
0  ...ates/install/step_definitions/web_steps_no.rb.erb → ...ll/templates/step_definitions/web_steps_no.rb.erb
File renamed without changes
View
0  ...s/install/step_definitions/web_steps_pt-BR.rb.erb → ...templates/step_definitions/web_steps_pt-BR.rb.erb
File renamed without changes
View
0  templates/install/support/_rails_each_run.rb.erb → .../install/templates/support/_rails_each_run.rb.erb
File renamed without changes
View
0  templates/install/support/_rails_prefork.rb.erb → ...r/install/templates/support/_rails_prefork.rb.erb
File renamed without changes
View
0  templates/install/support/capybara.rb → ...rs/cucumber/install/templates/support/capybara.rb
File renamed without changes
View
0  templates/install/support/edit_warning.txt → ...cumber/install/templates/support/edit_warning.txt
File renamed without changes
View
0  templates/install/support/paths.rb → ...ators/cucumber/install/templates/support/paths.rb
File renamed without changes
View
0  templates/install/support/rails.rb.erb → ...s/cucumber/install/templates/support/rails.rb.erb
File renamed without changes
View
0  templates/install/support/rails_spork.rb.erb → ...mber/install/templates/support/rails_spork.rb.erb
File renamed without changes
View
0  templates/install/support/selectors.rb → ...s/cucumber/install/templates/support/selectors.rb
File renamed without changes
View
0  templates/install/support/web_steps_warning.txt → ...r/install/templates/support/web_steps_warning.txt
File renamed without changes
View
0  templates/install/tasks/cucumber.rake.erb → ...ucumber/install/templates/tasks/cucumber.rake.erb
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.