<?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: Joe Sembler</title>
    <description>The latest articles on DEV Community by Joe Sembler (@joesembler).</description>
    <link>https://dev.to/joesembler</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F786295%2F2b57792f-8834-425f-a958-c0e99b905ce0.jpg</url>
      <title>DEV Community: Joe Sembler</title>
      <link>https://dev.to/joesembler</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/joesembler"/>
    <language>en</language>
    <item>
      <title>Authentication Spec (Fundamentals of TDD)</title>
      <dc:creator>Joe Sembler</dc:creator>
      <pubDate>Thu, 17 Feb 2022 20:16:07 +0000</pubDate>
      <link>https://dev.to/joesembler/authentication-spec-fundamentals-of-tdd-al1</link>
      <guid>https://dev.to/joesembler/authentication-spec-fundamentals-of-tdd-al1</guid>
      <description>&lt;h2&gt;
  
  
  Test Driven Development
&lt;/h2&gt;

&lt;p&gt;Test Driven Development, or TDD, is a process of development where the developer first creates test cases for the software, meaning what the developer wants the software to do, and then developing this software by repeatedly testing the software against the predetermined test cases. In most cases, developers do not use TDD; most developers create the software first and then test their software. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inspiration&lt;/strong&gt;&lt;br&gt;
TDD can be a very beneficial way of developing because the developer must first write very explicitly what he or she wants the computer to do and then simply follow the error messages to develop the software. In a way, it is like the developer first tells the computer what he or she wants it to do, then the computer tells the developer exactly the steps to developing that software. It can definitely be a nice guide if you do not know &lt;em&gt;exactly&lt;/em&gt; the steps you must complete  in order to develop something. &lt;/p&gt;
&lt;h2&gt;
  
  
  Authentication Spec
&lt;/h2&gt;

&lt;p&gt;For my Phase 4 project at Flatiron I have to build a webpage with a React frontend and a Rails backend; the page must feature user authentication using cookies and sessions. Below I created an authentication spec in order to develop the basic login of the webpage. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Capybara&lt;/strong&gt;&lt;br&gt;
First I installed the &lt;a href="https://github.com/teamcapybara/capybara"&gt;capybara&lt;/a&gt; gem and added it to my Gemfile. Next you want to add &lt;code&gt;require 'capybara/rails'&lt;/code&gt; below &lt;code&gt;require 'rspec/rails'&lt;/code&gt; in your &lt;code&gt;rails_helper.sb&lt;/code&gt; file. Next, you have to add &lt;code&gt;capybara/rspec&lt;/code&gt; in your &lt;code&gt;spec_helper.sb&lt;/code&gt; file. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;authentication_spec.rb&lt;/strong&gt;&lt;br&gt;
The next step is to create a file in &lt;code&gt;your-app/spec/features&lt;/code&gt; called &lt;code&gt;authentication_spec.rb&lt;/code&gt;. Let's take a look inside this file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;require 'rails_helper'

describe "the signin process", type: :feature do
   let!(:user) do
      User.create(username: 'username', password: 'password')
    end

    it "signs me in" do
      visit '/'
      within("#log_in_form") do
        fill_in 'username', with: user.username
        fill_in 'Password', with: user.password
      end
      click_button 'Sign in'
      expect(page).to have_content 'Welcome'
    end
  end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Woah! This is a lot to take in so let's break it down:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;describe "the signin process", type: :feature do&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In the line of code above we are describing what we want to test. In this case we are trying to make authentication work, so we are going to test the sign-in process of our application. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;let!(:user) do&lt;br&gt;
      User.create(username: 'username', password: 'password')&lt;br&gt;
    end&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here we use the bang operator (!) on let in order to create a  user instance. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;it "signs me in" do&lt;br&gt;
      visit '/'&lt;br&gt;
      within("#log_in_form") do&lt;br&gt;
        fill_in 'username', with: user.username&lt;br&gt;
        fill_in 'Password', with: user.password&lt;br&gt;
      end&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In the code block above we are telling the computer explicitly what we want the test to do. The test is going to visit our root directory and within that root directory it is going to look for an HTML element with an ID of &lt;code&gt;'log_in_form'&lt;/code&gt;. Within this form it is going to fill in the part of the form called 'username' with our username of our user instance we created above, along with the password. Finally it is going to:&lt;br&gt;
&lt;code&gt;click_button 'Sign In'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The last part of our code is very important: it is what the computer should expect to see in order to know that the test has passed! In our case we should see some kind of greeting when we are logged in. We can express this to the computer by saying: &lt;br&gt;
&lt;code&gt;expect(page).to have_content 'Welcome'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Putting it all together&lt;/strong&gt;&lt;br&gt;
Ok so now we have our test in place - let's run it! Go to the console and type &lt;code&gt;bundle exec run your-app/spec/features/authentication_spec.rb&lt;/code&gt;. Your test should be failing! Not only should it be failing but you should also get an error message saying what specifically failed. Now you want to repeatedly run this test, debugging each and every error message until the test passes. Then you will know that your software is doing exactly as you want it to and you never even had to leave VSCode!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The Fundamentals of Database Structure</title>
      <dc:creator>Joe Sembler</dc:creator>
      <pubDate>Tue, 25 Jan 2022 06:09:28 +0000</pubDate>
      <link>https://dev.to/joesembler/the-fundamentals-of-database-structure-3bfk</link>
      <guid>https://dev.to/joesembler/the-fundamentals-of-database-structure-3bfk</guid>
      <description>&lt;h2&gt;
  
  
  Where to begin?
&lt;/h2&gt;

&lt;p&gt;If you're wondering where to begin when creating a database just ask yourself: what is the purpose of this database? What data do you want to store in your database? How many tables will you need to store your data? What type of data will each table include? How will each table interact with one another? &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Purpose.&lt;/strong&gt; &lt;br&gt;
First determine what you want to accomplish with your database, i.e. track the classes of students&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data.&lt;/strong&gt; &lt;br&gt;
In order to track the classes of students you will need to not only store the classes of each student, but also the name of each student. The student itself may be a table that includes information such as the student's name, date of birth, GPA, etc. You may also want to include information about the class such as: the name of the class, the instructor, time and dates the class meet, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Types.&lt;/strong&gt; &lt;br&gt;
Just like when programming in JavaScript, or any other programming language, there are different data types to consider. Some common data types are numbers, strings and boolean. &lt;br&gt;
Pictured below is how our tables may look with their different data and data types. You will notice each table has its own &lt;code&gt;id&lt;/code&gt;. This is known as the &lt;em&gt;primary key&lt;/em&gt; and is what allows our program to distinguish between each item in each table. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lLkGDAWS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/da36ovc1mq8ux9hccfzm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lLkGDAWS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/da36ovc1mq8ux9hccfzm.png" alt="how our tables may look with their different data and data types" width="880" height="485"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Table Organization.&lt;/strong&gt; &lt;br&gt;
Table organization is key. How the tables interact with one another must follow the logic of how you want your database to be organized. This sounds trivial but can be tricky.&lt;br&gt;
For example, a student &lt;code&gt;has many&lt;/code&gt; classes but a class also &lt;code&gt;has many&lt;/code&gt; students. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PGYFRr40--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dxl9l8gcjhfvjnqaqv1l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PGYFRr40--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dxl9l8gcjhfvjnqaqv1l.png" alt="Student - classes relationship" width="880" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This means that we must have a join table, or a table that contains common fields from two or more tables. In our case it will be two fields: classes and students. These fields are known as &lt;em&gt;foreign keys&lt;/em&gt;. Our join table will be called grades and will store all of the grades for each student and each class.&lt;/p&gt;

&lt;p&gt;A student &lt;code&gt;has many&lt;/code&gt; grades but each grade &lt;code&gt;belongs to&lt;/code&gt; a student. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EfVBqdj6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6dce6pwxo8ueofj2xlvh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EfVBqdj6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6dce6pwxo8ueofj2xlvh.png" alt="student-grades relationship" width="880" height="491"&gt;&lt;/a&gt;&lt;br&gt;
A class &lt;code&gt;has many&lt;/code&gt; grades whiles grades belong to a class. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Neg_e_wa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qzb9wqa8501dtk6ue4sl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Neg_e_wa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qzb9wqa8501dtk6ue4sl.png" alt="class - grades relationship" width="880" height="487"&gt;&lt;/a&gt;&lt;br&gt;
It is important to note that students &lt;code&gt;has many&lt;/code&gt; classes &lt;code&gt;through&lt;/code&gt; grades and vice versa - classes &lt;code&gt;has many&lt;/code&gt; students &lt;code&gt;through&lt;/code&gt; grades.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZXh9u5AO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9skomo3pcmro0gcjic7z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZXh9u5AO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9skomo3pcmro0gcjic7z.png" alt="all table relationships" width="880" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;This is just the beginning of database structure, however, these very building blocks are what are used to create the most complicated databases on the internet.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Positioning Elements in CSS</title>
      <dc:creator>Joe Sembler</dc:creator>
      <pubDate>Wed, 05 Jan 2022 07:18:00 +0000</pubDate>
      <link>https://dev.to/joesembler/positioning-elements-in-css-4k2e</link>
      <guid>https://dev.to/joesembler/positioning-elements-in-css-4k2e</guid>
      <description>&lt;p&gt;As a beginner to web development one of the things I found that I struggled to learn how to do was styling my web pages, namely positioning elements on the page. I found this to be particularly difficult due to the number of variables that determine the position of an element.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Position&lt;/strong&gt;&lt;br&gt;
For starters there is the &lt;code&gt;position&lt;/code&gt; attribute. This attribute determines how an element will be rendered relative to the entire page. By default &lt;code&gt;position&lt;/code&gt; is &lt;code&gt;static&lt;/code&gt;, which means the element is positioned according to the normal flow of the document. We can change &lt;code&gt;position&lt;/code&gt; to be &lt;code&gt;relative&lt;/code&gt;,&lt;code&gt;absolute&lt;/code&gt;,&lt;code&gt;fixed&lt;/code&gt; or &lt;code&gt;sticky&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;relative&lt;/code&gt;: the element is positioned according to the normal flow of the document and offset according to &lt;code&gt;top&lt;/code&gt;, &lt;code&gt;left&lt;/code&gt;,&lt;code&gt;bottom&lt;/code&gt; and &lt;code&gt;right&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;absolute&lt;/code&gt;: the element is taken out of the normal document flow and no space is created for the element. The element is still positioned relative to its parent.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;fixed&lt;/code&gt;: not only is the element taken out of the document flow &lt;em&gt;and&lt;/em&gt; no space is created for the element, the element is positioned relative to the page, not the parent. The element also does not move on scroll.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;sticky&lt;/code&gt;: similar to &lt;code&gt;fixed&lt;/code&gt;, though it differs in that the element will move on a scroll, but it will get stuck at the top of the screen. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Web Dev Simplified made a really nice &lt;a href="https://www.youtube.com/watch?v=jx5jmI0UlXU"&gt;YouTube video&lt;/a&gt; that explains the &lt;code&gt;position&lt;/code&gt; attribute very well and it is just under 10 minutes long! &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Display&lt;/strong&gt;&lt;br&gt;
Ok so now that we understand &lt;code&gt;position&lt;/code&gt; we should probably take a look at &lt;code&gt;display&lt;/code&gt;. This attribute is very complicated and could use multiple articles to explain it fully! For beginner's sake the most three important keywords to look at are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;block&lt;/code&gt;: the element generates a block element box and creates line breaks before and after the element in the normal flow. This means that your element(s) will be on their own line.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;inline&lt;/code&gt;: the element does not generate a line break before or after itself, therefore the element(s) will be on the same line together.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;inline-block&lt;/code&gt;: a mix of &lt;code&gt;inline&lt;/code&gt; and &lt;code&gt;block&lt;/code&gt; (exactly as one would expect), the element generates a block element box much like the &lt;code&gt;block&lt;/code&gt; keyword, though unlike &lt;code&gt;block&lt;/code&gt;, &lt;code&gt;inline-block&lt;/code&gt; does not create line breaks before or after the element so that the element(s) are displayed neatly in boxes, all on the same line. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mxRlAom0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/frc2bcec47abrm0d5kt1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mxRlAom0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/frc2bcec47abrm0d5kt1.png" alt="Displaying the differences between block, inline and inline-block" width="696" height="197"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Margin vs. Padding&lt;/strong&gt;&lt;br&gt;
Additionally relevant to positioning elements in CSS is understanding the differences between &lt;code&gt;margin&lt;/code&gt; and &lt;code&gt;padding&lt;/code&gt;. &lt;code&gt;margin&lt;/code&gt; is the spacing between the element and the edge of the page. While, &lt;code&gt;padding&lt;/code&gt; refers to the spacing between the border your element and the content your element contains. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nPXh1DPm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/486x4sa0p5lnoa3udasd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nPXh1DPm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/486x4sa0p5lnoa3udasd.png" alt="Image displaying the differences between margin and padding" width="544" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
After learning these fundamentals of CSS I felt comfortable positioning any element in my document anywhere on the page. To be clear these will fundamentals alone will not make you an expert, but they will definitely help you achieve a nice looking web page!&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
