gherkin_generator 1.0.3 → 1.0.4

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gherkin_generator.rb +68 -0
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1252b9c59effa14e97e71eb82a6d1a3d6abcd66
4
- data.tar.gz: 6154bddbccc55a7b65b9266532f8e8c53e9fa4b6
3
+ metadata.gz: 8a1bd5e59eeb1e2030c5426a7911825508e4ffbd
4
+ data.tar.gz: 0388574fbf0e3d67cbaccb8e60d25ab51329679b
5
5
  SHA512:
6
- metadata.gz: a2a650dbdb55be2e173a8de6ab08e3407f306ca0b80508c4007b12149bdc1bb9ae7717f3e76333f65fa0e5d0f85b14f61ef3217877bda4169c3eee68e4c51fc9
7
- data.tar.gz: a4eb5bd8531bafe74fbcd10c10b623166d196b32dc6f9130f6aa5b13f9e37ec0c2ccd38acb26b92549db56aa82abda57746fc5b6f1684e8ca84de5cf57ce5ab2
6
+ metadata.gz: d8d1f3e368b82c4dbc897045bb8cd198bfcc889bbdee17dd5ef7b68ca2f2b10d84d2ce05a8767aa2d5a726364660aba1ef696e4f652ea90a5c87317face9691a
7
+ data.tar.gz: 0e14be4e9c523ec2b8845e60903b63a21d0130befaa5c8537a09e25f62c704ba69d33095ca12a2141744b29b815241045698a1d101b3e7b4c24f625bb667ed2b
@@ -1,12 +1,45 @@
1
+ # A simple tool for generating Gherkin Feature Files programmatically.
2
+ #
3
+ # = Example
4
+ #
5
+ # gg = GherkinGenerator.new("My Feature")
6
+ # gg.add_scenario("Something: When I do something Then something should have happened")
7
+ # gg.add_scenario("Something Else: When I do something else Then something else should have happened")
8
+ # puts gg.to_gherkin
9
+ #
1
10
  class GherkinGenerator
11
+ ##
12
+ # A multiline feature description
13
+ #
14
+ # = Example
15
+ #
16
+ # GherkinGenerator.new("My Feature").description = <<EOS
17
+ # All sorts of information about my feature
18
+ # This info is not parsed, it's just a description of the feature
19
+ # EOS
2
20
  attr_accessor :description
3
21
 
22
+ ##
23
+ # Generate a new feature
24
+ #
25
+ # = Example
26
+ #
27
+ # GherkinGenerator.new("Feature name goes here")
4
28
  def initialize(feature_name)
5
29
  @feature_name = feature_name
6
30
  @scenarios = []
7
31
  @tag = ''
8
32
  end
9
33
 
34
+
35
+ ##
36
+ # Add a scenario to the feature. The format is a single line string
37
+ # with capital letters for the GWTA's
38
+ #
39
+ # = Example
40
+ #
41
+ # myFeature.add_scenario("My Scenario: Given I ... When I ... And I ... Then I ...")
42
+ #
10
43
  def add_scenario(scenario)
11
44
  examples_keyword = 'Examples '
12
45
  scenario_parts = scenario.split examples_keyword
@@ -18,10 +51,36 @@ class GherkinGenerator
18
51
  result
19
52
  end
20
53
 
54
+ ##
55
+ # Examples in Gherkin don't suite the one-line input well. This
56
+ #
57
+ # = Example
58
+ #
59
+ # myFeature.exampleHandler do |reference|
60
+ # puts "looking up examples with ref: #{reference}"
61
+ # <<EOS
62
+ # | something | another |
63
+ # | abc | def |
64
+ # | def | ghi |
65
+ # EOS
66
+ # end
67
+ # myFeature.add_scenario("My Scenario With" +
68
+ # " Examples: Given I ... Then I ... Examples http://example.org/example1")
69
+ #
21
70
  def example_handler(&block)
22
71
  @ex_yield = block
23
72
  end
24
73
 
74
+ ##
75
+ # Output the Gherkin formatted string, this can be saved in a Feature file.
76
+ #
77
+ # = Example
78
+ #
79
+ # gg = GherkinGenerator.new("My Feature")
80
+ # gg.add_scenario("Something: When I do something Then something should have happened")
81
+ # gg.add_scenario("Something Else: When I do something else Then something else should have happened")
82
+ # puts gg.to_gherkin
83
+ #
25
84
  def to_gherkin
26
85
  feature = 'Feature: ' + @feature_name
27
86
  desc = @description.nil? ? '' : "\n\t" + @description.sub("\n", "\n\t")
@@ -34,7 +93,11 @@ class GherkinGenerator
34
93
  feature + desc + scenarios + "\n"
35
94
  end
36
95
 
96
+ ##
97
+ # Object oriented representation of scenarios. This is designed for internal use by GherkinGenerator.
37
98
  class Scenario
99
+ ##
100
+ # Takes a single-line scenario and a formatted example table
38
101
  def initialize(scenario, examples)
39
102
  @scenario = scenario
40
103
  @tag = []
@@ -45,10 +108,15 @@ class GherkinGenerator
45
108
  end
46
109
  end
47
110
 
111
+ ##
112
+ # Adding a tag - the formatting is applied, you just supply the tag name
48
113
  def add_tag(tag)
49
114
  @tag << '@' + tag
50
115
  end
51
116
 
117
+ ##
118
+ # The output of the current scenario, a feature file is made up of a description
119
+ # and multiple scenarios formatted as a string.
52
120
  def format_string
53
121
  keywords = %w(Given And When Then)
54
122
  steps = @scenario.split(':')[1].strip
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gherkin_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mat Carey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-30 00:00:00.000000000 Z
11
+ date: 2014-07-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple tool for generating Gherkin Feature Files programmatically.
14
14
  email: opensource+gherkin-formatter@dorightdigital.com
@@ -17,7 +17,7 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - lib/gherkin_generator.rb
20
- homepage:
20
+ homepage: https://github.com/dorightdigital/gherkin-generator
21
21
  licenses:
22
22
  - MIT
23
23
  metadata: {}