casecumber-rails 1.0.2.1

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 (84) hide show
  1. data/.gitignore +6 -0
  2. data/.rspec +1 -0
  3. data/.rvmrc +1 -0
  4. data/Gemfile +2 -0
  5. data/Gemfile.lock +205 -0
  6. data/History.md +219 -0
  7. data/LICENSE +22 -0
  8. data/README.md +77 -0
  9. data/Rakefile +9 -0
  10. data/config/.gitignore +1 -0
  11. data/config/cucumber.yml +1 -0
  12. data/cucumber-rails.gemspec +46 -0
  13. data/dev_tasks/cucumber.rake +5 -0
  14. data/dev_tasks/rspec.rake +8 -0
  15. data/dev_tasks/yard.rake +0 -0
  16. data/dev_tasks/yard/default/layout/html/bubble_32x32.png +0 -0
  17. data/dev_tasks/yard/default/layout/html/footer.erb +5 -0
  18. data/dev_tasks/yard/default/layout/html/index.erb +1 -0
  19. data/dev_tasks/yard/default/layout/html/layout.erb +25 -0
  20. data/dev_tasks/yard/default/layout/html/logo.erb +1 -0
  21. data/dev_tasks/yard/default/layout/html/setup.rb +4 -0
  22. data/features/allow_rescue.feature +63 -0
  23. data/features/capybara_javascript_drivers.feature +87 -0
  24. data/features/database_cleaner.feature +44 -0
  25. data/features/emulate_javascript.feature +34 -0
  26. data/features/inspect_query_string.feature +37 -0
  27. data/features/install_cucumber_rails.feature +16 -0
  28. data/features/mongoid.feature +53 -0
  29. data/features/multiple_databases.feature +74 -0
  30. data/features/named_selectors.feature +33 -0
  31. data/features/no_database.feature +70 -0
  32. data/features/pseduo_class_selectors.feature +24 -0
  33. data/features/rerun_profile.feature +38 -0
  34. data/features/rest_api.feature +47 -0
  35. data/features/routing.feature +18 -0
  36. data/features/select_dates.feature +99 -0
  37. data/features/step_definitions/cucumber_rails_steps.rb +89 -0
  38. data/features/support/env.rb +37 -0
  39. data/features/test_unit.feature +43 -0
  40. data/lib/cucumber/rails.rb +23 -0
  41. data/lib/cucumber/rails/action_controller.rb +12 -0
  42. data/lib/cucumber/rails/application.rb +17 -0
  43. data/lib/cucumber/rails/capybara.rb +6 -0
  44. data/lib/cucumber/rails/capybara/javascript_emulation.rb +83 -0
  45. data/lib/cucumber/rails/capybara/select_dates_and_times.rb +50 -0
  46. data/lib/cucumber/rails/hooks.rb +4 -0
  47. data/lib/cucumber/rails/hooks/active_record.rb +21 -0
  48. data/lib/cucumber/rails/hooks/allow_rescue.rb +8 -0
  49. data/lib/cucumber/rails/hooks/database_cleaner.rb +13 -0
  50. data/lib/cucumber/rails/hooks/mail.rb +5 -0
  51. data/lib/cucumber/rails/rspec.rb +21 -0
  52. data/lib/cucumber/rails/world.rb +26 -0
  53. data/lib/cucumber/web/tableish.rb +118 -0
  54. data/lib/generators/cucumber/feature/USAGE +16 -0
  55. data/lib/generators/cucumber/feature/feature_generator.rb +28 -0
  56. data/lib/generators/cucumber/feature/named_arg.rb +19 -0
  57. data/lib/generators/cucumber/feature/templates/feature.erb +63 -0
  58. data/lib/generators/cucumber/feature/templates/steps.erb +14 -0
  59. data/lib/generators/cucumber/install/USAGE +15 -0
  60. data/lib/generators/cucumber/install/install_generator.rb +88 -0
  61. data/lib/generators/cucumber/install/templates/config/cucumber.yml.erb +8 -0
  62. data/lib/generators/cucumber/install/templates/script/cucumber +10 -0
  63. data/lib/generators/cucumber/install/templates/step_definitions/web_steps.rb.erb +192 -0
  64. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_cs.rb.erb +127 -0
  65. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_da.rb.erb +105 -0
  66. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_de.rb.erb +127 -0
  67. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_es.rb.erb +127 -0
  68. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_ja.rb.erb +140 -0
  69. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_ko.rb.erb +142 -0
  70. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_no.rb.erb +105 -0
  71. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_pt-BR.rb.erb +132 -0
  72. data/lib/generators/cucumber/install/templates/support/_rails_each_run.rb.erb +36 -0
  73. data/lib/generators/cucumber/install/templates/support/_rails_prefork.rb.erb +1 -0
  74. data/lib/generators/cucumber/install/templates/support/capybara.rb +5 -0
  75. data/lib/generators/cucumber/install/templates/support/edit_warning.txt +5 -0
  76. data/lib/generators/cucumber/install/templates/support/paths.rb +33 -0
  77. data/lib/generators/cucumber/install/templates/support/rails.rb.erb +4 -0
  78. data/lib/generators/cucumber/install/templates/support/rails_spork.rb.erb +13 -0
  79. data/lib/generators/cucumber/install/templates/support/selectors.rb +39 -0
  80. data/lib/generators/cucumber/install/templates/support/web_steps_warning.txt +19 -0
  81. data/lib/generators/cucumber/install/templates/tasks/cucumber.rake.erb +60 -0
  82. data/spec/cucumber/web/tableish_spec.rb +239 -0
  83. data/spec/spec_helper.rb +3 -0
  84. metadata +514 -0
data/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # Cucumber-Rails
2
+
3
+ Cucumber-Rails brings Cucumber to 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,
7
+ giving you a head start for writing Cucumber features against your Rails app.
8
+
9
+ ## Installation
10
+
11
+ Before you can use the generator, add the gem to your project's Gemfile as follows:
12
+
13
+ group :test do
14
+ gem 'cucumber-rails'
15
+ # database_cleaner is not required, but highly recommended
16
+ gem 'database_cleaner'
17
+ end
18
+
19
+ Then install it by running:
20
+
21
+ bundle install
22
+
23
+ Learn about the various options:
24
+
25
+ rails generate cucumber:install --help
26
+
27
+ Finally, bootstrap your Rails app, for example:
28
+
29
+ rails generate cucumber:install
30
+
31
+ ## Generating a Cucumber feature
32
+
33
+ IMPORTANT: Only do this if you are new to Cucumber. We recommend you write your
34
+ Cucumber features by hand once you get the hang of it.
35
+
36
+ Example:
37
+
38
+ rails generate cucumber:feature post title:string body:text published:boolean
39
+ rails generate scaffold post title:string body:text published:boolean
40
+ rake db:migrate
41
+ rake cucumber
42
+
43
+ ## Running Cucumber
44
+
45
+ With Rake:
46
+
47
+ rake cucumber
48
+
49
+ Without Rake:
50
+
51
+ [bundle exec] cucumber
52
+
53
+ ## Bugs and feature requests
54
+
55
+ The *only* way to have a bug fixed or a new feature accepted is to describe it with a Cucumber feature. Let's say you think you have found a bug in the cucumber:install generator. Fork this project, clone it to your workstation and check out a branch with a descriptive name:
56
+
57
+ git clone git@github.com:you/cucumber-rails.git
58
+ git checkout -b bug-install-generator
59
+
60
+ Start by making sure you can run the existing features. Now, create a feature that demonstrates what's wrong. See the existing features for examples. When you have a failing feature that reproduces the bug, commit, push and send a pull request. Someone from the Cucumber-Rails team will review it and hopefully create a fix.
61
+
62
+ If you know how to fix the bug yourself, make a second commit (after committing the failing feature) before you send the pull request.
63
+
64
+ ### Setting up your environment
65
+
66
+ I strongly recommend rvm and ruby 1.9.2. When you have that, cd into your cucumber-rails repository and:
67
+
68
+ gem install bundler
69
+ bundle install
70
+
71
+ ### Running all features
72
+
73
+ With all dependencies installed, all features should pass:
74
+
75
+ rake cucumber
76
+
77
+ One of the features uses MongoDB, which needs to be running in order to make features/mongoid.feature to pass.
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+ CUCUMBER_RAILS_VERSION = Gem::Specification.load(File.dirname(__FILE__) + '/cucumber-rails.gemspec').version.version
3
+ require 'rubygems'
4
+ require 'bundler/setup'
5
+ Bundler::GemHelper.install_tasks
6
+
7
+ $:.unshift(File.dirname(__FILE__) + '/lib')
8
+ Dir["#{File.dirname(__FILE__)}/dev_tasks/*.rake"].sort.each { |ext| load ext }
9
+ task :default => :cucumber
data/config/.gitignore ADDED
@@ -0,0 +1 @@
1
+ aruba-rvm.yml
@@ -0,0 +1 @@
1
+ default: --tags ~@broken
@@ -0,0 +1,46 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'casecumber-rails'
6
+ s.version = '1.0.2.1'
7
+ s.authors = ["Aslak Hellesøy", "Dennis Blöte", "Rob Holland", "Case Commons LLC", "Trace Wax", "Jason Berlinsky"]
8
+ s.description = "Cucumber Generators and Runtime for Rails"
9
+ s.summary = "#{s.name}-#{s.version}"
10
+ s.email = ["cukes@googlegroups.com", "casecommons-dev@googlegroups.com", "gems@tracedwax.com", "jason@jasonberlinsky.com"]
11
+ s.homepage = "http://cukes.info"
12
+
13
+ s.add_dependency('casecumber', '~> 1.0.2.1')
14
+ s.add_dependency('nokogiri', '>= 1.4.6')
15
+ s.add_dependency('capybara', '>= 1.0.0')
16
+ s.add_development_dependency('rails', '>= 3.1.0.rc4')
17
+ s.add_development_dependency('rake', '>= 0.9.2')
18
+ s.add_development_dependency('bundler', '>= 1.0.15')
19
+ s.add_development_dependency('aruba', '>= 0.4.3')
20
+ s.add_development_dependency('sqlite3-ruby', '>= 1.3.3')
21
+ s.add_development_dependency('rspec', '>= 2.6.0')
22
+ s.add_development_dependency('rspec-rails', '>= 2.6.1')
23
+ s.add_development_dependency('factory_girl', '>= 2.0.0')
24
+ s.add_development_dependency('database_cleaner', '>= 0.6.7')
25
+ s.add_development_dependency('mongoid', '>= 2.0.2')
26
+ s.add_development_dependency('bson_ext', '>= 1.3.1')
27
+ # s.add_development_dependency('akephalos', '>= 0.2.5')
28
+
29
+ # Various Stuff that Rails 3.1 puts inside apps.
30
+ s.add_development_dependency('turn', '>= 0.8.2')
31
+ s.add_development_dependency('sass', '>= 3.1.3')
32
+ s.add_development_dependency('coffee-script', '>= 2.2.0')
33
+ s.add_development_dependency('uglifier', '>= 1.0.0')
34
+ s.add_development_dependency('jquery-rails', '>= 1.0.12')
35
+
36
+ # For Documentation:
37
+ s.add_development_dependency('yard', '= 0.7.1')
38
+ s.add_development_dependency('rdiscount', '= 1.6.8')
39
+ s.add_development_dependency('bcat', '= 0.6.1')
40
+
41
+ s.rubygems_version = ">= 1.6.1"
42
+ s.files = `git ls-files`.split("\n")
43
+ s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
44
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
45
+ s.require_path = "lib"
46
+ end
@@ -0,0 +1,5 @@
1
+ require 'cucumber/rake/task'
2
+
3
+ Cucumber::Rake::Task.new do |t|
4
+ t.rcov = false
5
+ end
@@ -0,0 +1,8 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ desc "Run RSpec"
4
+ RSpec::Core::RakeTask.new do |t|
5
+ t.rcov = ENV['RCOV']
6
+ t.rcov_opts = %w{--exclude osx\/objc,gems\/,spec\/}
7
+ t.verbose = true
8
+ end
File without changes
@@ -0,0 +1,5 @@
1
+ <div id="footer">
2
+ Generated on <%= Time.now.strftime("%c") %> by
3
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
4
+ <%= YARD::VERSION %> (ruby-<%= RUBY_VERSION %>).
5
+ </div>
@@ -0,0 +1 @@
1
+ <%= yieldall %>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <%= erb(:headers) %>
6
+ </head>
7
+ <body>
8
+ <script type="text/javascript" charset="utf-8">
9
+ if (window.top.frames.main) document.body.className = 'frames';
10
+ </script>
11
+
12
+ <div id="header">
13
+ <%= erb(:logo) %>
14
+ <%= erb(:breadcrumb) %>
15
+ <%= erb(:search) %>
16
+ <div class="clear"></div>
17
+ </div>
18
+
19
+ <iframe id="search_frame"></iframe>
20
+
21
+ <div id="content"><%= yieldall %></div>
22
+
23
+ <%= erb(:footer) %>
24
+ </body>
25
+ </html>
@@ -0,0 +1 @@
1
+ <h3><img src="<%= url_for('images/bubble_32x32.png') %>"></img> Cucumber-Rails <%= CUCUMBER_RAILS_VERSION %></h3>
@@ -0,0 +1,4 @@
1
+ def init
2
+ super
3
+ options[:serializer].serialize('/images/bubble_32x32.png', IO.read(File.dirname(__FILE__) + '/bubble_32x32.png'))
4
+ end
@@ -0,0 +1,63 @@
1
+ Feature: Allow Cucumber to rescue exceptions
2
+
3
+ Background: A controller that raises an exception in a Rails app without web_steps.rb
4
+ Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
5
+ And I remove the file "features/step_definitions/web_steps.rb"
6
+ And I write to "app/controllers/posts_controller.rb" with:
7
+ """
8
+ class PostsController < ApplicationController
9
+ def index
10
+ raise "There is an error in index"
11
+ end
12
+ end
13
+ """
14
+ And I write to "config/routes.rb" with:
15
+ """
16
+ Rails3App::Application.routes.draw do
17
+ resources :posts
18
+ end
19
+ """
20
+
21
+ Scenario: Allow rescue
22
+ And I write to "features/posts.feature" with:
23
+ """
24
+ Feature: posts
25
+ @allow-rescue
26
+ Scenario: See posts
27
+ When I look at the posts
28
+ """
29
+ And I write to "features/step_definitions/posts_steps.rb" with:
30
+ """
31
+ When /^I look at the posts$/ do
32
+ visit '/posts'
33
+ end
34
+ """
35
+ And I run `bundle exec rake db:migrate`
36
+ And I run `bundle exec cucumber`
37
+ Then it should pass with:
38
+ """
39
+ 1 scenario (1 passed)
40
+ 1 step (1 passed)
41
+ """
42
+
43
+ Scenario: Don't allow rescue
44
+ Given I write to "features/posts.feature" with:
45
+ """
46
+ Feature: posts
47
+ Scenario: See them
48
+ When I look at the posts
49
+ """
50
+ And I write to "features/step_definitions/posts_steps.rb" with:
51
+ """
52
+ When /^I look at the posts$/ do
53
+ visit '/posts'
54
+ end
55
+ """
56
+ And I run `bundle exec rake db:migrate`
57
+ And I run `bundle exec cucumber`
58
+ Then it should fail with:
59
+ """
60
+ 1 scenario (1 failed)
61
+ 1 step (1 failed)
62
+ """
63
+
@@ -0,0 +1,87 @@
1
+ Feature: Capybara Javascript Drivers
2
+
3
+ Background: A simple calendar app
4
+ Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
5
+ And I successfully run `bundle exec rails g scaffold appointment name:string when:datetime`
6
+
7
+ Scenario Outline: Use a particular driver
8
+ Given I write to "features/create_appointment.feature" with:
9
+ """
10
+ @javascript
11
+ Feature: Create appointments
12
+ Scenario: Constitution on May 17
13
+ Given I am on the new appointment page
14
+ And I fill in "Norway's constitution" for "Name"
15
+ And I select "2009-02-20 15:10:00 UTC" as the "When" date and time
16
+ And I press "Create Appointment"
17
+ Then I should see "Norway's constitution"
18
+ And I should see "2009-02-20 15:10:00 UTC"
19
+
20
+ """
21
+ And I append to "Gemfile" with:
22
+ """
23
+ <Gemfile extra>
24
+
25
+ """
26
+ And I append to "features/support/env.rb" with:
27
+ """
28
+ <env.rb extra>
29
+
30
+ """
31
+
32
+ When I run `bundle exec rake db:migrate`
33
+ And I run `bundle exec rake cucumber`
34
+ Then it should pass with:
35
+ """
36
+ 1 scenario (1 passed)
37
+ 6 steps (6 passed)
38
+ """
39
+
40
+ Examples:
41
+ | Gemfile extra | env.rb extra |
42
+ | gem "capybara", :group => :test | require 'capybara' |
43
+
44
+ Scenario Outline: Mixed DB access
45
+ Given I write to "features/create_appointment.feature" with:
46
+ """
47
+ @javascript
48
+ Feature: Create appointments
49
+ Scenario: Constitution on May 17
50
+ Given a random appointment
51
+ And I am viewing random appointment
52
+ Then I should see "Random appointment"
53
+
54
+ """
55
+ And I write to "features/step_definitions/custom_steps.rb" with:
56
+ """
57
+ Given /^a random appointment$/ do
58
+ @appointment = Appointment.create!(:name => 'Random appointment', :when => DateTime.now)
59
+ end
60
+
61
+ Given /^I am viewing random appointment$/ do
62
+ visit appointment_path(@appointment)
63
+ end
64
+ """
65
+ And I append to "Gemfile" with:
66
+ """
67
+ <Gemfile extra>
68
+
69
+ """
70
+ And I append to "features/support/env.rb" with:
71
+ """
72
+ <env.rb extra>
73
+
74
+ """
75
+
76
+ When I run `bundle exec rake db:migrate`
77
+ And I run `bundle exec rake cucumber`
78
+ Then it should pass with:
79
+ """
80
+ 1 scenario (1 passed)
81
+ 3 steps (3 passed)
82
+ """
83
+
84
+ Examples:
85
+ | Gemfile extra | env.rb extra |
86
+ | gem "capybara", :group => :test | require 'capybara' |
87
+
@@ -0,0 +1,44 @@
1
+ Feature: DatabaseCleaner
2
+
3
+ Scenario: Create records in background
4
+ Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
5
+ And I write to "features/widgets.feature" with:
6
+ """
7
+ Feature: Create widgets
8
+ Background: some widdgets
9
+ Given I have 2 widgets
10
+
11
+ Scenario: Add 3
12
+ When I create 3 more widgets
13
+ Then I should have 5 widgets
14
+
15
+ Scenario: Add 7
16
+ When I create 7 more widgets
17
+ Then I should have 9 widgets
18
+ """
19
+ And I successfully run `rails generate model widget name:string`
20
+ And I write to "features/step_definitions/widget_steps.rb" with:
21
+ """
22
+ Given /^I have (\d+) widgets$/ do |n|
23
+ n.to_i.times do |i|
24
+ Widget.create! :name => "Widget #{Widget.count + i}"
25
+ end
26
+ end
27
+
28
+ When /^I create (\d+) more widgets$/ do |n|
29
+ n.to_i.times do |i|
30
+ Widget.create! :name => "Widget #{Widget.count + i}"
31
+ end
32
+ end
33
+
34
+ Then /^I should have (\d+) widgets$/ do |n|
35
+ Widget.count.should == n.to_i
36
+ end
37
+ """
38
+ And I run `bundle exec rake db:migrate`
39
+ And I run `bundle exec rake cucumber`
40
+ Then it should pass with:
41
+ """
42
+ 2 scenarios (2 passed)
43
+ 6 steps (6 passed)
44
+ """
@@ -0,0 +1,34 @@
1
+ Feature: Emulate Javascript
2
+
3
+ Scenario: See a widget
4
+ Given I have created a new Rails 3 app "widgets" with cucumber-rails support
5
+ And I successfully run `rails generate scaffold widget name:string`
6
+ And I write to "features/f.feature" with:
7
+ """
8
+ @javascript
9
+ Feature: Widget inventory
10
+ Scenario: Delete a widget
11
+ Given there is a widget named "wrench"
12
+ When I go to the widgets page
13
+ Then I should see "wrench"
14
+ """
15
+ And I write to "features/step_definitions/s.rb" with:
16
+ """
17
+ Given /^there is a widget named "([^"]*)"$/ do |name|
18
+ Factory(:widget, :name => name)
19
+ end
20
+ """
21
+ And I write to "features/support/factories.rb" with:
22
+ """
23
+ Factory.define :widget do |f|
24
+ f.name 'testwidget'
25
+ end
26
+ """
27
+ When I run `bundle exec rake db:migrate`
28
+ And I run `bundle exec rake cucumber`
29
+ Then it should pass with:
30
+ """
31
+ 1 scenario (1 passed)
32
+ 3 steps (3 passed)
33
+ """
34
+