rspec-debug 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
+ SHA256:
3
+ metadata.gz: 68d1438cb27952d2d8afda27e88b854e58d9ea63a09be2d66a65b05df7992f61
4
+ data.tar.gz: 73de8f6f284e8118c9fc1ec7e8673cb179789e031291d5e531b804f612f851b4
5
+ SHA512:
6
+ metadata.gz: 826b4d04dca70fb52a8d355e3257fc93282c4307e9a75c12660e338658de45e85353cf13c1bd7db2af0bd925af808078f4d96b0f2a371374b2eaddb4841a8e3a
7
+ data.tar.gz: a9ed097ae5245f2d11b351353aa521bae61d88975154ac57e5796a48d9433c82af4c5d08a3874a1d2fb54e5ed0707b06403fca2a12abc512f573d11469b2cf9a
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in rspec-debug.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Koichi Sasada
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # Rspec::Debug
2
+
3
+ Launch [debugger](https://github.com/ruby/debug) if spec is failed.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'rspec-debug'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install rspec-debug
20
+
21
+ ## Usage
22
+
23
+ Add `RSPEC_DEBUG=1` environment variable for `rspec` (or `rake spec` and so on).
24
+
25
+ ```
26
+ # example
27
+ $ RSPEC_DEBUG=1 rspec foo_spec.rb
28
+ $ RSPEC_DEBUG=1 rake spec
29
+ ```
30
+
31
+ and invokes debugger if the spec is failed.
32
+
33
+ If you clone this repository, you can try this gem with the following steps:
34
+
35
+ ```
36
+ $ bundle install
37
+ $ RSPEC_DEBUG=true bundle exec rake
38
+ RSpec::Debug
39
+ has a version number
40
+
41
+ try debug, 1st
42
+ Failure:
43
+
44
+ expected false
45
+ got true
46
+ [9, 18] in .../rspec-debug/spec/rspec_debug_spec.rb
47
+ 9| require_relative '../lib/rspec/debug'
48
+ 10|
49
+ 11| RSpec.describe 'try debug, 1st' do
50
+ 12| it 'should fail and debugger' do
51
+ 13| a = true
52
+ => 14| expect(a).to be false
53
+ 15| end
54
+ 16|
55
+ 17| it 'should fail and debugger, 2nd' do
56
+ 18| a = 42
57
+ =>#0 block in <top (required)> (2 levels) at .../rspec-debug/spec/rspec_debug_spec.rb:14```
58
+ ```
59
+
60
+ ## License
61
+
62
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require "rspec/core/rake_task"
4
+ RSpec::Core::RakeTask.new("spec")
5
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rspec/debug"
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,5 @@
1
+ module RSpec
2
+ module Debug
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,49 @@
1
+ require "rspec/debug/version"
2
+
3
+ return unless ['1', 'true'].include?(ENV['RSPEC_DEBUG'])
4
+
5
+ # start debug session
6
+ require 'debug/session'
7
+ DEBUGGER__::start no_sigint_hook: true, nonstop: true
8
+
9
+ module RSpec
10
+ module Core
11
+ class Example
12
+ module DebugAtStop
13
+ def initialize example_group_class, description, user_metadata, example_block=nil
14
+ orig_example_block = example_block
15
+
16
+ if example_block
17
+ example_block = Proc.new do
18
+ begin
19
+ postmortem_hook = TracePoint.new(:raise){|tp|
20
+ exc = tp.raised_exception
21
+ frames = DEBUGGER__.capture_frames(nil)
22
+ frames.delete_if{|e| /(exe|bin|lib)\/rspec/ =~ e.path}
23
+ exc.instance_variable_set(:@__debugger_postmortem_frames, frames)
24
+ }
25
+
26
+ postmortem_hook.enable
27
+ begin
28
+ self.instance_eval(&orig_example_block)
29
+ ensure
30
+ postmortem_hook.disable
31
+ end
32
+
33
+ rescue Exception => e
34
+ STDERR.puts "Failure:"
35
+ STDERR.puts e.message
36
+ DEBUGGER__::SESSION.enter_postmortem_session e
37
+ raise
38
+ end
39
+ end # Proc.new
40
+ end
41
+
42
+ super
43
+ end
44
+ end
45
+ prepend DebugAtStop
46
+ end
47
+ end
48
+ end
49
+
@@ -0,0 +1,26 @@
1
+ require_relative 'lib/rspec/debug/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "rspec-debug"
5
+ spec.version = RSpec::Debug::VERSION
6
+ spec.authors = ["Koichi Sasada"]
7
+ spec.email = ["ko1@atdot.net"]
8
+
9
+ spec.summary = %q{invoke debugger if spec fails}
10
+ spec.description = %q{invoke debugger if spec fails}
11
+ spec.homepage = "https://github.com/ko1/rspec-debug"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = spec.homepage
17
+ spec.metadata["changelog_uri"] = spec.homepage
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+ spec.require_paths = ["lib"]
25
+ spec.add_runtime_dependency 'debug', '>= 1.3.2'
26
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-debug
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Koichi Sasada
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-10-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: debug
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.3.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.3.2
27
+ description: invoke debugger if spec fails
28
+ email:
29
+ - ko1@atdot.net
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - ".rspec"
36
+ - Gemfile
37
+ - LICENSE.txt
38
+ - README.md
39
+ - Rakefile
40
+ - bin/console
41
+ - bin/setup
42
+ - lib/rspec/debug.rb
43
+ - lib/rspec/debug/version.rb
44
+ - rspec-debug.gemspec
45
+ homepage: https://github.com/ko1/rspec-debug
46
+ licenses:
47
+ - MIT
48
+ metadata:
49
+ homepage_uri: https://github.com/ko1/rspec-debug
50
+ source_code_uri: https://github.com/ko1/rspec-debug
51
+ changelog_uri: https://github.com/ko1/rspec-debug
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 2.6.0
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubygems_version: 3.1.6
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: invoke debugger if spec fails
71
+ test_files: []