fix 0.7.1 → 0.8.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: 863a38a69f60ebe69ce196d25129f59804f34b34
4
- data.tar.gz: 5407d7adad29320bd7aea6ff813bc594f0b5f9c1
3
+ metadata.gz: 1dbcef751a7f141ec73878ddf24961d2c0de3252
4
+ data.tar.gz: f5a1b9113e857511e2f81de21fcee062ccf2ce13
5
5
  SHA512:
6
- metadata.gz: e0043e4cb94dd1ff42112658242a1f8de439da164bade1d97d2e2777349069e84f9c80e1d05bb9bfc54d1b1714664f118e715147a0ee021e888dba11e6dcedf0
7
- data.tar.gz: c6bd204ea3691b355a1103cfaeeeee6ae7945f0dbb6b9d4fbc043842d41d7955fc61567f30888a47a202f090bb8114fc7c4bc3e129458e8a484adf4e270d689c
6
+ metadata.gz: 7131c6f5781345f0eb35ebb45b787ea7e04892e237cafdd413c3659670eb8aab3f64bb5e2bcdb3f9a97ae80d93ec4ea5f87645ee4e0b442fe8a61785db5e3849
7
+ data.tar.gz: f4174a6f9c687a4c726ad2d44d0dffc0c404dad88c3971254aeb6b7a5b74cd536efff75418766deac7d97c997112614e66bdf6ca9ffb08bfd03ab31be60487c5
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/VERSION.semver CHANGED
@@ -1 +1 @@
1
- 0.7.1
1
+ 0.8.0
data/lib/fix.rb CHANGED
@@ -13,13 +13,14 @@ module Fix
13
13
  # end
14
14
  #
15
15
  # @param front_object [BasicObject] The front object.
16
+ # @param options [Hash] Some options.
16
17
  # @param specs [Proc] The set of specs.
17
18
  #
18
19
  # @return [ExpectationTarget] The expectation target.
19
- def self.describe(front_object, &specs)
20
- t = Test.new(front_object, &specs)
20
+ def self.describe(front_object, options = {}, &specs)
21
+ t = Test.new(front_object, options, &specs)
21
22
 
22
- puts "#{t.report}"
23
+ puts "#{t.report}" if options.fetch(:verbose, true)
23
24
  exit t.pass?
24
25
  end
25
26
  end
@@ -25,7 +25,7 @@ module Fix
25
25
  f
26
26
  end
27
27
 
28
- print result.to_char
28
+ print result.to_char if @configuration.fetch(:verbose, true)
29
29
  results << result
30
30
  end
31
31
  end
@@ -21,7 +21,8 @@ module Fix
21
21
  def on(method_name, *args, &block)
22
22
  o = On.new(@front_object,
23
23
  results,
24
- *@challenges, Spectus::Challenge.new(method_name, *args))
24
+ (@challenges + [Spectus::Challenge.new(method_name, *args)]),
25
+ @configuration)
25
26
 
26
27
  o.instance_eval(&block)
27
28
  end
data/lib/fix/on.rb CHANGED
@@ -17,13 +17,15 @@ module Fix
17
17
  class On
18
18
  # Initialize the on class.
19
19
  #
20
- # @param front_object [BasicObject] The front object of the test.
21
- # @param results [Array] The list of collected results.
22
- # @param challenges [Array] The list of challenges to apply.
23
- def initialize(front_object, results, *challenges)
24
- @front_object = front_object
25
- @results = results
26
- @challenges = challenges
20
+ # @param front_object [BasicObject] The front object of the test.
21
+ # @param results [Array] The list of collected results.
22
+ # @param challenges [Array] The list of challenges to apply.
23
+ # @param configuration [Hash] Settings.
24
+ def initialize(front_object, results, challenges, configuration = {})
25
+ @front_object = front_object
26
+ @results = results
27
+ @challenges = challenges
28
+ @configuration = configuration
27
29
  end
28
30
 
29
31
  # @!attribute [r] results
data/lib/fix/report.rb CHANGED
@@ -20,11 +20,19 @@ module Fix
20
20
  #
21
21
  # @return [String] The report in plain text.
22
22
  def to_s
23
- maybe_results_banner + total_time_banner + statistics_banner
23
+ maybe_thematic_break +
24
+ maybe_alerts_banner +
25
+ total_time_banner +
26
+ statistics_banner
24
27
  end
25
28
 
26
29
  private
27
30
 
31
+ # @private
32
+ def maybe_thematic_break
33
+ test.results.any? && @test.configuration.fetch(:verbose) ? "\n\n" : ''
34
+ end
35
+
28
36
  # @private
29
37
  def total_time_banner
30
38
  "Ran #{test.results.length} tests in #{test.total_time} seconds\n"
@@ -36,14 +44,8 @@ module Fix
36
44
  end
37
45
 
38
46
  # @private
39
- def maybe_results_banner
40
- if alerts.any?
41
- "\n" \
42
- "\n" \
43
- "#{results_banner.join("\n")}\n"
44
- else
45
- ''
46
- end
47
+ def maybe_alerts_banner
48
+ alerts.any? ? "#{results_banner.join("\n")}\n" : ''
47
49
  end
48
50
 
49
51
  # @private
@@ -55,11 +57,7 @@ module Fix
55
57
 
56
58
  # @private
57
59
  def maybe_backtrace(result)
58
- if result.respond_to?(:backtrace)
59
- " #{result.backtrace.first}\n"
60
- else
61
- ''
62
- end
60
+ result.respond_to?(:backtrace) ? " #{result.backtrace.first}\n" : ''
63
61
  end
64
62
 
65
63
  # @private
data/lib/fix/test.rb CHANGED
@@ -10,17 +10,26 @@ module Fix
10
10
  # Initialize the test class.
11
11
  #
12
12
  # @param front_object [BasicObject] The front object of the test.
13
+ # @param options [Hash] Some options.
13
14
  # @param specs [Proc] The specs to test against the object.
14
- def initialize(front_object, &specs)
15
+ def initialize(front_object, options = {}, &specs)
16
+ @configuration = { verbose: true }
17
+ @configuration.update(options)
18
+
15
19
  start_time = Time.now
16
20
 
17
- g = On.new(front_object, [])
21
+ g = On.new(front_object, [], [], @configuration)
18
22
  g.instance_eval(&specs)
19
23
 
20
24
  @results = g.results
21
25
  @total_time = Time.now - start_time
22
26
  end
23
27
 
28
+ # @!attribute [r] configuration
29
+ #
30
+ # @return [Hash] The settings.
31
+ attr_reader :configuration
32
+
24
33
  # @!attribute [r] results
25
34
  #
26
35
  # @return [Array] The results.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Wack
metadata.gz.sig CHANGED
Binary file