Module: Testable::Context

Defined in:
lib/testable/context.rb

Instance Method Summary collapse

Instance Method Details

#on(definition, &block) ⇒ Object

Creates a definition context for actions. If an existing context exists, that context will be re-used. You can use this simply to keep the context for a script clear. For example, say you have the following interface definitions for pages:

class Home
  include Testable
  url_is "http://localhost:9292"
end

class Navigation
  include Testable
end

You could then do this:

on_visit(Home)
on(Navigation)

The Home definition needs the url_is attribute in order for the on_view factory to work. But Navigation does not because the ‘on` method is not attempting to visit, simply to reference.



44
45
46
47
# File 'lib/testable/context.rb', line 44

def on(definition, &block)
  create_active(definition)
  call_block(&block)
end

#on_visit(definition, &block) ⇒ Object

Creates a definition context for actions and establishes the context for execution. Given an interface definition for a page like this:

class TestPage
  include Testable

  url_is "http://localhost:9292"
end

You can do the following:

on_visit(TestPage)


15
16
17
18
19
20
# File 'lib/testable/context.rb', line 15

def on_visit(definition, &block)
  create_active(definition)
  @context.visit
  verify_page(@context)
  call_block(&block)
end