Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Pass args to the shared example groups to filter out particular examp…

…les.
  • Loading branch information...
commit 910c1b59767c3ce75c7b5c58513e0834c6760b8e 1 parent fed4966
@myronmarston myronmarston authored
View
2  spec/acceptance/em_http_request/em_http_request_spec.rb
@@ -9,7 +9,7 @@
describe "EM::HttpRequest" do
include EMHttpRequestSpecHelper
- include_examples "with WebMock"
+ include_context "with WebMock", :no_status_message
#functionality only supported for em-http-request 1.x
if defined?(EventMachine::HttpConnection)
View
2  spec/acceptance/excon/excon_spec.rb
@@ -4,7 +4,7 @@
describe "Excon" do
include ExconSpecHelper
- include_context "with WebMock"
+ include_context "with WebMock", :no_status_message, :no_url_auth
it 'should allow Excon requests to use query hash paramters' do
stub_request(:get, "http://example.com/resource/?a=1&b=2").to_return(:body => "abc")
View
2  spec/acceptance/shared/allowing_and_disabling_net_connect.rb
@@ -1,4 +1,4 @@
-shared_context "allowing and disabling net connect" do
+shared_context "allowing and disabling net connect" do |*adapter_info|
describe "when net connect" do
describe "is allowed", :net_connect => true do
before(:each) do
View
10 spec/acceptance/shared/callbacks.rb
@@ -1,4 +1,4 @@
-shared_context "callbacks" do
+shared_context "callbacks" do |*adapter_info|
describe "when after_request callback is declared" do
before(:each) do
WebMock.reset_callbacks
@@ -105,12 +105,8 @@
end
it "should pass real response to callback with status and message" do
- # not supported by em-http-request, it always returns "unknown" for http_reason
- # not supported by excon, it only returns a status code
- unless [:em_http_request, :excon].include?(http_library)
- @response.status[0].should == 302
- @response.status[1].should == "Found"
- end
+ @response.status[0].should == 302
+ @response.status[1].should == "Found" unless adapter_info.include?(:no_status_message)
end
it "should pass real response to callback with headers" do
View
2  spec/acceptance/shared/enabling_and_disabling_webmock.rb
@@ -1,4 +1,4 @@
-shared_context "enabled and disabled webmock" do
+shared_context "enabled and disabled webmock" do |*adapter_info|
describe "when webmock is disabled" do
before(:each) do
WebMock.disable!
View
2  spec/acceptance/shared/precedence_of_stubs.rb
@@ -1,4 +1,4 @@
-shared_context "precedence of stubs" do
+shared_context "precedence of stubs" do |*adapter_info|
describe "when choosing a matching request stub" do
it "should use the last declared matching request stub" do
stub_request(:get, "www.example.com").to_return(:body => "abc")
View
5 spec/acceptance/shared/request_expectations.rb
@@ -1,4 +1,4 @@
-shared_context "request expectations" do
+shared_context "request expectations" do |*adapter_info|
describe "when request expectations are set" do
describe "when net connect is not allowed" do
before(:each) do
@@ -437,9 +437,8 @@
end
end
- describe "with authentication" do
+ describe "with authentication", :unless => (adapter_info.include?(:no_url_auth)) do
before(:each) do
- pending "Excon does not accept basic auth user-info in URLs" if http_library == :excon
stub_request(:any, "http://user:pass@www.example.com")
stub_request(:any, "http://user:pazz@www.example.com")
end
View
34 spec/acceptance/shared/returning_declared_responses.rb
@@ -1,6 +1,6 @@
class MyException < StandardError; end;
-shared_context "declared responses" do
+shared_context "declared responses" do |*adapter_info|
describe "when request stub declares that request should raise exception" do
it "should raise exception" do
stub_request(:get, "www.example.com").to_raise(MyException)
@@ -72,14 +72,10 @@ class MyException < StandardError; end;
http_request(:get, "http://www.example.com/").status.should == "500"
end
- it "should return response with declared status message" do
+ it "should return response with declared status message", :unless => (adapter_info.include?(:no_status_message)) do
stub_request(:get, "www.example.com").to_return(:status => [500, "Internal Server Error"])
response = http_request(:get, "http://www.example.com/")
- # not supported by em-http-request, it always returns "unknown" for http_reason
- # not supported by excon, it only returns a status code
- unless [:em_http_request, :excon].include?(http_library)
- response.message.should == "Internal Server Error"
- end
+ response.message.should == "Internal Server Error"
end
it "should return response with a default status code" do
@@ -87,14 +83,10 @@ class MyException < StandardError; end;
http_request(:get, "http://www.example.com/").status.should == "200"
end
- it "should return default response with empty message if response was not declared" do
+ it "should return default response with empty message if response was not declared", :unless => (adapter_info.include?(:no_status_message)) do
stub_request(:get, "www.example.com")
response = http_request(:get, "http://www.example.com/")
- # not supported by em-http-request, it always returns "unknown" for http_reason
- # not supported by excon, it only returns a status code
- unless [:em_http_request, :excon].include?(http_library)
- response.message.should == ""
- end
+ response.message.should == ""
end
describe "when response body was declared as IO" do
@@ -188,12 +180,8 @@ def call(request)
@response.status.should == "202"
end
- it "should return recorded status message" do
- # not supported by em-http-request, it always returns "unknown" for http_reason
- # not supported by excon, it only returns a status code
- unless [:em_http_request, :excon].include?(http_library)
- @response.message.should == "OK"
- end
+ it "should return recorded status message", :unless => (adapter_info.include?(:no_status_message)) do
+ @response.message.should == "OK"
end
it "should ensure file is closed" do
@@ -226,12 +214,8 @@ def call(request)
@response.status.should == "202"
end
- it "should return recorded status message" do
- # not supported by em-http-request, it always returns "unknown" for http_reason
- # not supported by excon, it only returns a status code
- unless [:em_http_request, :excon].include?(http_library)
- @response.message.should == "OK"
- end
+ it "should return recorded status message", :unless => (adapter_info.include?(:no_status_message)) do
+ @response.message.should == "OK"
end
end
View
8 spec/acceptance/shared/stubbing_requests.rb
@@ -1,4 +1,4 @@
-shared_examples_for "stubbing requests" do
+shared_examples_for "stubbing requests" do |*adapter_info|
describe "when requests are stubbed" do
describe "based on uri" do
it "should return stubbed response even if request have escaped parameters" do
@@ -295,11 +295,7 @@
end
end
- describe "when stubbing request with basic authentication" do
- before do
- pending "Excon does not accept basic auth user-info in URLs" if http_library == :excon
- end
-
+ describe "when stubbing request with basic authentication", :unless => (adapter_info.include?(:no_url_auth)) do
it "should match if credentials are the same" do
stub_request(:get, "user:pass@www.example.com")
http_request(:get, "http://user:pass@www.example.com/").status.should == "200"
View
16 spec/acceptance/webmock_shared.rb
@@ -13,7 +13,7 @@
NOT_ESCAPED_PARAMS = "z='Stop!' said Fred&x=ab c"
end
-shared_examples "with WebMock" do
+shared_examples "with WebMock" do |*adapter_info|
describe "with WebMock" do
let(:webmock_server_url) {"http://#{WebMockServer.instance.host_with_port}/"}
before(:each) do
@@ -21,18 +21,18 @@
WebMock.reset!
end
- include_context "allowing and disabling net connect"
+ include_context "allowing and disabling net connect", *adapter_info
- include_context "stubbing requests"
+ include_context "stubbing requests", *adapter_info
- include_context "declared responses"
+ include_context "declared responses", *adapter_info
- include_context "precedence of stubs"
+ include_context "precedence of stubs", *adapter_info
- include_context "request expectations"
+ include_context "request expectations", *adapter_info
- include_context "callbacks"
+ include_context "callbacks", *adapter_info
- include_context "enabled and disabled webmock"
+ include_context "enabled and disabled webmock", *adapter_info
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.