author avatar

satya

Mon Jan 22 2024

we can raise error using to_raise method inside our webmock in the spec file. for example:

stub_request(:post, "https://slack.com/api/users.info") .with( body: { "user" => "some_random_id" }, headers: { 'Accept' => 'application/json; charset=utf-8', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/x-www-form-urlencoded', 'User-Agent' => 'Slack Ruby Client/2.2.0' } ) .to_raise(Slack::Web::Api::Errors::UserNotFound.new('user_not_found'))