jax 1.0.1 → 1.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitmodules +3 -0
- data/.travis.yml +32 -0
- data/CHANGELOG +126 -0
- data/README.md +1 -1
- data/Rakefile +125 -19
- data/bin/jax +1 -1
- data/builtin/{shaders → app/shaders}/basic/common.ejs +0 -0
- data/builtin/{shaders → app/shaders}/basic/fragment.ejs +0 -0
- data/builtin/{shaders → app/shaders}/basic/vertex.ejs +0 -0
- data/builtin/{shaders → app/shaders}/depthmap/common.ejs +0 -0
- data/builtin/{shaders → app/shaders}/depthmap/fragment.ejs +0 -0
- data/builtin/{shaders → app/shaders}/depthmap/material.js +0 -0
- data/builtin/{shaders → app/shaders}/depthmap/vertex.ejs +0 -0
- data/builtin/{shaders → app/shaders}/fog/common.ejs +0 -0
- data/builtin/{shaders → app/shaders}/fog/fragment.ejs +0 -0
- data/builtin/{shaders → app/shaders}/fog/manifest.yml +0 -0
- data/builtin/{shaders → app/shaders}/fog/material.js +0 -0
- data/builtin/{shaders → app/shaders}/fog/vertex.ejs +0 -0
- data/builtin/{shaders → app/shaders}/functions/depth_map.ejs +0 -0
- data/builtin/{shaders → app/shaders}/functions/lights.ejs +0 -0
- data/builtin/{shaders → app/shaders}/functions/noise.ejs +0 -0
- data/builtin/{shaders → app/shaders}/lighting/common.ejs +0 -0
- data/builtin/{shaders → app/shaders}/lighting/fragment.ejs +0 -0
- data/builtin/{shaders → app/shaders}/lighting/manifest.yml +0 -0
- data/builtin/{shaders → app/shaders}/lighting/material.js +0 -0
- data/builtin/{shaders → app/shaders}/lighting/vertex.ejs +0 -0
- data/builtin/{shaders → app/shaders}/normal_map/common.ejs +0 -0
- data/builtin/{shaders → app/shaders}/normal_map/fragment.ejs +0 -0
- data/builtin/{shaders → app/shaders}/normal_map/manifest.yml +0 -0
- data/builtin/{shaders → app/shaders}/normal_map/material.js +0 -0
- data/builtin/{shaders → app/shaders}/normal_map/vertex.ejs +0 -0
- data/builtin/{shaders → app/shaders}/paraboloid/common.ejs +0 -0
- data/builtin/{shaders → app/shaders}/paraboloid/fragment.ejs +0 -0
- data/builtin/{shaders → app/shaders}/paraboloid/manifest.yml +0 -0
- data/builtin/{shaders → app/shaders}/paraboloid/material.js +0 -0
- data/builtin/{shaders → app/shaders}/paraboloid/vertex.ejs +0 -0
- data/builtin/{shaders → app/shaders}/picking/common.ejs +0 -0
- data/builtin/{shaders → app/shaders}/picking/fragment.ejs +0 -0
- data/builtin/{shaders → app/shaders}/picking/material.js +0 -0
- data/builtin/{shaders → app/shaders}/picking/vertex.ejs +0 -0
- data/builtin/{shaders → app/shaders}/shadow_map/common.ejs +0 -0
- data/builtin/{shaders → app/shaders}/shadow_map/fragment.ejs +0 -0
- data/builtin/{shaders → app/shaders}/shadow_map/manifest.yml +0 -0
- data/builtin/{shaders → app/shaders}/shadow_map/material.js +0 -0
- data/builtin/{shaders → app/shaders}/shadow_map/vertex.ejs +0 -0
- data/builtin/{shaders → app/shaders}/texture/common.ejs +0 -0
- data/builtin/{shaders → app/shaders}/texture/fragment.ejs +0 -0
- data/builtin/{shaders → app/shaders}/texture/manifest.yml +0 -0
- data/builtin/{shaders → app/shaders}/texture/material.js +0 -0
- data/builtin/{shaders → app/shaders}/texture/vertex.ejs +0 -0
- data/jax.gems +1 -1
- data/jax.gemspec +9 -7
- data/lib/jax.rb +23 -9
- data/lib/jax/application.rb +118 -60
- data/lib/jax/application/builtin.rb +12 -0
- data/lib/jax/application/builtin/configurable.rb +5 -0
- data/lib/jax/application/builtin/configuration.rb +5 -0
- data/lib/jax/application/configurable.rb +19 -0
- data/lib/jax/application/configuration.rb +46 -13
- data/lib/jax/application/railties.rb +26 -0
- data/lib/jax/core_ext/kernel.rb +7 -0
- data/lib/jax/engine.rb +64 -0
- data/lib/jax/engine/configurable.rb +19 -0
- data/lib/jax/engine/configuration.rb +49 -0
- data/lib/jax/generators/app.rb +3 -2
- data/lib/jax/generators/app/app_generator.rb +9 -2
- data/lib/jax/generators/app/templates/config/environment.rb.tt +5 -0
- data/lib/jax/generators/app/templates/public/index.html.tt +26 -0
- data/lib/jax/generators/app/templates/public/javascripts/jax.js +8726 -1
- data/lib/jax/generators/app/templates/public/stylesheets/%file_name%.css.tt +11 -0
- data/lib/jax/generators/app/templates/public/webgl_not_supported.html +1 -1
- data/lib/jax/generators/app/templates/spec/javascripts/support/jasmine.yml +1 -0
- data/lib/jax/generators/app/templates/spec/javascripts/support/spec_helpers/jax_spec_environment_helper.js +13 -5
- data/lib/jax/generators/app/templates/spec/javascripts/support/spec_helpers/jax_spec_helper.js +6 -10
- data/lib/jax/generators/commands.rb +168 -42
- data/lib/jax/generators/controller/controller_generator.rb +9 -2
- data/lib/jax/generators/interactions.rb +56 -0
- data/lib/jax/generators/light_source/light_source_generator.rb +1 -2
- data/lib/jax/generators/material/material_generator.rb +1 -2
- data/lib/jax/generators/model/model_generator.rb +1 -3
- data/lib/jax/generators/packager/package_generator.rb +32 -0
- data/lib/jax/generators/plugin/USAGE +4 -0
- data/lib/jax/generators/plugin/all.rb +113 -0
- data/lib/jax/generators/plugin/credentials.rb +108 -0
- data/lib/jax/generators/plugin/plugin_generator.rb +72 -0
- data/lib/jax/generators/plugin/plugin_manager.rb +254 -0
- data/lib/jax/generators/plugin/templates/new_plugin/app/controllers/.empty_directory +0 -0
- data/lib/jax/generators/plugin/templates/new_plugin/app/helpers/.empty_directory +0 -0
- data/lib/jax/generators/plugin/templates/new_plugin/app/models/.empty_directory +0 -0
- data/lib/jax/generators/plugin/templates/new_plugin/app/resources/.empty_directory +0 -0
- data/lib/jax/generators/plugin/templates/new_plugin/app/views/.empty_directory +0 -0
- data/lib/jax/generators/plugin/templates/new_plugin/config/routes.rb +3 -0
- data/lib/jax/generators/plugin/templates/new_plugin/init.rb +1 -0
- data/lib/jax/generators/plugin/templates/new_plugin/install.rb +2 -0
- data/lib/jax/generators/plugin/templates/new_plugin/public/.empty_directory +0 -0
- data/lib/jax/generators/plugin/templates/new_plugin/spec/.empty_directory +0 -0
- data/lib/jax/generators/plugin/templates/new_plugin/uninstall.rb +2 -0
- data/lib/jax/generators/script_jax_loader.rb +17 -0
- data/lib/jax/generators/shader/shader_generator.rb +2 -3
- data/lib/jax/monkeypatch/jasmine/config.rb +25 -1
- data/lib/jax/monkeypatch/jasmine/server.rb +1 -1
- data/lib/jax/packager.rb +12 -11
- data/lib/jax/packager/sprockets_template.rb +15 -6
- data/lib/jax/plugin.rb +49 -0
- data/lib/jax/plugin/manifest.rb +71 -0
- data/lib/jax/resource_compiler.rb +24 -14
- data/lib/jax/routes.rb +1 -0
- data/lib/jax/shader.rb +16 -1
- data/lib/jax/tasks/rake.rb +1 -1
- data/lib/jax/version.rb +3 -3
- data/spec/benchmark.htm +93 -0
- data/spec/fixtures/web/plugins/404.http +39 -0
- data/spec/fixtures/web/plugins/all.xml +106 -0
- data/spec/fixtures/web/plugins/author/create_account.xml.http +20 -0
- data/spec/fixtures/web/plugins/author/create_new_plugin.xml.http +27 -0
- data/spec/fixtures/web/plugins/author/login_existing_account.xml.http +19 -0
- data/spec/fixtures/web/plugins/author/login_not_found.xml.http +14 -0
- data/spec/fixtures/web/plugins/author/login_password_invalid.xml.http +12 -0
- data/spec/fixtures/web/plugins/clouds.xml +51 -0
- data/spec/fixtures/web/plugins/example.tgz.http +0 -0
- data/spec/fixtures/web/plugins/example.tgz.http.old +0 -0
- data/spec/fixtures/web/plugins/none.http +13 -0
- data/spec/fixtures/web/plugins/vert.xml +68 -0
- data/spec/fixtures/web/plugins/vertex-blob.xml +37 -0
- data/spec/fixtures/web/plugins/vertex-height-map.xml +44 -0
- data/spec/generators/app_generator_test.rb +42 -0
- data/spec/generators/controller_generator_test.rb +47 -0
- data/spec/generators/light_generator_test.rb +37 -0
- data/spec/generators/material_generator_test.rb +22 -0
- data/spec/generators/model_generator_test.rb +26 -0
- data/spec/generators/plugin_generator_test.rb +114 -0
- data/spec/generators/plugin_manager/push_test.rb +59 -0
- data/spec/generators/plugin_manager_test.rb +192 -0
- data/spec/generators/shader_generator_test.rb +38 -0
- data/spec/lib/jax/application_test.rb +18 -0
- data/spec/lib/jax/generators/plugin/credentials_test.rb +72 -0
- data/spec/lib/jax/packager_test.rb +87 -0
- data/spec/lib/jax/plugin_test.rb +27 -0
- data/spec/lib/jax/reloading_test.rb +23 -0
- data/spec/lib/jax/routes_test.rb +28 -0
- data/spec/lib/jax/shader_test.rb +29 -0
- data/spec/lib/jax/tasks/jax_rake_test.rb +85 -0
- data/spec/support/bases/generator_test_case.rb +108 -0
- data/spec/support/bases/isolated_test_case.rb +148 -0
- data/spec/support/fixtures_helper.rb +21 -0
- data/spec/support/spec_shell.rb +14 -1
- data/spec/test_app.rb +3 -0
- data/spec/test_helper.rb +55 -0
- metadata +200 -92
- data/spec/generators/app_generator_spec.rb +0 -47
- data/spec/generators/controller_generator_spec.rb +0 -68
- data/spec/generators/light_generator_spec.rb +0 -51
- data/spec/generators/material_generator_spec.rb +0 -35
- data/spec/generators/model_generator_spec.rb +0 -43
- data/spec/lib/jax/routes_spec.rb +0 -24
- data/spec/lib/jax/shader_spec.rb +0 -57
- data/spec/lib/jax/tasks/jax_rake_spec.rb +0 -92
- data/spec/spec_helper.rb +0 -11
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
pwd = File.join(Dir.pwd, "generator_tests")
|
4
|
-
EXPECTED_FILES = %w(
|
5
|
-
app/controllers/application_controller.js
|
6
|
-
app/helpers/application_helper.js
|
7
|
-
app/models/
|
8
|
-
app/resources/
|
9
|
-
app/views/
|
10
|
-
config/application.rb
|
11
|
-
config/routes.rb
|
12
|
-
config/boot.rb
|
13
|
-
public/webgl_not_supported.html
|
14
|
-
script/jax
|
15
|
-
spec/javascripts/support/jasmine.yml
|
16
|
-
spec/javascripts/support/jasmine_runner.rb
|
17
|
-
spec/javascripts/support/spec_layout.html.erb
|
18
|
-
spec/javascripts/support/spec_helpers/jax_spec_environment_helper.js
|
19
|
-
spec/javascripts/support/spec_helpers/jax_spec_helper.js
|
20
|
-
Rakefile
|
21
|
-
Gemfile
|
22
|
-
)
|
23
|
-
|
24
|
-
describe Jax::Generators::App::AppGenerator do
|
25
|
-
def generate(*args)
|
26
|
-
Jax::Generators::App::AppGenerator.start(args + ['--debug'], :shell => SpecShell.new)
|
27
|
-
end
|
28
|
-
|
29
|
-
before :each do
|
30
|
-
FileUtils.rm_rf pwd
|
31
|
-
Dir.chdir File.expand_path('..', pwd)
|
32
|
-
FileUtils.mkdir_p pwd
|
33
|
-
Dir.chdir pwd
|
34
|
-
end
|
35
|
-
|
36
|
-
after :each do
|
37
|
-
FileUtils.rm_rf pwd
|
38
|
-
Dir.chdir File.expand_path('..', pwd)
|
39
|
-
end
|
40
|
-
|
41
|
-
EXPECTED_FILES.each do |file|
|
42
|
-
it "should generate '#{file}'" do
|
43
|
-
generate("test_app")
|
44
|
-
File.should exist(File.expand_path(File.join("test_app", file), pwd))
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
pwd = File.join(Dir.pwd, "generator_tests")
|
4
|
-
|
5
|
-
describe Jax::Generators::Controller::ControllerGenerator do
|
6
|
-
def generate(*args)
|
7
|
-
Jax::Generators::Controller::ControllerGenerator.start(args, :shell => shell)
|
8
|
-
end
|
9
|
-
|
10
|
-
def shell
|
11
|
-
@shell ||= SpecShell.new
|
12
|
-
end
|
13
|
-
|
14
|
-
before :each do
|
15
|
-
FileUtils.rm_rf pwd
|
16
|
-
Dir.chdir File.expand_path('..', pwd)
|
17
|
-
FileUtils.mkdir_p pwd
|
18
|
-
Dir.chdir pwd
|
19
|
-
Jax::Generators::App::AppGenerator.start(["test_app"], :shell => shell)
|
20
|
-
Dir.chdir File.join(pwd, "test_app")
|
21
|
-
end
|
22
|
-
|
23
|
-
after :each do
|
24
|
-
FileUtils.rm_rf pwd
|
25
|
-
Dir.chdir File.expand_path('..', pwd)
|
26
|
-
end
|
27
|
-
|
28
|
-
context "with no arguments" do
|
29
|
-
before(:each) { generate 'welcome' }
|
30
|
-
|
31
|
-
it "should generate controller source file" do
|
32
|
-
File.should exist("app/controllers/welcome_controller.js")
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should use controller class name" do
|
36
|
-
File.read(File.expand_path("test_app/app/controllers/welcome_controller.js", pwd)).
|
37
|
-
should =~ /^var WelcomeController \=/
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should generate controller helper file" do
|
41
|
-
File.should exist('app/helpers/welcome_helper.js')
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should generate controller test file" do
|
45
|
-
File.should exist('spec/javascripts/controllers/welcome_controller_spec.js')
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context "with arguments" do
|
50
|
-
before(:each) { generate "welcome", "index" }
|
51
|
-
|
52
|
-
it "should generate controller source file" do
|
53
|
-
File.should exist("app/controllers/welcome_controller.js")
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should add action to controller source" do
|
57
|
-
File.read(File.join(pwd, "test_app/app/controllers/welcome_controller.js")).should =~ /^\s*index: function\(\)\s*\{/
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should generate view file" do
|
61
|
-
File.should exist("app/views/welcome/index.js")
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should register route" do
|
65
|
-
File.read("config/routes.rb").should match(/^ map ['"]welcome\/index['"]/)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
pwd = File.join(Dir.pwd, "generator_tests")
|
4
|
-
|
5
|
-
describe Jax::Generators::LightSource::LightSourceGenerator do
|
6
|
-
def generate(*args)
|
7
|
-
Jax::Generators::LightSource::LightSourceGenerator.start(args, :shell => shell)
|
8
|
-
end
|
9
|
-
|
10
|
-
def shell
|
11
|
-
@shell ||= SpecShell.new
|
12
|
-
end
|
13
|
-
|
14
|
-
before :each do
|
15
|
-
FileUtils.rm_rf pwd
|
16
|
-
Dir.chdir File.expand_path('..', pwd)
|
17
|
-
FileUtils.mkdir_p pwd
|
18
|
-
Dir.chdir pwd
|
19
|
-
Jax::Generators::App::AppGenerator.start(["test_app"], :shell => shell)
|
20
|
-
Dir.chdir File.join(pwd, "test_app")
|
21
|
-
end
|
22
|
-
|
23
|
-
after :each do
|
24
|
-
FileUtils.rm_rf pwd
|
25
|
-
Dir.chdir File.expand_path('..', pwd)
|
26
|
-
end
|
27
|
-
|
28
|
-
context "with light name" do
|
29
|
-
before(:each) { generate 'torch' }
|
30
|
-
|
31
|
-
it "should generate resource file" do
|
32
|
-
File.should exist("app/resources/light_sources/torch.yml")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "with directional" do
|
37
|
-
before(:each) { generate 'torch', 'directional' }
|
38
|
-
|
39
|
-
it "should not include position" do
|
40
|
-
File.read("app/resources/light_sources/torch.yml").should_not =~ /position/
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context "with point" do
|
45
|
-
before(:each) { generate 'torch', 'point' }
|
46
|
-
|
47
|
-
it "should not include direction" do
|
48
|
-
File.read("app/resources/light_sources/torch.yml").should_not =~ /direction/
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
pwd = File.join(Dir.pwd, "generator_tests")
|
4
|
-
|
5
|
-
describe Jax::Generators::Material::MaterialGenerator do
|
6
|
-
def generate(*args)
|
7
|
-
Jax::Generators::Material::MaterialGenerator.start(args, :shell => shell)
|
8
|
-
end
|
9
|
-
|
10
|
-
def shell
|
11
|
-
@shell ||= SpecShell.new
|
12
|
-
end
|
13
|
-
|
14
|
-
before :each do
|
15
|
-
FileUtils.rm_rf pwd
|
16
|
-
Dir.chdir File.expand_path('..', pwd)
|
17
|
-
FileUtils.mkdir_p pwd
|
18
|
-
Dir.chdir pwd
|
19
|
-
Jax::Generators::App::AppGenerator.start(["test_app"], :shell => shell)
|
20
|
-
Dir.chdir File.join(pwd, "test_app")
|
21
|
-
end
|
22
|
-
|
23
|
-
after :each do
|
24
|
-
FileUtils.rm_rf pwd
|
25
|
-
Dir.chdir File.expand_path('..', pwd)
|
26
|
-
end
|
27
|
-
|
28
|
-
context "with material name" do
|
29
|
-
before(:each) { generate 'brick' }
|
30
|
-
|
31
|
-
it "should generate model source file" do
|
32
|
-
File.should exist("app/resources/materials/brick.yml")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
pwd = File.join(Dir.pwd, "generator_tests")
|
4
|
-
|
5
|
-
describe Jax::Generators::Model::ModelGenerator do
|
6
|
-
def generate(*args)
|
7
|
-
Jax::Generators::Model::ModelGenerator.start(args, :shell => shell)
|
8
|
-
end
|
9
|
-
|
10
|
-
def shell
|
11
|
-
@shell ||= SpecShell.new
|
12
|
-
end
|
13
|
-
|
14
|
-
before :each do
|
15
|
-
FileUtils.rm_rf pwd
|
16
|
-
Dir.chdir File.expand_path('..', pwd)
|
17
|
-
FileUtils.mkdir_p pwd
|
18
|
-
Dir.chdir pwd
|
19
|
-
Jax::Generators::App::AppGenerator.start(["test_app"], :shell => shell)
|
20
|
-
Dir.chdir File.join(pwd, "test_app")
|
21
|
-
end
|
22
|
-
|
23
|
-
after :each do
|
24
|
-
FileUtils.rm_rf pwd
|
25
|
-
Dir.chdir File.expand_path('..', pwd)
|
26
|
-
end
|
27
|
-
|
28
|
-
context "with no arguments" do
|
29
|
-
before(:each) { generate 'character' }
|
30
|
-
|
31
|
-
it "should generate model source file" do
|
32
|
-
File.should exist("app/models/character.js")
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should generate model test file" do
|
36
|
-
File.should exist("spec/javascripts/models/character_spec.js")
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should generate resources directory" do
|
40
|
-
File.should exist("app/resources/characters")
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
data/spec/lib/jax/routes_spec.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'stringio'
|
3
|
-
|
4
|
-
describe Jax::Routes do
|
5
|
-
before(:each) { @out = ""; @io = StringIO.new(@out) }
|
6
|
-
|
7
|
-
it "should map root" do
|
8
|
-
subject.root "welcome"
|
9
|
-
subject.compile(@io)
|
10
|
-
@out.strip.should == 'Jax.routes.root(WelcomeController, "index");'
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should map" do
|
14
|
-
subject.map "path/to", "welcome"
|
15
|
-
subject.compile(@io)
|
16
|
-
@out.strip.should == 'Jax.routes.map("path/to", WelcomeController, "index");'
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should map with action name" do
|
20
|
-
subject.map "path/to", "welcome", "another"
|
21
|
-
subject.compile(@io)
|
22
|
-
@out.strip.should == 'Jax.routes.map("path/to", WelcomeController, "another");'
|
23
|
-
end
|
24
|
-
end
|
data/spec/lib/jax/shader_spec.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Jax::Shader do
|
4
|
-
subject { Jax::Shader.new("path/to/shader") }
|
5
|
-
|
6
|
-
it "should set name" do
|
7
|
-
subject.name.should == "shader"
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should set path" do
|
11
|
-
subject.path.should == "path/to/shader"
|
12
|
-
end
|
13
|
-
|
14
|
-
context "with an export" do
|
15
|
-
before(:each) { subject.fragment = "void main(void)\n{\n vec4 ambient;\n export(vec4, ambient, ambient);\n}" }
|
16
|
-
|
17
|
-
it "should NOT produce global variable declaration because that's done in JS" do
|
18
|
-
# This has to be done in JS because we can't possibly avoid variable redefinitions at this stage
|
19
|
-
# it's this or have broken shader chains whenever two shaders happen to export the same variable
|
20
|
-
subject.to_s.should_not =~ /vec4 _shader_ambient;/
|
21
|
-
end
|
22
|
-
# it "should produce global variable declaration" do
|
23
|
-
# subject.to_s.should =~ /vec4 _shader_ambient;/
|
24
|
-
# end
|
25
|
-
|
26
|
-
# moved to JS for greater flexibility -- doing it here we can't adjust for shader chains
|
27
|
-
# it "should produce global variable assignment" do
|
28
|
-
# subject.to_s.should =~ /_shader_ambient = ambient;/
|
29
|
-
# end
|
30
|
-
|
31
|
-
it "should save exports to js" do
|
32
|
-
subject.to_s.should =~ /exports: \{['"]ambient['"]:\s*['"]vec4['"]\},/
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "with conflicting export values" do
|
37
|
-
before(:each) { subject.fragment = "void main(void) { export(vec4, ambient, one); export(vec4, ambient, two); }" }
|
38
|
-
|
39
|
-
# it "should not have two exports" do
|
40
|
-
# subject.to_s.should_not =~ /vec4 _shader_ambient.*vec4 _shader_ambient/
|
41
|
-
# end
|
42
|
-
end
|
43
|
-
|
44
|
-
context "with an import" do
|
45
|
-
before(:each) { subject.fragment = "void main(void)\n{\n vec4 a = import(ambient);\n}" }
|
46
|
-
|
47
|
-
it "should NOT produce global variable reference because that's done in JS" do
|
48
|
-
# This has to be done in JavaScript because we can't possibly know the exports of other shaders at this stage...
|
49
|
-
# it's this or have broken shader chains whenever they're not used in an expected order
|
50
|
-
subject.to_s.should_not =~ /_shader_ambient/
|
51
|
-
end
|
52
|
-
|
53
|
-
# it "should produce global variable reference" do
|
54
|
-
# subject.to_s.should =~ /vec4 a = _shader_ambient;/
|
55
|
-
# end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,92 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
pwd = File.join(Dir.pwd, "generator_tests")
|
4
|
-
|
5
|
-
describe "Rake Tasks:" do
|
6
|
-
def shell
|
7
|
-
@shell ||= SpecShell.new
|
8
|
-
end
|
9
|
-
|
10
|
-
def rake(args)
|
11
|
-
output = `bundle exec rake #{args} 2>&1`
|
12
|
-
if !$?.success?
|
13
|
-
raise output
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
before :all do
|
18
|
-
FileUtils.rm_rf pwd
|
19
|
-
Dir.chdir File.expand_path('..', pwd)
|
20
|
-
FileUtils.mkdir_p pwd
|
21
|
-
Dir.chdir pwd
|
22
|
-
Jax::Generators::App::AppGenerator.start(["test_app"], :shell => shell)
|
23
|
-
# puts shell.output.string
|
24
|
-
Dir.chdir File.join(pwd, "test_app")
|
25
|
-
File.open("Gemfile", "w") { |f| f.print "gem 'jax', :path => '#{File.join(File.dirname(__FILE__), "../../../..")}'"}
|
26
|
-
`bundle install`
|
27
|
-
Jax::Generators::Controller::ControllerGenerator.start(['welcome', 'index'], :shell => shell)
|
28
|
-
File.open("config/routes.rb", "w") do |f|
|
29
|
-
f.puts "TestApp.routes.map do\n root 'welcome'\nmap 'another/index'\nend"
|
30
|
-
end
|
31
|
-
FileUtils.mkdir_p "public/images"
|
32
|
-
FileUtils.touch "public/images/test.png"
|
33
|
-
end
|
34
|
-
|
35
|
-
after :all do
|
36
|
-
FileUtils.rm_rf pwd
|
37
|
-
Dir.chdir File.expand_path('..', pwd)
|
38
|
-
end
|
39
|
-
|
40
|
-
context "jax:generate_files" do
|
41
|
-
before(:each) { rake('jax:generate_files') }
|
42
|
-
subject { File.read(File.expand_path('tmp/version_check.js')) }
|
43
|
-
|
44
|
-
it "should do a version check" do
|
45
|
-
subject.should =~ /jax:update/
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context "jax:package" do
|
50
|
-
before(:each) { rake('jax:package') }
|
51
|
-
|
52
|
-
context "javascript" do
|
53
|
-
subject { File.read(File.expand_path('pkg/javascripts/test_app.js')) }
|
54
|
-
|
55
|
-
it "should install assets" do
|
56
|
-
File.should exist('pkg/images/test.png')
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should not do a version check" do
|
60
|
-
subject.should_not =~ /jax:update/
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should contain views" do
|
64
|
-
subject.should =~ /Jax.views.push\('welcome\/index'/
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should contain welcome controller" do
|
68
|
-
subject.should =~ /var WelcomeController = /
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should contain application controller" do
|
72
|
-
subject.should =~ /var ApplicationController = /
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should contain welcome helper" do
|
76
|
-
subject.should =~ /var WelcomeHelper = /
|
77
|
-
end
|
78
|
-
|
79
|
-
it "should contain application helper" do
|
80
|
-
subject.should =~ /var ApplicationHelper = /
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should contain routes" do
|
84
|
-
subject.should =~ /#{Regexp::escape 'Jax.routes.root(WelcomeController, "index")'}/
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should not contain ruby package names" do
|
88
|
-
subject.should =~ /#{Regexp::escape 'Jax.routes.map("another/index", AnotherController, "index")'}/
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "../lib/jax")
|
2
|
-
require File.join(File.dirname(__FILE__), "../lib/jax/generators/app")
|
3
|
-
require File.join(File.dirname(__FILE__), "../lib/jax/generators/commands")
|
4
|
-
|
5
|
-
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each do |fi|
|
6
|
-
require fi
|
7
|
-
end
|
8
|
-
|
9
|
-
RSpec.configure do |config|
|
10
|
-
config.include FileExistMatcher
|
11
|
-
end
|