Commit 408f95c9 by liyijie

Add aqi model spec

parent c9ef0d17
......@@ -103,7 +103,7 @@ module WeatherModel
"pm2_5" => 32,
"pm2_5_24h" => 42,
"position_name" => "市政府",
"primary_pollutant" => null,
"primary_pollutant" => nil,
"quality" => "优",
"so2" => 10,
"so2_24h" => 13,
......
require "spec_helper"
require 'active_record'
require "ohm"
Dir[File.dirname(__FILE__) + '../lib/weather-model.rb'].each { |file| require file }
include WeatherModel
# include WeatherModel
RSpec.describe WeatherModel do
......@@ -12,7 +13,7 @@ RSpec.describe WeatherModel do
# run migration
Dir[File.dirname(__FILE__) + '/../db/migrate/*.rb'].each { |file| require file }
# drop table
FileUtils.rm 'weather-model-test.sqlite3'
FileUtils.rm_f 'weather-model-test.sqlite3'
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => 'weather-model-test.sqlite3'
......@@ -46,7 +47,7 @@ RSpec.describe WeatherModel do
temp_high: '100',
temp_low: '0',
weather_text1: '酷热',
weather_text1: '严寒',
weather_text2: '严寒',
weather_pic: 'http://xxx.com',
win_dir: '东南西北风',
win_speed: '1级',
......@@ -86,10 +87,10 @@ RSpec.describe WeatherModel do
it 'Test all source data' do
[
Forecast::CityForecast,
AutoStation::AutoStationTenMins,
Aqi::AqiForecast,
Aqi::RealtimeAqi
WeatherModel::Forecast::CityForecast,
WeatherModel::AutoStation::AutoStationTenMins,
WeatherModel::Aqi::AqiForecast,
WeatherModel::Aqi::AqiLive,
].each { |source| source.all; source.const_get('Ohm').all }
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment