Module: Zucchini::Compiler

Included in:
Feature
Defined in:
lib/zucchini/compiler.rb

Instance Method Summary collapse

Instance Method Details

#compile_js(orientation) ⇒ String

Compile the feature Javascript file for UIAutomation

Parameters:

  • orientation (String)

    initial device orientation, ‘portrait` or `landscape`

Returns:

  • (String)

    path to a compiled js file



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/zucchini/compiler.rb', line 10

def compile_js(orientation)
  js_path  = "#{run_data_path}/feature.js"
  lib_path = File.expand_path(File.dirname(__FILE__))

  coffee_src_paths = [
    "#{lib_path}/uia",
    "#{path}/../support/screens",
    "#{path}/../support/lib",
    feature_coffee("#{path}/feature.zucchini", orientation)
  ].select { |p| File.exists? p }.join ' '

  "coffee -o #{run_data_path} -j #{js_path} -c #{coffee_src_paths}".tap do |cmd|
    raise "Error compiling a feature file: #{cmd}" unless system(cmd)
  end

  concat("#{lib_path}/uia/lib", js_path)
  js_path
end