我有一个方法,比较两个文本文件是否具有相同的内容.
如何使用rspec比较两个文本文件是否具有相同的内容?
我正在尝试测试一些与RSpec的关联,但我得到了这些失败:
Category
Failure/Error: it {should belong_to :post}
Expected Category to have a belongs_to association called post (Category does not have a post_id foreign key.)
# ./spec/models/category_spec.rb:7:in `block (2 levels) in <top (required)>'
Post
Failure/Error: it {should have_one (:category)}
Expected Post to have a has_one association called category (Category does not have a post_id foreign key.)
# ./spec/models/post_spec.rb:8:in `block (2 levels) in <top (required)>'
Run Code Online (Sandbox Code Playgroud)
这是我的模特:
class Post < ActiveRecord::Base
has_one :category
validates_presence_of :author, :category, :post
end
class Category < ActiveRecord::Base
belongs_to …Run Code Online (Sandbox Code Playgroud)