Sha256: dab60c8b5a0503cd5b64b4f3ea3f011fc18aab21cda14475d1119009f843fbd2

Contents?: true

Size: 939 Bytes

Versions: 1

Compression:

Stored size: 939 Bytes

Contents

require 'spec_helper'

module Skeptic
  describe Environment do
    let(:env) { Environment.new }

    it "maps names to objects" do
      env[:foo] = 42
      env[:foo].should eq 42
    end

    it "returns nil for names that are not set" do
      env[:foo].should be_nil
    end

    it "allows environments to be extender" do
      env.push foo: 2
      env[:foo].should eq 2
    end

    it "allows environments to be unextended" do
      env[:foo] = 1
      env.push foo: 2
      env.pop
      env[:foo].should eq 1
    end

    it "looks up undefined names in the closure" do
      env[:foo] = 1
      env.push
      env[:foo].should eq 1
    end

    it "can be extended for a block" do
      executed_block = false

      env[:foo] = 1
      env.scoped do
        env[:foo] = 2
        env[:foo].should eq 2
        executed_block = true
      end

      executed_block.should be_true
      env[:foo].should eq 1
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
skeptic-0.0.0 spec/skeptic/environment_spec.rb