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
// tests/support/schemas/user.json | |
{ | |
"$schema": "http://json-schema.org/draft-04/schema#", | |
"title": "User response schema", | |
"type": "object", | |
"properties": { | |
"data": { | |
"type": "object", | |
"properties": { |
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 PlainText | |
class << self | |
def write(&block) | |
return unless block_given? | |
@previous_line = current_line | |
@line = [] | |
@paragraph = [] | |
undefine_methods |
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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
hifi: Ember.inject.service(), | |
actions: { | |
play() { | |
const url = "https://stream.wqxr.org/wqxr"; | |
const mimeType = 'audio/mpeg'; |
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
# This module provides a function to compile city data using the free data | |
# provided on http://download.geonames.org/export/dump. | |
# It uses following files to compile a list of 4.4 mio. cities world-wide, | |
# including their name, state (administrative level 1), country, time zone, | |
# latitude, and longitude: | |
# | |
# * allCountries.txt (included in allCountries.zip) | |
# * countryInfo.txt | |
# * admin1CodesASCII.txt | |
# |
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
def test_get_user(client): | |
# Do whatever is necessary to create a user here… | |
response = client.get('/users/1') | |
json_data = json.loads(response.data) | |
assert 'data' in json_data | |
assert 'type' in json_data['data'] | |
assert 'id' in json_data['data'] | |
assert 'attributes' in json_data['data'] |
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
#!/bin/bash | |
# Erlang | |
ERLANG_VERSION=${ERLANG_VERSION:-20.2} | |
ERLANG_CACHED_DOWNLOAD="${HOME}/cache/OTP-${ERLANG_VERSION}.tar.gz" | |
ERLANG_DIR=${ERLANG_DIR:="$HOME/erlang"} | |
# Elixir | |
ELIXIR_VERSION=${ELIXIR_VERSION:-1.6.3} | |
ELIXIR_CACHED_DOWNLOAD="${HOME}/cache/elixir-v${ELIXIR_VERSION}.zip" |
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
# tests/test_users.py | |
import json | |
from .support.assertions import assert_valid_schema | |
def test_get_user(client): | |
# Do whatever is necessary to create a user here… | |
response = client.get('/users/1') |
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
{ | |
"data": { | |
"type": "users", | |
"id": 1, | |
"attributes": { | |
"email": "paul@grammofy.com", | |
"username": "paul" | |
} | |
} | |
} |
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
# tests/support/assertions.py | |
import json | |
from os.path import join, dirname | |
from jsonschema import validate | |
def assert_valid_schema(data, schema_file): | |
""" Checks whether the given data matches the schema """ |
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
assert_valid_schema(json_data, 'user.json') |
NewerOlder