Sha256: ad56f9a4cb776edd65afa0efd3e1ad82898aa31798715b6f91eb2cef1dc5ccca

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require "spec_helper"

describe HighVoltage::Constraints::RootRoute, ".matches?" do
  it "returns true when the view file exists" do
    request = double(path: 'index')
    file_path = Rails.root.join("app", "views", "pages", "index.html*").to_s

    allow(Dir).to receive(:glob).with(file_path).and_return(["about.html.erb"])

    result = HighVoltage::Constraints::RootRoute.matches?(request)

    expect(result).to be true
  end

  it "returns true when the view file exists and url ends with .html" do
    request = double(path: "index.html")
    file_path = Rails.root.join("app", "views", "pages", "index.html*").to_s

    allow(Dir).to receive(:glob).with(file_path).and_return(["about.html.erb"])

    result = HighVoltage::Constraints::RootRoute.matches?(request)

    expect(result).to be true
  end

  it "returns false when the view files does not exist" do
    request = double(path: 'index')
    file_path = Rails.root.join("app", "views", "pages", "index", ".html*").to_s

    allow(File).to receive(:glob).with(file_path).and_return([])

    result = HighVoltage::Constraints::RootRoute.matches?(request)

    expect(result).to be false
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
high_voltage-3.0.0 spec/constraints/root_route_spec.rb