-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolid_stack_web_spec.rb
More file actions
65 lines (54 loc) · 1.94 KB
/
Copy pathsolid_stack_web_spec.rb
File metadata and controls
65 lines (54 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require "rails_helper"
RSpec.describe SolidStackWeb do
describe ".configure" do
it "yields self so callers can set attributes in a block" do
SolidStackWeb.configure do |config|
config.page_size = 50
end
expect(SolidStackWeb.page_size).to eq(50)
ensure
SolidStackWeb.page_size = 25
end
end
describe ".mount_path" do
it "returns the path at which the engine is mounted in the dummy app" do
expect(SolidStackWeb.mount_path).to eq("/solid_stack")
end
it "returns a string with no trailing format suffix" do
expect(SolidStackWeb.mount_path).not_to include("(")
end
end
describe ".deprecator" do
it "returns an ActiveSupport::Deprecation instance scoped to SolidStackWeb" do
expect(SolidStackWeb.deprecator).to be_a(ActiveSupport::Deprecation)
end
it "returns the same instance on repeated calls" do
expect(SolidStackWeb.deprecator).to be(SolidStackWeb.deprecator)
end
end
describe ".deprecated_config" do
it "issues a deprecation warning and forwards the value to the new key" do
SolidStackWeb.send(:deprecated_config, :legacy_limit, :search_results_limit)
warned = false
SolidStackWeb.deprecator.behavior = ->(msg, *) { warned = true if msg.include?("config.legacy_limit=") }
SolidStackWeb.legacy_limit = 42
expect(warned).to be(true)
expect(SolidStackWeb.search_results_limit).to eq(42)
ensure
SolidStackWeb.search_results_limit = nil
SolidStackWeb.deprecator.behavior = :stderr
SolidStackWeb.singleton_class.remove_method(:legacy_limit=)
end
end
describe ".search_results_limit" do
it "defaults to 25" do
expect(SolidStackWeb.search_results_limit).to eq(25)
end
it "returns the configured value" do
SolidStackWeb.search_results_limit = 50
expect(SolidStackWeb.search_results_limit).to eq(50)
ensure
SolidStackWeb.search_results_limit = nil
end
end
end