Sha256: 3070225997d4d41c7c57252513e18a9b80de912325b64bd44088e722529630b3

Contents?: true

Size: 1.16 KB

Versions: 465

Compression:

Stored size: 1.16 KB

Contents

require File.expand_path('../helper', __FILE__)
require 'stringio'

class TestRakeExtension < Rake::TestCase

  module Redirect
    def error_redirect
      old_err = $stderr
      result = StringIO.new
      $stderr = result
      yield
      result
    ensure
      $stderr = old_err
    end
  end

  class Sample
    extend Redirect

    def duplicate_method
      :original
    end

    OK_ERRS = error_redirect do
      rake_extension("a") do
        def ok_method
        end
      end
    end


    DUP_ERRS = error_redirect do
      rake_extension("duplicate_method") do
        def duplicate_method
          :override
        end
      end
    end
  end

  def test_methods_actually_exist
    sample = Sample.new
    sample.ok_method
    sample.duplicate_method
  end

  def test_no_warning_when_defining_ok_method
    assert_equal "", Sample::OK_ERRS.string
  end

  def test_extension_complains_when_a_method_that_is_present
    assert_match(/warning:/i, Sample::DUP_ERRS.string)
    assert_match(/already exists/i, Sample::DUP_ERRS.string)
    assert_match(/duplicate_method/i, Sample::DUP_ERRS.string)
    assert_equal :original, Sample.new.duplicate_method
  end

end

Version data entries

465 entries across 395 versions & 113 rubygems

Version Path
pomodorokun-0.1.0 bundle/ruby/2.4.0/gems/rake-10.5.0/test/test_rake_extension.rb
cspeezy_palindrome-0.3.0 path/ruby/2.6.0/gems/rake-10.5.0/test/test_rake_extension.rb
cspeezy_palindrome-0.2.0 path/ruby/2.6.0/gems/rake-10.5.0/test/test_rake_extension.rb
cspeezy_palindrome-0.1.0 path/ruby/2.6.0/gems/rake-10.5.0/test/test_rake_extension.rb
blackjack_jp-0.1.3 vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/test/test_rake_extension.rb
blackjack_jp-0.1.2 vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/test/test_rake_extension.rb
blackjack_jp-0.1.1 vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/test/test_rake_extension.rb
blackjack_jp-0.1.0 vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/test/test_rake_extension.rb
steenfest_palindrome-0.1.2 ruby/2.5/gems/rake-10.5.0/test/test_rake_extension.rb
steenfest_palindrome-0.1.1b ruby/2.5/gems/rake-10.5.0/test/test_rake_extension.rb
xaiml-0.1.3 vendor/bundle/ruby/2.5.0/gems/rake-10.5.0/test/test_rake_extension.rb
alimentos-alu0100945645-0.1.0 vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/test/test_rake_extension.rb
alimentos-alu0100945645-1.0.0 vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/test/test_rake_extension.rb
xaiml-0.1.2 vendor/bundle/ruby/2.5.0/gems/rake-10.5.0/test/test_rake_extension.rb
nullifyable-0.1.0 vendor/bundle/gems/rake-10.5.0/test/test_rake_extension.rb
dmurphy_palindrome-0.1.0 vendor/cache/ruby/2.3.0/gems/rake-10.5.0/test/test_rake_extension.rb
dmurphy_palindrome-0.1.0 vendor/cache/ruby/2.3.0/gems/dmurphy_palindrome-0.1.0/vendor/cache/ruby/2.3.0/gems/rake-10.5.0/test/test_rake_extension.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/rake-10.5.0/test/test_rake_extension.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/rake-10.5.0/test/test_rake_extension.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/rake-10.5.0/test/test_rake_extension.rb