Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions exempi.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ Gem::Specification.new do |gem|
gem.add_dependency 'ffi', '>= 1.1.5'

gem.add_development_dependency 'rake', '>= 0.9.2.2'
gem.add_development_dependency 'minitest', '~> 5.0'
end
32 changes: 16 additions & 16 deletions test/dataconverter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,45 @@

describe "dataconverter helper" do
it "should be able to look up single symbol values" do
Exempi::XmpOpenFileOptions.to_native(:XMP_OPEN_READ, nil).must_equal 0x00000001
_(Exempi::XmpOpenFileOptions.to_native(:XMP_OPEN_READ, nil)).must_equal 0x00000001
end

it "should be able to look up an array of symbol values" do
Exempi::XmpOpenFileOptions.to_native([:XMP_OPEN_USESMARTHANDLER,
:XMP_OPEN_USEPACKETSCANNING], nil).must_equal 0x00000060
_(Exempi::XmpOpenFileOptions.to_native([:XMP_OPEN_USESMARTHANDLER,
:XMP_OPEN_USEPACKETSCANNING], nil)).must_equal 0x00000060
end

it "should be able to handle pure integer values" do
Exempi::XmpOpenFileOptions.to_native(0x00000001, nil).must_equal 0x00000001
_(Exempi::XmpOpenFileOptions.to_native(0x00000001, nil)).must_equal 0x00000001
end

it "should return 0 when nil is passed" do
Exempi::XmpOpenFileOptions.to_native(nil, nil).must_equal 0
_(Exempi::XmpOpenFileOptions.to_native(nil, nil)).must_equal 0
end

it "should raise when invalid options are passed" do
lambda do
_{
Exempi::XmpOpenFileOptions.to_native(:notanoption, nil)
end.must_raise Exempi::InvalidOptionError
}.must_raise Exempi::InvalidOptionError

lambda do
_{
Exempi::XmpOpenFileOptions.to_native([:notanoption, :notanoption], nil)
end.must_raise Exempi::InvalidOptionError
}.must_raise Exempi::InvalidOptionError
end

it "should be able to translate integers into hashes of options" do
hash = Exempi.parse_bitmask 0x00000060, Exempi::XMP_OPEN_FILE_OPTIONS

assert hash[:XMP_OPEN_USESMARTHANDLER]
assert hash[:XMP_OPEN_USEPACKETSCANNING]
refute hash[:XMP_OPEN_FORUPDATE]
_(hash[:XMP_OPEN_USESMARTHANDLER]).must_equal true
_(hash[:XMP_OPEN_USEPACKETSCANNING]).must_equal true
_(hash[:XMP_OPEN_FORUPDATE]).must_equal false
end

it "should optionally be able to return short option names" do
hash = Exempi.parse_bitmask 0x00000060, Exempi::XMP_OPEN_FILE_OPTIONS, true

assert hash[:usesmarthandler]
assert hash[:usepacketscanning]
refute hash[:forupdate]
_(hash[:usesmarthandler]).must_equal true
_(hash[:usepacketscanning]).must_equal true
_(hash[:forupdate]).must_equal false
end
end
end
10 changes: 5 additions & 5 deletions test/datetime_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@
today = DateTime.now
date = Exempi::XmpDateTime.from_datetime today

date[:year].must_equal today.year
_(date[:year]).must_equal today.year
end

it "should be able to create an XmpDateTime struct from a string" do
today = '2012-09-07'
date = Exempi::XmpDateTime.from_datetime today

date[:year].must_equal 2012
date[:month].must_equal 9
date[:day].must_equal 7
_(date[:year]).must_equal 2012
_(date[:month]).must_equal 9
_(date[:day]).must_equal 7
end

it "should be able to translate XmpDateTime structs into DateTime objects" do
today = DateTime.now
date = Exempi::XmpDateTime.from_datetime today

date.to_datetime.must_equal today
_(date.to_datetime).must_equal today
end
end
10 changes: 5 additions & 5 deletions test/helpers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
describe "Exempi helpers" do
it "should be able to silence stderr for noisy blocks" do
Exempi.verbose = false
lambda do
_{
Exempi.send(:shutup!) { STDERR.puts "You should not see this" }
end.must_be_silent
}.must_be_silent
end

it "should wrap Exempi functions correctly" do
Exempi.verbose = false
lambda do
_{
# Exempi spews errors to stderr, so we've wrapped attach_function
# in order to ensure that every function call is wrapped with
# the silencing shutup! method
Exempi.xmp_files_open_new('no_file_here', 0)
end.must_be_silent
}.must_be_silent
end
end
end