ex_aequo_rspex 0.2.1 → 0.2.3

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
  SHA256:
3
- metadata.gz: 335fe7935ff1b443a9257a9b7ceb586c6a50e592bde4865322340e0782446500
4
- data.tar.gz: 29ae913c08b5c74726b2c858b4dc04ab469d9c3c0a36890ffbe7e681e565814b
3
+ metadata.gz: 5cf5dd95612e3e30cd5dd885c7b616aef9c80e9c7b71915c46233755667b510d
4
+ data.tar.gz: 850d49f4effefa6b108a1a87ed6516f2c221b022a1c9c0e0d19817ae2acc0757
5
5
  SHA512:
6
- metadata.gz: 4e701c3cea1c37c56f89bfd01af6e880ea06920663e87eff7587241ac8224b2b268223da2da07a45b1ccb731f0f6b1192ba8c0eb82eaa8c303e11f546f277260
7
- data.tar.gz: 9354fe60aeeb1f203d5dcc62e34822fda233467be6a7695337c637428c220be2b57d501a663dfad911a9a3f835977e8f7565bef4cc8e176a5dbc8ce25ce75669
6
+ metadata.gz: 49f0152eccf21ba5c68f66bd655355d03a6c463fd6fdcdd8f8949fca17cd9630a343fd443fb5263b29bc5b83c55c44964857c7547f41cda374f4f2a087c37507
7
+ data.tar.gz: 25e88bb11d4643d72a8151da999a85282602f40d3594191c61371eab1001b1c7efc79cf26d9bce8a5bb60f8e1f678635ce7c3eb92f4848e4b34a8cbb38d89848
data/README.md CHANGED
@@ -17,6 +17,4 @@ Copyright 2026 Robert Dober robert.dober@gmail.com
17
17
 
18
18
  AGPL-3.0-or-later c.f. [LICENSE](LICENSE)
19
19
 
20
-
21
-
22
20
  <!-- SPDX-License-Identifier: AGPL-3.0-or-later -->
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ExAequo
4
+ module RSpex
5
+ module Helpers
6
+ module SubjectHelpers
7
+ module MatchHelper extend self
8
+ def make_line_matchers(*matchers)
9
+ Regexp.compile(
10
+ matchers
11
+ .map { mk_rgx_part it }
12
+ .join("\n")
13
+ )
14
+ end
15
+
16
+ private
17
+ def mk_rgx_part(part)
18
+ case part
19
+ when Regexp
20
+ part.source
21
+ when nil
22
+ ".*"
23
+ when String
24
+ Regexp.escape(part)
25
+ else
26
+ raise ArgumentError, "rgx part must be a regex, a string or nil, but was: #{part.inspect}"
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ # SPDX-License-Identifier: AGPL-3.0-or-later
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative './subject_helpers/match_helper'
3
4
  module ExAequo
4
5
  module RSpex
5
6
  module Helpers
@@ -31,7 +32,7 @@ module ExAequo
31
32
  end
32
33
 
33
34
  def it_is_false(&blk) = it_equals(false, &blk)
34
-
35
+
35
36
  def it_is_falsy(&blk)
36
37
  actual = blk ? instance_eval(&blk) : subject
37
38
  expect(actual).to be_falsy
@@ -51,11 +52,39 @@ module ExAequo
51
52
  expect(actual).not_to send("be_#{predicate}", *args)
52
53
  end
53
54
 
55
+ def it_has_same_lines(expected, &blk)
56
+ actual = blk ? instance_eval(&blk) : subject
57
+
58
+ actual = actual.lines(chomp: true) if String === actual
59
+ expected = expected.lines(chomp: true) if String === expected
60
+
61
+ actual.each.with_index do |line, idx|
62
+ expect(line:, idx:).to eq(line: expected[idx], idx:)
63
+ end
64
+
65
+ missing = expected.drop(actual.length)
66
+ missing.each do
67
+ expect(it).to be_nil, "#{it} is missing in actual result"
68
+ end
69
+ end
70
+
54
71
  def it_matches(matcher, &blk)
55
72
  actual = blk ? instance_eval(&blk) : subject
56
73
  expect(actual).to match(matcher)
57
74
  end
58
75
 
76
+ def it_matches_output(*matches, to: :stdout, &blk)
77
+ match = MatchHelper.make_line_matchers(*matches.flatten)
78
+ case to
79
+ when :stdout
80
+ expect{ instance_eval(&blk) }.to output(match).to_stdout
81
+ when :stderr
82
+ expect{ instance_eval(&blk) }.to output(match).to_stderr
83
+ else
84
+ raise ArgumentError, "to: must be :stdout or :stderr, but was: #{to.inspect}"
85
+ end
86
+ end
87
+
59
88
  def it_raises(exception, message=nil, &blk)
60
89
  expect { blk ? instance_eval(&blk) : subject }
61
90
  .to raise_error(exception, message)
@@ -57,12 +57,24 @@ module ExAequo
57
57
  end
58
58
  end
59
59
 
60
+ def it_has_same_lines(expected, &blk)
61
+ specify do
62
+ it_has_same_lines(expected, &blk)
63
+ end
64
+ end
65
+
60
66
  def it_matches(matcher, &blk)
61
67
  specify do
62
68
  it_matches(matcher, &blk)
63
69
  end
64
70
  end
65
71
 
72
+ def it_matches_output(*parts, to: :stdout, &blk)
73
+ specify do
74
+ it_matches_output(*parts, to:, &blk)
75
+ end
76
+ end
77
+
66
78
  def it_raises(exception, message=nil,&blk)
67
79
  specify do
68
80
  it_raises(exception, message, &blk)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module ExAequo
4
4
  module RSpex
5
- VERSION = '0.2.1'
5
+ VERSION = '0.2.3'
6
6
  end
7
7
  end
8
8
  # SPDX-License-Identifier: AGPL-3.0-or-later
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ex_aequo_rspex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Dober
@@ -34,6 +34,7 @@ files:
34
34
  - lib/ex_aequo/rspex.rb
35
35
  - lib/ex_aequo/rspex/helpers.rb
36
36
  - lib/ex_aequo/rspex/helpers/subject_helpers.rb
37
+ - lib/ex_aequo/rspex/helpers/subject_helpers/match_helper.rb
37
38
  - lib/ex_aequo/rspex/macros.rb
38
39
  - lib/ex_aequo/rspex/macros/let_macros.rb
39
40
  - lib/ex_aequo/rspex/macros/subject_macros.rb
@@ -49,14 +50,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
49
50
  requirements:
50
51
  - - ">="
51
52
  - !ruby/object:Gem::Version
52
- version: 3.4.5
53
+ version: 4.0.1
53
54
  required_rubygems_version: !ruby/object:Gem::Requirement
54
55
  requirements:
55
56
  - - ">="
56
57
  - !ruby/object:Gem::Version
57
58
  version: '0'
58
59
  requirements: []
59
- rubygems_version: 4.0.3
60
+ rubygems_version: 4.0.9
60
61
  specification_version: 4
61
62
  summary: RSpec macros and helpers
62
63
  test_files: []