Sha256: d04035be8e9480900185fd2215e37600decb03ce0893fee1d930202d87b11d91

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

require File.dirname(__FILE__) + '/../lib/sane'
require 'rubygems'
class TestSane; end

describe TestSane do

  before do
    #Object.send(:remove_const, 'Klass') rescue nil
  end

  it "should have working __DIR__" do
    __DIR__.should_not == nil
  end

  it "should write to files" do
   filename = __DIR__ + '/test'
   File.write(filename, "abc\n")
   assert(File.exist?(filename))
   if RUBY_PLATFORM =~ /mswin|mingw/
     assert(File.binread(filename) == "abc\r\n") # it should have written it out *not* in binary mode
   end
   File.delete filename
  end

  class A
    def go; 3; end
    alias_h :go2 => :go
  end

  it "should aliaz right" do
    A.new.go2.should == 3
  end

  it "should have a singleton_class method" do
    class A; end
    A.singleton_class.module_eval { def go; end }
    A.go
  end

  it "should have a binread method" do
    File.open("bin_test", "wb") do |f|; f.write "a\r\n"; end
    assert File.binread("bin_test") == "a\r\n"
  end  

  it "should have a binwrite method" do
   File.binwrite 'bin_test', "a\r\n"
   assert File.binread("bin_test") == "a\r\n"
  end

  it "should hash hashes right" do
    a = {}

    a[{:a => 3, :b => 4}] = 3
    assert a[{:b => 4, :a => 3}] == 3
    assert a[{:b => 3, :a => 4}] == nil
    a = {:a => 3}
    a - {:a => 4}
    assert a.length == 1
 
  end

  it "should allow regexes to be added" do
    /a/ + /b/
  end

  it "should allow for brackets on enumerators" do
    require 'backports' # ugh
    assert "ab\r\nc".lines[0] == "ab\r\n"
  end
 
   
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sane-0.8.0 spec/test_sane.spec