File: test_coffeescript.rb

package info (click to toggle)
jekyll 2.2.0+dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,908 kB
  • ctags: 687
  • sloc: ruby: 6,811; sh: 121; xml: 106; makefile: 35
file content (50 lines) | stat: -rw-r--r-- 1,217 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
require 'helper'

class TestCoffeeScript < Test::Unit::TestCase
  context "converting CoffeeScript" do
    setup do
      @site = Jekyll::Site.new(Jekyll.configuration({
        "source" => source_dir,
        "destination" => dest_dir
      }))
      @site.process
      @test_coffeescript_file = dest_dir("js/coffeescript.js")
      @js_output = <<-JS
(function() {

  $(function() {
    var cube, cubes, list, num, square;
    list = [1, 2, 3, 4, 5];
    square = function(x) {
      return x * x;
    };
    cube = function(x) {
      return square(x) * x;
    };
    cubes = (function() {
      var _i, _len, _results;
      _results = [];
      for (_i = 0, _len = list.length; _i < _len; _i++) {
        num = list[_i];
        _results.push(math.cube(num));
      }
      return _results;
    })();
    if (typeof elvis !== \"undefined\" && elvis !== null) {
      return alert(\"I knew it!\");
    }
  });

}).call(this);
JS
    end

    should "write a JS file in place" do
      assert File.exist?(@test_coffeescript_file), "Can't find the converted CoffeeScript file in the dest_dir."
    end

    should "produce JS" do
      assert_equal @js_output, File.read(@test_coffeescript_file)
    end
  end
end