rspec_fixtures 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 401c7787d4df45c79d720a28a04804fb926937697328840b80cfe20e1865486c
4
- data.tar.gz: 7c55d0c11c8ea28108724633cb941db07d5bf1cd7eb6039b3267ae2513ead084
3
+ metadata.gz: e275cbc4415001359fe5cba161e50ac4e9624521d41540d098ca653eeb3fda4a
4
+ data.tar.gz: de7b6b0ee599760ea4bf17c79056d7b5bc3497521600709e163e3afa9bb036b0
5
5
  SHA512:
6
- metadata.gz: 54d81dece952c56aa6b26ae36badf588945a025abba189907d2e6784dbbcd03b710b2352608771320b8f5690113764962b1637bec4686831b177f821d6593870
7
- data.tar.gz: a6582c268f11d342806f31a1c7a5c443e6c62807c5f597396fb562493f47385355214867c8d2257e83197055d015698d55933ee95269f8701523d7fe00a2ff21
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
 
@@ -1,7 +1,7 @@
1
1
  module RSpecFixtures
2
2
  module Matchers
3
3
  # Adds the matcher to RSpec:
4
- # `expect{ stream }.to output_fixture(file)`
4
+ # `expect { stream }.to output_fixture(file)`
5
5
  def output_fixture(expected)
6
6
  OutputFixture.new expected
7
7
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module RSpecFixtures
2
- VERSION = "0.6.3"
2
+ VERSION = "0.6.4"
3
3
  end
@@ -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.3
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-09-17 00:00:00.000000000 Z
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