File: spec_helper.rb

package info (click to toggle)
ruby-cbor 0.5.10.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 428 kB
  • sloc: ansic: 3,464; ruby: 1,732; makefile: 4
file content (68 lines) | stat: -rw-r--r-- 1,220 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
require 'rubygems'              # for 1.8

RSpec.configure do |config|
  config.expect_with :rspec do |c|
    c.syntax = [:should, :expect]
  end
  config.mock_with :rspec do |c|
    c.syntax = [:should, :expect]
  end
end


class String
  if ''.respond_to? :encode
    def encode_as_utf8
      encode(Encoding::UTF_8)
    end
    def force_as_utf8
      force_encoding(Encoding::UTF_8)
    end
    unless String.instance_methods.include?(:b)
      def b
        dup.force_encoding(Encoding::BINARY)
      end
    end
  else
    def encode_as_utf8
      self                      # MRI 1.8
    end
    def force_as_utf8
      self                      # MRI 1.8
    end
    def b
      self
    end
  end
  unless ''.respond_to? :clear
    def clear
      replace('')
    end
  end
  def hexbytes(sep = '')
    bytes.map{|x| "%02x" % x}.join(sep)
  end
end

if ENV['SIMPLE_COV']
  require 'simplecov'
  SimpleCov.start do
    add_filter 'spec/'
    add_filter 'pkg/'
    add_filter 'vendor/'
  end
end

if ENV['GC_STRESS']
  puts "enable GC.stress"
  GC.stress = true
end

require 'cbor'

MessagePack = CBOR              # XXX

Packer = MessagePack::Packer
Unpacker = MessagePack::Unpacker
Buffer = MessagePack::Buffer