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/ext/ostruct_spec.rb

31 lines
765 B
Ruby
Raw Normal View History

2014-01-02 19:10:24 -05:00
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
begin
require 'ostruct'
require 'awesome_print/ext/ostruct'
describe 'AwesomePrint Ostruct extension' do
before do
stub_dotfile!
@ap = AwesomePrint::Inspector.new(:plain => true, :sort_keys => true)
end
it "empty hash" do
struct = OpenStruct.new
@ap.send(:awesome, struct).should == "OpenStruct {}"
end
it "plain multiline" do
struct = OpenStruct.new :name => "Marshall Shen", :address => "605 Madion St."
@ap.send(:awesome, struct).should == <<-EOS.strip
OpenStruct {
:address => "605 Madion St.",
:name => "Marshall Shen"
}
EOS
end
end
rescue LoadError => error
puts "Skipping OpenStruct specs: #{error}"
end