]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/examples/pure/greeter_spec.rb
added RSpec and RSpec on Rails
[rails.git] / vendor / gems / rspec-1.1.2 / examples / pure / greeter_spec.rb
1 require File.dirname(__FILE__) + '/spec_helper'
2 # greeter.rb
3 #
4 # Based on http://glu.ttono.us/articles/2006/12/19/tormenting-your-tests-with-heckle
5 #
6 # Run with:
7 #
8 #   spec greeter_spec.rb --heckle Greeter
9 #
10 class Greeter
11   def initialize(person = nil)
12     @person = person
13   end
14
15   def greet
16     @person.nil? ? "Hi there!" : "Hi #{@person}!"
17   end
18 end
19
20 describe "Greeter" do
21   it "should say Hi to person" do
22     greeter = Greeter.new("Kevin")
23     greeter.greet.should == "Hi Kevin!"
24   end
25
26   it "should say Hi to nobody" do
27     greeter = Greeter.new
28     # Uncomment the next line to make Heckle happy
29     #greeter.greet.should == "Hi there!"
30   end
31 end