1
0
Fork 0
mirror of https://github.com/awesome-print/awesome_print synced 2023-03-27 23:22:34 -04:00
awesome_print/spec/formatters/ostruct_spec.rb

24 lines
515 B
Ruby
Raw Normal View History

require 'spec_helper'
require 'ostruct'
2014-01-02 19:10:24 -05:00
RSpec.describe 'AwesomePrint Ostruct extension' do
before do
@ap = AwesomePrint::Inspector.new(plain: true, sort_keys: true)
end
2014-01-02 19:10:24 -05:00
it 'empty hash' do
struct = OpenStruct.new
expect(@ap.send(:awesome, struct)).to eq('OpenStruct {}')
end
2014-01-02 19:10:24 -05:00
it 'plain multiline' do
struct = OpenStruct.new name: 'Foo', address: 'Bar'
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
}
EOS
2014-01-02 19:10:24 -05:00
end
end