rspec_on_failure 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4dba5bf3d282671405d93226ce281c07a1d246f4
4
+ data.tar.gz: 64e5d97bc0ee6ca7cd439dc327cd3b5270a40189
5
+ SHA512:
6
+ metadata.gz: cc3678f720bf8607771ed742956188e3d9f121714a13d21ff8ba2b384a6ec91a66a16dd0b0b4fe8cd43fe4dff6465fee1701a63fb2c73b296bc79eb82980e1ee
7
+ data.tar.gz: f7d76c8b7529a19bc009df70bd0fad87c6e71c3c22f597a5639082ed5de6dfaddacc5ecf4f50e2737358ff08b959e5e22732a5f98d16ade9c8156bc5536f31ba
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in rspec_on_failure.gemspec
6
+ gemspec
7
+
8
+ gem 'byebug'
data/Gemfile.lock ADDED
@@ -0,0 +1,50 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rspec_on_failure (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (5.2.0)
10
+ concurrent-ruby (~> 1.0, >= 1.0.2)
11
+ i18n (>= 0.7, < 2)
12
+ minitest (~> 5.1)
13
+ tzinfo (~> 1.1)
14
+ byebug (10.0.2)
15
+ concurrent-ruby (1.0.5)
16
+ diff-lcs (1.3)
17
+ i18n (1.0.1)
18
+ concurrent-ruby (~> 1.0)
19
+ minitest (5.11.3)
20
+ rake (10.5.0)
21
+ rspec (3.7.0)
22
+ rspec-core (~> 3.7.0)
23
+ rspec-expectations (~> 3.7.0)
24
+ rspec-mocks (~> 3.7.0)
25
+ rspec-core (3.7.1)
26
+ rspec-support (~> 3.7.0)
27
+ rspec-expectations (3.7.0)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.7.0)
30
+ rspec-mocks (3.7.0)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.7.0)
33
+ rspec-support (3.7.1)
34
+ thread_safe (0.3.6)
35
+ tzinfo (1.2.5)
36
+ thread_safe (~> 0.1)
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ activesupport
43
+ bundler (~> 1.16)
44
+ byebug
45
+ rake (~> 10.0)
46
+ rspec (~> 3.0)
47
+ rspec_on_failure!
48
+
49
+ BUNDLED WITH
50
+ 1.16.1
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # RspecOnFailure
2
+
3
+ Provide additional debugging information to be printed if a test fails.
4
+
5
+ In case the debugging information you want to display on failure cannot be easily determined prior
6
+ to evaluating the expectation. This won't work as expected, for example:
7
+
8
+ expect(user).to be_valid, user.errors.full_messages
9
+
10
+ because user.errors.full_messages is evaluated *before* it actually calls user.valid?, so it will be empty.
11
+
12
+ Instead, you can do this, which defers evaluation of the debug information until the time of the
13
+ failure:
14
+
15
+ on_failure ->{ user.errors.full_messages } do
16
+ user.should be_valid
17
+ end
18
+
19
+ If no block is given, the provided on_failure proc remains in effect until the end of the current
20
+ example.
21
+
22
+ ## Installation
23
+
24
+ Add this line to your application's Gemfile:
25
+
26
+ ```ruby
27
+ gem 'rspec_on_failure'
28
+ ```
29
+
30
+ And then execute:
31
+
32
+ $ bundle
33
+
34
+ Or install it yourself as:
35
+
36
+ $ gem install rspec_on_failure
37
+
38
+ ## Usage
39
+
40
+ TODO: Write usage instructions here
41
+
42
+ ## Development
43
+
44
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
45
+
46
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
47
+
48
+ ## Contributing
49
+
50
+ Bug reports and pull requests are welcome on GitHub at https://github.com/TylerRick/rspec_on_failure.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rspec_on_failure"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ module RspecOnFailure
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,63 @@
1
+ require "rspec_on_failure/version"
2
+
3
+ module RspecOnFailure
4
+ # Provide additional debugging information to be printed if a test fails.
5
+ #
6
+ # In case the debugging information you want to display on failure cannot be easily determined prior
7
+ # to evaluating the expectation. This won't work as expected, for example:
8
+ #
9
+ # expect(user).to be_valid, user.errors.full_messages
10
+ #
11
+ # because user.errors.full_messages is evaluated *before* it actually calls user.valid?, so it will be empty.
12
+ #
13
+ # Instead, you can do this, which defers evaluation of the debug information until the time of the
14
+ # failure:
15
+ #
16
+ # on_failure ->{ user.errors.full_messages } do
17
+ # user.should be_valid
18
+ # end
19
+ #
20
+ # If no block is given, the provided on_failure proc remains in effect until the end of the current
21
+ # example.
22
+ #
23
+ def on_failure(on_failure_proc)
24
+ if block_given?
25
+ on_failure_call_proc(on_failure_proc) do
26
+ yield
27
+ end
28
+ else
29
+ # The provided proc remains in effect until the end of the current example
30
+ @_on_failure_proc = on_failure_proc
31
+ end
32
+ end
33
+
34
+ def on_failure_call_proc(on_failure_proc)
35
+ begin
36
+ yield
37
+ rescue RSpec::Expectations::ExpectationNotMetError
38
+ run_failure_call_proc on_failure_proc
39
+ raise
40
+ end
41
+ end
42
+
43
+ def run_failure_call_proc(on_failure_proc, *args)
44
+ return unless on_failure_proc
45
+ result = on_failure_proc.call *[args].first(on_failure_proc.arity)
46
+ p result unless result.nil?
47
+ end
48
+ end
49
+
50
+ RSpec.configure do |config|
51
+ config.include RspecOnFailure
52
+ config.after(:each) do |example|
53
+ begin
54
+ if example.exception.is_a? RSpec::Expectations::ExpectationNotMetError
55
+ run_failure_call_proc example.metadata[:on_failure], example
56
+ puts %(@_on_failure_proc=#{(@_on_failure_proc).inspect})
57
+ run_failure_call_proc @_on_failure_proc, example
58
+ end
59
+ ensure
60
+ @_on_failure_proc = nil
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,34 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "rspec_on_failure/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rspec_on_failure"
8
+ spec.version = RspecOnFailure::VERSION
9
+ spec.authors = ["Tyler Rick"]
10
+ spec.email = ["tyler@tylerrick.com"]
11
+
12
+ spec.summary = %q{Provide additional debugging information to be printed if a test fails.}
13
+ spec.homepage = "https://github.com/TylerRick/rspec_on_failure"
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
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
25
+ f.match(%r{^(test|spec|features)/})
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.16"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "rspec", "~> 3.0"
34
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec_on_failure
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tyler Rick
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-08-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description:
56
+ email:
57
+ - tyler@tylerrick.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - README.md
68
+ - Rakefile
69
+ - bin/console
70
+ - bin/setup
71
+ - lib/rspec_on_failure.rb
72
+ - lib/rspec_on_failure/version.rb
73
+ - rspec_on_failure.gemspec
74
+ homepage: https://github.com/TylerRick/rspec_on_failure
75
+ licenses: []
76
+ metadata:
77
+ allowed_push_host: https://rubygems.org
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.6.11
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Provide additional debugging information to be printed if a test fails.
98
+ test_files: []