Sha256: bd4a98e72acf9a77e77ff1d54108b6bf05dd7111f5407b86a5c973cb4f04ca37

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'
require 'stringio'

describe Less::Loader do
  
  describe 'eval console.log()' do
    
    it 'should write message to $stdout' do
      stdout = $stdout; io_stub = StringIO.new
      begin
        $stdout = io_stub
        subject.environment.runtime.eval("console.log('log much?');")
      ensure
        $stdout = stdout
      end
      io_stub.string.should == "log much?\n"
    end
    
    it 'should write messages to $stdout' do
      stdout = $stdout; io_stub = StringIO.new
      begin
        $stdout = io_stub
        subject.environment.runtime.eval("console.log('1','2','3');")
      ensure
        $stdout = stdout
      end
      io_stub.string.should == "1, 2, 3\n"
    end
    
  end

  describe 'eval process.exit()' do
    
    process = Less::Loader::Process
    
    it 'should not raise an error' do
      # process = double("process")
      process.any_instance.should_receive(:warn) do |msg| 
        msg.should match(/JS process\.exit\(-2\)/)
      end
      subject.environment.runtime.eval("process.exit(-2);")
    end
    
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
less-2.3.2 spec/less/loader_spec.rb