diff --git a/lib/naught/basic_object.rb b/lib/naught/basic_object.rb index e3acb7f..fc0c0ac 100644 --- a/lib/naught/basic_object.rb +++ b/lib/naught/basic_object.rb @@ -4,7 +4,11 @@ class BasicObject < ::BasicObject end else class BasicObject #:nodoc: - keep = %w[! != == __id__ __send__ equal? instance_eval instance_exec method_missing singleton_method_added singleton_method_removed singleton_method_undefined] + keep = %w[ + ! != == __id__ __send__ equal? instance_eval instance_exec + method_missing singleton_method_added singleton_method_removed + singleton_method_undefined + ] instance_methods.each do |method_name| undef_method(method_name) unless keep.include?(method_name) end diff --git a/lib/naught/null_class_builder/commands/impersonate.rb b/lib/naught/null_class_builder/commands/impersonate.rb index 5bdeefb..11c3840 100644 --- a/lib/naught/null_class_builder/commands/impersonate.rb +++ b/lib/naught/null_class_builder/commands/impersonate.rb @@ -2,8 +2,7 @@ module Naught::NullClassBuilder::Commands class Impersonate < Naught::NullClassBuilder::Commands::Mimic def initialize(builder, class_to_impersonate, options = {}) super - - builder.base_class = class_to_impersonate + builder.base_class = class_to_impersonate end end end diff --git a/lib/naught/null_class_builder/commands/mimic.rb b/lib/naught/null_class_builder/commands/mimic.rb index d6742a8..1156ebd 100644 --- a/lib/naught/null_class_builder/commands/mimic.rb +++ b/lib/naught/null_class_builder/commands/mimic.rb @@ -27,11 +27,7 @@ def call private def root_class_of(klass) - if klass.ancestors.include?(Object) - Object - else - Naught::BasicObject - end + klass.ancestors.include?(Object) ? Object : Naught::BasicObject end def methods_to_stub diff --git a/lib/naught/null_class_builder/commands/predicates_return.rb b/lib/naught/null_class_builder/commands/predicates_return.rb index be72868..6952e58 100644 --- a/lib/naught/null_class_builder/commands/predicates_return.rb +++ b/lib/naught/null_class_builder/commands/predicates_return.rb @@ -20,8 +20,7 @@ def define_method_missing(subject) subject.module_exec(@predicate_return_value) do |return_value| if subject.method_defined?(:method_missing) original_method_missing = instance_method(:method_missing) - define_method(:method_missing) do - |method_name, *args, &block| + define_method(:method_missing) do |method_name, *args, &block| if method_name.to_s.end_with?('?') return_value else diff --git a/lib/naught/null_class_builder/commands/traceable.rb b/lib/naught/null_class_builder/commands/traceable.rb index 958c14a..93a7485 100644 --- a/lib/naught/null_class_builder/commands/traceable.rb +++ b/lib/naught/null_class_builder/commands/traceable.rb @@ -8,11 +8,8 @@ def call attr_reader :__file__, :__line__ def initialize(options = {}) - backtrace = if RUBY_VERSION.to_f == 1.9 && RUBY_PLATFORM != 'java' - options.fetch(:caller) { Kernel.caller(4) } - else - options.fetch(:caller) { Kernel.caller(3) } - end + range = (RUBY_VERSION.to_f == 1.9 && RUBY_PLATFORM != 'java') ? 4 : 3 + backtrace = options.fetch(:caller) { Kernel.caller(range) } @__file__, line, _ = backtrace[0].split(':') @__line__ = line.to_i end diff --git a/spec/pebble_spec.rb b/spec/pebble_spec.rb index 0992ed9..caba3ca 100644 --- a/spec/pebble_spec.rb +++ b/spec/pebble_spec.rb @@ -46,7 +46,8 @@ def call_method_inside_nested_block(thing) end context 'when is called from a block' do - it 'prints the indication of a block', :pending => jruby? || rubinius? || ruby_18? do + it 'prints the indication of a block', + :pending => jruby? || rubinius? || ruby_18? do expect(test_output).to receive(:puts).twice. with(/from block/) Caller.new.call_method_inside_block(null) @@ -60,7 +61,8 @@ def call_method_inside_nested_block(thing) end context 'when is called from many levels blocks' do - it 'prints the indication of blocks and its levels', :pending => jruby? || rubinius? || ruby_18? do + it 'prints the indication of blocks and its levels', + :pending => jruby? || rubinius? || ruby_18? do expect(test_output).to receive(:puts).exactly(4).times. with(/from block \(2 levels\)/) Caller.new.call_method_inside_nested_block(null)