Skip to content

Commit

Permalink
Merge pull request #77 from norekinc/master
Browse files Browse the repository at this point in the history
Bump up to gherkin 4.0
  • Loading branch information
Franklin Webber authored Nov 30, 2016
2 parents c1d6efe + 046e062 commit e2daff6
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source "https://rubygems.org"

gem 'redcarpet'
gem 'gherkin', '~> 3'
gem 'gherkin', '~> 4.0'

gemspec
gemspec
33 changes: 19 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,37 +1,42 @@
PATH
remote: .
specs:
yard-cucumber (2.3.2)
cucumber (>= 1.3.0)
gherkin (~> 2.12)
yard (>= 0.8.1)
yard-cucumber (3.0.0)
cucumber (~> 2)
gherkin (~> 4.0)
yard (~> 0.8, >= 0.8.1)

GEM
remote: https://rubygems.org/
specs:
builder (3.2.2)
cucumber (2.0.2)
cucumber (2.4.0)
builder (>= 2.1.2)
cucumber-core (~> 1.2.0)
cucumber-core (~> 1.5.0)
cucumber-wire (~> 0.0.1)
diff-lcs (>= 1.1.3)
gherkin (~> 2.12)
gherkin (~> 4.0)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.1.2)
cucumber-core (1.2.0)
gherkin (~> 2.12.0)
cucumber-core (1.5.0)
gherkin (~> 4.0)
cucumber-wire (0.0.1)
diff-lcs (1.2.5)
gherkin (2.12.2)
multi_json (~> 1.3)
multi_json (1.11.2)
gherkin (4.0.0)
multi_json (1.12.1)
multi_test (0.1.2)
rake (10.4.2)
redcarpet (2.2.2)
yard (0.8.7.6)
yard (0.9.5)

PLATFORMS
ruby

DEPENDENCIES
rake
gherkin (~> 4.0)
rake (~> 10)
redcarpet
yard-cucumber!

BUNDLED WITH
1.12.4
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ English step definitions. Even without specifying this feature files in other
languages are found, this provides the ability for the step definitions to match
correctly to step definitions.

* Exclude features or scenarios from yardoc

You can exclude any feature or scenario from the yardoc by adding a predefined tags to them.
To define tags that will be excluded, again in yard configuration file:

```yaml
:"yard-cucumber":
exclude_tags: [ 'exclude-yardoc', 'also-exclude-yardoc' ]
```

## Details

There are two things that I enjoy: a test framework written in my own Domain
Expand Down Expand Up @@ -185,4 +195,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39 changes: 28 additions & 11 deletions lib/cucumber/city_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,25 @@ def find_or_create_tag(tag_name,parent)
# This is once, as the gherking parser does not like multiple feature per
# file.
#
def feature(feature)
def feature(document)
#log.debug "FEATURE"
feature = document[:feature]
return if has_exclude_tags?(feature[:tags].map { |t| t[:name].gsub(/^@/, '') })

@feature = YARD::CodeObjects::Cucumber::Feature.new(@namespace,File.basename(@file.gsub('.feature','').gsub('.','_'))) do |f|
f.comments = feature[:comments] ? feature[:comments].map{|comment| comment[:text]}.join("\n") : ''
f.description = ''#feature.description
f.description = feature[:description] || ''
f.add_file(@file,feature[:location][:line])
f.keyword = feature[:keyword]
f.value = feature[:name]
f.tags = []

feature[:tags].each {|feature_tag| find_or_create_tag(feature_tag[:name],f) }
end
feature[:scenarioDefinitions].each { |s|
feature[:children].each { |s|
case s[:type]
when :Background
background(s)
when :ScenarioOutline
scenario_outline(s)
when :Scenario
Expand All @@ -113,21 +117,24 @@ def feature(feature)
#
# Called when a background has been found
#
# @see #scenario
# @see #feature
def background(background)
#log.debug "BACKGROUND"

@background = YARD::CodeObjects::Cucumber::Scenario.new(@feature,"background") do |b|
b.comments = background.comments.map{|comment| comment.value}.join("\n")
b.description = background.description
b.keyword = background.keyword
b.value = background.name
b.add_file(@file,background.line)
b.comments = background[:comments] ? background[:comments].map{|comment| comment.value}.join("\n") : ''
b.description = background[:description] || ''
b.keyword = background[:keyword]
b.value = background[:name]
b.add_file(@file,background[:location][:line])
end

@feature.background = @background
@background.feature = @feature
@step_container = @background
background[:steps].each { |s|
step(s)
}
end

#
Expand All @@ -146,9 +153,11 @@ def background(background)
def scenario(statement)
#log.debug "SCENARIO"

return if has_exclude_tags?(statement[:tags].map { |t| t[:name].gsub(/^@/, '') })

scenario = YARD::CodeObjects::Cucumber::Scenario.new(@feature,"scenario_#{@feature.scenarios.length + 1}") do |s|
s.comments = statement[:comments] ? statement[:comments].map{|comment| comment.value}.join("\n") : ''
s.description = ''#statement.description
s.description = statement[:description] || ''
s.add_file(@file,statement[:location][:line])
s.keyword = statement[:keyword]
s.value = statement[:name]
Expand All @@ -174,9 +183,11 @@ def scenario(statement)
def scenario_outline(statement)
#log.debug "SCENARIO OUTLINE"

return if has_exclude_tags?(statement[:tags].map { |t| t[:name].gsub(/^@/, '') })

outline = YARD::CodeObjects::Cucumber::ScenarioOutline.new(@feature,"scenario_#{@feature.scenarios.length + 1}") do |s|
s.comments = statement[:comments] ? statement[:comments].map{|comment| comment.value}.join("\n") : ''
s.description = ''#statement.description
s.description = statement[:description] || ''
s.add_file(@file,statement[:location][:line])
s.keyword = statement[:keyword]
s.value = statement[:name]
Expand Down Expand Up @@ -340,6 +351,12 @@ def clone_table(base)
base.map {|row| row.map {|cell| cell.dup }}
end

def has_exclude_tags?(tags)
if YARD::Config.options["yard-cucumber"] and YARD::Config.options["yard-cucumber"]["exclude_tags"]
return true unless (YARD::Config.options["yard-cucumber"]["exclude_tags"] & tags).empty?
end
end

end
end
end
2 changes: 1 addition & 1 deletion yard-cucumber.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Gem::Specification.new do |s|

s.add_development_dependency 'rake', '~> 10'

s.add_dependency 'gherkin', '~> 3'
s.add_dependency 'gherkin', '~> 4.0'
s.add_dependency 'cucumber', '~> 2'
s.add_dependency 'yard', '~> 0.8', '>= 0.8.1'

Expand Down

0 comments on commit e2daff6

Please sign in to comment.