Thanks Phil. So the trick is to use db:schema:load instead of db:migrate. I'd still like to know why migrating fails but at least this has given me a way forward.
On Tue, 16 Feb 2021 at 16:25, Phil Pirozhkov <pirjs...@gmail.com> wrote: > I see the following in the `spec/dummy/config/database.yml`: > > ``` > # Warning: The database defined as "test" will be erased and > # re-generated from your development database when you run "rake". > # Do not set this db to the same as development or production. > ``` > > So, I've generated a migration > `db/migrate/20210216160820_add_sample_engine_grommets.rb` and added a > model `app/models/sample_engine/grommet.rb` > > After that, I've run migrations for development env: > ``` > == 20210215210420 CreateSampleEngineWidgets: migrating > ======================== > -- create_table(:sample_engine_widgets) > -> 0.0055s > == 20210215210420 CreateSampleEngineWidgets: migrated (0.0057s) > =============== > > == 20210216160820 AddSampleEngineGrommets: migrating > ========================== > -- create_table(:sample_engine_grommets) > -> 0.0039s > == 20210216160820 AddSampleEngineGrommets: migrated (0.0040s) > ================= > ``` > > DBs reside in > spec/dummy/db/development.sqlite3 > spec/dummy/db/test.sqlite3 > > I was surely getting the same message as you: > ``` > Migrations are pending. To resolve this issue, run: > bin/rails db:migrate RAILS_ENV=test > > You have 1 pending migration: > 20210215210420_create_sample_engine_widgets.rb > ``` > > ``` > bundle exec rails db:schema:load RAILS_ENV=test > ``` > > After that, `rspec` runs just fine: > > ``` > $ rspec > Warning: the running version of Bundler (2.1.4) is older than the > version that created the lockfile (2.2.3). We suggest you to upgrade > to the version that created the lockfile by running `gem install > bundler:2.2.3`. > * > > Pending: (Failures listed here are expected and do not affect your > suite's status) > > 1) SampleEngine::Widget add some examples to (or delete) > > /Users/pirj/source/tmp/sample_engine/spec/models/sample_engine/widget_spec.rb > # Not yet implemented > # ./spec/models/sample_engine/widget_spec.rb:5 > > > Finished in 0.00592 seconds (files took 2.1 seconds to load) > 1 example, 0 failures, 1 pending > ``` > > To double-check, I've added `spec/models/sample_engine/grommet_spec.rb`: > > ``` > require 'rails_helper' > > module SampleEngine > RSpec.describe Grommet, type: :model do > it do > Grommet.create(name: 'hello') > expect(Grommet.count).to eq(1) > end > end > end > ``` > > and it passes just fine. > Well, only for the first time, because `use_transactional_fixtures` is off. > > Hope all that helps. > > - Phil > > -- > You received this message because you are subscribed to the Google Groups > "rspec" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rspec+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/rspec/CAAk5Ok86BdhbYEf9bVuPu5%2BEEoiQks46fuzDeg88wQp3eAY%2BAw%40mail.gmail.com > . > -- You received this message because you are subscribed to the Google Groups "rspec" group. To unsubscribe from this group and stop receiving emails from it, send an email to rspec+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/CAKRXwc3_n5HQq28yXC%2BvY4hDObNnc5LhrnTuc4rR6uaXFKDWBA%40mail.gmail.com.