cucumber-core 3.0.0 → 3.1.0
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/lib/cucumber/core/version.rb +1 -1
- metadata +19 -85
- data/.coveralls.yml +0 -1
- data/.github/ISSUE_TEMPLATE.md +0 -48
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -39
- data/.rspec +0 -1
- data/.ruby-gemset +0 -1
- data/.travis.yml +0 -30
- data/.yardopts +0 -6
- data/Gemfile +0 -2
- data/Rakefile +0 -28
- data/cucumber-core.gemspec +0 -36
- data/spec/capture_warnings.rb +0 -74
- data/spec/coverage.rb +0 -11
- data/spec/cucumber/core/ast/background_spec.rb +0 -11
- data/spec/cucumber/core/ast/data_table_spec.rb +0 -81
- data/spec/cucumber/core/ast/doc_string_spec.rb +0 -114
- data/spec/cucumber/core/ast/empty_multiline_argument_spec.rb +0 -28
- data/spec/cucumber/core/ast/examples_table_spec.rb +0 -113
- data/spec/cucumber/core/ast/location_spec.rb +0 -199
- data/spec/cucumber/core/ast/outline_step_spec.rb +0 -93
- data/spec/cucumber/core/ast/step_spec.rb +0 -174
- data/spec/cucumber/core/compiler_spec.rb +0 -267
- data/spec/cucumber/core/event_bus_spec.rb +0 -163
- data/spec/cucumber/core/event_spec.rb +0 -40
- data/spec/cucumber/core/filter_spec.rb +0 -101
- data/spec/cucumber/core/gherkin/parser_spec.rb +0 -261
- data/spec/cucumber/core/gherkin/writer_spec.rb +0 -333
- data/spec/cucumber/core/report/summary_spec.rb +0 -175
- data/spec/cucumber/core/test/action_spec.rb +0 -154
- data/spec/cucumber/core/test/case_spec.rb +0 -316
- data/spec/cucumber/core/test/duration_matcher.rb +0 -20
- data/spec/cucumber/core/test/filters/locations_filter_spec.rb +0 -405
- data/spec/cucumber/core/test/result_spec.rb +0 -474
- data/spec/cucumber/core/test/runner_spec.rb +0 -310
- data/spec/cucumber/core/test/step_spec.rb +0 -98
- data/spec/cucumber/core/test/timer_spec.rb +0 -25
- data/spec/cucumber/core_spec.rb +0 -262
- data/spec/readme_spec.rb +0 -37
- data/spec/report_api_spy.rb +0 -25
data/spec/coverage.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'simplecov'
|
3
|
-
formatters = [ SimpleCov::Formatter::HTMLFormatter ]
|
4
|
-
|
5
|
-
if ENV['TRAVIS']
|
6
|
-
require 'coveralls'
|
7
|
-
formatters << Coveralls::SimpleCov::Formatter
|
8
|
-
end
|
9
|
-
|
10
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(formatters)
|
11
|
-
SimpleCov.start
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'cucumber/core/ast/background'
|
3
|
-
module Cucumber::Core::Ast
|
4
|
-
describe Background do
|
5
|
-
it "has a useful inspect" do
|
6
|
-
location = Location.new("features/a_feature.feature", 3)
|
7
|
-
background = Background.new(location, double, "Background", "the name", double, [])
|
8
|
-
expect(background.inspect).to eq(%{#<Cucumber::Core::Ast::Background "Background: the name" (#{location})>})
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
require 'cucumber/core/ast/data_table'
|
4
|
-
|
5
|
-
module Cucumber
|
6
|
-
module Core
|
7
|
-
module Ast
|
8
|
-
describe DataTable do
|
9
|
-
let(:location) { Location.new('foo.feature', 9..12) }
|
10
|
-
|
11
|
-
before do
|
12
|
-
@table = DataTable.new([
|
13
|
-
%w{one four seven},
|
14
|
-
%w{4444 55555 666666}
|
15
|
-
], location)
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "equality" do
|
19
|
-
it "is equal to another table with the same data" do
|
20
|
-
expect( DataTable.new([[1,2],[3,4]], location) ).to eq DataTable.new([[1,2],[3,4]], location)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "is not equal to another table with different data" do
|
24
|
-
expect( DataTable.new([[1,2],[3,4]], location) ).not_to eq DataTable.new([[1,2]], location)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "is not equal to a non table" do
|
28
|
-
expect( DataTable.new([[1,2],[3,4]], location) ).not_to eq Object.new
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "#data_table?" do
|
33
|
-
let(:table) { DataTable.new([[1,2],[3,4]], location) }
|
34
|
-
|
35
|
-
it "returns true" do
|
36
|
-
expect(table).to be_data_table
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "#doc_string" do
|
41
|
-
let(:table) { DataTable.new([[1,2],[3,4]], location) }
|
42
|
-
|
43
|
-
it "returns false" do
|
44
|
-
expect(table).not_to be_doc_string
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "#map" do
|
49
|
-
let(:table) { DataTable.new([ %w{foo bar}, %w{1 2} ], location) }
|
50
|
-
|
51
|
-
it 'yields the contents of each cell to the block' do
|
52
|
-
|
53
|
-
expect { |b| table.map(&b) }.to yield_successive_args('foo', 'bar', '1', '2')
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'returns a new table with the cells modified by the block' do
|
57
|
-
expect( table.map { |cell| "*#{cell}*" } ).to eq DataTable.new([%w{*foo* *bar*}, %w{*1* *2*}], location)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe "#transpose" do
|
62
|
-
before(:each) do
|
63
|
-
@table = DataTable.new([
|
64
|
-
%w{one 1111},
|
65
|
-
%w{two 22222}
|
66
|
-
], location)
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should transpose the table" do
|
70
|
-
transposed = DataTable.new([
|
71
|
-
%w{one two},
|
72
|
-
%w{1111 22222}
|
73
|
-
], location)
|
74
|
-
expect( @table.transpose ).to eq( transposed )
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,114 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'cucumber/core/ast/location'
|
3
|
-
require 'cucumber/core/ast/doc_string'
|
4
|
-
require 'unindent'
|
5
|
-
|
6
|
-
module Cucumber
|
7
|
-
module Core
|
8
|
-
module Ast
|
9
|
-
describe DocString do
|
10
|
-
let(:location) { double }
|
11
|
-
let(:doc_string) { DocString.new(content, content_type, location) }
|
12
|
-
|
13
|
-
describe "#data_table?" do
|
14
|
-
let(:doc_string) { DocString.new("test", "text/plain" , location) }
|
15
|
-
|
16
|
-
it "returns false" do
|
17
|
-
expect(doc_string).not_to be_data_table
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "#doc_string" do
|
22
|
-
let(:doc_string) { DocString.new("test", "text/plain" , location) }
|
23
|
-
|
24
|
-
it "returns true" do
|
25
|
-
expect(doc_string).to be_doc_string
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context '#map' do
|
30
|
-
let(:content) { 'original content' }
|
31
|
-
let(:content_type) { double }
|
32
|
-
|
33
|
-
it 'yields with the content' do
|
34
|
-
expect { |b| doc_string.map(&b) }.to yield_with_args(content)
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'returns a new docstring with new content' do
|
38
|
-
expect( doc_string.map { 'foo' }.content ).to eq 'foo'
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'raises an error if no block is given' do
|
42
|
-
expect { doc_string.map }.to raise_error ArgumentError
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context 'equality' do
|
47
|
-
let(:content) { 'foo' }
|
48
|
-
let(:content_type) { 'text/plain' }
|
49
|
-
|
50
|
-
it 'is equal to another DocString with the same content and content_type' do
|
51
|
-
expect( doc_string ).to eq DocString.new(content, content_type, location)
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'is not equal to another DocString with different content' do
|
55
|
-
expect( doc_string ).not_to eq DocString.new('bar', content_type, location)
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'is not equal to another DocString with different content_type' do
|
59
|
-
expect( doc_string ).not_to eq DocString.new(content, 'text/html', location)
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'is equal to a string with the same content' do
|
63
|
-
expect( doc_string ).to eq 'foo'
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'returns false when compared with something odd' do
|
67
|
-
expect( doc_string ).not_to eq 5
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context 'quacking like a String' do
|
72
|
-
let(:content) { String.new('content') }
|
73
|
-
let(:content_type) { 'text/plain' }
|
74
|
-
|
75
|
-
it 'delegates #encoding to the content string' do
|
76
|
-
content.force_encoding('us-ascii')
|
77
|
-
expect( doc_string.encoding ).to eq Encoding.find('US-ASCII')
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'allows implicit conversion to a String' do
|
81
|
-
expect( 'expected content' ).to include(doc_string)
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'allows explicit conversion to a String' do
|
85
|
-
expect( doc_string.to_s ).to eq 'content'
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'delegates #gsub to the content string' do
|
89
|
-
expect( doc_string.gsub(/n/, '_') ).to eq 'co_te_t'
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'delegates #split to the content string' do
|
93
|
-
expect(doc_string.split('n')).to eq ['co', 'te', 't']
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
context "inspect" do
|
99
|
-
let(:location) { Location.new("features/feature.feature", 8) }
|
100
|
-
let(:content_type) { 'text/plain' }
|
101
|
-
|
102
|
-
it "provides a useful inspect method" do
|
103
|
-
doc_string = DocString.new("some text", content_type, location)
|
104
|
-
expect(doc_string.inspect).to eq <<-END.chomp.unindent
|
105
|
-
#<Cucumber::Core::Ast::DocString (features/feature.feature:8)
|
106
|
-
"""text/plain
|
107
|
-
some text
|
108
|
-
""">
|
109
|
-
END
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'cucumber/core/ast/location'
|
3
|
-
require 'cucumber/core/ast/empty_multiline_argument'
|
4
|
-
|
5
|
-
module Cucumber
|
6
|
-
module Core
|
7
|
-
module Ast
|
8
|
-
describe EmptyMultilineArgument do
|
9
|
-
|
10
|
-
let(:location) { double }
|
11
|
-
let(:arg) { EmptyMultilineArgument.new }
|
12
|
-
|
13
|
-
describe "#data_table?" do
|
14
|
-
it "returns false" do
|
15
|
-
expect(arg).not_to be_data_table
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "#doc_string" do
|
20
|
-
it "returns false" do
|
21
|
-
expect(arg).not_to be_doc_string
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,113 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'cucumber/core/ast/examples_table'
|
3
|
-
|
4
|
-
module Cucumber::Core::Ast
|
5
|
-
describe ExamplesTable do
|
6
|
-
let(:location) { double(:to_s => 'file.feature:8') }
|
7
|
-
let(:language) { double }
|
8
|
-
let(:comments) { double }
|
9
|
-
|
10
|
-
describe ExamplesTable::Header do
|
11
|
-
let(:header) { ExamplesTable::Header.new(%w{foo bar baz}, location, comments) }
|
12
|
-
|
13
|
-
describe 'location' do
|
14
|
-
it 'knows the file and line number' do
|
15
|
-
expect( header.file_colon_line ).to eq 'file.feature:8'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'comments' do
|
20
|
-
it "has comments" do
|
21
|
-
expect( header ).to respond_to(:comments)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'building a row' do
|
26
|
-
it 'includes the header values as keys' do
|
27
|
-
expect( header.build_row(%w{1 2 3}, 1, location, language, comments) ).to eq ExamplesTable::Row.new({'foo' => '1', 'bar' => '2', 'baz' => '3'}, 1, location, language, comments)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
describe ExamplesTable::Row do
|
32
|
-
|
33
|
-
describe 'location' do
|
34
|
-
it 'knows the file and line number' do
|
35
|
-
row = ExamplesTable::Row.new({}, 1, location, language, comments)
|
36
|
-
expect( row.file_colon_line ).to eq 'file.feature:8'
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe 'language' do
|
41
|
-
it "has a language" do
|
42
|
-
expect( ExamplesTable::Row.new({}, 1, location, language, comments) ).to respond_to(:language)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe 'comments' do
|
47
|
-
it "has comments" do
|
48
|
-
expect( ExamplesTable::Row.new({}, 1, location, language, comments) ).to respond_to(:comments)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe "expanding a string" do
|
53
|
-
context "when an argument matches" do
|
54
|
-
it "replaces the argument with the value from the row" do
|
55
|
-
row = ExamplesTable::Row.new({'arg' => 'replacement'}, 1, location, language, comments)
|
56
|
-
text = 'this <arg> a test'
|
57
|
-
expect( row.expand(text) ).to eq 'this replacement a test'
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context "when the replacement value is nil" do
|
62
|
-
it "uses an empty string for the replacement" do
|
63
|
-
row = ExamplesTable::Row.new({'color' => nil}, 1, location, language, comments)
|
64
|
-
text = 'a <color> cucumber'
|
65
|
-
expect( row.expand(text) ).to eq 'a cucumber'
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context "when an argument does not match" do
|
70
|
-
it "ignores the arguments that do not match" do
|
71
|
-
row = ExamplesTable::Row.new({'x' => '1', 'y' => '2'}, 1, location, language, comments)
|
72
|
-
text = 'foo <x> bar <z>'
|
73
|
-
expect( row.expand(text) ).to eq 'foo 1 bar <z>'
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe 'accessing the values' do
|
79
|
-
it 'returns the actual row values' do
|
80
|
-
row = ExamplesTable::Row.new({'x' => '1', 'y' => '2'}, 1, location, language, comments)
|
81
|
-
expect( row.values ).to eq ['1', '2']
|
82
|
-
end
|
83
|
-
|
84
|
-
it "can access a row value by it's parameter name" do
|
85
|
-
row = ExamplesTable::Row.new({'x' => '1', 'y' => '2'}, 1, location, language, comments)
|
86
|
-
expect( row['x']).to eq '1'
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe 'equality' do
|
91
|
-
let(:data) { {} }
|
92
|
-
let(:number) { double }
|
93
|
-
let(:location) { double }
|
94
|
-
let(:original) { ExamplesTable::Row.new(data, number, location, language, comments) }
|
95
|
-
|
96
|
-
it 'is equal to another instance with the same data, number and location' do
|
97
|
-
expect( original ).to eq ExamplesTable::Row.new(data, number, location, language, comments)
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'is not equal to another instance with different data, number or location' do
|
101
|
-
expect( original ).not_to eq ExamplesTable::Row.new({'x' => 'y'}, number, location, language, comments)
|
102
|
-
expect( original ).not_to eq ExamplesTable::Row.new(data, double, location, language, comments)
|
103
|
-
expect( original ).not_to eq ExamplesTable::Row.new(data, number, double, double, double)
|
104
|
-
end
|
105
|
-
|
106
|
-
it 'is not equal to another type of object' do
|
107
|
-
expect( original ).not_to eq double(data: data, number: number, location: location, language: language)
|
108
|
-
end
|
109
|
-
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
@@ -1,199 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'cucumber/core/ast/location'
|
3
|
-
|
4
|
-
module Cucumber::Core::Ast
|
5
|
-
RSpec::Matchers.define :be_included_in do |expected|
|
6
|
-
match do |actual|
|
7
|
-
expected.include? actual
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe Location do
|
12
|
-
let(:line) { 12 }
|
13
|
-
let(:file) { "foo.feature" }
|
14
|
-
|
15
|
-
describe "equality" do
|
16
|
-
it "is equal to another Location on the same line of the same file" do
|
17
|
-
one_location = Location.new(file, line)
|
18
|
-
another_location = Location.new(file, line)
|
19
|
-
expect( one_location ).to eq another_location
|
20
|
-
end
|
21
|
-
|
22
|
-
it "is not equal to a wild card of the same file" do
|
23
|
-
expect( Location.new(file, line) ).not_to eq Location.new(file)
|
24
|
-
end
|
25
|
-
|
26
|
-
context "collections of locations" do
|
27
|
-
it "behave as expected with uniq" do
|
28
|
-
unique_collection = [Location.new(file, line), Location.new(file, line)].uniq
|
29
|
-
expect( unique_collection ).to eq [Location.new(file, line)]
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "to_s" do
|
35
|
-
it "is file:line for a precise location" do
|
36
|
-
expect( Location.new("foo.feature", 12).to_s ).to eq "foo.feature:12"
|
37
|
-
end
|
38
|
-
|
39
|
-
it "is file for a wildcard location" do
|
40
|
-
expect( Location.new("foo.feature").to_s ).to eq "foo.feature"
|
41
|
-
end
|
42
|
-
|
43
|
-
it "is file:first_line..last_line for a ranged location" do
|
44
|
-
expect( Location.new("foo.feature", 13..19).to_s ).to eq "foo.feature:13..19"
|
45
|
-
end
|
46
|
-
|
47
|
-
it "is file:line:line:line for an arbitrary set of lines" do
|
48
|
-
expect( Location.new("foo.feature", [1,3,5]).to_s ).to eq "foo.feature:1:3:5"
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe "matches" do
|
53
|
-
let(:matching) { Location.new(file, line) }
|
54
|
-
let(:same_file_other_line) { Location.new(file, double) }
|
55
|
-
let(:not_matching) { Location.new(other_file, line) }
|
56
|
-
let(:other_file) { double }
|
57
|
-
|
58
|
-
context 'a precise location' do
|
59
|
-
let(:precise) { Location.new(file, line) }
|
60
|
-
|
61
|
-
it "matches a precise location of the same file and line" do
|
62
|
-
expect( matching ).to be_match(precise)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "does not match a precise location on a different line in the same file" do
|
66
|
-
expect( matching ).not_to be_match(same_file_other_line)
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
context 'a wildcard' do
|
72
|
-
let(:wildcard) { Location.new(file) }
|
73
|
-
|
74
|
-
it "matches any location with the same filename" do
|
75
|
-
expect( wildcard ).to be_match(matching)
|
76
|
-
end
|
77
|
-
|
78
|
-
it "is matched by any location of the same file" do
|
79
|
-
expect( matching ).to be_match(wildcard)
|
80
|
-
end
|
81
|
-
|
82
|
-
it "does not match a location in a different file" do
|
83
|
-
expect( wildcard ).not_to be_match(not_matching)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
context 'a range wildcard' do
|
88
|
-
let(:range) { Location.new("foo.feature", 13..17) }
|
89
|
-
|
90
|
-
it "matches the first line in the same file" do
|
91
|
-
other = Location.new("foo.feature", 13)
|
92
|
-
expect( range ).to be_match(other)
|
93
|
-
end
|
94
|
-
|
95
|
-
it "matches a line within the docstring in the same file" do
|
96
|
-
other = Location.new("foo.feature", 15)
|
97
|
-
expect( range ).to be_match(other)
|
98
|
-
end
|
99
|
-
|
100
|
-
it "is matched by a line within the docstring in the same file" do
|
101
|
-
other = Location.new("foo.feature", 15)
|
102
|
-
expect( other ).to be_match(range)
|
103
|
-
end
|
104
|
-
|
105
|
-
it "matches a wildcard in the same file" do
|
106
|
-
wildcard = Location.new("foo.feature")
|
107
|
-
expect( range ).to be_match(wildcard)
|
108
|
-
end
|
109
|
-
|
110
|
-
it "does not match a location outside of the range" do
|
111
|
-
other = Location.new("foo.feature", 18)
|
112
|
-
expect( range ).not_to be_match(other)
|
113
|
-
end
|
114
|
-
|
115
|
-
it "does not match a location in another file" do
|
116
|
-
other = Location.new("bar.feature", 13)
|
117
|
-
expect( range ).not_to be_match(other)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
context "an arbitrary list of lines" do
|
122
|
-
let(:location) { Location.new("foo.feature", [1,5,6,7]) }
|
123
|
-
|
124
|
-
it "matches any of the given lines" do
|
125
|
-
[1,5,6,7].each do |line|
|
126
|
-
other = Location.new("foo.feature", line)
|
127
|
-
expect(location).to be_match(other)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
it "does not match another line" do
|
132
|
-
other = Location.new("foo.feature", 2)
|
133
|
-
expect(location).not_to be_match(other)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
describe "created from source location" do
|
139
|
-
context "when the location is in the tree below pwd" do
|
140
|
-
it "create a relative path from pwd" do
|
141
|
-
expect( Location.from_source_location(Dir.pwd + "/path/file.rb", 1).file ).to eq "path/file.rb"
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
context "when the location is in an installed gem" do
|
146
|
-
it "create a relative path from the gem directory" do
|
147
|
-
expect( Location.from_source_location("/path/gems/gem-name/path/file.rb", 1).file ).to eq "gem-name/path/file.rb"
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
context "when the location is neither below pwd nor in an installed gem" do
|
152
|
-
it "use the absolute path to the file" do
|
153
|
-
expect( Location.from_source_location("/path/file.rb", 1).file ).to eq "/path/file.rb"
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
describe "created from file-colon-line" do
|
159
|
-
it "handles also Windows paths" do
|
160
|
-
expect( Location.from_file_colon_line("c:\path\file.rb:123").file ).to eq "c:\path\file.rb"
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
describe "created of caller" do
|
165
|
-
it "use the location of the caller" do
|
166
|
-
expect( Location.of_caller.to_s ).to be_included_in caller[0]
|
167
|
-
end
|
168
|
-
|
169
|
-
context "when specifying additional caller depth"do
|
170
|
-
it "use the location of the n:th caller" do
|
171
|
-
expect( Location.of_caller(1).to_s ).to be_included_in caller[1]
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
describe ".merge" do
|
177
|
-
it "merges locations from the same file" do
|
178
|
-
file = "test.feature"
|
179
|
-
location = Location.merge(
|
180
|
-
Location.new(file, 1),
|
181
|
-
Location.new(file, 6),
|
182
|
-
Location.new(file, 7)
|
183
|
-
)
|
184
|
-
expect(location.to_s).to eq "test.feature:1:6:7"
|
185
|
-
end
|
186
|
-
|
187
|
-
it "raises an error when the locations are from different files" do
|
188
|
-
expect {
|
189
|
-
Location.merge(
|
190
|
-
Location.new("one.feature", 1),
|
191
|
-
Location.new("two.feature", 1)
|
192
|
-
)
|
193
|
-
}.to raise_error(IncompatibleLocations)
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|