-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
105 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
@tag1 @tag2 | ||
@batman @robin | ||
Feature: Has lots of tags | ||
|
||
@tag @another_tag | ||
@green_lantern @spider_man | ||
Scenario: Also has some tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Feature: List Tags | ||
In order to be informed of all tags | ||
As a stakeholder | ||
I want a list of tags to be displayed | ||
|
||
Scenario: Multiple tags | ||
Given a feature file named "sample.feature" with the contents: | ||
""" | ||
@tag1 | ||
Feature: Tag Feature | ||
@tag2 @multiple | ||
Scenario: Tag Scenario 1 | ||
@tag3 @multiple | ||
Scenario: Tag Scenario 2 | ||
""" | ||
When I visit the home page | ||
Then I should see a link to "@tag1 (1)" with the url "/search?q=@tag1" | ||
And I should see a link to "@tag2 (1)" with the url "/search?q=@tag2" | ||
And I should see a link to "@tag3 (1)" with the url "/search?q=@tag3" | ||
And I should see a link to "@multiple (2)" with the url "/search?q=@multiple" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Wally | ||
class CountsTags | ||
def initialize lists_features | ||
@lists_features = lists_features | ||
end | ||
|
||
def count_tags | ||
@lists_features.features.inject(Hash.new(0)) do |tag_count, feature| | ||
if feature["tags"] | ||
feature["tags"].each do |tag| | ||
tag_count[tag["name"]] += 1 | ||
end | ||
end | ||
if feature["elements"] | ||
feature["elements"].each do |element| | ||
if element["tags"] | ||
element["tags"].each do |tag| | ||
tag_count[tag["name"]] += 1 | ||
end | ||
end | ||
end | ||
end | ||
tag_count | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Wally | ||
VERSION = "0.0.15" | ||
VERSION = "0.0.16" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require File.join(File.dirname(__FILE__), "..", "spec_helper") | ||
require 'fileutils' | ||
require "wally/counts_tags" | ||
|
||
module Wally | ||
describe CountsTags do | ||
before do | ||
FileUtils.mkdir_p "application-features" | ||
end | ||
|
||
after do | ||
FileUtils.rm_rf "application-features" | ||
end | ||
|
||
def write_feature(name, contents) | ||
File.open("application-features/#{name}", "w") do |file| | ||
file.write(contents) | ||
end | ||
end | ||
|
||
it "counts feature tags" do | ||
write_feature("feature-1.feature", "@tag1 @tag2\nFeature: Feature 1") | ||
write_feature("feature-2.feature", "@tag2 @tag2\nFeature: Feature 2") | ||
lists_features = ListsFeatures.new("application-features") | ||
|
||
CountsTags.new(lists_features).count_tags.should == { | ||
"@tag1" => 1, | ||
"@tag2" => 3 | ||
} | ||
end | ||
|
||
it "counts scenario tags" do | ||
write_feature("feature-1.feature", "Feature: Feature 1\n@tag1@tag1\nScenario: Scenario 1") | ||
write_feature("feature-2.feature", "Feature: Feature 2\n@tag3@tag1\nScenario: Scenario 1") | ||
lists_features = ListsFeatures.new("application-features") | ||
CountsTags.new(lists_features).count_tags.should == { | ||
"@tag1" => 3, | ||
"@tag3" => 1 | ||
} | ||
end | ||
end | ||
end |