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

describe FbGraph::Connections::Subscriptions, '#subscriptions' do
  context 'when included by FbGraph::Application' do
    before do
      fake_json(:get, 'fb_graph/subscriptions?access_token=access_token', 'applications/subscriptions/fb_graph_private')
    end

    context 'when access_token is given' do
      it 'should return liked pages as FbGraph::Page' do
        subscriptions = FbGraph::Application.new('fb_graph', :access_token => 'access_token').subscriptions
        subscriptions.each do |subscription|
          subscription.should be_instance_of(FbGraph::Subscription)
        end
      end
    end
  end
end<commit_msg>subscription spec<commit_after>require File.join(File.dirname(__FILE__), '../../spec_helper')

describe FbGraph::Connections::Subscriptions, '#subscriptions' do
  context 'when included by FbGraph::Application' do
    before do
      fake_json(:get, 'fb_graph/subscriptions?access_token=access_token', 'applications/subscriptions/fb_graph_private')
    end

    context 'when access_token is given' do
      it 'should return liked pages as FbGraph::Page' do
        subscriptions = FbGraph::Application.new('fb_graph', :access_token => 'access_token').subscriptions
        subscriptions.each do |subscription|
          subscription.should be_instance_of(FbGraph::Subscription)
        end
      end
    end
  end
end

describe FbGraph::Connections::Subscriptions, '#subscribe!' do
  before do
    @app = FbGraph::Application.new('fb_graph', :access_token => 'access_token')
  end

  it 'should POST to /:app_id/subscriptions' do
    lambda do
      @app.subscribe!(
        :object => "user",
        :fields => "name,email",
        :callback_url => "http://fbgraphsample.heroku.com/subscription",
        :verify_token => "Define by yourself"
      )
    end.should request_to 'fb_graph/subscriptions', :post
  end
end

describe FbGraph::Connections::Subscriptions, '#unsubscribe!' do
  before do
    @app = FbGraph::Application.new('fb_graph', :access_token => 'access_token')
  end

  it 'should DELETE /:app_id/subscriptions' do
    lambda do
      @app.unsubscribe!(
        :object => 'user'
      )
    end.should request_to 'fb_graph/subscriptions?access_token=access_token&object=user', :delete
  end
end
{'fraction_non_alphanumeric': 0.11363636363636363, 'fraction_numerical': 0.0, 'mean_word_length': 3.911578947368421, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 0, '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': '1782138', 'n_tokens_mistral': 693, 'n_tokens_neox': 692, 'n_words': 157}