spec/processor/persistence_spec.rb in pupa-0.0.9 vs spec/processor/persistence_spec.rb in pupa-0.0.10
- old
+ new
@@ -3,11 +3,11 @@
describe Pupa::Processor::Persistence do
before :all do
Pupa.session = Moped::Session.new(['localhost:27017'], database: 'pupa_test')
Pupa.session.collections.each(&:drop)
- Pupa::Processor::Persistence.new(Pupa::Person.new(name: 'existing')).save
+ Pupa::Processor::Persistence.new(Pupa::Person.new(_id: 'existing', name: 'existing')).save
Pupa.session[:people].insert(_type: 'pupa/person', name: 'non-unique')
Pupa.session[:people].insert(_type: 'pupa/person', name: 'non-unique')
end
@@ -25,14 +25,14 @@
end
end
describe '#save' do
it 'should insert a document if no matches' do
- Pupa::Processor::Persistence.new(Pupa::Person.new(_id: 'new', name: 'new')).save.should == 'new'
+ Pupa::Processor::Persistence.new(Pupa::Person.new(_id: 'new', name: 'new')).save.should == [true, 'new']
end
it 'should update a document if one match' do
- Pupa::Processor::Persistence.new(Pupa::Person.new(_id: 'existing', name: 'existing')).save.should_not == 'existing'
+ Pupa::Processor::Persistence.new(Pupa::Person.new(_id: 'changed', name: 'existing')).save.should == [false, 'existing']
end
it 'should raise an error if many matches' do
expect{Pupa::Processor::Persistence.new(Pupa::Person.new(name: 'non-unique')).save}.to raise_error(Pupa::Errors::TooManyMatches)
end