Created
January 13, 2017 05:04
-
-
Save laiso/3169c66a58143bb15846f797b2b65c94 to your computer and use it in GitHub Desktop.
こんなかんじ・・? #CodePiece
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Charge { | |
static var stubObjects: [Charge] { | |
let JSON = json(from: "Fixtures/charges.json") | |
return try! decodeArray(JSON, rootKeyPath: "data") | |
} | |
} | |
struct MockWebAPI: HomeAPIProtocol { | |
func getCharges() -> Observable<[Charge]> { | |
return Observable.from(Charge.stubObjects) | |
} | |
} | |
class HomeViewModelSpec: QuickSpec { | |
override func spec() { | |
describe("HomeViewModel") { | |
var viewModel: HomeViewModel! | |
beforeEach { | |
let api = MockWebAPI() | |
viewModel = HomeViewModel(with: api) | |
} | |
describe("#charges") { | |
context("initial value") { | |
var charges: [Charge]! | |
beforeEach { | |
charges = viewModel.charges.value | |
} | |
it("should be equal stubing") { | |
let stub = Charge.stubObjects | |
expect(charges).to(equal(stub)) | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment