File: rspec3-port.patch

package info (click to toggle)
ruby-messagebus-api 3.0.7%2Bgit.20130130.97b34ece.REALLY.1.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 172 kB
  • ctags: 71
  • sloc: ruby: 630; makefile: 2
file content (270 lines) | stat: -rw-r--r-- 10,783 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
Description: Port tests to RSpec 3 syntax
Author: Balasankar C <balasankarc@autistici.org>
Last-Update: 2015-12-28
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/Gemfile
+++ b/Gemfile
@@ -3,7 +3,7 @@
 gem 'activesupport'
 
 group :test, :development do
-  gem 'rspec', '2.5.0'
+  gem 'rspec', '>= 3.0.0'
   gem 'rr', '1.0.2'
   gem 'fakeweb'
 end
--- a/spec/messagebus_ruby_api/messagebus_spec.rb
+++ b/spec/messagebus_ruby_api/messagebus_spec.rb
@@ -95,7 +95,7 @@
       cert_file_path = File.join(File.dirname(__FILE__), "nofile.pem")
       expect do
         client.cacert_info(cert_file_path)
-      end.should raise_error
+      end.to raise_error
     end
 
     it "accepts a cert file that exists" do
@@ -103,59 +103,59 @@
       cert_file_path = File.join(File.dirname(__FILE__), "cacert.pem")
       expect do
         client.cacert_info(cert_file_path)
-      end.should_not raise_error
+      end.not_to raise_error
     end
   end
 
   describe "#add_message" do
     it "buffered send that adds to empty buffer" do
       client.add_message(default_message_params)
-      client.flushed?.should be_false
+      expect(client.flushed?).to be_falsey
     end
 
     it "buffered send that adds to empty buffer and sends with flush_buffer flag" do
       FakeWeb.register_uri(:post, "https://api.messagebus.com/api/v3/emails/send", :body => json_valid_send)
       client.add_message(default_message_params, true)
-      client.flushed?.should be_true
+      expect(client.flushed?).to be_truthy
     end
 
     it "should have user-agent and x-messagebus-key set in request headers" do
       FakeWeb.register_uri(:post, "https://api.messagebus.com/api/v3/emails/send", :body => json_valid_send)
       client.add_message(default_message_params, true)
-      client.flushed?.should be_true
+      expect(client.flushed?).to be_truthy
 
-      FakeWeb.last_request.get_fields("X-MessageBus-Key").should_not be_nil
-      FakeWeb.last_request.get_fields("User-Agent").should_not be_nil
-      FakeWeb.last_request.get_fields("Content-Type").should_not be_nil
+      expect(FakeWeb.last_request.get_fields("X-MessageBus-Key")).not_to be_nil
+      expect(FakeWeb.last_request.get_fields("User-Agent")).not_to be_nil
+      expect(FakeWeb.last_request.get_fields("Content-Type")).not_to be_nil
     end
 
     it "buffered send that adds to a buffer and auto-flushes" do
       FakeWeb.register_uri(:post, "https://api.messagebus.com/api/v3/emails/send", :body => create_success_result(client.message_buffer_size).to_json)
       (client.message_buffer_size-1).times do |idx|
         client.add_message(default_message_params)
-        client.flushed?.should be_false
+        expect(client.flushed?).to be_falsey
       end
       client.add_message(default_message_params)
-      client.flushed?.should be_true
-      client.results[:results].size.should == client.message_buffer_size
+      expect(client.flushed?).to be_truthy
+      expect(client.results[:results].size).to eq(client.message_buffer_size)
     end
 
     it "buffered send that adds templates to a buffer and auto-flushes" do
       FakeWeb.register_uri(:post, "https://api.messagebus.com/api/v3/templates/send", :body => create_success_result(client.message_buffer_size).to_json)
       (client.message_buffer_size-1).times do |idx|
         client.add_message(default_template_message_params)
-        client.flushed?.should be_false
+        expect(client.flushed?).to be_falsey
       end
       client.add_message(default_template_message_params)
-      client.flushed?.should be_true
-      client.results[:results].size.should == client.message_buffer_size
+      expect(client.flushed?).to be_truthy
+      expect(client.results[:results].size).to eq(client.message_buffer_size)
     end
   end
 
   describe "#flush" do
     it "flush called on empty buffer" do
       client.flush
-      client.flushed?.should be_false
+      expect(client.flushed?).to be_falsey
     end
 
     it "flush called on partially filled buffer" do
@@ -163,59 +163,59 @@
       FakeWeb.register_uri(:post, "https://api.messagebus.com/api/v3/emails/send", :body => create_success_result(message_count).to_json)
       (message_count).times do |idx|
         client.add_message(default_message_params)
-        client.flushed?.should be_false
+        expect(client.flushed?).to be_falsey
       end
       client.flush
-      client.flushed?.should be_true
-      client.results[:results].size.should == message_count
+      expect(client.flushed?).to be_truthy
+      expect(client.results[:results].size).to eq(message_count)
     end
 
     it "doesnt reset connection if under a minute old" do
       current_init_time=client.last_init_time
-      current_init_time.should be > Time.now.utc-5
+      expect(current_init_time).to be > Time.now.utc-5
       FakeWeb.register_uri(:post, "https://api.messagebus.com/api/v3/emails/send", :body => create_success_result(1).to_json)
       client.add_message(default_message_params)
       client.flush
-      client.flushed?.should be_true
-      client.results[:results].size.should == 1
-      client.last_init_time.should == current_init_time
+      expect(client.flushed?).to be_truthy
+      expect(client.results[:results].size).to eq(1)
+      expect(client.last_init_time).to eq(current_init_time)
     end
 
     it "resets connection if over a minute old" do
       client.last_init_time=Time.now.utc-60
       current_init_time=client.last_init_time
-      current_init_time.should be < Time.now.utc-59
+      expect(current_init_time).to be < Time.now.utc-59
       FakeWeb.register_uri(:post, "https://api.messagebus.com/api/v3/emails/send", :body => create_success_result(1).to_json)
       client.add_message(default_message_params)
       client.flush
-      client.flushed?.should be_true
-      client.results[:results].size.should == 1
-      client.last_init_time.should be > current_init_time
+      expect(client.flushed?).to be_truthy
+      expect(client.results[:results].size).to eq(1)
+      expect(client.last_init_time).to be > current_init_time
     end
   end
 
   describe "#message_buffer_size=" do
     it "can set the buffer size" do
       client.message_buffer_size=(10)
-      client.message_buffer_size.should == 10
+      expect(client.message_buffer_size).to eq(10)
     end
 
     it "cannot set an invalid buffer size" do
       default_buffer_size = 20
       client.message_buffer_size=(-1)
-      client.message_buffer_size.should == default_buffer_size
+      expect(client.message_buffer_size).to eq(default_buffer_size)
 
       client.message_buffer_size=(0)
-      client.message_buffer_size.should == default_buffer_size
+      expect(client.message_buffer_size).to eq(default_buffer_size)
 
       client.message_buffer_size=(101)
-      client.message_buffer_size.should == default_buffer_size
+      expect(client.message_buffer_size).to eq(default_buffer_size)
 
       client.message_buffer_size=(1)
-      client.message_buffer_size.should == 1
+      expect(client.message_buffer_size).to eq(1)
 
       client.message_buffer_size=(100)
-      client.message_buffer_size.should == 100
+      expect(client.message_buffer_size).to eq(100)
     end
   end
 
@@ -228,9 +228,9 @@
       FakeWeb.register_uri(:get, "https://api.messagebus.com/api/v3/delivery_errors?startDate=#{start_date_str}&endDate=#{end_date_str}&tag=", :body => json_delivery_errors)
       expect do
         response = client.delivery_errors(start_date_str, end_date_str)
-        FakeWeb.last_request.body.should be_nil
-        response.should == json_parse(json_delivery_errors)
-      end.should_not raise_error
+        expect(FakeWeb.last_request.body).to be_nil
+        expect(response).to eq(json_parse(json_delivery_errors))
+      end.not_to raise_error
     end
   end
 
@@ -245,9 +245,9 @@
       FakeWeb.register_uri(:get, expected_request, :body => json_unsubscribes)
       expect do
         response = client.unsubscribes(start_date_str, end_date_str)
-        FakeWeb.last_request.body.should be_nil
-        response.should == json_parse(json_unsubscribes)
-      end.should_not raise_error
+        expect(FakeWeb.last_request.body).to be_nil
+        expect(response).to eq(json_parse(json_unsubscribes))
+      end.not_to raise_error
     end
   end
 
@@ -261,9 +261,9 @@
       FakeWeb.register_uri(:delete, expected_request, :body => json_response_200)
       expect do
         response = client.delete_mailing_list_entry(mailing_list_key, to_email)
-        FakeWeb.last_request.body.should be_nil
-        response[:statusCode].should == 200
-      end.should_not raise_error
+        expect(FakeWeb.last_request.body).to be_nil
+        expect(response[:statusCode]).to eq(200)
+      end.not_to raise_error
 
     end
   end
@@ -277,9 +277,9 @@
       FakeWeb.register_uri(:post, expected_request, :body => json_response_200)
       expect do
         response = client.add_mailing_list_entry(mailing_list_key, merge_fields)
-        FakeWeb.last_request.body.should =~ /mergeField/
-        response[:statusCode].should == 200
-      end.should_not raise_error
+        expect(FakeWeb.last_request.body).to match(/mergeField/)
+        expect(response[:statusCode]).to eq(200)
+      end.not_to raise_error
 
     end
   end
@@ -291,8 +291,8 @@
       FakeWeb.register_uri(:get, expected_request, :body => json_mailing_lists)
       expect do
         response = client.mailing_lists
-        response.should == json_parse(json_mailing_lists)
-      end.should_not raise_error
+        expect(response).to eq(json_parse(json_mailing_lists))
+      end.not_to raise_error
     end
   end
 
@@ -303,8 +303,8 @@
       FakeWeb.register_uri(:post, expected_request, :body => json_mailing_list_create)
       expect do
         response = client.create_mailing_lists("Test List", ["%EMAIL%", "%SOME_TOKEN%"])
-        response.should == json_parse(json_mailing_list_create)
-      end.should_not raise_error
+        expect(response).to eq(json_parse(json_mailing_list_create))
+      end.not_to raise_error
     end
   end
 
@@ -318,14 +318,14 @@
       FakeWeb.register_uri(:get, expected_request, :body => json_stats)
       expect do
         response = client.stats(start_date_str, end_date_str)
-        response.should == json_parse(json_stats)
-      end.should_not raise_error
+        expect(response).to eq(json_parse(json_stats))
+      end.not_to raise_error
     end
   end
 
   describe "#format_iso_time" do
     it "formats ISO time in format YYYY-MM-DDTHH:mm:ssZ" do
-      client.format_iso_time(Time.now).should =~ /2\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ/
+      expect(client.format_iso_time(Time.now)).to match(/2\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ/)
     end
   end