http_stub 0.9.3 → 0.9.4

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.
@@ -52,8 +52,10 @@ module HttpStub
52
52
  end
53
53
 
54
54
  def initialize!
55
- server_has_started!
55
+ on_initialize if self.respond_to?(:on_initialize) && !@initialized
56
56
  initialize_command_chain.execute()
57
+ @initialized = true
58
+ server_has_started!
57
59
  end
58
60
 
59
61
  def reset!
@@ -1,3 +1,3 @@
1
1
  module HttpStub
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.4"
3
3
  end
@@ -366,6 +366,19 @@ describe HttpStub::Configurer, "when the server is running" do
366
366
 
367
367
  end
368
368
 
369
+ context "and the configurer contains an on initialize callback" do
370
+
371
+ let(:configurer) { HttpStub::Examples::ConfigurerWithInitializeCallback.new }
372
+
373
+ it "should execute the callback" do
374
+ response = Net::HTTP.get_response(server_host, "/stubbed_on_initialize_path", server_port)
375
+
376
+ response.code.should eql("200")
377
+ response.body.should eql("Stubbed on initialize body")
378
+ end
379
+
380
+ end
381
+
369
382
  end
370
383
 
371
384
  context "and the configurer is uninitialized" do
@@ -443,6 +456,18 @@ describe HttpStub::Configurer, "when the server is running" do
443
456
 
444
457
  end
445
458
 
459
+ context "and the configurer contains an on initialize callback" do
460
+
461
+ let(:configurer) { HttpStub::Examples::ConfigurerWithInitializeCallback.new }
462
+
463
+ it "should not execute the callback" do
464
+ response = Net::HTTP.get_response(server_host, "/stubbed_on_initialize_path", server_port)
465
+
466
+ response.code.should eql("404")
467
+ end
468
+
469
+ end
470
+
446
471
  end
447
472
 
448
473
  end
@@ -15,6 +15,7 @@ require File.expand_path('../../lib/http_stub/rake/task_generators', __FILE__)
15
15
  require File.expand_path('../../lib/http_stub', __FILE__)
16
16
  require File.expand_path('../../examples/configurer_with_class_activator', __FILE__)
17
17
  require File.expand_path('../../examples/configurer_with_class_stub', __FILE__)
18
+ require File.expand_path('../../examples/configurer_with_initialize_callback', __FILE__)
18
19
  require File.expand_path('../../examples/configurer_with_complex_initializer', __FILE__)
19
20
  require File.expand_path('../../examples/configurer_with_many_class_activators', __FILE__)
20
21
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_stub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -325,7 +325,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
325
325
  version: '0'
326
326
  segments:
327
327
  - 0
328
- hash: -207127698310422263
328
+ hash: 2243155845271337400
329
329
  requirements: []
330
330
  rubyforge_project: http_stub
331
331
  rubygems_version: 1.8.25