Sha256: 1697ec6e89f654280ae56dd72d961600fe33158a08bec17ace9e311323e99307

Contents?: true

Size: 811 Bytes

Versions: 1

Compression:

Stored size: 811 Bytes

Contents

require 'spec_helper'
module WLang
  describe Scope, ".coerce" do

    it 'recognizes Binding' do
      Scope.coerce(binding).should be_a(Scope::BindingScope)
    end

    it 'recognizes Procs' do
      Scope.coerce(lambda{}).should be_a(Scope::ProcScope)
    end

    it 'falls back to ObjectScope on Hash' do
      Scope.coerce({}).should be_a(Scope::ObjectScope)
    end

    it 'falls back to ObjectScope' do
      Scope.coerce(12).should be_a(Scope::ObjectScope)
    end

    it 'returns the Scope if nothing has to be done' do
      Scope.coerce(Scope.null).should eq(Scope.null)
      s = Scope.coerce({})
      Scope.coerce(s).should eq(s)
    end

    it 'returns the Scope on a Scope' do
      s = Scope.coerce({})
      Scope.coerce(s).should eq(s)
    end

  end # describe Scope
end # module WLang

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wlang-3.0.0 spec/unit/scope/test_coerce.rb