maniok_bdd 0.1.0 → 0.2.0

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.
@@ -17,64 +17,85 @@ class ManiokBdd::GherkinFormatter
17
17
  @feature = Feature.new gherkin_model_feature
18
18
  end
19
19
 
20
- class Feature
21
- attr_reader :scenarios
20
+ def scenario(gherkin_model_scenario)
21
+ @feature.scenarios << (@current_scenario = Scenario.new(gherkin_model_scenario))
22
+ end
23
+
24
+ def step(gherkin_model_step)
25
+ @current_scenario.steps << Step.new(gherkin_model_step)
26
+ end
27
+
28
+ # to avoid undefined method `uri' & efo and keep Gherkin parser happy
29
+ def uri(*)
30
+ end
31
+
32
+ def eof
33
+ end
22
34
 
23
- def initialize(gherkin_model_feature)
24
- @gherkin_model_feature = gherkin_model_feature
25
- @scenarios = []
35
+ private
36
+
37
+ class GherkinCollection
38
+ attr_reader :elements
39
+
40
+ def initialize(gherkin_object)
41
+ @gherkin_object = gherkin_object
42
+ @elements = []
26
43
  end
27
44
 
28
45
  def to_s
29
- # TODO later
30
- #{@gherkin_model_feature.description}
46
+ <<RUBY
47
+ #{gherkin_to_maniok_block} do
31
48
 
32
- <<RUBY_FEATURE
33
- require 'spec_helper'
49
+ #{print_elements}
50
+ end
51
+ RUBY
52
+ end
34
53
 
35
- Feature "#{@gherkin_model_feature.name}" do
54
+ private
36
55
 
37
- #{print_scenarios}
38
- end
39
- RUBY_FEATURE
56
+ def gherkin_to_maniok_block
57
+ "#{gherkin_model_name} \"#{@gherkin_object.name}\""
40
58
  end
41
59
 
42
- def print_scenarios
43
- @scenarios.map do |scenario|
44
- scenario.to_s
60
+ def gherkin_model_name
61
+ @gherkin_object.class.name.split('::').last
62
+ end
63
+
64
+ def print_elements
65
+ @elements.map do |element|
66
+ element.to_s
45
67
  end.join("\n")
46
68
  end
47
69
  end
48
70
 
49
- def scenario(gherkin_model_scenario)
50
- @feature.scenarios << (@current_scenario = Scenario.new(gherkin_model_scenario))
51
- end
71
+ class Feature < GherkinCollection
72
+ alias :scenarios :elements
52
73
 
53
- class Scenario
54
- attr_reader :steps
55
- def initialize(gherkin_model_scenario)
56
- @gherkin_model_scenario = gherkin_model_scenario
57
- @steps = []
74
+ def to_s
75
+ # TODO later
76
+ #{@gherkin_model_feature.description}
77
+
78
+ <<RUBY_FEATURE
79
+ require 'spec_helper'
80
+
81
+ #{super.to_s}
82
+ RUBY_FEATURE
58
83
  end
59
84
 
85
+ end
86
+
87
+ class Scenario < GherkinCollection
88
+ alias :steps :elements
89
+
60
90
  def to_s
61
91
  <<RUBY_SCENARIO
62
- Scenario "#{@gherkin_model_scenario.name}" do
92
+ #{gherkin_to_maniok_block} do
63
93
 
64
- #{print_steps}
94
+ #{print_elements}
65
95
  end
66
96
  RUBY_SCENARIO
67
97
  end
68
98
 
69
- def print_steps
70
- @steps.map do |step|
71
- step.to_s
72
- end.join("\n")
73
- end
74
- end
75
-
76
- def step(gherkin_model_step)
77
- @current_scenario.steps << Step.new(gherkin_model_step)
78
99
  end
79
100
 
80
101
  class Step
@@ -91,11 +112,4 @@ RUBY_STEP
91
112
  end
92
113
  end
93
114
 
94
- # to avoid undefined method `uri' & efo and keep Gherkin parser happy
95
- def uri(*)
96
- end
97
-
98
- def eof
99
- end
100
-
101
115
  end
@@ -29,6 +29,10 @@ module ManiokBdd
29
29
  Step :but, message, options, &block
30
30
  end
31
31
 
32
+ def _(message, options = {}, &block)
33
+ Step :_, message, options, &block
34
+ end
35
+
32
36
  private
33
37
 
34
38
  def Step(type, message, options = {}, &block)
@@ -1,3 +1,3 @@
1
1
  module ManiokBdd
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: maniok_bdd
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jean-Michel Garnier
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-18 00:00:00.000000000 Z
12
+ date: 2013-05-13 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: jean-michel@21croissants.com
@@ -40,23 +40,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - ! '>='
42
42
  - !ruby/object:Gem::Version
43
- version: '0'
44
43
  segments:
45
44
  - 0
46
- hash: -2301873164338472506
45
+ hash: -3922873329849072388
46
+ version: '0'
47
47
  none: false
48
48
  required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  requirements:
50
50
  - - ! '>='
51
51
  - !ruby/object:Gem::Version
52
- version: '0'
53
52
  segments:
54
53
  - 0
55
- hash: -2301873164338472506
54
+ hash: -3922873329849072388
55
+ version: '0'
56
56
  none: false
57
57
  requirements: []
58
58
  rubyforge_project:
59
- rubygems_version: 1.8.24
59
+ rubygems_version: 1.8.25
60
60
  signing_key:
61
61
  specification_version: 3
62
62
  summary: BDD with POROs