2014-12-31 15:59:32 -05:00
|
|
|
require 'spec_helper'
|
2019-01-22 11:01:43 -05:00
|
|
|
require 'ostruct'
|
2014-01-02 19:10:24 -05:00
|
|
|
|
2014-12-31 15:59:32 -05:00
|
|
|
RSpec.describe 'AwesomePrint Ostruct extension' do
|
|
|
|
before do
|
2016-11-08 09:53:17 -05:00
|
|
|
@ap = AwesomePrint::Inspector.new(plain: true, sort_keys: true)
|
2014-12-31 15:59:32 -05:00
|
|
|
end
|
2014-01-02 19:10:24 -05:00
|
|
|
|
2016-11-08 00:07:03 -05:00
|
|
|
it 'empty hash' do
|
2014-12-31 15:59:32 -05:00
|
|
|
struct = OpenStruct.new
|
2016-11-08 00:07:03 -05:00
|
|
|
expect(@ap.send(:awesome, struct)).to eq('OpenStruct {}')
|
2014-12-31 15:59:32 -05:00
|
|
|
end
|
2014-01-02 19:10:24 -05:00
|
|
|
|
2016-11-08 00:07:03 -05:00
|
|
|
it 'plain multiline' do
|
2016-11-08 09:53:17 -05:00
|
|
|
struct = OpenStruct.new name: 'Foo', address: 'Bar'
|
2014-12-31 15:59:32 -05:00
|
|
|
expect(@ap.send(:awesome, struct)).to eq <<-EOS.strip
|
2014-01-02 19:10:24 -05:00
|
|
|
OpenStruct {
|
2014-01-08 17:42:50 -05:00
|
|
|
:address => "Bar",
|
|
|
|
:name => "Foo"
|
2014-01-02 19:10:24 -05:00
|
|
|
}
|
2014-12-31 15:59:32 -05:00
|
|
|
EOS
|
2014-01-02 19:10:24 -05:00
|
|
|
end
|
2014-12-31 15:59:32 -05:00
|
|
|
end
|