Sha256: efcdb97bf1ceb8eaedc3cd177ca06f0e12b0d1382c41aff05a876791b970faf5

Contents?: true

Size: 1.3 KB

Versions: 7

Compression:

Stored size: 1.3 KB

Contents

require 'test_helper'

class IModuleTest < Test::Unit::TestCase
  context "The IModule class" do

    should "be able to return its symbol" do
      assert_equal(:"AbsoluteRenamer::IModule", AbsoluteRenamer::IModule.symbol)
    end

  end

  context "An IModule instance" do

    setup do
      @imodule = AbsoluteRenamer::IModule.new
      @fileinfo = AbsoluteRenamer::FileInfo.new('/some/path/to/a_file.txt')
    end

    should "set the right filename format when calling process" do
      assert_equal('format', @imodule.process(@fileinfo, 'format', :name))
    end

    should "set the right extension format when calling process" do
      assert_equal('format', @imodule.process(@fileinfo, 'format', :ext))
    end

    context "with config file loaded" do

      setup do
        AbsoluteRenamer::Config.load('conf/absrenamer/absrenamer.conf')
        @default_string = AbsoluteRenamer::Config[:options][:default_string]
        @infos = [nil, nil, '', 'matched']
      end

      should "be able to interpret a matching result for filename" do
        assert_equal(@default_string, @imodule.interpret(@fileinfo, @infos, :name))
      end

      should "be able to interpret a matching result for extension" do
        assert_equal(@default_string, @imodule.interpret(@fileinfo, @infos, :ext))
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
AbsoluteRenamer-1.0.4 test/imodule_test.rb
AbsoluteRenamer-1.0.3 test/imodule_test.rb
AbsoluteRenamer-1.0.2 test/imodule_test.rb
AbsoluteRenamer-1.0.1 test/imodule_test.rb
AbsoluteRenamer-1.0.0 test/imodule_test.rb
AbsoluteRenamer-0.10.0 test/imodule_test.rb
AbsoluteRenamer-0.10.1 test/imodule_test.rb