Skip to content

Commit

Permalink
Added with_nonce method [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Feb 3, 2022
1 parent b3f72de commit fe74fd1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/helper_test.rb
Expand Up @@ -12,13 +12,14 @@ def test_spec
end

def test_nonce_chart
stub(:content_security_policy_nonce, "test123") do
with_nonce do
assert_match '<script nonce="test123">', vega_chart(Vega.lite)
end
refute_match "nonce", vega_chart(Vega.lite, nonce: false)
end

def test_nonce_spec
stub(:content_security_policy_nonce, "test123") do
with_nonce do
assert_match '<script nonce="test123">', vega_chart(Vega.lite.spec)
end
end
Expand All @@ -35,6 +36,12 @@ def test_bad_type
assert_equal "expected Vega chart or spec", error.message
end

def with_nonce
stub(:content_security_policy_nonce, "test123") do
yield
end
end

# for stubbing
def content_security_policy_nonce
nil
Expand Down

0 comments on commit fe74fd1

Please sign in to comment.