spec/lita/handlers/onewheel_aqi_spec.rb in lita-onewheel-aqi-2.1.1 vs spec/lita/handlers/onewheel_aqi_spec.rb in lita-onewheel-aqi-2.2.0
- old
+ new
@@ -4,14 +4,16 @@
describe Lita::Handlers::OnewheelAqi, lita_handler: true do
it { is_expected.to route_command('aqi') }
it { is_expected.to route_command('aqidetails') }
it { is_expected.to route_command('aqideets') }
- before do
- mock = File.open('spec/fixtures/Output.json').read
+ def mock(file)
+ mock = File.open("spec/fixtures/#{file}.json").read
allow(RestClient).to receive(:get) { mock }
+ end
+ before do
Timecop.freeze Time.local(2017, 8, 11, 16, 0, 0)
Geocoder.configure(lookup: :test)
Geocoder::Lookup::Test.add_stub(
@@ -48,24 +50,34 @@
}]
)
end
it 'queries the aqi' do
+ mock('Output')
send_command 'aqi'
expect(replies.last).to include("AQI for Portland, OR, USA, ⚠️ 08Moderate ⚠️ pm25: 0876 µg/m³(est): 23.99 pm10: 0340 updated 0860 minutes ago. 14(http://aqicn.org/city/usa/oregon/government-camp-multorpor-visibility/)")
end
it 'queries the aqideets' do
+ mock('Output')
send_command 'aqideets'
expect(replies.last).to eq("AQI for Portland, OR, USA, ⚠️ 08Moderate ⚠️ humidity: 11% pressure: 1014mb pm25: 0876 µg/m³(est): 23.99 pm10: 0340 temp: 34.65C updated 0860 minutes ago. 14(http://aqicn.org/city/usa/oregon/government-camp-multorpor-visibility/)")
end
it 'queries the aqi by location' do
+ mock('Output')
send_command 'aqi Beaverton'
expect(replies.last).to include("AQI for Beaverton, OR, USA, ⚠️ 08Moderate ⚠️ pm25: 0876 µg/m³(est): 23.99 pm10: 0340 updated 0860 minutes ago. 14(http://aqicn.org/city/usa/oregon/government-camp-multorpor-visibility/)")
end
it 'queries the aqideets' do
+ mock('Output')
send_command 'aqideets Beaverton'
expect(replies.last).to eq("AQI for Beaverton, OR, USA, ⚠️ 08Moderate ⚠️ humidity: 11% pressure: 1014mb pm25: 0876 µg/m³(est): 23.99 pm10: 0340 temp: 34.65C updated 0860 minutes ago. 14(http://aqicn.org/city/usa/oregon/government-camp-multorpor-visibility/)")
+ end
+
+ it 'dehli' do
+ mock('dehli')
+ send_command 'aqi'
+ expect(replies.last).to eq("AQI for Portland, OR, USA, 🚫☣🚫 13Hazardous 🚫☣🚫 pm25: 13641 µg/m³(est): [0..50, 51..100, 101..150, 151..200, 201..300, 301..500] pm10: 13875 updated -127740 minutes ago. 14(http://aqicn.org/city/delhi/punjabi-bagh/)")
end
end