~caneypuggies/reformedchurcheslocator/couchapp-backbone

« back to all changes in this revision

Viewing changes to _attachments/js/vendor/jasmine/spec/tasks/build_standalone_distribution_spec.rb

  • Committer: Tim Black
  • Date: 2013-09-16 22:50:16 UTC
  • Revision ID: tim@alwaysreformed.com-20130916225016-zk8jiba25z33ew7h
Versioned Bower vendor directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'spec_helper.rb'
 
2
 
 
3
describe "Standalone Distribution tasks" do
 
4
 
 
5
  let(:jasmine_dev) { JasmineDev.new }
 
6
  let(:standalone_temp_dir) { File.join(Dir.tmpdir, 'jasmine_test') }
 
7
  let(:download_dir) { File.join(standalone_temp_dir, 'download')}
 
8
 
 
9
  describe "build_standalone_distribution" do
 
10
    before do
 
11
      reset_dir standalone_temp_dir
 
12
      reset_dir download_dir
 
13
 
 
14
      Dir.should_receive(:tmpdir).any_number_of_times.and_return(standalone_temp_dir)
 
15
 
 
16
      @standalone_staging_dir = File.join(standalone_temp_dir, 'jasmine_standalone')
 
17
 
 
18
      @version_dir = File.join(@standalone_staging_dir, "jasmine-standalone-#{jasmine_version}")
 
19
      @lib_dir = File.join(@version_dir, 'lib')
 
20
      @source_dir = File.join(@version_dir, 'src')
 
21
      @spec_dir = File.join(@version_dir, 'spec')
 
22
 
 
23
      @output = capture_output { jasmine_dev.build_standalone_distribution download_dir }
 
24
    end
 
25
 
 
26
    it "should build the distribution" do
 
27
      @output.should match(/Building Jasmine distribution/)
 
28
    end
 
29
 
 
30
    it "should tell the developer the task has started" do
 
31
      @output.should match(/Building standalone distribution/)
 
32
    end
 
33
 
 
34
    it "should copy the lib directory to the staging directory, under a versioned directory" do
 
35
      lib_dir_files = Dir.glob(File.join(standalone_temp_dir, 'jasmine_standalone', '**', '*'))
 
36
 
 
37
      staged_lib_files = %w{ jasmine.js jasmine-html.js jasmine.css MIT.LICENSE }
 
38
      staged_lib_files.each do |filename|
 
39
        lib_dir_files.should include(File.join(@lib_dir, "jasmine-#{jasmine_version}", filename))
 
40
      end
 
41
    end
 
42
 
 
43
    it "should copy the sample project source to the staging directory" do
 
44
      File.exist?(File.join(@source_dir, 'Player.js')).should be_true
 
45
      File.exist?(File.join(@source_dir, 'Song.js')).should be_true
 
46
    end
 
47
 
 
48
    it "should copy the sample project specs to the staging directory" do
 
49
      File.exist?(File.join(@spec_dir, 'PlayerSpec.js')).should be_true
 
50
      File.exist?(File.join(@spec_dir, 'SpecHelper.js')).should be_true
 
51
    end
 
52
 
 
53
    it "should copy a build SpecRunner.html to the staging directory" do
 
54
      File.exist?(File.join(@version_dir, 'SpecRunner.html')).should be_true
 
55
    end
 
56
 
 
57
    it "should zip up the contents of the staging directory" do
 
58
      File.exist?(File.join(@standalone_staging_dir, "jasmine-standalone-#{jasmine_version}.zip")).should be_true
 
59
    end
 
60
 
 
61
    it "should copy the zip file to the pages sub directory" do
 
62
      File.exist?(File.join(download_dir, "jasmine-standalone-#{jasmine_version}.zip")).should be_true
 
63
    end
 
64
    
 
65
    describe "when the zip file is unzipped" do
 
66
      before do
 
67
        @out_directory = File.join(standalone_temp_dir, 'unzip')
 
68
        reset_dir @out_directory
 
69
 
 
70
        FileUtils.cp File.join(@standalone_staging_dir, "jasmine-standalone-#{jasmine_version}.zip"),
 
71
                     @out_directory
 
72
 
 
73
        Dir.chdir @out_directory do
 
74
          system("unzip -qq jasmine-standalone-#{jasmine_version}.zip")
 
75
        end
 
76
      end
 
77
 
 
78
      describe "the distirbution" do
 
79
        before do
 
80
          Dir.chdir @out_directory do
 
81
            @files = Dir.glob(File.join('**', '*'))
 
82
          end
 
83
        end
 
84
 
 
85
        it "should include the correct root files" do
 
86
          @files.should include('SpecRunner.html')
 
87
        end
 
88
 
 
89
        it "should include the correct lib files" do
 
90
          %w{ jasmine.js jasmine-html.js jasmine.css MIT.LICENSE }.each do |file|
 
91
            @files.should include(File.join('lib', "jasmine-#{jasmine_version}", file))
 
92
          end
 
93
        end
 
94
 
 
95
        it "should include the correct src files" do
 
96
          %w{Player.js Song.js}.each do |file|
 
97
            @files.should include(File.join('src', file))
 
98
          end
 
99
        end
 
100
 
 
101
        it "should include the correct spec files" do
 
102
          %w{PlayerSpec.js SpecHelper.js}.each do |file|
 
103
            @files.should include(File.join('spec', file))
 
104
          end
 
105
        end
 
106
      end
 
107
    end
 
108
  end
 
109
end
 
 
b'\\ No newline at end of file'