Sha256: 170984fb1e074e6b5025f52342cdb5da8804cb9fb1c70d8342e196fd8fa3defe

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

describe Crystal::Tag do
  subject { Crystal::Tag.new('og:title', 'Caesar must die') }
  its(:name) {should == 'og:title'}
  its(:value) {should == 'Caesar must die'}

  context '#value_for_context' do
    let(:context) { double }

    it 'returns asset path if asset' do
      image = '1.png'
      asset_path = "/assets/#{image}"
      context.should_receive('image_path').with(image).and_return(asset_path)
      tag('og:image', image).value_for_context(context).should == asset_path
    end

    it 'returns iso8601 for date' do
      tag('date', Date.parse('1979-12-09')).value_for_context(context).should == '1979-12-09'
    end

    it 'returns iso8601 for time' do
      tag('date', DateTime.parse('1979-12-09 13:09')).value_for_context(context).should == '1979-12-09T13:09:00+00:00'
    end

    it 'returns original value otherwise' do
      tag('og:image:width', 100).value_for_context(context).should == 100
      tag('published', true).value_for_context(context).should be_true
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
crystalmeta-0.9.3 spec/unit/tag_spec.rb
crystalmeta-0.9.2 spec/unit/tag_spec.rb
crystalmeta-0.9.1 spec/unit/tag_spec.rb
crystalmeta-0.9.0 spec/unit/tag_spec.rb