Sha256: ae751a1ce45a15b827abd0a78d6d95b8d87d65b3bececddf916433b2b177f8ad

Contents?: true

Size: 739 Bytes

Versions: 7

Compression:

Stored size: 739 Bytes

Contents

require 'spec_helper'

describe 'H notation' do
  context 'if H is already defined' do
    before do
      @old_H = Object.send(:remove_const, :H)
      @old_stderr, $stderr = $stderr, StringIO.new
      ::H = 'foo'.freeze
    end

    after do
      Object.send(:remove_const, :H)
      $stderr = @old_stderr
      ::H = @old_H
    end

    it 'should not override H' do
      expect(H).to eq('foo')
    end

    it 'should print out a warning on STDERR' do
      load 'hexp/h.rb'
      expect($stderr.string).to match(/WARN/)
    end

  end

  context 'if H is not set yet' do
    before do
      Object.send(:remove_const, :H)
    end

    it 'should define H' do
      load 'hexp/h.rb'
      expect(H).to be_a Module
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hexp-0.4.6 spec/unit/hexp/h_spec.rb
hexp-0.4.5 spec/unit/hexp/h_spec.rb
hexp-0.4.4 spec/unit/hexp/h_spec.rb
hexp-0.4.3 spec/unit/hexp/h_spec.rb
hexp-0.4.2 spec/unit/hexp/h_spec.rb
hexp-0.4.1 spec/unit/hexp/h_spec.rb
hexp-0.4.0.beta1 spec/unit/hexp/h_spec.rb