<?xml version="1.0" encoding="UTF-8"?>
<rss version='2.0' xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Robert Elroy</title>
    <description>Union Operator
CSL Behring</description>
    <link>https://robertelroy.silvrback.com/feed</link>
    <atom:link href="https://robertelroy.silvrback.com/feed" rel="self" type="application/rss+xml"/>
    <category domain="robertelroy.silvrback.com">Content Management/Blog</category>
    <language>en-us</language>
      <pubDate>Sat, 23 Sep 2017 05:43:50 -0500</pubDate>
    <managingEditor>relroy5499@gmail.com (Robert Elroy)</managingEditor>
      <item>
        <guid>http://robertelroy.com/blessed--2#34542</guid>
          <pubDate>Sat, 23 Sep 2017 05:43:50 -0500</pubDate>
        <link>http://robertelroy.com/blessed--2</link>
        <title>Blessed</title>
        <description>CSL Behring</description>
        <content:encoded><![CDATA[<p>May 23rd I started at CSL Behring in Kankakee. What an awesome blessing. This has helped my family out tremendously! I am now an inspection Operator. <br>
God has been very good to me through thick and thin! Sometimes when all seems doomed, always keep your faith. God provides what is needed. Not always what you want, but what you need.</p>
]]></content:encoded>
      </item>
      <item>
        <guid>http://robertelroy.com/ruby-meetup#10884</guid>
          <pubDate>Fri, 02 Jan 2015 15:10:18 -0600</pubDate>
        <link>http://robertelroy.com/ruby-meetup</link>
        <title>Ruby Meetup</title>
        <description>with Mark Richarson</description>
        <content:encoded><![CDATA[<h1 id="awesome-time">Awesome time!</h1>

<p>I had an awesome time listening to Mark Richardson teach about the basics of Ruby and how to get started.<br>
Mark finished classes with me at ACLTC this past December 2014. He did a great job getting eager new Rubyists started making their very first app.I was able to assist him with people that struggled a little getting the syntax right which gave me kind of the bug to want to teach and help others as well.<br>
Seems the more you give of your time and efforts to others the more you want to. New developers are so eager and thankful when someone gives them the empowerment to succeed.It&#39;s very rewarding!<br>
<img alt="Silvrback blog image" src="https://silvrback.s3.amazonaws.com/uploads/9af0ee32-4fe0-4cb8-a738-7d44ebb733b9/Ruby_logo_large.png" /></p>
]]></content:encoded>
      </item>
      <item>
        <guid>http://robertelroy.com/tdd-in-rails#10872</guid>
          <pubDate>Fri, 02 Jan 2015 11:28:31 -0600</pubDate>
        <link>http://robertelroy.com/tdd-in-rails</link>
        <title>TDD in Rails</title>
        <description>Not as hard as you think!</description>
        <content:encoded><![CDATA[<h1 id="tdd-is-not-so-bad">TDD is not so bad!</h1>

<h2 id="here-are-a-few-things-to-think-about-getting-started">Here are a few things to think about getting started:</h2>

<p>*You&#39;ll need a test suite like RSpec.</p>

<h4 id="these-instructions-can-be-made-obsolete-in-the-future-always-be-sure-to-check-https-github-com-rspec-rspec-rails">These instructions can be made obsolete in the future. Always be sure to check: <a href="https://github.com/rspec/rspec-rails">https://github.com/rspec/rspec-rails</a></h4>

<p>Add this to your Gemfile:<br>
group :development, :test do<br>
  gem &#39;rspec-rails&#39;, &#39;~&gt; 3.0&#39;<br>
end</p>

<p>In your terminal: bundle<br>
In your terminal: rails generate rspec:install<br>
In your terminal: bundle binstubs rspec-core<br>
Make sure that you can run in your terminal: rspec<br>
If so, that means you’re in good shape!</p>

<p>*In this example you would need the proper Models in the database which will consist of Product, Order, and CartedProduct Models.<br>
<a href="https://github.com/relroy/capstone">Here is my app on github for your review</a><br>
<a href="https://github.com/relroy/capstone/blob/master/spec/models/order_spec.rb">OR my spec folder.</a><br>
*Test your model logic mostly.<br>
*Does any of your logic have validations?<br>
*Find this out on your Mac by clicking command - shift - F and find all &quot;vailidates&quot;. This will give you all the items that need validations.<br>
*Add  the Simplecov gem to your gem file.<br>
<a href="https://github.com/colszowka/simplecov">simplecov link</a> Read the documentation carefully! This is really cool and helpful! It will actually tell you, by percentage, how much of your app is covered by tests and where you need tests still.</p>

<h2 id="ok-lets-get-started">Ok, let&#39;s get started!</h2>

<h4 id="where-do-you-begin">Where do you begin?</h4>

<p>Let&#39;s say you want to test your sub-total method in your orders model.<br>
First you&#39;ll need to navigate to your spec folder and add a models folder to it. Then add an order_spec.rb file to the models folder.<br>
At the top of the order_spec file you should place <br>
<code>require &#39;rails_helper&#39;</code><br>
Then start your test code block.<br>
Here is an example and then I&#39;ll explain:<br>
<code>require &#39;rails_helper&#39;</code></p>

<p><code>describe Order do</code><br>
 <code>describe &#39;sub_total&#39; do</code><br>
    <code>it &#39;should return the sub_total of all the carted products prices times the quantity of each&#39; do</code><br>
     <code>product = Product.create!(:price =&gt; 3.0, :name =&gt; &quot;cone&quot;)</code><br>
      <code>product_2 = Product.create!(:price =&gt; 5.0, :name =&gt; &quot;shake&quot;)</code><br>
      <code>order = Order.create!(:user_id =&gt; 2, :status =&gt; &#39;cart&#39;)</code><br>
    <code>carted_product_1 = CartedProduct.create!(:product_id =&gt; product.id, :quantity =&gt; 3, :order_id =&gt; order.id)</code><br>
    <code>carted_product_2 = CartedProduct.create!(:product_id =&gt; product_2.id, :quantity =&gt; 2, :order_id =&gt; order.id)</code></p>

<p><code>expect(order.sub_total).to eq(19.0)</code><br>
   <code>end</code><br>
<code>end</code><br>
<code>end</code><br>
As you notice, first you need to describe what it is you&#39;re testing. in this case Order.<br>
<code>describe Order do</code><br>
Then you need to describe what method you are testing. Again, this will be the sub_total method.<br>
 <code>describe &#39;sub_total&#39; do</code><br>
Now, you need to tell it what it should do. <em>Notice things in single quotes are arbitrary, they are not part of the code</em> so be as accurate of a description as you can so someone else years from now could understand what you are testing.<br>
<code>it &#39;should return the sub_total of all the carted products prices times the quantity of each&#39; do</code><br>
Here&#39;s the part you need to think about. You&#39;ll need to build everything from scratch because remember that this is a piece of metal. It doesn&#39;t know what you want automatically. You have to be specific. You are creating in the <strong>test development database</strong> a couple of temporary products with the following code because they don&#39;t exist yet even though you may have things in you <strong>development database</strong>.<br>
<code>product = Product.create!(:price =&gt; 3.0, :name =&gt; &quot;cone&quot;)</code><br>
 <code>product_2 = Product.create!(:price =&gt; 5.0, :name =&gt; &quot;shake&quot;)</code><br>
Notice that I have the price and name? That&#39;s because in <strong>my app</strong> I have validations for these two items.<br>
OK, Next let&#39;s create an order.<br>
 <code>order = Order.create!(:user_id =&gt; 2, :status =&gt; &#39;cart&#39;)</code><br>
Again, I need validations of a user_id and a status of  &#39;cart&#39; to make this happen.<br>
Now, for a couple of carted_products. Think of this like putting you items in the grocery cart at the store before you head to the cashier. <br>
<code>carted_product_1 = CartedProduct.create!(:product_id =&gt; product.id, :quantity =&gt; 3, :order_id =&gt; order.id)</code><br>
    <code>carted_product_2 = CartedProduct.create!(:product_id =&gt; product_2.id, :quantity =&gt; 2, :order_id =&gt; order.id)</code><br>
Be careful to make your variables different, remember this stupid machine doesn&#39;t know anything unless you tell it. If you say something monkey is purple and then on another line say monkey is purple it thinks it&#39;s the same item.<br>
Ok, this is where you tell the computer what you are expecting to happen when the RSpec command in the terminal is run.<br>
<code>expect(order.sub_total).to eq(19.0)</code><br>
This should be what your products above should come to when you run the sub_total method on you order.<br>
Now, go to your terminal and run rspec.<br>
This will generate whether your test passes or fails. If you&#39;ve installed the simplecov gem properly it will also generate e report for you to see what percentage of your app is properly covered by testing. It will also tell you where you may want tests.</p>

<h3 id="a-little-confusing-to-get-started-but-the-more-you-do-it-the-more-comfortable-you-become-with-running-these-tests-good-luck">A little confusing to get started but the more you do it the more comfortable you become with running these tests.<strong>Good Luck!</strong></h3>
]]></content:encoded>
      </item>
  </channel>
</rss>