Sha256: e8abdf009d2dfb5b44210cd78d60b5a5a174b5a1f09d864016d2a2d64d7ea761

Contents?: true

Size: 823 Bytes

Versions: 6

Compression:

Stored size: 823 Bytes

Contents

require "spec_helper"

module Nyanko
  describe Function do
    let(:unit) do
      Loader.load(:example_unit)
    end

    let(:context) do
      Class.new(ActionView::Base) do
        include Nyanko::Invoker

        def current_unit
          units.last
        end

        def units
          @units ||= []
        end

        def path
          view_paths.first.to_s
        end
      end.new
    end

    describe ".invoke" do
      it "invokes block with given context and stacked unit" do
        described_class.new(unit, :label) { current_unit }.invoke(context).should == unit
      end


      context "when context is a view" do
        it "invokes with unit's view path" do
          described_class.new(unit, :label) { path }.invoke(context).should == unit.view_path
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
nyanko-0.0.7 spec/nyanko/function_spec.rb
nyanko-0.0.6 spec/nyanko/function_spec.rb
nyanko-0.0.5 spec/nyanko/function_spec.rb
nyanko-0.0.4 spec/nyanko/function_spec.rb
nyanko-0.0.3 spec/nyanko/function_spec.rb
nyanko-0.0.1 spec/nyanko/function_spec.rb