Skip to content

Instantly share code, notes, and snippets.

@huacnlee
Created January 28, 2020 04:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huacnlee/64fa2f230b30c78d2f4edb870529cb26 to your computer and use it in GitHub Desktop.
Save huacnlee/64fa2f230b30c78d2f4edb870529cb26 to your computer and use it in GitHub Desktop.
RSpec to Minitest

RSpec to Minitest

Use Assertions method instead of RSpec expect.

expect to assert_equal

Cases

expect(response.status).to eq 400
expect(json["user"]["name"]).to eq current_user.name
expect(response.status).not_to eq(401)

Regexp

expect\((.+)\)\.(not_){0,1}to eq[\(\s](.+[^\}\)\s])[\)\s]{0,1}


assert_$2equal $3, $1

except be_nil

Cases

expect(json["user"]["avatar_url"]).to be_nil
expect(json["user"]["avatar_url"]).not_to be_nil

Regexp

expect\((.+)\)\.(not_){0,1}to be_nil

assert_$2nil $1

expect be_truthy

Cases

expect(state).to be_truthy
expect(state).not_to be_truthy

Regexp

expect\((.+)\)\.(not_){0,1}to be_truthy

assert_$2equal true, $1

expect be_falsey

Cases

expect(state).to be_falsey
expect(state).not_to be_falsey

Regexp

expect\((.+)\)\.(not_){0,1}to be_falsey

assert_$2equal false, $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment