public
Last active

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
# Old way, assumes that since this is a User test
# it should look for @user and use it in the
# macros if it's set. Otherwise it instantiates a
# User and uses that in the macro.
class UserTest < Whatever::TestCase
 
context "A user that is an admin" do
setup do
@user = User.new
@user.admin = true
end
 
should_validate_presence_of :name
end
 
end
 
# New way, specify what instance the macros
# should use.
class UserTest < Whatever::TestCase
 
context "A user that is an admin" do
setup do
@user = User.new
@user.admin = true
end
 
subject { @user }
 
should_validate_presence_of :name
end
 
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.