avataree 0.6.0 → 0.6.1

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/lib/avataree.rb CHANGED
@@ -20,8 +20,15 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  # encoding: utf-8
23
-
24
- require File.join(File.dirname(__FILE__), *%w[avataree railtie]) if defined?(::Rails::Railtie)
23
+ if defined?(::Rails::Railtie)
24
+ require File.join(File.dirname(__FILE__), *%w[avataree railtie])
25
+ else
26
+ require 'avataree'
27
+ require 'avataree/helper'
28
+ require 'avataree/image'
29
+ require 'avataree/profile'
30
+ # require 'avataree/switch'
31
+ end
25
32
 
26
33
  module Avataree
27
34
  end
@@ -0,0 +1,83 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Avataree" do
4
+
5
+ #tests for client googl
6
+ describe "Helper" do
7
+ before(:all) do
8
+ @klass = Struct.new(:class)
9
+ @klass.instance_eval { include Helper }
10
+ @email = "test@test.com"
11
+ @expected_digest = "b642b4217b34b1e8d3bd915fc65c4452"
12
+ @hash = {:email => @email, :name => "testing"}
13
+ end
14
+
15
+ it "should make a proper md5 digest for given email" do
16
+ digest = @klass.new.make_digest(@email)
17
+ digest.should_not be_empty
18
+ digest.should == @expected_digest
19
+ end
20
+
21
+ it "should be able to convert a hash into params" do
22
+ Hash.new.should respond_to :to_param
23
+ @hash.to_param.should == "name=testing&email=test@test.com"
24
+ end
25
+
26
+ it "should respond to (secure) url services" do
27
+ Helper.should respond_to :url_services
28
+ Helper.should respond_to :secure_url_services
29
+ end
30
+
31
+ it "should gives default (secure) url if not changed" do
32
+ Helper.secure_url_services.should == "https://secure.gravatar.com/"
33
+ Helper.url_services.should == "http://www.gravatar.com/"
34
+ end
35
+
36
+ # it "should allow to change (secure)urls" do
37
+ # Helper.url_services = "http://google.com"
38
+ # Helper.secure_url_services = "https://google.com"
39
+ # Helper.secure_url_services.should == "https://google.com"
40
+ # Helper.url_services.should == "http://google.com"
41
+ # end
42
+ end
43
+
44
+ describe "Image Services" do
45
+
46
+ before(:all) do
47
+ @email = "beau@automattic.com"
48
+ @klass = Struct.new(:class)
49
+ @klass.instance_eval{ include Avataree::ImageServices }
50
+ @options = {:extension => "jpg", :size => "100x100", :rating => "g"}
51
+ end
52
+
53
+ it "should respond to methods if included" do
54
+ @klass.new.should respond_to :gravatar
55
+ @klass.new.should respond_to :gravatar_image_path
56
+ end
57
+
58
+ it "should return a valid gravatar url provided email" do
59
+ response = @klass.new.gravatar(@email)
60
+ response.should == "http://www.gravatar.com/avatar/22bd03ace6f176bfe0c593650bcf45d8"
61
+ end
62
+
63
+ it "should return a valid gravatar url provided email and options" do
64
+ response = @klass.new.gravatar(@email, @options)
65
+ response.should == "#{Helper.url_services}avatar/22bd03ace6f176bfe0c593650bcf45d8.jpg?rating=g&size=100x100"
66
+ end
67
+
68
+ it "should return a secure url if given in options" do
69
+ response = @klass.new.gravatar(@email, @options.merge({:secure => true}))
70
+ uri = URI.parse(response)
71
+ uri.scheme.should == "https"
72
+ end
73
+
74
+ it "should return a normal url if secure option set to false" do
75
+ response = @klass.new.gravatar(@email, @options.merge({:secure => false}))
76
+ uri = URI.parse(response)
77
+ uri.scheme.should_not == "https"
78
+ uri.scheme.should == "http"
79
+ end
80
+
81
+ end
82
+
83
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'avataree'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avataree
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 0
10
- version: 0.6.0
9
+ - 1
10
+ version: 0.6.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bagwan Pankaj (a.k.a modulo9)
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-05 00:00:00 +05:30
18
+ date: 2011-01-16 00:00:00 +05:30
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -51,16 +51,18 @@ dependencies:
51
51
  - !ruby/object:Gem::Dependency
52
52
  type: :development
53
53
  prerelease: false
54
- name: shoulda
54
+ name: rspec
55
55
  version_requirements: &id003 !ruby/object:Gem::Requirement
56
56
  none: false
57
57
  requirements:
58
- - - ">="
58
+ - - ~>
59
59
  - !ruby/object:Gem::Version
60
- hash: 3
60
+ hash: 11
61
61
  segments:
62
+ - 2
63
+ - 1
62
64
  - 0
63
- version: "0"
65
+ version: 2.1.0
64
66
  requirement: *id003
65
67
  - !ruby/object:Gem::Dependency
66
68
  type: :development
@@ -126,10 +128,8 @@ files:
126
128
  - lib/avataree/switch.rb
127
129
  - LICENSE.txt
128
130
  - README.textile
129
- - test/avataree_test.rb
130
- - test/helper.rb
131
- - test/test_avataree.rb
132
- - test/test_helper.rb
131
+ - spec/avataree_spec.rb
132
+ - spec/spec_helper.rb
133
133
  has_rdoc: true
134
134
  homepage: http://github.com/bagwanpankaj/avataree
135
135
  licenses:
@@ -165,7 +165,5 @@ signing_key:
165
165
  specification_version: 3
166
166
  summary: Ruby DSL for Gravatar profile and images
167
167
  test_files:
168
- - test/avataree_test.rb
169
- - test/helper.rb
170
- - test/test_avataree.rb
171
- - test/test_helper.rb
168
+ - spec/avataree_spec.rb
169
+ - spec/spec_helper.rb
@@ -1,8 +0,0 @@
1
- require 'test_helper'
2
-
3
- class AvatareeTest < ActiveSupport::TestCase
4
- # Replace this with your real tests.
5
- test "the truth" do
6
- assert true
7
- end
8
- end
data/test/helper.rb DELETED
@@ -1,18 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'test/unit'
11
- require 'shoulda'
12
-
13
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
- $LOAD_PATH.unshift(File.dirname(__FILE__))
15
- require 'avataree'
16
-
17
- class Test::Unit::TestCase
18
- end
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestAvataree < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end
data/test/test_helper.rb DELETED
@@ -1,3 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'active_support'