eris 0.0.8 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  var jasmineEnyoBootstrap = jasmineEnyoBootstrap || {};
2
2
 
3
+ // exposure for testing
3
4
  jasmineEnyoBootstrap.getXhr = function() {
4
5
  try {
5
6
  return new XMLHttpRequest();
@@ -16,29 +17,61 @@ jasmineEnyoBootstrap.getXhr = function() {
16
17
  return null;
17
18
  };
18
19
 
19
- jasmineEnyoBootstrap.setLaunchParams = function() {
20
+ // exposure for testing
21
+ jasmineEnyoBootstrap.getDocument = function() {
22
+ return document;
23
+ };
24
+
20
25
 
26
+ function ErisConfig() {
21
27
  var xhr = jasmineEnyoBootstrap.getXhr();
22
- xhr.open("GET", "eris_config.json", false);
23
- xhr.send();
24
28
 
25
- if (xhr.status != 200) {
26
- return;
27
- }
29
+ var config;
28
30
 
29
- var launchParams = JSON.parse(xhr.responseText).enyoLaunchParams;
31
+ var self = this;
30
32
 
31
- if (!launchParams) {
32
- return;
33
- }
33
+ self.load = function() {
34
+ xhr.open("GET", "eris_config.json", false);
35
+ xhr.send();
34
36
 
35
- window.history.pushState({}, "Jasmine Suite", "http://localhost:8888?" + buildQueryString());
37
+ if (xhr.status != 200) {
38
+ config = {};
39
+ } else {
40
+ config = JSON.parse(xhr.responseText);
41
+ }
42
+ };
36
43
 
37
- function buildQueryString() {
38
- return Object.keys(launchParams).map(function(key) {
39
- return encodeURIComponent(key) + '=' + encodeURIComponent(launchParams[key]);
40
- }).join('&');
41
- }
42
- };
44
+ self.enyoPath = function() {
45
+ var version = config["enyoVersion"] || "0.10";
46
+
47
+ return "/usr/palm/frameworks/enyo/" + version + "/framework/enyo.js";
48
+ };
49
+
50
+ self.launchParams = function() {
51
+ if (!config.enyoLaunchParams) {
52
+ return [];
53
+ }
43
54
 
44
- jasmineEnyoBootstrap.setLaunchParams();
55
+ return Object.keys(config.enyoLaunchParams).filter(function(key) {
56
+ return config.enyoLaunchParams[key];
57
+ });
58
+ };
59
+
60
+ return self;
61
+ }
62
+
63
+ jasmineEnyoBootstrap.setEnyoArgs = function() {
64
+
65
+ window.enyo = {
66
+ args: {}
67
+ };
68
+
69
+ var config = new ErisConfig();
70
+ config.load();
71
+
72
+ var launchParams = config.launchParams();
73
+
74
+ launchParams.forEach(function(p) {
75
+ enyo.args[p] = true;
76
+ });
77
+ };
@@ -0,0 +1 @@
1
+ jasmineEnyoBootstrap.setEnyoArgs();
@@ -20,9 +20,11 @@ class ErisConfig
20
20
  end
21
21
  end
22
22
 
23
- def enyo_js_path
24
- version = @config_hash['enyoVersion'] || "0.10"
23
+ def enyo_version
24
+ @config_hash['enyoVersion'] || "0.10"
25
+ end
25
26
 
26
- "usr/palm/frameworks/enyo/#{version}/framework/enyo.js"
27
+ def enyo_js_path
28
+ "usr/palm/frameworks/enyo/#{enyo_version}/framework/enyo.js"
27
29
  end
28
30
  end
@@ -5,7 +5,7 @@ module Jasmine
5
5
  def src_files
6
6
  eris_config = ErisConfig.new(:config_path => 'eris_config.json', :app_root => project_root)
7
7
 
8
- files = ["__ERIS_RESOURCES__/jasmineEnyoBootstrap.js", eris_config.enyo_js_path]
8
+ files = ["__ERIS_RESOURCES__/jasmineEnyoBootstrap.js","__ERIS_RESOURCES__/jasmineEnyoLoader.js", eris_config.enyo_js_path]
9
9
  files += match_files(src_dir, simple_config['src_files']) if simple_config['src_files']
10
10
  files
11
11
  end
@@ -16,6 +16,25 @@ module Jasmine
16
16
  end
17
17
  end
18
18
 
19
+
20
+ # This exists in order to allow enyo.args to be initialized outside the Enyo loader's closure, only for
21
+ # when specs are running. We've asked for this line to be added to the Enyo loader. This code is harmless
22
+ # when the line gets added and can be removed from Eris once it is
23
+ module Rack
24
+ class EnyoJs
25
+ def initialize(enyo_js_path)
26
+ @enyo_js_path = "/#{enyo_js_path}"
27
+ end
28
+
29
+ def call(env)
30
+ enyo_js = ::File.read(@enyo_js_path).gsub(/enyo\.args = \{\};/, "enyo.args = enyo.args || {};")
31
+ [200,
32
+ { "Content-Type" => 'application/javascript' },
33
+ [enyo_js]]
34
+ end
35
+ end
36
+ end
37
+
19
38
  module Jasmine
20
39
  def self.app(config)
21
40
  Rack::Builder.app do
@@ -29,6 +48,7 @@ module Jasmine
29
48
  map(config.root_path) { run Rack::File.new(config.project_root) }
30
49
 
31
50
  eris_config = ErisConfig.new(:config_path => 'eris_config.json', :app_root => config.project_root)
51
+ map("/#{eris_config.enyo_js_path}") { run Rack::EnyoJs.new(eris_config.enyo_js_path) }
32
52
  map("/usr/palm/frameworks") { run Rack::File.new(eris_config.enyo_root) }
33
53
 
34
54
  map("/__ERIS_RESOURCES__") { run Rack::File.new(File.expand_path(File.join(File.dirname(__FILE__), '/../js'))) }
@@ -4,16 +4,18 @@ module Eris
4
4
  class Tasks < Thor
5
5
  desc "generate", "generate an enyo application"
6
6
  def generate
7
- template "lib/eris/templates/Gemfile",'Gemfile'
8
- template "lib/eris/templates/Rakefile",'Rakefile'
9
- template "lib/eris/templates/jasmine.yml", "spec/unit/support/jasmine.yml"
10
- template "lib/eris/templates/sampleSpec.js", "spec/unit/source/sampleSpec.js"
7
+ #template "lib/eris/templates/Gemfile",'Gemfile'
8
+ #template "lib/eris/templates/Rakefile",'Rakefile'
9
+ #template "lib/eris/templates/jasmine.yml", "spec/unit/support/jasmine.yml"
10
+ #template "lib/eris/templates/sampleSpec.js", "spec/unit/source/sampleSpec.js"
11
+ directory "lib/eris/templates/sample_app", "."
11
12
  create_file ".rvmrc", "rvm use ruby-1.9.2-p180@palm"
12
- template "lib/eris/templates/ci_build.sh", "ci_build.sh"
13
+ #template "lib/eris/templates/ci_build.sh", "ci_build.sh"
13
14
  chmod "ci_build.sh", 0755
14
- template "lib/eris/templates/eris_config.json", "eris_config.json"
15
+ #template "lib/eris/templates/eris_config.json", "eris_config.json"
15
16
  empty_directory "spec/unit/source/mock"
16
- template "lib/eris/templates/specHelper.js", "spec/unit/specHelper.js"
17
+ empty_directory "spec/helpers/testResponses"
18
+ #template "lib/eris/templates/specHelper.js", "spec/unit/specHelper.js"
17
19
  end
18
20
  end
19
21
  end
@@ -0,0 +1 @@
1
+ var testResponses = {};
@@ -1,3 +1,3 @@
1
1
  module Eris
2
- Eris::VERSION = "0.0.8"
2
+ Eris::VERSION = "0.0.10"
3
3
  end
@@ -2,7 +2,7 @@
2
2
  "localEnyoRoot": "../",
3
3
  "ciEnyoRoot": "../ciboxenyo",
4
4
  "enyoLaunchParams": {
5
- "foo": "bar baz",
6
- "zip": 12
5
+ "foo": true,
6
+ "bar": false
7
7
  }
8
8
  }
@@ -0,0 +1,50 @@
1
+ describe("setEnyoArgs", function () {
2
+ var enyoTag, fakeXhr, fakeResponse, fakeDocument;
3
+
4
+ beforeEach(function() {
5
+ enyo = {};
6
+ fakeXhr = {
7
+ open: function() {
8
+ },
9
+ send: function() {
10
+ fakeXhr.status = fakeResponse.status;
11
+ fakeXhr.responseText = fakeResponse.responseText;
12
+ },
13
+ responseText: null
14
+ };
15
+
16
+ fakeDocument = document.createElement('div');
17
+ fakeDocument.setAttribute('class', 'fake doc');
18
+ fakeDocument.appendChild(document.createElement('head'));
19
+
20
+ spyOn(jasmineEnyoBootstrap, 'getXhr').andReturn(fakeXhr);
21
+ });
22
+
23
+
24
+ describe("with defaults", function () {
25
+ beforeEach(function() {
26
+ fakeResponse = testResponses.erisConfig.withDefaults.success;
27
+
28
+ jasmineEnyoBootstrap.setEnyoArgs();
29
+ });
30
+
31
+ it("should give enyo no launch params", function() {
32
+ expect(enyo.args).toEqual({})
33
+ });
34
+ });
35
+
36
+ describe("with overrides", function () {
37
+ beforeEach(function() {
38
+ fakeResponse = testResponses.erisConfig.withOverrides.success;
39
+
40
+ jasmineEnyoBootstrap.setEnyoArgs();
41
+ });
42
+
43
+ it("should give enyo the requested launch params", function() {
44
+ expect(enyo.args).toBeDefined();
45
+ expect(enyo.args.foo).toBeTruthy();
46
+ expect(enyo.args.baz).toBeTruthy();
47
+ });
48
+ });
49
+
50
+ });
@@ -0,0 +1,69 @@
1
+ describe("ErisConfig", function () {
2
+ var erisConfig, fakeXhr, fakeResponse;
3
+
4
+ beforeEach(function() {
5
+
6
+ fakeXhr = {
7
+ open: function() {
8
+ },
9
+ send: function() {
10
+ fakeXhr.status = fakeResponse.status;
11
+ fakeXhr.responseText = fakeResponse.responseText;
12
+ },
13
+ responseText: null
14
+ };
15
+ spyOn(jasmineEnyoBootstrap, 'getXhr').andReturn(fakeXhr);
16
+
17
+ erisConfig = new ErisConfig();
18
+ });
19
+
20
+ describe("#enyoPath", function () {
21
+
22
+ describe("with defaults", function () {
23
+ beforeEach(function() {
24
+ fakeResponse = testResponses.erisConfig.withDefaults.success;
25
+ erisConfig.load();
26
+ });
27
+
28
+ it("should return a path to the default version", function() {
29
+ expect(erisConfig.enyoPath()).toEqual('/usr/palm/frameworks/enyo/0.10/framework/enyo.js');
30
+ });
31
+ });
32
+
33
+ describe("with overrides", function () {
34
+ beforeEach(function() {
35
+ fakeResponse = testResponses.erisConfig.withOverrides.success;
36
+ erisConfig.load();
37
+ });
38
+
39
+ it("should return a path to the default version", function() {
40
+ expect(erisConfig.enyoPath()).toEqual('/usr/palm/frameworks/enyo/19/framework/enyo.js');
41
+ });
42
+ });
43
+ });
44
+
45
+ describe("#launchParams", function () {
46
+
47
+ describe("when no launch parameters are specified", function () {
48
+ beforeEach(function() {
49
+ fakeResponse = testResponses.erisConfig.withDefaults.success;
50
+ erisConfig.load();
51
+ });
52
+
53
+ it("should return an empty array", function() {
54
+ expect(erisConfig.launchParams()).toEqual([]);
55
+ });
56
+ });
57
+
58
+ describe("when launch parameters are specified", function () {
59
+ beforeEach(function() {
60
+ fakeResponse = testResponses.erisConfig.withOverrides.success;
61
+ erisConfig.load();
62
+ });
63
+
64
+ it("should return a comma-delimited list of truthy keys", function() {
65
+ expect(erisConfig.launchParams()).toEqual(["foo","baz"]);
66
+ });
67
+ });
68
+ });
69
+ });
@@ -1,7 +1,7 @@
1
1
  testResponses = {};
2
2
 
3
3
  testResponses.erisConfig = {
4
- noLaunchParams: {
4
+ withDefaults: {
5
5
  success: {
6
6
  status: 200,
7
7
  responseText: JSON.stringify({
@@ -12,15 +12,17 @@ testResponses.erisConfig = {
12
12
  }
13
13
  },
14
14
 
15
- withLaunchParams: {
15
+ withOverrides: {
16
16
  success: {
17
17
  status: 200,
18
18
  responseText: JSON.stringify({
19
19
  "localEnyoRoot": "../",
20
20
  "ciEnyoRoot": "../ciboxenyo",
21
+ "enyoVersion": "19",
21
22
  "enyoLaunchParams": {
22
- "foo": "bar baz",
23
- "zip": 12
23
+ "foo": true,
24
+ "bar": false,
25
+ "baz": true
24
26
  }
25
27
  }
26
28
  )
@@ -11,7 +11,7 @@
11
11
  # - dist/**/*.js
12
12
  #
13
13
  src_files:
14
- - lib/eris/js/**/*.js
14
+ - lib/eris/js/**/jasmineEnyoBootstrap.js
15
15
 
16
16
  # stylesheets
17
17
  #
@@ -11,30 +11,32 @@ describe Eris do
11
11
 
12
12
  describe "generate command" do
13
13
  before :each do
14
- # capture_output do
14
+ capture_output do
15
15
  Dir.chdir @tmp_dir do
16
16
  @thor.invoke Eris::Tasks, "generate"
17
17
  end
18
- # end
18
+ end
19
19
  end
20
20
 
21
21
  it "should run jasmine:ci" do
22
22
  Bundler.with_clean_env do
23
23
  gem_dir = File.expand_path('../../../../', File.dirname(__FILE__))
24
- system! "cd #{gem_dir} && bundle exec rake build"
25
- system! "mkdir -p #{@tmp_dir}/vendor/cache/"
26
- system! "cp #{gem_dir}/pkg/eris-#{Eris::VERSION}.gem #{@tmp_dir}/vendor/cache/"
27
- system "cd #{@tmp_dir} && rvm-exec ruby-1.9.2-p180@palm-test bash -c 'gem uninstall -aIx eris'"
28
- system! "cd #{@tmp_dir} && rvm-exec ruby-1.9.2-p180@palm-test bash -c 'gem list | grep bundler || gem install bundler'"
29
- system! "cd #{@tmp_dir} && rvm-exec ruby-1.9.2-p180@palm-test bash -c 'bundle install'"
30
- system! "cd #{@tmp_dir} && rvm-exec ruby-1.9.2-p180@palm-test bash -c 'bundle exec gem list | grep eris'"
31
- system! "cd #{@tmp_dir} && rvm-exec ruby-1.9.2-p180@palm-test bash -c 'bundle exec gem list | grep jasmine'"
32
- system "cd #{@tmp_dir} && rvm-exec ruby-1.9.2-p180@palm-test bash -c 'bundle show jasmine'"
24
+ gemfile_location = "#{@tmp_dir}/Gemfile"
25
+ gemfile_contents = File.read(gemfile_location).gsub(%Q{gem "eris"}, %Q{gem "eris", :path => "#{gem_dir}"})
26
+
27
+ File.open(gemfile_location, 'w') { |file| file << gemfile_contents }
28
+ system("echo 'rvm use ruby-1.9.2-p180@palm-test' > #{@tmp_dir}/.rvmrc")
29
+ system "cd #{@tmp_dir} && gem uninstall -aIx eris"
30
+ system! "cd #{@tmp_dir} && gem list | grep bundler || gem install bundler"
31
+ system! "cd #{@tmp_dir} && bundle install"
32
+ system! "cd #{@tmp_dir} && bundle exec gem list | grep eris"
33
+ system! "cd #{@tmp_dir} && bundle exec gem list | grep jasmine"
34
+ system "cd #{@tmp_dir} && bundle show jasmine"
33
35
  eris_config_location = "#{@tmp_dir}eris_config.json"
34
36
  eris_config = File.read(eris_config_location)
35
37
  eris_config.gsub!("../../", "/usr/palm/frameworks/")
36
38
  File.open(eris_config_location, 'w') {|f| f.write(eris_config) }
37
- system("cd #{@tmp_dir} && rvm-exec ruby-1.9.2-p180@palm-test bash -c 'bundle exec rake jasmine:ci'").should be_true
39
+ system("cd #{@tmp_dir} && bundle exec rake jasmine:ci").should be_true
38
40
  end
39
41
  end
40
42
  end
@@ -46,6 +46,18 @@ describe Eris do
46
46
  rakefile_contents.should include('describe')
47
47
  end
48
48
  end
49
+
50
+ it "should generate a testResponses directory" do
51
+ Dir.chdir @tmp_dir do
52
+ File.exists?('spec/helpers/testResponses').should be_true
53
+ end
54
+ end
55
+
56
+ it "should generate a testResponses.js file" do
57
+ Dir.chdir @tmp_dir do
58
+ File.exists?('spec/helpers/testResponses.js').should be_true
59
+ end
60
+ end
49
61
 
50
62
  it "should generate a spec/unit/source/mock" do
51
63
  Dir.chdir @tmp_dir do
@@ -55,7 +67,7 @@ describe Eris do
55
67
 
56
68
  it "should generate a spec/unit/specHelper.js" do
57
69
  Dir.chdir @tmp_dir do
58
- rakefile_contents = File.read("spec/unit/specHelper.js")
70
+ rakefile_contents = File.read("spec/helpers/specHelper.js")
59
71
  rakefile_contents.should include('getJson')
60
72
  end
61
73
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eris
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 8
10
- version: 0.0.8
9
+ - 10
10
+ version: 0.0.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - HP webOS
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-08-08 00:00:00 -07:00
19
+ date: 2011-08-22 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -224,6 +224,7 @@ files:
224
224
  - lib/eris.rb
225
225
  - lib/eris/eris.ru
226
226
  - lib/eris/js/jasmineEnyoBootstrap.js
227
+ - lib/eris/js/jasmineEnyoLoader.js
227
228
  - lib/eris/lib/eris_config.rb
228
229
  - lib/eris/lib/jasmine_config_overrides.rb
229
230
  - lib/eris/lib/jasmine_rspec_runner.rb
@@ -232,13 +233,14 @@ files:
232
233
  - lib/eris/lib/server.rb
233
234
  - lib/eris/tasks/generate.rb
234
235
  - lib/eris/tasks/server.rb
235
- - lib/eris/templates/Gemfile
236
- - lib/eris/templates/Rakefile
237
- - lib/eris/templates/ci_build.sh
238
- - lib/eris/templates/eris_config.json
239
- - lib/eris/templates/jasmine.yml
240
- - lib/eris/templates/sampleSpec.js
241
- - lib/eris/templates/specHelper.js
236
+ - lib/eris/templates/sample_app/Gemfile
237
+ - lib/eris/templates/sample_app/Rakefile
238
+ - lib/eris/templates/sample_app/ci_build.sh
239
+ - lib/eris/templates/sample_app/eris_config.json
240
+ - lib/eris/templates/sample_app/spec/helpers/specHelper.js
241
+ - lib/eris/templates/sample_app/spec/helpers/testResponses.js
242
+ - lib/eris/templates/sample_app/spec/unit/source/sampleSpec.js
243
+ - lib/eris/templates/sample_app/spec/unit/support/jasmine.yml
242
244
  - lib/eris/version.rb
243
245
  - spec/fixtures/enyo/0.10/framework/enyo.js
244
246
  - spec/fixtures/sample_app/app/models/foo.js
@@ -250,7 +252,8 @@ files:
250
252
  - spec/fixtures/sample_app/spec/acceptance/helpers/AppHelper.js
251
253
  - spec/fixtures/vcr_cassettes/failure.yml
252
254
  - spec/fixtures/vcr_cassettes/success.yml
253
- - spec/javascripts/SetLaunchParamsSpec.js
255
+ - spec/javascripts/EnyoLoaderSpec.js
256
+ - spec/javascripts/ErisConfigSpec.js
254
257
  - spec/javascripts/helpers/TestResponses.js
255
258
  - spec/javascripts/helpers/specHelper.js
256
259
  - spec/javascripts/support/jasmine.yml
@@ -310,7 +313,8 @@ test_files:
310
313
  - spec/fixtures/sample_app/spec/acceptance/helpers/AppHelper.js
311
314
  - spec/fixtures/vcr_cassettes/failure.yml
312
315
  - spec/fixtures/vcr_cassettes/success.yml
313
- - spec/javascripts/SetLaunchParamsSpec.js
316
+ - spec/javascripts/EnyoLoaderSpec.js
317
+ - spec/javascripts/ErisConfigSpec.js
314
318
  - spec/javascripts/helpers/TestResponses.js
315
319
  - spec/javascripts/helpers/specHelper.js
316
320
  - spec/javascripts/support/jasmine.yml
@@ -1,37 +0,0 @@
1
- describe("setLaunchParams", function () {
2
- var fakeXhr, fakeResponse;
3
- beforeEach(function() {
4
- window.history.pushState({}, "Jasmine Suite", "http://localhost:8888/");
5
- fakeXhr = {
6
- open: function() {},
7
- send: function() {
8
- fakeXhr.status = fakeResponse.status;
9
- fakeXhr.responseText = fakeResponse.responseText;
10
- },
11
- responseText: null
12
- };
13
- spyOn(jasmineEnyoBootstrap, 'getXhr').andReturn(fakeXhr);
14
- });
15
-
16
- describe("when no launch parameters are specified", function () {
17
- beforeEach(function() {
18
- fakeResponse = testResponses.erisConfig.noLaunchParams.success;
19
- jasmineEnyoBootstrap.setLaunchParams();
20
- });
21
-
22
- it("should not put any params onto the window's query string", function() {
23
- expect(window.location.search).toEqual("");
24
- });
25
- });
26
-
27
- describe("when launch parameters are specified", function () {
28
- beforeEach(function() {
29
- fakeResponse = testResponses.erisConfig.withLaunchParams.success;
30
- jasmineEnyoBootstrap.setLaunchParams();
31
- });
32
-
33
- it("should put any params from eris_config.json onto the window", function() {
34
- expect(window.location.search).toEqual("?foo=bar%20baz&zip=12");
35
- });
36
- });
37
- });