crunchbase_v2 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -22,4 +22,5 @@ tmp
22
22
  mkmf.log
23
23
 
24
24
  *.swp
25
- spec/apikey.yml
25
+ spec/apikey.yml
26
+ spec/fixtures/vcr_cassettes/*
data/crunchbase.gemspec CHANGED
@@ -6,8 +6,8 @@ require 'crunchbase/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "crunchbase_v2"
8
8
  spec.version = Crunchbase::VERSION
9
- spec.authors = ["Encore Shao"]
10
- spec.email = ["encore.shao@gmail.com"]
9
+ spec.authors = ["Encore Shao", "Mark", "Ladislav Martincik"]
10
+ spec.email = ["encore.shao@gmail.com", "ladislav.martincik@gmail.com"]
11
11
  spec.summary = %q{ Ruby wrapper for Crunchbase API version 2 }
12
12
  spec.description = %q{ Ruby wrapper for Crunchbase API version 2 }
13
13
  spec.homepage = "https://github.com/encoreshao/crunchbase_v2"
@@ -20,5 +20,8 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.6"
22
22
  spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec", "~> 2.10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
24
+ spec.add_development_dependency "rspec-its"
25
+ spec.add_development_dependency "webmock"
26
+ spec.add_development_dependency "vcr"
24
27
  end
@@ -15,7 +15,7 @@ module Crunchbase
15
15
  def self.search(options)
16
16
  return [] unless self == Crunchbase::Organization
17
17
 
18
- return Search.new options, API.search( options, self::RESOURCE_LIST )
18
+ return Search.new options, API.search( options, self::RESOURCE_LIST ), SearchResult
19
19
  end
20
20
 
21
21
  def self.lists_for_permalink(permalink, options={})
@@ -26,7 +26,11 @@ module Crunchbase
26
26
  @funding_type = properties['funding_type']
27
27
  @permalink = properties['permalink']
28
28
  @money_raised_usd = properties['money_raised_usd']
29
- @announced_on = properties['announced_on'] && DateTime.parse(properties['announced_on'])
29
+ if (properties['announced_on'].blank? || properties['announced_on'] == "0000-01-01")
30
+ @announced_on = nil
31
+ else
32
+ @announced_on = DateTime.parse(properties['announced_on'])
33
+ end
30
34
  @announced_on_trust_code = properties['announced_on_trust_code']
31
35
  @canonical_currency_code = properties['canonical_currency_code']
32
36
  @money_raised = properties['money_raised']
@@ -4,25 +4,30 @@
4
4
 
5
5
  module Crunchbase
6
6
  class Headquarter < CBEntity
7
-
7
+
8
8
  RESOURCE_LIST = 'headquarters'
9
9
 
10
- attr_reader :type_name, :name, :street_1, :street_2, :city, :city_uuid, :city_path,
11
- :region, :country_code, :created_at, :updated_at
12
-
10
+ attr_reader :type_name, :name, :street_1, :street_2, :postal_code, :city, :city_path,
11
+ :region, :region_path, :country, :country_path, :latitude, :longitude,
12
+ :created_at, :updated_at
13
+
13
14
  def initialize(json)
14
15
  @type_name = json['type']
15
16
  @name = json['name']
16
17
  @street_1 = json['street_1']
17
18
  @street_2 = json['street_2']
19
+ @postal_code = json['postal_code']
18
20
  @city = json['city']
19
- @city_uuid = json['city_uuid']
20
21
  @city_path = json['city_path']
21
22
  @region = json['region']
22
- @country_code = json['country_code']
23
+ @region_path = json['region_path']
24
+ @country = json['country']
25
+ @country_path = json['country_path']
26
+ @latitude = json['latitude']
27
+ @longitude = json['longitude']
23
28
  @created_at = Time.at(json['created_at']).utc
24
29
  @updated_at = Time.at(json['updated_at']).utc
25
30
  end
26
31
 
27
32
  end
28
- end
33
+ end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Crunchbase
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.0"
5
5
  end
@@ -1,26 +1,20 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  module Crunchbase
4
- describe Acquisition do
4
+ describe Acquisition, :vcr do
5
+ describe 'a list' do
6
+ subject { Acquisition.lists_for_permalink("facebook") }
5
7
 
6
- describe "advanced indexing" do
7
- before(:all) do
8
- @all_acquisitions = Acquisition.lists_for_permalink("facebook")
9
- end
8
+ its(:size) { should eq(49) }
10
9
 
11
- it "should pull from web api" do
12
- @all_acquisitions.per_page.should == 1000
13
- @all_acquisitions.current_page.should == 1
14
- @all_acquisitions.size.should == 49
15
- end
10
+ it_has_behavior 'pagination'
16
11
  end
17
-
18
- it "should pull from web api" do
19
- acquisition = Acquisition.get("7a3d7915ed43073c0e4b5b0d7601def8")
20
12
 
21
- acquisition.name.should == "Acquisition"
22
- acquisition.permalink.should == "7a3d7915ed43073c0e4b5b0d7601def8"
23
- end
13
+ describe 'an entity' do
14
+ subject { Acquisition.get("7a3d7915ed43073c0e4b5b0d7601def8") }
24
15
 
16
+ its(:name) { should eq('Acquisition') }
17
+ its(:permalink) { should eq('7a3d7915ed43073c0e4b5b0d7601def8') }
18
+ end
25
19
  end
26
20
  end
@@ -1,16 +1,9 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  module Crunchbase
4
- describe BoardMembersAndAdvisor do
5
- describe "advanced indexing" do
6
- before(:all) do
7
- @all_board_members_and_advisors = BoardMembersAndAdvisor.lists_for_permalink("facebook")
8
- end
4
+ describe BoardMembersAndAdvisor, :vcr do
5
+ subject { BoardMembersAndAdvisor.lists_for_permalink("facebook") }
9
6
 
10
- it "should pull from web api" do
11
- @all_board_members_and_advisors.per_page.should == 1000
12
- @all_board_members_and_advisors.current_page.should == 1
13
- end
14
- end
7
+ it_has_behavior 'pagination'
15
8
  end
16
9
  end
@@ -1,25 +1,18 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  module Crunchbase
4
- describe Category do
4
+ describe Category, :vcr do
5
+ subject { Category.lists_for_permalink("facebook") }
5
6
 
6
- describe "advanced indexing" do
7
- before(:all) do
8
- @all_categories = Category.lists_for_permalink("facebook")
9
- end
7
+ it_has_behavior 'pagination'
8
+ it_behaves_like 'a container', 7
9
+
10
+ its(:size) { should eq(7) }
10
11
 
11
- it "should pull from web api" do
12
- @all_categories.per_page.should == 1000
13
- @all_categories.current_page.should == 1
14
- @all_categories.size.should == 7
15
- @all_categories.items.count.should == 7
16
- end
17
- end
18
12
 
19
13
  it "return categories lists" do
20
14
  results = Category.list(1)
21
15
  results.per_page.should == 1000
22
16
  end
23
-
24
17
  end
25
18
  end
@@ -1,19 +1,10 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  module Crunchbase
4
- describe Competitor do
5
-
6
- describe "advanced indexing" do
7
- before(:all) do
8
- @all_competitors = Competitor.lists_for_permalink("facebook")
9
- end
4
+ describe Competitor, :vcr do
5
+ subject { Competitor.lists_for_permalink("facebook") }
10
6
 
11
- it "should pull from web api" do
12
- @all_competitors.per_page.should == 1000
13
- @all_competitors.current_page.should == 1
14
- @all_competitors.size.should == 9
15
- end
16
- end
17
-
7
+ it_has_behavior 'pagination'
8
+ its(:size) { should eq(9) }
18
9
  end
19
10
  end
@@ -1,17 +1,11 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  module Crunchbase
4
- describe CurrentTeam do
5
- describe "advanced indexing" do
6
- before(:all) do
7
- @all_current_teams = CurrentTeam.lists_for_permalink("facebook")
8
- end
4
+ describe CurrentTeam, :vcr do
5
+ subject { CurrentTeam.lists_for_permalink("facebook") }
9
6
 
10
- it "should pull from web api" do
11
- @all_current_teams.per_page.should == 1000
12
- @all_current_teams.current_page.should == 1
13
- @all_current_teams.size.should == 137
14
- end
15
- end
7
+ it_has_behavior 'pagination'
8
+
9
+ its(:size) { should eq(139) }
16
10
  end
17
11
  end
@@ -1,20 +1,12 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  module Crunchbase
4
- describe Customer do
4
+ describe Customer, :vcr do
5
+ subject { Customer.lists_for_permalink("facebook") }
5
6
 
6
- describe "advanced indexing" do
7
- before(:all) do
8
- @all_customers = Customer.lists_for_permalink("facebook")
9
- end
10
-
11
- it "should pull from web api" do
12
- @all_customers.per_page.should == 1000
13
- @all_customers.current_page.should == 1
14
- @all_customers.size.should == 1
15
- @all_customers.items.count.should == 1
16
- end
17
- end
7
+ it_has_behavior 'pagination'
8
+ it_behaves_like 'a container', 1
18
9
 
10
+ its(:size) { should eq(1) }
19
11
  end
20
12
  end
@@ -1,20 +1,11 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  module Crunchbase
4
- describe Founder do
5
-
6
- describe "advanced indexing" do
7
- before(:all) do
8
- @all_founders = Founder.lists_for_permalink("facebook")
9
- end
4
+ describe Founder, :vcr do
5
+ subject { Founder.lists_for_permalink("facebook") }
10
6
 
11
- it "should pull from web api" do
12
- @all_founders.per_page.should == 1000
13
- @all_founders.current_page.should == 1
14
- @all_founders.size.should == 5
15
- @all_founders.items.count.should == 5
16
- end
17
- end
18
-
7
+ it_behaves_like 'a container', 5
8
+
9
+ its(:size) { should eq(5) }
19
10
  end
20
11
  end
@@ -1,26 +1,20 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  module Crunchbase
4
- describe FundingRound do
4
+ describe FundingRound, :vcr do
5
+ describe 'a list' do
6
+ subject { FundingRound.lists_for_permalink("facebook") }
5
7
 
6
- describe "advanced indexing" do
7
- before(:all) do
8
- @all_funding_rounds = FundingRound.lists_for_permalink("facebook")
9
- end
8
+ it_has_behavior 'pagination'
9
+ it_behaves_like 'a container', 11
10
10
 
11
- it "check the return results is correct" do
12
- @all_funding_rounds.per_page.should == 1000
13
- @all_funding_rounds.current_page.should == 1
14
- @all_funding_rounds.size.should == 11
15
- @all_funding_rounds.items.count.should == 11
16
- end
11
+ its(:size) { should eq(11) }
17
12
  end
18
-
19
- it "should pull from web api" do
20
- funding_round = FundingRound.get("37bd05f961af726ba3c1b279da842805")
21
13
 
22
- funding_round.permalink.should == '37bd05f961af726ba3c1b279da842805'
23
- end
14
+ describe 'an entity' do
15
+ subject { FundingRound.get("37bd05f961af726ba3c1b279da842805") }
24
16
 
17
+ its(:permalink) { should eq('37bd05f961af726ba3c1b279da842805') }
18
+ end
25
19
  end
26
20
  end
@@ -1,17 +1,10 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  module Crunchbase
4
- describe Headquarter do
5
- describe "advanced indexing" do
6
- before(:all) do
7
- @all_headquarters = Headquarter.lists_for_permalink("facebook")
8
- end
4
+ describe Headquarter, :vcr do
5
+ subject { Headquarter.lists_for_permalink("facebook") }
9
6
 
10
- it "should pull from web api" do
11
- @all_headquarters.per_page.should == 1000
12
- @all_headquarters.current_page.should == 1
13
- @all_headquarters.items.count.should == 1
14
- end
15
- end
7
+ it_has_behavior 'pagination'
8
+ it_behaves_like 'a container', 1
16
9
  end
17
10
  end
@@ -1,20 +1,12 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  module Crunchbase
4
- describe Investment do
5
-
6
- describe "advanced indexing" do
7
- before(:all) do
8
- @all_investments = Investment.lists_for_permalink("facebook")
9
- end
4
+ describe Investment, :vcr do
5
+ subject { Investment.lists_for_permalink("facebook") }
10
6
 
11
- it "should pull from web api" do
12
- @all_investments.per_page.should == 1000
13
- @all_investments.current_page.should == 1
14
- @all_investments.size.should == 3
15
- @all_investments.items.count.should == 3
16
- end
17
- end
18
-
7
+ it_has_behavior 'pagination'
8
+ it_behaves_like 'a container', 3
9
+
10
+ its(:size) { should eq(3) }
19
11
  end
20
12
  end
@@ -1,29 +1,24 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  module Crunchbase
4
- describe Ipo do
4
+ describe Ipo, :vcr do
5
+ describe 'a list' do
6
+ subject { Ipo.lists_for_permalink("facebook") }
5
7
 
6
- describe "advanced indexing" do
7
- before(:all) do
8
- @all_ipos = Ipo.lists_for_permalink("facebook")
9
- end
10
-
11
- it "should pull from web api" do
12
- @all_ipos.per_page.should == 1000
13
- @all_ipos.current_page.should == 1
14
- @all_ipos.size.should == 3
15
- @all_ipos.items.count.should == 3
8
+ it_has_behavior 'pagination'
9
+ it_behaves_like 'a container', 3
16
10
 
17
- puts @all_ipos.items.inspect
18
- end
11
+ its(:size) { should eq(3) }
19
12
  end
20
13
 
21
- it "should pull from web api" do
22
- ipo = Ipo.get("a3bc391490d52ba8529d1cfc20550a87")
14
+ describe 'an entity' do
15
+ subject { Ipo.get("a3bc391490d52ba8529d1cfc20550a87") }
23
16
 
24
- ipo.permalink.should == 'a3bc391490d52ba8529d1cfc20550a87'
25
- ipo.funded_companies[0].name.should == 'Facebook'
26
- end
17
+ its(:permalink) { should eq('a3bc391490d52ba8529d1cfc20550a87') }
27
18
 
19
+ it 'has correct funded companies' do
20
+ expect(subject.funded_companies[0].name).to eq('Facebook')
21
+ end
22
+ end
28
23
  end
29
24
  end
@@ -1,16 +1,14 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  module Crunchbase
4
- describe Location do
4
+ describe Location, :vcr do
5
+ subject { Location.list(1) }
5
6
 
6
- it "return location lists" do
7
- results = Location.list(1)
7
+ it_has_behavior 'pagination'
8
8
 
9
- results.per_page.should == 1000
10
- results.current_page.should == 1
11
-
12
- puts results.items.first(3).inspect
13
- end
9
+ # it "return location lists" do
10
+ # puts results.items.first(3).inspect
11
+ # end
14
12
 
15
13
  end
16
14
  end
@@ -1,33 +1,19 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  module Crunchbase
4
- describe NewItem do
4
+ describe NewItem, :vcr do
5
+ subject { NewItem.lists_for_permalink("facebook") }
5
6
 
6
- describe "advanced indexing" do
7
- before(:all) do
8
- @all_news = NewItem.lists_for_permalink("facebook")
9
- end
7
+ it_has_behavior 'pagination'
8
+ it_behaves_like 'a container', 1000
10
9
 
11
- it "should pull from web api" do
12
- puts @all_news.items.first.title
13
- puts @all_news.next_page_url
14
-
15
- @all_news.per_page.should == 1000
16
- @all_news.current_page.should == 1
17
- end
10
+ describe 'paging' do
11
+ let(:page) { 4 }
12
+ subject { NewItem.lists_for_permalink("facebook", {page: page}) }
18
13
 
19
- it "should get oranization all news list" do
20
- @all_news.items.count.should == 3116
21
- end
22
- end
23
-
24
- it "Fetched all news data paging" do
25
- page = 4
26
- second_news = NewItem.lists_for_permalink("facebook", {page: page})
27
-
28
- second_news.next_page_url.should == nil
29
- second_news.per_page.should == 1000
30
- second_news.current_page.should == page
14
+ its(:next_page_url) { should be nil }
15
+ its(:per_page) { should eq(1000) }
16
+ its(:current_page) { should eq(page) }
31
17
  end
32
18
  end
33
19
  end
@@ -1,19 +1,10 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  module Crunchbase
4
- describe Office do
5
- describe "advanced indexing" do
6
- before(:all) do
7
- @all_offices = Office.lists_for_permalink("facebook")
8
- end
4
+ describe Office, :vcr do
5
+ subject { Office.lists_for_permalink("facebook") }
9
6
 
10
- it "should pull from web api" do
11
- @all_offices.per_page.should == 1000
12
- @all_offices.current_page.should == 1
13
- @all_offices.items.count.should == 3
14
-
15
- puts @all_offices.items.inspect
16
- end
17
- end
7
+ it_has_behavior 'pagination'
8
+ it_behaves_like 'a container', 3
18
9
  end
19
10
  end
@@ -1,62 +1,35 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  module Crunchbase
4
- describe Organization do
5
-
6
- describe "Get Organization object from premalink" do
7
- before(:all) do
8
- @company = Organization.get("facebook")
9
- end
10
-
11
- it "should loading relationship data" do
12
- puts @company.websites_total_items
13
- puts @company.websites.inspect
14
- teams = Website.lists_for_permalink(@company.permalink)
15
- end
16
-
17
- it "should organization's websites data" do
18
- # Top 8 websites
19
- puts @company.websites
20
- # Show websites total count
21
- puts @company.websites_total_items
22
- # Show organization's websites list search by organization permalink
23
- teams = Website.lists_for_permalink(@company.permalink)
24
- end
25
-
26
- it "should pull from web api" do
27
- @company.name.should == "Facebook"
28
- @company.competitors_total_items.should == 9
29
- @company.customers_total_items.should == 1
30
- @company.founders_total_items.should == 5
31
- @company.funding_rounds_total_items.should == 11
32
- @company.ipos_total_items.should == 3
33
- @company.products_total_items.should == 16
34
- @company.sub_organizations_total_items.should == 2
35
-
36
- @company.past_teams_total_items.should == 186
37
- @company.current_teams_total_items.should == 137
38
- @company.acquisitions_total_items.should == 49
39
- @company.offices_total_items.should == 3
40
- @company.headquarters_total_items.should == 1
41
- @company.categories_total_items.should == 7
42
- @company.investments_total_items.should == 3
43
- @company.primary_images_total_items.should == 1
44
- @company.images_total_items.should == 1
45
- @company.websites_total_items.should == 6
46
- @company.new_items_total_items.should == 3116
47
- @company.board_members_and_advisors_total_items.should == 12
48
- end
49
-
50
-
51
- end
52
-
53
- it "Search organizations by name" do
54
- results = Organization.search({ domain_name: "facebook.com", organization_types: 'company' })
55
-
56
- results.per_page.should == 1000
57
- results.current_page.should == 1
58
- puts results.results[0].inspect
4
+ describe Organization, :vcr do
5
+ subject { Organization.get("facebook") }
6
+
7
+ its(:name) { should eq('Facebook') }
8
+ its(:competitors_total_items) { should eq(9) }
9
+ its(:customers_total_items) { should eq(1) }
10
+ its(:founders_total_items) { should eq(5) }
11
+ its(:funding_rounds_total_items) { should eq(11) }
12
+ its(:ipos_total_items) { should eq(3) }
13
+ its(:products_total_items) { should eq(17) }
14
+ its(:sub_organizations_total_items) { should eq(2) }
15
+
16
+ its(:past_teams_total_items) { should eq(187) }
17
+ its(:current_teams_total_items) { should eq(139) }
18
+ its(:acquisitions_total_items) { should eq(49) }
19
+ its(:offices_total_items) { should eq(3) }
20
+ its(:headquarters_total_items) { should eq(1) }
21
+ its(:categories_total_items) { should eq(7) }
22
+ its(:investments_total_items) { should eq(3) }
23
+ its(:primary_images_total_items) { should eq(1) }
24
+ its(:images_total_items) { should eq(1) }
25
+ its(:websites_total_items) { should eq(6) }
26
+ its(:new_items_total_items) { should eq(3118) }
27
+ its(:board_members_and_advisors_total_items) { should eq(12) }
28
+
29
+ describe '.search' do
30
+ subject { Organization.search({ domain_name: "facebook.com", organization_types: 'company' }) }
31
+
32
+ it_has_behavior 'pagination'
59
33
  end
60
-
61
34
  end
62
35
  end
@@ -1,16 +1,9 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  module Crunchbase
4
- describe PastTeam do
5
- describe "advanced indexing" do
6
- before(:all) do
7
- @all_past_teams = PastTeam.lists_for_permalink("facebook")
8
- end
4
+ describe PastTeam, :vcr do
5
+ subject { PastTeam.lists_for_permalink("facebook") }
9
6
 
10
- it "should pull from web api" do
11
- @all_past_teams.per_page.should == 1000
12
- @all_past_teams.current_page.should == 1
13
- end
14
- end
7
+ it_has_behavior 'pagination'
15
8
  end
16
9
  end
@@ -2,18 +2,10 @@ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
  require 'json'
3
3
 
4
4
  module Crunchbase
5
- describe Person do
6
- describe "advanced indexing" do
7
- before(:all) do
8
- @all_person = Person.list
9
- end
5
+ describe Person, :vcr do
6
+ subject { Person.list }
10
7
 
11
- it "should pull from web api" do
12
- @all_person.per_page.should == 1000
13
- @all_person.current_page.should == 1
14
- puts @all_person.results[0..10].inspect
15
- end
16
- end
8
+ it_has_behavior 'pagination'
17
9
 
18
10
  # it "should pull from web api" do
19
11
  # person = Crunchbase::Person.get('eduardo-saverin')
@@ -1,20 +1,14 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  module Crunchbase
4
- describe PrimaryImage do
4
+ describe PrimaryImage, :vcr do
5
+ subject { PrimaryImage.lists_for_permalink("facebook") }
5
6
 
6
- describe "advanced indexing" do
7
- before(:all) do
8
- @all_primary_image = PrimaryImage.lists_for_permalink("facebook")
9
- end
10
-
11
- it "should pull from web api" do
12
- @all_primary_image.per_page.should == 1000
13
- @all_primary_image.current_page.should == 1
14
- end
7
+ it_has_behavior 'pagination'
15
8
 
9
+ describe "advanced indexing" do
16
10
  it "should get a company all primary image list" do
17
- @all_primary_image.items[0].title.should == nil
11
+ subject.items[0].title.should == nil
18
12
  end
19
13
  end
20
14
  end
@@ -1,22 +1,20 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  module Crunchbase
4
- describe Product do
5
-
6
- describe "advanced indexing" do
7
- before(:all) do
8
- @all_products = Product.lists_for_permalink("facebook")
9
- end
10
-
11
- it "should pull from web api" do
12
- @all_products.per_page.should == 1000
13
- @all_products.current_page.should == 1
14
- @all_products.size.should == 16
15
- @all_products.results.count.should == 16
16
- puts @all_products.results.inspect
17
- end
18
- end
19
-
4
+ describe Product, :vcr do
5
+ subject { Product.lists_for_permalink("facebook") }
6
+
7
+ it_has_behavior 'pagination'
8
+
9
+ its(:size) { should eq(17) }
10
+
11
+ # describe "advanced indexing" do
12
+
13
+ # it "should pull from web api" do
14
+ # @all_products.results.count.should == 16
15
+ # end
16
+ # end
17
+
20
18
  # it "should pull from web api" do
21
19
  # product = Product.get("internet-org")
22
20
 
@@ -2,15 +2,9 @@ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
  require 'net/http'
3
3
 
4
4
  module Crunchbase
5
- describe SearchResult do
6
-
7
- before(:all) do
8
- @result = Search.find('google').results[0]
9
- end
10
-
11
- it "should return the entity which is named" do
12
- @result.name.should == 'Google'
13
- end
5
+ describe SearchResult, :vcr do
6
+ subject { Search.find('google').results[0] }
14
7
 
8
+ its(:name) { should eq('Google') }
15
9
  end
16
10
  end
@@ -2,16 +2,16 @@ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
  require 'net/http'
3
3
 
4
4
  module Crunchbase
5
- describe Search do
5
+ describe Search, :vcr do
6
6
 
7
- it "should retrieve search results" do
8
- s = Search.search('google')
9
- puts s.total_items
10
- puts s.per_page
11
- puts s.pages
12
- puts s.current_page
13
- s.results.each { |result| puts result.name }
14
- end
7
+ # it "should retrieve search results" do
8
+ # s = Search.search('google')
9
+ # puts s.total_items
10
+ # puts s.per_page
11
+ # puts s.pages
12
+ # puts s.current_page
13
+ # s.results.each { |result| puts result.name }
14
+ # end
15
15
 
16
16
  end
17
17
  end
@@ -1,21 +1,11 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  module Crunchbase
4
- describe SubOrganization do
5
-
6
- describe "advanced indexing" do
7
- before(:all) do
8
- @all_sub_organizations = SubOrganization.lists_for_permalink("facebook")
9
- end
4
+ describe SubOrganization, :vcr do
5
+ subject { SubOrganization.lists_for_permalink("facebook") }
10
6
 
11
- it "should pull from web api" do
12
- @all_sub_organizations.per_page.should == 1000
13
- @all_sub_organizations.current_page.should == 1
14
- @all_sub_organizations.size.should == 2
7
+ it_has_behavior 'pagination'
15
8
 
16
- puts @all_sub_organizations.items.inspect
17
- end
18
- end
19
-
9
+ its(:size) { should eq(2) }
20
10
  end
21
11
  end
@@ -1,25 +1,10 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  module Crunchbase
4
- describe Website do
4
+ describe Website, :vcr do
5
+ subject { Website.lists_for_permalink("facebook") }
5
6
 
6
- describe "advanced indexing" do
7
- before(:all) do
8
- @all_websites = Website.lists_for_permalink("facebook")
9
- end
10
-
11
- it "should pull from web api" do
12
- puts @all_websites.items.first.title
13
- puts @all_websites.next_page_url
14
-
15
- @all_websites.per_page.should == 1000
16
- @all_websites.current_page.should == 1
17
- @all_websites.items.count.should == 6
18
- end
19
-
20
- it "Show Top 8 websites" do
21
- puts @all_websites.items.inspect
22
- end
23
- end
7
+ it_has_behavior 'pagination'
8
+ it_behaves_like 'a container', 6
24
9
  end
25
10
  end
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,24 @@
1
1
  $LOAD_PATH << File.join(File.dirname(__FILE__), "..", "lib")
2
2
  require 'rspec'
3
+ require 'rspec/its'
3
4
  require 'crunchbase'
4
5
  require 'date'
5
6
  require 'yaml'
7
+ require 'vcr'
6
8
 
7
9
  yaml = YAML.load_file(File.join(File.dirname(__FILE__),'apikey.yml'))
8
10
 
9
11
  Crunchbase::API.key = yaml["key"]
10
12
  Crunchbase::API.debug = yaml["debug"]
13
+
14
+ VCR.configure do |c|
15
+ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
16
+ c.hook_into :webmock
17
+ c.configure_rspec_metadata!
18
+ end
19
+
20
+ RSpec.configure do |c|
21
+ c.alias_it_should_behave_like_to :it_has_behavior, 'has behavior:'
22
+ end
23
+
24
+ Dir["./spec/support/**/*.rb"].sort.each { |f| require f}
@@ -0,0 +1,10 @@
1
+ shared_examples 'pagination' do
2
+ its(:per_page) { should eq(1000) }
3
+ its(:current_page) { should eq(1) }
4
+ end
5
+
6
+ shared_examples 'a container' do |count|
7
+ it 'has correct number of items' do
8
+ expect(subject.items.count).to eq(count)
9
+ end
10
+ end
metadata CHANGED
@@ -1,15 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crunchbase_v2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Encore Shao
9
+ - Mark
10
+ - Ladislav Martincik
9
11
  autorequire:
10
12
  bindir: bin
11
13
  cert_chain: []
12
- date: 2015-02-06 00:00:00.000000000 Z
14
+ date: 2015-03-17 00:00:00.000000000 Z
13
15
  dependencies:
14
16
  - !ruby/object:Gem::Dependency
15
17
  name: bundler
@@ -50,7 +52,7 @@ dependencies:
50
52
  requirements:
51
53
  - - ~>
52
54
  - !ruby/object:Gem::Version
53
- version: 2.10.0
55
+ version: '3.0'
54
56
  type: :development
55
57
  prerelease: false
56
58
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,10 +60,59 @@ dependencies:
58
60
  requirements:
59
61
  - - ~>
60
62
  - !ruby/object:Gem::Version
61
- version: 2.10.0
63
+ version: '3.0'
64
+ - !ruby/object:Gem::Dependency
65
+ name: rspec-its
66
+ requirement: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ type: :development
73
+ prerelease: false
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ - !ruby/object:Gem::Dependency
81
+ name: webmock
82
+ requirement: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: vcr
98
+ requirement: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
62
112
  description: ! ' Ruby wrapper for Crunchbase API version 2 '
63
113
  email:
64
114
  - encore.shao@gmail.com
115
+ - ladislav.martincik@gmail.com
65
116
  executables: []
66
117
  extensions: []
67
118
  extra_rdoc_files: []
@@ -140,6 +191,7 @@ files:
140
191
  - spec/fixtures/organization-facebook.js
141
192
  - spec/fixtures/person-randi-zuckerberg.js
142
193
  - spec/spec_helper.rb
194
+ - spec/support/shared_examples.rb
143
195
  homepage: https://github.com/encoreshao/crunchbase_v2
144
196
  licenses:
145
197
  - MIT
@@ -155,7 +207,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
155
207
  version: '0'
156
208
  segments:
157
209
  - 0
158
- hash: -2613269083352727618
210
+ hash: -3668500788587651473
159
211
  required_rubygems_version: !ruby/object:Gem::Requirement
160
212
  none: false
161
213
  requirements:
@@ -164,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
216
  version: '0'
165
217
  segments:
166
218
  - 0
167
- hash: -2613269083352727618
219
+ hash: -3668500788587651473
168
220
  requirements: []
169
221
  rubyforge_project:
170
222
  rubygems_version: 1.8.23.2
@@ -203,3 +255,4 @@ test_files:
203
255
  - spec/fixtures/organization-facebook.js
204
256
  - spec/fixtures/person-randi-zuckerberg.js
205
257
  - spec/spec_helper.rb
258
+ - spec/support/shared_examples.rb