clarion-given 1.0.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 +7 -0
- data/lib/given/assertions.rb +71 -0
- data/lib/given/binary_operation.rb +34 -0
- data/lib/given/core.rb +11 -0
- data/lib/given/evaluator.rb +52 -0
- data/lib/given/ext/numeric.rb +31 -0
- data/lib/given/extensions.rb +277 -0
- data/lib/given/failure.rb +80 -0
- data/lib/given/failure_matcher.rb +100 -0
- data/lib/given/file_cache.rb +18 -0
- data/lib/given/fuzzy_number.rb +68 -0
- data/lib/given/fuzzy_shortcuts.rb +1 -0
- data/lib/given/line_extractor.rb +57 -0
- data/lib/given/minitest/all.rb +12 -0
- data/lib/given/minitest/before_extension.rb +36 -0
- data/lib/given/minitest/configure.rb +7 -0
- data/lib/given/minitest/context_extension.rb +3 -0
- data/lib/given/minitest/failure_must_raise.rb +13 -0
- data/lib/given/minitest/framework.rb +37 -0
- data/lib/given/minitest/new_assertions.rb +22 -0
- data/lib/given/module_methods.rb +83 -0
- data/lib/given/natural_assertion.rb +191 -0
- data/lib/given/rspec/all.rb +29 -0
- data/lib/given/rspec/before_extensions.rb +15 -0
- data/lib/given/rspec/configure.rb +20 -0
- data/lib/given/rspec/framework.rb +46 -0
- data/lib/given/rspec/have_failed.rb +37 -0
- data/lib/given/rspec/have_failed_212.rb +39 -0
- data/lib/given/rspec/have_failed_pre212.rb +22 -0
- data/lib/given/rspec/monkey.rb +42 -0
- data/lib/given/rspec/use_natural_assertions.rb +10 -0
- data/lib/given/version.rb +9 -0
- data/lib/given.rb +2 -0
- data/lib/minitest/given.rb +1 -0
- data/lib/minitest-given.rb +9 -0
- data/lib/rspec/given.rb +1 -0
- data/lib/rspec-given.rb +9 -0
- metadata +96 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module RSpec
|
|
2
|
+
module Given
|
|
3
|
+
module HaveFailed
|
|
4
|
+
|
|
5
|
+
# The RSpec-2.12 and later version of the have_failed matcher
|
|
6
|
+
|
|
7
|
+
class HaveFailedMatcher < RSpec::Matchers::BuiltIn::RaiseError
|
|
8
|
+
# RSpec 3's RaiseError requires the target to be a Proc. A
|
|
9
|
+
# Given::Failure quacks like a proc that raises the captured
|
|
10
|
+
# exception when called, so normalize it to a real lambda at
|
|
11
|
+
# the boundary. (Non-proc values keep the historical
|
|
12
|
+
# behavior: they never match have_failed.)
|
|
13
|
+
def matches?(given_proc, negative_expectation = false)
|
|
14
|
+
if given_proc.is_a?(::Given::Failure)
|
|
15
|
+
super(lambda { given_proc.call }, negative_expectation)
|
|
16
|
+
elsif ::Proc === given_proc
|
|
17
|
+
super
|
|
18
|
+
else
|
|
19
|
+
super(lambda { }, negative_expectation)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def does_not_match?(given_proc)
|
|
24
|
+
if given_proc.is_a?(::Given::Failure)
|
|
25
|
+
super(lambda { given_proc.call })
|
|
26
|
+
elsif ::Proc === given_proc
|
|
27
|
+
super
|
|
28
|
+
else
|
|
29
|
+
super(lambda { })
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def to_s
|
|
34
|
+
"<Failure matching #{@expected_error}: #{@expected_message.inspect}>"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module RSpec
|
|
2
|
+
module Given
|
|
3
|
+
module HaveFailed
|
|
4
|
+
|
|
5
|
+
# The Pre-Rspec 2.12 version of the matcher
|
|
6
|
+
|
|
7
|
+
class HaveFailedMatcher < RSpec::Matchers::BuiltIn::RaiseError
|
|
8
|
+
def matches?(given_proc)
|
|
9
|
+
if given_proc.is_a?(::Given::Failure)
|
|
10
|
+
super
|
|
11
|
+
else
|
|
12
|
+
super(lambda { })
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def to_s
|
|
17
|
+
"<FailureMatcher on #{@expected_error}: #{@expected_message.inspect}>"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require 'rspec'
|
|
2
|
+
require 'rspec/expectations'
|
|
3
|
+
require 'given/module_methods'
|
|
4
|
+
|
|
5
|
+
# Monkey patch RSpec to detect matchers used in expectations.
|
|
6
|
+
|
|
7
|
+
unless defined?(RSpec::Given::MONKEY)
|
|
8
|
+
|
|
9
|
+
if defined?(RSpec::Expectations::PositiveExpectationHandler) &&
|
|
10
|
+
defined?(RSpec::Expectations::NegativeExpectationHandler)
|
|
11
|
+
|
|
12
|
+
RSpec::Given::MONKEY = true
|
|
13
|
+
|
|
14
|
+
module RSpec
|
|
15
|
+
module Expectations
|
|
16
|
+
class PositiveExpectationHandler
|
|
17
|
+
class << self
|
|
18
|
+
alias _gvn_rspec_original_handle_matcher handle_matcher
|
|
19
|
+
def handle_matcher(actual, matcher, message=nil, &block)
|
|
20
|
+
::Given.framework.explicitly_asserted
|
|
21
|
+
_gvn_rspec_original_handle_matcher(actual, matcher, message, &block)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
class NegativeExpectationHandler
|
|
27
|
+
class << self
|
|
28
|
+
alias _gvn_rspec_original_handle_matcher handle_matcher
|
|
29
|
+
def handle_matcher(actual, matcher, message=nil, &block)
|
|
30
|
+
::Given.framework.explicitly_asserted
|
|
31
|
+
_gvn_rspec_original_handle_matcher(actual, matcher, message, &block)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
else
|
|
39
|
+
RSpec::Given::MONKEY = false
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
data/lib/given.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'given/minitest/all'
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# This file file is to make bundler happy when auto-requiring files
|
|
2
|
+
# based on gem name. If you are manually requiring minitest/given,
|
|
3
|
+
# please use the canonical require file, ie.
|
|
4
|
+
#
|
|
5
|
+
# require 'minitest/given'
|
|
6
|
+
#
|
|
7
|
+
# Thanks.
|
|
8
|
+
|
|
9
|
+
require 'given/minitest/all'
|
data/lib/rspec/given.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'given/rspec/all'
|
data/lib/rspec-given.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: clarion-given
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Jim Weirich
|
|
8
|
+
- Steve Wagner (keeper)
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2026-10-07 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: rspec
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
requirements:
|
|
18
|
+
- - ">="
|
|
19
|
+
- !ruby/object:Gem::Version
|
|
20
|
+
version: '3.0'
|
|
21
|
+
type: :runtime
|
|
22
|
+
prerelease: false
|
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
24
|
+
requirements:
|
|
25
|
+
- - ">="
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: '3.0'
|
|
28
|
+
description: |
|
|
29
|
+
Clarion Given — keeper's edition of Jim Weirich's rspec-given.
|
|
30
|
+
An RSpec extension for Given/When/Then terminology in specifications.
|
|
31
|
+
Original by Jim Weirich (d. 2014), kept by the Lazarus Project.
|
|
32
|
+
email: jim.weirich@gmail.com
|
|
33
|
+
executables: []
|
|
34
|
+
extensions: []
|
|
35
|
+
extra_rdoc_files: []
|
|
36
|
+
files:
|
|
37
|
+
- lib/given.rb
|
|
38
|
+
- lib/given/assertions.rb
|
|
39
|
+
- lib/given/binary_operation.rb
|
|
40
|
+
- lib/given/core.rb
|
|
41
|
+
- lib/given/evaluator.rb
|
|
42
|
+
- lib/given/ext/numeric.rb
|
|
43
|
+
- lib/given/extensions.rb
|
|
44
|
+
- lib/given/failure.rb
|
|
45
|
+
- lib/given/failure_matcher.rb
|
|
46
|
+
- lib/given/file_cache.rb
|
|
47
|
+
- lib/given/fuzzy_number.rb
|
|
48
|
+
- lib/given/fuzzy_shortcuts.rb
|
|
49
|
+
- lib/given/line_extractor.rb
|
|
50
|
+
- lib/given/minitest/all.rb
|
|
51
|
+
- lib/given/minitest/before_extension.rb
|
|
52
|
+
- lib/given/minitest/configure.rb
|
|
53
|
+
- lib/given/minitest/context_extension.rb
|
|
54
|
+
- lib/given/minitest/failure_must_raise.rb
|
|
55
|
+
- lib/given/minitest/framework.rb
|
|
56
|
+
- lib/given/minitest/new_assertions.rb
|
|
57
|
+
- lib/given/module_methods.rb
|
|
58
|
+
- lib/given/natural_assertion.rb
|
|
59
|
+
- lib/given/rspec/all.rb
|
|
60
|
+
- lib/given/rspec/before_extensions.rb
|
|
61
|
+
- lib/given/rspec/configure.rb
|
|
62
|
+
- lib/given/rspec/framework.rb
|
|
63
|
+
- lib/given/rspec/have_failed.rb
|
|
64
|
+
- lib/given/rspec/have_failed_212.rb
|
|
65
|
+
- lib/given/rspec/have_failed_pre212.rb
|
|
66
|
+
- lib/given/rspec/monkey.rb
|
|
67
|
+
- lib/given/rspec/use_natural_assertions.rb
|
|
68
|
+
- lib/given/version.rb
|
|
69
|
+
- lib/minitest-given.rb
|
|
70
|
+
- lib/minitest/given.rb
|
|
71
|
+
- lib/rspec-given.rb
|
|
72
|
+
- lib/rspec/given.rb
|
|
73
|
+
homepage: https://github.com/steve9020/rspec-given
|
|
74
|
+
licenses:
|
|
75
|
+
- MIT
|
|
76
|
+
metadata: {}
|
|
77
|
+
post_install_message:
|
|
78
|
+
rdoc_options: []
|
|
79
|
+
require_paths:
|
|
80
|
+
- lib
|
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
|
+
requirements:
|
|
83
|
+
- - ">="
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: '2.7'
|
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
|
+
requirements:
|
|
88
|
+
- - ">="
|
|
89
|
+
- !ruby/object:Gem::Version
|
|
90
|
+
version: '0'
|
|
91
|
+
requirements: []
|
|
92
|
+
rubygems_version: 3.4.20
|
|
93
|
+
signing_key:
|
|
94
|
+
specification_version: 4
|
|
95
|
+
summary: Given/When/Then Specification Extensions for RSpec.
|
|
96
|
+
test_files: []
|