Skip to content

Commit

Permalink
Fixed up the tests and tightened up the display.
Browse files Browse the repository at this point in the history
  • Loading branch information
onewheelskyward committed May 15, 2016
1 parent 2a04aa0 commit f2b5767
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 51 deletions.
19 changes: 11 additions & 8 deletions lib/lita/handlers/onewheel_apex_bar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def send_response(tap, datum, response)
# reply += "Served in a #{datum[1]['glass']} glass. "
# reply += "#{get_display_prices datum[:prices]}, "
# reply += "#{datum[:remaining]}"
reply += "#{datum[:abv]}%"

Lita.logger.info "send_response: Replying with #{reply}"

Expand Down Expand Up @@ -84,25 +85,27 @@ def parse_response(response)
# gimme_what_you_got
tap_name = (index + 1).to_s

# brewery = beer_node.css('td')[0].children.to_s
beer_name = beer_node.css('td')[0].children.to_s
brewery = beer_node.css('td')[2].children.to_s
beer_name = beer_node.css('td')[0].children.text.to_s
beer_type = beer_name.match(/\s*-\s*\w+$/).to_s
beer_type.sub! /\s+-\s+/, ''
# beer_desc = get_beer_desc(beer_node)
abv = beer_node.css('td')[4].children.to_s
# full_text_search = "#{tap.sub /\d+/, ''} #{brewery} #{beer_name} #{beer_desc.to_s.gsub /\d+\.*\d*%*/, ''}"
full_text_search = "#{brewery} #{beer_name.to_s.gsub /(\d+|')/, ''}" # #{beer_desc.to_s.gsub /\d+\.*\d*%*/, ''}
# prices = get_prices(beer_node)

gimme_what_you_got[tap_name] = {
# type: tap_type,
# remaining: remaining,
# brewery: brewery.to_s,
brewery: brewery.to_s,
name: beer_name.to_s,
# desc: beer_desc.to_s,
desc: beer_type.to_s,
abv: abv.to_f,
# prices: prices,
# search: full_text_search
search: full_text_search
}
end
puts gimme_what_you_got.inspect
# puts gimme_what_you_got.inspect

gimme_what_you_got
end

Expand Down
2 changes: 1 addition & 1 deletion lita-onewheel-apex-bar.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = 'lita-onewheel-apex-bar'
spec.version = '0.0.0'
spec.version = '0.1.0'
spec.authors = ['Andrew Kreps']
spec.email = ['andrew.kreps@gmail.com']
spec.description = %q{Lita interface to Apex Bar's listings.}
Expand Down
74 changes: 32 additions & 42 deletions spec/lita/handlers/onewheel_apex_bar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
describe Lita::Handlers::OnewheelApexBar, lita_handler: true do
it { is_expected.to route_command('apex') }
it { is_expected.to route_command('apex 4') }
# it { is_expected.to route_command('apex nitro') }
# it { is_expected.to route_command('apex CASK') }
it { is_expected.to route_command('apex nitro') }
it { is_expected.to route_command('apex CASK') }
it { is_expected.to route_command('apex <$4') }
it { is_expected.to route_command('apex < $4') }
it { is_expected.to route_command('apex <=$4') }
Expand All @@ -23,51 +23,46 @@

it 'shows the Apex taps' do
send_command 'apex'
expect(replies.last).to eq("taps: 1) Aktien Helles Lager 2) Armored Fist - Big,Black&amp;Hoppy 3) Barrel Aged Old Thunderpussy 4) Blind Pig - IPA 5) Blue Bell Bitter 6) Bone-A-Fide - Pale 7) Breaking Bud - IPA 8) Cheap, cold 9) Cider- Huckleberry 10) Cider- NeverGiveAnInch -Rosé 11) Cuvée des Jacobins Rouge* 12) Delilah Jones '15 - StrongRye 13) Duet - IPA 14) Golden - Herbs,Seeds,Spelt 15) Grapefruit Radler 16) Handtruck - Pale 17) Head Shake - IIPA 18) Hop Venom - IIPA 19) Jahrhundert - Export Lager 20) Kalifornia Kolsch 21) Kristallweissbier 22) Le Terroir* 23) Lupulin River - IPA 24) Maisel's Weisse - Hefeweizen 25) Nitro- Adam -Drinking Tobacco 26) Nitro- Aphrodisiaque - Stout 27) Nitro- Old Rasputin - RIS 28) Nitro- Red Seal - Red 29) Nitro- Shake - Choco Porter 30) Nitro- Stout 31) Notorious - IIIPA 32) Off Leash - NW Session Ale 33) Old Crustacean '12-Barleywine 34) Pallet Jack - IPA 35) Phantasmagoria - IPA 36) Pilsner 37) Pliny The Elder 38) Prairie-Vous Francais - Saison  <div class=\"btn btn-danger btn-mini\">\n<i class=\"icon-star icon-white\"></i> Just Tapped<i class=\"icon-star icon-white\"></i>\n</div> 39) Proving Ground - IPA 40) Prowell Springs - Pilsner 41) Saison 42) Saison de Lily 43) Sho' Nuff - Belgian Pale 44) Simple Life - Lacto Saison* 45) Stout of Circumstance 46) Sump - Imp Coffee Stout 47) Tex Arcana - Stout 48) Tripel Karmeliet 49) Vivid - IIPA 50) WFO - IPA")
expect(replies.last).to eq("taps: 1) Bayreuther Aktien Helles Lager 2) Boneyard Armored Fist - Big,Black&Hoppy 3) Magnolia Barrel Aged Old Thunderpussy 4) Russian River Blind Pig - IPA 5) Magnolia Blue Bell Bitter 6) Boneyard Bone-A-Fide - Pale 7) Knee Deep Breaking Bud - IPA 8) Hamm's Cheap, cold 9) Two Rivers Cider- Huckleberry 10) Cider Riot! Cider- NeverGiveAnInch -Rosé 11) Bockor Cuvée des Jacobins Rouge* 12) Magnolia Delilah Jones '15 - StrongRye 13) Alpine Duet - IPA 14) NewBelg&amp;HofTenDormaal Golden - Herbs,Seeds,Spelt 15) Stiegl Grapefruit Radler 16) Barley Brown's Handtruck - Pale 17) Barley Brown's Head Shake - IIPA 18) Boneyard Hop Venom - IIPA 19) Ayinger Jahrhundert - Export Lager 20) Magnolia Kalifornia Kolsch 21) Weihenstephan Kristallweissbier 22) New Belgium Le Terroir* 23) Knee Deep Lupulin River - IPA 24) Gebruder Maisel Maisel's Weisse - Hefeweizen 25) Hair of the Dog Nitro- Adam -Drinking Tobacco 26) Dieu du Ciel! Nitro- Aphrodisiaque - Stout 27) North Coast Nitro- Old Rasputin - RIS 28) North Coast Nitro- Red Seal - Red 29) Boulder Nitro- Shake - Choco Porter 30) Guinness Nitro- Stout 31) Boneyard Notorious - IIIPA 32) Crux Off Leash - NW Session Ale 33) Rogue Old Crustacean '12-Barleywine 34) Barley Brown's Pallet Jack - IPA 35) Prairie Phantasmagoria - IPA 36) Radeberger Pilsner 37) Russian River Pliny The Elder 38) Prairie Prairie-Vous Francais - Saison   Just Tapped 39) Magnolia Proving Ground - IPA 40) Crux Prowell Springs - Pilsner 41) Dupont Saison 42) Magnolia Saison de Lily 43) Against the Grain Sho' Nuff - Belgian Pale 44) To Øl Simple Life - Lacto Saison* 45) Magnolia Stout of Circumstance 46) Perennial Sump - Imp Coffee Stout 47) Against the Grain Tex Arcana - Stout 48) Bosteels Tripel Karmeliet 49) Gigantic Vivid - IIPA 50) Barley Brown's WFO - IPA")
end

it 'displays details for tap 4' do
send_command 'apex 4'
expect(replies.last).to eq('Apex tap 4) Blind Pig - IPA ')
expect(replies.last).to eq('Apex tap 4) Blind Pig - IPA 6.1%')
end

it 'doesn\'t explode on 1' do
send_command 'taps 1'
send_command 'apex 1'
expect(replies.count).to eq(1)
expect(replies.last).to eq('Bailey\'s tap 1) Cider Riot! Plastic Paddy - Apple Cider w/ Irish tea 6.0%, 10oz - $4 | 20oz - $7 | 32oz Crowler - $10, 48% remaining')
expect(replies.last).to eq('Apex tap 1) Aktien Helles Lager 5.3%')
end

it 'gets nitro' do
send_command 'taps nitro'
expect(replies.last).to eq('Bailey\'s tap 6) (Nitro) Backwoods Winchester Brown - Brown Ale 6.2%, 10oz - $3 | 20oz - $5, 98% remaining')
end

it 'gets cask' do
send_command 'taps cask'
expect(replies.last).to eq("Bailey's tap 3) (Cask) Machine House Crystal Maze - ESB 4.0%, 10oz - $3 | 20oz - $5, 57% remaining")
send_command 'apex nitro'
expect(replies.last).to eq('Apex tap 30) Nitro- Stout 4.1%')
end

it 'searches for ipa' do
send_command 'taps ipa'
expect(replies.last).to eq("Bailey's tap 24) Oakshire Perfect Storm - Imperial IPA 9.0%, 10oz - $4 | 20oz - $6 | 32oz Crowler - $10, 61% remaining")
send_command 'apex ipa'
expect(replies.last).to eq('Apex tap 50) WFO - IPA 7.5%')
end

it 'searches for brown' do
send_command 'taps brown'
expect(replies.last).to eq("Bailey's tap 22) GoodLife 29er - India Brown Ale 6.0%, 10oz - $3 | 20oz - $5 | 32oz Crowler - $8, 37% remaining")
end
# it 'searches for brown' do
# send_command 'apex brown'
# expect(replies.last).to eq("Bailey's tap 22) GoodLife 29er - India Brown Ale 6.0%, 10oz - $3 | 20oz - $5 | 32oz Crowler - $8, 37% remaining")
# end

it 'searches for abv >9%' do
send_command 'taps >9%'
expect(replies.count).to eq(4)
send_command 'apex >9%'
expect(replies.count).to eq(8)
expect(replies[0]).to eq("Bailey's tap 8) Fat Head’s Zeus Juice - Belgian Strong Blonde 10.0%, 4oz - $2 | 12oz - $4 | 32oz Crowler - $9, 44% remaining")
expect(replies[1]).to eq("Bailey's tap 9) Hopworks Noggin’ Floggin’ - Barleywine 11.0%, 4oz - $3 | 12oz - $6 | 32oz Crowler - $13, 34% remaining")
expect(replies[2]).to eq("Bailey's tap 18) Knee Deep Hop Surplus - Triple IPA 10.0%, 4oz - $2 | 12oz - $4 | 32oz Crowler - $10, 25% remaining")
expect(replies[3]).to eq("Bailey's tap 20) Knee Deep Dark Horse - Imperial Stout 12.0%, 4oz - $2 | 12oz - $4 | 32oz Crowler - $10, 39% remaining")
end

it 'searches for abv > 9%' do
send_command 'taps > 9%'
send_command 'apex > 9%'
expect(replies.count).to eq(4)
expect(replies[0]).to eq("Bailey's tap 8) Fat Head’s Zeus Juice - Belgian Strong Blonde 10.0%, 4oz - $2 | 12oz - $4 | 32oz Crowler - $9, 44% remaining")
expect(replies[1]).to eq("Bailey's tap 9) Hopworks Noggin’ Floggin’ - Barleywine 11.0%, 4oz - $3 | 12oz - $6 | 32oz Crowler - $13, 34% remaining")
Expand All @@ -76,7 +71,7 @@
end

it 'searches for abv >= 9%' do
send_command 'taps >= 9%'
send_command 'apex >= 9%'
expect(replies.count).to eq(5)
expect(replies[0]).to eq("Bailey's tap 8) Fat Head’s Zeus Juice - Belgian Strong Blonde 10.0%, 4oz - $2 | 12oz - $4 | 32oz Crowler - $9, 44% remaining")
expect(replies[1]).to eq("Bailey's tap 9) Hopworks Noggin’ Floggin’ - Barleywine 11.0%, 4oz - $3 | 12oz - $6 | 32oz Crowler - $13, 34% remaining")
Expand All @@ -86,35 +81,35 @@
end

it 'searches for abv <4.1%' do
send_command 'taps <4.1%'
send_command 'apex <4.1%'
expect(replies.count).to eq(2)
expect(replies[0]).to eq("Bailey's tap 3) (Cask) Machine House Crystal Maze - ESB 4.0%, 10oz - $3 | 20oz - $5, 57% remaining")
expect(replies.last).to eq("Bailey's tap 11) Lagunitas Copper Fusion Ale - Copper Ale 4.0%, 10oz - $3 | 20oz - $5 | 32oz Crowler - $8, 19% remaining")
end

it 'searches for abv < 4.1%' do
send_command 'taps < 4.1%'
send_command 'apex < 4.1%'
expect(replies.count).to eq(2)
expect(replies[0]).to eq("Bailey's tap 3) (Cask) Machine House Crystal Maze - ESB 4.0%, 10oz - $3 | 20oz - $5, 57% remaining")
expect(replies.last).to eq("Bailey's tap 11) Lagunitas Copper Fusion Ale - Copper Ale 4.0%, 10oz - $3 | 20oz - $5 | 32oz Crowler - $8, 19% remaining")
end

it 'searches for abv <= 4%' do
send_command 'taps <= 4%'
send_command 'apex <= 4%'
expect(replies.count).to eq(2)
expect(replies[0]).to eq("Bailey's tap 3) (Cask) Machine House Crystal Maze - ESB 4.0%, 10oz - $3 | 20oz - $5, 57% remaining")
expect(replies.last).to eq("Bailey's tap 11) Lagunitas Copper Fusion Ale - Copper Ale 4.0%, 10oz - $3 | 20oz - $5 | 32oz Crowler - $8, 19% remaining")
end

it 'searches for prices >$6' do
send_command 'taps >$6'
send_command 'apex >$6'
expect(replies.count).to eq(2)
expect(replies[0]).to eq("Bailey's tap 1) Cider Riot! Plastic Paddy - Apple Cider w/ Irish tea 6.0%, 10oz - $4 | 20oz - $7 | 32oz Crowler - $10, 48% remaining")
expect(replies[1]).to eq("Bailey's tap 4) Wild Ride Solidarity - Abbey Dubbel – Barrel Aged (Pinot Noir) 8.2%, 4oz - $4 | 12oz - $7, 26% remaining")
end

it 'searches for prices >=$6' do
send_command 'taps >=$6'
send_command 'apex >=$6'
expect(replies.count).to eq(4)
expect(replies[0]).to eq("Bailey's tap 1) Cider Riot! Plastic Paddy - Apple Cider w/ Irish tea 6.0%, 10oz - $4 | 20oz - $7 | 32oz Crowler - $10, 48% remaining")
expect(replies[1]).to eq("Bailey's tap 4) Wild Ride Solidarity - Abbey Dubbel – Barrel Aged (Pinot Noir) 8.2%, 4oz - $4 | 12oz - $7, 26% remaining")
Expand All @@ -123,65 +118,60 @@
end

it 'searches for prices > $6' do
send_command 'taps > $6'
send_command 'apex > $6'
expect(replies.count).to eq(2)
expect(replies[0]).to eq("Bailey's tap 1) Cider Riot! Plastic Paddy - Apple Cider w/ Irish tea 6.0%, 10oz - $4 | 20oz - $7 | 32oz Crowler - $10, 48% remaining")
expect(replies[1]).to eq("Bailey's tap 4) Wild Ride Solidarity - Abbey Dubbel – Barrel Aged (Pinot Noir) 8.2%, 4oz - $4 | 12oz - $7, 26% remaining")
end

it 'searches for prices <$4.1' do
send_command 'taps <$4.1'
send_command 'apex <$4.1'
expect(replies.count).to eq(3)
expect(replies[0]).to eq("Bailey's tap 8) Fat Head’s Zeus Juice - Belgian Strong Blonde 10.0%, 4oz - $2 | 12oz - $4 | 32oz Crowler - $9, 44% remaining")
expect(replies[1]).to eq("Bailey's tap 18) Knee Deep Hop Surplus - Triple IPA 10.0%, 4oz - $2 | 12oz - $4 | 32oz Crowler - $10, 25% remaining")
expect(replies[2]).to eq("Bailey's tap 20) Knee Deep Dark Horse - Imperial Stout 12.0%, 4oz - $2 | 12oz - $4 | 32oz Crowler - $10, 39% remaining")
end

it 'searches for prices < $4.01' do
send_command 'taps < $4.01'
send_command 'apex < $4.01'
expect(replies.count).to eq(3)
expect(replies[0]).to eq("Bailey's tap 8) Fat Head’s Zeus Juice - Belgian Strong Blonde 10.0%, 4oz - $2 | 12oz - $4 | 32oz Crowler - $9, 44% remaining")
expect(replies[1]).to eq("Bailey's tap 18) Knee Deep Hop Surplus - Triple IPA 10.0%, 4oz - $2 | 12oz - $4 | 32oz Crowler - $10, 25% remaining")
expect(replies[2]).to eq("Bailey's tap 20) Knee Deep Dark Horse - Imperial Stout 12.0%, 4oz - $2 | 12oz - $4 | 32oz Crowler - $10, 39% remaining")
end

it 'searches for prices <= $4.00' do
send_command 'taps <= $4.00'
send_command 'apex <= $4.00'
expect(replies.count).to eq(3)
expect(replies[0]).to eq("Bailey's tap 8) Fat Head’s Zeus Juice - Belgian Strong Blonde 10.0%, 4oz - $2 | 12oz - $4 | 32oz Crowler - $9, 44% remaining")
expect(replies[1]).to eq("Bailey's tap 18) Knee Deep Hop Surplus - Triple IPA 10.0%, 4oz - $2 | 12oz - $4 | 32oz Crowler - $10, 25% remaining")
expect(replies[2]).to eq("Bailey's tap 20) Knee Deep Dark Horse - Imperial Stout 12.0%, 4oz - $2 | 12oz - $4 | 32oz Crowler - $10, 39% remaining")
end

it 'runs a random beer through' do
send_command 'taps roulette'
send_command 'apex roulette'
expect(replies.count).to eq(1)
expect(replies.last).to include("Bailey's tap")
end

it 'runs a random beer through' do
send_command 'taps random'
send_command 'apex random'
expect(replies.count).to eq(1)
expect(replies.last).to include("Bailey's tap")
end

it 'searches with a space' do
send_command 'taps zeus juice'
send_command 'apex zeus juice'
expect(replies.last).to eq("Bailey's tap 8) Fat Head’s Zeus Juice - Belgian Strong Blonde 10.0%, 4oz - $2 | 12oz - $4 | 32oz Crowler - $9, 44% remaining")
end

it 'displays low taps' do
send_command 'tapslow'
expect(replies.last).to eq("Bailey's tap 25) Green Flash Passion Fruit Kicker - Wheat Ale w/ Passion Fruit 5.5%, 10oz - $3 | 20oz - $5, <= 1% remaining")
end

it 'displays low abv' do
send_command 'tapsabvhigh'
send_command 'apexabvhigh'
expect(replies.last).to eq("Bailey's tap 20) Knee Deep Dark Horse - Imperial Stout 12.0%, 4oz - $2 | 12oz - $4 | 32oz Crowler - $10, 39% remaining")
end

it 'displays high abv' do
send_command 'tapsabvlow'
send_command 'apexabvlow'
expect(replies.last).to eq("Bailey's tap 3) (Cask) Machine House Crystal Maze - ESB 4.0%, 10oz - $3 | 20oz - $5, 57% remaining")
end
end

0 comments on commit f2b5767

Please sign in to comment.