onebox 1.8.1 → 1.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,5 +29,51 @@ describe Onebox::Engine::PubmedOnebox do
29
29
  it "has the URL to the resource" do
30
30
  expect(html).to include(link)
31
31
  end
32
+
33
+ context "Pubmed electronic print" do
34
+ let(:link) { "http://www.ncbi.nlm.nih.gov/pubmed/24737116" }
35
+ let(:xml_link) { "http://www.ncbi.nlm.nih.gov/pubmed/24737116?report=xml&format=text" }
36
+ let(:html) { described_class.new(link).to_html }
37
+
38
+ before do
39
+ fake(link, response("pubmed-electronic"))
40
+ fake(xml_link, response("pubmed-electronic-xml"))
41
+ end
42
+
43
+ it "has the paper's title" do
44
+ expect(html).to include("Cushingoid facies on (18)F-FDG PET/CT.")
45
+ end
46
+
47
+ it "has the paper's author" do
48
+ expect(html).to include("van Rheenen")
49
+ end
50
+
51
+ it "has the paper's date" do
52
+ expect(html).to include("Jul 2014")
53
+ end
54
+
55
+ it "has the URL to the resource" do
56
+ expect(html).to include(link)
57
+ end
58
+ end
59
+
60
+ context "regex URI match" do
61
+
62
+ it "matches on specific articles" do
63
+ expect(match("http://www.ncbi.nlm.nih.gov/pubmed/7288891")).to eq true
64
+ end
65
+
66
+ it "does not match on search" do
67
+ expect(match("http://www.ncbi.nlm.nih.gov/pubmed/?term=rheenen+r")).to eq false
68
+ end
69
+
70
+ it "does not match on the root" do
71
+ expect(match("http://www.ncbi.nlm.nih.gov/pubmed/")).to eq false
72
+ end
73
+
74
+ def match(url)
75
+ Onebox::Engine::PubmedOnebox === URI(url)
76
+ end
77
+ end
32
78
  end
33
79
 
@@ -15,10 +15,9 @@ describe Onebox::Engine::TwitterStatusOnebox do
15
15
  # expect(html).to include("http://www.peers.org/action/peers-pledgea")
16
16
  # end
17
17
 
18
- # TODO: weird spec..
19
- # it "includes timestamp" do
20
- # expect(html).to include("6:59 PM - 1 Aug 13")
21
- # end
18
+ it "gets the correct timestamp" do
19
+ expect(onebox.send(:timestamp)).to eq("6:59 PM - 1 Aug 2013")
20
+ end
22
21
 
23
22
  it "includes name" do
24
23
  expect(html).to include("Vyki Englert")
@@ -29,7 +28,7 @@ describe Onebox::Engine::TwitterStatusOnebox do
29
28
  end
30
29
 
31
30
  it "includes user avatar" do
32
- expect(html).to include("568244395007168512/qQVXa2Ql_normal.jpeg")
31
+ expect(html).to include("732349210264133632/RTNgZLrm_normal.jpg")
33
32
  end
34
33
  end
35
34
 
@@ -42,52 +41,9 @@ describe Onebox::Engine::TwitterStatusOnebox do
42
41
  context "with twitter client" do
43
42
  before(:each) do
44
43
  @twitter_client = double("TwitterClient")
45
- allow(@twitter_client).to receive("status") do
46
- {
47
- created_at: "Fri Aug 02 01:59:30 +0000 2013",
48
- id: 363_116_819_147_538_433,
49
- id_str: "363116819147538433",
50
- text:
51
- "I'm a sucker for pledges. @Peers Pledge #sharingeconomy http://t.co/T4Sc47KAzh",
52
- source:
53
- "<a href=\"http://twitter.com/tweetbutton\" rel=\"nofollow\">Tweet Button</a>",
54
- user:
55
- { id: 1_087_064_150,
56
- id_str: "1087064150",
57
- name: "Vyki Englert",
58
- screen_name: "vyki_e",
59
- location: "Los Angeles, CA",
60
- description: "I am woman, hear me #RoR.",
61
- url: "http://t.co/umZG76wmv2",
62
- protected: false,
63
- followers_count: 249,
64
- friends_count: 907,
65
- listed_count: 6,
66
- created_at: "Sun Jan 13 19:53:00 +0000 2013",
67
- favourites_count: 506,
68
- statuses_count: 926,
69
- lang: "en",
70
- contributors_enabled: false,
71
- is_translator: false,
72
- profile_image_url:
73
- "http://pbs.twimg.com/profile_images/568244395007168512/qQVXa2Ql_normal.jpeg",
74
- profile_image_url_https:
75
- "https://pbs.twimg.com/profile_images/568244395007168512/qQVXa2Ql_normal.jpeg",
76
- following: true,
77
- follow_request_sent: false,
78
- notifications: nil },
79
- geo: nil,
80
- coordinates: nil,
81
- place: nil,
82
- contributors: nil,
83
- retweet_count: 0,
84
- favorite_count: 0,
85
- favorited: false,
86
- retweeted: false,
87
- possibly_sensitive: false,
88
- lang: "en"
89
- }
90
- end
44
+ allow(@twitter_client).to receive("status")
45
+ .and_return mockTwitterAPIReponse
46
+
91
47
  allow(@twitter_client).to receive("prettify_tweet") do
92
48
  "I'm a sucker for pledges. <a href='https://twitter.com/Peers' target='_blank'>@Peers</a> Pledge <a href='https://twitter.com/search?q=%23sharingeconomy' target='_blank'>#sharingeconomy</a> <a target='_blank' href='http://www.peers.org/action/peers-pledgea/'>peers.org/action/peers-p…</a>"
93
49
  end
@@ -105,4 +61,127 @@ describe Onebox::Engine::TwitterStatusOnebox do
105
61
  it_behaves_like "an engine"
106
62
  it_behaves_like "#to_html"
107
63
  end
64
+
65
+ def mockTwitterAPIReponse
66
+ {
67
+ created_at: "Fri Aug 02 01:59:30 +0000 2013",
68
+ id: 363116819147538400,
69
+ id_str: "363116819147538433",
70
+ text: "I'm a sucker for pledges. @Peers Pledge #sharingeconomy http://t.co/T4Sc47KAzh",
71
+ truncated: false,
72
+ entities: {
73
+ hashtags: [
74
+ {
75
+ text: "sharingeconomy",
76
+ indices: [
77
+ 41,
78
+ 56
79
+ ]
80
+ }
81
+ ],
82
+ symbols: [],
83
+ user_mentions: [
84
+ {
85
+ screen_name: "peers",
86
+ name: "Peers",
87
+ id: 1428357889,
88
+ id_str: "1428357889",
89
+ indices: [
90
+ 27,
91
+ 33
92
+ ]
93
+ }
94
+ ],
95
+ urls: [
96
+ {
97
+ url: "http://t.co/T4Sc47KAzh",
98
+ expanded_url: "http://www.peers.org/action/peers-pledgea/",
99
+ display_url: "peers.org/action/peers-p…",
100
+ indices: [
101
+ 57,
102
+ 79
103
+ ]
104
+ }
105
+ ]
106
+ },
107
+ source: "<a href=\"https://dev.twitter.com/docs/tfw\" rel=\"nofollow\">Twitter for Websites</a>",
108
+ in_reply_to_status_id: nil,
109
+ in_reply_to_status_id_str: nil,
110
+ in_reply_to_user_id: nil,
111
+ in_reply_to_user_id_str: nil,
112
+ in_reply_to_screen_name: nil,
113
+ user: {
114
+ id: 1087064150,
115
+ id_str: "1087064150",
116
+ name: "Vyki Englert",
117
+ screen_name: "vyki_e",
118
+ location: "Los Angeles, CA",
119
+ description: "Rides bikes, writes code, likes maps. @CompilerLA / @CityGrows / Brigade Captain @HackforLA",
120
+ url: "http://t.co/YCAP3asRG1",
121
+ entities: {
122
+ url: {
123
+ urls: [
124
+ {
125
+ url: "http://t.co/YCAP3asRG1",
126
+ expanded_url: "http://www.compiler.la",
127
+ display_url: "compiler.la",
128
+ indices: [
129
+ 0,
130
+ 22
131
+ ]
132
+ }
133
+ ]
134
+ },
135
+ description: {
136
+ urls: []
137
+ }
138
+ },
139
+ protected: false,
140
+ followers_count: 1128,
141
+ friends_count: 2244,
142
+ listed_count: 83,
143
+ created_at: "Sun Jan 13 19:53:00 +0000 2013",
144
+ favourites_count: 2928,
145
+ utc_offset: -25200,
146
+ time_zone: "Pacific Time (US & Canada)",
147
+ geo_enabled: true,
148
+ verified: false,
149
+ statuses_count: 3295,
150
+ lang: "en",
151
+ contributors_enabled: false,
152
+ is_translator: false,
153
+ is_translation_enabled: false,
154
+ profile_background_color: "ACDED6",
155
+ profile_background_image_url: "http://abs.twimg.com/images/themes/theme18/bg.gif",
156
+ profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme18/bg.gif",
157
+ profile_background_tile: false,
158
+ profile_image_url: "http://pbs.twimg.com/profile_images/732349210264133632/RTNgZLrm_normal.jpg",
159
+ profile_image_url_https: "https://pbs.twimg.com/profile_images/732349210264133632/RTNgZLrm_normal.jpg",
160
+ profile_banner_url: "https://pbs.twimg.com/profile_banners/1087064150/1424315468",
161
+ profile_link_color: "4E99D1",
162
+ profile_sidebar_border_color: "EEEEEE",
163
+ profile_sidebar_fill_color: "F6F6F6",
164
+ profile_text_color: "333333",
165
+ profile_use_background_image: true,
166
+ has_extended_profile: false,
167
+ default_profile: false,
168
+ default_profile_image: false,
169
+ following: false,
170
+ follow_request_sent: false,
171
+ notifications: false
172
+ },
173
+ geo: nil,
174
+ coordinates: nil,
175
+ place: nil,
176
+ contributors: nil,
177
+ is_quote_status: false,
178
+ retweet_count: 0,
179
+ favorite_count: 0,
180
+ favorited: false,
181
+ retweeted: false,
182
+ possibly_sensitive: false,
183
+ possibly_sensitive_appealable: false,
184
+ lang: "en"
185
+ }
186
+ end
108
187
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onebox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joanna Zeta
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-02-08 00:00:00.000000000 Z
13
+ date: 2017-02-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json
@@ -396,6 +396,8 @@ files:
396
396
  - spec/fixtures/image.response
397
397
  - spec/fixtures/meetup.response.html
398
398
  - spec/fixtures/meetup_oembed.response
399
+ - spec/fixtures/pubmed-electronic-xml.response
400
+ - spec/fixtures/pubmed-electronic.response
399
401
  - spec/fixtures/pubmed-xml.response
400
402
  - spec/fixtures/pubmed.response
401
403
  - spec/fixtures/slides.response
@@ -489,7 +491,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
489
491
  version: '0'
490
492
  requirements: []
491
493
  rubyforge_project:
492
- rubygems_version: 2.6.8
494
+ rubygems_version: 2.6.7
493
495
  signing_key:
494
496
  specification_version: 4
495
497
  summary: A gem for turning URLs into previews.
@@ -505,6 +507,8 @@ test_files:
505
507
  - spec/fixtures/image.response
506
508
  - spec/fixtures/meetup.response.html
507
509
  - spec/fixtures/meetup_oembed.response
510
+ - spec/fixtures/pubmed-electronic-xml.response
511
+ - spec/fixtures/pubmed-electronic.response
508
512
  - spec/fixtures/pubmed-xml.response
509
513
  - spec/fixtures/pubmed.response
510
514
  - spec/fixtures/slides.response
@@ -554,3 +558,4 @@ test_files:
554
558
  - spec/lib/onebox_spec.rb
555
559
  - spec/spec_helper.rb
556
560
  - spec/support/html_spec_helper.rb
561
+ has_rdoc: