Sha256: a53cda76075b22e24bdddbd33ef09e59280e5955c9ecbeed445ecea35b89a8bb

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require './test/test_helper'

describe 'require_pattern' do
  it "requires relative to the current working directory by default" do
    require_pattern 'colors/*.rb'
    $red.must_equal true
    $green.must_equal true
  end

  it "can require relative to the current file" do
    require_relative_pattern 'dummy/sizes/*.rb'
    $tall.must_equal true
    $short.must_equal true
  end

  it "overcomes file ordering issues by intelligently retrying" do
    require_relative_pattern 'dummy/dependancies/*.rb'
    Golf
  end

  it "reports true only if a file was loaded" do
    require_pattern('loaded.rb').must_equal true
    require_pattern('loaded.rb').wont_equal true
  end

  it "can take multiple patterns" do
    require_pattern('colors/*.rb', 'shapes/*.rb').must_equal true
    assert $circle
    assert $square
  end

  it "outputs to STDERR on failure" do
    STDERR.expects(:puts).at_least(2)
    lambda {
      require_pattern 'bad.*'
    }.must_raise LoadError
  end

  it "doesn't care if it doesn't match any files" do
    require_pattern('good luck matching this').must_equal false
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
require_pattern_xt-1.1.0 test/require_pattern_xt_test.rb
require_pattern_xt-1.0.0 test/require_pattern_xt_test.rb