yari 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.idea/.name +1 -0
- data/.idea/encodings.xml +7 -0
- data/.idea/misc.xml +14 -0
- data/.idea/modules.xml +8 -0
- data/.idea/workspace.xml +712 -0
- data/.idea/yari.iml +135 -0
- data/.rspec +3 -0
- data/.travis.yml +14 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/coveralls.yml +1 -0
- data/features/no_scenario.feature +1 -0
- data/features/scenario_outline.feature +10 -0
- data/features/simple_feature.feature +22 -0
- data/features/test_cases.feature +6 -0
- data/features/updated_feature.feature +12 -0
- data/features/updated_scenario.feature +12 -0
- data/lib/yari.rb +74 -0
- data/lib/yari/builder.rb +88 -0
- data/lib/yari/version.rb +3 -0
- data/lib/yari/yari_dsl.rb +125 -0
- data/lib/yari/yari_loader.rb +52 -0
- data/spec/builder_spec.rb +45 -0
- data/spec/features/no_feature_spec.rb +7 -0
- data/spec/features/no_scenario_spec.rb +5 -0
- data/spec/features/scenario_outline_spec.rb +10 -0
- data/spec/features/simple_feature_spec.rb +26 -0
- data/spec/features/test_cases_spec.rb +13 -0
- data/spec/features/updated_feature_spec.rb +11 -0
- data/spec/features/updated_scenario_spec.rb +11 -0
- data/spec/integration_spec.rb +87 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/yari_spec.rb +58 -0
- data/yari.gemspec +27 -0
- metadata +169 -0
data/.idea/yari.iml
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="FacetManager">
|
4
|
+
<facet type="gem" name="Ruby Gem">
|
5
|
+
<configuration>
|
6
|
+
<option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
|
7
|
+
<option name="GEM_APP_TEST_PATH" value="$MODULE_DIR$/test" />
|
8
|
+
<option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
|
9
|
+
</configuration>
|
10
|
+
</facet>
|
11
|
+
</component>
|
12
|
+
<component name="ModuleRunConfigurationManager">
|
13
|
+
<configuration default="false" name="Run spec 'builder_spec': yari" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
|
14
|
+
<predefined_log_file id="RUBY_RSPEC" enabled="true" />
|
15
|
+
<module name="yari" />
|
16
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
17
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
|
18
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
|
19
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
|
20
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
|
21
|
+
<envs>
|
22
|
+
<env name="JRUBY_OPTS" value="-X+O" />
|
23
|
+
</envs>
|
24
|
+
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
|
25
|
+
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
26
|
+
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov" />
|
27
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
|
28
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/builder_spec.rb" />
|
29
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
|
30
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
|
31
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
|
32
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
|
33
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
|
34
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
|
35
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
|
36
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
|
37
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
|
38
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
|
39
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
|
40
|
+
<method />
|
41
|
+
</configuration>
|
42
|
+
<configuration default="false" name="Run spec 'integration_spec': yari" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
|
43
|
+
<predefined_log_file id="RUBY_RSPEC" enabled="true" />
|
44
|
+
<module name="yari" />
|
45
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
46
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
|
47
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
|
48
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
|
49
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
|
50
|
+
<envs>
|
51
|
+
<env name="JRUBY_OPTS" value="-X+O" />
|
52
|
+
</envs>
|
53
|
+
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
|
54
|
+
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
55
|
+
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov" />
|
56
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
|
57
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/integration_spec.rb" />
|
58
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
|
59
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
|
60
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
|
61
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
|
62
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
|
63
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
|
64
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
|
65
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
|
66
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
|
67
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
|
68
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
|
69
|
+
<method />
|
70
|
+
</configuration>
|
71
|
+
<configuration default="false" name="Run spec 'rspec-gherkin_spec': yari" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
|
72
|
+
<predefined_log_file id="RUBY_RSPEC" enabled="true" />
|
73
|
+
<module name="yari" />
|
74
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
75
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
|
76
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
|
77
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
|
78
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
|
79
|
+
<envs>
|
80
|
+
<env name="JRUBY_OPTS" value="-X+O" />
|
81
|
+
</envs>
|
82
|
+
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
|
83
|
+
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
84
|
+
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov" />
|
85
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
|
86
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="C:\Users\Alan\RubymineProjects\yari\spec\yari_spec.rb" />
|
87
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
|
88
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
|
89
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
|
90
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
|
91
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
|
92
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
|
93
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
|
94
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
|
95
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
|
96
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
|
97
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
|
98
|
+
<method />
|
99
|
+
</configuration>
|
100
|
+
</component>
|
101
|
+
<component name="NewModuleRootManager">
|
102
|
+
<content url="file://$MODULE_DIR$">
|
103
|
+
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
104
|
+
<excludeFolder url="file://$MODULE_DIR$/.bundle" />
|
105
|
+
<excludeFolder url="file://$MODULE_DIR$/vendor/bundle" />
|
106
|
+
</content>
|
107
|
+
<orderEntry type="inheritedJdk" />
|
108
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
109
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.7.7, ruby-2.0.0-p598) [gem]" level="application" />
|
110
|
+
<orderEntry type="library" scope="PROVIDED" name="coveralls (v0.8.2, ruby-2.0.0-p598) [gem]" level="application" />
|
111
|
+
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, ruby-2.0.0-p598) [gem]" level="application" />
|
112
|
+
<orderEntry type="library" scope="PROVIDED" name="docile (v1.1.5, ruby-2.0.0-p598) [gem]" level="application" />
|
113
|
+
<orderEntry type="library" scope="PROVIDED" name="domain_name (v0.5.24, ruby-2.0.0-p598) [gem]" level="application" />
|
114
|
+
<orderEntry type="library" scope="PROVIDED" name="ffi (v1.9.10, ruby-2.0.0-p598) [gem]" level="application" />
|
115
|
+
<orderEntry type="library" scope="PROVIDED" name="gherkin (v3.2.0, ruby-2.0.0-p598) [gem]" level="application" />
|
116
|
+
<orderEntry type="library" scope="PROVIDED" name="http-cookie (v1.0.2, ruby-2.0.0-p598) [gem]" level="application" />
|
117
|
+
<orderEntry type="library" scope="PROVIDED" name="json (v1.8.3, ruby-2.0.0-p598) [gem]" level="application" />
|
118
|
+
<orderEntry type="library" scope="PROVIDED" name="mime-types (v2.6.1, ruby-2.0.0-p598) [gem]" level="application" />
|
119
|
+
<orderEntry type="library" scope="PROVIDED" name="netrc (v0.10.3, ruby-2.0.0-p598) [gem]" level="application" />
|
120
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v10.4.2, ruby-2.0.0-p598) [gem]" level="application" />
|
121
|
+
<orderEntry type="library" scope="PROVIDED" name="rest-client (v1.8.0, ruby-2.0.0-p598) [gem]" level="application" />
|
122
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.4.0, ruby-2.0.0-p598) [gem]" level="application" />
|
123
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.4.1, ruby-2.0.0-p598) [gem]" level="application" />
|
124
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.4.0, ruby-2.0.0-p598) [gem]" level="application" />
|
125
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.4.1, ruby-2.0.0-p598) [gem]" level="application" />
|
126
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.4.1, ruby-2.0.0-p598) [gem]" level="application" />
|
127
|
+
<orderEntry type="library" scope="PROVIDED" name="simplecov (v0.10.0, ruby-2.0.0-p598) [gem]" level="application" />
|
128
|
+
<orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.10.0, ruby-2.0.0-p598) [gem]" level="application" />
|
129
|
+
<orderEntry type="library" scope="PROVIDED" name="term-ansicolor (v1.3.2, ruby-2.0.0-p598) [gem]" level="application" />
|
130
|
+
<orderEntry type="library" scope="PROVIDED" name="thor (v0.19.1, ruby-2.0.0-p598) [gem]" level="application" />
|
131
|
+
<orderEntry type="library" scope="PROVIDED" name="tins (v1.6.0, ruby-2.0.0-p598) [gem]" level="application" />
|
132
|
+
<orderEntry type="library" scope="PROVIDED" name="unf (v0.1.4, ruby-2.0.0-p598) [gem]" level="application" />
|
133
|
+
<orderEntry type="library" scope="PROVIDED" name="unf_ext (v0.0.7.1, ruby-2.0.0-p598) [gem]" level="application" />
|
134
|
+
</component>
|
135
|
+
</module>
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 Alan L Guy
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Yari
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'yari'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install yari
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/yari/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
@@ -0,0 +1 @@
|
|
1
|
+
Feature: Missing scenario
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Feature: using scenario outlines
|
2
|
+
Scenario Outline: a simple outline
|
3
|
+
Given there is a monster with <hp> hitpoints
|
4
|
+
When I attack the monster and do <damage> points damage
|
5
|
+
Then the monster should be <state>
|
6
|
+
|
7
|
+
Examples:
|
8
|
+
| hp | damage | state | happy |
|
9
|
+
| 10.0 | 13 | dead | false |
|
10
|
+
| 8.0 | 5 | alive | true |
|
@@ -0,0 +1,22 @@
|
|
1
|
+
@feature_tag
|
2
|
+
Feature: A simple feature
|
3
|
+
Background:
|
4
|
+
Given we live in monster world
|
5
|
+
|
6
|
+
@scenario_tag
|
7
|
+
Scenario: A simple scenario
|
8
|
+
Given there is a monster
|
9
|
+
When I attack it
|
10
|
+
Then it should die
|
11
|
+
|
12
|
+
Scenario: Raising error
|
13
|
+
When Running this scenario
|
14
|
+
Then Error should be raisen
|
15
|
+
|
16
|
+
Scenario: Different metadata type
|
17
|
+
When Running this scenario
|
18
|
+
Then Type of this scenario should be :controller
|
19
|
+
|
20
|
+
Scenario: Custom metadata tag
|
21
|
+
When Running this scenario
|
22
|
+
Then Metadata should contain :custom key with 'foobar' value
|
@@ -0,0 +1,12 @@
|
|
1
|
+
@updated
|
2
|
+
Feature: Updated feature
|
3
|
+
Scenario: Attack a monster with cool tag
|
4
|
+
Given there is a monster
|
5
|
+
When I attack it
|
6
|
+
Then it should die
|
7
|
+
|
8
|
+
Scenario: Attack another monster
|
9
|
+
Given there is a strong monster
|
10
|
+
When I attack it
|
11
|
+
And I attack it
|
12
|
+
Then it should die
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Feature: Feature with updated scenario
|
2
|
+
@updated
|
3
|
+
Scenario: Updated scenario
|
4
|
+
Given there is a monster
|
5
|
+
When I attack it
|
6
|
+
Then it should die
|
7
|
+
|
8
|
+
Scenario: Attack another monster
|
9
|
+
Given there is a strong monster
|
10
|
+
When I attack it
|
11
|
+
And I attack it
|
12
|
+
Then it should die
|
data/lib/yari.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require "yari/version"
|
2
|
+
|
3
|
+
require "yari/builder"
|
4
|
+
require "yari/yari_dsl"
|
5
|
+
require "yari/yari_loader"
|
6
|
+
|
7
|
+
module Yari
|
8
|
+
extend self
|
9
|
+
|
10
|
+
class << self
|
11
|
+
attr_accessor :features
|
12
|
+
end
|
13
|
+
|
14
|
+
class Pending < StandardError;
|
15
|
+
end
|
16
|
+
class Malformed < StandardError;
|
17
|
+
end
|
18
|
+
class Ambiguous < StandardError;
|
19
|
+
end
|
20
|
+
|
21
|
+
def feature?(path)
|
22
|
+
!!path.match(mask_to_pattern(feature_mask))
|
23
|
+
end
|
24
|
+
|
25
|
+
def feature_spec?(path)
|
26
|
+
!!path.match(mask_to_pattern(spec_mask))
|
27
|
+
end
|
28
|
+
|
29
|
+
def feature_to_spec(path, prefix = true)
|
30
|
+
path = path.match(mask_to_pattern(feature_mask))[0] unless prefix
|
31
|
+
path.sub(mask_to_pattern(feature_mask), mask_to_replacement(spec_mask))
|
32
|
+
end
|
33
|
+
|
34
|
+
def spec_to_feature(path, prefix = true)
|
35
|
+
path = path.match(mask_to_pattern(spec_mask))[0] unless prefix
|
36
|
+
path.sub(mask_to_pattern(spec_mask), mask_to_replacement(feature_mask))
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
|
41
|
+
def spec_mask
|
42
|
+
::RSpec.configuration.feature_mapping[:spec]
|
43
|
+
end
|
44
|
+
|
45
|
+
def feature_mask
|
46
|
+
::RSpec.configuration.feature_mapping[:feature]
|
47
|
+
end
|
48
|
+
|
49
|
+
def mask_to_pattern(mask)
|
50
|
+
Regexp.new("#{Regexp.escape(mask).sub("\\*\\*/\\*", '(.+)')}$")
|
51
|
+
end
|
52
|
+
|
53
|
+
def mask_to_replacement(mask)
|
54
|
+
"#{mask.sub('**/*') { '\\1' }}"
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
Yari.features = []
|
60
|
+
|
61
|
+
::RSpec.configure do |config|
|
62
|
+
config.extend Yari::DSL::Rspec
|
63
|
+
config.pattern << ",**/*.feature"
|
64
|
+
config.add_setting :feature_mapping
|
65
|
+
config.add_setting :feature_metadata
|
66
|
+
config.feature_mapping = {
|
67
|
+
:feature => 'features/**/*.feature',
|
68
|
+
:spec => 'spec/features/**/*_spec.rb'
|
69
|
+
}
|
70
|
+
config.feature_metadata = {:type => :feature, :feature => :true}
|
71
|
+
end
|
72
|
+
|
73
|
+
::RSpec::Core::Configuration.send(:include, Yari::RSpec::Loader)
|
74
|
+
|
data/lib/yari/builder.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'gherkin/parser'
|
2
|
+
module Yari
|
3
|
+
class Builder
|
4
|
+
attr_reader :features
|
5
|
+
|
6
|
+
def self.build(file)
|
7
|
+
parser = Gherkin::Parser.new
|
8
|
+
token = Gherkin::TokenScanner.new(File.read(file))
|
9
|
+
Yari::Builder.new(parser.parse(token))
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(feature_hash)
|
13
|
+
@features ||= []
|
14
|
+
@features << Feature.new(feature_hash)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Feature
|
19
|
+
attr_reader :raw, :scenarios, :tags
|
20
|
+
|
21
|
+
def initialize(raw)
|
22
|
+
@raw = raw
|
23
|
+
@scenarios = []
|
24
|
+
@raw[:scenarioDefinitions].each do |raw_scenario|
|
25
|
+
@scenarios << Scenario.new(raw_scenario)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def tags
|
30
|
+
@raw[:tags].map { |tag| tag[:name] }
|
31
|
+
end
|
32
|
+
|
33
|
+
def name
|
34
|
+
@raw[:name]
|
35
|
+
end
|
36
|
+
|
37
|
+
def location
|
38
|
+
@raw[:location]
|
39
|
+
end
|
40
|
+
|
41
|
+
def comments
|
42
|
+
@raw[:comments]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Scenario
|
47
|
+
attr_reader :raw, :steps, :tags, :examples
|
48
|
+
|
49
|
+
def initialize(raw_scenario)
|
50
|
+
@raw = raw_scenario
|
51
|
+
end
|
52
|
+
|
53
|
+
def name
|
54
|
+
@raw[:name]
|
55
|
+
end
|
56
|
+
|
57
|
+
def tags
|
58
|
+
@raw[:tags].map { |tag| tag[:name] }
|
59
|
+
end
|
60
|
+
|
61
|
+
def type
|
62
|
+
@raw[:type]
|
63
|
+
end
|
64
|
+
|
65
|
+
def location
|
66
|
+
@raw[:location]
|
67
|
+
end
|
68
|
+
|
69
|
+
def steps
|
70
|
+
@raw[:steps]
|
71
|
+
end
|
72
|
+
|
73
|
+
def examples
|
74
|
+
if type == :ScenarioOutline
|
75
|
+
@raw[:examples].each { |raw_example| Yari::Example.new(raw_example) }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
class Example
|
81
|
+
def initialize(raw_example)
|
82
|
+
@raw = raw_example
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|