Sha256: b05c2860bace8138bc851cf324226da89c7a7a9d630d2b830bcc1a49ed6609fd

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper_unit'

describe Mention::Alert do
  let(:account){ Mention::Account.new(account_id: 'abc', access_token: 'def') }
  let(:json){ File.read('spec/fixtures/get_account_alerts.json') }
  let(:alert_params){ JSON.parse(json)['alerts'].first }
  let(:alert){ Mention::Alert.new(alert_params) }
  let(:base_url){ "https://api.mention.net/api/accounts/abc/alerts/#{alert.id}/mentions" }

  it "fetches a list of mentions" do
    stub_request(:get, base_url).
      with(:headers => {'Accept'=>'application/json', 'Authorization'=>'Bearer def'}).
      to_return(:status => 200, :body => File.read("spec/fixtures/mention_list_default.json"))

    mentions = alert.mentions(account)
    mentions.should be_a(Mention::MentionList)
    mentions.count.should == 9
  end

  it "fetches a list of mentions since a given id" do
    stub_request(:get, "#{base_url}?since_id=3199497112").
      with(:headers => {'Accept'=>'application/json', 'Authorization'=>'Bearer def'}).
      to_return(:status => 200, :body => File.read("spec/fixtures/mention_list_since.json"))

    mentions = alert.mentions(account, since_id: "3199497112")
    mentions.should be_a(Mention::MentionList)
    mentions.count.should == 3
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mention-api-0.1.0 spec/lib/mention/alert_spec.rb
mention-api-0.0.3 spec/lib/mention/alert_spec.rb
mention-api-0.0.2 spec/lib/mention/alert_spec.rb