ruby - Capybara testing of sinatra app fails -


i trying test sinatra app using minitest , capybara several errors on tests using capybara features fill_in or visit.

test_index gives:

undefined local variable or method `app' #

test_create_user gives:

invalid expression: .////form[@id = 'register']

test_same_email gives:

unable find css "#register"

test_login gives:

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

any suggestions on may 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"       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) , ruby -v 1.9.2p320.

----update----

finally got tests work incorporating steve's suggestions:

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

and asserting response using capybara_minitest_spec:

page.must_have_content "password" page.must_have_button "register" 

i answered more recent question posted sintra webrat.

acceptance testing of sinatra app using webrat fails

i think problem here same. try replacing:

capybara.app = sinatra::application 

with:

capybara.app = kimsin 

personally choose capybara on webrat.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -