require 'test_helper' class GemTest < Test::Unit::TestCase def setup @valid = { 'name' => 'ruby-openid', 'version' => '2.1.4', 'native' => 0, } @no_name = { 'version' => '2.1.4', 'native' => 0, } @no_version = { 'name' => 'ruby-openid', 'native' => 0, } @no_native = { 'name' => 'ruby-openid', 'version' => '2.1.4', } end #============================================================================= # INSTANTIATION #============================================================================= should 'load a gem hash on initialization' do Gemi::Gem.new(@valid) end should 'not load if name is not given' do assert_raise(Gemi::InvalidGemHashError) do Gemi::Gem.new(@no_name) end end should 'not load if version is not given' do assert_raise(Gemi::InvalidGemHashError) do Gemi::Gem.new(@no_version) end end should 'not load if native is not given' do assert_raise(Gemi::InvalidGemHashError) do Gemi::Gem.new(@no_native) end end #============================================================================= # DATA RETRIVAL #============================================================================= should 'retrive gem name' do assert_equal 'ruby-openid', Gemi::Gem.new(@valid).name end should 'retrive gem version' do assert_equal '2.1.4', Gemi::Gem.new(@valid).version end should 'tell if gem has native extensions' do assert_equal false, Gemi::Gem.new(@valid).native? end end