Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9010461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:27:59+00:00 2026-06-16T02:27:59+00:00

I am creating test cases for my app developed using Mojolicious framework. I am

  • 0

I am creating test cases for my app developed using Mojolicious framework. I am testing the routes for appropriate responses for the REST calls that are made. I use JSON as a means of communication between the server and client. To test GET, POST and DELETE requests I use the following functions

GET : get_ok()
POST: post_json_ok()
DELETE: delete_ok()

but for PUT I am not able to use put_ok(). And example of my usage of put_ok() would be

my $t = Test::Mojo->new;
$t->put_ok('this/is/url/to/resource'=>{ "element" => "modified value"})->status_is(204)

I get a bad request status every time(400) and so the test fails. I use Test::Mojo for testing my application.

Additional information:

$t->put_ok('http://localhost:3000/application/instances/system/test'=>{"model" => "testing put"})->status_is(204);

This is the exact test for PUT request that is attempted.
model is a property of resource test that is being attempted to be changed to testing put and the expected status response is 204.

The mapping to the controller is done by
$r->route('/application/instances/system/:id, id => qr/[A-Za-z0-9 ]+/ -> via('put')
->to(controller => 'system', action => 'update_sys');


This route calls the update_sys method in the system controller and that is how the resource is located.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:28:00+00:00Added an answer on June 16, 2026 at 2:28 am

    Actually, after discussions with SRI on IRC, he pointed me to an example almost identical you your needs in the documentation.

    # Test custom transaction
    my $tx = $t->ua->build_json_tx('/user/99' => {name => 'sri'});
    $tx->req->method('PUT');
    $t->tx($t->ua->start($tx))
      ->status_is(200)
      ->json_is('/message' => 'User has been replaced.');
    

    So this should work for you!

    Postscript:

    You might be interested to know that this discussion has brought some progress: the next release of Mojolicious (version 3.66) will now have a cleaner syntax for this purpose, the new request_ok method. The above example can then be rewritten as

    my $tx = $t->ua->build_json_tx('/user/99' => {name => 'sri'});
    $tx->req->method('PUT');
    $t->request_ok($tx)
      ->status_is(200)
      ->json_is('/message' => 'User has been replaced.');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a custom test runner for JUnit test cases using JUnitCore's run(junit.framework.Test
I'm creating the test cases for web-tests using Jenkins, Python, Selenium2(webdriver) and Py.test frameworks.
I am creating Junit test cases in Spring. private static BeanFactory servicefactory = null;
I'm creating test data for a Rails app. How do I define the value
I'm currently creating rspec test cases for a Rails 2.3 application. The problem I'm
I'm using Capybara through Cucumber to test a Rails app. The Rails app has
I am creating test cases and I need to cover circular dependencies. So far
i set my in app purchase creating two bundle id's .i created a test
When I test my app using OCUnit, it sets up the AppDelegate, window and
ASP.Net app in Visual Studio 2008 I'm creating unit tests to test (in)valid logins

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.