From 58031e01c6dc46ce0a103fe991e59717702989a0 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sun, 31 Mar 2019 18:53:40 -0600 Subject: [PATCH 1/5] Missed a usage of yield that should be block --- src/spectator/dsl/matcher_dsl.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spectator/dsl/matcher_dsl.cr b/src/spectator/dsl/matcher_dsl.cr index 8311005..ac4315d 100644 --- a/src/spectator/dsl/matcher_dsl.cr +++ b/src/spectator/dsl/matcher_dsl.cr @@ -527,7 +527,7 @@ module Spectator::DSL # expect_raises { raise "foobar" } # ``` macro expect_raises - expect {{yield}}.to raise_error + expect {{block}}.to raise_error end # Indicates that some block should raise an error with a given type. From fef8715ce10a589b91ec18dc2384717250a96e0f Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sun, 31 Mar 2019 20:56:08 -0600 Subject: [PATCH 2/5] Allow it, pending, and xit to omit what --- src/spectator/dsl/structure_dsl.cr | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/spectator/dsl/structure_dsl.cr b/src/spectator/dsl/structure_dsl.cr index be3edfb..c741879 100644 --- a/src/spectator/dsl/structure_dsl.cr +++ b/src/spectator/dsl/structure_dsl.cr @@ -1412,6 +1412,34 @@ module Spectator::DSL ::Spectator::DSL::Builder.add_example(Example%example) 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. # This is identical to `#it`, # except that it doesn't take a "what" argument. @@ -1456,12 +1484,33 @@ module Spectator::DSL ::Spectator::DSL::Builder.add_example(Example%example) 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`. # Included for compatibility with RSpec. macro xit(what, &block) pending({{what}}) {{block}} 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. # The class serves multiple purposes, mostly dealing with scope. # 1. Include the parent modules as mix-ins. From 7a8ebf6db50ee3eac1f18559248de91bb71395c4 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Tue, 2 Apr 2019 21:38:36 -0600 Subject: [PATCH 3/5] Generate docs and publish to pages --- .gitlab-ci.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e9f41fa..fd81d0c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,3 +15,16 @@ spec: script: - crystal tool format --check - crystal spec + +pages: + stage: deploy + dependencies: + - spec + script: + - crystal docs + - mv docs/ public/ + artifacts: + paths: + - public + only: + - master From 675ef60f9d46e26284df813a626f8f068a9ddf6c Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Tue, 2 Apr 2019 22:05:27 -0600 Subject: [PATCH 4/5] Consistent version --- src/spectator.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spectator.cr b/src/spectator.cr index fa87ede..b11eef7 100644 --- a/src/spectator.cr +++ b/src/spectator.cr @@ -5,7 +5,7 @@ module Spectator extend self # Current version of the Spectator library. - VERSION = "0.1.0" + VERSION = "0.5.0" # Top-level describe method. # All specs in a file must be wrapped in this call. From 57c54d943cc2a3fed71a0a330eb60850e87fbfda Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Tue, 2 Apr 2019 22:10:52 -0600 Subject: [PATCH 5/5] Add info on generated docs --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 59846b1..32f7304 100644 --- a/README.md +++ b/README.md @@ -347,6 +347,9 @@ Macros that create types are not as easy to test, so they are exempt for the current time. 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 ------------