Skip to content
This repository was archived by the owner on Apr 17, 2018. It is now read-only.
Open
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
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
language: ruby
sudo: false
services:
- mysql
before_script:
- "bundle exec rake db:create"
before_install:
- gem install bundler
script: "bundle exec rake spec"
env:
- "ADAPTER=in_memory"
# - "ADAPTER=yaml"
- "ADAPTER=sqlite"
- "ADAPTER=mysql DM_DB_USER=root DM_DB_PASSWORD=''"
rvm:
- 1.9.3
- 2.0.0
- 2.1.5
- 2.2.0
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
require 'pathname'

source :rubygems
source 'https://rubygems.org'

gemspec

SOURCE = ENV.fetch('SOURCE', :git).to_sym
REPO_POSTFIX = SOURCE == :path ? '' : '.git'
DATAMAPPER = SOURCE == :path ? Pathname(__FILE__).dirname.parent : 'http://github.com/datamapper'
DM_VERSION = '~> 1.3.0.beta'
DO_VERSION = '~> 0.10.6'
DM_VERSION = '~> 1.2'
DO_VERSION = '~> 0.10.15'
DM_DO_ADAPTERS = %w[ sqlite postgres mysql oracle sqlserver ]
CURRENT_BRANCH = ENV.fetch('GIT_BRANCH', 'master')

Expand Down
7 changes: 4 additions & 3 deletions dm-aggregates.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Gem::Specification.new do |gem|
gem.summary = "DataMapper plugin providing support for aggregates on collections"
gem.description = gem.summary
gem.homepage = "http://datamapper.org"
gem.license = 'MIT'

gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
Expand All @@ -16,8 +17,8 @@ Gem::Specification.new do |gem|
gem.require_paths = [ "lib" ]
gem.version = DataMapper::Aggregates::VERSION

gem.add_runtime_dependency('dm-core', '~> 1.3.0.beta')
gem.add_runtime_dependency('dm-core', '~> 1.2')

gem.add_development_dependency('rake', '~> 0.9.2')
gem.add_development_dependency('rspec', '~> 1.3.2')
gem.add_development_dependency('rake', '~> 10.0')
gem.add_development_dependency('rspec', '~> 3.0')
end
2 changes: 1 addition & 1 deletion lib/dm-aggregates/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module DataMapper
module Aggregates
VERSION = '1.3.0.beta'
VERSION = '1.2.0'
end
end
8 changes: 3 additions & 5 deletions spec/isolated/require_after_setup_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
require 'backports'
require 'spec'

require 'rspec'
require 'isolated/require_spec'
require 'dm-core/spec/setup'

Expand All @@ -9,14 +7,14 @@

if %w[ postgres mysql sqlite oracle sqlserver ].include?(ENV['ADAPTER'])

describe "require 'dm-aggregates after calling DataMapper.setup" do
RSpec.describe "require 'dm-aggregates after calling DataMapper.setup" do

before(:all) do
@adapter = DataMapper::Spec.adapter
require 'dm-aggregates'
end

it_should_behave_like "require 'dm-aggregates'"
include_examples "require 'dm-aggregates'"

end

Expand Down
8 changes: 3 additions & 5 deletions spec/isolated/require_before_setup_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
require 'backports'
require 'spec'

require 'rspec'
require 'isolated/require_spec'
require 'dm-core/spec/setup'

Expand All @@ -9,14 +7,14 @@

if %w[ postgres mysql sqlite oracle sqlserver ].include?(ENV['ADAPTER'])

describe "require 'dm-aggregates' before calling DataMapper.setup" do
RSpec.describe "require 'dm-aggregates' before calling DataMapper.setup" do

before(:all) do
require 'dm-aggregates'
@adapter = DataMapper::Spec.adapter
end

it_should_behave_like "require 'dm-aggregates'"
include_examples "require 'dm-aggregates'"

end

Expand Down
6 changes: 3 additions & 3 deletions spec/isolated/require_spec.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
shared_examples_for "require 'dm-aggregates'" do
RSpec.shared_examples_for "require 'dm-aggregates'" do

%w[ Repository Model Collection Query ].each do |name|
it "should include the aggregate api in DataMapper::#{name}" do
(DataMapper.const_get(name) < DataMapper::Aggregates.const_get(name)).should be(true)
expect(DataMapper.const_get(name) < DataMapper::Aggregates.const_get(name)).to be(true)
end
end

it "should include the aggregate api into the adapter" do
@adapter.respond_to?(:aggregate).should be(true)
expect(@adapter.respond_to?(:aggregate)).to be(true)
end

end
42 changes: 23 additions & 19 deletions spec/public/collection_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
require 'spec_helper'

describe DataMapper::Collection do
RSpec.describe DataMapper::Collection do
supported_by :sqlite, :mysql, :postgres do
let(:dragons) { Dragon.all }
let(:countries) { Country.all }

it_should_behave_like 'It Has Setup Resources'
it_should_behave_like 'An Aggregatable Class'
include_examples 'It Has Setup Resources'
include_examples 'An Aggregatable Class'

describe 'ignore invalid query' do
let(:dragons) { Dragon.all.all(:id => []) }
Expand All @@ -15,38 +15,38 @@
describe "##{method}" do
subject { dragons.send(method) }

it { should == 0 }
it { is_expected.to eq(0) }
end
end

describe '#min' do
subject { dragons.min(:id) }

it { should be_nil }
it { is_expected.to be_nil }
end

describe '#max' do
subject { dragons.max(:id) }

it { should be_nil }
it { is_expected.to be_nil }
end

describe '#avg' do
subject { dragons.avg(:id) }

it { should be_nil }
it { is_expected.to be_nil }
end

describe '#sum' do
subject { dragons.sum(:id) }

it { should be_nil }
it { is_expected.to be_nil }
end

describe '#aggregate' do
subject { dragons.aggregate(:id) }

it { should == [] }
it { is_expected.to eq([]) }
end
end

Expand All @@ -56,43 +56,43 @@
describe '#size' do
subject { collection.size }

it { should == 2 }
it { is_expected.to eq(2) }
end

describe '#count' do
subject { collection.count }

it { should == 2 }
it { is_expected.to eq(2) }
end

describe '#min' do
subject { collection.min(:toes_on_claw) }

it { should == 3 }
it { is_expected.to eq(3) }
end

describe '#max' do
subject { collection.max(:toes_on_claw) }

it { should == 4 }
it { is_expected.to eq(4) }
end

describe '#avg' do
subject { collection.avg(:toes_on_claw) }

it { should == 3.5 }
it { is_expected.to eq(3.5) }
end

describe '#sum' do
subject { collection.sum(:toes_on_claw) }

it { should == 7 }
it { is_expected.to eq(7) }
end

describe '#aggregate' do
subject { collection.aggregate(:all.count, :name.count, :toes_on_claw.min, :toes_on_claw.max, :toes_on_claw.avg, :toes_on_claw.sum)}

it { should == [ 2, 2, 3, 4, 3.5, 7 ] }
it { is_expected.to eq([ 2, 2, 3, 4, 3.5, 7 ]) }
end
end

Expand All @@ -102,13 +102,17 @@
describe '#size' do
subject { dragons.size }

it { should == 1 }
it { is_expected.to eq(1) }
end

describe '#count' do
subject { dragons.count }

it { pending('TODO: make count apply to the limited collection. Currently limit applies after the count') { should == 1 } }
it do
pending('TODO: make count apply to the limited collection. Currently limit applies after the count')
is_expected.to eq(1)
end

end
end

Expand All @@ -118,7 +122,7 @@
let(:dragons) { Dragon.all(:order => [ :birth_at.desc ]) }

it 'displays the results in reverse order' do
should == Dragon.aggregate(:birth_at, :all.count).reverse
is_expected.to eq(Dragon.aggregate(:birth_at, :all.count).reverse)
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/public/model_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require 'spec_helper'

describe DataMapper::Model do
RSpec.describe DataMapper::Model do
supported_by :sqlite, :mysql, :postgres do
let(:dragons) { Dragon }
let(:countries) { Country }

it_should_behave_like 'It Has Setup Resources'
it_should_behave_like 'An Aggregatable Class'
include_examples 'It Has Setup Resources'
include_examples 'An Aggregatable Class'
end
end
Loading