cuke_modeler 2.0.0 → 3.3.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/CHANGELOG.md +59 -2
- data/README.md +14 -16
- data/cuke_modeler.gemspec +12 -9
- data/lib/cuke_modeler.rb +1 -0
- data/lib/cuke_modeler/adapters/gherkin_10_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_11_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_12_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_13_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_14_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_15_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/{gherkin_6_adapter.rb → gherkin_9_adapter.rb} +104 -69
- data/lib/cuke_modeler/containing.rb +15 -5
- data/lib/cuke_modeler/models/background.rb +1 -1
- data/lib/cuke_modeler/models/cell.rb +1 -1
- data/lib/cuke_modeler/models/comment.rb +1 -1
- data/lib/cuke_modeler/models/directory.rb +2 -2
- data/lib/cuke_modeler/models/doc_string.rb +1 -1
- data/lib/cuke_modeler/models/example.rb +1 -1
- data/lib/cuke_modeler/models/feature.rb +16 -5
- data/lib/cuke_modeler/models/feature_file.rb +2 -2
- data/lib/cuke_modeler/models/outline.rb +1 -1
- data/lib/cuke_modeler/models/row.rb +1 -1
- data/lib/cuke_modeler/models/rule.rb +99 -0
- data/lib/cuke_modeler/models/scenario.rb +1 -1
- data/lib/cuke_modeler/models/step.rb +1 -1
- data/lib/cuke_modeler/models/table.rb +1 -1
- data/lib/cuke_modeler/models/tag.rb +1 -1
- data/lib/cuke_modeler/parsing.rb +89 -110
- data/lib/cuke_modeler/version.rb +1 -1
- data/testing/cucumber/features/modeling/feature_modeling.feature +28 -7
- data/testing/cucumber/features/modeling/feature_output.feature +45 -23
- data/testing/cucumber/features/modeling/rule_modeling.feature +108 -0
- data/testing/cucumber/features/modeling/rule_output.feature +111 -0
- metadata +39 -140
- data/.gitignore +0 -18
- data/.simplecov +0 -7
- data/.travis.yml +0 -63
- data/Gemfile +0 -37
- data/Rakefile +0 -73
- data/appveyor.yml +0 -61
- data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +0 -274
- data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +0 -297
- data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +0 -309
- data/testing/cucumber/step_definitions/action_steps.rb +0 -13
- data/testing/cucumber/step_definitions/background_steps.rb +0 -1
- data/testing/cucumber/step_definitions/directory_steps.rb +0 -6
- data/testing/cucumber/step_definitions/doc_string_steps.rb +0 -1
- data/testing/cucumber/step_definitions/feature_file_steps.rb +0 -16
- data/testing/cucumber/step_definitions/feature_steps.rb +0 -7
- data/testing/cucumber/step_definitions/modeling_steps.rb +0 -49
- data/testing/cucumber/step_definitions/setup_steps.rb +0 -32
- data/testing/cucumber/step_definitions/step_steps.rb +0 -3
- data/testing/cucumber/step_definitions/table_steps.rb +0 -1
- data/testing/cucumber/step_definitions/tag_steps.rb +0 -3
- data/testing/cucumber/step_definitions/verification_steps.rb +0 -181
- data/testing/cucumber/support/env.rb +0 -30
- data/testing/dialect_helper.rb +0 -48
- data/testing/file_helper.rb +0 -47
- data/testing/gemfiles/gherkin2.gemfile +0 -33
- data/testing/gemfiles/gherkin3.gemfile +0 -26
- data/testing/gemfiles/gherkin4.gemfile +0 -27
- data/testing/gemfiles/gherkin5.gemfile +0 -27
- data/testing/gemfiles/gherkin6.gemfile +0 -10
- data/testing/rspec/spec/integration/adapters/gherkin_2_adapter_spec.rb +0 -166
- data/testing/rspec/spec/integration/adapters/gherkin_3_adapter_spec.rb +0 -166
- data/testing/rspec/spec/integration/adapters/gherkin_4_adapter_spec.rb +0 -165
- data/testing/rspec/spec/integration/adapters/gherkin_6_adapter_spec.rb +0 -166
- data/testing/rspec/spec/integration/models/background_integration_spec.rb +0 -442
- data/testing/rspec/spec/integration/models/cell_integration_spec.rb +0 -335
- data/testing/rspec/spec/integration/models/comment_integration_spec.rb +0 -177
- data/testing/rspec/spec/integration/models/directory_integration_spec.rb +0 -218
- data/testing/rspec/spec/integration/models/doc_string_integration_spec.rb +0 -402
- data/testing/rspec/spec/integration/models/example_integration_spec.rb +0 -741
- data/testing/rspec/spec/integration/models/feature_file_integration_spec.rb +0 -272
- data/testing/rspec/spec/integration/models/feature_integration_spec.rb +0 -650
- data/testing/rspec/spec/integration/models/model_integration_spec.rb +0 -15
- data/testing/rspec/spec/integration/models/outline_integration_spec.rb +0 -624
- data/testing/rspec/spec/integration/models/row_integration_spec.rb +0 -291
- data/testing/rspec/spec/integration/models/scenario_integration_spec.rb +0 -479
- data/testing/rspec/spec/integration/models/step_integration_spec.rb +0 -569
- data/testing/rspec/spec/integration/models/table_integration_spec.rb +0 -337
- data/testing/rspec/spec/integration/models/tag_integration_spec.rb +0 -259
- data/testing/rspec/spec/integration/nested_integration_spec.rb +0 -91
- data/testing/rspec/spec/integration/parsing_integration_spec.rb +0 -122
- data/testing/rspec/spec/integration/shared/models_integration_specs.rb +0 -18
- data/testing/rspec/spec/spec_helper.rb +0 -136
- data/testing/rspec/spec/unit/cuke_modeler_unit_spec.rb +0 -25
- data/testing/rspec/spec/unit/described_unit_spec.rb +0 -23
- data/testing/rspec/spec/unit/models/background_unit_spec.rb +0 -83
- data/testing/rspec/spec/unit/models/cell_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/models/comment_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/models/directory_unit_spec.rb +0 -127
- data/testing/rspec/spec/unit/models/doc_string_unit_spec.rb +0 -100
- data/testing/rspec/spec/unit/models/example_unit_spec.rb +0 -133
- data/testing/rspec/spec/unit/models/feature_file_unit_spec.rb +0 -125
- data/testing/rspec/spec/unit/models/feature_unit_spec.rb +0 -157
- data/testing/rspec/spec/unit/models/model_unit_spec.rb +0 -15
- data/testing/rspec/spec/unit/models/outline_unit_spec.rb +0 -117
- data/testing/rspec/spec/unit/models/row_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/models/scenario_unit_spec.rb +0 -86
- data/testing/rspec/spec/unit/models/step_unit_spec.rb +0 -109
- data/testing/rspec/spec/unit/models/table_unit_spec.rb +0 -77
- data/testing/rspec/spec/unit/models/tag_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/named_unit_spec.rb +0 -23
- data/testing/rspec/spec/unit/nested_unit_spec.rb +0 -43
- data/testing/rspec/spec/unit/parsed_unit_spec.rb +0 -27
- data/testing/rspec/spec/unit/parsing_unit_spec.rb +0 -54
- data/testing/rspec/spec/unit/shared/bare_bones_models_unit_specs.rb +0 -14
- data/testing/rspec/spec/unit/shared/containing_models_unit_specs.rb +0 -127
- data/testing/rspec/spec/unit/shared/described_models_unit_specs.rb +0 -38
- data/testing/rspec/spec/unit/shared/keyworded_models_unit_specs.rb +0 -58
- data/testing/rspec/spec/unit/shared/models_unit_specs.rb +0 -15
- data/testing/rspec/spec/unit/shared/named_models_unit_specs.rb +0 -39
- data/testing/rspec/spec/unit/shared/nested_models_unit_specs.rb +0 -51
- data/testing/rspec/spec/unit/shared/parsed_models_unit_specs.rb +0 -39
- data/testing/rspec/spec/unit/shared/prepopulated_models_unit_specs.rb +0 -18
- data/testing/rspec/spec/unit/shared/sourced_models_unit_specs.rb +0 -39
- data/testing/rspec/spec/unit/shared/stepped_models_unit_specs.rb +0 -46
- data/testing/rspec/spec/unit/shared/stringifiable_models_unit_specs.rb +0 -18
- data/testing/rspec/spec/unit/shared/tagged_models_unit_specs.rb +0 -72
- data/testing/rspec/spec/unit/sourceable_unit_spec.rb +0 -27
- data/testing/rspec/spec/unit/stepped_unit_spec.rb +0 -23
- data/testing/rspec/spec/unit/taggable_unit_spec.rb +0 -69
- data/testing/test_languages.json +0 -45
- data/todo.txt +0 -25
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
require "#{File.dirname(__FILE__)}/../spec_helper"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
describe 'Nested, Integration' do
|
|
5
|
-
|
|
6
|
-
let(:nodule) { CukeModeler::Nested }
|
|
7
|
-
let(:nested_model) { Object.new.extend(nodule) }
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
describe 'unique behavior' do
|
|
11
|
-
|
|
12
|
-
describe 'an object including the module' do
|
|
13
|
-
|
|
14
|
-
describe 'getting ancestors' do
|
|
15
|
-
|
|
16
|
-
context 'with a background ancestor' do
|
|
17
|
-
|
|
18
|
-
let(:background) { CukeModeler::Background.new }
|
|
19
|
-
|
|
20
|
-
before(:each) do
|
|
21
|
-
nested_model.parent_model = background
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
it "will find its background as a 'test' ancestor" do
|
|
26
|
-
ancestor = nested_model.get_ancestor(:test)
|
|
27
|
-
|
|
28
|
-
expect(ancestor).to equal(background)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "will find its background as a 'background' ancestor" do
|
|
32
|
-
ancestor = nested_model.get_ancestor(:background)
|
|
33
|
-
|
|
34
|
-
expect(ancestor).to equal(background)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
context 'with a scenario ancestor' do
|
|
40
|
-
|
|
41
|
-
let(:scenario) { CukeModeler::Scenario.new }
|
|
42
|
-
|
|
43
|
-
before(:each) do
|
|
44
|
-
nested_model.parent_model = scenario
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
it "will find its scenario as a 'test' ancestor" do
|
|
49
|
-
ancestor = nested_model.get_ancestor(:test)
|
|
50
|
-
|
|
51
|
-
expect(ancestor).to equal(scenario)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it "will find its scenario as a 'scenario' ancestor" do
|
|
55
|
-
ancestor = nested_model.get_ancestor(:scenario)
|
|
56
|
-
|
|
57
|
-
expect(ancestor).to equal(scenario)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
context 'with an outline ancestor' do
|
|
63
|
-
|
|
64
|
-
let(:outline) { CukeModeler::Outline.new }
|
|
65
|
-
|
|
66
|
-
before(:each) do
|
|
67
|
-
nested_model.parent_model = outline
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
it "will find its outline as a 'test' ancestor" do
|
|
72
|
-
ancestor = nested_model.get_ancestor(:test)
|
|
73
|
-
|
|
74
|
-
expect(ancestor).to equal(outline)
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it "will find its outline as a 'outline' ancestor" do
|
|
78
|
-
ancestor = nested_model.get_ancestor(:outline)
|
|
79
|
-
|
|
80
|
-
expect(ancestor).to equal(outline)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
end
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
require "#{File.dirname(__FILE__)}/../spec_helper"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
describe 'Parsing, Integration' do
|
|
5
|
-
|
|
6
|
-
let(:nodule) { CukeModeler::Parsing }
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
describe 'unique behavior' do
|
|
10
|
-
|
|
11
|
-
it 'will complain if using an unknown version of `gherkin`' do
|
|
12
|
-
original_version = Gem.loaded_specs['gherkin'].version
|
|
13
|
-
unknown_version = Gem::Version.new('0.0.0')
|
|
14
|
-
|
|
15
|
-
begin
|
|
16
|
-
Gem.loaded_specs['gherkin'].instance_variable_set(:@version, unknown_version)
|
|
17
|
-
|
|
18
|
-
expect { load "#{File.dirname(__FILE__)}/../../../../lib/cuke_modeler/parsing.rb" }.to raise_error("Unknown Gherkin version: '0.0.0'")
|
|
19
|
-
ensure
|
|
20
|
-
Gem.loaded_specs['gherkin'].instance_variable_set(:@version, original_version)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it 'loads the correct dialects based on the version of Gherkin used', :gherkin6 => true do
|
|
25
|
-
expect(nodule.dialects).to equal(Gherkin::DIALECTS)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it 'loads the correct dialects based on the version of Gherkin used', :gherkin3 => true, :gherkin4_5 => true do
|
|
29
|
-
expect(nodule.dialects).to equal(Gherkin::DIALECTS)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it 'loads the correct dialects based on the version of Gherkin used', :gherkin2 => true do
|
|
33
|
-
expect(nodule.dialects).to equal(Gherkin::I18n::LANGUAGES)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it 'can parse text that uses a non-default dialect' do
|
|
37
|
-
source_text = "# language: en-au
|
|
38
|
-
Pretty much:
|
|
39
|
-
|
|
40
|
-
First off:
|
|
41
|
-
Y'know foo
|
|
42
|
-
|
|
43
|
-
Awww, look mate:
|
|
44
|
-
It's just unbelievable that zip
|
|
45
|
-
But at the end of the day I reckon bar
|
|
46
|
-
|
|
47
|
-
Reckon it's like:
|
|
48
|
-
Yeah nah zen
|
|
49
|
-
Too right baz
|
|
50
|
-
You'll wanna:
|
|
51
|
-
| param |
|
|
52
|
-
| value |"
|
|
53
|
-
|
|
54
|
-
expect { nodule.parse_text(source_text) }.to_not raise_error
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it 'raises and error if given something to parse besides a string' do
|
|
58
|
-
expect { nodule.parse_text(5) }.to raise_error(ArgumentError, /Text to parse must be a String but got/)
|
|
59
|
-
expect { nodule.parse_text("#{FEATURE_KEYWORD}:") }.to_not raise_error
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
it 'includes the type of object provided when raising an non-string exception' do
|
|
63
|
-
expect { nodule.parse_text(:not_a_string) }.to raise_error(ArgumentError, /Symbol/)
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
# todo - Stop doing this. Just return a feature file rooted AST. (Will require major version number change)
|
|
67
|
-
it 'returns an Array' do
|
|
68
|
-
result = nodule.parse_text("#{FEATURE_KEYWORD}:")
|
|
69
|
-
expect(result).to be_a(Array)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
it 'raises an error if an error is encountered while parsing text' do
|
|
73
|
-
expect { nodule.parse_text('bad file') }.to raise_error(ArgumentError, /Error encountered while parsing '.*'/)
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
it 'includes the file parsed in the error that it raises' do
|
|
77
|
-
expect { nodule.parse_text('bad file', 'file foo.txt') }.to raise_error(/'file foo\.txt'/)
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
it 'has a default file name used while parsing if one is not provided' do
|
|
81
|
-
expect { nodule.parse_text('bad file') }.to raise_error(ArgumentError, /'cuke_modeler_fake_file\.feature'/)
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
it 'includes the underlying error message in the error that it raises' do
|
|
85
|
-
begin
|
|
86
|
-
$old_method = CukeModeler::Parsing.method(:parsing_method)
|
|
87
|
-
|
|
88
|
-
# Custom error type in order to ensure that we are throwing the correct thing
|
|
89
|
-
module CukeModeler
|
|
90
|
-
class TestError < StandardError
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
# Monkey patch the parsing method to throw the error that we need for testing
|
|
95
|
-
module CukeModeler
|
|
96
|
-
module Parsing
|
|
97
|
-
class << self
|
|
98
|
-
def parsing_method(*args)
|
|
99
|
-
raise(CukeModeler::TestError, 'something went wrong')
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
expect { nodule.parse_text('bad file') }.to raise_error(/CukeModeler::TestError.*something went wrong/)
|
|
107
|
-
ensure
|
|
108
|
-
# Making sure that our changes don't escape a test and ruin the rest of the suite
|
|
109
|
-
module CukeModeler
|
|
110
|
-
module Parsing
|
|
111
|
-
class << self
|
|
112
|
-
define_method(:parsing_method, $old_method)
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
require "#{File.dirname(__FILE__)}/../../spec_helper"
|
|
2
|
-
|
|
3
|
-
shared_examples_for 'a model, integration' do
|
|
4
|
-
|
|
5
|
-
# clazz must be defined by the calling file
|
|
6
|
-
|
|
7
|
-
let(:model) { clazz.new }
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
describe 'unique behavior' do
|
|
11
|
-
|
|
12
|
-
it 'inherits from the common model class' do
|
|
13
|
-
expect(model).to be_a(CukeModeler::Model)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
end
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
unless RUBY_VERSION.to_s < '1.9.0'
|
|
2
|
-
require 'simplecov'
|
|
3
|
-
SimpleCov.command_name('rspec_tests')
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
# Ruby 1.8.x seems to have trouble if relative paths get too nested, so resolving the path before using it here
|
|
8
|
-
this_dir = File.expand_path(File.dirname(__FILE__))
|
|
9
|
-
require "#{this_dir}/../../../lib/cuke_modeler"
|
|
10
|
-
|
|
11
|
-
require "#{this_dir}/unit/shared/models_unit_specs"
|
|
12
|
-
require "#{this_dir}/integration/shared/models_integration_specs"
|
|
13
|
-
require "#{this_dir}/unit/shared/named_models_unit_specs"
|
|
14
|
-
require "#{this_dir}/unit/shared/described_models_unit_specs"
|
|
15
|
-
require "#{this_dir}/unit/shared/stepped_models_unit_specs"
|
|
16
|
-
require "#{this_dir}/unit/shared/stringifiable_models_unit_specs"
|
|
17
|
-
require "#{this_dir}/unit/shared/nested_models_unit_specs"
|
|
18
|
-
require "#{this_dir}/unit/shared/tagged_models_unit_specs"
|
|
19
|
-
require "#{this_dir}/unit/shared/containing_models_unit_specs"
|
|
20
|
-
require "#{this_dir}/unit/shared/bare_bones_models_unit_specs"
|
|
21
|
-
require "#{this_dir}/unit/shared/prepopulated_models_unit_specs"
|
|
22
|
-
require "#{this_dir}/unit/shared/sourced_models_unit_specs"
|
|
23
|
-
require "#{this_dir}/unit/shared/parsed_models_unit_specs"
|
|
24
|
-
require "#{this_dir}/unit/shared/keyworded_models_unit_specs"
|
|
25
|
-
|
|
26
|
-
require "#{this_dir}/../../dialect_helper"
|
|
27
|
-
require "#{this_dir}/../../file_helper"
|
|
28
|
-
|
|
29
|
-
require 'rubygems/mock_gem_ui'
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
# Use a random dialect for testing in order to avoid hard coded language assumptions in the
|
|
33
|
-
# implementation and making the test dialect the default dialect so that language headers
|
|
34
|
-
# aren't needed for all of the test code. Only possible with some versions of Gherkin.
|
|
35
|
-
|
|
36
|
-
gherkin_version = Gem.loaded_specs['gherkin'].version.version
|
|
37
|
-
|
|
38
|
-
case gherkin_version
|
|
39
|
-
when /^6\./
|
|
40
|
-
# gherkin 6 does not preload the dialect module
|
|
41
|
-
require 'gherkin/dialect' if Gem.loaded_specs['gherkin'].version.version[/^6\./]
|
|
42
|
-
|
|
43
|
-
# TODO: choose randomly from Gherkin::DIALECTS once I figure out how to handle encodings...
|
|
44
|
-
test_dialect = ['en', 'en-lol', 'en-pirate', 'en-Scouse'].sample
|
|
45
|
-
puts "Testing with dialect '#{test_dialect}'..."
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
CukeModeler::DialectHelper.set_dialect(Gherkin::DIALECTS[test_dialect])
|
|
49
|
-
CukeModeler::Parsing.dialect = test_dialect
|
|
50
|
-
when /^[543]\./
|
|
51
|
-
# TODO: stop using test dialect and just randomize for all version of `gherkin`
|
|
52
|
-
dialect_file_path = "#{this_dir}/../../test_languages.json"
|
|
53
|
-
test_dialects = JSON.parse File.open(dialect_file_path, 'r:UTF-8').read
|
|
54
|
-
|
|
55
|
-
Gherkin::DIALECTS.merge!(test_dialects)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
module Gherkin
|
|
59
|
-
class Parser
|
|
60
|
-
|
|
61
|
-
alias_method :original_parse, :parse
|
|
62
|
-
|
|
63
|
-
def parse(token_scanner, token_matcher = TokenMatcher.new('cm-test'))
|
|
64
|
-
original_parse(token_scanner, token_matcher)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
CukeModeler::DialectHelper.set_dialect(test_dialects['cm-test'])
|
|
71
|
-
CukeModeler::Parsing.dialect = 'cm-test'
|
|
72
|
-
when /^2\./
|
|
73
|
-
CukeModeler::DialectHelper.set_dialect(Gherkin::I18n::LANGUAGES['en'])
|
|
74
|
-
CukeModeler::Parsing.dialect = 'en'
|
|
75
|
-
else
|
|
76
|
-
raise("Unknown Gherkin version: '#{gherkin_version}'")
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
RSpec.configure do |config|
|
|
81
|
-
gherkin_version = Gem.loaded_specs['gherkin'].version.version
|
|
82
|
-
|
|
83
|
-
case gherkin_version
|
|
84
|
-
when /^6\./
|
|
85
|
-
config.filter_run_excluding :gherkin2 => true,
|
|
86
|
-
:gherkin3 => true,
|
|
87
|
-
:gherkin4_5 => true,
|
|
88
|
-
:gherkin6 => false
|
|
89
|
-
when /^[54]\./
|
|
90
|
-
config.filter_run_excluding :gherkin2 => true,
|
|
91
|
-
:gherkin3 => true,
|
|
92
|
-
:gherkin4_5 => false,
|
|
93
|
-
:gherkin6 => true
|
|
94
|
-
when /^3\./
|
|
95
|
-
config.filter_run_excluding :gherkin2 => true,
|
|
96
|
-
:gherkin3 => false,
|
|
97
|
-
:gherkin4_5 => true,
|
|
98
|
-
:gherkin6 => true
|
|
99
|
-
when /^2\./
|
|
100
|
-
config.filter_run_excluding :gherkin2 => false,
|
|
101
|
-
:gherkin3 => true,
|
|
102
|
-
:gherkin4_5 => true,
|
|
103
|
-
:gherkin6 => true
|
|
104
|
-
else
|
|
105
|
-
raise("Unknown Gherkin version: '#{gherkin_version}'")
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
config.before(:suite) do
|
|
109
|
-
FEATURE_KEYWORD = CukeModeler::DialectHelper.feature_keyword
|
|
110
|
-
BACKGROUND_KEYWORD = CukeModeler::DialectHelper.background_keyword
|
|
111
|
-
SCENARIO_KEYWORD = CukeModeler::DialectHelper.scenario_keyword
|
|
112
|
-
OUTLINE_KEYWORD = CukeModeler::DialectHelper.outline_keyword
|
|
113
|
-
EXAMPLE_KEYWORD = CukeModeler::DialectHelper.example_keyword
|
|
114
|
-
STEP_KEYWORD = CukeModeler::DialectHelper.step_keyword
|
|
115
|
-
GIVEN_KEYWORD = CukeModeler::DialectHelper.given_keyword
|
|
116
|
-
THEN_KEYWORD = CukeModeler::DialectHelper.then_keyword
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
config.after(:suite) do
|
|
120
|
-
CukeModeler::FileHelper.created_directories.each do |dir_path|
|
|
121
|
-
FileUtils.remove_entry(dir_path, true)
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
def assert_bidirectional_equality(base_thing, compared_thing)
|
|
127
|
-
expect(base_thing).to eq(compared_thing)
|
|
128
|
-
expect(compared_thing).to eq(base_thing)
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
def assert_bidirectional_inequality(base_thing, compared_thing)
|
|
132
|
-
expect(base_thing).to_not eq(compared_thing)
|
|
133
|
-
expect(compared_thing).to_not eq(base_thing)
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
require "#{File.dirname(__FILE__)}/../spec_helper"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
describe 'the gem' do
|
|
5
|
-
|
|
6
|
-
let(:gemspec) { eval(File.read "#{File.dirname(__FILE__)}/../../../../cuke_modeler.gemspec") }
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
it 'validates cleanly' do
|
|
10
|
-
mock_ui = Gem::MockGemUi.new
|
|
11
|
-
Gem::DefaultUserInteraction.use_ui(mock_ui) { gemspec.validate }
|
|
12
|
-
|
|
13
|
-
expect(mock_ui.error).to_not match(/warn/i)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
describe CukeModeler do
|
|
20
|
-
|
|
21
|
-
it "has a version number" do
|
|
22
|
-
expect(CukeModeler::VERSION).not_to be nil
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
require "#{File.dirname(__FILE__)}/../spec_helper"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
describe 'Described, Unit', :unit_test => true do
|
|
5
|
-
|
|
6
|
-
let(:nodule) { CukeModeler::Described }
|
|
7
|
-
let(:described_model) { Object.new.extend(nodule) }
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
it 'has a description' do
|
|
11
|
-
expect(described_model).to respond_to(:description)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it 'can change its description' do
|
|
15
|
-
expect(described_model).to respond_to(:description=)
|
|
16
|
-
|
|
17
|
-
described_model.description = :some_description
|
|
18
|
-
expect(described_model.description).to eq(:some_description)
|
|
19
|
-
described_model.description = :some_other_description
|
|
20
|
-
expect(described_model.description).to eq(:some_other_description)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
end
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
require "#{File.dirname(__FILE__)}/../../spec_helper"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
describe 'Background, Unit', :unit_test => true do
|
|
5
|
-
|
|
6
|
-
let(:clazz) { CukeModeler::Background }
|
|
7
|
-
let(:background) { clazz.new }
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
describe 'common behavior' do
|
|
11
|
-
|
|
12
|
-
it_should_behave_like 'a model'
|
|
13
|
-
it_should_behave_like 'a keyworded model'
|
|
14
|
-
it_should_behave_like 'a named model'
|
|
15
|
-
it_should_behave_like 'a described model'
|
|
16
|
-
it_should_behave_like 'a stepped model'
|
|
17
|
-
it_should_behave_like 'a sourced model'
|
|
18
|
-
it_should_behave_like 'a parsed model'
|
|
19
|
-
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
describe 'unique behavior' do
|
|
24
|
-
|
|
25
|
-
it 'contains steps' do
|
|
26
|
-
steps = [:step_1, :step_2]
|
|
27
|
-
everything = steps
|
|
28
|
-
|
|
29
|
-
background.steps = steps
|
|
30
|
-
|
|
31
|
-
expect(background.children).to match_array(everything)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
describe 'comparison' do
|
|
36
|
-
|
|
37
|
-
it 'can gracefully be compared to other types of objects' do
|
|
38
|
-
# Some common types of object
|
|
39
|
-
[1, 'foo', :bar, [], {}].each do |thing|
|
|
40
|
-
expect { background == thing }.to_not raise_error
|
|
41
|
-
expect(background == thing).to be false
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
describe 'background output' do
|
|
49
|
-
|
|
50
|
-
context 'from abstract instantiation' do
|
|
51
|
-
|
|
52
|
-
let(:background) { clazz.new }
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
it 'can output an empty background' do
|
|
56
|
-
expect { background.to_s }.to_not raise_error
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it 'can output a background that has only a keyword' do
|
|
60
|
-
background.keyword = 'foo'
|
|
61
|
-
|
|
62
|
-
expect(background.to_s).to eq('foo:')
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
it 'can output a background that has only a name' do
|
|
66
|
-
background.name = 'a name'
|
|
67
|
-
|
|
68
|
-
expect { background.to_s }.to_not raise_error
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it 'can output a background that has only a description' do
|
|
72
|
-
background.description = 'a description'
|
|
73
|
-
|
|
74
|
-
expect { background.to_s }.to_not raise_error
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
end
|