Forum: RSpec How to write a feature that calls for a prompt?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Brian C. (Guest)
on 2009-04-15 01:03
(Received via mailing list)
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
Phlip (Guest)
on 2009-04-15 07:28
(Received via mailing list)
Colfer, Brian wrote:
> I am writing a feature that will test an LDAP protected site.  I need to
> login as my self with my real password.

When unit testing, thou shalt not hit the wire. Mock anything that goes
further
than your database.

Put another way, you are not going to refactor LDAP itself, or add
features to
it, so mocks should set the boundaries to what you do expect to
refactor.
Brian C. (Guest)
on 2009-04-15 11:01
(Received via mailing list)
Phlip,

Ah, but I am not unit testing ... I am writing an acceptance test. I am
QA, not the developer and using cucumber to automate the functional and
acceptance tests.

Brian
Aslak H. (Guest)
on 2009-04-15 12:05
(Received via mailing list)
On Wed, Apr 15, 2009 at 8:46 AM, Colfer, Brian 
<removed_email_address@domain.invalid>
wrote:

> Phlip,
>
> Ah, but I am not unit testing ... I am writing an acceptance test. I am
> QA, not the developer and using cucumber to automate the functional and
> acceptance tests.
>

By LDAP protected site - do you mean a web application that has a login
form
and a server component that authenticates the user against an LDAP
server?
Is this a Rails app? Or a web app in some other language? Not a web app
at
all?

Users usually don't access LDAP directly, but via some user interface,
so
interacting directly with LDAP from Cucumber sounds wrong to me.

Can you describe the architecture of your application a little more?
What
language, framework and components is it built on, and how are they
connected?

Aslak
Pat M. (Guest)
on 2009-04-15 20:02
(Received via mailing list)
You can use IO.popen to run and interact with a command line program.

Pat
This topic is locked and can not be replied to.