Sha256: b166a515477af96eeab6773292cab483981b140a88b1dd6e0c2bbe473a8cefbf

Contents?: true

Size: 1.77 KB

Versions: 2

Compression:

Stored size: 1.77 KB

Contents

Feature: Allow Cucumber to rescue exceptions

  Background: A controller that raises an exception
    Given I have created a new Rails app and installed cucumber-rails
    When 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:
      """
      TestApp::Application.routes.draw do
        resources :posts
      end
      """

  Scenario: Allow rescue
    When 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."
      end
      """
    And I run `bundle exec rake db:migrate`
    And I run `bundle exec cucumber`
    Then the feature run should pass with:
      """
      1 scenario (1 passed)
      2 steps (2 passed)
      """

  Scenario: Don't allow rescue
    When 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)
       """

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cucumber-rails-2.2.0 features/allow_rescue.feature
cucumber-rails-2.1.0 features/allow_rescue.feature