test/test_timeframe.rb in timeframe-0.2.0 vs test/test_timeframe.rb in timeframe-0.2.1

- old
+ new

@@ -273,27 +273,28 @@ Timeframe.parse(plain_year).must_equal Timeframe.new(:year => plain_year) Timeframe.parse(plain_year.to_s).must_equal Timeframe.new(:year => plain_year) end it 'understands JSON' do json =<<-EOS - 2009-05-01/2009-06-01 + "2009-05-01/2009-06-01" EOS Timeframe.parse(json).must_equal Timeframe.new(:year => 2009, :month => 5) end it 'understands a particular style of Ruby hash we used to emit (deprecated)' do hsh = { :startDate => '2009-05-01', :endDate => '2009-06-01' } Timeframe.parse(hsh).must_equal Timeframe.new(:year => 2009, :month => 5) Timeframe.parse(hsh.stringify_keys).must_equal Timeframe.new(:year => 2009, :month => 5) end end - describe '#to_json' do + describe '#as_json' do it 'should generate JSON (test fails on ruby 1.8)' do - Timeframe.new(:year => 2009).to_json.must_equal %{2009-01-01/2010-01-01} + Timeframe.new(:year => 2009).as_json.must_equal %{2009-01-01/2010-01-01} + MultiJson.dump(Timeframe.new(:year => 2009)).must_equal Timeframe.new(:year => 2009).as_json.inspect end - it 'understands its own #to_json' do + it 'understands its own JSON' do t = Timeframe.new(:year => 2009, :month => 5) - Timeframe.from_json(t.to_json).must_equal t + Timeframe.from_json(MultiJson.dump(t)).must_equal t end end describe '#to_param' do it 'should generate a URL-friendly parameter' do