lucid 0.4.1 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/spec/lucid/pending_spec.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'lucid/interface_rb/rb_language'
|
3
|
-
|
4
|
-
module Lucid
|
5
|
-
describe 'Pending' do
|
6
|
-
before(:each) do
|
7
|
-
l = InterfaceRb::RbLanguage.new(ContextLoader.new)
|
8
|
-
l.begin_rb_scenario(double('scenario').as_null_object)
|
9
|
-
@domain= l.current_domain
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'should raise a Pending if no block is supplied' do
|
13
|
-
lambda {
|
14
|
-
@domain.pending 'TODO'
|
15
|
-
}.should raise_error(Lucid::Pending, /TODO/)
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should raise a Pending if a supplied block fails as expected' do
|
19
|
-
lambda {
|
20
|
-
@domain.pending 'TODO' do
|
21
|
-
raise 'that is a problem'
|
22
|
-
end
|
23
|
-
}.should raise_error(Lucid::Pending, /TODO/)
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should raise a Pending if a supplied block fails as expected with a double' do
|
27
|
-
lambda {
|
28
|
-
@domain.pending 'TODO' do
|
29
|
-
m = double('test')
|
30
|
-
m.should_receive(:testing)
|
31
|
-
RSpec::Mocks.verify
|
32
|
-
end
|
33
|
-
}.should raise_error(Lucid::Pending, /TODO/)
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should raise a Pending if a supplied block starts working' do
|
37
|
-
lambda {
|
38
|
-
@domain.pending 'TODO' do
|
39
|
-
# Nothing happens here.
|
40
|
-
end
|
41
|
-
}.should raise_error(Lucid::Pending, /TODO/)
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
data/spec/lucid/progress_spec.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
require 'lucid/formatter/progress'
|
3
|
-
|
4
|
-
module Lucid
|
5
|
-
module Formatter
|
6
|
-
describe Progress do
|
7
|
-
|
8
|
-
before(:each) do
|
9
|
-
Lucid::Term::ANSIColor.coloring = false
|
10
|
-
@out = StringIO.new
|
11
|
-
progress = Lucid::Formatter::Progress.new(double('Runtime'), @out, {})
|
12
|
-
@visitor = Lucid::AST::Walker.new(nil, [progress])
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'visiting a table cell value without a status' do
|
16
|
-
it 'should take the status from the last run step' do
|
17
|
-
step_result = AST::StepResult.new('', '', nil, :failed, nil, 10, nil, nil)
|
18
|
-
step_result.accept(@visitor)
|
19
|
-
@visitor.visit_outline_table(double) do
|
20
|
-
@visitor.visit_table_cell_value('value', nil)
|
21
|
-
end
|
22
|
-
@out.string.should == "FF"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe 'visiting a table cell which is a table header' do
|
27
|
-
it 'should not output anything' do
|
28
|
-
@visitor.visit_table_cell_value('value', :skipped_param)
|
29
|
-
@out.string.should == ''
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,127 +0,0 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
|
3
|
-
module Lucid
|
4
|
-
module InterfaceRb
|
5
|
-
describe RbStepDefinition do
|
6
|
-
let(:interface) { double('interface') }
|
7
|
-
let(:orchestrator) { Lucid::ContextLoader::Orchestrator.new(interface) }
|
8
|
-
let(:rb) { orchestrator.load_code_language('rb') }
|
9
|
-
let(:dsl) do
|
10
|
-
rb
|
11
|
-
Object.new.extend(Lucid::InterfaceRb::RbLucid)
|
12
|
-
end
|
13
|
-
|
14
|
-
before do
|
15
|
-
rb.before(double('scenario').as_null_object)
|
16
|
-
$inside = nil
|
17
|
-
end
|
18
|
-
|
19
|
-
def run_step(text)
|
20
|
-
orchestrator.step_match(text).invoke(nil)
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should allow calling of other steps' do
|
24
|
-
dsl.Given /Outside/ do
|
25
|
-
step 'Inside'
|
26
|
-
end
|
27
|
-
dsl.Given /Inside/ do
|
28
|
-
$inside = true
|
29
|
-
end
|
30
|
-
|
31
|
-
run_step 'Outside'
|
32
|
-
$inside.should == true
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'should allow calling of other steps with inline arg' do
|
36
|
-
dsl.Given /Outside/ do
|
37
|
-
step 'Inside', Lucid::AST::Table.new([['inside']])
|
38
|
-
end
|
39
|
-
|
40
|
-
dsl.Given /Inside/ do |table|
|
41
|
-
$inside = table.raw[0][0]
|
42
|
-
end
|
43
|
-
|
44
|
-
run_step 'Outside'
|
45
|
-
$inside.should == 'inside'
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'mapping to domain methods' do
|
49
|
-
it 'should call a method on the domain when specified with a symbol' do
|
50
|
-
rb.current_domain.should_receive(:with_symbol)
|
51
|
-
dsl.Given /With symbol/, :with_symbol
|
52
|
-
run_step 'With symbol'
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'should call a method on a specified object' do
|
56
|
-
target = double('target')
|
57
|
-
rb.current_domain.stub(:target => target)
|
58
|
-
dsl.Given /With symbol on block/, :with_symbol, :on => lambda { target }
|
59
|
-
|
60
|
-
target.should_receive(:with_symbol)
|
61
|
-
run_step 'With symbol on block'
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'should call a method on a specified domain attribute' do
|
65
|
-
target = double('target')
|
66
|
-
rb.current_domain.stub(:target => target)
|
67
|
-
dsl.Given /With symbol on symbol/, :with_symbol, :on => :target
|
68
|
-
|
69
|
-
target.should_receive(:with_symbol)
|
70
|
-
run_step 'With symbol on symbol'
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'should raise Undefined when inside step is not defined' do
|
75
|
-
dsl.Given /Outside/ do
|
76
|
-
step 'Inside'
|
77
|
-
end
|
78
|
-
|
79
|
-
lambda { run_step 'Outside' }.should raise_error(Lucid::Undefined, 'Undefined step: "Inside"')
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'should allow forced pending' do
|
83
|
-
dsl.Given /Outside/ do
|
84
|
-
pending('This needs to be tested.')
|
85
|
-
end
|
86
|
-
|
87
|
-
lambda { run_step 'Outside' }.should raise_error(Lucid::Pending, 'This needs to be tested.')
|
88
|
-
end
|
89
|
-
|
90
|
-
it 'should allow puts' do
|
91
|
-
interface.should_receive(:puts).with('testing')
|
92
|
-
dsl.Given /Say Something/ do
|
93
|
-
puts 'testing'
|
94
|
-
end
|
95
|
-
run_step 'Say Something'
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'should recognize $arg style captures' do
|
99
|
-
arg_value = 'testing'
|
100
|
-
dsl.Given 'capture this: $arg' do |arg|
|
101
|
-
arg.should == arg_value
|
102
|
-
end
|
103
|
-
run_step 'capture this: testing'
|
104
|
-
end
|
105
|
-
|
106
|
-
it 'should have a JSON representation of the signature' do
|
107
|
-
RbStepDefinition.new(rb, /There are (\d+) Lucid tests/i, lambda{}, {}).to_hash.should == {'source' => "There are (\\d+) Lucid tests", 'flags' => 'i'}
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'should raise ArityMismatchError when the number of capture groups differs from the number of step arguments' do
|
111
|
-
dsl.Given /No group: \w+/ do |arg|
|
112
|
-
end
|
113
|
-
|
114
|
-
lambda { run_step 'No group: arg' }.should raise_error(Lucid::ArityMismatchError)
|
115
|
-
end
|
116
|
-
|
117
|
-
it 'should not allow modification of args since it messes up nice formatting' do
|
118
|
-
dsl.Given /Lucid tests are (.*)/ do |status|
|
119
|
-
status << 'good'
|
120
|
-
end
|
121
|
-
|
122
|
-
lambda { run_step 'Lucid tests are good' }.should raise_error(RuntimeError, /can't modify frozen String/i)
|
123
|
-
end
|
124
|
-
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
|
3
|
-
module Lucid
|
4
|
-
module InterfaceRb
|
5
|
-
describe RbTransform do
|
6
|
-
|
7
|
-
def transform(regexp)
|
8
|
-
RbTransform.new(nil, regexp, lambda { |a| })
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'converts captures groups to non-capture groups' do
|
12
|
-
transform(/(a|b)bc/).to_s.should == '(?:a|b)bc'
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'leaves non-capture groups alone' do
|
16
|
-
transform(/(?:a|b)bc/).to_s.should == '(?:a|b)bc'
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'strips away line anchors' do
|
20
|
-
transform(/^xyz$/).to_s.should == 'xyz'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
|
3
|
-
module Lucid
|
4
|
-
module InterfaceRb
|
5
|
-
describe RegexpArgumentMatcher do
|
6
|
-
|
7
|
-
it 'should create two arguments' do
|
8
|
-
arguments = RegexpArgumentMatcher.arguments_from(/Lucid (\w+) (\w+)/, 'Lucid works well')
|
9
|
-
arguments.map{|argument| [argument.val, argument.offset]}.should == [['works', 6], ['well', 12]]
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'should create two arguments when first group is optional' do
|
13
|
-
arguments = RegexpArgumentMatcher.arguments_from(/should( not)? be shown '([^']*?)'$/, "should be shown 'Login failed.'")
|
14
|
-
arguments.map{|argument| [argument.val, argument.offset]}.should == [[nil, nil], ['Login failed.', 17]]
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/spec/lucid/results_spec.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Lucid
|
4
|
-
describe ContextLoader::Results do
|
5
|
-
let(:configuration) {double 'Configuration', :strict? => false}
|
6
|
-
let(:passed_scenario) {double 'Scenario', :status => :passed}
|
7
|
-
let(:failed_scenario) {double 'Scenario', :status => :failed}
|
8
|
-
let(:passed_step) {double 'Step', :status => :passed}
|
9
|
-
let(:failed_step) {double 'Step', :status => :failed}
|
10
|
-
let(:pending_step) {double 'Step', :status => :pending}
|
11
|
-
let(:undefined_step) {double 'Step', :status => :undefined}
|
12
|
-
|
13
|
-
subject {described_class.new(configuration)}
|
14
|
-
|
15
|
-
describe '#failure?' do
|
16
|
-
context 'feature is not work in progress' do
|
17
|
-
before do
|
18
|
-
configuration.stub(:wip? => false)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should return true if a scenario failed' do
|
22
|
-
subject.scenario_visited(passed_scenario)
|
23
|
-
subject.scenario_visited(failed_scenario)
|
24
|
-
subject.should be_failure
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should return true if a step failed' do
|
28
|
-
subject.step_visited(failed_step)
|
29
|
-
subject.should be_failure
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should return false if there are no scenarios' do
|
33
|
-
subject.should_not be_failure
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should return false if all scenarios passed' do
|
37
|
-
subject.scenario_visited(passed_scenario)
|
38
|
-
subject.scenario_visited(passed_scenario)
|
39
|
-
subject.should_not be_failure
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'configuration is strict' do
|
43
|
-
before do
|
44
|
-
configuration.stub(:strict? => true)
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should return true if a step is pending' do
|
48
|
-
subject.step_visited(pending_step)
|
49
|
-
subject.should be_failure
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'should return true if a step is undefined' do
|
53
|
-
subject.step_visited(undefined_step)
|
54
|
-
subject.should be_failure
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'feature is work in progress' do
|
60
|
-
before do
|
61
|
-
configuration.stub(:wip? => true)
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'should return true if a scenario passed' do
|
65
|
-
subject.scenario_visited(passed_scenario)
|
66
|
-
subject.should be_failure
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'should return false if there are no scenarios' do
|
70
|
-
subject.should_not be_failure
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'should return false if all scenarios fail' do
|
74
|
-
subject.scenario_visited(failed_scenario)
|
75
|
-
subject.should_not be_failure
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
data/spec/lucid/runtime_spec.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Lucid
|
4
|
-
describe ContextLoader do
|
5
|
-
|
6
|
-
let(:options) { {} }
|
7
|
-
subject { ContextLoader.new(options) }
|
8
|
-
|
9
|
-
describe '#specs_paths' do
|
10
|
-
let(:options) { {:paths => ['specs/area1/test.spec', 'specs/area1/area2/test.spec', 'others_specs'] } }
|
11
|
-
|
12
|
-
it 'returns the value from the configuration.spec_source' do
|
13
|
-
subject.specs_paths.should == options[:spec_source]
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '#configure' do
|
18
|
-
let(:orchestrator) { double(ContextLoader::Orchestrator).as_null_object }
|
19
|
-
let(:results) { double(ContextLoader::Results).as_null_object }
|
20
|
-
let(:new_config) { double('New Configuration') }
|
21
|
-
|
22
|
-
before(:each) do
|
23
|
-
ContextLoader::Orchestrator.stub(:new => orchestrator)
|
24
|
-
ContextLoader::Results.stub(:new => results)
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'tells the orchestrator and results about the new configuration' do
|
28
|
-
orchestrator.should_receive(:configure).with(new_config)
|
29
|
-
results.should_receive(:configure).with(new_config)
|
30
|
-
subject.configure(new_config)
|
31
|
-
end
|
32
|
-
|
33
|
-
it '#doc_string' do
|
34
|
-
subject.doc_string('Testing').should == 'Testing'
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,74 +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 ConditionalSection do
|
8
|
-
|
9
|
-
context 'establishing a conditional section' do
|
10
|
-
it 'should be created with a variable name and a boolean' do
|
11
|
-
expect { ConditionalSection.new('testing', false) }.not_to raise_error
|
12
|
-
expect { ConditionalSection.new('testing', true) }.not_to raise_error
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should know whether to generated based on the existence of an actual value' do
|
16
|
-
[false, true].each do |existence|
|
17
|
-
instance = ConditionalSection.new('testing', existence)
|
18
|
-
expect(instance.existence).to eq(existence)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'generating a conditional section' do
|
24
|
-
let(:example_child_elements) do
|
25
|
-
[ StaticText.new('Test '),
|
26
|
-
Placeholder.new('content'),
|
27
|
-
EOLine.new
|
28
|
-
]
|
29
|
-
end
|
30
|
-
|
31
|
-
subject { ConditionalSection.new('testing', true) }
|
32
|
-
|
33
|
-
it 'should know its original source text' do
|
34
|
-
expect(subject.to_s).to eq('<?testing>')
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'should generate the children when conditions are met' do
|
38
|
-
example_child_elements.each { |child| subject.add_child(child) }
|
39
|
-
|
40
|
-
locals = { 'content' => 'found', 'testing' => 'exists' }
|
41
|
-
generated_text = subject.output(Object.new, locals)
|
42
|
-
expected_text = "Test found\n"
|
43
|
-
expect(generated_text).to eq(expected_text)
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should generate the children even when value does not exist' do
|
47
|
-
instance = ConditionalSection.new('testing', false)
|
48
|
-
example_child_elements.each { |child| instance.add_child(child) }
|
49
|
-
locals = { 'content' => 'found' }
|
50
|
-
generated_text = instance.output(Object.new, locals)
|
51
|
-
expected_text = "Test found\n"
|
52
|
-
expect(generated_text).to eq(expected_text)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should generate nothing when conditions are not met" do
|
56
|
-
example_child_elements.each { |child| subject.add_child(child) }
|
57
|
-
|
58
|
-
locals = { 'content' => 'found' }
|
59
|
-
generated_text = subject.output(Object.new, locals)
|
60
|
-
expect(generated_text).to eq('')
|
61
|
-
|
62
|
-
instance = ConditionalSection.new('testing', false)
|
63
|
-
example_child_elements.each { |child| instance.add_child(child) }
|
64
|
-
|
65
|
-
locals = { 'content' => 'found', 'testing' => 'exists' }
|
66
|
-
generated_text = instance.output(Object.new, locals)
|
67
|
-
expect(generated_text).to eq('')
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
end
|