Permalink
Browse files

Added initial set of rSpec tests.

  • Loading branch information...
runpaint committed Apr 26, 2009
1 parent bfda116 commit 8d44b545e5c674761a9285a43583daad5b10fb00
Showing with 83 additions and 5 deletions.
  1. +13 −0 spec/eye/new_spec.rb
  2. +31 −0 spec/eye/see_spec.rb
  3. +39 −0 spec/eye/seen_spec.rb
  4. +0 −5 spec/eye_spec.rb
View
@@ -0,0 +1,13 @@
+describe "Eye.new" do
+
+ it "initialises without arguments" do
+ lambda{eye = Eye.new}.should_not raise_error
+ end
+
+ it "creates an instance of Eye" do
+ eye = Eye.new
+ eye.class.should == Eye
+ eye.should.is_a?(Eye)
+ end
+
+end
View
@@ -0,0 +1,31 @@
+describe "Eye.see" do
+
+ before(:each) do
+ @eye = Eye.new
+ end
+
+ it "is a method" do
+ @eye.should.respond_to? :see
+ end
+
+ it "takes a single argument" do
+ lambda{@eye.see("string")}.should_not raise_error
+ end
+
+ it "raises an ArgumentError if called without arguments" do
+ lambda{@eye.see}.should raise_error(ArgumentError)
+ end
+
+ it "raises an ArgumentError if called with more than one argument" do
+ lambda{@eye.see(1,2)}.should raise_error(ArgumentError)
+ lambda{@eye.see("string",['glark'],"bar")}.should raise_error(ArgumentError)
+ end
+
+ it "returns true if the object was recorded" do
+ ['Kim', 'http://example.com/'].each do |obj|
+ @eye.see(obj).should == true
+ end
+ end
+
+end
+
View
@@ -0,0 +1,39 @@
+describe "Eye.seen?" do
+
+ before(:each) do
+ @eye = Eye.new
+ end
+
+ it "is a method" do
+ @eye.should.respond_to? :seen?
+ end
+
+ it "takes a single argument" do
+ lambda{@eye.seen?("string")}.should_not raise_error
+ end
+
+ it "raises an ArgumentError if called without arguments" do
+ lambda{@eye.seen?}.should raise_error(ArgumentError)
+ end
+
+ it "raises an ArgumentError if called with more than one argument" do
+ lambda{@eye.seen?(1,2)}.should raise_error(ArgumentError)
+ lambda{@eye.seen?("string",['glark'],"bar")}.should raise_error(ArgumentError)
+ end
+
+ it "returns true if .see(obj) has been called previously" do
+ ['Kim', 'http://example.com/'].each do |obj|
+ @eye.see obj
+ @eye.seen?(obj).should == true
+ end
+ @eye.seen?('Kim').should == true
+ end
+
+ it "returns false unless .see(obj) has been called previously" do
+ ['The Tao of Pooh', 29, 30.3].each do |obj|
+ @eye.seen?(obj).should == false
+ end
+ @eye.seen?(29).should == false
+ end
+
+end
View
@@ -1,7 +1,2 @@
require 'spec_helper'
-describe "Eye" do
- it "fails" do
- fail "hey buddy, you should probably rename this file and start specing for real"
- end
-end

0 comments on commit 8d44b54

Please sign in to comment.