<commit_before>require 'spec_helper'
require 'rakuten_web_service/ichiba/ranking'

describe RakutenWebService::Ichiba::RankingItem do
  let(:endpoint) { 'https://app.rakuten.co.jp/services/api/IchibaItem/Ranking/20120927' }
  let(:affiliate_id) { 'affiliate_id' }
  let(:application_id) { 'application_id' }
  let(:expected_query) do
    {
      :affiliateId => affiliate_id, :applicationId => application_id
    }
  end

  before do 
    response = JSON.parse(fixture('ichiba/ranking_search.json'))
    @expected_request = stub_request(:get, endpoint).
      with(:query => expected_query).to_return(:body => response.to_json)

    RakutenWebService.configuration do |c|
      c.affiliate_id = affiliate_id
      c.application_id = application_id
    end
  end

  describe '.search' do
    before do 
      @ranking_items = RakutenWebService::Ichiba::RankingItem.search({}).first
    end

    specify 'should call the endpoint once' do
      expect(@expected_request).to have_been_made.once
    end
  end

end
<commit_msg>RankingItem object has accessor the same of Item<commit_after>require 'spec_helper'
require 'rakuten_web_service/ichiba/ranking'

describe RakutenWebService::Ichiba::RankingItem do
  let(:endpoint) { 'https://app.rakuten.co.jp/services/api/IchibaItem/Ranking/20120927' }
  let(:affiliate_id) { 'affiliate_id' }
  let(:application_id) { 'application_id' }
  let(:expected_query) do
    {
      :affiliateId => affiliate_id, :applicationId => application_id
    }
  end

  before do 
    response = JSON.parse(fixture('ichiba/ranking_search.json'))
    @expected_request = stub_request(:get, endpoint).
      with(:query => expected_query).to_return(:body => response.to_json)

    RakutenWebService.configuration do |c|
      c.affiliate_id = affiliate_id
      c.application_id = application_id
    end
  end

  describe '.search' do
    let(:expected_json) do
      response = JSON.parse(fixture('ichiba/ranking_search.json'))
      response['Items'][0]['Item']
    end

    before do 
      @ranking_item = RakutenWebService::Ichiba::RankingItem.search({}).first
    end

    subject { @ranking_item }

    specify 'should call the endpoint once' do
      expect(@expected_request).to have_been_made.once
    end
    specify 'should be access by key' do
      expect(subject['itemName']).to eq(expected_json['itemName'])
      expect(subject['item_name']).to eq(expected_json['itemName'])
    end
    its(:rank) { should eq(1) }
    its(:name) { should eq(expected_json['itemName']) }
  end

end

{'fraction_non_alphanumeric': 0.11979373264577549, 'fraction_numerical': 0.007140023800079333, 'mean_word_length': 3.9645669291338583, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4503273', 'n_tokens_mistral': 856, 'n_tokens_neox': 811, 'n_words': 151}