cucumber-rails 0.4.1 → 0.5.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. data/History.txt +9 -0
  2. data/README.md +74 -0
  3. data/config/cucumber.yml +1 -0
  4. data/cucumber-rails.gemspec +18 -18
  5. data/features/capybara_javascript_drivers.feature +1 -0
  6. data/features/emulate_javascript.feature +33 -0
  7. data/features/multiple_databases.feature +74 -0
  8. data/features/no_database.feature +1 -0
  9. data/features/pseduo_class_selectors.feature +24 -0
  10. data/features/select_dates.feature +36 -0
  11. data/features/step_definitions/cucumber_rails_steps.rb +1 -0
  12. data/lib/cucumber/rails.rb +1 -5
  13. data/lib/cucumber/rails/capybara/javascript_emulation.rb +4 -4
  14. data/lib/cucumber/rails/capybara/select_dates_and_times.rb +1 -1
  15. data/lib/cucumber/rails/hooks/database_cleaner.rb +0 -25
  16. data/lib/generators/cucumber/feature/feature_generator.rb +7 -16
  17. data/{templates/feature → lib/generators/cucumber/feature/templates}/feature.erb +0 -0
  18. data/{templates/feature → lib/generators/cucumber/feature/templates}/steps.erb +0 -0
  19. data/lib/generators/cucumber/install/install_generator.rb +68 -23
  20. data/{templates/install → lib/generators/cucumber/install/templates}/config/cucumber.yml.erb +0 -0
  21. data/{templates/install → lib/generators/cucumber/install/templates}/environments/cucumber.rb.erb +0 -4
  22. data/{templates/install → lib/generators/cucumber/install/templates}/script/cucumber +0 -0
  23. data/{templates/install/step_definitions/capybara_steps.rb.erb → lib/generators/cucumber/install/templates/step_definitions/web_steps.rb.erb} +2 -2
  24. data/{templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_cs.rb.erb +0 -0
  25. data/{templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_da.rb.erb +0 -0
  26. data/{templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_de.rb.erb +15 -24
  27. data/{templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_es.rb.erb +0 -0
  28. data/{templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_ja.rb.erb +0 -0
  29. data/{templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_ko.rb.erb +0 -0
  30. data/{templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_no.rb.erb +0 -0
  31. data/{templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_pt-BR.rb.erb +0 -0
  32. data/{templates/install → lib/generators/cucumber/install/templates}/support/_rails_each_run.rb.erb +12 -0
  33. data/{templates/install → lib/generators/cucumber/install/templates}/support/_rails_prefork.rb.erb +0 -0
  34. data/{templates/install → lib/generators/cucumber/install/templates}/support/capybara.rb +0 -0
  35. data/{templates/install → lib/generators/cucumber/install/templates}/support/edit_warning.txt +0 -0
  36. data/{templates/install → lib/generators/cucumber/install/templates}/support/paths.rb +3 -3
  37. data/{templates/install → lib/generators/cucumber/install/templates}/support/rails.rb.erb +1 -1
  38. data/{templates/install → lib/generators/cucumber/install/templates}/support/rails_spork.rb.erb +1 -1
  39. data/{templates/install → lib/generators/cucumber/install/templates}/support/selectors.rb +3 -3
  40. data/{templates/install → lib/generators/cucumber/install/templates}/support/web_steps_warning.txt +0 -0
  41. data/{templates/install → lib/generators/cucumber/install/templates}/tasks/cucumber.rake.erb +0 -0
  42. metadata +64 -73
  43. data/HACKING.rdoc +0 -22
  44. data/README.rdoc +0 -68
  45. data/VERSION +0 -1
  46. data/generators/cucumber/USAGE +0 -13
  47. data/generators/cucumber/cucumber_generator.rb +0 -46
  48. data/generators/feature/USAGE +0 -12
  49. data/generators/feature/feature_generator.rb +0 -47
  50. data/lib/cucumber/rails/version.rb +0 -22
  51. data/lib/cucumber/rails2.rb +0 -16
  52. data/lib/cucumber/rails2/action_controller.rb +0 -29
  53. data/lib/generators/cucumber/feature/feature_base.rb +0 -29
  54. data/lib/generators/cucumber/install/install_base.rb +0 -149
  55. data/templates/install/step_definitions/webrat_steps.rb.erb +0 -277
  56. data/templates/install/support/webrat.rb +0 -8
data/HACKING.rdoc DELETED
@@ -1,22 +0,0 @@
1
- = Hacking on Cucumber-Rails
2
-
3
- If you have a bugfix or a new feature you want to contribute, please fork on Github and make your own feature branch:
4
-
5
- git clone git@github.com:you/cucumber-rails.git
6
- git checkout -b 87-my-awesome-bugfix
7
-
8
- The feature branch should contain a ticket number (if appliccable) and a descriptive name that aligns with the ticket name.
9
- When you think you're done send a pull request.
10
-
11
- == Setting up your environment
12
-
13
- I strongly recommend rvm and ruby 1.9.2. When you have that, cd into your cucumber-rails repository and:
14
-
15
- gem install bundler
16
- bundle install
17
-
18
- == Running all features
19
-
20
- rake cucumber
21
-
22
- One of the features uses MongoDB, which needs to be running in order to make features/mongoid.feature to pass.
data/README.rdoc DELETED
@@ -1,68 +0,0 @@
1
- = Cucumber-Rails
2
-
3
- Cucumber-Rails brings Cucumber to Rails2 and Rails3. It contains 2 generators - one
4
- for bootstrapping your Rails app for Cucumber, and a second one for generating features.
5
-
6
- Cucumber-Rails also contains Cucumber Step Definitions that wrap Capybara or Webrat,
7
- giving you a head start for writing Cucumber features against your Rails app.
8
-
9
- == Installation
10
-
11
- === Rails 3:
12
-
13
- Before you can use the generator, add the gem to your project's Gemfile as follows:
14
-
15
- group :test do
16
- gem 'cucumber-rails'
17
- gem 'capybara'
18
- gem 'database_cleaner'
19
- end
20
-
21
- Then install it by running:
22
-
23
- bundle install
24
-
25
- Learn about the various options:
26
-
27
- ruby script/rails generate cucumber:install --help
28
-
29
- Finally, bootstrap your Rails app, for example:
30
-
31
- rails generate cucumber:install
32
-
33
- === Rails 2.x:
34
-
35
- Before you can use the generator, install the gem by running:
36
-
37
- gem install cucumber-rails
38
-
39
- Learn about the various options:
40
-
41
- ruby script/generate cucumber --help
42
-
43
- Finally, bootstrap your Rails app, for example:
44
-
45
- ruby script/generate cucumber --rspec --capybara
46
-
47
- == Generating a Cucumber feature
48
-
49
- IMPORTANT: Only do this if you are new to Cucumber. We recommend you write your
50
- Cucumber features by hand once you get the hang of it.
51
-
52
- === Rails 3:
53
-
54
- Example:
55
-
56
- ruby script/rails generate cucumber:feature post title:string body:text published:boolean
57
- ruby script/rails generate scaffold post title:string body:text published:boolean
58
- rake db:migrate
59
- rake cucumber
60
-
61
- === Rails 2:
62
-
63
- Example:
64
-
65
- ruby script/generate feature post title:string body:text published:boolean
66
- ruby script/generate scaffold post title:string body:text published:boolean
67
- rake db:migrate
68
- rake cucumber
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.3.2
@@ -1,13 +0,0 @@
1
- Description:
2
- Sets up Cucumber in your Rails project. After running this generator you will
3
- get a new rake task called features.
4
-
5
- This also generates the necessary files in the features directory.
6
-
7
- Also see the feature generator
8
-
9
- Examples:
10
- `./script/generate cucumber`
11
-
12
- You can also provide a language argument for localized webrat_steps:
13
- `./script/generate cucumber de`
@@ -1,46 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../../lib/generators/cucumber/install/install_base'))
2
-
3
- # This generator bootstraps a Rails project for use with Cucumber
4
- class CucumberGenerator < Rails::Generator::Base
5
- include Cucumber::Generators::InstallBase
6
-
7
- attr_reader :language, :template_dir
8
-
9
- def initialize(runtime_args, runtime_options = {})
10
- super
11
- @language = @args.empty? ? 'en' : @args.first
12
- end
13
-
14
- def manifest
15
- record do |m|
16
- install_cucumber_rails(m)
17
- end
18
- end
19
-
20
- def self.gem_root
21
- File.expand_path('../../../', __FILE__)
22
- end
23
-
24
- def self.source_root
25
- File.join(gem_root, 'templates', 'install')
26
- end
27
-
28
- def source_root
29
- self.class.source_root
30
- end
31
-
32
- private
33
-
34
- def banner
35
- "Usage: #{$0} cucumber (language)"
36
- end
37
-
38
- def add_options!(opt)
39
- opt.separator ''
40
- opt.separator 'Options:'
41
- opt.on('--spork', 'Use Spork to run features') do
42
- options[:spork] = true
43
- end
44
- end
45
-
46
- end
@@ -1,12 +0,0 @@
1
- Description:
2
- Generates a skeleton for a new feature. Both a simple .feature file and
3
- a steps.rb file is generated. This generator should be used with moderation.
4
- See http://github.com/aslakhellesoy/cucumber/wikis/feature-coupled-steps-antipattern
5
- for details about the dangers involved.
6
-
7
- This generator can take an optional list of attribute pairs similar to Rails'
8
- built-in resource generator.
9
-
10
- Examples:
11
- `./script/generate feature post` # no attributes
12
- `./script/generate feature post title:string body:text published:boolean`
@@ -1,47 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../lib/generators/cucumber/feature/named_arg')
2
- require File.join(File.dirname(__FILE__), '../../lib/generators/cucumber/feature/feature_base')
3
-
4
- # This generator generates a baic feature.
5
- class FeatureGenerator < Rails::Generator::NamedBase
6
-
7
- include Cucumber::Generators::FeatureBase
8
-
9
- def manifest
10
- record do |m|
11
- create_directory(m, true)
12
- create_feature_file(m)
13
- create_steps_file(m)
14
- create_support_file(m)
15
- end
16
- end
17
-
18
- def self.gem_root
19
- File.expand_path('../../../', __FILE__)
20
- end
21
-
22
- def self.source_root
23
- File.join(gem_root, 'templates', 'feature')
24
- end
25
-
26
- def source_root
27
- self.class.source_root
28
- end
29
-
30
- def named_args
31
- args.map { |arg| NamedArg.new(arg) }
32
- end
33
-
34
- private
35
-
36
- def banner
37
- "Usage: #{$0} feature ModelName [field:type, field:type]"
38
- end
39
-
40
- def add_options!(opt)
41
- opt.separator ''
42
- opt.separator 'Options:'
43
- opt.on('--capybara=BACKEND', 'Generate a feature that uses a particular Capybara backend') do |backend|
44
- options[:capybara] = backend
45
- end
46
- end
47
- end
@@ -1,22 +0,0 @@
1
- module Cucumber
2
- module Rails
3
- VERSION = '0.4.1'
4
- DEPS = {
5
- 'aruba' => '>= 0.3.4',
6
- 'cucumber' => '>= 0.10.1',
7
-
8
- 'bundler' => '>= 1.0.10',
9
- 'rack-test' => '>= 0.5.7',
10
- 'nokogiri' => '>= 1.4.4',
11
- 'rails' => '>= 3.0.5',
12
- 'capybara' => '>= 0.4.1',
13
- 'webrat' => '>= 0.7.3',
14
- 'rspec-rails' => '>= 2.2.0',
15
- 'database_cleaner' => '>= 0.6.0',
16
- 'sqlite3-ruby' => '>= 1.3.3',
17
- 'mongoid' => '>= 2.0.0',
18
- 'bson_ext' => '>= 1.3.0',
19
- 'akephalos' => '>= 0.2.5'
20
- }
21
- end
22
- end
@@ -1,16 +0,0 @@
1
- require 'cucumber/rails2/action_controller'
2
- ENV["RAILS_ENV"] ||= "cucumber"
3
- env = caller.detect{|f| f =~ /\/env\.rb:/}
4
- require File.expand_path(File.dirname(env) + '/../../config/environment')
5
-
6
-
7
- if defined?(ActiveRecord::Base)
8
- require 'test_help'
9
- else
10
- require 'action_dispatch/testing/test_process'
11
- require 'action_dispatch/testing/integration'
12
- end
13
-
14
- if !Rails.configuration.cache_classes
15
- 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."
16
- end
@@ -1,29 +0,0 @@
1
- ActionController::Base.class_eval do
2
- cattr_accessor :allow_rescue
3
-
4
- alias_method :rescue_action_without_bypass, :rescue_action
5
-
6
- def rescue_action(exception)
7
- if ActionController::Base.allow_rescue
8
- rescue_action_without_bypass(exception)
9
- else
10
- raise exception
11
- end
12
- end
13
- end
14
-
15
- begin
16
- ActionController::Failsafe.class_eval do
17
- alias_method :failsafe_response_without_bypass, :failsafe_response
18
-
19
- def failsafe_response(exception)
20
- raise exception
21
- end
22
- end
23
- rescue NameError # Failsafe was introduced in Rails 2.3.2
24
- ActionController::Dispatcher.class_eval do
25
- def self.failsafe_response(output, status, exception = nil)
26
- raise exception
27
- end
28
- end
29
- end
@@ -1,29 +0,0 @@
1
- module Cucumber
2
- module Generators
3
- module FeatureBase
4
-
5
- def create_directory(m = self, rails2 = false)
6
- if rails2
7
- m.directory 'features/step_definitions'
8
- else
9
- m.empty_directory 'features/step_definitions'
10
- end
11
- end
12
-
13
- def create_feature_file(m = self)
14
- m.template 'feature.erb', "features/manage_#{plural_name}.feature"
15
- end
16
-
17
- def create_steps_file(m = self)
18
- m.template 'steps.erb', "features/step_definitions/#{singular_name}_steps.rb"
19
- end
20
-
21
- def create_support_file(m = self)
22
- m.gsub_file 'features/support/paths.rb', /'\/'/mi do |match|
23
- "#{match}\n when /the new #{singular_name} page/\n new_#{singular_name}_path\n"
24
- end
25
- end
26
-
27
- end
28
- end
29
- end
@@ -1,149 +0,0 @@
1
- require 'rbconfig'
2
- require 'cucumber/rails/version'
3
-
4
- module Cucumber
5
- module Generators
6
- module InstallBase
7
- DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
8
-
9
- def install_cucumber_rails(m)
10
- check_upgrade_limitations
11
- create_templates(m)
12
- create_scripts(m)
13
- create_step_definitions(m)
14
- create_feature_support(m)
15
- create_tasks(m)
16
- create_database(m) unless options[:skip_database]
17
- end
18
-
19
- # Checks and prints the limitations
20
- def check_upgrade_limitations
21
- if File.exist?('features/step_definitions/webrat_steps.rb')
22
- STDERR.puts "Please remove features/step_definitions/webrat_steps.rb\n" +
23
- "See upgrading instructions for 0.2.0 in History.txt"
24
- exit(1)
25
- end
26
-
27
- if File.exist?('features/support/version_check.rb')
28
- STDERR.puts "Please remove features/support/version_check.rb\n" +
29
- "See upgrading instructions for 0.2.0 in History.txt"
30
- exit(1)
31
- end
32
- end
33
-
34
- # Creates templates
35
- def create_templates(m)
36
- m.template 'config/cucumber.yml.erb', 'config/cucumber.yml'
37
- if rails2?
38
- m.template 'environments/cucumber.rb.erb', 'config/environments/cucumber.rb'
39
- end
40
- end
41
-
42
- def create_scripts(m)
43
- if rails2?
44
- m.file 'script/cucumber', 'script/cucumber', {
45
- :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang]
46
- }
47
- else
48
- m.copy_file 'script/cucumber', 'script/cucumber'
49
- m.chmod 'script/cucumber', 0755
50
- end
51
- end
52
-
53
- def create_step_definitions(m)
54
- if rails2?
55
- m.directory 'features/step_definitions'
56
- else
57
- m.empty_directory 'features/step_definitions'
58
- end
59
-
60
- m.template "step_definitions/#{driver}_steps.rb.erb", 'features/step_definitions/web_steps.rb'
61
- if language != 'en'
62
- m.template "step_definitions/web_steps_#{language}.rb.erb", "features/step_definitions/web_steps_#{language}.rb"
63
- end
64
- end
65
-
66
- def create_feature_support(m)
67
- if rails2?
68
- m.directory 'features/support'
69
- m.file 'support/paths.rb', 'features/support/paths.rb'
70
- m.file 'support/selectors.rb', 'features/support/selectors.rb'
71
- else
72
- m.empty_directory 'features/support'
73
- m.copy_file 'support/paths.rb', 'features/support/paths.rb'
74
- m.copy_file 'support/selectors.rb', 'features/support/selectors.rb'
75
- end
76
-
77
- if spork?
78
- m.template 'support/rails_spork.rb.erb', 'features/support/env.rb'
79
- else
80
- m.template 'support/rails.rb.erb', 'features/support/env.rb'
81
- end
82
- end
83
-
84
- def create_tasks(m)
85
- if rails2?
86
- m.directory 'lib/tasks'
87
- else
88
- m.empty_directory 'lib/tasks'
89
- end
90
-
91
- m.template 'tasks/cucumber.rake.erb', 'lib/tasks/cucumber.rake'
92
- end
93
-
94
- def create_database(m)
95
- return unless File.exist?('config/database.yml')
96
- unless File.read('config/database.yml').include? 'cucumber:'
97
- m.gsub_file 'config/database.yml', /^test:.*\n/, "test: &test\n"
98
- m.gsub_file 'config/database.yml', /\z/, "\ncucumber:\n <<: *test"
99
-
100
- # Since gsub_file doesn't ask the user, just inform user that the file was overwritten.
101
- puts " force config/database.yml"
102
- end
103
- end
104
-
105
- protected
106
-
107
- def add_gem(*args)
108
- if rails2?
109
- else
110
- self.gem(*args)
111
- end
112
- end
113
-
114
- def spork?
115
- options[:spork]
116
- end
117
-
118
- def rails2?
119
- defined?(Rails::Generator::Base) # In Rails3 it's Rails::Generators::Base (plural s)
120
- end
121
-
122
- def embed_file(source, indent='')
123
- IO.read(File.join(self.class.source_root, source)).gsub(/^/, indent)
124
- end
125
-
126
- def embed_template(source, indent='')
127
- template = File.join(self.class.source_root, source)
128
- ERB.new(IO.read(template), nil, '-').result(binding).gsub(/^/, indent)
129
- end
130
-
131
- def version
132
- IO.read(File.join(self.class.gem_root, 'VERSION')).chomp
133
- end
134
-
135
- def detect_in_env(choices)
136
- return nil unless File.file?("features/support/env.rb")
137
-
138
- env = IO.read("features/support/env.rb")
139
-
140
- choices.each do |choice|
141
- detected = choice[1] if env =~ /#{choice[0]}/n
142
- return detected if detected
143
- end
144
-
145
- nil
146
- end
147
- end
148
- end
149
- end