clavem 1.3.0 → 1.3.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/Rakefile CHANGED
@@ -9,3 +9,21 @@ require "rspec/core/rake_task"
9
9
 
10
10
  RSpec::Core::RakeTask.new("spec")
11
11
  RSpec::Core::RakeTask.new("spec:coverage") { |t| t.ruby_opts = "-r./spec/coverage_helper" }
12
+
13
+ desc "Generate the documentation"
14
+ task :docs do
15
+ system("yardoc") || raise("Failed Execution of: yardoc")
16
+ end
17
+
18
+ desc "Get the current release version"
19
+ task :version, :with_name do |_, args|
20
+ gem = Bundler::GemHelper.instance.gemspec
21
+ puts [args[:with_name] == "true" ? gem.name : nil, gem.version].compact.join("-")
22
+ end
23
+
24
+ desc "Prepare the release"
25
+ task :prerelease => ["spec:coverage", "docs"] do
26
+ ["git add -A", "git commit -am \"Version #{Bundler::GemHelper.instance.gemspec.version}\""].each do |cmd|
27
+ system(cmd) || raise("Failed Execution of: #{cmd}")
28
+ end
29
+ end
data/clavem.gemspec CHANGED
@@ -24,6 +24,6 @@ Gem::Specification.new do |gem|
24
24
 
25
25
  gem.required_ruby_version = ">= 1.9.3"
26
26
 
27
- gem.add_dependency("mamertes", "~> 2.2.0")
27
+ gem.add_dependency("mamertes", "~> 2.2.1")
28
28
  gem.add_dependency("webrick", "~> 1.3.1")
29
29
  end
@@ -5876,7 +5876,7 @@
5876
5876
  </div>
5877
5877
 
5878
5878
  <div id="footer">
5879
- Generated on Sun Jul 14 19:41:24 2013 by
5879
+ Generated on Sat Jul 20 12:09:47 2013 by
5880
5880
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
5881
5881
  0.8.6.2 (ruby-1.9.3).
5882
5882
  </div>
@@ -124,7 +124,7 @@
124
124
  </div>
125
125
 
126
126
  <div id="footer">
127
- Generated on Sun Jul 14 19:41:23 2013 by
127
+ Generated on Sat Jul 20 12:09:46 2013 by
128
128
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
129
129
  0.8.6.2 (ruby-1.9.3).
130
130
  </div>
@@ -124,7 +124,7 @@
124
124
  </div>
125
125
 
126
126
  <div id="footer">
127
- Generated on Sun Jul 14 19:41:23 2013 by
127
+ Generated on Sat Jul 20 12:09:46 2013 by
128
128
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
129
129
  0.8.6.2 (ruby-1.9.3).
130
130
  </div>
@@ -124,7 +124,7 @@
124
124
  </div>
125
125
 
126
126
  <div id="footer">
127
- Generated on Sun Jul 14 19:41:23 2013 by
127
+ Generated on Sat Jul 20 12:09:46 2013 by
128
128
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
129
129
  0.8.6.2 (ruby-1.9.3).
130
130
  </div>
@@ -116,7 +116,7 @@
116
116
  </div>
117
117
 
118
118
  <div id="footer">
119
- Generated on Sun Jul 14 19:41:23 2013 by
119
+ Generated on Sat Jul 20 12:09:46 2013 by
120
120
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
121
121
  0.8.6.2 (ruby-1.9.3).
122
122
  </div>
@@ -149,7 +149,7 @@
149
149
 
150
150
  </div>
151
151
  </dt>
152
- <dd><pre class="code"><span class='int'>0</span></pre></dd>
152
+ <dd><pre class="code"><span class='int'>1</span></pre></dd>
153
153
 
154
154
  <dt id="STRING-constant" class="">STRING =
155
155
  <div class="docstring">
@@ -180,7 +180,7 @@
180
180
  </div>
181
181
 
182
182
  <div id="footer">
183
- Generated on Sun Jul 14 19:41:23 2013 by
183
+ Generated on Sat Jul 20 12:09:46 2013 by
184
184
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
185
185
  0.8.6.2 (ruby-1.9.3).
186
186
  </div>
data/doc/Clavem.html CHANGED
@@ -120,7 +120,7 @@
120
120
  </div>
121
121
 
122
122
  <div id="footer">
123
- Generated on Sun Jul 14 19:41:23 2013 by
123
+ Generated on Sat Jul 20 12:09:46 2013 by
124
124
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
125
125
  0.8.6.2 (ruby-1.9.3).
126
126
  </div>
data/doc/_index.html CHANGED
@@ -183,7 +183,7 @@
183
183
  </div>
184
184
 
185
185
  <div id="footer">
186
- Generated on Sun Jul 14 19:41:23 2013 by
186
+ Generated on Sat Jul 20 12:09:46 2013 by
187
187
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
188
188
  0.8.6.2 (ruby-1.9.3).
189
189
  </div>
data/doc/file.README.html CHANGED
@@ -126,7 +126,7 @@ end
126
126
  </div></div>
127
127
 
128
128
  <div id="footer">
129
- Generated on Sun Jul 14 19:41:23 2013 by
129
+ Generated on Sat Jul 20 12:09:46 2013 by
130
130
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
131
131
  0.8.6.2 (ruby-1.9.3).
132
132
  </div>
data/doc/index.html CHANGED
@@ -126,7 +126,7 @@ end
126
126
  </div></div>
127
127
 
128
128
  <div id="footer">
129
- Generated on Sun Jul 14 19:41:23 2013 by
129
+ Generated on Sat Jul 20 12:09:46 2013 by
130
130
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
131
131
  0.8.6.2 (ruby-1.9.3).
132
132
  </div>
@@ -103,7 +103,7 @@
103
103
  </div>
104
104
 
105
105
  <div id="footer">
106
- Generated on Sun Jul 14 19:41:23 2013 by
106
+ Generated on Sat Jul 20 12:09:46 2013 by
107
107
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
108
  0.8.6.2 (ruby-1.9.3).
109
109
  </div>
@@ -16,7 +16,7 @@ module Clavem
16
16
  MINOR = 3
17
17
 
18
18
  # The patch version.
19
- PATCH = 0
19
+ PATCH = 1
20
20
 
21
21
  # The current version of clavem.
22
22
  STRING = [MAJOR, MINOR, PATCH].compact.join(".")
@@ -6,59 +6,59 @@
6
6
 
7
7
  require "spec_helper"
8
8
 
9
- class ClavemDummyServer
10
- attr_accessor :started
9
+ describe Clavem::Authorizer do
10
+ class ClavemDummyServer
11
+ attr_accessor :started
11
12
 
12
- def start
13
- self.started = true
14
- end
13
+ def start
14
+ self.started = true
15
+ end
15
16
 
16
- def shutdown
17
- self.started = false
18
- end
17
+ def shutdown
18
+ self.started = false
19
+ end
19
20
 
20
- def mount_proc(path, &handler)
21
+ def mount_proc(path, &handler)
21
22
 
23
+ end
22
24
  end
23
- end
24
25
 
25
- class ClavemDummyRequest
26
- attr_reader :query
26
+ class ClavemDummyRequest
27
+ attr_reader :query
27
28
 
28
- def initialize(token = nil)
29
- @query = {"oauth_token" => token}
29
+ def initialize(token = nil)
30
+ @query = {"oauth_token" => token}
31
+ end
30
32
  end
31
- end
32
33
 
33
- class ClavemDummyResponse
34
- attr_accessor :status
35
- attr_accessor :body
36
- end
34
+ class ClavemDummyResponse
35
+ attr_accessor :status
36
+ attr_accessor :body
37
+ end
37
38
 
38
- describe Clavem::Authorizer do
39
39
  let(:instance){::Clavem::Authorizer.new}
40
40
 
41
41
  describe ".instance" do
42
- it("should call .new with the passed arguments") do
43
- ::Clavem::Authorizer.should_receive(:new).with("HOST", "PORT", "COMMAND", "TITLE", "TEMPLATE", "TIMEOUT")
42
+ it "should call .new with the passed arguments" do
43
+ expect(::Clavem::Authorizer).to receive(:new).with("HOST", "PORT", "COMMAND", "TITLE", "TEMPLATE", "TIMEOUT")
44
44
  ::Clavem::Authorizer.instance("HOST", "PORT", "COMMAND", "TITLE", "TEMPLATE", "TIMEOUT")
45
45
  end
46
46
 
47
- it("should return the same instance") do
48
- ::Clavem::Authorizer.stub(:new) { Time.now }
47
+ it "should return the same instance" do
48
+ allow(::Clavem::Authorizer).to receive(:new) { Time.now }
49
49
  authorizer = ::Clavem::Authorizer.instance("FIRST")
50
50
  expect(::Clavem::Authorizer.instance("SECOND")).to be(authorizer)
51
51
  end
52
52
 
53
- it("should return a new instance if requested to") do
54
- ::Clavem::Authorizer.stub(:new) { Time.now }
53
+ it "should return a new instance if requested to" do
54
+ allow(::Clavem::Authorizer).to receive(:new) { Time.now }
55
55
  authorizer = ::Clavem::Authorizer.instance("FIRST")
56
56
  expect(::Clavem::Authorizer.instance("HOST", "PORT", "COMMAND", "TITLE", "TEMPLATE", "TIMEOUT", true)).not_to be(authorizer)
57
57
  end
58
58
  end
59
59
 
60
60
  describe "#initialize" do
61
- it("should handle default arguments") do
61
+ it "should handle default arguments" do
62
62
  authorizer = ::Clavem::Authorizer.new
63
63
  expect(authorizer.host).to eq("localhost")
64
64
  expect(authorizer.port).to eq(2501)
@@ -69,7 +69,7 @@ describe Clavem::Authorizer do
69
69
  expect(authorizer.response_handler).to be_nil
70
70
  end
71
71
 
72
- it("should assign arguments") do
72
+ it "should assign arguments" do
73
73
  authorizer = ::Clavem::Authorizer.new("HOST", 2511, "COMMAND", "TITLE", "TEMPLATE", 2) do end
74
74
  expect(authorizer.host).to eq("HOST")
75
75
  expect(authorizer.port).to eq(2511)
@@ -80,62 +80,62 @@ describe Clavem::Authorizer do
80
80
  expect(authorizer.response_handler).to be_a(Proc)
81
81
  end
82
82
 
83
- it("should correct wrong arguments") do
83
+ it "should correct wrong arguments" do
84
84
  authorizer = ::Clavem::Authorizer.new("IP", -10, nil, nil, "", -1)
85
85
  expect(authorizer.port).to eq(2501)
86
86
  expect(authorizer.timeout).to eq(0)
87
87
  end
88
88
 
89
- it("should setup internal status") do
89
+ it "should setup internal status" do
90
90
  authorizer = ::Clavem::Authorizer.new
91
91
  expect(authorizer.token).to be_nil
92
92
  expect(authorizer.status).to eq(:waiting)
93
93
  end
94
94
 
95
- it("should return self") do
95
+ it "should return self" do
96
96
  expect(::Clavem::Authorizer.new).to be_a(::Clavem::Authorizer)
97
97
  end
98
98
  end
99
99
 
100
100
  describe "#authorize" do
101
- it("should call the correct authorize sequence and then return self") do
101
+ it "should call the correct authorize sequence and then return self" do
102
102
  sequence = []
103
103
  instance = ::Clavem::Authorizer.new
104
104
  server = ::ClavemDummyServer.new
105
105
 
106
106
  # Setup stuff
107
- instance.stub(:setup_webserver) do sequence << 1 end
107
+ allow(instance).to receive(:setup_webserver) do sequence << 1 end
108
108
 
109
109
  instance.instance_variable_set(:@server, server)
110
- instance.stub(:setup_interruptions_handling) do sequence << 2 end
111
- instance.stub(:setup_timeout_handling) do sequence << 3 end
112
- instance.stub(:open_endpoint) do sequence << 4 end
110
+ allow(instance).to receive(:setup_interruptions_handling) do sequence << 2 end
111
+ allow(instance).to receive(:setup_timeout_handling) do sequence << 3 end
112
+ allow(instance).to receive(:open_endpoint) do sequence << 4 end
113
113
 
114
- server.should_receive(:start)
114
+ expect(server).to receive(:start)
115
115
  expect(instance.authorize("URL")).to be(instance)
116
116
  expect(sequence).to eq([1, 2, 3, 4])
117
117
  end
118
118
 
119
- it("should raise an exception in case of timeout") do
119
+ it "should raise an exception in case of timeout" do
120
120
  instance = ::Clavem::Authorizer.new
121
- instance.stub(:setup_webserver).and_raise(::Clavem::Exceptions::Timeout)
121
+ allow(instance).to receive(:setup_webserver).and_raise(::Clavem::Exceptions::Timeout)
122
122
  expect { instance.authorize("URL") }.to raise_error(::Clavem::Exceptions::Timeout)
123
123
  expect(instance.status).to eq(:failure)
124
124
  end
125
125
 
126
- it("should raise an exception in case of errors") do
126
+ it "should raise an exception in case of errors" do
127
127
  instance = ::Clavem::Authorizer.new
128
- instance.stub(:setup_webserver).and_raise(ArgumentError)
128
+ allow(instance).to receive(:setup_webserver).and_raise(ArgumentError)
129
129
  expect { instance.authorize("URL") }.to raise_error(::Clavem::Exceptions::Failure)
130
130
  expect(instance.status).to eq(:failure)
131
131
  end
132
132
 
133
- it("should always run #cleanup") do
133
+ it "should always run #cleanup" do
134
134
  cleaned = false
135
135
  instance = ::Clavem::Authorizer.new
136
- instance.stub(:cleanup) do cleaned = true end
137
- instance.stub(:open_endpoint) do end
138
- instance.stub(:setup_webserver) do
136
+ allow(instance).to receive(:cleanup) do cleaned = true end
137
+ allow(instance).to receive(:open_endpoint) do end
138
+ allow(instance).to receive(:setup_webserver) do
139
139
  instance.instance_variable_set(:@server, ::ClavemDummyServer.new)
140
140
  end
141
141
 
@@ -144,31 +144,31 @@ describe Clavem::Authorizer do
144
144
  expect(cleaned).to be_true
145
145
 
146
146
  cleaned = false
147
- instance.stub(:setup_webserver).and_raise(ArgumentError)
147
+ allow(instance).to receive(:setup_webserver).and_raise(ArgumentError)
148
148
  expect { instance.authorize("URL") }.to raise_error(::Clavem::Exceptions::Failure)
149
149
  expect(cleaned).to be_true
150
150
 
151
151
  cleaned = false
152
- instance.stub(:setup_webserver).and_raise(::Clavem::Exceptions::Timeout)
152
+ allow(instance).to receive(:setup_webserver).and_raise(::Clavem::Exceptions::Timeout)
153
153
  expect { instance.authorize("URL") }.to raise_error(::Clavem::Exceptions::Timeout)
154
154
  expect(cleaned).to be_true
155
155
  end
156
156
  end
157
157
 
158
158
  describe "#callback_url" do
159
- it("should return the correct callback") do
159
+ it "should return the correct callback" do
160
160
  expect(::Clavem::Authorizer.new.callback_url).to eq("http://localhost:2501/")
161
161
  expect(::Clavem::Authorizer.new("10.0.0.1", "80").callback_url).to eq("http://10.0.0.1:80/")
162
162
  end
163
163
  end
164
164
 
165
165
  describe "#default_response_handler" do
166
- it("should return the token") do
166
+ it "should return the token" do
167
167
  instance = ::Clavem::Authorizer.new
168
168
  expect(instance.default_response_handler(instance, ::ClavemDummyRequest.new("TOKEN"), nil)).to eq("TOKEN")
169
169
  end
170
170
 
171
- it("should return an empty string by default") do
171
+ it "should return an empty string by default" do
172
172
  instance = ::Clavem::Authorizer.new
173
173
  expect(instance.default_response_handler(instance, ::ClavemDummyRequest.new(nil), nil)).to eq("")
174
174
  end
@@ -182,63 +182,63 @@ describe Clavem::Authorizer do
182
182
 
183
183
  it "should set using English if called without arguments" do
184
184
  authorizer = ::Clavem::Authorizer.new
185
- R18n::I18n.should_receive(:new).with([:en, ENV["LANG"], R18n::I18n.system_locale].compact, File.absolute_path(::Pathname.new(File.dirname(__FILE__)).to_s + "/../../locales/")).and_call_original
185
+ expect(R18n::I18n).to receive(:new).with([:en, ENV["LANG"], R18n::I18n.system_locale].compact, File.absolute_path(::Pathname.new(File.dirname(__FILE__)).to_s + "/../../locales/")).and_call_original
186
186
  authorizer.localize
187
187
  end
188
188
 
189
189
  it "should set the requested locale" do
190
190
  authorizer = ::Clavem::Authorizer.new
191
- R18n::I18n.should_receive(:new).with([:it, ENV["LANG"], R18n::I18n.system_locale].compact, File.absolute_path(::Pathname.new(File.dirname(__FILE__)).to_s + "/../../locales/")).and_call_original
191
+ expect(R18n::I18n).to receive(:new).with([:it, ENV["LANG"], R18n::I18n.system_locale].compact, File.absolute_path(::Pathname.new(File.dirname(__FILE__)).to_s + "/../../locales/")).and_call_original
192
192
  authorizer.localize(:it)
193
193
  end
194
194
  end
195
195
 
196
196
  # PRIVATE
197
197
  describe "#open_endpoint" do
198
- it("should call system with the right command") do
199
- Kernel.should_receive(:system).with("open \"URL\"")
198
+ it "should call system with the right command" do
199
+ expect(Kernel).to receive(:system).with("open \"URL\"")
200
200
  instance.instance_variable_set(:@url, "URL")
201
201
  instance.send(:open_endpoint)
202
202
 
203
- Kernel.should_receive(:system).with("COMMAND")
203
+ expect(Kernel).to receive(:system).with("COMMAND")
204
204
  ::Clavem::Authorizer.new("HOST", "PORT", "COMMAND").send(:open_endpoint)
205
205
  end
206
206
 
207
- it("should raise exception in case of failures") do
208
- Kernel.stub(:system).and_raise(RuntimeError)
207
+ it "should raise exception in case of failures" do
208
+ allow(Kernel).to receive(:system).and_raise(RuntimeError)
209
209
  expect { instance.send(:open_endpoint) }.to raise_error(::Clavem::Exceptions::Failure)
210
210
  end
211
211
  end
212
212
 
213
213
  describe "#setup_interruptions_handling" do
214
- it("should add handler for SIGINT, SIGTERM, SIGKILL") do
215
- Kernel.should_receive(:trap).with("USR2")
216
- Kernel.should_receive(:trap).with("INT")
217
- Kernel.should_receive(:trap).with("TERM")
218
- Kernel.should_receive(:trap).with("KILL")
214
+ it "should add handler for SIGINT, SIGTERM, SIGKILL" do
215
+ expect(Kernel).to receive(:trap).with("USR2")
216
+ expect(Kernel).to receive(:trap).with("INT")
217
+ expect(Kernel).to receive(:trap).with("TERM")
218
+ expect(Kernel).to receive(:trap).with("KILL")
219
219
  instance.send(:setup_interruptions_handling)
220
220
  end
221
221
  end
222
222
 
223
223
  describe "#setup_timeout_handling" do
224
- it("should not set a timeout handler by default") do
224
+ it "should not set a timeout handler by default" do
225
225
  authorizer = ::Clavem::Authorizer.new
226
- authorizer.stub(:open_endpoint)
227
- authorizer.stub(:setup_webserver) do authorizer.instance_variable_set(:@server, ::ClavemDummyServer.new) end
226
+ allow(authorizer).to receive(:open_endpoint)
227
+ allow(authorizer).to receive(:setup_webserver) do authorizer.instance_variable_set(:@server, ::ClavemDummyServer.new) end
228
228
  authorizer.authorize("URL")
229
229
  expect(authorizer.instance_variable_get(:@timeout_handler)).to be_nil
230
230
  end
231
231
 
232
- it("should set and execute a timeout handler") do
233
- Process.should_receive(:kill).with("USR2", 0)
234
- Kernel.should_receive(:sleep).with(0.5)
232
+ it "should set and execute a timeout handler" do
233
+ expect(Process).to receive(:kill).with("USR2", 0)
234
+ expect(Kernel).to receive(:sleep).with(0.5)
235
235
 
236
236
  server = ::ClavemDummyServer.new
237
- server.stub(:start) do sleep(1) end
237
+ allow(server).to receive(:start) do sleep(1) end
238
238
 
239
239
  authorizer = ::Clavem::Authorizer.new("HOST", "PORT", "COMMAND", "TITLE", "TEMPLATE", 500)
240
- authorizer.stub(:open_endpoint) do end
241
- authorizer.stub(:setup_webserver) do authorizer.instance_variable_set(:@server, server) end
240
+ allow(authorizer).to receive(:open_endpoint) do end
241
+ allow(authorizer).to receive(:setup_webserver) do authorizer.instance_variable_set(:@server, server) end
242
242
  expect { authorizer.authorize("URL") }.to raise_error(::Clavem::Exceptions::Timeout)
243
243
 
244
244
  thread = authorizer.instance_variable_get(:@timeout_thread)
@@ -250,18 +250,18 @@ describe Clavem::Authorizer do
250
250
  describe "#setup_webserver" do
251
251
  it "should initialize a web server with correct arguments" do
252
252
  logger = WEBrick::Log.new("/dev/null")
253
- WEBrick::Log.stub(:new).and_return(logger)
253
+ allow(WEBrick::Log).to receive(:new).and_return(logger)
254
254
 
255
- ::WEBrick::HTTPServer.should_receive(:new).with(BindAddress: "10.0.0.1", Port: 80, Logger: logger, AccessLog: [nil, nil]).and_return(::ClavemDummyServer.new)
255
+ expect(::WEBrick::HTTPServer).to receive(:new).with(BindAddress: "10.0.0.1", Port: 80, Logger: logger, AccessLog: [nil, nil]).and_return(::ClavemDummyServer.new)
256
256
  authorizer = ::Clavem::Authorizer.new("10.0.0.1", 80)
257
257
  authorizer.send(:setup_webserver)
258
258
  end
259
259
 
260
260
  it "should setup a single request handler on /" do
261
261
  server = ::ClavemDummyServer.new
262
- ::WEBrick::HTTPServer.stub(:new).and_return(server)
262
+ allow(::WEBrick::HTTPServer).to receive(:new).and_return(server)
263
263
  authorizer = ::Clavem::Authorizer.new("HOST", "PORT")
264
- server.should_receive(:mount_proc).with("/")
264
+ expect(server).to receive(:mount_proc).with("/")
265
265
  authorizer.send(:setup_webserver)
266
266
  end
267
267
  end
@@ -273,12 +273,12 @@ describe Clavem::Authorizer do
273
273
 
274
274
  it "should call the correct handler" do
275
275
  instance.instance_variable_set(:@server, ::ClavemDummyServer.new)
276
- instance.should_receive(:default_response_handler).with(instance, request, response)
276
+ expect(instance).to receive(:default_response_handler).with(instance, request, response)
277
277
  instance.send(:dispatch_request, request, response)
278
278
 
279
279
  authorizer = ::Clavem::Authorizer.new do end
280
280
  authorizer.instance_variable_set(:@server, ::ClavemDummyServer.new)
281
- authorizer.response_handler.should_receive(:call).with(authorizer, request, response)
281
+ expect(authorizer.response_handler).to receive(:call).with(authorizer, request, response)
282
282
  authorizer.send(:dispatch_request, request, response)
283
283
  end
284
284
 
@@ -286,13 +286,13 @@ describe Clavem::Authorizer do
286
286
  authorizer = ::Clavem::Authorizer.new
287
287
  authorizer.instance_variable_set(:@server, server)
288
288
  authorizer.status = :waiting
289
- server.should_receive(:shutdown)
289
+ expect(server).to receive(:shutdown)
290
290
  authorizer.send(:dispatch_request, request, response)
291
291
 
292
292
  authorizer = ::Clavem::Authorizer.new
293
293
  authorizer.instance_variable_set(:@server, server)
294
294
  authorizer.status = :success
295
- server.should_not_receive(:shutdown)
295
+ expect(server).not_to receive(:shutdown)
296
296
  authorizer.send(:dispatch_request, request, response)
297
297
  end
298
298
 
@@ -313,7 +313,7 @@ describe Clavem::Authorizer do
313
313
  it "should render the body of the response" do
314
314
  authorizer = ::Clavem::Authorizer.new
315
315
  authorizer.instance_variable_set(:@server, server)
316
- authorizer.instance_variable_get(:@compiled_template).should_receive(:result).and_return("TEMPLATE")
316
+ expect(authorizer.instance_variable_get(:@compiled_template)).to receive(:result).and_return("TEMPLATE")
317
317
  authorizer.send(:dispatch_request, request, response)
318
318
  expect(response.body).to eq("TEMPLATE")
319
319
  end
@@ -322,30 +322,30 @@ describe Clavem::Authorizer do
322
322
  describe "#cleanup" do
323
323
  it "should shutdown the server and cleanup signal handling" do
324
324
  server = ::ClavemDummyServer.new
325
- server.stub(:start) do sleep(1) end
325
+ allow(server).to receive(:start) do sleep(1) end
326
326
 
327
327
  authorizer = ::Clavem::Authorizer.new("HOST", "PORT", "COMMAND", "TITLE", "TEMPLATE")
328
- authorizer.stub(:open_endpoint) do end
329
- authorizer.stub(:setup_webserver) do authorizer.instance_variable_set(:@server, server) end
328
+ allow(authorizer).to receive(:open_endpoint) do end
329
+ allow(authorizer).to receive(:setup_webserver) do authorizer.instance_variable_set(:@server, server) end
330
330
  authorizer.authorize("URL")
331
331
 
332
- Kernel.should_receive(:trap).with("USR2", "DEFAULT")
333
- Kernel.should_receive(:trap).with("INT", "DEFAULT")
334
- Kernel.should_receive(:trap).with("TERM", "DEFAULT")
335
- Kernel.should_receive(:trap).with("KILL", "DEFAULT")
336
- server.should_receive(:shutdown)
332
+ expect(Kernel).to receive(:trap).with("USR2", "DEFAULT")
333
+ expect(Kernel).to receive(:trap).with("INT", "DEFAULT")
334
+ expect(Kernel).to receive(:trap).with("TERM", "DEFAULT")
335
+ expect(Kernel).to receive(:trap).with("KILL", "DEFAULT")
336
+ expect(server).to receive(:shutdown)
337
337
  authorizer.send(:cleanup)
338
338
  end
339
339
 
340
340
  it "should exit timeout handling thread if active" do
341
341
  thread = nil
342
342
  server = ::ClavemDummyServer.new
343
- server.stub(:start) do sleep(1) end
343
+ allow(server).to receive(:start) do sleep(1) end
344
344
 
345
345
  authorizer = ::Clavem::Authorizer.new("HOST", "PORT", "COMMAND", "TITLE", "TEMPLATE", 5000)
346
346
  authorizer.send(:setup_timeout_handling)
347
347
  thread = authorizer.instance_variable_get(:@timeout_thread)
348
- thread.should_receive(:exit)
348
+ expect(thread).to receive(:exit)
349
349
  authorizer.send(:cleanup)
350
350
  end
351
351
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clavem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-15 00:00:00.000000000 Z
12
+ date: 2013-07-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mamertes
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 2.2.0
21
+ version: 2.2.1
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 2.2.0
29
+ version: 2.2.1
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: webrick
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  segments:
114
114
  - 0
115
- hash: 747595586087603511
115
+ hash: -4417363914143300704
116
116
  requirements: []
117
117
  rubyforge_project: clavem
118
118
  rubygems_version: 1.8.25