class Object

Public Class Methods

feature(name = nil, new_metadata = {}, &block) click to toggle source
# File lib/yari/yari_dsl.rb, line 2
def feature(name = nil, new_metadata = {}, &block)
  raise ArgumentError.new("requires a name") if name.nil?

  new_metadata = ::RSpec.configuration.feature_metadata.merge(new_metadata)
  matching_feature = find_feature(name)
  new_metadata[:feature_name]= name

  if matching_feature
    if matching_feature.tags.include?('@updated')
      pending_feature(name, new_metadata, block.source_location,
                      "Feature has been marked as updated\n \t# Update specs for this feature and remove the @updated tag\n \t# Feature file: '#{feature_path(block.source_location)}"
      )
    else
      describe("Feature: #{name}", new_metadata.merge(:current_feature => matching_feature), &block)
    end
  else
    pending_feature(name, new_metadata, block.source_location, "No such feature in '#{feature_path(block.source_location)}'")
  end
end
feature_path(spec_location) click to toggle source
# File lib/yari/yari_dsl.rb, line 30
def feature_path(spec_location)
  Yari.spec_to_feature(spec_location.first, false)
end
find_feature(name) click to toggle source
# File lib/yari/yari_dsl.rb, line 24
def find_feature(name)
  Yari.features.find do |feature|
    feature.name == name
  end
end
pending_feature(name, new_metadata, spec_location, reason) click to toggle source
# File lib/yari/yari_dsl.rb, line 34
def pending_feature(name, new_metadata, spec_location, reason)
  describe "Feature: #{name}", new_metadata do
    it do |example|
      example.metadata.merge!(
          file_path: spec_location[0],
          location: "#{spec_location[0]}:#{spec_location[1]}"
      )
      skip reason
    end
  end
end