Sha256: 6ac6253d2124bc229fb1b40551354b10dd56ed3932cf8a68d979ef738865b3cf

Contents?: true

Size: 998 Bytes

Versions: 1

Compression:

Stored size: 998 Bytes

Contents

require 'spec_helper'

describe AssemblyLine::GlobalContext do
  let(:global_context) { AssemblyLine::GlobalContext }
  after { global_context.clear }

  describe "#let" do
    it "defines the method within AssemblyLine::GlobalContext" do
      global_context.let(:foobarish) { :bar }
      global_context.foobarish.should == :bar
    end

    it "memoizes the defined method" do
      global_context.instance_variable_set(:@count, 0)
      global_context.let(:my_count) { @count += 1 }
      5.times { global_context.my_count }
      global_context.my_count.should == 1
    end

    it "tells Kernel to delegate this method to AssemblyLine::GlobalContext" do
      global_context.let(:global_method) { :global }
      Kernel.global_method.should == :global
    end
  end

  describe "#before" do
    it "runs the code block" do
      expect do
        global_context.before { @done = true }
      end.to change { global_context.instance_variable_get(:@done) }.from(nil).to(true)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
assembly_line-0.2.0 spec/assembly_line/global_context_spec.rb