[rspec-users] How to write a feature that calls for a prompt?

Pat Maddox pat.maddox at gmail.com
Wed Apr 15 11:56:21 EDT 2009


You can use IO.popen to run and interact with a command line program.

Pat

On Tue, Apr 14, 2009 at 1:58 PM, Colfer, Brian <bcolfer at shopping.com> wrote:
> I am writing a feature that will test an LDAP protected site.  I need to
> login as my self with my real password.
>
> I'm thinking of writing a feature that looks something like this
>
> Feature: Login
>
> As a LDAP user
> I want to login
> And see the welcome banner
> So that I can know that I can login to the system
>
> Scenario: LDAP login
>
> Given a LDAP user
> When I go to the site "https://toolsite.domain.com"
> And I enter the login name "enter_login_name"
> And I enter the password "enter_password"
> Then I should see the welcome banner "Tool Site at Domain.com"
>
> I imagine that I can have a step that would look something like this?
>
> require 'highline/import'
> require 'my-user-def'
> require 'my-site-runner'
>
> Given /^a LDAP user$/ do
>   @user.new
> end
>
> When /^I go to the site "([^\"]*)"$/ do |arg1|
>   @site.goto(arg1)
> end
>
> When /^I enter the login name "([^\"]*)"$/ do |arg1|
>   if arg1 == "enter_login_name"
>       @user.login_name = ask("Enter login name") {|q| q.echo = true}
>   end
> end
>
> When /^I enter the password "([^\"]*)"$/ do |arg1|
>   if arg1 == "enter_password"
>       @user.password = ask("Enter password") {|q| q.echo = false}
>   end
> end
>
> Then /^I should see the welcome banner "([^\"]*)"$/ do |arg1|
>   @site.text.include? arg1 == true
> end
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list