Commit 408f95c9 by liyijie

Add aqi model spec

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