Sha256: 8daaf1a723c582069e9334019b8dc70cfa13b925ea16a3fbbd9c8cf58196e02b
Contents?: true
Size: 1.56 KB
Versions: 3
Compression:
Stored size: 1.56 KB
Contents
# -*- coding: utf-8 -*- require 'spec_helper' describe Magellan::Cli::Messaging::Http do let(:cmd){ Magellan::Cli::Messaging::Http.new } let(:core){ double(:core) } before{ allow(cmd).to receive(:core).and_return(core) } let(:success_res){ double(:res, code: 200, body: "SUCCESS!\n") } let(:failure_res){ double(:res, code: 401, body: "NOT FOUND!\n") } describe :get do it "path only" do expect(core).to receive(:request).with("/foo", :get, nil, {}).and_return(success_res) cmd.get("/foo") end it "path only(401 error)" do expect(core).to receive(:request).with("/foo", :get, nil, {}).and_return(failure_res) cmd.get("/foo") end it "path and query string" do expect(core).to receive(:request).with("/foo?bar=baz", :get, nil, {}).and_return(success_res) cmd.get("/foo?bar=baz") end it "path and headers" do expect(core).to receive(:request).with("/foo", :get, nil, {"bar" => "baz"}).and_return(success_res) cmd.get("/foo", '{"bar":"baz"}') end let(:header_content){ YAML.load_file(File.expand_path("../http_headers.yml", __FILE__)) } it "path and headers yaml file" do expect(core).to receive(:request).with("/foo", :get, nil, header_content).and_return(success_res) cmd.get("/foo", File.expand_path("../http_headers.yml", __FILE__)) end it "path and headers json file" do expect(core).to receive(:request).with("/foo", :get, nil, header_content).and_return(success_res) cmd.get("/foo", File.expand_path("../http_headers.json", __FILE__)) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
magellan-cli-0.5.2 | spec/magellan/cli/messaging/http_spec.rb |
magellan-cli-0.5.1 | spec/magellan/cli/messaging/http_spec.rb |
magellan-cli-0.5.0 | spec/magellan/cli/messaging/http_spec.rb |