Merge branch 'master' of gitlab.com:arctic-fox/spectator

This commit is contained in:
Michael Miller 2019-04-03 18:20:24 -06:00
commit 7a0e28945a
5 changed files with 67 additions and 2 deletions

View file

@ -15,3 +15,16 @@ spec:
script: script:
- crystal tool format --check - crystal tool format --check
- crystal spec - crystal spec
pages:
stage: deploy
dependencies:
- spec
script:
- crystal docs
- mv docs/ public/
artifacts:
paths:
- public
only:
- master

View file

@ -347,6 +347,9 @@ Macros that create types are not as easy to test,
so they are exempt for the current time. so they are exempt for the current time.
However, please test all code locally with an example spec file. However, please test all code locally with an example spec file.
Documentation is automatically generated and published to GitLab pages.
It can be found here: https://arctic-fox.gitlab.io/spectator
Contributors Contributors
------------ ------------

View file

@ -5,7 +5,7 @@ module Spectator
extend self extend self
# Current version of the Spectator library. # Current version of the Spectator library.
VERSION = "0.1.0" VERSION = "0.5.0"
# Top-level describe method. # Top-level describe method.
# All specs in a file must be wrapped in this call. # All specs in a file must be wrapped in this call.

View file

@ -527,7 +527,7 @@ module Spectator::DSL
# expect_raises { raise "foobar" } # expect_raises { raise "foobar" }
# ``` # ```
macro expect_raises macro expect_raises
expect {{yield}}.to raise_error expect {{block}}.to raise_error
end end
# Indicates that some block should raise an error with a given type. # Indicates that some block should raise an error with a given type.

View file

@ -1412,6 +1412,34 @@ module Spectator::DSL
::Spectator::DSL::Builder.add_example(Example%example) ::Spectator::DSL::Builder.add_example(Example%example)
end end
# Creates an example, or a test case.
# The block contains the code to run the test.
# One or more expectations should be in the block.
#
# ```
# it { expect(1 + 2).to eq(3) }
# ```
#
# See `ExampleDSL` and `MatcherDSL` for additional macros and methods
# that can be used in example code blocks.
#
# A short-hand, one-liner syntax can also be used.
# Typically, this is combined with `#subject`.
# For instance:
# ```
# subject { 1 + 2 }
# it is_expected.to eq(3)
# ```
macro it(&block)
it({{block.body.stringify}}) {{block}}
end
# An alternative way to write an example.
# This is identical to `#it`.
macro specify(what, &block)
it({{what}}) {{block}}
end
# An alternative way to write an example. # An alternative way to write an example.
# This is identical to `#it`, # This is identical to `#it`,
# except that it doesn't take a "what" argument. # except that it doesn't take a "what" argument.
@ -1456,12 +1484,33 @@ module Spectator::DSL
::Spectator::DSL::Builder.add_example(Example%example) ::Spectator::DSL::Builder.add_example(Example%example)
end end
# Creates an example, or a test case, that does not run.
# This can be used to prototype functionality that isn't ready.
# The *what* argument describes "what" is being tested or asserted.
# The block contains the code to run the test.
# One or more expectations should be in the block.
#
# ```
# pending do
# # Something that isn't implemented yet.
# end
# ```
macro pending(&block)
peding({{block.body.stringify}}) {{block}}
end
# Same as `#pending`. # Same as `#pending`.
# Included for compatibility with RSpec. # Included for compatibility with RSpec.
macro xit(what, &block) macro xit(what, &block)
pending({{what}}) {{block}} pending({{what}}) {{block}}
end end
# Same as `#pending`.
# Included for compatibility with RSpec.
macro xit(&block)
pending({{block.body.stringify}}) {{block}}
end
# Creates a wrapper class for test code. # Creates a wrapper class for test code.
# The class serves multiple purposes, mostly dealing with scope. # The class serves multiple purposes, mostly dealing with scope.
# 1. Include the parent modules as mix-ins. # 1. Include the parent modules as mix-ins.