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,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Lucid::AST
4
-
5
- describe Walker do
6
- let(:tdl_walker) do
7
- Walker.new(nil, [double('listener', :before_visit_features => nil)])
8
- end
9
- let(:features) { double('features', :accept => nil) }
10
-
11
- it 'should visit features' do
12
- tdl_walker.should_not_receive(:warn)
13
- tdl_walker.visit_features(features)
14
- end
15
-
16
- it 'should return self' do
17
- tdl_walker.visit_features(features).should == tdl_walker
18
- end
19
- end
20
-
21
- end
@@ -1,328 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Lucid
4
- describe Context do
5
- describe '.default' do
6
- subject { Context.default }
7
-
8
- it 'has an autoload_code_paths containing default Lucid folders' do
9
- subject.autoload_code_paths.should include 'common'
10
- subject.autoload_code_paths.should include 'steps'
11
- subject.autoload_code_paths.should include 'pages'
12
- end
13
- end
14
-
15
- describe 'supports custom user options' do
16
- let(:user_options) { { :autoload_code_paths => ['library/common'] } }
17
- subject { Context.new(user_options) }
18
-
19
- it 'should allow the defaults to be overridden' do
20
- subject.autoload_code_paths.should == ['library/common']
21
- end
22
- end
23
- end
24
-
25
- module CLI
26
- describe Context do
27
-
28
- attr_reader :out, :error
29
-
30
- module ExposeOptions
31
- attr_reader :options
32
- end
33
-
34
- def config
35
- @config ||= Context.new(@out = StringIO.new, @error = StringIO.new).extend(ExposeOptions)
36
- end
37
-
38
- def with_these_files(*files)
39
- File.stub(:directory?).and_return(true)
40
- File.stub(:file?).and_return(true)
41
- Dir.stub(:[]).and_return(files)
42
- end
43
-
44
- def with_this_configuration(info)
45
- Dir.stub(:glob).with('{,.config/,config/}lucid{.yml,.yaml}').and_return(['lucid.yml'])
46
- File.stub(:exist?).and_return(true)
47
- profile_file = info.is_a?(Hash) ? info.to_yaml : info
48
- IO.stub(:read).with('lucid.yml').and_return(profile_file)
49
- end
50
-
51
- it 'should require driver.rb files first' do
52
- with_these_files('/common/support/browser.rb', '/common/support/driver.rb')
53
- config.parse_options(%w{--require /common})
54
-
55
- config.library_context.should == %w(
56
- /common/support/driver.rb
57
- /common/support/browser.rb
58
- )
59
- end
60
-
61
- it 'should not require driver.rb files when a dry run is attempted' do
62
- with_these_files('/common/support/browser.rb', '/common/support/driver.rb')
63
- config.parse_options(%w{--require /common --dry-run})
64
-
65
- config.library_context.should == %w(
66
- /common/support/browser.rb
67
- )
68
- end
69
-
70
- it 'should require files in default definition locations' do
71
- with_these_files('/pages/page.rb', '/steps/steps.rb')
72
- config.parse_options(%w{--require /specs})
73
-
74
- config.definition_context.should == %w(
75
- /pages/page.rb
76
- /steps/steps.rb
77
- )
78
- end
79
-
80
- it 'should default to a specs directory when no information is provided' do
81
- File.stub(:directory?).and_return(true)
82
- Dir.stub(:[]).with('specs/**/*.spec').and_return(['lucid.spec'])
83
- Dir.stub(:[]).with('specs/**/*.feature').and_return(['lucid.spec'])
84
- Dir.stub(:[]).with('specs/**/*.story').and_return(['lucid.spec'])
85
- config.parse_options(%w{})
86
- config.spec_context.should == ['lucid.spec']
87
- end
88
-
89
- it 'should search for all specs in the specified directory' do
90
- File.stub(:directory?).and_return(true)
91
- Dir.stub(:[]).with('specs/**/*.spec').and_return(['lucid.spec'])
92
- Dir.stub(:[]).with('specs/**/*.feature').and_return(['lucid.spec'])
93
- Dir.stub(:[]).with('specs/**/*.story').and_return(['lucid.spec'])
94
- config.parse_options(%w{specs/})
95
- config.spec_context.should == ['lucid.spec']
96
- end
97
-
98
- it 'should return the correct spec file type for feature file' do
99
- File.stub(:directory?).and_return(true)
100
- Dir.stub(:[]).with('specs/**/*.spec').and_return(['lucid.feature'])
101
- Dir.stub(:[]).with('specs/**/*.feature').and_return(['lucid.feature'])
102
- Dir.stub(:[]).with('specs/**/*.story').and_return(['lucid.feature'])
103
- config.parse_options(%w{specs/})
104
- config.spec_context.should == ['lucid.feature']
105
- end
106
-
107
- it 'should return the correct spec file type for story file' do
108
- File.stub(:directory?).and_return(true)
109
- Dir.stub(:[]).with('specs/**/*.spec').and_return(['lucid.story'])
110
- Dir.stub(:[]).with('specs/**/*.feature').and_return(['lucid.story'])
111
- Dir.stub(:[]).with('specs/**/*.story').and_return(['lucid.story'])
112
- config.parse_options(%w{specs/})
113
- config.spec_context.should == ['lucid.story']
114
- end
115
-
116
- it 'should preserve the order of the spec files' do
117
- config.parse_options(%w{test_b.spec test_c.spec test_a.spec})
118
- config.spec_context.should == %w[test_b.spec test_c.spec test_a.spec]
119
- end
120
-
121
- it 'should be able to exclude files based on a specific reference' do
122
- with_these_files('/common/support/browser.rb', '/common/support/driver.rb')
123
- config.parse_options(%w{--require /common --exclude browser.rb})
124
-
125
- config.spec_requires.should == %w(
126
- /common/support/driver.rb
127
- )
128
- end
129
-
130
- it 'should be able to exclude files based on a general pattern' do
131
- with_these_files('/steps/tester.rb', '/steps/tested.rb', '/steps/testing.rb', '/steps/quality.rb')
132
- config.parse_options(%w{--require /steps --exclude test(er|ed) --exclude quality})
133
-
134
- config.spec_requires.should == %w(
135
- /steps/testing.rb
136
- )
137
- end
138
-
139
- it 'should allow specifying environment variables on the command line' do
140
- config.parse_options(['test=this'])
141
- ENV['test'].should == 'this'
142
- config.spec_context.should_not include('test=this')
143
- end
144
-
145
- it 'should be able to use a --dry-run option' do
146
- config.parse_options(%w{--dry-run})
147
- config.options[:dry_run].should be_true
148
- end
149
-
150
- it 'should be able to use a --no-source option' do
151
- config.parse_options(%w{--no-source})
152
- config.options[:source].should be_false
153
- end
154
-
155
- it 'should be able to use a --no-matchers option' do
156
- config.parse_options(%w{--no-matchers})
157
- config.options[:matchers].should be_false
158
- end
159
-
160
- it 'should be able to use a --quiet option' do
161
- config.parse_options(%w{--quiet})
162
- config.options[:source].should be_false
163
- config.options[:matchers].should be_false
164
- end
165
-
166
- it 'should be able to use a --verbose option' do
167
- config.parse_options(%w{--verbose})
168
- config.options[:verbose].should be_true
169
- end
170
-
171
- it 'uses the default profile when no profile is defined' do
172
- with_this_configuration({'default' => '--require test_file'})
173
- config.parse_options(%w{--format progress})
174
- config.options[:require].should include('test_file')
175
- end
176
-
177
- describe 'generating output' do
178
-
179
- it 'should be able to use an --out option' do
180
- config.parse_options(%w{--out report.txt})
181
- config.formats.should == [%w(standard report.txt)]
182
- end
183
-
184
- it 'should be able to use multiple --out options' do
185
- config.parse_options(%w{--format standard --out report1.txt --out report2.txt})
186
- config.formats.should == [%w(standard report2.txt)]
187
- end
188
-
189
- end
190
-
191
- it 'should be able to use a --color option' do
192
- Lucid::Term::ANSIColor.should_receive(:coloring=).with(true)
193
- config.parse_options(['--color'])
194
- end
195
-
196
- it 'should accept --no-color option' do
197
- Lucid::Term::ANSIColor.should_receive(:coloring=).with(false)
198
- config = Context.new(StringIO.new)
199
- config.parse_options(['--no-color'])
200
- end
201
-
202
- it 'should accept multiple --format options and put the STDOUT one first so progress is seen' do
203
- config.parse_options(%w{--format standard --out output.txt --format progress})
204
- config.formats.should == [['progress', out], ['standard', 'output.txt']]
205
- end
206
-
207
- it 'should not accept multiple --format options when both use implicit STDOUT' do
208
- lambda do
209
- config.parse_options(%w{--format pretty --format progress})
210
- end.should raise_error('All but one formatter must use --out, only one can print to each stream (or STDOUT)')
211
- end
212
-
213
- it 'should accept same --format options with implicit STDOUT, and keep only one' do
214
- config.parse_options(%w{--format standard --format standard})
215
- config.formats.should == [['standard', out]]
216
- end
217
-
218
- it 'should not accept multiple --out streams pointing to the same place' do
219
- lambda do
220
- config.parse_options(%w{--format standard --out file1 --format progress --out file1})
221
- end.should raise_error('All but one formatter must use --out, only one can print to each stream (or STDOUT)')
222
- end
223
-
224
- it 'should associate --out to previous --format' do
225
- config.parse_options(%w{--format progress --out file1 --format profile --out file2})
226
- config.formats.should == [['progress', 'file1'], ['profile', 'file2']]
227
- end
228
-
229
- it 'should accept same --format options with same --out streams and keep only one' do
230
- config.parse_options(%w{--format html --out file --format standard --format html --out file})
231
- config.formats.should == [['standard', out], ['html', 'file']]
232
- end
233
-
234
- it 'should accept same --format options with different --out streams' do
235
- config.parse_options(%w{--format html --out file1 --format html --out file2})
236
- config.formats.should == [['html', 'file1'], ['html', 'file2']]
237
- end
238
-
239
- it 'should accept multiple --name options' do
240
- config.parse_options(['--name', 'User logs in', '--name', 'User signs up'])
241
-
242
- config.options[:name_regexps].should include(/User logs in/)
243
- config.options[:name_regexps].should include(/User signs up/)
244
- end
245
-
246
- it 'should accept multiple -n options' do
247
- config.parse_options(['-n', 'User logs in', '-n', 'User signs up'])
248
-
249
- config.options[:name_regexps].should include(/User logs in/)
250
- config.options[:name_regexps].should include(/User signs up/)
251
- end
252
-
253
- it 'should allow specifying environment variables in profiles' do
254
- with_this_configuration({'selenium' => 'DRIVER=selenium'})
255
- config.parse_options(['--profile', 'selenium'])
256
- ENV['DRIVER'].should == 'selenium'
257
- config.spec_context.should_not include('DRIVER=selenium')
258
- end
259
-
260
- describe 'Dry run execution' do
261
- it 'returns true when --dry-run was specified on in the arguments' do
262
- config.parse_options(['--dry-run'])
263
- config.dry_run?.should be_true
264
- end
265
-
266
- it 'returns true when --dry-run was specified in a profile' do
267
- with_this_configuration({'default' => '--dry-run'})
268
- config.parse_options([])
269
- config.dry_run?.should be_true
270
- end
271
-
272
- it 'returns false by default' do
273
- config.parse_options([])
274
- config.dry_run?.should be_false
275
- end
276
- end
277
-
278
- describe 'Specifying matcher type' do
279
- it 'returns the matcher type when it was set' do
280
- config.parse_options(['--matcher-type', 'classic'])
281
- config.matcher_type.should eql :classic
282
- end
283
-
284
- it 'returns the matcher type when it was set with shorthand option' do
285
- config.parse_options(['-I', 'classic'])
286
- config.matcher_type.should eql :classic
287
- end
288
-
289
- it 'returns the default matcher type if it was not set' do
290
- config.parse_options([])
291
- config.matcher_type.should eql :regexp
292
- end
293
- end
294
-
295
- describe 'handling tags' do
296
- it 'returns an empty expression when no tags are specified' do
297
- config.parse_options([])
298
- config.tag_expression.should be_empty
299
- end
300
-
301
- it 'returns an expression when tags are specified' do
302
- config.parse_options(['--tags','@smoke'])
303
- config.tag_expression.should_not be_empty
304
- end
305
- end
306
-
307
- describe 'Getting a backtrace of errors' do
308
- before do
309
- Lucid.use_full_backtrace = false
310
- end
311
-
312
- it 'should show full backtrace when --backtrace is called for' do
313
- config = App.new(['--backtrace'])
314
- begin
315
- 'x'.should == 'y'
316
- rescue => e
317
- e.backtrace[0].should_not == "#{__FILE__}:#{__LINE__ - 2}"
318
- end
319
- end
320
-
321
- after do
322
- Lucid.use_full_backtrace = false
323
- end
324
- end
325
-
326
- end
327
- end
328
- end
@@ -1,22 +0,0 @@
1
- require_relative '../spec_helper'
2
-
3
- module Lucid
4
- module Formatter
5
- describe Duration do
6
- include Duration
7
-
8
- it 'should format ms' do
9
- format_duration(0.002103).should == '0m0.002s'
10
- end
11
-
12
- it 'should format m' do
13
- format_duration(61.002503).should == '1m1.003s'
14
- end
15
-
16
- it 'should format h' do
17
- format_duration(3661.002503).should == '61m1.003s'
18
- end
19
-
20
- end
21
- end
22
- end
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Lucid
4
- describe ContextLoader::Facade do
5
-
6
- let(:interface) {double('interface')}
7
- subject { ContextLoader::Orchestrator.new(interface,{}) }
8
- let(:facade) { ContextLoader::Facade.new(subject, interface) }
9
-
10
- it 'should produce AST::Table by #table' do
11
- facade.table( %{
12
- | study | phase |
13
- | test-01 | I |
14
- | test-02 | II |
15
- } ).should be_kind_of(AST::Table)
16
- end
17
-
18
- it 'should produce AST::DocString by #doc_string with default content-type' do
19
- str = facade.doc_string('TEST')
20
- str.should be_kind_of(AST::DocString)
21
- str.content_type.should eq('')
22
- end
23
-
24
- it 'should produce AST::DocString by #doc_string with ruby content-type' do
25
- str = facade.doc_string('TEST','ruby')
26
- str.should be_kind_of(AST::DocString)
27
- str.content_type.should eq('ruby')
28
- end
29
-
30
- end
31
- end
@@ -1,16 +0,0 @@
1
- require_relative '../spec_helper'
2
-
3
- module Lucid
4
- describe Factory do
5
- include Factory
6
-
7
- it 'should load a valid formatter' do
8
- generated_class = create_object_of('Lucid::Formatter::Html')
9
- generated_class.name.should == 'Lucid::Formatter::Html'
10
- end
11
-
12
- it 'should not load an invalid formatter' do
13
- expect { create_object_of('Lucid::Formatter::Testing') }.to raise_error(LoadError)
14
- end
15
- end
16
- end
@@ -1,127 +0,0 @@
1
- require_relative '../spec_helper'
2
-
3
- module Lucid
4
- module InterfaceRb
5
- describe Matcher do
6
-
7
- before do
8
- @pattern = 'There is a missing step'
9
- @multiline_argument_class = nil
10
- end
11
-
12
- let(:code_keyword) { 'Given' }
13
-
14
- let(:matcher) do
15
- matcher_class.new(code_keyword, @pattern, @multiline_argument_class)
16
- end
17
-
18
- def unindent(s)
19
- s.split("\n")[1..-2].join("\n").indent(-10)
20
- end
21
-
22
- describe Matcher::Regexp do
23
- let(:matcher_class) { Matcher::Regexp }
24
- let(:matcher_text) { matcher.to_s }
25
-
26
- it 'should wrap matcher patterns in parentheses' do
27
- @pattern = 'A "string" with 4 spaces'
28
-
29
- matcher_text.should == unindent(%{
30
- Given (/^A "(.*?)" with (\\d+) spaces$/) do |arg1, arg2|
31
- pending
32
- end
33
- })
34
- end
35
-
36
- it 'should recognize numbers in name and make an according regexp' do
37
- @pattern = 'There are 4 spaces'
38
-
39
- matcher_text.should == unindent(%{
40
- Given (/^There are (\\d+) spaces$/) do |arg1|
41
- pending
42
- end
43
- })
44
- end
45
-
46
- it 'should recognise a mix of ints, strings and a table' do
47
- @pattern = 'There are 9 "lucid" tests in 20 "categories"'
48
- @multiline_argument_class = Lucid::AST::Table
49
-
50
- matcher_text.should == unindent(%{
51
- Given (/^There are (\\d+) "(.*?)" tests in (\\d+) "(.*?)"$/) do |arg1, arg2, arg3, arg4, table|
52
- # table is a Lucid::AST::Table
53
- pending
54
- end
55
- })
56
- end
57
-
58
- it "should recognize quotes in name and make according regexp" do
59
- @pattern = 'A "lucid" test'
60
-
61
- matcher_text.should == unindent(%{
62
- Given (/^A "(.*?)" test$/) do |arg1|
63
- pending
64
- end
65
- })
66
- end
67
-
68
- it 'should recognize several quoted words in name and make according regexp and args' do
69
- @pattern = 'A "first" and "second" arg'
70
-
71
- matcher_text.should == unindent(%{
72
- Given (/^A "(.*?)" and "(.*?)" arg$/) do |arg1, arg2|
73
- pending
74
- end
75
- })
76
- end
77
-
78
- it 'should not use quote group when there are no quotes' do
79
- @pattern = 'A first arg'
80
-
81
- matcher_text.should == unindent(%{
82
- Given (/^A first arg$/) do
83
- pending
84
- end
85
- })
86
- end
87
-
88
- it 'should be helpful with tables' do
89
- @pattern = 'A "first" arg'
90
- @multiline_argument_class = Lucid::AST::Table
91
-
92
- matcher_text.should == unindent(%{
93
- Given (/^A "(.*?)" arg$/) do |arg1, table|
94
- # table is a Lucid::AST::Table
95
- pending
96
- end
97
- })
98
- end
99
- end
100
-
101
- describe Matcher::Classic do
102
- let(:matcher_class) { Matcher::Classic }
103
-
104
- it 'renders matcher as unwrapped regular expression' do
105
- matcher.to_s.should eql unindent(%{
106
- Given /^There is a missing step$/ do
107
- pending
108
- end
109
- })
110
- end
111
- end
112
-
113
- describe Matcher::Percent do
114
- let(:matcher_class) { Matcher::Percent }
115
-
116
- it 'renders matcher as percent-style regular expression' do
117
- matcher.to_s.should eql unindent(%{
118
- Given %r{^There is a missing step$} do
119
- pending
120
- end
121
- })
122
- end
123
- end
124
-
125
- end
126
- end
127
- end