LoginSignup
6
3

More than 5 years have passed since last update.

インスタンス変数を参照するヘルパーメソッドのSpecを書く

Posted at

assignメソッドを使ってインスタンス変数に値をセットすることができる。

以下、some_instance_variableという名前のインスタンス変数に'FooBar'という値をセットしている例。

describe '#helper_method'
  subject { helper.helper_method }
  before do
    assign(:some_instance_variable, 'FooBar')
  end
  it { … }
end

参考:
helper spec - Helper specs - RSpec Rails - RSpec - Relish

6
3
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
6
3