require 'spec_helper' describe Mushikago::Http::Request do before :all do @request = Mushikago::Http::Request.new @request.host = 'tombo.ap-northeast-1.mushikago.org' @request.path = '/1/list.json' @request.headers['hoge'] = 'fuga' @request.set_param('param1', 'p1') @request.set_param('param2', 'p2') @request.set_param('timestamp', '2011-09-01T00:00:00Z') end subject{ @request } it{ should respond_to(:http_method) } it{ should respond_to(:host, :host=) } it{ should respond_to(:port, :port=) } it{ should respond_to(:path, :path=) } it{ should respond_to(:headers) } it{ should respond_to(:params) } it{ should respond_to(:set_param) } it{ should respond_to(:get_param) } it{ subject.http_method.should == 'GET' } it{ subject.host.should == 'tombo.ap-northeast-1.mushikago.org' } it{ subject.port.to_i.should == 80 } it{ subject.path.should == '/1/list.json' } it{ subject.headers.should be_a_kind_of(Hash) } it{ subject.headers['hoge'].should == 'fuga' } it{ subject.get_param('param1').should == 'p1' } it{ subject.get_param('param2').should == 'p2' } it{ subject.get_param('timestamp').should == '2011-09-01T00:00:00Z' } it{ subject.url_encoded_params.should == 'param1=p1¶m2=p2×tamp=2011-09-01T00%3A00%3A00Z' } context 'to http request' do subject{ @request.to_http_request } it{ should be_a_kind_of(Net::HTTPRequest) } end end