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.
- data/.gitignore +6 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +205 -0
- data/History.md +219 -0
- data/LICENSE +22 -0
- data/README.md +77 -0
- data/Rakefile +9 -0
- data/config/.gitignore +1 -0
- data/config/cucumber.yml +1 -0
- data/cucumber-rails.gemspec +46 -0
- data/dev_tasks/cucumber.rake +5 -0
- data/dev_tasks/rspec.rake +8 -0
- data/dev_tasks/yard.rake +0 -0
- data/dev_tasks/yard/default/layout/html/bubble_32x32.png +0 -0
- data/dev_tasks/yard/default/layout/html/footer.erb +5 -0
- data/dev_tasks/yard/default/layout/html/index.erb +1 -0
- data/dev_tasks/yard/default/layout/html/layout.erb +25 -0
- data/dev_tasks/yard/default/layout/html/logo.erb +1 -0
- data/dev_tasks/yard/default/layout/html/setup.rb +4 -0
- data/features/allow_rescue.feature +63 -0
- data/features/capybara_javascript_drivers.feature +87 -0
- data/features/database_cleaner.feature +44 -0
- data/features/emulate_javascript.feature +34 -0
- data/features/inspect_query_string.feature +37 -0
- data/features/install_cucumber_rails.feature +16 -0
- data/features/mongoid.feature +53 -0
- data/features/multiple_databases.feature +74 -0
- data/features/named_selectors.feature +33 -0
- data/features/no_database.feature +70 -0
- data/features/pseduo_class_selectors.feature +24 -0
- data/features/rerun_profile.feature +38 -0
- data/features/rest_api.feature +47 -0
- data/features/routing.feature +18 -0
- data/features/select_dates.feature +99 -0
- data/features/step_definitions/cucumber_rails_steps.rb +89 -0
- data/features/support/env.rb +37 -0
- data/features/test_unit.feature +43 -0
- data/lib/cucumber/rails.rb +23 -0
- data/lib/cucumber/rails/action_controller.rb +12 -0
- data/lib/cucumber/rails/application.rb +17 -0
- data/lib/cucumber/rails/capybara.rb +6 -0
- data/lib/cucumber/rails/capybara/javascript_emulation.rb +83 -0
- data/lib/cucumber/rails/capybara/select_dates_and_times.rb +50 -0
- data/lib/cucumber/rails/hooks.rb +4 -0
- data/lib/cucumber/rails/hooks/active_record.rb +21 -0
- data/lib/cucumber/rails/hooks/allow_rescue.rb +8 -0
- data/lib/cucumber/rails/hooks/database_cleaner.rb +13 -0
- data/lib/cucumber/rails/hooks/mail.rb +5 -0
- data/lib/cucumber/rails/rspec.rb +21 -0
- data/lib/cucumber/rails/world.rb +26 -0
- data/lib/cucumber/web/tableish.rb +118 -0
- data/lib/generators/cucumber/feature/USAGE +16 -0
- data/lib/generators/cucumber/feature/feature_generator.rb +28 -0
- data/lib/generators/cucumber/feature/named_arg.rb +19 -0
- data/lib/generators/cucumber/feature/templates/feature.erb +63 -0
- data/lib/generators/cucumber/feature/templates/steps.erb +14 -0
- data/lib/generators/cucumber/install/USAGE +15 -0
- data/lib/generators/cucumber/install/install_generator.rb +88 -0
- data/lib/generators/cucumber/install/templates/config/cucumber.yml.erb +8 -0
- data/lib/generators/cucumber/install/templates/script/cucumber +10 -0
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps.rb.erb +192 -0
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_cs.rb.erb +127 -0
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_da.rb.erb +105 -0
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_de.rb.erb +127 -0
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_es.rb.erb +127 -0
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_ja.rb.erb +140 -0
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_ko.rb.erb +142 -0
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_no.rb.erb +105 -0
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_pt-BR.rb.erb +132 -0
- data/lib/generators/cucumber/install/templates/support/_rails_each_run.rb.erb +36 -0
- data/lib/generators/cucumber/install/templates/support/_rails_prefork.rb.erb +1 -0
- data/lib/generators/cucumber/install/templates/support/capybara.rb +5 -0
- data/lib/generators/cucumber/install/templates/support/edit_warning.txt +5 -0
- data/lib/generators/cucumber/install/templates/support/paths.rb +33 -0
- data/lib/generators/cucumber/install/templates/support/rails.rb.erb +4 -0
- data/lib/generators/cucumber/install/templates/support/rails_spork.rb.erb +13 -0
- data/lib/generators/cucumber/install/templates/support/selectors.rb +39 -0
- data/lib/generators/cucumber/install/templates/support/web_steps_warning.txt +19 -0
- data/lib/generators/cucumber/install/templates/tasks/cucumber.rake.erb +60 -0
- data/spec/cucumber/web/tableish_spec.rb +239 -0
- data/spec/spec_helper.rb +3 -0
- metadata +514 -0
@@ -0,0 +1,37 @@
|
|
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 number:integer published:boolean`
|
6
|
+
And I successfully run `rails generate scaffold post title:string body:text number:integer published:boolean`
|
7
|
+
And I successfully run `rails generate scaffold cuke 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`
|
31
|
+
And I run `bundle exec rake cucumber`
|
32
|
+
Then it should pass with:
|
33
|
+
"""
|
34
|
+
3 scenarios (3 passed)
|
35
|
+
16 steps (16 passed)
|
36
|
+
"""
|
37
|
+
|
@@ -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,74 @@
|
|
1
|
+
Feature: Multiple Databases
|
2
|
+
In order to use Database Cleaner with multiple database repositories
|
3
|
+
As an engineer
|
4
|
+
I want to specify explicit strategies for each
|
5
|
+
|
6
|
+
Background: A Rails 3 app utilizing multiple database repositories exists
|
7
|
+
Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
|
8
|
+
And I remove the file "features/step_definitions/web_steps.rb"
|
9
|
+
And I append to "config/database.yml" with:
|
10
|
+
"""
|
11
|
+
|
12
|
+
ursidae:
|
13
|
+
adapter: sqlite3
|
14
|
+
database: db/ursidae.sqlite3
|
15
|
+
"""
|
16
|
+
And I write to "app/models/bear.rb" with:
|
17
|
+
"""
|
18
|
+
class Bear < ActiveRecord::Base
|
19
|
+
establish_connection "ursidae"
|
20
|
+
end
|
21
|
+
"""
|
22
|
+
And a directory named "db/migrate"
|
23
|
+
And I write to "db/migrate/001_create_bears.rb" with:
|
24
|
+
"""
|
25
|
+
class CreateBears < ActiveRecord::Migration
|
26
|
+
def self.up
|
27
|
+
if Rails.env == 'ursidae'
|
28
|
+
create_table :bears do |t|
|
29
|
+
t.string :name, :null => false
|
30
|
+
end
|
31
|
+
add_index :bears, :name, :unique => true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
"""
|
36
|
+
And I successfully run `bundle exec rake db:migrate`
|
37
|
+
And I successfully run `bundle exec rake db:migrate RAILS_ENV=ursidae`
|
38
|
+
And I write to "features/support/env.rb" with:
|
39
|
+
"""
|
40
|
+
require 'cucumber/rails'
|
41
|
+
DatabaseCleaner.strategy = :transaction
|
42
|
+
DatabaseCleaner[:active_record, {:connection => "ursidae"}].strategy = :truncation
|
43
|
+
"""
|
44
|
+
And I write to "features/create_bear.feature" with:
|
45
|
+
"""
|
46
|
+
Feature: Screws up in transactional test and must use truncation
|
47
|
+
Scenario: I create a bear
|
48
|
+
When I create a bear
|
49
|
+
And something transactional happens
|
50
|
+
"""
|
51
|
+
And I write to "features/step_definitions/create_bear_steps.rb" with:
|
52
|
+
"""
|
53
|
+
When /^I create a bear$/ do
|
54
|
+
Bear.create!(:name => "yogi")
|
55
|
+
end
|
56
|
+
When /^something transactional happens$/ do
|
57
|
+
Bear.transaction { Bear.find_by_name("yogi").lock! }
|
58
|
+
end
|
59
|
+
"""
|
60
|
+
|
61
|
+
Scenario: Default transactional strategy is not attempted on second database
|
62
|
+
When I run `bundle exec rake cucumber FEATURE=features/create_bear.feature`
|
63
|
+
Then it should pass with:
|
64
|
+
"""
|
65
|
+
1 scenario (1 passed)
|
66
|
+
2 steps (2 passed)
|
67
|
+
"""
|
68
|
+
And the output should not contain "cannot rollback - no transaction is active"
|
69
|
+
|
70
|
+
Scenario: Truncation strategy is used on the second database
|
71
|
+
Given I successfully run `bundle exec rails runner 'Bear.create(:name => "boo boo")'`
|
72
|
+
And I successfully run `bundle exec rake cucumber FEATURE=features/create_bear.feature`
|
73
|
+
When I run `bundle exec rails runner 'raise "ahh! bears!" if Bear.count > 0'`
|
74
|
+
Then the exit status should be 0
|
@@ -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,70 @@
|
|
1
|
+
@announce
|
2
|
+
Feature: No Database
|
3
|
+
Allow Cucumber to work with a Rails app without a database
|
4
|
+
|
5
|
+
Scenario: No ActiveRecord and DatabaseCleaner
|
6
|
+
Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
|
7
|
+
# Turn off ActiveRecord
|
8
|
+
And I write to "config/application.rb" with:
|
9
|
+
"""
|
10
|
+
require File.expand_path('../boot', __FILE__)
|
11
|
+
|
12
|
+
require 'action_controller/railtie'
|
13
|
+
require 'action_mailer/railtie'
|
14
|
+
require 'active_resource/railtie'
|
15
|
+
require 'rails/test_unit/railtie'
|
16
|
+
|
17
|
+
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
18
|
+
|
19
|
+
module Rails3App
|
20
|
+
class Application < Rails::Application
|
21
|
+
config.encoding = "utf-8"
|
22
|
+
config.filter_parameters += [:password]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
"""
|
26
|
+
And I remove the file "config/database.yml"
|
27
|
+
And I overwrite "features/support/env.rb" with:
|
28
|
+
"""
|
29
|
+
require 'cucumber/rails'
|
30
|
+
"""
|
31
|
+
# Remove DatabaseCleaner and SQLite
|
32
|
+
And I write to "Gemfile" with:
|
33
|
+
"""
|
34
|
+
source 'http://rubygems.org'
|
35
|
+
gem 'rails'
|
36
|
+
gem "cucumber-rails", :group => :test, :path => "../../.."
|
37
|
+
gem "capybara", :group => :test
|
38
|
+
gem "rspec-rails", :group => :test
|
39
|
+
"""
|
40
|
+
And I write to "app/controllers/posts_controller.rb" with:
|
41
|
+
"""
|
42
|
+
class PostsController < ApplicationController
|
43
|
+
def index
|
44
|
+
raise "There is an error in index"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
"""
|
48
|
+
And I write to "config/routes.rb" with:
|
49
|
+
"""
|
50
|
+
Rails3App::Application.routes.draw do
|
51
|
+
resources :posts
|
52
|
+
end
|
53
|
+
"""
|
54
|
+
And I write to "features/posts.feature" with:
|
55
|
+
"""
|
56
|
+
Feature: posts
|
57
|
+
Scenario: See them
|
58
|
+
When I do it
|
59
|
+
"""
|
60
|
+
And I write to "features/step_definitions/posts_steps.rb" with:
|
61
|
+
"""
|
62
|
+
When /^I do it$/ do
|
63
|
+
visit '/posts'
|
64
|
+
end
|
65
|
+
"""
|
66
|
+
And I run `bundle exec rake cucumber`
|
67
|
+
Then it should fail with:
|
68
|
+
"""
|
69
|
+
There is an error in index
|
70
|
+
"""
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Feature: Pseudo-class Selectors
|
2
|
+
|
3
|
+
Scenario: Look within css pseudo-class selectors
|
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>foo</div>
|
9
|
+
<div>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 "bar" within "div:nth-child(2)"
|
17
|
+
And I should not see "foo" within "div:nth-child(2)"
|
18
|
+
"""
|
19
|
+
And I run `rake cucumber`
|
20
|
+
Then it should pass with:
|
21
|
+
"""
|
22
|
+
1 scenario (1 passed)
|
23
|
+
3 steps (3 passed)
|
24
|
+
"""
|
@@ -0,0 +1,38 @@
|
|
1
|
+
Feature: Rerun profile
|
2
|
+
In order to concentrate on failing features
|
3
|
+
As a Rails developer working with Cucumber
|
4
|
+
I want to rerun only failing features
|
5
|
+
|
6
|
+
Scenario: Rerun
|
7
|
+
Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
|
8
|
+
And a file named "rerun.txt" with:
|
9
|
+
"""
|
10
|
+
features/rerun_test.feature:2
|
11
|
+
"""
|
12
|
+
And a file named "features/rerun_test.feature" with:
|
13
|
+
"""
|
14
|
+
Feature: Rerun test
|
15
|
+
Scenario: failing before
|
16
|
+
Given fixed now
|
17
|
+
|
18
|
+
Scenario: always passing
|
19
|
+
Given passing
|
20
|
+
"""
|
21
|
+
And a file named "features/step_definitions/rerun_steps.rb" with:
|
22
|
+
"""
|
23
|
+
Given /fixed now/ do
|
24
|
+
puts "All fixed now"
|
25
|
+
end
|
26
|
+
|
27
|
+
Given /passing/ do
|
28
|
+
puts "I've always been passing"
|
29
|
+
end
|
30
|
+
"""
|
31
|
+
When I successfully run `bundle exec cucumber -p rerun`
|
32
|
+
Then it should pass with:
|
33
|
+
"""
|
34
|
+
1 scenario (1 passed)
|
35
|
+
1 step (1 passed)
|
36
|
+
"""
|
37
|
+
And the file "rerun.txt" should not contain "features/rerun_test.feature:2"
|
38
|
+
|
@@ -0,0 +1,47 @@
|
|
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`
|
42
|
+
And I run `bundle exec rake cucumber`
|
43
|
+
Then it should pass with:
|
44
|
+
"""
|
45
|
+
1 scenario (1 passed)
|
46
|
+
2 steps (2 passed)
|
47
|
+
"""
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Feature: Routing
|
2
|
+
|
3
|
+
Scenario: Visit undefined route
|
4
|
+
Given a project without ActiveRecord
|
5
|
+
And I remove the file "public/index.html"
|
6
|
+
And I write to "features/tests.feature" with:
|
7
|
+
"""
|
8
|
+
Feature: Tests
|
9
|
+
Scenario: Tests
|
10
|
+
When I go to the home page
|
11
|
+
"""
|
12
|
+
And I run `rake cucumber`
|
13
|
+
Then it should fail with:
|
14
|
+
"""
|
15
|
+
1 scenario (1 failed)
|
16
|
+
1 step (1 failed)
|
17
|
+
"""
|
18
|
+
And the stdout should contain "ActionController::RoutingError"
|
@@ -0,0 +1,99 @@
|
|
1
|
+
Feature: Select dates
|
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
|
+
|
6
|
+
Scenario: Select date and time
|
7
|
+
Given I successfully run `bundle exec rails g scaffold appointment name:string when:datetime`
|
8
|
+
And I write to "features/create_appointment.feature" with:
|
9
|
+
"""
|
10
|
+
Feature: Create appointments
|
11
|
+
Scenario: Constitution on May 17
|
12
|
+
Given I am on the new appointment page
|
13
|
+
And I fill in "Norway's constitution" for "Name"
|
14
|
+
And I select "2009-02-20 15:10:00 UTC" as the "When" date and time
|
15
|
+
And I press "Create Appointment"
|
16
|
+
Then I should see "Norway's constitution"
|
17
|
+
And I should see "2009-02-20 15:10:00 UTC"
|
18
|
+
"""
|
19
|
+
When I run `bundle exec rake db:migrate`
|
20
|
+
And I run `bundle exec rake cucumber`
|
21
|
+
Then it should pass with:
|
22
|
+
"""
|
23
|
+
1 scenario (1 passed)
|
24
|
+
6 steps (6 passed)
|
25
|
+
"""
|
26
|
+
|
27
|
+
Scenario: Select date with label pointing to first select
|
28
|
+
Given I successfully run `bundle exec rails g scaffold appointment name:string when:date`
|
29
|
+
And I write to "features/create_appointment.feature" with:
|
30
|
+
"""
|
31
|
+
Feature: Create appointments
|
32
|
+
Scenario: Constitution on May 17
|
33
|
+
Given I am on the new appointment page
|
34
|
+
And I fill in "Norway's constitution" for "Name"
|
35
|
+
And I select "2009-02-20" as the "When" date
|
36
|
+
And I press "Create Appointment"
|
37
|
+
Then I should see "Norway's constitution"
|
38
|
+
And I should see "2009-02-20"
|
39
|
+
"""
|
40
|
+
And I write to "app/views/appointments/_form.html.erb" with:
|
41
|
+
"""
|
42
|
+
<%= form_for(@appointment) do |f| %>
|
43
|
+
<div class="field">
|
44
|
+
<%= f.label :name %><br />
|
45
|
+
<%= f.text_field :name %>
|
46
|
+
</div>
|
47
|
+
<div class="field">
|
48
|
+
<%= f.label :when, :for => "appointment_when_1i" %><br />
|
49
|
+
<%= f.date_select :when %>
|
50
|
+
</div>
|
51
|
+
<div class="actions">
|
52
|
+
<%= f.submit %>
|
53
|
+
</div>
|
54
|
+
<% end %>
|
55
|
+
"""
|
56
|
+
When I run `bundle exec rake db:migrate`
|
57
|
+
And I run `bundle exec rake cucumber`
|
58
|
+
Then it should pass with:
|
59
|
+
"""
|
60
|
+
1 scenario (1 passed)
|
61
|
+
6 steps (6 passed)
|
62
|
+
"""
|
63
|
+
|
64
|
+
Scenario: Select date when the order of fields is changed and label is set to the first select
|
65
|
+
Given I successfully run `bundle exec rails g scaffold appointment name:string when:date`
|
66
|
+
And I write to "features/create_appointment.feature" with:
|
67
|
+
"""
|
68
|
+
Feature: Create appointments
|
69
|
+
Scenario: Constitution on May 17
|
70
|
+
Given I am on the new appointment page
|
71
|
+
And I fill in "Norway's constitution" for "Name"
|
72
|
+
And I select "2009-02-20" as the "When" date
|
73
|
+
And I press "Create Appointment"
|
74
|
+
Then I should see "Norway's constitution"
|
75
|
+
And I should see "2009-02-20"
|
76
|
+
"""
|
77
|
+
And I write to "app/views/appointments/_form.html.erb" with:
|
78
|
+
"""
|
79
|
+
<%= form_for(@appointment) do |f| %>
|
80
|
+
<div class="field">
|
81
|
+
<%= f.label :name %><br />
|
82
|
+
<%= f.text_field :name %>
|
83
|
+
</div>
|
84
|
+
<div class="field">
|
85
|
+
<%= f.label :when, :for => "appointment_when_2i" %><br />
|
86
|
+
<%= f.date_select :when, :order=>[:month, :day, :year] %>
|
87
|
+
</div>
|
88
|
+
<div class="actions">
|
89
|
+
<%= f.submit %>
|
90
|
+
</div>
|
91
|
+
<% end %>
|
92
|
+
"""
|
93
|
+
When I run `bundle exec rake db:migrate`
|
94
|
+
And I run `bundle exec rake cucumber`
|
95
|
+
Then it should pass with:
|
96
|
+
"""
|
97
|
+
1 scenario (1 passed)
|
98
|
+
6 steps (6 passed)
|
99
|
+
"""
|