mailgun 0.8 → 0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,16 +4,16 @@ shared_examples_for Set do
4
4
  Multiset[nil]
5
5
  Multiset[1, 2, 3]
6
6
 
7
- Multiset[].size.should eql(0)
8
- Multiset[nil].size.should eql(1)
9
- Multiset[[]].size.should eql(1)
10
- Multiset[[nil]].size.should eql(1)
7
+ expect(Multiset[].size).to eql(0)
8
+ expect(Multiset[nil].size).to eql(1)
9
+ expect(Multiset[[]].size).to eql(1)
10
+ expect(Multiset[[nil]].size).to eql(1)
11
11
 
12
12
  set = Multiset[2, 4, 6, 4]
13
- Multiset.new([2, 4, 6]).should_not eql(set)
13
+ expect(Multiset.new([2, 4, 6])).to_not eql(set)
14
14
 
15
15
  set = Multiset[2, 4, 6, 4]
16
- Multiset.new([2, 4, 6, 4]).should eql(set)
16
+ expect(Multiset.new([2, 4, 6, 4])).to eql(set)
17
17
  end
18
18
 
19
19
  it "should create a new set containing the elements of the given enumerable object" do
@@ -23,247 +23,247 @@ shared_examples_for Set do
23
23
  Multiset.new([1, 2])
24
24
  Multiset.new('a'..'c')
25
25
 
26
- lambda { Multiset.new(false) }.should raise_error
27
- lambda { Multiset.new(1) }.should raise_error
28
- lambda { Multiset.new(1, 2) }.should raise_error
26
+ expect(lambda { Multiset.new(false) }).to raise_error
27
+ expect(lambda { Multiset.new(1) }).to raise_error
28
+ expect(lambda { Multiset.new(1, 2) }).to raise_error
29
29
 
30
- Multiset.new().size.should eql(0)
31
- Multiset.new(nil).size.should eql(0)
32
- Multiset.new([]).size.should eql(0)
33
- Multiset.new([nil]).size.should eql(1)
30
+ expect(Multiset.new().size).to eql(0)
31
+ expect(Multiset.new(nil).size).to eql(0)
32
+ expect(Multiset.new([]).size).to eql(0)
33
+ expect(Multiset.new([nil]).size).to eql(1)
34
34
 
35
35
  ary = [2, 4, 6, 4]
36
36
  set = Multiset.new(ary)
37
37
  ary.clear
38
- set.should_not be_empty
39
- set.size.should eql(4)
38
+ expect(set).to_not be_empty
39
+ expect(set.size).to eql(4)
40
40
 
41
41
  ary = [1, 2, 3]
42
42
 
43
43
  s = Multiset.new(ary) { |o| o * 2 }
44
- [2, 4, 6].should eql(s.sort)
44
+ expect([2, 4, 6]).to eql(s.sort)
45
45
  end
46
46
 
47
47
  it "should duplicate set" do
48
48
  set1 = Multiset[1, 2]
49
49
  set2 = set1.dup
50
50
 
51
- set1.should_not equal(set2)
51
+ expect(set1).to_not equal(set2)
52
52
 
53
- set1.should eql(set2)
53
+ expect(set1).to eql(set2)
54
54
 
55
55
  set1.add(3)
56
56
 
57
- set1.should_not eql(set2)
57
+ expect(set1).to_not eql(set2)
58
58
  end
59
59
 
60
60
  it "should return the number of elements" do
61
- Multiset[].size.should eql(0)
62
- Multiset[1, 2].size.should eql(2)
63
- Multiset[1, 2, 1].size.should eql(3)
61
+ expect(Multiset[].size).to eql(0)
62
+ expect(Multiset[1, 2].size).to eql(2)
63
+ expect(Multiset[1, 2, 1].size).to eql(3)
64
64
  end
65
65
 
66
66
  it "should return true if the set contains no elements" do
67
- Multiset[].should be_empty
68
- Multiset[1, 2].should_not be_empty
67
+ expect(Multiset[]).to be_empty
68
+ expect(Multiset[1, 2]).to_not be_empty
69
69
  end
70
70
 
71
71
  it "should remove all elements and returns self" do
72
72
  set = Multiset[1, 2]
73
73
  ret = set.clear
74
74
 
75
- set.should equal(ret)
76
- set.should be_empty
75
+ expect(set).to equal(ret)
76
+ expect(set).to be_empty
77
77
  end
78
78
 
79
79
  it "should replaces the contents of the set with the contents of the given enumerable object and returns self" do
80
80
  set = Multiset[1, 2]
81
81
  ret = set.replace('a'..'c')
82
82
 
83
- set.should equal(ret)
84
- set.should eql(Multiset['a', 'b', 'c'])
83
+ expect(set).to equal(ret)
84
+ expect(set).to eql(Multiset['a', 'b', 'c'])
85
85
  end
86
86
 
87
87
  it "should convert the set to an array" do
88
88
  set = Multiset[1, 2, 3, 2]
89
89
  ary = set.to_a
90
90
 
91
- ary.sort.should eql([1, 2, 2, 3])
91
+ expect(ary.sort).to eql([1, 2, 2, 3])
92
92
  end
93
93
 
94
94
  it "should return true if the set contains the given object" do
95
95
  set = Multiset[1, 2, 3]
96
96
 
97
- set.include?(1).should be_true
98
- set.include?(2).should be_true
99
- set.include?(3).should be_true
100
- set.include?(0).should be_false
101
- set.include?(nil).should be_false
97
+ expect(set.include?(1)).to be_true
98
+ expect(set.include?(2)).to be_true
99
+ expect(set.include?(3)).to be_true
100
+ expect(set.include?(0)).to be_false
101
+ expect(set.include?(nil)).to be_false
102
102
 
103
103
  set = Multiset["1", nil, "2", nil, "0", "1", false]
104
- set.include?(nil).should be_true
105
- set.include?(false).should be_true
106
- set.include?("1").should be_true
107
- set.include?(0).should be_false
108
- set.include?(true).should be_false
104
+ expect(set.include?(nil)).to be_true
105
+ expect(set.include?(false)).to be_true
106
+ expect(set.include?("1")).to be_true
107
+ expect(set.include?(0)).to be_false
108
+ expect(set.include?(true)).to be_false
109
109
  end
110
110
 
111
111
  it "should return true if the set is a superset of the given set" do
112
112
  set = Multiset[1, 2, 3]
113
113
 
114
- lambda { set.superset?() }.should raise_error
115
- lambda { set.superset?(2) }.should raise_error
116
- lambda { set.superset?([2]) }.should raise_error
114
+ expect(lambda { set.superset?() }).to raise_error
115
+ expect(lambda { set.superset?(2) }).to raise_error
116
+ expect(lambda { set.superset?([2]) }).to raise_error
117
117
 
118
- set.superset?(Multiset[]).should be_true
119
- set.superset?(Multiset[1, 2]).should be_true
120
- set.superset?(Multiset[1, 2, 3]).should be_true
121
- set.superset?(Multiset[1, 2, 3, 4]).should be_false
122
- set.superset?(Multiset[1, 4]).should be_false
118
+ expect(set.superset?(Multiset[])).to be_true
119
+ expect(set.superset?(Multiset[1, 2])).to be_true
120
+ expect(set.superset?(Multiset[1, 2, 3])).to be_true
121
+ expect(set.superset?(Multiset[1, 2, 3, 4])).to be_false
122
+ expect(set.superset?(Multiset[1, 4])).to be_false
123
123
 
124
- Multiset[].superset?(Multiset[]).should be_true
124
+ expect(Multiset[].superset?(Multiset[])).to be_true
125
125
  end
126
126
 
127
127
  it "should return true if the set is a proper superset of the given set" do
128
128
  set = Multiset[1, 2, 3]
129
129
 
130
- lambda { set.proper_superset?() }.should raise_error
131
- lambda { set.proper_superset?(2) }.should raise_error
132
- lambda { set.proper_superset?([2]) }.should raise_error
130
+ expect(lambda { set.proper_superset?() }).to raise_error
131
+ expect(lambda { set.proper_superset?(2) }).to raise_error
132
+ expect(lambda { set.proper_superset?([2]) }).to raise_error
133
133
 
134
- set.proper_superset?(Multiset[]).should be_true
135
- set.proper_superset?(Multiset[1, 2]).should be_true
136
- set.proper_superset?(Multiset[1, 2, 3]).should be_false
137
- set.proper_superset?(Multiset[1, 2, 3, 4]).should be_false
138
- set.proper_superset?(Multiset[1, 4]).should be_false
134
+ expect(set.proper_superset?(Multiset[])).to be_true
135
+ expect(set.proper_superset?(Multiset[1, 2])).to be_true
136
+ expect(set.proper_superset?(Multiset[1, 2, 3])).to be_false
137
+ expect(set.proper_superset?(Multiset[1, 2, 3, 4])).to be_false
138
+ expect(set.proper_superset?(Multiset[1, 4])).to be_false
139
139
 
140
- Multiset[].proper_superset?(Multiset[]).should be_false
140
+ expect(Multiset[].proper_superset?(Multiset[])).to be_false
141
141
  end
142
142
 
143
143
  it "should return true if the set is a subset of the given set" do
144
144
  set = Multiset[1, 2, 3]
145
145
 
146
- lambda { set.subset?() }.should raise_error
147
- lambda { set.subset?(2) }.should raise_error
148
- lambda { set.subset?([2]) }.should raise_error
146
+ expect(lambda { set.subset?() }).to raise_error
147
+ expect(lambda { set.subset?(2) }).to raise_error
148
+ expect(lambda { set.subset?([2]) }).to raise_error
149
149
 
150
- set.subset?(Multiset[1, 2, 3, 4]).should be_true
151
- set.subset?(Multiset[1, 2, 3]).should be_true
152
- set.subset?(Multiset[1, 2]).should be_false
153
- set.subset?(Multiset[]).should be_false
150
+ expect(set.subset?(Multiset[1, 2, 3, 4])).to be_true
151
+ expect(set.subset?(Multiset[1, 2, 3])).to be_true
152
+ expect(set.subset?(Multiset[1, 2])).to be_false
153
+ expect(set.subset?(Multiset[])).to be_false
154
154
 
155
- Multiset[].subset?(Multiset[1]).should be_true
156
- Multiset[].subset?(Multiset[]).should be_true
155
+ expect(Multiset[].subset?(Multiset[1])).to be_true
156
+ expect(Multiset[].subset?(Multiset[])).to be_true
157
157
  end
158
158
 
159
159
  it "should return true if the set is a proper subset of the given set" do
160
160
  set = Multiset[1, 2, 3]
161
161
 
162
- lambda { set.proper_subset?() }.should raise_error
163
- lambda { set.proper_subset?(2) }.should raise_error
164
- lambda { set.proper_subset?([2]) }.should raise_error
162
+ expect(lambda { set.proper_subset?() }).to raise_error
163
+ expect(lambda { set.proper_subset?(2) }).to raise_error
164
+ expect(lambda { set.proper_subset?([2]) }).to raise_error
165
165
 
166
- set.proper_subset?(Multiset[1, 2, 3, 4]).should be_true
167
- set.proper_subset?(Multiset[1, 2, 3]).should be_false
168
- set.proper_subset?(Multiset[1, 2]).should be_false
169
- set.proper_subset?(Multiset[]).should be_false
166
+ expect(set.proper_subset?(Multiset[1, 2, 3, 4])).to be_true
167
+ expect(set.proper_subset?(Multiset[1, 2, 3])).to be_false
168
+ expect(set.proper_subset?(Multiset[1, 2])).to be_false
169
+ expect(set.proper_subset?(Multiset[])).to be_false
170
170
 
171
- Multiset[].proper_subset?(Multiset[]).should be_false
171
+ expect(Multiset[].proper_subset?(Multiset[])).to be_false
172
172
  end
173
173
 
174
174
  it "should add the given object to the set and return self" do
175
175
  set = Multiset[1, 2, 3]
176
176
 
177
177
  ret = set.add(2)
178
- set.should equal(ret)
179
- set.should eql(Multiset[1, 2, 2, 3])
178
+ expect(set).to equal(ret)
179
+ expect(set).to eql(Multiset[1, 2, 2, 3])
180
180
 
181
181
  ret = set.add(4)
182
- set.should equal(ret)
183
- set.should eql(Multiset[1, 2, 2, 3, 4])
182
+ expect(set).to equal(ret)
183
+ expect(set).to eql(Multiset[1, 2, 2, 3, 4])
184
184
  end
185
185
 
186
186
  it "should delete the given object from the set and return self" do
187
187
  set = Multiset[1, 2, 3]
188
188
 
189
189
  ret = set.delete(4)
190
- set.should equal(ret)
191
- set.should eql(Multiset[1, 2, 3])
190
+ expect(set).to equal(ret)
191
+ expect(set).to eql(Multiset[1, 2, 3])
192
192
 
193
193
  ret = set.delete(2)
194
- set.should eql(ret)
195
- set.should eql(Multiset[1, 3])
194
+ expect(set).to eql(ret)
195
+ expect(set).to eql(Multiset[1, 3])
196
196
  end
197
197
 
198
198
  it "should delete every element of the set for which block evaluates to true, and return self" do
199
199
  set = Multiset.new(1..10)
200
200
  ret = set.delete_if { |i| i > 10 }
201
- set.should equal(ret)
202
- set.should eql(Multiset.new(1..10))
201
+ expect(set).to equal(ret)
202
+ expect(set).to eql(Multiset.new(1..10))
203
203
 
204
204
  set = Multiset.new(1..10)
205
205
  ret = set.delete_if { |i| i % 3 == 0 }
206
- set.should equal(ret)
207
- set.should eql(Multiset[1, 2, 4, 5, 7, 8, 10])
206
+ expect(set).to equal(ret)
207
+ expect(set).to eql(Multiset[1, 2, 4, 5, 7, 8, 10])
208
208
  end
209
209
 
210
210
  it "should deletes every element of the set for which block evaluates to true but return nil if no changes were made" do
211
211
  set = Multiset.new(1..10)
212
212
 
213
213
  ret = set.reject! { |i| i > 10 }
214
- ret.should be_nil
215
- set.should eql(Multiset.new(1..10))
214
+ expect(ret).to be_nil
215
+ expect(set).to eql(Multiset.new(1..10))
216
216
 
217
217
  ret = set.reject! { |i| i % 3 == 0 }
218
- set.should equal(ret)
219
- set.should eql(Multiset[1, 2, 4, 5, 7, 8, 10])
218
+ expect(set).to equal(ret)
219
+ expect(set).to eql(Multiset[1, 2, 4, 5, 7, 8, 10])
220
220
  end
221
221
 
222
222
  it "should merge the elements of the given enumerable object to the set and return self" do
223
223
  set = Multiset[1, 2, 3]
224
224
 
225
225
  ret = set.merge([2, 4, 6])
226
- set.should equal(ret)
227
- set.should eql(Multiset[1, 2, 2, 3, 4, 6])
226
+ expect(set).to equal(ret)
227
+ expect(set).to eql(Multiset[1, 2, 2, 3, 4, 6])
228
228
  end
229
229
 
230
230
  it "should delete every element that appears in the given enumerable object and return self" do
231
231
  set = Multiset[1, 2, 3]
232
232
 
233
233
  ret = set.subtract([2, 4, 6])
234
- set.should equal(ret)
235
- set.should eql(Multiset[1, 3])
234
+ expect(set).to equal(ret)
235
+ expect(set).to eql(Multiset[1, 3])
236
236
  end
237
237
 
238
238
  it "should return a new set built by merging the set and the elements of the given enumerable object" do
239
239
  set = Multiset[1, 2, 3]
240
240
 
241
241
  ret = set + [2, 4, 6]
242
- set.should_not equal(ret)
243
- ret.should eql(Multiset[1, 2, 2, 3, 4, 6])
242
+ expect(set).to_not equal(ret)
243
+ expect(ret).to eql(Multiset[1, 2, 2, 3, 4, 6])
244
244
  end
245
245
 
246
246
  it "should return a new set built by duplicating the set, removing every element that appears in the given enumerable object" do
247
247
  set = Multiset[1, 2, 3]
248
248
 
249
249
  ret = set - [2, 4, 6]
250
- set.should_not equal(ret)
251
- ret.should eql(Multiset[1, 3])
250
+ expect(set).to_not equal(ret)
251
+ expect(ret).to eql(Multiset[1, 3])
252
252
  end
253
253
 
254
254
  it "should return a new set containing elements common to the set and the given enumerable object" do
255
255
  set = Multiset[1, 2, 3, 4]
256
256
 
257
257
  ret = set & [2, 4, 6]
258
- set.should_not equal(ret)
259
- ret.should eql(Multiset[2, 4])
258
+ expect(set).to_not equal(ret)
259
+ expect(ret).to eql(Multiset[2, 4])
260
260
  end
261
261
 
262
262
  it "should return a new set containing elements exclusive between the set and the given enumerable object" do
263
263
  set = Multiset[1, 2, 3, 4]
264
264
  ret = set ^ [2, 4, 5]
265
- set.should_not equal(ret)
266
- ret.should eql(Multiset[1, 3, 5])
265
+ expect(set).to_not equal(ret)
266
+ expect(ret).to eql(Multiset[1, 3, 5])
267
267
  end
268
268
  end
269
269
 
@@ -271,31 +271,31 @@ shared_examples_for Set, "with inital values [1, 2]" do
271
271
  it "should add element to set" do
272
272
  @set.add("foo")
273
273
 
274
- @set.include?(1).should be_true
275
- @set.include?(2).should be_true
276
- @set.include?("foo").should be_true
274
+ expect(@set.include?(1)).to be_true
275
+ expect(@set.include?(2)).to be_true
276
+ expect(@set.include?("foo")).to be_true
277
277
  end
278
278
 
279
279
  it "should merge elements into the set" do
280
280
  @set.merge([2, 6])
281
281
 
282
- @set.include?(1).should be_true
283
- @set.include?(2).should be_true
284
- @set.include?(2).should be_true
285
- @set.include?(6).should be_true
282
+ expect(@set.include?(1)).to be_true
283
+ expect(@set.include?(2)).to be_true
284
+ expect(@set.include?(2)).to be_true
285
+ expect(@set.include?(6)).to be_true
286
286
  end
287
287
 
288
288
  it "should iterate over all the values in the set" do
289
289
  a = []
290
290
  @set.each { |o| a << o }
291
- a.should eql([1, 2])
291
+ expect(a).to eql([1, 2])
292
292
  end
293
293
 
294
294
  it "should convert to an array" do
295
- @set.to_a.should eql([1, 2])
295
+ expect(@set.to_a).to eql([1, 2])
296
296
  end
297
297
 
298
298
  it "should convert to a set" do
299
- @set.to_set.to_a.should eql([1, 2])
299
+ expect(@set.to_set.to_a).to eql([1, 2])
300
300
  end
301
301
  end
@@ -11,11 +11,11 @@ Spec::Matchers.define :sorted_eql do |expected|
11
11
  if defined? Rubinius
12
12
  sorter = lambda { |a, b| a.hash <=> b.hash }
13
13
  match do |actual|
14
- actual.sort(&sorter).should eql(expected.sort(&sorter))
14
+ expect(actual.sort(&sorter)).to eql(expected.sort(&sorter))
15
15
  end
16
16
  else
17
17
  match do |actual|
18
- actual.should eql(expected)
18
+ expect(actual).to eql(expected)
19
19
  end
20
20
  end
21
21
  end
@@ -12,11 +12,9 @@ Gem::Specification.new do |gem|
12
12
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
13
  gem.name = "mailgun"
14
14
  gem.require_paths = ["lib"]
15
- gem.version = "0.8"
16
-
17
- gem.add_dependency(%q<rest-client>, [">= 0"])
15
+ gem.version = "0.11"
18
16
 
19
17
  gem.add_development_dependency(%q<rspec>, [">= 2"])
20
- gem.add_development_dependency(%q<debugger>, [">= 0"])
21
- gem.add_development_dependency(%q<vcr>, [">= 0"])
18
+ gem.add_development_dependency(%q<pry>, [">= 0"])
19
+ gem.add_development_dependency(%q<webmock>, [">= 2"])
22
20
  end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mailgun::Address do
4
+
5
+ before :each do
6
+ @sample = "foo@mailgun.net"
7
+ end
8
+
9
+ describe "validate an address" do
10
+ it "should require a public api key" do
11
+ mailgun = Mailgun({:api_key => "api-key"})
12
+ expect { mailgun.addresses }.to raise_error(ArgumentError, ":public_api_key is a required argument to validate addresses")
13
+ end
14
+ it "should make a GET request with correct params to find a given webhook" do
15
+ mailgun = Mailgun({:api_key => "api-key", :public_api_key => "public-api-key"})
16
+
17
+ sample_response = "{\"is_valid\":true,\"address\":\"foo@mailgun.net\",\"parts\":{\"display_name\":null,\"local_part\":\"foo\",\"domain\":\"mailgun.net\"},\"did_you_mean\":null}"
18
+ validate_url = mailgun.addresses.send(:address_url, 'validate')
19
+
20
+ expect(Mailgun).to receive(:submit).
21
+ with(:get, validate_url, {:address => @sample}).
22
+ and_return(sample_response)
23
+
24
+ mailgun.addresses.validate(@sample)
25
+ end
26
+ end
27
+ end