rsocialize 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,316 @@
1
+ require 'spec_helper'
2
+ describe "rsocialize" do
3
+ class DummyClass
4
+ include Rsocialize
5
+ end
6
+ context "with EXAMPLE1_OPTIONS" do
7
+ before(:each) do
8
+ @dumb_class = DummyClass.new
9
+ @js_code_example1 = %Q[<script>
10
+ $(document).ready(function() { $('#twitter').sharrre({
11
+ share: { twitter: true },
12
+
13
+ enableHover: false,
14
+ enableTracking: true,
15
+ buttons: { twitter: {via: '_JulienH'}
16
+ },
17
+
18
+ click: function(api, options){
19
+ api.simulateClick();
20
+ api.openPopup('twitter');}
21
+ });
22
+ $('#facebook').sharrre({
23
+ share: { facebook: true },
24
+
25
+ enableHover: false,
26
+ enableTracking: true,
27
+ click: function(api, options){
28
+ api.simulateClick();
29
+ api.openPopup('facebook');}
30
+
31
+ });
32
+ $('#googleplus').sharrre({
33
+ share: { googlePlus: true },
34
+
35
+ enableHover: false,
36
+ enableTracking: true,
37
+ click: function(api, options){
38
+ api.simulateClick();
39
+ api.openPopup('googlePlus');}
40
+ });
41
+ });
42
+ </script>]
43
+ @div_example1=%Q{
44
+ <div id="example1">
45
+ <div id="twitter" data-url="http://sharrre.com/" data-text="Make your sharing widget with Sharrre (jQuery Plugin)" data-title="Tweet"></div>
46
+ <div id="facebook" data-url="http://sharrre.com/" data-text="Make your sharing widget with Sharrre (jQuery Plugin)" data-title="Like"></div>
47
+ <div id="googleplus" data-url="http://sharrre.com/" data-text="Make your sharing widget with Sharrre (jQuery Plugin)" data-title="+1"></div>
48
+ </div>
49
+ }
50
+ end
51
+ it "should return sharrre jQuery code" do
52
+ @return_js_code = @dumb_class.rsocialize_js_tag({:js_template=>"example1"})
53
+ @return_js_code.tr("\n","").tr(" ","").should == @js_code_example1.tr("\n","").tr(" ","")
54
+ end
55
+ it "should return html div code" do
56
+ @return_html_code = @dumb_class.rsocialize_div_tag("",:div_template=>"example1")
57
+ @return_html_code.tr("\n","").tr(" ","").should == @div_example1.tr("\n","").tr(" ","")
58
+ end
59
+ end #context example 1
60
+ context "with EXAMPLE2_OPTIONS" do
61
+ before(:each) do
62
+ @dumb_class = DummyClass.new
63
+ @js_code_example2 = %Q[
64
+ <script>
65
+ $(document).ready(function() { $('#shareme').sharrre({
66
+ share: {
67
+ twitter: true,
68
+ facebook: true,
69
+ googlePlus: true
70
+ },
71
+ template: '<div class="box"><div class="left">Share</div><div class="middle"><a href="#" class="facebook">f</a><a href="#" class="twitter">t</a><a href="#" class="googleplus">+1</a></div><div class="right">{total}</div></div>',
72
+ enableHover: false,
73
+ enableTracking: true,
74
+ render: function(api, options){
75
+ $(api.element).on('click', '.twitter', function() {
76
+ api.openPopup('twitter');
77
+ });
78
+ $(api.element).on('click', '.facebook', function() {
79
+ api.openPopup('facebook');
80
+ });
81
+ $(api.element).on('click', '.googleplus', function() {
82
+ api.openPopup('googlePlus');
83
+ });
84
+ }
85
+ });
86
+ });
87
+ </script>
88
+ ]
89
+ @div_example2 = %Q{
90
+ <div id="example2">
91
+ <div id="shareme" data-url="http://sharrre.com/" data-text="Make your sharing widget with Sharrre (jQuery Plugin)"></div>
92
+ </div>
93
+ }
94
+ end
95
+ it "should return sharrre jQuery code" do
96
+ @return_js_code = @dumb_class.rsocialize_js_tag({:js_template=>"example2"})
97
+ @return_js_code.tr("\n","").tr(" ","").should == @js_code_example2.tr("\n","").tr(" ","")
98
+ end
99
+ it "should return html div code" do
100
+ @return_html_code = @dumb_class.rsocialize_div_tag("",:div_template=>"example2")
101
+ @return_html_code.tr("\n","").tr(" ","").should == @div_example2.tr("\n","").tr(" ","")
102
+ end
103
+ end #context example 2
104
+ context "with EXAMPLE3_OPTIONS" do
105
+ before(:each) do
106
+ @dumb_class = DummyClass.new
107
+ @js_code_example3 = %Q[<script>
108
+ $(document).ready(function() { $('#shareme').sharrre({
109
+ share: {
110
+ googlePlus: true,
111
+ facebook: true,
112
+ twitter: true,
113
+ digg: true,
114
+ delicious: true
115
+ },
116
+ enableTracking: true,
117
+ buttons: {
118
+ googlePlus: {size: 'tall'},
119
+ facebook: {layout: 'box_count'},
120
+ twitter: {count: 'vertical'},
121
+ digg: {type: 'DiggMedium'},
122
+ delicious: {size: 'tall'}
123
+ },
124
+ hover: function(api, options){
125
+ $(api.element).find('.buttons').show();
126
+ },
127
+ hide: function(api, options){
128
+ $(api.element).find('.buttons').hide();
129
+ }
130
+ });
131
+ });
132
+ </script>]
133
+ @div_example3 = %Q{
134
+ <div id="example3">
135
+ <div id="shareme" data-url="http://sharrre.com/" data-text="Make your sharing widget with Sharrre (jQuery Plugin)" data-title="share this page"></div>
136
+ </div>
137
+ }
138
+ end
139
+ it "should return sharrre jQuery code" do
140
+ @return_js_code = @dumb_class.rsocialize_js_tag({:js_template=>"example3"})
141
+ @return_js_code.tr("\n","").tr(" ","").should == @js_code_example3.tr("\n","").tr(" ","")
142
+ end
143
+ it "should return html div code" do
144
+ @return_html_code = @dumb_class.rsocialize_div_tag("",:div_template=>"example3")
145
+ @return_html_code.tr("\n","").tr(" ","").should == @div_example3.tr("\n","").tr(" ","")
146
+ end
147
+ end #context example 3
148
+ context "with EXAMPLE5_OPTIONS" do
149
+ before(:each) do
150
+ @dumb_class = DummyClass.new
151
+ @js_code_example5 = %Q[<script>
152
+ $(document).ready(function() { $('#shareme').sharrre({
153
+ share: {
154
+ googlePlus: true,
155
+ facebook: true,
156
+ twitter: true,
157
+ digg: true,
158
+ delicious: true,
159
+ stumbleupon: true,
160
+ linkedin: true,
161
+ pinterest: true
162
+ },
163
+ buttons: {
164
+ googlePlus: {size: 'tall'},
165
+ facebook: {layout: 'box_count'},
166
+ twitter: {count: 'vertical'},
167
+ digg: {type: 'DiggMedium'},
168
+ delicious: {size: 'tall'},
169
+ stumbleupon: {layout: '5'},
170
+ linkedin: {counter: 'top'},
171
+ pinterest: {media: 'http://sharrre.com/img/example1.png', description: $('#shareme').data('text'), layout: 'vertical'}
172
+ },
173
+ enableHover: false,
174
+ enableCounter: false,
175
+ enableTracking: true
176
+ });
177
+ });
178
+ </script>]
179
+ @div_example5 = %Q{
180
+ <div id="example5">
181
+ <div id="shareme" data-url="http://sharrre.com/" data-text="Make your sharing widget with Sharrre (jQuery Plugin)"></div>
182
+ </div>
183
+ }
184
+ end
185
+ it "should return sharrre jQuery code" do
186
+ @return_js_code = @dumb_class.rsocialize_js_tag({:js_template=>"example5"})
187
+ @return_js_code.tr("\n","").tr(" ","").should == @js_code_example5.tr("\n","").tr(" ","")
188
+ end
189
+ it "should return html div code" do
190
+ @return_html_code = @dumb_class.rsocialize_div_tag("",:div_template=>"example5")
191
+ @return_html_code.tr("\n","").tr(" ","").should == @div_example5.tr("\n","").tr(" ","")
192
+ end
193
+ end #context example 5
194
+ context "with EXAMPLE6_OPTIONS" do
195
+ before(:each) do
196
+ @dumb_class = DummyClass.new
197
+ @js_code_example6 = %Q[<script>
198
+ $(document).ready(function() { $('#twitter').sharrre({
199
+ share: {
200
+ twitter: true
201
+ },
202
+ template: '<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><span></span>Tweet</div></a>',
203
+ enableHover: false,
204
+ enableTracking: true,
205
+ buttons: { twitter: {via: '_JulienH'}},
206
+ click: function(api, options){
207
+ api.simulateClick();
208
+ api.openPopup('twitter');
209
+ }
210
+ });
211
+ $('#facebook').sharrre({
212
+ share: {
213
+ facebook: true
214
+ },
215
+ template: '<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><span></span>Like</div></a>',
216
+ enableHover: false,
217
+ enableTracking: true,
218
+ click: function(api, options){
219
+ api.simulateClick();
220
+ api.openPopup('facebook');
221
+ }
222
+ });
223
+ $('#googleplus').sharrre({
224
+ share: {
225
+ googlePlus: true
226
+ },
227
+ template: '<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><span></span>+1</div></a>',
228
+ enableHover: false,
229
+ enableTracking: true,
230
+ click: function(api, options){
231
+ api.simulateClick();
232
+ api.openPopup('googlePlus');
233
+ }
234
+ });
235
+ });
236
+ </script>]
237
+ @div_example6 = %Q{
238
+ <div id="example6">
239
+ <div id="twitter" data-url="http://sharrre.com/" data-text="Make your sharing widget with Sharrre (jQuery Plugin)"></div>
240
+ <div id="facebook" data-url="http://sharrre.com/" data-text="Make your sharing widget with Sharrre (jQuery Plugin)"></div>
241
+ <div id="googleplus" data-url="http://sharrre.com/" data-text="Make your sharing widget with Sharrre (jQuery Plugin)"></div>
242
+ </div>
243
+ }
244
+ end
245
+ it "should return sharrre jQuery code" do
246
+ @return_js_code = @dumb_class.rsocialize_js_tag({:js_template=>"example6"})
247
+ @return_js_code.tr("\n","").tr(" ","").should == @js_code_example6.tr("\n","").tr(" ","")
248
+ end
249
+ it "should return html div code" do
250
+ @return_html_code = @dumb_class.rsocialize_div_tag("",:div_template=>"example6")
251
+ @return_html_code.tr("\n","").tr(" ","").should == @div_example6.tr("\n","").tr(" ","")
252
+ end
253
+ end #context example 6
254
+ context "with CUSTOM_OPTIONS" do
255
+ before(:each) do
256
+ @dumb_class = DummyClass.new
257
+ @custom_div = %Q{
258
+ <div id="demo1" data-url="http://sharrre.com" data-text="Make your sharing widget with Sharrre (jQuery Plugin)" data-title="share"></div>
259
+ }
260
+ @js_custom_options = {
261
+ demo1: {
262
+ share: {
263
+ googlePlus: true,
264
+ facebook: true,
265
+ twitter: true
266
+ },
267
+ buttons: {
268
+ googlePlus: {size: 'tall'},
269
+ facebook: {layout: 'box_count'},
270
+ twitter: {count: 'vertical', via: '_JulienH'}
271
+ },
272
+ hover: %Q[function(api, options){
273
+ $(api.element).find('.buttons').show();
274
+ }],
275
+ hide: %Q[function(api, options){
276
+ $(api.element).find('.buttons').hide();
277
+ }],
278
+ enableTracking: true
279
+ }
280
+ }
281
+ @js_code_custom_example = %Q[
282
+ <script>
283
+ $(document).ready(function() {
284
+ $('#demo1').sharrre({
285
+ share: {
286
+ googlePlus: true,
287
+ facebook: true,
288
+ twitter: true
289
+ },
290
+ buttons: {
291
+ googlePlus: {size: 'tall'},
292
+ facebook: {layout: 'box_count'},
293
+ twitter: {count: 'vertical', via: '_JulienH'}
294
+ },
295
+ hover: function(api, options){
296
+ $(api.element).find('.buttons').show();
297
+ },
298
+ hide: function(api, options){
299
+ $(api.element).find('.buttons').hide();
300
+ },
301
+ enableTracking: true
302
+ });
303
+ });
304
+ </script>
305
+ ]
306
+ end
307
+ it "should return sharrre jQuery code" do
308
+ @return_js_code = @dumb_class.rsocialize_js_tag(@js_custom_options)
309
+ @return_js_code.tr("\n","").tr(" ","").should == @js_code_custom_example.tr("\n","").tr(" ","")
310
+ end
311
+ it "should return html div code" do
312
+ @return_html_code = @dumb_class.rsocialize_div_tag(@custom_div,:div_template=>"custom")
313
+ @return_html_code.tr("\n","").tr(" ","").should == @custom_div.tr("\n","").tr(" ","")
314
+ end
315
+ end #context custom options
316
+ end #describe rsocialize
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'rsocialize'
4
+
5
+ RSpec.configure do |config|
6
+ config.color_enabled = true
7
+ config.formatter = 'documentation'
8
+ end
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rsocialize
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Bruce Park
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.11.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 2.11.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.9.2.2
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.9.2.2
46
+ - !ruby/object:Gem::Dependency
47
+ name: curb
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.8.2
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.8.2
62
+ - !ruby/object:Gem::Dependency
63
+ name: activesupport
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 3.2.8
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 3.2.8
78
+ - !ruby/object:Gem::Dependency
79
+ name: nokogiri
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 1.5.5
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 1.5.5
94
+ - !ruby/object:Gem::Dependency
95
+ name: actionpack
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 3.2.8
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 3.2.8
110
+ description: Provides a simple way to add social media buttons to your rails application
111
+ email:
112
+ - bruce at binarywebpark.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - .rvmrc
118
+ - Gemfile
119
+ - Gemfile.lock
120
+ - LICENSE
121
+ - README.md
122
+ - Rakefile
123
+ - lib/.rvmrc
124
+ - lib/generators/USAGE
125
+ - lib/generators/rsocialize/install_generator.rb
126
+ - lib/generators/rsocialize/switch_css_generator.rb
127
+ - lib/generators/rsocialize/templates/example1.css
128
+ - lib/generators/rsocialize/templates/example2.css
129
+ - lib/generators/rsocialize/templates/example3.css
130
+ - lib/generators/rsocialize/templates/example5.css
131
+ - lib/generators/rsocialize/templates/example6.css
132
+ - lib/generators/rsocialize/templates/images/example6.png
133
+ - lib/generators/rsocialize/templates/jquery.sharrre-1.3.4.min.js
134
+ - lib/generators/rsocialize/templates/rsocialize.css
135
+ - lib/generators/rsocialize/templates/rsocialize_controller.rb
136
+ - lib/generators/rsocialize/uninstall_generator.rb
137
+ - lib/rsocialize.rb
138
+ - lib/rsocialize/engine.rb
139
+ - lib/rsocialize/version.rb
140
+ - rsocialize.gemspec
141
+ - spec/rsocialize_spec.rb
142
+ - spec/spec_helper.rb
143
+ homepage: ''
144
+ licenses: []
145
+ post_install_message:
146
+ rdoc_options: []
147
+ require_paths:
148
+ - lib
149
+ required_ruby_version: !ruby/object:Gem::Requirement
150
+ none: false
151
+ requirements:
152
+ - - ! '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ none: false
157
+ requirements:
158
+ - - ! '>='
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ requirements: []
162
+ rubyforge_project:
163
+ rubygems_version: 1.8.24
164
+ signing_key:
165
+ specification_version: 3
166
+ summary: Provides a simple way to add social media buttons to your rails application. It's
167
+ a ruby wrapper for the sharrre jQuery plugin.'
168
+ test_files: []