Skip to content

Commit

Permalink
Merge pull request #4 from thermistor/feature/https
Browse files Browse the repository at this point in the history
Use https for placeholdit urls + fix rspec
  • Loading branch information
ohokay committed Feb 23, 2015
2 parents 48ec63c + ad79a3f commit fb7d0c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/placeholdit.rb
Expand Up @@ -5,7 +5,7 @@ module ViewHelpers
def placeholdit_image_tag(size, opts={})

size = "#{size}" unless size.is_a?(String)
src = "http://placehold.it/#{size}"
src = "https://placehold.it/#{size}"

config = {
:alt => (opts[:text] || "A placeholder image"),
Expand Down
24 changes: 12 additions & 12 deletions spec/placeholdit_spec.rb
Expand Up @@ -8,42 +8,42 @@ class MyView
let(:view) { MyView.new }

it "should accept integers as params" do
view.placeholdit_image_tag(500).should == "<img src='http://placehold.it/500' alt='A placeholder image' class='placeholder' height='500' width='500' />"
expect(view.placeholdit_image_tag(500)).to eq "<img src='https://placehold.it/500' alt='A placeholder image' class='placeholder' height='500' width='500' />"
end

it "should accept a string" do
view.placeholdit_image_tag("500").should == "<img src='http://placehold.it/500' alt='A placeholder image' class='placeholder' height='500' width='500' />"
expect(view.placeholdit_image_tag("500")).to eq "<img src='https://placehold.it/500' alt='A placeholder image' class='placeholder' height='500' width='500' />"
end

it "should accept a componded WxH" do
view.placeholdit_image_tag("500x500").should == "<img src='http://placehold.it/500x500' alt='A placeholder image' class='placeholder' height='500' width='500' />"
expect(view.placeholdit_image_tag("500x500")).to eq "<img src='https://placehold.it/500x500' alt='A placeholder image' class='placeholder' height='500' width='500' />"
end

it "should accept custom text" do
view.placeholdit_image_tag("500x500", text: 'Buy me!').should == "<img src='http://placehold.it/500x500&text=Buy me!' alt='Buy me!' class='placeholder' height='500' width='500' />"
expect(view.placeholdit_image_tag("500x500", text: 'Buy me!')).to eq "<img src='https://placehold.it/500x500&text=Buy me!' alt='Buy me!' class='placeholder' height='500' width='500' />"
end

it "should accept custom colors" do
view.placeholdit_image_tag("500", text_color: 'fff', background_color: '000').should == "<img src='http://placehold.it/500/000/fff' alt='A placeholder image' class='placeholder' height='500' width='500' />"
expect(view.placeholdit_image_tag("500", text_color: 'fff', background_color: '000')).to eq "<img src='https://placehold.it/500/000/fff' alt='A placeholder image' class='placeholder' height='500' width='500' />"
end

it "should strip the pound from hex colors" do
view.placeholdit_image_tag("500", text_color: '#fff', background_color: '000').should == "<img src='http://placehold.it/500/000/fff' alt='A placeholder image' class='placeholder' height='500' width='500' />"
view.placeholdit_image_tag("500", text_color: '#fff', background_color: '#000000').should == "<img src='http://placehold.it/500/000000/fff' alt='A placeholder image' class='placeholder' height='500' width='500' />"
view.placeholdit_image_tag("500", text_color: 'fff', background_color: '#000000').should == "<img src='http://placehold.it/500/000000/fff' alt='A placeholder image' class='placeholder' height='500' width='500' />"
view.placeholdit_image_tag("500", text_color: 'ffffff', background_color: '#000000').should == "<img src='http://placehold.it/500/000000/ffffff' alt='A placeholder image' class='placeholder' height='500' width='500' />"
expect(view.placeholdit_image_tag("500", text_color: '#fff', background_color: '000')).to eq "<img src='https://placehold.it/500/000/fff' alt='A placeholder image' class='placeholder' height='500' width='500' />"
expect(view.placeholdit_image_tag("500", text_color: '#fff', background_color: '#000000')).to eq "<img src='https://placehold.it/500/000000/fff' alt='A placeholder image' class='placeholder' height='500' width='500' />"
expect(view.placeholdit_image_tag("500", text_color: 'fff', background_color: '#000000')).to eq "<img src='https://placehold.it/500/000000/fff' alt='A placeholder image' class='placeholder' height='500' width='500' />"
expect(view.placeholdit_image_tag("500", text_color: 'ffffff', background_color: '#000000')).to eq "<img src='https://placehold.it/500/000000/ffffff' alt='A placeholder image' class='placeholder' height='500' width='500' />"
end

it "should accept title" do
view.placeholdit_image_tag("500", title: "Lorem ipsum").should == "<img src='http://placehold.it/500' alt='A placeholder image' class='placeholder' height='500' width='500' title='Lorem ipsum' />"
expect(view.placeholdit_image_tag("500", title: "Lorem ipsum")).to eq "<img src='https://placehold.it/500' alt='A placeholder image' class='placeholder' height='500' width='500' title='Lorem ipsum' />"
end

it "should alias to placeholdit" do
view.placeholdit("500", text_color: 'fff', background_color: '000').should == "<img src='http://placehold.it/500/000/fff' alt='A placeholder image' class='placeholder' height='500' width='500' />"
expect(view.placeholdit("500", text_color: 'fff', background_color: '000')).to eq "<img src='https://placehold.it/500/000/fff' alt='A placeholder image' class='placeholder' height='500' width='500' />"
end

it "should accept style" do
view.placeholdit_image_tag("500", style: "float:right;").should == "<img src='http://placehold.it/500' alt='A placeholder image' class='placeholder' height='500' width='500' style='float:right;' />"
expect(view.placeholdit_image_tag("500", style: "float:right;")).to eq "<img src='https://placehold.it/500' alt='A placeholder image' class='placeholder' height='500' width='500' style='float:right;' />"
end

end

0 comments on commit fb7d0c4

Please sign in to comment.