petitest 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 352ae5dae0ba8eb8e866f277ae8252b94c15f4bd
4
- data.tar.gz: c5feb6113073d80f36e406e6cfd4f4929cd2160a
3
+ metadata.gz: b3397f79b2986d3d5d8923e80056e1b516297a70
4
+ data.tar.gz: 7fd4625071e8ec6ec1d160eaf919c74ff15b528a
5
5
  SHA512:
6
- metadata.gz: dd63a6b94dd92d850e56e96ca98e0eabfc80feaa1312b112f8c229f73b149a4c32acd0940a45ef0918acc75956bd5f43c949672fd6e2d2ebf5c64d9a74de87d4
7
- data.tar.gz: 712f51bada7fd39c605d340629a072c9930a91563d27c9eb18ada7903ecde018dc949adfa4f0aef3ca0d6c878f63b629cc4c11e20eb1fad884bd36df01f436b1
6
+ metadata.gz: b2d48d9522dd74bf68f64670363db7a4fdf9e0787e37702e37c14d2cc62e07f862f40ec8ca5818f7f1065e770afd7114f69f19041f9160eac3b84756bdb3f6d0
7
+ data.tar.gz: 0b3d803d927296fbc111446a2d9a74dccd0a24248b037cd567d66f10f6e80ce380bf98477caca696f563b6d5d8f4619eecc7c8176850b9c5de4ea35a8397daa3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v0.1.2
2
+
3
+ - Add Petitest.configuration.output
4
+ - Improve configuration API
5
+
1
6
  ## v0.1.1
2
7
 
3
8
  - Support block on `#assert` method for Power Assert
data/README.md CHANGED
@@ -106,3 +106,7 @@ Times:
106
106
  Finished: 2017-03-22T05:40:32.846784+09:00
107
107
  Total: 0.000144s
108
108
  ```
109
+
110
+ ## Plug-ins
111
+
112
+ - https://github.com/petitest/petitest-power_assert
@@ -9,18 +9,23 @@ module Petitest
9
9
  }
10
10
 
11
11
  # @return [Hash{Symbol => Symbol}]
12
- def color_scheme
13
- @color_scheme ||= DEFAULT_COLOR_SCHEME.dup
14
- end
12
+ attr_accessor :color_scheme
15
13
 
16
14
  # @return [Boolean]
17
- def colored
18
- true
19
- end
15
+ attr_accessor :color
16
+
17
+ # @return [IO]
18
+ attr_accessor :output
20
19
 
21
20
  # @return [Array<Petitest::Subscribers::BaseSubscriber>]
22
- def subscribers
23
- @subscribers ||= [::Petitest::Subscribers::ProgressReportSubscriber.new]
21
+ attr_accessor :subscribers
22
+
23
+ def initialize
24
+ @color_scheme = DEFAULT_COLOR_SCHEME.dup
25
+ @color = true
26
+ @output = ::STDOUT
27
+ @output.sync = true
28
+ @subscribers = [::Petitest::Subscribers::ProgressReportSubscriber.new]
24
29
  end
25
30
  end
26
31
  end
@@ -0,0 +1,24 @@
1
+ module Petitest
2
+ module SubscriberConcerns
3
+ module OutputConcern
4
+ # @note Override
5
+ def after_running_test_cases(test_cases)
6
+ super
7
+ self.finished_at = ::Time.now
8
+ end
9
+
10
+ # @note Override
11
+ def before_running_test_cases(test_cases)
12
+ super
13
+ self.started_at = ::Time.now
14
+ end
15
+
16
+ private
17
+
18
+ # @return [IO]
19
+ def output
20
+ ::Petitest.configuration.output
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,9 +1,8 @@
1
- require "petitest/subscribers/base_subscriber"
2
1
  require "time"
3
2
 
4
3
  module Petitest
5
- module Subscribers
6
- class TimerSubscriber < ::Petitest::Subscribers::BaseSubscriber
4
+ module SubscriberConcerns
5
+ module TimeConcern
7
6
  # @return [Time, nil]
8
7
  attr_accessor :finished_at
9
8
 
@@ -1,9 +1,14 @@
1
1
  require "json"
2
- require "petitest/subscribers/timer_subscriber"
2
+ require "petitest/subscribers/base_subscriber"
3
+ require "petitest/subscriber_concerns/output_concern"
4
+ require "petitest/subscriber_concerns/time_concern"
3
5
 
4
6
  module Petitest
5
7
  module Subscribers
6
- class JsonReportSubscriber < ::Petitest::Subscribers::TimerSubscriber
8
+ class JsonReportSubscriber < ::Petitest::Subscribers::BaseSubscriber
9
+ include ::Petitest::SubscriberConcerns::OutputConcern
10
+ include ::Petitest::SubscriberConcerns::TimeConcern
11
+
7
12
  # @note Override
8
13
  def after_running_test_cases(test_cases)
9
14
  super
@@ -31,8 +36,8 @@ module Petitest
31
36
  started_at: started_at.iso8601(6),
32
37
  },
33
38
  }
34
- output = ::JSON.pretty_generate(data)
35
- puts output
39
+ string = ::JSON.pretty_generate(data)
40
+ output.puts(string)
36
41
  end
37
42
  end
38
43
  end
@@ -1,22 +1,29 @@
1
- require "petitest/subscribers/timer_subscriber"
1
+ require "petitest/subscribers/base_subscriber"
2
+ require "petitest/subscriber_concerns/output_concern"
3
+ require "petitest/subscriber_concerns/time_concern"
2
4
 
3
5
  module Petitest
4
6
  module Subscribers
5
- class ProgressReportSubscriber < ::Petitest::Subscribers::TimerSubscriber
7
+ class ProgressReportSubscriber < ::Petitest::Subscribers::BaseSubscriber
8
+ include ::Petitest::SubscriberConcerns::OutputConcern
9
+ include ::Petitest::SubscriberConcerns::TimeConcern
10
+
6
11
  # @note Override
7
12
  def after_running_test_case(test_case)
8
13
  super
9
- print ::Petitest::Texts::TestCaseResultCharacterText.new(test_case: test_case)
14
+ string = ::Petitest::Texts::TestCaseResultCharacterText.new(test_case: test_case).to_s
15
+ output.print(string)
10
16
  end
11
17
 
12
18
  # @note Override
13
19
  def after_running_test_cases(test_cases)
14
20
  super
15
- puts ::Petitest::Texts::TestCasesResultText.new(
21
+ string = ::Petitest::Texts::TestCasesResultText.new(
16
22
  finished_at: finished_at,
17
23
  started_at: started_at,
18
24
  test_cases: test_cases,
19
- )
25
+ ).to_s
26
+ output.puts(string)
20
27
  end
21
28
  end
22
29
  end
@@ -36,7 +36,7 @@ module Petitest
36
36
  # @param color_type [Symbol]
37
37
  # @return [String]
38
38
  def colorize(string, color_type)
39
- if ::Petitest.configuration.colored
39
+ if ::Petitest.configuration.color
40
40
  "\e[#{ansi_color_code_for(color_type)}m#{string}\e[0m"
41
41
  else
42
42
  string
@@ -1,3 +1,3 @@
1
1
  module Petitest
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/petitest.rb CHANGED
@@ -1,10 +1,11 @@
1
1
  require "petitest/assertion_failure_error"
2
2
  require "petitest/assertions"
3
3
  require "petitest/configuration"
4
+ require "petitest/subscriber_concerns/output_concern"
5
+ require "petitest/subscriber_concerns/time_concern"
4
6
  require "petitest/subscribers/base_subscriber"
5
7
  require "petitest/subscribers/json_report_subscriber"
6
8
  require "petitest/subscribers/progress_report_subscriber"
7
- require "petitest/subscribers/timer_subscriber"
8
9
  require "petitest/test_case"
9
10
  require "petitest/test_cases_runner"
10
11
  require "petitest/test_group"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: petitest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-21 00:00:00.000000000 Z
11
+ date: 2017-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -56,10 +56,11 @@ files:
56
56
  - lib/petitest/assertions.rb
57
57
  - lib/petitest/autorun.rb
58
58
  - lib/petitest/configuration.rb
59
+ - lib/petitest/subscriber_concerns/output_concern.rb
60
+ - lib/petitest/subscriber_concerns/time_concern.rb
59
61
  - lib/petitest/subscribers/base_subscriber.rb
60
62
  - lib/petitest/subscribers/json_report_subscriber.rb
61
63
  - lib/petitest/subscribers/progress_report_subscriber.rb
62
- - lib/petitest/subscribers/timer_subscriber.rb
63
64
  - lib/petitest/test_case.rb
64
65
  - lib/petitest/test_cases_runner.rb
65
66
  - lib/petitest/test_group.rb