|
8 | 8 | body = 'abc' |
9 | 9 | stub_request(:get, "www.example.com").to_return(:body => body, :status => 200) |
10 | 10 | response = RestClient.get "www.example.com" |
11 | | - response.code.should eq 200 |
12 | | - response.body.should eq body |
| 11 | + expect(response.code).to eq 200 |
| 12 | + expect(response.body).to eq body |
13 | 13 | end |
14 | 14 |
|
15 | 15 | it "a simple request with gzipped content" do |
16 | 16 | stub_request(:get, "www.example.com").with(:headers => { 'Accept-Encoding' => 'gzip, deflate' }).to_return(:body => "\037\213\b\b\006'\252H\000\003t\000\313T\317UH\257\312,HM\341\002\000G\242(\r\v\000\000\000", :status => 200, :headers => { 'Content-Encoding' => 'gzip' } ) |
17 | 17 | response = RestClient.get "www.example.com" |
18 | | - response.code.should eq 200 |
19 | | - response.body.should eq "i'm gziped\n" |
| 18 | + expect(response.code).to eq 200 |
| 19 | + expect(response.body).to eq "i'm gziped\n" |
20 | 20 | end |
21 | 21 |
|
22 | 22 | it "a 404" do |
|
26 | 26 | RestClient.get "www.example.com" |
27 | 27 | raise |
28 | 28 | rescue RestClient::ResourceNotFound => e |
29 | | - e.http_code.should eq 404 |
30 | | - e.response.code.should eq 404 |
31 | | - e.response.body.should eq body |
32 | | - e.http_body.should eq body |
| 29 | + expect(e.http_code).to eq 404 |
| 30 | + expect(e.response.code).to eq 404 |
| 31 | + expect(e.response.body).to eq body |
| 32 | + expect(e.http_body).to eq body |
33 | 33 | end |
34 | 34 | end |
35 | 35 |
|
|
41 | 41 | 'Content-Type' => 'text/plain; charset=UTF-8' |
42 | 42 | }) |
43 | 43 | response = RestClient.get "www.example.com" |
44 | | - response.encoding.should eq Encoding::UTF_8 |
45 | | - response.valid_encoding?.should eq true |
| 44 | + expect(response.encoding).to eq Encoding::UTF_8 |
| 45 | + expect(response.valid_encoding?).to eq true |
46 | 46 | end |
47 | 47 |
|
48 | 48 | it 'handles windows-1252' do |
|
52 | 52 | 'Content-Type' => 'text/plain; charset=windows-1252' |
53 | 53 | }) |
54 | 54 | response = RestClient.get "www.example.com" |
55 | | - response.encoding.should eq Encoding::WINDOWS_1252 |
56 | | - response.encode('utf-8').should eq "ÿ" |
57 | | - response.valid_encoding?.should eq true |
| 55 | + expect(response.encoding).to eq Encoding::WINDOWS_1252 |
| 56 | + expect(response.encode('utf-8')).to eq "ÿ" |
| 57 | + expect(response.valid_encoding?).to eq true |
58 | 58 | end |
59 | 59 |
|
60 | 60 | it 'handles binary' do |
|
64 | 64 | 'Content-Type' => 'application/octet-stream; charset=binary' |
65 | 65 | }) |
66 | 66 | response = RestClient.get "www.example.com" |
67 | | - response.encoding.should eq Encoding::BINARY |
68 | | - lambda { |
| 67 | + expect(response.encoding).to eq Encoding::BINARY |
| 68 | + expect { |
69 | 69 | response.encode('utf-8') |
70 | | - }.should raise_error(Encoding::UndefinedConversionError) |
71 | | - response.valid_encoding?.should eq true |
| 70 | + }.to raise_error(Encoding::UndefinedConversionError) |
| 71 | + expect(response.valid_encoding?).to eq true |
72 | 72 | end |
73 | 73 |
|
74 | 74 | it 'handles euc-jp' do |
75 | 75 | body = "\xA4\xA2\xA4\xA4\xA4\xA6\xA4\xA8\xA4\xAA". |
76 | 76 | force_encoding(Encoding::BINARY) |
77 | 77 | body_utf8 = 'あいうえお' |
78 | | - body_utf8.encoding.should eq Encoding::UTF_8 |
| 78 | + expect(body_utf8.encoding).to eq Encoding::UTF_8 |
79 | 79 |
|
80 | 80 | stub_request(:get, 'www.example.com').to_return( |
81 | 81 | :body => body, :status => 200, :headers => { |
82 | 82 | 'Content-Type' => 'text/plain; charset=EUC-JP' |
83 | 83 | }) |
84 | 84 | response = RestClient.get 'www.example.com' |
85 | | - response.encoding.should eq Encoding::EUC_JP |
86 | | - response.valid_encoding?.should eq true |
87 | | - response.length.should eq 5 |
88 | | - response.encode('utf-8').should eq body_utf8 |
| 85 | + expect(response.encoding).to eq Encoding::EUC_JP |
| 86 | + expect(response.valid_encoding?).to eq true |
| 87 | + expect(response.length).to eq 5 |
| 88 | + expect(response.encode('utf-8')).to eq body_utf8 |
89 | 89 | end |
90 | 90 |
|
91 | 91 | it 'defaults to Encoding.default_external' do |
|
95 | 95 | }) |
96 | 96 |
|
97 | 97 | response = RestClient.get 'www.example.com' |
98 | | - response.encoding.should eq Encoding.default_external |
| 98 | + expect(response.encoding).to eq Encoding.default_external |
99 | 99 | end |
100 | 100 |
|
101 | 101 | it 'handles invalid encoding' do |
|
105 | 105 | }) |
106 | 106 |
|
107 | 107 | response = RestClient.get 'www.example.com' |
108 | | - response.encoding.should eq Encoding.default_external |
| 108 | + expect(response.encoding).to eq Encoding.default_external |
109 | 109 | end |
110 | 110 |
|
111 | 111 | it 'leaves images as binary' do |
|
117 | 117 | }) |
118 | 118 |
|
119 | 119 | response = RestClient.get 'www.example.com' |
120 | | - response.encoding.should eq Encoding::BINARY |
| 120 | + expect(response.encoding).to eq Encoding::BINARY |
121 | 121 | end |
122 | 122 | end |
123 | 123 | end |
0 commit comments