Skip to content

Instantly share code, notes, and snippets.

@justincampbell
Created February 5, 2014 14:14
Show Gist options
  • Save justincampbell/8824417 to your computer and use it in GitHub Desktop.
Save justincampbell/8824417 to your computer and use it in GitHub Desktop.
def tap_pin(pin)
set_pin(pin, :on)
set_pin_in(pin, :off, 0.25)
end
def set_pin(pin, state)
return if read_pin(pin) == state
pin.send(state)
end
def set_pin_in(pin, state, seconds)
Thread.new {
sleep seconds
set_pin pin, state
}
end
it "defines an open_close method that taps the pin" do
pin = runner.pins[:open_close]
expect(pin).to receive(:on)
expect(runner).to receive(:set_pin_in).with(pin, :off, 0.25)
runner.open_close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment