Sha256: 5051f77026569926cb1f96c8fba8db1ac24c794dd1fe1be115ae765b5c0eb89e

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
require 'hardmock/method_cleanout'

class MethodCleanoutTest < Test::Unit::TestCase
  class Victim
    OriginalMethods = instance_methods
    include Hardmock::MethodCleanout
  end
  
  def setup
    @victim = Victim.new
  end

  def test_should_remove_most_methods_from_a_class
    expect_removed = Victim::OriginalMethods.reject { |m| 
      Hardmock::MethodCleanout::SACRED_METHODS.include?(m)
    }
    expect_removed.each do |m|
      assert !@victim.respond_to?(m), "should not have method #{m}"
    end
  end

  def test_should_leave_the_sacred_methods_defined
    Hardmock::MethodCleanout::SACRED_METHODS.each do |m|
      assert @victim.respond_to?(m)
    end
  end

  def test_should_include_certain_important_methods_in_the_sacred_methods_list
    %w|__id__ __send__ equal? object_id send nil? class kind_of? respond_to? inspect method to_s instance_variables instance_eval|.each do |m|
      assert Hardmock::MethodCleanout::SACRED_METHODS.include?(m), "important method #{m} is not included in SACRED_METHODS"
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hardmock-1.2.3 test/unit/method_cleanout_test.rb
hardmock-1.3.0 test/unit/method_cleanout_test.rb
hardmock-1.3.1 test/unit/method_cleanout_test.rb
hardmock-1.3.2 test/unit/method_cleanout_test.rb