lib/sugar/debug_sugar.rb in pry-moves-1.0.3 vs lib/sugar/debug_sugar.rb in pry-moves-1.0.4

- old
+ new

@@ -7,15 +7,13 @@ def error(msg = "Error", debug_object = nil) pry_moves_stack_end = true err = "😱 #{msg}" unless PryMoves.open? if PryMoves.stop_on_breakpoints - lines = [err.red] - lines.prepend debug_object.ai if debug_object - PryMoves.debug_error lines.join("\n") + PryMoves.debug_error err.red, debug_object else - STDERR.puts debug_object.ai if debug_object + STDERR.puts PryMoves.format_debug_object(debug_object) if debug_object STDERR.puts err.ljust(80, ' ').red end end raise PryMoves::ErrorWithData.new(msg, debug_object) end @@ -37,10 +35,18 @@ pry_moves_stack_end = true error("required parameter is missing") if self.nil? self end + def should_be *classes + hide_from_stack = true + if self && !classes.some?{self.is_a?(_1)} + error("Expected class #{classes.join ", "}, got #{self.class.ai}", self) + end + self + end + end RSpec.configure do |config| config.before(:each) do @@ -53,11 +59,11 @@ PryMoves.restartable(rspec_example: example) do example.run end end -end if defined? RSpec +end if ENV['PRY_MOVES'] != 'off' and defined? RSpec Rake::Task.class_eval do alias execute_origin_for_pry_moves execute @@ -73,10 +79,10 @@ rake_task_path = actions[0].source_location[0] actions.clear load rake_task_path end -end if defined? Rake and defined? Rake::Task +end if ENV['PRY_MOVES'] != 'off' and defined? Rake and defined? Rake::Task Diffy.module_eval do class << self def diff text1, text2