I am going through the rails tutorial and am at section 6.11
For some reason, I am getting 4 examples and 4 failures in rspec vs 4 examples and 1 failure (and consequently 0) as in the tutorial.
I am seeing this in my rspec:
Failure/Error: @user = User.new(name: "Example User", email: "[email protected]")
ActiveRecord::StatementInvalid:
PGError: ERROR: relation "users" does not exist
The thing is, the tutorial is going along in sqlite, but I migrated to postgres (as suggested in the tutorial earlier) so I could learn about postgres as well. Is this what is causing the problems? Shouldn't activerecord be making it transparent as to what kind of database I am using anyways?
I have created the proper databases, updated my database.yml, run a db:mgirate and the command
User.new(name: "Example User", email: "[email protected]")
works fine in a sandboxed console.
Any help greatly appreciated. I am trying to stay on top of rspec here, to me it is the most challenging part about learning Rails. It almost feels like one spends 90% of one's energy writing and debugging tests instead. (The only stumbling blocks/mind bending headca I've encountered so far have been rspec tests)
The user_rspec.rb:
require 'spec_helper'
describe User do
before do
@user = User.new(name: "Example User", email: "[email protected]")
end
subject { @user }
it { should respond_to(:name) }
it { should respond_to(:email) }
it { should be_valid }
describe "when name is not present" do
before { @user.name = " " }
it { should_not be_valid }
end
end
--
As a secondary question, I find that my rspec tests are running multiple times? I installed the ruby-gntp gem and am finding growl popping up multiple times each time a test is run, with the same information.
