54 lines
1.6 KiB
Ruby
54 lines
1.6 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.2.4.tar.gz"
|
|
sha256 "c2394a4f5e94cd0a6c8d380085b806e0fa4e52586ea3c888148ad9767ad9ef3b"
|
|
license "Apache-2.0"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "1177ebf6dd5b6507305913a9738c54c842291a2956658fbc73ca682e04a50b21" => :catalina
|
|
end
|
|
|
|
depends_on xcode: ["11.4", :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 var numSetCallCount = 0
|
|
public var num: Int = 0 { didSet { numSetCallCount += 1 } }
|
|
|
|
public 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
|