Sha256: 71332852c06953eef215e8ace63d227d69e2e363a4aba201fc90661d3f4e98d8
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 KB
Contents
require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__))) describe "multi_run plugin" do it "adds Roda.run method for setting up prefix delegations to other rack apps" do app(:multi_run) do |r| r.multi_run "c" end app.run "a", Class.new(Roda).class_eval{route{"a1"}; app} body("/a").must_equal 'a1' body("/b").must_equal 'c' body("/b/a").must_equal 'c' body.must_equal 'c' app.run "b", Class.new(Roda).class_eval{route{"b1"}; app} body("/a").must_equal 'a1' body("/b").must_equal 'b1' body("/b/a").must_equal 'b1' body.must_equal 'c' app.run "b/a", Class.new(Roda).class_eval{route{"b2"}; app} body("/a").must_equal 'a1' body("/b").must_equal 'b1' body("/b/a").must_equal 'b2' body.must_equal 'c' end it "works when freezing the app" do app(:multi_run) do |r| r.multi_run "c" end app.run "a", Class.new(Roda).class_eval{route{"a1"}; app} app.run "b", Class.new(Roda).class_eval{route{"b1"}; app} app.run "b/a", Class.new(Roda).class_eval{route{"b2"}; app} app.freeze body("/a").must_equal 'a1' body("/b").must_equal 'b1' body("/b/a").must_equal 'b2' body.must_equal 'c' proc{app.run "a", Class.new(Roda).class_eval{route{"a1"}; app}}.must_raise FrozenError end it "works when subclassing" do app(:multi_run) do |r| r.multi_run "c" end app.run "a", Class.new(Roda).class_eval{route{"a1"}; app} body("/a").must_equal 'a1' a = app @app = Class.new(a) a.run "b", Class.new(Roda).class_eval{route{"b2"}; app} app.run "b", Class.new(Roda).class_eval{route{"b1"}; app} body("/a").must_equal 'a1' body("/b").must_equal 'b1' @app = a body("/b").must_equal 'b2' end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
roda-2.3.0 | spec/plugin/multi_run_spec.rb |