Sha256: 504e0529cf7909072047d7985c5eb73178b3502987e6b1d3040d8c7be3e838d9

Contents?: true

Size: 1.25 KB

Versions: 9

Compression:

Stored size: 1.25 KB

Contents

# encoding: utf-8
require 'fedux_org_stdlib/core_ext/string/characterize'

module Middleman
  module Presentation
    module Helpers
      # Test helpers
      module Test
        # Helpers for tests
        def ci?
          ENV.key?('CI') || ENV.key?('TRAVIS')
        end

        def temporary_fixture_path(name)
          File.expand_path("../../../tmp/fixtures/#{name}", __FILE__)
        end

        def temporary_fixture_exist?(name)
          File.exist? File.expand_path("../../../tmp/fixtures/#{name}", __FILE__)
        end

        def create_presentation(name, title, date)
          directory = []
          directory << name
          directory << ('-' + title)
          directory << ('-' + date) if date

          directory = directory.join.characterize

          command = []
          command << "middleman-presentation create presentation #{temporary_fixture_path(directory)}"
          command << "--title #{Shellwords.escape(title)}"
          command << "--date #{Shellwords.escape(date)}" if date

          system(command.join(' ')) unless temporary_fixture_exist?(directory)

          FileUtils.cp_r temporary_fixture_path(directory), absolute_path(name)
        end

        module_function :temporary_fixture_path
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
middleman-presentation-helpers-0.17.7 lib/middleman-presentation-helpers/test_helpers.rb
middleman-presentation-helpers-0.17.6 lib/middleman-presentation-helpers/test_helpers.rb
middleman-presentation-helpers-0.17.2 lib/middleman-presentation-helpers/test_helpers.rb
middleman-presentation-helpers-0.17.1 lib/middleman-presentation-helpers/test_helpers.rb
middleman-presentation-helpers-0.17.0 lib/middleman-presentation-helpers/test_helpers.rb
middleman-presentation-helpers-0.16.3 lib/middleman-presentation-helpers/test_helpers.rb
middleman-presentation-helpers-0.16.2 lib/middleman-presentation-helpers/test_helpers.rb
middleman-presentation-helpers-0.16.0 lib/middleman-presentation-helpers/test_helpers.rb
middleman-presentation-helpers-0.16.0.rc2 lib/middleman-presentation-helpers/test_helpers.rb