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 9303937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:35:51+00:00 2026-06-18T23:35:51+00:00

i have the following step definition: When /^I upload it$/ do end which relates

  • 0

i have the following step definition:

When /^I upload it$/ do

end

which relates to a file upload. the visit method in capybara, from what i can tell is a GET only method .. and the only way to do a POST request is by implementation:

visit "/files/new"
within('#upload-form') do
  attach_file('File', @files_path+'/file.txt')
  click_button('Upload')
end

this doesnt seem a very strong test, as its dependant on the HTML and form tags within the files/new template.

is there a better way to handle this, or is this OK to do? i had in mind something like this:

post files_new_path { file: => ‘a_file_on_the_system.txt’ }

but then again cucumber tests are integration tests .. so which is the ‘official’ or best way to write tests at this level?

  • 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-18T23:35:52+00:00Added an answer on June 18, 2026 at 11:35 pm

    The Capybara codes mimic human actions. You can’t expect human to “POST” but only “visit”, “click_button” etc.

    The syntax you mentioned would fit controller test better, but not integration test with Capybara.

    The best style in integration test, in my opinion, is to think and act like human being but not machine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting started with cucumber, and I have written the following step definition, which
I have a Spring Batch process which has following kind of code. <step id=step1
I have the following step definition written with Cucumber based on Calabash. The name
I have the following part of a step definition: page.should have_content Contraseña o Email
I'm using following construct in a cucumber step definition. Given I have following stuff
I have the following step: Then I should see an error message with identical
For strongly-typed & type-safe solution, I have to do the following step. Create some
I have got a the following problem: I have got multi-step form where in
I have a table like the following: RuleStep StepID | Step Property | Step
I have following div in a page (I can not modify). <div id=:0.control>Click me</div>

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.