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

  • Home
  • SEARCH
  • 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 8090691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:48:30+00:00 2026-06-05T19:48:30+00:00

I am trying to test a sinatra app using minitest and capybara but get

  • 0

I am trying to test a sinatra app using minitest and capybara but get several errors on all tests using capybara features like fill_in or visit.

test_index gives:

undefined local variable or method `app’ for #

test_create_user gives:

Invalid expression: .////form[@id = ‘register’]

test_same_email gives:

Unable to find css “#register”

test_login gives:

cannot fill in, no text field, text area or password field with id,
name, or label ’email’ found

Any suggestions on what may be wrong?

test.rb

require "test/unit"
require "minitest/autorun"
require "capybara"
require "capybara/dsl"
require "rack/test"
require_relative "../lib/kimsin.rb"

ENV["RACK_ENV"] = "test"

class KimsinTests < Test::Unit::TestCase
  include Rack::Test::Methods
  include Capybara::DSL
  Capybara.app = Sinatra::Application

  def test_index
    visit "/"
    assert stuff..
  end

  def test_create_user
    visit "/user/new"
    within "//form#register" do
      fill_in :username, :with => "first@company.com"
      fill_in :password, :with => "abC123?*"
      fill_in :confirm_password, :with => "abC123?*"
      click_link "Register"
    end
    assert stuff..
  end
end

I’m using cygwin 1.7.15-1 on windows 7, rvm -v 1.14.1 (stable) and ruby -v 1.9.2p320.

—-UPDATE—-

Finally I got the tests work by incorporating Steve’s suggestions:

within "form#register" do
fill_in "email", :with => "first@company.com"
click_button "Register"

and asserting the response by using capybara_minitest_spec:

page.must_have_content "Password"
page.must_have_button "Register"
  • 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-05T19:48:31+00:00Added an answer on June 5, 2026 at 7:48 pm

    I just answered a more recent question you posted about Sintra with Webrat.

    Acceptance testing of sinatra app using webrat fails

    I think the problem here is the same. Try replacing:

    Capybara.app = Sinatra::Application
    

    with:

    Capybara.app = Kimsin
    

    Personally I would choose Capybara over Webrat.

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

Sidebar

Related Questions

I'm trying to get my first Sinatra app off the ground, but am getting
I'm trying to use Capybara + Rspec to test a Sinatra app, and I'm
Trying to test deploy a simple Rails 3.1 app in production mode, using the
I'm using ActionMailer to send emails, but I'd like to use Sinatra's Tilt rendering.
just trying to test for equality in this piece of code, but getting a
I trying to test an AccountController that uses DotNetOpenAuth but I am running into
Im trying to test my successfully creates a new user after login (using authlogic).
I'm trying to test some TPL dataflow code and run into what looks like
I'm trying to test an app that creates some custom permissions during intialization. These
I'm trying to test jasperreport and wrote Java code but it giving me error:

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.