Created
February 5, 2014 14:14
-
-
Save justincampbell/8824417 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
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 |
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
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