title: How do RSpec's let and let! replace the original parameters?
body: <p>In the process of writing tests in Rspec, if you encounter repeated required parameters {...}, you can use <code>let</code> to write it. This avoids writing a bunch of parameter preparations in advance for each example.</p>
  <p>However, I don't quite understand the paradigm of Better Specs. His original code is this:</p>
  <pre><code>describe '#type_id' do
    before { @resource = FactoryBot.create :device }
    before { @type     = Type.find @resource.type_id }
  
    it 'sets the type_id field' do
      expect(@resource.type_id).to eq(@type.id)
    end
  end
  </code></pre>
  <p>After using let it becomes the following</p>
  <pre><code>describe '#type_id' do
    let(:resource) { FactoryBot.create :device }
    let(:type)     { Type.find resource.type_id }
  
    it 'sets the type_id field' do
      expect(resource.type_id).to eq(type.id)
    end
  end
  </code></pre>
  <p>It looks like the way to call a <code>resource</code> is pretty much the same, what's the benefit of using let ? What is the function of <code>FactoryBot.create:device</code>? And I can't see where <code>type</code> is being called?</p>