-
-
Notifications
You must be signed in to change notification settings - Fork 329
/
allow_rescue.feature
66 lines (63 loc) · 1.85 KB
/
allow_rescue.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Feature: Allow Cucumber to rescue exceptions
Background: A controller that raises an exception
Given I have created a new Rails app "rails-3-app" and installed cucumber-rails
And I write to "app/controllers/posts_controller.rb" with:
"""
class PostsController < ApplicationController
def index
raise "There is an error in index"
end
end
"""
And I write to "config/routes.rb" with:
"""
Rails3App::Application.routes.draw do
resources :posts
end
"""
Scenario: Allow rescue
Given I write to "features/posts.feature" with:
"""
Feature: posts
@allow-rescue
Scenario: See posts
When I look at the posts
Then I should see the public error page
"""
And I write to "features/step_definitions/posts_steps.rb" with:
"""
When /^I look at the posts$/ do
visit '/posts'
end
Then /^I should see the public error page$/ do
expect(page).to have_content "We're sorry, but something went wrong. \
If you are the application owner check the logs for more information."
end
"""
And I run `bundle exec rake db:migrate`
And I run `bundle exec cucumber`
Then it should pass with:
"""
1 scenario (1 passed)
2 steps (2 passed)
"""
Scenario: Don't allow rescue
Given I write to "features/posts.feature" with:
"""
Feature: posts
Scenario: See them
When I look at the posts
"""
And I write to "features/step_definitions/posts_steps.rb" with:
"""
When /^I look at the posts$/ do
visit '/posts'
end
"""
And I run `bundle exec rake db:migrate`
And I run `bundle exec cucumber`
Then it should fail with:
"""
1 scenario (1 failed)
1 step (1 failed)
"""