lucid 0.4.1 → 0.5.1

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 (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,48 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Lucid
4
- module AST
5
- describe Spec do
6
- let(:spec) { Spec.new }
7
-
8
- def parse_feature(gherkin)
9
- path = 'specs/test.spec'
10
- builder = Lucid::Parser::SpecBuilder.new(path)
11
- parser = Gherkin::Parser::Parser.new(builder, true, 'root', false)
12
- parser.parse(gherkin, path, 0)
13
- builder.language = parser.i18n_language
14
- feature = builder.result
15
- spec.add_feature(feature)
16
- end
17
-
18
- it 'has a step_count' do
19
- parse_feature(<<-GHERKIN)
20
- Feature:
21
- Background:
22
- Given step 1
23
- And step 2
24
-
25
- Scenario:
26
- Given step 3
27
- And step 4
28
- And step 5
29
-
30
- Scenario Outline:
31
- Given step <n>
32
- And another step
33
-
34
- Examples:
35
- | n |
36
- | 6 |
37
- | 7 |
38
-
39
- Examples:
40
- | n |
41
- | 8 |
42
- GHERKIN
43
-
44
- spec.step_count.should == (2 + 3) + (3 * (2 + 2))
45
- end
46
- end
47
- end
48
- end
@@ -1,45 +0,0 @@
1
- require 'spec_helper'
2
- require 'lucid/ast/step_invocation'
3
-
4
- module Lucid
5
- module AST
6
- describe StepInvocation do
7
- let(:step_invocation) do
8
- matched_cells = []
9
- StepInvocation.new(double, double, double, matched_cells)
10
- end
11
-
12
- describe 'filtering backtraces' do
13
- context 'when enabled' do
14
- before { Lucid.stub use_full_backtrace: false }
15
-
16
- it "removes lines with 'gems' in the path" do
17
- original_backtrace = ['/foo/bar/gems/baz', '/path/to/my/file.rb']
18
- exception = StandardError.new
19
- exception.set_backtrace(original_backtrace)
20
- result = step_invocation.filter_backtrace(exception).backtrace
21
- result.should == ['/path/to/my/file.rb']
22
- end
23
-
24
- it "removes lines with '.gem' in the path" do
25
- original_backtrace = ['/foo/bar/.gem/baz', '/path/to/my/file.rb']
26
- exception = StandardError.new
27
- exception.set_backtrace(original_backtrace)
28
- result = step_invocation.filter_backtrace(exception).backtrace
29
- result.should == ['/path/to/my/file.rb']
30
- end
31
- end
32
-
33
- context 'when disabled' do
34
- before { Lucid.stub use_full_backtrace: true }
35
-
36
- it 'return the exception unmodified' do
37
- exception = double
38
- step_invocation.filter_backtrace(exception).should == exception
39
- end
40
- end
41
- end
42
-
43
- end
44
- end
45
- end
@@ -1,72 +0,0 @@
1
- require 'spec_helper'
2
-
3
- require 'lucid/ast'
4
- require 'lucid/lang_extend'
5
-
6
- module Lucid
7
- module AST
8
-
9
- describe Step do
10
- let(:language) { double }
11
-
12
- it 'should replace arguments in name' do
13
- step = Step.new(language, 1, 'Given', 'a <status> test')
14
-
15
- invocation_table = Table.new([
16
- %w{status build},
17
- %w{passing failing}
18
- ])
19
-
20
- cells = invocation_table.cells_rows[1]
21
- step_invocation = step.step_invocation_from_cells(cells)
22
-
23
- step_invocation.name.should == 'a passing test'
24
- end
25
-
26
- it 'should use empty string for the replacement of arguments in name when replace value is nil' do
27
- step = Step.new(language, 1, 'Given', 'a <status> test')
28
-
29
- invocation_table = Table.new([
30
- %w(status),
31
- [nil]
32
- ])
33
-
34
- cells = invocation_table.cells_rows[1]
35
- step_invocation = step.step_invocation_from_cells(cells)
36
-
37
- step_invocation.name.should == 'a test'
38
- end
39
-
40
- it 'should replace arguments in provided table arguments' do
41
- arg_table = Table.new([%w{status_<status> type_<type>}])
42
- step = Step.new(language, 1, 'Given', 'a <status> test', arg_table)
43
-
44
- invocation_table = Table.new([
45
- %w{status type},
46
- %w{passing regression}
47
- ])
48
-
49
- cells = invocation_table.cells_rows[1]
50
- step_invocation = step.step_invocation_from_cells(cells)
51
-
52
- step_invocation.instance_variable_get('@multiline_arg').raw.should == [%w{status_passing type_regression}]
53
- end
54
-
55
- it 'should replace arguments in a doc string argument' do
56
- doc_string = DocString.new('status_<status> type_<type>', '')
57
- step = Step.new(language, 1, 'Given', 'a <status> test', doc_string)
58
-
59
- invocation_table = Table.new([
60
- %w{status type},
61
- %w{passing regression}
62
- ])
63
-
64
- cells = invocation_table.cells_rows[1]
65
- step_invocation = step.step_invocation_from_cells(cells)
66
-
67
- step_invocation.instance_variable_get('@multiline_arg').to_step_definition_arg.should == 'status_passing type_regression'
68
- end
69
-
70
- end
71
- end
72
- end
@@ -1,265 +0,0 @@
1
- require 'spec_helper'
2
- require 'lucid/ast/table'
3
-
4
- module Lucid
5
- module AST
6
-
7
- describe Table do
8
- before do
9
- @table = Table.new([
10
- %w{one four seven},
11
- %w{4444 55555 666666}
12
- ])
13
-
14
- def @table.cells_rows; super; end
15
- def @table.columns; super; end
16
- end
17
-
18
- it 'should have rows' do
19
- @table.cells_rows[0].map{|cell| cell.value}.should == %w{one four seven}
20
- end
21
-
22
- it 'should have columns' do
23
- @table.columns[1].map{|cell| cell.value}.should == %w{four 55555}
24
- end
25
-
26
- it 'should have headers' do
27
- @table.headers.should == %w{one four seven}
28
- end
29
-
30
- it 'should have same cell objects in rows and columns' do
31
- @table.cells_rows[1].__send__(:[], 2).should equal(@table.columns[2].__send__(:[], 1))
32
- end
33
-
34
- it 'should know about max width of a row' do
35
- @table.columns[1].__send__(:width).should == 5
36
- end
37
-
38
- it 'should be convertible to an array of hashes' do
39
- @table.hashes.should == [
40
- {'one' => '4444', 'four' => '55555', 'seven' => '666666'}
41
- ]
42
- end
43
-
44
- it 'should accept symbols as keys for the hashes' do
45
- @table.hashes.first[:one].should == '4444'
46
- end
47
-
48
- it 'should return the row values in order' do
49
- @table.rows.first.should == %w{4444 55555 666666}
50
- end
51
-
52
- describe '#map_column!' do
53
- it 'should allow mapping columns' do
54
- @table.map_column!('one') { |v| v.to_i }
55
- @table.hashes.first['one'].should == 4444
56
- end
57
-
58
- it 'applies the block once to each value' do
59
- headers = ['header']
60
- rows = ['value']
61
- table = Table.new [headers, rows]
62
- count = 0
63
- table.map_column!('header') { |value| count +=1 }
64
- table.rows
65
- count.should eq rows.size
66
- end
67
-
68
- it 'should allow mapping columns and take a symbol as the column name' do
69
- @table.map_column!(:one) { |v| v.to_i }
70
- @table.hashes.first['one'].should == 4444
71
- end
72
-
73
- it 'should allow mapping columns and modify the rows as well' do
74
- @table.map_column!(:one) { |v| v.to_i }
75
- @table.rows.first.should include(4444)
76
- @table.rows.first.should_not include('4444')
77
- end
78
-
79
- it 'should pass silently if a mapped column does not exist in non-strict mode' do
80
- lambda {
81
- @table.map_column!('two', false) { |v| v.to_i }
82
- @table.hashes
83
- }.should_not raise_error
84
- end
85
-
86
- it 'should fail if a mapped column does not exist in strict mode' do
87
- lambda {
88
- @table.map_column!('two', true) { |v| v.to_i }
89
- @table.hashes
90
- }.should raise_error('The column named "two" does not exist')
91
- end
92
-
93
- it 'should return the table' do
94
- (@table.map_column!(:one) { |v| v.to_i }).should == @table
95
- end
96
- end
97
-
98
- describe '#match' do
99
- before(:each) do
100
- @table = Table.new([
101
- %w{one four seven},
102
- %w{4444 55555 666666}
103
- ])
104
- end
105
-
106
- it 'returns nil if headers do not match' do
107
- @table.match('does,not,match').should be_nil
108
- end
109
-
110
- it 'requires a table: prefix on match' do
111
- @table.match('table:one,four,seven').should_not be_nil
112
- end
113
-
114
- it 'does not match if no table: prefix on match' do
115
- @table.match('one,four,seven').should be_nil
116
- end
117
- end
118
-
119
- describe '#transpose' do
120
- before(:each) do
121
- @table = Table.new([
122
- %w{one 1111},
123
- %w{two 22222}
124
- ])
125
- end
126
-
127
- it 'should be convertible in to an array where each row is a hash' do
128
- @table.transpose.hashes[0].should == {'one' => '1111', 'two' => '22222'}
129
- end
130
- end
131
-
132
- describe '#rows_hash' do
133
- it 'should return a hash of the rows' do
134
- table = Table.new([
135
- %w{one 1111},
136
- %w{two 22222}
137
- ])
138
-
139
- table.rows_hash.should == {'one' => '1111', 'two' => '22222'}
140
- end
141
-
142
- it 'should fail if the table does not have two columns' do
143
- faulty_table = Table.new([
144
- %w{one 1111 abc},
145
- %w{two 22222 def}
146
- ])
147
-
148
- lambda {
149
- faulty_table.rows_hash
150
- }.should raise_error('The table must have exactly 2 columns')
151
- end
152
-
153
- it 'should support header and column mapping' do
154
- table = Table.new([
155
- %w{one 1111},
156
- %w{two 22222}
157
- ])
158
-
159
- table.map_headers!({ 'two' => 'Two' }) { |header| header.upcase }
160
- table.map_column!('two', false) { |val| val.to_i }
161
- table.rows_hash.should == { 'ONE' => '1111', 'Two' => 22222 }
162
- end
163
- end
164
-
165
- describe '#map_headers!' do
166
- let(:table) do
167
- Table.new([
168
- %w{HELLO LUCID},
169
- %w{4444 55555}
170
- ])
171
- end
172
-
173
- it 'renames the columns to the specified values in the provided hash' do
174
- @table.map_headers!('one' => :three)
175
- @table.hashes.first[:three].should == '4444'
176
- end
177
-
178
- it 'allows renaming columns using regular expressions' do
179
- @table.map_headers!(/one|uno/ => :three)
180
- @table.hashes.first[:three].should == '4444'
181
- end
182
-
183
- it 'copies column mappings' do
184
- @table.map_column!('one') { |v| v.to_i }
185
- @table.map_headers!('one' => 'three')
186
- @table.hashes.first['three'].should == 4444
187
- end
188
-
189
- it 'takes a block and operates on all the headers with it' do
190
- table.map_headers! do |header|
191
- header.downcase
192
- end
193
- table.hashes.first.keys.should =~ %w[hello lucid]
194
- end
195
-
196
- it 'treats the mappings in the provided hash as overrides when used with a block' do
197
- table.map_headers!('LUCID' => 'test') do |header|
198
- header.downcase
199
- end
200
- table.hashes.first.keys.should =~ %w[hello test]
201
- end
202
- end
203
-
204
- describe 'replacing arguments' do
205
- before(:each) do
206
- @table = Table.new([
207
- %w{showings movie},
208
- %w{<showings> <movie>}
209
- ])
210
- end
211
-
212
- it 'should return a new table with arguments replaced with values' do
213
- table_with_replaced_args = @table.arguments_replaced({'<movie>' => 'Gravity', '<showings>' => '5'})
214
- table_with_replaced_args.hashes[0]['movie'].should == 'Gravity'
215
- table_with_replaced_args.hashes[0]['showings'].should == '5'
216
- end
217
-
218
- it 'should recognise when entire cell is delimited' do
219
- @table.should have_text('<movie>')
220
- end
221
-
222
- it 'should recognise when just a subset of a cell is delimited' do
223
- table = Table.new([
224
- %w{showings movie},
225
- [nil, "Seeing <director>'s movie"]
226
- ])
227
-
228
- table.should have_text('<director>')
229
- end
230
-
231
- it 'should replace nil values with nil' do
232
- table_with_replaced_args = @table.arguments_replaced({'<movie>' => nil})
233
- table_with_replaced_args.hashes[0]['movie'].should == nil
234
- end
235
-
236
- it 'should preserve values which do not match a placeholder when replacing with nil' do
237
- table = Table.new([
238
- %w{movie},
239
- %w{screenplay}
240
- ])
241
- table_with_replaced_args = table.arguments_replaced({'<movie>' => nil})
242
- table_with_replaced_args.hashes[0]['movie'].should == 'screenplay'
243
- end
244
-
245
- it 'should not change the original table' do
246
- @table.arguments_replaced({'<movie>' => 'Gravity'})
247
- @table.hashes[0]['movie'].should_not == 'Gravity'
248
- end
249
-
250
- it 'should not raise an error when there are nil values in the table' do
251
- table = Table.new([
252
- ['movie', 'showings'],
253
- ['<movie', nil]
254
- ])
255
-
256
- lambda {
257
- table.arguments_replaced({'<movie>' => nil, '<showings>' => '5'})
258
- }.should_not raise_error
259
- end
260
- end
261
-
262
- end
263
-
264
- end
265
- end
@@ -1,78 +0,0 @@
1
- require 'lucid/ast'
2
-
3
- module Lucid
4
- module AST
5
- module TDLFactory
6
-
7
- class TestDomain
8
-
9
- end
10
-
11
- def create_feature(dsl)
12
- dsl.Given (/^a (.*) step with an inline argument:$/) do |action, table|
13
- end
14
-
15
- dsl.Given (/^a (.*) step$/) do |action|
16
- end
17
-
18
- dsl.Domain do
19
- TestDomain.new
20
- end
21
-
22
- table = AST::Table.new([
23
- %w{1 22 333},
24
- %w{4444 55555 666666}
25
- ])
26
-
27
- doc_string = AST::DocString.new(%{\n Testing with\nLucid tools\n}, '')
28
- location = AST::Location.new('test.spec', 2)
29
- language = double.as_null_object
30
-
31
- background = AST::Background.new(
32
- language,
33
- location,
34
- AST::Comment.new(''),
35
- 'Background:',
36
- '',
37
- '',
38
- [
39
- Step.new(language, location.on_line(3), 'Given', 'a passing step')
40
- ]
41
- )
42
-
43
- if Lucid::WINDOWS
44
- location = Location.new('specs\\test.spec', 0)
45
- else
46
- location = Location.new('specs/test.spec', 0)
47
- end
48
-
49
- AST::Feature.new(
50
- location,
51
- background,
52
- AST::Comment.new("# Feature Comment Line\n"),
53
- AST::Tags.new(6, [Gherkin::Formatter::Model::Tag.new('smoke', 6),
54
- Gherkin::Formatter::Model::Tag.new('critical', 6)]),
55
- 'Feature',
56
- 'Testing TDL',
57
- '',
58
- [AST::Scenario.new(
59
- language,
60
- location.on_line(9),
61
- background,
62
- AST::Comment.new(" # Scenario Comment Line 1 \n# Scenario Comment Line 2 \n"),
63
- AST::Tags.new(8, [Gherkin::Formatter::Model::Tag.new('regression', 8),
64
- Gherkin::Formatter::Model::Tag.new('selenium', 8)]),
65
- AST::Tags.new(1, []),
66
- 'Scenario:', 'Test Scenario', '',
67
- [
68
- Step.new(language, location.on_line(10), 'Given', 'a passing step with an inline argument:', table),
69
- Step.new(language, location.on_line(11), 'Given', 'a working step with an inline argument:', doc_string),
70
- Step.new(language, location.on_line(12), 'Given', 'a non-passing step')
71
- ]
72
- )]
73
- )
74
- end
75
-
76
- end
77
- end
78
- end