Sha256: 2cfb9bcf0b7f6ead2b49d4fc62359a95818ccea5f308b5538c64dfadf31106c0

Contents?: true

Size: 987 Bytes

Versions: 1

Compression:

Stored size: 987 Bytes

Contents

require 'spec_helper'

describe AssemblyLine::GenericContext do
  let(:generic_context) { AssemblyLine.generic_context }

  after { generic_context.clear }

  describe "#let" do
    it "defines the method on the GenericContext instance" do
      generic_context.let(:foobarish) { :bar }
      generic_context.foobarish.should == :bar
    end

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

    it "adds a delegating method to AssemblyLine" do
      generic_context.let(:global_method) { :global }
      AssemblyLine.global_method.should == :global
    end
  end

  describe "#before" do
    it "runs the code block" do
      expect do
        generic_context.before { @done = true }
      end.to change { generic_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.1 spec/assembly_line/generic_context_spec.rb