monkey_wrench 0.1.0
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/README.mdown +18 -0
- data/Rakefile +11 -0
- data/lib/monkey_wrench.rb +10 -0
- data/lib/monkey_wrench/array.rb +9 -0
- data/lib/monkey_wrench/base.rb +67 -0
- data/lib/monkey_wrench/campaign.rb +0 -0
- data/lib/monkey_wrench/campaign_aim.rb +0 -0
- data/lib/monkey_wrench/campaign_stats.rb +0 -0
- data/lib/monkey_wrench/config.rb +34 -0
- data/lib/monkey_wrench/error.rb +104 -0
- data/lib/monkey_wrench/hash.rb +69 -0
- data/lib/monkey_wrench/helper.rb +0 -0
- data/lib/monkey_wrench/list.rb +309 -0
- data/lib/monkey_wrench/member.rb +33 -0
- data/lib/monkey_wrench/security.rb +0 -0
- data/test/fixtures/api_fail.json +1 -0
- data/test/fixtures/campaigns_success.json +24 -0
- data/test/fixtures/listBatchSubscribe10_success.json +1 -0
- data/test/fixtures/listBatchSubscribe5_success.json +1 -0
- data/test/fixtures/listBatchSubscribe_success.json +1 -0
- data/test/fixtures/listBatchSubscribe_with_error_success.json +1 -0
- data/test/fixtures/listBatchUnsubscribe_success.json +1 -0
- data/test/fixtures/listMemberInfo_fail.json +1 -0
- data/test/fixtures/listMemberInfo_success.json +1 -0
- data/test/fixtures/listMembers_none_success.json +1 -0
- data/test/fixtures/listMembers_success.json +8 -0
- data/test/fixtures/listSubscribe_success.json +1 -0
- data/test/fixtures/listUnsubscribe_success.json +0 -0
- data/test/fixtures/listUpdateMember_success.json +1 -0
- data/test/fixtures/lists_success.json +14 -0
- data/test/monkey_wrench/campaign_aim_test.rb +0 -0
- data/test/monkey_wrench/campaign_stats_test.rb +0 -0
- data/test/monkey_wrench/campaign_test.rb +0 -0
- data/test/monkey_wrench/hash_test.rb +47 -0
- data/test/monkey_wrench/helper_test.rb +0 -0
- data/test/monkey_wrench/list_test.rb +310 -0
- data/test/monkey_wrench/security_test.rb +0 -0
- data/test/test_helper.rb +67 -0
- metadata +134 -0
File without changes
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'shoulda'
|
4
|
+
require 'net/http'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require "redgreen"
|
8
|
+
rescue LoadError;
|
9
|
+
end
|
10
|
+
|
11
|
+
require File.expand_path(File.dirname(__FILE__)) + '/lib/fakeweb/lib/fake_web'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require "#{File.dirname(__FILE__)}/../lib/monkey_wrench"
|
16
|
+
|
17
|
+
FakeWeb.allow_net_connect = false
|
18
|
+
|
19
|
+
class Test::Unit::TestCase
|
20
|
+
protected
|
21
|
+
|
22
|
+
def setup_config
|
23
|
+
MonkeyWrench::Config.new(:apikey => "my-key", :datacenter => "my-dc")
|
24
|
+
end
|
25
|
+
|
26
|
+
def mock_response(method, api, dc, remote_method, params, fixture, is_success)
|
27
|
+
params.merge!({ :method => remote_method, :output => :json, :apikey => api})
|
28
|
+
form_params = map_form_params(params).gsub(/%5([b-d])/) {|s| s.upcase}
|
29
|
+
uri = "http://#{dc}.api.mailchimp.com/1.2/?#{form_params}"
|
30
|
+
response = File.read(json_fixture_path(fixture, is_success))
|
31
|
+
store_response(uri, params, response)
|
32
|
+
FakeWeb.register_uri(method, uri, { :body => response, :content_type => 'application/json' })
|
33
|
+
end
|
34
|
+
|
35
|
+
def mock_chimp_post(method, params = {}, is_success = true, fixture = nil)
|
36
|
+
mock_response(:post, "my-key", "my-dc", method, params, fixture || method, is_success)
|
37
|
+
end
|
38
|
+
|
39
|
+
def store_response(uri, params, response)
|
40
|
+
@stored_responses ||= {}
|
41
|
+
@stored_responses[uri] ||= {}
|
42
|
+
@stored_responses[uri][params.collect_kv{|k,v| [k.to_s, v.to_s]}.inspect] = response
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_response(uri, actual_params)
|
46
|
+
response = @stored_responses[uri][actual_params.inspect]
|
47
|
+
raise "Unable to handle request to #{uri} with params: #{actual_params.inspect}" unless response
|
48
|
+
response
|
49
|
+
end
|
50
|
+
|
51
|
+
def map_form_params(params)
|
52
|
+
request = Net::HTTP::Post.new("http://localhost/")
|
53
|
+
request.set_form_data(params)
|
54
|
+
request.body
|
55
|
+
end
|
56
|
+
|
57
|
+
def json_fixture_path(fixture, is_success)
|
58
|
+
response = is_success ? "success" : "fail"
|
59
|
+
File.join(File.dirname(__FILE__), "fixtures", "#{fixture}_#{response}.json")
|
60
|
+
end
|
61
|
+
|
62
|
+
def clear_fakeweb
|
63
|
+
FakeWeb.clean_registry
|
64
|
+
FakeWeb.allow_net_connect = false
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: monkey_wrench
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Glenn Gillen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-07-13 00:00:00 +10:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: json
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - "="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.1.9
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: httparty
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.4.5
|
34
|
+
version:
|
35
|
+
description: A ruby API for managing lists, campaigns, subscribers, etc. within Mailchimp (http://www.mailchimp.com/)
|
36
|
+
email: glenn@rubypond.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
43
|
+
files:
|
44
|
+
- README.mdown
|
45
|
+
- Rakefile
|
46
|
+
- lib/monkey_wrench/array.rb
|
47
|
+
- lib/monkey_wrench/base.rb
|
48
|
+
- lib/monkey_wrench/campaign.rb
|
49
|
+
- lib/monkey_wrench/campaign_aim.rb
|
50
|
+
- lib/monkey_wrench/campaign_stats.rb
|
51
|
+
- lib/monkey_wrench/config.rb
|
52
|
+
- lib/monkey_wrench/error.rb
|
53
|
+
- lib/monkey_wrench/hash.rb
|
54
|
+
- lib/monkey_wrench/helper.rb
|
55
|
+
- lib/monkey_wrench/list.rb
|
56
|
+
- lib/monkey_wrench/member.rb
|
57
|
+
- lib/monkey_wrench/security.rb
|
58
|
+
- lib/monkey_wrench.rb
|
59
|
+
- test/fixtures/api_fail.json
|
60
|
+
- test/fixtures/campaigns_success.json
|
61
|
+
- test/fixtures/listBatchSubscribe10_success.json
|
62
|
+
- test/fixtures/listBatchSubscribe5_success.json
|
63
|
+
- test/fixtures/listBatchSubscribe_success.json
|
64
|
+
- test/fixtures/listBatchSubscribe_with_error_success.json
|
65
|
+
- test/fixtures/listBatchUnsubscribe_success.json
|
66
|
+
- test/fixtures/listMemberInfo_fail.json
|
67
|
+
- test/fixtures/listMemberInfo_success.json
|
68
|
+
- test/fixtures/listMembers_none_success.json
|
69
|
+
- test/fixtures/listMembers_success.json
|
70
|
+
- test/fixtures/lists_success.json
|
71
|
+
- test/fixtures/listSubscribe_success.json
|
72
|
+
- test/fixtures/listUnsubscribe_success.json
|
73
|
+
- test/fixtures/listUpdateMember_success.json
|
74
|
+
- test/monkey_wrench/campaign_aim_test.rb
|
75
|
+
- test/monkey_wrench/campaign_stats_test.rb
|
76
|
+
- test/monkey_wrench/campaign_test.rb
|
77
|
+
- test/monkey_wrench/hash_test.rb
|
78
|
+
- test/monkey_wrench/helper_test.rb
|
79
|
+
- test/monkey_wrench/list_test.rb
|
80
|
+
- test/monkey_wrench/security_test.rb
|
81
|
+
- test/test_helper.rb
|
82
|
+
has_rdoc: true
|
83
|
+
homepage: http://github.com/rubypond/monkey_wrench
|
84
|
+
licenses: []
|
85
|
+
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
|
89
|
+
require_paths:
|
90
|
+
- .
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: "0"
|
97
|
+
version:
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: "0"
|
103
|
+
version:
|
104
|
+
requirements: []
|
105
|
+
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 1.3.5
|
108
|
+
signing_key:
|
109
|
+
specification_version: 2
|
110
|
+
summary: A ruby wrapper for the Mailchimp API
|
111
|
+
test_files:
|
112
|
+
- test/fixtures/api_fail.json
|
113
|
+
- test/fixtures/campaigns_success.json
|
114
|
+
- test/fixtures/listBatchSubscribe10_success.json
|
115
|
+
- test/fixtures/listBatchSubscribe5_success.json
|
116
|
+
- test/fixtures/listBatchSubscribe_success.json
|
117
|
+
- test/fixtures/listBatchSubscribe_with_error_success.json
|
118
|
+
- test/fixtures/listBatchUnsubscribe_success.json
|
119
|
+
- test/fixtures/listMemberInfo_fail.json
|
120
|
+
- test/fixtures/listMemberInfo_success.json
|
121
|
+
- test/fixtures/listMembers_none_success.json
|
122
|
+
- test/fixtures/listMembers_success.json
|
123
|
+
- test/fixtures/lists_success.json
|
124
|
+
- test/fixtures/listSubscribe_success.json
|
125
|
+
- test/fixtures/listUnsubscribe_success.json
|
126
|
+
- test/fixtures/listUpdateMember_success.json
|
127
|
+
- test/monkey_wrench/campaign_aim_test.rb
|
128
|
+
- test/monkey_wrench/campaign_stats_test.rb
|
129
|
+
- test/monkey_wrench/campaign_test.rb
|
130
|
+
- test/monkey_wrench/hash_test.rb
|
131
|
+
- test/monkey_wrench/helper_test.rb
|
132
|
+
- test/monkey_wrench/list_test.rb
|
133
|
+
- test/monkey_wrench/security_test.rb
|
134
|
+
- test/test_helper.rb
|