Module | Shoulda::InstanceMethods |
In: |
lib/shoulda/context.rb
|
Returns an instance of the class under test.
class UserTest should "be a user" do assert_kind_of User, subject # passes end end
The subject can be explicitly set using the subject class method:
class UserTest subject { User.first } should "be an existing user" do assert !subject.new_record? # uses the first user end end
The subject is used by all macros that require an instance of the class being tested.