multicuke 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/multicuke/runner.rb +23 -3
- data/lib/multicuke/version.rb +1 -1
- data/spec/dryrun_spec.rb +5 -4
- data/spec/fork_spec.rb +1 -0
- data/spec/runner_spec.rb +3 -0
- data/spec/system_command_spec.rb +18 -0
- metadata +4 -2
data/lib/multicuke/runner.rb
CHANGED
@@ -5,6 +5,15 @@ require 'multicuke/reports_index'
|
|
5
5
|
|
6
6
|
module Multicuke
|
7
7
|
|
8
|
+
# Wrapper of {Kernel#system} method for test/mock
|
9
|
+
class SystemCommand
|
10
|
+
|
11
|
+
def run(full_command_as_array)
|
12
|
+
system *full_command_as_array
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
8
17
|
# Set of features under one specific directory
|
9
18
|
class FeaturesDir
|
10
19
|
|
@@ -61,12 +70,18 @@ module Multicuke
|
|
61
70
|
# Optional only the features directories to be included
|
62
71
|
attr_accessor :included_only_dirs
|
63
72
|
|
73
|
+
# Array of extra options to pass to the command
|
74
|
+
attr_accessor :extra_options
|
75
|
+
|
64
76
|
# Full final path where html reports will be generated
|
65
77
|
attr_reader :reports_path
|
66
78
|
|
67
79
|
# Optional. If true will generate index file but not launch processes. Used for testing.
|
68
80
|
attr_accessor :dry_run
|
69
81
|
|
82
|
+
# Delegate to a wrapper of system call in order mock/test
|
83
|
+
attr_accessor :system_command
|
84
|
+
|
70
85
|
def initialize
|
71
86
|
yield self if block_given?
|
72
87
|
|
@@ -75,7 +90,9 @@ module Multicuke
|
|
75
90
|
@output_path = "" unless output_path
|
76
91
|
@excluded_dirs = [] unless excluded_dirs
|
77
92
|
@included_only_dirs = [] unless included_only_dirs
|
93
|
+
@extra_options = [] unless extra_options
|
78
94
|
@reports_path = File.join(output_path, output_dir_name)
|
95
|
+
@system_command = SystemCommand.new unless system_command
|
79
96
|
end
|
80
97
|
|
81
98
|
def start
|
@@ -96,8 +113,8 @@ module Multicuke
|
|
96
113
|
fork {
|
97
114
|
main_command = %W[bundle exec cucumber #{feature_full_path}]
|
98
115
|
options = %W[-r #{features_root_path} --format html --out #{report_file_path}]
|
99
|
-
full_command = main_command + options
|
100
|
-
result =
|
116
|
+
full_command = main_command + options + extra_options
|
117
|
+
result = system_command.run full_command
|
101
118
|
puts "Features '#{features_dir.name}' finished. #{result ? 'SUCCESS' : 'FAILURE'} (pid: #{Process.pid})"
|
102
119
|
}
|
103
120
|
}
|
@@ -141,7 +158,10 @@ module Multicuke
|
|
141
158
|
if included_only_dirs.empty?
|
142
159
|
included_dir?(path)
|
143
160
|
else
|
144
|
-
|
161
|
+
exact_word_match_expressions = included_only_dirs.map { |dir_name|
|
162
|
+
"\\b#{dir_name}\\b"
|
163
|
+
}
|
164
|
+
path.match(Regexp.new(exact_word_match_expressions.join("|")))
|
145
165
|
end
|
146
166
|
end
|
147
167
|
|
data/lib/multicuke/version.rb
CHANGED
data/spec/dryrun_spec.rb
CHANGED
@@ -52,21 +52,22 @@ module Multicuke
|
|
52
52
|
it "run on included dirs only" do
|
53
53
|
runner = Multicuke::Runner.new do |r|
|
54
54
|
r.features_root_path = File.expand_path("../features", __FILE__)
|
55
|
-
r.included_only_dirs = ["
|
55
|
+
r.included_only_dirs = ["addition"]
|
56
56
|
r.dry_run = true
|
57
57
|
r.output_path = RESULTS_DIR_PATH
|
58
58
|
end
|
59
59
|
|
60
|
-
File.should_not exist("#{RESULTS_DIR_PATH}/
|
60
|
+
File.should_not exist("#{RESULTS_DIR_PATH}/cucumber_reports")
|
61
61
|
|
62
62
|
runner.start
|
63
63
|
|
64
64
|
File.open("#{RESULTS_DIR_PATH}/cucumber_reports/index.html") { |file|
|
65
65
|
content = file.read
|
66
66
|
|
67
|
-
content.should match /.*<a href="
|
67
|
+
content.should match /.*<a href="addition.html">Addition<\/a>.*/
|
68
68
|
|
69
|
-
content.should_not match /.*
|
69
|
+
content.should_not match /.*bad_addition.*/i
|
70
|
+
content.should_not match /.*division.*/i
|
70
71
|
content.should_not match /.*substraction.*/i
|
71
72
|
content.should_not match /.*multiplication.*/i
|
72
73
|
content.should_not match /.*steps_definition.*/
|
data/spec/fork_spec.rb
CHANGED
@@ -12,6 +12,7 @@ module Multicuke
|
|
12
12
|
runner = Multicuke::Runner.new do |r|
|
13
13
|
r.features_root_path = File.expand_path("../features", __FILE__)
|
14
14
|
r.excluded_dirs = ["steps_definition"]
|
15
|
+
r.extra_options = ["-t", "~@non_existing_tag"]
|
15
16
|
r.output_path = RESULTS_DIR_PATH
|
16
17
|
end
|
17
18
|
|
data/spec/runner_spec.rb
CHANGED
@@ -10,6 +10,7 @@ module Multicuke
|
|
10
10
|
r.output_path = "my_output_path"
|
11
11
|
r.dry_run = true
|
12
12
|
r.excluded_dirs = ["my_first_dir", "my_second_dir"]
|
13
|
+
r.extra_options = ["-p", "profile"]
|
13
14
|
end
|
14
15
|
|
15
16
|
runner.features_root_path.should == "my_feature_path"
|
@@ -17,6 +18,7 @@ module Multicuke
|
|
17
18
|
runner.output_path.should == "my_output_path"
|
18
19
|
runner.dry_run.should be_true
|
19
20
|
runner.excluded_dirs.should include("my_first_dir", "my_second_dir")
|
21
|
+
runner.extra_options.should include("-p", "profile")
|
20
22
|
end
|
21
23
|
|
22
24
|
it "initializes with default values" do
|
@@ -26,6 +28,7 @@ module Multicuke
|
|
26
28
|
runner.output_path.should == ""
|
27
29
|
runner.dry_run.should be_false
|
28
30
|
runner.excluded_dirs.should be_empty
|
31
|
+
runner.extra_options.should be_empty
|
29
32
|
end
|
30
33
|
end
|
31
34
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "System command" do
|
4
|
+
|
5
|
+
it "runs 'bundle exec cucumber ...' command" do
|
6
|
+
runner = Multicuke::Runner.new do |r|
|
7
|
+
r.features_root_path = File.expand_path("../features", __FILE__)
|
8
|
+
r.included_only_dirs = ["addition"]
|
9
|
+
r.output_path = RESULTS_DIR_PATH
|
10
|
+
r.system_command = mock('SystemCommand mock')
|
11
|
+
end
|
12
|
+
|
13
|
+
runner.should_receive(:fork)
|
14
|
+
runner.start
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
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.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-04 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Run your features faster
|
15
15
|
email:
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- spec/fork_spec.rb
|
42
42
|
- spec/runner_spec.rb
|
43
43
|
- spec/spec_helper.rb
|
44
|
+
- spec/system_command_spec.rb
|
44
45
|
homepage: https://github.com/simcap/multicuke
|
45
46
|
licenses: []
|
46
47
|
post_install_message:
|
@@ -80,4 +81,5 @@ test_files:
|
|
80
81
|
- spec/fork_spec.rb
|
81
82
|
- spec/runner_spec.rb
|
82
83
|
- spec/spec_helper.rb
|
84
|
+
- spec/system_command_spec.rb
|
83
85
|
has_rdoc:
|