Skip to content

Instantly share code, notes, and snippets.

View ilyapuchka's full-sized avatar

Ilya Puchka ilyapuchka

View GitHub Profile
@ilyapuchka
ilyapuchka / Assert.swift
Created November 12, 2017 18:46
AssertThrow
func AssertNoThrow<T>(_ expression: @autoclosure () throws -> T, file: StaticString = #file, line: UInt = #line) rethrows -> T {
do {
return try expression()
} catch {
XCTFail("\(error)", file: file, line: line)
throw error
}
}
func returnSomethingOrThrow() throws -> Int { ... }
@ilyapuchka
ilyapuchka / create_xcode_snippets.rb
Last active September 9, 2018 15:10
Generate Xcode snippets from XCTest_Gherkin step definitions
#!/usr/bin/env ruby
# Usage:
# chmod 755 create_xcode_snippets.rb
# ./create_xcode_snippets.rb --project_path "path-to-project-file.xcodeproj"
require 'xcodeproj'
$project_path = File.expand_path(ARGV.find.with_index { |item, index| ARGV[index - 1] == "--project_path" })
$snippets_path = File.expand_path("~/Library/Developer/Xcode/UserData/CodeSnippets/")
$snippet_prefix = "STEP-"
@ilyapuchka
ilyapuchka / Stringify.swift
Created June 16, 2019 13:02
FunctionBuilders
func stringify(@StringBuilder _ value: () -> Stringified) {
print(value().value)
}
struct Stringified {
let value: String
init(_ value: String) {
self.value = "stringified " + value
}
}
import Foundation
public struct Unit: Codable, Equatable {
init() {}
public init(from decoder: Decoder) {}
public func encode(to encoder: Encoder) throws {}
public static func ==(lhs: Self, rhs: Self) -> Bool {
return true
}
}