Sha256: 69f62e2d6e077049904bdc75563227029e1a5e40b39d3299ea94385ab38dc6db

Contents?: true

Size: 1.21 KB

Versions: 10

Compression:

Stored size: 1.21 KB

Contents

require 'rails_helper'

describe Admin::ApplicationHelper, :type => :helper do
  describe '#timestamp' do
    it "should return 'Never' if a timedate is not given" do
      expect(timestamp).to eq('Never')
    end

    it "should reutrn 'x ago' when the supplied timestamp is less than a week ago" do
      expect(timestamp(6.days.ago)).to match('.*? ago')
    end

    it "should not return 'x at x' when the timestamp is less than a week ago" do
      expect(timestamp(5.minutes.ago)).to_not match(/.*? at .*/)
    end

    it "should return 'x at x' when the timestamp is more than a week ago" do
      expect(timestamp(7.days.ago)).to match(/.*? at .*/)
    end

    it "should not reutrn 'x ago' when the supplied timestamp is more than a week ago" do
      expect(timestamp(8.days.ago)).to_not match('.*? ago')
    end

  end

  describe '#tb_form_errors' do
    before(:each) do
      @user = FactoryGirl.create(:spud_user)
    end

    it "should return blank when no errors exist" do
      expect(helper.tb_form_errors(@user)).to be_blank
    end

    it "should display the error" do
      error = "You're invalid"
      @user.errors[:base] << error
      expect(helper.tb_form_errors(@user)).to include(error)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
tb_core-1.3.10 spec/helpers/spud/admin/application_helper_spec.rb
tb_core-1.3.9 spec/helpers/spud/admin/application_helper_spec.rb
tb_core-1.3.7 spec/helpers/spud/admin/application_helper_spec.rb
tb_core-1.3.6 spec/helpers/spud/admin/application_helper_spec.rb
tb_core-1.3.5 spec/helpers/spud/admin/application_helper_spec.rb
tb_core-1.3.4 spec/helpers/spud/admin/application_helper_spec.rb
tb_core-1.3.3 spec/helpers/spud/admin/application_helper_spec.rb
tb_core-1.3.2 spec/helpers/spud/admin/application_helper_spec.rb
tb_core-1.3.1 spec/helpers/spud/admin/application_helper_spec.rb
tb_core-1.3.0 spec/helpers/spud/admin/application_helper_spec.rb