veritas 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (244) hide show
  1. data/.travis.yml +4 -2
  2. data/Gemfile +7 -8
  3. data/README.rdoc +17 -18
  4. data/Rakefile +2 -2
  5. data/TODO +18 -14
  6. data/benchmarks/memory.rb +8 -7
  7. data/benchmarks/speed.rb +4 -3
  8. data/config/flay.yml +1 -1
  9. data/lib/veritas/aggregate.rb +3 -0
  10. data/lib/veritas/algebra/join.rb +11 -4
  11. data/lib/veritas/algebra/product.rb +2 -1
  12. data/lib/veritas/algebra/restriction.rb +3 -2
  13. data/lib/veritas/algebra/summarization.rb +8 -3
  14. data/lib/veritas/attribute/string.rb +3 -1
  15. data/lib/veritas/attribute.rb +1 -1
  16. data/lib/veritas/function/binary.rb +1 -0
  17. data/lib/veritas/function/comparable.rb +1 -0
  18. data/lib/veritas/function/connective/negation.rb +2 -0
  19. data/lib/veritas/function/proposition.rb +5 -1
  20. data/lib/veritas/function/unary.rb +1 -0
  21. data/lib/veritas/function.rb +3 -0
  22. data/lib/veritas/relation/base.rb +32 -3
  23. data/lib/veritas/relation/header.rb +2 -2
  24. data/lib/veritas/relation/materialized.rb +12 -0
  25. data/lib/veritas/relation/operation/binary.rb +1 -0
  26. data/lib/veritas/relation/operation/limit.rb +1 -1
  27. data/lib/veritas/relation/operation/offset.rb +1 -1
  28. data/lib/veritas/relation/operation/order/direction_set.rb +67 -5
  29. data/lib/veritas/relation/operation/order.rb +25 -3
  30. data/lib/veritas/relation/operation/set.rb +1 -0
  31. data/lib/veritas/relation.rb +20 -7
  32. data/lib/veritas/support/abstract_class.rb +1 -0
  33. data/lib/veritas/support/evaluator.rb +49 -3
  34. data/lib/veritas/support/immutable.rb +2 -1
  35. data/lib/veritas/tuple.rb +28 -14
  36. data/lib/veritas/version.rb +1 -1
  37. data/lib/veritas.rb +6 -3
  38. data/spec/integration/veritas/algebra/projection_spec.rb +4 -4
  39. data/spec/integration/veritas/relation/efficient_enumerable_spec.rb +1 -1
  40. data/spec/shared/each_method_behaviour.rb +2 -2
  41. data/spec/shared/hash_method_behavior.rb +2 -2
  42. data/spec/spec_helper.rb +1 -0
  43. data/spec/unit/date/pred_spec.rb +3 -3
  44. data/spec/unit/range/overlaps_spec.rb +14 -14
  45. data/spec/unit/range/to_inclusive_spec.rb +2 -2
  46. data/spec/unit/time/pred_spec.rb +3 -3
  47. data/spec/unit/veritas/abstract_class/class_methods/new_spec.rb +1 -1
  48. data/spec/unit/veritas/aggregate/count/class_methods/call_spec.rb +1 -1
  49. data/spec/unit/veritas/aggregate/count/methods/count_spec.rb +1 -1
  50. data/spec/unit/veritas/aggregate/maximum/methods/maximum_spec.rb +1 -1
  51. data/spec/unit/veritas/aggregate/mean/class_methods/call_spec.rb +1 -1
  52. data/spec/unit/veritas/aggregate/mean/methods/mean_spec.rb +1 -1
  53. data/spec/unit/veritas/aggregate/minimum/methods/minimum_spec.rb +1 -1
  54. data/spec/unit/veritas/aggregate/standard_deviation/methods/standard_deviation_spec.rb +1 -1
  55. data/spec/unit/veritas/aggregate/sum/class_methods/call_spec.rb +1 -1
  56. data/spec/unit/veritas/aggregate/sum/methods/sum_spec.rb +1 -1
  57. data/spec/unit/veritas/aggregate/variance/class_methods/call_spec.rb +1 -1
  58. data/spec/unit/veritas/aggregate/variance/methods/variance_spec.rb +1 -1
  59. data/spec/unit/veritas/algebra/difference/methods/difference_spec.rb +2 -2
  60. data/spec/unit/veritas/algebra/extension/class_methods/new_spec.rb +1 -1
  61. data/spec/unit/veritas/algebra/extension/eql_spec.rb +5 -5
  62. data/spec/unit/veritas/algebra/extension/header_spec.rb +1 -1
  63. data/spec/unit/veritas/algebra/extension/methods/extend_spec.rb +1 -1
  64. data/spec/unit/veritas/algebra/intersection/methods/intersect_spec.rb +2 -2
  65. data/spec/unit/veritas/algebra/join/class_methods/new_spec.rb +2 -2
  66. data/spec/unit/veritas/algebra/join/join_header_spec.rb +17 -0
  67. data/spec/unit/veritas/algebra/join/methods/join_spec.rb +2 -2
  68. data/spec/unit/veritas/algebra/product/class_methods/new_spec.rb +1 -1
  69. data/spec/unit/veritas/algebra/product/methods/product_spec.rb +1 -1
  70. data/spec/unit/veritas/algebra/projection/eql_spec.rb +5 -5
  71. data/spec/unit/veritas/algebra/projection/header_spec.rb +1 -1
  72. data/spec/unit/veritas/algebra/projection/methods/project_spec.rb +1 -1
  73. data/spec/unit/veritas/algebra/projection/methods/remove_spec.rb +1 -1
  74. data/spec/unit/veritas/algebra/rename/aliases/class_methods/coerce_spec.rb +4 -4
  75. data/spec/unit/veritas/algebra/rename/aliases/class_methods/new_spec.rb +1 -1
  76. data/spec/unit/veritas/algebra/rename/aliases/eql_spec.rb +4 -4
  77. data/spec/unit/veritas/algebra/rename/aliases/equal_value_spec.rb +4 -4
  78. data/spec/unit/veritas/algebra/rename/aliases/to_hash_spec.rb +1 -1
  79. data/spec/unit/veritas/algebra/rename/aliases/union_spec.rb +10 -10
  80. data/spec/unit/veritas/algebra/rename/directions_spec.rb +3 -3
  81. data/spec/unit/veritas/algebra/rename/eql_spec.rb +5 -5
  82. data/spec/unit/veritas/algebra/rename/header_spec.rb +1 -1
  83. data/spec/unit/veritas/algebra/rename/methods/rename_spec.rb +1 -1
  84. data/spec/unit/veritas/algebra/restriction/eql_spec.rb +5 -5
  85. data/spec/unit/veritas/algebra/restriction/methods/restrict_spec.rb +1 -1
  86. data/spec/unit/veritas/algebra/summarization/class_methods/new_spec.rb +1 -1
  87. data/spec/unit/veritas/algebra/summarization/eql_spec.rb +7 -7
  88. data/spec/unit/veritas/algebra/summarization/header_spec.rb +1 -1
  89. data/spec/unit/veritas/algebra/summarization/methods/summarize_spec.rb +18 -8
  90. data/spec/unit/veritas/algebra/summarization/summaries/summarize_by_spec.rb +3 -3
  91. data/spec/unit/veritas/algebra/summarization/summaries/to_hash_spec.rb +2 -2
  92. data/spec/unit/veritas/algebra/summarization/summary/summarize_by_spec.rb +1 -1
  93. data/spec/unit/veritas/algebra/union/methods/union_spec.rb +2 -2
  94. data/spec/unit/veritas/aliasable/inheritable_alias_spec.rb +2 -2
  95. data/spec/unit/veritas/attribute/class_methods/coerce_spec.rb +4 -4
  96. data/spec/unit/veritas/attribute/class_methods/descendants_spec.rb +2 -6
  97. data/spec/unit/veritas/attribute/class_methods/new_spec.rb +1 -1
  98. data/spec/unit/veritas/attribute/comparable/comparable_spec.rb +3 -3
  99. data/spec/unit/veritas/attribute/eql_spec.rb +4 -4
  100. data/spec/unit/veritas/attribute/equal_value_spec.rb +4 -4
  101. data/spec/unit/veritas/attribute/inspect_spec.rb +1 -1
  102. data/spec/unit/veritas/attribute/joinable_spec.rb +4 -4
  103. data/spec/unit/veritas/attribute/numeric/joinable_spec.rb +3 -3
  104. data/spec/unit/veritas/attribute/options_spec.rb +2 -2
  105. data/spec/unit/veritas/attribute/orderable/asc_spec.rb +1 -1
  106. data/spec/unit/veritas/attribute/orderable/desc_spec.rb +1 -1
  107. data/spec/unit/veritas/attribute/rename_spec.rb +1 -1
  108. data/spec/unit/veritas/attribute/string/joinable_spec.rb +14 -4
  109. data/spec/unit/veritas/evaluator/context/method_missing_spec.rb +29 -0
  110. data/spec/unit/veritas/evaluator/context/respond_to_spec.rb +39 -0
  111. data/spec/unit/veritas/evaluator/context/send_spec.rb +28 -0
  112. data/spec/unit/veritas/evaluator/context/yield_spec.rb +14 -0
  113. data/spec/unit/veritas/function/binary/equal_value_spec.rb +5 -5
  114. data/spec/unit/veritas/function/binary/invertible/inverse_spec.rb +1 -1
  115. data/spec/unit/veritas/function/binary/rename_spec.rb +3 -3
  116. data/spec/unit/veritas/function/connective/conjunction/inverse_spec.rb +1 -1
  117. data/spec/unit/veritas/function/connective/disjunction/inverse_spec.rb +1 -1
  118. data/spec/unit/veritas/function/connective/negation/methods/not_spec.rb +2 -2
  119. data/spec/unit/veritas/function/numeric/absolute/methods/absolute_spec.rb +1 -1
  120. data/spec/unit/veritas/function/numeric/addition/methods/add_spec.rb +1 -1
  121. data/spec/unit/veritas/function/numeric/division/methods/divide_spec.rb +1 -1
  122. data/spec/unit/veritas/function/numeric/exponentiation/inverse_spec.rb +1 -1
  123. data/spec/unit/veritas/function/numeric/exponentiation/methods/exponent_spec.rb +1 -1
  124. data/spec/unit/veritas/function/numeric/modulo/methods/modulo_spec.rb +1 -1
  125. data/spec/unit/veritas/function/numeric/multiplication/methods/multiply_spec.rb +1 -1
  126. data/spec/unit/veritas/function/numeric/square_root/methods/square_root_spec.rb +1 -1
  127. data/spec/unit/veritas/function/numeric/subtraction/methods/subtract_spec.rb +1 -1
  128. data/spec/unit/veritas/function/numeric/unary_minus/methods/unary_minus_spec.rb +1 -1
  129. data/spec/unit/veritas/function/numeric/unary_plus/methods/unary_plus_spec.rb +1 -1
  130. data/spec/unit/veritas/function/predicate/eql_spec.rb +5 -5
  131. data/spec/unit/veritas/function/predicate/equality/inverse_spec.rb +1 -1
  132. data/spec/unit/veritas/function/predicate/equality/methods/eq_spec.rb +1 -1
  133. data/spec/unit/veritas/function/predicate/exclusion/inverse_spec.rb +1 -1
  134. data/spec/unit/veritas/function/predicate/exclusion/methods/exclude_spec.rb +1 -1
  135. data/spec/unit/veritas/function/predicate/greater_than/inverse_spec.rb +1 -1
  136. data/spec/unit/veritas/function/predicate/greater_than/methods/gt_spec.rb +1 -1
  137. data/spec/unit/veritas/function/predicate/greater_than_or_equal_to/inverse_spec.rb +1 -1
  138. data/spec/unit/veritas/function/predicate/greater_than_or_equal_to/methods/gte_spec.rb +1 -1
  139. data/spec/unit/veritas/function/predicate/inclusion/inverse_spec.rb +1 -1
  140. data/spec/unit/veritas/function/predicate/inclusion/methods/include_spec.rb +1 -1
  141. data/spec/unit/veritas/function/predicate/inequality/inverse_spec.rb +1 -1
  142. data/spec/unit/veritas/function/predicate/inequality/methods/ne_spec.rb +1 -1
  143. data/spec/unit/veritas/function/predicate/inverse_spec.rb +1 -1
  144. data/spec/unit/veritas/function/predicate/less_than/inverse_spec.rb +1 -1
  145. data/spec/unit/veritas/function/predicate/less_than/methods/lt_spec.rb +1 -1
  146. data/spec/unit/veritas/function/predicate/less_than_or_equal_to/inverse_spec.rb +1 -1
  147. data/spec/unit/veritas/function/predicate/less_than_or_equal_to/methods/lte_spec.rb +1 -1
  148. data/spec/unit/veritas/function/predicate/match/inverse_spec.rb +1 -1
  149. data/spec/unit/veritas/function/predicate/match/methods/match_spec.rb +1 -1
  150. data/spec/unit/veritas/function/predicate/no_match/inverse_spec.rb +1 -1
  151. data/spec/unit/veritas/function/predicate/no_match/methods/no_match_spec.rb +1 -1
  152. data/spec/unit/veritas/function/proposition/eql_spec.rb +3 -3
  153. data/spec/unit/veritas/function/proposition/equal_value_spec.rb +3 -3
  154. data/spec/unit/veritas/function/string/length/methods/length_spec.rb +1 -1
  155. data/spec/unit/veritas/function/unary/equal_value_spec.rb +4 -4
  156. data/spec/unit/veritas/function/unary/invertible/inverse_spec.rb +1 -1
  157. data/spec/unit/veritas/function/unary/rename_spec.rb +1 -1
  158. data/spec/unit/veritas/immutable/class_methods/freeze_object_spec.rb +7 -1
  159. data/spec/unit/veritas/immutable/class_methods/new_spec.rb +1 -1
  160. data/spec/unit/veritas/immutable/freeze_spec.rb +2 -2
  161. data/spec/unit/veritas/immutable/module_methods/memoize_spec.rb +2 -2
  162. data/spec/unit/veritas/operation/binary/eql_spec.rb +5 -5
  163. data/spec/unit/veritas/operation/unary/eql_spec.rb +4 -4
  164. data/spec/unit/veritas/relation/base/class_methods/new_spec.rb +35 -0
  165. data/spec/unit/veritas/relation/base/eql_spec.rb +100 -0
  166. data/spec/unit/veritas/relation/base/hash_spec.rb +16 -0
  167. data/spec/unit/veritas/relation/class_methods/new_spec.rb +2 -2
  168. data/spec/unit/veritas/relation/directions_spec.rb +1 -1
  169. data/spec/unit/veritas/relation/eql_spec.rb +15 -15
  170. data/spec/unit/veritas/relation/equal_value_spec.rb +16 -16
  171. data/spec/unit/veritas/relation/header/class_methods/coerce_spec.rb +1 -1
  172. data/spec/unit/veritas/relation/header/class_methods/new_spec.rb +2 -2
  173. data/spec/unit/veritas/relation/header/difference_spec.rb +1 -1
  174. data/spec/unit/veritas/relation/header/eql_spec.rb +5 -5
  175. data/spec/unit/veritas/relation/header/equal_value_spec.rb +7 -7
  176. data/spec/unit/veritas/relation/header/inspect_spec.rb +1 -1
  177. data/spec/unit/veritas/relation/header/intersect_spec.rb +1 -1
  178. data/spec/unit/veritas/relation/header/project_spec.rb +1 -1
  179. data/spec/unit/veritas/relation/header/rename_spec.rb +1 -1
  180. data/spec/unit/veritas/relation/header/to_ary_spec.rb +1 -1
  181. data/spec/unit/veritas/relation/header/union_spec.rb +1 -1
  182. data/spec/unit/veritas/relation/materialize_spec.rb +3 -3
  183. data/spec/unit/veritas/relation/materialized/class_methods/new_spec.rb +2 -2
  184. data/spec/unit/veritas/relation/materialized/materialized_spec.rb +15 -0
  185. data/spec/unit/veritas/relation/materialized_spec.rb +15 -0
  186. data/spec/unit/veritas/relation/operation/binary/class_methods/new_spec.rb +6 -6
  187. data/spec/unit/veritas/relation/operation/binary/header_spec.rb +1 -1
  188. data/spec/unit/veritas/relation/operation/combination/header_spec.rb +1 -1
  189. data/spec/unit/veritas/relation/operation/limit/class_methods/new_spec.rb +12 -5
  190. data/spec/unit/veritas/relation/operation/limit/directions_spec.rb +1 -1
  191. data/spec/unit/veritas/relation/operation/limit/each_spec.rb +1 -1
  192. data/spec/unit/veritas/relation/operation/limit/eql_spec.rb +11 -11
  193. data/spec/unit/veritas/relation/operation/limit/hash_spec.rb +1 -1
  194. data/spec/unit/veritas/relation/operation/limit/limit_spec.rb +1 -1
  195. data/spec/unit/veritas/relation/operation/limit/methods/first_spec.rb +3 -3
  196. data/spec/unit/veritas/relation/operation/limit/methods/last_spec.rb +3 -3
  197. data/spec/unit/veritas/relation/operation/limit/methods/take_spec.rb +2 -2
  198. data/spec/unit/veritas/relation/operation/offset/class_methods/new_spec.rb +12 -5
  199. data/spec/unit/veritas/relation/operation/offset/directions_spec.rb +1 -1
  200. data/spec/unit/veritas/relation/operation/offset/each_spec.rb +1 -1
  201. data/spec/unit/veritas/relation/operation/offset/eql_spec.rb +11 -11
  202. data/spec/unit/veritas/relation/operation/offset/hash_spec.rb +1 -1
  203. data/spec/unit/veritas/relation/operation/offset/methods/drop_spec.rb +2 -2
  204. data/spec/unit/veritas/relation/operation/offset/offset_spec.rb +1 -1
  205. data/spec/unit/veritas/relation/operation/order/ascending/reverse_spec.rb +1 -1
  206. data/spec/unit/veritas/relation/operation/order/class_methods/new_spec.rb +3 -7
  207. data/spec/unit/veritas/relation/operation/order/descending/reverse_spec.rb +1 -1
  208. data/spec/unit/veritas/relation/operation/order/direction/class_methods/coerce_spec.rb +1 -1
  209. data/spec/unit/veritas/relation/operation/order/direction/eql_spec.rb +4 -4
  210. data/spec/unit/veritas/relation/operation/order/direction/rename_spec.rb +1 -1
  211. data/spec/unit/veritas/relation/operation/order/direction_set/attributes_spec.rb +1 -1
  212. data/spec/unit/veritas/relation/operation/order/direction_set/class_methods/coerce_spec.rb +4 -4
  213. data/spec/unit/veritas/relation/operation/order/direction_set/class_methods/new_spec.rb +32 -0
  214. data/spec/unit/veritas/relation/operation/order/direction_set/eql_spec.rb +4 -4
  215. data/spec/unit/veritas/relation/operation/order/direction_set/equal_value_spec.rb +6 -6
  216. data/spec/unit/veritas/relation/operation/order/direction_set/project_spec.rb +1 -1
  217. data/spec/unit/veritas/relation/operation/order/direction_set/rename_spec.rb +1 -1
  218. data/spec/unit/veritas/relation/operation/order/direction_set/reverse_spec.rb +2 -2
  219. data/spec/unit/veritas/relation/operation/order/direction_set/sort_tuples_spec.rb +4 -4
  220. data/spec/unit/veritas/relation/operation/order/direction_set/to_ary_spec.rb +1 -1
  221. data/spec/unit/veritas/relation/operation/order/direction_set/union_spec.rb +1 -1
  222. data/spec/unit/veritas/relation/operation/order/eql_spec.rb +5 -5
  223. data/spec/unit/veritas/relation/operation/order/methods/order_spec.rb +24 -4
  224. data/spec/unit/veritas/relation/operation/order/methods/sort_by_spec.rb +28 -0
  225. data/spec/unit/veritas/relation/operation/reverse/class_methods/new_spec.rb +6 -6
  226. data/spec/unit/veritas/relation/operation/reverse/directions_spec.rb +1 -1
  227. data/spec/unit/veritas/relation/operation/reverse/each_spec.rb +1 -1
  228. data/spec/unit/veritas/relation/operation/reverse/methods/reverse_spec.rb +2 -2
  229. data/spec/unit/veritas/relation/operation/set/class_methods/new_spec.rb +1 -1
  230. data/spec/unit/veritas/tuple/class_methods/coerce_spec.rb +1 -1
  231. data/spec/unit/veritas/tuple/data_spec.rb +16 -0
  232. data/spec/unit/veritas/tuple/element_reference_spec.rb +1 -1
  233. data/spec/unit/veritas/tuple/eql_spec.rb +5 -5
  234. data/spec/unit/veritas/tuple/equal_value_spec.rb +7 -7
  235. data/spec/unit/veritas/tuple/extend_spec.rb +3 -3
  236. data/spec/unit/veritas/tuple/hash_spec.rb +1 -1
  237. data/spec/unit/veritas/tuple/inspect_spec.rb +2 -2
  238. data/spec/unit/veritas/tuple/join_spec.rb +1 -1
  239. data/spec/unit/veritas/tuple/predicate_spec.rb +44 -0
  240. data/spec/unit/veritas/tuple/project_spec.rb +1 -1
  241. data/spec/unit/veritas/tuple/to_ary_spec.rb +3 -1
  242. data/tasks/metrics/heckle.rake +1 -0
  243. data/veritas.gemspec +28 -14
  244. metadata +31 -17
@@ -0,0 +1,32 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Relation::Operation::Order::DirectionSet, '.new' do
6
+ subject { object.new(argument) }
7
+
8
+ let(:id) { Attribute::Integer.new(:id) }
9
+ let(:name) { Attribute::String.new(:name) }
10
+ let(:age) { Attribute::Integer.new(:age) }
11
+ let(:object) { described_class }
12
+
13
+ context 'with an argument that responds to #to_ary and do not contain duplicates' do
14
+ let(:argument) { [ id, name ] }
15
+
16
+ it { should be_instance_of(object) }
17
+
18
+ it { should == argument }
19
+ end
20
+
21
+ context 'with an argument that responds to #to_ary and contain duplicates' do
22
+ let(:argument) { [ id, id, name, name, age ] }
23
+
24
+ specify { expect { subject }.to raise_error(DuplicateAttributeError, 'duplicate attributes: id, name') }
25
+ end
26
+
27
+ context 'with an argument that does not respond to #to_ary' do
28
+ let(:argument) { { :id => Integer } }
29
+
30
+ specify { expect { subject }.to raise_error(NoMethodError) }
31
+ end
32
+ end
@@ -14,7 +14,7 @@ describe Relation::Operation::Order::DirectionSet, '#eql?' do
14
14
  it { should be(true) }
15
15
 
16
16
  it 'is symmetric' do
17
- should == other.eql?(object)
17
+ should eql(other.eql?(object))
18
18
  end
19
19
  end
20
20
 
@@ -24,7 +24,7 @@ describe Relation::Operation::Order::DirectionSet, '#eql?' do
24
24
  it { should be(true) }
25
25
 
26
26
  it 'is symmetric' do
27
- should == other.eql?(object)
27
+ should eql(other.eql?(object))
28
28
  end
29
29
  end
30
30
 
@@ -34,7 +34,7 @@ describe Relation::Operation::Order::DirectionSet, '#eql?' do
34
34
  it { should be(false) }
35
35
 
36
36
  it 'is symmetric' do
37
- should == other.eql?(object)
37
+ should eql(other.eql?(object))
38
38
  end
39
39
  end
40
40
 
@@ -45,7 +45,7 @@ describe Relation::Operation::Order::DirectionSet, '#eql?' do
45
45
  it { should be(false) }
46
46
 
47
47
  it 'is symmetric' do
48
- should == other.eql?(object)
48
+ should eql(other.eql?(object))
49
49
  end
50
50
  end
51
51
  end
@@ -14,7 +14,7 @@ describe Relation::Operation::Order::DirectionSet, '#==' do
14
14
  it { should be(true) }
15
15
 
16
16
  it 'is symmetric' do
17
- should == (other == object)
17
+ should eql(other == object)
18
18
  end
19
19
  end
20
20
 
@@ -24,7 +24,7 @@ describe Relation::Operation::Order::DirectionSet, '#==' do
24
24
  it { should be(true) }
25
25
 
26
26
  it 'is symmetric' do
27
- should == (other == object)
27
+ should eql(other == object)
28
28
  end
29
29
  end
30
30
 
@@ -34,7 +34,7 @@ describe Relation::Operation::Order::DirectionSet, '#==' do
34
34
  it { should be(true) }
35
35
 
36
36
  it 'is symmetric' do
37
- should == (other == object)
37
+ should eql(other == object)
38
38
  end
39
39
  end
40
40
 
@@ -45,7 +45,7 @@ describe Relation::Operation::Order::DirectionSet, '#==' do
45
45
  it { should be(false) }
46
46
 
47
47
  it 'is symmetric' do
48
- should == (other == object)
48
+ should eql(other == object)
49
49
  end
50
50
  end
51
51
 
@@ -55,7 +55,7 @@ describe Relation::Operation::Order::DirectionSet, '#==' do
55
55
  it { should be(true) }
56
56
 
57
57
  it 'is symmetric' do
58
- should == (other == object)
58
+ should eql(other == object)
59
59
  end
60
60
  end
61
61
 
@@ -65,7 +65,7 @@ describe Relation::Operation::Order::DirectionSet, '#==' do
65
65
  it { should be(false) }
66
66
 
67
67
  it 'is symmetric' do
68
- should == (other == object)
68
+ should eql(other == object)
69
69
  end
70
70
  end
71
71
  end
@@ -11,7 +11,7 @@ describe Relation::Operation::Order::DirectionSet, '#project' do
11
11
 
12
12
  it { should_not equal(object) }
13
13
 
14
- it { should be_kind_of(described_class) }
14
+ it { should be_instance_of(described_class) }
15
15
 
16
16
  it { should == [ header[:id] ] }
17
17
  end
@@ -12,7 +12,7 @@ describe Relation::Operation::Order::DirectionSet, '#rename' do
12
12
 
13
13
  it { should_not equal(object) }
14
14
 
15
- it { should be_kind_of(described_class) }
15
+ it { should be_instance_of(described_class) }
16
16
 
17
17
  it { should == [ Attribute::Integer.new(:other_id) ] }
18
18
  end
@@ -11,13 +11,13 @@ describe Relation::Operation::Order::DirectionSet, '#reverse' do
11
11
 
12
12
  it_should_behave_like 'an idempotent method'
13
13
 
14
- it { should be_kind_of(described_class) }
14
+ it { should be_instance_of(described_class) }
15
15
 
16
16
  it 'reverses each direction' do
17
17
  should == [ attribute1.desc, attribute2.desc ]
18
18
  end
19
19
 
20
20
  it 'does not reverse the attribute order' do
21
- subject.attributes.should == [ attribute1, attribute2 ]
21
+ subject.attributes.should eql([ attribute1, attribute2 ])
22
22
  end
23
23
  end
@@ -13,7 +13,7 @@ describe Relation::Operation::Order::DirectionSet, '#sort_tuples' do
13
13
  context 'sorted with ascending id and descending name' do
14
14
  let(:object) { described_class.new([ relation[:id].asc, relation[:name].desc ]) }
15
15
 
16
- it { should be_kind_of(Array) }
16
+ it { should be_instance_of(Array) }
17
17
 
18
18
  it { should == [ [ 1, 'Dan Kubb' ], [ 2, 'Dan Kubb' ], [ 2, 'Alex Kubb' ] ] }
19
19
  end
@@ -21,7 +21,7 @@ describe Relation::Operation::Order::DirectionSet, '#sort_tuples' do
21
21
  context 'sorted with ascending id and ascending name' do
22
22
  let(:object) { described_class.new([ relation[:id].asc, relation[:name].asc ]) }
23
23
 
24
- it { should be_kind_of(Array) }
24
+ it { should be_instance_of(Array) }
25
25
 
26
26
  it { should == [ [ 1, 'Dan Kubb' ], [ 2, 'Alex Kubb' ], [ 2, 'Dan Kubb' ] ] }
27
27
  end
@@ -29,7 +29,7 @@ describe Relation::Operation::Order::DirectionSet, '#sort_tuples' do
29
29
  context 'sorted with descending id and ascending name' do
30
30
  let(:object) { described_class.new([ relation[:id].desc, relation[:name].asc ]) }
31
31
 
32
- it { should be_kind_of(Array) }
32
+ it { should be_instance_of(Array) }
33
33
 
34
34
  it { should == [ [ 2, 'Alex Kubb' ], [ 2, 'Dan Kubb' ], [ 1, 'Dan Kubb' ] ] }
35
35
  end
@@ -37,7 +37,7 @@ describe Relation::Operation::Order::DirectionSet, '#sort_tuples' do
37
37
  context 'sorted with descending id and descending name' do
38
38
  let(:object) { described_class.new([ relation[:id].desc, relation[:name].desc ]) }
39
39
 
40
- it { should be_kind_of(Array) }
40
+ it { should be_instance_of(Array) }
41
41
 
42
42
  it { should == [ [ 2, 'Dan Kubb' ], [ 2, 'Alex Kubb' ], [ 1, 'Dan Kubb' ] ] }
43
43
  end
@@ -8,7 +8,7 @@ describe Relation::Operation::Order::DirectionSet, '#to_ary' do
8
8
  let(:attribute) { Attribute::Integer.new(:id) }
9
9
  let(:object) { described_class.new([ attribute ]) }
10
10
 
11
- it { should be_kind_of(Array) }
11
+ it { should be_instance_of(Array) }
12
12
 
13
13
  it { should == [ attribute.asc ] }
14
14
  end
@@ -11,7 +11,7 @@ require 'spec_helper'
11
11
  let(:object) { described_class.new([ attribute1 ]) }
12
12
  let(:other) { described_class.new([ attribute2 ]) }
13
13
 
14
- it { should be_kind_of(described_class) }
14
+ it { should be_instance_of(described_class) }
15
15
 
16
16
  it { should == [ attribute1.asc, attribute2.asc ] }
17
17
  end
@@ -15,7 +15,7 @@ describe Relation::Operation::Order, '#eql?' do
15
15
  it { should be(true) }
16
16
 
17
17
  it 'is symmetric' do
18
- should == other.eql?(object)
18
+ should eql(other.eql?(object))
19
19
  end
20
20
  end
21
21
 
@@ -25,7 +25,7 @@ describe Relation::Operation::Order, '#eql?' do
25
25
  it { should be(true) }
26
26
 
27
27
  it 'is symmetric' do
28
- should == other.eql?(object)
28
+ should eql(other.eql?(object))
29
29
  end
30
30
  end
31
31
 
@@ -35,7 +35,7 @@ describe Relation::Operation::Order, '#eql?' do
35
35
  it { should be(false) }
36
36
 
37
37
  it 'is symmetric' do
38
- should == other.eql?(object)
38
+ should eql(other.eql?(object))
39
39
  end
40
40
  end
41
41
 
@@ -47,7 +47,7 @@ describe Relation::Operation::Order, '#eql?' do
47
47
  it { should be(false) }
48
48
 
49
49
  it 'is symmetric' do
50
- should == other.eql?(object)
50
+ should eql(other.eql?(object))
51
51
  end
52
52
  end
53
53
 
@@ -59,7 +59,7 @@ describe Relation::Operation::Order, '#eql?' do
59
59
  it { should be(false) }
60
60
 
61
61
  it 'is symmetric' do
62
- should == other.eql?(object)
62
+ should eql(other.eql?(object))
63
63
  end
64
64
  end
65
65
  end
@@ -6,15 +6,29 @@ describe Relation::Operation::Order::Methods, '#order' do
6
6
  let(:described_class) { Relation }
7
7
  let(:object) { described_class.new([ [ :id, Integer ] ], [ [ 1 ], [ 2 ] ].each) }
8
8
 
9
+ before do
10
+ @original, $stderr = $stderr, StringIO.new
11
+ end
12
+
13
+ after do
14
+ $stderr = @original
15
+ end
16
+
9
17
  context 'with no arguments' do
10
18
  subject { object.order }
11
19
 
12
- it { should be_kind_of(Relation::Operation::Order) }
20
+ it { should be_instance_of(Relation::Operation::Order) }
13
21
 
14
22
  its(:directions) { should == object.header }
15
23
 
16
24
  it 'behaves the same as Array#sort_by' do
17
- subject.to_a.should == object.to_a.sort_by { |tuple| tuple[:id] }
25
+ subject.to_a.should eql(object.to_a.sort_by { |tuple| tuple[:id] })
26
+ end
27
+
28
+ it 'warns with a deprecation message' do
29
+ expect { subject }.to change { $stderr.string.chomp }.
30
+ from(nil).
31
+ to('Veritas::Relation#order is deprecated and will be removed from Veritas 0.0.6')
18
32
  end
19
33
  end
20
34
 
@@ -23,12 +37,18 @@ describe Relation::Operation::Order::Methods, '#order' do
23
37
 
24
38
  let(:block) { lambda { |relation| [ relation[:id].desc ] } }
25
39
 
26
- it { should be_kind_of(Relation::Operation::Order) }
40
+ it { should be_instance_of(Relation::Operation::Order) }
27
41
 
28
42
  its(:directions) { should == block.call(object) }
29
43
 
30
44
  it 'behaves the same as Array#sort_by' do
31
- subject.to_a.should == object.to_a.sort_by { |tuple| tuple[:id] }.reverse
45
+ subject.to_a.should eql(object.to_a.sort_by { |tuple| tuple[:id] }.reverse)
46
+ end
47
+
48
+ it 'warns with a deprecation message' do
49
+ expect { subject }.to change { $stderr.string.chomp }.
50
+ from(nil).
51
+ to('Veritas::Relation#order is deprecated and will be removed from Veritas 0.0.6')
32
52
  end
33
53
  end
34
54
  end
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Relation::Operation::Order::Methods, '#sort_by' do
6
+ let(:described_class) { Relation }
7
+ let(:object) { described_class.new([ [ :id, Integer ] ], [ [ 1 ], [ 2 ] ].each) }
8
+
9
+ context 'with no block' do
10
+ subject { object.sort_by }
11
+
12
+ specify { expect { subject }.to raise_error(LocalJumpError) }
13
+ end
14
+
15
+ context 'with a block' do
16
+ subject { object.sort_by(&block) }
17
+
18
+ let(:block) { lambda { |relation| [ relation[:id].desc ] } }
19
+
20
+ it { should be_instance_of(Relation::Operation::Order) }
21
+
22
+ its(:directions) { should == block.call(object) }
23
+
24
+ it 'behaves the same as Array#sort_by' do
25
+ subject.to_a.should eql(object.to_a.sort_by { |tuple| tuple[:id] }.reverse)
26
+ end
27
+ end
28
+ end
@@ -9,22 +9,22 @@ describe Relation::Operation::Reverse, '.new' do
9
9
  let(:object) { described_class }
10
10
 
11
11
  context 'with an ordered relation' do
12
- let(:relation) { original_relation.order { |r| r[:id] } }
12
+ let(:relation) { original_relation.sort_by { |r| r.id } }
13
13
 
14
- it { should be_kind_of(object) }
14
+ it { should be_instance_of(object) }
15
15
 
16
16
  it 'reverses the directions' do
17
- subject.directions.should == relation.directions.reverse
17
+ subject.directions.should eql(relation.directions.reverse)
18
18
  end
19
19
  end
20
20
 
21
21
  context 'with an ordered relation having an empty header' do
22
- let(:relation) { original_relation.order { |r| r[:id] }.project([]) }
22
+ let(:relation) { original_relation.sort_by { |r| r.id }.project([]) }
23
23
 
24
- it { should be_kind_of(object) }
24
+ it { should be_instance_of(object) }
25
25
 
26
26
  it 'reverses the directions' do
27
- subject.directions.should == relation.directions.reverse
27
+ subject.directions.should eql(relation.directions.reverse)
28
28
  end
29
29
  end
30
30
 
@@ -7,7 +7,7 @@ describe Relation::Operation::Reverse, '#directions' do
7
7
 
8
8
  let(:relation) { Relation.new([ [ :id, Integer ] ], [].each) }
9
9
  let(:object) { described_class.new(ordered) }
10
- let(:ordered) { relation.order }
10
+ let(:ordered) { relation.sort_by { |r| r.id } }
11
11
 
12
12
  it_should_behave_like 'an idempotent method'
13
13
 
@@ -6,7 +6,7 @@ describe Relation::Operation::Reverse, '#each' do
6
6
  subject { object.each { |tuple| yields << tuple } }
7
7
 
8
8
  let(:relation) { Relation.new([ [ :id, Integer ] ], [ [ 1 ], [ 2 ], [ 3 ] ]) }
9
- let(:order) { relation.order }
9
+ let(:order) { relation.sort_by { |r| r.id } }
10
10
  let(:object) { described_class.new(order) }
11
11
  let(:yields) { [] }
12
12
 
@@ -7,9 +7,9 @@ describe Relation::Operation::Reverse::Methods, '#reverse' do
7
7
 
8
8
  let(:described_class) { Relation }
9
9
  let(:relation) { described_class.new([ [ :id, Integer ] ], [ [ 1 ], [ 2 ] ].each) }
10
- let(:object) { relation.order }
10
+ let(:object) { relation.sort_by { |r| r.id } }
11
11
 
12
- it { should be_kind_of(Relation::Operation::Reverse) }
12
+ it { should be_instance_of(Relation::Operation::Reverse) }
13
13
 
14
14
  it 'behaves the same as Array#reverse' do
15
15
  should == relation.to_a.reverse
@@ -13,7 +13,7 @@ describe Relation::Operation::Set::ClassMethods, '#new' do
13
13
  context 'with relations having equivalent headers' do
14
14
  let(:right) { Relation.new(header, [ [ 2 ] ]) }
15
15
 
16
- it { should be_kind_of(object) }
16
+ it { should be_instance_of(object) }
17
17
  end
18
18
 
19
19
  context 'with relations having headers with common attributes' do
@@ -18,7 +18,7 @@ describe Tuple, '.coerce' do
18
18
  context 'when the argument responds to #to_ary' do
19
19
  let(:argument) { [ 1 ] }
20
20
 
21
- it { should be_kind_of(object) }
21
+ it { should be_instance_of(object) }
22
22
 
23
23
  it { should == tuple }
24
24
  end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Tuple, '#data' do
6
+ subject { object.data }
7
+
8
+ let(:header) { Relation::Header.new([ [ :id, Integer ] ]) }
9
+ let(:object) { described_class.new(header, [ 1 ]) }
10
+
11
+ it_should_behave_like 'an idempotent method'
12
+
13
+ it { should be_instance_of(Hash) }
14
+
15
+ it { should eql(header[:id] => 1) }
16
+ end
@@ -17,6 +17,6 @@ describe Tuple, '#[]' do
17
17
  context 'with an unknown attribute' do
18
18
  let(:attribute) { Attribute::Integer.new(:other_id) }
19
19
 
20
- it { should be_nil }
20
+ specify { expect { subject }.to raise_error(IndexError) }
21
21
  end
22
22
  end
@@ -15,7 +15,7 @@ describe Tuple, '#eql?' do
15
15
  it { should be(true) }
16
16
 
17
17
  it 'is symmetric' do
18
- should == other.eql?(object)
18
+ should eql(other.eql?(object))
19
19
  end
20
20
  end
21
21
 
@@ -25,7 +25,7 @@ describe Tuple, '#eql?' do
25
25
  it { should be(true) }
26
26
 
27
27
  it 'is symmetric' do
28
- should == other.eql?(object)
28
+ should eql(other.eql?(object))
29
29
  end
30
30
  end
31
31
 
@@ -35,7 +35,7 @@ describe Tuple, '#eql?' do
35
35
  it { should be(false) }
36
36
 
37
37
  it 'is symmetric' do
38
- should == other.eql?(object)
38
+ should eql(other.eql?(object))
39
39
  end
40
40
  end
41
41
 
@@ -47,7 +47,7 @@ describe Tuple, '#eql?' do
47
47
  it { should be(false) }
48
48
 
49
49
  it 'is symmetric' do
50
- should == other.eql?(object)
50
+ should eql(other.eql?(object))
51
51
  end
52
52
  end
53
53
 
@@ -59,7 +59,7 @@ describe Tuple, '#eql?' do
59
59
  it { should be(false) }
60
60
 
61
61
  it 'is symmetric' do
62
- should == other.eql?(object)
62
+ should eql(other.eql?(object))
63
63
  end
64
64
  end
65
65
  end
@@ -15,7 +15,7 @@ describe Tuple, '#==' do
15
15
  it { should be(true) }
16
16
 
17
17
  it 'is symmetric' do
18
- should == (other == object)
18
+ should eql(other == object)
19
19
  end
20
20
  end
21
21
 
@@ -25,7 +25,7 @@ describe Tuple, '#==' do
25
25
  it { should be(true) }
26
26
 
27
27
  it 'is symmetric' do
28
- should == (other == object)
28
+ should eql(other == object)
29
29
  end
30
30
  end
31
31
 
@@ -35,7 +35,7 @@ describe Tuple, '#==' do
35
35
  it { should be(true) }
36
36
 
37
37
  it 'is symmetric' do
38
- should == (other == object)
38
+ should eql(other == object)
39
39
  end
40
40
  end
41
41
 
@@ -47,7 +47,7 @@ describe Tuple, '#==' do
47
47
  it { should be(false) }
48
48
 
49
49
  it 'is symmetric' do
50
- should == (other == object)
50
+ should eql(other == object)
51
51
  end
52
52
  end
53
53
 
@@ -59,7 +59,7 @@ describe Tuple, '#==' do
59
59
  it { should be(false) }
60
60
 
61
61
  it 'is symmetric' do
62
- should == (other == object)
62
+ should eql(other == object)
63
63
  end
64
64
  end
65
65
 
@@ -69,7 +69,7 @@ describe Tuple, '#==' do
69
69
  it { should be(true) }
70
70
 
71
71
  it 'is symmetric' do
72
- should == (other == object)
72
+ should eql(other == object)
73
73
  end
74
74
  end
75
75
 
@@ -79,7 +79,7 @@ describe Tuple, '#==' do
79
79
  it { should be(false) }
80
80
 
81
81
  it 'is symmetric' do
82
- should == (other == object)
82
+ should eql(other == object)
83
83
  end
84
84
  end
85
85
  end
@@ -12,7 +12,7 @@ describe Tuple, '#extend' do
12
12
  context 'when the extension is a Proc' do
13
13
  let(:extensions) { [ lambda { |tuple| 1 } ] }
14
14
 
15
- it { should be_kind_of(described_class) }
15
+ it { should be_instance_of(described_class) }
16
16
 
17
17
  its(:header) { should equal(new_header) }
18
18
 
@@ -22,7 +22,7 @@ describe Tuple, '#extend' do
22
22
  context 'when the extension is a Function' do
23
23
  let(:extensions) { [ header[:id].abs ] }
24
24
 
25
- it { should be_kind_of(described_class) }
25
+ it { should be_instance_of(described_class) }
26
26
 
27
27
  its(:header) { should equal(new_header) }
28
28
 
@@ -32,7 +32,7 @@ describe Tuple, '#extend' do
32
32
  context 'when the extension is a value' do
33
33
  let(:extensions) { [ 1 ] }
34
34
 
35
- it { should be_kind_of(described_class) }
35
+ it { should be_instance_of(described_class) }
36
36
 
37
37
  its(:header) { should equal(new_header) }
38
38
 
@@ -11,5 +11,5 @@ describe Tuple, '#hash' do
11
11
 
12
12
  it_should_behave_like 'a hash method'
13
13
 
14
- it { should == described_class.hash ^ header.hash ^ Hash[header.zip(data)].hash }
14
+ it { should == described_class.hash ^ Hash[header.zip(data)].hash }
15
15
  end
@@ -8,7 +8,7 @@ describe Tuple, '#inspect' do
8
8
  let(:header) { Relation::Header.new([ [ :id, Integer ] ]) }
9
9
  let(:object) { described_class.new(header, [ 1 ]) }
10
10
 
11
- it { should be_kind_of(String) }
11
+ it { should be_instance_of(String) }
12
12
 
13
- it { should == '[1]' }
13
+ it { should == '{<Attribute::Integer name: id>=>1}' }
14
14
  end
@@ -10,7 +10,7 @@ describe Tuple, '#join' do
10
10
  let(:values) { [ 'Dan Kubb' ] }
11
11
  let(:object) { described_class.new(header, [ 1 ]) }
12
12
 
13
- it { should be_kind_of(described_class) }
13
+ it { should be_instance_of(described_class) }
14
14
 
15
15
  its(:header) { should equal(new_header) }
16
16
 
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Tuple, '#predicate' do
6
+ subject { object.predicate }
7
+
8
+ context 'when the header is empty' do
9
+ let(:header) { Relation::Header.new([]) }
10
+ let(:object) { described_class.new(header, []) }
11
+
12
+ it_should_behave_like 'an idempotent method'
13
+
14
+ it 'returns a tautology' do
15
+ should equal(Function::Proposition::Tautology.instance)
16
+ end
17
+ end
18
+
19
+ context 'when the header contains one attribute' do
20
+ let(:header) { Relation::Header.new([ [ :id, Integer ] ]) }
21
+ let(:object) { described_class.new(header, [ 1 ]) }
22
+
23
+ it_should_behave_like 'an idempotent method'
24
+
25
+ it { should be_kind_of(Function) }
26
+
27
+ it 'returns an equality match' do
28
+ should eql(header[:id].eq(1))
29
+ end
30
+ end
31
+
32
+ context 'when the header contains two or more attribute' do
33
+ let(:header) { Relation::Header.new([ [ :id, Integer ], [ :name, String ] ]) }
34
+ let(:object) { described_class.new(header, [ 1, 'Dan Kubb' ]) }
35
+
36
+ it_should_behave_like 'an idempotent method'
37
+
38
+ it { should be_kind_of(Function) }
39
+
40
+ it 'returns a conjunction of equality matches' do
41
+ should eql(header[:id].eq(1).and(header[:name].eq('Dan Kubb')))
42
+ end
43
+ end
44
+ end
@@ -9,7 +9,7 @@ describe Tuple, '#project' do
9
9
  let(:reversed_header) { Relation::Header.new(header.to_a.reverse) }
10
10
  let(:object) { described_class.new(header, [ 'Dan Kubb', 1 ]) }
11
11
 
12
- it { should be_kind_of(described_class) }
12
+ it { should be_instance_of(described_class) }
13
13
 
14
14
  its(:header) { should equal(reversed_header) }
15
15