Sha256: 066605e0b8f8eb0559bdac4653bf2cefdf3e8fd7097e0c6965c44b0821743f2a
Contents?: true
Size: 1.88 KB
Versions: 3
Compression:
Stored size: 1.88 KB
Contents
describe "HTTP" do before do @localhost_url = 'http://localhost' @fake_url = 'http://fake.url' end describe "Core HTTP method calls" do def test_http_method(method) called = false delegator = Proc.new { |r, q| @the_response = r; @the_query = q; called = true } query = BubbleWrap::HTTP.send(method, @localhost_url, { name: 'bubble-wrap', action: delegator }) query.should.not.equal nil query.method.should.equal method.to_s.upcase query.options[:name].should.equal 'bubble-wrap' query.instance_variable_get(:@delegator).should.equal delegator query.connectionDidFinishLoading(query.connection) query.should.be.same_as @the_query query.response.should.be.same_as @the_response called.should.equal true end it ".get .post .put .delete .head .patch should properly generate the HTTP::Query" do [:get, :post, :put, :delete, :head, :patch].each do |method| test_http_method method end end it "uses the block instead of :action if both were given" do [:get, :post, :put, :delete, :head, :patch].each do |method| called = false expected_delegator = Proc.new {|response| called = true } query = BubbleWrap::HTTP.send(method, @localhost_url, { action: 'not_valid' }, &expected_delegator) query.connectionDidFinishLoading(query.connection) query.instance_variable_get(:@delegator).should.equal expected_delegator called.should.equal true end end it "works with classic blocks as well" do [:get, :post, :put, :delete, :head, :patch].each do |method| called = false query = BubbleWrap::HTTP.send(method, @localhost_url, { action: 'not_valid' } ) do |response| called = true end query.connectionDidFinishLoading(query.connection) called.should.equal true end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bubble-wrap-1.4.0 | spec/motion/http_spec.rb |
bubble-wrap-1.3.0 | spec/motion/http_spec.rb |
bubble-wrap-1.3.0.osx | spec/motion/http_spec.rb |