Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# encoding: utf-8 | ||
module Origin | ||
module Optional | ||
module MaxScan | ||
|
||
def max_scan(value = nil) | ||
option(value) { |options| options.store(:max_scan, value) } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
require "spec_helper" | ||
|
||
describe Origin::Optional::MaxScan do | ||
|
||
let(:query) do | ||
Origin::Query.new | ||
end | ||
|
||
describe "#max_scan" do | ||
|
||
context "when provided no options" do | ||
|
||
let(:selection) do | ||
query.max_scan | ||
end | ||
|
||
it "does not add any options" do | ||
selection.options.should eq({}) | ||
end | ||
|
||
it "returns the query" do | ||
selection.should eq(query) | ||
end | ||
|
||
it "returns a cloned query" do | ||
selection.should_not equal(query) | ||
end | ||
end | ||
|
||
context "when provided nil" do | ||
|
||
let(:selection) do | ||
query.max_scan(nil) | ||
end | ||
|
||
it "does not add any options" do | ||
selection.options.should eq({}) | ||
end | ||
|
||
it "returns the query" do | ||
selection.should eq(query) | ||
end | ||
|
||
it "returns a cloned query" do | ||
selection.should_not equal(query) | ||
end | ||
end | ||
|
||
context "when provided arguments" do | ||
|
||
let(:selection) do | ||
query.max_scan(500) | ||
end | ||
|
||
it "adds the field options" do | ||
selection.options.should eq({ :max_scan => 500 }) | ||
end | ||
|
||
it "returns a cloned query" do | ||
selection.should_not equal(query) | ||
end | ||
end | ||
end | ||
end |