# RSpec

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

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

---

## [Scaffold views spec failing](https://www.ruby-forum.com/t/scaffold-views-spec-failing/186559)

<div class="topic-metadata">

**Author:** [@ben\_rooney](https://www.ruby-forum.com/u/ben_rooney)\
**Replies:** 0\
**Last updated:** [April 8, 2010, 10:36pm UTC](https://www.ruby-forum.com/t/scaffold-views-spec-failing/186559 "2010-04-08T22:36:06Z")

</div>

Obviously my noooooob question was embarrassingly noob - so I was forced to actually do some work and answer my own questions. The answer was that I had to stub out the association - natch… before(:each) do assigns\[:…

---

## [Best way to match several attributes of an object?](https://www.ruby-forum.com/t/best-way-to-match-several-attributes-of-an-object/186032)

<div class="topic-metadata">

**Author:** [@George](https://www.ruby-forum.com/u/George)\
**Replies:** 4\
**Last updated:** [April 8, 2010, 9:11am UTC](https://www.ruby-forum.com/t/best-way-to-match-several-attributes-of-an-object/186032 "2010-04-08T09:11:00Z")

</div>

When you need to check several properties of an object, what is the best way to match them all? I’m using the ‘satisfy’ matcher at the moment but perhaps there’s a better way than this: flight.should satisfy { |f| f…

---

## [Rspec and Selenium Question](https://www.ruby-forum.com/t/rspec-and-selenium-question/186469)

<div class="topic-metadata">

**Author:** [@Cid\_D](https://www.ruby-forum.com/u/Cid_D)\
**Replies:** 1\
**Last updated:** [April 7, 2010, 7:12pm UTC](https://www.ruby-forum.com/t/rspec-and-selenium-question/186469 "2010-04-07T19:12:09Z")

</div>

So I have created a number of rspec test using the selenium ruby client. The problem is I can not figure out a easy way to say run all the test I have on each browser I want to support. The current work around I have …

---

## [NullDB has a new maintainer](https://www.ruby-forum.com/t/nulldb-has-a-new-maintainer/186435)

<div class="topic-metadata">

**Author:** [@avdi](https://www.ruby-forum.com/u/avdi)\
**Replies:** 0\
**Last updated:** [April 7, 2010, 6:46am UTC](https://www.ruby-forum.com/t/nulldb-has-a-new-maintainer/186435 "2010-04-07T06:46:54Z")

</div>

As also reported on my blog \[NullDB has a new maintainer - avdi.codes\], Myron M. is now the official maintainer of NullDB. I thought I’d report it here as well since some of the list participants have expressed inter…

---

## [Passing get request parameters in an rspec test](https://www.ruby-forum.com/t/passing-get-request-parameters-in-an-rspec-test/186233)

<div class="topic-metadata">

**Author:** [@Matt\_Kolenda](https://www.ruby-forum.com/u/Matt_Kolenda)\
**Replies:** 3\
**Last updated:** [April 7, 2010, 6:00am UTC](https://www.ruby-forum.com/t/passing-get-request-parameters-in-an-rspec-test/186233 "2010-04-07T06:00:05Z")

</div>

Hello Please forgive my noobness to rspec. I have a controller method that inspects the params\[:id\] object and renders a view that depends on the existence of that :id. I want to ensure that the view is rendered in …

---

## [Scaffold views spec failing](https://www.ruby-forum.com/t/scaffold-views-spec-failing/186427)

<div class="topic-metadata">

**Author:** [@ben\_rooney](https://www.ruby-forum.com/u/ben_rooney)\
**Replies:** 0\
**Last updated:** [April 7, 2010, 1:46am UTC](https://www.ruby-forum.com/t/scaffold-views-spec-failing/186427 "2010-04-07T01:46:41Z")

</div>

Forgive a very nooooob question. I am trying to get my head around all of this. Have a couple of simple models (weird spelling of tipe was in case type was a reserved word …). They were all generated with the rspec\_s…

---

## [Can I use mocking in this way?](https://www.ruby-forum.com/t/can-i-use-mocking-in-this-way/186293)

<div class="topic-metadata">

**Author:** [@Vojto\_R](https://www.ruby-forum.com/u/Vojto_R)\
**Replies:** 8\
**Last updated:** [April 6, 2010, 4:55am UTC](https://www.ruby-forum.com/t/can-i-use-mocking-in-this-way/186293 "2010-04-06T04:55:36Z")

</div>

Hello RSpec users! I have one abstract class and a few classes that inherit from that abstract one. I’d like to test if my abstract class works with RSpec, but I can’t test directly abstract class (or can I?) and I …

---

## [Stub a class and instances](https://www.ruby-forum.com/t/stub-a-class-and-instances/186330)

<div class="topic-metadata">

**Author:** [@mhfs](https://www.ruby-forum.com/u/mhfs)\
**Replies:** 1\
**Last updated:** [April 5, 2010, 2:52pm UTC](https://www.ruby-forum.com/t/stub-a-class-and-instances/186330 "2010-04-05T14:52:10Z")

</div>

For example, I have this scenario where a Directory model will only save if it can connect to the LDAP server. In a test I’m writting, though, connecting to the LDAP server is not relevant, so I tried doing this: con…

---

## [Help me refactor a step for finding href in specific link](https://www.ruby-forum.com/t/help-me-refactor-a-step-for-finding-href-in-specific-link/186133)

<div class="topic-metadata">

**Author:** [@oreng](https://www.ruby-forum.com/u/oreng)\
**Replies:** 2\
**Last updated:** [April 2, 2010, 8:44pm UTC](https://www.ruby-forum.com/t/help-me-refactor-a-step-for-finding-href-in-specific-link/186133 "2010-04-02T20:44:07Z")

</div>

I want to verify the href is correct: Website my step in the cucumber file: And the “website” class should have “www.happyhour.com” the step definition: Then /^the “(\[^"\])" class should have "(\[^"\])”$/ do |lin…

---

## [Setting partial stub for just one value and letting obj handle the rest](https://www.ruby-forum.com/t/setting-partial-stub-for-just-one-value-and-letting-obj-handle-the-rest/186190)

<div class="topic-metadata">

**Author:** [@drewB](https://www.ruby-forum.com/u/drewB)\
**Replies:** 6\
**Last updated:** [April 2, 2010, 3:37am UTC](https://www.ruby-forum.com/t/setting-partial-stub-for-just-one-value-and-letting-obj-handle-the-rest/186190 "2010-04-02T03:37:00Z")

</div>

Occasionally, I find myself in a situation where I want to have a mock obj returned if a method is called with a particular argument but handled normally otherwise. For example, lets say I have a Model named User and…

---

## [Rspec and resque - tips?](https://www.ruby-forum.com/t/rspec-and-resque-tips/186196)

<div class="topic-metadata">

**Author:** [@Matthew\_Van\_Horn](https://www.ruby-forum.com/u/Matthew_Van_Horn)\
**Replies:** 0\
**Last updated:** [April 1, 2010, 11:52pm UTC](https://www.ruby-forum.com/t/rspec-and-resque-tips/186196 "2010-04-01T23:52:12Z")

</div>

I’ve just gotten started refactoring my app to use Resque/Redis to do things like email and order capture asynchronously. I’m wondering if anyone has any tips on how to test my job classes, and how to run integration …

---

## [Matcher for bad request](https://www.ruby-forum.com/t/matcher-for-bad-request/186149)

<div class="topic-metadata">

**Author:** [@drewB](https://www.ruby-forum.com/u/drewB)\
**Replies:** 2\
**Last updated:** [April 1, 2010, 8:05pm UTC](https://www.ruby-forum.com/t/matcher-for-bad-request/186149 "2010-04-01T20:05:39Z")

</div>

Is there a built-in matcher for a response returning a bad request (e.g. header code in the 400s)? For example, “response.should be\_bad\_request”.

---

## [Broken pipe error in progress\_bar\_formatter when autotest detects changes and try to run the specs a](https://www.ruby-forum.com/t/broken-pipe-error-in-progress-bar-formatter-when-autotest-detects-changes-and-try-to-run-the-specs-a/186178)

<div class="topic-metadata">

**Author:** [@eagoweb](https://www.ruby-forum.com/u/eagoweb)\
**Replies:** 0\
**Last updated:** [April 1, 2010, 5:48pm UTC](https://www.ruby-forum.com/t/broken-pipe-error-in-progress-bar-formatter-when-autotest-detects-changes-and-try-to-run-the-specs-a/186178 "2010-04-01T17:48:06Z")

</div>

Hi, I have a Broken pipe error in progress\_bar\_formatter when autotest detects changes and try to run the specs again: 508 $ autospec loading autotest/rspec /usr/bin/ruby1.8 /usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/…

---

## [Subject in the before block?](https://www.ruby-forum.com/t/subject-in-the-before-block/186129)

<div class="topic-metadata">

**Author:** [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Replies:** 5\
**Last updated:** [April 1, 2010, 5:00pm UTC](https://www.ruby-forum.com/t/subject-in-the-before-block/186129 "2010-04-01T17:00:42Z")

</div>

Is there a reason why I cannot access the subject in the before block? It seems to me that anything that I have access to in the it blocks should also be accessible in the before block.

---

## [Autotest - garbled output](https://www.ruby-forum.com/t/autotest-garbled-output/186030)

<div class="topic-metadata">

**Author:** [@m3oliver](https://www.ruby-forum.com/u/m3oliver)\
**Replies:** 5\
**Last updated:** [March 31, 2010, 2:42pm UTC](https://www.ruby-forum.com/t/autotest-garbled-output/186030 "2010-03-31T14:42:32Z")

</div>

I recently reinstalled my gems for autotest, and since then I have unintelligible output coming from autotest like this (note everything after unit\_diff -u) loading autotest/rails /System/Library/Frameworks/Ruby.fram…

---

## [Spork](https://www.ruby-forum.com/t/spork/185969)

<div class="topic-metadata">

**Author:** [@Ashley\_M](https://www.ruby-forum.com/u/Ashley_M)\
**Replies:** 4\
**Last updated:** [March 31, 2010, 11:12am UTC](https://www.ruby-forum.com/t/spork/185969 "2010-03-31T11:12:59Z")

</div>

Hi Hopefully I’ll get chance to finish Spork integration with RSpec 2 this weekend. I’ve got two questions… (1) What’s the best way to merge my changes back in? My shockingly bad Git-fu has made it impossible to re…

---

## [Gem tutorials / setting up rspec in a gem](https://www.ruby-forum.com/t/gem-tutorials-setting-up-rspec-in-a-gem/186009)

<div class="topic-metadata">

**Author:** [@ramontayag](https://www.ruby-forum.com/u/ramontayag)\
**Replies:** 5\
**Last updated:** [March 31, 2010, 4:30am UTC](https://www.ruby-forum.com/t/gem-tutorials-setting-up-rspec-in-a-gem/186009 "2010-03-31T04:30:23Z")

</div>

Hey everyone! A few days ago, I tried my hand at creating a gem. I’ve been putting it off for a long time because of the lack of documentation (or the lack of my Googling skills). When I search how to create gems wit…

---

## [Describe blocks without before(:all) / after(:all)](https://www.ruby-forum.com/t/describe-blocks-without-before-all-after-all/185990)

<div class="topic-metadata">

**Author:** [@jsoho](https://www.ruby-forum.com/u/jsoho)\
**Replies:** 1\
**Last updated:** [March 30, 2010, 6:30am UTC](https://www.ruby-forum.com/t/describe-blocks-without-before-all-after-all/185990 "2010-03-30T06:30:17Z")

</div>

Hi All, We have many specs like the pattern given below. The problem is that it’s slow, because each inner context block will execute the before(:all) in the outer describe block. Is there a way to setup an inner co…

---

## [Undefined method](https://www.ruby-forum.com/t/undefined-method/185982)

<div class="topic-metadata">

**Author:** [@kojilab](https://www.ruby-forum.com/u/kojilab)\
**Replies:** 0\
**Last updated:** [March 30, 2010, 4:14am UTC](https://www.ruby-forum.com/t/undefined-method/185982 "2010-03-30T04:14:28Z")

</div>

Hi My test has the following line Account.stub(:find\_by\_slug\_and\_owner\_id).with(“my-account”, ‘1’).and\_return(mock\_account) In my model, I have def self.find\_by\_slug\_and\_owner\_id(slug, owner\_id) \[code\] end But I …

---

## [View spec template.base\_path](https://www.ruby-forum.com/t/view-spec-template-base-path/185769)

<div class="topic-metadata">

**Author:** [@pkoebbe](https://www.ruby-forum.com/u/pkoebbe)\
**Replies:** 2\
**Last updated:** [March 27, 2010, 12:15am UTC](https://www.ruby-forum.com/t/view-spec-template-base-path/185769 "2010-03-27T00:15:05Z")

</div>

I have a helper method def partial\_path\_for(partial, options = {}) base\_path = options\[:base\_path\] || self.template.base\_path “\_partials/#{base\_path}/#{partial}” end and use it in a template (haml) like = render :p…

---

## [Trivial controller spec fail](https://www.ruby-forum.com/t/trivial-controller-spec-fail/185736)

<div class="topic-metadata">

**Author:** [@rodrigo\_benenson](https://www.ruby-forum.com/u/rodrigo_benenson)\
**Replies:** 3\
**Last updated:** [March 26, 2010, 11:45pm UTC](https://www.ruby-forum.com/t/trivial-controller-spec-fail/185736 "2010-03-26T23:45:14Z")

</div>

Hello RSpec community ! I’m a Ruby on Rails newby trying to get my first application running. I already got some of the website running and now I’m writting the tests to verify that everything works as expected and th…

---

## [RSpec 2.0.0.beta.4 stubbing rails controller method issue](https://www.ruby-forum.com/t/rspec-2-0-0-beta-4-stubbing-rails-controller-method-issue/185802)

<div class="topic-metadata">

**Author:** [@DEfusion](https://www.ruby-forum.com/u/DEfusion)\
**Replies:** 1\
**Last updated:** [March 26, 2010, 12:48pm UTC](https://www.ruby-forum.com/t/rspec-2-0-0-beta-4-stubbing-rails-controller-method-issue/185802 "2010-03-26T12:48:25Z")

</div>

I’m trying to stub a controller method using RSpec 2.0.0.beta.4 and Rails 3 and whenever I attempt to do it I get an error, e.g. controller.stub!(:current\_host).and\_return(Factory.build(:host)) post :create Results i…

---

## [Specing Ruby Game Development?](https://www.ruby-forum.com/t/specing-ruby-game-development/185705)

<div class="topic-metadata">

**Author:** [@churp](https://www.ruby-forum.com/u/churp)\
**Replies:** 2\
**Last updated:** [March 25, 2010, 4:31pm UTC](https://www.ruby-forum.com/t/specing-ruby-game-development/185705 "2010-03-25T16:31:32Z")

</div>

HI Folks, Roll Call for anyone using Rspec for Ruby Game Development (Rubygame, GOSU, TkRuby, etc.) ??? I’m having trouble finding the latest-and-greatest with Google searches. Happy Gaming!

---

## [How to stub a has\_many relationship in Rails 2.3.5](https://www.ruby-forum.com/t/how-to-stub-a-has-many-relationship-in-rails-2-3-5/185684)

<div class="topic-metadata">

**Author:** [@killswitchcollectiv](https://www.ruby-forum.com/u/killswitchcollectiv)\
**Replies:** 1\
**Last updated:** [March 25, 2010, 1:24pm UTC](https://www.ruby-forum.com/t/how-to-stub-a-has-many-relationship-in-rails-2-3-5/185684 "2010-03-25T13:24:46Z")

</div>

We have a test that has been working find until we upgraded to rails 2.3.5. I’m not too familiar with mocks/stubs so maybe there is an easy solution. Here is a simple example of our scenario. Class Person \< ActiveRe…

---

## [Mock "Consent\_6335" received unexpected message :marked\_for\_destruction? with (no args)](https://www.ruby-forum.com/t/mock-consent-6335-received-unexpected-message-marked-for-destruction-with-no-args/185700)

<div class="topic-metadata">

**Author:** [@thoen](https://www.ruby-forum.com/u/thoen)\
**Replies:** 2\
**Last updated:** [March 25, 2010, 1:00pm UTC](https://www.ruby-forum.com/t/mock-consent-6335-received-unexpected-message-marked-for-destruction-with-no-args/185700 "2010-03-25T13:00:12Z")

</div>

I have a mock object (Person) that is associated with another object (my\_object) through a belongs\_to association. When I check whether my\_object is valid (my\_object.should be\_valid), I am getting an error like the fo…

---

## [Mock Global method](https://www.ruby-forum.com/t/mock-global-method/185653)

<div class="topic-metadata">

**Author:** [@garren](https://www.ruby-forum.com/u/garren)\
**Replies:** 4\
**Last updated:** [March 25, 2010, 5:57am UTC](https://www.ruby-forum.com/t/mock-global-method/185653 "2010-03-25T05:57:01Z")

</div>

Hi All, I’m very new to ruby and mocking a dynamic language. I would like to mock a helper method in Sinatra. So an example is this: helper do def my\_helper\_method puts “Should do something useful here…” end end H…

---

## [Continuing on my quest to learn rspec](https://www.ruby-forum.com/t/continuing-on-my-quest-to-learn-rspec/185626)

<div class="topic-metadata">

**Author:** [@cghost](https://www.ruby-forum.com/u/cghost)\
**Replies:** 2\
**Last updated:** [March 24, 2010, 9:52am UTC](https://www.ruby-forum.com/t/continuing-on-my-quest-to-learn-rspec/185626 "2010-03-24T09:52:22Z")

</div>

Ok, So… My first attempt at specing a method in my photo model didn’t go so well… Both of these tests are failing, and I am not even sure if I am structuring this anywhere near correct or not… In other words… H…

---

## [Link to current documentation](https://www.ruby-forum.com/t/link-to-current-documentation/185639)

<div class="topic-metadata">

**Author:** [@pkoebbe](https://www.ruby-forum.com/u/pkoebbe)\
**Replies:** 0\
**Last updated:** [March 23, 2010, 11:12pm UTC](https://www.ruby-forum.com/t/link-to-current-documentation/185639 "2010-03-23T23:12:40Z")

</div>

I bookmark the RSpec documentation like http://rspec.rubyforge.org/rspec-rails/1.3.2/ I was wondering if the maintainer of the site (David?) would be willing to create “current” link that would redirect to the appropr…

---

## [Lots of nil problems!](https://www.ruby-forum.com/t/lots-of-nil-problems/185444)

<div class="topic-metadata">

**Author:** [@patrick99e99](https://www.ruby-forum.com/u/patrick99e99)\
**Replies:** 14\
**Last updated:** [March 22, 2010, 8:55pm UTC](https://www.ruby-forum.com/t/lots-of-nil-problems/185444 "2010-03-22T20:55:43Z")

</div>

Hi, I have this in my controller action: from\_address = Setting.find\_by\_name(“shipping\_from\_address”).address and my spec fails: NoMethodError in ‘Admin::ShippingLabelsController should render a pdf file’ undefined…

---

## [Autotest, rails and view specs](https://www.ruby-forum.com/t/autotest-rails-and-view-specs/185548)

<div class="topic-metadata">

**Author:** [@brunopires](https://www.ruby-forum.com/u/brunopires)\
**Replies:** 0\
**Last updated:** [March 22, 2010, 4:41pm UTC](https://www.ruby-forum.com/t/autotest-rails-and-view-specs/185548 "2010-03-22T16:41:34Z")

</div>

Hi, I’ve read in \[1\] that autotest “does not work with view specs for rails versions \< 2.3”, but I didn’t find a reason for that. Is it just a bug? – \[\]'s Bruno \[1\] http://wiki.github.com/dchelimsky/rspec/spork-aut…

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

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