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.
- checksums.yaml +4 -4
- data/Gemfile +0 -3
- data/HISTORY.md +12 -0
- data/LICENSE +0 -3
- data/README.md +7 -5
- data/Rakefile +0 -14
- data/lib/lucid.rb +4 -0
- data/lib/lucid/cli/app.rb +1 -5
- data/lib/lucid/cli/context.rb +8 -6
- data/lib/lucid/cli/profile.rb +9 -9
- data/lib/lucid/context.rb +1 -1
- data/lib/lucid/interface_rb/matcher.rb +1 -2
- data/lib/lucid/platform.rb +2 -1
- data/lucid.gemspec +12 -12
- data/spec/lucid/lucid_spec.rb +7 -0
- data/spec/spec_helper.rb +0 -19
- metadata +34 -116
- data/.travis.yml +0 -15
- data/lib/lucid/sequence.rb +0 -5
- data/lib/lucid/sequence/sequence_errors.rb +0 -64
- data/lib/lucid/sequence/sequence_group.rb +0 -35
- data/lib/lucid/sequence/sequence_phrase.rb +0 -166
- data/lib/lucid/sequence/sequence_steps.rb +0 -20
- data/lib/lucid/sequence/sequence_support.rb +0 -26
- data/lib/lucid/sequence/sequence_template.rb +0 -354
- data/spec/lucid/ansicolor_spec.rb +0 -31
- data/spec/lucid/app_spec.rb +0 -82
- data/spec/lucid/ast/background_spec.rb +0 -128
- data/spec/lucid/ast/doc_string_spec.rb +0 -36
- data/spec/lucid/ast/feature_spec.rb +0 -66
- data/spec/lucid/ast/outline_table_spec.rb +0 -21
- data/spec/lucid/ast/scenario_outline_spec.rb +0 -81
- data/spec/lucid/ast/specs_spec.rb +0 -48
- data/spec/lucid/ast/step_invocation_spec.rb +0 -45
- data/spec/lucid/ast/step_spec.rb +0 -72
- data/spec/lucid/ast/table_spec.rb +0 -265
- data/spec/lucid/ast/tdl_factory.rb +0 -78
- data/spec/lucid/ast/tdl_walker_spec.rb +0 -21
- data/spec/lucid/context_spec.rb +0 -328
- data/spec/lucid/duration_spec.rb +0 -22
- data/spec/lucid/facade_spec.rb +0 -31
- data/spec/lucid/factory_spec.rb +0 -16
- data/spec/lucid/matcher_spec.rb +0 -127
- data/spec/lucid/options_spec.rb +0 -346
- data/spec/lucid/orchestrator_spec.rb +0 -117
- data/spec/lucid/pending_spec.rb +0 -45
- data/spec/lucid/progress_spec.rb +0 -34
- data/spec/lucid/rb_step_definition_spec.rb +0 -127
- data/spec/lucid/rb_transform_spec.rb +0 -24
- data/spec/lucid/regexp_argument_matcher_spec.rb +0 -19
- data/spec/lucid/results_spec.rb +0 -81
- data/spec/lucid/runtime_spec.rb +0 -38
- data/spec/lucid/sequences/sequence_conditional_spec.rb +0 -74
- data/spec/lucid/sequences/sequence_group_spec.rb +0 -55
- data/spec/lucid/sequences/sequence_phrase_spec.rb +0 -122
- data/spec/lucid/sequences/sequence_placeholder_spec.rb +0 -56
- data/spec/lucid/sequences/sequence_section_spec.rb +0 -61
- data/spec/lucid/sequences/sequence_support_spec.rb +0 -65
- data/spec/lucid/sequences/sequence_template_spec.rb +0 -298
- data/spec/lucid/step_match_spec.rb +0 -55
@@ -1,31 +0,0 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
|
3
|
-
module Lucid
|
4
|
-
module Formatter
|
5
|
-
describe ANSIColor do
|
6
|
-
include ANSIColor
|
7
|
-
|
8
|
-
it 'should wrap passed_param with bold green and reset to green' do
|
9
|
-
passed_param('test').should == "\e[32m\e[1mtest\e[0m\e[0m\e[32m"
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'should wrap passed in green' do
|
13
|
-
passed('test').should == "\e[32mtest\e[0m"
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should not reset passed if there are no arguments' do
|
17
|
-
passed.should == "\e[32m"
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should wrap comments in grey' do
|
21
|
-
comment('test').should == "\e[90mtest\e[0m"
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should not generate ansi codes when colors are disabled' do
|
25
|
-
::Lucid::Term::ANSIColor.coloring = false
|
26
|
-
passed('test').should == 'test'
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/spec/lucid/app_spec.rb
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'lucid/spec_builder'
|
3
|
-
require 'gherkin/formatter/model'
|
4
|
-
|
5
|
-
module Lucid
|
6
|
-
module CLI
|
7
|
-
describe App do
|
8
|
-
|
9
|
-
let(:args) { [] }
|
10
|
-
let(:stdin) { StringIO.new }
|
11
|
-
let(:stdout) { StringIO.new }
|
12
|
-
let(:stderr) { StringIO.new }
|
13
|
-
let(:kernel) { double(:kernel) }
|
14
|
-
subject { App.new(args, stdin, stdout, stderr, kernel) }
|
15
|
-
|
16
|
-
describe 'start' do
|
17
|
-
context 'passed a runtime' do
|
18
|
-
let(:runtime) { double('runtime').as_null_object }
|
19
|
-
|
20
|
-
def do_start
|
21
|
-
subject.start!(runtime)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'configures the runtime' do
|
25
|
-
configuration = double('Configuration').as_null_object
|
26
|
-
Context.stub(:new => configuration)
|
27
|
-
runtime.should_receive(:configure).with(configuration)
|
28
|
-
kernel.should_receive(:exit).with(1)
|
29
|
-
do_start
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'uses that runtime for running and reporting results' do
|
33
|
-
results = double('results', :failure? => true)
|
34
|
-
runtime.should_receive(:execute)
|
35
|
-
runtime.stub(:results).and_return(results)
|
36
|
-
kernel.should_receive(:exit).with(1)
|
37
|
-
do_start
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'execution is interrupted' do
|
42
|
-
after do
|
43
|
-
Lucid.wants_to_quit = false
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should register as a failure' do
|
47
|
-
results = double('results', :failure? => false)
|
48
|
-
runtime = ContextLoader.any_instance
|
49
|
-
runtime.stub(:excute)
|
50
|
-
runtime.stub(:results).and_return(results)
|
51
|
-
|
52
|
-
Lucid.wants_to_quit = true
|
53
|
-
kernel.should_receive(:exit).with(1)
|
54
|
-
subject.start!
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe 'verbose execution' do
|
60
|
-
before(:each) do
|
61
|
-
b = Lucid::Parser::SpecBuilder.new('specs/test.spec')
|
62
|
-
b.feature(Gherkin::Formatter::Model::Feature.new([], [], 'Feature', 'Testing', '', 99, ''))
|
63
|
-
b.language = double
|
64
|
-
@empty_feature = b.result
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'should show the spec files that were parsed' do
|
68
|
-
cli = App.new(%w{--verbose test.spec}, stdin, stdout, stderr, kernel)
|
69
|
-
cli.stub(:require)
|
70
|
-
|
71
|
-
Lucid::SpecFile.stub(:new).and_return(double('spec file', :parse => @empty_feature))
|
72
|
-
kernel.should_receive(:exit).with(0)
|
73
|
-
|
74
|
-
cli.start!
|
75
|
-
|
76
|
-
stdout.string.should include('test.spec')
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,128 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'lucid/ast'
|
4
|
-
require 'lucid/interface_rb/rb_language'
|
5
|
-
|
6
|
-
module Lucid
|
7
|
-
module AST
|
8
|
-
describe Background do
|
9
|
-
|
10
|
-
let(:language) { double.as_null_object }
|
11
|
-
|
12
|
-
before do
|
13
|
-
extend(Lucid::InterfaceRb::RbLucid)
|
14
|
-
@runtime = Lucid::ContextLoader.new
|
15
|
-
@rb = @runtime.load_code_language('rb')
|
16
|
-
|
17
|
-
$x = $y = nil
|
18
|
-
Before do
|
19
|
-
$x = 2
|
20
|
-
end
|
21
|
-
Given /y is (\d+)/ do |n|
|
22
|
-
$y = $x * n.to_i
|
23
|
-
end
|
24
|
-
|
25
|
-
@visitor = Walker.new(@runtime)
|
26
|
-
|
27
|
-
@feature = double('feature', :visit? => true, :feature_elements => []).as_null_object
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should execute Before blocks before background steps' do
|
31
|
-
background = Background.new(
|
32
|
-
language,
|
33
|
-
Location.new('test.spec', 2),
|
34
|
-
comment = Comment.new(''),
|
35
|
-
keyword = '',
|
36
|
-
title = '',
|
37
|
-
description = '',
|
38
|
-
steps = [
|
39
|
-
Step.new(language,Location.new('test.spec', 7), "Given", "y is 5")
|
40
|
-
]
|
41
|
-
)
|
42
|
-
|
43
|
-
scenario = Scenario.new(
|
44
|
-
language,
|
45
|
-
background,
|
46
|
-
comment = Comment.new(''),
|
47
|
-
tags = Tags.new(98,[]),
|
48
|
-
feature_tags = Tags.new(1,[]),
|
49
|
-
line = 99,
|
50
|
-
keyword = '',
|
51
|
-
title = '',
|
52
|
-
description = '',
|
53
|
-
steps=[]
|
54
|
-
)
|
55
|
-
|
56
|
-
background.feature = @feature
|
57
|
-
background.accept(@visitor)
|
58
|
-
$x.should == 2
|
59
|
-
$y.should == 10
|
60
|
-
end
|
61
|
-
|
62
|
-
describe 'should respond to #name' do
|
63
|
-
it 'with a value' do
|
64
|
-
background = Background.new(
|
65
|
-
language,
|
66
|
-
Location.new('test.spec', 2),
|
67
|
-
comment = Comment.new(''),
|
68
|
-
keyword = '',
|
69
|
-
title = 'background name',
|
70
|
-
description = '',
|
71
|
-
steps=[]
|
72
|
-
)
|
73
|
-
|
74
|
-
lambda{ background.name }.should_not raise_error
|
75
|
-
background.name.should == 'background name'
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'without a value' do
|
79
|
-
background = Background.new(
|
80
|
-
language,
|
81
|
-
comment = Comment.new(''),
|
82
|
-
line = 2,
|
83
|
-
keyword = '',
|
84
|
-
title = '',
|
85
|
-
description = '',
|
86
|
-
steps=[]
|
87
|
-
)
|
88
|
-
|
89
|
-
lambda{ background.name }.should_not raise_error
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe 'failures in a Before hook' do
|
94
|
-
before do
|
95
|
-
Before do
|
96
|
-
raise Exception, 'Exception from Before hook'
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'should state that the background has failed' do
|
101
|
-
background = Background.new(
|
102
|
-
language,
|
103
|
-
Location.new('test.spec', 2),
|
104
|
-
comment = Comment.new(''),
|
105
|
-
keyword = '',
|
106
|
-
title = '',
|
107
|
-
description = '',
|
108
|
-
steps = [
|
109
|
-
Step.new(language, Location.new('test.spec', 7), "Given", "y is 5")
|
110
|
-
]
|
111
|
-
)
|
112
|
-
|
113
|
-
background.feature = @feature
|
114
|
-
|
115
|
-
@visitor.should_receive( :visit_exception ) do |exception, status|
|
116
|
-
exception.should be_instance_of( Exception )
|
117
|
-
exception.message.should == "Exception from Before hook"
|
118
|
-
status.should == :failed
|
119
|
-
end
|
120
|
-
|
121
|
-
lambda{ background.accept(@visitor) }.should_not raise_error
|
122
|
-
background.should be_failed
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'lucid/ast/doc_string'
|
3
|
-
|
4
|
-
module Lucid
|
5
|
-
module AST
|
6
|
-
describe DocString do
|
7
|
-
|
8
|
-
describe 'replacing arguments' do
|
9
|
-
before(:each) do
|
10
|
-
@ps = DocString.new("<book>\n<qty>\n", '')
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should return a new doc_string with arguments replaced with values' do
|
14
|
-
doc_string_with_replaced_arg = @ps.arguments_replaced({'<book>' => 'Leviathan', '<qty>' => '5'})
|
15
|
-
doc_string_with_replaced_arg.to_step_definition_arg.should == "Leviathan\n5\n"
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should not change the original doc_string' do
|
19
|
-
doc_string_with_replaced_arg = @ps.arguments_replaced({'<book>' => 'Leviathan'})
|
20
|
-
@ps.to_s.should_not include('Leviathan')
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should replace nil with empty string' do
|
24
|
-
ps = DocString.new("'<book>'", '')
|
25
|
-
doc_string_with_replaced_arg = ps.arguments_replaced({'<book>' => nil})
|
26
|
-
doc_string_with_replaced_arg.to_step_definition_arg.should == "''"
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'should recognise when just a subset of a cell is delimited' do
|
30
|
-
@ps.should have_text('<qty>')
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'lucid/ast/tdl_factory'
|
3
|
-
|
4
|
-
module Lucid
|
5
|
-
module AST
|
6
|
-
describe Feature do
|
7
|
-
include TDLFactory
|
8
|
-
|
9
|
-
it 'should convert to a symbolic expression' do
|
10
|
-
runtime = Lucid::ContextLoader.new
|
11
|
-
runtime.load_code_language('rb')
|
12
|
-
dsl = Object.new
|
13
|
-
dsl.extend Lucid::InterfaceRb::RbLucid
|
14
|
-
|
15
|
-
feature = create_feature(dsl)
|
16
|
-
if Lucid::WINDOWS
|
17
|
-
feature_file_path = 'specs\\test.spec'
|
18
|
-
else
|
19
|
-
feature_file_path = 'specs/test.spec'
|
20
|
-
end
|
21
|
-
|
22
|
-
feature.to_sexp.should ==
|
23
|
-
[
|
24
|
-
:feature,
|
25
|
-
feature_file_path,
|
26
|
-
'Testing TDL',
|
27
|
-
[:comment, "# Feature Comment Line\n"],
|
28
|
-
[:tag, 'smoke'],
|
29
|
-
[:tag, 'critical'],
|
30
|
-
[:background, 2, 'Background:',
|
31
|
-
[:step, 3, 'Given', 'a passing step']],
|
32
|
-
[:scenario, 9, 'Scenario:',
|
33
|
-
'Test Scenario',
|
34
|
-
[:comment, " # Scenario Comment Line 1 \n# Scenario Comment Line 2 \n"],
|
35
|
-
[:tag, 'regression'],
|
36
|
-
[:tag, 'selenium'],
|
37
|
-
[:step_invocation, 3, 'Given', 'a passing step'],
|
38
|
-
[:step_invocation, 10, 'Given', 'a passing step with an inline argument:',
|
39
|
-
[:table,
|
40
|
-
[:row, -1,
|
41
|
-
[:cell, '1'], [:cell, '22'], [:cell, '333']],
|
42
|
-
[:row, -1,
|
43
|
-
[:cell, '4444'], [:cell, '55555'], [:cell, '666666']]]],
|
44
|
-
[:step_invocation, 11, 'Given', 'a working step with an inline argument:',
|
45
|
-
[:doc_string, "\n Testing with\nLucid tools\n"]],
|
46
|
-
[:step_invocation, 12, 'Given', 'a non-passing step']]
|
47
|
-
]
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'should store operating system specific file paths' do
|
51
|
-
runtime = Lucid::ContextLoader.new
|
52
|
-
runtime.load_code_language('rb')
|
53
|
-
dsl = Object.new
|
54
|
-
dsl.extend Lucid::InterfaceRb::RbLucid
|
55
|
-
feature = create_feature(dsl)
|
56
|
-
|
57
|
-
if Lucid::WINDOWS
|
58
|
-
feature.file.should == 'specs\test.spec'
|
59
|
-
else
|
60
|
-
feature.file.should == 'specs/test.spec'
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Lucid::AST
|
4
|
-
describe OutlineTable do
|
5
|
-
describe OutlineTable::ExampleRow do
|
6
|
-
describe 'a header row' do
|
7
|
-
before(:each) do
|
8
|
-
@row = OutlineTable::ExampleRow.new(
|
9
|
-
double('table', :index => 0),
|
10
|
-
[double('cell', :status= => nil, :accept => nil)]
|
11
|
-
)
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should raise an error if you try to call #failed?' do
|
15
|
-
@row.accept_plain double('visitor', :visit_table_cell => nil)
|
16
|
-
lambda{ @row.failed? }.should raise_error(NoMethodError, /cannot pass or fail/)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'lucid/ast'
|
4
|
-
require 'lucid/lang_extend'
|
5
|
-
require 'lucid/interface_rb/rb_language'
|
6
|
-
|
7
|
-
module Lucid
|
8
|
-
module AST
|
9
|
-
|
10
|
-
describe ScenarioOutline do
|
11
|
-
|
12
|
-
before do
|
13
|
-
@runtime = Lucid::ContextLoader.new
|
14
|
-
@runtime.load_code_language('rb')
|
15
|
-
@dsl = Object.new
|
16
|
-
@dsl.extend(Lucid::InterfaceRb::RbLucid)
|
17
|
-
|
18
|
-
@dsl.Given(/^there are (\d+) tests$/) do |n|
|
19
|
-
@initial = n.to_i
|
20
|
-
end
|
21
|
-
|
22
|
-
@dsl.When(/^testing (\d+) scenarios$/) do |n|
|
23
|
-
@tested = n.to_i
|
24
|
-
end
|
25
|
-
|
26
|
-
@dsl.Then(/^there should be (\d+) tests$/) do |n|
|
27
|
-
(@initial - @tested).should == n.to_i
|
28
|
-
end
|
29
|
-
|
30
|
-
@dsl.Then(/^there should be (\d+) tests completed$/) do |n|
|
31
|
-
@tested.should == n.to_i
|
32
|
-
end
|
33
|
-
|
34
|
-
location = AST::Location.new('test.spec', 19)
|
35
|
-
language = double
|
36
|
-
|
37
|
-
@scenario_outline = ScenarioOutline.new(
|
38
|
-
language,
|
39
|
-
location,
|
40
|
-
background=AST::EmptyBackground.new,
|
41
|
-
Comment.new(''),
|
42
|
-
Tags.new(18, []),
|
43
|
-
Tags.new(0, []),
|
44
|
-
'Scenario:', 'Test Outline', '',
|
45
|
-
[
|
46
|
-
Step.new(language, location.on_line(20), 'Given', 'there are <start> tests'),
|
47
|
-
Step.new(language, location.on_line(21), 'When', 'testing <tests> scenarios'),
|
48
|
-
Step.new(language, location.on_line(22), 'Then', 'there should be <left> tests'),
|
49
|
-
Step.new(language, location.on_line(23), 'And', 'there should be <tests> tests completed')
|
50
|
-
],
|
51
|
-
[
|
52
|
-
[
|
53
|
-
[
|
54
|
-
location.on_line(24),
|
55
|
-
Comment.new("# Testing\n"),
|
56
|
-
'Examples:',
|
57
|
-
'First table',
|
58
|
-
'',
|
59
|
-
[
|
60
|
-
%w{start tests left},
|
61
|
-
%w{12 5 7},
|
62
|
-
%w{20 6 14}
|
63
|
-
]
|
64
|
-
],
|
65
|
-
Gherkin::Formatter::Model::Examples.new(nil, nil, nil, nil, nil, nil, nil, nil)
|
66
|
-
]
|
67
|
-
]
|
68
|
-
)
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'should replace all variables and call outline once for each table row' do
|
72
|
-
visitor = Walker.new(@runtime)
|
73
|
-
visitor.should_receive(:visit_table_row).exactly(3).times
|
74
|
-
@scenario_outline.feature = double.as_null_object
|
75
|
-
@scenario_outline.accept(visitor)
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|