Skip to content

Commit

Permalink
CompoundPredicateSpec - styling
Browse files Browse the repository at this point in the history
  • Loading branch information
asaf schers committed Dec 1, 2017
1 parent 87a9e6b commit af08122
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions spec/scoruby/predicates/compound_predicate_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
require 'spec_helper'

describe Scoruby::Predicates::CompoundPredicate do

context 'evaluates and' do
let (:pred_string) { <<-XML
<CompoundPredicate booleanOperator="and"><True /><SimplePredicate field="f" operator="lessOrEqual" value="16.0918513223731" /></CompoundPredicate>
XML
}
let (:pred_xml) { Nokogiri::XML(pred_string); }
let (:predicate) { described_class.new(pred_xml.children.first) }
let(:pred_string) do
<<-XML
<CompoundPredicate booleanOperator="and">
<True />
<SimplePredicate field="f" operator="lessOrEqual" value="16.0918513223731" />
</CompoundPredicate>
XML
end

let(:pred_xml) { Nokogiri::XML(pred_string); }
let(:predicate) { described_class.new(pred_xml.children.first) }

it 'returns true' do
expect(predicate.true?(f: 16)).to eq true
Expand All @@ -20,12 +24,14 @@
end

context 'evaluates or' do
let (:pred_string) { <<-XML
<CompoundPredicate booleanOperator="or"><False /><SimplePredicate field="f" operator="lessOrEqual" value="16.0918513223731" /></CompoundPredicate>
XML
}
let (:pred_xml) { Nokogiri::XML(pred_string); }
let (:predicate) { described_class.new(pred_xml.children.first) }
let(:pred_string) do
<<-XML
<CompoundPredicate booleanOperator="or"><False /><SimplePredicate field="f" operator="lessOrEqual" value="16.0918513223731" /></CompoundPredicate>
XML
end

let(:pred_xml) { Nokogiri::XML(pred_string); }
let(:predicate) { described_class.new(pred_xml.children.first) }

it 'returns true' do
expect(predicate.true?(f: 16)).to eq true
Expand All @@ -37,14 +43,14 @@
end

context 'evaluates surrogate' do

context 'simple predicate' do
let (:pred_string) { <<-XML
let(:pred_string) do
<<-XML
<CompoundPredicate booleanOperator="surrogate"><SimplePredicate field="f" operator="lessOrEqual" value="16.0918513223731" /><False /></CompoundPredicate>
XML
}
let (:pred_xml) { Nokogiri::XML(pred_string); }
let (:predicate) { described_class.new(pred_xml.children.first) }
XML
end
let(:pred_xml) { Nokogiri::XML(pred_string); }
let(:predicate) { described_class.new(pred_xml.children.first) }

it 'missing' do
expect(predicate.true?(g: 17)).to eq false
Expand All @@ -55,4 +61,4 @@
end
end
end
end
end

0 comments on commit af08122

Please sign in to comment.