Sha256: 0ebf8d32daf9b17d20908b9de283968cb0d81cfcc90e32d507d6aa4187679f01

Contents?: true

Size: 1.45 KB

Versions: 3

Compression:

Stored size: 1.45 KB

Contents

require "#{File.dirname(__FILE__)}/test_helper"
require 'httparty'

module Messenger

  class CampfireTest < Test::Unit::TestCase

    context "Campfire notification" do
      setup do
        @success_response = stub("response", :code => 200)
        @failure_response = stub("response", :code => 500)
      end

      should "post a successful message" do
        HTTParty.expects(:post).with("http://subdomain.campfirenow.com/room/room/speak.json", :basic_auth => { :username => 'api', :password => 'x' }, :body => '{"message":{"body":"content"}}', :headers => { "Content-Type" => "application/json" }).returns(@success_response)
        result = Campfire.send("campfire://api:room@subdomain.campfirewnow.com", 'content')
        assert_equal [true, @success_response], result
      end

      should "post a failed message" do
        HTTParty.expects(:post).with("http://subdomain.campfirenow.com/room/room/speak.json", :basic_auth => { :username => 'api', :password => 'x' }, :body => '{"message":{"body":"content"}}', :headers => { "Content-Type" => "application/json" }).returns(@failure_response)
        result = Campfire.send("campfire://api:room@subdomain.campfirewnow.com", 'content')
        assert_equal [false, @failure_response], result
      end

      should "raise on invalid URL" do
        assert_raises Messenger::URLError do
          Campfire.send("campfire://missing_room@subdomain.campfirewnow.com", 'content')
        end
      end
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
messenger-0.0.3 test/test_campfire.rb
messenger-0.0.2 test/test_campfire.rb
messenger-0.0.1 test/test_campfire.rb