Skip to content

Instantly share code, notes, and snippets.

@zunda
Last active May 4, 2023 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zunda/aa6870d0f9f68e705d54d1fa882b0cc0 to your computer and use it in GitHub Desktop.
Save zunda/aa6870d0f9f68e705d54d1fa882b0cc0 to your computer and use it in GitHub Desktop.
Mastodonのrspecを走らせられるようにする

Mastodonのrspecを走らせられるようにする

Dockerの外でやらないといけない感じなのかな?

rbenv

git clone https://github.com/rbenv/rbenv.git ~/.rbenvpro
cd ~/.rbenv && src/configure && make -C src
cat << _END > ~/.bashrc
PATH=$HOME/.rbenv/bin:$PATH
eval "$(rbenv init -)"
_END
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv install 2.4.2
gem install bundler

環境整備

.travis.ymlを見ながらやってみよう

Node.js

https://github.com/nodesource/distributions#installation-instructions

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs

Yarn

https://yarnpkg.com/en/docs/install#linux-tab

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get install -y yarn

Mastodonに必要なdebパッケージ

sudo apt update
sudo apt install redis-server postgresql imagemagick ffmpeg libicu-dev libidn11 libidn11-dev libpq-dev libxdamage1 libxfixes3 libpam0g-dev

Ubuntu-22.04の場合には、libidn11libidn11-devの代わりに、libidn12libidn-devをインストールします。

Postgresqlのroleの用意

sudo -u postgres psql
> create role zunda with createdb login;

ツリーの準備

git clean -dxf
export RAILS_ENV=test
export NODE_OPTIONS=--openssl-legacy-provider
bundle install --path=vendor/bundle --with pam_authentication --without development production
yarn install --pure-lockfile

時々データベースのドロップが必要なのかも…

bundle exec rake db:drop
for i in 2 3 4; do bundle exec rake db:drop TEST_ENV_NUMBER=$i; done

データベースとアセットの用意

bundle exec rails db:setup
bundle exec rails assets:precompile

Specを走らせる

bundle exec rspec

bundle exec rake specはruby-2.6.0だといろいろ落ちる

参考文献

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment