Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Shoegaze doesn't support mock a class with argumented initializer #3

Open
@zozowell

Description

What is problem I'd like to solve?

For class with argumented initializer, shoegaze doesn't mock class initialize function, then instantiation like FakeClass.proxy.new(args) fails with following error:

  1) FakeTest works with customized initializer in shoegaze
     Failure/Error: subject { FakeTest.proxy.new("dummy") }

     ArgumentError:
       wrong number of arguments (given 1, expected 0)

How to reproduce

class TestClass
  def initialize(dummy)
  end
end

class FakeTest < Shoegaze::Mock
  mock "TestClass"

  implement_instance_method :initialize do
    default do
      datasource do |*arg|
        "instance method implementation doesn't help, \
        because `missing_method` wasn't hit at all."
      end
    end
  end
end

describe FakeTest do
  subject { FakeTest.proxy.new("dummy") }
  
  it "works with customized initializer in shoegaze" do
    expect(subject).to be_kind_of Shoegaze::Proxy::Template
  end
end

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions