RSpec test of "wrong number of arguments" error fails in some environments

Viewed 919

I have an issue in my test.

I have this spec:

context 'when no section is supplied' do
  it 'raises an ArgumentError regarding the missing section_id argument' do
    expect do
      described_class.with_section
    end.to raise_error(ArgumentError)
      .with_message /wrong number of arguments \(given 0\, expected 1\)/
  end
end

In some environments the message is:

ArgumentError: wrong number of arguments (0 for 1)

In other environments the message is:

ArgumentError: wrong number of arguments (given 0, expected 1)

So I have a test that passes on my Mac and fails on another computer.

How can I fix this?

2 Answers
Related