require 'spec_helper' describe Ginatra::Helpers do before { allow(Time).to receive(:now).and_return(Time.new(2012, 12, 25, 0, 0, 0, '+00:00')) } let(:repo) { Ginatra::RepoList.find('test') } let(:commit) { repo.commit('095955b') } describe "#secure_mail" do it "returns masked email" do expect(secure_mail('eggscellent@example.com')).to eq('eggs...@example.com') end end describe "#gravatar_image_tag" do context "when options passed" do it "returns a gravatar image tag with custom options" do expect( gravatar_image_tag('john@example.com', size: 100, alt: 'John', class: 'avatar') ).to eq("John") end end context "when options not passed" do it "returns a gravatar image tag with default options" do expect( gravatar_image_tag('john@example.com') ).to eq("john") end end end describe "#file_icon" do context "symbolic link" do it "returns icon share-alt" do expect(file_icon(40960)).to eq("") end end context "executable file" do it "returns icon asterisk" do expect(file_icon(33261)).to eq("") end end context "non-executable file" do it "returns icon file" do expect(file_icon(33188)).to eq("") end end end describe "#nicetime" do it "returns a time in nice format" do expect(nicetime(Time.now)).to eq('Dec 25, 2012 – 00:00') end end describe "#time_tag" do it "returns a time in nice format" do expect( time_tag(Time.now) ).to eq("") end end describe "#patch_link" do it "returns a link for a commit patch" do expect( patch_link(commit, 'test') ).to eq("Download Patch") end end describe "#empty_description_hint_for" do it "returns a hint for a repo with empty description" do hint_text = "Edit `#{repo.path}description` file to set the repository description." expect(empty_description_hint_for(repo)).to eq("") end end describe "#atom_feed_url" do context "when ref name passed" do it "returns a link to repo reference atom feed" do expect(atom_feed_url('test', 'master')).to eq("/test/master.atom") end end context "when ref name not passed" do it "returns a link to repo atom feed" do expect(atom_feed_url('test')).to eq("/test.atom") end end end end