Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

Bash

specifying ports for rspec and spork

$ rspec --color --drb --drb-port 3011
$ spork -p 3011
https://snipt.net/embed/165933cb5dfcee30a045b6030e5918d8/
https://snipt.net/raw/165933cb5dfcee30a045b6030e5918d8/
165933cb5dfcee30a045b6030e5918d8
bash
Bash
2
2016-12-04T06:56:53
True
False
False
/api/public/snipt/56292/
specifying-ports-for-rspec-and-spork
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$ rspec --color --drb --drb-port 3011 </span><span id="L-2"><a name="L-2"></a>$ spork -p 3011 </span></pre></div> </td></tr></table>
rails, rspec, ruby, spork

Ruby

Rails test stuff

1
2
3
4
5
6
7
8
gem 'rspec-rails', :group => [:development, :test]

group :test do
  gem 'capybara'
  gem 'guard-rspec'
  gem 'rb-fsevent'
  gem 'growl'
end
https://snipt.net/embed/74b39b025f9ac25008df744daf1c24de/
https://snipt.net/raw/74b39b025f9ac25008df744daf1c24de/
74b39b025f9ac25008df744daf1c24de
rb
Ruby
8
2016-12-10T12:19:58
True
False
False
/api/public/snipt/34347/
rails-test-stuff
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="n">gem</span> <span class="s1">&#39;rspec-rails&#39;</span><span class="p">,</span> <span class="ss">:group</span> <span class="o">=&gt;</span> <span class="o">[</span><span class="ss">:development</span><span class="p">,</span> <span class="ss">:test</span><span class="o">]</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="n">group</span> <span class="ss">:test</span> <span class="k">do</span> </span><span id="L-4"><a name="L-4"></a> <span class="n">gem</span> <span class="s1">&#39;capybara&#39;</span> </span><span id="L-5"><a name="L-5"></a> <span class="n">gem</span> <span class="s1">&#39;guard-rspec&#39;</span> </span><span id="L-6"><a name="L-6"></a> <span class="n">gem</span> <span class="s1">&#39;rb-fsevent&#39;</span> </span><span id="L-7"><a name="L-7"></a> <span class="n">gem</span> <span class="s1">&#39;growl&#39;</span> </span><span id="L-8"><a name="L-8"></a><span class="k">end</span> </span></pre></div> </td></tr></table>
rails, rspec, tdd

Bash

Run Autospec

1
2
3
$ export AUTOFEATURE=true
$ spork RSpec &
$ ruby script/autospec 
https://snipt.net/embed/b9df82eae5c75586d02fbb6acc2ca989/
https://snipt.net/raw/b9df82eae5c75586d02fbb6acc2ca989/
b9df82eae5c75586d02fbb6acc2ca989
bash
Bash
3
2016-12-09T18:37:22
True
False
False
/api/public/snipt/18718/
run-rspec
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$ <span class="nb">export</span> <span class="nv">AUTOFEATURE</span><span class="o">=</span><span class="nb">true</span> </span><span id="L-2"><a name="L-2"></a>$ spork RSpec <span class="p">&amp;</span> </span><span id="L-3"><a name="L-3"></a>$ ruby script/autospec </span></pre></div> </td></tr></table>
rails, rspec, ruby, spork

Ruby

Crear stubs encadenados

1
2
3
4
5
6
7
8
describe User do
  it "should return friends count" do
    @user = mock(User)
    @user.stub_chain(:friends, :filtered, :count).and_return(100)
 
    @user.friends.filtered.count.should == 100
  end
end
https://snipt.net/embed/748b77b1260dca92f661801d339cea91/
https://snipt.net/raw/748b77b1260dca92f661801d339cea91/
748b77b1260dca92f661801d339cea91
rb
Ruby
8
2016-12-09T11:59:52
True
False
False
/api/public/snipt/8798/
crear-stubs-encadenados
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="n">describe</span> <span class="no">User</span> <span class="k">do</span> </span><span id="L-2"><a name="L-2"></a> <span class="n">it</span> <span class="s2">&quot;should return friends count&quot;</span> <span class="k">do</span> </span><span id="L-3"><a name="L-3"></a> <span class="vi">@user</span> <span class="o">=</span> <span class="n">mock</span><span class="p">(</span><span class="no">User</span><span class="p">)</span> </span><span id="L-4"><a name="L-4"></a> <span class="vi">@user</span><span class="o">.</span><span class="n">stub_chain</span><span class="p">(</span><span class="ss">:friends</span><span class="p">,</span> <span class="ss">:filtered</span><span class="p">,</span> <span class="ss">:count</span><span class="p">)</span><span class="o">.</span><span class="n">and_return</span><span class="p">(</span><span class="mi">100</span><span class="p">)</span> </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a> <span class="vi">@user</span><span class="o">.</span><span class="n">friends</span><span class="o">.</span><span class="n">filtered</span><span class="o">.</span><span class="n">count</span><span class="o">.</span><span class="n">should</span> <span class="o">==</span> <span class="mi">100</span> </span><span id="L-7"><a name="L-7"></a> <span class="k">end</span> </span><span id="L-8"><a name="L-8"></a><span class="k">end</span> </span></pre></div> </td></tr></table>
rspec, stubs
Copyrighted, illegal, or inappropriate content? Email [email protected].