Sha256: 055b32efca3f0f42edb1ab7d89f35fdf37670a57524dc858c375462b13352414

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

require 'spec_helper'

describe Wordini do
	describe "#obfuscator" do

		before(:each) do
			@word_string = "this string is an awesome string"
			@words_to_remove = ["this", "is", "not", "a", "string"]
		end

		it "takes a string as the first argument" do
			Wordini.obfuscate(@word_string, @words_to_remove)
			@word_string.should be_an_instance_of(String)
		end

		it "takes an string or array as the second argument" do
			Wordini.obfuscate(@word_string, @words_to_remove)
			@words_to_remove.should be_an_instance_of(Array)
		end

		it "does not take other first arguments besides a string" do
			@word_string = ["cow"]
			lambda {Wordini.obfuscate(@word_string, @words_to_remove)}.should raise_error
		end

		it "does not take other second arguments besides an array or string" do
			@words_to_remove = 8
			lambda {Wordini.obfuscate(@word_string, @words_to_remove)}.should raise_error
		end

		it "maintains the same number of 'words' in string" do
			new_string = Wordini.obfuscate(@word_string, @words_to_remove)
			new_string.split.count.should == 6
		end

		it "replaces the chosen words with *" do
			new_string = Wordini.obfuscate(@word_string, @words_to_remove)
			split_array = new_string.split('')
			remaining_char = split_array - ["*"]
			remaining_char.count.should == 14
		end

		it "contains replaced words with equivalent * count for word_char" do
			new_string = Wordini.obfuscate(@word_string, @words_to_remove)
			split_array = new_string.split('')
			count = split_array.select{ |star| star == '*' }.size
			count.should == 18
		end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wordini-0.0.0 spec/wordini_spec.rb