Sha256: 92bd9d1e4acd5b6a589be85ca383b46a81059407bfc9e1ab1471b3f683fa0cb2

Contents?: true

Size: 1.25 KB

Versions: 332

Compression:

Stored size: 1.25 KB

Contents

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

class TestRakeTopLevelFunctions < Rake::TestCase

  def setup
    super

    @app = Object.new

    def @app.called
      @called
    end

    def @app.method_missing(*a, &b)
      @called ||= []
      @called << [a, b]
      nil
    end

    Rake.application = @app
  end

  def test_namespace
    block = proc do end

    namespace("xyz", &block)

    expected = [
      [[:in_namespace, 'xyz'], block]
    ]

    assert_equal expected, @app.called
  end

  def test_import
    import('x', 'y', 'z')

    expected = [
      [[:add_import, 'x'], nil],
      [[:add_import, 'y'], nil],
      [[:add_import, 'z'], nil],
    ]

    assert_equal expected, @app.called
  end

  def test_when_writing
    out, = capture_io do
      when_writing("NOTWRITING") do
        puts "WRITING"
      end
    end
    assert_equal "WRITING\n", out
  end

  def test_when_not_writing
    Rake::FileUtilsExt.nowrite_flag = true
    _, err = capture_io do
      when_writing("NOTWRITING") do
        puts "WRITING"
      end
    end
    assert_equal "DRYRUN: NOTWRITING\n", err
  ensure
    Rake::FileUtilsExt.nowrite_flag = false
  end

  def test_missing_other_constant
    assert_raises(NameError) do Object.const_missing(:Xyz) end
  end
end

Version data entries

332 entries across 291 versions & 95 rubygems

Version Path
pomodorokun-0.1.0 bundle/ruby/2.4.0/gems/rake-10.5.0/test/test_rake_top_level_functions.rb
cspeezy_palindrome-0.3.0 path/ruby/2.6.0/gems/rake-10.5.0/test/test_rake_top_level_functions.rb
cspeezy_palindrome-0.2.0 path/ruby/2.6.0/gems/rake-10.5.0/test/test_rake_top_level_functions.rb
cspeezy_palindrome-0.1.0 path/ruby/2.6.0/gems/rake-10.5.0/test/test_rake_top_level_functions.rb
blackjack_jp-0.1.3 vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/test/test_rake_top_level_functions.rb
blackjack_jp-0.1.2 vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/test/test_rake_top_level_functions.rb
blackjack_jp-0.1.1 vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/test/test_rake_top_level_functions.rb
blackjack_jp-0.1.0 vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/test/test_rake_top_level_functions.rb
steenfest_palindrome-0.1.2 ruby/2.5/gems/rake-10.5.0/test/test_rake_top_level_functions.rb
steenfest_palindrome-0.1.1b ruby/2.5/gems/rake-10.5.0/test/test_rake_top_level_functions.rb
xaiml-0.1.3 vendor/bundle/ruby/2.5.0/gems/rake-10.5.0/test/test_rake_top_level_functions.rb
alimentos-alu0100945645-0.1.0 vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/test/test_rake_top_level_functions.rb
alimentos-alu0100945645-1.0.0 vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/test/test_rake_top_level_functions.rb
xaiml-0.1.2 vendor/bundle/ruby/2.5.0/gems/rake-10.5.0/test/test_rake_top_level_functions.rb
nullifyable-0.1.0 vendor/bundle/gems/rake-10.5.0/test/test_rake_top_level_functions.rb
dmurphy_palindrome-0.1.0 vendor/cache/ruby/2.3.0/gems/rake-10.5.0/test/test_rake_top_level_functions.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_top_level_functions.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_top_level_functions.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/rake-10.5.0/test/test_rake_top_level_functions.rb
config_gems_initialization_aim-0.1.3 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_top_level_functions.rb