Sha256: 6183e676c35f5c9d87a699e9e89112d42ef97483e1bcd09e693d5a0514042b49

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require "test_helper"
require 'httparty'

module Messenger

  class NotifoTest < Test::Unit::TestCase

    context "Notifo notification" do
      should "post a successful message" do
        stub_request(:post, "https://api.notifo.com/v1/send_notification").to_return(:status => 200)
        result = Notifo.send("notifo://testuser", 'message')
        assert result.success?
      end

      should "post a failed message" do
        stub_request(:post, "https://api.notifo.com/v1/send_notification").to_return(:status => 400)
        result = Notifo.send("notifo://testuser", 'message')
        assert !result.success?
      end

      should "raise when sending to an invalid URL" do
        assert_raises URLError do
          Notifo.send("notifo://", 'message')
        end
      end
    end

    context "Notifo URL validation" do
      should "return true for good URLs" do
        assert true, Notifo.valid_url?("notifo://testuser")
      end

      should "return false for bad URLs" do
        assert_equal false, Notifo.valid_url?("notifo://")
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
messenger-0.2.0 test/test_notifo.rb