excursion 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'Excursion::Helpers::ApplicationHelper' do
3
+ describe 'Excursion::Builders::ApplicationBuilder' do
4
4
  before(:all) do
5
5
  Excursion::Pool.class_variable_set(:@@applications, {})
6
6
  File.unlink(Excursion::Specs::DUMMY_POOL_FILE) if File.exists?(Excursion::Specs::DUMMY_POOL_FILE)
@@ -27,8 +27,8 @@ describe 'Excursion::Helpers::ApplicationHelper' do
27
27
  end
28
28
 
29
29
  context 'when the requested application is in the pool' do
30
- it 'should return an application UrlHelper for the app' do
31
- Excursion.url_helpers.excursion('dummy').should be_an_instance_of(Excursion::Helpers::UrlHelper)
30
+ it 'should return an application UrlBuilder for the app' do
31
+ Excursion.url_helpers.excursion('dummy').should be_an_instance_of(Excursion::Builders::UrlBuilder)
32
32
  Excursion.url_helpers.excursion('dummy').application.should eql(Excursion::Pool.application('dummy'))
33
33
  end
34
34
  end
@@ -40,7 +40,7 @@ describe 'Excursion::Helpers::ApplicationHelper' do
40
40
  end
41
41
  end
42
42
 
43
- it 'should allow referencing application helper methods directly by name' do
43
+ it 'should allow referencing application builder methods directly by name' do
44
44
  expect { Excursion.url_helpers.dummy }.to_not raise_exception#(NoMethodError)
45
45
  Excursion.url_helpers.dummy.should eql(Excursion.url_helpers.excursion('dummy'))
46
46
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'Excursion::Helpers::UrlHelper' do
3
+ describe 'Excursion::Builders::UrlBuilder' do
4
4
  before(:all) do
5
5
  Excursion::Pool.class_variable_set(:@@applications, {})
6
6
  File.unlink(Excursion::Specs::DUMMY_POOL_FILE) if File.exists?(Excursion::Specs::DUMMY_POOL_FILE)
@@ -38,7 +38,7 @@ describe 'Excursion::Helpers::UrlHelper' do
38
38
  context 'url helper methods' do
39
39
  before(:all) do
40
40
  Excursion.configuration.default_url_options = {host: 'test.example.com', port: 3000}
41
- Excursion::Helpers.instance_variable_get(:@helpers).delete('dummy')
41
+ Excursion::Builders.instance_variable_get(:@builders).delete('dummy')
42
42
  Excursion::Pool.remove_application(Rails.application)
43
43
  Excursion::Pool.register_application(Rails.application)
44
44
  end
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- class Excursion::Specs::TestHelperOne
4
- include Excursion::Helpers::ApplicationHelper
3
+ class Excursion::Specs::TestBuilderOne
4
+ include Excursion::Builders::ApplicationBuilder
5
5
  end
6
- class Excursion::Specs::TestHelperTwo
7
- include Excursion::Helpers::ApplicationHelper
6
+ class Excursion::Specs::TestBuilderTwo
7
+ include Excursion::Builders::ApplicationBuilder
8
8
  end
9
9
 
10
10
  describe 'Excursion' do
@@ -35,7 +35,7 @@ describe 'Excursion' do
35
35
  end
36
36
  end
37
37
 
38
- describe 'Excursion::Helpers' do
38
+ describe 'Excursion::Builders' do
39
39
  before(:each) do
40
40
  Excursion::Pool.class_variable_set(:@@applications, {})
41
41
  File.unlink(Excursion::Specs::DUMMY_POOL_FILE) if File.exists?(Excursion::Specs::DUMMY_POOL_FILE)
@@ -55,11 +55,11 @@ describe 'Excursion::Helpers' do
55
55
  end
56
56
  end
57
57
 
58
- it 'should share instances of helper classes' do
59
- h1 = Excursion::Specs::TestHelperOne.new
60
- h2 = Excursion::Specs::TestHelperTwo.new
58
+ it 'should share instances of builder classes' do
59
+ h1 = Excursion::Specs::TestBuilderOne.new
60
+ h2 = Excursion::Specs::TestBuilderTwo.new
61
61
  Excursion::Pool.register_application(Rails.application)
62
62
  h1.dummy.should eql(h2.dummy)
63
- h1.dummy.should eql(Excursion::Specs::TestHelperOne.new.dummy)
63
+ h1.dummy.should eql(Excursion::Specs::TestBuilderOne.new.dummy)
64
64
  end
65
65
  end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe Excursion::JavascriptHelper do
4
+ before(:all) do
5
+ Excursion::Pool.class_variable_set(:@@applications, {})
6
+ File.unlink(Excursion::Specs::DUMMY_POOL_FILE) if File.exists?(Excursion::Specs::DUMMY_POOL_FILE)
7
+ Excursion.configure do |config|
8
+ config.datastore = :file
9
+ config.datastore_file = Excursion::Specs::DUMMY_POOL_FILE
10
+ end
11
+ Excursion::Pool.register_application(Rails.application)
12
+ end
13
+
14
+ after(:all) do
15
+ Excursion::Pool.class_variable_set(:@@applications, {})
16
+ File.unlink(Excursion::Specs::DUMMY_POOL_FILE) if File.exists?(Excursion::Specs::DUMMY_POOL_FILE)
17
+ Excursion.configure do |config|
18
+ config.datastore = nil
19
+ config.datastore_file = nil
20
+ config.memcache_server = nil
21
+ end
22
+ end
23
+
24
+ describe "#render_excursion_javascript_helpers" do
25
+ it "should return an ActiveSupport::SafeBuffer string" do
26
+ expect(helper.render_excursion_javascript_helpers).to be_an_instance_of(ActiveSupport::SafeBuffer)
27
+ end
28
+
29
+ it "should return a script tag which loads the pool" do
30
+ expect(helper.render_excursion_javascript_helpers.match(/\A<script.*>Excursion\.loadPool\(.*\);<\/script>\Z/)[0]).to_not be_nil
31
+ end
32
+
33
+ it "should base64 encode the dumped route pool" do
34
+ pool = helper.render_excursion_javascript_helpers.match(/\A<script.*>Excursion\.loadPool\('(.*)'\);<\/script>\Z/)[1]
35
+ expect(JSON.parse(Base64.decode64(pool))).to be_an_instance_of(Array)
36
+ end
37
+ end
38
+ end
@@ -1,5 +1,6 @@
1
1
  require File.expand_path("../dummy/config/environment", __FILE__)
2
2
  require 'rspec/core'
3
+ require 'rspec/rails'
3
4
 
4
5
  ActiveRecord::Base.establish_connection :adapter => "sqlite3",
5
6
  :database => ":memory:"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: excursion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Rebec
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-16 00:00:00.000000000 Z
11
+ date: 2014-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -82,14 +82,13 @@ files:
82
82
  - lib/excursion/exceptions/pool.rb
83
83
  - lib/excursion/exceptions/active_record.rb
84
84
  - lib/excursion/exceptions/memcache.rb
85
+ - lib/excursion/asset_middleware.rb
85
86
  - lib/excursion/pool/dummy_application.rb
86
87
  - lib/excursion/pool/dsl.rb
87
88
  - lib/excursion/pool/application.rb
88
89
  - lib/excursion/railtie.rb
89
90
  - lib/excursion/configuration.rb
90
- - lib/excursion/helpers/url_helper.rb
91
- - lib/excursion/helpers/javascript_helper.rb
92
- - lib/excursion/helpers/application_helper.rb
91
+ - lib/excursion/builders.rb
93
92
  - lib/excursion/exceptions.rb
94
93
  - lib/excursion/datastores/datastore.rb
95
94
  - lib/excursion/datastores/active_record_with_memcache.rb
@@ -97,13 +96,15 @@ files:
97
96
  - lib/excursion/datastores/active_record.rb
98
97
  - lib/excursion/datastores/memcache.rb
99
98
  - lib/excursion/datastores/test.rb
100
- - lib/excursion/helpers.rb
101
99
  - lib/excursion/route_pool.rb
102
100
  - lib/excursion/version.rb
103
101
  - lib/excursion/cors.rb
102
+ - lib/excursion/builders/application_builder.rb
103
+ - lib/excursion/builders/url_builder.rb
104
104
  - lib/generators/excursion/active_record_generator.rb
105
105
  - lib/generators/excursion/templates/migration.rb
106
106
  - lib/excursion.rb
107
+ - app/helpers/excursion/javascript_helper.rb
107
108
  - app/assets/javascripts/excursion.js
108
109
  - app/assets/javascripts/excursion/pool.js.erb
109
110
  - config/routes.rb
@@ -148,19 +149,20 @@ files:
148
149
  - spec/dummy/app/assets/images/rails.png
149
150
  - spec/dummy/Rakefile
150
151
  - spec/support/mocks.rb
151
- - spec/excursion/helpers_spec.rb
152
152
  - spec/excursion/route_pool_spec.rb
153
153
  - spec/excursion/pool/dsl_spec.rb
154
154
  - spec/excursion/pool/application_spec.rb
155
155
  - spec/excursion/pool/dummy_application_spec.rb
156
156
  - spec/excursion/pool_spec.rb
157
- - spec/excursion/helpers/url_helper_spec.rb
158
- - spec/excursion/helpers/application_helper_spec.rb
159
157
  - spec/excursion/datastores/test_spec.rb
160
158
  - spec/excursion/datastores/active_record_with_memcache_spec.rb
161
159
  - spec/excursion/datastores/active_record_spec.rb
162
160
  - spec/excursion/datastores/memcache_spec.rb
163
161
  - spec/excursion/datastores/file_spec.rb
162
+ - spec/excursion/builders_spec.rb
163
+ - spec/excursion/builders/url_builder_spec.rb
164
+ - spec/excursion/builders/application_builder_spec.rb
165
+ - spec/helpers/excursion/javascript_helper_spec.rb
164
166
  - spec/spec_helper.rb
165
167
  homepage: http://github.com/markrebec/excursion
166
168
  licenses:
@@ -228,18 +230,19 @@ test_files:
228
230
  - spec/dummy/app/assets/images/rails.png
229
231
  - spec/dummy/Rakefile
230
232
  - spec/support/mocks.rb
231
- - spec/excursion/helpers_spec.rb
232
233
  - spec/excursion/route_pool_spec.rb
233
234
  - spec/excursion/pool/dsl_spec.rb
234
235
  - spec/excursion/pool/application_spec.rb
235
236
  - spec/excursion/pool/dummy_application_spec.rb
236
237
  - spec/excursion/pool_spec.rb
237
- - spec/excursion/helpers/url_helper_spec.rb
238
- - spec/excursion/helpers/application_helper_spec.rb
239
238
  - spec/excursion/datastores/test_spec.rb
240
239
  - spec/excursion/datastores/active_record_with_memcache_spec.rb
241
240
  - spec/excursion/datastores/active_record_spec.rb
242
241
  - spec/excursion/datastores/memcache_spec.rb
243
242
  - spec/excursion/datastores/file_spec.rb
243
+ - spec/excursion/builders_spec.rb
244
+ - spec/excursion/builders/url_builder_spec.rb
245
+ - spec/excursion/builders/application_builder_spec.rb
246
+ - spec/helpers/excursion/javascript_helper_spec.rb
244
247
  - spec/spec_helper.rb
245
248
  has_rdoc:
@@ -1,32 +0,0 @@
1
- require 'excursion/helpers/url_helper'
2
- require 'excursion/helpers/application_helper'
3
- require 'excursion/helpers/javascript_helper'
4
-
5
- module Excursion
6
- module Helpers
7
- def self.helpers
8
- @helpers ||= {}
9
- end
10
-
11
- def self.helper(name)
12
- helpers[name]
13
- end
14
-
15
- # Helpers register themselves here when they're created so they can be shared
16
- # between different instances (like the StaticHelper below and ActionController)
17
- def self.register_helper(h)
18
- @helpers ||= {}
19
- @helpers[h.application.name] = h
20
- h
21
- end
22
- end
23
-
24
- class StaticHelper
25
- include Helpers::ApplicationHelper
26
- end
27
-
28
- # Provides quick global access to url helpers with using the StaticHelper
29
- def self.url_helpers
30
- @url_helpers ||= StaticHelper.new
31
- end
32
- end
@@ -1,12 +0,0 @@
1
- module Excursion
2
- module Helpers
3
- module JavascriptHelper
4
- def render_excursion_javascript_helpers
5
- content_tag :script, raw("Excursion.loadPool('#{raw Base64.encode64(Excursion::Pool.all_applications.values.map(&:to_cache).to_json.to_s).gsub("\n","")}');"), type: "text/javascript"
6
- end
7
-
8
- end
9
- end
10
- end
11
-
12
- ActionController::Base.send :helper, Excursion::Helpers::JavascriptHelper