require 'spec_helper' describe "persistance" do let(:db){CouchPotato.database.couchrest_database} let(:db_uri){ File.join(db.host, db.name)} describe "database format" do it "persists with proper ruby class" do employee = create :employee response = Net::HTTP.get URI(File.join(db_uri, employee.id)) response.should include %|"ruby_class":"Employee"| response.should_not include %|"id":| end it "stores time in UTC iso8601 format" do time = Time.utc(1981, 3, 9, 13, 22, 2).in_time_zone Timecop.travel time do employee_shift = create :employee_shift, start_from: time, end_on: time + 2.hours response = JSON.parse Net::HTTP.get URI(File.join(db_uri, employee_shift.id)) response['created_at'].should eq "1981-03-09T13:22:02Z" response['updated_at'].should eq "1981-03-09T13:22:02Z" response['start_from'].should eq "1981-03-09T13:22:02Z" response['end_on'].should eq "1981-03-09T15:22:02Z" end end end end