-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from tilfin/fix/socket-gethostname
Fix to get hostname that contains UTF-8 chars
- Loading branch information
Showing
3 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Ougai | ||
VERSION = "0.7.3" | ||
VERSION = "0.7.4" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
require 'spec_helper' | ||
|
||
describe Ougai::Formatters::Base do | ||
subject { described_class.new(app_name, hostname) } | ||
|
||
context 'without arguments and hostname contains a UTF-8 char' do | ||
let (:app_name) { nil } | ||
let (:hostname) { nil } | ||
|
||
it 'has default app_name and default hostname' do | ||
myhostname = "Taro\xE2\x80\x99s-MacBook".force_encoding('ASCII-8BIT') | ||
allow(Socket).to receive(:gethostname).and_return(myhostname) | ||
expect(subject.app_name).to eq('rspec') | ||
expect(subject.hostname).to eq("Taro’s-MacBook") | ||
end | ||
end | ||
|
||
context 'with app_name' do | ||
let (:app_name) { 'myapp' } | ||
let (:hostname) { nil } | ||
|
||
it 'has specified app_name and default hostname' do | ||
myhostname = "Hanako's PC".encode('ASCII-8BIT') | ||
allow(Socket).to receive(:gethostname).and_return(myhostname) | ||
expect(subject.app_name).to eq('myapp') | ||
expect(subject.hostname).to eq("Hanako's PC") | ||
end | ||
end | ||
|
||
context 'with hostname' do | ||
let (:app_name) { nil } | ||
let (:hostname) { 'myhost' } | ||
|
||
it 'has default app_name and specified hostname' do | ||
expect(subject.app_name).to eq('rspec') | ||
expect(subject.hostname).to eq('myhost') | ||
end | ||
end | ||
|
||
context 'with app_name and hostname' do | ||
let (:app_name) { 'myapp' } | ||
let (:hostname) { 'myhost' } | ||
|
||
it 'has specified app_name and specified hostname' do | ||
expect(subject.app_name).to eq('myapp') | ||
expect(subject.hostname).to eq('myhost') | ||
end | ||
end | ||
end |