-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruby_script_server_spec.rb
More file actions
59 lines (34 loc) · 1.35 KB
/
ruby_script_server_spec.rb
File metadata and controls
59 lines (34 loc) · 1.35 KB
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
51
52
53
54
55
56
57
58
59
require 'ruby_script_server'
require 'rack/mock'
describe RubyScriptServer do
before do
@app = RubyScriptServer.new('public', 'src')
end
after do
FileUtils.rmtree 'public/cjs'
end
it "registers script names as path" do
Rack::MockRequest.new(@app).get("/hello").status.should.equal 200
end
it "creates the compile directory in the public directory" do
File.directory?('public/cjs').should.be.false
Rack::MockRequest.new(@app).get("/hello")
File.directory?('public/cjs').should.be.true
end
it "compiles the scripts" do
File.file?('public/cjs/hello.rb.js').should.be.false
Rack::MockRequest.new(@app).get("/hello")
File.file?('public/cjs/hello.rb.js').should.be.true
end
it "sends back the compiled javascript" do
response = Rack::MockRequest.new(@app).get("/hello")
response.body.should.equal open("public/cjs/hello.rb.js").readlines.join
end
it "sends back the compiled script and the dependent javascripts" do
response = Rack::MockRequest.new(@app).get("/script_2")
expected = open("public/cjs/modules/script_1_dep.rb.js").readlines.join
expected << open("public/cjs/script_1.rb.js").readlines.join
expected << open("public/cjs/script_2.rb.js").readlines.join
response.body.should.equal expected
end
end