Module: Buildr::Checks

Includes:
Extension
Included in:
Project
Defined in:
lib/buildr/core/checks.rb

Overview

Methods added to Project to allow checking the build.

Defined Under Namespace

Modules: Matchers Classes: Expectation

Instance Method Summary collapse

Methods included from Extension

included

Instance Method Details

#check(*args, &block) ⇒ Object

:call-seq:

check(description) { ... }
check(subject, description) { ... }

Adds an expectation. The expectation is run against the project by the check task, executed after packaging. You can access any package created by the project.

An expectation is written using a subject, description and block to validate the expectation. For example:

For example:

check package(:jar), "should exist" do
  it.should exist
end
check package(:jar), "should contain a manifest" do
  it.should contain("META-INF/MANIFEST.MF")
end
check package(:jar).path("com/acme"), "should contain classes" do
  it.should_not be_empty
end
check package(:jar).entry("META-INF/MANIFEST"), "should be a recent license" do
  it.should contain(/Copyright (C) 2007/)
end

If you omit the subject, the project is used as the subject. If you omit the description, the subject is used as description.

During development you can write placeholder expectations by omitting the block. This will simply report the expectation as pending.



193
194
195
# File 'lib/buildr/core/checks.rb', line 193

def check(*args, &block)
  expectations << Checks::Expectation.new(*args, &block)
end

#expectationsObject

:call-seq:

expectations() => Expectation*

Returns a list of expectations (see #check).



201
202
203
# File 'lib/buildr/core/checks.rb', line 201

def expectations()
  @expectations ||= []
end