Skip to content

Commit b750ad3

Browse files
committed
Add specs
1 parent 12cc9f4 commit b750ad3

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

.rspec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--require spec_helper
2+
--color
3+
--format documentation

spec/spec_helper.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# frozen_string_literal: true
2+
3+
require "strict_pagination"
4+
5+
RSpec.configure do |config|
6+
# Enable flags like --only-failures and --next-failure
7+
config.example_status_persistence_file_path = ".rspec_status"
8+
9+
# Disable RSpec exposing methods globally on `Module` and `main`
10+
config.disable_monkey_patching!
11+
12+
config.expect_with :rspec do |c|
13+
c.syntax = :expect
14+
end
15+
16+
# Filter out gems from backtrace
17+
config.filter_gems_from_backtrace "activerecord", "activesupport"
18+
end

spec/strict_pagination_spec.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# frozen_string_literal: true
2+
3+
require "spec_helper"
4+
5+
RSpec.describe StrictPagination do
6+
it "has a version number" do
7+
expect(described_class::VERSION).not_to be_nil
8+
end
9+
10+
describe ".configure" do
11+
it "yields configuration" do
12+
expect { |b| described_class.configure(&b) }.to yield_with_args(described_class.config)
13+
end
14+
15+
it "allows setting validate_on_all_queries" do
16+
described_class.configure do |config|
17+
config.validate_on_all_queries = true
18+
end
19+
20+
expect(described_class.config.validate_on_all_queries).to be true
21+
22+
# Reset to default
23+
described_class.config.validate_on_all_queries = false
24+
end
25+
26+
it "allows setting safe_view_prefixes" do
27+
described_class.configure do |config|
28+
config.safe_view_prefixes = ["Custom::"]
29+
end
30+
31+
expect(described_class.config.safe_view_prefixes).to eq(["Custom::"])
32+
33+
# Reset to default
34+
described_class.config.safe_view_prefixes = []
35+
end
36+
end
37+
38+
describe ".config" do
39+
it "returns configuration instance" do
40+
expect(described_class.config).to be_a(described_class::Configuration)
41+
end
42+
end
43+
end

0 commit comments

Comments
 (0)