r_spec 1.0.0 → 1.0.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 +4 -4
- data/LICENSE.md +2 -2
- data/README.md +54 -206
- data/lib/r_spec.rb +3 -165
- metadata +9 -67
- data/lib/r_spec/console.rb +0 -38
- data/lib/r_spec/dsl.rb +0 -348
- data/lib/r_spec/error/pending_expectation.rb +0 -27
- data/lib/r_spec/error/reserved_method.rb +0 -11
- data/lib/r_spec/error/undefined_described_class.rb +0 -11
- data/lib/r_spec/error/undefined_subject.rb +0 -11
- data/lib/r_spec/error.rb +0 -14
- data/lib/r_spec/expectation_helper/it.rb +0 -41
- data/lib/r_spec/expectation_helper/its.rb +0 -25
- data/lib/r_spec/expectation_helper/shared.rb +0 -82
- data/lib/r_spec/expectation_helper.rb +0 -10
- data/lib/r_spec/expectation_target/base.rb +0 -82
- data/lib/r_spec/expectation_target/block.rb +0 -49
- data/lib/r_spec/expectation_target/value.rb +0 -48
- data/lib/r_spec/expectation_target.rb +0 -30
@@ -1,49 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "base"
|
4
|
-
|
5
|
-
module RSpec
|
6
|
-
module ExpectationTarget
|
7
|
-
# Wraps the target of an expectation with a block.
|
8
|
-
#
|
9
|
-
# @example
|
10
|
-
# expect { something } # => ExpectationTarget::Block wrapping something
|
11
|
-
#
|
12
|
-
# # used with `to`
|
13
|
-
# expect { actual }.to be(42)
|
14
|
-
#
|
15
|
-
# # with `not_to`
|
16
|
-
# expect { actual }.not_to be(4)
|
17
|
-
#
|
18
|
-
# @note `RSpec::ExpectationTarget::Block` is not intended to be instantiated
|
19
|
-
# directly by users. Use `expect` instead.
|
20
|
-
class Block < Base
|
21
|
-
protected
|
22
|
-
|
23
|
-
# @param matcher [#matches?] The matcher.
|
24
|
-
# @param negate [Boolean] The assertion is positive or negative.
|
25
|
-
#
|
26
|
-
# @return [nil] Write a message to STDOUT.
|
27
|
-
#
|
28
|
-
# @raise [SystemExit] Terminate execution immediately by calling
|
29
|
-
# `Kernel.exit(false)` with a failure message written to STDERR.
|
30
|
-
def absolute_requirement(matcher:, negate:)
|
31
|
-
experiment = ::TestTube.invoke(
|
32
|
-
@actual,
|
33
|
-
isolation: false,
|
34
|
-
matcher: matcher,
|
35
|
-
negate: negate
|
36
|
-
)
|
37
|
-
|
38
|
-
result(
|
39
|
-
experiment.got.equal?(true),
|
40
|
-
actual: experiment.actual,
|
41
|
-
error: experiment.error,
|
42
|
-
got: experiment.got,
|
43
|
-
matcher: matcher,
|
44
|
-
negate: negate
|
45
|
-
)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "base"
|
4
|
-
|
5
|
-
module RSpec
|
6
|
-
module ExpectationTarget
|
7
|
-
# Wraps the target of an expectation with a value.
|
8
|
-
#
|
9
|
-
# @example
|
10
|
-
# expect(something) # => ExpectationTarget::Value wrapping something
|
11
|
-
#
|
12
|
-
# # used with `to`
|
13
|
-
# expect(actual).to be(42)
|
14
|
-
#
|
15
|
-
# # with `not_to`
|
16
|
-
# expect(actual).not_to be(4)
|
17
|
-
#
|
18
|
-
# @note `RSpec::ExpectationTarget::Value` is not intended to be instantiated
|
19
|
-
# directly by users. Use `expect` instead.
|
20
|
-
class Value < Base
|
21
|
-
protected
|
22
|
-
|
23
|
-
# @param matcher [#matches?] The matcher.
|
24
|
-
# @param negate [Boolean] The assertion is positive or negative.
|
25
|
-
#
|
26
|
-
# @return [nil] Write a message to STDOUT.
|
27
|
-
#
|
28
|
-
# @raise [SystemExit] Terminate execution immediately by calling
|
29
|
-
# `Kernel.exit(false)` with a failure message written to STDERR.
|
30
|
-
def absolute_requirement(matcher:, negate:)
|
31
|
-
experiment = ::TestTube.pass(
|
32
|
-
@actual,
|
33
|
-
matcher: matcher,
|
34
|
-
negate: negate
|
35
|
-
)
|
36
|
-
|
37
|
-
result(
|
38
|
-
experiment.got.equal?(true),
|
39
|
-
actual: experiment.actual,
|
40
|
-
error: experiment.error,
|
41
|
-
got: experiment.got,
|
42
|
-
matcher: matcher,
|
43
|
-
negate: negate
|
44
|
-
)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative File.join("expectation_target", "block")
|
4
|
-
require_relative File.join("expectation_target", "value")
|
5
|
-
|
6
|
-
module RSpec
|
7
|
-
# Wraps the target of an expectation.
|
8
|
-
#
|
9
|
-
# @api private
|
10
|
-
module ExpectationTarget
|
11
|
-
# @param undefined_value A sentinel value to be able to tell when the user
|
12
|
-
# did not pass an argument. We can't use `nil` for that because `nil` is a
|
13
|
-
# valid value to pass.
|
14
|
-
# @param value [#object_id, nil] An actual value.
|
15
|
-
# @param block [#call, nil] A code to evaluate.
|
16
|
-
#
|
17
|
-
# @return [Block, Value] The wrapped target of an expectation.
|
18
|
-
def self.call(undefined_value, value, block)
|
19
|
-
if undefined_value.equal?(value)
|
20
|
-
raise ::ArgumentError, "Pass either an argument or a block" unless block
|
21
|
-
|
22
|
-
Block.new(block)
|
23
|
-
else
|
24
|
-
raise ::ArgumentError, "Can't pass both an argument and a block" if block
|
25
|
-
|
26
|
-
Value.new(value)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|