Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Mastodonのrake specを走らせられるようにする

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

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

rbenv

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
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_8.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 protobuf-compiler libprotobuf-dev redis-server postgresql imagemagick ffmpeg libicu-dev libidn11 libidn11-dev libpq-dev libxdamage1 libxfixes3

Postgresqlのroleの用意

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

ツリーの準備

git clean -dxf
export RAILS_ENV=test
bundle install --path=vendor/bundle --without development production
yarn install

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

bundle exec rake db:drop
for i in 2 3 4; do bundle exec rake db:drop TEST_ENV_NUMBER=$i; done
bundle exec rake parallel:create parallel:load_schema parallel:prepare
bundle exec rails assets:precompile

Specを走らせる

bundle exec rake spec
  :
Finished in 2 minutes 7.8 seconds (files took 5.38 seconds to load)
1340 examples, 4 failures, 9 pending

Failed examples:

rspec ./spec/controllers/api/push_controller_spec.rb:30 # Api::PushController POST #update with hub.mode=unsubscribe unsubscribes the account
rspec ./spec/controllers/api/push_controller_spec.rb:6 # Api::PushController POST #update with hub.mode=subscribe creates a subscription
rspec ./spec/controllers/api/subscriptions_controller_spec.rb:61 # Api::SubscriptionsController POST #update returns http success
rspec ./spec/controllers/api/subscriptions_controller_spec.rb:65 # Api::SubscriptionsController POST #update creates statuses for feed

Randomized with seed 40726

やっとここまでできました!あとひといき?

Finished in 2 minutes 6.8 seconds (files took 5.19 seconds to load)
1340 examples, 0 failures, 9 pending

全部通ることもあるw

Finished in 2 minutes 10.9 seconds (files took 5.43 seconds to load)
1340 examples, 9 failures, 9 pending

Failed examples:

rspec ./spec/controllers/api/salmon_controller_spec.rb:38 # Api::SalmonController POST #update with valid post data creates mention for target account
rspec ./spec/controllers/api/salmon_controller_spec.rb:34 # Api::SalmonController POST #update with valid post data creates status
rspec ./spec/controllers/api/salmon_controller_spec.rb:30 # Api::SalmonController POST #update with valid post data creates remote account
rspec ./spec/controllers/api/salmon_controller_spec.rb:22 # Api::SalmonController POST #update with valid post data contains XML in the request body
rspec ./spec/controllers/api/salmon_controller_spec.rb:26 # Api::SalmonController POST #update with valid post data returns http success
rspec ./spec/controllers/api/push_controller_spec.rb:6 # Api::PushController POST #update with hub.mode=subscribe creates a subscription
rspec ./spec/controllers/api/push_controller_spec.rb:30 # Api::PushController POST #update with hub.mode=unsubscribe unsubscribes the account
rspec ./spec/controllers/api/subscriptions_controller_spec.rb:65 # Api::SubscriptionsController POST #update creates statuses for feed
rspec ./spec/controllers/api/subscriptions_controller_spec.rb:61 # Api::SubscriptionsController POST #update returns http success

Randomized with seed 60110

おっと。

特定のファイルだけ実行するならSPECに指定する

bundle exec rake spec SPEC=spec/controllers/api/push_controller_spec.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment