Pigeon-Ruby/spec/pigeon/bundle_spec.rb

31 lines
807 B
Ruby
Raw Normal View History

require "spec_helper"
RSpec.describe Pigeon::Message do
before(:each) do
2020-04-01 13:07:39 +00:00
p = Pigeon::DEFAULT_BUNDLE_PATH
File.delete(p) if File.file?(p)
Pigeon::Storage.reset
Pigeon::LocalIdentity.reset
end
2020-04-01 13:07:39 +00:00
def create_fake_messages
(1..10)
.to_a
2020-04-01 13:07:39 +00:00
.map do |n| { "foo" => ["bar", "123", SecureRandom.uuid].sample } end
.map do |d| Pigeon::Helpers.create_message(SecureRandom.uuid, d) end
2020-04-01 13:07:39 +00:00
end
it "creates a bundle" do
expected_bundle = create_fake_messages.map(&:render).join("\n\n") + "\n"
Pigeon::Bundle.create
actual_bundle = File.read(Pigeon::DEFAULT_BUNDLE_PATH)
expect(expected_bundle).to eq(actual_bundle)
end
2020-04-01 13:07:39 +00:00
it "does not crash when ingesting old messages" do
2020-04-01 13:07:39 +00:00
create_fake_messages
Pigeon::Bundle.create
Pigeon::Bundle.ingest
2020-04-01 13:07:39 +00:00
end
end