require 'spec_helper'
describe CareerBuilder::Client do
describe "#get_resume" do
context "with invalid credentials" do
before do
@client = CareerBuilder::Client.new("valid_email", "invalid_password")
@client.stub(:authenticate).and_return(false)
end
context "with valid options" do
it 'should raise InvalidCredentials' do
expect {
@client.get_resume(:resume_id => "4242424242")
}.to raise_error(CareerBuilder::InvalidCredentials)
end
end
context "with invalid options" do
it 'should raise ArgumentError' do
expect {
@client.get_resume(:foo => "bar")
}.to raise_error(ArgumentError)
end
end
end
context "with valid credentials" do
before do
@client = CareerBuilder::Client.new("valid_email", "valid_password")
@client.stub(:session_token).and_return(42)
@client.stub(:authenticate).and_return(true)
end
context "with invalid options" do
it 'should raise ArgumentError' do
expect {
@client.get_resume(:foo => "bar")
}.to raise_error(ArgumentError)
end
end
context "when out of credits" do
before do
stub_request(:post, "http://ws.careerbuilder.com/resumes/resumes.asmx/V2_GetResume").with(:body => 'Packet=%3cPacket%3e%3cSessionToken%3e42%3c%2fSessionToken%3e%3cResumeID%3eRH52G867678F7GH02Q3%3c%2fResumeID%3e%3c%2fPacket%3e').to_return(:body => "\r\n<Packet><Warning></Warning></Packet>")
end
it 'should raise OutOfCredits' do
expect {
@resume = @client.get_resume(:resume_id => "RH52G867678F7GH02Q3")
}.to raise_error(CareerBuilder::OutOfCredits)
end
end
context "with valid options" do
RAW_RESUME_RESPONSE = "\r\n<Packet><TimeStamp>6/25/2010 3:19:20 PM</TimeStamp><ResumeID>RH52G867678F7GH02Q3</ResumeID><ResumeTitle>Warehouse Distribution Specialist</ResumeTitle><ContactName>Jeffrey Davis</ContactName><ContactEmail>Jeffd1969@aol.com</ContactEmail><ContactPhone>513-625-7228</ContactPhone><HomeLocation><City>Goshen</City><State>OH</State><Country>US</Country><ZipCode>45122</ZipCode><WorkStatus>Can work for any employer</WorkStatus></HomeLocation><Relocations><ExtLocation><City>Tokyo</City><State/><Country>JP</Country><ZipCode /><WorkStatus>Can work for any employer</WorkStatus></ExtLocation></Relocations><MaxCommuteMiles>10</MaxCommuteMiles><TravelPreference>Up to 25%</TravelPreference><CurrentlyEmployed>Yes</CurrentlyEmployed><MostRecentPay><Amount>35776</Amount><Per>year</Per></MostRecentPay><DesiredPay><Amount>45000</Amount><Per>year</Per></DesiredPay><DesiredJobTypes><string>Full Time</string></DesiredJobTypes><MostRecentTitle>Warehouse Lead Supervisor</MostRecentTitle><ExperienceMonths>216</ExperienceMonths><Management><ManagedOthers>No</ManagedOthers><NumberManaged>0</NumberManaged></Management><JobsLastThreeYears>0</JobsLastThreeYears><LastJobTenureMonths>0</LastJobTenureMonths><SecurityClearance>No</SecurityClearance><FelonyConvictions>No</FelonyConvictions><HighestDegree>None</HighestDegree><Certifications /><MotivationToChangeJobs /><EmploymentType /><LastUpdated>5/23/2010 10:41:12 PM</LastUpdated><Languages><string>English</string></Languages><DesiredShiftPreferences><string /></DesiredShiftPreferences><Interests><ExtInterest><Interest>Warehouse</Interest><ExperienceMonths>216</ExperienceMonths></ExtInterest></Interests><ResumeText>JEFFREY A. DAVIS</ResumeText><MilitaryExperience>Veteran</MilitaryExperience><WorkHistory><ExtCompany><CompanyName>OWENS & MINOR</CompanyName><JobTitle>Warehouse Lead Supervisor</JobTitle><Tenure>01/01/2008 - Present</Tenure></ExtCompany><ExtCompany><CompanyName>THE HOME DEPOT</CompanyName><JobTitle>- Sales Specialist</JobTitle><Tenure>01/01/2005 - Present</Tenure></ExtCompany><ExtCompany><CompanyName>RUBIES COSTUME CO</CompanyName><JobTitle>- Warehouse Assistant Manager</JobTitle><Tenure>01/01/2004 - 01/01/2006</Tenure></ExtCompany><ExtCompany><CompanyName>UNITED ELECTRIC POWER</CompanyName><JobTitle>Inventory Operations Manager</JobTitle><Tenure>01/01/2000 - 01/01/2004</Tenure></ExtCompany><ExtCompany><CompanyName>VEECO INSTRUMENTS, INC</CompanyName><JobTitle>Warehouse Supervisor</JobTitle><Tenure>01/01/1996 - 01/01/2000</Tenure></ExtCompany></WorkHistory><EducationHistory><ExtSchool><SchoolName>Eastern Oklahoma State College</SchoolName><Major>Business Management</Major><Degree /><GraduationDate>11993</GraduationDate></ExtSchool><ExtSchool><SchoolName>Suffolk County Community College</SchoolName><Major>Business Management</Major><Degree /><GraduationDate>11997</GraduationDate></ExtSchool></EducationHistory><Warning></Warning></Packet>".freeze
before do
stub_request(:post, "http://ws.careerbuilder.com/resumes/resumes.asmx/V2_GetResume").with(:body => 'Packet=%3cPacket%3e%3cSessionToken%3e42%3c%2fSessionToken%3e%3cResumeID%3eRH52G867678F7GH02Q3%3c%2fResumeID%3e%3c%2fPacket%3e').to_return(:body => RAW_RESUME_RESPONSE)
@resume = @client.get_resume(:resume_id => "RH52G867678F7GH02Q3")
end
# despite the fact that career builder gives us jacked up
# double encoded XML, let's retrieve the Resume#raw_response
# in a sane way.
it 'should return the raw response' do
@resume.raw_response.should == "\n6/25/2010 3:19:20 PMRH52G867678F7GH02Q3Warehouse Distribution SpecialistJeffrey DavisJeffd1969@aol.com513-625-7228GoshenOHUS45122Can work for any employerTokyoJPCan work for any employer10Up to 25%Yes35776year45000yearFull TimeWarehouse Lead Supervisor216No000NoNoNone5/23/2010 10:41:12 PMEnglishWarehouse216JEFFREY A. DAVISVeteranOWENS & MINORWarehouse Lead Supervisor01/01/2008 - PresentTHE HOME DEPOT- Sales Specialist01/01/2005 - PresentRUBIES COSTUME CO- Warehouse Assistant Manager01/01/2004 - 01/01/2006UNITED ELECTRIC POWERInventory Operations Manager01/01/2000 - 01/01/2004VEECO INSTRUMENTS, INCWarehouse Supervisor01/01/1996 - 01/01/2000Eastern Oklahoma State CollegeBusiness Management11993Suffolk County Community CollegeBusiness Management11997"
end
it 'should return the correct timestamp' do
@resume.timestamp.should == Time.mktime(2010, 6, 25, 15, 19, 20)
end
it 'should return the correct id' do
@resume.id.should == "RH52G867678F7GH02Q3"
end
it 'should return the correct title' do
@resume.title.should == "Warehouse Distribution Specialist"
end
it 'should return the correct contact name' do
@resume.contact_name.should == "Jeffrey Davis"
end
it 'should return the correct contact email' do
@resume.contact_email.should == "Jeffd1969@aol.com"
end
it 'should return the correct contact phone' do
@resume.contact_phone.should == "513-625-7228"
end
describe "#home_location" do
before do
@home_location = @resume.home_location
end
it 'should return the correct city' do
@home_location.city.should == "Goshen"
end
it 'should return the correct state' do
@home_location.state.should == "OH"
end
it 'should return the correct zip code' do
@home_location.zip_code.should == "45122"
end
it 'should return the correct country' do
@home_location.country.should == "US"
end
it 'should return the correct work status' do
@home_location.work_status.should == "Can work for any employer"
end
end
describe "#relocations" do
before do
@relocations = @resume.relocations
@relocation = @relocations.first
end
it 'should return the correct city' do
@relocation.city.should == "Tokyo"
end
it 'should return the correct state' do
@relocation.state.should == ""
end
it 'should return the correct zip code' do
@relocation.zip_code.should == ""
end
it 'should return the correct country' do
@relocation.country.should == "JP"
end
it 'should return the correct work status' do
@relocation.work_status.should == "Can work for any employer"
end
end
it 'should return the correct max commute miles' do
@resume.max_commute_miles.should == 10
end
it 'should return the correct travel preference' do
@resume.travel_preference.should == "Up to 25%"
end
it 'should return the correct currently employed' do
@resume.currently_employed.should == "Yes"
end
describe "#most_recent_pay" do
before do
@most_recent_pay = @resume.most_recent_pay
end
it 'should return the correct amount' do
@most_recent_pay.amount.should == 35776
end
it 'should return the correct per' do
@most_recent_pay.per.should == "year"
end
end
describe "#desired_pay" do
before do
@desired_pay = @resume.desired_pay
end
it 'should return the correct amount' do
@desired_pay.amount.should == 45000
end
it 'should return the correct per' do
@desired_pay.per.should == "year"
end
end
describe "#desired_job_types" do
before do
@desired_job_types = @resume.desired_job_types
@desired_job_type = @desired_job_types.first
end
it 'should return the correct text' do
@desired_job_type.text.should == "Full Time"
end
end
it 'should return the correct most recent title' do
@resume.most_recent_title.should == "Warehouse Lead Supervisor"
end
it 'should return the correct experience months' do
@resume.experience_months.should == 216
end
it 'should return the correct managed others' do
@resume.managed_others.should == "No"
end
it 'should return the correct number managed' do
@resume.number_managed.should == 0
end
it 'should return the correct jobs last three years' do
@resume.jobs_last_three_years.should == 0
end
it 'should return the correct last job tenure months' do
@resume.last_job_tenure_months.should == 0
end
it 'should return the correct security clearance' do
@resume.security_clearance.should == "No"
end
it 'should return the correct felony convictions' do
@resume.felony_convictions.should == "No"
end
it 'should return the correct highest degree' do
@resume.highest_degree.should == "None"
end
it 'should return the correct certifications' do
@resume.certifications.should == ""
end
it 'should return the correct motivation to change jobs' do
@resume.motivation_to_change_jobs.should == ""
end
it 'should return the correct employment type' do
@resume.employment_type.should == ""
end
it 'should return the correct last updated' do
@resume.last_updated.should == Time.mktime(2010, 5, 23, 22, 41, 12)
end
describe "#languages" do
before do
@languages = @resume.languages
@language = @languages.first
end
it 'should return the correct text' do
@language.text.should == "English"
end
end
describe "#desired_shift_preferences" do
before do
@desired_shift_preferences = @resume.desired_shift_preferences
@desired_shift_preference = @desired_shift_preferences.first
end
it 'should return the correct desired shift preferences' do
@desired_shift_preference.text.should == ""
end
end
describe "#interests" do
before do
@interests = @resume.interests
@interest = @interests.first
end
it 'should return the correct interest' do
@interest.interest.should == "Warehouse"
end
it 'should return the correct experience in months' do
@interest.experience_months.should == 216
end
end
it 'should return the correct resume text' do
@resume.text.should == "JEFFREY A. DAVIS"
end
it 'should return the military experience' do
@resume.military_experience.should == "Veteran"
end
describe "#companies" do
before do
@companies = @resume.companies
@company = @companies.first
end
it 'should return the correct company name' do
@company.name.should == "OWENS & MINOR"
end
it 'should return the correct job title' do
@company.job_title.should == "Warehouse Lead Supervisor"
end
it 'should return the correct tenure' do
@company.tenure.should == "01/01/2008 - Present"
end
end
describe "#schools" do
before do
@schools = @resume.schools
@school = @schools.first
end
it 'should return the correct school name' do
@school.name.should == "Eastern Oklahoma State College"
end
it 'should return the correct major' do
@school.major.should == "Business Management"
end
it 'should return the correct degree' do
@school.degree.should == ""
end
it 'should return the correct graduation date' do
@school.graduation_date.should == "11993"
end
end
it 'should return the correct warning' do
@resume.warning.should == ""
end
end
end
end
end