Sha256: 77213c3cf5421b8e87487ac38ebe034474fe33c96d6eb1c441808d62e931fb85
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
require 'spec_helper' describe Mongoid::Fields do context 'delegate' do before do Bus.create_indexes end context 'x, y helpers' do let(:bus) { Bus.create!(name: 'Far', location: [7, 8]) } it 'should set instance method x' do expect(bus.x).to eq(7) end it 'should set instance method y' do expect(bus.y).to eq(8) end it 'should set instance method x=' do bus.x = 9 expect(bus.x).to eq(9) end it 'should set instance method y=' do bus.y = 9 expect(bus.y).to eq(9) end end it 'should set instance methods x= and y=' do bus = Bus.create!(name: 'B', location: [7, 7]) bus.x = 8 bus.y = 9 expect(bus.location.to_a).to eq([8, 9]) end it 'should work fine with default values' do event = Event.create!(name: 'Bvent') event.x = 8 event.y = 9 expect(event.location.to_a).to eq([8, 9]) end it 'should not work fine with nils' do bus = Bus.create!(name: 'B', location: nil) expect { bus.x = 9; bus.y = 9 }.to raise_error(NoMethodError) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongoid-geospatial-4.0.1 | spec/mongoid/geospatial/helpers/delegate_spec.rb |