Sha256: 00d6585930800a5d5babe62613063556292341b3921901acf4a94979b796d457
Contents?: true
Size: 967 Bytes
Versions: 3
Compression:
Stored size: 967 Bytes
Contents
require 'spec_helper' class MyPlugin include Cinch::Plugin def initialize(*args) super @storage = CinchStorage.new(config[:filename] || '/dev/null', []) end match /store (.*)/ def execute(m, thing) @storage.data << thing @storage.synced_save(@bot) end end describe CinchStorage do include Cinch::Test before(:each) do @filename = '/tmp/storage_test.tmp' File.delete(@filename) if File.exist?(@filename) @bot = make_bot(MyPlugin, { :filename => @filename }) end it 'should allow users to store information between bot runs' do storage = CinchStorage.new(@filename, []) storage.data << 'foo' storage.save CinchStorage.new(@filename).data. should include 'foo' end it 'should handle multiple bot threads attempting to write to the same file' do 10.times { |x| get_replies(make_message(@bot, "!store #{x}"))} CinchStorage.new(@filename).data.length. should == 10 end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cinch-storage-1.0.3 | spec/cinch-storage_spec.rb |
cinch-storage-1.0.2 | spec/cinch-storage_spec.rb |
cinch-storage-1.0.0 | spec/cinch-storage_spec.rb |