spec/ppl/adapter/storage/disk_spec.rb in ppl-4.0.1 vs spec/ppl/adapter/storage/disk_spec.rb in ppl-4.0.2
- old
+ new
@@ -9,28 +9,28 @@
end
describe "#create_address_book" do
it "should create the directory if it doesn't exist yet" do
Ppl::Adapter::Storage::Disk.create_address_book("/contacts")
- Dir.exists?("/contacts").should eq true
+ expect(Dir.exists?("/contacts")).to eq true
FileUtils.rm_rf("/contacts")
end
it "should return a Ppl::Adapter::Storage::Disk" do
disk = Ppl::Adapter::Storage::Disk.create_address_book("/contacts")
FileUtils.rm_rf("/contacts")
- disk.should be_a(Ppl::Adapter::Storage::Disk)
+ expect(disk).to be_a(Ppl::Adapter::Storage::Disk)
end
end
end
describe Ppl::Adapter::Storage::Disk, "#initialize" do
it "should accept a Dir object" do
directory = Dir.new("/tmp")
@storage = Ppl::Adapter::Storage::Disk.new(directory)
- @storage.directory.should be directory
+ expect(@storage.directory).to be directory
end
end
describe Ppl::Adapter::Storage::Disk do
@@ -41,11 +41,11 @@
describe "#vcard_adapter=" do
it "should accept a vcard adapter" do
adapter = double(Ppl::Adapter::Vcard)
@storage.vcard_adapter = adapter
- @storage.vcard_adapter.should be adapter
+ expect(@storage.vcard_adapter).to be adapter
end
end
end
@@ -68,83 +68,83 @@
FakeFS.deactivate!
end
describe "#path" do
it "should return the path of the directory" do
- @storage.path.should eq "/contacts"
+ expect(@storage.path).to eq "/contacts"
end
end
describe "#load_address_book" do
it "should return a Ppl::Entity::AddressBook" do
- @storage.load_address_book.should be_a(Ppl::Entity::AddressBook)
+ expect(@storage.load_address_book).to be_a(Ppl::Entity::AddressBook)
end
it "should fill the address book with the contacts in the directory" do
FileUtils.touch "/contacts/one.vcf"
FileUtils.touch "/contacts/two.vcf"
- @adapter.should_receive(:decode).twice
+ expect(@adapter).to receive(:decode).twice
address_book = @storage.load_address_book
- address_book.contacts.count.should eq 2
+ expect(address_book.contacts.count).to eq 2
end
end
describe "#load_contact" do
it "should return nil if the given contact doesn't exist" do
- @storage.load_contact("xyz").should be nil
+ expect(@storage.load_contact("xyz")).to be nil
end
it "should return a Ppl::Entity::Contact" do
FileUtils.touch "/contacts/one.vcf"
- @adapter.should_receive(:decode).once.and_return(@contact)
- @storage.load_contact("one").should be_a(Ppl::Entity::Contact)
+ expect(@adapter).to receive(:decode).once.and_return(@contact)
+ expect(@storage.load_contact("one")).to be_a(Ppl::Entity::Contact)
end
it "should populate the contact's id" do
FileUtils.touch "/contacts/one.vcf"
- @adapter.should_receive(:decode).once.and_return(@contact)
- @storage.load_contact("one").id.should eq "one"
+ expect(@adapter).to receive(:decode).once.and_return(@contact)
+ expect(@storage.load_contact("one").id).to eq "one"
end
end
describe "#save_contact" do
it "should write the contact to disk" do
- @adapter.should_receive(:encode).with(@contact).and_return("asdfg")
+ expect(@adapter).to receive(:encode).with(@contact).and_return("asdfg")
@contact.id = "test"
@storage.save_contact(@contact)
- File.read("/contacts/test.vcf").should eq "asdfg"
+ expect(File.read("/contacts/test.vcf")).to eq "asdfg"
end
end
describe "#delete_contact" do
it "should remove the the contact from the disk" do
FileUtils.touch "/contacts/test.vcf"
@contact.id = "test"
@storage.delete_contact(@contact)
- File.exists?("/contacts/test.vcf").should eq false
+ expect(File.exists?("/contacts/test.vcf")).to eq false
end
end
describe "#filename_for_contact" do
it "should base the filename on the contact's id" do
@contact.id = "test"
- @storage.filename_for_contact(@contact).should eq "/contacts/test.vcf"
+ expect(@storage.filename_for_contact(@contact)).to eq "/contacts/test.vcf"
end
end
describe "#filename_for_contact_id" do
it "should base the filename on the directory path" do
- @storage.filename_for_contact_id("test").should eq "/contacts/test.vcf"
+ expect(@storage.filename_for_contact_id("test")).to eq "/contacts/test.vcf"
end
end
end