Skip to content

Instantly share code, notes, and snippets.

View hmayer00's full-sized avatar

Henry Mayer hmayer00

  • Curious.com
  • SF Bay Area
View GitHub Profile
@hmayer00
hmayer00 / observable_set_view.dart
Created February 18, 2020 21:02
ObservableSetViews for filtering and sorting ObservableSets
import 'package:collection/collection.dart';
import 'package:mobx/mobx.dart';
typedef FilterPredicate<T> = bool Function(T element);
/// An unmodifiable but observable view of an ObservableSet.
///
/// This just delegates reads and observations to the [sourceSet].
class ObservableSetView<E> extends UnmodifiableSetView<E> implements ObservableSet<E> {
ObservableSetView(ObservableSet<E> sourceSet)
@hmayer00
hmayer00 / any_instance_should_receive_with_spec.rb
Last active January 4, 2016 10:39
Demonstrating problems with any_instance.should_receive().with corrupting subsequent tests
require 'spec_helper'
# These specs demonstrate that any_instance.should_receive().with will break subsequent specs if
# the message is received without the expected argument
describe "should_receive corruption", :focus do
class Foo
def bar(options = {})
end
# The base is stolen from @gist: https://gist.github.com/gr2m/2191748, and then substantially modified.
beforeEach ->
@addMatchers
toBePromise: ->
@actual.done && !@actual.resolve
toBeRejected: ->
@actual.state() == "rejected"
toBeResolved: ->
@actual.state() == "resolved"
toBeResolvedWith: ->