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.
- data/.rvmrc +1 -1
- data/HACKING.rdoc +6 -8
- data/History.txt +18 -2
- data/README.rdoc +8 -10
- data/cucumber-rails.gemspec +10 -6
- data/dev_tasks/cucumber.rake +1 -1
- data/features/allow_rescue.feature +61 -0
- data/features/inspect_query_string.feature +36 -0
- data/features/install_cucumber_rails.feature +16 -0
- data/features/mongoid.feature +53 -0
- data/features/named_selectors.feature +33 -0
- data/features/no_database.feature +69 -0
- data/features/rerun_profile.feature +1 -2
- data/features/rest_api.feature +46 -0
- data/features/routing.feature +21 -0
- data/features/select_dates.feature +25 -0
- data/features/step_definitions/cucumber_rails_steps.rb +65 -4
- data/features/support/env.rb +5 -1
- data/generators/cucumber/cucumber_generator.rb +1 -27
- data/lib/cucumber/rails.rb +3 -20
- data/lib/cucumber/rails/capybara.rb +7 -0
- data/lib/cucumber/rails/capybara/select_dates_and_times.rb +21 -14
- data/lib/cucumber/rails/hooks.rb +3 -0
- data/lib/cucumber/rails/hooks/database_cleaner.rb +16 -3
- data/lib/cucumber/rails/rspec.rb +2 -0
- data/lib/cucumber/rails/version.rb +14 -9
- data/lib/cucumber/rails/world.rb +6 -0
- data/lib/cucumber/rails2.rb +1 -1
- data/lib/cucumber/rails3.rb +7 -7
- data/lib/generators/cucumber/install/install_base.rb +11 -51
- data/templates/install/config/cucumber.yml.erb +1 -1
- data/templates/install/step_definitions/capybara_steps.rb.erb +63 -85
- data/templates/install/step_definitions/web_steps_cs.rb.erb +11 -20
- data/templates/install/step_definitions/web_steps_da.rb.erb +11 -20
- data/templates/install/step_definitions/web_steps_es.rb.erb +11 -20
- data/templates/install/step_definitions/web_steps_ja.rb.erb +1 -0
- data/templates/install/step_definitions/web_steps_ko.rb.erb +1 -0
- data/templates/install/step_definitions/web_steps_no.rb.erb +11 -20
- data/templates/install/step_definitions/web_steps_pt-BR.rb.erb +11 -20
- data/templates/install/step_definitions/webrat_steps.rb.erb +11 -10
- data/templates/install/support/_rails_each_run.rb.erb +3 -19
- data/templates/install/support/edit_warning.txt +19 -5
- data/templates/install/support/selectors.rb +39 -0
- data/templates/install/tasks/cucumber.rake.erb +4 -0
- metadata +100 -82
- data/features/rails2.feature +0 -45
- data/features/rails3.feature +0 -123
- data/features/support/matchers/files.rb +0 -17
- data/spec/generators/cucumber/install/install_base_spec.rb +0 -75
data/features/rails2.feature
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
@announce
|
2
|
-
Feature: Rails 2
|
3
|
-
In order to take over the world
|
4
|
-
Cucumber-Rails should work on major versions
|
5
|
-
of Rails2 and Ruby, with Capybara, Webrat, Spork and DatabaseCleaner
|
6
|
-
|
7
|
-
Scenario: Run Cucumber
|
8
|
-
Given a Rails "2.3.5" project named "rails-2-app" with Cucumber-Rails generated with "--capybara --rspec"
|
9
|
-
|
10
|
-
Given break
|
11
|
-
And I symlink "../../../../cucumber" to "vendor/plugins/cucumber"
|
12
|
-
And I symlink "../../.." to "vendor/plugins/cucumber-rails"
|
13
|
-
And I successfully run "ruby script/generate cucumber --capybara"
|
14
|
-
And I successfully run "ruby script/generate feature post title:string body:text published:boolean <feature_args>"
|
15
|
-
And I successfully run "ruby script/generate scaffold post title:string body:text published:boolean"
|
16
|
-
And I successfully run "ruby script/generate scaffold cukes name:string"
|
17
|
-
And I write to "app/controllers/cukes_controller.rb" with:
|
18
|
-
"""
|
19
|
-
class CukesController < ApplicationController
|
20
|
-
def index
|
21
|
-
redirect_to cuke_path(10, :params => {:name => 'cucumber', :what => 'vegetable'})
|
22
|
-
end
|
23
|
-
|
24
|
-
def show
|
25
|
-
render :text => "Cuke #{params[:id]}"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
"""
|
29
|
-
And I write to "features/tests.feature" with:
|
30
|
-
"""
|
31
|
-
Feature: Tests
|
32
|
-
Scenario: Tests
|
33
|
-
When I go to the cukes page
|
34
|
-
Then I should have the following query string:
|
35
|
-
|name|cucumber|
|
36
|
-
|what|vegetable|
|
37
|
-
And I should see "Cuke 10"
|
38
|
-
"""
|
39
|
-
And I successfully run "rake db:migrate"
|
40
|
-
When I successfully run "rake cucumber"
|
41
|
-
Then it should pass with:
|
42
|
-
"""
|
43
|
-
3 scenarios (3 passed)
|
44
|
-
14 steps (14 passed)
|
45
|
-
"""
|
data/features/rails3.feature
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
@announce
|
2
|
-
Feature: Rails 3
|
3
|
-
In order to take over the world
|
4
|
-
Cucumber-Rails should work on major versions
|
5
|
-
of Rails 3 and Ruby, with Capybara, Spork and DatabaseCleaner
|
6
|
-
|
7
|
-
Scenario: Install Cucumber-Rails
|
8
|
-
Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
|
9
|
-
Then the following files should exist:
|
10
|
-
| config/cucumber.yml |
|
11
|
-
| script/cucumber |
|
12
|
-
| features/step_definitions/web_steps.rb |
|
13
|
-
| features/support/env.rb |
|
14
|
-
| features/support/paths.rb |
|
15
|
-
| lib/tasks/cucumber.rake |
|
16
|
-
And the file "features/support/env.rb" should contain "require 'cucumber/rails'"
|
17
|
-
|
18
|
-
Scenario: Inspect query string
|
19
|
-
Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
|
20
|
-
And I successfully run "rails generate cucumber:feature post title:string body:text published:boolean"
|
21
|
-
And I successfully run "rails generate scaffold post title:string body:text published:boolean"
|
22
|
-
And I successfully run "rails generate scaffold cukes name:string"
|
23
|
-
And I overwrite "app/controllers/cukes_controller.rb" with:
|
24
|
-
"""
|
25
|
-
class CukesController < ApplicationController
|
26
|
-
def index
|
27
|
-
redirect_to cuke_path(10, {:name => 'cucumber', :what => 'vegetable'})
|
28
|
-
end
|
29
|
-
|
30
|
-
def show
|
31
|
-
render :text => "Cuke #{params[:id]}"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
"""
|
35
|
-
And I write to "features/tests.feature" with:
|
36
|
-
"""
|
37
|
-
Feature: Tests
|
38
|
-
Scenario: Tests
|
39
|
-
When I go to the cukes page
|
40
|
-
Then I should have the following query string:
|
41
|
-
| name | cucumber |
|
42
|
-
| what | vegetable |
|
43
|
-
And I should see "Cuke 10"
|
44
|
-
"""
|
45
|
-
And I successfully run "rake db:migrate"
|
46
|
-
And I successfully run "rake cucumber"
|
47
|
-
Then it should pass with:
|
48
|
-
"""
|
49
|
-
3 scenarios (3 passed)
|
50
|
-
14 steps (14 passed)
|
51
|
-
"""
|
52
|
-
|
53
|
-
Scenario: Allow rescue
|
54
|
-
Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
|
55
|
-
And I write to "app/controllers/posts_controller.rb" with:
|
56
|
-
"""
|
57
|
-
class PostsController < ApplicationController
|
58
|
-
def index
|
59
|
-
raise "There is an error in index"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
"""
|
63
|
-
And I write to "config/routes.rb" with:
|
64
|
-
"""
|
65
|
-
Rails3App::Application.routes.draw do
|
66
|
-
resources :posts
|
67
|
-
end
|
68
|
-
"""
|
69
|
-
And I write to "features/posts.feature" with:
|
70
|
-
"""
|
71
|
-
Feature: posts
|
72
|
-
@allow-rescue
|
73
|
-
Scenario: See them
|
74
|
-
When I do it
|
75
|
-
"""
|
76
|
-
And I write to "features/step_definitions/posts_steps.rb" with:
|
77
|
-
"""
|
78
|
-
When /^I do it$/ do
|
79
|
-
visit '/posts'
|
80
|
-
puts page.body
|
81
|
-
end
|
82
|
-
"""
|
83
|
-
And I run "rake cucumber"
|
84
|
-
Then it should pass with:
|
85
|
-
"""
|
86
|
-
1 scenario (1 passed)
|
87
|
-
1 step (1 passed)
|
88
|
-
"""
|
89
|
-
|
90
|
-
Scenario: Don't allow rescue
|
91
|
-
Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
|
92
|
-
And I write to "app/controllers/posts_controller.rb" with:
|
93
|
-
"""
|
94
|
-
class PostsController < ApplicationController
|
95
|
-
def index
|
96
|
-
raise "There is an error in index"
|
97
|
-
end
|
98
|
-
end
|
99
|
-
"""
|
100
|
-
And I write to "config/routes.rb" with:
|
101
|
-
"""
|
102
|
-
Rails3App::Application.routes.draw do
|
103
|
-
resources :posts
|
104
|
-
end
|
105
|
-
"""
|
106
|
-
And I write to "features/posts.feature" with:
|
107
|
-
"""
|
108
|
-
Feature: posts
|
109
|
-
Scenario: See them
|
110
|
-
When I do it
|
111
|
-
"""
|
112
|
-
And I write to "features/step_definitions/posts_steps.rb" with:
|
113
|
-
"""
|
114
|
-
When /^I do it$/ do
|
115
|
-
visit '/posts'
|
116
|
-
end
|
117
|
-
"""
|
118
|
-
And I run "rake cucumber"
|
119
|
-
Then it should fail with:
|
120
|
-
"""
|
121
|
-
1 scenario (1 failed)
|
122
|
-
1 step (1 failed)
|
123
|
-
"""
|
@@ -1,17 +0,0 @@
|
|
1
|
-
RSpec::Matchers.define :have_files do |expected_files|
|
2
|
-
match do |rails_app|
|
3
|
-
actual_files = rails_app.files
|
4
|
-
@missing_files = expected_files - actual_files
|
5
|
-
@missing_files.empty?
|
6
|
-
end
|
7
|
-
|
8
|
-
failure_message_for_should do |expected_files|
|
9
|
-
"Rails app was missing these files:\n" + @missing_files.map { |file| " #{file}" }.join("\n")
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
RSpec::Matchers.define :have_contents do |contents|
|
14
|
-
match do |file|
|
15
|
-
file.read.include?(contents)
|
16
|
-
end
|
17
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'generators/cucumber/install/install_base'
|
2
|
-
|
3
|
-
module Cucumber
|
4
|
-
module Generators
|
5
|
-
describe InstallBase do
|
6
|
-
def instance_of_class_including(mixin)
|
7
|
-
Class.new do
|
8
|
-
include mixin
|
9
|
-
end.new
|
10
|
-
end
|
11
|
-
|
12
|
-
before(:each) do
|
13
|
-
Kernel.stub(:require => nil)
|
14
|
-
|
15
|
-
@generator = instance_of_class_including(Cucumber::Generators::InstallBase)
|
16
|
-
end
|
17
|
-
|
18
|
-
# This is a private method, but there was a bug in it where it
|
19
|
-
# defaulted to :testunit (the framework) when called to identify
|
20
|
-
# the driver
|
21
|
-
describe "#first_loadable" do
|
22
|
-
it "detects loadable libraries" do
|
23
|
-
Gem.should_receive(:available?).with('capybara').and_return(true)
|
24
|
-
@generator.send(:first_loadable, [['capybara', :capybara], ['webrat', :webrat ]]).should == :capybara
|
25
|
-
end
|
26
|
-
|
27
|
-
it "tries the given libraries in order" do
|
28
|
-
Gem.stub(:available?).with('capybara').and_return(false)
|
29
|
-
Gem.should_receive(:available?).with('webrat').and_return(true)
|
30
|
-
@generator.send(:first_loadable, [['capybara', :capybara], ['webrat', :webrat ]]).should == :webrat
|
31
|
-
end
|
32
|
-
|
33
|
-
it "returns nil if no libraries are available" do
|
34
|
-
Gem.stub(:available? => false)
|
35
|
-
@generator.send(:first_loadable, [['capybara', :capybara], ['webrat', :webrat ]]).should be_nil
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# This is a private method, but there may have been a bug in it where
|
40
|
-
# it defaulted to :testunit (the framework) when called to identify
|
41
|
-
# the driver
|
42
|
-
describe "#detect_in_env" do
|
43
|
-
describe "when env.rb doesn't exist" do
|
44
|
-
it "returns nil" do
|
45
|
-
File.should_receive(:file?).with("features/support/env.rb").and_return(false)
|
46
|
-
@generator.send(:detect_in_env, [['capybara', :capybara], ['webrat', :webrat]]).should be_nil
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "when env.rb exists" do
|
51
|
-
before(:each) do
|
52
|
-
File.stub(:file => true)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "detects loadable libraries, choosing the first in the argument list" do
|
56
|
-
IO.should_receive(:read).with("features/support/env.rb").and_return("blah webrat capybara blah")
|
57
|
-
@generator.send(:detect_in_env, [['capybara', :capybara], ['webrat', :webrat]]).should == :capybara
|
58
|
-
end
|
59
|
-
|
60
|
-
it "tries the given libraries in order" do
|
61
|
-
IO.should_receive(:read).with("features/support/env.rb").and_return("blah webrat blah")
|
62
|
-
@generator.send(:detect_in_env, [['capybara', :capybara], ['webrat', :webrat]]).should == :webrat
|
63
|
-
end
|
64
|
-
|
65
|
-
it "returns nil if no libraries are available" do
|
66
|
-
IO.should_receive(:read).with("features/support/env.rb").and_return("blah blah")
|
67
|
-
@generator.send(:detect_in_env, [['capybara', :capybara], ['webrat', :webrat]]).should be_nil
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|