Skip to content

Instantly share code, notes, and snippets.

Avatar

Jarosław rozkminiacz

View GitHub Profile
View data.json
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
@rozkminiacz
rozkminiacz / google directions api response
Created Feb 23, 2018
google directions api response
View google directions api response
{
"geocoded_waypoints" : [
{
"geocoder_status" : "OK",
"place_id" : "EilLcm93b2RlcnNrYSAxMC0xNCwgMzEtMTQxIEtyYWvDs3csIFBvbHNrYQ",
"types" : [ "street_address" ]
},
{
"geocoder_status" : "OK",
"place_id" : "EiNwbGFjIE5vd3kgNCwgMzMtMzMyIEtyYWvDs3csIFBvbHNrYQ",
View spek-test-example.kt
on("presenter detach"){
presenter.detach()
it("should dispose observables"){
//
}
}
@rozkminiacz
rozkminiacz / PeopleListContract.kt
Created Mar 12, 2018
Model View Presenter Writing Spek Specification - gists for blog post
View PeopleListContract.kt
interface PeopleListContract {
interface View {
fun addPeople(people: List<Person>)
fun showError(throwable: Throwable = Throwable())
fun showLoading()
fun hideLoading()
}
interface Presenter {
fun attach(view: View)
View build.gradle
dependencies {
(...)
testImplementation unitTestDependencies.values()
testImplementation spekDependencies.values()
testImplementation kotlinTestDependencies.values()
}
View PeopleListContract.kt
interface PeopleListContract {
interface View {
fun addPeople(people: List<Person>)
fun showError(throwable: Throwable = Throwable())
fun showLoading()
fun hideLoading()
}
interface Presenter {
fun attach(view: View)
View PeopleListPresenter#impl.kt
class PeopleListPresenter(private val repository: Repository<Person>) : PeopleListContract.Presenter {
var view: PeopleListContract.View? = null
override fun attach(view: PeopleListContract.View) {
this.view = view
loadPeople()
}
private fun loadPeople() {
View testDependencies.gradle
ext {
def JunitVersion = '4.12'
def KotlinMockitoVersion = '1.5.0'
def SpekVersion = "1.1.5"
unitTestDependencies = [
junit : "junit:junit:${JunitVersion}",
]
View build.gradle#module
dependencies {
(...)
testImplementation unitTestDependencies.values()
testImplementation spekDependencies.values()
testImplementation kotlinTestDependencies.values()
}
View PeopleListTest#start.kt
import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.*
import org.junit.platform.runner.JUnitPlatform
import com.nhaarman.mockito_kotlin.*
import org.junit.runner.RunWith
@RunWith(JUnitPlatform::class)
object PeopleListTest : Spek({
given("people exists in repository"){
val view: PeopleListContract.View = mock()