Last active
January 16, 2017 22:36
-
-
Save ian-ellis/2efc12dc2fd1d0260f74fc1d89f6eeab to your computer and use it in GitHub Desktop.
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
package com.theiconic.spockexamples.bag.domain.usecases | |
import com.theiconic.spockexamples.bag.domain.repositories.BagRepository | |
import com.theiconic.spockexamples.bag.domain.usecases.RemoveProductFromBagUseCase | |
import rx.Observable | |
import rx.observers.TestSubscriber | |
import spock.lang.Specification | |
class RemoveProductFromBagUseCaseSpec extends Specification{ | |
protected RemoveProductFromBagUseCase useCase; | |
protected TestSubscriber<Boolean> subscriber; | |
def setup() { | |
useCase = new RemoveProductFromBagUseCase(); | |
useCase.repository = Mock BagRepository; | |
subscriber = new TestSubscriber<>(); | |
} | |
def 'execute() - Removes product from the repository' () { | |
given: | |
def simpleSku = "ABC123"; | |
def out = true; | |
when: | |
useCase.execute(simpleSku).subscribe(subscriber); | |
then: | |
1 * useCase.repository.removeItem(simpleSku) >> Observable.just(out); | |
subscriber.onNextEvents.size() == 1; | |
subscriber.onNextEvents[0] == out; | |
subscriber.assertNoErrors(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment