1
require 'spec_helper.rb'
3
describe "Standalone Distribution tasks" do
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')}
9
describe "build_standalone_distribution" do
11
reset_dir standalone_temp_dir
12
reset_dir download_dir
14
Dir.should_receive(:tmpdir).any_number_of_times.and_return(standalone_temp_dir)
16
@standalone_staging_dir = File.join(standalone_temp_dir, 'jasmine_standalone')
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')
23
@output = capture_output { jasmine_dev.build_standalone_distribution download_dir }
26
it "should build the distribution" do
27
@output.should match(/Building Jasmine distribution/)
30
it "should tell the developer the task has started" do
31
@output.should match(/Building standalone distribution/)
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', '**', '*'))
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))
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
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
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
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
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
65
describe "when the zip file is unzipped" do
67
@out_directory = File.join(standalone_temp_dir, 'unzip')
68
reset_dir @out_directory
70
FileUtils.cp File.join(@standalone_staging_dir, "jasmine-standalone-#{jasmine_version}.zip"),
73
Dir.chdir @out_directory do
74
system("unzip -qq jasmine-standalone-#{jasmine_version}.zip")
78
describe "the distirbution" do
80
Dir.chdir @out_directory do
81
@files = Dir.glob(File.join('**', '*'))
85
it "should include the correct root files" do
86
@files.should include('SpecRunner.html')
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))
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))
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))
b'\\ No newline at end of file'