LoginSignup
1
1

More than 5 years have passed since last update.

rspecのprepend_beforeの実行順について調べてみた

Last updated at Posted at 2017-06-28

rspec 3.5.0で調査。

require 'rails_helper'

RSpec.describe 'sample', type: :model do

  prepend_before { puts "outside prepend_before" }
  before { puts "outside before" }

  context "context" do
    prepend_before { puts "inside prepend_before" }
    before { puts "inside before" }

    it { expect(true).to eq true }
  end
end

実行結果

outside prepend_before
outside before
inside prepend_before
inside before

inside prepend_beforeよりもoutside beforeが先なのね。
変えてくれないかなこの挙動。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1