spec/spec_helper.rb in nanoc-4.6.2 vs spec/spec_helper.rb in nanoc-4.6.3
- old
+ new
@@ -172,9 +172,35 @@
failure_message_when_negated do |_actual|
"expected that proc would not yield #{expected.inspect} from fiber, but was #{@res.inspect}"
end
end
+RSpec::Matchers.define :raise_wrapped_error do |expected|
+ supports_block_expectations
+
+ include RSpec::Matchers::Composable
+
+ match do |actual|
+ begin
+ actual.call
+ rescue Nanoc::Int::Errors::CompilationError => e
+ values_match?(expected, e.unwrap)
+ end
+ end
+
+ description do
+ "raise wrapped error #{expected.inspect}"
+ end
+
+ failure_message do |_actual|
+ "expected that proc would raise wrapped error #{expected.inspect}"
+ end
+
+ failure_message_when_negated do |_actual|
+ "expected that proc would not raise wrapped error #{expected.inspect}"
+ end
+end
+
RSpec::Matchers.define :be_some_textual_content do |expected|
include RSpec::Matchers::Composable
match do |actual|
actual.is_a?(Nanoc::Int::TextualContent) && values_match?(expected, actual.string)