|
9 | 9 | @response_object.stub(:body => "{foo:'bar'}") |
10 | 10 | @response_object['last-modified'] = @last_modified |
11 | 11 | @response_object['content-length'] = @content_length |
12 | | - @parsed_response = {"foo" => "bar"} |
| 12 | + @parsed_response = lambda { {"foo" => "bar"} } |
13 | 13 | @response = HTTParty::Response.new(@request_object, @response_object, @parsed_response) |
14 | 14 | end |
15 | 15 |
|
|
51 | 51 | end |
52 | 52 |
|
53 | 53 | it "should send missing methods to delegate" do |
54 | | - response = HTTParty::Response.new(@request_object, @response_object, {'foo' => 'bar'}) |
| 54 | + response = HTTParty::Response.new(@request_object, @response_object, @parsed_response) |
55 | 55 | response['foo'].should == 'bar' |
56 | 56 | end |
57 | 57 |
|
58 | 58 | it "response to request" do |
59 | | - response = HTTParty::Response.new(@request_object, @response_object, {'foo' => 'bar'}) |
| 59 | + response = HTTParty::Response.new(@request_object, @response_object, @parsed_response) |
60 | 60 | response.respond_to?(:request).should be_true |
61 | 61 | end |
62 | 62 |
|
63 | 63 | it "responds to response" do |
64 | | - response = HTTParty::Response.new(@request_object, @response_object, {'foo' => 'bar'}) |
| 64 | + response = HTTParty::Response.new(@request_object, @response_object, @parsed_response) |
65 | 65 | response.respond_to?(:response).should be_true |
66 | 66 | end |
67 | 67 |
|
68 | 68 | it "responds to body" do |
69 | | - response = HTTParty::Response.new(@request_object, @response_object, {'foo' => 'bar'}) |
| 69 | + response = HTTParty::Response.new(@request_object, @response_object, @parsed_response) |
70 | 70 | response.respond_to?(:body).should be_true |
71 | 71 | end |
72 | 72 |
|
73 | 73 | it "responds to headers" do |
74 | | - response = HTTParty::Response.new(@request_object, @response_object, {'foo' => 'bar'}) |
| 74 | + response = HTTParty::Response.new(@request_object, @response_object, @parsed_response) |
75 | 75 | response.respond_to?(:headers).should be_true |
76 | 76 | end |
77 | 77 |
|
78 | 78 | it "responds to parsed_response" do |
79 | | - response = HTTParty::Response.new(@request_object, @response_object, {'foo' => 'bar'}) |
| 79 | + response = HTTParty::Response.new(@request_object, @response_object, @parsed_response) |
80 | 80 | response.respond_to?(:parsed_response).should be_true |
81 | 81 | end |
82 | 82 |
|
83 | 83 | it "responds to anything parsed_response responds to" do |
84 | | - response = HTTParty::Response.new(@request_object, @response_object, {'foo' => 'bar'}) |
| 84 | + response = HTTParty::Response.new(@request_object, @response_object, @parsed_response) |
85 | 85 | response.respond_to?(:[]).should be_true |
86 | 86 | end |
87 | 87 |
|
88 | 88 | it "should be able to iterate if it is array" do |
89 | | - response = HTTParty::Response.new(@request_object, @response_object, [{'foo' => 'bar'}, {'foo' => 'baz'}]) |
| 89 | + response = HTTParty::Response.new(@request_object, @response_object, lambda { [{'foo' => 'bar'}, {'foo' => 'baz'}] }) |
90 | 90 | response.size.should == 2 |
91 | 91 | expect { |
92 | 92 | response.each { |item| } |
|
114 | 114 | end |
115 | 115 | end |
116 | 116 |
|
117 | | - xit "should allow hashes to be accessed with dot notation" do |
118 | | - response = HTTParty::Response.new(@request_object, {'foo' => 'bar'}, "{foo:'bar'}", 200, 'OK') |
119 | | - response.foo.should == 'bar' |
120 | | - end |
121 | | - |
122 | | - xit "should allow nested hashes to be accessed with dot notation" do |
123 | | - response = HTTParty::Response.new(@request_object, {'foo' => {'bar' => 'baz'}}, "{foo: {bar:'baz'}}", 200, 'OK') |
124 | | - response.foo.should == {'bar' => 'baz'} |
125 | | - response.foo.bar.should == 'baz' |
126 | | - end |
127 | | - |
128 | 117 | describe "semantic methods for response codes" do |
129 | 118 | def response_mock(klass) |
130 | 119 | response = klass.new('', '', '') |
|
0 commit comments