require File.expand_path('test_helper.rb', File.dirname(__FILE__))

class GtkOverridesTest < MiniTest::Spec
  setup do
    @gtk = Module.new do
      def self.init arr
        ["baz", "qux", "zonk"]
      end
    end
    # FIXME: Too-complex stubbing because of violation of Law of Demeter.
    stub(@builder = Object.new).setup_function {}
    stub(@gtk).gir_ffi_builder { @builder }
    @gtk.instance_eval do
      include GirFFI::Overrides::Gtk
    end
  end

  context "The .init function" do
    should "not take any arguments" do
      assert_raises(ArgumentError) { @gtk.init 1, ["foo"] }
      assert_raises(ArgumentError) { @gtk.init ["foo"] }
      assert_nothing_raised { @gtk.init }
    end

    should "replace ARGV with the tail of the result of the original init function" do
      ARGV.replace ["foo", "bar"]
      @gtk.init
      assert_equal ["qux", "zonk"], ARGV.to_a
    end
  end
end


require File.expand_path('test_helper.rb', File.dirname(__FILE__))
require 'gir_ffi/overrides/gtk'

class GtkOverridesTest < MiniTest::Spec
  setup do
    @gtk = Module.new do
      def self.init arr
        ["baz", "qux", "zonk"]
      end
    end
    # FIXME: Too-complex stubbing because of violation of Law of Demeter.
    stub(@builder = Object.new).setup_function {}
    stub(@gtk).gir_ffi_builder { @builder }
    @gtk.instance_eval do
      include GirFFI::Overrides::Gtk
    end
  end

  context "The .init function" do
    should "not take any arguments" do
      assert_raises(ArgumentError) { @gtk.init 1, ["foo"] }
      assert_raises(ArgumentError) { @gtk.init ["foo"] }
      assert_nothing_raised { @gtk.init }
    end

    should "replace ARGV with the tail of the result of the original init function" do
      ARGV.replace ["foo", "bar"]
      @gtk.init
      assert_equal ["qux", "zonk"], ARGV.to_a
    end
  end
end


Make sure overrides file for Gtk has been required in tests.
Make sure overrides file for Gtk has been required in tests.
