Sha256: bd62ef98a42def037fba9d8dd4f63a340508398021ce667de4dc803bbc921853

Contents?: true

Size: 1.88 KB

Versions: 13

Compression:

Stored size: 1.88 KB

Contents

# encoding: utf-8
require 'spec_helper'

RSpec.describe SlideName do
  context '#to_s' do
    let(:old_slide) { instance_double('Middleman::Presentation::ExistingSlide') }

    it 'switches type from erb to md if no basename/type is given' do
      expect(old_slide).to receive(:base_name).and_return('01')
      expect(old_slide).to receive(:ext_name).and_return('.html.erb')

      name = SlideName.new(old_slide, base_name: nil, type: nil)
      expect(name.to_s).to eq '01.md'
    end

    it 'switches type from erb to md if no basename/type is given' do
      expect(old_slide).to receive(:base_name).and_return('01')
      expect(old_slide).to receive(:ext_name).and_return('.html.md')

      name = SlideName.new(old_slide, base_name: nil, type: nil)
      expect(name.to_s).to eq '01.erb'
    end

    it 'switches type from other types than erb/md to md only if no basename/type is given' do
      expect(old_slide).to receive(:base_name).and_return('01')
      expect(old_slide).to receive(:ext_name).and_return('.html.liquid')

      name = SlideName.new(old_slide, base_name: nil, type: nil)
      expect(name.to_s).to eq '01.md'
    end

    it 'switches to given type and uses base name from old slide' do
      expect(old_slide).to receive(:base_name).and_return('01')

      name = SlideName.new(old_slide, base_name: nil, type: 'erb')
      expect(name.to_s).to eq '01.erb'
    end

    it 'switches to given type (with dot) and uses base name from old slide' do
      expect(old_slide).to receive(:base_name).and_return('01')

      name = SlideName.new(old_slide, base_name: nil, type: '.erb')
      expect(name.to_s).to eq '01.erb'
    end

    it 'switches to given basename and uses type from old slide' do
      expect(old_slide).to receive(:ext_name).and_return('.html.erb')

      name = SlideName.new(old_slide, base_name: '02', type: nil)
      expect(name.to_s).to eq '02.erb'
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
middleman-presentation-core-0.17.7 spec/slide_name_spec.rb
middleman-presentation-core-0.17.6 spec/slide_name_spec.rb
middleman-presentation-core-0.17.5 spec/slide_name_spec.rb
middleman-presentation-core-0.17.2 spec/slide_name_spec.rb
middleman-presentation-core-0.17.1 spec/slide_name_spec.rb
middleman-presentation-core-0.17.0 spec/slide_name_spec.rb
middleman-presentation-core-0.16.3 spec/slide_name_spec.rb
middleman-presentation-core-0.16.2 spec/slide_name_spec.rb
middleman-presentation-core-0.16.0 spec/slide_name_spec.rb
middleman-presentation-core-0.16.0.rc2 spec/slide_name_spec.rb
middleman-presentation-core-0.16.0.rc1 spec/slide_name_spec.rb
middleman-presentation-core-0.16.0.beta spec/slide_name_spec.rb
middleman-presentation-core-0.16.0.alpha spec/slide_name_spec.rb