RSpec.describe CreateUser do
subject(:create_user) do
CreateUser.new
end
context "with valid params" do
it "returns success" do
expect(create_user.(name: "Jane", email: "jane@doe.org")).to be_success
end
end
context "with invalid params" do
# THIS RIGHT HERE - BAD, VERY BAD `LET`
let(:create_user) do
CreateUser.new(some_custom: "stuff for this example")
end
it "returns failure when name is missing" do
expect(create_user.(name: "", email: "jane@doe.org")).to be_failure
end
it "returns failure when email is missing" do
expect(create_user.(name: "Jane", email: "")).to be_failure
end
end
end
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter