webrat

How to deal with hidden field with cucumber and webrat ?

I have to set a select date field with the month and day discarded. So Month and day are hidden in the form which caused a "undefined method `options' for # (NoMethodError)" when executing the cucumber scenario. How can i solve this issue and get the year correctly into the cucumber step ? ...

Weird problem: cucumber behaving differently when run with the debugger

When I run a cucumber test it executes the code thinking that a collection obtained inside of a controller via a has_many relationship on a model is empty when it isn't. I ran this same test but with the debugger turned on and a breakpoint before the collection is used. When I print collection in the debugger at this breakpoint the colle...

changing selenium domain/subdomain within cucumber scenarios

So, I have a Rails webapp that utilizes subdomains for separating the admin functionality from the public functionality using subdomain-fu. So there is functionality(that I want to test!) contained within two urls(eg admin.example.com and www.example.com). I want some scenarios to run against the admin domain, and some against the www d...

How can I test a form that requires the entry of two random characters from a security phrase?

I need to test a two-stage login system which first asks for your email address and password and then presents the user with two select lists containing [a-zA-Z0-9]. The labels beside the drop down's are of the form 'Select character X from your security phrase', where X is a random character index from a known security phrase. I'd rath...

How do I test an image alt value using capybara?

I'm trying to define a step to test the value of alt text of an image using capybara and the css selectors. I wrote one for input values based on the readme examples: Then /^I should see a value of "([^\"])" within the "([^\"])" input$/ do |input_value, input_id| element_value = locate("input##{input_id}").value element_value.s...

How to test css property in rspec?

I'm using tabnav plugin for Rails and I want to use rpsec to make sure it highlights properly. describe 'account navigation links' do it 'should have account settings link' do get '/account/settings' response.should have_tag("li", :text => "Account Settings") end it 'should be highlighted' do get '/account/settings' resp...

Webrat select_date selector failure.

Code in steps file: select_date user.date_of_birth, :from => "Date of birth" Selector fail When I register with valid user credentials # features/step_definitions/authentication_steps.rb:2 Could not find field: "user_date_of_birth_1i_1i" (Webrat::NotFoundError) ./features/step_definitions/authentication_steps.rb:9:in `/^I regis...

Testing across multiple sessions in merb using webrat

I want to test across multiple sessions using webrat in merb. Apparently, this is fairly easy to accomodate in Rails via: http://erikonrails.snowedin.net/?p=159. Following the same logic, I am trying to do something that follows that pattern for merb and webrat. Here is an attempt (which does not work because MerbAdapter does not respon...

What happens when you click a button using WebRat under cucumber

I am trying to login to a Java web application. The login page has the following html : <html> <head><title>Login Page</title></head> <body onload='document.f.j_username.focus();'> <h3>Login with Username and Password</h3> <form name='f' action='/ui/j_spring_security_check' method='POST'> <table> ...

Webrat and Rails: Using assert_contain after click_button gives me "You are being redirected"

I'm writing an integration test for a rails application using webrat. After filling out a form, the user presses submit and an account is created. click_button "Submit" assert_contain "Your Account Has Been Created" However, the test fails: expected the following element's content to include "Your Account Has Been Created": You are ...

Using Webrat to check a list has a specific number of li elements

For a cucumber step, I know that a particular ul element should have 5 children li. How can I assert this with Webrat? I'm guessing there could be something like: Then ".selector" should have n ".another-selector" or maybe Then I should see n ".selector" within ".another.selector" Is there anything like this floating around, or sho...

authlogic flash[:notice] does not show up in cucumber webrat step

Hi, I am running BDD steps with cucumber to implement my autlogic login behavior. Scenario: log in Given a registered user: "[email protected]" with password: "p@ssword" exists And I am on the homepage When I follow "Log in" And I fill in "Username" with "[email protected]" And I fill in "Password" with "p@ssword" And I open the page And I pre...

Webrat / Cucumber Matcher - Testing content match with links

Currently I have a like/dislike voting functionality that outputs in the following format: like (#) dislike (#) Where like and dislike are clickable links that update the total count of like/dislike votes (represented by (#)) I am writing a cucumber test to check the like/dislike counts are correct. I'd like to check ... Then I sh...

How can I test one, more or none images in a page with Cucumber?

I want to test if I have 0, 1, 2 or 3 times a pictures ('foo.png') in a certain page with Cucumber. How should I write the custom step? Thanks ...

How can I test with a certain word is a link or not with Cucumber?

I would like this custom step: Then I should see the link 'foo' and his opposite: But I should not see the link 'foo' In the page I can have something like: lorem foo bar or alternatively lorem <a href=''>foo</a> bar I need to test when 'foo' is a link and when isn't. Thank you. ...

undefined method `find_link' for #<Cucumber::Rails::World:0x818e02e8> (NoMethodError)

Rspec obviously hates me. I kinda hate him back. #features/step_definitions/custom_steps.rb Then /^I should see the link "([^\"]*)"$/ do |linked_text| find_link(linked_text) end #link.feature Then I should see the link "foo" From terminal: undefined method `find_link' for #<Cucumber::Rails::World:0x818e02e8> (NoMethodError) ./featu...

Cucumber, Webrat, Mechanize: can't access "response" variable

I am trying to use Cucumber+webrat+mechanize to test some web pages. In a simple example, I set up something like ... And I goto Home Then I should see "Welcome" And I have the following in my step file: Then /^I should see "([^\"]*)"$/ do |text| response_body.should contain(text) end I get an error, complaining that there is no...

Using Cucumber to test my OAuth provider in Rails

I have a rails site that allows authentication through OAuth (I use Restful Authentication and the Rails OAuth Plugin). To make sure that it worked, I made a quick site to act as an OAuth consumer. However, I want the testing to be self-contained in Cucumber features. Ideally, this would use Webrat so that Cucumber could correctly m...

Using Rails with webrat + selenium or only selenium?

Im reading The Rspec book and in that book, they are using webrat with selenium. I wonder if its possible to use selenium directly for integration tests in Rails instead of using it through webrat? What are the pros and cons with each way? ...

Webrat (web_steps.rb) not being used

When I execute the following cucumber script: Feature: Manage Customers In order to store customers As a user I want to create and manage customers Scenario Outline: Create Customer Given I am on new customer screen When I fill in Name with "Test Company" And I press "Create" Then I should see "Custome...