Sha256: 8facae08447d0bd72b709c5e20e43ae194a7a7a73a19d33729f6204bb66dec6b

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 KB

Contents

describe NetworkExecutive::Components::TweetPlayer do

  let(:klass) do
    Class.new do
      def name; 'foo'; end
    end.send :include, described_class
  end

  before do
    stub_const 'MyProgram', klass
  end

  subject { MyProgram.new }

  its(:url) { should == '/twitter' }

  its(:refresh) { should be_false }

  describe '#onload' do
    it 'should include the Twitter search results' do
      subject.class.should_receive( :tweets ).and_return( statuses: [] )

      subject.onload.should include(:tweets)
    end
  end

  describe '.tweets' do
    it 'should delegate to the class' do
      described_class.should_receive :tweets

      described_class.tweets
    end
  end

  describe '.client' do
    it 'should be a Twitter Client' do
      subject.class.client.should be_a Twitter::Client
    end
  end

  describe '.configure' do
    it 'should yield the client' do
      arg = nil

      subject.class.configure { |c| arg = c }

      arg.should eq subject.class.client
    end
  end

  describe '.search' do
    it 'should configure the search query' do
      subject.class.search 'search term', count: 4

      subject.class.query.should eq [ 'search term', { count: 4 }]
    end
  end

  describe '.tweets' do
    it 'should search with the client instance' do
      subject.class.search 'foo'

      Twitter::Client.any_instance.should_receive( :search ).with 'foo'

      subject.class.tweets
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
network_executive-0.0.8 spec/unit/components/tweet_player_spec.rb
network_executive-0.0.7 spec/unit/components/tweet_player_spec.rb