我的RSpec测试不断弹出这些“MyString”属性。人们说这与固定装置有关,但我不使用它们。我删除了test
目录,但问题仍然存在。我正在使用Fabrication for Factories / Fabricators。我也在使用Devise的测试助手。
这是我的控制器规范有问题:
it "allows you to see your posts" do
sign_in Fabricate(:user)
Fabricate(:post)
get 'by_me'
@posts.first.song.should eq "The Sound of Settling"
end
这是我的Post Factory / Fabricator:
Fabricator(:post) do
song "The Sound of Settling"
artist "Death Cab for Cutie"
album "Transatlantism"
username "foo"
end
我的用户工厂/制造商:
Fabricator(:user) do
username "foo"
password "password"
password_confirmation "password"
end
这是失败的消息:
1) PostsController allows you to see your posts
Failure/Error: Post.first.song.should eq "The Sound of Settling"
expected: "The Sound of Settling"
got: "MyString"
(compared using ==)
# ./spec/controllers/posts_controller_spec.rb:31:in `block (2 levels) in <top (required)>'
我该如何解决这个问题?
答案 0 :(得分:0)
我不知道发生了什么,但问题已经消失了。