Skip to content

Commit

Permalink
SVG colours
Browse files Browse the repository at this point in the history
  • Loading branch information
pikesley committed Sep 7, 2016
1 parent 0f11c77 commit 4f19b92
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ GEM
minitest (5.9.0)
multi_json (1.12.1)
nenv (0.3.0)
nineteen-eighty-two (0.1.1)
nineteen-eighty-two (0.1.2)
erubis
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
Expand Down
2 changes: 1 addition & 1 deletion lib/uncle_clive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class App < Sinatra::Base
end

wants.svg do
Nineteen::Eighty::Two::Formats::SVG.format params[:text]
Nineteen::Eighty::Two::Formats::SVG.format params[:text], {colour: "##{params.fetch('colour', '000000')}"}
end

wants.text do
Expand Down
16 changes: 12 additions & 4 deletions spec/uncle_clive/uncle_clive_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,18 @@ module UncleClive
expect(last_response.body.split("\n")[2]).to eq " ()()() ()()() () () ()()() "
end

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' />"
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
end
end
Expand Down

0 comments on commit 4f19b92

Please sign in to comment.