diff --git a/.rspec b/.rspec index 34c5164..210a1d6 100644 --- a/.rspec +++ b/.rspec @@ -1,3 +1,2 @@ --format documentation ---color ---require spec_helper +--color \ No newline at end of file diff --git a/spec/textstat_spec.rb b/spec/textstat_spec.rb new file mode 100644 index 0000000..2485222 --- /dev/null +++ b/spec/textstat_spec.rb @@ -0,0 +1,64 @@ +require 'rspec' +require_relative '../lib/textstat.rb' + +describe TextStat do + before do + @long_test = 'Playing ... games has always been thought to be ' \ + 'important to the development of well-balanced and ' \ + 'creative children; however, what part, if any, ' \ + 'they should play in the lives of adults has never ' \ + 'been researched that deeply. I believe that ' \ + 'playing games is every bit as important for adults ' \ + 'as for children. Not only is taking time out to ' \ + 'play games with our children and other adults ' \ + 'valuable to building interpersonal relationships ' \ + 'but is also a wonderful way to release built up ' \ + "tension.\n" \ + "There's nothing my husband enjoys more after a " \ + 'hard day of work than to come home and play a game ' \ + 'of Chess with someone. This enables him to unwind ' \ + "from the day's activities and to discuss the highs " \ + 'and lows of the day in a non-threatening, kick back ' \ + 'environment. One of my most memorable wedding ' \ + 'gifts, a Backgammon set, was received by a close ' \ + 'friend. I asked him why in the world he had given ' \ + 'us such a gift. He replied that he felt that an ' \ + 'important aspect of marriage was for a couple to ' \ + 'never quit playing games together. Over the years, ' \ + 'as I have come to purchase and play, with other ' \ + 'couples & coworkers, many games like: Monopoly, ' \ + 'Chutes & Ladders, Mastermind, Dweebs, Geeks, & ' \ + 'Weirdos, etc. I can reflect on the integral part ' \ + 'they have played in our weekends and our ' \ + '"shut-off the T.V. and do something more ' \ + 'stimulating" weeks. They have enriched my life and ' \ + 'made it more interesting. Sadly, many adults ' \ + 'forget that games even exist and have put them ' \ + 'away in the cupboards, forgotten until the ' \ + "grandchildren come over.\n" \ + 'All too often, adults get so caught up in working ' \ + 'to pay the bills and keeping up with the ' \ + "\"Joneses'\" that they neglect to harness the fun " \ + 'in life; the fun that can be the reward of ' \ + 'enjoying a relaxing game with another person. It ' \ + 'has been said that "man is that he might have ' \ + 'joy" but all too often we skate through life ' \ + 'without much of it. Playing games allows us to: ' \ + 'relax, learn something new and stimulating, ' \ + 'interact with people on a different more ' \ + 'comfortable level, and to enjoy non-threatening ' \ + 'competition. For these reasons, adults should ' \ + 'place a higher priority on playing games in their ' \ + 'lives' + end + + context 'When testing the TextStat class' do + it 'should return the correct number of chars' do + count = TextStat.char_count(@long_test) + count_spaces = TextStat.char_count(@long_test, false) + + expect(count).to eql 1750 + expect(count_spaces).to eql 2123 + end + end +end \ No newline at end of file diff --git a/textstat.gemspec b/textstat.gemspec index beb8c32..b2404e7 100644 --- a/textstat.gemspec +++ b/textstat.gemspec @@ -33,7 +33,7 @@ Gem::Specification.new do |spec| spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib/textstat.rb", "lib/easy_words.txt"] - spec.test_files = ["spec/spec_helper.rb", "spec/textstat_spec.rb"] + spec.test_files = ["spec/textstat_spec.rb", "lib/easy_words.txt"] spec.add_runtime_dependency "text-hyphen", "~> 1.4", ">= 1.4.1" spec.add_development_dependency "bundler", "~> 2.0.a"