2014-12-31 15:59:32 -05:00
|
|
|
require 'spec_helper'
|
2013-02-07 15:53:44 -05:00
|
|
|
|
2014-12-31 15:59:32 -05:00
|
|
|
RSpec.describe 'AwesomePrint/Ripple', skip: ->{ !ExtVerifier.has_ripple? }.call do
|
2013-02-07 15:53:44 -05:00
|
|
|
|
2014-12-31 15:59:32 -05:00
|
|
|
if ExtVerifier.has_ripple?
|
2013-02-07 15:53:44 -05:00
|
|
|
before :all do
|
|
|
|
class RippleUser
|
|
|
|
include Ripple::Document
|
|
|
|
|
|
|
|
key_on :_id
|
|
|
|
property :_id, String
|
|
|
|
property :first_name, String
|
|
|
|
property :last_name, String
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
after :all do
|
|
|
|
Object.instance_eval { remove_const :RippleUser }
|
|
|
|
end
|
2014-12-31 15:59:32 -05:00
|
|
|
end
|
2013-02-07 15:53:44 -05:00
|
|
|
|
2014-12-31 15:59:32 -05:00
|
|
|
before do
|
|
|
|
@ap = AwesomePrint::Inspector.new :plain => true, :sort_keys => true
|
|
|
|
end
|
2013-02-07 15:53:44 -05:00
|
|
|
|
2014-12-31 15:59:32 -05:00
|
|
|
it "should print class instance" do
|
|
|
|
user = RippleUser.new :_id => "12345", :first_name => "Al", :last_name => "Capone"
|
|
|
|
out = @ap.send :awesome, user
|
2013-02-07 15:53:44 -05:00
|
|
|
|
2016-05-09 10:04:42 -04:00
|
|
|
expect(out).to be_similar_to <<-EOS.strip
|
|
|
|
#<RippleUser:placeholder_id> {
|
2013-02-07 15:53:44 -05:00
|
|
|
:_id => "12345",
|
|
|
|
:first_name => "Al",
|
|
|
|
:last_name => "Capone"
|
|
|
|
}
|
2014-12-31 15:59:32 -05:00
|
|
|
EOS
|
|
|
|
end
|
2013-02-07 15:53:44 -05:00
|
|
|
|
2014-12-31 15:59:32 -05:00
|
|
|
it "should print the class" do
|
|
|
|
expect(@ap.send(:awesome, RippleUser)).to eq <<-EOS.strip
|
2013-02-07 15:53:44 -05:00
|
|
|
class RippleUser < Object {
|
|
|
|
:_id => :string,
|
|
|
|
:first_name => :string,
|
|
|
|
:last_name => :string
|
|
|
|
}
|
2014-12-31 15:59:32 -05:00
|
|
|
EOS
|
2013-02-07 15:53:44 -05:00
|
|
|
end
|
|
|
|
end
|