Sha256: 63ed0eb361221f8983fc5b2586135cd954b3a9ec4c539874ff2c8c325b4c9c71

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

require File.join(File.dirname(__FILE__), 'test_helper')

module Boson
  class FileLibraryTest < Test::Unit::TestCase
    context "file library" do
      before(:each) { reset; FileLibrary.reset_file_cache }

      test "loads" do
        load :blah, :file_string=>"module Blah; def blah; end; end"
        library_has_module('blah', 'Boson::Commands::Blah')
        command_exists?('blah')
      end

      test "in a subdirectory loads" do
        load 'site/delicious', :file_string=>"module Delicious; def blah; end; end"
        library_has_module('site/delicious', "Boson::Commands::Site::Delicious")
        command_exists?('blah')
      end

      test "in a sub subdirectory loads" do
        load 'web/site/delicious', :file_string=>"module Delicious; def blah; end; end"
        library_has_module('web/site/delicious', "Boson::Commands::Web::Site::Delicious")
        command_exists?('blah')
      end

      test "loads by basename" do
        Dir.stubs(:[]).returns(['./test/commands/site/github.rb'])
        load 'github', :file_string=>"module Github; def blah; end; end", :exists=>false
        library_has_module('site/github', "Boson::Commands::Site::Github")
        command_exists?('blah')
      end

      test "prints error for file library with no module" do
        capture_stderr { load(:blah, :file_string=>"def blah; end") }.should =~ /Can't.*at least/
      end

      test "prints error for file library with multiple modules" do
        capture_stderr { load(:blah, :file_string=>"module Doo; end; module Daa; end") }.should =~ /Can't.*config/
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
boson-0.2.1 test/file_library_test.rb