Module: RSpec::Has

Defined in:
lib/rspec/has.rb

Instance Method Summary collapse

Instance Method Details

#hasObject

Note:

This only works if you are using rspec-expectations.

describe UserFactory do

  subject { UserFactory.create_user }

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

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

See Also:

  • #subject
  • #should
  • #is_expected


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

def has
  expect { subject }
end