tumblr_publish_agent_spec.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. require 'spec_helper'
  2. describe Agents::TumblrPublishAgent do
  3. before do
  4. @opts = {
  5. :blog_name => "huginnbot.tumblr.com",
  6. :post_type => "text",
  7. :expected_update_period_in_days => "2",
  8. :options => {
  9. :title => "{{title}}",
  10. :body => "{{body}}",
  11. },
  12. }
  13. @checker = Agents::TumblrPublishAgent.new(:name => "HuginnBot", :options => @opts)
  14. @checker.service = services(:generic)
  15. @checker.user = users(:bob)
  16. @checker.save!
  17. @event = Event.new
  18. @event.agent = agents(:bob_weather_agent)
  19. @event.payload = { :title => "Gonna rain...", :body => 'San Francisco is gonna get wet' }
  20. @event.save!
  21. stub.any_instance_of(Agents::TumblrPublishAgent).tumblr {
  22. stub!.text(anything, anything) { { "id" => "5" } }
  23. }
  24. end
  25. describe '#receive' do
  26. it 'should publish any payload it receives' do
  27. Agents::TumblrPublishAgent.async_receive(@checker.id, [@event.id])
  28. expect(@checker.events.count).to eq(1)
  29. expect(@checker.events.first.payload['post_id']).to eq('5')
  30. expect(@checker.events.first.payload['published_post']).to eq('[huginnbot.tumblr.com] text')
  31. end
  32. end
  33. end