geordi 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/bin/cuc +2 -34
  2. data/lib/geordi/cuc.rb +98 -0
  3. data/lib/geordi/version.rb +1 -1
  4. metadata +6 -5
data/bin/cuc CHANGED
@@ -1,36 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + "/../lib/geordi/setup_firefox_for_selenium"
2
+ require File.join(File.dirname(__FILE__), '../lib/geordi/cuc')
3
3
 
4
- def exec_with_shell_expansion(*args)
5
- escaped_args = args.collect do |arg|
6
- arg.gsub(/([\\ "])/) { |match| "\\#{$1}" }
7
- end
8
- exec escaped_args.join(' ')
9
- end
10
-
11
- def rerun_txt_exists_and_has_content?
12
- File.exists?("rerun.txt") && !IO.read("rerun.txt").to_s.strip.empty?
13
- end
14
-
15
- # Print some whitespace
16
- 4.times { puts }
17
- puts "Running Cucumber tests..."
18
- puts "========================="
19
-
20
- # Check if cucumber_spinner is available
21
- spinner_available = File.exists?('Gemfile') && File.open('Gemfile').read.scan(/cucumber_spinner/).any?
22
- format_args = spinner_available ? ['--format', 'CucumberSpinner::CuriousProgressBarFormatter'] : ['--format', 'progress']
23
-
24
- # Check if parallel_tests is available
25
- parallel_tests_available = ['rake', 'parallel:spec'] if File.exists?('Gemfile') && File.open('Gemfile').read.scan(/parallel_tests/).any?
26
-
27
- use_parallel_tests = parallel_tests_available && (ARGV[0] == nil) && !rerun_txt_exists_and_has_content?
28
-
29
- use_firefox_for_selenium = "PATH=#{Geordi::SetupFirefoxForSelenium::FIREFOX_FOR_SELENIUM_PATH}:$PATH"
30
-
31
- if use_parallel_tests
32
- puts "Using parallel_tests ...\n\n"
33
- exec_with_shell_expansion *[use_firefox_for_selenium, 'b', 'rake', 'parallel:features', ARGV].flatten
34
- else
35
- exec_with_shell_expansion *[use_firefox_for_selenium, "b", "cucumber", format_args, ARGV].flatten
36
- end
4
+ Geordi::Cucumber.new.run
data/lib/geordi/cuc.rb ADDED
@@ -0,0 +1,98 @@
1
+ require 'rubygems'
2
+ require 'geordi/setup_firefox_for_selenium'
3
+
4
+ module Geordi
5
+ class Cucumber
6
+
7
+ def run
8
+ 4.times { puts }
9
+ puts "Running Cucumber tests..."
10
+ puts "========================="
11
+
12
+ consolidate_rerun_txt_files
13
+ show_rerun_txt_file_content
14
+
15
+ command = use_parallel_tests? ? parallel_execution_command : serial_execution_command
16
+ exec command
17
+ end
18
+
19
+ def serial_execution_command
20
+ format_args = spinner_available ? ['--format', 'CucumberSpinner::CuriousProgressBarFormatter'] : ['--format', 'progress']
21
+ [use_firefox_for_selenium, "b", "cucumber", format_args, escape_shell_args(ARGV)].flatten.compact.join(" ")
22
+ end
23
+
24
+
25
+ def parallel_execution_command
26
+ puts "Using parallel_tests ...\n\n"
27
+ parallel_tests_args = '-t features'
28
+ cucumber_args = ARGV.empty? ? '' : "-o '#{escape_shell_args(ARGV).join(" ")}'"
29
+ [use_firefox_for_selenium, 'b', 'parallel_test', parallel_tests_args, cucumber_args].flatten.compact.join(" ")
30
+ end
31
+
32
+
33
+ def use_firefox_for_selenium
34
+ "PATH=#{Geordi::SetupFirefoxForSelenium::FIREFOX_FOR_SELENIUM_PATH}:$PATH"
35
+ end
36
+
37
+
38
+ def escape_shell_args(*args)
39
+ args.flatten.collect do |arg|
40
+ arg.gsub(/([\\ "])/) { |match| "\\#{$1}" }
41
+ end
42
+ end
43
+
44
+
45
+ def rerun_txt_exists_and_has_content?
46
+ File.exists?("rerun.txt") && !IO.read("rerun.txt").to_s.strip.empty?
47
+ end
48
+
49
+
50
+ def consolidate_rerun_txt_files
51
+ parallel_rerun_files = Dir.glob("parallel_rerun*.txt")
52
+ unless parallel_rerun_files.empty?
53
+ 2.times { puts }
54
+ puts "consolidating parallel_rerun.txt files ..."
55
+
56
+ rerun_content = []
57
+ parallel_rerun_files.each do |filename|
58
+ rerun_content << File.read(filename).strip
59
+ File.unlink(filename)
60
+ end
61
+
62
+ File.open("rerun.txt", "w") do |f|
63
+ f.puts(rerun_content.join(" "))
64
+ end
65
+ end
66
+ end
67
+
68
+
69
+ def show_rerun_txt_file_content
70
+ return unless rerun_txt_exists_and_has_content?
71
+
72
+ 2.times { puts }
73
+ puts "content of rerun.txt:"
74
+ puts "-------------------------"
75
+ puts File.read('rerun.txt')
76
+ puts "-------------------------"
77
+ 2.times { puts }
78
+ end
79
+
80
+
81
+ # Check if cucumber_spinner is available
82
+ def spinner_available?
83
+ @spinner_available ||= File.exists?('Gemfile') && File.open('Gemfile').read.scan(/cucumber_spinner/).any?
84
+ end
85
+
86
+
87
+ # Check if parallel_tests is available
88
+ def parallel_tests_available?
89
+ @parallel_tests_available ||= File.exists?('Gemfile') && File.open('Gemfile').read.scan(/parallel_tests/).any?
90
+ end
91
+
92
+
93
+ def use_parallel_tests?
94
+ parallel_tests_available? && !rerun_txt_exists_and_has_content?
95
+ end
96
+
97
+ end
98
+ end
@@ -1,3 +1,3 @@
1
1
  module Geordi
2
- VERSION = '0.8.1'
2
+ VERSION = '0.9.0'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geordi
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
4
+ hash: 59
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 8
9
- - 1
10
- version: 0.8.1
8
+ - 9
9
+ - 0
10
+ version: 0.9.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Henning Koch
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-13 00:00:00 +01:00
18
+ date: 2012-02-20 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -72,6 +72,7 @@ files:
72
72
  - bin/tests
73
73
  - geordi.gemspec
74
74
  - lib/geordi.rb
75
+ - lib/geordi/cuc.rb
75
76
  - lib/geordi/gitpt.rb
76
77
  - lib/geordi/setup_firefox_for_selenium.rb
77
78
  - lib/geordi/version.rb