Permalink
Browse files

Implement #unmount.

  • Loading branch information...
1 parent 107a5ef commit 07a13931d7ce0510c330ff5ac61d626bd7388916 @mdub committed Apr 4, 2013
Showing with 33 additions and 1 deletion.
  1. +8 −1 lib/sham_rack/registration.rb
  2. +25 −0 spec/sham_rack_spec.rb
@@ -21,11 +21,14 @@ def application_for(address, port = nil)
mount_point_for(address, port).app
end
- # deprecated
def mount(app, address, port = nil)
at(address, port).mount(app)
end
+ def unmount(address, port = nil)
+ at(address, port).unmount
+ end
+
private
def mount_point_for(address, port)
@@ -57,6 +60,10 @@ def mount(app)
@app = app
end
+ def unmount
+ @app = nil
+ end
+
alias run mount
def rackup(&block)
@@ -9,6 +9,16 @@
describe ShamRack do
+ class NetHttpProhibited < StandardError; end
+
+ before do
+ any_instance_of(Net::HTTP) do |http|
+ stub(http).start do
+ raise NetHttpProhibited, "real network calls are not allowed"
+ end
+ end
+ end
+
after(:each) do
ShamRack.unmount_all
end
@@ -70,6 +80,21 @@
end
+ describe ".unmount" do
+
+ it "deregisters a mounted app" do
+
+ ShamRack.mount(GreetingApp.new, "gone.xyz")
+ ShamRack.unmount("gone.xyz")
+
+ lambda do
+ open("http://gone.xyz").read
+ end.should raise_error(NetHttpProhibited)
+
+ end
+
+ end
+
describe ".at" do
describe "with a block" do

0 comments on commit 07a1393

Please sign in to comment.