Sha256: 4e7dad81f404eb60bb72625dab507a78ac1814c4b5fad0c49de1b9a525526e46

Contents?: true

Size: 1.94 KB

Versions: 4

Compression:

Stored size: 1.94 KB

Contents

require 'helper'

describe WorldbankAsDataframe::ParamQuery do
  context 'lending types' do
    it 'accepts a single LendingType as param' do
      stub_get('countries/all?format=json&lendingTypes=IDB')
      lending_type = WorldbankAsDataframe::LendingType.new({"id" => "IDB","value" => "Blend"})
      WorldbankAsDataframe::Country.all.raw.lending_type(lending_type).fetch
      a_get('countries/all?format=json&lendingTypes=IDB').should have_been_made
    end
  end
  context 'income levels' do
    it 'accepts a single IncomeLevels as param' do
      stub_get('countries/all?format=json&incomeLevels=LMC')
      WorldbankAsDataframe::Country.all.raw.income_level('LMC').fetch
      a_get('countries/all?format=json&incomeLevels=LMC').should have_been_made
    end
  end
  context 'sources' do
    it 'accepts a single Source as param' do
      stub_get('countries/all?format=json&sources=1')
      WorldbankAsDataframe::Country.all.raw.source(1).fetch
      a_get('countries/all?format=json&sources=1').should have_been_made
    end
  end
  context 'featured_indicators' do
    it 'adds featured param with value of 1' do
      stub_get('indicators/all?format=json&featured=1')
      WorldbankAsDataframe::Indicator.featured.raw.fetch
      a_get('indicators/all?format=json&featured=1').should have_been_made
    end
  end
  context 'country' do
    it 'adds countries to the params if given ISO-2 code' do
      stub_get('indicators/AB.LND.ARBL.ZS?format=json&countries=br')
      WorldbankAsDataframe::Indicator.find('AB.LND.ARBL.ZS').country('br').raw.fetch
      a_get('indicators/AB.LND.ARBL.ZS?format=json&countries=br').should have_been_made
    end
    it 'adds countries to the params if given human name' do
      stub_get('indicators/AB.LND.ARBL.ZS?format=json&countries=BR')
      WorldbankAsDataframe::Indicator.find('AB.LND.ARBL.ZS').country('brazil').raw.fetch
      a_get('indicators/AB.LND.ARBL.ZS?format=json&countries=BR').should have_been_made
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
worldbank_as_dataframe-0.2.1 spec/worldbank_as_dataframe/param_query_spec.rb
worldbank_as_dataframe-0.2 spec/worldbank_as_dataframe/param_query_spec.rb
worldbank_as_dataframe-0.1.1 spec/worldbank_as_dataframe/param_query_spec.rb
worldbank_as_dataframe-0.1.0 spec/worldbank_as_dataframe/param_query_spec.rb