guilded 1.1.0 → 2.0.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -4
- data/.rspec +2 -0
- data/.rvmrc +1 -1
- data/Gemfile +1 -21
- data/Guardfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +21 -0
- data/Rakefile +1 -1
- data/guilded.gemspec +23 -24
- data/lib/{generators/guilded_assets/templates → assets/javascripts}/guilded.js +0 -0
- data/lib/assets/javascripts/jquery-1.6.4.js +9046 -0
- data/lib/assets/javascripts/jquery-1.6.4.min.js +4 -0
- data/lib/assets/javascripts/jquery-1.7.1.js +9266 -0
- data/lib/assets/javascripts/jquery-1.7.1.min.js +4 -0
- data/lib/assets/javascripts/jquery-1.7.2.js +9404 -0
- data/lib/assets/javascripts/jquery-1.7.2.min.js +4 -0
- data/lib/assets/javascripts/jquery-1.8.0.js +9227 -0
- data/lib/assets/javascripts/jquery-1.8.0.min.js +2 -0
- data/lib/assets/javascripts/jquery-1.8.1.js +9301 -0
- data/lib/assets/javascripts/jquery-1.8.1.min.js +2 -0
- data/lib/assets/javascripts/jquery-1.8.2.js +9440 -0
- data/lib/assets/javascripts/jquery-1.8.2.min.js +2 -0
- data/lib/assets/javascripts/jquery-1.8.3.js +9472 -0
- data/lib/assets/javascripts/jquery-1.8.3.min.js +2 -0
- data/lib/assets/javascripts/jquery-1.9.0.js +9555 -0
- data/lib/assets/javascripts/jquery-1.9.0.min.js +4 -0
- data/lib/assets/javascripts/jquery-1.9.1.js +9597 -0
- data/lib/assets/javascripts/jquery-1.9.1.min.js +5 -0
- data/lib/guilded.rb +23 -73
- data/lib/guilded/component.rb +32 -0
- data/lib/guilded/configuration.rb +27 -0
- data/lib/guilded/data.rb +25 -0
- data/lib/guilded/engine.rb +5 -0
- data/lib/guilded/guilder.rb +27 -370
- data/lib/guilded/rails.rb +7 -4
- data/lib/guilded/rails/controller.rb +23 -0
- data/lib/guilded/rails/helpers.rb +1 -3
- data/lib/guilded/rails/view_helpers.rb +16 -112
- data/lib/guilded/version.rb +1 -1
- data/spec/guilded/component_spec.rb +13 -0
- data/spec/guilded/configuration_spec.rb +68 -0
- data/spec/guilded/data_spec.rb +29 -0
- data/spec/guilded/guilder_spec.rb +67 -63
- data/spec/guilded/rails/view_helpers_spec.rb +49 -0
- data/spec/spec_helper.rb +5 -29
- metadata +174 -122
- data/Gemfile.lock +0 -61
- data/README.rdoc +0 -204
- data/lib/generators/guilded_assets/guilded_assets_generator.rb +0 -21
- data/lib/generators/guilded_assets/templates/guilded.min.js +0 -1
- data/lib/generators/guilded_assets/templates/jquery-1.2.6.js +0 -3549
- data/lib/generators/guilded_assets/templates/jquery-1.2.6.min.js +0 -32
- data/lib/generators/guilded_assets/templates/jquery-1.3.2.js +0 -4376
- data/lib/generators/guilded_assets/templates/jquery-1.3.2.min.js +0 -19
- data/lib/generators/guilded_assets/templates/jquery-url.js +0 -199
- data/lib/generators/guilded_assets/templates/jquery-url.min.js +0 -9
- data/lib/generators/guilded_assets/templates/mootools-1.2.3.js +0 -4036
- data/lib/generators/guilded_assets/templates/mootools-1.2.3.min.js +0 -356
- data/lib/generators/guilded_assets/templates/reset-min.css +0 -7
- data/lib/generators/guilded_config/guilded_config_generator.rb +0 -11
- data/lib/generators/guilded_config/templates/guilded_config.rb +0 -16
- data/lib/guilded/component_def.rb +0 -27
- data/lib/guilded/exceptions.rb +0 -29
- data/lib/guilded/rails/active_record/human_attribute_hint.rb +0 -41
- data/lib/guilded/rails/controller_actions.rb +0 -22
- data/lib/guilded/rails/inactive_record/human_attribute_hint.rb +0 -26
- data/rails_generators/guilded_assets/guilded_assets_generator.rb +0 -23
- data/rails_generators/guilded_assets/templates/guilded.js +0 -12
- data/rails_generators/guilded_assets/templates/guilded.min.js +0 -1
- data/rails_generators/guilded_assets/templates/jquery-1.2.6.js +0 -3549
- data/rails_generators/guilded_assets/templates/jquery-1.2.6.min.js +0 -32
- data/rails_generators/guilded_assets/templates/jquery-1.3.2.js +0 -4376
- data/rails_generators/guilded_assets/templates/jquery-1.3.2.min.js +0 -19
- data/rails_generators/guilded_assets/templates/jquery-url.js +0 -199
- data/rails_generators/guilded_assets/templates/jquery-url.min.js +0 -9
- data/rails_generators/guilded_assets/templates/mootools-1.2.3.js +0 -4036
- data/rails_generators/guilded_assets/templates/mootools-1.2.3.min.js +0 -356
- data/rails_generators/guilded_assets/templates/reset-min.css +0 -7
- data/rails_generators/guilded_config/guilded_config_generator.rb +0 -11
- data/rails_generators/guilded_config/templates/guilded_config.rb +0 -16
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/spec/generators/guilded_assets_generator_spec.rb +0 -35
- data/spec/generators/guilded_config_generator_spec.rb +0 -24
- data/spec/guilded/component_def_spec.rb +0 -24
- data/spec/guilded_spec.rb +0 -7
- data/spec/spec.opts +0 -7
- data/tasks/rails.rake +0 -8
- data/tasks/rspec.rake +0 -21
- data/test/guilded/rails/helpers_test.rb +0 -1450
- data/test/test_helper.rb +0 -39
data/lib/guilded/rails.rb
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Guilded::Rails
|
|
2
|
+
module Controller
|
|
3
|
+
|
|
4
|
+
def self.included( base )
|
|
5
|
+
base.instance_eval do
|
|
6
|
+
attr_reader :guilded
|
|
7
|
+
helper_method :guilded
|
|
8
|
+
before_filter :initialize_guilded
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
base.send :include, InstanceMethods
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
module InstanceMethods
|
|
15
|
+
|
|
16
|
+
def initialize_guilded
|
|
17
|
+
@guilded = Guilded::Guilder.new
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -1,118 +1,22 @@
|
|
|
1
|
-
module Guilded
|
|
2
|
-
module
|
|
3
|
-
module ViewHelpers
|
|
1
|
+
module Guilded::Rails
|
|
2
|
+
module ViewHelpers
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
# Must be called once per rendered page. You can include it just before the closing body
|
|
9
|
-
# tag of your application layout. If no Guilded elements were called in the template, the
|
|
10
|
-
# call to g_apply_behavior will not output anything.
|
|
11
|
-
#
|
|
12
|
-
def g_apply_behavior( options={} )
|
|
13
|
-
Guilded::Guilder.instance.generate_javascript_init( options )
|
|
14
|
-
end
|
|
4
|
+
def jquery_include_tag( options={} )
|
|
5
|
+
version = options.fetch( :version, Guilded.configuration.jquery_version )
|
|
6
|
+
min = options.fetch( :min, false )
|
|
15
7
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# Must be called once per rendered page. You can include it just before the closing body
|
|
19
|
-
# tag of your application layout. If no Guilded elements were called in the template, the
|
|
20
|
-
# call to g_apply_includes will not output anything.
|
|
21
|
-
#
|
|
22
|
-
def g_apply_includes
|
|
23
|
-
g = Guilded::Guilder.instance
|
|
24
|
-
g.generate_asset_lists
|
|
25
|
-
|
|
26
|
-
# JavaScript
|
|
27
|
-
if g.production? && g.use_remote_jquery
|
|
28
|
-
js_groups = g.combined_js_srcs.partition { |src| src == g.jquery_js }
|
|
29
|
-
output = javascript_include_tag( g.jquery_remote_url )
|
|
30
|
-
output << javascript_include_tag( js_groups[1], :cache => "cache/#{g.js_cache_name}" ) unless js_groups[1].nil?
|
|
31
|
-
else
|
|
32
|
-
output = javascript_include_tag( g.combined_js_srcs, :cache => "cache/#{g.js_cache_name}" )
|
|
33
|
-
end
|
|
34
|
-
output
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def g_apply_style
|
|
38
|
-
"<!-- guilded.styles -->"
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# Injects the CSS into the header. Must be called once per rendered page and within a scope that allows access
|
|
42
|
-
# to the output buffer of the tempalte system being used.
|
|
43
|
-
#
|
|
44
|
-
def g_inject_styles
|
|
45
|
-
g = Guilded::Guilder.instance
|
|
46
|
-
self.output_buffer.sub!( /<!-- guilded.styles -->/, stylesheet_link_tag( g.combined_css_srcs, :cache => "cache/#{g.css_cache_name}" ) )
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# Creates a javascript include tag for a Guilded specific file. The only difference
|
|
50
|
-
# being that it adds the file to a sources array to be concatenated and included at the
|
|
51
|
-
# end of the page with the dependencies specified for the Guilded components used.
|
|
52
|
-
#
|
|
53
|
-
# To explicitly include the jQuery or MooTools libraries you can use :jquery and/or :mootools
|
|
54
|
-
# respectively. If a component that uses either jQuery or MooTools is used on a page, there is
|
|
55
|
-
# no need to explicitly include the library, as it will be resolved as a dependency and only
|
|
56
|
-
# included once.
|
|
57
|
-
#
|
|
58
|
-
def g_javascript_include_tag( *sources )
|
|
59
|
-
g = Guilded::Guilder.instance
|
|
60
|
-
defaults = nil
|
|
61
|
-
if sources.include?( :defaults )
|
|
62
|
-
defaults = ActionView::Helpers::AssetTagHelper::JAVASCRIPT_DEFAULT_SOURCES
|
|
63
|
-
sources.delete( :defaults )
|
|
64
|
-
end
|
|
65
|
-
if sources.include?( :jquery )
|
|
66
|
-
sources.insert( 0, g.jquery_js ) unless sources.include?( g.jquery_js )
|
|
67
|
-
sources.delete( :jquery )
|
|
68
|
-
end
|
|
69
|
-
if sources.include?( :mootools )
|
|
70
|
-
unless sources.include?( g.mootools_js )
|
|
71
|
-
insert_at = 0
|
|
72
|
-
insert_at = 1 if( sources.include?( g.jquery_js ) )
|
|
73
|
-
sources.insert( insert_at, g.mootools_js )
|
|
74
|
-
end
|
|
75
|
-
sources.delete( :mootools )
|
|
76
|
-
end
|
|
77
|
-
if defaults
|
|
78
|
-
g.add_js_sources( *(sources << defaults) )
|
|
79
|
-
else
|
|
80
|
-
g.add_js_sources( *sources )
|
|
81
|
-
end
|
|
82
|
-
''
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
# Replaces the Rails stylesheet_link_tag helper if you wnat Guilded to manage CSS for you.
|
|
86
|
-
# Although the syntax is exactly the same, the method works a little differently.
|
|
87
|
-
#
|
|
88
|
-
# This helper adds the stylesheet(s) to a collection to be renderred out together
|
|
89
|
-
# with all the guilded componenets stylesheets. This allows the stylesheets passed
|
|
90
|
-
# to this method to be cached with the guilded stylesheests into a single reusable file.
|
|
91
|
-
#
|
|
92
|
-
# The helper will ensure that these stylesheets are included after Guilded's reset
|
|
93
|
-
# stylesheet and before guilded's component's stylesheets so that they can override any
|
|
94
|
-
# resets, etc and not override any guilded components styles.
|
|
95
|
-
|
|
96
|
-
# *options*
|
|
97
|
-
# :position The place to position the css. pre for before the component's css or post for after.
|
|
98
|
-
# Defaults to post.
|
|
99
|
-
#
|
|
100
|
-
def g_stylesheet_link_tag( *sources )
|
|
101
|
-
options = sources.extract_options! || {}
|
|
102
|
-
options[:position] ||= :post
|
|
103
|
-
sources.each { |src| Guilded::Guilder.instance.add_css_source( src, options[:position] ) }
|
|
104
|
-
''
|
|
105
|
-
end
|
|
8
|
+
raw "<script src=\"#{jquery_url( version, min )}\" type=\"text/javascript\"></script>"
|
|
9
|
+
end
|
|
106
10
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
""
|
|
113
|
-
end
|
|
114
|
-
end
|
|
11
|
+
def jquery_url( version, min )
|
|
12
|
+
%w(development test cucumber).include?( Guilded.configuration.environment.to_s ) ?
|
|
13
|
+
Guilded.configuration.local_jquery_name( version, min ) :
|
|
14
|
+
Guilded.configuration.jquery_google_url( version )
|
|
15
|
+
end
|
|
115
16
|
|
|
17
|
+
def apply_guilded_behavior
|
|
18
|
+
raw guilded.javascript_initializer
|
|
116
19
|
end
|
|
20
|
+
|
|
117
21
|
end
|
|
118
|
-
end
|
|
22
|
+
end
|
data/lib/guilded/version.rb
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Guilded::Component do
|
|
4
|
+
|
|
5
|
+
let :component do
|
|
6
|
+
described_class.new :flash_growler, :position => :bottom, :delay => 4000
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "should produce the correct javascript initializer" do
|
|
10
|
+
component.javascript_initializer.should == "g.initFlashGrowler({\"position\":\"bottom\",\"delay\":4000});"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Guilded::Configuration do
|
|
4
|
+
|
|
5
|
+
subject { Guilded.configuration }
|
|
6
|
+
|
|
7
|
+
before :each do
|
|
8
|
+
Guilded.configure do |config|
|
|
9
|
+
config.environment = :production
|
|
10
|
+
config.jquery_version = '1.8.3'
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should have the correct value for environment" do
|
|
15
|
+
subject.environment.should == :production
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should have the correct value for jquery_verison" do
|
|
19
|
+
subject.jquery_version.should == '1.8.3'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
context "when the jquery_google_url_template is not overridden" do
|
|
23
|
+
|
|
24
|
+
it "should have the correct value for the jquery_google_url_template" do
|
|
25
|
+
subject.jquery_google_url_template.should == "https://ajax.googleapis.com/ajax/libs/jquery/{{version}}/jquery.min.js"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context "when the jquery_google_url_template is overridden" do
|
|
31
|
+
|
|
32
|
+
before :each do
|
|
33
|
+
Guilded.configure do |config|
|
|
34
|
+
config.jquery_google_url_template = "something"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "should have the correct value for the jquery_google_url_template" do
|
|
39
|
+
subject.jquery_google_url_template.should == "something"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should have return the correct value for jquery_google_url" do
|
|
45
|
+
subject.jquery_google_url( '1.8.3' ).should == "https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe "#local_jquery_name" do
|
|
49
|
+
|
|
50
|
+
context "when min version is requested" do
|
|
51
|
+
|
|
52
|
+
it "should return the correct value" do
|
|
53
|
+
subject.local_jquery_name( '1.8.3', true ).should == "/assets/jquery-1.8.3.min.js"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
context "when uncompressed version is requested" do
|
|
59
|
+
|
|
60
|
+
it "should return the correct value" do
|
|
61
|
+
subject.local_jquery_name( '1.8.3', false ).should == "/assets/jquery-1.8.3.js"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Guilded::Data do
|
|
4
|
+
|
|
5
|
+
let :data do
|
|
6
|
+
subject
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
context "when there is no data" do
|
|
10
|
+
|
|
11
|
+
it "should output the correct javascript" do
|
|
12
|
+
data.to_javascript.should == "g[\"data\"]={};"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
context "when there is data" do
|
|
18
|
+
|
|
19
|
+
before :each do
|
|
20
|
+
data.add :a => 1, :b => { :c => 3}
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "should output the correct javascript" do
|
|
24
|
+
data.to_javascript.should == "g[\"data\"]={\"a\":1,\"b\":{\"c\":3}};"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
@@ -1,77 +1,81 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe Guilded::Guilder do
|
|
4
|
-
before :each do
|
|
5
|
-
@g = Guilded::Guilder.instance
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
it "should return an instance" do
|
|
9
|
-
@g.should_not be_nil
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it "should be a singleton" do
|
|
13
|
-
@g.initialized_at.should eql( Guilded::Guilder.instance.initialized_at )
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "should have 1 css source after init" do
|
|
17
|
-
@g.combined_css_srcs.size.should eql( 1 )
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "should have 3 js sources after init" do
|
|
21
|
-
@g.combined_js_srcs.size.should eql( 3 )
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "should increase count by one when you add a component" do
|
|
25
|
-
count = @g.count
|
|
26
|
-
@g.add( 'grid', { :id => 'grid' } )
|
|
27
|
-
@g.count.should eql( count + 1 )
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "should respond to add" do
|
|
31
|
-
@g.respond_to?( :add ).should be_true
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it "should respond to count" do
|
|
35
|
-
@g.respond_to?( :count ).should be_true
|
|
36
|
-
end
|
|
37
4
|
|
|
38
|
-
|
|
39
|
-
|
|
5
|
+
let :guilder do
|
|
6
|
+
subject
|
|
40
7
|
end
|
|
41
8
|
|
|
42
|
-
|
|
43
|
-
@g.respond_to?( :apply ).should be_true
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it "should respond to generate_javascript_init" do
|
|
47
|
-
@g.respond_to?( :generate_javascript_init ).should be_true
|
|
48
|
-
end
|
|
9
|
+
describe "#component?" do
|
|
49
10
|
|
|
50
|
-
|
|
51
|
-
@g.respond_to?( :js_cache_name ).should be_true
|
|
52
|
-
end
|
|
11
|
+
context "when there is a component already in existence" do
|
|
53
12
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
it "should respond_to generate_js_cache_name" do
|
|
59
|
-
@g.respond_to?( :generate_js_cache_name ).should be_true
|
|
60
|
-
end
|
|
13
|
+
before :each do
|
|
14
|
+
guilder.add :flash_growler
|
|
15
|
+
end
|
|
61
16
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
17
|
+
it "should agree that the component is already defined" do
|
|
18
|
+
guilder.component?( :flash_growler ).should be_true
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
context "when there is not a component already in existence" do
|
|
24
|
+
|
|
25
|
+
before :each do
|
|
26
|
+
guilder.add :flash_growler
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "should agree that the component is already defined" do
|
|
30
|
+
guilder.component?( :scroll_to ).should be_false
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
65
34
|
|
|
66
|
-
it "should respond_to combined_css_srcs" do
|
|
67
|
-
@g.respond_to?( :combined_css_srcs ).should be_true
|
|
68
35
|
end
|
|
69
36
|
|
|
70
|
-
|
|
71
|
-
|
|
37
|
+
context "when there are components requiring javascript" do
|
|
38
|
+
|
|
39
|
+
before :each do
|
|
40
|
+
guilder.add :flash_growler, :position => :bottom
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "should generate the correct javascript initializer" do
|
|
44
|
+
guilder.javascript_initializer.should == "<script type=\"text/javascript\">\n//<![CDATA[\ng[\"data\"]={};var initGuilded = function(){g.initFlashGrowler({\"position\":\"bottom\"});};jQuery('document').ready(initGuilded);jQuery('body').trigger('guildedInitialized');\n//]]>\n</script>"
|
|
45
|
+
end
|
|
46
|
+
|
|
72
47
|
end
|
|
73
48
|
|
|
74
|
-
|
|
75
|
-
|
|
49
|
+
context "when there are no components requiring javascript" do
|
|
50
|
+
|
|
51
|
+
before :each do
|
|
52
|
+
guilder.add :flash_growler, :has_javascript => false, :position => :bottom
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should generate the correct javascript initializer" do
|
|
56
|
+
guilder.javascript_initializer.should == "<script type=\"text/javascript\">\n//<![CDATA[\ng[\"data\"]={};jQuery('body').trigger('guildedInitialized');\n//]]>\n</script>"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
context "and there is no data to pass" do
|
|
60
|
+
|
|
61
|
+
it "should generate the correct javascript initializer" do
|
|
62
|
+
guilder.javascript_initializer.should == "<script type=\"text/javascript\">\n//<![CDATA[\ng[\"data\"]={};jQuery('body').trigger('guildedInitialized');\n//]]>\n</script>"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
context "and there is data to pass" do
|
|
68
|
+
|
|
69
|
+
before :each do
|
|
70
|
+
guilder.add_data :a => 1
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "should generate the correct javascript initializer" do
|
|
74
|
+
guilder.javascript_initializer.should == "<script type=\"text/javascript\">\n//<![CDATA[\ng[\"data\"]={\"a\":1};jQuery('body').trigger('guildedInitialized');\n//]]>\n</script>"
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
|
|
76
79
|
end
|
|
77
|
-
|
|
80
|
+
|
|
81
|
+
end
|