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