|
1 | | -require 'spec_helper' |
| 1 | +require "spec_helper" |
2 | 2 |
|
3 | | -describe HighVoltage::Constraints::RootRoute, '.matches?' do |
4 | | - it 'returns true when the view file exists' do |
| 3 | +describe HighVoltage::Constraints::RootRoute, ".matches?" do |
| 4 | + it "returns true when the view file exists" do |
5 | 5 | request = double(path: 'index') |
6 | | - allow(Dir).to receive(:glob).and_return(["about.html.erb"]) |
| 6 | + file_path = Rails.root.join("app", "views", "pages", "index.html*").to_s |
| 7 | + |
| 8 | + allow(Dir).to receive(:glob).with(file_path).and_return(["about.html.erb"]) |
7 | 9 |
|
8 | 10 | result = HighVoltage::Constraints::RootRoute.matches?(request) |
9 | 11 |
|
10 | 12 | expect(result).to be true |
11 | 13 | end |
12 | 14 |
|
13 | | - it 'returns false when the view files does not exist' do |
| 15 | + it "returns true when the view file exists and url ends with .html" do |
| 16 | + request = double(path: "index.html") |
| 17 | + file_path = Rails.root.join("app", "views", "pages", "index.html*").to_s |
| 18 | + |
| 19 | + allow(Dir).to receive(:glob).with(file_path).and_return(["about.html.erb"]) |
| 20 | + |
| 21 | + result = HighVoltage::Constraints::RootRoute.matches?(request) |
| 22 | + |
| 23 | + expect(result).to be true |
| 24 | + end |
| 25 | + |
| 26 | + it "returns false when the view files does not exist" do |
14 | 27 | request = double(path: 'index') |
15 | | - allow(File).to receive(:glob).and_return([]) |
| 28 | + file_path = Rails.root.join("app", "views", "pages", "index", ".html*").to_s |
| 29 | + |
| 30 | + allow(File).to receive(:glob).with(file_path).and_return([]) |
16 | 31 |
|
17 | 32 | result = HighVoltage::Constraints::RootRoute.matches?(request) |
18 | 33 |
|
|
0 commit comments