Sha256: effebc8488c504a9bcf679a617adbd490c1f05d3f751304b3ad2874da0de032e

Contents?: true

Size: 1.51 KB

Versions: 12

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'

describe Swearjar do

  it "should detect dirty words" do
    Swearjar.default.profane?('fuck you jim henson').should be_true
  end

  it "should detect dirty words regardless of case" do
    Swearjar.default.profane?('FuCk you jim henson').should be_true
  end

  it "should not detect non-dirty words" do
    Swearjar.default.profane?('i love you jim henson').should be_false
  end

  it "should give us a scorecard" do
    Swearjar.default.scorecard('fuck you jim henson').should == {'sexual'=>1}
  end

  it "should detect multiword" do
    Swearjar.default.scorecard('jim henson has a hard on').should == {'sexual'=>1}
  end

  it "should detect multiword plurals" do
    Swearjar.default.scorecard('jim henson has a hard ons').should == {'sexual'=>1}
  end

  it "should detect simple dirty plurals" do
    Swearjar.default.profane?('jim henson had two dicks').should be_true
    Swearjar.default.profane?('jim henson has two asses').should be_true
  end

  it "should censor a string" do
    Swearjar.default.censor('jim henson has a massive hard on he is gonna use to fuck everybody').should == 'jim henson has a massive **** ** he is gonna use to **** everybody'
  end

  it "should not do much when given a non-string" do
    Swearjar.default.profane?(nil).should be_false
  end

  it "should allow you to load a new yaml file" do
    sj = Swearjar.new
    sj.load_file(File.expand_path('../data/swear.yml', __FILE__))
    sj.censor("Python is the best language!").should == "****** is the best language!"
  end

end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
cf-swearjar-1.1.1 spec/swearjar_spec.rb
cf-swearjar-1.1.0 spec/swearjar_spec.rb
cf-swearjar-1.0.9 spec/swearjar_spec.rb
cf-swearjar-1.0.8 spec/swearjar_spec.rb
cf-swearjar-1.0.7 spec/swearjar_spec.rb
cf-swearjar-1.0.6 spec/swearjar_spec.rb
cf-swearjar-1.0.5 spec/swearjar_spec.rb
cf-swearjar-1.0.4 spec/swearjar_spec.rb
cf-swearjar-1.0.3 spec/swearjar_spec.rb
cf-swearjar-1.0.2 spec/swearjar_spec.rb
cf-swearjar-1.0.1 spec/swearjar_spec.rb
swearjar-1.0.0 spec/swearjar_spec.rb