class SpectatorTestContext

Overview

Class used as the base for all specs using the DSL. It adds methods and macros necessary to use the DSL from the spec. This type is intentionally outside the Spectator module. The reason for this is to prevent name collision when using the DSL to define a spec.

Included Modules

Defined in:

spectator/test_context.cr

Instance methods inherited from module Spectator::DSL::Mocks

allow(stubbable : Stubbable | StubbedType)
allow(stubbable)
allow
, any_args any_args, no_args no_args

Macros inherited from module Spectator::DSL::Mocks

double(name, **value_methods, &block)
double(**value_methods)
double
, inject_mock(type, **value_methods, &block) inject_mock, mock(type, **value_methods, &block) mock, receive(method, *, _file = __FILE__, _line = __LINE__, &block) receive

Macros inherited from module Spectator::DSL::Memoize

let(name, &block) let, let!(name, &block) let!, subject(&block)
subject(name, &block)
subject
, subject!(&block)
subject!(name, &block)
subject!

Macros inherited from module Spectator::DSL::Matchers

all(matcher) all, be
be(expected)
be
, be_a(expected) be_a, be_a_kind_of(expected) be_a_kind_of, be_an(expected) be_an, be_an_instance_of(expected) be_an_instance_of, be_between(min, max) be_between, be_close(expected, delta) be_close, be_empty be_empty, be_false be_false, be_falsey be_falsey, be_ge(expected) be_ge, be_gt(expected) be_gt, be_instance_of(expected) be_instance_of, be_kind_of(expected) be_kind_of, be_le(expected) be_le, be_lt(expected) be_lt, be_nil be_nil, be_true be_true, be_truthy be_truthy, be_within(expected) be_within, change(&expression) change, compile_as(expected) compile_as, contain(*expected) contain, contain_elements(expected) contain_elements, contain_exactly(*expected) contain_exactly, cover(*expected) cover, end_with(expected) end_with, eq(expected) eq, expect_raises(&block)
expect_raises(type, &block)
expect_raises(type, message, &block)
expect_raises
, has_key(expected) has_key, has_value(expected) has_value, have(*expected) have, have_attributes(**expected) have_attributes, have_elements(expected) have_elements, have_key(expected) have_key, have_received(method) have_received, have_size(expected) have_size, have_size_of(expected) have_size_of, have_value(expected) have_value, match(expected) match, match_array(expected) match_array, method_missing(call) method_missing, ne(expected) ne, raise_error
raise_error(type_or_message)
raise_error(type, message)
raise_error
, respond_to(*expected) respond_to, start_with(expected) start_with

Macros inherited from module Spectator::DSL::Hooks

after(&block) after, after_all(&block) after_all, after_each(&block) after_each, after_suite(&block) after_suite, around(&block) around, around_each(&block) around_each, before(&block) before, before_all(&block) before_all, before_each(&block) before_each, before_suite(&block) before_suite, define_example_group_hook(type, name = nil, &block) define_example_group_hook, define_example_hook(type, name = nil, &block) define_example_hook, post_condition(&block) post_condition, pre_condition(&block) pre_condition

Macros inherited from module Spectator::DSL::Groups

context(what, *tags, **metadata, &block) context, define_example_group(name, *tags, **metadata) define_example_group, define_iterative_group(name, *tags, **metadata, &block) define_iterative_group, describe(what, *tags, **metadata, &block) describe, example_group(what, *tags, **metadata, &block) example_group, fcontext(what, *tags, **metadata, &block) fcontext, fdescribe(what, *tags, **metadata, &block) fdescribe, fexample_group(what, *tags, **metadata, &block) fexample_group, frandom_sample(collection, *tags, count = nil, **metadata, &block) frandom_sample, fsample(collection, *tags, count = nil, **metadata, &block) fsample, random_sample(collection, *tags, count = nil, **metadata, &block) random_sample, sample(collection, *tags, count = nil, **metadata, &block) sample, xcontext(what, *tags, **metadata, &block) xcontext, xdescribe(what, *tags, **metadata, &block) xdescribe, xexample_group(what, *tags, **metadata, &block) xexample_group, xrandom_sample(collection, *tags, count = nil, **metadata, &block) xrandom_sample, xsample(collection, *tags, count = nil, **metadata, &block) xsample

Instance methods inherited from module Spectator::DSL::Expectations

aggregate_failures(label = nil, &) aggregate_failures, fail(message = "Example failed", *, _file = __FILE__, _line = __LINE__) fail, pending(message = PendingResult::DEFAULT_REASON, *, _file = __FILE__, _line = __LINE__) pending, skip(message = PendingResult::DEFAULT_REASON, *, _file = __FILE__, _line = __LINE__) skip

Macros inherited from module Spectator::DSL::Expectations

expect(actual)
expect(&block)
expect
, is(expected) is, is_expected is_expected, is_not(expected) is_not, should(*args) should, should_eventually(*args) should_eventually, should_never(*args) should_never, should_not(*args) should_not

Macros inherited from module Spectator::DSL::Examples

define_example(name, *tags, **metadata) define_example, define_pending_example(name, *tags, **metadata) define_pending_example, example(what = nil, *tags, **metadata, &block) example, fexample(what = nil, *tags, **metadata, &block) fexample, fit(what = nil, *tags, **metadata, &block) fit, fspecify(what = nil, *tags, **metadata, &block) fspecify, it(what = nil, *tags, **metadata, &block) it, pending(what = nil, *tags, **metadata, &block) pending, skip(what = nil, *tags, **metadata, &block) skip, specify(what = nil, *tags, **metadata, &block) specify, xexample(what = nil, *tags, **metadata, &block) xexample, xfexample(what = nil, *tags, **metadata, &block) xfexample, xfit(what = nil, *tags, **metadata, &block) xfit, xfspecify(what = nil, *tags, **metadata, &block) xfspecify, xit(what = nil, *tags, **metadata, &block) xit, xspecify(what = nil, *tags, **metadata, &block) xspecify

Macros inherited from module Spectator::DSL::Concise

given(*assignments, **kwargs, &block) given, provided(*assignments, it description = nil, **kwargs, &block) provided

Instance methods inherited from class SpectatorContext

eval(&) eval, inspect(io : IO) : Nil inspect, to_s(io : IO) : Nil to_s

Instance methods inherited from class Object

should(matcher : Spectator::Matchers::TypeMatcher(U), message = nil, *, _file = __FILE__, _line = __LINE__) forall U
should(matcher, message = nil, *, _file = __FILE__, _line = __LINE__)
should
, should_eventually(matcher, message = nil, *, _file = __FILE__, _line = __LINE__) should_eventually, should_never(matcher, message = nil, *, _file = __FILE__, _line = __LINE__) should_never, should_not(matcher : Spectator::Matchers::TypeMatcher(U), message = nil, *, _file = __FILE__, _line = __LINE__) forall U
should_not(matcher : Spectator::Matchers::NilMatcher, message = nil, *, _file = __FILE__, _line = __LINE__)
should_not(matcher, message = nil, *, _file = __FILE__, _line = __LINE__)
should_not