spec/invoker/power/url_rewriter_spec.rb in invoker-1.5.6 vs spec/invoker/power/url_rewriter_spec.rb in invoker-1.5.7

- old
+ new

@@ -1,20 +1,26 @@ require 'spec_helper' describe Invoker::Power::UrlRewriter do let(:rewriter) { Invoker::Power::UrlRewriter.new } - context "matching domain part of incoming request" do - before(:all) do - @original_invoker_config = Invoker.config + before(:all) do + @original_invoker_config = Invoker.config + end - Invoker.config = mock - Invoker.config.stubs(:tld).returns("test") - end + def mock_invoker_tld_as(domain) + Invoker.config = mock + Invoker.config.stubs(:tld).returns(domain) + end - after(:all) do - Invoker.config = @original_invoker_config + after(:all) do + Invoker.config = @original_invoker_config + end + + context "matching domain part of incoming request" do + before(:each) do + mock_invoker_tld_as("test") end it "should match foo.test" do match = rewriter.extract_host_from_domain("foo.test") expect(match).to_not be_empty @@ -45,26 +51,19 @@ expect(match[0]).to eq("hello-world") end context 'user sets up a custom top level domain' do - before(:all) do - @original_invoker_config = Invoker.config - - Invoker.config = mock - Invoker.config.stubs(:tld).returns("local") + before(:each) do + mock_invoker_tld_as("local") end it 'should match domain part of incoming request correctly' do match = rewriter.extract_host_from_domain("foo.local") expect(match).to_not be_empty matching_string = match[0] expect(matching_string).to eq("foo") - end - - after(:all) do - Invoker.config = @original_invoker_config end end end end