Sha256: 74da4eed7488dff7156b01eba8106ba5e3aca3e6d74d682d3723b623f39ece2a

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe 'TweetStream JSON Parsers' do
  it 'should default to the JSON Gem' do
    TweetStream::Client.new('test','fake').parser.should == TweetStream::Parsers::JsonGem
  end
  
  [:json_gem, :yajl, :active_support, :json_pure].each do |engine|
    describe "#{engine} parsing" do
      before do
        @client = TweetStream::Client.new('test','fake',engine)
        @class_name = "TweetStream::Parsers::#{engine.to_s.split('_').map{|s| s.capitalize}.join('')}"
      end
      
      it 'should set the parser to the appropriate class' do
        @client.parser.to_s == @class_name
      end
      
      it 'should be settable via client.parser=' do
        @client.parser = nil
        @client.parser.should be_nil
        @client.parser = engine
        @client.parser.to_s.should == @class_name
      end
    end
  end
  
  class FakeParser
    def self.decode(text)
      {}
    end
  end
  
  it 'should be settable to a class' do
    @client = TweetStream::Client.new('abc','def')
    @client.parser = FakeParser
    @client.parser.should == FakeParser
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tweetstream-1.0.5 spec/tweetstream/parser_spec.rb
tweetstream-1.0.4 spec/tweetstream/parser_spec.rb
tweetstream-1.0.3 spec/tweetstream/parser_spec.rb
tweetstream-1.0.2 spec/tweetstream/parser_spec.rb
tweetstream-1.0.1 spec/tweetstream/parser_spec.rb