# RSpec

**URL:** https://www.ruby-forum.com/c/testing/rspec/25.md?page=32

[Latest](https://www.ruby-forum.com/latest.md) · [Categories](https://www.ruby-forum.com/categories.md) · [Tags](https://www.ruby-forum.com/tags.md)

**Page:** 33

---

## [RSpec Email-Spec Problem](https://www.ruby-forum.com/t/rspec-email-spec-problem/191517)

<div class="topic-metadata">

**Author:** [@railslist](https://www.ruby-forum.com/u/railslist)\
**Replies:** 2\
**Last updated:** [July 14, 2010, 4:40pm UTC](https://www.ruby-forum.com/t/rspec-email-spec-problem/191517 "2010-07-14T16:40:20Z")

</div>

Hi! I am using email-spec gem with rspec to test email. If the email is multipart email then the example fails. The example passes if it’s not multipart email. Any advise on how to get it to pass. Here is the error: …

---

## [Hiding test\_unit Generators?](https://www.ruby-forum.com/t/hiding-test-unit-generators/191538)

<div class="topic-metadata">

**Author:** [@arco](https://www.ruby-forum.com/u/arco)\
**Replies:** 1\
**Last updated:** [July 14, 2010, 2:47pm UTC](https://www.ruby-forum.com/t/hiding-test-unit-generators/191538 "2010-07-14T14:47:19Z")

</div>

In a recent blog post, David wrote: Because RSpec is the test framework of record, Rails doesn’t know to hide the test\_unit generators. If you want to hide them, just add this to one of your config files: Rails::Gene…

---

## [Spec for a rails helper that renders a partial template](https://www.ruby-forum.com/t/spec-for-a-rails-helper-that-renders-a-partial-template/191529)

<div class="topic-metadata">

**Author:** [@jrochkind](https://www.ruby-forum.com/u/jrochkind)\
**Replies:** 6\
**Last updated:** [July 14, 2010, 1:59am UTC](https://www.ruby-forum.com/t/spec-for-a-rails-helper-that-renders-a-partial-template/191529 "2010-07-14T01:59:52Z")

</div>

So the stock answer to this is “don’t do it”. But I’m in a situation where it’s really what I want to do to test what I want to test. a helper method: def some\_helper render(:partial =\> “some/partial”, :locals =\> {:…

---

## [\[Rspec\] Difference between stub and message expectation with any\_number\_of\_times](https://www.ruby-forum.com/t/rspec-difference-between-stub-and-message-expectation-with-any-number-of-times/191511)

<div class="topic-metadata">

**Author:** [@Benyi\_W](https://www.ruby-forum.com/u/Benyi_W)\
**Replies:** 2\
**Last updated:** [July 14, 2010, 1:14am UTC](https://www.ruby-forum.com/t/rspec-difference-between-stub-and-message-expectation-with-any-number-of-times/191511 "2010-07-14T01:14:53Z")

</div>

I’m wondering what’s the difference between stub and message expectation with any\_number\_of\_times, for example: myMock = mock(“mymock”) myMock.stub!(:is\_a?).with(MyClass).and\_return(false) and myMock = mock(“mymock”…

---

## [Does rspec2 work with datamapper?](https://www.ruby-forum.com/t/does-rspec2-work-with-datamapper/191399)

<div class="topic-metadata">

**Author:** [@kevin](https://www.ruby-forum.com/u/kevin)\
**Replies:** 2\
**Last updated:** [July 14, 2010, 12:14am UTC](https://www.ruby-forum.com/t/does-rspec2-work-with-datamapper/191399 "2010-07-14T00:14:34Z")

</div>

I keep getting this error message: /Users/kevin/.bundle/ruby/1.8/gems/rspec-rails-2.0.0.beta.16/lib/ rspec/ rails/fixture\_support.rb:12: uninitialized constant RSpec::Rails::FixtureSupport::ActiveRecord (NameError) …

---

## [RSpec Controller Testing - render\_templte Issue](https://www.ruby-forum.com/t/rspec-controller-testing-render-templte-issue/191440)

<div class="topic-metadata">

**Author:** [@railslist](https://www.ruby-forum.com/u/railslist)\
**Replies:** 3\
**Last updated:** [July 12, 2010, 8:11pm UTC](https://www.ruby-forum.com/t/rspec-controller-testing-render-templte-issue/191440 "2010-07-12T20:11:25Z")

</div>

Hi! I am writing controller specs and getting a weird expectation failure. Here is the example. Please read the comments for details: it ‘renders children/\_show partial’ do post :create, :child =\> @child # The lin…

---

## [(rspec2/rails3) spec'ing the details of a controller that is not purely \*skinny\* by design](https://www.ruby-forum.com/t/rspec2-rails3-specing-the-details-of-a-controller-that-is-not-purely-skinny-by-design/191273)

<div class="topic-metadata">

**Author:** [@dizzyone](https://www.ruby-forum.com/u/dizzyone)\
**Replies:** 12\
**Last updated:** [July 12, 2010, 6:05pm UTC](https://www.ruby-forum.com/t/rspec2-rails3-specing-the-details-of-a-controller-that-is-not-purely-skinny-by-design/191273 "2010-07-12T18:05:28Z")

</div>

Looks like I didn’t read the instructions before posting… I’m hoping that the “moderator” is /dev/null - otherwise this might come up as a repost. Anyway. I want my controller to set certain attributes on #create and…

---

## [New project: rspec\_for\_generators - toolbox for using RSpec 2 to test and spec Rails 3 generators](https://www.ruby-forum.com/t/new-project-rspec-for-generators-toolbox-for-using-rspec-2-to-test-and-spec-rails-3-generators/191416)

<div class="topic-metadata">

**Author:** [@kristianm](https://www.ruby-forum.com/u/kristianm)\
**Replies:** 0\
**Last updated:** [July 12, 2010, 12:22pm UTC](https://www.ruby-forum.com/t/new-project-rspec-for-generators-toolbox-for-using-rspec-2-to-test-and-spec-rails-3-generators/191416 "2010-07-12T12:22:20Z")

</div>

I have created a complete project where I have extracted all my RSpec 2 utilities, configurations, special matchers etc. for creating nice Rails 3 Generator specs. http://github.com/kristianmandrup/rspec\_for\_generator…

---

## [Rspec-method missing error](https://www.ruby-forum.com/t/rspec-method-missing-error/191405)

<div class="topic-metadata">

**Author:** [@siva](https://www.ruby-forum.com/u/siva)\
**Replies:** 1\
**Last updated:** [July 12, 2010, 5:00am UTC](https://www.ruby-forum.com/t/rspec-method-missing-error/191405 "2010-07-12T05:00:26Z")

</div>

Hi Thanks in advance for helping me. I got the following error: /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/ active\_support/whiny\_nil.rb:52:in method\_missing': undefined methodstrip’ for nil:NilClass (No…

---

## [How to test a method that return random values](https://www.ruby-forum.com/t/how-to-test-a-method-that-return-random-values/191401)

<div class="topic-metadata">

**Author:** [@guilhermemm](https://www.ruby-forum.com/u/guilhermemm)\
**Replies:** 1\
**Last updated:** [July 12, 2010, 4:35am UTC](https://www.ruby-forum.com/t/how-to-test-a-method-that-return-random-values/191401 "2010-07-12T04:35:52Z")

</div>

Hi, How can I test this method using rspec ? def self.generate\_calculation number1, number2, operation number1 = rand(number1) number2 = rand(number2) … end This method return an operation with those random number…

---

## [Strange behavior with using webrat in requests tests](https://www.ruby-forum.com/t/strange-behavior-with-using-webrat-in-requests-tests/191402)

<div class="topic-metadata">

**Author:** [@Mike\_Gehard](https://www.ruby-forum.com/u/Mike_Gehard)\
**Replies:** 1\
**Last updated:** [July 12, 2010, 4:18am UTC](https://www.ruby-forum.com/t/strange-behavior-with-using-webrat-in-requests-tests/191402 "2010-07-12T04:18:18Z")

</div>

Good morning, I am using Rails3 (beta4) and RSpec2 (beta 15) under RVM and am running into an interesting issue. My request tests using webrat seem to think that they are running in the development Rails environment…

---

## [RSpec 2 - specs for Rails generators :)](https://www.ruby-forum.com/t/rspec-2-specs-for-rails-generators/191403)

<div class="topic-metadata">

**Author:** [@kristianm](https://www.ruby-forum.com/u/kristianm)\
**Replies:** 0\
**Last updated:** [July 12, 2010, 3:03am UTC](https://www.ruby-forum.com/t/rspec-2-specs-for-rails-generators/191403 "2010-07-12T03:03:24Z")

</div>

In my fork of jnunemaker’s canable I show my port of the unit test way of testing generators for RSpec 2. It still needs some tidying up to make it even more elegant :wink: Feel free to provide suggestions etc. Kri…

---

## [Experimenting with converting Rails::Generators::TestCase to RSpec 2](https://www.ruby-forum.com/t/experimenting-with-converting-rails-testcase-to-rspec-2/191404)

<div class="topic-metadata">

**Author:** [@kristianm](https://www.ruby-forum.com/u/kristianm)\
**Replies:** 0\
**Last updated:** [July 12, 2010, 2:56am UTC](https://www.ruby-forum.com/t/experimenting-with-converting-rails-testcase-to-rspec-2/191404 "2010-07-12T02:56:22Z")

</div>

Example: require File.expand\_path(File.dirname(FILE) + ‘/…/spec\_helper’) describe ‘Generator’ do let(:generator) { Rails::Generators::Testcase.new } with generator do destination File.join(Rails.root) tests Canab…

---

## [RSpec 2 equivalent for Rails::Generators::TestCase?](https://www.ruby-forum.com/t/rspec-2-equivalent-for-rails-testcase/191400)

<div class="topic-metadata">

**Author:** [@kristianm](https://www.ruby-forum.com/u/kristianm)\
**Replies:** 0\
**Last updated:** [July 12, 2010, 2:48am UTC](https://www.ruby-forum.com/t/rspec-2-equivalent-for-rails-testcase/191400 "2010-07-12T02:48:11Z")

</div>

I have been creating a lot of Thor generators and Rails generators during the past 4 months, but only this week did I find some good examples of how to write tests for generators using Rails::Generators::TestCase - in…

---

## [Devise: session variable is empty on session\_serializer.rb#store](https://www.ruby-forum.com/t/devise-session-variable-is-empty-on-session-serializer-rb-store/191337)

<div class="topic-metadata">

**Author:** [@dazuma](https://www.ruby-forum.com/u/dazuma)\
**Replies:** 9\
**Last updated:** [July 10, 2010, 10:49pm UTC](https://www.ruby-forum.com/t/devise-session-variable-is-empty-on-session-serializer-rb-store/191337 "2010-07-10T22:49:05Z")

</div>

I’ve been trying to test a very simple action on a controller with this setup: rspec 1.3.0 ruby 1.8.7 (2009-06-12 patchlevel 174) \[universal-darwin10.0\] Rails 2.3.8 devise 1.0.8 And this is the test: before :each …

---

## [Setting up rspec-rails for hacking](https://www.ruby-forum.com/t/setting-up-rspec-rails-for-hacking/191176)

<div class="topic-metadata">

**Author:** [@Lalish-MenaghS\_Trev](https://www.ruby-forum.com/u/Lalish-MenaghS_Trev)\
**Replies:** 6\
**Last updated:** [July 9, 2010, 3:39pm UTC](https://www.ruby-forum.com/t/setting-up-rspec-rails-for-hacking/191176 "2010-07-09T15:39:56Z")

</div>

I am sure most of you could do this easily, but I wanted to write down how I got there in any case, so here are my instructions on how to set up rspec-rails to hack on: Enjoy, Trevor Trevor Lalish-Menagh 484.868.6…

---

## [Testing equality](https://www.ruby-forum.com/t/testing-equality/191255)

<div class="topic-metadata">

**Author:** [@jmcervera](https://www.ruby-forum.com/u/jmcervera)\
**Replies:** 3\
**Last updated:** [July 9, 2010, 9:37am UTC](https://www.ruby-forum.com/t/testing-equality/191255 "2010-07-09T09:37:05Z")

</div>

Hello How can I test equality with two objects when they include some attribute that is BigDecimal? if I make something like this: it “should …whatever” do obj = Factory.create(:my\_object) … MyObject.first.should …

---

## [Rspec-rails how to selectively turn on csrf protection for controller specs?](https://www.ruby-forum.com/t/rspec-rails-how-to-selectively-turn-on-csrf-protection-for-controller-specs/191278)

<div class="topic-metadata">

**Author:** [@nruth](https://www.ruby-forum.com/u/nruth)\
**Replies:** 2\
**Last updated:** [July 9, 2010, 3:57am UTC](https://www.ruby-forum.com/t/rspec-rails-how-to-selectively-turn-on-csrf-protection-for-controller-specs/191278 "2010-07-09T03:57:26Z")

</div>

I’m setting up a Paypal IPN listener and need the create action to not use rails’ default CSRF protection. I’ve got that working fine & test it actually works with cucumber (where I’ve turned CSRF back on, since it’s …

---

## [RSpec TM bundle question](https://www.ruby-forum.com/t/rspec-tm-bundle-question/191286)

<div class="topic-metadata">

**Author:** [@jay](https://www.ruby-forum.com/u/jay)\
**Replies:** 2\
**Last updated:** [July 8, 2010, 9:56pm UTC](https://www.ruby-forum.com/t/rspec-tm-bundle-question/191286 "2010-07-08T21:56:52Z")

</div>

does the RSpec TM bundle require that one have the RSpec 2 prerelease version installed? When I try to use the latest TMBundle I get a can’t find rspec/core error

---

## [RSpec.tmbundle failure after removing at\_exit hook](https://www.ruby-forum.com/t/rspec-tmbundle-failure-after-removing-at-exit-hook/191283)

<div class="topic-metadata">

**Author:** [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Replies:** 0\
**Last updated:** [July 8, 2010, 8:01pm UTC](https://www.ruby-forum.com/t/rspec-tmbundle-failure-after-removing-at-exit-hook/191283 "2010-07-08T20:01:31Z")

</div>

Hey all, Following up on the problem with textmate after removing the at\_exit hook (see http://groups.google.com/group/rspec/browse\_thread/thread/37bbe78aa52682b0): The problem is that the file(s) do(es) not get load…

---

## [Experimental branch with no at\_exit hook](https://www.ruby-forum.com/t/experimental-branch-with-no-at-exit-hook/191282)

<div class="topic-metadata">

**Author:** [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Replies:** 0\
**Last updated:** [July 8, 2010, 7:48pm UTC](https://www.ruby-forum.com/t/experimental-branch-with-no-at-exit-hook/191282 "2010-07-08T19:48:03Z")

</div>

Hey all, I’ve got an experimental branch of rspec-core-2 that removes the at\_exit hook: http://github.com/rspec/rspec-core/tree/no-at-exit. It works just fine with the rake and rspec commands, as well as spork. You ca…

---

## [Accessing view helpers to spec cell views, Rails3, RSpec2](https://www.ruby-forum.com/t/accessing-view-helpers-to-spec-cell-views-rails3-rspec2/191252)

<div class="topic-metadata">

**Author:** [@biot023](https://www.ruby-forum.com/u/biot023)\
**Replies:** 2\
**Last updated:** [July 8, 2010, 2:30pm UTC](https://www.ruby-forum.com/t/accessing-view-helpers-to-spec-cell-views-rails3-rspec2/191252 "2010-07-08T14:30:07Z")

</div>

Hi – I’m trying to use the excellent Cells http://cells.rubyforge.org/ gem in a Rails 3 project with RSpec 2. I’ve got the ‘controller’ bit of the cells specced okay, but I’m struggling with the ‘view’ bit. What I …

---

## [RSpec uses at\_exit - forks and stuff](https://www.ruby-forum.com/t/rspec-uses-at-exit-forks-and-stuff/191208)

<div class="topic-metadata">

**Author:** [@diabolist](https://www.ruby-forum.com/u/diabolist)\
**Replies:** 5\
**Last updated:** [July 8, 2010, 12:58pm UTC](https://www.ruby-forum.com/t/rspec-uses-at-exit-forks-and-stuff/191208 "2010-07-08T12:58:47Z")

</div>

Hi there. My understanding (which is limited) is that rspec uses at\_exit to run its specs. I don’t really know why - could somoene explain? My problem with this behaviour is that I would like the running of a spec t…

---

## [How to test an app with multiple databases?](https://www.ruby-forum.com/t/how-to-test-an-app-with-multiple-databases/184732)

<div class="topic-metadata">

**Author:** [@russellf](https://www.ruby-forum.com/u/russellf)\
**Replies:** 6\
**Last updated:** [July 8, 2010, 12:42pm UTC](https://www.ruby-forum.com/t/how-to-test-an-app-with-multiple-databases/184732 "2010-07-08T12:42:58Z")

</div>

Our app connects to two databases. The main database (through ActiveRecord::Base) is automatically cleared before each test. How do I force the clear of the secondary database as well ? Thanks in advance… Russell

---

## [Rspec rake tasks fail inside active record](https://www.ruby-forum.com/t/rspec-rake-tasks-fail-inside-active-record/191147)

<div class="topic-metadata">

**Author:** [@andreyr](https://www.ruby-forum.com/u/andreyr)\
**Replies:** 2\
**Last updated:** [July 8, 2010, 10:31am UTC](https://www.ruby-forum.com/t/rspec-rake-tasks-fail-inside-active-record/191147 "2010-07-08T10:31:49Z")

</div>

Hi, i have a problem that any of my rspec rake tasks fail with the following error: rake -f unittests.rake spec \*\* Invoke spec (first\_time) \*\* Execute spec C:/Ruby18/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/a…

---

## [Remarkable Rails validations not working](https://www.ruby-forum.com/t/remarkable-rails-validations-not-working/191201)

<div class="topic-metadata">

**Author:** [@johnnybutler7](https://www.ruby-forum.com/u/johnnybutler7)\
**Replies:** 0\
**Last updated:** [July 7, 2010, 2:44pm UTC](https://www.ruby-forum.com/t/remarkable-rails-validations-not-working/191201 "2010-07-07T14:44:37Z")

</div>

Hi, Ive installed the remarkable\_rails plugin(3.1.13) so i can use the macros to test the model associations and validations. For my model user i have: validates\_presence\_of :title, :message =\> ‘cannot be blank!’ …

---

## [Rspec2 Beta Changelog?](https://www.ruby-forum.com/t/rspec2-beta-changelog/191159)

<div class="topic-metadata">

**Author:** [@arco](https://www.ruby-forum.com/u/arco)\
**Replies:** 1\
**Last updated:** [July 6, 2010, 6:09pm UTC](https://www.ruby-forum.com/t/rspec2-beta-changelog/191159 "2010-07-06T18:09:23Z")

</div>

Is there a change log for the Rspec2 beta? I couldn’t find one in the source or wiki…

---

## [Possible improvements to routing spec API](https://www.ruby-forum.com/t/possible-improvements-to-routing-spec-api/191092)

<div class="topic-metadata">

**Author:** [@Wincent\_C](https://www.ruby-forum.com/u/Wincent_C)\
**Replies:** 14\
**Last updated:** [July 6, 2010, 2:59pm UTC](https://www.ruby-forum.com/t/possible-improvements-to-routing-spec-api/191092 "2010-07-06T14:59:04Z")

</div>

Hi folks, I’ve been unhappy with routing specs for a long time now and last night when updating some old 1.3 specs for 2.0 I decided to see if I could come up with something that didn’t make me feel unhappy. Principa…

---

## [Rspec 2 not cleaning up after examples run?](https://www.ruby-forum.com/t/rspec-2-not-cleaning-up-after-examples-run/190814)

<div class="topic-metadata">

**Author:** [@Timo\_RSSSSSSSSner](https://www.ruby-forum.com/u/Timo_RSSSSSSSSner)\
**Replies:** 12\
**Last updated:** [July 6, 2010, 12:18am UTC](https://www.ruby-forum.com/t/rspec-2-not-cleaning-up-after-examples-run/190814 "2010-07-06T00:18:35Z")

</div>

Hey guys, I let the code speak for itself: Below are my currently failing specs, please don’t pay too much attention to the specs themselves, I just want to give you a “real life example” of what’s happening - the on…

---

## [\[ANN\] ShRUG 8, Mon July 12th: Introduction to RSpec](https://www.ruby-forum.com/t/ann-shrug-8-mon-july-12th-introduction-to-rspec/191111)

<div class="topic-metadata">

**Author:** [@Ashley\_M](https://www.ruby-forum.com/u/Ashley_M)\
**Replies:** 0\
**Last updated:** [July 5, 2010, 8:01pm UTC](https://www.ruby-forum.com/t/ann-shrug-8-mon-july-12th-introduction-to-rspec/191111 "2010-07-05T20:01:34Z")

</div>

Hi all Reposting this for the benefit of anyone who may be able to attend but wouldn’t normally see ShRUG announcements. ShRUG is the Sheffield (UK) Ruby U. Group. ShRUG July 2010 is now confirmed. Ashley M. (that’…

[Previous page](https://www.ruby-forum.com/c/testing/rspec/25.md?page=31)

[Next page](https://www.ruby-forum.com/c/testing/rspec/25.md?page=33)
