Skip to content

Commit

Permalink
UrlFetchTitle: テストの HTTP エラーメッセージを変更した
Browse files Browse the repository at this point in the history
refs #22
  • Loading branch information
ochaochaocha3 committed Mar 18, 2015
1 parent 061241b commit 3dfdab8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions spec/rgrb/plugin/url_fetch_title/generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,19 @@
end

context 'タイムアウトした場合' do
let(:webmock_timeout_url) { 'http://example.net/very_very_heavy' }
let(:timeout_url) { 'http://example.net/timeout' }
let(:open_timeout_url) { 'http://example.net/open_timeout' }
let(:read_timeout_url) { 'http://example.net/read_timeout' }
let(:error_message) { '(タイムアウト)' }

before do
stub_request(:get, webmock_timeout_url).to_timeout
stub_request(:get, timeout_url).to_timeout
stub_request(:get, open_timeout_url).to_raise(Net::OpenTimeout)
stub_request(:get, read_timeout_url).to_raise(Net::ReadTimeout)
end

it 'タイムアウトしたことを示すエラーメッセージを返す' do
expect(generator.fetch_title(webmock_timeout_url)).
expect(generator.fetch_title(timeout_url)).
to eq(format[error_message])
expect(generator.fetch_title(open_timeout_url)).
to eq(format[error_message])
Expand All @@ -139,7 +139,7 @@

subject { generator.fetch_title(url) }
it '"401 Unauthorized" エラーメッセージが返る' do
expect(subject).to eq(format['(401 Unauthorized)'])
expect(subject).to eq(format['(HTTP 401 Unauthorized)'])
end
end

Expand All @@ -152,7 +152,7 @@

subject { generator.fetch_title(url) }
it '"403 Forbidden" エラーメッセージが返る' do
expect(subject).to eq(format['(403 Forbidden)'])
expect(subject).to eq(format['(HTTP 403 Forbidden)'])
end
end

Expand All @@ -165,7 +165,7 @@

subject { generator.fetch_title(url) }
it '"404 Not Found" エラーメッセージが返る' do
expect(subject).to eq(format['(404 Not Found)'])
expect(subject).to eq(format['(HTTP 404 Not Found)'])
end
end

Expand All @@ -178,7 +178,7 @@

subject { generator.fetch_title(url) }
it '"不明なエラー" エラーメッセージが返る' do
expect(subject).to eq(format['(999 不明なエラー)'])
expect(subject).to eq(format['(HTTP 999 不明なエラー)'])
end
end
end
Expand Down

0 comments on commit 3dfdab8

Please sign in to comment.