Module: RSpec::WillBeExpected

Defined in:
lib/rspec/will_be_expected.rb

Instance Method Summary collapse

Instance Method Details

#will_be_expectedObject

Note:

This only works if you are using rspec-expectations.

describe UserFactory do

  subject { UserFactory.create_user }

  it { will_be_expected.to change(User.count).by(1) }
  it { will_be_expected.to output.to_stdout }

  context 'with database issues' do
    it { will_be_expected.to output.to_stderr }
    it { will_be_expected.to raise_error }
  end
end

See Also:

  • #subject
  • #should
  • #is_expected


29
30
31
# File 'lib/rspec/will_be_expected.rb', line 29

def will_be_expected
  expect { subject }
end