facebook_share 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- facebook_share (0.0.1)
4
+ facebook_share (0.0.2)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/README.md CHANGED
@@ -51,10 +51,6 @@ The simplest usage (given you specified your project's Facebook Application ID)
51
51
 
52
52
  That will produce a link "Share on Facebook" with a class of "fb_share" and a corresponding JavaScript script tags initializing Facebook app and sharing method bind to click on that link. By default gem passes ".fb_share" selector to jQuery.
53
53
 
54
- ## Todo
55
-
56
- * add tests
57
-
58
54
  ## Note on patches/pull requests
59
55
 
60
56
  * Fork the project.
@@ -1,3 +1,3 @@
1
1
  module FacebookShare
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -47,7 +47,7 @@ JS
47
47
 
48
48
  def facebook_connect_js_tag(options = {})
49
49
  options = default_facebook_share_options.merge(options)
50
- html_safe_string("<script type=\"text/javascript\" src=\"https://connect.facebook.net/#{default_facebook_share_options.merge(options)[:locale]}/all.js\"></script>")
50
+ html_safe_string("<script type=\"text/javascript\" src=\"https://connect.facebook.net/#{options[:locale]}/all.js\"></script>")
51
51
  end
52
52
 
53
53
  def facebook_init_script(options = {})
@@ -64,7 +64,7 @@ JS
64
64
  param_check = ( for_init ) ? FacebookShare::INIT_PARAMS.include?(key.to_s) : !(FacebookShare::REMOVE_PARAMS.include?(key.to_s))
65
65
 
66
66
  if value && param_check
67
- value_sanitized = value.gsub(/"/, '\"')
67
+ value_sanitized = value.to_s.gsub(/"/, '\"')
68
68
  script << ", #{key}: \"#{value_sanitized}\""
69
69
  end
70
70
  end
@@ -0,0 +1,49 @@
1
+ require File.expand_path(File.dirname(File.dirname(__FILE__)) + '/spec_helper')
2
+
3
+ describe FacebookShare do
4
+ include FacebookShare
5
+
6
+ describe "building params" do
7
+ before(:all) do
8
+ @options = {
9
+ :app_id => "123123123",
10
+
11
+ :selector => "#some_fancy > .selector",
12
+ :display => "popup",
13
+ :link => "http://railslove.com/",
14
+ :caption => "Railslove",
15
+
16
+ :status => "true",
17
+ :xfbml => "true",
18
+ :cookie => "false"
19
+ }
20
+ end
21
+ context "when not for_init" do
22
+ subject { build_params(@options) }
23
+
24
+ it { should_not match(/app_id/) }
25
+ it { should_not match(/cookies/) }
26
+ it { should_not match(/xfbml/) }
27
+
28
+ it { should match(/display: "popup"/) }
29
+ it { should match(/link: "http:\/\/railslove.com\/"/) }
30
+ it { should match(/caption: "Railslove"/) }
31
+
32
+ it { should_not match(/selector: "/) }
33
+ end
34
+
35
+ context "when for_init" do
36
+ subject { build_params(@options, true) }
37
+
38
+ it { should_not match(/app_id/) }
39
+ it { should match(/cookie: "false"/) }
40
+ it { should match(/xfbml: "true"/) }
41
+
42
+ it { should_not match(/display: "popup"/) }
43
+ it { should_not match(/link: "http:\/\/railslove.com\/"/) }
44
+ it { should_not match(/caption: "Railslove"/) }
45
+
46
+ it { should_not match(/selector: "/) }
47
+ end
48
+ end
49
+ end
data/spec/spec_helper.rb CHANGED
@@ -13,4 +13,4 @@ def fixture_path(file_name)
13
13
  end
14
14
 
15
15
  RSpec.configure do |config|
16
- end
16
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebook_share
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Mike Po\xC5\x82tyn"
@@ -50,6 +50,7 @@ files:
50
50
  - facebook_share.gemspec
51
51
  - lib/facebook_share.rb
52
52
  - lib/facebook_share/version.rb
53
+ - spec/facebook_share/facebook_share_spec.rb
53
54
  - spec/spec_helper.rb
54
55
  has_rdoc: true
55
56
  homepage: http://github.com/Holek/facebook_share