This file contains 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
document.querySelectorAll('#rsvp-list .member-name > a').forEach(node => console.log(node.textContent.trim())) |
This file contains 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
case HTTPoison.get(url, headers) do | |
{:ok, %HTTPoison.Response{status_code: 200, body: body}} -> | |
case Poison.decode(body) do | |
{:ok, decoded} -> {:ok, decoded} | |
{:error, error} -> {:error, error} | |
end | |
{:ok, %HTTPoison.Response{status_code: status_code}} -> | |
{:error, status_code} |
This file contains 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
class Service | |
def initialize(dependency) | |
@dependency = dependency | |
end | |
def exec() | |
{ | |
success: true, | |
data: @dependency.call() | |
} |
This file contains 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
describe 'service object' do | |
let(:data) { { a: 1, b: 2 } } | |
let(:dependency) { double() } | |
before do | |
allow(dependency).to receive(:call).and_return(data) | |
end | |
it 'wraps data from dependency into a hash' do | |
result = Service.new(dependency).exec() |
This file contains 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
class Service | |
def exec() | |
{ | |
success: true, | |
data: @dependency.call().merge!(hello: 'world') | |
} | |
end | |
end |
This file contains 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
func (c *Client) HGetAll(key string) *StringStringMapCmd {} | |
func (c *Client) HMSet(key string, fields map[string]interface{}) *StatusCmd {} |
This file contains 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
func (cmd *StringStringMapCmd) Result() (map[string]string, error) { | |
return cmd.val, cmd.err | |
} |
This file contains 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
type RedisProxy interface { | |
HGetAll(string) (map[string]string, error) | |
HMSet(string, map[string]interface{}) (string, error) | |
} |
This file contains 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
package main | |
import ( | |
"testing" | |
"github.com/stretchr/testify/assert" | |
) | |
type stubRedis struct { | |
data map[string]string | |
err error |
This file contains 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
func TestFetchAccountWhenAccountExists(t *testing.T) { | |
repository := createRepositoryWithData(fakeData) | |
account, err := repository.FetchAccount(id) | |
assert.Equal(t, id, account.Id) | |
assert.Equal(t, "John Doe", account.Name) | |
assert.Equal(t, 100, account.Balance) | |
assert.Nil(t, err) | |
} |
OlderNewer