Skip to content

Commit

Permalink
refactored test to use shoulda macro
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared Carroll committed Jan 9, 2009
1 parent bd52641 commit c3b3c9c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 25 deletions.
2 changes: 1 addition & 1 deletion shoulda_macros/webster.rb
@@ -1,4 +1,4 @@
module Webster
class Webster
module Shoulda
# Example:
# context "Subscription#activation_code" do
Expand Down
27 changes: 3 additions & 24 deletions test/webster_test.rb
@@ -1,6 +1,7 @@
require 'test/unit'
require 'rubygems'
require 'shoulda'
require File.join(File.dirname(__FILE__), '..', 'shoulda_macros', 'webster')
require File.join(File.dirname(__FILE__), "..", "lib", "webster")

class WebsterTest < Test::Unit::TestCase
Expand All @@ -27,32 +28,10 @@ class WebsterTest < Test::Unit::TestCase
context "#random_word" do
setup do
webster = Webster.new
@random = webster.random_word
@word = webster.random_word
end

should "be a String" do
assert_kind_of String, @random
end

should "be downcase" do
assert_equal @random, @random.downcase
end

should "be greater than or equal to five characters long" do
assert @random.length >= 5, "#{@random.inspect}, length: #{@random.length}"
end

should "be less than or equal to nine characters long" do
assert @random.length <= 9, "#{@random.inspect}, length: #{@random.length}"
end

should "not contain a carriage return" do
assert_no_match /\n/, @random
end

should "be a word in the dictionary" do
assert Webster::DICTIONARY.include?(@random)
end
should_be_webster_word '@word'
end

end

0 comments on commit c3b3c9c

Please sign in to comment.