multicuke 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,13 +7,16 @@ module Multicuke
7
7
  # Collection of ran features directories results used for reporting
8
8
  attr_reader :features_dirs
9
9
 
10
+ # Full path for the index html file
11
+ attr_reader :index_path
12
+
10
13
  def initialize(reports_path, features_dirs)
11
14
  @features_dirs = features_dirs
12
- @index_file_path = File.join(reports_path, "index.html")
15
+ @index_path = File.join(reports_path, "index.html")
13
16
  end
14
17
 
15
18
  def generate
16
- index_file = File.new(@index_file_path, "w")
19
+ index_file = File.new(index_path, "w")
17
20
 
18
21
  b = Builder::XmlMarkup.new :target => index_file, :indent => 2
19
22
  b.html {
@@ -26,12 +26,16 @@ module Multicuke
26
26
  def initialize(dir_name)
27
27
  @name = dir_name
28
28
  @failed = false
29
+ @scenarios_results = ""
30
+ @steps_results = ""
29
31
  end
30
32
 
33
+ # True if one feature has failed
31
34
  def failed?
32
- @failed
35
+ (scenarios_results.include?"failed") || (steps_results.include?"failed")
33
36
  end
34
37
 
38
+ # Human readable name used for index page (ex: user_logout --> User logout)
35
39
  def human_name
36
40
  name.gsub(/[_-]/, " ").capitalize
37
41
  end
@@ -74,7 +78,8 @@ module Multicuke
74
78
  FileUtils.mkdir_p reports_path
75
79
  launch_process_per_dir
76
80
  collect_results
77
- ReportsIndex.new(reports_path, features_dirs).generate
81
+ reports = ReportsIndex.new(reports_path, features_dirs).generate
82
+ puts "See reports index at #{reports.index_path}" if reports
78
83
  end
79
84
 
80
85
  private
@@ -85,13 +90,14 @@ module Multicuke
85
90
  report_file_path = File.join(reports_path, "#{features_dir.name}.html")
86
91
  feature_full_path = File.join(features_root_path, "#{features_dir.name}")
87
92
  fork {
88
- command = "bundle exec cucumber #{feature_full_path} -r #{features_root_path} --format html --out #{report_file_path}"
89
- p "RUNNING #{command}"
90
- system command
93
+ main_command = %W[bundle exec cucumber #{feature_full_path}]
94
+ options = %W[-r #{features_root_path} --format html --out #{report_file_path}]
95
+ full_command = main_command + options
96
+ result = system *full_command
97
+ puts "Features '#{features_dir.name}' finished. #{result ? 'SUCCESS' : 'FAILURE'} (pid: #{Process.pid})"
91
98
  }
92
-
93
- p Process.waitall
94
99
  }
100
+ Process.waitall
95
101
  end
96
102
  end
97
103
 
@@ -106,12 +112,10 @@ module Multicuke
106
112
  scenarios = scenarios_match ? scenarios_match.captures.first : ""
107
113
  steps_match = content.match(/\d+ steps? \((.*?)\)/)
108
114
  steps = steps_match ? steps_match.captures.first : ""
109
- failed = (scenarios.include?"failed") || (steps.include?"failed")
110
115
 
111
116
  features_dir.scenarios_results = scenarios
112
117
  features_dir.steps_results = steps
113
118
  features_dir.duration = duration
114
- features_dir.failed = failed
115
119
  } if File.exists?(feature_file)
116
120
  }
117
121
  end
@@ -121,19 +125,16 @@ module Multicuke
121
125
  end
122
126
 
123
127
  def features_dirs
124
- @features_dirs ||= find_features_dirs
128
+ @features_dirs ||= resolve_features_dirs_name
125
129
  end
126
130
 
127
- def find_features_dirs
128
- @features_dirs = []
129
- Dir.glob(File.join(features_root_path, "*")).reject{ |path|
130
- File.file?(path) || match_excluded_dirs(path)
131
+ def resolve_features_dirs_name
132
+ Dir.glob(File.join(features_root_path, "*", "*.feature")).reject{ |path|
133
+ match_excluded_dirs(path)
131
134
  }.map { |feature_path|
132
- File.basename(feature_path)
133
- }.each { |dir_name|
134
- @features_dirs << FeaturesDir.new(dir_name)
135
+ dir_name = File.basename(File.dirname(feature_path))
136
+ FeaturesDir.new(dir_name)
135
137
  }
136
- @features_dirs
137
138
  end
138
139
 
139
140
  end
@@ -1,3 +1,3 @@
1
1
  module Multicuke
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -9,6 +9,25 @@ module Multicuke
9
9
  other_features = FeaturesDir.new("bye-bye-blackbird")
10
10
  other_features.human_name.should == "Bye bye blackbird"
11
11
  end
12
+
13
+ it "return failed true when scenarios contain failures" do
14
+ features = FeaturesDir.new("")
15
+ features.scenarios_results = "1 passed, 1 failed"
16
+ features.should be_failed
17
+ end
18
+
19
+ it "return failed true when steps contain failures" do
20
+ features = FeaturesDir.new("")
21
+ features.steps_results = "1 passed, 1 failed"
22
+ features.should be_failed
23
+ end
24
+
25
+ it "return failed false when steps or scenarios do not contain failures" do
26
+ features = FeaturesDir.new("")
27
+ features.steps_results = "1 passed"
28
+ features.scenarios_results = "1 passed"
29
+ features.should_not be_failed
30
+ end
12
31
  end
13
32
 
14
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multicuke
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: