From 0970f02465f3869b86c01fc7eba5c069399c7bf8 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sun, 27 Sep 2020 10:14:30 -0600 Subject: [PATCH 1/3] Yield instead of forwarding block Forwarding the block like this captures it, which prevents yield from being used. Addresses https://gitlab.com/arctic-fox/spectator/-/issues/54 --- src/spectator/mocks/method_stub.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spectator/mocks/method_stub.cr b/src/spectator/mocks/method_stub.cr index ad1d8d0..492fc3f 100644 --- a/src/spectator/mocks/method_stub.cr +++ b/src/spectator/mocks/method_stub.cr @@ -17,7 +17,7 @@ module Spectator::Mocks abstract def call(args : GenericArguments(T, NT), &original : -> RT) forall T, NT, RT def call!(args : GenericArguments(T, NT), &original : -> RT) : RT forall T, NT, RT - value = call(args, &original) + value = call(args) { |*ya| yield *ya } if value.is_a?(RT) value.as(RT) else From e68697a2125db3414894d7c7ca65cd04c96c4fae Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sun, 27 Sep 2020 10:30:51 -0600 Subject: [PATCH 2/3] Fix stubbed yielding method calling original instead of stub --- src/spectator/mocks/stubs.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spectator/mocks/stubs.cr b/src/spectator/mocks/stubs.cr index 54436ef..d18c3ab 100644 --- a/src/spectator/mocks/stubs.cr +++ b/src/spectator/mocks/stubs.cr @@ -84,7 +84,7 @@ module Spectator::Mocks end {% if body && !body.is_a?(Nop) %} - %method({{args.splat}}) { {{original}} { |*%ya| yield *%ya } } + %method({{args.splat}}) { |*%ya| yield *%ya } {% else %} {{original}} do |*%yield_args| yield *%yield_args From 93fa6f6e7210b3fda4fd04cdff9fec8c85030075 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sun, 27 Sep 2020 10:35:28 -0600 Subject: [PATCH 3/3] Bump version to 0.9.26 --- shard.yml | 2 +- src/spectator.cr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shard.yml b/shard.yml index e5c0a65..b7f2fc9 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: spectator -version: 0.9.25 +version: 0.9.26 description: | A feature-rich spec testing framework for Crystal with similarities to RSpec. diff --git a/src/spectator.cr b/src/spectator.cr index c3e1bef..a188d08 100644 --- a/src/spectator.cr +++ b/src/spectator.cr @@ -6,7 +6,7 @@ module Spectator extend self # Current version of the Spectator library. - VERSION = "0.9.25" + VERSION = "0.9.26" # Top-level describe method. # All specs in a file must be wrapped in this call.