summaryrefslogtreecommitdiff
blob: 32e97221ed825b1b2efd93f899526c6ae4985eef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=5
USE_RUBY="ruby20 ruby21"

RUBY_FAKEGEM_RECIPE_DOC="rdoc"
# functional testing crashes Ruby from within Portage, but works
# outside of it, needs to be investigated thoroughly, but at least
# unit testing works.
RUBY_FAKEGEM_RECIPE_TEST="rspec"

RUBY_FAKEGEM_EXTRADOC="README.md CHANGELOG.md"

RUBY_FAKEGEM_GEMSPEC="${PN}.gemspec"

GITHUB_USER="${PN}"
GITHUB_PROJECT="${PN}"

inherit ruby-fakegem

DESCRIPTION="ODM (Object Document Mapper) Framework for MongoDB"
HOMEPAGE="http://two.mongoid.org/"
SRC_URI="https://github.com/${GITHUB_USER}/${GITHUB_PROJECT}/archive/v${PV}.tar.gz -> ${GITHUB_PROJECT}-${PV}.tar.gz"
LICENSE="MIT"

SLOT="0"
KEYWORDS="~amd64"
IUSE="test"

ruby_add_rdepend "
	>=dev-ruby/activemodel-3.1 =dev-ruby/activemodel-3*
	>=dev-ruby/mongo-1.9:0
	>=dev-ruby/tzinfo-0.3.22:0
"

ruby_add_bdepend "
	test? (
		dev-ruby/bundler
		dev-ruby/ammeter
		dev-ruby/mocha:0.11
		dev-ruby/rdoc
		dev-ruby/rspec
		dev-util/watchr
	)"

DEPEND+=" test? ( dev-db/mongodb )"

all_ruby_prepare() {
	# Remove unsupported development dependencies and fix versions.
	sed -i -e '/\(guard-rspec\|rb-fsevent\)/ s:^:#:' \
		-e '/mocha/ s/= 0.11/~> 0.11.0/' mongoid.gemspec || die

	# Avoid specs tied to localhost
	rm spec/functional/mongoid/config/{database,replset_database}_spec.rb || die

	# Avoid some failing specs that should be investigated later
	sed -i -e '/sets the capped size/,/end/ s:^:#:' spec/functional/mongoid/collection_spec.rb || die
	sed -i -e '/.from_hash/,/^  end/ s:^:#:' spec/functional/mongoid/config_spec.rb || die
	rm spec/functional/mongoid/persistence_spec.rb || die
}

each_ruby_test() {
	mkdir "${T}/mongodb_$(basename $RUBY)"
	mongod --port 27017 --dbpath "${T}/mongodb_$(basename $RUBY)" \
		--noprealloc --noauth --nohttpinterface --nounixsocket --nojournal \
		--bind_ip 127.255.255.254 &
	mongod_pid=$!
	failed=0

	sleep 2

	export MONGOID_SPEC_HOST="127.255.255.254"
	export MONGOID_SPEC_PORT="27017"

	${RUBY} -S bundle exec rspec-2 --format progress spec || failed=1
	kill "${mongod_pid}"

	[[ "${failed}" == "1" ]] && die "tests failed"
}