Sha256: 2377d15340555ac7e86a7ea4055e107e497a22fffddcf62a764412763a75a2d8

Contents?: true

Size: 1.4 KB

Versions: 5

Compression:

Stored size: 1.4 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
require 'tempfile'

describe "Chatterbot::ConfigManager" do
  before(:each) do
    @tmp_config_dest = "/tmp/bot.yml"
    @config = Chatterbot::ConfigManager.new(@tmp_config_dest, {:consumer_key => "bar"})
  end
  after(:each) do
    if File.exist?(@tmp_config_dest)
      File.unlink(@tmp_config_dest)
    end
  end

  describe "delete" do
    it "deletes a key" do
      expect(@config.delete(:baz)).to be_nil
    end

    it "works with missing key" do

    end

    it "retains read-only data" do
      expect(@config[:consumer_key]).to eql("bar")
      expect(@config.delete(:consumer_key)).to be_nil
      expect(@config[:consumer_key]).to eql("bar")
    end
  end

  describe "[]=" do
    it "writes a key" do
      expect(@config[:baz]).to be_nil
      @config[:baz] = "hello"
      expect(@config[:baz]).to eql("hello")
    end

    it "does not overwrite read-only data" do
      expect(@config[:consumer_key]).to eql("bar")
      @config[:consumer_key] = "baz"
      expect(@config[:consumer_key]).to eql("bar")
    end
  end

  describe "[]" do
    it "works with missing key" do
      expect(@config[:baz]).to be_nil
    end

    it "works with read-only data" do
      expect(@config[:consumer_key]).to eql("bar")
    end

    it "works with present key" do
      @config[:baz] = "hello"
      expect(@config[:baz]).to eql("hello")
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
chatterbot-2.0.5 spec/config_manager_spec.rb
chatterbot-2.0.4 spec/config_manager_spec.rb
chatterbot-2.0.3 spec/config_manager_spec.rb
chatterbot-2.0.2 spec/config_manager_spec.rb
chatterbot-2.0.0.pre spec/config_manager_spec.rb