Skip to content

Commit

Permalink
Add unit tests for collection matching
Browse files Browse the repository at this point in the history
The match_attribute and match_no_attribute didn't test what happens if
the property returns a collection
  • Loading branch information
whit0694 committed Apr 4, 2015
1 parent 72dd790 commit eba9dd9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions spec/lib/query_string_search/matchers/match_attribute_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
end
end

describe "if the target's attribute returns a collection" do
let(:target) { SearchTarget.new(property: %w(a b c)) }

it "is true" do
matcher = MatchAttribute.new
matcher.attribute = :property
expect(matcher.match?(target)).to be_truthy
end
end

describe "if the target's attribute is nil" do
let(:target) { SearchTarget.new(property: nil) }

Expand Down
10 changes: 10 additions & 0 deletions spec/lib/query_string_search/matchers/match_no_attribute_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
end
end

describe "if the target's attribute returns a collection" do
let(:target) { SearchTarget.new(property: %w(a b c)) }

it "is false" do
matcher = MatchAttribute.new
matcher.attribute = :property
expect(matcher.match?(target)).to be_falsey
end
end

describe "if the target's attribute is false" do
let(:target) { SearchTarget.new(property: false) }

Expand Down

0 comments on commit eba9dd9

Please sign in to comment.