Sha256: 5723c7f2ffad52d5cb7118ac93cc07dfad93a6f83faf01a80fe5d0e5999164d4

Contents?: true

Size: 1.21 KB

Versions: 7

Compression:

Stored size: 1.21 KB

Contents

require "spec_helper"

module Chanko
  describe Loader do
    describe ".load" do
      after do
        described_class.cache.clear
      end

      context "when existent unit name is passed" do
        it "loads unit in units directory and returns the Module" do
          described_class.load(:example_unit).should == ExampleUnit
        end
      end

      context "when non-existent unit name is passed" do
        it "returns nil" do
          described_class.load(:non_existent_unit).should == nil
        end
      end

      context "when loader has ever loaded specified unit" do
        it "load unit from cache" do
          described_class.any_instance.should_receive(:load_from_file).and_call_original
          described_class.load(:example_unit)
          described_class.load(:example_unit)
        end
      end

      context "when loader has ever loaded specified wrong unit" do
        before do
          described_class.cache.clear
        end

        it "load unit from cache" do
          described_class.any_instance.should_receive(:load_from_file).and_call_original
          described_class.load(:non_existent_unit)
          described_class.load(:non_existent_unit)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
chanko-2.0.6 spec/chanko/loader_spec.rb
chanko-2.0.5 spec/chanko/loader_spec.rb
chanko-2.0.4 spec/chanko/loader_spec.rb
chanko-2.0.3 spec/chanko/loader_spec.rb
chanko-2.0.2 spec/chanko/loader_spec.rb
chanko-2.0.1 spec/chanko/loader_spec.rb
chanko-2.0.0 spec/chanko/loader_spec.rb