bwkfanboy 1.4.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +7 -0
  3. data/Gemfile.lock +51 -0
  4. data/Procfile +1 -0
  5. data/README.rdoc +40 -77
  6. data/Rakefile +13 -48
  7. data/bin/bwkfanboy +47 -166
  8. data/bin/bwkfanboy_generate +7 -19
  9. data/bin/bwkfanboy_parse +21 -17
  10. data/bwkfanboy.gemspec +40 -0
  11. data/config.ru +3 -0
  12. data/doc/NEWS.rdoc +21 -79
  13. data/doc/plugin.rdoc +63 -79
  14. data/etc/bwkfanboy.yaml +2 -0
  15. data/etc/sinatra.rb +34 -0
  16. data/lib/bwkfanboy/cliconfig.rb +141 -0
  17. data/lib/bwkfanboy/cliutils.rb +114 -0
  18. data/lib/bwkfanboy/fetch.rb +22 -24
  19. data/lib/bwkfanboy/generator.rb +78 -0
  20. data/lib/bwkfanboy/home.rb +53 -0
  21. data/lib/bwkfanboy/meta.rb +5 -2
  22. data/lib/bwkfanboy/plugin.rb +247 -0
  23. data/lib/bwkfanboy/plugin_skeleton.erb +19 -23
  24. data/lib/bwkfanboy/server.rb +73 -0
  25. data/lib/bwkfanboy/utils.rb +39 -129
  26. data/plugins/bwk.rb +25 -0
  27. data/plugins/econlib.rb +22 -0
  28. data/plugins/freebsd-ports-update.rb +73 -0
  29. data/plugins/inc.rb +29 -0
  30. data/plugins/test.rb +29 -0
  31. data/public/.gitattributes +1 -0
  32. data/public/favicon.ico +0 -0
  33. data/public/jquery-1.7.2.min.js +0 -0
  34. data/public/list.js +111 -0
  35. data/public/loading.gif +0 -0
  36. data/public/style.css +54 -0
  37. data/shotgun.rb +20 -0
  38. data/test/example/.gitattributes +1 -0
  39. data/test/example/.gitignore +1 -0
  40. data/test/example/02/plugins/bwk.html +0 -0
  41. data/test/{plugins → example/02/plugins}/empty.rb +0 -0
  42. data/test/example/02/plugins/garbage.rb +1 -0
  43. data/test/example/02/plugins/inc.html +0 -0
  44. data/test/helper.rb +30 -27
  45. data/test/helper_cliutils.rb +34 -0
  46. data/test/test_cli.rb +86 -0
  47. data/test/test_fetch.rb +49 -18
  48. data/test/test_generate.rb +43 -16
  49. data/test/test_home.rb +33 -0
  50. data/test/test_plugin.rb +141 -0
  51. data/test/test_server.rb +21 -32
  52. data/views/list.haml +38 -0
  53. metadata +223 -110
  54. data/bin/bwkfanboy_fetch +0 -13
  55. data/bin/bwkfanboy_server +0 -126
  56. data/doc/README.erb +0 -114
  57. data/doc/README.rdoc +0 -141
  58. data/doc/TODO +0 -7
  59. data/doc/bwkfanboy_fetch.rdoc +0 -4
  60. data/doc/bwkfanboy_generate.rdoc +0 -7
  61. data/doc/bwkfanboy_parse.rdoc +0 -7
  62. data/doc/bwkfanboy_server.rdoc +0 -35
  63. data/doc/rakefile.rb +0 -59
  64. data/lib/bwkfanboy/generate.rb +0 -63
  65. data/lib/bwkfanboy/parser.rb +0 -156
  66. data/lib/bwkfanboy/plugins/bwk.rb +0 -33
  67. data/lib/bwkfanboy/plugins/econlib.rb +0 -34
  68. data/lib/bwkfanboy/plugins/freebsd-ports-update.rb +0 -76
  69. data/lib/bwkfanboy/plugins/inc.rb +0 -37
  70. data/lib/bwkfanboy/schema.js +0 -39
  71. data/test/popen4.sh +0 -4
  72. data/test/rake_git.rb +0 -36
  73. data/test/semis/Rakefile +0 -35
  74. data/test/semis/bwk.html +0 -393
  75. data/test/semis/bwk.json +0 -82
  76. data/test/semis/econlib.html +0 -21
  77. data/test/semis/inc.html +0 -1067
  78. data/test/semis/links.txt +0 -4
  79. data/test/test_parse.rb +0 -27
  80. data/test/xml-clean.sh +0 -8
  81. data/web/bwkfanboy.cgi +0 -36
@@ -0,0 +1,34 @@
1
+ # :erb: ruby-cli
2
+ # Various staff for minitest. Include this file into your 'helper.rb'.
3
+
4
+ require 'fileutils'
5
+ include FileUtils
6
+
7
+ require_relative '../lib/bwkfanboy/cliutils'
8
+ include Bwkfanboy
9
+
10
+ require 'minitest/autorun'
11
+
12
+ # Return an absolute path of a _c_.
13
+ def cmd(c)
14
+ case File.basename(Dir.pwd)
15
+ when Meta::NAME.downcase
16
+ # test probably is executed from the Rakefile
17
+ Dir.chdir('test')
18
+ $stderr.puts('*** chdir to ' + Dir.pwd)
19
+ when 'test'
20
+ # we are in the test directory, there is nothing special to do
21
+ else
22
+ # tests were invoked by 'gem check -t bwkfanboy'
23
+ # (for a classic rubygems 1.3.7)
24
+ begin
25
+ Dir.chdir(CliUtils::DIR_LIB_SRC.parent.parent + test)
26
+ rescue
27
+ raise "running tests from '#{Dir.pwd}' isn't supported: #{$!}"
28
+ end
29
+ end
30
+
31
+ File.absolute_path('../bin/' + c)
32
+ end
33
+
34
+ # Don't remove this: falsework/2.0.0/ruby-cli/2012-03-05T05:04:11+02:00
@@ -0,0 +1,86 @@
1
+ require 'msgpack'
2
+ require 'fakefs/safe'
3
+ require 'digest/md5'
4
+
5
+ require_relative '../lib/bwkfanboy/utils'
6
+ require_relative 'helper'
7
+
8
+ class TestCLI < MiniTest::Unit::TestCase
9
+ def setup
10
+ # this runs every time before test_*
11
+ @cmd = cmd('bwkfanboy') # get path to the exe & cd to tests directory
12
+
13
+ @bwkfanboy_parse = File.dirname(@cmd) + '/bwkfanboy_parse'
14
+ @bwkfanboy_generate = File.dirname(@cmd) + '/bwkfanboy_generate'
15
+ end
16
+
17
+ def test_bwkfanboy_parse_fail
18
+ r = CliUtils.exec "echo '' | #{@bwkfanboy_parse}"
19
+ assert_equal EX_USAGE, r[0]
20
+ assert_match /bwkfanboy_parse \[options\] plugin/, r[1]
21
+
22
+ r = CliUtils.exec "echo '' | #{@bwkfanboy_parse} BUGUS-PLUGIN"
23
+ assert_equal EX_DATAERR, r[0]
24
+ assert_match /'BUGUS-PLUGIN' not found/, r[1]
25
+
26
+ r = CliUtils.exec "echo '' | #{@bwkfanboy_parse} bwk"
27
+ assert_equal EX_DATAERR, r[0]
28
+ assert_match /it ain\'t grab anything/, r[1]
29
+ end
30
+
31
+ def test_bwkfanboy_parse
32
+ r = CliUtils.exec "#{@bwkfanboy_parse} bwk < example/02/plugins/bwk.html"
33
+ assert_equal EX_OK, r[0]
34
+
35
+ raw = MessagePack.unpack r[2]
36
+ assert raw
37
+ assert_equal raw['channel']['title'], "Brian Kernighan's articles from Daily Princetonian"
38
+ assert_operator 4, :<=, raw['x_entries'].size
39
+ end
40
+
41
+ def test_bwkfanboy_generate_fail
42
+ r = CliUtils.exec "echo '' | #{@bwkfanboy_generate}"
43
+ assert_equal EX_DATAERR, r[0]
44
+ end
45
+
46
+ def test_bwkfanboy_fail
47
+ r = CliUtils.exec "#{@cmd}"
48
+ assert_equal EX_USAGE, r[0]
49
+
50
+ r = CliUtils.exec "#{@cmd} BOGUS-PLUGIN"
51
+ assert_equal EX_DATAERR, r[0]
52
+ assert_match /not found/, r[1]
53
+
54
+ r = CliUtils.exec "#{@cmd} test"
55
+ assert_equal EX_DATAERR, r[0]
56
+ assert_match /forget about additional options/, r[1]
57
+ end
58
+
59
+ def test_bwkfanboy
60
+ r = CliUtils.exec "#{@cmd} test foo bar"
61
+ assert_equal EX_OK, r[0]
62
+ end
63
+
64
+ def test_skeleton
65
+ skel = File.read '../lib/bwkfanboy/plugin_skeleton.erb'
66
+ FakeFS do
67
+ File.open('skel.erb', 'w+') {|fp| fp.write skel }
68
+
69
+ Utils.skeletonCreate 'skel.erb', '1'
70
+ m1 = Digest::MD5.file('1').hexdigest
71
+ Utils.skeletonCreate 'skel.erb', '1'
72
+ m2 = Digest::MD5.file('1').hexdigest
73
+ assert_equal m1, m2
74
+
75
+ File.open('1', 'w+') {|fp| fp.write 'fffffuuuu' }
76
+ m3 = Digest::MD5.file('1').hexdigest
77
+ out, err = capture_io { Utils.skeletonCreate 'skel.erb', '1' }
78
+ assert_match /1 already exists/, err
79
+ m4 = Digest::MD5.file('1').hexdigest
80
+ assert_equal m3, m4
81
+
82
+ refute_equal m1, m4
83
+ end
84
+ end
85
+
86
+ end
@@ -1,28 +1,59 @@
1
+ require 'stringio'
2
+
1
3
  require_relative 'helper'
4
+ require_relative '../lib/bwkfanboy/plugin'
5
+ require_relative '../lib/bwkfanboy/fetch'
2
6
 
3
- # TODO add HTTP 404 check; drop connection from server during HTTP 200
4
- # replay...
5
7
  class TestFetch < MiniTest::Unit::TestCase
6
- CMD = cmd('bwkfanboy_fetch')
8
+
9
+ def setup
10
+ # this runs every time before test_*
11
+ @cmd = cmd('bwkfanboy') # get path to the exe & cd to tests directory
7
12
 
8
- def test_empty_url
9
- r = Utils.cmd_run("echo '' | #{CMD}")
10
- assert_equal(1, r[0])
11
- assert_match(/No such file or directory/, r[1])
13
+ ENV['BWKFANBOY_CONF'] = ''
14
+ @h = Home.new('example/02')
12
15
  end
13
16
 
14
- def test_invalid_url
15
- r = Utils.cmd_run("echo 'http://invalid.hostname.qwerty' | #{CMD}")
16
- assert_equal(1, r[0])
17
- assert_match(/504 Host .+ lookup failed: Host not found/, r[1])
17
+ def test_fetch
18
+ url1 = @h.root + Home::PLUGINS + 'bwk.html'
19
+
20
+ streams = Fetch.openStreams [url1, url1]
21
+ assert_equal 2, streams.size
22
+ assert streams.sample.is_a?(File)
23
+
24
+ # stream in an array is readale
25
+ rs = streams.sample
26
+ assert_operator 500, :<, rs.read.size
27
+ rs.rewind
28
+
29
+ # open plugin with 1 stream only
30
+ p0 = Plugin.new @h.conf[:plugins_path], 'bwk', []
31
+ assert p0
32
+ p0.run_parser [streams.sample]
33
+
34
+ # open the same plugin with 2 streams
35
+ streams_other = Fetch.openStreams [url1, url1]
36
+ all = Plugin.new @h.conf[:plugins_path], 'bwk', []
37
+ assert all
38
+ all.run_parser streams_other
39
+
40
+ assert_operator p0.size, :<, all.size
41
+
42
+ Fetch.closeStreams streams
18
43
  end
19
44
 
20
- def test_local_file
21
- cmd CMD
22
- r = Utils.cmd_run("echo semis/bwk.html | #{CMD}")
23
- assert_equal(0, r[0])
24
- # MD5 (html/bwk.html) = c8259a358dd7261a79b226985d3e8753
25
- assert_equal(Digest::MD5.hexdigest(r[2]), '00cc906c59c0eb11c3eaa8166dab729f')
45
+ def test_fetch_fail
46
+ refute Fetch.openStreams(nil)
47
+
48
+ e = assert_raises(FetchException) { Fetch.openStreams [] }
49
+ assert_match /failed to open at least 1/, e.message
50
+
51
+ e = assert_raises(FetchException) { Fetch.openStreams [nil] }
52
+ assert_match /can\'t convert nil into String/, e.message
53
+
54
+ e = assert_raises(FetchException) {
55
+ Fetch.openStreams ["/FILE/DOESN'T/EXIST"]
56
+ }
57
+ assert_match /No such file or directory/, e.message
26
58
  end
27
-
28
59
  end
@@ -1,24 +1,51 @@
1
+ require 'stringio'
2
+
1
3
  require_relative 'helper'
4
+ require_relative '../lib/bwkfanboy/plugin'
5
+ require_relative '../lib/bwkfanboy/generator'
2
6
 
3
7
  class TestGenerate < MiniTest::Unit::TestCase
4
- CMD = cmd('bwkfanboy_generate')
5
-
6
- def test_empty_input
7
- r = Utils.cmd_run("echo '' | #{CMD}")
8
- assert_equal(1, r[0])
9
- assert_match(/stdin had invalid JSON/, r[1])
8
+ def setup
9
+ # this runs every time before test_*
10
+ @cmd = cmd('bwkfanboy') # get path to the exe & cd to tests directory
11
+
12
+ ENV['BWKFANBOY_CONF'] = ''
13
+ @h = Home.new('example/02')
14
+ end
15
+
16
+ def test_atom
17
+ stream = [StringIO.new(File.read(@h.root + Home::PLUGINS + 'bwk.html'))]
18
+ p = Plugin.new @h.conf[:plugins_path], 'bwk', {}
19
+ p.run_parser stream
20
+
21
+ raw = StringIO.new ''
22
+ p.pack raw
23
+ raw.rewind
24
+
25
+ data = Generator.unpack raw
26
+ # pp data
27
+ r = Generator.atom data
28
+ # pp r
29
+ doc = Nokogiri::HTML r.to_s
30
+ assert_equal("Brian Kernighan's articles from Daily Princetonian",
31
+ doc.xpath('//feed/title').text)
10
32
  end
11
-
12
- def test_invalid_json
13
- r = Utils.cmd_run("echo '{\"foo\" : \"bar\"}' | #{CMD} --check")
14
- assert_equal(1, r[0])
15
- assert_match(/channel:? is missing and it is not optional/, r[1])
33
+
34
+ def test_atom_fail
35
+ e = assert_raises(GeneratorException) { Generator.atom nil }
36
+ assert_match /input is nil/, e.message
37
+
38
+ e = assert_raises(GeneratorException) { Generator.atom [1,2] }
39
+ assert_match /can\'t convert String into Integer/, e.message
16
40
  end
17
41
 
18
- def test_right_json
19
- r = Utils.cmd_run("#{CMD} --check < semis/bwk.json")
20
- assert_equal(0, r[0])
21
- # bin/bwkfanboy_generate < test/semis/bwk.json|md5
22
- assert_equal('adc5a0d9487bdc11b6896fe29745ffa3', Digest::MD5.hexdigest(r[2]))
42
+ def test_unpack
43
+ refute Generator.unpack(nil)
44
+
45
+ raw = StringIO.new ''
46
+ refute Generator.unpack(raw)
47
+
48
+ raw = StringIO.new MessagePack.pack([1,2,3])
49
+ assert_equal [1,2,3], Generator.unpack(raw)
23
50
  end
24
51
  end
@@ -0,0 +1,33 @@
1
+ require_relative 'helper'
2
+
3
+ require_relative '../lib/bwkfanboy/home'
4
+
5
+ class TestHome < MiniTest::Unit::TestCase
6
+ def setup
7
+ # this runs every time before test_*
8
+ @cmd = cmd('bwkfanboy') # get path to the exe & cd to tests directory
9
+
10
+ rm_rf 'example/01'
11
+ ENV['BWKFANBOY_CONF'] = ''
12
+ end
13
+
14
+ def test_home_dirs
15
+ h = Home.new 'example/01'
16
+ assert_equal 'example/01/log', h.logs.to_s
17
+ assert_equal 'example/01/plugins', h.conf[:plugins_path].first.to_s
18
+ assert_equal 2, h.conf[:plugins_path].size
19
+ assert File.readable?(h.root)
20
+ assert File.readable?(h.conf[:plugins_path].first.to_s)
21
+ assert File.readable?(h.logs)
22
+ end
23
+
24
+ def test_home_opts
25
+ ENV['BWKFANBOY_CONF'] = '-I /tmp -I /bin -I /INVALID-DIR --zzz "later on"'
26
+ h = Home.new('example/01') {|loader, o|
27
+ o.on('--zzz ARG', 'zzz') {|i| loader.conf[:zzz] = i }
28
+ }
29
+ assert_equal(['example/01/plugins', Home::SYSTEM_PLUGINS.to_s, '/tmp', '/bin'],
30
+ h.conf[:plugins_path].map(&:to_s) )
31
+ assert_equal 'later on', h.conf[:zzz]
32
+ end
33
+ end
@@ -0,0 +1,141 @@
1
+ require 'stringio'
2
+
3
+ require_relative 'helper'
4
+ require_relative '../lib/bwkfanboy/home'
5
+ require_relative '../lib/bwkfanboy/plugin'
6
+
7
+ class TestPlugin < MiniTest::Unit::TestCase
8
+ def setup
9
+ # this runs every time before test_*
10
+ @cmd = cmd('bwkfanboy') # get path to the exe & cd to tests directory
11
+
12
+ ENV['BWKFANBOY_CONF'] = ''
13
+ @h = Home.new('example/02')
14
+ end
15
+
16
+ def test_allset
17
+ assert_equal false, BH.all_set?([])
18
+ assert_equal false, BH.all_set?(nil)
19
+ assert_equal false, BH.all_set?('')
20
+ assert_equal false, BH.all_set?(' ')
21
+ assert_equal false, BH.all_set?([1,2, ''])
22
+ assert_equal false, BH.all_set?([1,2, nil])
23
+ assert_equal true, BH.all_set?(1)
24
+ assert_equal true, BH.all_set?('1')
25
+ end
26
+
27
+ def test_entryMostRecent
28
+ stream = [StringIO.new(File.read(@h.root + Home::PLUGINS + 'bwk.html'))]
29
+ p = Plugin.new @h.conf[:plugins_path], 'bwk', []
30
+ p.run_parser stream
31
+
32
+ # p.each {|i| puts i[:updated]}
33
+ assert_equal '2012-03-12T00:00:00+00:00', p.entryMostRecent
34
+
35
+ p[rand(0..3)]['updated'] = '2042-03-12T00:00:00+00:00'
36
+ assert_equal '2042-03-12T00:00:00+00:00', p.entryMostRecent
37
+ end
38
+
39
+ def test_load_ok
40
+ stream = [StringIO.new(File.read(@h.root + Home::PLUGINS + 'bwk.html'))]
41
+ p1 = Plugin.new @h.conf[:plugins_path], 'bwk', []
42
+ assert(p1)
43
+ p1.run_parser stream
44
+
45
+ assert_match /^http:\/\/\S+/, p1[2]['link']
46
+ assert DateTime.parse(p1[2]['updated'])
47
+
48
+ ['title', 'author', 'content'].each {|i|
49
+ assert_operator 0, :<, p1[2][i].size
50
+ }
51
+
52
+ assert_operator 4, :<=, p1.size
53
+ end
54
+
55
+ def test_load_failed
56
+ e = assert_raises(PluginException) { Plugin.new nil, 'foo', [] }
57
+ assert_match /invalid search path/, e.message
58
+
59
+ e = assert_raises(PluginInvalidName) { Plugin.new nil, 'BOGUS PLUGIN', [] }
60
+ assert_match /name doesn\'t match/, e.message
61
+
62
+ e = assert_raises(PluginNotFound) {
63
+ Plugin.new @h.conf[:plugins_path], 'BOGUS-PLUGIN', []
64
+ }
65
+ assert_match /not found/, e.message
66
+
67
+ e = assert_raises(PluginException) {
68
+ p = Plugin.new @h.conf[:plugins_path], 'bwk', []
69
+ p.run_parser nil
70
+ }
71
+ assert_match /parser expects a valid array of IO objects/, e.message
72
+
73
+ stream = [StringIO.new("")]
74
+ p = Plugin.new @h.conf[:plugins_path], 'bwk', []
75
+ assert(p)
76
+ e = assert_raises(PluginException) { p.run_parser stream }
77
+ assert_match /it ain\'t grab anything/, e.message
78
+
79
+ stream = [StringIO.new("fffffuuuuuuu")]
80
+ p = Plugin.new @h.conf[:plugins_path], 'bwk', []
81
+ assert(p)
82
+ e = assert_raises(PluginException) { p.run_parser stream }
83
+ assert_match /it ain\'t grab anything/, e.message
84
+ end
85
+
86
+ def test_broken_plugins
87
+ streams = [StringIO.new(File.read(@h.root + Home::PLUGINS + 'bwk.html'))]
88
+ e = assert_raises(PluginNoOptions) {
89
+ Plugin.new @h.conf[:plugins_path], 'empty', []
90
+ }
91
+ assert_match /forget about additional options/, e.message
92
+
93
+ e = assert_raises(PluginException) {
94
+ Plugin.new @h.conf[:plugins_path], 'empty', [1,2,3]
95
+ }
96
+ assert_match /uri must be an array of strings/, e.message
97
+
98
+ e = assert_raises(PluginException) {
99
+ p = Plugin.new @h.conf[:plugins_path], 'garbage', []
100
+ }
101
+ assert_match /failed to parse/, e.message
102
+ end
103
+
104
+ def test_plugin_with_opt
105
+ streams = [StringIO.new(File.read(@h.root + Home::PLUGINS + 'inc.html')),
106
+ StringIO.new(File.read(@h.root + Home::PLUGINS + 'inc.html'))]
107
+
108
+ e = assert_raises(PluginNoOptions) {
109
+ Plugin.new @h.conf[:plugins_path], 'inc', []
110
+ }
111
+ assert_match /forget about additional options/, e.message
112
+
113
+ rs = streams.sample
114
+ p1 = Plugin.new @h.conf[:plugins_path], 'inc', [1]
115
+ p1.run_parser [rs]
116
+ rs.rewind
117
+
118
+ p2 = Plugin.new @h.conf[:plugins_path], 'inc', [1,2]
119
+ p2.run_parser streams
120
+
121
+ assert_operator p1.size, :<, p2.size
122
+ end
123
+
124
+ def test_PluginInfo_about
125
+ e = assert_raises(PluginException) { PluginInfo.about nil, 'foo', nil }
126
+ assert_match /invalid search path/, e.message
127
+
128
+ e = assert_raises(PluginNotFound) {
129
+ PluginInfo.about @h.conf[:plugins_path], 'BOGUS-PLUGIN', nil
130
+ }
131
+ assert_match /not found/, e.message
132
+
133
+ out, err = capture_io {
134
+ PluginInfo.about @h.conf[:plugins_path], 'bwk', nil
135
+ }
136
+ out.split("\n")[0..3].each {|i|
137
+ assert_match /^[A-Z]+ *: .+/, i
138
+ }
139
+
140
+ end
141
+ end
@@ -1,44 +1,33 @@
1
- require 'open-uri'
1
+ require 'rack/test'
2
2
 
3
3
  require_relative 'helper'
4
+ require_relative '../lib/bwkfanboy/server'
4
5
 
5
- $count = 1
6
-
7
- # this tests will mess up logs and the pid file
8
6
  class TestServer < MiniTest::Unit::TestCase
9
- CMD = cmd('bwkfanboy_server')
10
- PORT = 9042
11
- ADDR = '127.0.0.1'
7
+ include Rack::Test::Methods
12
8
 
13
- def setup
14
- @port = PORT + $count
15
- @pid = spawn("#{CMD} -D -p #{@port}")
16
- $count += 1
17
- sleep(2) # wait for the server's loading
9
+ def app
10
+ MyApp
18
11
  end
12
+
13
+ def setup
14
+ # this runs every time before test_*
15
+ @cmd = cmd('bwkfanboy') # get path to the exe & cd to tests directory
19
16
 
20
- def teardown
21
- Process.kill("TERM", @pid)
17
+ ENV['BWKFANBOY_CONF'] = ''
22
18
  end
23
-
24
- def test_no_plugin
25
- assert_raises(OpenURI::HTTPError) { open("http://#{ADDR}:#{@port}") }
26
- assert_raises(OpenURI::HTTPError) { open("http://#{ADDR}:#{@port}/?p=INVALID") }
27
- # 'o' is missing
28
- assert_raises(OpenURI::HTTPError) { open("http://#{ADDR}:#{@port}/?p=inc") }
19
+
20
+ def test_list
21
+ get '/'
22
+ assert last_response.ok?
23
+ assert_match /Plugins List/, last_response.body
29
24
  end
30
25
 
31
- def test_right_plugins
32
- plugins = {
33
- 'bwk' => '64186fac2c52e5a969ad5675b9cc95ed',
34
- 'econlib' => '11f6114a9ab54d6ec67a26cbd76f5260',
35
- 'inc' => '13dae248c81dd6407ff327dd5575f8b5',
36
- }
37
- plugins.each {|k,v|
38
- r = ''
39
- open("http://#{ADDR}:#{@port}/?p=#{k}&o=foo") { |f| r = f.read }
40
- # wget -q -O - '127.0.0.1:9042/?p=inc&o=foo' | md5
41
- assert_equal(v, Digest::MD5.hexdigest(r))
42
- }
26
+ def test_plugin_test
27
+ get '/test?o=foo&o=bar'
28
+ assert last_response.ok?
29
+ assert_operator 100, :<, last_response.header['Content-Length'].to_i
30
+ assert_equal 'application/atom+xml; charset=UTF-8', last_response.header['Content-Type']
43
31
  end
32
+
44
33
  end