Skip to content

Instantly share code, notes, and snippets.

@rhysforyou
Created February 22, 2012 06:23
Show Gist options
  • Select an option

  • Save rhysforyou/1882204 to your computer and use it in GitHub Desktop.

Select an option

Save rhysforyou/1882204 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe Game do
subject { FactoryGirl.build :game }
it "requires a title" do
subject.title = ""
subject.save.should be_false
subject.errors.should include("can't be blank")
end
end
› rake spec
/Users/rpowell/.rvm/rubies/ruby-1.9.3-p0/bin/ruby -S rspec ./spec/controllers/games_controller_spec.rb ./spec/helpers/games_helper_spec.rb ./spec/models/game_spec.rb ./spec/views/games/new.html.erb_spec.rb
.F
Failures:
1) Game requires a title
Failure/Error: subject.errors.should include("can't be blank")
expected #<ActiveModel::Errors:0x007fa4ee1a6c98 @base=#<Game id: nil, title: "", created_at: nil, updated_at: nil>, @messages={:title=>["can't be blank"]}> to include "can't be blank"
Diff:
@@ -1,2 +1,4 @@
-["can't be blank"]
+#<ActiveModel::Errors:0x007fa4ee1a6c98
+ @base=#<Game id: nil, title: "", created_at: nil, updated_at: nil>,
+ @messages={:title=>["can't be blank"]}>
# ./spec/models/game_spec.rb:9:in `block (2 levels) in <top (required)>'
Finished in 0.07394 seconds
2 examples, 1 failure
Failed examples:
rspec ./spec/models/game_spec.rb:6 # Game requires a title
rake aborted!
/Users/rpowell/.rvm/rubies/ruby-1.9.3-p0/bin/ruby -S rspec ./spec/controllers/games_controller_spec.rb ./spec/helpers/games_helper_spec.rb ./spec/models/game_spec.rb ./spec/views/games/new.html.erb_spec.rb failed
Tasks: TOP => spec
(See full trace by running task with --trace)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment