|
3 | 3 |
|
4 | 4 | describe ControllersHelper do
|
5 | 5 |
|
| 6 | + describe "#namespace?" do |
| 7 | + before do |
| 8 | + allow(helper).to receive(:params).and_return(controller: "admin/contents") |
| 9 | + end |
| 10 | + |
| 11 | + it "returns true if match" do |
| 12 | + expect(helper.namespace?("admin")).to be true |
| 13 | + end |
| 14 | + |
| 15 | + it "returns true if match any" do |
| 16 | + expect(helper.namespace?("admin", "application")).to be true |
| 17 | + end |
| 18 | + |
| 19 | + it "returns false if didn't match" do |
| 20 | + expect(helper.namespace?("application")).to be false |
| 21 | + end |
| 22 | + end |
| 23 | + |
6 | 24 | describe "#controller?" do
|
7 | 25 | before do
|
8 | 26 | allow(helper).to receive(:params).and_return(controller: "contents")
|
9 | 27 | end
|
10 | 28 |
|
11 |
| - it "returns true if contoller match" do |
| 29 | + it "returns true if match" do |
12 | 30 | expect(helper.controller?("contents")).to be true
|
13 | 31 | end
|
14 | 32 |
|
15 | 33 | it "returns true if match any" do
|
16 | 34 | expect(helper.controller?("contents", "users")).to be true
|
17 | 35 | end
|
| 36 | + |
| 37 | + it "returns false if didn't match any" do |
| 38 | + expect(helper.controller?("application", "users")).to be false |
| 39 | + end |
18 | 40 | end
|
19 | 41 |
|
20 | 42 |
|
|
23 | 45 | allow(helper).to receive(:params).and_return(action: "index")
|
24 | 46 | end
|
25 | 47 |
|
26 |
| - it "returns true if action match" do |
| 48 | + it "returns true if match" do |
27 | 49 | expect(helper.action?("index")).to be true
|
28 | 50 | end
|
29 | 51 |
|
30 |
| - it "returns false if action didn't match" do |
| 52 | + it "returns true if match any" do |
| 53 | + expect(helper.action?("index", "new")).to be true |
| 54 | + end |
| 55 | + |
| 56 | + it "returns false if didn't match" do |
31 | 57 | expect(helper.action?("new")).to be false
|
32 | 58 | end
|
33 | 59 | end
|
|
0 commit comments