lita-onewheel-election-cnn 3.1.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3bb1422abe3d459298c1eddf84b05980aa807c0
|
4
|
+
data.tar.gz: f263abdc2c27528407fae3b274c1d4e296bbb27d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d578ac031eb79186d3ffb39c2aefd86dfdd672e7f81777947a83d763f88ec29a3fa2aeeac2c1da71086d1963e3a050350c30d84708f1085793614d3b8aa37be
|
7
|
+
data.tar.gz: 0b026e66640dec66a32dd109d113b535a75a7620872a06ae5dcbbcb058c555ca6cdc9920fee5b53394fddd987f61fe0612fcb1a5461f5ba8b0d8335b91bbb742
|
@@ -25,6 +25,7 @@ module Lita
|
|
25
25
|
Lita.logger.debug 'Getting election data'
|
26
26
|
results = JSON.parse(RestClient.get('http://data.cnn.com/ELECTION/2016/full/P.full.json'))
|
27
27
|
|
28
|
+
response.reply "United States 2016 Presidential Election, #{results['races'][0]['pctsrep']}% reporting."
|
28
29
|
results['candidates'].each do |candidate|
|
29
30
|
candidate_str = "#{candidate['fname']} #{candidate['lname']}: "
|
30
31
|
candidate_str += "#{candidate['pctDecimal']}%, #{candidate['evotes']} electoral votes."
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'lita-onewheel-election-cnn'
|
3
|
-
spec.version = '3.
|
3
|
+
spec.version = '3.2.0'
|
4
4
|
spec.authors = ['Andrew Kreps']
|
5
5
|
spec.email = ['andrew.kreps@gmail.com']
|
6
6
|
spec.description = %q{Lita interface to CNN's 2016 Presidential Election JSON.}
|
data/spec/fixtures/election.json
CHANGED
data/spec/fixtures/winner.json
CHANGED
@@ -10,16 +10,18 @@ describe Lita::Handlers::OnewheelElectionCnn, lita_handler: true do
|
|
10
10
|
mock = File.open('spec/fixtures/election.json').read
|
11
11
|
allow(RestClient).to receive(:get) { mock }
|
12
12
|
send_command 'election'
|
13
|
-
expect(replies[0]).to eq("
|
14
|
-
expect(replies[1]).to eq("
|
13
|
+
expect(replies[0]).to eq("United States 2016 Presidential Election, 1% reporting.")
|
14
|
+
expect(replies[1]).to eq("Hillary Clinton: 0.0%, 0 electoral votes.")
|
15
|
+
expect(replies[2]).to eq("Donald Trump: 0.0%, 19 electoral votes.")
|
15
16
|
end
|
16
17
|
|
17
18
|
it 'shows a winner' do
|
18
19
|
mock = File.open('spec/fixtures/winner.json').read
|
19
20
|
allow(RestClient).to receive(:get) { mock }
|
20
21
|
send_command 'election'
|
21
|
-
expect(replies[0]).to eq("
|
22
|
-
expect(replies[1]).to eq("
|
22
|
+
expect(replies[0]).to eq("United States 2016 Presidential Election, 1% reporting.")
|
23
|
+
expect(replies[1]).to eq("Hillary Clinton: 0.0%, 0 electoral votes. WINNER! ")
|
24
|
+
expect(replies[2]).to eq("Donald Trump: 0.0%, 0 electoral votes.")
|
23
25
|
end
|
24
26
|
|
25
27
|
it 'shows by state' do
|