Rails と RSpec は初めてなので、このテストを機能させる方法についていくつかの指針が欲しいです。
メールを新しいものから古いものへと並べ替えたいのですが、これをテストするのに苦労しています。
私はRailsを初めて使用し、これまでのところ、実際の機能よりもテストを機能させるのに苦労しています。
更新しました
require 'spec_helper'
describe Email do
before do
@email = Email.new(email_address: "user@example.com")
end
subject { @email }
it { should respond_to(:email_address) }
it { should respond_to(:newsletter) }
it { should be_valid }
describe "order" do
@email_newest = Email.new(email_address: "newest@example.com")
it "should have the right emails in the right order" do
Email.all.should == [@email_newest, @email]
end
end
end
これが私が得るエラーです:
1) Email order should have the right emails in the right order
Failure/Error: Email.all.should == [@email_newest, @email]
expected: [nil, #<Email id: nil, email_address: "user@example.com", newsletter: nil, created_at: nil, updated_at: nil>]
got: [] (using ==)
Diff:
@@ -1,3 +1,2 @@
-[nil,
- #<Email id: nil, email_address: "user@example.com", newsletter: nil, created_at: nil, updated_at: nil>]
+[]
# ./spec/models/email_spec.rb:32:in `block (3 levels) in <top (required)>'