Sha256: c2897463d4680b32bf754d0ccdf479a3b2fa9414c180d66c4be86a2f6f272f97

Contents?: true

Size: 1.03 KB

Versions: 7

Compression:

Stored size: 1.03 KB

Contents

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

describe "Chatterbot::Safelist" do
  describe "on_safelist?" do
    before(:each) do
      @bot = test_bot
      @bot.safelist = [fake_user('user', 100), "skippy", "blippy", "dippy"]
    end

    it "includes users we want" do
      expect(@bot.on_safelist?("user")).to eq(true)
      expect(@bot.on_safelist?("skippy")).to eq(true)
    end

    it "excludes users we don't want" do
      expect(@bot.on_safelist?("flippy")).to eq(false)
    end

    it "isn't case-specific" do
      expect(@bot.on_safelist?("FLIPPY")).to eq(false)
      expect(@bot.on_safelist?("SKIPPY")).to eq(true)
    end

    it "works with result hashes" do
      expect(@bot.on_safelist?(Twitter::Tweet.new(:id => 1,
                                            :user => {:id => 1, :screen_name => "skippy"}))).to eq(true)
      expect(@bot.on_safelist?(Twitter::Tweet.new(:id => 1,
                                            :user => {:id => 1, :screen_name => "flippy"}))).to eq(false)
    end   
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
chatterbot-2.2.0 spec/whitelist_spec.rb
chatterbot-2.1.0 spec/whitelist_spec.rb
chatterbot-2.0.5 spec/whitelist_spec.rb
chatterbot-2.0.4 spec/whitelist_spec.rb
chatterbot-2.0.3 spec/whitelist_spec.rb
chatterbot-2.0.2 spec/whitelist_spec.rb
chatterbot-2.0.0.pre spec/whitelist_spec.rb