Class: RoadForest::Testing::MatchesQuery
- Inherits:
-
Object
- Object
- RoadForest::Testing::MatchesQuery
- Defined in:
- lib/roadforest/test-support/matchers.rb
Instance Method Summary collapse
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(pattern = nil, &block) ⇒ MatchesQuery
constructor
A new instance of MatchesQuery.
- #matches?(actual) ⇒ Boolean
Constructor Details
#initialize(pattern = nil, &block) ⇒ MatchesQuery
Returns a new instance of MatchesQuery.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/roadforest/test-support/matchers.rb', line 4 def initialize(pattern = nil, &block) pattern ||= [] if Hash === pattern pattern = [pattern] end pattern = pattern.map do |item| ::RDF::Query::Pattern.from(item) end @query = ::RDF::Query.new(pattern, &block) end |
Instance Method Details
#failure_message_for_should ⇒ Object
21 22 23 |
# File 'lib/roadforest/test-support/matchers.rb', line 21 def "expected #{@query.patterns.inspect} to return solutions on \n#{@actual.dump(:nquads)}\n but didn't" end |
#failure_message_for_should_not ⇒ Object
25 26 27 |
# File 'lib/roadforest/test-support/matchers.rb', line 25 def "expected #{@query.patterns.inspect} not to return solutions on \n#{@actual.dump(:nquads)}\n but does" end |
#matches?(actual) ⇒ Boolean
15 16 17 18 19 |
# File 'lib/roadforest/test-support/matchers.rb', line 15 def matches?(actual) @actual = actual solutions = @query.execute(actual) not solutions.empty? end |