I am looking through the discourse source code here https://github.com/discourse/discourse/blob/master/spec/models/invite_spec.rb and see code like this:
require 'spec_helper'
describe Invite do
it { should belong_to :user }
it { should have_many :topic_invites }
it { should belong_to :invited_by }
it { should have_many :topics }
it { should validate_presence_of :email }
it { should validate_presence_of :invited_by_id }
I'm unfamiliar with where they are getting a value for it
. It seems like they have an implicit object here but I don't see where they are creating it - should this be in a before hook?. They are using Fabricator instead of FactoryGirl - can somebody tell me how these are passing?
There is an implicit subject of Invite
. This is an RSpec feature:
The first argument to the outermost example group block is made available to each example as an implicit subject of that example.
See https://www.relishapp.com/rspec/rspec-core/v/2-0/docs/subject/implicit-subject