rspec-rails 2.5.0 → 2.6.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.
- data/.gitignore +10 -5
- data/.rspec +1 -0
- data/.travis.yml +10 -0
- data/README.md +2 -0
- data/README_DEV.md +43 -0
- data/Rakefile +72 -31
- data/Thorfile +33 -18
- data/features/.nav +2 -0
- data/features/Autotest.md +7 -0
- data/features/Changelog.md +26 -2
- data/features/Generators.md +1 -1
- data/features/GettingStarted.md +45 -1
- data/features/Upgrade.md +13 -12
- data/features/controller_specs/README.md +18 -10
- data/features/controller_specs/anonymous_controller.feature +5 -5
- data/features/controller_specs/controller_spec.feature +1 -2
- data/features/controller_specs/isolation_from_views.feature +49 -3
- data/features/controller_specs/render_views.feature +3 -3
- data/features/helper_specs/helper_spec.feature +3 -3
- data/features/mailer_specs/url_helpers.feature +2 -2
- data/features/matchers/new_record_matcher.feature +1 -43
- data/features/matchers/redirect_to_matcher.feature +3 -3
- data/features/matchers/render_template_matcher.feature +12 -9
- data/features/mocks/mock_model.feature +21 -5
- data/features/mocks/stub_model.feature +2 -2
- data/features/model_specs/errors_on.feature +1 -1
- data/features/model_specs/transactional_examples.feature +10 -5
- data/features/request_specs/request_spec.feature +49 -0
- data/features/routing_specs/README.md +2 -1
- data/features/routing_specs/be_routable_matcher.feature +5 -5
- data/features/routing_specs/named_routes.feature +1 -1
- data/features/routing_specs/route_to_matcher.feature +28 -8
- data/features/step_definitions/additional_cli_steps.rb +1 -1
- data/features/support/env.rb +7 -19
- data/features/view_specs/inferred_controller_path.feature +3 -3
- data/features/view_specs/stub_template.feature +2 -2
- data/features/view_specs/view_spec.feature +16 -35
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/base.rb +58 -0
- data/gemfiles/rails-3-0-stable +6 -0
- data/gemfiles/rails-3.0.0 +5 -0
- data/gemfiles/rails-3.0.1 +5 -0
- data/gemfiles/rails-3.0.2 +5 -0
- data/gemfiles/rails-3.0.3 +5 -0
- data/gemfiles/rails-3.0.4 +5 -0
- data/gemfiles/rails-3.0.5 +5 -0
- data/gemfiles/rails-3.0.6 +5 -0
- data/gemfiles/rails-3.0.7 +5 -0
- data/gemfiles/rails-3.1.0.beta1 +5 -0
- data/gemfiles/rails-master +7 -0
- data/lib/generators/rspec/scaffold/scaffold_generator.rb +20 -2
- data/lib/generators/rspec/scaffold/templates/controller_spec.rb +86 -54
- data/lib/generators/rspec/scaffold/templates/edit_spec.rb +7 -7
- data/lib/generators/rspec/scaffold/templates/index_spec.rb +2 -2
- data/lib/generators/rspec/scaffold/templates/new_spec.rb +5 -5
- data/lib/generators/rspec/scaffold/templates/routing_spec.rb +14 -14
- data/lib/generators/rspec/scaffold/templates/show_spec.rb +2 -2
- data/lib/rspec/rails/example/controller_example_group.rb +12 -22
- data/lib/rspec/rails/example/helper_example_group.rb +0 -5
- data/lib/rspec/rails/example/mailer_example_group.rb +0 -9
- data/lib/rspec/rails/example/request_example_group.rb +0 -25
- data/lib/rspec/rails/example/routing_example_group.rb +1 -0
- data/lib/rspec/rails/example/view_example_group.rb +7 -6
- data/lib/rspec/rails/matchers/routing_matchers.rb +23 -2
- data/lib/rspec/rails/mocks.rb +3 -0
- data/lib/rspec/rails/tasks/rspec.rake +1 -1
- data/lib/rspec/rails/vendor/capybara.rb +29 -0
- data/lib/rspec/rails/vendor/webrat.rb +33 -0
- data/lib/rspec/rails/version.rb +1 -1
- data/lib/rspec/rails/view_rendering.rb +24 -8
- data/lib/rspec/rails.rb +2 -2
- data/rspec-rails.gemspec +5 -36
- data/spec/autotest/rails_rspec2_spec.rb +2 -7
- data/spec/rspec/rails/example/controller_example_group_spec.rb +25 -0
- data/spec/rspec/rails/matchers/route_to_spec.rb +15 -0
- data/spec/rspec/rails/mocks/ar_classes.rb +5 -2
- data/spec/rspec/rails/view_rendering_spec.rb +0 -6
- data/spec/spec_helper.rb +0 -22
- data/spec/support/matchers.rb +9 -0
- data/templates/generate_stuff.rb +9 -1
- data/templates/run_specs.rb +2 -2
- metadata +44 -65
- data/Gemfile-3-0-stable +0 -6
- data/Gemfile-3.0.0 +0 -3
- data/Gemfile-3.0.3 +0 -3
- data/Gemfile-base +0 -38
- data/Gemfile-master +0 -5
- data/lib/rspec/rails/browser_simulators.rb +0 -30
- data/specs.watchr +0 -59
- data/templates/Gemfile-base +0 -17
|
@@ -25,7 +25,7 @@ Feature: helper spec
|
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
"""
|
|
28
|
-
When I run
|
|
28
|
+
When I run `rspec spec/helpers/application_helper_spec.rb`
|
|
29
29
|
Then the examples should all pass
|
|
30
30
|
|
|
31
31
|
Scenario: helper method that accesses an instance variable
|
|
@@ -50,7 +50,7 @@ Feature: helper spec
|
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
"""
|
|
53
|
-
When I run
|
|
53
|
+
When I run `rspec spec/helpers/application_helper_spec.rb`
|
|
54
54
|
Then the examples should all pass
|
|
55
55
|
|
|
56
56
|
Scenario: application helper is included in helper object
|
|
@@ -83,5 +83,5 @@ Feature: helper spec
|
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
85
|
"""
|
|
86
|
-
When I run
|
|
86
|
+
When I run `rspec spec/helpers/widgets_helper_spec.rb`
|
|
87
87
|
Then the examples should all pass
|
|
@@ -15,7 +15,7 @@ Feature: URL helpers in mailer examples
|
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
"""
|
|
18
|
-
When I run
|
|
18
|
+
When I run `rspec spec`
|
|
19
19
|
Then the examples should all pass
|
|
20
20
|
|
|
21
21
|
Scenario: using URL helpers without default options
|
|
@@ -34,5 +34,5 @@ Feature: URL helpers in mailer examples
|
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
"""
|
|
37
|
-
When I run
|
|
37
|
+
When I run `rspec spec`
|
|
38
38
|
Then the examples should all pass
|
|
@@ -24,47 +24,5 @@ Feature: be_a_new matcher
|
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
"""
|
|
27
|
-
When I run
|
|
28
|
-
Then the examples should all pass
|
|
29
|
-
|
|
30
|
-
Scenario: example spec using be_a_new.with
|
|
31
|
-
Given a file named "spec/models/widget_spec.rb" with:
|
|
32
|
-
"""
|
|
33
|
-
require "spec_helper"
|
|
34
|
-
|
|
35
|
-
class Widget < ActiveRecord::Base
|
|
36
|
-
establish_connection :adapter => 'sqlite3',
|
|
37
|
-
:database => ':memory:'
|
|
38
|
-
|
|
39
|
-
connection.execute <<-eosql
|
|
40
|
-
CREATE TABLE widgets (
|
|
41
|
-
foo_id integer,
|
|
42
|
-
number integer
|
|
43
|
-
)
|
|
44
|
-
eosql
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
describe Widget do
|
|
48
|
-
context "when initialized with attributes" do
|
|
49
|
-
subject { Widget.new(:foo_id => 1, :number => 1) }
|
|
50
|
-
|
|
51
|
-
it "has all of the attributes" do
|
|
52
|
-
should be_a_new(Widget).with(:foo_id => 1, :number => 1)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it "has one of the attributes" do
|
|
56
|
-
should be_a_new(Widget).with(:foo_id => 1)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it "has none of the attributes" do
|
|
60
|
-
should_not be_a_new(Widget).with(:blah => 'blah')
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it "has one of the attribute values not the same" do
|
|
64
|
-
should_not be_a_new(Widget).with(:foo_id => 2)
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
"""
|
|
69
|
-
When I run "rspec spec/models/widget_spec.rb"
|
|
27
|
+
When I run `rspec spec/models/widget_spec.rb`
|
|
70
28
|
Then the examples should all pass
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Feature: redirect_to matcher
|
|
2
2
|
|
|
3
|
-
The `redirect_to` matcher is used to specify that
|
|
4
|
-
|
|
3
|
+
The `redirect_to` matcher is used to specify that a request redirects to a
|
|
4
|
+
given template or action. It delegates to
|
|
5
5
|
[`assert_redirected_to`](http://api.rubyonrails.org/classes/ActionDispatch/Assertions/ResponseAssertions.html#method-i-assert_redirected_to).
|
|
6
6
|
|
|
7
7
|
It is available in controller specs (spec/controllers) and request
|
|
@@ -36,5 +36,5 @@ Feature: redirect_to matcher
|
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
"""
|
|
39
|
-
When I run
|
|
39
|
+
When I run `rspec spec/controllers/widgets_controller_spec.rb`
|
|
40
40
|
Then the examples should all pass
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
Feature: render_template matcher
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
The `render_template` matcher is used to specify that a request renders a
|
|
4
|
+
given template. It delegates to
|
|
5
|
+
[`assert_template`](http://api.rubyonrails.org/classes/ActionController/TemplateAssertions.html#method-i-assert_template)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
It is available in controller specs (spec/controllers) and request
|
|
8
|
+
specs (spec/requests).
|
|
9
|
+
|
|
10
|
+
NOTE: use `redirect_to(:action => 'new')` for redirects, not `render_template`.
|
|
8
11
|
|
|
9
12
|
Scenario: render_template with three possible options
|
|
10
13
|
Given a file named "spec/controllers/gadgets_spec.rb" with:
|
|
@@ -12,14 +15,14 @@ Feature: render_template matcher
|
|
|
12
15
|
require "spec_helper"
|
|
13
16
|
|
|
14
17
|
describe GadgetsController do
|
|
15
|
-
describe "#index" do
|
|
18
|
+
describe "GET #index" do
|
|
16
19
|
subject { get :index }
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
it { should render_template(:index) }
|
|
22
|
+
it { should render_template("index") }
|
|
23
|
+
it { should render_template("gadgets/index") }
|
|
21
24
|
end
|
|
22
25
|
end
|
|
23
26
|
"""
|
|
24
|
-
When I run
|
|
27
|
+
When I run `rspec spec/controllers/gadgets_spec.rb`
|
|
25
28
|
Then the examples should all pass
|
|
@@ -36,7 +36,7 @@ Feature: mock_model
|
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
"""
|
|
39
|
-
When I run
|
|
39
|
+
When I run `rspec spec/models/car_spec.rb`
|
|
40
40
|
Then the examples should all pass
|
|
41
41
|
|
|
42
42
|
Scenario: passing a string that represents an existing constant
|
|
@@ -51,7 +51,7 @@ Feature: mock_model
|
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
"""
|
|
54
|
-
When I run
|
|
54
|
+
When I run `rspec spec/models/widget_spec.rb`
|
|
55
55
|
Then the examples should all pass
|
|
56
56
|
|
|
57
57
|
Scenario: passing a class that does not extend ActiveModel::Naming
|
|
@@ -65,7 +65,7 @@ Feature: mock_model
|
|
|
65
65
|
end
|
|
66
66
|
end
|
|
67
67
|
"""
|
|
68
|
-
When I run
|
|
68
|
+
When I run `rspec spec/models/string_spec.rb`
|
|
69
69
|
Then the examples should all pass
|
|
70
70
|
|
|
71
71
|
Scenario: passing an Active Record constant
|
|
@@ -94,7 +94,7 @@ Feature: mock_model
|
|
|
94
94
|
end
|
|
95
95
|
end
|
|
96
96
|
"""
|
|
97
|
-
When I run
|
|
97
|
+
When I run `rspec spec/models/widget_spec.rb`
|
|
98
98
|
Then the examples should all pass
|
|
99
99
|
|
|
100
100
|
Scenario: passing an Active Record constant with method stubs
|
|
@@ -127,5 +127,21 @@ Feature: mock_model
|
|
|
127
127
|
end
|
|
128
128
|
end
|
|
129
129
|
"""
|
|
130
|
-
When I run
|
|
130
|
+
When I run `rspec spec/models/widget_spec.rb`
|
|
131
|
+
Then the examples should all pass
|
|
132
|
+
|
|
133
|
+
Scenario: mock_model outside rails
|
|
134
|
+
Given a file named "mock_model_outside_rails_spec.rb" with:
|
|
135
|
+
"""
|
|
136
|
+
require 'rspec/rails/mocks'
|
|
137
|
+
|
|
138
|
+
describe "Foo" do
|
|
139
|
+
it "is mockable" do
|
|
140
|
+
foo = mock_model("Foo")
|
|
141
|
+
foo.id.should eq(1001)
|
|
142
|
+
foo.to_param.should eq("1001")
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
"""
|
|
146
|
+
When I run `rspec mock_model_outside_rails_spec.rb`
|
|
131
147
|
Then the examples should all pass
|
|
@@ -34,7 +34,7 @@ Feature: stub_model
|
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
"""
|
|
37
|
-
When I run
|
|
37
|
+
When I run `rspec spec/models/widget_spec.rb`
|
|
38
38
|
Then the examples should all pass
|
|
39
39
|
|
|
40
40
|
Scenario: passing an Active Record constant with a block of stubs
|
|
@@ -54,5 +54,5 @@ Feature: stub_model
|
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
"""
|
|
57
|
-
When I run
|
|
57
|
+
When I run `rspec spec/models/widget_spec.rb`
|
|
58
58
|
Then the examples should all pass
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
Feature: transactional examples
|
|
2
2
|
|
|
3
|
+
By default rspec executes each individual example in a transaction.
|
|
4
|
+
|
|
5
|
+
You can also explicitly enable/disable transactions the configuration
|
|
6
|
+
property 'use_transactional_examples'.
|
|
7
|
+
|
|
3
8
|
Scenario: run in transactions (default)
|
|
4
9
|
Given a file named "spec/models/widget_spec.rb" with:
|
|
5
10
|
"""
|
|
@@ -20,7 +25,7 @@ Feature: transactional examples
|
|
|
20
25
|
end
|
|
21
26
|
end
|
|
22
27
|
"""
|
|
23
|
-
When I run
|
|
28
|
+
When I run `rspec spec/models/widget_spec.rb`
|
|
24
29
|
Then the examples should all pass
|
|
25
30
|
|
|
26
31
|
Scenario: run in transactions (explicit)
|
|
@@ -47,7 +52,7 @@ Feature: transactional examples
|
|
|
47
52
|
end
|
|
48
53
|
end
|
|
49
54
|
"""
|
|
50
|
-
When I run
|
|
55
|
+
When I run `rspec spec/models/widget_spec.rb`
|
|
51
56
|
Then the examples should all pass
|
|
52
57
|
|
|
53
58
|
Scenario: disable transactions (explicit)
|
|
@@ -76,7 +81,7 @@ Feature: transactional examples
|
|
|
76
81
|
after(:all) { Widget.destroy_all }
|
|
77
82
|
end
|
|
78
83
|
"""
|
|
79
|
-
When I run
|
|
84
|
+
When I run `rspec spec/models/widget_spec.rb`
|
|
80
85
|
Then the examples should all pass
|
|
81
86
|
|
|
82
87
|
Scenario: run in transactions with fixture
|
|
@@ -84,7 +89,7 @@ Feature: transactional examples
|
|
|
84
89
|
"""
|
|
85
90
|
require "spec_helper"
|
|
86
91
|
|
|
87
|
-
describe Thing do
|
|
92
|
+
describe Thing do
|
|
88
93
|
fixtures :things
|
|
89
94
|
it "fixture method defined" do
|
|
90
95
|
things(:one)
|
|
@@ -96,7 +101,7 @@ Feature: transactional examples
|
|
|
96
101
|
one:
|
|
97
102
|
name: MyString
|
|
98
103
|
"""
|
|
99
|
-
When I run
|
|
104
|
+
When I run `rspec spec/models/thing_spec.rb`
|
|
100
105
|
Then the examples should all pass
|
|
101
106
|
|
|
102
107
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
Feature: request spec
|
|
2
|
+
|
|
3
|
+
Request specs provide a thin wrapper around Rails' integration tests, and are
|
|
4
|
+
designed to drive behavior through the full stack, including routing
|
|
5
|
+
(provided by Rails) and without stubbing (that's up to you).
|
|
6
|
+
|
|
7
|
+
With request specs, you can:
|
|
8
|
+
|
|
9
|
+
* specify a single request
|
|
10
|
+
* specify multiple requests across multiple controllers
|
|
11
|
+
* specify multiple requests across multiple sessions
|
|
12
|
+
|
|
13
|
+
Check the rails documentation on integration tests for more information.
|
|
14
|
+
|
|
15
|
+
RSpec provides two matchers that delegate to Rails assertions:
|
|
16
|
+
|
|
17
|
+
render_template # delegates to assert_template
|
|
18
|
+
redirect_to # delegates to assert_redirected_to
|
|
19
|
+
|
|
20
|
+
Check the Rails docs for details on these methods as well.
|
|
21
|
+
|
|
22
|
+
If you would like to use webrat or capybara with your request specs, all you
|
|
23
|
+
have to do is include one of them in your Gemfile and RSpec will
|
|
24
|
+
automatically load them in a request spec.
|
|
25
|
+
|
|
26
|
+
Scenario: specify managing a Widget with Rails integration methods
|
|
27
|
+
Given a file named "spec/requests/widget_management_spec.rb" with:
|
|
28
|
+
"""
|
|
29
|
+
require "spec_helper"
|
|
30
|
+
|
|
31
|
+
describe "Widget management" do
|
|
32
|
+
|
|
33
|
+
it "creates a Widget and redirects to the Widget's page" do
|
|
34
|
+
get "/widgets/new"
|
|
35
|
+
response.should render_template(:new)
|
|
36
|
+
|
|
37
|
+
post "/widgets", :widget => {:name => "My Widget"}
|
|
38
|
+
|
|
39
|
+
response.should redirect_to(assigns(:widget))
|
|
40
|
+
follow_redirect!
|
|
41
|
+
|
|
42
|
+
response.should render_template(:show)
|
|
43
|
+
response.body.should include("Widget was successfully created.")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
"""
|
|
48
|
+
When I run `rspec spec/requests/widget_management_spec.rb`
|
|
49
|
+
Then the example should pass
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
Routing specs live in the `spec/routing` directory
|
|
1
|
+
Routing specs live in the `spec/routing` directory, or any example group with
|
|
2
|
+
`:type => :routing`.
|
|
2
3
|
|
|
3
4
|
Simple apps with nothing but standard RESTful routes won't get much value from
|
|
4
5
|
routing specs, but they can provide significant value when used to specify
|
|
@@ -16,7 +16,7 @@ Feature: be_routable matcher
|
|
|
16
16
|
end
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
|
-
When I run
|
|
19
|
+
When I run `rspec spec/routing/widgets_routing_spec.rb`
|
|
20
20
|
Then the output should contain "1 example, 1 failure"
|
|
21
21
|
|
|
22
22
|
Scenario: specify non-routeable route should not be routable (passes)
|
|
@@ -31,7 +31,7 @@ Feature: be_routable matcher
|
|
|
31
31
|
end
|
|
32
32
|
"""
|
|
33
33
|
|
|
34
|
-
When I run
|
|
34
|
+
When I run `rspec spec/routing/widgets_routing_spec.rb`
|
|
35
35
|
Then the examples should all pass
|
|
36
36
|
|
|
37
37
|
Scenario: specify routeable route should be routable (passes)
|
|
@@ -46,7 +46,7 @@ Feature: be_routable matcher
|
|
|
46
46
|
end
|
|
47
47
|
"""
|
|
48
48
|
|
|
49
|
-
When I run
|
|
49
|
+
When I run `rspec spec/routing/widgets_routing_spec.rb`
|
|
50
50
|
Then the examples should all pass
|
|
51
51
|
|
|
52
52
|
Scenario: specify non-routeable route should be routable (fails)
|
|
@@ -61,7 +61,7 @@ Feature: be_routable matcher
|
|
|
61
61
|
end
|
|
62
62
|
"""
|
|
63
63
|
|
|
64
|
-
When I run
|
|
64
|
+
When I run `rspec spec/routing/widgets_routing_spec.rb`
|
|
65
65
|
Then the output should contain "1 example, 1 failure"
|
|
66
66
|
|
|
67
67
|
Scenario: be_routable in a controller spec
|
|
@@ -76,5 +76,5 @@ Feature: be_routable matcher
|
|
|
76
76
|
end
|
|
77
77
|
"""
|
|
78
78
|
|
|
79
|
-
When I run
|
|
79
|
+
When I run `rspec spec/controllers/widgets_controller_spec.rb`
|
|
80
80
|
Then the examples should all pass
|
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
Feature: route_to matcher
|
|
2
2
|
|
|
3
|
-
The `route_to` matcher specifies that a request (verb +
|
|
4
|
-
is most valuable when specifying routes other than standard RESTful
|
|
3
|
+
The `route_to` matcher specifies that a request (verb + path) is routable.
|
|
4
|
+
It is most valuable when specifying routes other than standard RESTful
|
|
5
|
+
routes.
|
|
6
|
+
|
|
7
|
+
get("/").should route_to("welcome#index") # new in 2.6.0
|
|
8
|
+
|
|
9
|
+
or
|
|
5
10
|
|
|
6
11
|
{ :get => "/" }.should route_to(:controller => "welcome")
|
|
7
12
|
|
|
8
|
-
Scenario: passing route spec
|
|
13
|
+
Scenario: passing route spec with shortcut syntax
|
|
14
|
+
Given a file named "spec/routing/widgets_routing_spec.rb" with:
|
|
15
|
+
"""
|
|
16
|
+
require "spec_helper"
|
|
17
|
+
|
|
18
|
+
describe "routes for Widgets" do
|
|
19
|
+
it "routes /widgets to the widgets controller" do
|
|
20
|
+
get("/widgets").
|
|
21
|
+
should route_to("widgets#index")
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
When I run `rspec spec/routing/widgets_routing_spec.rb`
|
|
27
|
+
Then the examples should all pass
|
|
28
|
+
|
|
29
|
+
Scenario: passing route spec with verbose syntax
|
|
9
30
|
Given a file named "spec/routing/widgets_routing_spec.rb" with:
|
|
10
31
|
"""
|
|
11
32
|
require "spec_helper"
|
|
@@ -18,7 +39,7 @@ Feature: route_to matcher
|
|
|
18
39
|
end
|
|
19
40
|
"""
|
|
20
41
|
|
|
21
|
-
When I run
|
|
42
|
+
When I run `rspec spec/routing/widgets_routing_spec.rb`
|
|
22
43
|
Then the examples should all pass
|
|
23
44
|
|
|
24
45
|
Scenario: route spec for a route that doesn't exist (fails)
|
|
@@ -28,11 +49,10 @@ Feature: route_to matcher
|
|
|
28
49
|
|
|
29
50
|
describe "routes for Widgets" do
|
|
30
51
|
it "routes /widgets/foo to the /foo action" do
|
|
31
|
-
|
|
32
|
-
should route_to(:controller => "widgets", :action => "foo")
|
|
52
|
+
get("/widgets/foo").should route_to("widgets#foo")
|
|
33
53
|
end
|
|
34
54
|
end
|
|
35
55
|
"""
|
|
36
56
|
|
|
37
|
-
When I run
|
|
38
|
-
Then the output should contain "1
|
|
57
|
+
When I run `rspec spec/routing/widgets_routing_spec.rb`
|
|
58
|
+
Then the output should contain "1 failure"
|
data/features/support/env.rb
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
require 'aruba'
|
|
2
|
-
require 'webrat'
|
|
1
|
+
require 'aruba/cucumber'
|
|
3
2
|
|
|
4
|
-
module
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def run(cmd, fail_on_error=false)
|
|
8
|
-
if cmd =~ /^rspec/
|
|
9
|
-
orig_run("bundle exec #{cmd}", fail_on_error)
|
|
10
|
-
else
|
|
11
|
-
orig_run(cmd, fail_on_error)
|
|
12
|
-
end
|
|
3
|
+
module ArubaExt
|
|
4
|
+
def run(cmd)
|
|
5
|
+
super(cmd =~ /^rspec/ ? "bundle exec #{cmd}" : cmd)
|
|
13
6
|
end
|
|
14
7
|
end
|
|
15
8
|
|
|
9
|
+
World(ArubaExt)
|
|
10
|
+
|
|
16
11
|
Before do
|
|
17
|
-
|
|
12
|
+
@aruba_timeout_seconds = 10
|
|
18
13
|
end
|
|
19
14
|
|
|
20
15
|
unless File.directory?('./tmp/example_app')
|
|
@@ -41,7 +36,6 @@ def copy(file_or_dir)
|
|
|
41
36
|
system "cp -r #{source} #{target}"
|
|
42
37
|
end
|
|
43
38
|
|
|
44
|
-
|
|
45
39
|
Before do
|
|
46
40
|
steps %Q{
|
|
47
41
|
Given a directory named "spec"
|
|
@@ -56,10 +50,4 @@ Before do
|
|
|
56
50
|
["spec/spec_helper.rb"].each do |file_or_dir|
|
|
57
51
|
write_symlink("tmp/example_app/#{file_or_dir}")
|
|
58
52
|
end
|
|
59
|
-
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
Around do |scenario, block|
|
|
63
|
-
Bundler.with_clean_env &block
|
|
64
53
|
end
|
|
65
|
-
|
|
@@ -11,7 +11,7 @@ Feature: view spec infers controller path and action
|
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
"""
|
|
14
|
-
When I run
|
|
14
|
+
When I run `rspec spec/views`
|
|
15
15
|
Then the examples should all pass
|
|
16
16
|
|
|
17
17
|
Scenario: infer action
|
|
@@ -25,7 +25,7 @@ Feature: view spec infers controller path and action
|
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
"""
|
|
28
|
-
When I run
|
|
28
|
+
When I run `rspec spec/views`
|
|
29
29
|
Then the examples should all pass
|
|
30
30
|
|
|
31
31
|
Scenario: do not infer action in a partial
|
|
@@ -39,6 +39,6 @@ Feature: view spec infers controller path and action
|
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
"""
|
|
42
|
-
When I run
|
|
42
|
+
When I run `rspec spec/views`
|
|
43
43
|
Then the examples should all pass
|
|
44
44
|
|
|
@@ -26,7 +26,7 @@ Feature: stub template
|
|
|
26
26
|
"""
|
|
27
27
|
<%= render :partial => "gadget", :collection => @gadgets %>
|
|
28
28
|
"""
|
|
29
|
-
When I run
|
|
29
|
+
When I run `rspec spec/views/gadgets/list.html.erb_spec.rb`
|
|
30
30
|
Then the examples should all pass
|
|
31
31
|
|
|
32
32
|
Scenario: stub template that exists
|
|
@@ -46,6 +46,6 @@ Feature: stub template
|
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
"""
|
|
49
|
-
When I run
|
|
49
|
+
When I run `rspec spec/views/gadgets/edit.html.erb_spec.rb`
|
|
50
50
|
Then the examples should all pass
|
|
51
51
|
|