55 lines
1.8 KiB
Ruby
55 lines
1.8 KiB
Ruby
class Mockolo < Formula
|
|
desc "Efficient Mock Generator for Swift"
|
|
homepage "https://github.com/uber/mockolo"
|
|
url "https://github.com/uber/mockolo/archive/1.3.1.tar.gz"
|
|
sha256 "9afa5c6567f1d7e87b5c2050a5443cb6bcefcf987e6b5c1c71a55d20ebe29fa4"
|
|
license "Apache-2.0"
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "47f35d16bdf3668a7edecae8f9e30ee1174b8156df4445d34eb7d3c29e8fbdbc"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "8a8a5729fab962a71e80ddac64068995afc5aad06a6b4092a55c68a0779f8f8a"
|
|
sha256 cellar: :any_skip_relocation, catalina: "dfb579cf2d36c941b2192dcef4a652cec11a71ede37cb873084db860e6c68192"
|
|
end
|
|
|
|
depends_on xcode: ["12.0", :build]
|
|
|
|
def install
|
|
system "swift", "build", "-c", "release", "--disable-sandbox"
|
|
bin.install ".build/release/mockolo"
|
|
end
|
|
|
|
test do
|
|
(testpath/"testfile.swift").write("
|
|
/// @mockable
|
|
public protocol Foo {
|
|
var num: Int { get set }
|
|
func bar(arg: Float) -> String
|
|
}")
|
|
system "#{bin}/mockolo", "-srcs", testpath/"testfile.swift", "-d", testpath/"GeneratedMocks.swift"
|
|
assert_predicate testpath/"GeneratedMocks.swift", :exist?
|
|
assert_equal "
|
|
///
|
|
/// @Generated by Mockolo
|
|
///
|
|
public class FooMock: Foo {
|
|
public init() { }
|
|
public init(num: Int = 0) {
|
|
self.num = num
|
|
}
|
|
|
|
public private(set) var numSetCallCount = 0
|
|
public var num: Int = 0 { didSet { numSetCallCount += 1 } }
|
|
|
|
public private(set) var barCallCount = 0
|
|
public var barHandler: ((Float) -> (String))?
|
|
public func bar(arg: Float) -> String {
|
|
barCallCount += 1
|
|
if let barHandler = barHandler {
|
|
return barHandler(arg)
|
|
}
|
|
return \"\"
|
|
}
|
|
}".gsub(/\s+/, "").strip, shell_output("cat #{testpath/"GeneratedMocks.swift"}").gsub(/\s+/, "").strip
|
|
end
|
|
end
|