kickboxer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+ require 'kickboxer/request'
3
+
4
+ describe Kickboxer::Request do
5
+ it 'builds a url with api key' do
6
+ Kickboxer.stub(:api_key).and_return('12345')
7
+
8
+ req = described_class.new("ns/action")
9
+ uri = URI.parse(req.build_url(username: 'jdoe'))
10
+
11
+ uri.scheme.should eq 'https'
12
+ uri.host.should eq 'api.fullcontact.com'
13
+ uri.path.should eq '/v2/ns/action.json'
14
+ q = uri.query || ""
15
+
16
+ q.should =~ /username=jdoe/
17
+ q.should =~ /apiKey=12345/
18
+ end
19
+
20
+ it 'raises an error if api key is not set' do
21
+ Kickboxer.api_key.should be_nil
22
+ lambda { described_class.run("ns/action", username: 'jdoe') }.should raise_error(Kickboxer::NoApiKeyError)
23
+ end
24
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+ require 'kickboxer/response'
3
+
4
+ describe Kickboxer::Response do
5
+ it 'builds methods dynamically in initialize block' do
6
+ r = described_class.new do
7
+ custom_method "hello"
8
+ another_method 42
9
+ end
10
+
11
+ r.should respond_to(:custom_method)
12
+ r.custom_method.should eq 'hello'
13
+
14
+ r.should respond_to(:another_method)
15
+ r.another_method.should eq 42
16
+
17
+ r.should_not respond_to(:yet_another_method)
18
+ end
19
+
20
+ it 'accepts an initial data hash' do
21
+ r = described_class.new('custom_method' => 'hello')
22
+ r.should respond_to(:custom_method)
23
+ r.custom_method.should eq 'hello'
24
+ r.should_not respond_to(:another_method)
25
+ end
26
+
27
+ it 'merges initial data with block-defined data' do
28
+ r = described_class.new('custom_method' => 'hello') do
29
+ another_method 42
30
+ end
31
+
32
+ r.should respond_to(:custom_method)
33
+ r.custom_method.should eq 'hello'
34
+
35
+ r.should respond_to(:another_method)
36
+ r.another_method.should eq 42
37
+
38
+ r.should_not respond_to(:yet_another_method)
39
+ end
40
+ end
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../lib'))
4
+
5
+ require 'rspec'
6
+ require 'rspec/autorun'
7
+
8
+ def stub_response(fixture, status=[200, "OK"])
9
+ require 'kickboxer/request'
10
+ response = StringIO.new IO.read("spec/fixtures/#{ fixture }.json")
11
+ response.stub(:status).and_return(status)
12
+ Kickboxer::Request.any_instance.stub(:open).and_return(response)
13
+ Kickboxer.stub(:api_key).and_return('12345')
14
+ end
15
+
16
+ RSpec.configure do |config|
17
+ config.mock_with :rspec
18
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kickboxer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Solomon White
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: pry
16
+ requirement: &70141056905720 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70141056905720
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &70141056905240 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70141056905240
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &70141056904760 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70141056904760
47
+ description: Kickboxer
48
+ email:
49
+ - rubysolo@gmail.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - LICENSE
57
+ - README.md
58
+ - Rakefile
59
+ - kickboxer.gemspec
60
+ - lib/kickboxer.rb
61
+ - lib/kickboxer/config.rb
62
+ - lib/kickboxer/name.rb
63
+ - lib/kickboxer/person.rb
64
+ - lib/kickboxer/request.rb
65
+ - lib/kickboxer/response.rb
66
+ - lib/kickboxer/version.rb
67
+ - spec/fixtures/name-deduce-email.json
68
+ - spec/fixtures/name-normalize.json
69
+ - spec/fixtures/name-parse.json
70
+ - spec/fixtures/name-similarity.json
71
+ - spec/fixtures/name-stats-ambiguous.json
72
+ - spec/fixtures/name-stats-both.json
73
+ - spec/fixtures/name-stats-family.json
74
+ - spec/fixtures/name-stats-given.json
75
+ - spec/fixtures/person-email.json
76
+ - spec/fixtures/person-facebook.json
77
+ - spec/fixtures/person-phone.json
78
+ - spec/fixtures/person-twitter.json
79
+ - spec/kickboxer/config_spec.rb
80
+ - spec/kickboxer/name_spec.rb
81
+ - spec/kickboxer/person_spec.rb
82
+ - spec/kickboxer/request_spec.rb
83
+ - spec/kickboxer/response_spec.rb
84
+ - spec/spec_helper.rb
85
+ homepage: https://github.com/rubysolo/kickboxer
86
+ licenses: []
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 1.8.11
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: Kickboxer is a Ruby library for accessing the FullContact API
109
+ test_files:
110
+ - spec/fixtures/name-deduce-email.json
111
+ - spec/fixtures/name-normalize.json
112
+ - spec/fixtures/name-parse.json
113
+ - spec/fixtures/name-similarity.json
114
+ - spec/fixtures/name-stats-ambiguous.json
115
+ - spec/fixtures/name-stats-both.json
116
+ - spec/fixtures/name-stats-family.json
117
+ - spec/fixtures/name-stats-given.json
118
+ - spec/fixtures/person-email.json
119
+ - spec/fixtures/person-facebook.json
120
+ - spec/fixtures/person-phone.json
121
+ - spec/fixtures/person-twitter.json
122
+ - spec/kickboxer/config_spec.rb
123
+ - spec/kickboxer/name_spec.rb
124
+ - spec/kickboxer/person_spec.rb
125
+ - spec/kickboxer/request_spec.rb
126
+ - spec/kickboxer/response_spec.rb
127
+ - spec/spec_helper.rb