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,346 +0,0 @@
1
- require 'spec_helper'
2
- require 'lucid/cli/options'
3
-
4
- module Lucid
5
- module CLI
6
- describe Options do
7
-
8
- before(:each) do
9
- Kernel.stub(:exit).and_return(nil)
10
- end
11
-
12
- def output_stream
13
- @output_stream ||= StringIO.new
14
- end
15
-
16
- def error_stream
17
- @error_stream ||= StringIO.new
18
- end
19
-
20
- def options
21
- @options ||= Options.new(output_stream, error_stream)
22
- end
23
-
24
- def prep_args(args)
25
- args.is_a?(Array) ? args : args.split(' ')
26
- end
27
-
28
- def with_this_configuration(info)
29
- Dir.stub(:glob).with('{,.config/,config/}lucid{.yml,.yaml}').and_return(['lucid.yml'])
30
- File.stub(:exist?).and_return(true)
31
- lucid_yml = info.is_a?(Hash) ? info.to_yaml : info
32
- IO.stub(:read).with('lucid.yml').and_return(lucid_yml)
33
- end
34
-
35
- describe 'parsing options' do
36
-
37
- def during_parsing(command)
38
- yield
39
- options.parse(prep_args(command))
40
- end
41
-
42
- def after_parsing(command)
43
- options.parse(prep_args(command))
44
- yield
45
- end
46
-
47
- context '--version' do
48
- it 'should display Lucid version' do
49
- after_parsing('--version') do
50
- output_stream.string.should =~ /#{Lucid::VERSION}/
51
- end
52
- end
53
-
54
- it 'should exit from any Lucid execution' do
55
- during_parsing('--version') { Kernel.should_receive(:exit) }
56
- end
57
- end
58
-
59
- context 'environment variables' do
60
- it 'should put all environment variables into a hash' do
61
- after_parsing('MODE=symbiont AUTOSPEC=true') do
62
- options[:env_vars].should == {'MODE' => 'symbiont', 'AUTOSPEC' => 'true'}
63
- end
64
- end
65
- end
66
-
67
- context '--i18n' do
68
- context "with LANG specified as 'help'" do
69
- it 'lists all known languages' do
70
- during_parsing '--i18n help' do
71
- Kernel.should_receive(:exit)
72
- end
73
- end
74
-
75
- it 'exits the program' do
76
- during_parsing('--i18n help') { Kernel.should_receive(:exit) }
77
- end
78
- end
79
- end
80
-
81
- context '-r or --require' do
82
- it 'should collect all specified files into an array' do
83
- after_parsing('--require file_a.rb -r file_b.rb') do
84
- options[:require].should == ['file_a.rb', 'file_b.rb']
85
- end
86
- end
87
- end
88
-
89
- context '-n NAME or --name NAME' do
90
- it 'should store provided scenario names as regular expressions' do
91
- after_parsing('-n sc1 --name sc2') { options[:name_regexps].should == [/sc1/,/sc2/] }
92
- end
93
- end
94
-
95
- context '-l LINES or --lines LINES' do
96
- it 'should add line numbers to spec files' do
97
- options.parse(%w{-l 42 FILE})
98
- options.instance_variable_get(:@args).should == ['FILE:42']
99
- end
100
- end
101
-
102
- context '-e PATTERN or --exclude PATTERN' do
103
- it 'should stored provided exclusions as regular expressions' do
104
- after_parsing('-e file1 --exclude file2') { options[:excludes].should == [/file1/,/file2/] }
105
- end
106
- end
107
-
108
- context '-b or --backtrace' do
109
- it 'should use a full backtrace during Lucid execution' do
110
- during_parsing('-b') do
111
- Lucid.should_receive(:use_full_backtrace=).with(true)
112
- end
113
- end
114
- end
115
-
116
- context '-t TAGS --tags TAGS' do
117
- it 'should store tags passed with different --tags options separately' do
118
- after_parsing('--tags @smoke --tags @wip') { options[:tag_expressions].should == ['@smoke', '@wip'] }
119
- end
120
-
121
- it 'should designate tags prefixed with ~ as tags to be excluded' do
122
- after_parsing('--tags ~@smoke,@wip') { options[:tag_expressions].should == ['~@smoke,@wip'] }
123
- end
124
- end
125
-
126
- context '-f FORMAT or --format FORMAT' do
127
- it 'should default to using the standard output stream (STDOUT) formatter' do
128
- after_parsing('-f standard') { options[:formats].should == [['standard', output_stream]] }
129
- end
130
- end
131
-
132
- context '-o [FILE|DIR] or --out [FILE|DIR]' do
133
- it 'should default to the standard formatter when not specified' do
134
- after_parsing('-o file.txt') { options[:formats].should == [['standard', 'file.txt']] }
135
- end
136
-
137
- it 'should set the output for the formatter defined for each option' do
138
- after_parsing('-f profile --out file.txt -f standard -o file2.txt') do
139
- options[:formats].should == [['profile', 'file.txt'], ['standard', 'file2.txt']]
140
- end
141
- end
142
- end
143
-
144
- context '-P or --no-profile' do
145
- it 'disables profiles' do
146
- with_this_configuration({'default' => '-v --require code_file.rb'})
147
-
148
- after_parsing('-P --require other_code_file.rb') do
149
- options[:require].should == ['other_code_file.rb']
150
- end
151
- end
152
-
153
- it 'notifies the user that the profiles are being disabled' do
154
- with_this_configuration({'default' => '-v'})
155
-
156
- after_parsing('--no-profile --require other_code_file.rb') do
157
- output_stream.string.should =~ /Disabling profiles.../
158
- end
159
- end
160
- end
161
-
162
- context '-p PROFILE or --profile PROFILE' do
163
- it 'respects --quiet when defined in the profile' do
164
- with_this_configuration('test' => '-q')
165
-
166
- options.parse(%w[-p test])
167
- options[:matchers].should be_false
168
- options[:source].should be_false
169
- end
170
-
171
- it 'uses the default profile passed in during initialization if none is specified by the user' do
172
- with_this_configuration({'default' => '--require test_helper'})
173
-
174
- options = Options.new(output_stream, error_stream, :default_profile => 'default')
175
- options.parse(%w{--format progress})
176
- options[:require].should include('test_helper')
177
- end
178
-
179
- it 'merges all unique values from both the command line and the profile' do
180
- with_this_configuration('test' => %w[--verbose])
181
-
182
- options.parse(%w[--wip --profile test])
183
- options[:wip].should be_true
184
- options[:verbose].should be_true
185
- end
186
-
187
- it 'gives precedence to the original options spec source path' do
188
- with_this_configuration('test' => %w[specs])
189
-
190
- options.parse(%w[test.spec -p test])
191
- options[:spec_source].should == %w[test.spec]
192
- end
193
-
194
- it 'combines the require files of both' do
195
- with_this_configuration('bar' => %w[--require specs -r helper.rb])
196
-
197
- options.parse(%w[--require test.rb -p bar])
198
- options[:require].should == %w[test.rb specs helper.rb]
199
- end
200
-
201
- it 'combines the tag names of both' do
202
- with_this_configuration('test' => %w[-t @smoke])
203
-
204
- options.parse(%w[--tags @wip -p test])
205
- options[:tag_expressions].should == ['@wip', '@smoke']
206
- end
207
-
208
- it 'only takes the paths from the original options, and disregards the profiles' do
209
- with_this_configuration('test' => %w[specs])
210
-
211
- options.parse(%w[test.spec -p test])
212
- options[:spec_source].should == ['test.spec']
213
- end
214
-
215
- it 'uses the paths from the profile when none are specified originally' do
216
- with_this_configuration('test' => %w[test.spec])
217
-
218
- options.parse(%w[-p test])
219
- options[:spec_source].should == ['test.spec']
220
- end
221
-
222
- it 'combines environment variables from the profile but gives precedence to command line args' do
223
- with_this_configuration('test' => %w[BROWSER=firefox DRIVER=mechanize])
224
-
225
- options.parse(%w[-p test DRIVER=watir CI=jenkins])
226
- options[:env_vars].should == {'CI' => 'jenkins', 'BROWSER' => 'firefox', 'DRIVER' => 'watir'}
227
- end
228
-
229
- it 'disregards STDOUT formatter defined in profile when another is passed in via command line' do
230
- with_this_configuration({'test' => %w[--format standard]})
231
-
232
- options.parse(%w{--format progress --profile test})
233
- options[:formats].should == [['progress', output_stream]]
234
- end
235
-
236
- it 'includes any non-STDOUT formatters from the profile' do
237
- with_this_configuration({'report' => %w[--format html -o results.html]})
238
-
239
- options.parse(%w{--format progress --profile report})
240
- options[:formats].should == [['progress', output_stream], ['html', 'results.html']]
241
- end
242
-
243
- it 'does not include STDOUT formatters from the profile if there is a STDOUT formatter in command line' do
244
- with_this_configuration({'report' => %w[--format html -o results.html --format standard]})
245
-
246
- options.parse(%w{--format progress --profile report})
247
- options[:formats].should == [['progress', output_stream], ['html', 'results.html']]
248
- end
249
-
250
- it 'includes any STDOUT formatters from the profile if no STDOUT formatter was specified in command line' do
251
- with_this_configuration({'report' => %w[--format html]})
252
-
253
- options.parse(%w{--format rerun -o rerun.txt --profile report})
254
- options[:formats].should == [['html', output_stream], ['rerun', 'rerun.txt']]
255
- end
256
-
257
- it 'assumes all of the formatters defined in the profile when none are specified on command line' do
258
- with_this_configuration({'report' => %w[--format progress --format html -o results.html]})
259
-
260
- options.parse(%w{--profile report})
261
- options[:formats].should == [['progress', output_stream], ['html', 'results.html']]
262
- end
263
-
264
- it 'only reads lucid.yml once' do
265
- original_parse_count = $lucid_yml_read_count
266
- $lucid_yml_read_count = 0
267
-
268
- begin
269
- with_this_configuration(<<-END
270
- <% $lucid_yml_read_count += 1 %>
271
- default: --format standard
272
- END
273
- )
274
- options = Options.new(output_stream, error_stream, :default_profile => 'default')
275
- options.parse(%w(-f progress))
276
-
277
- $lucid_yml_read_count.should == 1
278
- ensure
279
- $lucid_yml_read_count = original_parse_count
280
- end
281
- end
282
- end
283
-
284
- context '-P or --no-profile' do
285
- it 'disables profiles' do
286
- with_this_configuration({'default' => '-v --require file_specified_in_default_profile.rb'})
287
-
288
- after_parsing('-P --require test_helper.rb') do
289
- options[:require].should == ['test_helper.rb']
290
- end
291
- end
292
-
293
- it 'notifies the user that the profiles are being disabled' do
294
- with_this_configuration({'default' => '-v'})
295
-
296
- after_parsing('--no-profile --require test_helper.rb') do
297
- output_stream.string.should =~ /Disabling profiles.../
298
- end
299
- end
300
- end
301
-
302
- context '--matcher-type' do
303
- it 'parses the matcher type argument' do
304
- after_parsing('--matcher-type classic') do
305
- options[:matcher_type].should eql :classic
306
- end
307
- end
308
- end
309
-
310
- it 'assigns any extra arguments as paths to specs' do
311
- after_parsing('-f pretty test.spec other_specs') do
312
- options[:spec_source].should == ['test.spec', 'other_specs']
313
- end
314
- end
315
-
316
- it 'does not mistake environment variables as spec paths' do
317
- after_parsing('test.spec ENV=ci') do
318
- options[:spec_source].should == ['test.spec']
319
- end
320
- end
321
-
322
- describe 'dry-run' do
323
- it 'should have the default value for matchers' do
324
- with_this_configuration({'test' => %w[--dry-run]})
325
- options.parse(%w{--dry-run})
326
- options[:matchers].should == true
327
- end
328
-
329
- it 'should set matchers to false when no-matchers is provided after dry-run' do
330
- with_this_configuration({'test' => %w[--dry-run --no-snippets]})
331
- options.parse(%w{--dry-run --no-matchers})
332
- options[:matchers].should == false
333
- end
334
-
335
- it 'should set matchers to false when no-matchers is provided before dry-run' do
336
- with_this_configuration({'test' => %w[--no-snippet --dry-run]})
337
- options.parse(%w{--no-matchers --dry-run})
338
- options[:matchers].should == false
339
- end
340
- end
341
-
342
- end
343
-
344
- end
345
- end
346
- end
@@ -1,117 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Lucid
4
- describe ContextLoader::Orchestrator do
5
- let(:options) { {} }
6
- let(:interface) { double('interface') }
7
- subject { ContextLoader::Orchestrator.new(interface, options) }
8
-
9
- let(:dsl) do
10
- @rb = subject.load_code_language('rb')
11
- Object.new.extend(InterfaceRb::RbLucid)
12
- end
13
-
14
- it 'should format step names' do
15
- dsl.Given(/it (.*) in (.*)/) { |what, month| }
16
- dsl.Given(/some other phrase/) { |what, month| }
17
-
18
- format = subject.step_match('it works in lucid').format_args('[%s]')
19
- format.should == 'it [works] in [lucid]'
20
- end
21
-
22
- it 'should cache step match results' do
23
- dsl.Given(/it (.*) in (.*)/) { |what, month| }
24
- step_match = subject.step_match('it works in lucid')
25
- @rb.should_not_receive :step_matches
26
- second_step_match = subject.step_match('it works in lucid')
27
- step_match.should equal(second_step_match)
28
- end
29
-
30
-
31
- describe 'resolving test definition matches' do
32
- it 'should raise Undefined error when no test definitions match' do
33
- lambda do
34
- subject.step_match('Simple Lucid Test')
35
- end.should raise_error(Undefined)
36
- end
37
-
38
- it 'should raise Ambiguous error with guess hint when multiple test definitions match' do
39
- expected_error = %{Ambiguous match of "Simple Lucid Test":
40
-
41
- spec/lucid/orchestrator_spec.rb:\\d+:in `/Simple (.*) Test/'
42
- spec/lucid/orchestrator_spec.rb:\\d+:in `/Simple Lucid (.*)/'
43
-
44
- You can run again with --guess to make Lucid be a little more smart about it.
45
- }
46
- dsl.Given(/Simple (.*) Test/) {|app|}
47
- dsl.Given(/Simple Lucid (.*)/) {|action|}
48
-
49
- lambda do
50
- subject.step_match("Simple Lucid Test")
51
- end.should raise_error(Ambiguous, /#{expected_error}/)
52
- end
53
-
54
- describe 'when --guess is used' do
55
- let(:options) { {:guess => true} }
56
-
57
- it 'should not show --guess hint' do
58
- expected_error = %{Ambiguous match of "Simple lucid test":
59
-
60
- spec/lucid/orchestrator_spec.rb:\\d+:in `/Simple (.*)/'
61
- spec/lucid/orchestrator_spec.rb:\\d+:in `/Simple (.*)/'
62
-
63
- }
64
- dsl.Given(/Simple (.*)/) {|phrase|}
65
- dsl.Given(/Simple (.*)/) {|phrase|}
66
-
67
- lambda do
68
- subject.step_match('Simple lucid test')
69
- end.should raise_error(Ambiguous, /#{expected_error}/)
70
- end
71
-
72
- it 'should pick right test definition when an equal number of capture groups' do
73
- right = dsl.Given(/Simple (.*) test/) {|app|}
74
- wrong = dsl.Given(/Simple (.*)/) {|phrase|}
75
-
76
- subject.step_match('Simple lucid test').step_definition.should == right
77
- end
78
-
79
- it 'should pick right test definition when an unequal number of capture groups' do
80
- right = dsl.Given(/Simple (.*) test ran (.*)/) {|app|}
81
- wrong = dsl.Given(/Simple (.*)/) {|phrase|}
82
-
83
- subject.step_match('Simple lucid test ran well').step_definition.should == right
84
- end
85
-
86
- it 'should pick most specific test definition when an unequal number of capture groups' do
87
- general = dsl.Given(/Simple (.*) test ran (.*)/) {|app|}
88
- specific = dsl.Given(/Simple lucid test ran well/) do; end
89
- more_specific = dsl.Given(/^Simple lucid test ran well$/) do; end
90
-
91
- subject.step_match('Simple lucid test ran well').step_definition.should == more_specific
92
- end
93
-
94
- it 'should not raise Ambiguous error when multiple test definitions match' do
95
- dsl.Given(/Simple (.*) test/) {|app|}
96
- dsl.Given(/Simple (.*)/) {|phrase|}
97
-
98
- lambda do
99
- subject.step_match('Simple lucid test')
100
- end.should_not raise_error
101
- end
102
-
103
- it 'should not raise NoMethodError when guessing from multiple test definitions with nil fields' do
104
- dsl.Given(/Simple (.*) test( cannot run well)?/) {|app, status|}
105
- dsl.Given(/Simple (.*)?/) {|phrase|}
106
-
107
- lambda do
108
- subject.step_match('Simple lucid test')
109
- end.should_not raise_error
110
- end
111
-
112
- end
113
-
114
- end
115
-
116
- end
117
- end