问题
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