Skip to content

Commit 085e936

Browse files
committed
Include tests for new inertia_rendering? helper method
1 parent 39131ab commit 085e936

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

spec/inertia/helper_spec.rb

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# frozen_string_literal: true
2+
3+
RSpec.describe InertiaRails::Helper do
4+
let(:controller) { ApplicationController.new }
5+
6+
let(:test_helper) do
7+
Class.new do
8+
include InertiaRails::Helper
9+
attr_accessor :controller
10+
end.new
11+
end
12+
13+
before do
14+
test_helper.controller = controller
15+
end
16+
17+
describe '#inertia_rendering?' do
18+
context 'when not rendering through Inertia' do
19+
it 'returns nil' do
20+
expect(test_helper.inertia_rendering?).to be_nil
21+
end
22+
end
23+
24+
context 'when rendering through Inertia' do
25+
before do
26+
controller.instance_variable_set('@_inertia_rendering', true)
27+
end
28+
29+
it 'returns true' do
30+
expect(test_helper.inertia_rendering?).to be true
31+
end
32+
end
33+
end
34+
end

0 commit comments

Comments
 (0)