Sha256: c98d89ff5e1e353165d927ec562cf35cdcc5e005d7f40c228c21f3c0e064f176

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

$LOAD_PATH << "../../.." unless $LOAD_PATH.include?("../../..")
require 'test/unit'
require 'langscan/rpmspec'

class TestRPMSpec < Test::Unit::TestCase
  def assert_yield_any(recv, meth, *args)
    success = false
    recv.__send__(meth, *args) {|*block_args|
      if yield(*block_args)
        assert(true)
        success = true
        break
      end
    }
    assert(false, "no expected yields") unless success
  end

  def assert_yield_all(recv, meth, *args)
    recv.__send__(meth, *args) {|*block_args|
      if !yield(*block_args)
        assert(false, "unexpected yields")
        return
      end
    }
    assert(true)
  end

  def test_preamble
    assert_yield_any(LangScan::RPMSpec, :scan, "\nName: gonzui") {|f|
      f.type == :keyword && f.text == 'Name'
    }
  end

  def test_part
    assert_yield_any(LangScan::RPMSpec, :scan, "\n%description devel") {|f|
      f.type == :keyword && f.text == '%description'
    }
  end

  def test_comment
    assert_yield_any(LangScan::RPMSpec, :scan, "\n# comment") {|f|
      f.type == :comment && f.text == '# comment'
    }
  end

  def test_string
    assert_yield_any(LangScan::RPMSpec, :scan, "\nCFLAGS=\"$RPM_OPT_FLAGS -Wall\"") {|f|
      f.type == :string && f.text == '"$RPM_OPT_FLAGS -Wall"'
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
langscan-1.2-x86-mswin32-60 test/langscan/rpmspec/test/test_rpmspec.rb
langscan-1.2 test/langscan/rpmspec/test/test_rpmspec.rb