HOW TO USE========== COMMAND LINE =============rspec --color --format doc spec/widget_spec.rb RAILS 3 (RSPEC 2) =============./rails/generate model Userrake -T spec # lists all rspec rake tasksrake spec # run all specsrake spec/models/mymodel_spec.rb # run a single spec filerake spec/models/mymodel_spec.rb:27 # run a single example or group on line 27 RAILS 2 (RSPEC 1) =============./script/generate rspec_model Userrake -T spec # lists all rspec rake tasksrake spec # run all specsrake spec SPEC=spec/models/mymodel_spec.rb SPEC_OPTS="-e \"should dosomething\"" #run a single specmodule UserSpecHelper def valid_user_attributes { :email => "joe@bloggs.com", :username => "joebloggs", :password => "abcdefg"} endenddescribe "A User (in general)" do include UserSpecHelper before(:each) do @user = User.new end it "should be invalid without a username" do pending "some other thing we depend on" @user.attributes = valid_user_attributes.except(:username) @user.should_not be_valid @user.should have(1).error_on(:username) @user.errors.on(:username).should == "is required" @user.username = "someusername" @user.should be_valid endendEXPECTATIONS=====================target.should satisfy {|arg| ...}target.should_not satisfy {|arg| ...}target.should equal target.should not_equal target.should be_close , target.should_not be_close , target.should be target.should_not be target.should predicate [optional args]target.should be_predicate [optional args]target.should_not predicate [optional args]target.should_not be_predicate [optional args]target.should be < 6target.should == 5target.should be_between(1, 10)target.should_not == 'Samantha'target.should match target.should_not match target.should be_an_instance_of target.should_not be_an_instance_of target.should be_a_kind_of target.should_not be_a_kind_of target.should respond_to target.should_not respond_to lambda {a_call}.should raise_errorlambda {a_call}.should raise_error( [, message])lambda {a_call}.should_not raise_errorlambda {a_call}.should_not raise_error( [, message])proc.should throw proc.should_not throw target.should include