mofo 0.1.2 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,200 @@
1
+ <!DOCTYPE html PUBdtC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5
+ <title>XFN Test Data</title>
6
+ <style type="text/css">
7
+ body {
8
+ font-family: Helvetica, Arial, sans-serif;
9
+ color: #161616;
10
+ }
11
+ h1, h2, h3, h4 {
12
+ color: #333;
13
+ }
14
+
15
+ h1 {
16
+ font-weight: normal;
17
+ font-size: 240%;
18
+ }
19
+
20
+ dt {
21
+ font-weight: bold;
22
+ padding-left:20px;
23
+ }
24
+
25
+ .valid dt {
26
+ color: #45C445;
27
+ }
28
+ .invalid dt {
29
+ color: #D22828;
30
+ }
31
+ a { color: #666666; }
32
+ </style>
33
+ </head>
34
+
35
+ <body>
36
+ <h1>XFN Test Data</h1>
37
+ <h4>Steve Ivy, 02-05-2007</h4>
38
+ <p>This test data is based on the <a href="http://gmpg.org/xfn/11">XFN 1.1 profile</a>. Comments or suggestions on this data can be sent to <a href="mailto:steveivy@gmail.com">steveivy@gmail.com</a>.</p>
39
+ <h3>Valid Relationships - singletons</h3>
40
+ <p>These represent a single relationship on each link and are all valid.</p>
41
+
42
+ <dl class="valid">
43
+ <dt>Friendship - pick at most one</dt>
44
+ <dd><a href="#contact" rel="contact">friend - contact</a></dd>
45
+ <dd><a href="#acquaintance" rel="acquaintance">friend - acquaintance</a></dd>
46
+ <dd><a href="#friend" rel="friend">friend - friend</a></dd>
47
+ </dl>
48
+
49
+ <dl class="valid">
50
+ <dt>Physical</dt>
51
+ <dd><a href="#met" rel="met">physical - met</a></dd>
52
+ <dd><a href="#met" rel="met">physical - met (dupe)</a></dd>
53
+ </dl>
54
+
55
+ <dl class="valid">
56
+ <dt>Professional</dt>
57
+ <dd><a href="#co-worker" rel="co-worker">professional - co-worker</a></dd>
58
+ <dd><a href="#colleague" rel="colleague">professional - colleague</a></dd>
59
+ </dl>
60
+
61
+ <dl class="valid">
62
+ <dt>Geographical - pick at most one</dt>
63
+ <dd><a href="#co-resident" rel="co-resident">geographical - co-resident</a></dd>
64
+ <dd><a href="#neighbor" rel="neighbor">geographical - neighbor</a></dd>
65
+ </dl>
66
+
67
+ <dl class="valid">
68
+ <dt>Family - pick at most one</dt>
69
+ <dd><a href="#child" rel="child">family - child</a></dd>
70
+ <dd><a href="#parent" rel="parent">family - parent</a></dd>
71
+ <dd><a href="#sibling" rel="sibling">family - sibling</a></dd>
72
+ <dd><a href="#spouse" rel="spouse">family - spouse</a></dd>
73
+ <dd><a href="#kin" rel="kin">family - kin</a></dd>
74
+ </dl>
75
+
76
+ <dl class="valid">
77
+ <dt>Romantic</dt>
78
+ <dd><a href="#muse" rel="muse">romantic - muse</a></dt>
79
+ <dd><a href="#crush" rel="crush">romantic - crush</a></dd>
80
+ <dd><a href="#date" rel="colleague">romantic - date</a></dd>
81
+ <dd><a href="#sweetheart" rel="sweetheart">romantic - sweetheart</a></dd>
82
+ </dl>
83
+
84
+ <dl class="valid">
85
+ <dt>Identity</dt>
86
+ <dd><a href="#me" rel="me">me</a> (exclusive of all other values)</dd>
87
+ </dl>
88
+
89
+ <h3>Valid Relationships - compound</h3>
90
+ <p>These represent compound relationship on each link and should all be valid.</p>
91
+
92
+ <dl class="valid">
93
+ <dt>Friendship + Physical</dt>
94
+ <dd><a href="#contact" rel="contact met">contact + met</a></dd>
95
+ <dd><a href="#acquaintance" rel="acquaintance met">acquaintance + met</a></dd>
96
+ <dd><a href="#friend" rel="friend met">friend + met</a></dd>
97
+ </dl>
98
+
99
+ <dl class="valid">
100
+ <dt>Friendship + Professional</dt>
101
+ <dd><a href="#contact" rel="contact co-worker">contact + co-worker</a></dd>
102
+ <dd><a href="#acquaintance" rel="acquaintance co-worker">acquaintance + co-worker</a></dd>
103
+ <dd><a href="#friend" rel="friend co-worker">friend + co-worker</a></dd>
104
+ </dl>
105
+
106
+ <dl class="valid">
107
+ <dt>Friendship + Geographic</dt>
108
+ <dd><a href="#contact" rel="contact co-resident">contact + co-resident</a></dd>
109
+ <dd><a href="#acquaintance" rel="acquaintance co-resident">acquaintance + co-resident</a></dd>
110
+ <dd><a href="#friend" rel="friend co-resident">friend - co-resident</a></dd>
111
+ <dd><a href="#contact2" rel="contact co-resident">contact + neighbor</a></dd>
112
+ <dd><a href="#acquaintance2" rel="acquaintance neighbor">acquaintance + neighbor</a></dd>
113
+ <dd><a href="#friend2" rel="friend neighbor">friend - neighbor</a></dd>
114
+ </dl>
115
+
116
+ <dl class="valid">
117
+ <dt>Professional + Physical</dt>
118
+ <dd><a href="#co-worker" rel="co-worker met">co-worker + met</a></dd>
119
+ <dd><a href="#colleague" rel="colleague met">colleague + met</a></dd>
120
+ </dl>
121
+
122
+ <dl class="valid">
123
+ <dt>Professional + Romantic</dt>
124
+ <dd><a href="#co-worker" rel="co-worker muse">co-worker + muse</a></dd>
125
+ <dd><a href="#colleague" rel="colleague muse">colleague + muse</a></dd>
126
+ <dd><a href="#co-worker" rel="co-worker crush">co-worker + crush</a></dd>
127
+ <dd><a href="#colleague" rel="colleague crush">colleague + crush</a></dd>
128
+ <dd><a href="#co-worker" rel="co-worker date">co-worker + date</a></dd>
129
+ <dd><a href="#colleague" rel="colleague date">colleague + date</a></dd>
130
+ <dd><a href="#co-worker" rel="co-worker sweetheart">co-worker + sweetheart</a></dd>
131
+ <dd><a href="#colleague" rel="colleague sweetheart">colleague + sweetheart</a></dd>
132
+ </dl>
133
+
134
+ <dl class="valid">
135
+ <dt>Family + Professional</dt>
136
+ <dd><a href="#child" rel="child co-worker">child + co-worker</a></dd>
137
+ <dd><a href="#child" rel="child colleague">child + colleague</a></dd>
138
+ <dd><a href="#parent" rel="parent co-worker">parent + co-worker</a></dd>
139
+ <dd><a href="#parent" rel="parent colleague">parent + colleague</a></dd>
140
+ <dd><a href="#sibling" rel="sibling co-worker">sibling + co-worker</a></dd>
141
+ <dd><a href="#sibling" rel="sibling colleague">sibling + colleague</a></dd>
142
+ <dd><a href="#spouse" rel="spouse co-worker">spouse + co-worker</a></dd>
143
+ <dd><a href="#spouse" rel="spouse colleague">spouse + colleague</a></dd>
144
+ <dd><a href="#kin" rel="kin co-worker">kin + co-worker</a></dd>
145
+ <dd><a href="#kin" rel="kin colleague">kin + colleague</a></dd>
146
+ <dd><a href="#kin" rel="kin colleague">kin + colleague (purposeful dupe)</a></dd>
147
+ </dl>
148
+
149
+ <h3>Invalid relationships</h3>
150
+ <p>These relationships violate rules of exclusivity, mostly.</p>
151
+
152
+ <dl class="invalid">
153
+ <dt>Friendship - multiple values</dt>
154
+ <dd><a href="#contact" rel="contact acquaintance">contact + acquaintance</a></dd>
155
+ <dd><a href="#acquaintance" rel="acquaintance friend">acquaintance + friend</a></dd>
156
+ <dd><a href="#friend" rel="friend contact">friend + contact</a></dd>
157
+ </dl>
158
+
159
+ <dl class="invalid">
160
+ <dt>Geographical - multiple values</dt>
161
+ <dd><a href="#co-resident" rel="co-resident neighbor">co-resident + neighbor</a></dd>
162
+ </dl>
163
+
164
+ <dl class="invalid">
165
+ <dt>Family - multiple values</dt>
166
+ <dd><a href="#child" rel="child parent">child + parent</a></dd>
167
+ <dd><a href="#child" rel="child sibling">child + sibling</a></dd>
168
+ <dd><a href="#child" rel="child spouse">child + spouse</a></dd>
169
+ <dd><a href="#child" rel="child kin">child + kin</a></dd>
170
+ <dd><a href="#parent" rel="parent sibling">parent + sibling</a></dd>
171
+ <dd><a href="#parent" rel="parent spouse">parent + spouse</a></dd>
172
+ <dd><a href="#parent" rel="parent kin">parent + kin</a></dd>
173
+ <dd><a href="#sibling" rel="sibling spouse">sibling + spouse</a></dd>
174
+ <dd><a href="#sibling" rel="sibling kin">sibling + kin</a></dd>
175
+ <dd><a href="#spouse" rel="spouse kin">spouse + kin</a></dd>
176
+ </dl>
177
+
178
+ <dl class="invalid">
179
+ <dt>Identity - me + anything</dt>
180
+ <dd><a href="#contact" rel="me contact">me + contact</a></dd>
181
+ <dd><a href="#acquaintance" rel="me acquaintance">me + acquaintance</a></dd>
182
+ <dd><a href="#friend" rel="me friend">me + friend</a></dd>
183
+ <dd><a href="#met" rel="me met">me + met</a></dd>
184
+ <dd><a href="#co-worker" rel="me co-worker">me + co-worker</a></dd>
185
+ <dd><a href="#colleague" rel="me colleague">me + colleague</a></dd>
186
+ <dd><a href="#co-resident" rel="me co-resident">me + co-resident</a></dd>
187
+ <dd><a href="#neighbor" rel="me neighbor">me + neighbor</a></dd>
188
+ <dd><a href="#child" rel="me child">me + child</a></dd>
189
+ <dd><a href="#parent" rel="me parent">me + parent</a></dd>
190
+ <dd><a href="#sibling" rel="me sibling">me + sibling</a></dd>
191
+ <dd><a href="#spouse" rel="me spouse">me + spouse</a></dd>
192
+ <dd><a href="#kin" rel="me kin">me + kin</a></dd>
193
+ <dd><a href="#muse" rel="me muse">me + muse</a></dt>
194
+ <dd><a href="#crush" rel="me crush">me + crush</a></dd>
195
+ <dd><a href="#date" rel="me colleague">me + date</a></dd>
196
+ <dd><a href="#sweetheart" rel="me sweetheart">me + sweetheart</a></dd>
197
+ </dl>
198
+
199
+ </body>
200
+ </html>
@@ -1,4 +1,4 @@
1
- require 'test/test_helper'
1
+ require File.dirname(__FILE__) + '/test_helper'
2
2
  require 'mofo/hcard'
3
3
  require 'mofo/hreview'
4
4
 
@@ -1,4 +1,4 @@
1
- require 'test/test_helper'
1
+ require File.dirname(__FILE__) + '/test_helper'
2
2
  require 'mofo/hentry'
3
3
 
4
4
  context "A parsed hEntry object" do
@@ -23,11 +23,10 @@ context "A parsed hEntry object" do
23
23
  $hentry.published.should.be.an.instance_of Time
24
24
  end
25
25
 
26
- # TODO
27
- # specify "should have an inferred updated attribute which references the published date object" do
28
- # $hentry.updated.should.be.an.instance_of Time
29
- # $hentry.updated.should.be $hentry.published
30
- # end
26
+ xspecify "should have an inferred updated attribute which references the published date object" do
27
+ $hentry.updated.should.be.an.instance_of Time
28
+ $hentry.updated.should.be $hentry.published
29
+ end
31
30
 
32
31
  specify "should have a bookmark (permalink)" do
33
32
  $hentry.bookmark.should.equal "/post/13"
@@ -0,0 +1,33 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+ require 'mofo/hcalendar'
3
+
4
+ context "A parsed hCalendar object with an embedded hCard" do
5
+ setup do
6
+ $hcalendar_hcard ||= HCalendar.find(:first => fixture(:upcoming_single))
7
+ end
8
+
9
+ specify "should have an HCard for its location" do
10
+ $hcalendar_hcard.location.should.be.an.instance_of HCard
11
+ end
12
+ end
13
+
14
+ context "A parsed hCalendar object with embedded adr" do
15
+ setup do
16
+ $hcalendar_addr ||= HCalendar.find(:first => fixture(:event_addr))
17
+ end
18
+
19
+ specify "should have an Adr for its location" do
20
+ $hcalendar_addr.location.should.be.an.instance_of Adr
21
+ end
22
+ end
23
+
24
+ context "A parsed hCalendar object with string location" do
25
+ setup do
26
+ $hcalendar_string ||= HCalendar.find(:first => fixture(:upcoming))
27
+ end
28
+
29
+ specify "should have a string for its location" do
30
+ $hcalendar_string.location.should.be.an.instance_of String
31
+ $hcalendar_string.location.should.not.be.empty
32
+ end
33
+ end
@@ -0,0 +1,132 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+ require 'mofo/hcard'
3
+ require 'mofo/hreview'
4
+
5
+ context "A simple hcard definition" do
6
+ specify "should parse a page with an hcard" do
7
+ proc { HCard.find(fixture(:fauxtank)) }.should.not.raise MicroformatNotFound
8
+ end
9
+
10
+ specify "should raise an error if no hcard is found in strict mode" do
11
+ proc { HCard.find(fixture(:fake), :strict => true) }.should.raise MicroformatNotFound
12
+ end
13
+
14
+ specify "should return an empty array if no hcard is found" do
15
+ HCard.find(fixture(:fake)).should.equal []
16
+ end
17
+
18
+ specify "should return nil if no hcard is found with :first" do
19
+ HCard.find(:first => fixture(:fake)).should.equal nil
20
+ end
21
+
22
+ specify "should return nil if no hcard is found with :all" do
23
+ HCard.find(:all => fixture(:fake)).should.equal []
24
+ end
25
+
26
+ specify "should accept a :text option" do
27
+ HCard.find(:text => open(fixture(:fauxtank)).read).should.not.equal []
28
+ HCard.find(:text => open(fixture(:fauxtank)).read).should.not.equal nil
29
+ end
30
+ end
31
+
32
+ context "The parsed fauxtank hCard object" do
33
+ setup do
34
+ $fauxtank ||= HCard.find(:first => fixture(:fauxtank))
35
+ end
36
+
37
+ specify "should be an instance of HCard" do
38
+ $fauxtank.should.be.an.instance_of HCard
39
+ end
40
+
41
+ specify "should have `fauxtank' as the nickname" do
42
+ $fauxtank.nickname.should.equal "fauxtank"
43
+ end
44
+
45
+ specify "should have two email addresses" do
46
+ $fauxtank.email.size.should.equal 2
47
+ $fauxtank.email.first.should.equal "fauxtank [at] gmail.com"
48
+ $fauxtank.email.last.should.equal "chris [at] fauxtank.com"
49
+ end
50
+
51
+ specify "should have `Chris' as the given name" do
52
+ $fauxtank.n.given_name.should.equal "Chris"
53
+ end
54
+
55
+ specify "should have `Murphy' as the family name" do
56
+ $fauxtank.n.family_name.should.equal "Murphy"
57
+ end
58
+
59
+ specify "should have `Chicago' as the locality" do
60
+ $fauxtank.adr.locality.should.equal "Chicago"
61
+ end
62
+
63
+ specify "should have `United States' as the country-name" do
64
+ $fauxtank.adr.country_name.should.equal "United States"
65
+ end
66
+
67
+ specify "should have fauxtank's profile pic as the logo" do
68
+ $fauxtank.logo.should.equal "http://static.flickr.com/25/buddyicons/89622800@N00.jpg?1128967902"
69
+ end
70
+
71
+ specify "should know what properties it found" do
72
+ $fauxtank.properties.sort.should.equal ["fn", "note", "n", "email", "logo", "adr", "nickname", "title", "url"].sort
73
+ end
74
+ end
75
+
76
+ context "The parsed Bob hCard object" do
77
+ setup do
78
+ $bob ||= HCard.find(:first => fixture(:bob))
79
+ end
80
+
81
+ specify "should have three valid emails with type information" do
82
+ $bob.email.value.size.should.equal 3
83
+ $bob.email.type.first.should.equal 'home'
84
+ $bob.email.value.first.should.equal 'bob@gmail.com'
85
+ $bob.email.type[1].should.equal 'work'
86
+ $bob.email.value[1].should.equal 'robert@yahoo.com'
87
+ $bob.email.type.last.should.equal 'home'
88
+ $bob.email.value.last.should.equal 'bobby@gmail.com'
89
+ end
90
+
91
+ specify "should have two valid telephone numbers with type information" do
92
+ $bob.tel.type.size.should.equal 2
93
+ $bob.tel.type.first.should.equal 'home'
94
+ $bob.tel.value.first.should.equal '707-555-9990'
95
+ $bob.tel.type.last.should.equal 'cell'
96
+ $bob.tel.value.last.should.equal '707-555-4756'
97
+ end
98
+
99
+ specify "should have a given, additional, and family name" do
100
+ $bob.n.given_name.should.equal 'Robert'
101
+ $bob.n.additional_name.should.equal 'Albert'
102
+ $bob.n.family_name.should.equal 'Smith'
103
+ end
104
+
105
+ specify "should have a valid url" do
106
+ $bob.url.should.equal "http://nubhub.com/bob"
107
+ end
108
+ end
109
+
110
+ context "The parsed simple hCard object" do
111
+ setup do
112
+ $simple ||= HCard.find(:first => fixture(:simple))
113
+ end
114
+
115
+ specify "should have an org string" do
116
+ $simple.org.should.be.an.instance_of String
117
+ $simple.org.should.equal "Err the Blog"
118
+ end
119
+
120
+ specify "should have an email string" do
121
+ $simple.email.should.be.an.instance_of String
122
+ $simple.email.should.equal "chris[at]ozmm[dot]org"
123
+ end
124
+
125
+ specify "should have a valid name" do
126
+ $simple.fn.should.equal "Chris Wanstrath"
127
+ end
128
+
129
+ specify "should have a valid url" do
130
+ $simple.url.should.equal "http://ozmm.org/"
131
+ end
132
+ end
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+ require 'mofo/hresume'
3
+
4
+ context "A parsed hResume object" do
5
+ setup do
6
+ $hresume ||= HResume.find(:first => fixture(:hresume))
7
+ end
8
+
9
+ fields = {
10
+ :contact => HCard,
11
+ :education => HCalendar,
12
+ :experience => Array,
13
+ :summary => String,
14
+ :skills => String
15
+ }
16
+
17
+ fields.each do |field, klass|
18
+ specify "should have an #{klass} for #{field}" do
19
+ $hresume.send(field).should.not.be.nil
20
+ $hresume.send(field).should.be.an.instance_of klass
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+ require 'mofo/hreview'
3
+
4
+ context "The parsed Firesteed hReview object" do
5
+ setup do
6
+ $firesteed ||= HReview.find(:first => fixture(:corkd))
7
+ end
8
+
9
+ specify "should have a valid, coerced dtreviewed field" do
10
+ $firesteed.dtreviewed.should.be.an.instance_of Time
11
+ end
12
+
13
+ specify "should have a rating of 5" do
14
+ $firesteed.rating.should.equal 5
15
+ end
16
+
17
+ specify "should have a description" do
18
+ $firesteed.description.should.equal %[This is probably my favorite every day (well, not every day) wine. It's light, subtly sweet, ripe fruit, slightly spicy oak. It's a bit "slippery", if that makes sense (in a very good way). Highly drinkable.]
19
+ end
20
+
21
+ specify "should have an HCard as the reviewer" do
22
+ $firesteed.reviewer.fn.should.equal "simplebits"
23
+ $firesteed.reviewer.photo.should.equal "/img/icon-user-64.gif"
24
+ $firesteed.reviewer.url.should.equal "/people/simplebits"
25
+ end
26
+
27
+ specify "should have a valid item" do
28
+ $firesteed.item.fn.should.equal "Firesteed 2003 Pinot Noir"
29
+ end
30
+
31
+ specify "should have 7 tags" do
32
+ $firesteed.tags.size.should.equal 7
33
+ $firesteed.tags.first.should.equal "berry"
34
+ $firesteed.tags.last.should.equal "sweet"
35
+ end
36
+ end