github.com/getgauge/gauge@v1.6.9/gauge/specification_test.go (about)

     1  /*----------------------------------------------------------------
     2   *  Copyright (c) ThoughtWorks, Inc.
     3   *  Licensed under the Apache License, Version 2.0
     4   *  See LICENSE in the project root for license information.
     5   *----------------------------------------------------------------*/
     6  
     7  package gauge
     8  
     9  import . "gopkg.in/check.v1"
    10  
    11  func (s *MySuite) TestUsesArgsInContext(c *C) {
    12  	spec := &Specification{
    13  		Contexts: []*Step{
    14  			&Step{Value: "some ",
    15  				LineText:  "sfd <foo>",
    16  				IsConcept: false,
    17  				Args: []*StepArg{
    18  					&StepArg{
    19  						Value:   "foo",
    20  						ArgType: Dynamic,
    21  					},
    22  				},
    23  			},
    24  		},
    25  		TearDownSteps: []*Step{},
    26  	}
    27  
    28  	c.Assert(spec.UsesArgsInContextTeardown("foo"), Equals, true)
    29  }
    30  
    31  func (s *MySuite) TestDoesNotUseDynamicArgsInContext(c *C) {
    32  	spec := &Specification{
    33  		Contexts: []*Step{
    34  			&Step{Value: "some ",
    35  				LineText:  "sfd <foo>",
    36  				IsConcept: false,
    37  				Args: []*StepArg{
    38  					&StepArg{
    39  						Value:   "foo",
    40  						ArgType: Static,
    41  					},
    42  				},
    43  			},
    44  		},
    45  		TearDownSteps: []*Step{},
    46  	}
    47  
    48  	c.Assert(spec.UsesArgsInContextTeardown("foo"), Equals, false)
    49  }
    50  
    51  func (s *MySuite) TestDoesNotUseArgsInTeardown(c *C) {
    52  	spec := &Specification{
    53  		Contexts: []*Step{},
    54  		TearDownSteps: []*Step{
    55  			&Step{Value: "some ",
    56  				LineText:  "sfd <foo>",
    57  				IsConcept: false,
    58  				Args: []*StepArg{
    59  					&StepArg{
    60  						Value:   "foo",
    61  						ArgType: Static,
    62  					},
    63  				},
    64  			},
    65  		},
    66  	}
    67  
    68  	c.Assert(spec.UsesArgsInContextTeardown("foo"), Equals, false)
    69  }
    70  
    71  func (s *MySuite) TestStepsGiveAllStepsPresentInSpec(c *C) {
    72  	step1 := &Step{
    73  		Value:     "something {}",
    74  		LineText:  "something <foo>",
    75  		IsConcept: false,
    76  		Args: []*StepArg{
    77  			&StepArg{
    78  				Value:   "foo",
    79  				ArgType: Static,
    80  			},
    81  		},
    82  	}
    83  
    84  	step2 := &Step{
    85  		Value:     "something",
    86  		LineText:  "something",
    87  		IsConcept: false,
    88  	}
    89  
    90  	step3 := &Step{
    91  		Value:     "sfd {}",
    92  		LineText:  "sfd <foo>",
    93  		IsConcept: false,
    94  		Args: []*StepArg{
    95  			&StepArg{
    96  				Value:   "foo",
    97  				ArgType: Static,
    98  			},
    99  		},
   100  	}
   101  
   102  	scen := &Scenario{
   103  		Steps: []*Step{step2},
   104  	}
   105  
   106  	spec := &Specification{
   107  		Contexts:      []*Step{step1},
   108  		Scenarios:     []*Scenario{scen},
   109  		TearDownSteps: []*Step{step3},
   110  	}
   111  
   112  	c.Assert(spec.Steps(), DeepEquals, []*Step{step1, step2, step3})
   113  }