File: model_mocks_integration_spec.rb

package info (click to toggle)
ruby-rspec-rails 7.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,796 kB
  • sloc: ruby: 11,068; sh: 198; makefile: 6
file content (15 lines) | stat: -rw-r--r-- 426 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
require 'rails_helper'

RSpec.describe "Using rspec-mocks with models" do
  it "supports stubbing class methods on models" do
    allow(Widget).to receive(:all).and_return(:any_stub)
    expect(Widget.all).to be :any_stub
  end

  it "supports stubbing attribute methods on models" do
    a_widget = Widget.new
    allow(a_widget).to receive(:name).and_return("Any Stub")

    expect(a_widget.name).to eq "Any Stub"
  end
end