Sha256: 224ad6bd6ab344098dbf94648a581333b53d184969cc68afb709d0e79ea54260

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

require 'spec_helper'
require 'helpers'

describe Ayadn::Databases do
  before do
    Ayadn::Settings.stub(:config).and_return({
        paths: {
          db: 'spec/mock/',
          pagination: 'spec/mock/'
        }
      })
    Ayadn::Databases.open_databases
  end
  describe ".add_to_users_db" do
    it "adds a user" do
      Ayadn::Databases.add_to_users_db(33, 'test', 'Mr Test')
      expect(Ayadn::Databases.users.keys).to eq ['33']
      u = Ayadn::Databases.users[33]
      expect(u['test']).to eq 'Mr Test'
    end
  end
  describe ".add_to_users_db_from_list" do
    it "imports users from a list" do
      list = {12=>['yolo', 'Miss YOLO'], 666=>['lucy', 'Lucy Fair']}
      Ayadn::Databases.add_to_users_db_from_list(list)
      expect(Ayadn::Databases.users.keys).to eq ['12', '666']
      u = Ayadn::Databases.users[12]
      expect(u['yolo']).to eq 'Miss YOLO'
      u = Ayadn::Databases.users[666]
      expect(u['lucy']).to eq 'Lucy Fair'
    end
  end
  # describe ".save_max_id" do
  #   it "saves pagination" do


  #   end
  # end
  # describe ".has_new?" do
  #   it "check if new posts since last pagination record" do
  #     stream = {'meta'=>{'max_id'=>33666}}

  #   end
  # end
  after do
    Ayadn::Databases.users.clear
    Ayadn::Databases.close_all
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ayadn-1.0.3 spec/unit/databases_spec.rb
ayadn-1.0.2 spec/unit/databases_spec.rb