When i ran my spec it shows
localjumperror no block given (yield)
My service file
service/update_many_post.rb
class UpdateManyPost
def call
posts.each do |post|
response = UpdateAPost.new(post: post).call
yield response
end
end
private
def posts
Post.all
end
end
/service/update_a_post.rb
class UpdateAPost
def initialize(post:)
@post = post
end
def call
@post.title = "I am great"
@post.save
end
end
This is how I call the service.
UpdateManyPost.new.call do |response|
puts(response)
end
My rspec file
describe 'call' do
let(:posts) { build(:post, 3) }
subject { UpdateManyPost.new }
it "has to update all the post" do
expect { subject.call }
end
end
When I ran the spec it always shows that yield error, I need the yield for it to work, but I'm not sure how to fix the spec specifically