LoginSignup
2
2

More than 1 year has passed since last update.

Forgery の mock を作る

Last updated at Posted at 2016-01-08

Forgery の Class は?

たとえば Forgery(:basic).text に対してモックを作りたいときは。
Forgery::Basic がクラスだ。なのでそれに対してモックを作る。

example_spec.rb
require 'spec_helper'

describe  do
  subject { Forgery(:basic).text }

  before do
    allow(Forgery::Basic).to receive(:text).and_return('mocked text')
  end

  it { should eq 'mocked text' }
end

結果

$ rspec example_spec.rb

テストが通る。

1 example, 0 failures

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

メンター受付

2
2
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
2
2