jam-cloud/ruby/spec/jam_ruby/models/artifact_update_spec.rb

40 lines
960 B
Ruby
Raw Permalink Normal View History

2013-02-06 05:14:07 +00:00
require 'spec_helper'
require 'digest/md5'
2013-02-06 05:14:07 +00:00
describe ArtifactUpdate do
2013-02-13 01:56:40 +00:00
include UsesTempFiles
ARTIFACT_FILE='jkclient-0.1.1.exe'
in_directory_with_file(ARTIFACT_FILE)
before do
content_for_file("exe binary globby goo")
end
2013-02-06 05:14:07 +00:00
it "return empty" do
ArtifactUpdate.count.should == 0
2013-02-06 05:14:07 +00:00
end
2013-02-13 01:56:40 +00:00
2013-02-06 05:14:07 +00:00
it "should allow insertion" do
2013-02-13 01:56:40 +00:00
2013-02-06 05:14:07 +00:00
artifact = ArtifactUpdate.new
artifact.product = 'JamClient/Win32'
artifact.version = '0.1.1'
2013-02-13 01:56:40 +00:00
artifact.uri = File.open(ARTIFACT_FILE)
2013-02-06 05:14:07 +00:00
artifact.save!
artifact.environment.should == "public"
artifact.product.should == "JamClient/Win32"
artifact.version.should == "0.1.1"
2013-02-13 01:56:40 +00:00
File.basename(artifact.uri.path).should == ARTIFACT_FILE
artifact.sha1.should == Digest::MD5.hexdigest(File.read(ARTIFACT_FILE))
artifact.size.should == File.size(ARTIFACT_FILE)
2013-02-06 05:14:07 +00:00
found = ArtifactUpdate.find_by_product_and_version('JamClient/Win32', '0.1.1')
artifact.should == found
end
end