nitra 0.9.4 → 0.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,126 @@
1
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../../lib')
2
+ gem 'minitest'
3
+ require 'ostruct'
4
+ require 'minitest/spec'
5
+ require 'minitest/autorun'
6
+ require 'nitra/formatter'
7
+ require 'nitra/progress'
8
+ require 'nitra/configuration'
9
+ require 'nitra/utils'
10
+
11
+ describe Nitra::Formatter do
12
+ let(:progress) { Nitra::Progress.new }
13
+ let(:config) { Nitra::Configuration.new }
14
+ let(:formatter) { Nitra::Formatter.new(progress, config) }
15
+
16
+ describe "start" do
17
+ it "prints the progress bar and saves the start time" do
18
+ progress.file_count = 100
19
+ output = Nitra::Utils.capture_output { formatter.start }
20
+ output.must_include("..")
21
+ formatter.start_time.wont_be_nil
22
+ end
23
+ end
24
+
25
+ describe "#print_progress" do
26
+ before :each do
27
+ progress.file_count = 100
28
+ end
29
+
30
+ it "skips the bar when passed quiet config" do
31
+ config.quiet = true
32
+ output = Nitra::Utils.capture_output { formatter.print_progress }
33
+ output.wont_include("..")
34
+ end
35
+
36
+ it "skips the bar when passed debug config" do
37
+ config.debug = true
38
+ output = Nitra::Utils.capture_output { formatter.print_progress }
39
+ output.wont_include("..")
40
+ end
41
+
42
+ it "skips the bar when there's no files" do
43
+ progress.file_count = 0
44
+ output = Nitra::Utils.capture_output { formatter.print_progress }
45
+ output.wont_include("..")
46
+ end
47
+
48
+ it "prints output since last progress if print_failures config is on" do
49
+ progress.output = "lemons"
50
+ output = Nitra::Utils.capture_output { formatter.print_progress }
51
+ output.wont_include("lemons")
52
+ progress.output.must_equal "lemons"
53
+
54
+ config.print_failures = true
55
+
56
+ output = Nitra::Utils.capture_output { formatter.print_progress }
57
+ output.must_include("lemons")
58
+ progress.output.must_equal ""
59
+ end
60
+ end
61
+
62
+ describe "finish" do
63
+ it "prints some basic stats" do
64
+ progress.files_completed = 1
65
+ progress.file_count = 2
66
+ Nitra::Utils.capture_output { formatter.start } #silence
67
+ output = Nitra::Utils.capture_output { formatter.finish }
68
+ output.must_include("1/2 files")
69
+ output.must_include("Finished in")
70
+ end
71
+ end
72
+ end
73
+ __END__
74
+
75
+ def initialize(configuration, progress)
76
+ self.configuration = configuration
77
+ self.progress = progress
78
+ end
79
+
80
+ def start
81
+ self.start_time = Time.now
82
+ print_progress
83
+ end
84
+
85
+ def print_progress
86
+ print_failures
87
+ print_bar
88
+ end
89
+
90
+ def finish
91
+ puts progress.filtered_output
92
+
93
+ puts "\n#{overview}"
94
+ puts "#{$aborted ? "Aborted after" : "Finished in"} #{"%0.1f" % (Time.now-start_time)} seconds"
95
+ end
96
+
97
+ private
98
+
99
+ ##
100
+ # Print the progress bar, doesn't do anything if we're in debug.
101
+ #
102
+ def print_bar
103
+ return if configuration.quiet || configuration.debug
104
+ total = 50
105
+ completed = (progress.files_completed / progress.file_count.to_f * total).to_i
106
+ print "\r[#{"X" * completed}#{"." * (total - completed)}] #{overview}\r"
107
+ $stdout.flush
108
+ end
109
+
110
+ ##
111
+ # Prints the output in the progress object and resets it if we've got eager printing turned on.
112
+ #
113
+ def print_failures
114
+ return unless progress.output.length > 0 && configuration.print_failures
115
+ puts progress.filtered_output
116
+ progress.output = ""
117
+ end
118
+
119
+ ##
120
+ # A simple overview of files processed so far and success/failure numbers.
121
+ #
122
+ def overview
123
+ "#{progress.files_completed}/#{progress.file_count} files | #{progress.example_count} examples, #{progress.failure_count} failures"
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,16 @@
1
+ gem 'minitest'
2
+ require 'minitest/spec'
3
+ require 'minitest/autorun'
4
+ require 'ostruct'
5
+ require '../../lib/tasks.rb'
6
+
7
+ # Tasks needs an overhaul - it should just run stuff and report back, not talk to channels.
8
+ # describe Nitra::Tasks do
9
+ # def runner_tasks
10
+ # {:before_runner => 'before_runner', :before_worker => 'before_worker', :after_runner => 'after_runner', :debug => false}
11
+ # end
12
+ # it "runs tasks for runners" do
13
+ # tasks = Nitra::Tasks.new(runner_tasks)
14
+ # tasks.run(:before_runner).must eq('ran before_runner')
15
+ # end
16
+ # end
@@ -0,0 +1,13 @@
1
+ gem 'minitest'
2
+ require 'minitest/spec'
3
+ require 'minitest/autorun'
4
+ require_relative '../../lib/nitra/worker'
5
+
6
+ describe Nitra::Workers::Worker do
7
+ it "does some inheritance tricks" do
8
+ class RSpec < Nitra::Workers::Worker
9
+ end
10
+ Nitra::Workers::Worker.worker_classes['rspec'].must_equal RSpec
11
+ RSpec.framework_name.must_equal 'rspec'
12
+ end
13
+ end
metadata CHANGED
@@ -1,79 +1,111 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: nitra
3
- version: !ruby/object:Gem::Version
4
- hash: 51
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.5
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 9
9
- - 4
10
- version: 0.9.4
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Roger Nesbitt
9
+ - Andy Newport
10
+ - Jeremy Wells
11
+ - Will Bryant
14
12
  autorequire:
15
13
  bindir: bin
16
14
  cert_chain: []
17
-
18
- date: 2012-06-08 00:00:00 +12:00
19
- default_executable:
20
- dependencies: []
21
-
15
+ date: 2013-05-24 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: cucumber
19
+ requirement: !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
24
+ version: 1.1.9
25
+ type: :runtime
26
+ prerelease: false
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 1.1.9
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec
35
+ requirement: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '2.12'
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: '2.12'
22
49
  description: Multi-process rspec runner
23
50
  email: roger@youdo.co.nz
24
- executables:
51
+ executables:
25
52
  - nitra
26
53
  extensions: []
27
-
28
54
  extra_rdoc_files: []
29
-
30
- files:
31
- - README
55
+ files:
56
+ - README.md
32
57
  - lib/nitra.rb
33
58
  - bin/nitra
34
59
  - lib/nitra/channel.rb
35
- - lib/nitra/client.rb
36
60
  - lib/nitra/command_line.rb
37
61
  - lib/nitra/configuration.rb
62
+ - lib/nitra/ext/cucumber.rb
63
+ - lib/nitra/formatter.rb
38
64
  - lib/nitra/master.rb
39
65
  - lib/nitra/progress.rb
66
+ - lib/nitra/rails_tooling.rb
40
67
  - lib/nitra/runner.rb
41
68
  - lib/nitra/slave.rb
69
+ - lib/nitra/tasks.rb
42
70
  - lib/nitra/utils.rb
43
71
  - lib/nitra/worker.rb
44
- has_rdoc: true
45
- homepage:
46
- licenses: []
47
-
72
+ - lib/nitra/workers/cucumber.rb
73
+ - lib/nitra/workers/rspec.rb
74
+ - spec/nitra/channel_spec.rb
75
+ - spec/nitra/command_line_spec.rb
76
+ - spec/nitra/configuration_spec.rb
77
+ - spec/nitra/formatter.rb
78
+ - spec/nitra/tasks_spec.rb
79
+ - spec/nitra/worker_spec.rb
80
+ homepage: http://github.com/powershop/nitra
81
+ licenses:
82
+ - MIT
48
83
  post_install_message:
49
84
  rdoc_options: []
50
-
51
- require_paths:
85
+ require_paths:
52
86
  - lib
53
- required_ruby_version: !ruby/object:Gem::Requirement
87
+ required_ruby_version: !ruby/object:Gem::Requirement
54
88
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
62
- required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
94
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- hash: 3
68
- segments:
69
- - 0
70
- version: "0"
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
71
99
  requirements: []
72
-
73
100
  rubyforge_project:
74
- rubygems_version: 1.6.2
101
+ rubygems_version: 1.8.23
75
102
  signing_key:
76
103
  specification_version: 3
77
104
  summary: Multi-process rspec runner
78
- test_files: []
79
-
105
+ test_files:
106
+ - spec/nitra/channel_spec.rb
107
+ - spec/nitra/command_line_spec.rb
108
+ - spec/nitra/configuration_spec.rb
109
+ - spec/nitra/formatter.rb
110
+ - spec/nitra/tasks_spec.rb
111
+ - spec/nitra/worker_spec.rb
data/README DELETED
@@ -1,3 +0,0 @@
1
- Nitra is a multi-process rspec runner.
2
-
3
- Copyright 2011 Powershop Limited, YouDo Limited. MIT licence.
data/lib/nitra/client.rb DELETED
@@ -1,43 +0,0 @@
1
- class Nitra::Client
2
- attr_reader :configuration, :files
3
-
4
- def initialize(configuration, files = nil)
5
- @configuration = configuration
6
- @files = files
7
- @columns = (ENV['COLUMNS'] || 120).to_i
8
- end
9
-
10
- def run
11
- start_time = Time.now
12
-
13
- master = Nitra::Master.new(configuration, files)
14
- progress = master.run do |progress, data|
15
- print_progress(progress)
16
- if data && configuration.print_failures && data["failure_count"] != 0
17
- puts unless configuration.quiet
18
- puts "=== output for #{data["filename"]} #{'='*40}"
19
- puts data["text"].gsub(/\n\n\n+/, "\n\n")
20
- end
21
- end
22
-
23
- puts progress.output.gsub(/\n\n\n+/, "\n\n")
24
-
25
- puts "\n#{progress.files_completed}/#{progress.file_count} files processed, #{progress.example_count} examples, #{progress.failure_count} failures"
26
- puts "#{$aborted ? "Aborted after" : "Finished in"} #{"%0.1f" % (Time.now-start_time)} seconds" unless configuration.quiet
27
-
28
- !$aborted && progress.files_completed == progress.file_count && progress.failure_count.zero?
29
- end
30
-
31
- protected
32
- def print_progress(progress)
33
- return if configuration.quiet
34
-
35
- bar_length = @columns - 50
36
- progress_factor = progress.files_completed / progress.file_count.to_f
37
- length_completed = (progress_factor * bar_length).to_i
38
- length_to_go = bar_length - length_completed
39
- print "\r[#{"X" * length_completed}#{"." * length_to_go}] #{progress.files_completed}/#{progress.file_count} (#{"%0.1f%%" % (progress_factor*100)}) * #{progress.example_count} examples, #{progress.failure_count} failures\r"
40
- puts if configuration.debug
41
- $stdout.flush
42
- end
43
- end