Skip to content

Commit

Permalink
Merge pull request #292 from showaltb/add-annotations-config
Browse files Browse the repository at this point in the history
Add annotations configuration in generator
  • Loading branch information
Kosmas committed Dec 17, 2015
2 parents 42e78b8 + 6abbeab commit 506bab3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
23 changes: 23 additions & 0 deletions features/annotations.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@requires-rails-version-42
Feature: Annotations

I order to track my development progress
As a developer
I should be able to list annotations in my features

Background:
Given I have created a new Rails app "test-app" with no database and installed cucumber-rails
And I write to "features/tests.feature" with:
"""
Feature: Tests
Scenario: Tests
# TODO: When I go to the products page
"""

Scenario: See annotations in .feature file
When I run `bundle exec rake notes`
Then it should pass with:
"""
features/tests.feature:
* [ 3] [TODO] When I go to the products page
"""
12 changes: 12 additions & 0 deletions features/support/version_hooks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module VersionHooksHelper
def rails_version
@rails_version ||= `bundle exec rails --version`.match(/[\d.]+$/).to_s
end
end

Before '@requires-rails-version-42' do
extend VersionHooksHelper
if Gem::Version.new(rails_version) < Gem::Version.new('4.2')
skip_this_scenario
end
end
11 changes: 11 additions & 0 deletions lib/generators/cucumber/install/templates/tasks/cucumber.rake.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ begin
::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
end

task :annotations_setup do
Rails.application.configure do
if config.respond_to?(:annotations)
config.annotations.directories << 'features'
config.annotations.register_extensions('feature') { |tag| /#\s*(#{tag}):?\s*(.*)$/ }
end
end
end
end
desc 'Alias for cucumber:ok'
task :cucumber => 'cucumber:ok'
Expand All @@ -50,6 +59,8 @@ begin
end

task :stats => 'cucumber:statsetup'

task :notes => 'cucumber:annotations_setup'
rescue LoadError
desc 'cucumber rake task not available (cucumber not installed)'
task :cucumber do
Expand Down

0 comments on commit 506bab3

Please sign in to comment.