class FeatureFile
Attributes
file_path[RW]
scenarios[RW]
Public Class Methods
new(file_path:)
click to toggle source
# File lib/kraken-mobile/models/feature_file.rb, line 15 def initialize(file_path:) @file_path = file_path @scenarios = [] read_content end
Public Instance Methods
all_scenarios_have_a_user_tag?()
click to toggle source
# File lib/kraken-mobile/models/feature_file.rb, line 109 def all_scenarios_have_a_user_tag? scenarios.each do |scenario| user_tag = scenario.tags.select do |tag| tag.start_with?('@user') end.first return false if user_tag.nil? end true end
number_of_required_devices()
click to toggle source
# File lib/kraken-mobile/models/feature_file.rb, line 48 def number_of_required_devices user_tags.count end
number_of_required_mobile_devices()
click to toggle source
# File lib/kraken-mobile/models/feature_file.rb, line 40 def number_of_required_mobile_devices system_tags.select { |tag| tag == '@mobile' }.count end
number_of_required_web_devices()
click to toggle source
# File lib/kraken-mobile/models/feature_file.rb, line 44 def number_of_required_web_devices system_tags.select { |tag| tag == '@web' }.count end
only_one_user_tag_for_each_scenario?()
click to toggle source
# File lib/kraken-mobile/models/feature_file.rb, line 99 def only_one_user_tag_for_each_scenario? scenarios.each do |scenario| user_tags = scenario.tags.select do |tag| tag.start_with?('@user') end return false if user_tags.count != 1 end true end
required_devices()
click to toggle source
# File lib/kraken-mobile/models/feature_file.rb, line 52 def required_devices users = user_tags systems = system_tags users.map do |user| { user_id: user.delete_prefix('@user'), system_type: systems.shift || '@mobile' } end end
right_syntax?()
click to toggle source
# File lib/kraken-mobile/models/feature_file.rb, line 80 def right_syntax? all_scenarios_have_a_user_tag? && only_one_user_tag_for_each_scenario? && !duplicate_tags_for_a_user? end
sorted_required_devices()
click to toggle source
# File lib/kraken-mobile/models/feature_file.rb, line 64 def sorted_required_devices required_devices.sort_by do |device| device[:user_id].to_i end end
Private Instance Methods
read_content()
click to toggle source
# File lib/kraken-mobile/models/feature_file.rb, line 121 def read_content parser = Gherkin::Parser.new file = File.open(file_path) file_content = file.read file.close gherkin_document = parser.parse(file_content) pickles = Gherkin::Pickles::Compiler.new.compile(gherkin_document) pickles.each do |scenario| scenarios << FeatureScenario.new( name: scenario[:name], tags: scenario[:tags] ) end end