cucumber-rails 0.4.0.beta.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/.rvmrc +1 -1
  2. data/HACKING.rdoc +6 -8
  3. data/History.txt +18 -2
  4. data/README.rdoc +8 -10
  5. data/cucumber-rails.gemspec +10 -6
  6. data/dev_tasks/cucumber.rake +1 -1
  7. data/features/allow_rescue.feature +61 -0
  8. data/features/inspect_query_string.feature +36 -0
  9. data/features/install_cucumber_rails.feature +16 -0
  10. data/features/mongoid.feature +53 -0
  11. data/features/named_selectors.feature +33 -0
  12. data/features/no_database.feature +69 -0
  13. data/features/rerun_profile.feature +1 -2
  14. data/features/rest_api.feature +46 -0
  15. data/features/routing.feature +21 -0
  16. data/features/select_dates.feature +25 -0
  17. data/features/step_definitions/cucumber_rails_steps.rb +65 -4
  18. data/features/support/env.rb +5 -1
  19. data/generators/cucumber/cucumber_generator.rb +1 -27
  20. data/lib/cucumber/rails.rb +3 -20
  21. data/lib/cucumber/rails/capybara.rb +7 -0
  22. data/lib/cucumber/rails/capybara/select_dates_and_times.rb +21 -14
  23. data/lib/cucumber/rails/hooks.rb +3 -0
  24. data/lib/cucumber/rails/hooks/database_cleaner.rb +16 -3
  25. data/lib/cucumber/rails/rspec.rb +2 -0
  26. data/lib/cucumber/rails/version.rb +14 -9
  27. data/lib/cucumber/rails/world.rb +6 -0
  28. data/lib/cucumber/rails2.rb +1 -1
  29. data/lib/cucumber/rails3.rb +7 -7
  30. data/lib/generators/cucumber/install/install_base.rb +11 -51
  31. data/templates/install/config/cucumber.yml.erb +1 -1
  32. data/templates/install/step_definitions/capybara_steps.rb.erb +63 -85
  33. data/templates/install/step_definitions/web_steps_cs.rb.erb +11 -20
  34. data/templates/install/step_definitions/web_steps_da.rb.erb +11 -20
  35. data/templates/install/step_definitions/web_steps_es.rb.erb +11 -20
  36. data/templates/install/step_definitions/web_steps_ja.rb.erb +1 -0
  37. data/templates/install/step_definitions/web_steps_ko.rb.erb +1 -0
  38. data/templates/install/step_definitions/web_steps_no.rb.erb +11 -20
  39. data/templates/install/step_definitions/web_steps_pt-BR.rb.erb +11 -20
  40. data/templates/install/step_definitions/webrat_steps.rb.erb +11 -10
  41. data/templates/install/support/_rails_each_run.rb.erb +3 -19
  42. data/templates/install/support/edit_warning.txt +19 -5
  43. data/templates/install/support/selectors.rb +39 -0
  44. data/templates/install/tasks/cucumber.rake.erb +4 -0
  45. metadata +100 -82
  46. data/features/rails2.feature +0 -45
  47. data/features/rails3.feature +0 -123
  48. data/features/support/matchers/files.rb +0 -17
  49. data/spec/generators/cucumber/install/install_base_spec.rb +0 -75
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm @cucumber
1
+ rvm @cucumber --create
@@ -3,22 +3,20 @@
3
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
4
 
5
5
  git clone git@github.com:you/cucumber-rails.git
6
- git checkout -b 87-add-chinese-translation
6
+ git checkout -b 87-my-awesome-bugfix
7
7
 
8
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.
9
10
 
10
11
  == Setting up your environment
11
12
 
12
- Before you change anything, you should make sure you can run all the Cucumber features for Cucumber-Rails. You need rvm.
13
+ I strongly recommend rvm and ruby 1.9.2. When you have that, cd into your cucumber-rails repository and:
13
14
 
14
- sudo gem install rvm
15
- rvm install ruby-1.8.7-p249 ruby-1.9.1-p378
15
+ gem install bundler
16
+ bundle install
16
17
 
17
18
  == Running all features
18
19
 
19
20
  rake cucumber
20
21
 
21
- This takes a long time because a lot of gems have to be installed. (This is done while running the cucumber features)
22
-
23
- == Gotchas
24
- * https://rails.lighthouseapp.com/projects/8994/tickets/3865-invalid-gemspec-format-in-and-already-initialized-constant-warnings-with-ruby-192dev
22
+ One of the features uses MongoDB, which needs to be running in order to make features/mongoid.feature to pass.
@@ -1,10 +1,26 @@
1
- == In Git
1
+ == 0.4.0 2011-03-20
2
2
 
3
- No more Cucumber::Rails::World.use_transactional_fixtures = false. Use DatabaseCleaner.strategy = :none instead
3
+ === New Features
4
+ * Add selectors helper (#63 Bodaniel Jeanes)
5
+ * Capybara date stepdefs (#66 Rob Holland)
6
+ * The World now includes Rack::Test::Methods, allowing get, post, put delete (Aslak Hellesøy)
4
7
 
5
8
  === Bugfixes
9
+ * Allow setting rails root (#102, #103, Fabio Kreusch)
10
+ * Fix Date selection steps and helpers (#93, #99, #100, #101, #109 James Herdman, John Ferlito, twalpole, Geoff Drake, Ricky Robinson, Michael Fleet)
11
+ * Can not run cucumber-rails (0.4.0.beta.1) with cucumber (0.10.0) (#89 Aslak Hellesøy)
12
+ * Installing cucumber-rails without a database.yml fails (#61 Aslak Hellesøy)
13
+ * Fix #click_link compatibility with Capybara 0.4. (#54, #77, #78, #80 Aslak Hellesøy)
14
+ * Support for projects using other ORMs than ActiveRecord (or nothing at all). (#18, #22, #46, #85, #86, #87, #90 Aslak Hellesøy)
15
+ * @allow-rescue not working in rails 3 (#31 Joe Ferris, Aslak Hellesøy)
6
16
  * Gem dependency on Nokogiri (for #tableish). (#53 Aslak Hellesøy)
7
17
 
18
+ === Removed Features
19
+ * Automatic detection of RSpec, Capybara and Webrat for install generator. Set gems explicitly in your Gemfile (Rails3) or environment.rb (Rails2)
20
+ * Then /^(?:|I )should see JSON:$/. Use #get and #last_response instead. See features/rails3.feature. (Aslak Hellesøy)
21
+ * Cucumber::Rails::World.use_transactional_fixtures. TODO: Explain what to do instead.
22
+ No more Cucumber::Rails::World.use_transactional_fixtures = false. Use DatabaseCleaner.strategy = :none instead
23
+
8
24
  == 0.3.2 2010-06-06
9
25
 
10
26
  == Changed features
@@ -10,17 +10,15 @@ giving you a head start for writing Cucumber features against your Rails app.
10
10
 
11
11
  === Rails 3:
12
12
 
13
- Before you can use the generator, add the necessary gems to your project's Gemfile as follows:
13
+ Before you can use the generator, add the gem to your project's Gemfile as follows:
14
14
 
15
- gem 'capybara'
16
- gem 'database_cleaner'
17
- gem 'cucumber-rails'
18
- gem 'cucumber'
19
- gem 'rspec-rails'
20
- gem 'spork'
21
- gem 'launchy' # So you can do Then show me the page
15
+ group :test do
16
+ gem 'cucumber-rails'
17
+ gem 'capybara'
18
+ gem 'database_cleaner'
19
+ end
22
20
 
23
- Then install the gems by running:
21
+ Then install it by running:
24
22
 
25
23
  bundle install
26
24
 
@@ -30,7 +28,7 @@ Learn about the various options:
30
28
 
31
29
  Finally, bootstrap your Rails app, for example:
32
30
 
33
- ruby script/rails generate cucumber:install --rspec --capybara
31
+ rails generate cucumber:install
34
32
 
35
33
  === Rails 2.x:
36
34
 
@@ -11,16 +11,20 @@ Gem::Specification.new do |s|
11
11
  s.email = 'cukes@googlegroups.com'
12
12
  s.homepage = "http://cukes.info"
13
13
 
14
- s.add_dependency('cucumber', '~> 0.10.0')
15
- s.add_development_dependency('aruba', '~> 0.2.7')
16
- s.add_development_dependency('rails', '~> 3.0.3')
17
- s.add_development_dependency('sqlite3-ruby', '~> 1.3.2')
14
+ s.add_dependency('cucumber', Cucumber::Rails::DEPS['cucumber'])
15
+ s.add_dependency('rack-test', Cucumber::Rails::DEPS['rack-test'])
16
+ s.add_dependency('nokogiri', Cucumber::Rails::DEPS['nokogiri'])
17
+ s.add_development_dependency('bundler', Cucumber::Rails::DEPS['bundler'])
18
+ s.add_development_dependency('aruba', Cucumber::Rails::DEPS['aruba'])
19
+ s.add_development_dependency('rails', Cucumber::Rails::DEPS['rails'])
20
+ s.add_development_dependency('sqlite3-ruby', Cucumber::Rails::DEPS['sqlite3-ruby'])
18
21
  s.add_development_dependency('rspec-rails', Cucumber::Rails::DEPS['rspec-rails'])
19
22
  s.add_development_dependency('capybara', Cucumber::Rails::DEPS['capybara'])
20
23
  s.add_development_dependency('webrat', Cucumber::Rails::DEPS['webrat'])
21
24
  s.add_development_dependency('database_cleaner', Cucumber::Rails::DEPS['database_cleaner'])
22
-
23
- s.rubygems_version = "1.3.7"
25
+ s.add_development_dependency('mongoid', Cucumber::Rails::DEPS['mongoid'])
26
+
27
+ s.rubygems_version = ">= 1.6.1"
24
28
  s.files = `git ls-files`.split("\n")
25
29
  s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
26
30
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
@@ -1,5 +1,5 @@
1
1
  require 'cucumber/rake/task'
2
2
 
3
3
  Cucumber::Rake::Task.new do |t|
4
- t.rcov = true
4
+ t.rcov = false
5
5
  end
@@ -0,0 +1,61 @@
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 cucumber`
36
+ Then it should pass with:
37
+ """
38
+ 1 scenario (1 passed)
39
+ 1 step (1 passed)
40
+ """
41
+
42
+ Scenario: Don't allow rescue
43
+ Given I write to "features/posts.feature" with:
44
+ """
45
+ Feature: posts
46
+ Scenario: See them
47
+ When I look at the posts
48
+ """
49
+ And I write to "features/step_definitions/posts_steps.rb" with:
50
+ """
51
+ When /^I look at the posts$/ do
52
+ visit '/posts'
53
+ end
54
+ """
55
+ And I run `bundle exec rake db:migrate cucumber`
56
+ Then it should fail with:
57
+ """
58
+ 1 scenario (1 failed)
59
+ 1 step (1 failed)
60
+ """
61
+
@@ -0,0 +1,36 @@
1
+ Feature: Inspect query string
2
+
3
+ Scenario: Inspect query string
4
+ Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
5
+ And I successfully run `rails generate cucumber:feature post title:string body:text published:boolean`
6
+ And I successfully run `rails generate scaffold post title:string body:text published:boolean`
7
+ And I successfully run `rails generate scaffold cukes name:string`
8
+ And I overwrite "app/controllers/cukes_controller.rb" with:
9
+ """
10
+ class CukesController < ApplicationController
11
+ def index
12
+ redirect_to cuke_path(10, {:name => 'cucumber', :what => 'vegetable'})
13
+ end
14
+
15
+ def show
16
+ render :text => "Cuke #{params[:id]}"
17
+ end
18
+ end
19
+ """
20
+ And I write to "features/tests.feature" with:
21
+ """
22
+ Feature: Tests
23
+ Scenario: Tests
24
+ When I go to the cukes page
25
+ Then I should have the following query string:
26
+ | name | cucumber |
27
+ | what | vegetable |
28
+ And I should see "Cuke 10"
29
+ """
30
+ And I run `bundle exec rake db:migrate cucumber`
31
+ Then it should pass with:
32
+ """
33
+ 3 scenarios (3 passed)
34
+ 14 steps (14 passed)
35
+ """
36
+
@@ -0,0 +1,16 @@
1
+ Feature: Rails 3
2
+ In order to take over the world
3
+ Cucumber-Rails should work on major versions
4
+ of Rails 3 and Ruby, with Capybara, Spork and DatabaseCleaner
5
+
6
+ Scenario: Install Cucumber-Rails
7
+ Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
8
+ Then the following files should exist:
9
+ | config/cucumber.yml |
10
+ | script/cucumber |
11
+ | features/step_definitions/web_steps.rb |
12
+ | features/support/env.rb |
13
+ | features/support/paths.rb |
14
+ | features/support/selectors.rb |
15
+ | lib/tasks/cucumber.rake |
16
+ And the file "features/support/env.rb" should contain "require 'cucumber/rails'"
@@ -0,0 +1,53 @@
1
+ @announce
2
+ Feature: Mongoid
3
+
4
+ Scenario: Keep Mongoid happy
5
+ Given I successfully run `rails new cuke-app`
6
+ And I cd to "cuke-app"
7
+ And I write to "config/application.rb" with:
8
+ """
9
+ require File.expand_path('../boot', __FILE__)
10
+
11
+ require 'action_controller/railtie'
12
+ require 'action_mailer/railtie'
13
+ require 'active_resource/railtie'
14
+ require 'rails/test_unit/railtie'
15
+
16
+ Bundler.require(:default, Rails.env) if defined?(Bundler)
17
+
18
+ module CukeApp
19
+ class Application < Rails::Application
20
+ config.encoding = "utf-8"
21
+ config.filter_parameters += [:password]
22
+ end
23
+ end
24
+ """
25
+ And I remove the file "config/database.yml"
26
+ And I append to "Gemfile" with:
27
+ """
28
+ gem "cucumber-rails", :group => :test, :path => '../../..'
29
+ gem "capybara", :group => :test
30
+ gem "database_cleaner", :group => :test
31
+ gem "mongoid", :group => :test
32
+ gem "bson_ext", :group => :test
33
+
34
+ """
35
+ And I successfully run `bundle exec rails generate cucumber:install`
36
+ And I successfully run `bundle exec rails generate mongoid:config`
37
+ And I write to "features/tests.feature" with:
38
+ """
39
+ Feature: Tests
40
+ Scenario: Tests
41
+ When I go to the home page
42
+ """
43
+ And I overwrite "features/support/env.rb" with:
44
+ """
45
+ require 'cucumber/rails'
46
+ DatabaseCleaner.strategy = :truncation
47
+ """
48
+ And I run `bundle exec rake cucumber`
49
+ Then it should pass with:
50
+ """
51
+ 1 scenario (1 passed)
52
+ 1 step (1 passed)
53
+ """
@@ -0,0 +1,33 @@
1
+ Feature: Named Selectors
2
+
3
+ Scenario: Look within named selector
4
+ Given a project without ActiveRecord
5
+ And a cukes resource
6
+ And I write to "app/views/cukes/index.html.erb" with:
7
+ """
8
+ <div class="foo">foo</div>
9
+ <div class="bar">bar</div>
10
+ """
11
+ And I write to "features/tests.feature" with:
12
+ """
13
+ Feature: Tests
14
+ Scenario: Tests
15
+ When I go to the cukes page
16
+ Then I should see "foo" within the foo div
17
+ And I should not see "bar" within the foo div
18
+ """
19
+ And I overwrite "features/support/selectors.rb" with:
20
+ """
21
+ module HtmlSelectorsHelpers
22
+ def selector_for(locator)
23
+ return '.foo' if locator == 'the foo div'
24
+ end
25
+ end
26
+ World(HtmlSelectorsHelpers)
27
+ """
28
+ And I run `rake cucumber`
29
+ Then it should pass with:
30
+ """
31
+ 1 scenario (1 passed)
32
+ 3 steps (3 passed)
33
+ """
@@ -0,0 +1,69 @@
1
+ Feature: No Database
2
+ Allow Cucumber to work with a Rails app without a database
3
+
4
+ Scenario: No ActiveRecord and DatabaseCleaner
5
+ Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
6
+ # Turn off ActiveRecord
7
+ And I write to "config/application.rb" with:
8
+ """
9
+ require File.expand_path('../boot', __FILE__)
10
+
11
+ require 'action_controller/railtie'
12
+ require 'action_mailer/railtie'
13
+ require 'active_resource/railtie'
14
+ require 'rails/test_unit/railtie'
15
+
16
+ Bundler.require(:default, Rails.env) if defined?(Bundler)
17
+
18
+ module Rails3App
19
+ class Application < Rails::Application
20
+ config.encoding = "utf-8"
21
+ config.filter_parameters += [:password]
22
+ end
23
+ end
24
+ """
25
+ And I remove the file "config/database.yml"
26
+ And I overwrite "features/support/env.rb" with:
27
+ """
28
+ require 'cucumber/rails'
29
+ """
30
+ # Remove DatabaseCleaner and SQLite
31
+ And I write to "Gemfile" with:
32
+ """
33
+ source 'http://rubygems.org'
34
+ gem 'rails'
35
+ gem "cucumber-rails", :group => :test, :path => "../../.."
36
+ gem "capybara", :group => :test
37
+ gem "rspec-rails", :group => :test
38
+ """
39
+ And I write to "app/controllers/posts_controller.rb" with:
40
+ """
41
+ class PostsController < ApplicationController
42
+ def index
43
+ raise "There is an error in index"
44
+ end
45
+ end
46
+ """
47
+ And I write to "config/routes.rb" with:
48
+ """
49
+ Rails3App::Application.routes.draw do
50
+ resources :posts
51
+ end
52
+ """
53
+ And I write to "features/posts.feature" with:
54
+ """
55
+ Feature: posts
56
+ Scenario: See them
57
+ When I do it
58
+ """
59
+ And I write to "features/step_definitions/posts_steps.rb" with:
60
+ """
61
+ When /^I do it$/ do
62
+ visit '/posts'
63
+ end
64
+ """
65
+ And I run `bundle exec rake cucumber`
66
+ Then it should fail with:
67
+ """
68
+ There is an error in index
69
+ """
@@ -1,4 +1,3 @@
1
- @announce
2
1
  Feature: Rerun profile
3
2
  In order to concentrate on failing features
4
3
  As a Rails developer working with Cucumber
@@ -29,7 +28,7 @@ Feature: Rerun profile
29
28
  puts "I've always been passing"
30
29
  end
31
30
  """
32
- When I successfully run "ruby script/cucumber -p rerun"
31
+ When I successfully run `bundle exec cucumber -p rerun`
33
32
  Then it should pass with:
34
33
  """
35
34
  1 scenario (1 passed)
@@ -0,0 +1,46 @@
1
+ Feature: REST API
2
+
3
+ Scenario: Compare JSON
4
+ Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
5
+ And I write to "app/controllers/posts_controller.rb" with:
6
+ """
7
+ class PostsController < ApplicationController
8
+ def index
9
+ render :json => {'hello' => 'world'}.to_json
10
+ end
11
+ end
12
+ """
13
+ And I write to "config/routes.rb" with:
14
+ """
15
+ Rails3App::Application.routes.draw do
16
+ resources :posts
17
+ end
18
+ """
19
+ And I write to "features/posts.feature" with:
20
+ """
21
+ Feature: posts
22
+ Scenario: See them
23
+ When the client requests GET /posts
24
+ Then the response should be JSON:
25
+ \"\"\"
26
+ {
27
+ "hello": "world"
28
+ }
29
+ \"\"\"
30
+ """
31
+ And I write to "features/step_definitions/rest_steps.rb" with:
32
+ """
33
+ When /^the client requests GET (.*)$/ do |path|
34
+ get(path)
35
+ end
36
+
37
+ Then /^the response should be JSON:$/ do |json|
38
+ JSON.parse(last_response.body).should == JSON.parse(json)
39
+ end
40
+ """
41
+ And I run `bundle exec rake db:migrate cucumber`
42
+ Then it should pass with:
43
+ """
44
+ 1 scenario (1 passed)
45
+ 2 steps (2 passed)
46
+ """