I hereby claim:
- I am purinkle on github.
- I am purinkle (https://keybase.io/purinkle) on keybase.
- I have a public key ASCBX3cSW4htVNVeUi0VEq9n7Tce3B80eYBLIxlsUGibawo
To claim this, I am signing this object:
# -*- encoding: utf-8 -*- | |
# Keyboard: Sample Bot | |
# | |
# Special bot controlled with the keyboard | |
# | |
# Controls: | |
# w drive forward | |
# s drive backwards | |
# a rotate left | |
# d rotate right |
class ProductCreationResponder | |
@@responders = [] | |
def self.build(product) | |
responders.detect do |responder| | |
responder.applicable_to?(product) | |
end.new(product) | |
end | |
def self.register(responder) |
// appointments/actions.js | |
const doFetchedAppointmentQuestionnaires = (appointmentId, questionnaires) => ({ | |
type: types.APPOINTMENT_QUESTIONNAIRES_FETCHED, | |
payload: { appointmentId, questionnaires }, | |
}); | |
const handleFetchQuestionnaires(appointmentId) = () => async dispatch => { | |
const questionnaires = await PatientApi.getQuestionnaires(appointmentId); | |
dispatch(doFetchedQuestionnaires(appointmentId, questionnaires)); |
I hereby claim:
To claim this, I am signing this object:
class Job | |
attr_reader :dependency, :name | |
def initialize(spec) | |
@name, @dependency = spec.split('=>').map(&:strip) | |
if @name == @dependency | |
raise ArgumentError | |
end | |
end |
When writing code that depends on another class, we sometimes like to stub out the dependency. This can result in test examples that are hard to read and full of details that aren't relevant to the actual test.
it "does something" do
dependency = double(:dependency)
allow(dependency).to receive(:foo).with(:bar).and_return(:baz)
allow(Dependency).to receive(:new).and_return(dependency)
RSpec has many fantastic built-in matchers. One of my favourites is the [predicate matcher][1]. Not only does this matcher help make my tests more readable, but it also helps me design the name of my method.
You might decide to have a method like the following.
class SomeClass
require "net/http" | |
class HttpWrapper | |
def post(url, body, headers) | |
Net::HTTP.post(URI.parse(url), body, headers) | |
end | |
end | |
url = "https://example.com/path" | |
body = {TEST_KEY: "TEST_VALUE"} |