Using implicit `subject` with `expect` in RSpec-2.11

前端 未结 3 804
隐瞒了意图╮
隐瞒了意图╮ 2020-12-08 06:50

With the new expect syntax in rspec-2.11, how is it possible to use the implicit subject? Is there a better way than explicitly referencing s

3条回答
  •  渐次进展
    2020-12-08 07:12

    One could use the new named subject syntax, although it's not implicit.

    describe User do
      subject(:author) { User.new }
    
      it 'is valid' do
        expect(author).to be_valid
      end
    end
    

提交回复
热议问题