From 8d48e441b2fbdb0922f12620411cef804b292432 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Wed, 3 Feb 2021 10:06:00 -0700 Subject: [PATCH 1/2] Fix generating source from brace-less examples. Addresses https://github.com/icy-arctic-fox/spectator/issues/20 --- src/spectator/dsl/examples.cr | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/spectator/dsl/examples.cr b/src/spectator/dsl/examples.cr index 58bef0f..641fe3b 100644 --- a/src/spectator/dsl/examples.cr +++ b/src/spectator/dsl/examples.cr @@ -18,7 +18,11 @@ module Spectator end {% end %} - %source = ::Spectator::Source.new({{block.filename}}, {{block.line_number}}) + {% if block.is_a?(Nop) %} + %source = ::Spectator::Source.new({{description.filename}}, {{description.line_number}}) + {% else %} + %source = ::Spectator::Source.new({{block.filename}}, {{block.line_number}}) + {% end %} ::Spectator::SpecBuilder.add_example( {{description.is_a?(StringLiteral) || description.is_a?(StringInterpolation) || description.is_a?(NilLiteral) ? description : description.stringify}}, %source, @@ -45,7 +49,11 @@ module Spectator end {% end %} - %source = ::Spectator::Source.new({{block.filename}}, {{block.line_number}}) + {% if block.is_a?(Nop) %} + %source = ::Spectator::Source.new({{description.filename}}, {{description.line_number}}) + {% else %} + %source = ::Spectator::Source.new({{block.filename}}, {{block.line_number}}) + {% end %} ::Spectator::SpecBuilder.add_pending_example( {{description.is_a?(StringLiteral) || description.is_a?(StringInterpolation) || description.is_a?(NilLiteral) ? description : description.stringify}}, %source, From e0c4d2ac3ebcf72599fd274b78c76cc2c7876298 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Wed, 3 Feb 2021 10:08:46 -0700 Subject: [PATCH 2/2] Bump version to 0.9.32 --- CHANGELOG.md | 4 ++++ shard.yml | 2 +- src/spectator.cr | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92be77e..52772fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.9.32] - 2021-02-03 +### Fixed +- Fix source reference with brace-less example syntax. [#20](https://github.com/icy-arctic-fox/spectator/issues/20) + ## [0.9.31] - 2021-01-08 ### Fixed - Fix misaligned line numbers when referencing examples and groups. diff --git a/shard.yml b/shard.yml index 5999a92..1779903 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: spectator -version: 0.9.31 +version: 0.9.32 description: | A feature-rich spec testing framework for Crystal with similarities to RSpec. diff --git a/src/spectator.cr b/src/spectator.cr index 6e99407..c669c1c 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.31" + VERSION = "0.9.32" # Top-level describe method. # All specs in a file must be wrapped in this call.