Sha256: d6e205b5daaffff28b3a4a03eacea02034eec4ab3fca7ca2eb55da0550bccfb3

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

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

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

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

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

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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
chatterbot-1.0.2 spec/whitelist_spec.rb
chatterbot-1.0.1 spec/whitelist_spec.rb
chatterbot-1.0.0 spec/whitelist_spec.rb
chatterbot-0.9.3 spec/whitelist_spec.rb
chatterbot-0.9.2 spec/whitelist_spec.rb