File: warnings_test.rb

package info (click to toggle)
ruby-bindata 2.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 568 kB
  • ctags: 932
  • sloc: ruby: 8,146; makefile: 3
file content (29 lines) | stat: -rwxr-xr-x 699 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
#!/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

    lambda {
      BaseWithInitialize.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

    lambda {
      BaseWithInitializeInstance.new
    }.must_raise RuntimeError
  end
end