How to Test a Concern in Rails

后端 未结 4 1053
[愿得一人]
[愿得一人] 2020-12-07 10:36

Given that I have a Personable concern in my Rails 4 application which has a full_name method, how would I go about testing this using RSpec?

4条回答
  •  独厮守ぢ
    2020-12-07 11:07

    just include your concern in spec and test it if it returns the right value.

    RSpec.describe Personable do
      include Personable
    
      context 'test' do
        let!(:person) { create(:person) }
    
        it 'should match' do
           expect(person.full_name).to eql 'David King'
        end
      end
    end
    

提交回复
热议问题