|
10 | 10 | CastleDevise.configuration.publishable_key = "pk_spec" |
11 | 11 | end |
12 | 12 |
|
13 | | - it "configures the SDK without loading a script when src is omitted" do |
| 13 | + it "loads castle.umd.js from /vendor/castle-js" do |
14 | 14 | html = helper.castle_javascript_tag |
15 | 15 |
|
| 16 | + expect(html).to include("/vendor/castle-js/castle.umd.js") |
| 17 | + expect(html).to include("window.module") |
| 18 | + expect(html).to include("window.Castle") |
| 19 | + expect(html).to include("@castleio/castle-js") |
16 | 20 | expect(html).to include(".configure") |
17 | | - expect(html).to include("pk") |
18 | 21 | expect(html).to include("pk_test") |
19 | 22 | expect(html).to include("castleDeviseOnFormSubmit") |
20 | | - expect(html).not_to include("castle.umd.js") |
21 | 23 | expect(html).not_to include("cdn.castle.io") |
| 24 | + expect(html).not_to include("castle.browser.js") |
22 | 25 | end |
23 | 26 |
|
24 | | - it "loads a hosted UMD build when src is given" do |
25 | | - html = helper.castle_javascript_tag(src: "/castle-js/castle.umd.js") |
| 27 | + it "loads a custom UMD src when given" do |
| 28 | + html = helper.castle_javascript_tag(src: "/assets/castle.umd.js") |
26 | 29 |
|
27 | | - expect(html).to include("/castle-js/castle.umd.js") |
| 30 | + expect(html).to include("/assets/castle.umd.js") |
| 31 | + expect(html).not_to include("/vendor/castle-js/castle.umd.js") |
28 | 32 | expect(html).to include("window.module") |
29 | | - expect(html).to include("window.Castle") |
30 | | - expect(html).to include("@castleio/castle-js") |
| 33 | + expect(html).not_to include("cdn.castle.io") |
| 34 | + end |
| 35 | + |
| 36 | + it "skips the script tag when src is nil" do |
| 37 | + html = helper.castle_javascript_tag(src: nil) |
| 38 | + |
| 39 | + expect(html).to include(".configure") |
31 | 40 | expect(html).to include("pk_test") |
| 41 | + expect(html).not_to include("castle.umd.js") |
32 | 42 | expect(html).not_to include("cdn.castle.io") |
33 | 43 | end |
34 | 44 | end |
|
0 commit comments