Sha256: ed5f13400d845995588d5eae1ef8f1038612c227e0b3b8b7cbb65497b4d8942a

Contents?: true

Size: 1.29 KB

Versions: 6

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

module Capistrano
  module Template
    module Helpers
      describe PathsLookup do
        subject do
          PathsLookup.new(lookup_paths, context)
        end

        let(:tmp_folder) { File.join(__dir__, '..', '..', '..', 'tmp') }

        let(:lookup_paths) { ["#{tmp_folder}/%<host>s", "#{tmp_folder}"] }
        let(:context) { OpenStruct.new(host: 'localhost') }

        let(:template_content) { '<%=var1%> -- <%=var2%>' }
        let(:template_name) { 'my_template.erb' }
        let(:template_fullname) { File.join(tmp_folder, template_name) }

        before :each do
          Dir.mkdir(tmp_folder) unless Dir.exist? tmp_folder
          File.write(template_fullname, template_content, mode: 'w')
        end

        after :each do
          if File.exist? template_fullname
            system('rm', '-f', File.join(tmp_folder, template_fullname))
          end
        end

        describe '#template_exists?' do

          it 'returns true when a template file exists' do
            expect(subject.template_exists?(template_name)).to be_truthy
          end

          it 'returns false when a template does not file exists' do
            expect(subject.template_exists?("#{template_name}.not_exists")).to be_falsy
          end

        end

      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
capistrano-template-0.0.7 spec/integration/capistrano/template/helpers/paths_lookup_spec.rb
capistrano-template-0.0.5 spec/integration/capistrano/template/helpers/paths_lookup_spec.rb
capistrano-template-0.0.4 spec/integration/capistrano/template/helpers/paths_lookup_spec.rb
capistrano-template-0.0.3 spec/integration/capistrano/template/helpers/paths_lookup_spec.rb
capistrano-template-0.0.2 spec/integration/capistrano/template/helpers/paths_lookup_spec.rb
capistrano-template-0.0.1 spec/integration/capistrano/template/helpers/paths_lookup_spec.rb