File: akismet_test.rb

package info (click to toggle)
ruby-akismet 2.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 124 kB
  • ctags: 62
  • sloc: ruby: 380; makefile: 3
file content (42 lines) | stat: -rw-r--r-- 800 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require 'test_helper'

class AkismetTest < Test

  def setup
    Akismet.api_key = API_KEY
    Akismet.app_url = 'http://example.com'
  end

  [:spam?, :check, :spam, :ham].each do |method|
    define_method("test_#{method}_succeeds") do
      Akismet.send method, 'ip', 'ua'
    end
  end

  def test_check_raises_if_api_key_not_set
    Akismet.api_key = nil
    assert_raises(RuntimeError) do
      Akismet.check 'ip', 'ua'
    end
  end

  def test_check_raises_if_app_url_not_set
    Akismet.app_url = nil
    assert_raises(RuntimeError) do
      Akismet.check 'ip', 'ua'
    end
  end

  def test_open_succeeds
    Akismet.open do |client|
      client.check 'ip', 'ua'
    end
  end

  def test_open_raises_without_block
    assert_raises(RuntimeError) do
      Akismet.open
    end
  end

end