Sha256: a1461c51bbdcc38342c5cead753785ddbf6af170fb606785d4b78f8530c11b5e

Contents?: true

Size: 1.09 KB

Versions: 19

Compression:

Stored size: 1.09 KB

Contents

= Toplevel Simulation

QED simulates Ruby's TOPLEVEL environment in both the Demonstrandum
and the Applique contexts. This serves two important purposes.
First, it provides the tester the environment that is most intutive.
And second, and more importantly, it stays out of the actual
TOPLEVEL space to prevent any potential interferece with any of 
the code it is intended to test.

Let's look at some examples. For starters, we have access to a class
defined at the "toplevel" in the applique.

  ToplevelClass

We can also call a method defined in the toplevel.

  toplevel_method.assert == true

At the demonstrandum level we can define reusable methods.

  def demo_method
    true
  end

  demo_method.assert == true

And at the demonstrandum level even singleton methods are accessible.

  def self.singleton_method; true; end

  singleton_method.assert == true

QED uses a self-extend modules to achieve this simulation, so the
contexts are in fact a bit more capable then even Ruby's TOPLEVEL.
For instance, #define_method can be used.

  define_method(:named_method){ true }

  named_method.assert == true

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
qed-2.9.0 qed/07_toplevel.rdoc
qed-2.8.8 qed/07_toplevel.rdoc
qed-2.8.7 qed/07_toplevel.rdoc
qed-2.8.6 qed/07_toplevel.rdoc
qed-2.8.5 qed/07_toplevel.rdoc
qed-2.8.4 qed/07_toplevel.rdoc
qed-2.8.3 qed/07_toplevel.rdoc
qed-2.8.2 qed/07_toplevel.rdoc
qed-2.8.1 qed/07_toplevel.rdoc
qed-2.8.0 qed/07_toplevel.rdoc
qed-2.7.0 qed/07_toplevel.rdoc
qed-2.6.3 spec/07_toplevel.rdoc
qed-2.6.2 spec/07_toplevel.rdoc
qed-2.6.1 qed/07_toplevel.rdoc
qed-2.6.0 qed/07_toplevel.rdoc
qed-2.5.1 qed/07_toplevel.rdoc
qed-2.5.0 qed/07_toplevel.rdoc
qed-2.4.0 qed/07_toplevel.rdoc
qed-2.3.0 demo/07_toplevel.rdoc