Skip to content
Browse files

Fixing keys

  • Loading branch information...
1 parent fdc062f commit bb5dd80ee1d94b88c9d47061d1337b7aab8154c9 @timd committed Feb 28, 2012
Showing with 98 additions and 0 deletions.
  1. +98 −0 spec/models/tweeter_spec.rb
View
98 spec/models/tweeter_spec.rb
@@ -0,0 +1,98 @@
+require 'spec_helper'
+
+describe Tweeter do
+
+ before(:each) do
+
+ @client = Grackle::Client.new(:auth=>{
+ :type=>:oauth,
+ :consumer_key => TWITTER_CONSUMER_KEY ,
+ :consumer_secret=> TWITTER_CONSUMER_SECRET,
+ :token => TWITTER_OAUTH_TOKEN,
+ :token_secret => TWITTER_OAUTH_SECRET
+ })
+
+ Twitter.configure do |config|
+ config.consumer_key = TWITTER_CONSUMER_KEY
+ config.consumer_secret = TWITTER_CONSUMER_SECRET
+ config.oauth_token = TWITTER_OAUTH_TOKEN
+ config.oauth_token_secret = TWITTER_OAUTH_SECRET
+ end
+
+ WebMock.allow_net_connect!
+
+ end
+
+ before(:each) do
+ #Twitter.should_receive(:configure).and_return true
+ @tweeter = Tweeter.new
+ end
+
+ it "should grab @ messages from the Twitter timeline" do
+ results = @tweeter.grab("timd")
+ results.each do |result|
+
+ result.marshal_dump.each do |key, value|
+ puts "#{key} - #{value}"
+ end
+
+ end
+ end
+
+ it "should store the latest @ message id in the database" do
+ pending
+ end
+
+ it "sends a Tweet" do
+ pending
+ Twitter.should_receive(:update).with("Foo!").and_return true
+ @tweeter.send("Foo!")
+ end
+
+ it "retrieves and parses some tweets" do
+ pending
+ Twitter.should_receive(:configure).and_return true
+ @tweeter = Tweeter.new
+
+ @timeline = ["first!", "second"]
+
+ Twitter.should_receive(:user_timeline).with("foo").and_return(@timeline)
+
+ @tweeter.grab("foo").should eq("first!")
+
+ end
+
+
+ it "uses the customer's name in the header when the customer name is Tim" do
+
+ pending
+
+ customer = double('customer')
+ customer.should_receive(:name).and_return('Tim')
+
+ logger = mock('logger')
+
+
+ statement = Tweeter.new(customer, logger)
+ statement.generate.should =~ /^Statement for Tim/
+
+ end
+
+ it "logs a message on generate()" do
+
+ pending
+
+ customer = stub('customer')
+ customer.stub(:name).and_return('Tim')
+
+ logger = mock('logger')
+
+ statement = Tweeter.new(customer, logger)
+
+ logger.should_receive(:log).with(/Statement generated for Tim/)
+
+ statement.generate
+
+ end
+
+end

0 comments on commit bb5dd80

Please sign in to comment.
Something went wrong with that request. Please try again.