jam-cloud/spec/requests/artifacts_api_spec.rb

36 lines
1.0 KiB
Ruby

require 'spec_helper'
describe "Artifact API ", :type => :api do
include Rack::Test::Methods
subject { page }
describe "profile page" do
before do
@artifact = FactoryGirl.create(:artifact_update)
end
it "matches an artifact" do
get '/api/versioncheck.json', { :os=>'Win32', :product=>'JamClient'}
last_response.status.should eql(200)
JSON.parse(last_response.body).should eql({ "version" => @artifact.version, "uri" => @artifact.uri.path})
end
it "matches no artifact" do
@artifact.delete
get '/api/versioncheck.json', { :os=>'Win32', :product=>'JamClient'}
last_response.status.should eql(200)
JSON.parse(last_response.body).should eql({})
end
it "fails on bad product" do
@artifact.delete
get '/api/versioncheck.json', { :os=>'what', :product=>'JamClient'}
last_response.status.should eql(422)
JSON.parse(last_response.body).should eql({ "errors" => {"product" => ['not a valid product']}})
end
end
end