<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rukesh Basukala</title>
    <description>The latest articles on DEV Community by Rukesh Basukala (@rukeshb).</description>
    <link>https://dev.to/rukeshb</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F922980%2F7da099a9-3ddb-46cf-9c1c-584f5015a1a6.jpeg</url>
      <title>DEV Community: Rukesh Basukala</title>
      <link>https://dev.to/rukeshb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rukeshb"/>
    <language>en</language>
    <item>
      <title>How do I display images from Google Drive on a website?</title>
      <dc:creator>Rukesh Basukala</dc:creator>
      <pubDate>Wed, 18 Dec 2024 17:59:11 +0000</pubDate>
      <link>https://dev.to/rukeshb/how-do-i-display-images-from-google-drive-on-a-website-3km6</link>
      <guid>https://dev.to/rukeshb/how-do-i-display-images-from-google-drive-on-a-website-3km6</guid>
      <description>&lt;p&gt;&lt;strong&gt;Step 1: Open Google Drive&lt;/strong&gt;&lt;br&gt;
Visit Google Drive Official Website and share a file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Share File&lt;/strong&gt;&lt;br&gt;
Open Google Drive and upload the image you want to use on your website. Then, click on the image with your right mouse button and select "Share" to grab the link and change permission.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8sy80imy06drmufxdvy0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8sy80imy06drmufxdvy0.png" alt="Share File" width="800" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Change Permission&lt;/strong&gt;&lt;br&gt;
In the sharing window, click on the permissions menu and pick "Anyone with the link." This lets anyone with the link see the file, even if they don't have a Google account. Then, hit "Copy link" to copy the link to your file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh8pkgbp9ntkt4okkejfp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh8pkgbp9ntkt4okkejfp.png" alt="Change Permission of File" width="568" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Create Thumbnail Image Link&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Step 3 will give link like this: &lt;code&gt;https://drive.google.com/file/d/10hhX4pIZr0NhuusN4eHvf4ghah5d6yAG/view?usp=sharing&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Extract the ID of the image from the link, which is between /d/ and /view. In this case, the ID is &lt;code&gt;10hhX4pIZr0NhuusN4eHvf4ghah5d6yAG&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use the extracted ID to create a thumbnail link by inserting it into the following URL template: &lt;code&gt;https://drive.google.com/thumbnail?id={ID of Image}&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The final thumbnail link will look like this: &lt;code&gt;https://drive.google.com/thumbnail?id=10hhX4pIZr0NhuusN4eHvf4ghah5d6yAG&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Use it on Your Website&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;img src="https://drive.google.com/thumbnail?id=10hhX4pIZr0NhuusN4eHvf4ghah5d6yAG" alt="Image From Drive"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;reference &lt;br&gt;
&lt;a href="https://codepen.io/raulpenate/pen/wvOozzw" rel="noopener noreferrer"&gt;https://codepen.io/raulpenate/pen/wvOozzw&lt;/a&gt;&lt;/p&gt;

</description>
      <category>frontend</category>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Testing: Mock And Stub</title>
      <dc:creator>Rukesh Basukala</dc:creator>
      <pubDate>Tue, 18 Apr 2023 14:24:42 +0000</pubDate>
      <link>https://dev.to/rukeshb/testing-mock-and-stub-eje</link>
      <guid>https://dev.to/rukeshb/testing-mock-and-stub-eje</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Testing is a method to check whether the actual software product matches the expected requirements.Testing is Important because if there are any bugs or errors in the software, they can be identified early and can be solved before the delivery of the software product.&lt;br&gt;
Testing is a crucial part of software development, but it can be challenging to test code that depends on external dependencies and if you're interacting with 3rd party APIs, you don't want to make real calls every time you run a test. That's where mocks and stubs come in. In this guide, we'll take a deep dive into the world of mocks and stubs, and explore how they can help you isolate your tests and improve the reliability of your code.&lt;/p&gt;
&lt;h2&gt;
  
  
  What are mocks and stubs?
&lt;/h2&gt;

&lt;p&gt;Before diving into how to use mocks and stubs, it's important to understand what they are. In short, mocks and stubs are simulated objects that mimic the behavior of real objects in controlled ways. Mocks are typically more flexible and configurable, while stubs are simpler and more focused on replacing a single dependency.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmwx8yn1cezskzxgmvab4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmwx8yn1cezskzxgmvab4.png" alt="mock diagram" width="800" height="565"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmwrczm15ovh5mwbz4iuj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmwrczm15ovh5mwbz4iuj.png" alt="stub diagram" width="800" height="565"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Mock Vs Stub
&lt;/h2&gt;

&lt;p&gt;The main difference between a mock and a stub is that mocks tend to be more flexible and configurable, while stubs are simpler and more focused on replacing a single dependency. Both mocks and stubs are used to isolate the code being tested from external dependencies.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why use mocks and stubs?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Mocks and stubs are used to isolate the code being tested from external dependencies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;mocks and stubs can help you to speed up your tests by eliminating the need to wait for external dependencies to respond.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  How to use RSpec-mocks
&lt;/h2&gt;

&lt;p&gt;RSpec is a popular testing framework for Ruby on Rails. We can use &lt;a href="https://github.com/bblimke/webmock" rel="noopener noreferrer"&gt;webmock&lt;/a&gt; gem to mock and stub in Ruby on Rails.&lt;br&gt;
The following steps show how you might use WebMock to mock an HTTP request in a Rails application:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;add the webmock gem to your Gemfile and bundle install:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;group :test do
  gem "webmock"
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;code&gt;bundle install&lt;/code&gt;&lt;br&gt;
or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gem install webmock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;In your test file, require the webmock gem and disable real HTTP connections:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;require 'webmock/rspec'
WebMock.disable_net_connect!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Set up the stubbed response:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;get request
&lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;stub_request(:get, "https://example.com/users").
to_return(status: 200, body: '{"users": [{"id": 1, "name": "foo", email: "example@test.com"}]}')
&lt;/code&gt;&lt;/pre&gt;



&lt;ul&gt;
&lt;li&gt;post request
&lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt; stub_request(:post, "https://example.com/users/signup")
    .with(body: {email: "example@test.com", password: "password1234", name: "foo"}.to_json)
    .to_return(status: 200, body: {"user": {"id": 1, "name": "foo", email: "example@test.com"}})

&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Trigger the code that makes the request to the external API. The stubbed response will be returned instead of a real response.&lt;br&gt;&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe MyController do
  it "does something" do
    get :index
    expect(response.body).to eq '{"users": [{"id": 1, "name": "foo", email: 'example@test.com'}]}'
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion:
&lt;/h2&gt;

&lt;p&gt;Mocks and stubs are powerful tools for isolating your tests and improving the reliability of your code. With this guide, you should now have a solid understanding of what mocks and stubs are, why to use them and how to mock using webmock.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>opensource</category>
      <category>aws</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
