Sha256: ae89dd26aa5965a010450eafa70d8d225484178cb7d81393585bab5054ec17b2

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require "spec_helper"

module Nyanko
  describe UnitProxyProvider do
    let(:view) do
      Class.new { include Nyanko::UnitProxyProvider }.new
    end

    describe "#unit" do
      it "is aliased with `ext`" do
        view.ext(:example_unit).should be_a UnitProxy
      end

      context "when given unit name" do
        it "returns proxy for specified unit" do
          proxy = view.unit(:example_unit)
          proxy.should be_a UnitProxy
          proxy.unit.should == ExampleUnit
        end

        context "when unit is not found" do
          it "raises NoUnitError" do
            expect { view.unit(:non_existent_unit) }.to raise_error(described_class::NoUnitError)
          end
        end
      end

      context "when given no unit name" do
        before do
          Function.units << Loader.load(:example_unit)
        end

        after do
          Function.units.pop
        end

        it "returns proxy for the top unit of current unit stack" do
          proxy = view.unit
          proxy.unit.should == ExampleUnit
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nyanko-0.0.3 spec/nyanko/unit_proxy_provider_spec.rb