how to check array changes in rspec after a service call?

风格不统一 提交于 2020-07-09 05:22:18

问题


The goal is simple

example we have an array

[
  {name: "ghost", state: "rejected"}, 
  {name: "donkey", state: "rejected"}
]

After running the Service call UpdateAllUsers, it would change all the users to 'accepted'

   [
      {name: "ghost", state: "accepted"}, 
      {name: "donkey", state: "accepted"}
    ]

The question here is how do i check all the object in the array to have the same value after that service call in rspec?

example in rspec

describe 'call' do
   let(:all_users) { build(:users, 2, state: "rejected")

    service_call { UpdateAllUsers.new.call }


    it "change all user state to approved" do
         # The goal is to check all the users state after the Service call.
         # Can't find a way to do so
         # the after state should be state => 'accepted'
     end
end

来源:https://stackoverflow.com/questions/62457656/how-to-check-array-changes-in-rspec-after-a-service-call

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!