rrrspec-client 0.2.4 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a8eeee74390a15216c9ee1617ece868ca8c8d35
4
- data.tar.gz: 7c5d6bcabc4418977305017db7b6aed02a6497de
3
+ metadata.gz: 42b80bd79e217f92b060c1cc3ee329fc47e65d20
4
+ data.tar.gz: c81027789ac8dde9d749f2c044cb6f38c66f1659
5
5
  SHA512:
6
- metadata.gz: 26acef471216841b57ca5c03af5dedc133d3878519842c6a8a0b8cbbd669df7439b17b1264417bd0a7c76b07dd14a95603f4ff024e481c411d0ecb1fc643bac4
7
- data.tar.gz: 3975213a640c79809879ed3fd4754fb0aabcfe2a4a5cccd68f82e41f065c56b866b7731d282995404bddb70039cede434e326959c2ec884d6b888826676f33ab
6
+ metadata.gz: 23b32613282ccd0680fe04c98b89b22a5595e82cedc9d1c566d23aaff4450c42394f44e5ba8319cfe432aa14ae7eb3e6db6733836ad95ac4c5c3fb1ddc180632
7
+ data.tar.gz: 312c3195f17d9ea1d50a34bc80f333b6955f92c5619dc6502b881e24684a42650a18345cf881c9888998efa980b240c31656d7fd86063c2a0a3926cad4bff8ce
@@ -6,9 +6,7 @@ module RRRSpec
6
6
  class RSpecRunner
7
7
  def initialize
8
8
  @options = RSpec::Core::ConfigurationOptions.new([])
9
- @options.parse_options
10
9
  @configuration = RSpec.configuration
11
- @configuration.setup_load_path_and_require([])
12
10
  @world = RSpec.world
13
11
  @before_suite_run = false
14
12
  end
@@ -39,7 +37,7 @@ module RRRSpec
39
37
  @configuration.load_spec_files
40
38
  @world.announce_filters
41
39
  unless @before_suite_run
42
- @configuration.run_hook(:before, :suite)
40
+ run_before_suite_hooks
43
41
  @before_suite_run = true
44
42
  end
45
43
  status = true
@@ -59,21 +57,11 @@ module RRRSpec
59
57
  @configuration.output_stream = $stdout
60
58
  @configuration.error_stream = $stderr
61
59
  @configuration.add_formatter(RSpec::Core::Formatters::BaseTextFormatter)
62
- if @configuration.respond_to?(:formatter_loader)
63
- # RSpec >= 2.99
64
- formatters.each do |formatter|
65
- @configuration.formatter_loader.formatters << formatter
66
- end
67
- else
68
- formatters.each do |formatter|
69
- @configuration.formatters << formatter
70
- end
60
+ formatters.each do |formatter|
61
+ @configuration.add_formatter(formatter)
71
62
  end
72
- @configuration.reporter.report(
73
- @world.example_count,
74
- @configuration.randomize? ? @configuration.seed : nil
75
- ) do |reporter|
76
- @world.example_groups.ordered.each do |example_group|
63
+ @configuration.reporter.report(@world.example_count) do |reporter|
64
+ @world.ordered_example_groups.each do |example_group|
77
65
  example_group.run(reporter)
78
66
  end
79
67
  end
@@ -87,6 +75,16 @@ module RRRSpec
87
75
  @world.example_groups.clear
88
76
  @configuration.reset
89
77
  end
78
+
79
+ private
80
+
81
+ def run_before_suite_hooks
82
+ hooks = @configuration.instance_variable_get(:@before_suite_hooks)
83
+ hook_context = RSpec::Core::SuiteHookContext.new
84
+ hooks.each do |h|
85
+ h.run(hook_context)
86
+ end
87
+ end
90
88
  end
91
89
  end
92
90
  end
@@ -1,6 +1,7 @@
1
1
  require 'set'
2
2
  require 'extreme_timeout'
3
3
  require 'timeout'
4
+ require 'rspec/core/formatters'
4
5
 
5
6
  module RRRSpec
6
7
  module Client
@@ -66,7 +67,7 @@ module RRRSpec
66
67
 
67
68
  soft_timeout_sec, hard_timeout_sec = spec_timeout_sec(task)
68
69
 
69
- formatter = RedisReportingFormatter.new
70
+ formatter = RedisReportingFormatter
70
71
  trial.start
71
72
  status, outbuf, errbuf = ExtremeTimeout::timeout(
72
73
  hard_timeout_sec, TIMEOUT_EXITCODE
@@ -87,41 +88,62 @@ module RRRSpec
87
88
  end
88
89
 
89
90
  class RedisReportingFormatter
90
- attr_reader :passed, :pending, :failed
91
+ RSpec::Core::Formatters.register(self, :example_passed, :example_pending, :example_failed)
91
92
 
92
- def initialize
93
- @passed = 0
94
- @pending = 0
95
- @failed = 0
96
- @timeout = false
93
+ def initialize(_output)
94
+ self.class.reset
97
95
  end
98
96
 
99
- def example_passed(example)
100
- @passed += 1
97
+ def example_passed(_notification)
98
+ self.class.example_passed
101
99
  end
102
100
 
103
- def example_pending(example)
104
- @pending += 1
101
+ def example_pending(_notification)
102
+ self.class.example_pending
105
103
  end
106
104
 
107
- def example_failed(example)
108
- @failed += 1
109
- if example.exception.is_a?(SoftTimeoutException)
110
- @timeout = true
111
- end
105
+ def example_failed(notification)
106
+ self.class.example_failed(notification)
112
107
  end
113
108
 
114
- def status
115
- if @timeout
116
- 'timeout'
117
- elsif @failed != 0
118
- 'failed'
119
- elsif @pending != 0
120
- 'pending'
121
- else
122
- 'passed'
109
+ module ClassMethods
110
+ attr_reader :passed, :pending, :failed
111
+
112
+ def reset
113
+ @passed = 0
114
+ @pending = 0
115
+ @failed = 0
116
+ @timeout = false
117
+ end
118
+
119
+ def example_passed
120
+ @passed += 1
121
+ end
122
+
123
+ def example_pending
124
+ @pending += 1
125
+ end
126
+
127
+ def example_failed(notification)
128
+ @failed += 1
129
+ if notification.exception.is_a?(SoftTimeoutException)
130
+ @timeout = true
131
+ end
132
+ end
133
+
134
+ def status
135
+ if @timeout
136
+ 'timeout'
137
+ elsif @failed != 0
138
+ 'failed'
139
+ elsif @pending != 0
140
+ 'pending'
141
+ else
142
+ 'passed'
143
+ end
123
144
  end
124
145
  end
146
+ extend ClassMethods
125
147
  end
126
148
  end
127
149
  end
@@ -1,5 +1,5 @@
1
1
  module RRRSpec
2
2
  module Client
3
- VERSION = "0.2.4"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency "extreme_timeout"
30
30
  spec.add_dependency "launchy"
31
31
  spec.add_dependency "redis"
32
- spec.add_dependency "rspec", ">= 2.14.1", "< 3"
32
+ spec.add_dependency "rspec", ">= 3.0"
33
33
  spec.add_dependency "thor"
34
34
  spec.add_dependency "uuidtools"
35
35
  spec.add_dependency "tzinfo"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rrrspec-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaya Suzuki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-15 00:00:00.000000000 Z
11
+ date: 2015-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,20 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: 2.14.1
104
- - - "<"
105
- - !ruby/object:Gem::Version
106
- version: '3'
103
+ version: '3.0'
107
104
  type: :runtime
108
105
  prerelease: false
109
106
  version_requirements: !ruby/object:Gem::Requirement
110
107
  requirements:
111
108
  - - ">="
112
109
  - !ruby/object:Gem::Version
113
- version: 2.14.1
114
- - - "<"
115
- - !ruby/object:Gem::Version
116
- version: '3'
110
+ version: '3.0'
117
111
  - !ruby/object:Gem::Dependency
118
112
  name: thor
119
113
  requirement: !ruby/object:Gem::Requirement