fear-rspec 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/README.md +35 -5
- data/lib/fear/rspec/be_failure_of.rb +40 -0
- data/lib/fear/rspec/be_some_of.rb +42 -0
- data/lib/fear/rspec/be_success_of.rb +41 -0
- data/lib/fear/rspec/version.rb +1 -1
- data/lib/fear/rspec.rb +3 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f759cb1fba803e80557dcee13188953ddab2039
|
4
|
+
data.tar.gz: fa7f26349dc37c36b0b2a85d89cf60a9c591d218
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48dd6a7a70c6ec250a43876032aaed46bb5f526eac343c2f89383aae53d2438080acd8638b0a6286fb53095137805d337c7eddf33a247e4992e8ca6d10b45c54
|
7
|
+
data.tar.gz: 8415757e11f14dbe81a4d768c996d38c7a8c28982596c8a53186617cddc7d16113fe61fef97c6c7a00e966556c9bd8b4d7aabcda5245adcbd012071a39aafc5f
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -26,24 +26,54 @@ Load matchers:
|
|
26
26
|
require 'fear/rspec'
|
27
27
|
```
|
28
28
|
|
29
|
+
### Try matchers
|
30
|
+
|
31
|
+
To match against a `Failure`, use `be_failure_of` matcher.
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
expect(Failure(ArgumentError)).to be_failure_of(ArgumentError) # passes
|
35
|
+
expect(Failure(ArgumentError)).to be_failure_of(RuntimeError) # fails
|
36
|
+
expect(Success(5)).to be_failure_of(5) # fails
|
37
|
+
```
|
38
|
+
|
39
|
+
To match against a `Success`, use `be_success_of` matcher.
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
expect(5).not_to be_success_of(5) # passes
|
43
|
+
expect(Success(5)).to be_success_of(5) # passes
|
44
|
+
expect(Success(1)).to be_success_of(5) # fails
|
45
|
+
expect(Failure(ArgumentError)).to be_success_of(5) # fails
|
46
|
+
```
|
47
|
+
|
29
48
|
### Either matchers
|
30
49
|
|
31
50
|
To match against a `Left`, use `be_left_of` matcher.
|
32
51
|
|
33
52
|
```ruby
|
34
|
-
expect(5).not_to
|
35
|
-
expect(Left(5)).to
|
36
|
-
expect(Left(1)).to
|
53
|
+
expect(5).not_to be_left_of(5) # passes
|
54
|
+
expect(Left(5)).to be_left_of(5) # passes
|
55
|
+
expect(Left(1)).to be_left_of(5) # fails
|
37
56
|
expect(Right(5)).to be_left_of(5) # fails
|
38
57
|
```
|
39
58
|
|
40
59
|
To match against a `Right`, use `be_right_of` matcher.
|
41
60
|
|
42
61
|
```ruby
|
43
|
-
expect(5).not_to
|
62
|
+
expect(5).not_to be_right_of(5) # passes
|
44
63
|
expect(Right(5)).to be_right_of(5) # passes
|
45
64
|
expect(Right(1)).to be_right_of(5) # fails
|
46
|
-
expect(Left(5)).to
|
65
|
+
expect(Left(5)).to be_right_of(5) # fails
|
66
|
+
```
|
67
|
+
|
68
|
+
### Option matchers
|
69
|
+
|
70
|
+
To match against a `Some`, use `be_some_of` matcher.
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
expect(5).not_to be_some_of(5) # passes
|
74
|
+
expect(Some(5)).to be_some_of(5) # passes
|
75
|
+
expect(Some(1)).to be_some_of(5) # fails
|
76
|
+
expect(None()).to be_some_of(5) # fails
|
47
77
|
```
|
48
78
|
|
49
79
|
## Development
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Fear
|
2
|
+
module RSpec
|
3
|
+
# Passes if `actual` is Left and matches `expected`.
|
4
|
+
#
|
5
|
+
# @example
|
6
|
+
# expect(5).not_to be_failure_of (5)
|
7
|
+
# expect(Failure(5)).to be_failure_of (5)
|
8
|
+
#
|
9
|
+
::RSpec::Matchers.define :be_failure_of do |expected|
|
10
|
+
match do |actual|
|
11
|
+
actual.is_a?(Fear::Failure) && begin
|
12
|
+
expected = with_matchers_cloned(expected)
|
13
|
+
::RSpec::Support::FuzzyMatcher.values_match?(expected, actual.exception)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
failure_message_when_negated do |actual|
|
18
|
+
format(
|
19
|
+
"\nexpected: not Failure of %<expected>s\n got: %<actual>s\n",
|
20
|
+
expected: ::RSpec::Support::ObjectFormatter.format(expected),
|
21
|
+
actual: ::RSpec::Support::ObjectFormatter.format(actual),
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
failure_message do |actual|
|
26
|
+
format(
|
27
|
+
"\nexpected: Failure of %<expected>s\n got: %<actual>s\n",
|
28
|
+
expected: ::RSpec::Support::ObjectFormatter.format(expected),
|
29
|
+
actual: ::RSpec::Support::ObjectFormatter.format(actual),
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
description do
|
34
|
+
"be Failure of #{expected}"
|
35
|
+
end
|
36
|
+
|
37
|
+
diffable
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Fear
|
2
|
+
module RSpec
|
3
|
+
# Passes if `actual` is Some and matches `expected`.
|
4
|
+
#
|
5
|
+
# @example
|
6
|
+
# expect(5).not_to be_some_of(5)
|
7
|
+
# expect(Some(5)).to be_some_of(5)
|
8
|
+
# expect(None()).to be_some_of(5)
|
9
|
+
#
|
10
|
+
::RSpec::Matchers.define :be_some_of do |expected|
|
11
|
+
match do |actual|
|
12
|
+
actual.is_a?(Fear::Option) &&
|
13
|
+
actual.any? do |value|
|
14
|
+
expected = with_matchers_cloned(expected)
|
15
|
+
::RSpec::Support::FuzzyMatcher.values_match?(expected, value)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_when_negated do |actual|
|
20
|
+
format(
|
21
|
+
"\nexpected: not Some of %<expected>s\n got: %<actual>s\n",
|
22
|
+
expected: ::RSpec::Support::ObjectFormatter.format(expected),
|
23
|
+
actual: ::RSpec::Support::ObjectFormatter.format(actual),
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
failure_message do |actual|
|
28
|
+
format(
|
29
|
+
"\nexpected: Some of %<expected>s\n got: %<actual>s\n",
|
30
|
+
expected: ::RSpec::Support::ObjectFormatter.format(expected),
|
31
|
+
actual: ::RSpec::Support::ObjectFormatter.format(actual),
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
description do
|
36
|
+
"be Some of #{expected}"
|
37
|
+
end
|
38
|
+
|
39
|
+
diffable
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Fear
|
2
|
+
module RSpec
|
3
|
+
# Passes if `actual` is Success and matches `expected`.
|
4
|
+
#
|
5
|
+
# @example
|
6
|
+
# expect(5).not_to be_success_of(5)
|
7
|
+
# expect(Success(5)).to be_success_of(5)
|
8
|
+
#
|
9
|
+
::RSpec::Matchers.define :be_success_of do |expected|
|
10
|
+
match do |actual|
|
11
|
+
actual.is_a?(Fear::Try) &&
|
12
|
+
actual.any? do |value|
|
13
|
+
expected = with_matchers_cloned(expected)
|
14
|
+
::RSpec::Support::FuzzyMatcher.values_match?(expected, value)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
failure_message_when_negated do |actual|
|
19
|
+
format(
|
20
|
+
"\nexpected: not Success of %<expected>s\n got: %<actual>s\n",
|
21
|
+
expected: ::RSpec::Support::ObjectFormatter.format(expected),
|
22
|
+
actual: ::RSpec::Support::ObjectFormatter.format(actual),
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
failure_message do |actual|
|
27
|
+
format(
|
28
|
+
"\nexpected: Success of %<expected>s\n got: %<actual>s\n",
|
29
|
+
expected: ::RSpec::Support::ObjectFormatter.format(expected),
|
30
|
+
actual: ::RSpec::Support::ObjectFormatter.format(actual),
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
description do
|
35
|
+
"be Success of #{expected}"
|
36
|
+
end
|
37
|
+
|
38
|
+
diffable
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/fear/rspec/version.rb
CHANGED
data/lib/fear/rspec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fear-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tema Bolshakov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -113,8 +113,11 @@ files:
|
|
113
113
|
- bin/setup
|
114
114
|
- fear-rspec.gemspec
|
115
115
|
- lib/fear/rspec.rb
|
116
|
+
- lib/fear/rspec/be_failure_of.rb
|
116
117
|
- lib/fear/rspec/be_left_of.rb
|
117
118
|
- lib/fear/rspec/be_right_of.rb
|
119
|
+
- lib/fear/rspec/be_some_of.rb
|
120
|
+
- lib/fear/rspec/be_success_of.rb
|
118
121
|
- lib/fear/rspec/version.rb
|
119
122
|
homepage: https://github.com/bolshakov/fear-rspec
|
120
123
|
licenses:
|