@Test
public void containsStream_emitsOnListenerUpdate() {

    final String testKey = "Test contains key";
    when(mockSharedPreferences.contains(testKey)).thenReturn(true);
    final TestObserver<Boolean> subscription = rxPreferences.containsStream(testKey).test();
    subscriptions.add(subscription);
    subscription
            .assertNotComplete()
            .assertValueCount(1)
            .assertValue(true);
    final ArgumentCaptor<SharedPreferences.OnSharedPreferenceChangeListener> listenerCaptor =
            ArgumentCaptor.forClass(SharedPreferences.OnSharedPreferenceChangeListener.class);
    verify(mockSharedPreferences).registerOnSharedPreferenceChangeListener(listenerCaptor.capture());
    final SharedPreferences.OnSharedPreferenceChangeListener listener = listenerCaptor.getValue();
    listener.onSharedPreferenceChanged(mockSharedPreferences, testKey);
    subscription
            .assertNotComplete()
            .assertValueCount(2)
            .assertValues(true, true);
}