diff --git a/.ruby-version b/.ruby-version index 4efbd8f..72b3400 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-3.0.2 +ruby-3.2.1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fed12b..e73ab0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 1.0.0 + +- Support including class/method after file/line in every `pd` printout + ## 0.13.5 - Fix not printing source line in Rails app w/ Pry diff --git a/Gemfile b/Gemfile index 7359880..29d2e46 100644 --- a/Gemfile +++ b/Gemfile @@ -13,9 +13,9 @@ group :development do gem 'rdoc', '~> 3.12' gem 'jeweler', '~> 2.3.9' gem 'bundler', '>= 2.1.4' - gem 'coveralls', '= 0.8.23', require: false - gem 'simplecov', '~> 0.16.1', require: nil - gem 'simplecov-lcov', '~> 0.7.0', require: nil +# gem 'coveralls', '= 0.8.23', require: false +# gem 'simplecov', '~> 0.16.1', require: nil +# gem 'simplecov-lcov', '~> 0.7.0', require: nil gem 'logging', '>= 2.3.0' gem 'rake-tui' end diff --git a/Gemfile.lock b/Gemfile.lock index 6d0403d..82cb8aa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,19 +4,12 @@ GEM addressable (2.4.0) awesome_print (1.9.2) builder (3.2.4) - coveralls (0.8.23) - json (>= 1.8, < 3) - simplecov (~> 0.16.1) - term-ansicolor (~> 1.3) - thor (>= 0.19.4, < 2.0) - tins (~> 1.6) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) diff-lcs (1.5.0) - docile (1.4.0) faraday (0.9.2) multipart-post (>= 1.2, < 3) - git (1.10.2) + git (1.11.0) rchardet (~> 1.8) github_api (0.16.0) addressable (~> 2.4.0) @@ -26,7 +19,7 @@ GEM mime-types (>= 1.16, < 3.0) oauth2 (~> 1.0) hashie (5.0.0) - highline (2.0.3) + highline (2.1.0) jeweler (2.3.9) builder bundler @@ -39,65 +32,53 @@ GEM rdoc semver2 json (1.8.6) - jwt (2.3.0) + jwt (2.7.0) little-plugger (1.1.4) - logging (2.3.0) + logging (2.3.1) little-plugger (~> 1.1) multi_json (~> 1.14) mime-types (2.99.3) - mini_portile2 (2.7.1) + mini_portile2 (2.8.2) multi_json (1.15.0) multi_xml (0.6.0) - multipart-post (2.1.1) - nokogiri (1.13.1) - mini_portile2 (~> 2.7.0) + multipart-post (2.3.0) + nokogiri (1.14.3) + mini_portile2 (~> 2.8.0) racc (~> 1.4) - oauth2 (1.4.7) - faraday (>= 0.8, < 2.0) + oauth2 (1.4.8) + faraday (>= 0.8, < 3.0) jwt (>= 1.0, < 3.0) multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) pastel (0.8.0) tty-color (~> 0.5) - psych (4.0.3) + psych (5.1.0) stringio - racc (1.6.0) - rack (2.2.3) + racc (1.6.2) + rack (2.2.7) rake (13.0.6) rake-tui (0.2.3) tty-prompt rchardet (1.8.0) rdoc (3.12.2) json (~> 1.4) - rspec (3.10.0) - rspec-core (~> 3.10.0) - rspec-expectations (~> 3.10.0) - rspec-mocks (~> 3.10.0) - rspec-core (3.10.2) - rspec-support (~> 3.10.0) - rspec-expectations (3.10.2) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-mocks (3.10.3) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.5) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-support (3.10.3) + rspec-support (~> 3.12.0) + rspec-support (3.12.0) semver2 (3.4.2) - simplecov (0.16.1) - docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) - simplecov-lcov (0.7.0) - stringio (3.0.1) - sync (0.5.0) - term-ansicolor (1.7.1) - tins (~> 1.0) - thor (1.2.1) + stringio (3.0.6) thread_safe (0.3.6) - tins (1.31.0) - sync tty-color (0.6.0) tty-cursor (0.7.1) tty-prompt (0.23.1) @@ -116,15 +97,12 @@ PLATFORMS DEPENDENCIES awesome_print (~> 1.9.2) bundler (>= 2.1.4) - coveralls (= 0.8.23) jeweler (~> 2.3.9) logging (>= 2.3.0) rake-tui rdoc (~> 3.12) rspec (~> 3.5) rspec-mocks (~> 3.5) - simplecov (~> 0.16.1) - simplecov-lcov (~> 0.7.0) BUNDLED WITH - 2.3.6 + 2.4.13 diff --git a/LICENSE.txt b/LICENSE.txt index a0f8eb4..96b7749 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2017-2021 - Andy Maleh +Copyright (c) 2017-2024 - Andy Maleh Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/README.md b/README.md index ed174c1..b8bec42 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ -# Puts Debuggerer (debugger-less debugging FTW) -## [Featured in State of the Art Rails 2021 Edition](https://github.com/DanielVartanov/state-of-the-art-rails/tree/3d538fc6ba5287ce6c1ed15ced598ce19bbe81b5) +# Puts Debuggerer 1.0.0 +## Debugger-less Debugging FTW +## [Featured in State of the Art Rails 2023 Edition](https://github.com/DanielVartanov/state-of-the-art-rails/tree/bd7a509f5f0ab07cebfeada779b5c73e1eaf22ed) [![Gem Version](https://badge.fury.io/rb/puts_debuggerer.svg)](http://badge.fury.io/rb/puts_debuggerer) [![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/puts_debuggerer/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/puts_debuggerer?branch=master) [![Maintainability](https://api.codeclimate.com/v1/badges/81d8f6e046eb1b4a36f4/maintainability)](https://codeclimate.com/github/AndyObtiva/puts_debuggerer/maintainability) @@ -12,7 +13,7 @@ Debuggers are great! They help us troubleshoot complicated programming problems In day-to-day test-driven development and simple app debugging though, a puts statement can be a lot quicker in revealing what is going on than halting execution completely just to inspect a single value or a few. This is certainly true when writing the simplest possible code that could possibly work, and running a test every few seconds or minutes. Still, there are a number of problems with puts debugging, like difficulty in locating puts statements in a large output log, knowing which methods and line numbers were invoked, identifying which variables were printed, and seeing the content of structured hashes and arrays in an understandable format. -Enter [puts_debuggerer](https://rubygems.org/gems/puts_debuggerer)! A guilt-free puts debugging Ruby gem FTW that prints file names, line numbers, code statements, headers, footers, stack traces, and formats output nicely courtesy of [awesome_print](https://rubygems.org/gems/awesome_print) (or [amazing_print](https://github.com/amazing-print/amazing_print) if you prefer). +Enter [puts_debuggerer](https://rubygems.org/gems/puts_debuggerer)! A guilt-free puts debugging Ruby gem FTW that prints file names, line numbers, invoked class methods, code statements, headers, footers, stack traces, and formats output nicely courtesy of [awesome_print](https://rubygems.org/gems/awesome_print) (or [amazing_print](https://github.com/amazing-print/amazing_print) if you prefer). [puts_debuggerer](https://rubygems.org/gems/puts_debuggerer) automates tips mentioned in [this blog post](https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html) by Aaron Patterson using the `pd` method available everywhere after requiring the [gem](https://rubygems.org/gems/puts_debuggerer). @@ -21,18 +22,25 @@ Basic Example: ```ruby # /Users/User/trivia_app.rb # line 1 require 'pd' # line 2 -bug_or_band = 'beatles' # line 3 -pd bug_or_band # line 4 (band) +class TriviaApp # line 3 + def question # line 4 + bug_or_band = 'Beatles' # line 5 + pd bug_or_band # line 6 + end # line 7 +end # line 8 +TriviaApp.new.question # line 9 ``` Output: ```bash -[PD] /Users/User/trivia_app.rb:4 - > pd bug_or_band # line 4 (band) - => "beatles" +[PD] /Users/User/trivia_app.rb:6 in TriviaApp.question + > pd bug_or_band # line 6 + => "Beatles" ``` +`pd` revealed that the variable contains the band name "Beatles" as its value not the bug "Beetle", in addition to revealing the printed code statement `pd bug_or_band`, the file name `/Users/User/trivia_app.rb`, the line number `6`, the class name `TriviaApp`, and the invoked method name `question`. + ## Background It can be quite frustrating to lose puts statements in a large output or log file. One way to help find them is add an announcer (e.g. `puts "The Order Total"`) or a header (e.g. `puts '>'*80`) before every puts statement. Unfortunately, that leads to repetitive wasteful effort that adds up quickly over many work sessions and interrupts thinking flow while solving problems. @@ -64,7 +72,7 @@ Which gets lost in a logging stream such as: (0.2ms) COMMIT ``` -Here is a simple example using `pd` instead, which provides everything the puts statements above provide in addition to deducing the file name and line number automatically for dead easy debugging: +Here is a simple example using `pd` instead, which provides everything the puts statements above provide in addition to deducing the file name, line number, and invoked class method automatically for dead-easy debugging: ```ruby pd order_total @@ -78,7 +86,7 @@ Output: (0.2ms) BEGIN SQL (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", 2017-08-24 22:56:52 UTC], ["updated_at", 2017-08-24 22:56:52 UTC]] (0.3ms) COMMIT -[PD] /Users/User/ordering/order.rb:39 +[PD] /Users/User/ordering/order.rb:39 in Order.calculate_order_total > pd order_total => 195.50 ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]] @@ -99,19 +107,19 @@ Output: ``` (2.7ms) CREATE TABLE "ar_internal_metadata" ("key" character varying PRIMARY KEY, "value" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) ActiveRecord::InternalMetadata Load (0.4ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]] -[PD] /Users/User/ordering/order.rb:39 +[PD] /Users/User/ordering/order.rb:39 in Order.calculate_order_total > pd order_total => 195.50 (0.2ms) BEGIN SQL (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", 2017-08-24 22:56:52 UTC], ["updated_at", 2017-08-24 22:56:52 UTC]] (0.3ms) COMMIT -[PD] /Users/User/ordering/order.rb:40 +[PD] /Users/User/ordering/order.rb:40 in Order.calculate_order_total > pd order_summary => "Pragmatic Ruby Book" ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]] (0.2ms) BEGIN (0.2ms) COMMIT -[PD] /Users/User/ordering/order.rb:41 +[PD] /Users/User/ordering/order.rb:41 in Order.calculate_order_total > pd order_details => "[Hard Cover] Pragmatic Ruby Book - English Version" ``` @@ -138,19 +146,19 @@ Output: (2.7ms) CREATE TABLE "ar_internal_metadata" ("key" character varying PRIMARY KEY, "value" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) ActiveRecord::InternalMetadata Load (0.4ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -[PD] /Users/User/ordering/order.rb:39 +[PD] /Users/User/ordering/order.rb:39 in Order.calculate_order_total > pd order_total, header: true => 195.50 (0.2ms) BEGIN SQL (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", 2017-08-24 22:56:52 UTC], ["updated_at", 2017-08-24 22:56:52 UTC]] (0.3ms) COMMIT -[PD] /Users/User/ordering/order.rb:40 +[PD] /Users/User/ordering/order.rb:40 in Order.calculate_order_total > pd order_summary => "Pragmatic Ruby Book" ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]] (0.2ms) BEGIN (0.2ms) COMMIT -[PD] /Users/User/ordering/order.rb:41 +[PD] /Users/User/ordering/order.rb:41 in Order.calculate_order_total > pd order_details => "[Hard Cover] Pragmatic Ruby Book - English Version" ``` @@ -177,19 +185,19 @@ Output: (2.7ms) CREATE TABLE "ar_internal_metadata" ("key" character varying PRIMARY KEY, "value" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) ActiveRecord::InternalMetadata Load (0.4ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]] ################################################################################ -[PD] /Users/User/ordering/order.rb:39 +[PD] /Users/User/ordering/order.rb:39 in Order.calculate_order_total > pd order_total, header: '>'*80 => 195.50 (0.2ms) BEGIN SQL (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", 2017-08-24 22:56:52 UTC], ["updated_at", 2017-08-24 22:56:52 UTC]] (0.3ms) COMMIT -[PD] /Users/User/ordering/order.rb:40 +[PD] /Users/User/ordering/order.rb:40 in Order.calculate_order_total > pd order_summary => "Pragmatic Ruby Book" ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]] (0.2ms) BEGIN (0.2ms) COMMIT -[PD] /Users/User/ordering/order.rb:41 +[PD] /Users/User/ordering/order.rb:41 in Order.calculate_order_total > pd order_details, footer: '<'*80 => "[Hard Cover] Pragmatic Ruby Book - English Version" ################################################################################ @@ -217,7 +225,7 @@ Output: (2.7ms) CREATE TABLE "ar_internal_metadata" ("key" character varying PRIMARY KEY, "value" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) ActiveRecord::InternalMetadata Load (0.4ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]] ******************************************************************************** -[PD] /Users/User/ordering/order.rb:39 +[PD] /Users/User/ordering/order.rb:39 in Order.calculate_order_total > pd order_total, caller: true, wrapper: true => 195.50 /Users/User/.rvm/gems/ruby-2.7.1/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' @@ -261,13 +269,13 @@ Output: (0.2ms) BEGIN SQL (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", 2017-08-24 22:56:52 UTC], ["updated_at", 2017-08-24 22:56:52 UTC]] (0.3ms) COMMIT -[PD] /Users/User/ordering/order.rb:40 +[PD] /Users/User/ordering/order.rb:40 in Order.calculate_order_total > pd order_summary => "Pragmatic Ruby Book" ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]] (0.2ms) BEGIN (0.2ms) COMMIT -[PD] /Users/User/ordering/order.rb:41 +[PD] /Users/User/ordering/order.rb:41 in Order.calculate_order_total > pd order_details => "[Hard Cover] Pragmatic Ruby Book - English Version" ``` @@ -292,7 +300,7 @@ pd order_details (2.7ms) CREATE TABLE "ar_internal_metadata" ("key" character varying PRIMARY KEY, "value" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) ActiveRecord::InternalMetadata Load (0.4ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]] ******************************************************************************** -[PD] /Users/User/ordering/order.rb:39 +[PD] /Users/User/ordering/order.rb:39 in Order.calculate_order_total > pd order_total, caller: 3, wrapper: true => 195.50 /Users/User/.rvm/gems/ruby-2.7.1/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' @@ -302,13 +310,13 @@ pd order_details (0.2ms) BEGIN SQL (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", 2017-08-24 22:56:52 UTC], ["updated_at", 2017-08-24 22:56:52 UTC]] (0.3ms) COMMIT -[PD] /Users/User/ordering/order.rb:40 +[PD] /Users/User/ordering/order.rb:40 in Order.calculate_order_total > pd order_summary => "Pragmatic Ruby Book" ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]] (0.2ms) BEGIN (0.2ms) COMMIT -[PD] /Users/User/ordering/order.rb:41 +[PD] /Users/User/ordering/order.rb:41 in Order.calculate_order_total > pd order_details => "[Hard Cover] Pragmatic Ruby Book - English Version" ``` @@ -324,7 +332,7 @@ This is the recommended way for installing in [Rails](rubyonrails.org) apps in a Add the following to bundler's `Gemfile` (in Rails, you can optionally limit to the `:development` and `:test` groups). ```ruby -gem 'puts_debuggerer', '~> 0.13.5' +gem 'puts_debuggerer', '~> 1.0.0' ``` Run: @@ -350,7 +358,7 @@ end Or manually install and require library. ```bash -gem install puts_debuggerer -v0.13.5 +gem install puts_debuggerer -v1.0.0 ``` ```ruby @@ -386,13 +394,39 @@ gem "puts_debuggerer" ### Usage -First, add `pd` method anywhere in your code to display details about an object or expression (if you're used to awesome_print, you're in luck! puts_debuggerer includes awesome_print as the default print engine for output). +First, add `pd` method anywhere in your code to display details about an object or expression (if you're used to awesome_print, you're in luck! puts_debuggerer includes awesome_print (or amazing_print if preferred) as the default print engine for output). + +Example: + +```ruby +# /Users/User/trivia_app.rb # line 1 +require 'pd' # line 2 +class TriviaApp # line 3 + def question # line 4 + bug_or_band = 'Beatles' # line 5 + pd bug_or_band # line 6 + end # line 7 +end # line 8 +TriviaApp.new.question # line 9 +``` + +Output: + +```bash +[PD] /Users/User/trivia_app.rb:6 in TriviaApp.question + > pd bug_or_band # line 6 + => "Beatles" +``` + +In addition to the object/expression output, you get to see the source file name, line number, invoked class method, and source code to help you debug and troubleshoot problems quicker (it even works in IRB). + +You can use `pd` at the top-level main object too, and it prings `Object.
` for the class/method. Example: ```ruby # /Users/User/finance_calculator_app/pd_test.rb # line 1 -bug = 'beatles' # line 2 +bug = 'Beetle' # line 2 pd "Show me the source of the bug: #{bug}" # line 3 pd "Show me the result of the calculation: #{(12.0/3.0)}" # line 4 ``` @@ -400,19 +434,18 @@ pd "Show me the result of the calculation: #{(12.0/3.0)}" # line 4 Output: ```bash -[PD] /Users/User/finance_calculator_app/pd_test.rb:3 +[PD] /Users/User/finance_calculator_app/pd_test.rb:3 in Object.
> pd "Show me the source of the bug: #{bug}" - => "Show me the source of the bug: beatles" -[PD] /Users/User/finance_calculator_app/pd_test.rb:4 + => "Show me the source of the bug: Beetle" +[PD] /Users/User/finance_calculator_app/pd_test.rb:4 in Object.
> pd "Show me the result of the calculation: #{(12.0/3.0)}" => "Show me the result of the calculation: 4.0" ``` -In addition to the main object/expression output, you get to see the source file name, line number, and source code to help you debug and troubleshoot problems quicker (it even works in IRB). - Second, quickly locate printed lines using the Find feature (e.g. CTRL+F) by looking for: * [PD] * file:line_number +* class.method * known ruby expression. Third, easily remove your ` pd ` statements via the source code Find feature once done debugging. @@ -430,7 +463,7 @@ greeting = "Hello #{pd(name)}" # line 3 Output: ```bash -[PD] /Users/User/greeting_app/pd_test.rb:3 +[PD] /Users/User/greeting_app/pd_test.rb:3 in Object.
> greeting = "Hello #{pd(name)}" => "Hello Robert" ``` @@ -474,7 +507,7 @@ Prints out: ```bash >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -[PD] /Users/User/project/piecemeal.rb:3 +[PD] /Users/User/project/piecemeal.rb:3 in Object.
> pd data, header: true => [1, [2, 3]] ``` @@ -492,7 +525,7 @@ Prints out: ```bash >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -<[PD]>- - /Users/User/project/piecemeal.rb:3 + /Users/User/project/piecemeal.rb:3 in Object.
> pd data, header: '>'*80, footer: '<'*80, announcer: " -<[PD]>-\n " => [1, [2, 3]] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @@ -516,16 +549,16 @@ Example: ```ruby # /Users/User/finance_calculator_app/pd_test.rb # line 1 PutsDebuggerer.app_path = File.join('/Users', 'User', 'finance_calculator_app') # line 2 -bug = 'beatles' # line 3 +bug = 'Beetle' # line 3 pd "Show me the source of the bug: #{bug}" # line 4 ``` Example Printout: ```bash -[PD] /pd_test.rb:4 +[PD] /pd_test.rb:4 in Object.
> pd "Show me the source of the bug: #{bug}" - => "Show me the source of the bug: beatles" + => "Show me the source of the bug: Beetle" ``` #### `PutsDebuggerer.header` @@ -547,7 +580,7 @@ Prints out: ```bash >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -[PD] /Users/User/example.rb:1 +[PD] /Users/User/example.rb:1 in Object.
> pd (x=1), header: true => "1" ``` @@ -562,7 +595,7 @@ Prints out: ```bash >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -[PD] /Users/User/example.rb:1 +[PD] /Users/User/example.rb:1 in Object.
> pd (x=1), h: :t => "1" ``` @@ -579,11 +612,11 @@ Prints out: ```bash >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -[PD] /Users/User/example.rb:2 +[PD] /Users/User/example.rb:2 in Object.
> pd (x=1) => "1" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -[PD] /Users/User/example.rb:3 +[PD] /Users/User/example.rb:3 in Object.
> pd (x=2) => "2" ``` @@ -606,7 +639,7 @@ pd (x=1), footer: true Prints out: ```bash -[PD] /Users/User/example.rb:1 +[PD] /Users/User/example.rb:1 in Object.
> pd (x=1), footer: true => "1" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @@ -621,7 +654,7 @@ pd (x=1), f: :t Prints out: ```bash -[PD] /Users/User/example.rb:1 +[PD] /Users/User/example.rb:1 in Object.
> pd (x=1), f: :t => "1" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @@ -638,11 +671,11 @@ pd (x=2) Prints out: ```bash -[PD] /Users/User/example.rb:2 +[PD] /Users/User/example.rb:2 in Object.
> pd (x=1) => "1" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -[PD] /Users/User/example.rb:3 +[PD] /Users/User/example.rb:3 in Object.
> pd (x=2) => "2" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @@ -667,7 +700,7 @@ Prints out: ```bash ******************************************************************************** -[PD] /Users/User/example.rb:1 +[PD] /Users/User/example.rb:1 in Object.
> pd x=1, wrapper: true => "1" ******************************************************************************** @@ -683,7 +716,7 @@ Prints out: ```bash ******************************************************************************** -[PD] /Users/User/example.rb:1 +[PD] /Users/User/example.rb:1 in Object.
> pd x=1, w: :t => "1" ******************************************************************************** @@ -701,12 +734,12 @@ Prints out: ```bash ******************************************************************************** -[PD] /Users/User/example.rb:2 +[PD] /Users/User/example.rb:2 in Object.
> pd (x=1) => "1" ******************************************************************************** ******************************************************************************** -[PD] /Users/User/example.rb:3 +[PD] /Users/User/example.rb:3 in Object.
> pd (x=2) => "2" ******************************************************************************** @@ -727,7 +760,7 @@ pd (true || Prints out: ``` -[PD] /Users/User/example.rb:1 +[PD] /Users/User/example.rb:1 in Object.
> pd (true || false), source_line_count: 2 => "true" @@ -744,7 +777,7 @@ pd (true || Prints out: ``` -[PD] /Users/User/example.rb:2 +[PD] /Users/User/example.rb:2 in Object.
> pd (true || false), source_line_count: 2 => "true" @@ -798,7 +831,7 @@ Prints out the following in standard out stream only (not in log files): Print engine is similar to `printer`, except it is focused on the scope of formatting the data object being printed (excluding metadata such as file name, line number, -and expression, which are handled by the `printer`). +invoked class method, and expression, which are handled by the `printer`). As such, it is also a global method symbol or lambda expression. Examples of global methods are `:p`, `:ap`, and `:pp`. An example of a lambda expression is `lambda {|object| puts object.to_a.join(" | ")}` @@ -819,7 +852,7 @@ pd array Prints out: ```bash -[PD] /Users/User/example.rb:4 +[PD] /Users/User/example.rb:4 in Object.
> pd array => [1, [2, 3]] ``` @@ -840,7 +873,7 @@ Prints out: ```bash *** PD *** - /Users/User/example.rb:2 + /Users/User/example.rb:2 in Object.
> pd x=1 => "1" ``` @@ -850,15 +883,17 @@ Prints out: Formatter used in every print out Passed a data argument with the following keys: -* :announcer (string) -* :caller (array) -* :file (string) -* :footer (string) -* :header (string) -* :line_number (string) -* :pd_expression (string) -* :object (object) -* :object_printer (proc) +* `:announcer` (`String`) +* `:caller` (`Array`) +* `:class` (`String`) +* `:file` (`String`) +* `:footer` (`String`) +* `:header` (`String`) +* `:line_number` (`String`) +* `:method` (`String`) +* `:pd_expression` (`String`) +* `:object` (`Object`) +* `:object_printer` (`Proc`) NOTE: data for :object_printer is not a string, yet a proc that must be called to output value. It is a proc as it automatically handles usage @@ -873,6 +908,8 @@ PutsDebuggerer.formatter = -> (data) { puts "HEADER: #{data[:header]}" puts "FILE: #{data[:file]}" puts "LINE: #{data[:line_number]}" + puts "CLASS: #{data[:class]}" + puts "METHOD: #{data[:method]}" puts "EXPRESSION: #{data[:pd_expression]}" print "PRINT OUT: " data[:object_printer].call @@ -886,9 +923,11 @@ Prints out: ```bash -<[PD]>- -FILE: /Users/User/example.rb HEADER: ******************************************************************************** +FILE: /Users/User/example.rb LINE: 9 +CLASS: Example +METHOD: test EXPRESSION: x=1 PRINT OUT: 1 CALLER: #/Users/User/master_examples.rb:83:in `block (3 levels) in ' @@ -908,15 +947,17 @@ Example: ```ruby # File Name: /Users/User/sample_app/lib/sample.rb -pd (x=1), caller: 3 +class Sample + pd (x=1), caller: 3 +end ``` Prints out (fictional): ```bash -[PD] /Users/User/sample_app/lib/sample.rb:2 +[PD] /Users/User/sample_app/lib/sample.rb:3 in Sample. > pd x=1, caller: 3 - => "1" + => 1 /Users/User/sample_app/lib/master_samples.rb:368:in \`block (3 levels) in \' /Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`eval\' /Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`evaluate\' @@ -927,15 +968,17 @@ Shortcut Example: ```ruby # File Name: /Users/User/sample_app/lib/sample.rb -pd (x=1), c: 3 +class Sample + pd (x=1), c: 3 +end ``` Prints out (fictional): ```bash -[PD] /Users/User/sample_app/lib/sample.rb:2 +[PD] /Users/User/sample_app/lib/sample.rb:3 in Sample. > pd x=1, caller: 3 - => "1" + => 1 /Users/User/sample_app/lib/master_samples.rb:368:in \`block (3 levels) in \' /Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`eval\' /Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`evaluate\' @@ -947,23 +990,30 @@ Global Option Example: ```ruby # File Name: /Users/User/sample_app/lib/sample.rb PutsDebuggerer.caller = 3 # always print 3 lines only of the stack trace -pd (x=1) -pd (x=2) +class Sample + class << self + def test + pd (x=1) + pd (x=2) + end + end +end +Sample.test ``` Prints out: ```bash -[PD] /Users/User/sample_app/lib/sample.rb:2 +[PD] /Users/User/sample_app/lib/sample.rb:6 in Sample.test > pd (x=1) - => "1" + => 1 /Users/User/sample_app/lib/master_samples.rb:368:in \`block (3 levels) in \' /Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`eval\' /Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`evaluate\' /Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/context.rb:381:in \`evaluate\' -[PD] /Users/User/sample_app/lib/sample.rb:3 +[PD] /Users/User/sample_app/lib/sample.rb:7 in Sample.test > pd (x=2) - => "2" + => 2 /Users/User/sample_app/lib/master_samples.rb:368:in \`block (3 levels) in \' /Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`eval\' /Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`evaluate\' @@ -1135,4 +1185,4 @@ Note that it ignores the configured printer when printing exceptions as it relie [MIT](LICENSE.txt) -Copyright (c) 2017-2021 - Andy Maleh. +Copyright (c) 2017-2024 - Andy Maleh. diff --git a/Rakefile b/Rakefile index 03c35e0..1df2265 100644 --- a/Rakefile +++ b/Rakefile @@ -17,10 +17,10 @@ Jeweler::Tasks.new do |gem| gem.name = "puts_debuggerer" gem.homepage = "http://github.com/AndyObtiva/puts_debuggerer" gem.license = "MIT" - gem.summary = %Q{Ruby library for improved puts debugging, automatically displaying bonus useful information such as source line number and source code.} + gem.summary = %Q{Ruby library for improved puts debugging, automatically displaying bonus useful information such as source file name, line number, invoked class method, and source code.} gem.description = <<-MULTI Debuggers are great! They help us troubleshoot complicated programming problems by inspecting values produced by code, line by line. They are invaluable when trying to understand what is going on in a large application composed of thousands or millions of lines of code. -In day-to-day test-driven development and simple debugging though, a puts statement can be a lot quicker in revealing what is going on than halting execution completely just to inspect a single value or a few. This is certainly true when writing the simplest possible code that could possibly work, and running a test every few seconds or minutes. Problem is you need to locate puts statements in large output logs, know which methods were invoked, find out what variable names are being printed, and see nicely formatted output. Enter puts_debuggerer. A guilt-free puts debugging Ruby gem FTW that prints file names, line numbers, code statements, and formats output nicely courtesy of awesome_print. +In day-to-day test-driven development and simple debugging though, a puts statement can be a lot quicker in revealing what is going on than halting execution completely just to inspect a single value or a few. This is certainly true when writing the simplest possible code that could possibly work, and running a test every few seconds or minutes. Problem is you need to locate puts statements in large output logs, know which methods were invoked, find out what variable names are being printed, and see nicely formatted output. Enter puts_debuggerer. A guilt-free puts debugging Ruby gem FTW that prints file names, line numbers, invoked class methods, code statements, and formats output nicely courtesy of awesome_print. Partially inspired by this blog post: https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html (Credit to Tenderlove.) MULTI gem.email = "andy.am@gmail.com" diff --git a/TODO.md b/TODO.md index fabc4b7..af914b3 100644 --- a/TODO.md +++ b/TODO.md @@ -6,8 +6,6 @@ Here are tasks considered for future versions. Once done, they are moved to the - Fix issue with attempting to modify a frozen hash when passed as value for `pd` command (check if frozen) - When using last arg as hash for options, leave out options that are not puts_debuggerer-specific for printing out -- Automatically print class and method name as part of the file name and line number printout -- Automatically print `self` - Support displaying the date/time of the pd printout via an option (local and global) - Consider supporting `header: :method` to print the Class#method name as the header (consider supporting in footer/wrapper too) - Consider adding performance profiling to pd methods automatically, with some customization options too diff --git a/VERSION b/VERSION index c37136a..3eefcb9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.13.5 +1.0.0 diff --git a/lib/pd.rb b/lib/pd.rb index 4b5e3ac..6684ad5 100644 --- a/lib/pd.rb +++ b/lib/pd.rb @@ -1 +1,3 @@ +$LOAD_PATH.unshift(File.expand_path(__dir__)) + require 'puts_debuggerer' diff --git a/lib/puts_debuggerer.rb b/lib/puts_debuggerer.rb index b015f42..a51ca79 100644 --- a/lib/puts_debuggerer.rb +++ b/lib/puts_debuggerer.rb @@ -1,3 +1,5 @@ +$LOAD_PATH.unshift(File.expand_path(__dir__)) unless $LOAD_PATH.include?(File.expand_path(__dir__)) + require 'puts_debuggerer/core_ext/kernel' require 'puts_debuggerer/core_ext/logger' require 'puts_debuggerer/core_ext/logging/logger' @@ -52,7 +54,7 @@ def format_obj(obj) FORMATTER_DEFAULT = -> (data) { puts data[:wrapper] if data[:wrapper] puts data[:header] if data[:header] - print "#{data[:announcer]} #{data[:file]}#{':' if data[:line_number]}#{data[:line_number]}#{" (run:#{data[:run_number]})" if data[:run_number]}#{__format_pd_expression__(data[:pd_expression], data[:object])} " + print "#{data[:announcer]} #{data[:file]}#{':' if data[:line_number]}#{data[:line_number]} in #{[data[:class], data[:method]].compact.join('.')}#{" (run:#{data[:run_number]})" if data[:run_number]}#{__format_pd_expression__(data[:pd_expression], data[:object])} " data[:object_printer].call puts data[:caller].map {|l| ' ' + l} unless data[:caller].to_a.empty? puts data[:footer] if data[:footer] @@ -63,6 +65,7 @@ def format_obj(obj) STACK_TRACE_CALL_LINE_NUMBER_REGEX = /\:(\d+)\:in / STACK_TRACE_CALL_SOURCE_FILE_REGEX = /[ ]*([^:]+)\:\d+\:in / STACK_TRACE_CALL_SOURCE_FILE_REGEX_OPAL = /(http[^\)]+)/ + STACK_TRACE_CALL_METHOD_REGEX = /`([^']+)'$/ OPTIONS = [:app_path, :source_line_count, :header, :h, :wrapper, :w, :footer, :f, :printer, :print_engine, :announcer, :formatter, :caller, :run_at] OPTION_ALIASES = { a: :announcer, diff --git a/lib/puts_debuggerer/core_ext/kernel.rb b/lib/puts_debuggerer/core_ext/kernel.rb index 2932f2d..d0c9f1f 100644 --- a/lib/puts_debuggerer/core_ext/kernel.rb +++ b/lib/puts_debuggerer/core_ext/kernel.rb @@ -143,6 +143,12 @@ def __caller_file__(caller_depth=0) caller[caller_depth] && caller[caller_depth][regex, 1] end + # Provides caller method starting 1 level above caller of + # this method. + def __caller_method__(caller_depth=0) + regex = PutsDebuggerer::STACK_TRACE_CALL_METHOD_REGEX + caller[caller_depth] && caller[caller_depth][regex, 1] + end # Provides caller source line starting 1 level above caller of # this method. @@ -189,6 +195,8 @@ def __build_pd_data__(object, print_engine_options:nil, source_line_count:nil, r pd_data = { announcer: PutsDebuggerer.announcer, file: __caller_file__(depth)&.sub(PutsDebuggerer.app_path.to_s, ''), + class: self.is_a?(Module) ? self : self.class, + method: __caller_method__(depth)&.sub(PutsDebuggerer.app_path.to_s, ''), line_number: __caller_line_number__(depth), pd_expression: __caller_pd_expression__(depth, source_line_count), run_number: run_number, diff --git a/puts_debuggerer.gemspec b/puts_debuggerer.gemspec index 873a4ca..62e7e65 100644 --- a/puts_debuggerer.gemspec +++ b/puts_debuggerer.gemspec @@ -2,17 +2,17 @@ # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- -# stub: puts_debuggerer 0.13.5 ruby lib +# stub: puts_debuggerer 1.0.0 ruby lib Gem::Specification.new do |s| s.name = "puts_debuggerer".freeze - s.version = "0.13.5" + s.version = "1.0.0".freeze s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= s.require_paths = ["lib".freeze] s.authors = ["Andy Maleh".freeze] - s.date = "2022-03-29" - s.description = "Debuggers are great! They help us troubleshoot complicated programming problems by inspecting values produced by code, line by line. They are invaluable when trying to understand what is going on in a large application composed of thousands or millions of lines of code.\nIn day-to-day test-driven development and simple debugging though, a puts statement can be a lot quicker in revealing what is going on than halting execution completely just to inspect a single value or a few. This is certainly true when writing the simplest possible code that could possibly work, and running a test every few seconds or minutes. Problem is you need to locate puts statements in large output logs, know which methods were invoked, find out what variable names are being printed, and see nicely formatted output. Enter puts_debuggerer. A guilt-free puts debugging Ruby gem FTW that prints file names, line numbers, code statements, and formats output nicely courtesy of awesome_print.\nPartially inspired by this blog post: https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html (Credit to Tenderlove.)\n".freeze + s.date = "2024-05-31" + s.description = "Debuggers are great! They help us troubleshoot complicated programming problems by inspecting values produced by code, line by line. They are invaluable when trying to understand what is going on in a large application composed of thousands or millions of lines of code.\nIn day-to-day test-driven development and simple debugging though, a puts statement can be a lot quicker in revealing what is going on than halting execution completely just to inspect a single value or a few. This is certainly true when writing the simplest possible code that could possibly work, and running a test every few seconds or minutes. Problem is you need to locate puts statements in large output logs, know which methods were invoked, find out what variable names are being printed, and see nicely formatted output. Enter puts_debuggerer. A guilt-free puts debugging Ruby gem FTW that prints file names, line numbers, invoked class methods, code statements, and formats output nicely courtesy of awesome_print.\nPartially inspired by this blog post: https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html (Credit to Tenderlove.)\n".freeze s.email = "andy.am@gmail.com".freeze s.extra_rdoc_files = [ "CHANGELOG.md", @@ -33,37 +33,18 @@ Gem::Specification.new do |s| ] s.homepage = "http://github.com/AndyObtiva/puts_debuggerer".freeze s.licenses = ["MIT".freeze] - s.rubygems_version = "3.3.1".freeze - s.summary = "Ruby library for improved puts debugging, automatically displaying bonus useful information such as source line number and source code.".freeze + s.rubygems_version = "3.5.3".freeze + s.summary = "Ruby library for improved puts debugging, automatically displaying bonus useful information such as source file name, line number, invoked class method, and source code.".freeze - if s.respond_to? :specification_version then - s.specification_version = 4 - end + s.specification_version = 4 - if s.respond_to? :add_runtime_dependency then - s.add_runtime_dependency(%q.freeze, ["~> 1.9.2"]) - s.add_development_dependency(%q.freeze, ["~> 3.5"]) - s.add_development_dependency(%q.freeze, ["~> 3.5"]) - s.add_development_dependency(%q.freeze, ["~> 3.12"]) - s.add_development_dependency(%q.freeze, ["~> 2.3.9"]) - s.add_development_dependency(%q.freeze, [">= 2.1.4"]) - s.add_development_dependency(%q.freeze, ["= 0.8.23"]) - s.add_development_dependency(%q.freeze, ["~> 0.16.1"]) - s.add_development_dependency(%q.freeze, ["~> 0.7.0"]) - s.add_development_dependency(%q.freeze, [">= 2.3.0"]) - s.add_development_dependency(%q.freeze, [">= 0"]) - else - s.add_dependency(%q.freeze, ["~> 1.9.2"]) - s.add_dependency(%q.freeze, ["~> 3.5"]) - s.add_dependency(%q.freeze, ["~> 3.5"]) - s.add_dependency(%q.freeze, ["~> 3.12"]) - s.add_dependency(%q.freeze, ["~> 2.3.9"]) - s.add_dependency(%q.freeze, [">= 2.1.4"]) - s.add_dependency(%q.freeze, ["= 0.8.23"]) - s.add_dependency(%q.freeze, ["~> 0.16.1"]) - s.add_dependency(%q.freeze, ["~> 0.7.0"]) - s.add_dependency(%q.freeze, [">= 2.3.0"]) - s.add_dependency(%q.freeze, [">= 0"]) - end + s.add_runtime_dependency(%q.freeze, ["~> 1.9.2".freeze]) + s.add_development_dependency(%q.freeze, ["~> 3.5".freeze]) + s.add_development_dependency(%q.freeze, ["~> 3.5".freeze]) + s.add_development_dependency(%q.freeze, ["~> 3.12".freeze]) + s.add_development_dependency(%q.freeze, ["~> 2.3.9".freeze]) + s.add_development_dependency(%q.freeze, [">= 2.1.4".freeze]) + s.add_development_dependency(%q.freeze, [">= 2.3.0".freeze]) + s.add_development_dependency(%q.freeze, [">= 0".freeze]) end diff --git a/spec/lib/puts_debuggerer__exception_cases__spec.rb b/spec/lib/puts_debuggerer__exception_cases__spec.rb index 075c761..9cc551e 100644 --- a/spec/lib/puts_debuggerer__exception_cases__spec.rb +++ b/spec/lib/puts_debuggerer__exception_cases__spec.rb @@ -13,14 +13,14 @@ name = 'Robert' PutsDebuggererInvoker.multi_line_dynamic_greeting(name) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:30\n > pd \"Hello \" +\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:30 in PutsDebuggererInvoker.multi_line_dynamic_greeting\n > pd \"Hello \" +\n => \"Hello Robert\"\n") end it 'handles multi line ruby expressions correctly printing source line count of 2' do name = 'Robert' PutsDebuggererInvoker.multi_line_dynamic_greeting_source_line_count(name) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:43\n > pd \"Hello \" +\n name.to_s, source_line_count: 2\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:43 in PutsDebuggererInvoker.multi_line_dynamic_greeting_source_line_count\n > pd \"Hello \" +\n name.to_s, source_line_count: 2\n => \"Hello Robert\"\n") end end end diff --git a/spec/lib/puts_debuggerer__with_app_path_provided__spec.rb b/spec/lib/puts_debuggerer__with_app_path_provided__spec.rb index c68964b..dab8b65 100644 --- a/spec/lib/puts_debuggerer__with_app_path_provided__spec.rb +++ b/spec/lib/puts_debuggerer__with_app_path_provided__spec.rb @@ -14,7 +14,7 @@ name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("[PD] /spec/support/puts_debuggerer_invoker.rb:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] /spec/support/puts_debuggerer_invoker.rb:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") end end end diff --git a/spec/lib/puts_debuggerer__with_caller_backtrace__spec.rb b/spec/lib/puts_debuggerer__with_caller_backtrace__spec.rb index 23768b1..eb198eb 100644 --- a/spec/lib/puts_debuggerer__with_caller_backtrace__spec.rb +++ b/spec/lib/puts_debuggerer__with_caller_backtrace__spec.rb @@ -15,7 +15,7 @@ PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string expected_caller = (["#{__FILE__}:#{__LINE__-2}:in `block (3 levels) in '"] + caller).map {|l| ' '*5 + l} - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n#{expected_caller.join("\n")}\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n#{expected_caller.join("\n")}\n") end it 'includes depth-limited caller backtrace when printing file, line number, ruby expression, and evaluated string object' do PutsDebuggerer.caller = 0 # just give me one backtrace entry @@ -23,7 +23,7 @@ PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string expected_caller = [" #{__FILE__}:#{__LINE__-2}:in `block (3 levels) in '"] - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n#{expected_caller.join("\n")}\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n#{expected_caller.join("\n")}\n") end end end diff --git a/spec/lib/puts_debuggerer__with_custom_announcer__spec.rb b/spec/lib/puts_debuggerer__with_custom_announcer__spec.rb index 8942ad4..a093dd1 100644 --- a/spec/lib/puts_debuggerer__with_custom_announcer__spec.rb +++ b/spec/lib/puts_debuggerer__with_custom_announcer__spec.rb @@ -15,14 +15,14 @@ name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq(" #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq(" #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") end it 'resets to default announcer when announcer is set to nil' do PutsDebuggerer.announcer = nil name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") end end end diff --git a/spec/lib/puts_debuggerer__with_custom_formatter__spec.rb b/spec/lib/puts_debuggerer__with_custom_formatter__spec.rb index 8034371..940917a 100644 --- a/spec/lib/puts_debuggerer__with_custom_formatter__spec.rb +++ b/spec/lib/puts_debuggerer__with_custom_formatter__spec.rb @@ -41,7 +41,7 @@ PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string expected_caller = " #{__FILE__}:#{__LINE__-2}:in `block (3 levels) in '" - expect(output).to eq("#{PutsDebuggerer::HEADER_DEFAULT}\n[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n#{expected_caller}\n#{PutsDebuggerer::FOOTER_DEFAULT}\n") + expect(output).to eq("#{PutsDebuggerer::HEADER_DEFAULT}\n[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n#{expected_caller}\n#{PutsDebuggerer::FOOTER_DEFAULT}\n") end #TODO support formatting header, footer, and caller backtrace too end diff --git a/spec/lib/puts_debuggerer__with_custom_print_engine__spec.rb b/spec/lib/puts_debuggerer__with_custom_print_engine__spec.rb index 7eb91b4..8d3ebf1 100644 --- a/spec/lib/puts_debuggerer__with_custom_print_engine__spec.rb +++ b/spec/lib/puts_debuggerer__with_custom_print_engine__spec.rb @@ -33,17 +33,17 @@ def print_meh(object) name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => **\"Hello Robert\"**\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => **\"Hello Robert\"**\n") end it 'prints file relative to app path, line number, ruby expression, and evaluated string object' do PutsDebuggererInvoker.static_nested_array output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:22\n > pd [1, [2, 3]]\n => #{expected_object_printout}\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:22 in PutsDebuggererInvoker.static_nested_array\n > pd [1, [2, 3]]\n => #{expected_object_printout}\n") end it 'prints file relative to app path, line number, ruby expression, and evaluated string object' do PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]]) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => #{expected_object_printout}\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => #{expected_object_printout}\n") end it 'raises informative error if print_engine was invalid' do expect {PutsDebuggerer.print_engine = :invalid}.to raise_error('print_engine must be a valid global method symbol (e.g. :p, :ap or :pp) or lambda/proc receiving an object arg') @@ -51,13 +51,13 @@ def print_meh(object) it 'supports passing extra options to print_engines like awesome_print' do PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]], indent: 2) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => #{expected_object_printout_indent2}\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => #{expected_object_printout_indent2}\n") end it 'ignores extra options with print_engines not supporting them' do PutsDebuggerer.print_engine = :print_meh PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]], indent: 2) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => Meh! [1, [2, 3]]\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => Meh! [1, [2, 3]]\n") end end diff --git a/spec/lib/puts_debuggerer__with_custom_printer__spec.rb b/spec/lib/puts_debuggerer__with_custom_printer__spec.rb index 6ea7bf6..6089e45 100644 --- a/spec/lib/puts_debuggerer__with_custom_printer__spec.rb +++ b/spec/lib/puts_debuggerer__with_custom_printer__spec.rb @@ -39,14 +39,14 @@ name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("\n[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n\n") + expect(output).to eq("\n[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n\n") end it 'prints with default :puts printer (file relative to app path, line number, ruby expression, and evaluated string object)' do expect(PutsDebuggerer.printer).to eq(:puts) PutsDebuggererInvoker.static_nested_array output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:22\n > pd [1, [2, 3]]\n => #{expected_object_printout}\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:22 in PutsDebuggererInvoker.static_nested_array\n > pd [1, [2, 3]]\n => #{expected_object_printout}\n") end it 'prints with specified :print printer (file relative to app path, line number, ruby expression, and evaluated string object)' do @@ -54,7 +54,7 @@ expect(PutsDebuggerer.printer).to eq(:ap) PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]]) output = $stdout.string - expect(output).to eq("\"[PD] #{puts_debuggerer_invoker_file}:26\\n > pd *array_including_options\\n => #{expected_object_printout_awesome_print}\\n\"\n") + expect(output).to eq("\"[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\\n > pd *array_including_options\\n => #{expected_object_printout_awesome_print}\\n\"\n") end it 'prints with specified logger object (file relative to app path, line number, ruby expression, and evaluated string object)' do @@ -63,14 +63,14 @@ expect(PutsDebuggerer.printer).to eq(logger) PutsDebuggererInvoker.static_nested_array output = $stdout.string - expect(output).to eq("D, [2000-01-01T01:01:01.000000 ##{Process.pid}] DEBUG -- : [PD] #{puts_debuggerer_invoker_file}:22\n > pd [1, [2, 3]]\n => #{expected_object_printout}\n\n") + expect(output).to eq("D, [2000-01-01T01:01:01.000000 ##{Process.pid}] DEBUG -- : [PD] #{puts_debuggerer_invoker_file}:22 in PutsDebuggererInvoker.static_nested_array\n > pd [1, [2, 3]]\n => #{expected_object_printout}\n\n") $stdout = StringIO.new logger = Logger.new($stdout) PutsDebuggerer.printer = logger PutsDebuggererInvoker.logger_log logger, 'error', [1, [2, 3]] output = $stdout.string - expect(output).to eq("E, [2000-01-01T01:01:01.000000 ##{Process.pid}] ERROR -- : [PD] #{puts_debuggerer_invoker_file}:64\n > logger.send(severity, *args)\n => #{expected_object_printout}\n\n") + expect(output).to eq("E, [2000-01-01T01:01:01.000000 ##{Process.pid}] ERROR -- : [PD] #{puts_debuggerer_invoker_file}:64 in Array.logger_log\n > logger.send(severity, *args)\n => #{expected_object_printout}\n\n") end it 'prints with specified logging logger object (file relative to app path, line number, ruby expression, and evaluated string object)' do @@ -80,11 +80,11 @@ PutsDebuggerer.printer = logger expect(PutsDebuggerer.printer).to eq(logger) PutsDebuggererInvoker.static_nested_array - expected_output1 = "DEBUG test : [PD] #{puts_debuggerer_invoker_file}:22\n > pd [1, [2, 3]]\n => #{expected_object_printout}\n\n" + expected_output1 = "DEBUG test : [PD] #{puts_debuggerer_invoker_file}:22 in PutsDebuggererInvoker.static_nested_array\n > pd [1, [2, 3]]\n => #{expected_object_printout}\n\n" PutsDebuggererInvoker.logger_log logger, 'error', [1, [2, 3]] output = logger.appenders.first.sio.string - expected_output2 = "ERROR test : [PD] #{puts_debuggerer_invoker_file}:64\n > logger.send(severity, *args)\n => #{expected_object_printout}\n\n" + expected_output2 = "ERROR test : [PD] #{puts_debuggerer_invoker_file}:64 in Array.logger_log\n > logger.send(severity, *args)\n => #{expected_object_printout}\n\n" expect(output).to eq("#{expected_output1}#{expected_output2}") end @@ -94,14 +94,14 @@ return_value = PutsDebuggererInvoker.static_nested_array output = $stdout.string expect(output).to eq('') - expect(return_value).to eq("[PD] #{puts_debuggerer_invoker_file}:22\n > pd [1, [2, 3]]\n => #{expected_object_printout}\n") + expect(return_value).to eq("[PD] #{puts_debuggerer_invoker_file}:22 in PutsDebuggererInvoker.static_nested_array\n > pd [1, [2, 3]]\n => #{expected_object_printout}\n") end it 'does not print with printer as false, but returns rendered string instead of object' do return_value = PutsDebuggererInvoker.call_pd [1, [2, 3]], printer: false output = $stdout.string expect(output).to eq('') - expect(return_value).to eq("[PD] #{puts_debuggerer_invoker_file}:60\n > pd *args\n => #{expected_object_printout}\n") + expect(return_value).to eq("[PD] #{puts_debuggerer_invoker_file}:60 in PutsDebuggererInvoker.call_pd\n > pd *args\n => #{expected_object_printout}\n") end it 'raises informative error if print_engine was invalid' do @@ -133,7 +133,7 @@ def self.env name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("Rails.logger.debug: [PD] /spec/support/puts_debuggerer_invoker.rb:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("Rails.logger.debug: [PD] /spec/support/puts_debuggerer_invoker.rb:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") end it 'prints using Rails test env lambda printer' do @@ -162,8 +162,8 @@ def self.env PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string expect(output).to eq( - "[PD] /spec/support/puts_debuggerer_invoker.rb:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n" + - "Rails.logger.debug: [PD] /spec/support/puts_debuggerer_invoker.rb:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n" + "[PD] /spec/support/puts_debuggerer_invoker.rb:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n" + + "Rails.logger.debug: [PD] /spec/support/puts_debuggerer_invoker.rb:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n" ) end end diff --git a/spec/lib/puts_debuggerer__with_footer_support_enabled__spec.rb b/spec/lib/puts_debuggerer__with_footer_support_enabled__spec.rb index 96da47c..c85d141 100644 --- a/spec/lib/puts_debuggerer__with_footer_support_enabled__spec.rb +++ b/spec/lib/puts_debuggerer__with_footer_support_enabled__spec.rb @@ -11,28 +11,28 @@ name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n#{PutsDebuggerer::FOOTER_DEFAULT}\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n#{PutsDebuggerer::FOOTER_DEFAULT}\n") end it 'disables footer with nil footer' do PutsDebuggerer.footer = nil name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") end it 'disables footer with false footer' do PutsDebuggerer.footer = false name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") end it 'disables footer with empty string footer' do PutsDebuggerer.footer = '' name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") end end context 'as custom footer' do @@ -44,7 +44,7 @@ name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n#{custom_footer}\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n#{custom_footer}\n") end end end diff --git a/spec/lib/puts_debuggerer__with_header_support_enabled__spec.rb b/spec/lib/puts_debuggerer__with_header_support_enabled__spec.rb index a58c5a6..555c2a0 100644 --- a/spec/lib/puts_debuggerer__with_header_support_enabled__spec.rb +++ b/spec/lib/puts_debuggerer__with_header_support_enabled__spec.rb @@ -11,28 +11,28 @@ name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("#{PutsDebuggerer::HEADER_DEFAULT}\n[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("#{PutsDebuggerer::HEADER_DEFAULT}\n[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") end it 'disables header with nil header' do PutsDebuggerer.header = nil name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") end it 'disables header with false header' do PutsDebuggerer.header = false name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") end it 'disables header with empty string header' do PutsDebuggerer.header = '' name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") end end context 'as custom header' do @@ -44,7 +44,7 @@ name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("#{custom_header}\n[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("#{custom_header}\n[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") end end end diff --git a/spec/lib/puts_debuggerer__with_irb_support__spec.rb b/spec/lib/puts_debuggerer__with_irb_support__spec.rb index 3f48de1..58eb666 100644 --- a/spec/lib/puts_debuggerer__with_irb_support__spec.rb +++ b/spec/lib/puts_debuggerer__with_irb_support__spec.rb @@ -18,7 +18,10 @@ allow_any_instance_of(Kernel).to receive(:__LINE__) {'285'} pd 'whoami' output = $stdout.string - expect(output).to eq("[PD] (irb):285\n > pd 'whoami'\n => \"whoami\"\n") + expect(output.lines.size).to eq(3) + expect(output.lines[0]).to match(/\[PD\] \(irb\):285 in RSpec::ExampleGroups::PutsDebuggerer[^:]*::IrbSupport/) + expect(output.lines[1]).to match(/ > pd 'whoami'/) + expect(output.lines[2]).to match(/ => \"whoami\"\n/) end it 'does not utilize IRB when not having conf io (like in MiniTest Rails)' do # senseless faking to get irb support to work (tested in IRB as working) @@ -27,7 +30,10 @@ allow_any_instance_of(Kernel).to receive(:__LINE__) {'285'} pd 'whoami' output = $stdout.string - expect(output).to eq("[PD] (irb):285\n > \n => \"whoami\"\n") + expect(output.lines.size).to eq(3) + expect(output.lines[0]).to match(/\[PD\] \(irb\):285 in RSpec::ExampleGroups::PutsDebuggerer[^:]*::IrbSupport/) + expect(output.lines[1]).to match(/ > /) + expect(output.lines[2]).to match(/ => \"whoami\"/) end end diff --git a/spec/lib/puts_debuggerer__with_piecemeal_options__spec.rb b/spec/lib/puts_debuggerer__with_piecemeal_options__spec.rb index ccf5693..a964ae3 100644 --- a/spec/lib/puts_debuggerer__with_piecemeal_options__spec.rb +++ b/spec/lib/puts_debuggerer__with_piecemeal_options__spec.rb @@ -17,137 +17,137 @@ it 'supports enabling header per single puts' do PutsDebuggererInvoker.dynamic_nested_array(header: true) # support options alone output = $stdout.string - expect(output).to eq("#{PutsDebuggerer::HEADER_DEFAULT}\n[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => {}\n") + expect(output).to eq("#{PutsDebuggerer::HEADER_DEFAULT}\n[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => {}\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]], header: true) output = $stdout.string - expect(output).to eq("#{PutsDebuggerer::HEADER_DEFAULT}\n[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n") + expect(output).to eq("#{PutsDebuggerer::HEADER_DEFAULT}\n[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array(name: 'Sean', header: true) # support hash including options output = $stdout.string - expect(output).to eq("#{PutsDebuggerer::HEADER_DEFAULT}\n[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => {:name=>\"Sean\"}\n") + expect(output).to eq("#{PutsDebuggerer::HEADER_DEFAULT}\n[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => {:name=>\"Sean\"}\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]]) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n") end it 'supports enabling header per single puts using shortcut syntax' do PutsDebuggererInvoker.dynamic_nested_array(h: :t) # support options alone output = $stdout.string - expect(output).to eq("#{PutsDebuggerer::HEADER_DEFAULT}\n[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => {}\n") + expect(output).to eq("#{PutsDebuggerer::HEADER_DEFAULT}\n[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => {}\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]], h: :t) output = $stdout.string - expect(output).to eq("#{PutsDebuggerer::HEADER_DEFAULT}\n[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n") + expect(output).to eq("#{PutsDebuggerer::HEADER_DEFAULT}\n[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array(name: 'Sean', h: :t) # support hash including options output = $stdout.string - expect(output).to eq("#{PutsDebuggerer::HEADER_DEFAULT}\n[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => {:name=>\"Sean\"}\n") + expect(output).to eq("#{PutsDebuggerer::HEADER_DEFAULT}\n[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => {:name=>\"Sean\"}\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]]) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n") end it 'supports enabling footer per single puts' do PutsDebuggererInvoker.dynamic_nested_array(footer: true) # support options alone output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => {}\n#{PutsDebuggerer::FOOTER_DEFAULT}\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => {}\n#{PutsDebuggerer::FOOTER_DEFAULT}\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]], footer: true) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n#{PutsDebuggerer::FOOTER_DEFAULT}\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n#{PutsDebuggerer::FOOTER_DEFAULT}\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array(name: 'Sean', footer: true) # support hash including options output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => {:name=>\"Sean\"}\n#{PutsDebuggerer::FOOTER_DEFAULT}\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => {:name=>\"Sean\"}\n#{PutsDebuggerer::FOOTER_DEFAULT}\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]]) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n") end it 'supports enabling footer per single puts using shortcut syntax' do PutsDebuggererInvoker.dynamic_nested_array(f: :t) # support options alone output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => {}\n#{PutsDebuggerer::FOOTER_DEFAULT}\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => {}\n#{PutsDebuggerer::FOOTER_DEFAULT}\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]], f: :t) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n#{PutsDebuggerer::FOOTER_DEFAULT}\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n#{PutsDebuggerer::FOOTER_DEFAULT}\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array(name: 'Sean', f: :t) # support hash including options output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => {:name=>\"Sean\"}\n#{PutsDebuggerer::FOOTER_DEFAULT}\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => {:name=>\"Sean\"}\n#{PutsDebuggerer::FOOTER_DEFAULT}\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]]) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n") end it 'supports enabling both header and footer per single puts' do PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]], header: '#'*80, footer: true) output = $stdout.string - expect(output).to eq("#{'#'*80}\n[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n#{PutsDebuggerer::FOOTER_DEFAULT}\n") + expect(output).to eq("#{'#'*80}\n[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n#{PutsDebuggerer::FOOTER_DEFAULT}\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]]) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n") end it 'supports enabling wrapper per single puts using shortcut syntax' do PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]], w: :t) output = $stdout.string - expect(output).to eq("#{PutsDebuggerer::WRAPPER_DEFAULT}\n[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n#{PutsDebuggerer::WRAPPER_DEFAULT}\n") + expect(output).to eq("#{PutsDebuggerer::WRAPPER_DEFAULT}\n[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n#{PutsDebuggerer::WRAPPER_DEFAULT}\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]]) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n") end it 'supports switching printer per single puts' do PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]], printer: lambda {|output| puts output.upcase}) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file.upcase}:26\n > PD *ARRAY_INCLUDING_OPTIONS\n => [1, [2, 3]]\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file.upcase}:26 IN PUTSDEBUGGERERINVOKER.DYNAMIC_NESTED_ARRAY\n > PD *ARRAY_INCLUDING_OPTIONS\n => [1, [2, 3]]\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]]) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n") end it 'supports switching print engine per single puts' do PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]], print_engine: :ap) output = $stdout.string expected_object_printout = "[\n [0] 1,\n [1] [\n [0] 2,\n [1] 3\n ]\n]" - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => #{expected_object_printout}\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => #{expected_object_printout}\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]]) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n") end it 'supports switching app path per single puts' do app_path = File.expand_path(File.join(__FILE__, '..')) PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]], app_path: app_path) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file.sub(app_path, '')}:26\n > pd *array_including_options\n => [1, [2, 3]]\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file.sub(app_path, '')}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]]) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n") end it 'supports switching announcer per single puts' do app_path = File.expand_path(File.join(__FILE__, '..')) PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]], announcer: "!!!!!HELLO!!!!!") output = $stdout.string - expect(output).to eq("!!!!!HELLO!!!!! #{puts_debuggerer_invoker_file.sub(app_path, '')}:26\n > pd *array_including_options\n => [1, [2, 3]]\n") + expect(output).to eq("!!!!!HELLO!!!!! #{puts_debuggerer_invoker_file.sub(app_path, '')}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]]) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n") end it 'supports switching announcer per single puts with shortcut syntax' do app_path = File.expand_path(File.join(__FILE__, '..')) PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]], a: "!!!!!HELLO!!!!!") output = $stdout.string - expect(output).to eq("!!!!!HELLO!!!!! #{puts_debuggerer_invoker_file.sub(app_path, '')}:26\n > pd *array_including_options\n => [1, [2, 3]]\n") + expect(output).to eq("!!!!!HELLO!!!!! #{puts_debuggerer_invoker_file.sub(app_path, '')}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]]) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n") end it 'supports switching formatter per single puts' do app_path = File.expand_path(File.join(__FILE__, '..')) @@ -160,29 +160,29 @@ $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]]) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n") end it 'supports enabling caller per single puts' do app_path = File.expand_path(File.join(__FILE__, '..')) PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]], caller: 0) output = $stdout.string expected_caller = [" #{__FILE__}:#{__LINE__-2}:in `block (3 levels) in '"] - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n#{expected_caller.join("\n")}\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n#{expected_caller.join("\n")}\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]]) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n") end it 'supports enabling caller per single puts with shortcut syntax' do app_path = File.expand_path(File.join(__FILE__, '..')) PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]], c: 0) output = $stdout.string expected_caller = [" #{__FILE__}:#{__LINE__-2}:in `block (3 levels) in '"] - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n#{expected_caller.join("\n")}\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n#{expected_caller.join("\n")}\n") $stdout = StringIO.new PutsDebuggererInvoker.dynamic_nested_array([1, [2, 3]]) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26\n > pd *array_including_options\n => [1, [2, 3]]\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:26 in PutsDebuggererInvoker.dynamic_nested_array\n > pd *array_including_options\n => [1, [2, 3]]\n") end end end diff --git a/spec/lib/puts_debuggerer__with_rails__spec.rb b/spec/lib/puts_debuggerer__with_rails__spec.rb index 61c9a8d..2b33f7d 100644 --- a/spec/lib/puts_debuggerer__with_rails__spec.rb +++ b/spec/lib/puts_debuggerer__with_rails__spec.rb @@ -44,7 +44,7 @@ def self.logger name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("[PD] /spec/support/puts_debuggerer_invoker.rb:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] /spec/support/puts_debuggerer_invoker.rb:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") end it 'defaults to Rails awesome_print logger in Rails app with awesome_print' do load "awesome_print/core_ext/kernel.rb" @@ -52,7 +52,7 @@ def self.logger PutsDebuggererInvoker.static_nested_array output = $stdout.string expect(output).to eq(<<-MULTILINE -[PD] /spec/support/puts_debuggerer_invoker.rb:22 +[PD] /spec/support/puts_debuggerer_invoker.rb:22 in PutsDebuggererInvoker.static_nested_array > pd [1, [2, 3]] => [ [0] 1, diff --git a/spec/lib/puts_debuggerer__with_run_at_support__spec.rb b/spec/lib/puts_debuggerer__with_run_at_support__spec.rb index 4f753eb..6a28d9e 100644 --- a/spec/lib/puts_debuggerer__with_run_at_support__spec.rb +++ b/spec/lib/puts_debuggerer__with_run_at_support__spec.rb @@ -17,10 +17,10 @@ PutsDebuggererInvoker.dynamic_greeting_run_at(name, 5) expect(output).to be_empty PutsDebuggererInvoker.dynamic_greeting_run_at(name, 5) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:5)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:5)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string - PutsDebuggererInvoker.dynamic_greeting_run_at(name, 5) + PutsDebuggererInvoker.dynamic_greeting_run_at(name, 5) expect(output).to be_empty $stdout = StringIO.new output = $stdout.string @@ -38,7 +38,7 @@ PutsDebuggererInvoker.dynamic_greeting_run_at(name, nil) PutsDebuggererInvoker.dynamic_greeting_run_at(name, nil) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n" * 7) + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n" * 7) end end @@ -47,7 +47,7 @@ name = 'Robert' output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, [1, 3]) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:1)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:1)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string @@ -57,7 +57,7 @@ $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, [1, 3]) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:3)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:3)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string @@ -97,17 +97,17 @@ $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, 3..5) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:3)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:3)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, 3..5) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:4)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:4)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, 3..5) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:5)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:5)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string @@ -136,27 +136,27 @@ $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, 3..-1) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:3)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:3)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, 3..-1) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:4)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:4)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, 3..-1) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:5)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:5)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, 3..-1) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:6)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:6)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, 3..-1) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:7)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:7)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") end it 'skips first 2 runs, prints on the rest' do @@ -173,27 +173,27 @@ $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, 3...-1) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:3)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:3)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, 3...-1) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:4)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:4)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, 3...-1) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:5)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:5)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, 3...-1) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:6)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:6)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, 3...-1) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:7)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:7)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") end end @@ -217,17 +217,17 @@ $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting(name) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 (run:3)\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting (run:3)\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting(name) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 (run:4)\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting (run:4)\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting(name) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 (run:5)\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting (run:5)\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string @@ -246,12 +246,12 @@ name = 'Robert' PutsDebuggererInvoker.dynamic_greeting_run_at(name, 1..2) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:1)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:1)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, 1..2) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:2)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:2)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string @@ -264,12 +264,12 @@ $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, 1..2) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:1)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:1)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, 1..2) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:2)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:2)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string @@ -281,12 +281,12 @@ name = 'Robert' PutsDebuggererInvoker.dynamic_greeting_run_at(name, 1..2) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:1)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:1)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, 1..2) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:2)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:2)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string @@ -299,12 +299,12 @@ $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, 1..2) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:1)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:1)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting_run_at(name, 1..2) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 (run:2)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:39 in PutsDebuggererInvoker.dynamic_greeting_run_at (run:2)\n > pd \"Hello \#{name}\", run_at: run_at\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string @@ -317,12 +317,12 @@ name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 (run:1)\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting (run:1)\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting(name) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 (run:2)\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting (run:2)\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string @@ -335,12 +335,12 @@ $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting(name) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 (run:1)\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting (run:1)\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string PutsDebuggererInvoker.dynamic_greeting(name) - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 (run:2)\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting (run:2)\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") $stdout = StringIO.new output = $stdout.string diff --git a/spec/lib/puts_debuggerer__with_wrapper_support_enabled__spec.rb b/spec/lib/puts_debuggerer__with_wrapper_support_enabled__spec.rb index 6b57a3b..e4bab2b 100644 --- a/spec/lib/puts_debuggerer__with_wrapper_support_enabled__spec.rb +++ b/spec/lib/puts_debuggerer__with_wrapper_support_enabled__spec.rb @@ -11,28 +11,28 @@ name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("#{PutsDebuggerer::WRAPPER_DEFAULT}\n[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n#{PutsDebuggerer::WRAPPER_DEFAULT}\n") + expect(output).to eq("#{PutsDebuggerer::WRAPPER_DEFAULT}\n[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n#{PutsDebuggerer::WRAPPER_DEFAULT}\n") end it 'disables wrapper with nil wrapper' do PutsDebuggerer.wrapper = nil name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") end it 'disables wrapper with false wrapper' do PutsDebuggerer.wrapper = false name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") end it 'disables wrapper with empty string wrapper' do PutsDebuggerer.wrapper = '' name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") end end context 'as custom wrapper' do @@ -47,7 +47,7 @@ name = 'Robert' PutsDebuggererInvoker.dynamic_greeting(name) output = $stdout.string - expect(output).to eq("#{custom_wrapper}\n[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n#{custom_wrapper}\n") + expect(output).to eq("#{custom_wrapper}\n[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n#{custom_wrapper}\n") end end end diff --git a/spec/lib/puts_debuggerer_spec.rb b/spec/lib/puts_debuggerer_spec.rb index 5240c4d..367ba0d 100644 --- a/spec/lib/puts_debuggerer_spec.rb +++ b/spec/lib/puts_debuggerer_spec.rb @@ -7,27 +7,27 @@ name = 'Robert' expect(PutsDebuggererInvoker.dynamic_greeting(name)).to eq('Hello Robert') output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:10 in PutsDebuggererInvoker.dynamic_greeting\n > pd \"Hello \#{name}\"\n => \"Hello Robert\"\n") end it 'prints file, line number, ruby expression, and evaluated string object without extra parentheses when already surrounded; returns evaluated object' do name = 'Robert' expect(PutsDebuggererInvoker.parentheses_dynamic_greeting(name)).to eq("Hello Robert") output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:14\n > pd (\"Hello \#{name}\")\n => \"Hello Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:14 in PutsDebuggererInvoker.parentheses_dynamic_greeting\n > pd (\"Hello \#{name}\")\n => \"Hello Robert\"\n") end it 'prints file, line number, ruby expression, and evaluated numeric object without quotes; returns evaluated integer' do expect(PutsDebuggererInvoker.numeric_squaring(3)).to eq(9) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:18\n > pd n*n\n => 9\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:18 in PutsDebuggererInvoker.numeric_squaring\n > pd n*n\n => 9\n") end it 'prints inside pd expression' do name = 'Robert' expect(PutsDebuggererInvoker.inside_dynamic_greeting(name)).to eq('Hello Robert') output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:35\n > greeting = \"Hello \#{pd(name)}\"\n => \"Robert\"\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:35 in PutsDebuggererInvoker.inside_dynamic_greeting\n > greeting = \"Hello \#{pd(name)}\"\n => \"Robert\"\n") end it 'prints exception stack trace' do @@ -43,26 +43,27 @@ def full_message e = FakeException.new PutsDebuggererInvoker.exception_stack_trace(e) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:48\n > pd error\n => stack trace line 1\nstack trace line 2\nstack trace line 3\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:48 in PutsDebuggererInvoker.exception_stack_trace\n > pd error\n => stack trace line 1\nstack trace line 2\nstack trace line 3\n") end it 'prints *args array' do result = PutsDebuggererInvoker.vararg_array expect(result).to eq(['hello', 3, true]) output = $stdout.string - expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:52\n > pd 'hello', 3, true\n => [\"hello\", 3, true]\n") + expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:52 in PutsDebuggererInvoker.vararg_array\n > pd 'hello', 3, true\n => [\"hello\", 3, true]\n") end it 'prints *args array with options at the end' do result = PutsDebuggererInvoker.vararg_array_with_options(wrapper: true) expect(result).to eq(['hello', 3, true]) output = $stdout.string - expect(output).to eq("********************************************************************************\n[PD] #{puts_debuggerer_invoker_file}:56\n > pd 'hello', 3, true, options\n => [\"hello\", 3, true]\n********************************************************************************\n") + expect(output).to eq("********************************************************************************\n[PD] #{puts_debuggerer_invoker_file}:56 in PutsDebuggererInvoker.vararg_array_with_options\n > pd 'hello', 3, true, options\n => [\"hello\", 3, true]\n********************************************************************************\n") end it 'prints using pd_inspect' do result = PutsDebuggererInvoker.call_pd_inspect([1, [2, [3]]]) - expect(result).to eq("[PD] #{puts_debuggerer_invoker_file}:68\n > object.pd_inspect\n => [1, [2, [3]]]\n") + # TODO it is odd we are getting the PutsDebuggerInvoker file, but the Array class. See if we should fix something here. + expect(result).to eq("[PD] #{puts_debuggerer_invoker_file}:68 in Array.call_pd_inspect\n > object.pd_inspect\n => [1, [2, [3]]]\n") output = $stdout.string expect(output).to eq("") end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 22b8b2a..8ad8188 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,15 +1,15 @@ -require 'simplecov' -require 'simplecov-lcov' -require 'coveralls' if ENV['TRAVIS'] - -SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true -formatters = [] -formatters << SimpleCov::Formatter::LcovFormatter -formatters << Coveralls::SimpleCov::Formatter if ENV['TRAVIS'] -SimpleCov.formatters = formatters -SimpleCov.start do - add_filter(/^\/spec\//) -end +# require 'simplecov' +# require 'simplecov-lcov' +# require 'coveralls' if ENV['TRAVIS'] +# +# SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true +# formatters = [] +# formatters << SimpleCov::Formatter::LcovFormatter +# formatters << Coveralls::SimpleCov::Formatter if ENV['TRAVIS'] +# SimpleCov.formatters = formatters +# SimpleCov.start do +# add_filter(/^\/spec\//) +# end $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__))