rspec_on_failure 0.1.1 → 1.0.0

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
  SHA1:
3
- metadata.gz: dfe76197162f75903969fc14398f10a0ef5303b7
4
- data.tar.gz: 98ee7e8eaf05fc9a46ff902014e12c0064b79629
3
+ metadata.gz: ea10d3320e923830fc00ce40dfc03899f0da511f
4
+ data.tar.gz: 2572ad00a6ba1a95d8de57fb9d2899a9145ced74
5
5
  SHA512:
6
- metadata.gz: a568989a4a16620960e0e23d8ff8f2ccd743d733c5076caa4171d40d08ba0d1443fc5a1d5d516bf9c935601fd5516ba3cd8263b7889f8762b8bf8892b27fe041
7
- data.tar.gz: 9e3cf964634da64774f6e1b48fd886aebbd747c6bc76d05f2c6f0ce939cb0d5da398c740da1a7c5257cc925b3305f431d2739b67b80c2afe5ac6af4c2ce0c020
6
+ metadata.gz: 3762ee0570b803c2077cab03699add33950777da2961d68130288b0515e111372b3aee00cd8f81da93427011f212edb4b1ab08351adaa3aced79a2d55e2c7742
7
+ data.tar.gz: fb2c1fde304c4dd11a0cd95975d8c24d743fb2520dabe681bc230f3a1f3c38da9576603167b5e593502b10dcc6344617c8f4e4e1f64c60c6d75efd74c913c505
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
3
+ This project follows [semver 2.0.0](http://semver.org/spec/v2.0.0.html) and the
4
+ recommendations of [keepachangelog.com](http://keepachangelog.com/).
5
+
6
+ ## (Unreleased)
7
+
8
+ ## 1.0.0 (2019-10-18)
9
+
10
+ ### Breaking changes
11
+ - Rescue a broader set of exceptions, not just `RSpec::Expectations::ExpectationNotMetError`
12
+
13
+ ### Fixed
14
+ - It was failing to trigger the `on_failure` block when the failure was due to an
15
+ exception other than a `ExpectationNotMetError`, like `Capybara::ElementNotFound`.
16
+
data/License ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2019 Tyler Rick
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
4
+ associated documentation files (the "Software"), to deal in the Software without restriction,
5
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
6
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
7
+ furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial
10
+ portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18
+ SOFTWARE.
@@ -2,23 +2,35 @@
2
2
 
3
3
  Provide additional debugging information to be printed if a test fails.
4
4
 
5
- In case the debugging information you want to display on failure cannot be easily determined prior
5
+ In case the debugging information you want to display on failure cannot be easily determined *prior*
6
6
  to evaluating the expectation. This won't work as expected, for example:
7
7
 
8
- expect(user).to be_valid, user.errors.full_messages
8
+ ```ruby
9
+ expect(user).to be_valid, user.errors.full_messages
10
+ ```
9
11
 
10
- because user.errors.full_messages is evaluated *before* it actually calls user.valid?, so it will be empty.
12
+ because `user.errors.full_messages` gets evaluated too soon. This will show the list of errors as it
13
+ was *prior* to calling `user.valid?` (that is, an empty array), rather than the list of errors as it
14
+ was *after* validating therecord, which is what we actually want.
11
15
 
12
16
  Instead, you can do this, which defers evaluation of the debug information until the time of the
13
17
  failure:
14
18
 
19
+ ```ruby
15
20
  on_failure ->{ user.errors.full_messages } do
16
- user.should be_valid
21
+ expect(user).to be_valid
17
22
  end
23
+ ```
18
24
 
19
25
  If no block is given, the provided on_failure proc remains in effect until the end of the current
20
26
  example.
21
27
 
28
+ ```ruby
29
+ on_failure ->{ user.errors.full_messages }
30
+ expect(user).to be_valid
31
+ expect(user.errors[:name]).to include "is required"
32
+ ```
33
+
22
34
  ## Installation
23
35
 
24
36
  Add this line to your application's Gemfile:
@@ -14,12 +14,16 @@ module RspecOnFailure
14
14
  # failure:
15
15
  #
16
16
  # on_failure ->{ user.errors.full_messages } do
17
- # user.should be_valid
17
+ # expect(user).to be_valid
18
18
  # end
19
19
  #
20
20
  # If no block is given, the provided on_failure proc remains in effect until the end of the current
21
21
  # example.
22
22
  #
23
+ # on_failure ->{ user.errors.full_messages }
24
+ # expect(user).to be_valid
25
+ # expect(user.errors[:name]).to include "is required"
26
+ #
23
27
  def on_failure(on_failure_proc)
24
28
  if block_given?
25
29
  on_failure_call_proc(on_failure_proc) do
@@ -34,7 +38,7 @@ module RspecOnFailure
34
38
  def on_failure_call_proc(on_failure_proc)
35
39
  begin
36
40
  yield
37
- rescue RSpec::Expectations::ExpectationNotMetError
41
+ rescue RSpec::Support::AllExceptionsExceptOnesWeMustNotRescue
38
42
  run_failure_call_proc on_failure_proc
39
43
  raise
40
44
  end
@@ -51,7 +55,7 @@ RSpec.configure do |config|
51
55
  config.include RspecOnFailure
52
56
  config.after(:each) do |example|
53
57
  begin
54
- if example.exception.is_a? RSpec::Expectations::ExpectationNotMetError
58
+ if example.exception and RSpec::Support::AllExceptionsExceptOnesWeMustNotRescue === example.exception
55
59
  run_failure_call_proc example.metadata[:on_failure], example
56
60
  #puts %(@_on_failure_proc=#{(@_on_failure_proc).inspect})
57
61
  run_failure_call_proc @_on_failure_proc, example
@@ -1,3 +1,5 @@
1
1
  module RspecOnFailure
2
- VERSION = "0.1.1"
2
+ def self.version
3
+ "1.0.0"
4
+ end
3
5
  end
@@ -5,22 +5,13 @@ require "rspec_on_failure/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "rspec_on_failure"
8
- spec.version = RspecOnFailure::VERSION
8
+ spec.version = RspecOnFailure.version
9
9
  spec.authors = ["Tyler Rick"]
10
10
  spec.email = ["tyler@tylerrick.com"]
11
11
 
12
12
  spec.summary = %q{Provide additional debugging information to be printed if a test fails.}
13
13
  spec.homepage = "https://github.com/TylerRick/rspec_on_failure"
14
14
 
15
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
16
- # to allow pushing to a single host or delete this section to allow pushing to any host.
17
- if spec.respond_to?(:metadata)
18
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
- else
20
- raise "RubyGems 2.0 or newer is required to protect against " \
21
- "public gem pushes."
22
- end
23
-
24
15
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
25
16
  f.match(%r{^(test|spec|features)/})
26
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_on_failure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Rick
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-13 00:00:00.000000000 Z
11
+ date: 2019-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -62,10 +62,12 @@ files:
62
62
  - ".gitignore"
63
63
  - ".rspec"
64
64
  - ".travis.yml"
65
+ - Changelog.md
65
66
  - Gemfile
66
67
  - Gemfile.lock
67
- - README.md
68
+ - License
68
69
  - Rakefile
70
+ - Readme.md
69
71
  - bin/console
70
72
  - bin/setup
71
73
  - lib/rspec_on_failure.rb
@@ -73,8 +75,7 @@ files:
73
75
  - rspec_on_failure.gemspec
74
76
  homepage: https://github.com/TylerRick/rspec_on_failure
75
77
  licenses: []
76
- metadata:
77
- allowed_push_host: https://rubygems.org
78
+ metadata: {}
78
79
  post_install_message:
79
80
  rdoc_options: []
80
81
  require_paths:
@@ -91,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
92
  version: '0'
92
93
  requirements: []
93
94
  rubyforge_project:
94
- rubygems_version: 2.6.11
95
+ rubygems_version: 2.6.14.3
95
96
  signing_key:
96
97
  specification_version: 4
97
98
  summary: Provide additional debugging information to be printed if a test fails.