<commit_before>require 'spec_helper'

class MyView
  include Placeholdit::ViewHelpers
end

describe Placeholdit::ViewHelpers do
  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' />"
  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' />"
  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' />"
  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' />"
  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' />"
  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' />"
  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' />"
  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' />"
  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;' />"
  end

end
<commit_msg>Make tests pass with new https url, and remove deprecation warning about old rspec syntax<commit_after>require 'spec_helper'

class MyView
  include Placeholdit::ViewHelpers
end

describe Placeholdit::ViewHelpers do
  let(:view) { MyView.new }

  it "should accept integers as params" do
    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
    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
    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
    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
    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
    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
    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
    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
    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

{'fraction_non_alphanumeric': 0.17328218812541696, 'fraction_numerical': 0.07004669779853236, 'mean_word_length': 5.626519337016575, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4087324', 'n_tokens_mistral': 2217, 'n_tokens_neox': 1902, 'n_words': 470}