lucid 0.4.1 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -3
  3. data/HISTORY.md +12 -0
  4. data/LICENSE +0 -3
  5. data/README.md +7 -5
  6. data/Rakefile +0 -14
  7. data/lib/lucid.rb +4 -0
  8. data/lib/lucid/cli/app.rb +1 -5
  9. data/lib/lucid/cli/context.rb +8 -6
  10. data/lib/lucid/cli/profile.rb +9 -9
  11. data/lib/lucid/context.rb +1 -1
  12. data/lib/lucid/interface_rb/matcher.rb +1 -2
  13. data/lib/lucid/platform.rb +2 -1
  14. data/lucid.gemspec +12 -12
  15. data/spec/lucid/lucid_spec.rb +7 -0
  16. data/spec/spec_helper.rb +0 -19
  17. metadata +34 -116
  18. data/.travis.yml +0 -15
  19. data/lib/lucid/sequence.rb +0 -5
  20. data/lib/lucid/sequence/sequence_errors.rb +0 -64
  21. data/lib/lucid/sequence/sequence_group.rb +0 -35
  22. data/lib/lucid/sequence/sequence_phrase.rb +0 -166
  23. data/lib/lucid/sequence/sequence_steps.rb +0 -20
  24. data/lib/lucid/sequence/sequence_support.rb +0 -26
  25. data/lib/lucid/sequence/sequence_template.rb +0 -354
  26. data/spec/lucid/ansicolor_spec.rb +0 -31
  27. data/spec/lucid/app_spec.rb +0 -82
  28. data/spec/lucid/ast/background_spec.rb +0 -128
  29. data/spec/lucid/ast/doc_string_spec.rb +0 -36
  30. data/spec/lucid/ast/feature_spec.rb +0 -66
  31. data/spec/lucid/ast/outline_table_spec.rb +0 -21
  32. data/spec/lucid/ast/scenario_outline_spec.rb +0 -81
  33. data/spec/lucid/ast/specs_spec.rb +0 -48
  34. data/spec/lucid/ast/step_invocation_spec.rb +0 -45
  35. data/spec/lucid/ast/step_spec.rb +0 -72
  36. data/spec/lucid/ast/table_spec.rb +0 -265
  37. data/spec/lucid/ast/tdl_factory.rb +0 -78
  38. data/spec/lucid/ast/tdl_walker_spec.rb +0 -21
  39. data/spec/lucid/context_spec.rb +0 -328
  40. data/spec/lucid/duration_spec.rb +0 -22
  41. data/spec/lucid/facade_spec.rb +0 -31
  42. data/spec/lucid/factory_spec.rb +0 -16
  43. data/spec/lucid/matcher_spec.rb +0 -127
  44. data/spec/lucid/options_spec.rb +0 -346
  45. data/spec/lucid/orchestrator_spec.rb +0 -117
  46. data/spec/lucid/pending_spec.rb +0 -45
  47. data/spec/lucid/progress_spec.rb +0 -34
  48. data/spec/lucid/rb_step_definition_spec.rb +0 -127
  49. data/spec/lucid/rb_transform_spec.rb +0 -24
  50. data/spec/lucid/regexp_argument_matcher_spec.rb +0 -19
  51. data/spec/lucid/results_spec.rb +0 -81
  52. data/spec/lucid/runtime_spec.rb +0 -38
  53. data/spec/lucid/sequences/sequence_conditional_spec.rb +0 -74
  54. data/spec/lucid/sequences/sequence_group_spec.rb +0 -55
  55. data/spec/lucid/sequences/sequence_phrase_spec.rb +0 -122
  56. data/spec/lucid/sequences/sequence_placeholder_spec.rb +0 -56
  57. data/spec/lucid/sequences/sequence_section_spec.rb +0 -61
  58. data/spec/lucid/sequences/sequence_support_spec.rb +0 -65
  59. data/spec/lucid/sequences/sequence_template_spec.rb +0 -298
  60. data/spec/lucid/step_match_spec.rb +0 -55
@@ -1,55 +0,0 @@
1
- require_relative '../../spec_helper'
2
-
3
- require_relative '../../../lib/lucid/sequence/sequence_group'
4
-
5
- module Sequence
6
- describe SequenceGroup do
7
-
8
- let(:singleton) { SequenceGroup.instance() }
9
-
10
- context 'starting state' do
11
- it 'should be empty' do
12
- expect(singleton.sequence_steps).to be_empty
13
- end
14
- end
15
-
16
- context 'basic operation' do
17
- let(:example_steps) do
18
- example = <<-EXAMPLE
19
- Given the login page
20
- When the username is "<username>"
21
- And the password is "<password>"
22
- And login is clicked
23
- EXAMPLE
24
- end
25
-
26
- it 'should accept the addition of a new sequence phrase' do
27
- phrase = '[enter credentials]'
28
- args = [phrase, example_steps, true]
29
- expect { singleton.add_sequence(*args) }.not_to raise_error
30
- expect(singleton).to have(1).sequence_steps
31
- end
32
-
33
- it 'should not accept the addition of an existing sequence phrase' do
34
- phrase = '[enter credentials]'
35
- args = [phrase, example_steps, true]
36
- msg = "A sequence with phrase '[enter credentials]' already exists."
37
- expect { singleton.add_sequence(*args) }.to raise_error(Sequence::DuplicateSequenceError, msg)
38
- end
39
-
40
- it 'should return the steps of a sequence phrase' do
41
- phrase = '[enter credentials]'
42
- input_values = [['username', 'jnyman'], ['password', 'thx1138']]
43
- generated = singleton.generate_steps(phrase, input_values)
44
- expected = <<-EXAMPLE
45
- Given the login page
46
- When the username is "jnyman"
47
- And the password is "thx1138"
48
- And login is clicked
49
- EXAMPLE
50
- expect(generated).to eq(expected)
51
- end
52
- end
53
-
54
- end
55
- end
@@ -1,122 +0,0 @@
1
- require_relative '../../spec_helper'
2
- require_relative '../../../lib/lucid/sequence/sequence_phrase'
3
-
4
- module Sequence
5
-
6
- describe SequencePhrase do
7
- let(:example_phrase) { 'enter login credentials as <username>' }
8
-
9
- let(:example_template) do
10
- example = <<-EXAMPLE
11
- Given the login page
12
- When the username is "<username>"
13
- And the password is "<password>"
14
- And login is clicked
15
- EXAMPLE
16
- end
17
-
18
- subject { SequencePhrase.new(example_phrase, example_template, true) }
19
-
20
- context 'sequence phrase generation' do
21
- it 'should be created with a phrase, steps and a data table indicator' do
22
- expect { SequencePhrase.new(example_phrase, example_template, true) }.not_to raise_error
23
- end
24
-
25
- it 'should indicate that a step argument can never be assigned a value via the phrase' do
26
- msg = "The step parameter 'password' does not appear in the phrase."
27
- expect { SequencePhrase.new(example_phrase, example_template, false) }.to raise_error(Sequence::UnreachableStepParameter, msg)
28
- end
29
-
30
- it 'should indicate when an argument in the phrase never occurs in any steps' do
31
- phrase = 'enter credentials as <tester>'
32
- msg = "The phrase parameter 'tester' does not appear in any step."
33
- expect { SequencePhrase.new(phrase, example_template, true) }.to raise_error(Sequence::UselessPhraseParameter, msg)
34
- end
35
-
36
- it 'should have a sequence key' do
37
- expect(subject.key).to eq('enter_login_credentials_as_X_T')
38
- end
39
-
40
- it 'should establish the placeholders from the sequence phrase' do
41
- expect(subject.phrase_params).to eq(%w[username])
42
- end
43
-
44
- it 'should know the placeholders from the phrase and generated template' do
45
- expect(subject.values).to eq(%w[username password])
46
- end
47
- end
48
-
49
- context 'sequence phrase execution' do
50
-
51
- let(:phrase_instance) { %Q|enter credentials as "jnyman"| }
52
-
53
- it 'should generate the steps' do
54
- text = subject.expand(phrase_instance, [ %w(password thx1138) ])
55
- expectation = <<-EXAMPLE
56
- Given the login page
57
- When the username is "jnyman"
58
- And the password is "thx1138"
59
- And login is clicked
60
- EXAMPLE
61
-
62
- expect(text).to eq(expectation)
63
- end
64
-
65
- it 'should generate steps even when a step argument has no value' do
66
- text = subject.expand(phrase_instance, [ ])
67
- expectation = <<-EXAMPLE
68
- Given the login page
69
- When the username is "jnyman"
70
- And the password is ""
71
- And login is clicked
72
- EXAMPLE
73
-
74
- expect(text).to eq(expectation)
75
- end
76
-
77
- it 'should unescape any double-quotes for phrase arguments' do
78
- specific_phrase = %q|enter credentials as "jnyman\""|
79
- text = subject.expand(specific_phrase, [ %w(password thx1138) ])
80
- expectation = <<-EXAMPLE
81
- Given the login page
82
- When the username is "jnyman""
83
- And the password is "thx1138"
84
- And login is clicked
85
- EXAMPLE
86
-
87
- expect(text).to eq(expectation)
88
- end
89
-
90
- it 'should indicate when an unknown variable is used' do
91
- error_message = "Unknown sequence step parameter 'unknown'."
92
- args = [ %w(unknown anything) ]
93
- expect { subject.expand(phrase_instance, args) }.to raise_error(UnknownParameterError, error_message)
94
- end
95
-
96
- it 'should indicate when an argument gets a value from a phrase and a table' do
97
- phrase = %Q|enter credentials as "jnyman"|
98
- msg = "The sequence parameter 'username' has value 'jnyman' and 'tester'."
99
- args = [ %w(username tester), %w(password thx1138) ]
100
- expect { subject.expand(phrase, args) }.to raise_error(AmbiguousParameterValue, msg)
101
- end
102
-
103
- it 'should expand any built-in variables' do
104
- phrase = 'do nothing useful'
105
- quoted_steps = <<-EXAMPLE
106
- Given the following films:
107
- <quotes>
108
- Iron Man 3
109
- World War Z
110
- <quotes>
111
- EXAMPLE
112
-
113
- instance = SequencePhrase.new(phrase, quoted_steps, true)
114
- actual = instance.expand(phrase, [])
115
- expected = quoted_steps.gsub(/<quotes>/, '"""')
116
- expect(actual).to eq(expected)
117
- end
118
- end
119
-
120
- end
121
-
122
- end
@@ -1,56 +0,0 @@
1
- require_relative '../../spec_helper'
2
- require_relative '../../../lib/lucid/sequence/sequence_template'
3
-
4
- module Sequence
5
- module SequenceTemplate
6
-
7
- describe Placeholder do
8
- subject { Placeholder.new('testing') }
9
-
10
- context 'establishing a placeholder' do
11
- it 'should be created with a variable name' do
12
- expect { Placeholder.new('testing') }.not_to raise_error
13
- end
14
-
15
- it 'should know the name of its variable' do
16
- expect(subject.name).to eq('testing')
17
- end
18
- end
19
-
20
- context 'generating a placeholder' do
21
- it 'should generate an empty string when an actual value is absent' do
22
- generated_text = subject.output(Object.new, {})
23
- expect(generated_text).to be_empty
24
-
25
- generated_text = subject.output(Object.new, { 'testing' => nil })
26
- expect(generated_text).to be_empty
27
- end
28
-
29
- it 'should generate an empty string when the context object value is absent' do
30
- context = Object.new
31
- def context.testing
32
- nil
33
- end
34
- generated_text = subject.output(context, {})
35
- expect(generated_text).to be_empty
36
- end
37
-
38
- it 'should render the actual value bound to the placeholder' do
39
- generated_text = subject.output(Object.new, { 'testing' => 'test' })
40
- expect(generated_text).to eq('test')
41
- end
42
-
43
- it 'should render the context object actual value bound to the placeholder' do
44
- context = Object.new
45
- def context.testing
46
- 'test'
47
- end
48
- generated_text = subject.output(context, {})
49
- expect(generated_text).to eq('test')
50
- end
51
-
52
- end
53
- end
54
-
55
- end
56
- end
@@ -1,61 +0,0 @@
1
- require_relative '../../spec_helper'
2
- require_relative '../../../lib/lucid/sequence/sequence_template'
3
-
4
- module Sequence
5
- module SequenceTemplate
6
-
7
- describe Section do
8
- subject { Section.new('testing') }
9
-
10
- let(:example_child_elements) do
11
- [ StaticText.new('Test '),
12
- Placeholder.new('content'),
13
- EOLine.new
14
- ]
15
- end
16
-
17
- context 'establishing a section' do
18
- it 'should be created with a variable name' do
19
- expect { Section.new('testing') }.not_to raise_error
20
- end
21
-
22
- it 'should know the name of its variable' do
23
- expect(subject.name).to eq('testing')
24
- end
25
-
26
- it 'should have no child elements by default' do
27
- expect(subject).to have(0).children
28
- end
29
- end
30
-
31
- context 'generating a section' do
32
- it 'should add child elements' do
33
- example_child_elements.each do |child|
34
- subject.add_child(child)
35
- end
36
-
37
- expect(subject.children).to eq(example_child_elements)
38
- end
39
-
40
- it 'should know the names of all child placeholders' do
41
- example_child_elements.each { |child| subject.add_child(child) }
42
- expect(subject.variables).to eq([ 'content' ])
43
-
44
- parent = Section.new('added')
45
- [ subject,
46
- StaticText.new('Content '),
47
- Placeholder.new('tested'),
48
- EOLine.new
49
- ].each { |child| parent.add_child(child) }
50
- expect(parent.variables).to eq(%w(content tested))
51
- end
52
-
53
- it 'should expect that its subclasses generate the children elements' do
54
- msg = 'Method Section.output must be implemented in subclass.'
55
- expect { subject.send(:output, Object.new, {}) }.to raise_error(NotImplementedError, msg)
56
- end
57
- end
58
- end
59
-
60
- end
61
- end
@@ -1,65 +0,0 @@
1
- require_relative '../../spec_helper'
2
- require_relative '../../../lib/lucid/sequence/sequence_support'
3
-
4
- module Sequence
5
-
6
- class TestDomain
7
- include Sequence::SequenceSupport
8
-
9
- attr_reader :seq_steps
10
-
11
- def steps(generated_steps)
12
- @seq_steps ||= {}
13
- @seq_steps << generated_steps
14
- end
15
- end
16
-
17
- describe SequenceSupport do
18
- let(:domain) { TestDomain.new }
19
- let(:phrase) { 'enter credentials' }
20
-
21
- let(:example_steps) do
22
- example = <<-EXAMPLE
23
- Given the login page
24
- When the username is "<username>"
25
- And the password is "<password>"
26
- And login is clicked
27
- EXAMPLE
28
- end
29
-
30
- context 'defining a sequence' do
31
- it 'should add a valid new sequence phrase and associated steps' do
32
- expect { domain.add_sequence phrase, example_steps, true }.not_to raise_error
33
- end
34
-
35
- it 'should not add an existing sequence phrase' do
36
- msg = "A sequence with phrase 'enter credentials' already exists."
37
- expect { domain.add_sequence(phrase, example_steps, true) }.to raise_error(Sequence::DuplicateSequenceError, msg)
38
- end
39
-
40
- it 'should not allow a sequence to have steps with arguments and no way to use those arguments' do
41
- phrase = 'fill in the credentials'
42
- msg = "The step parameter 'username' does not appear in the phrase."
43
- expect { domain.add_sequence(phrase, example_steps, false) }.to raise_error(Sequence::UnreachableStepParameter, msg)
44
- end
45
- end
46
-
47
- context 'invoking a sequence' do
48
- it 'should not be able to invoke an unknown sequence phrase' do
49
- phrase = 'fill in the credentials'
50
- msg = "Unknown sequence step with phrase: 'fill in the credentials'."
51
- expect { domain.invoke_sequence(phrase) }.to raise_error(Sequence::UnknownSequenceError, msg)
52
- end
53
- end
54
-
55
- context 'clearing sequences' do
56
- it 'should clear all sequences from the sequence group' do
57
- expect { domain.clear_sequences() }.not_to raise_error
58
- expect(SequenceGroup.instance.sequence_steps).to be_empty
59
- end
60
-
61
- end
62
-
63
- end
64
-
65
- end
@@ -1,298 +0,0 @@
1
- require_relative '../../spec_helper'
2
- require_relative '../../../lib/lucid/sequence/sequence_template'
3
-
4
- module Sequence
5
- module SequenceTemplate
6
-
7
- describe Engine do
8
-
9
- let(:example_template) do
10
- example = <<-EXAMPLE
11
- Given the login page
12
- When the username is "<user_name>"
13
- And the password is "<password>"
14
- And login is clicked
15
- EXAMPLE
16
- end
17
-
18
- let(:conditional_template) do
19
- example = <<-EXAMPLE
20
- When the first name is "<first_name>"
21
- And the last name is "<last_name>"
22
- <?age>
23
- And the age is "<age>"
24
- </age>
25
- <?ssn>
26
- And the ssn is "<ssn>"
27
- </ssn>
28
- EXAMPLE
29
- end
30
-
31
- subject { Engine.new(example_template) }
32
-
33
- context 'parsing' do
34
- def strip_chevrons(text)
35
- text.gsub(/^<|>$/, '')
36
- end
37
-
38
- it 'should parse an empty text line' do
39
- expect(Engine.parse('')).to be_empty
40
- end
41
-
42
- it 'should parse a text line without a parameter' do
43
- sample_text = 'a TDL statement'
44
- result = Engine.parse(sample_text)
45
-
46
- expect(result).to have(1).items
47
- expect(result[0]).to eq([:static, sample_text])
48
- end
49
-
50
- it 'should parse a text line that consists of only a parameter' do
51
- sample_text = '<some_parameter>'
52
- result = Engine.parse(sample_text)
53
-
54
- expect(result).to have(1).items
55
- expect(result[0]).to eq([:dynamic, strip_chevrons(sample_text)])
56
- end
57
-
58
- it 'should parse a text line with a parameter at the start' do
59
- sample_text = '<some_parameter> in a TDL statement'
60
- result = Engine.parse(sample_text)
61
-
62
- expect(result).to have(2).items
63
- expect(result[0]).to eq([:dynamic, 'some_parameter'])
64
- expect(result[1]).to eq([:static, ' in a TDL statement'])
65
- end
66
-
67
- it 'should parse a text line with a parameter at the end' do
68
- sample_text = 'a TDL statement with <some_parameter>'
69
- result = Engine.parse(sample_text)
70
-
71
- expect(result).to have(2).items
72
- expect(result[0]).to eq([:static, 'a TDL statement with '])
73
- expect(result[1]).to eq([:dynamic, 'some_parameter'])
74
- end
75
-
76
- it 'should parse a text line with a parameter in the middle' do
77
- sample_text = 'a TDL statement with <some_parameter> in it'
78
- result = Engine.parse(sample_text)
79
-
80
- expect(result).to have(3).items
81
- expect(result[0]).to eq([:static, 'a TDL statement with '])
82
- expect(result[1]).to eq([:dynamic, 'some_parameter'])
83
- expect(result[2]).to eq([:static, ' in it'])
84
- end
85
-
86
- it 'should parse a text line with two separated parameters' do
87
- sample_text = 'TDL with <one_parameter> and with <another_parameter> in it'
88
- result = Engine.parse(sample_text)
89
-
90
- expect(result).to have(5).items
91
- expect(result[0]).to eq([:static , 'TDL with '])
92
- expect(result[1]).to eq([:dynamic, 'one_parameter'])
93
- expect(result[2]).to eq([:static , ' and with '])
94
- expect(result[3]).to eq([:dynamic, 'another_parameter'])
95
- expect(result[4]).to eq([:static, ' in it'])
96
- end
97
-
98
- it 'should parse a text line with two consecutive parameters' do
99
- sample_text = 'TDL with <one_parameter> <another_parameter> in it'
100
- result = Engine.parse(sample_text)
101
-
102
- expect(result).to have(5).items
103
- expect(result[0]).to eq([:static, 'TDL with '])
104
- expect(result[1]).to eq([:dynamic, 'one_parameter'])
105
- expect(result[2]).to eq([:static, ' '])
106
- expect(result[3]).to eq([:dynamic, 'another_parameter'])
107
- expect(result[4]).to eq([:static, ' in it'])
108
- end
109
-
110
- it 'should parse a text line with escaped chevrons' do
111
- sample_text = 'A TDL \<parameter\> is escaped'
112
- result = Engine.parse(sample_text)
113
-
114
- expect(result).to have(1).items
115
- expect(result[0]).to eq([:static, sample_text])
116
- end
117
-
118
- it 'should parse a text line with escaped chevrons in a parameter' do
119
- sample_text = 'A TDL with <some_\<\\>escaped\>_parameter> in it'
120
- result = Engine.parse(sample_text)
121
-
122
- expect(result).to have(3).items
123
- expect(result[0]).to eq([:static, 'A TDL with '])
124
- expect(result[1]).to eq([:dynamic, 'some_\<\\>escaped\>_parameter'])
125
- expect(result[2]).to eq([:static, ' in it'])
126
- end
127
-
128
- it 'should indicate if a parameter has a missing closing chevron' do
129
- sample_text = 'A TDL with <some_parameter that is malformed'
130
- error_message = "Missing closing chevron '>'."
131
- expect { Engine.parse(sample_text) }.to raise_error(StandardError, error_message)
132
- end
133
-
134
- it 'should indicate if a parameter has a missing opening chevron' do
135
- sample_text = 'A TDL with some_parameter> that is malformed'
136
- error_message = "Missing opening chevron '<'."
137
- expect { Engine.parse(sample_text) }.to raise_error(StandardError, error_message)
138
- end
139
-
140
- it 'should indicate if a text has nested opening chevrons' do
141
- sample_text = 'A TDL with <<some_parameter> > that is nested'
142
- error_message = "Nested opening chevron '<'."
143
- expect { Engine.parse(sample_text) }.to raise_error(StandardError, error_message)
144
- end
145
- end
146
-
147
- context 'creation of source template' do
148
- it 'should accept an empty template text' do
149
- expect { Engine.new '' }.not_to raise_error
150
- end
151
-
152
- it 'should be created with a template text' do
153
- expect { Engine.new example_template }.not_to raise_error
154
- end
155
-
156
- it 'should know the source text' do
157
- expect(subject.source).to eq(example_template)
158
- instance = Engine.new ''
159
- expect(instance.source).to be_empty
160
- end
161
-
162
- it 'should indicate when a placeholder is empty or blank' do
163
- text = example_template.sub(/user_name/, '')
164
- msg = %q(An empty or blank parameter occurred in 'When the username is "<>"'.)
165
- expect { Engine.new(text) }.to raise_error(Sequence::EmptyParameterError, msg)
166
- end
167
-
168
- it 'should indicate when a placeholder contains an invalid character' do
169
- text = example_template.sub(/user_name/, 'user%name')
170
- msg = "The invalid element '%' occurs in the parameter 'user%name'."
171
- expect { Engine.new(text)}.to raise_error(Sequence::InvalidElementError, msg)
172
- end
173
-
174
- it 'should accept conditional sections' do
175
- expect { Engine.new(conditional_template) }.not_to raise_error
176
- instance = Engine.new(conditional_template)
177
- elements = instance.instance_variable_get(:@generated_source)
178
- sections = elements.select { |e| e.is_a?(Section) }
179
- names = sections.map { |e| e.to_s }
180
- expect(names).to eq(%w(<?age> <?ssn>))
181
- end
182
-
183
- it 'should indicate when a section has no closing tag' do
184
- text = conditional_template.sub(/<\/age>/, '')
185
- msg = 'Unterminated section <?age>.'
186
- expect { Engine.new(text) }.to raise_error(StandardError, msg)
187
- end
188
-
189
- it 'should indicate when a closing tag has no corresponding opening tag' do
190
- text = conditional_template.sub(/<\/age>/, '</test>')
191
- msg = "End of section </test> does not match current section 'age'."
192
- expect { Engine.new(text) }.to raise_error(StandardError, msg)
193
- end
194
-
195
- it 'should indicate when a closing tag is found without opening tag' do
196
- text = conditional_template.sub(/<\?ssn>/, '</test>')
197
- msg = "End of section </test> found while no corresponding section is open."
198
- expect { Engine.new(text) }.to raise_error(StandardError, msg)
199
- end
200
- end
201
-
202
- context 'rendering a template' do
203
- it 'should know the parameters it contains' do
204
- expect(subject.variables).to be == ['user_name', 'password']
205
- instance = Engine.new ''
206
- expect(instance.variables).to be_empty
207
- end
208
-
209
- it 'should generate the text with the actual values for parameters' do
210
- locals = { 'user_name' => 'jnyman' }
211
- generated_text = subject.output(Object.new, locals)
212
- expected = <<-RESULT
213
- Given the login page
214
- When the username is "jnyman"
215
- And the password is ""
216
- And login is clicked
217
- RESULT
218
-
219
- expect(generated_text).to eq(expected)
220
- end
221
-
222
- it 'should generate the text with the actual non-string values for parameters' do
223
- locals = { 'user_name' => 'jnyman', 'password' => 12345 }
224
- generated_text = subject.output(Object.new, locals)
225
-
226
- expected = <<-RESULT
227
- Given the login page
228
- When the username is "jnyman"
229
- And the password is "12345"
230
- And login is clicked
231
- RESULT
232
-
233
- expect(generated_text).to eq(expected)
234
- end
235
-
236
- it 'should generate the text with the actual values in context' do
237
- ContextObject = Struct.new(:user_name, :password)
238
- context = ContextObject.new('superb', 'tester')
239
- generated_text = subject.output(context, { 'user_name' => 'jnyman' })
240
-
241
- expected = <<-RESULT
242
- Given the login page
243
- When the username is "jnyman"
244
- And the password is "tester"
245
- And login is clicked
246
- RESULT
247
-
248
- expect(generated_text).to eq(expected)
249
- end
250
-
251
- it 'should handle an empty source template' do
252
- instance = Engine.new('')
253
- expect(instance.output(nil, {})).to be_empty
254
- end
255
-
256
- it 'should generate conditional sections' do
257
- instance = Engine.new(conditional_template)
258
- locals = { 'first_name' => 'Jeff',
259
- 'last_name' => 'Nyman' ,
260
- 'age' => '41'
261
- }
262
- generated_text = instance.output(Object.new, locals)
263
- expected = <<-RESULT
264
- When the first name is "Jeff"
265
- And the last name is "Nyman"
266
- And the age is "41"
267
- RESULT
268
- expect(generated_text).to eq(expected)
269
-
270
- locals['age'] = nil
271
- locals['ssn'] = '000-00-0000'
272
- generated_text = instance.output(Object.new, locals)
273
-
274
- expected = <<-RESULT
275
- When the first name is "Jeff"
276
- And the last name is "Nyman"
277
- And the ssn is "000-00-0000"
278
- RESULT
279
- expect(generated_text).to eq(expected)
280
- end
281
-
282
- it 'should generate multi-valued actual text from parameters' do
283
- locals = { 'user_name' => %w(jnyman tester) }
284
- generated_text = subject.output(Object.new, locals)
285
- expected = <<-RESULT
286
- Given the login page
287
- When the username is "jnyman<br/>tester"
288
- And the password is ""
289
- And login is clicked
290
- RESULT
291
- expect(generated_text).to eq(expected)
292
- end
293
- end
294
-
295
- end
296
-
297
- end
298
- end