我的 RSpec 测试不断弹出这些“MyString”属性。人们说这与固定装置有关,但我不使用它们。我删除了test
目录,但问题仍然存在。我正在为工厂/制造商使用制造。我也在使用 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
这是我的后期工厂/制造商:
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)>'
我该如何解决这个问题?