Commit da693bf7 by ivan Lan

Add test to updating mysql obj

parent 2dc79236
...@@ -23,7 +23,7 @@ RSpec.describe WeatherModel do ...@@ -23,7 +23,7 @@ RSpec.describe WeatherModel do
end end
it 'Forecast' do it 'Forecast' do
Forecast::ShanghaiTen.create({ mysql_obj = Forecast::ShanghaiTen.create({
datetime: '2017-05-16', datetime: '2017-05-16',
cityname: 'shanghai', cityname: 'shanghai',
temp_high: '100', temp_high: '100',
...@@ -35,10 +35,13 @@ RSpec.describe WeatherModel do ...@@ -35,10 +35,13 @@ RSpec.describe WeatherModel do
}) })
expect(Forecast::ShanghaiTen.count).to eq(1) expect(Forecast::ShanghaiTen.count).to eq(1)
expect(Forecast::ShanghaiTen::Ohm.all.count).to eq(1) expect(Forecast::ShanghaiTen::Ohm.all.count).to eq(1)
# p 'p Forecast::ShanghaiTen::Ohm.all.first.attributes'
expect(Forecast::ShanghaiTen::Ohm.all.first.temp_low).to eq(mysql_obj.temp_low.to_s)
# 'ohm 对象 同步 mysql对象更新'
mysql_obj.update(temp_low: 99)
expect(Forecast::ShanghaiTen::Ohm.all.first.temp_low).to eq('99'), 'ohm 对象 同步 mysql对象更新'
# ttl 失败 # ttl 失败
p Forecast::ShanghaiTen::Ohm.all.to_a # p Forecast::ShanghaiTen::Ohm.all.to_a.map(&:get_ttl)
p Forecast::ShanghaiTen::Ohm.all.to_a.map(&:get_ttl)
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