Sha256: 19c550382fa061fdd6599b760848a604d24054dc2f6c21b03b6a4b094d682459

Contents?: true

Size: 1.99 KB

Versions: 93

Compression:

Stored size: 1.99 KB

Contents

#!/usr/bin/env ruby

begin
  require 'rubygems'
rescue LoadError
  # got no gems
end

require 'test/unit'
require 'flexmock/test_unit'
require 'test/capture_stdout'
require 'test/rake_test_setup'
require 'rake'

class TestTopLevelFunctions < Test::Unit::TestCase
  include CaptureStdout
  include TestMethods

  def setup
    super
    @app = Rake.application
    Rake.application = flexmock("app")
  end

  def teardown
    Rake.application = @app
    super
  end

  def test_namespace
    Rake.application.should_receive(:in_namespace).with("xyz", any).once
    namespace "xyz" do end
  end

  def test_import
    Rake.application.should_receive(:add_import).with("x").once.ordered
    Rake.application.should_receive(:add_import).with("y").once.ordered
    Rake.application.should_receive(:add_import).with("z").once.ordered
    import('x', 'y', 'z')
  end

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

  def test_when_not_writing
    RakeFileUtils.nowrite_flag = true
    out = capture_stdout do
      when_writing("NOTWRITING") do
        puts "WRITING"
      end
    end
    assert_equal "DRYRUN: NOTWRITING\n", out
  ensure
    RakeFileUtils.nowrite_flag = false
  end

  def test_missing_constants_task
    Rake.application.should_receive(:const_warning).with(:Task).once
    Object.const_missing(:Task)
  end

  def test_missing_constants_file_task
    Rake.application.should_receive(:const_warning).with(:FileTask).once
    Object.const_missing(:FileTask)
  end

  def test_missing_constants_file_creation_task
    Rake.application.should_receive(:const_warning).with(:FileCreationTask).once
    Object.const_missing(:FileCreationTask)
  end

  def test_missing_constants_rake_app
    Rake.application.should_receive(:const_warning).with(:RakeApp).once
    Object.const_missing(:RakeApp)
  end

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

Version data entries

93 entries across 65 versions & 9 rubygems

Version Path
dirty_history-0.4.8 dirty_history/ruby/1.9.1/gems/rake-0.8.7/test/test_top_level_functions.rb
dirty_history-0.4.8 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/rake-0.8.7/test/test_top_level_functions.rb
dirty_history-0.4.8 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/rake-0.8.7/test/test_top_level_functions.rb
dirty_history-0.4.7 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/rake-0.8.7/test/test_top_level_functions.rb
dirty_history-0.4.7 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/rake-0.8.7/test/test_top_level_functions.rb
dirty_history-0.4.7 dirty_history/ruby/1.9.1/gems/rake-0.8.7/test/test_top_level_functions.rb
dirty_history-0.4.6 dirty_history/ruby/1.9.1/gems/rake-0.8.7/test/test_top_level_functions.rb
dirty_history-0.4.6 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/rake-0.8.7/test/test_top_level_functions.rb
dirty_history-0.4.6 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/rake-0.8.7/test/test_top_level_functions.rb
dirty_history-0.4.5 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/rake-0.8.7/test/test_top_level_functions.rb
dirty_history-0.4.5 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/rake-0.8.7/test/test_top_level_functions.rb
dirty_history-0.4.5 dirty_history/ruby/1.9.1/gems/rake-0.8.7/test/test_top_level_functions.rb
dirty_history-0.4.4 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/rake-0.8.7/test/test_top_level_functions.rb
dirty_history-0.4.4 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/rake-0.8.7/test/test_top_level_functions.rb
dirty_history-0.4.4 dirty_history/ruby/1.9.1/gems/rake-0.8.7/test/test_top_level_functions.rb
dirty_history-0.4.3 dirty_history/ruby/1.9.1/gems/rake-0.8.7/test/test_top_level_functions.rb
dirty_history-0.4.3 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/rake-0.8.7/test/test_top_level_functions.rb
dirty_history-0.4.3 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/rake-0.8.7/test/test_top_level_functions.rb
dirty_history-0.4.2 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/rake-0.8.7/test/test_top_level_functions.rb
dirty_history-0.4.2 dirty_history/ruby/1.9.1/gems/rake-0.8.7/test/test_top_level_functions.rb