rspec_fixtures 0.6.3 → 0.6.4
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/README.md +15 -5
- data/lib/rspec_fixtures/matchers/output_fixture.rb +1 -1
- data/lib/rspec_fixtures/matchers/raise_fixture.rb +30 -0
- data/lib/rspec_fixtures/version.rb +1 -1
- data/lib/rspec_fixtures.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e275cbc4415001359fe5cba161e50ac4e9624521d41540d098ca653eeb3fda4a
|
4
|
+
data.tar.gz: de7b6b0ee599760ea4bf17c79056d7b5bc3497521600709e163e3afa9bb036b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a265b08892e6a2568c2f628bc290d09378013cc1428acef54d09581912c270efe2892a39880f34e26acc856692e9c46e52c7d408b7288d4caba2de0a9a9b696
|
7
|
+
data.tar.gz: 4205ad6ce9c5d9df45e4e8440f620134bc9420d3cc52ac014efecd1069914575a6cd5e0f0ac6224937bd5939e9fbed1f05d0a6a74d24b3647f05becbfa21853f
|
data/README.md
CHANGED
@@ -73,14 +73,24 @@ expect('some string').to match_fixture('fixture_filename')
|
|
73
73
|
Compare an output (stdout or stderr) with a pre-approved fixture.
|
74
74
|
|
75
75
|
```ruby
|
76
|
-
expect{ puts "hello" }.to output_fixture('fixture_filename')
|
77
|
-
expect{ puts "hello" }.to output_fixture('fixture_filename').to_stdout
|
78
|
-
expect{ $stderr.puts "hello" }.to output_fixture('fixture_filename').to_stderr
|
76
|
+
expect { puts "hello" }.to output_fixture('fixture_filename')
|
77
|
+
expect { puts "hello" }.to output_fixture('fixture_filename').to_stdout
|
78
|
+
expect { $stderr.puts "hello" }.to output_fixture('fixture_filename').to_stderr
|
79
79
|
|
80
80
|
# The first two are the same, as the default stream is stdout.
|
81
81
|
```
|
82
82
|
|
83
83
|
|
84
|
+
### `raise_fixture` - Compare raised exceptions
|
85
|
+
|
86
|
+
Compare a raised exception with a pre-approved fixture.
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
expect { raise 'some error' }.to raise_fixture('fixture_filename')
|
90
|
+
```
|
91
|
+
|
92
|
+
|
93
|
+
|
84
94
|
Modifiers
|
85
95
|
--------------------------------------------------
|
86
96
|
|
@@ -94,8 +104,8 @@ the same, using `diff` compares the strings using the
|
|
94
104
|
In the below example, we allow up to 5 characters to be different.
|
95
105
|
|
96
106
|
```ruby
|
97
|
-
expect('some string').to match_fixture('fixture_filename').diff(5)
|
98
|
-
expect{ puts 'some string' }.to output_fixture('fixture_filename').diff(5)
|
107
|
+
expect ('some string').to match_fixture('fixture_filename').diff(5)
|
108
|
+
expect { puts 'some string' }.to output_fixture('fixture_filename').diff(5)
|
99
109
|
```
|
100
110
|
|
101
111
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module RSpecFixtures
|
2
|
+
module Matchers
|
3
|
+
# Adds the matcher to RSpec:
|
4
|
+
# `expect { something_that_errors }.to raise_fixture(file)`
|
5
|
+
def raise_fixture(expected)
|
6
|
+
RaiseFixture.new expected
|
7
|
+
end
|
8
|
+
|
9
|
+
class RaiseFixture < Base
|
10
|
+
# Called by RSpec
|
11
|
+
def matches?(block)
|
12
|
+
return false unless block.is_a? Proc
|
13
|
+
@actual = 'Nothing raised'
|
14
|
+
|
15
|
+
begin
|
16
|
+
block.call
|
17
|
+
rescue => e
|
18
|
+
@actual = e.inspect
|
19
|
+
end
|
20
|
+
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
# Lets RSpec know that this matcher requires a block.
|
25
|
+
def supports_block_expectations?
|
26
|
+
true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/rspec_fixtures.rb
CHANGED
@@ -5,5 +5,6 @@ require 'rspec_fixtures/approval_handler'
|
|
5
5
|
require 'rspec_fixtures/matchers/base'
|
6
6
|
require 'rspec_fixtures/matchers/match_fixture'
|
7
7
|
require 'rspec_fixtures/matchers/output_fixture'
|
8
|
+
require 'rspec_fixtures/matchers/raise_fixture'
|
8
9
|
|
9
10
|
require 'rspec_fixtures/rspec_config'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec_fixtures
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- lib/rspec_fixtures/matchers/base.rb
|
80
80
|
- lib/rspec_fixtures/matchers/match_fixture.rb
|
81
81
|
- lib/rspec_fixtures/matchers/output_fixture.rb
|
82
|
+
- lib/rspec_fixtures/matchers/raise_fixture.rb
|
82
83
|
- lib/rspec_fixtures/rspec_config.rb
|
83
84
|
- lib/rspec_fixtures/stream_capturer.rb
|
84
85
|
- lib/rspec_fixtures/version.rb
|