cucumber-rails-training-wheels 1.0.0

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 (30) hide show
  1. data/.gitignore +8 -0
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +156 -0
  4. data/README.md +29 -0
  5. data/Rakefile +10 -0
  6. data/cucumber-rails-training-wheels.gemspec +25 -0
  7. data/features/step_defintions/rails_steps.rb +21 -0
  8. data/features/support/env.rb +8 -0
  9. data/features/use_training_wheels.feature +17 -0
  10. data/lib/generators/cucumber_rails_training_wheels/feature/USAGE +16 -0
  11. data/lib/generators/cucumber_rails_training_wheels/feature/feature_generator.rb +27 -0
  12. data/lib/generators/cucumber_rails_training_wheels/feature/named_arg.rb +20 -0
  13. data/lib/generators/cucumber_rails_training_wheels/feature/templates/feature.erb +63 -0
  14. data/lib/generators/cucumber_rails_training_wheels/feature/templates/steps.erb +14 -0
  15. data/lib/generators/cucumber_rails_training_wheels/install/USAGE +15 -0
  16. data/lib/generators/cucumber_rails_training_wheels/install/install_generator.rb +33 -0
  17. data/lib/generators/cucumber_rails_training_wheels/install/templates/step_definitions/web_steps.rb.erb +235 -0
  18. data/lib/generators/cucumber_rails_training_wheels/install/templates/step_definitions/web_steps_cs.rb.erb +127 -0
  19. data/lib/generators/cucumber_rails_training_wheels/install/templates/step_definitions/web_steps_da.rb.erb +105 -0
  20. data/lib/generators/cucumber_rails_training_wheels/install/templates/step_definitions/web_steps_de.rb.erb +127 -0
  21. data/lib/generators/cucumber_rails_training_wheels/install/templates/step_definitions/web_steps_es.rb.erb +127 -0
  22. data/lib/generators/cucumber_rails_training_wheels/install/templates/step_definitions/web_steps_ja.rb.erb +140 -0
  23. data/lib/generators/cucumber_rails_training_wheels/install/templates/step_definitions/web_steps_ko.rb.erb +142 -0
  24. data/lib/generators/cucumber_rails_training_wheels/install/templates/step_definitions/web_steps_no.rb.erb +105 -0
  25. data/lib/generators/cucumber_rails_training_wheels/install/templates/step_definitions/web_steps_pt-BR.rb.erb +132 -0
  26. data/lib/generators/cucumber_rails_training_wheels/install/templates/support/paths.rb +38 -0
  27. data/lib/generators/cucumber_rails_training_wheels/install/templates/support/selectors.rb +44 -0
  28. data/lib/generators/cucumber_rails_training_wheels/install/templates/support/web_steps_warning.txt +19 -0
  29. data/lib/generators/cucumber_rails_training_wheels/install/templates/tasks/cucumber.rake.erb +60 -0
  30. metadata +148 -0
@@ -0,0 +1,8 @@
1
+ pkg
2
+ doc
3
+ tmp
4
+ coverage
5
+ .bundle
6
+ .rvmrc
7
+ .yardoc/
8
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
@@ -0,0 +1,156 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cucumber-rails-training-wheels (1.0.0)
5
+ cucumber-rails (>= 1.1.1)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actionmailer (3.1.0)
11
+ actionpack (= 3.1.0)
12
+ mail (~> 2.3.0)
13
+ actionpack (3.1.0)
14
+ activemodel (= 3.1.0)
15
+ activesupport (= 3.1.0)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ i18n (~> 0.6)
19
+ rack (~> 1.3.2)
20
+ rack-cache (~> 1.0.3)
21
+ rack-mount (~> 0.8.2)
22
+ rack-test (~> 0.6.1)
23
+ sprockets (~> 2.0.0)
24
+ activemodel (3.1.0)
25
+ activesupport (= 3.1.0)
26
+ bcrypt-ruby (~> 3.0.0)
27
+ builder (~> 3.0.0)
28
+ i18n (~> 0.6)
29
+ activerecord (3.1.0)
30
+ activemodel (= 3.1.0)
31
+ activesupport (= 3.1.0)
32
+ arel (~> 2.2.1)
33
+ tzinfo (~> 0.3.29)
34
+ activeresource (3.1.0)
35
+ activemodel (= 3.1.0)
36
+ activesupport (= 3.1.0)
37
+ activesupport (3.1.0)
38
+ multi_json (~> 1.0)
39
+ arel (2.2.1)
40
+ aruba (0.4.6)
41
+ bcat (>= 0.6.1)
42
+ childprocess (>= 0.2.0)
43
+ cucumber (>= 1.0.2)
44
+ rdiscount (>= 1.6.8)
45
+ rspec (>= 2.6.0)
46
+ bcat (0.6.2)
47
+ rack (~> 1.0)
48
+ bcrypt-ruby (3.0.1)
49
+ builder (3.0.0)
50
+ capybara (1.1.1)
51
+ mime-types (>= 1.16)
52
+ nokogiri (>= 1.3.3)
53
+ rack (>= 1.0.0)
54
+ rack-test (>= 0.5.4)
55
+ selenium-webdriver (~> 2.0)
56
+ xpath (~> 0.1.4)
57
+ childprocess (0.2.2)
58
+ ffi (~> 1.0.6)
59
+ cucumber (1.1.0)
60
+ builder (>= 2.1.2)
61
+ diff-lcs (>= 1.1.2)
62
+ gherkin (~> 2.5.0)
63
+ json (>= 1.4.6)
64
+ term-ansicolor (>= 1.0.6)
65
+ cucumber-rails (1.1.1)
66
+ capybara (>= 1.1.1)
67
+ cucumber (>= 1.1.0)
68
+ nokogiri (>= 1.5.0)
69
+ database_cleaner (0.6.7)
70
+ diff-lcs (1.1.3)
71
+ erubis (2.7.0)
72
+ ffi (1.0.9)
73
+ gherkin (2.5.1)
74
+ json (>= 1.4.6)
75
+ hike (1.2.1)
76
+ i18n (0.6.0)
77
+ json (1.6.1)
78
+ json_pure (1.6.1)
79
+ mail (2.3.0)
80
+ i18n (>= 0.4.0)
81
+ mime-types (~> 1.16)
82
+ treetop (~> 1.4.8)
83
+ mime-types (1.16)
84
+ multi_json (1.0.3)
85
+ nokogiri (1.5.0)
86
+ polyglot (0.3.2)
87
+ rack (1.3.4)
88
+ rack-cache (1.0.3)
89
+ rack (>= 0.4)
90
+ rack-mount (0.8.3)
91
+ rack (>= 1.0.0)
92
+ rack-ssl (1.3.2)
93
+ rack
94
+ rack-test (0.6.1)
95
+ rack (>= 1.0)
96
+ rails (3.1.0)
97
+ actionmailer (= 3.1.0)
98
+ actionpack (= 3.1.0)
99
+ activerecord (= 3.1.0)
100
+ activeresource (= 3.1.0)
101
+ activesupport (= 3.1.0)
102
+ bundler (~> 1.0)
103
+ railties (= 3.1.0)
104
+ railties (3.1.0)
105
+ actionpack (= 3.1.0)
106
+ activesupport (= 3.1.0)
107
+ rack-ssl (~> 1.3.2)
108
+ rake (>= 0.8.7)
109
+ rdoc (~> 3.4)
110
+ thor (~> 0.14.6)
111
+ rake (0.9.2)
112
+ rdiscount (1.6.8)
113
+ rdoc (3.9.4)
114
+ rspec (2.6.0)
115
+ rspec-core (~> 2.6.0)
116
+ rspec-expectations (~> 2.6.0)
117
+ rspec-mocks (~> 2.6.0)
118
+ rspec-core (2.6.4)
119
+ rspec-expectations (2.6.0)
120
+ diff-lcs (~> 1.1.2)
121
+ rspec-mocks (2.6.0)
122
+ rspec-rails (2.6.1)
123
+ actionpack (~> 3.0)
124
+ activesupport (~> 3.0)
125
+ railties (~> 3.0)
126
+ rspec (~> 2.6.0)
127
+ rubyzip (0.9.4)
128
+ selenium-webdriver (2.7.0)
129
+ childprocess (>= 0.2.1)
130
+ ffi (>= 1.0.7)
131
+ json_pure
132
+ rubyzip
133
+ sprockets (2.0.1)
134
+ hike (~> 1.2)
135
+ rack (~> 1.0)
136
+ tilt (~> 1.1, != 1.3.0)
137
+ term-ansicolor (1.0.6)
138
+ thor (0.14.6)
139
+ tilt (1.3.3)
140
+ treetop (1.4.10)
141
+ polyglot
142
+ polyglot (>= 0.3.1)
143
+ tzinfo (0.3.30)
144
+ xpath (0.1.4)
145
+ nokogiri (~> 1.3)
146
+
147
+ PLATFORMS
148
+ ruby
149
+
150
+ DEPENDENCIES
151
+ aruba (>= 0.4.6)
152
+ cucumber-rails-training-wheels!
153
+ database_cleaner (>= 0.6.7)
154
+ rails (>= 3.1.0)
155
+ rspec (>= 2.6.0)
156
+ rspec-rails (>= 2.6.1)
@@ -0,0 +1,29 @@
1
+ # Cucumber-Rails Training Wheels
2
+
3
+ Cucumber-Rails Training Wheels contains a couple of generators to get you started with Cucumber and Rails really quickly. You won't even have to think! There is a little snag: If you don't take those training wheels off immediately you will end up with a complete mess. -And remember - every time you run a Cucumber feature based on Cucumber-Rails Training Wheels, god kills a kitten. But hey, you're running Cucumber!
4
+
5
+ You have been warned. I think you should read [The training wheels came off](http://aslakhellesoy.com/post/11055981222/the-training-wheels-came-off)
6
+
7
+ ## Installation
8
+
9
+ Add this to your Gemfile:
10
+
11
+ gem "cucumber-rails-training-wheels", :group => :test
12
+
13
+ Generate `features/step_definitions/web_steps.rb`, which will make you write really bad features:
14
+
15
+ rails generate cucumber_rails_training_wheels:install
16
+
17
+ Or generate a feature file:
18
+
19
+ rails generate cucumber_rails_training_wheels:feature post title:string body:text number:integer published:boolean
20
+ rails generate scaffold post title:string body:text number:integer published:boolean
21
+
22
+ Congratulations! You have created Cucumber features that no stakeholder will ever want to read. Features that don't express
23
+ any business value at all, but hey - they are green! Good luck maintaining them. You have become an [MDD](http://skillsmatter.com/podcast/home/refuctoring-your-cukes) pro!
24
+
25
+ ## Pull requests
26
+
27
+ Please don't bother. This gem exists for the sole purpose of helping people who are reading books or blogs that were written prior to Cucumber-Rails 1.1.0. I really want this code to go away and be forgotten.
28
+
29
+ If something is broken, just fork it and use your own fork.
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+ require 'rubygems'
3
+ require 'bundler/setup'
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ require 'cucumber/rake/task'
7
+ Cucumber::Rake::Task.new do |t|
8
+ end
9
+
10
+ task :default => :cucumber
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'cucumber-rails-training-wheels'
5
+ s.version = '1.0.0'
6
+ s.authors = ["Aslak Hellesøy"]
7
+ s.description = "Training Wheels for Cucumber-Rails"
8
+ s.summary = "#{s.name}-#{s.version}"
9
+ s.email = 'cukes@googlegroups.com'
10
+ s.homepage = "http://cukes.info"
11
+
12
+ s.add_runtime_dependency('cucumber-rails', '>= 1.1.1')
13
+
14
+ s.add_development_dependency('rails', '>= 3.1.0')
15
+ s.add_development_dependency('aruba', '>= 0.4.6')
16
+ s.add_development_dependency('rspec', '>= 2.6.0')
17
+ s.add_development_dependency('rspec-rails', '>= 2.6.1')
18
+ s.add_development_dependency('database_cleaner', '>= 0.6.7')
19
+
20
+ s.rubygems_version = ">= 1.6.1"
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
+ s.require_path = "lib"
25
+ end
@@ -0,0 +1,21 @@
1
+ Given /^I have created a new Rails 3 app "([^"]*)" with cucumber\-rails support$/ do |app_name|
2
+ steps %Q{
3
+ When I successfully run `rails new #{app_name}`
4
+ Then it should pass with:
5
+ """
6
+ README
7
+ """
8
+ And I cd to "#{app_name}"
9
+ And I append to "Gemfile" with:
10
+ """
11
+ gem "cucumber-rails-training-wheels", :group => :test, :path => "../../.."
12
+ gem "cucumber-rails", :group => :test
13
+ gem "capybara", :group => :test
14
+ gem "rspec-rails", :group => :test
15
+ gem "database_cleaner", :group => :test
16
+ gem 'factory_girl', :group => :test
17
+
18
+ """
19
+ And I successfully run `bundle exec rails generate cucumber:install`
20
+ }
21
+ end
@@ -0,0 +1,8 @@
1
+ require 'bundler/setup'
2
+ require 'rspec/expectations'
3
+ require 'aruba/cucumber'
4
+
5
+ Before do
6
+ @aruba_timeout_seconds = 120 # A long time needed some times
7
+ unset_bundler_env_vars
8
+ end
@@ -0,0 +1,17 @@
1
+ Feature: Use training wheels
2
+
3
+ Scenario: I don't care. I'll use it anyway. Yee-haa!!
4
+ Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
5
+ # Generate features/step_definitions/web_steps.rb
6
+ And I successfully run `rails generate cucumber_rails_training_wheels:install`
7
+ # Generate features/post_feature.rb
8
+ And I successfully run `rails generate cucumber_rails_training_wheels:feature post title:string body:text number:integer published:boolean`
9
+ And I successfully run `rails generate scaffold post title:string body:text number:integer published:boolean`
10
+ And I run `bundle exec rake db:migrate`
11
+ And I run `bundle exec rake cucumber`
12
+ Then it should pass with:
13
+ """
14
+ 2 scenarios (2 passed)
15
+ 13 steps (13 passed)
16
+ """
17
+
@@ -0,0 +1,16 @@
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 https://github.com/cucumber/cucumber/wiki/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 (Rails 3):
11
+ `script/rails generate cucumber:feature post` # no attributes
12
+ `script/rails generate cucumber:feature post title:string body:text published:boolean`
13
+
14
+ Examples (Rails 2):
15
+ `script/generate feature post` # no attributes
16
+ `script/generate feature post title:string body:text published:boolean`
@@ -0,0 +1,27 @@
1
+ require File.join(File.dirname(__FILE__), 'named_arg')
2
+
3
+ module CucumberRailsTrainingWheels
4
+ class FeatureGenerator < ::Rails::Generators::NamedBase
5
+ source_root File.expand_path("../templates", __FILE__)
6
+
7
+ argument :fields, :optional => true, :type => :array, :banner => "[field:type, field:type]"
8
+
9
+ attr_reader :named_args
10
+
11
+ def parse_fields
12
+ @named_args = @fields.nil? ? [] : @fields.map { |arg| NamedArg.new(arg) }
13
+ end
14
+
15
+ def generate
16
+ template 'feature.erb', "features/manage_#{plural_name}.feature"
17
+ template 'steps.erb', "features/step_definitions/#{singular_name}_steps.rb"
18
+ gsub_file 'features/support/paths.rb', /'\/'/mi do |match|
19
+ "#{match}\n when /the new #{singular_name} page/\n new_#{singular_name}_path\n"
20
+ end
21
+ end
22
+
23
+ def self.banner
24
+ "#{$0} cucumber:feature ModelName [field:type, field:type]"
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,20 @@
1
+ module CucumberRailsTrainingWheels
2
+ class NamedArg
3
+ attr_reader :name
4
+ attr_reader :type
5
+
6
+ def initialize(s)
7
+ @name, @type = *s.split(':')
8
+ end
9
+
10
+ def value(n)
11
+ if @type == 'boolean'
12
+ (n % 2) == 0
13
+ elsif @type == 'integer'
14
+ n
15
+ else
16
+ "#{@name} #{n}"
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,63 @@
1
+ Feature: Manage <%= plural_name %>
2
+ In order to [goal]
3
+ [stakeholder]
4
+ wants [behaviour]
5
+
6
+ Scenario: Register new <%= singular_name %>
7
+ Given I am on the new <%= singular_name %> page
8
+ <% keyword = 'When' -%>
9
+ <% named_args.each do |arg| -%>
10
+ <% if arg.type == 'boolean' -%>
11
+ <%= keyword %> I uncheck "<%= arg.name.humanize %>"
12
+ <% else -%>
13
+ <%= keyword %> I fill in "<%= arg.name.humanize %>" with "<%= arg.value(1) %>"
14
+ <% end -%>
15
+ <% keyword = 'And' -%>
16
+ <% end -%>
17
+ And I press "Create"
18
+ <% keyword = 'Then' -%>
19
+ <% named_args.each do |arg| -%>
20
+ <%= keyword %> I should see "<%= arg.value(1) %>"
21
+ <% keyword = 'And' -%>
22
+ <% end -%>
23
+
24
+ <% if IO.read('features/support/env.rb') =~ /capybara/n -%>
25
+ # Rails generates Delete links that use Javascript to pop up a confirmation
26
+ # dialog and then do a HTTP POST request (emulated DELETE request).
27
+ #
28
+ # Capybara must use Culerity/Celerity or Selenium2 (webdriver) when pages rely
29
+ # on Javascript events. Only Culerity/Celerity supports clicking on confirmation
30
+ # dialogs.
31
+ #
32
+ # Since Culerity/Celerity and Selenium2 has some overhead, Cucumber-Rails will
33
+ # detect the presence of Javascript behind Delete links and issue a DELETE request
34
+ # instead of a GET request.
35
+ #
36
+ # You can turn this emulation off by tagging your scenario with @no-js-emulation.
37
+ # Turning on browser testing with @selenium, @culerity, @celerity or @javascript
38
+ # will also turn off the emulation. (See the Capybara documentation for
39
+ # details about those tags). If any of the browser tags are present, Cucumber-Rails
40
+ # will also turn off transactions and clean the database with DatabaseCleaner
41
+ # after the scenario has finished. This is to prevent data from leaking into
42
+ # the next scenario.
43
+ #
44
+ # Another way to avoid Cucumber-Rails' javascript emulation without using any
45
+ # of the tags above is to modify your views to use <button> instead. You can
46
+ # see how in http://github.com/jnicklas/capybara/issues#issue/12
47
+ #
48
+ <% if options[:capybara] -%>
49
+ @<%= options[:capybara] %>
50
+ <% end -%>
51
+ <% end -%>
52
+ Scenario: Delete <%= singular_name %>
53
+ Given the following <%= plural_name %>:
54
+ |<%= named_args.map(&:name).join('|') %>|
55
+ <% (1..4).each do |n| -%>
56
+ |<%= named_args.map{|arg| arg.value(n)}.join('|') %>|
57
+ <% end -%>
58
+ When I delete the 3rd <%= singular_name %>
59
+ Then I should see the following <%= plural_name %>:
60
+ |<%= named_args.map{|arg| arg.name.humanize}.join('|') %>|
61
+ <% [1,2,4].each do |n| -%>
62
+ |<%= named_args.map{|arg| arg.value(n)}.join('|') %>|
63
+ <% end -%>
@@ -0,0 +1,14 @@
1
+ Given /^the following <%= plural_name %>:$/ do |<%= plural_name %>|
2
+ <%= class_name %>.create!(<%= plural_name %>.hashes)
3
+ end
4
+
5
+ When /^I delete the (\d+)(?:st|nd|rd|th) <%= singular_name %>$/ do |pos|
6
+ visit <%= plural_name %>_path
7
+ within("table tr:nth-child(#{pos.to_i+1})") do
8
+ click_link "Destroy"
9
+ end
10
+ end
11
+
12
+ Then /^I should see the following <%= plural_name %>:$/ do |expected_<%= plural_name %>_table|
13
+ expected_<%= plural_name %>_table.diff!(tableish('table tr', 'td,th'))
14
+ end
@@ -0,0 +1,15 @@
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 cucumber:feature generator.
8
+
9
+ Examples:
10
+ `rails generate cucumber:install`
11
+
12
+ `rails generate cucumber:install --help`
13
+
14
+ You can also provide a language argument for localized web_steps:
15
+ `rails generate cucumber:install de`