Module: Middleman::Presentation::Helpers::Test

Defined in:
lib/middleman-presentation-helpers/test_helpers.rb

Overview

Test helpers

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.temporary_fixture_path(name) ⇒ Object



14
15
16
# File 'lib/middleman-presentation-helpers/test_helpers.rb', line 14

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

Instance Method Details

#ci?Boolean

Helpers for tests

Returns:

  • (Boolean)


10
11
12
# File 'lib/middleman-presentation-helpers/test_helpers.rb', line 10

def ci?
  ENV.key?('CI') || ENV.key?('TRAVIS')
end

#create_presentation(name, title, date) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/middleman-presentation-helpers/test_helpers.rb', line 22

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

#temporary_fixture_exist?(name) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/middleman-presentation-helpers/test_helpers.rb', line 18

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