Sha256: bec6a61af352f688960134c4c31f61fe3ed98aa421670ab0b4d802848bab0bed

Contents?: true

Size: 1009 Bytes

Versions: 7

Compression:

Stored size: 1009 Bytes

Contents

require 'spec_helper'

describe Parslet::Scope do
  let(:scope) { described_class.new }
  
  describe 'simple store/retrieve' do
    before(:each) { scope[:foo] = :bar }
    it "allows storing objects" do
      scope[:obj] = 42
    end 
    it "raises on access of empty slots" do
      expect {
        scope[:empty]
      }.to raise_error(Parslet::Scope::NotFound)
    end 
    it "allows retrieval of stored values" do
      scope[:foo].should == :bar
    end 
  end
  
  describe 'scoping' do
    before(:each) { scope[:depth] = 1 }
    before(:each) { scope.push }
    
    let(:depth) { scope[:depth] }
    subject { depth }
    
    it { should == 1 }
    describe 'after a push' do
      before(:each) { scope.push }
      it { should == 1 }
      
      describe 'and reassign' do
        before(:each) { scope[:depth] = 2 }
        
        it { should == 2 }

        describe 'and a pop' do
          before(:each) { scope.pop }
          it { should == 1 }
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
parslet-2.0.0 spec/parslet/scope_spec.rb
parslet-1.8.2 spec/parslet/scope_spec.rb
parslet-1.8.1 spec/parslet/scope_spec.rb
parslet-1.8.0 spec/parslet/scope_spec.rb
swift-pyrite-0.1.1 vendor/bundle/ruby/2.0.0/gems/parslet-1.7.1/spec/parslet/scope_spec.rb
swift-pyrite-0.1.0 vendor/bundle/ruby/2.0.0/gems/parslet-1.7.1/spec/parslet/scope_spec.rb
parslet-1.7.1 spec/parslet/scope_spec.rb