ape 1.5.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,56 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ require 'rexml/document'
4
+
5
+ class CollElementTest < Test::Unit::TestCase
6
+
7
+ def test_accept
8
+ # no <accept> should accept only application/atom+xml;type=entry
9
+ c = make_coll('')
10
+ assert(c.accept?(Ape::Names::AtomEntryMediaType))
11
+ assert(!c.accept?(Ape::Names::AtomMediaType))
12
+ assert(!c.accept?(Ape::Names::AtomFeedMediaType))
13
+ assert(!c.accept?(Ape::Names::AppMediaType))
14
+ assert(!c.accept?('image/jpeg'))
15
+ assert(!c.accept?('text/plain'))
16
+
17
+ # */* should accept anything
18
+ types = [ Ape::Names::AtomEntryMediaType, Ape::Names::AtomMediaType,
19
+ Ape::Names::AtomFeedMediaType, Ape::Names::AppMediaType,
20
+ 'image/jpeg', 'text/plain'
21
+ ]
22
+ c = make_coll('*/*')
23
+ types.each { |t| assert(c.accept?(t))}
24
+
25
+ # ... even if it's got something else in front of it
26
+ c = make_coll('image/jpeg', '*/*')
27
+ types.each { |t| assert(c.accept?(t))}
28
+ assert(c.accept?('image/jpeg'))
29
+
30
+ # .. shouldn't accept anything but one type
31
+ c = make_coll('audio/mp3')
32
+ types.each { |t| assert(!c.accept?(t))}
33
+ assert(c.accept?('audio/mp3'))
34
+
35
+ # image/*
36
+ c = make_coll('image/*')
37
+ ['jpeg', 'png', 'gif'].each {|sub| assert(c.accept?("image/#{sub}"))}
38
+ [ Ape::Names::AtomEntryMediaType, Ape::Names::AtomMediaType,
39
+ Ape::Names::AtomFeedMediaType, Ape::Names::AppMediaType,
40
+ 'text/plain' ].each {|t| assert(!c.accept?(t))}
41
+
42
+ end
43
+
44
+ private
45
+
46
+ def make_coll(*accepts)
47
+ front = '<collection xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom">
48
+ <atom:title>X</atom:title>'
49
+ back = "</collection>"
50
+ r = front
51
+ accepts.each { |a| r += "<accept>#{a}</accept>" }
52
+ r += back
53
+ r = REXML::Document.new(r).root
54
+ Ape::CollElement.new(r)
55
+ end
56
+ end
@@ -0,0 +1,43 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ require 'rexml/document'
4
+
5
+ class CollectionTest < Test::Unit::TestCase
6
+
7
+ def test_make_rake_shut_up
8
+ assert(true, "WIll fill some tests in when I look at Collection")
9
+ end
10
+
11
+ # def test_post_require_data
12
+ # assert_raise(StandardError) { stub_coll.post() }
13
+ # end
14
+
15
+ # def test_post_should_matches_content_type
16
+ # assert_raise(StandardError) { stub_coll.post(:data => 'asdfsadf', :type => 'image/png') }
17
+ # end
18
+
19
+ # def test_post_method_returns_poster
20
+ # assert_not_nil(stub_coll.post(:data => 'asdf'))
21
+ # end
22
+
23
+ # private
24
+ # def stub_coll
25
+ # post = Ape::Poster.new('http://localhost', nil)
26
+ # post.stubs(:post).returns(true)
27
+ #
28
+ # coll = make_coll(Ape::Names::AtomEntryMediaType)
29
+ # coll.stubs(:poster).returns(post)
30
+ # coll
31
+ # end
32
+
33
+ # def make_coll(*accepts)
34
+ # front = '<collection xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom">
35
+ # <atom:title>X</atom:title>'
36
+ # back = "</collection>"
37
+ # r = front
38
+ # accepts.each { |a| r += "<accept>#{a}</accept>" }
39
+ # r += back
40
+ # r = REXML::Document.new(r).root
41
+ # Ape::CollElement.new(r)
42
+ # end
43
+ end
@@ -22,4 +22,10 @@ class InvokerTest < Test::Unit::TestCase
22
22
  end
23
23
  end
24
24
  end
25
+
26
+ def test_post_header_setted
27
+ poster = Ape::Poster.new('http://localhost', nil)
28
+ poster['Slug'] = 'the slug header'
29
+ assert_equal('the slug header', poster['Slug'])
30
+ end
25
31
  end
@@ -4,7 +4,7 @@ require 'rexml/document'
4
4
  class SamplesTest < Test::Unit::TestCase
5
5
 
6
6
  def test_ape_home
7
- assert_match(/[.]ape$/, Ape::Ape.home)
7
+ assert_match(/[.]ape$/, ::Ape.home)
8
8
  end
9
9
 
10
10
  def test_load_service_schema
@@ -0,0 +1,47 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ class ServiceTest < Test::Unit::TestCase
4
+ def test_new_service_instance_raises_not_found_error
5
+ assert_raise(StandardError) {
6
+ Ape::Service.new(:uri => 'http://localhost/atomPub')
7
+ }
8
+ end
9
+
10
+ def test_service_each_gets_entry_collection
11
+ service_doc = load_service
12
+ titles = []
13
+ service_doc.collections.each do |collection|
14
+ titles << collection.title if collection.accept?(Ape::Names::AtomEntryMediaType)
15
+ end
16
+ assert_equal(['Posts', 'Comments'], titles)
17
+ end
18
+
19
+ def test_service_each_gets_all_collections
20
+ service_doc = load_service
21
+ titles = []
22
+ service_doc.collections.each do |collection|
23
+ titles << collection.title
24
+ end
25
+ assert_equal(4, titles.size)
26
+ end
27
+
28
+ def test_service_each_gets_none_collections
29
+ service_doc = load_service
30
+ titles = []
31
+ service_doc.collections.each do |collection|
32
+ titles << collection.title if collection.accept?('video/*')
33
+ end
34
+ assert_equal(0, titles.size)
35
+ end
36
+
37
+ def load_service
38
+ service_doc = Ape::Service.new
39
+ service_doc.service = service {
40
+ collection('Posts') +
41
+ collection('Comments') +
42
+ collection('Attachments', ['image/jpg']) +
43
+ collection('Attachments2', ['image/png'])
44
+ }
45
+ service_doc
46
+ end
47
+ end
@@ -1,7 +1,7 @@
1
1
  <html>
2
2
  <head>
3
3
  <title>Atom Protocol Exerciser</title>
4
- <link rel='stylesheet' type='text/css' href='/layout/ape.css' />
4
+ <link rel='stylesheet' type='text/css' href='ape.css' />
5
5
  <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/>
6
6
  </head>
7
7
  <body>
metadata CHANGED
@@ -1,19 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ape
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Bray
8
+ - David Calavera
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
 
12
- date: 2008-07-04 00:00:00 +02:00
13
+ date: 2009-10-27 00:00:00 +01:00
13
14
  default_executable:
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: rake
18
+ type: :runtime
17
19
  version_requirement:
18
20
  version_requirements: !ruby/object:Gem::Requirement
19
21
  requirements:
@@ -23,6 +25,7 @@ dependencies:
23
25
  version:
24
26
  - !ruby/object:Gem::Dependency
25
27
  name: mongrel
28
+ type: :runtime
26
29
  version_requirement:
27
30
  version_requirements: !ruby/object:Gem::Requirement
28
31
  requirements:
@@ -32,6 +35,7 @@ dependencies:
32
35
  version:
33
36
  - !ruby/object:Gem::Dependency
34
37
  name: erubis
38
+ type: :runtime
35
39
  version_requirement:
36
40
  version_requirements: !ruby/object:Gem::Requirement
37
41
  requirements:
@@ -41,6 +45,7 @@ dependencies:
41
45
  version:
42
46
  - !ruby/object:Gem::Dependency
43
47
  name: rubyforge
48
+ type: :runtime
44
49
  version_requirement:
45
50
  version_requirements: !ruby/object:Gem::Requirement
46
51
  requirements:
@@ -50,6 +55,7 @@ dependencies:
50
55
  version:
51
56
  - !ruby/object:Gem::Dependency
52
57
  name: mocha
58
+ type: :runtime
53
59
  version_requirement:
54
60
  version_requirements: !ruby/object:Gem::Requirement
55
61
  requirements:
@@ -58,7 +64,9 @@ dependencies:
58
64
  version: 0.9.0
59
65
  version:
60
66
  description:
61
- email: tim.bray@sun.com
67
+ email:
68
+ - tim.bray@sun.com
69
+ - calavera@apache.org
62
70
  executables:
63
71
  - ape_server
64
72
  extensions: []
@@ -67,74 +75,74 @@ extra_rdoc_files:
67
75
  - README
68
76
  - LICENSE
69
77
  files:
70
- - lib/ape.rb
71
- - lib/ape
72
- - lib/ape/feed.rb
73
- - lib/ape/categories.rb
74
- - lib/ape/names.rb
75
- - lib/ape/crumbs.rb
76
78
  - lib/ape/server.rb
77
- - lib/ape/service.rb
78
79
  - lib/ape/collection.rb
79
- - lib/ape/validator_dsl.rb
80
- - lib/ape/reporter.rb
81
- - lib/ape/util.rb
82
- - lib/ape/invokers
83
- - lib/ape/invokers/poster.rb
84
- - lib/ape/invokers/getter.rb
80
+ - lib/ape/print_writer.rb
81
+ - lib/ape/samples.rb
85
82
  - lib/ape/invokers/deleter.rb
83
+ - lib/ape/invokers/getter.rb
84
+ - lib/ape/invokers/poster.rb
86
85
  - lib/ape/invokers/putter.rb
86
+ - lib/ape/reporter.rb
87
+ - lib/ape/escaper.rb
87
88
  - lib/ape/atomURI.rb
89
+ - lib/ape/categories.rb
90
+ - lib/ape/invoker.rb
91
+ - lib/ape/validator_dsl.rb
92
+ - lib/ape/version.rb
93
+ - lib/ape/coll_element.rb
94
+ - lib/ape/feed.rb
95
+ - lib/ape/service.rb
96
+ - lib/ape/auth/google_login_credentials.rb
97
+ - lib/ape/auth/wsse_credentials.rb
98
+ - lib/ape/authent.rb
88
99
  - lib/ape/entry.rb
89
- - lib/ape/validators
100
+ - lib/ape/handler.rb
101
+ - lib/ape/reporters/html_template.eruby
102
+ - lib/ape/reporters/html_reporter.rb
103
+ - lib/ape/reporters/atom_reporter.rb
104
+ - lib/ape/reporters/text_reporter.rb
105
+ - lib/ape/reporters/atom_template.eruby
106
+ - lib/ape/crumbs.rb
107
+ - lib/ape/util.rb
108
+ - lib/ape/names.rb
109
+ - lib/ape/validator.rb
90
110
  - lib/ape/validators/entry_posts_validator.rb
111
+ - lib/ape/validators/media_posts_validator.rb
112
+ - lib/ape/validators/service_document_validator.rb
91
113
  - lib/ape/validators/sanitization_validator.rb
92
- - lib/ape/validators/schema_validator.rb
93
114
  - lib/ape/validators/media_linkage_validator.rb
94
- - lib/ape/validators/service_document_validator.rb
95
- - lib/ape/validators/media_posts_validator.rb
96
115
  - lib/ape/validators/sorting_validator.rb
97
- - lib/ape/print_writer.rb
98
- - lib/ape/auth
99
- - lib/ape/auth/wsse_credentials.rb
100
- - lib/ape/auth/google_login_credentials.rb
101
- - lib/ape/escaper.rb
102
- - lib/ape/authent.rb
103
- - lib/ape/version.rb
104
- - lib/ape/validator.rb
105
- - lib/ape/reporters
106
- - lib/ape/reporters/atom_template.eruby
107
- - lib/ape/reporters/atom_reporter.rb
108
- - lib/ape/reporters/text_reporter.rb
109
- - lib/ape/reporters/html_template.eruby
110
- - lib/ape/reporters/html_reporter.rb
111
- - lib/ape/samples.rb
112
- - lib/ape/invoker.rb
113
- - lib/ape/handler.rb
116
+ - lib/ape/validators/schema_validator.rb
114
117
  - lib/ape/html.rb
115
- - samples/basic_entry.eruby
116
- - samples/categories_schema.txt
118
+ - lib/ape.rb
117
119
  - samples/service_schema.txt
118
- - samples/mini_entry.eruby
119
120
  - samples/atom_schema.txt
120
121
  - samples/unclean_xhtml_entry.eruby
121
- - test/unit
122
- - test/unit/samples_test.rb
123
- - test/unit/validators_test.rb
124
- - test/unit/invoker_test.rb
122
+ - samples/basic_entry.eruby
123
+ - samples/categories_schema.txt
124
+ - samples/mini_entry.eruby
125
+ - test/test_helper.rb
125
126
  - test/unit/reporter_test.rb
127
+ - test/unit/invoker_test.rb
126
128
  - test/unit/ape_test.rb
129
+ - test/unit/samples_test.rb
130
+ - test/unit/collection_test.rb
131
+ - test/unit/coll_element_test.rb
132
+ - test/unit/validators_test.rb
133
+ - test/unit/service_test.rb
127
134
  - test/unit/authent_test.rb
128
- - test/test_helper.rb
129
- - web/info.png
130
- - web/ape_logo.png
131
135
  - web/ape.css
136
+ - web/ape_logo.png
132
137
  - web/index.html
138
+ - web/info.png
133
139
  - README
134
140
  - LICENSE
135
141
  - Rakefile
136
- has_rdoc: false
137
- homepage: ape.rubyforge.org
142
+ has_rdoc: true
143
+ homepage: http://ape.rubyforge.org
144
+ licenses: []
145
+
138
146
  post_install_message:
139
147
  rdoc_options: []
140
148
 
@@ -155,9 +163,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
163
  requirements: []
156
164
 
157
165
  rubyforge_project: ape
158
- rubygems_version: 1.1.1
166
+ rubygems_version: 1.3.5
159
167
  signing_key:
160
- specification_version: 2
168
+ specification_version: 3
161
169
  summary: The Atom Protocol Exerciser
162
170
  test_files: []
163
171