-
-
Save paulcsmith/d44ac002bd1b7c57dcb8f7217ac499a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it "creates new users" do | |
conn.nested_params :user, name: "Paul", email: "foo@bar.com" | |
conn.params page: 1 | |
conn.headers "CONTENT_TYPE" => "text/url-form-encoded" | |
conn.request Users::Create | |
conn.response.body.should contain "Success!" | |
end | |
private def conn | |
TestConn.build # Build create a new conn or gets the global one | |
# Hook up after_spec to clean out test connections after each test | |
end | |
# Or make your own connection | |
class AdminConn < TestConn | |
def sign_in(admin : Admin) | |
session :user_id, admin.id.to_s | |
end | |
end | |
private def conn | |
AdminConn.build | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Includes the methods directly so it's easier to work with in tests :D | |
# Also auto includes matchers | |
private include TestConn | |
# Or add a new describe that le's you add helpers. Does a private include and includes matchers if present | |
describe Users::Create, with_helper: TestConn do | |
it "creates a user" do | |
nested_params :user, UserBox.params | |
set_cookie :user_id, AdminBox.create.id.to_s | |
request Users::Create.route | |
response.body.should contain "Created!" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment