Class: CucumberMonitor::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber_monitor/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cucumber_output_fileObject



18
19
20
# File 'lib/cucumber_monitor/base.rb', line 18

def self.cucumber_output_file
  "#{path}/tmp/cucumber.out"
end

.features_pathObject



10
11
12
# File 'lib/cucumber_monitor/base.rb', line 10

def self.features_path
  "#{path}/features"
end

.pathObject



6
7
8
# File 'lib/cucumber_monitor/base.rb', line 6

def self.path
  CucumberMonitor.path
end

.step_definitions_pathObject



14
15
16
# File 'lib/cucumber_monitor/base.rb', line 14

def self.step_definitions_path
  "#{features_path}/step_definitions"
end

Instance Method Details

#featuresObject



57
58
59
60
61
62
63
# File 'lib/cucumber_monitor/base.rb', line 57

def features
  collection = []
  files.each do |file|
    collection << CucumberMonitor::FeatureFile.new(file)  
  end
  collection
end

#filesObject



26
27
28
29
30
# File 'lib/cucumber_monitor/base.rb', line 26

def files
  collection = []
  dir_entries = Dir.entries(self.class.features_path)
  search_and_include_features(dir_entries)
end

#locateObject



22
23
24
# File 'lib/cucumber_monitor/base.rb', line 22

def locate
  "Printing: #{I18n.t("feature")}"
end

#search(criteria) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
# File 'lib/cucumber_monitor/base.rb', line 74

def search(criteria)
  results = []
  features.each do |feature|
    feature.scenarios.each do |scenario|
      scenario.steps.each do |step|
        results << step if step.description.include?(criteria)
      end
    end
  end
  results
end

#search_and_include_features(dir_entries, collection = []) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/cucumber_monitor/base.rb', line 39

def search_and_include_features(dir_entries, collection=[])
  dir_entries.each do |entrie|
    if entrie.include?('.feature')
      collection << entrie
    end
  end
  collection
end

#search_and_include_step_definitions(dir_entries, path, collection = []) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/cucumber_monitor/base.rb', line 48

def search_and_include_step_definitions(dir_entries, path, collection=[])
  dir_entries.each do |entrie|
    if entrie.include?('_step.rb')
      collection << entrie
    end
  end
  {collection: collection, path: path}
end

#search_match(criteria) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
# File 'lib/cucumber_monitor/base.rb', line 86

def search_match(criteria)
  results = []
  step_definitions.each do |step_definition|
    step_definition.definitions.each do |definition|
      if definition.matcher && criteria.match(definition.matcher)
        results << definition
      end
    end
  end
  results.first if results.any?
end

#step_definitionsObject



65
66
67
68
69
70
71
72
# File 'lib/cucumber_monitor/base.rb', line 65

def step_definitions
  collection = []
  step_definitions_files[:collection].each do |file|
    path = "#{step_definitions_files[:path]}/#{file}"
    collection << StepDefinitionFile.new(file,path)  
  end
  collection
end

#step_definitions_filesObject



32
33
34
35
36
37
# File 'lib/cucumber_monitor/base.rb', line 32

def step_definitions_files
  collection = []
  dir_entries = Dir.entries(self.class.step_definitions_path)
  path = self.class.step_definitions_path + "/step_definitions"
  search_and_include_step_definitions(dir_entries,path)
end