# RSpec

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

[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:** 46

---

## [Be\_true and be\_false](https://www.ruby-forum.com/t/be-true-and-be-false/180767)

<div class="topic-metadata">

**Author:** [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Replies:** 1\
**Last updated:** [December 28, 2009, 8:14pm UTC](https://www.ruby-forum.com/t/be-true-and-be-false/180767 "2009-12-28T20:14:15Z")

</div>

Hi all, The be\_true and be\_false matchers pass if the actual object is the singleton instance of true or false respectively. e.g. true.should be\_true # passes 1.should be\_true # fails “true”.should be\_true #fails f…

---

## [Class variables different between spec and runtime?](https://www.ruby-forum.com/t/class-variables-different-between-spec-and-runtime/180599)

<div class="topic-metadata">

**Author:** [@churp](https://www.ruby-forum.com/u/churp)\
**Replies:** 7\
**Last updated:** [December 28, 2009, 6:20am UTC](https://www.ruby-forum.com/t/class-variables-different-between-spec-and-runtime/180599 "2009-12-28T06:20:04Z")

</div>

Hello Folks, This gist user.rb · GitHub has an example user.rb, user\_spec.rb At runtime, this snippet fails u = User.find(123) u.update\_with\_profile({…}) The error occurred while evaluating nil.select): app/models…

---

## [Generated gem config?](https://www.ruby-forum.com/t/generated-gem-config/180717)

<div class="topic-metadata">

**Author:** [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Replies:** 0\
**Last updated:** [December 27, 2009, 5:14pm UTC](https://www.ruby-forum.com/t/generated-gem-config/180717 "2009-12-27T17:14:03Z")

</div>

Hey all, The cucumber-rails generator generates config/environments/cucumber.rb for us, which means we don’t need to do any gem configuration. As things stand now, rspec-rails does not do the same thing for us. I’m …

---

## [DB does not reset between runs](https://www.ruby-forum.com/t/db-does-not-reset-between-runs/180710)

<div class="topic-metadata">

**Author:** [@magic6435](https://www.ruby-forum.com/u/magic6435)\
**Replies:** 2\
**Last updated:** [December 27, 2009, 9:26am UTC](https://www.ruby-forum.com/t/db-does-not-reset-between-runs/180710 "2009-12-27T09:26:31Z")

</div>

For some reason any thing that is created while running specs like users from a Factory remain in the database between runs which leads to errors such as “Validation failed: Email has already been taken” and yes i hav…

---

## [Custom matcher for predicates](https://www.ruby-forum.com/t/custom-matcher-for-predicates/180703)

<div class="topic-metadata">

**Author:** [@Ed\_Howland](https://www.ruby-forum.com/u/Ed_Howland)\
**Replies:** 3\
**Last updated:** [December 27, 2009, 5:31am UTC](https://www.ruby-forum.com/t/custom-matcher-for-predicates/180703 "2009-12-27T05:31:50Z")

</div>

I hope this isn’t a dumb question, but can a custom matcher be written for a possibly non-existant predicate? I know that if the object responds to some predicate? message, RSpec will breate a custom matcher on the fl…

---

## [What does as\_null\_object do?](https://www.ruby-forum.com/t/what-does-as-null-object-do/180671)

<div class="topic-metadata">

**Author:** [@t73net](https://www.ruby-forum.com/u/t73net)\
**Replies:** 1\
**Last updated:** [December 25, 2009, 5:23pm UTC](https://www.ruby-forum.com/t/what-does-as-null-object-do/180671 "2009-12-25T17:23:45Z")

</div>

So I’m going through the rspec book right now, and get to page 72, as it introduces Spec::Mocks::Methods#as\_null\_object . In the book, it doesn’t describe how it operates, or much detail about it other than it tells to …

---

## [Spec'ing Inherited Resource Controllers](https://www.ruby-forum.com/t/specing-inherited-resource-controllers/180633)

<div class="topic-metadata">

**Author:** [@jmcervera](https://www.ruby-forum.com/u/jmcervera)\
**Replies:** 1\
**Last updated:** [December 25, 2009, 3:29pm UTC](https://www.ruby-forum.com/t/specing-inherited-resource-controllers/180633 "2009-12-25T15:29:44Z")

</div>

Hello, I am trying to write the specs for controllers that use InheritedResource. Can somebody tell me if this is possible? I have read that I have to use integrated\_views, but even in that case it doesn’t work. I …

---

## [Problem with Before Filters](https://www.ruby-forum.com/t/problem-with-before-filters/180045)

<div class="topic-metadata">

**Author:** [@tornado](https://www.ruby-forum.com/u/tornado)\
**Replies:** 6\
**Last updated:** [December 24, 2009, 12:29pm UTC](https://www.ruby-forum.com/t/problem-with-before-filters/180045 "2009-12-24T12:29:43Z")

</div>

Hello, I am writing controller specs.I want to know how can i write specs which invlove before filters in controllers.

---

## [Spec with user culture](https://www.ruby-forum.com/t/spec-with-user-culture/180591)

<div class="topic-metadata">

**Author:** [@gnagno](https://www.ruby-forum.com/u/gnagno)\
**Replies:** 6\
**Last updated:** [December 23, 2009, 1:34pm UTC](https://www.ruby-forum.com/t/spec-with-user-culture/180591 "2009-12-23T13:34:53Z")

</div>

Hello all, I am making my first experiments with rspec, I wanted to do something like this: when a user visit the home page of my site he will be redirected depending on his culture, so if his culture is english he w…

---

## [Concept of given](https://www.ruby-forum.com/t/concept-of-given/180601)

<div class="topic-metadata">

**Author:** [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Replies:** 5\
**Last updated:** [December 22, 2009, 5:21pm UTC](https://www.ruby-forum.com/t/concept-of-given/180601 "2009-12-22T17:21:21Z")

</div>

Forgive me if the question is a common one… does rspec have any concept like given “a certain set of paths” do it “should be able to recreate them” do; end it “…”; end end ? Thanks. -r

---

## [State-based expectations (as per jMock in GOOS)](https://www.ruby-forum.com/t/state-based-expectations-as-per-jmock-in-goos/180369)

<div class="topic-metadata">

**Author:** [@Ashley\_M](https://www.ruby-forum.com/u/Ashley_M)\
**Replies:** 3\
**Last updated:** [December 18, 2009, 4:17pm UTC](https://www.ruby-forum.com/t/state-based-expectations-as-per-jmock-in-goos/180369 "2009-12-18T16:17:39Z")

</div>

Hi all I’m working my way through Growing Object-Oriented Software\[1\], currently at the start of chapter 15. Chapter 14 introduces a concept I haven’t seen before, state-based expectations based on sent messages. Th…

---

## [Spec'ing controllers](https://www.ruby-forum.com/t/specing-controllers/180289)

<div class="topic-metadata">

**Author:** [@stefankroes](https://www.ruby-forum.com/u/stefankroes)\
**Replies:** 2\
**Last updated:** [December 16, 2009, 6:39pm UTC](https://www.ruby-forum.com/t/specing-controllers/180289 "2009-12-16T18:39:52Z")

</div>

Hey guys. I switched completely to RSpec and Cucumber this spring and I am really happy with. While I think I’ve gotten quite good with it, I’m not sure I understand the value of spec’ing controllers (in Rails). I wou…

---

## [Cleanup pendings?](https://www.ruby-forum.com/t/cleanup-pendings/180245)

<div class="topic-metadata">

**Author:** [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Replies:** 0\
**Last updated:** [December 15, 2009, 6:17pm UTC](https://www.ruby-forum.com/t/cleanup-pendings/180245 "2009-12-15T18:17:19Z")

</div>

Currently with pending… it “should do something”; or it “should do something” do pending “some work” end I get this type of output: Pending: After should immediately return if the other process doesn’t exist (No…

---

## ["have" matcher special case for owned collection with 1 item](https://www.ruby-forum.com/t/have-matcher-special-case-for-owned-collection-with-1-item/180225)

<div class="topic-metadata">

**Author:** [@DeNigris\_S](https://www.ruby-forum.com/u/DeNigris_S)\
**Replies:** 1\
**Last updated:** [December 15, 2009, 7:01am UTC](https://www.ruby-forum.com/t/have-matcher-special-case-for-owned-collection-with-1-item/180225 "2009-12-15T07:01:54Z")

</div>

If I’m reading the docs right, the current implementation would be: my\_workspace.should have(1).documents Would it be hard to have it be: my\_workspace.should have(1).document ^ (no s) Sean DeNigris removed\_email\_…

---

## [RSPEC and RoR undefined method for hash when running model tests](https://www.ruby-forum.com/t/rspec-and-ror-undefined-method-for-hash-when-running-model-tests/180212)

<div class="topic-metadata">

**Author:** [@Matt\_Riches](https://www.ruby-forum.com/u/Matt_Riches)\
**Replies:** 7\
**Last updated:** [December 14, 2009, 10:59pm UTC](https://www.ruby-forum.com/t/rspec-and-ror-undefined-method-for-hash-when-running-model-tests/180212 "2009-12-14T22:59:38Z")

</div>

Within my project, I have a number of models that have additional methods within them other than those provided by active record. as an example (to keep it short and sweet) class foo \< ActiveRecod::Base def status …

---

## [Undefined method \`route\_for](https://www.ruby-forum.com/t/undefined-method-route-for/178738)

<div class="topic-metadata">

**Author:** [@tornado](https://www.ruby-forum.com/u/tornado)\
**Replies:** 22\
**Last updated:** [December 14, 2009, 11:06am UTC](https://www.ruby-forum.com/t/undefined-method-route-for/178738 "2009-12-14T11:06:09Z")

</div>

Hi all, I am writing scenarios for testing my routes but it is giving me error as undefined method \`route\_for and also for params\_from. Did i miss something which i need to add in my controller My code is as follows: …

---

## [Example vs ExampleProxy](https://www.ruby-forum.com/t/example-vs-exampleproxy/180164)

<div class="topic-metadata">

**Author:** [@williamtaft](https://www.ruby-forum.com/u/williamtaft)\
**Replies:** 1\
**Last updated:** [December 14, 2009, 5:01am UTC](https://www.ruby-forum.com/t/example-vs-exampleproxy/180164 "2009-12-14T05:01:32Z")

</div>

Hey all, I’m working on bring DeepTest up to compatibility with rspec 1.2.9 in order to parallelize tests, and hit a few roadblocks after 1.1.12. Specifically, I was wondering about ExampleProxy (which I know now is …

---

## [Error Running Standalone/Command Line rspec: undefined method Pathname](https://www.ruby-forum.com/t/error-running-standalone-command-line-rspec-undefined-method-pathname/180137)

<div class="topic-metadata">

**Author:** [@athem](https://www.ruby-forum.com/u/athem)\
**Replies:** 1\
**Last updated:** [December 12, 2009, 7:31pm UTC](https://www.ruby-forum.com/t/error-running-standalone-command-line-rspec-undefined-method-pathname/180137 "2009-12-12T19:31:43Z")

</div>

Hello, I’ve written the following simple rspec test that I’m trying to run (rspec 1.2.9) standalone (outside Rails) from the command line and getting the following error. Any idea for how to fix this? Thanks. $\> s…

---

## [RSpec wire protocol Was:Re: describe "RSpec's documentation" do](https://www.ruby-forum.com/t/rspec-wire-protocol-was-describe-rspecs-documentation-do/179974)

<div class="topic-metadata">

**Author:** [@Ed\_Howland](https://www.ruby-forum.com/u/Ed_Howland)\
**Replies:** 3\
**Last updated:** [December 12, 2009, 3:55am UTC](https://www.ruby-forum.com/t/rspec-wire-protocol-was-describe-rspecs-documentation-do/179974 "2009-12-12T03:55:54Z")

</div>

Matt, I was facinated to read the email thread on Cuke’s wire protoccol. You guys collaborated well. I have been working on my own to develop a similar protocol for RSpec. It is totally external to RSpec right now …

---

## [Stubbing calls to S3 from Paperclip](https://www.ruby-forum.com/t/stubbing-calls-to-s3-from-paperclip/180104)

<div class="topic-metadata">

**Author:** [@cautaro](https://www.ruby-forum.com/u/cautaro)\
**Replies:** 1\
**Last updated:** [December 11, 2009, 6:38pm UTC](https://www.ruby-forum.com/t/stubbing-calls-to-s3-from-paperclip/180104 "2009-12-11T18:38:09Z")

</div>

Any idea on how to stub calls to Amazon S3 from the Paperclip plugin?

---

## [Custom Matcher and Webrat methods](https://www.ruby-forum.com/t/custom-matcher-and-webrat-methods/179969)

<div class="topic-metadata">

**Author:** [@dracko](https://www.ruby-forum.com/u/dracko)\
**Replies:** 4\
**Last updated:** [December 10, 2009, 11:15am UTC](https://www.ruby-forum.com/t/custom-matcher-and-webrat-methods/179969 "2009-12-10T11:15:59Z")

</div>

I would like to be able to write a custom matcher so that I could call this test, for instance: @user.should be\_allowed\_to\_visit(url) @non\_welcome.should\_not be\_allowed\_to\_visit(url) The matcher would call Webrat met…

---

## [Autospec is running the full suite too often](https://www.ruby-forum.com/t/autospec-is-running-the-full-suite-too-often/180026)

<div class="topic-metadata">

**Author:** [@DEfusion](https://www.ruby-forum.com/u/DEfusion)\
**Replies:** 1\
**Last updated:** [December 10, 2009, 11:10am UTC](https://www.ruby-forum.com/t/autospec-is-running-the-full-suite-too-often/180026 "2009-12-10T11:10:43Z")

</div>

This is a problem I experience quite a bit: Create a spec and outline all the examples (as not yet implemented) Write the body of a example Autospec runs spec -\> fail Make that example pass Autospec runs spec -\> pass A…

---

## [New RSpec methods to Object proposal: should\_all and should\_none](https://www.ruby-forum.com/t/new-rspec-methods-to-object-proposal-should-all-and-should-none/179994)

<div class="topic-metadata">

**Author:** [@dracko](https://www.ruby-forum.com/u/dracko)\
**Replies:** 10\
**Last updated:** [December 10, 2009, 12:42am UTC](https://www.ruby-forum.com/t/new-rspec-methods-to-object-proposal-should-all-and-should-none/179994 "2009-12-10T00:42:41Z")

</div>

I was thinking that it would be great to add 2 additional methods to Object: should\_all and should\_none. The idea is that we would be able to write tests like: \[@admin, @allowed\_user\].should\_all be\_allowed\_to\_visit(ur…

---

## [Can't run specs after upgrading gems... get 0 tests, 0 assertions](https://www.ruby-forum.com/t/cant-run-specs-after-upgrading-gems-get-0-tests-0-assertions/176403)

<div class="topic-metadata">

**Author:** [@ignu](https://www.ruby-forum.com/u/ignu)\
**Replies:** 10\
**Last updated:** [December 8, 2009, 11:12pm UTC](https://www.ruby-forum.com/t/cant-run-specs-after-upgrading-gems-get-0-tests-0-assertions/176403 "2009-12-08T23:12:45Z")

</div>

So after I updated all my gems, I started getting: /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active\_support/ dependencies.rb:105:in const\_missing': uninitialized constant Test::Unit::TestResult::TestResultFai…

---

## [Rspec, Mocha Expectations Not Met Bug?](https://www.ruby-forum.com/t/rspec-mocha-expectations-not-met-bug/179929)

<div class="topic-metadata">

**Author:** [@sweb](https://www.ruby-forum.com/u/sweb)\
**Replies:** 2\
**Last updated:** [December 8, 2009, 5:01pm UTC](https://www.ruby-forum.com/t/rspec-mocha-expectations-not-met-bug/179929 "2009-12-08T17:01:36Z")

</div>

Code and tests at, I have debugged this code and both destroy and email! are being called! However, rspec/mocha says that the two expectations at the bottom of these tests are not met: both tests fail. Any help wou…

---

## [Fwd: \[ANN\] Announcing MountainWest RubyConf 2010](https://www.ruby-forum.com/t/fwd-ann-announcing-mountainwest-rubyconf-2010/179923)

<div class="topic-metadata">

**Author:** [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Replies:** 0\
**Last updated:** [December 8, 2009, 5:59am UTC](https://www.ruby-forum.com/t/fwd-ann-announcing-mountainwest-rubyconf-2010/179923 "2009-12-08T05:59:41Z")

</div>

FYI, MWRC 2010 is accepting presentation proposals now (see link below). I’ve been to this conference every year and it has been great each time. If you have anything you would like to present please send in a propos…

---

## [\[rspec-rails\] spec vs. autospec](https://www.ruby-forum.com/t/rspec-rails-spec-vs-autospec/179830)

<div class="topic-metadata">

**Author:** [@ddancer](https://www.ruby-forum.com/u/ddancer)\
**Replies:** 2\
**Last updated:** [December 5, 2009, 3:33pm UTC](https://www.ruby-forum.com/t/rspec-rails-spec-vs-autospec/179830 "2009-12-05T15:33:22Z")

</div>

Hi All, any reason why some tests might pass via spec … and fail from within autospec? I have a rails app using AuthLogic and Declarative Authorization. I have tests that create user\_sessions and assign roles agains…

---

## [HTML array problem](https://www.ruby-forum.com/t/html-array-problem/179741)

<div class="topic-metadata">

**Author:** [@itsterry](https://www.ruby-forum.com/u/itsterry)\
**Replies:** 2\
**Last updated:** [December 4, 2009, 10:44am UTC](https://www.ruby-forum.com/t/html-array-problem/179741 "2009-12-04T10:44:59Z")

</div>

Hi all. Apologies if this is an easy one, but I’ve spent a while Googling and trying trial-and-error, and can’t find the solution. I’m trying to spec a controller. It accepts an HTML array, then processes items matchi…

---

## [Form\_for problem](https://www.ruby-forum.com/t/form-for-problem/179783)

<div class="topic-metadata">

**Author:** [@Brandon\_Goodin](https://www.ruby-forum.com/u/Brandon_Goodin)\
**Replies:** 1\
**Last updated:** [December 3, 2009, 10:10pm UTC](https://www.ruby-forum.com/t/form-for-problem/179783 "2009-12-03T22:10:32Z")

</div>

Greetings All, I have an interesting issue that I can only assume is me doing something dumb. ====== I have the following route defined map.namespace(:admin) do |admin| admin.resources :users end ====== I have a …

---

## [Surprising](https://www.ruby-forum.com/t/surprising/179575)

<div class="topic-metadata">

**Author:** [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Replies:** 5\
**Last updated:** [December 3, 2009, 4:52pm UTC](https://www.ruby-forum.com/t/surprising/179575 "2009-12-03T16:52:08Z")

</div>

It is somewhat surprising to me, as a newbie, to have to assert a.should be\_a(Hash) That extra space in there feels awkward. Suggestion: allow for constructs like a.should.be\_a(Hash) Thoughts? Much thanks. -r

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

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