snipt

Ctrl+h for KB shortcuts

Text only

Snippet : Rspec - stubbing

Object.stub_chain(:config_hash, :find) { { week: 12, day: 13} }
Object.stub(:all_by_agent) { Agent.where(id: ids) }
https://snipt.net/embed/6ff81b4f7d10bd8dc76af6ff15bc21b5/
https://snipt.net/raw/6ff81b4f7d10bd8dc76af6ff15bc21b5/
6ff81b4f7d10bd8dc76af6ff15bc21b5
text
Text only
2
2016-09-27T20:42:38
True
False
False
Jan 14, 2016 at 07:58 AM
/api/public/snipt/143549/
snippet-rspec-stubbing
<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 id="L-1"><a name="L-1"></a>Object.stub_chain(:config_hash, :find) { { week: 12, day: 13} } </span><span id="L-2"><a name="L-2"></a>Object.stub(:all_by_agent) { Agent.where(id: ids) } </span></pre></div> </td></tr></table>
rspec, snippet

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-09-27T07:42:03
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 id="L-1"><a name="L-1"></a><span class="nv">$ </span>rspec --color --drb --drb-port 3011 </span><span id="L-2"><a name="L-2"></a><span class="nv">$ </span>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-09-28T16:08:41
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 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-09-28T12:59:11
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 id="L-1"><a name="L-1"></a><span class="nv">$ </span><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><span class="nv">$ </span>spork RSpec <span class="p">&amp;</span> </span><span id="L-3"><a name="L-3"></a><span class="nv">$ </span>ruby script/autospec </span></pre></div> </td></tr></table>
rails, rspec, ruby, spork
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.