-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
182 additions
and
64 deletions.
There are no files selected for viewing
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 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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module UncleClive | ||
describe App do | ||
context 'HTML' do | ||
specify 'single line' do | ||
get '/html' | ||
expect(last_response).to be_ok | ||
expect(last_response.body).to match /<tr><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><\/tr>/ | ||
end | ||
|
||
specify 'multi-line' do | ||
get '/ab---cd' | ||
expect(last_response).to be_ok | ||
expect(last_response.body.split("\n").count).to eq 81 | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
module UncleClive | ||
JSON_HEADERS = { 'HTTP_ACCEPT' => 'application/json' } | ||
|
||
describe App do | ||
context 'JSON' do | ||
specify 'single line' do | ||
get '/json', nil, JSON_HEADERS | ||
expect(last_response).to be_ok | ||
expect(JSON.parse last_response.body).to eq ( | ||
{ | ||
'id' => 'json', | ||
'data' => [ | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0], | ||
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0], | ||
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0], | ||
[0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0], | ||
[0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] | ||
} | ||
) | ||
end | ||
|
||
specify 'multi-line' do | ||
get '/ab---cd', nil, JSON_HEADERS | ||
expect(last_response).to be_ok | ||
expect(JSON.parse last_response.body).to eq ( | ||
{ | ||
'id' => "[ab, cd]", | ||
'data' => [ | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], | ||
[0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0], | ||
[0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0], | ||
[0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0], | ||
[0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], | ||
[0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], | ||
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0], | ||
[0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0], | ||
[0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0], | ||
[0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] | ||
] | ||
} | ||
) | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module UncleClive | ||
SVG_HEADERS = { 'HTTP_ACCEPT' => 'image/svg+xml' } | ||
|
||
describe App do | ||
context 'SVG' do | ||
context 'single line' do | ||
it 'serves SVG' do | ||
get '/svg', nil, SVG_HEADERS | ||
expect(last_response).to be_ok | ||
expect(last_response.body.split("\n")[9]).to eq " <rect x='2' y='2' width='3' height='1' class='on' />" | ||
end | ||
|
||
it 'changes the colour' do | ||
get '/svg?colour=fa8100', nil, SVG_HEADERS | ||
expect(last_response).to be_ok | ||
expect(last_response.body.split("\n")[4]).to eq " fill: #fa8100;" | ||
end | ||
end | ||
|
||
context 'multi-line' do | ||
it 'serves SVG' do | ||
get '/ab---cd', nil, SVG_HEADERS | ||
expect(last_response).to be_ok | ||
lines = last_response.body.split("\n") | ||
expect(lines[0]).to eq"<svg viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'>" | ||
expect((lines).count).to eq 38 | ||
end | ||
|
||
it 'changes the colour' do | ||
get '/ab---cd?colour=abcdef', nil, SVG_HEADERS | ||
expect(last_response).to be_ok | ||
expect(last_response.body.split("\n")[4]).to eq " fill: #abcdef;" | ||
end | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module UncleClive | ||
TEXT_HEADERS = { 'HTTP_ACCEPT' => 'text/plain' } | ||
|
||
describe App do | ||
context 'text' do | ||
specify 'single line' do | ||
get '/text', nil, TEXT_HEADERS | ||
expect(last_response).to be_ok | ||
expect(last_response.body.split("\n")[2]).to eq " ()()() ()()() () () ()()() " | ||
end | ||
|
||
specify 'multi-line' do | ||
get 'ab---cd', nil, TEXT_HEADERS | ||
expect(last_response).to be_ok | ||
expect(last_response.body.split("\n").count).to eq 16 | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,37 @@ | ||
module UncleClive | ||
JSON_HEADERS = { 'HTTP_ACCEPT' => 'application/json' } | ||
TEXT_HEADERS = { 'HTTP_ACCEPT' => 'text/plain' } | ||
SVG_HEADERS = { 'HTTP_ACCEPT' => 'image/svg+xml' } | ||
|
||
describe App do | ||
it 'has a homepage' do | ||
get '/' | ||
expect(last_response).to be_ok | ||
expect(last_response.body).to match /Sinclair Spectrum Font as a Service/ | ||
end | ||
|
||
context 'spectrum font' do | ||
it 'serves JSON' do | ||
get '/json', nil, JSON_HEADERS | ||
expect(last_response).to be_ok | ||
expect(JSON.parse last_response.body).to eq ( | ||
{ | ||
'id' => 'json', | ||
'data' => [ | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0], | ||
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0], | ||
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0], | ||
[0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0], | ||
[0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] | ||
} | ||
) | ||
end | ||
|
||
it 'serves HTML' do | ||
get '/html' | ||
expect(last_response).to be_ok | ||
expect(last_response.body).to match /<tr><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><td class='off'> <\/td><\/tr>/ | ||
end | ||
|
||
it 'serves text' do | ||
get '/text', nil, TEXT_HEADERS | ||
expect(last_response).to be_ok | ||
expect(last_response.body.split("\n")[2]).to eq " ()()() ()()() () () ()()() " | ||
end | ||
|
||
context 'SVG' do | ||
it 'serves SVG' do | ||
get '/svg', nil, SVG_HEADERS | ||
expect(last_response).to be_ok | ||
expect(last_response.body.split("\n")[9]).to eq "<rect x='2' y='2' width='3' height='1' class='on' />" | ||
end | ||
|
||
it 'changes the colour' do | ||
get '/svg?colour=fa8100', nil, SVG_HEADERS | ||
expect(last_response).to be_ok | ||
expect(last_response.body.split("\n")[4]).to eq " fill: #fa8100;" | ||
end | ||
end | ||
it 'can take a custom line-separator' do | ||
get '/ab:cd?line-separator=:', nil, { 'HTTP_ACCEPT' => 'application/json' } | ||
expect(last_response).to be_ok | ||
expect(JSON.parse last_response.body).to eq ( | ||
{ | ||
'id' => "[ab, cd]", | ||
'data' => [ | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], | ||
[0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0], | ||
[0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0], | ||
[0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0], | ||
[0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], | ||
[0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], | ||
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0], | ||
[0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0], | ||
[0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0], | ||
[0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] | ||
] | ||
} | ||
) | ||
end | ||
end | ||
end |