56 lines
1.7 KiB
Ruby
56 lines
1.7 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.8.tar.gz"
|
|
sha256 "6433c8c5afc2a9d02c4fe6610c59f60e3fcb1783ee6c60b7d1bf1935fc654664"
|
|
license "Apache-2.0"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
rebuild 1
|
|
sha256 "88b19c71e47e5badad6215d49877e65302da8ffd95f4aedb3e793a065106b395" => :big_sur
|
|
sha256 "0cdb833934996a911b08f7eedfa44c1bbf7ebcf50823eb0e8c9a382170ba4bbd" => :catalina
|
|
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
|