Sha256: eb7b28e1db930128a65f58b4eb18df445bec65975eff74cbafff4f78a3a006ff

Contents?: true

Size: 897 Bytes

Versions: 2

Compression:

Stored size: 897 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

    let(:options) do
      { :type => :plain }
    end

    describe ".invoke" do
      it "invokes block with given context and stacked unit" do
        described_class.new(unit, :label) { current_unit }.invoke(context, options).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, options).should == unit.view_path
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nyanko-0.0.9 spec/nyanko/function_spec.rb
nyanko-0.0.8 spec/nyanko/function_spec.rb