Sha256: b590307954b347b41e8cfef02a0cfb9a8f28a89f37392c0cab9c608561978f04

Contents?: true

Size: 946 Bytes

Versions: 13

Compression:

Stored size: 946 Bytes

Contents

require_relative '../../test_helper'
require_relative '../../fixtures/wut'
DuckPuncher.punch! Method

class MethodTest < MiniTest::Test

  # Called before every test method runs. Can be used
  # to set up fixture information.
  def setup
    @subject = Wut.new
  end

  def test_to_instruct
    assert_match /:to_a/, @subject.method(:to_a).to_instruct
    assert_match /newarray/, @subject.method(:to_a).to_instruct
    assert_match /opt_plus/, @subject.method(:to_a).to_instruct
    assert_equal nil, [].method(:to_s).to_instruct
  end

  def test_to_instruct_single_line
    assert_match /:to_f/, @subject.method(:to_f).to_instruct
    assert_match /getconstant\s*:INFINITY/, @subject.method(:to_f).to_instruct
  end

  def test_to_source
    assert_equal "def to_a\n  ['w'] + ['u'] + ['t']\nend\n", @subject.method(:to_a).to_source
  end

  def test_to_source_with_no_source
    assert_equal '', @subject.method(:object_id).to_source
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
duck_puncher-4.5.1 test/lib/duck_puncher/method_test.rb
duck_puncher-4.5.0 test/lib/duck_puncher/method_test.rb
duck_puncher-4.4.2 test/lib/duck_puncher/method_test.rb
duck_puncher-4.4.1 test/lib/duck_puncher/method_test.rb
duck_puncher-4.4.0 test/lib/duck_puncher/method_test.rb
duck_puncher-4.3.1 test/lib/duck_puncher/method_test.rb
duck_puncher-4.3.0 test/lib/duck_puncher/method_test.rb
duck_puncher-4.2.3 test/lib/duck_puncher/method_test.rb
duck_puncher-4.2.2 test/lib/duck_puncher/method_test.rb
duck_puncher-4.2.1 test/lib/duck_puncher/method_test.rb
duck_puncher-4.2.0 test/lib/duck_puncher/method_test.rb
duck_puncher-4.1.0 test/lib/duck_puncher/method_test.rb
duck_puncher-4.0.0 test/lib/duck_puncher/method_test.rb