/
build_spec.rb
59 lines (49 loc) · 1.64 KB
/
build_spec.rb
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
describe Jets::Commands::Build do
before(:each) do
FileUtils.rm_f("spec/fixtures/project/handlers/controllers/posts.js")
end
let(:build) do
Jets::Commands::Build.new(noop: true)
end
context "running build process" do
# TODO: figure out way to test build.rb fast
# it "builds handlers javascript files" do
# build.build
# file_exist = File.exist?("#{Jets.root}handlers/controllers/posts.js")
# expect(file_exist).to be true
# end
# Would be nice to be able to automate testing the shim
# context "node shim" do
# it "posts create should return json" do
# # build.build
# # Dir.chdir(ENV["JETS_ROOT"]) do
# out = execute("cd #{ENV["JETS_ROOT"]} && node handlers/controllers/posts.js")
# puts out
# # end
# end
# end
end
context "methods" do
it "app_file?" do
yes = Jets::Commands::Build.app_file?("app/controllers/posts_controller.rb")
expect(yes).to be true
yes = Jets::Commands::Build.app_file?("app/jobs/hard_job.rb")
expect(yes).to be true
yes = Jets::Commands::Build.app_file?("app/functions/hello.rb")
expect(yes).to be true
yes = Jets::Commands::Build.app_file?("app/models/post.rb")
expect(yes).to be false
end
it "internal_app_files" do
router = Jets::Router.drawn_router
files = Jets::Commands::Build.internal_app_files
expect(files).to eq([])
router.draw do
root "jets/welcome#index"
any "*catchall", to: "jets/public#show"
end
files = Jets::Commands::Build.internal_app_files
expect(files.size).to eq 2
end
end
end