Sha256: 43365a2d66c9c53f1758ef38690ecbc429e914f7605a0b6e242afde26d195cba
Contents?: true
Size: 1.23 KB
Versions: 14
Compression:
Stored size: 1.23 KB
Contents
require 'teststrap' context "Chaining ContextMiddleware" do teardown { Riot::Context.middlewares.clear } context("when middleware halts the call chain") do hookup do Class.new(Riot::ContextMiddleware) do register def initialize(middleware); end def call(context) "whoops"; end end end setup do situation = Riot::Situation.new Riot::Context.new("Foo") do setup { "foo" } end.local_run(MockReporter.new, situation) situation end asserts("situation topic") { topic.topic }.nil end # when middleware halts the call chain context("when middleware continues the call chain") do hookup do Class.new(Riot::ContextMiddleware) do register def call(context) context.setup { ["foo"] } middleware.call(context) context.hookup { topic << "baz" } end end end setup do situation = Riot::Situation.new Riot::Context.new("Foo") do hookup { topic << "bar" } end.local_run(MockReporter.new, situation) situation end asserts("situation topic") { topic.topic }.equals(%w[foo bar baz]) end # when middleware halts the call chain end # Chaining ContextMiddleware
Version data entries
14 entries across 14 versions & 1 rubygems