<commit_before>require File.join(File.dirname(__FILE__), '../spec_helper')

describe FbGraph::Page, '.new' do
  it 'should setup all supported attributes' do
    attributes = {
      :id => '19292868552',
      :name => 'Facebook Platform',
      :founded => 'May 2007',
      :category => 'Technology',
      :username => 'platform',
      :mission => 'To make the web more open and social.',
      :products => "Facebook Application Programming Interface (API)\nFacebook Query Language (FQL)\nFacebook Markup Language (FBML)\nFacebook JavaScript (FBJS)\nFacebook Connect\n",
      :likes => 578246,
      :company_overview => 'Facebook Platform enables anyone to build social applications on Facebook and the web.',
      :link => 'http://www.facebook.com/platform',
      :picture => 'http://profile.ak.fbcdn.net/profile-ak-snc1/object3/1566/8/s19292868552_1660.jpg',
      :website => 'http://developers.facebook.com'
    }
    page = FbGraph::Page.new(attributes.delete(:id), attributes)
    page.identifier.should == '19292868552'
    page.name.should       == 'Facebook Platform'
    page.founded.should    == Date.new(2007, 5)
    page.category.should   == 'Technology'
    page.username.should   == 'platform'
    page.mission.should    == 'To make the web more open and social.'
    page.products.should   == "Facebook Application Programming Interface (API)\nFacebook Query Language (FQL)\nFacebook Markup Language (FBML)\nFacebook JavaScript (FBJS)\nFacebook Connect\n"
    page.like_count.should == 578246
    page.company_overview.should == 'Facebook Platform enables anyone to build social applications on Facebook and the web.'
    page.link.should     == 'http://www.facebook.com/platform'
    page.picture.should  == 'https://graph.facebook.com/19292868552/picture' # use connection
    page.website.should  == 'http://developers.facebook.com'
  end

  it 'should allow invalid date as founded' do
    page = FbGraph::Page.new(12345, :founded => "2004")
    page.founded.should == '2004'
  end

  it 'should allow invalid date as release_date' do
    page1 = FbGraph::Page.new(12345, :release_date => "2010-04-23")
    page1.release_date.should == Date.new(2010, 4, 23)
    page2 = FbGraph::Page.new(12345, :release_date => "someday")
    page2.release_date.should == 'someday'
  end
end

describe FbGraph::Page, '.fetch' do
  before do
    fake_json(:get, 'platform', 'pages/platform_public')
    fake_json(:get, 'platform?access_token=access_token', 'pages/platform_private')
  end

  it 'should get page attributes' do
    page = FbGraph::Page.fetch('platform')
    page.identifier.should == '19292868552'
    page.name.should       == 'Facebook Platform'
    page.category.should   == 'Technology'
  end
end<commit_msg>update spec<commit_after>require File.join(File.dirname(__FILE__), '../spec_helper')

describe FbGraph::Page do
  let(:attributes) do
    {
      :id       => '19292868552',
      :category => 'Technology',
      :likes    => 578246,
      :name     => 'Facebook Platform',
      :username => 'platform'
    }
  end
  subject do
    FbGraph::Page.new(attributes[:id], attributes)
  end

  its(:identifier) { should == attributes[:id]       }
  its(:category)   { should == attributes[:category] }
  its(:like_count) { should == attributes[:likes]    }
  its(:name)       { should == attributes[:name]     }
  its(:username)   { should == attributes[:username] }

  describe '.fetch' do
    before do
      fake_json(:get, 'platform', 'pages/platform_public')
      fake_json(:get, 'platform?access_token=access_token', 'pages/platform_private')
    end

    context 'when access_token is given' do
      subject { FbGraph::Page.fetch('platform') }
      its(:identifier) { should == '19292868552' }
      its(:name)       { should == 'Facebook Platform' }
      its(:category)   { should == 'Technology' }
      its(:like_count) { should == 578214 }
    end

    context 'otherwise' do
      subject { FbGraph::Page.fetch('platform', :access_token => 'access_token') }
      its(:like_count) { should == 578214 }
    end
  end
end
{'fraction_non_alphanumeric': 0.14075165806927045, 'fraction_numerical': 0.041513141734217635, 'mean_word_length': 3.41648590021692, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 24, 'https://': 1, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 19, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1849561', 'n_tokens_mistral': 1382, 'n_tokens_neox': 1232, 'n_words': 293}