Sha256: d7a8282ebe9cabfd61638026baf5a35632c8e810c8b044bfc20046d5eff72a1c

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'

module Skeptic
  describe Scope do
    it "contains levels of nesting" do
      Scope.new(nil, nil, [:for, :if]).levels.should eq [:for, :if]
      Scope.new(nil, nil, []).levels.should eq []
      Scope.new.levels.should eq []
    end

    it "can be compared to another scope" do
      Scope.new(nil, nil, [:for, :if]).should eq Scope.new(nil, nil, [:for, :if])
      Scope.new(nil, nil, []).should_not eq Scope.new(nil, nil, [:if])
      Scope.new('Bar', nil).should_not eq Scope.new('Foo', nil)
      Scope.new(nil, 'bar').should_not eq Scope.new(nil, 'foo')
    end

    it "can be extended and unextended" do
      Scope.new.push(:if).should eq Scope.new(nil, nil, [:if])
      Scope.new(nil, nil, [:for, :if]).pop.should eq Scope.new(nil, nil, [:for])

      Scope.new.in_class('Foo').should eq Scope.new('Foo')
      Scope.new.in_method('bar').should eq Scope.new(nil, 'bar')
    end

    it "can tell its depth" do
      Scope.new(nil, nil, [:for]).depth.should eq 1
      Scope.new(nil, nil, [:for, :if]).depth.should eq 2
      Scope.new(nil, nil, [:for, :if, :if]).depth.should eq 3
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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