Skip to content

Commit

Permalink
Made specs check if/when the xhr script tag is added
Browse files Browse the repository at this point in the history
Before it was ambiguous because the output for the tag was empty.
  • Loading branch information
iainbeeston committed Feb 24, 2021
1 parent 08e86b5 commit bbaf1cf
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions spec/bullet/rack_spec.rb
Expand Up @@ -90,7 +90,7 @@ module Bullet
before do
expect(Bullet).to receive(:notification?).and_return(true)
allow(Bullet).to receive(:gather_inline_notifications).and_return('<bullet></bullet>')
allow(middleware).to receive(:xhr_script).and_return('')
allow(middleware).to receive(:xhr_script).and_return('<script></script>')
allow(middleware).to receive(:footer_note).and_return('footer')
expect(Bullet).to receive(:perform_out_of_channel_notifications)
end
Expand All @@ -99,9 +99,8 @@ module Bullet
expect(Bullet).to receive(:add_footer).exactly(3).times.and_return(true)
_, headers, response = middleware.call('Content-Type' => 'text/html')

expect(headers['Content-Length']).to eq((56 + middleware.send(:footer_note).length).to_s)
expect(response.first).to start_with('<html><head></head><body>')
expect(response.first).to include('<bullet></bullet><')
expect(headers['Content-Length']).to eq((73 + middleware.send(:footer_note).length).to_s)
expect(response).to eq(%w[<html><head></head><body>footer<bullet></bullet><script></script></body></html>])
end

it 'should change response body for html safe string if add_footer is true' do
Expand All @@ -111,9 +110,8 @@ module Bullet
end
_, headers, response = middleware.call('Content-Type' => 'text/html')

expect(headers['Content-Length']).to eq((56 + middleware.send(:footer_note).length).to_s)
expect(response.first).to start_with('<html><head></head><body>')
expect(response.first).to include('<bullet></bullet><')
expect(headers['Content-Length']).to eq((73 + middleware.send(:footer_note).length).to_s)
expect(response).to eq(%w[<html><head></head><body>footer<bullet></bullet><script></script></body></html>])
end

it 'should change response body if console_enabled is true' do
Expand Down

0 comments on commit bbaf1cf

Please sign in to comment.