File: warnings_test.rb

package info (click to toggle)
ruby-bindata 2.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 652 kB
  • sloc: ruby: 8,896; makefile: 4
file content (41 lines) | stat: -rwxr-xr-x 971 bytes parent folder | download
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
#!/usr/bin/env ruby

require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))

describe BinData::Base, "when defining" do
  it "fails if #initialize is overridden" do
    class BaseWithInitialize < BinData::Base
      def initialize(params = {}, parent = nil)
        super
      end
    end

    _ {
      BaseWithInitialize.new
    }.must_raise RuntimeError
  end

  it "fails if #initialize is overridden on BasePrimitive" do
    class BasePrimitiveWithInitialize < BinData::String
      def initialize(params = {}, parent = nil)
        super
      end
    end

    _ {
      BasePrimitiveWithInitialize.new
    }.must_raise RuntimeError
  end

  it "handles if #initialize is naively renamed to #initialize_instance" do
    class BaseWithInitializeInstance < BinData::Base
      def initialize_instance(params = {}, parent = nil)
        super
      end
    end

    _ {
      BaseWithInitializeInstance.new
    }.must_raise RuntimeError
  end
end