# RSpec tests won't pass on discourse\_dev docker image

**URL:** https://meta.discourse.org/t/rspec-tests-wont-pass-on-discourse-dev-docker-image/59515
**Category:** Development
**Created:** [March 20, 2017, 3:42am UTC](https://meta.discourse.org/t/rspec-tests-wont-pass-on-discourse-dev-docker-image/59515 "2017-03-20T03:42:01Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [March 20, 2017, 3:42am UTC](https://meta.discourse.org/t/rspec-tests-wont-pass-on-discourse-dev-docker-image/59515/1 "2017-03-20T03:42:01Z")

</div>

I’ve been experimenting with different dev environments, and am trying to get the [development docker image](https://github.com/discourse/discourse/tree/master/bin/docker) working. While everything seems to work fairly well, I can’t get the rspec tests to pass. Repro steps:

```plaintext
git clone -b tests-passed https://github.com/discourse/discourse discourse
cd discourse
./bin/docker/boot_dev --init
./bin/docker/bundle exec rspec

```

3 tests fail every time:

```plaintext
Failures:
  1) i18n integrity checks has an i18n key for each Site Setting
     Failure/Error: value = send(s)
     
     NoMethodError:
       undefined method `last_vacuum' for #<Class:0x00562777625f30>
     # ./lib/site_setting_extension.rb:180:in `block in all_settings'
     # ./lib/site_setting_extension.rb:179:in `each'
     # ./lib/site_setting_extension.rb:179:in `map'
     # ./lib/site_setting_extension.rb:179:in `all_settings'
     # ./spec/integrity/i18n_spec.rb:49:in `block (2 levels) in <top (required)>'
  2) Admin::SiteSettingsController while logged in as an admin index returns JSON
     Failure/Error: value = send(s)
     
     NoMethodError:
       undefined method `last_vacuum' for #<Class:0x00562777625f30>
     # ./lib/site_setting_extension.rb:180:in `block in all_settings'
     # ./lib/site_setting_extension.rb:179:in `each'
     # ./lib/site_setting_extension.rb:179:in `map'
     # ./lib/site_setting_extension.rb:179:in `all_settings'
     # ./app/controllers/admin/site_settings_controller.rb:4:in `index'
     # ./spec/controllers/admin/site_settings_controller_spec.rb:21:in `block (4 levels) in <top (required)>'
  3) Admin::SiteSettingsController while logged in as an admin index returns success
     Failure/Error: value = send(s)
     
     NoMethodError:
       undefined method `last_vacuum' for #<Class:0x00562777625f30>
     # ./lib/site_setting_extension.rb:180:in `block in all_settings'
     # ./lib/site_setting_extension.rb:179:in `each'
     # ./lib/site_setting_extension.rb:179:in `map'
     # ./lib/site_setting_extension.rb:179:in `all_settings'
     # ./app/controllers/admin/site_settings_controller.rb:4:in `index'
     # ./spec/controllers/admin/site_settings_controller_spec.rb:16:in `block (4 levels) in <top (required)>'

```

I’ve replicated this exact process on macOS and on Ubuntu.

Installing all the dependencies and running natively works on both macOS and Ubuntu, but I’d far rather use Docker if possible.

Am I missing a step somewhere, or is there something wrong with the docker scripts?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [March 20, 2017, 10:57am UTC](https://meta.discourse.org/t/rspec-tests-wont-pass-on-discourse-dev-docker-image/59515/2 "2017-03-20T10:57:00Z")

</div>

This is weird because there is no mention of “`last_vacuum`” in the entire source tree of Discourse…

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [March 20, 2017, 11:28am UTC](https://meta.discourse.org/t/rspec-tests-wont-pass-on-discourse-dev-docker-image/59515/3 "2017-03-20T11:28:07Z")

</div>

Indeed, I did come across this (cannot remember how I managed to find this)

> <https://github.com/discourse/discourse/blob/5dbd6a304bed5400be481d71061d3e3ebb4d6785/lib/tasks/db.rake#L13>

But that’s not in the current codebase of master or tests-passed. I wonder if it’s been left behind in some kind of database template in the docker image??? Or something like that

Edit: looks like it was removed in this commit by @tgxworld  
[https://github.com/discourse/discourse/commit/9baf89a901647676933747a6760463c5ead0827f](https://github.com/discourse/discourse/commit/9baf89a901647676933747a6760463c5ead0827f)

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [March 20, 2017, 12:17pm UTC](https://meta.discourse.org/t/rspec-tests-wont-pass-on-discourse-dev-docker-image/59515/4 "2017-03-20T12:17:40Z")

</div>

Ok, I got it working by doing

```plaintext
git clone -b tests-passed https://github.com/discourse/discourse discourse
cd discourse
./bin/docker/boot_dev
./bin/docker/bundle install --retry=3 --jobs=3
./bin/docker/psql "-c 'ALTER USER discourse WITH SUPERUSER;'"
RAILS_ENV=test ./bin/docker/rake db:drop db:create db:migrate
./bin/docker/bundle exec rspec

```

Had to change the database permissions for the user ‘discourse’ because otherwise `db:drop` wouldn’t work.

So from that, I guess there is some kind of stale database setup in the docker image. Would it be possible to get that updated? Or maybe assign enough privileges to the postgres ‘discourse’ user to allow for dropping/creating tables in the discourse\_dev image?

---

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [April 26, 2017, 4:23pm UTC](https://meta.discourse.org/t/rspec-tests-wont-pass-on-discourse-dev-docker-image/59515/5 "2017-04-26T16:23:19Z")

</div>

This is still an issue, but this got it working, cheers!

Just a note to anybody else affected out there, this didn’t work on my first attempt and I _think_ it’s because I don’t allow non-root to run docker, so the `RAILS_ENV=test` wasn’t getting passed through sudo.

So if you’re like me, use this to drop, create and migrate the db instead:

```plaintext
sudo d/shell
cd /src
RAILS_ENV=test rake db:drop db:create db:migrate

```
