spec/piglet/field/reference_spec.rb in piglet-0.1.2 vs spec/piglet/field/reference_spec.rb in piglet-0.2.0
- old
+ new
@@ -17,11 +17,11 @@
@field.to_s.should eql("field")
end
end
context 'eval/aggregate functions' do
- %w(avg count diff max min size sum tokenize).each do |function_name|
+ %w(avg count max min size sum tokenize).each do |function_name|
it "supports \"#{function_name.upcase}\" through ##{function_name}" do
@field.send(function_name).to_s.should eql("#{function_name.upcase}(field)")
end
end
@@ -31,9 +31,23 @@
end
context 'nested expressions' do
it 'handles nested expressions' do
@field.max.min.avg.empty?.tokenize.to_s.should eql("TOKENIZE(IsEmpty(AVG(MIN(MAX(field)))))")
+ end
+ end
+
+ context 'nested fields' do
+ it 'handles nested field access' do
+ @field.a.to_s.should eql('field.a')
+ end
+
+ it 'handles nested field access through #field' do
+ @field.field(:a).to_s.should eql('field.a')
+ end
+
+ it 'handles nested field access throuh []' do
+ @field[0].to_s.should eql('field.$0')
end
end
context 'field renaming' do
it 'supports renaming a field' do
\ No newline at end of file