From 28680fa8491855933461a36e4a70a9bd03451d0a Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Thu, 1 Aug 2019 15:22:18 -0600 Subject: [PATCH] Rename Actual types to be more "human" sounding --- src/spectator/dsl/example_dsl.cr | 6 +++--- .../expectations/{block_actual.cr => actual_block.cr} | 2 +- .../expectations/{value_actual.cr => actual_value.cr} | 2 +- src/spectator/should.cr | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) rename src/spectator/expectations/{block_actual.cr => actual_block.cr} (94%) rename src/spectator/expectations/{value_actual.cr => actual_value.cr} (94%) diff --git a/src/spectator/dsl/example_dsl.cr b/src/spectator/dsl/example_dsl.cr index 87261c6..611c3fb 100644 --- a/src/spectator/dsl/example_dsl.cr +++ b/src/spectator/dsl/example_dsl.cr @@ -19,7 +19,7 @@ module Spectator::DSL # Where the actual value is returned by the system-under-test, # and the expected value is what the actual value should be to satisfy the condition. macro expect(actual, _source_file = __FILE__, _source_line = __LINE__) - value_actual = ::Spectator::Expectations::ValueActual.new({{actual.stringify}}, {{actual}}) + value_actual = ::Spectator::Expectations::ActualValue.new({{actual.stringify}}, {{actual}}) source = ::Spectator::Source.new({{_source_file}}, {{_source_line}}) ::Spectator::Expectations::ExpectationPartial.new(value_actual, source) end @@ -70,11 +70,11 @@ module Spectator::DSL # The raw block can't be used because it's not clear to the user. {% method_name = block.body.id.split('.')[1..-1].join('.') %} %partial = %proc.partial(subject) - block_actual = ::Spectator::Expectations::ValueActual.new({{"#" + method_name}}, %partial) + block_actual = ::Spectator::Expectations::ActualValue.new({{"#" + method_name}}, %partial) {% else %} # In this case, it looks like the short-hand method syntax wasn't used. # Just drop in the proc as-is. - block_actual = ::Spectator::Expectations::ValueActual.new({{"`" + block.body.stringify + "`"}}, %proc) + block_actual = ::Spectator::Expectations::ActualValue.new({{"`" + block.body.stringify + "`"}}, %proc) {% end %} source = ::Spectator::Source.new({{_source_file}}, {{_source_line}}) diff --git a/src/spectator/expectations/block_actual.cr b/src/spectator/expectations/actual_block.cr similarity index 94% rename from src/spectator/expectations/block_actual.cr rename to src/spectator/expectations/actual_block.cr index 512ce3e..b1b77d6 100644 --- a/src/spectator/expectations/block_actual.cr +++ b/src/spectator/expectations/actual_block.cr @@ -2,7 +2,7 @@ require "./actual" module Spectator::Expectations # Captures an actual block and its label. - struct BlockActual(ReturnType) < Actual + struct ActualBlock(ReturnType) < Actual # Calls the block and retrieves the value. def value : ReturnType @proc.call diff --git a/src/spectator/expectations/value_actual.cr b/src/spectator/expectations/actual_value.cr similarity index 94% rename from src/spectator/expectations/value_actual.cr rename to src/spectator/expectations/actual_value.cr index c5a6de4..eaa542f 100644 --- a/src/spectator/expectations/value_actual.cr +++ b/src/spectator/expectations/actual_value.cr @@ -2,7 +2,7 @@ require "./actual" module Spectator::Expectations # Captures an actual value and its label. - struct ValueActual(T) < Actual + struct ActualValue(T) < Actual # Actual value. getter value : T diff --git a/src/spectator/should.cr b/src/spectator/should.cr index 0653a0e..d8f0316 100644 --- a/src/spectator/should.cr +++ b/src/spectator/should.cr @@ -21,7 +21,7 @@ class Object # However, since this isn't a macro and we can't "look behind" this method call # to see what it was invoked on, the argument is an empty string. # Additionally, the source file and line can't be obtained. - actual = ::Spectator::Expectations::ValueActual.new(self) + actual = ::Spectator::Expectations::ActualValue.new(self) source = ::Spectator::Source.new(__FILE__, __LINE__) ::Spectator::Expectations::ExpectationPartial.new(actual, source).to(matcher) end @@ -29,7 +29,7 @@ class Object # Works the same as `#should` except the condition is inverted. # When `#should` succeeds, this method will fail, and vice-versa. def should_not(matcher : ::Spectator::Matchers::Matcher) - actual = ::Spectator::Expectations::ValueActual.new(self) + actual = ::Spectator::Expectations::ActualValue.new(self) source = ::Spectator::Source.new(__FILE__, __LINE__) ::Spectator::Expectations::ExpectationPartial.new(actual, source).to_not(matcher) end @@ -39,7 +39,7 @@ struct Proc(*T, R) # Extension method to create an expectation for a block of code (proc). # Depending on the matcher, the proc may be executed multiple times. def should(matcher : ::Spectator::Matchers::Matcher) - actual = ::Spectator::Expectations::BlockActual.new(self) + actual = ::Spectator::Expectations::ActualBlock.new(self) source = ::Spectator::Source.new(__FILE__, __LINE__) ::Spectator::Expectations::ExpectationPartial.new(actual, source).to(matcher) end @@ -47,7 +47,7 @@ struct Proc(*T, R) # Works the same as `#should` except the condition is inverted. # When `#should` succeeds, this method will fail, and vice-versa. def should_not(matcher : ::Spectator::Matchers::Matcher) - actual = ::Spectator::Expectations::BlockActual.new(self) + actual = ::Spectator::Expectations::ActualBlock.new(self) source = ::Spectator::Source.new(__FILE__, __LINE__) ::Spectator::Expectations::BlockExpectationPartial.new(actual, source).to_not(matcher) end