Sha256: 68126d01d8a81bee3a14f97432eb370bf2e88a7985bc22a0f7f4f70a0647aad8

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

describe 'TweetStream MultiJson Support' do
  after do
    TweetStream.reset
  end

  it "should default to the MultiJson default's paser" do
    TweetStream::Client.new.json_parser.engine.to_s.should == MultiJson.engine.to_s
  end

  [:json_gem, :yajl, :json_pure].each do |engine|
    describe "#{engine} parsing" do
      before do
        TweetStream.configure do |config|
          config.username = 'test'
          config.password = 'fake'
          config.parser   = engine
        end
        @client = TweetStream::Client.new
        @class_name = "MultiJson::Engines::#{engine.to_s.split('_').map{|s| s.capitalize}.join('')}"
      end

      it 'should set the parser to the appropriate class' do
        @client.json_parser.engine.to_s == @class_name
      end

      it 'should be settable via client.parser=' do
        @client.parser = engine
        @client.json_parser.engine.to_s.should == @class_name
      end
    end
  end

  class FakeParser; end

  it 'should be settable to a class' do
    @client = TweetStream::Client.new
    @client.parser = FakeParser
    @client.json_parser.engine.should == FakeParser
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tweetstream-1.1.4 spec/tweetstream/parser_spec.rb
tweetstream-1.1.3 spec/tweetstream/parser_spec.rb
tweetstream-1.1.2 spec/tweetstream/parser_spec.rb
tweetstream-1.1.1 spec/tweetstream/parser_spec.rb
tweetstream-1.1.0 spec/tweetstream/parser_spec.rb