Class: CucumberMonitor::FeatureRunner

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

Class Method Summary collapse

Class Method Details

.command(feature) ⇒ Object



5
6
7
# File 'lib/cucumber_monitor/feature_runner.rb', line 5

def self.command(feature)
	"bundle exec cucumber features/#{feature}.feature --format json --out tmp/cucumber.out"
end

.elementsObject



23
24
25
# File 'lib/cucumber_monitor/feature_runner.rb', line 23

def self.elements
	json.first['elements'].map{|e| "#{e['keyword']}: #{e['name']}"}
end

.jsonObject



13
14
15
# File 'lib/cucumber_monitor/feature_runner.rb', line 13

def self.json
	JSON.parse(File.open(CucumberMonitor::Base.cucumber_output_file).read)
end

.prepareObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/cucumber_monitor/feature_runner.rb', line 27

def self.prepare
	prepared_json = json
	prepared_json.first['elements'].each do |element|
		element['steps'].each do |step|
			puts step['match']['location']
			description = "#{step['keyword']}#{step['name']}"
			code_first_part = element['name'].blank? ?  element['keyword'].parameterize : element['name'].parameterize
			code_second_part = description.parameterize
			code = "#{code_first_part}-#{code_second_part}"
			step.merge!({
				            'description' => description,
				            'code' => code.parameterize
				          })
		end 
	end
	prepared_json
end

.run(options = {}) ⇒ Object



9
10
11
# File 'lib/cucumber_monitor/feature_runner.rb', line 9

def self.run(options={})
	`#{command(options[:name])}` if options.has_key?(:name) 
end

.run_and_return_json(options = {}) ⇒ Object



17
18
19
20
21
# File 'lib/cucumber_monitor/feature_runner.rb', line 17

def self.run_and_return_json(options={})
	run(options)
	json
	prepare
end