class LuosimaoTest

Public Instance Methods

setup() click to toggle source
# File lib/test/test_luosimao.rb, line 6
def setup
        Luosimao.username = "your_username"
        Luosimao.key = "your_key"
        Luosimao.brand = "your_brand"
        @right_phone = "10086"
        @wrong_phone = "020"
        @right_msg = "hello world"
        @empty_msg = ""
        @sensitive_msg = "共产党"
end
test_check_deposit() click to toggle source
# File lib/test/test_luosimao.rb, line 37
def test_check_deposit
        assert_equal Luosimao::Message.deposit_check["error"], 0
end
test_fail_check_deposit() click to toggle source
# File lib/test/test_luosimao.rb, line 41
def test_fail_check_deposit
        Luosimao.key = "testkey"
        assert_equal Luosimao::Message.deposit_check["error"], -10
end
test_send_empty_message() click to toggle source
# File lib/test/test_luosimao.rb, line 26
def test_send_empty_message
        temp = Luosimao.brand
        Luosimao.brand = ''
        assert_equal Luosimao::Message.to(@right_phone, @empty_msg)["error"], -30
        Luosimao.brand = temp
end
test_send_right_message() click to toggle source
# File lib/test/test_luosimao.rb, line 21
def test_send_right_message
        assert_equal Luosimao::Message.to(@right_phone, @right_msg),
                {"error" => 0, "msg" => "ok"}
end
test_send_sensitive_message() click to toggle source
# File lib/test/test_luosimao.rb, line 33
def test_send_sensitive_message
        assert_equal Luosimao::Message.to(@right_phone, @sensitive_msg)["error"], -31
end
test_send_to_wrong_phone() click to toggle source
# File lib/test/test_luosimao.rb, line 17
def test_send_to_wrong_phone
        assert_equal Luosimao::Message.to(@wrong_phone, @right_msg)["error"], -40
end