Skip to content

Commit

Permalink
Update multi app tests to verify responses
Browse files Browse the repository at this point in the history
  • Loading branch information
rsamoilov committed Jul 15, 2024
1 parent e0e7c1c commit 41203f2
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions spec/multi_application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,52 @@
end

context "with a 200 response" do
let(:rage_response) { [200, {}, []] }

it "calls Rage app" do
expect(rage_verifier).to receive(:call).with(env).and_return([200, {}, []])
subject
expect(rage_verifier).to receive(:call).with(env).and_return(rage_response)
expect(subject).to eq(rage_response)
end
end

context "with a 404 response" do
let(:rage_response) { [404, {}, []] }

it "calls Rage app" do
expect(rage_verifier).to receive(:call).with(env).and_return([404, {}, []])
subject
expect(rage_verifier).to receive(:call).with(env).and_return(rage_response)
expect(subject).to eq(rage_response)
end
end

context "with an async response" do
let(:rage_response) { [:__http_defer__, Fiber.new {}] }

it "calls Rage app" do
expect(rage_verifier).to receive(:call).with(env).and_return([:__http_defer__, Fiber.new {}])
subject
expect(rage_verifier).to receive(:call).with(env).and_return(rage_response)
expect(subject).to eq(rage_response)
end
end

context "with an X-Cascade response" do
let(:rage_response) { [200, { "X-Cascade" => "pass" }, []] }
let(:rails_response) { :test_rails_response }

it "calls both Rage and Rails apps" do
expect(rage_verifier).to receive(:call).with(env).and_return([200, { "X-Cascade" => "pass" }, []])
expect(rails_verifier).to receive(:call).with(env)
subject
expect(rage_verifier).to receive(:call).with(env).and_return(rage_response)
expect(rails_verifier).to receive(:call).with(env).and_return(rails_response)
expect(subject).to eq(rails_response)
end
end

context "with Rails internal request" do
let(:env) { { "PATH_INFO"=> "/rails/action_mailbox" } }
let(:rage_response) { [200, {}, []] }
let(:rails_response) { :test_rails_response }

it "calls both Rage and Rails apps" do
expect(rage_verifier).to receive(:call).with(env).and_return([200, {}, []])
expect(rails_verifier).to receive(:call).with(env)
subject
expect(rage_verifier).to receive(:call).with(env).and_return(rage_response)
expect(rails_verifier).to receive(:call).with(env).and_return(rails_response)
expect(subject).to eq(rails_response)
end
end
end

0 comments on commit 41203f2

Please sign in to comment.