Skip to content

Commit

Permalink
Changing inspec on object id and binary
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Feb 12, 2015
1 parent ee13068 commit 990c715
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
6 changes: 1 addition & 5 deletions Guardfile
@@ -1,9 +1,5 @@
# vim:set filetype=ruby:
guard(
"rspec",
:all_after_pass => false,
:cli => "--fail-fast --tty --format documentation --colour") do

guard 'rspec', :all_after_pass => false, :cmd => 'bundle exec rspec -t ~style' do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |match| "spec/#{match[1]}_spec.rb" }
end
2 changes: 1 addition & 1 deletion lib/bson/binary.rb
Expand Up @@ -117,7 +117,7 @@ def initialize(data = "", type = :generic)
#
# @since 2.3.0
def inspect
"BSON::Binary:#{object_id}"
"<BSON::Binary:0x#{object_id} type=#{type} data=#{data[0, 8]}...>"
end

# Encode the binary type
Expand Down
2 changes: 1 addition & 1 deletion lib/bson/object_id.rb
Expand Up @@ -124,7 +124,7 @@ def hash
#
# @since 2.0.0
def inspect
"BSON::ObjectId('#{to_s}')"
"<BSON::ObjectId:0x#{object_id} data=#{to_s}>"
end

# Dump the raw bson when calling Marshal.dump.
Expand Down
11 changes: 11 additions & 0 deletions spec/bson/binary_spec.rb
Expand Up @@ -84,6 +84,17 @@
end
end

describe '#inspect' do

let(:object) do
described_class.new('testing123', :user)
end

it 'returns the truncated data and type' do
expect(object.inspect).to eq("<BSON::Binary:0x#{object.object_id} type=user data=testing1...>")
end
end

describe "#to_bson/#from_bson" do

let(:type) { 5.chr }
Expand Down
2 changes: 1 addition & 1 deletion spec/bson/object_id_spec.rb
Expand Up @@ -390,7 +390,7 @@
end

it "returns the inspection with the object id to_s" do
expect(object_id.inspect).to eq("BSON::ObjectId('#{object_id.to_s}')")
expect(object_id.inspect).to eq("<BSON::ObjectId:0x#{object_id.object_id} data=#{object_id.to_s}>")
end
end

Expand Down

0 comments on commit 990c715

Please sign in to comment.