josephwilk (owner)

Forks

Revisions

gist: 48018 Download_button fork
public
Description:
Background feature for Cucumber
Public Clone URL: git://gist.github.com/48018.git
Embed All Files: show embed
background.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
Feature: Backgrounds
  In order to provide a context to my scenarios within a feature
  As a feature editor
  I want to write a background section in my features.
  
  Scenario: run a scenario with a background with a passing step
    When I run cucumber -q features/passing_background_sample.feature:6
    Then it should pass with
    """
    Feature: sample
      
      Background:
        Given '10' cukes
      
      Scenario: passing background
        Then I have '10' cukes
 
    1 scenario
    1 step passed
    """
 
  Scenario: run a scenario with a background with a failing step
    When I run cucumber -q features/failing_background_sample.feature:6
    Then it should fail with
    """
    Feature: sample
    
      Background:
        Given -1 cukes
          FAIL (RuntimeError)
          ./features/step_definitions/sample_steps.rb:7:in `Given /^'(.+)' cukes$/'
          features/sample.feature:12:in `Given -1 cukes'
        
 
      Scenario: failing background
        FAIL (RuntimeError)
          ./features/step_definitions/sample_steps.rb:7:in `Given /^'(.+)' cukes$/'
        features/sample.feature:12:in `Given -1 cukes'
        Then I have '10' cukes
 
    1 scenario
    1 step failed
    """
    
  Scenario: run a scenario showing explicit background steps --explicit-background
    When I run cucumber -q features/passing_background_sample.feature:6 --explicit-background
    Then it should pass with
    """
    Feature: sample
 
      Background:
        Given '10' cukes
 
      Scenario: passing
        (Given '10' cukes)
        Then I have '10' cukes
 
    1 scenario
    1 step passed
    """
failing_background_sample.feature #
1
2
3
4
5
6
7
8
Feature: sample
  
  Background:
    Given '-1' cukes
    
  Scenario: failing background
    Then I have '10' cukes
 
passing_background_sample.feature #
1
2
3
4
5
6
7
8
Feature: sample
  
  Background:
    Given '10' cukes
    
  Scenario: passing background
    Then I have '10' cukes