Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions elasticsearch-dsl/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ end
if File.exist? File.expand_path("../../elasticsearch-extensions", __FILE__)
gem 'elasticsearch-extensions', :path => File.expand_path("../../elasticsearch-extensions", __FILE__), :require => false
end

group :development do
gem 'rspec'
gem 'pry-nav'
end
5 changes: 5 additions & 0 deletions elasticsearch-dsl/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ task :test => 'test:unit'
# ----- Test tasks ------------------------------------------------------------

require 'rake/testtask'
require 'rspec/core/rake_task'

namespace :test do

RSpec::Core::RakeTask.new(:spec)

Rake::TestTask.new(:unit) do |test|
test.libs << 'lib' << 'test'
test.test_files = FileList["test/unit/**/*_test.rb"]
test.deps = [ :spec ]
test.verbose = false
test.warning = false
end
Expand Down
71 changes: 71 additions & 0 deletions elasticsearch-dsl/spec/aggregations/pipeline/avg_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
require 'spec_helper'

describe Elasticsearch::DSL::Search::Aggregations::AvgBucket do

let(:search) do
described_class.new
end

describe '#to_hash' do

it 'can be converted to a hash' do
expect(search.to_hash).to eq(avg_bucket: {})
end
end

context 'when options methods are called' do

let(:search) do
described_class.new(:foo)
end

describe '#buckets_path' do

before do
search.buckets_path('bar')
end

it 'applies the option' do
expect(search.to_hash[:avg_bucket][:foo][:buckets_path]).to eq('bar')
end
end

describe '#gap_policy' do

before do
search.gap_policy('skip')
end

it 'applies the option' do
expect(search.to_hash[:avg_bucket][:foo][:gap_policy]).to eq('skip')
end
end

describe '#format' do

before do
search.format('bar')
end

it 'applies the option' do
expect(search.to_hash[:avg_bucket][:foo][:format]).to eq('bar')
end
end
end

describe '#initialize' do

context 'when a block is provided' do

let(:search) do
described_class.new(:foo) do
format 'bar'
end
end

it 'executes the block' do
expect(search.to_hash).to eq({ avg_bucket: { foo: { format: 'bar' } } })
end
end
end
end
82 changes: 82 additions & 0 deletions elasticsearch-dsl/spec/aggregations/pipeline/bucket_script_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
require 'spec_helper'

describe Elasticsearch::DSL::Search::Aggregations::BucketScript do

let(:search) do
described_class.new
end

describe '#to_hash' do

it 'can be converted to a hash' do
expect(search.to_hash).to eq(bucket_script: {})
end
end

context 'when options methods are called' do

let(:search) do
described_class.new(:foo)
end

describe '#buckets_path' do

before do
search.buckets_path('bar')
end

it 'applies the option' do
expect(search.to_hash[:bucket_script][:foo][:buckets_path]).to eq('bar')
end
end

describe '#script' do

before do
search.script('bar')
end

it 'applies the option' do
expect(search.to_hash[:bucket_script][:foo][:script]).to eq('bar')
end
end

describe '#gap_policy' do

before do
search.gap_policy('skip')
end

it 'applies the option' do
expect(search.to_hash[:bucket_script][:foo][:gap_policy]).to eq('skip')
end
end

describe '#format' do

before do
search.format('bar')
end

it 'applies the option' do
expect(search.to_hash[:bucket_script][:foo][:format]).to eq('bar')
end
end
end

describe '#initialize' do

context 'when a block is provided' do

let(:search) do
described_class.new(:foo) do
format 'bar'
end
end

it 'executes the block' do
expect(search.to_hash).to eq({ bucket_script: { foo: { format: 'bar' } } })
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
require 'spec_helper'

describe Elasticsearch::DSL::Search::Aggregations::BucketSelector do

let(:search) do
described_class.new
end

describe '#to_hash' do

it 'can be converted to a hash' do
expect(search.to_hash).to eq(bucket_selector: {})
end
end

context 'when options methods are called' do

let(:search) do
described_class.new(:foo)
end

describe '#buckets_path' do

before do
search.buckets_path('bar')
end

it 'applies the option' do
expect(search.to_hash[:bucket_selector][:foo][:buckets_path]).to eq('bar')
end
end

describe '#script' do

before do
search.script('bar')
end

it 'applies the option' do
expect(search.to_hash[:bucket_selector][:foo][:script]).to eq('bar')
end
end

describe '#gap_policy' do

before do
search.gap_policy('skip')
end

it 'applies the option' do
expect(search.to_hash[:bucket_selector][:foo][:gap_policy]).to eq('skip')
end
end
end

describe '#initialize' do

context 'when a block is provided' do

let(:search) do
described_class.new(:foo) do
gap_policy 'skip'
end
end

it 'executes the block' do
expect(search.to_hash).to eq({ bucket_selector: { foo: { gap_policy: 'skip' } } })
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
require 'spec_helper'

describe Elasticsearch::DSL::Search::Aggregations::CumulativeSum do

let(:search) do
described_class.new
end

describe '#to_hash' do

it 'can be converted to a hash' do
expect(search.to_hash).to eq(cumulative_sum: {})
end
end

context 'when options methods are called' do

let(:search) do
described_class.new(:foo)
end

describe '#buckets_path' do

before do
search.buckets_path('bar')
end

it 'applies the option' do
expect(search.to_hash[:cumulative_sum][:foo][:buckets_path]).to eq('bar')
end
end

describe '#script' do

before do
search.format('bar')
end

it 'applies the option' do
expect(search.to_hash[:cumulative_sum][:foo][:format]).to eq('bar')
end
end
end

describe '#initialize' do

context 'when a block is provided' do

let(:search) do
described_class.new(:foo) do
format 'bar'
end
end

it 'executes the block' do
expect(search.to_hash).to eq({ cumulative_sum: { foo: { format: 'bar' } } })
end
end
end
end
71 changes: 71 additions & 0 deletions elasticsearch-dsl/spec/aggregations/pipeline/derivative_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
require 'spec_helper'

describe Elasticsearch::DSL::Search::Aggregations::Derivative do

let(:search) do
described_class.new
end

describe '#to_hash' do

it 'can be converted to a hash' do
expect(search.to_hash).to eq(derivative: {})
end
end

context 'when options methods are called' do

let(:search) do
described_class.new(:foo)
end

describe '#buckets_path' do

before do
search.buckets_path('bar')
end

it 'applies the option' do
expect(search.to_hash[:derivative][:foo][:buckets_path]).to eq('bar')
end
end

describe '#gap_policy' do

before do
search.gap_policy('bar')
end

it 'applies the option' do
expect(search.to_hash[:derivative][:foo][:gap_policy]).to eq('bar')
end
end

describe '#script' do

before do
search.format('bar')
end

it 'applies the option' do
expect(search.to_hash[:derivative][:foo][:format]).to eq('bar')
end
end
end

describe '#initialize' do

context 'when a block is provided' do

let(:search) do
described_class.new(:foo) do
format 'bar'
end
end

it 'executes the block' do
expect(search.to_hash).to eq({ derivative: { foo: { format: 'bar' } } })
end
end
end
end
Loading