Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Commit

Permalink
Optimized specs
Browse files Browse the repository at this point in the history
  • Loading branch information
yatish27 committed Mar 29, 2014
1 parent c6039e7 commit 7dc63b9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 33 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -4,3 +4,4 @@ rvm:
- 1.9.3
- 1.9.2
- jruby-19mode
- 2.1.1
62 changes: 29 additions & 33 deletions spec/linkedin-scraper/profile_spec.rb
Expand Up @@ -2,155 +2,151 @@
require 'linkedin-scraper'

describe Linkedin::Profile do


before(:all) do
@page = Nokogiri::HTML(File.open('spec/fixtures/jgrevich.html', 'r') { |f| f.read })
@profile = Linkedin::Profile.new('http://www.linkedin.com/in/jgrevich')
end


let(:profile) { Linkedin::Profile.new('http://www.linkedin.com/in/jgrevich') }

describe '.get_profile' do
it 'Create an instance of Linkedin::Profile class' do
expect(@profile).to be_instance_of Linkedin::Profile
expect(profile).to be_instance_of Linkedin::Profile
end
end

describe '#first_name' do
it 'returns the first name of the profile' do
expect(@profile.first_name).to eq 'Justin'
expect(profile.first_name).to eq 'Justin'
end
end

describe '#last_name' do
it 'returns the last name of the profile' do
expect(@profile.last_name).to eq 'Grevich'
expect(profile.last_name).to eq 'Grevich'
end
end

describe '#title' do
it 'returns the title of the profile' do
expect(@profile.title).to eq 'Presidential Innovation Fellow'
expect(profile.title).to eq 'Presidential Innovation Fellow'
end
end

describe '#location' do
it 'returns the location of the profile' do
expect(@profile.location).to eq 'Washington'
expect(profile.location).to eq 'Washington'
end
end

describe '#country' do
it 'returns the country of the profile' do
expect(@profile.country).to eq 'District Of Columbia'
expect(profile.country).to eq 'District Of Columbia'
end
end

describe '#industry' do
it 'returns the industry of the profile' do
expect(@profile.industry).to eq 'Information Technology and Services'
expect(profile.industry).to eq 'Information Technology and Services'
end
end

describe '#summary' do
it 'returns the summary of the profile' do
expect(@profile.summary).to match(/Justin Grevich is a Presidential Innovation Fellow working/)
expect(profile.summary).to match(/Justin Grevich is a Presidential Innovation Fellow working/)
end
end

describe '#picture' do
it 'returns the picture url of the profile' do
expect(@profile.picture).to eq 'http://m.c.lnkd.licdn.com/mpr/pub/image-1OSOQPrarAEIMksx5uUyhfRUO9zb6R4JjbULhhrDOMFS6dtV1OSLWbcaOK9b92S3rlE9/justin-grevich.jpg'
expect(profile.picture).to eq 'http://m.c.lnkd.licdn.com/mpr/pub/image-1OSOQPrarAEIMksx5uUyhfRUO9zb6R4JjbULhhrDOMFS6dtV1OSLWbcaOK9b92S3rlE9/justin-grevich.jpg'
end
end

describe '#skills' do
it 'returns the array of skills of the profile' do
skills = ['Ruby', 'Ruby on Rails', 'Web Development', 'Web Applications', 'CSS3', 'HTML 5', 'Shell Scripting', 'Python', 'Chef', 'Git', 'Subversion', 'JavaScript', 'Rspec', 'jQuery', 'Capistrano', 'Sinatra', 'CoffeeScript', 'Haml', 'Standards Compliance', 'MySQL', 'PostgreSQL', 'Solr', 'Sphinx', 'Heroku', 'Amazon Web Services (AWS)', 'Information Security', 'Vulnerability Assessment', 'SAN', 'ZFS', 'Backup Solutions', 'SaaS', 'System Administration', 'Project Management', 'Linux', 'Troubleshooting', 'Network Security', 'OS X', 'Bash', 'Cloud Computing', 'Web Design', 'MongoDB', 'Z-Wave', 'Home Automation']
expect(@profile.skills).to include(*skills)
expect(profile.skills).to include(*skills)
end
end

describe '#past_companies' do
it 'returns an array of hashes of past companies with its details' do
@profile.past_companies
profile.past_companies
end
end

describe '#current_companies' do
it 'returns an array of hashes of current companies with its details' do
@profile.current_companies
profile.current_companies
end
end

describe '#education' do
it 'returns the array of hashes of education with details' do
@profile.education
profile.education
end
end

describe '#websites' do
it 'returns the array of websites' do
@profile.websites
profile.websites
end
end

describe '#groups' do
it 'returns the array of hashes of groups with details' do
@profile.groups
profile.groups
end
end

describe '#name' do
it 'returns the first and last name of the profile' do
expect(@profile.name).to eq 'Justin Grevich'
expect(profile.name).to eq 'Justin Grevich'
end
end

describe '#organizations' do
it 'returns an array of organization hashes for the profile' do
expect(@profile.organizations.class).to eq Array
expect(@profile.organizations.first[:name]).to eq 'San Diego Ruby'
expect(profile.organizations.class).to eq Array
expect(profile.organizations.first[:name]).to eq 'San Diego Ruby'
end
end

describe '#languages' do
it 'returns an array of languages hashes' do
expect(@profile.languages.class).to eq Array
expect(profile.languages.class).to eq Array
end

context 'with language data' do
it 'returns an array with one language hash' do
expect(@profile.languages.class).to eq Array
expect(profile.languages.class).to eq Array
end

describe 'language hash' do
it 'contains the key and value for language name' do
expect(@profile.languages.first[:language]).to eq 'English'
expect(profile.languages.first[:language]).to eq 'English'
end

it 'contains the key and value for language proficiency' do
expect(@profile.languages.first[:proficiency]).to eq '(Native or bilingual proficiency)'
expect(profile.languages.first[:proficiency]).to eq '(Native or bilingual proficiency)'
end
end
end # context 'with language data' do

end # describe '.languages' do

#WIP
describe '#recommended_visitors' do
it 'returns the array of hashes of recommended visitors' do
@profile.recommended_visitors
profile.recommended_visitors
end
end

describe '#certifications' do
it 'returns the array of hashes of certifications' do
@profile.certifications
profile.certifications
end
end

describe '#to_json' do
it 'returns the json format of the profile' do
@profile.to_json
profile.to_json
end
end

Expand Down

0 comments on commit 7dc63b9

Please sign in to comment.