# RSpec

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

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

---

## [Model spec for file upload with paperclip and fastercsv](https://www.ruby-forum.com/t/model-spec-for-file-upload-with-paperclip-and-fastercsv/178745)

<div class="topic-metadata">

**Author:** [@tick](https://www.ruby-forum.com/u/tick)\
**Replies:** 4\
**Last updated:** [November 11, 2009, 5:07pm UTC](https://www.ruby-forum.com/t/model-spec-for-file-upload-with-paperclip-and-fastercsv/178745 "2009-11-11T17:07:53Z")

</div>

I just started my ImportsController and was this was really the way to go: ////////import.rb///////////////// class Import \< ActiveRecord::Base has\_attached\_file :csv validates\_attachment\_presence :csv after\_save :…

---

## [Un-recognised routes that do exist, using namespaces & subdomain 	checking](https://www.ruby-forum.com/t/un-recognised-routes-that-do-exist-using-namespaces-subdomain-checking/178757)

<div class="topic-metadata">

**Author:** [@DEfusion](https://www.ruby-forum.com/u/DEfusion)\
**Replies:** 0\
**Last updated:** [November 10, 2009, 11:37pm UTC](https://www.ruby-forum.com/t/un-recognised-routes-that-do-exist-using-namespaces-subdomain-checking/178757 "2009-11-10T23:37:33Z")

</div>

Using RSpec 1.2.9 and Rails 2.3.4. RSpec is not matching some of my routes during controller testing when I have subdomain checking (courtesy of subdomain-fu) on namespaces. These routes appear in the rake routes outp…

---

## [This test should pass, but it does not :-/ Why?](https://www.ruby-forum.com/t/this-test-should-pass-but-it-does-not-why/178737)

<div class="topic-metadata">

**Author:** [@san](https://www.ruby-forum.com/u/san)\
**Replies:** 2\
**Last updated:** [November 10, 2009, 1:34pm UTC](https://www.ruby-forum.com/t/this-test-should-pass-but-it-does-not-why/178737 "2009-11-10T13:34:12Z")

</div>

---

## [\[BDD\] View specs and cucumber -- duplication of effort?](https://www.ruby-forum.com/t/bdd-view-specs-and-cucumber-duplication-of-effort/178101)

<div class="topic-metadata">

**Author:** [@nruth](https://www.ruby-forum.com/u/nruth)\
**Replies:** 17\
**Last updated:** [November 9, 2009, 10:11pm UTC](https://www.ruby-forum.com/t/bdd-view-specs-and-cucumber-duplication-of-effort/178101 "2009-11-09T22:11:07Z")

</div>

Hi Guys I’m going to put the cat amongst the pigeons here in the hope of some clarity falling out of the sky on me. My question is this: In a world with Cucumber what is the value of view specs? In the community (ra…

---

## [Re: "lambda Should Change" Behavior Failing When Checking Time](https://www.ruby-forum.com/t/re-lambda-should-change-behavior-failing-when-checking-time/178638)

<div class="topic-metadata">

**Author:** [@carakan](https://www.ruby-forum.com/u/carakan)\
**Replies:** 1\
**Last updated:** [November 9, 2009, 2:43am UTC](https://www.ruby-forum.com/t/re-lambda-should-change-behavior-failing-when-checking-time/178638 "2009-11-09T02:43:16Z")

</div>

Thanks to everyone that responded to my question. Here is what I ended up doing to make the spec pass: time\_now = Time.now Time.stub!(:now).and\_return(time\_now) lambda { @post.publish! }.should change(@post, :publis…

---

## ["lambda Should Change" Behavior Failing When Checking Time](https://www.ruby-forum.com/t/lambda-should-change-behavior-failing-when-checking-time/178613)

<div class="topic-metadata">

**Author:** [@carakan](https://www.ruby-forum.com/u/carakan)\
**Replies:** 3\
**Last updated:** [November 8, 2009, 3:31pm UTC](https://www.ruby-forum.com/t/lambda-should-change-behavior-failing-when-checking-time/178613 "2009-11-08T15:31:18Z")

</div>

Hello, I’m having a problem with RSpec when using the “lambda should change behavior”. This is happening in a Rails 2.3.4 app and I’m running the following in my test environment: ‘cucumber’, :version =\> ‘0.4.2’ ‘f…

---

## [Rake spec runs my spec:remote specs!](https://www.ruby-forum.com/t/rake-spec-runs-my-spec-remote-specs/178604)

<div class="topic-metadata">

**Author:** [@jko170](https://www.ruby-forum.com/u/jko170)\
**Replies:** 1\
**Last updated:** [November 8, 2009, 3:27am UTC](https://www.ruby-forum.com/t/rake-spec-runs-my-spec-remote-specs/178604 "2009-11-08T03:27:23Z")

</div>

In my spec folder, I have a “remote” directory, which contains my specs for live data transferring with an outside api. When I run rake spec, it runs the remote specs and I don’t want it to. Keep in mind there is NO l…

---

## [Should\_yield (is it needed?)](https://www.ruby-forum.com/t/should-yield-is-it-needed/178590)

<div class="topic-metadata">

**Author:** [@Martin\_Emde](https://www.ruby-forum.com/u/Martin_Emde)\
**Replies:** 0\
**Last updated:** [November 7, 2009, 7:53am UTC](https://www.ruby-forum.com/t/should-yield-is-it-needed/178590 "2009-11-07T07:53:23Z")

</div>

I have the code working for this but I wanted an opinion on making a patch. I sometimes have the need to expect that a method will yield a block it’s given. Usually this means something like this: yielded = false su…

---

## [\[WEBSITE\] runners.html page out of date](https://www.ruby-forum.com/t/website-runners-html-page-out-of-date/178531)

<div class="topic-metadata">

**Author:** [@conz](https://www.ruby-forum.com/u/conz)\
**Replies:** 2\
**Last updated:** [November 6, 2009, 9:27am UTC](https://www.ruby-forum.com/t/website-runners-html-page-out-of-date/178531 "2009-11-06T09:27:11Z")

</div>

Hi, the following page needs to be updated to use spork instead of spec\_server: http://rspec.info/rails/runners.html

---

## [\[Rails\] render\_to\_string in a controller fails under RSpec](https://www.ruby-forum.com/t/rails-render-to-string-in-a-controller-fails-under-rspec/178529)

<div class="topic-metadata">

**Author:** [@skizzybiz](https://www.ruby-forum.com/u/skizzybiz)\
**Replies:** 1\
**Last updated:** [November 6, 2009, 3:17am UTC](https://www.ruby-forum.com/t/rails-render-to-string-in-a-controller-fails-under-rspec/178529 "2009-11-06T03:17:50Z")

</div>

I’m using render\_to\_string in a controller to send some JSON data with an HTML fragment. Unfortunately, it seems that rspec-rails breaks that by intercepting render and simply recording that a render was called. Using…

---

## [Stub named\_scope with params](https://www.ruby-forum.com/t/stub-named-scope-with-params/178524)

<div class="topic-metadata">

**Author:** [@Elza\_Di\_Sirio](https://www.ruby-forum.com/u/Elza_Di_Sirio)\
**Replies:** 1\
**Last updated:** [November 5, 2009, 11:32pm UTC](https://www.ruby-forum.com/t/stub-named-scope-with-params/178524 "2009-11-05T23:32:28Z")

</div>

I need some help to stub this method of my controller @users = User.accessible\_by(current\_user).paginate( :conditions =\> conditions.to\_sql, :include =\> :user\_channels, :order =\> build\_sort\_conditions(:name, …

---

## [\[Cucumber\] How Do You Use Cucumber?](https://www.ruby-forum.com/t/cucumber-how-do-you-use-cucumber/159345)

<div class="topic-metadata">

**Author:** [@cwd](https://www.ruby-forum.com/u/cwd)\
**Replies:** 2\
**Last updated:** [November 5, 2009, 10:49am UTC](https://www.ruby-forum.com/t/cucumber-how-do-you-use-cucumber/159345 "2009-11-05T10:49:11Z")

</div>

I’m using Cucumber on my current project and it’s causing me to wonder what other people’s experience has been. I’ve read discussions about speeding up Cucumber and a basically everything else I can. Also, the rSpec b…

---

## [Question](https://www.ruby-forum.com/t/question/178454)

<div class="topic-metadata">

**Author:** [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Replies:** 1\
**Last updated:** [November 5, 2009, 6:27am UTC](https://www.ruby-forum.com/t/question/178454 "2009-11-05T06:27:29Z")

</div>

Perhaps it would be useful to do some parsing of the messages… it “should raise an Exception if record is invalid” do end expects that block to raise Thoughts? -r

---

## [Some tiny but usefill fix](https://www.ruby-forum.com/t/some-tiny-but-usefill-fix/178466)

<div class="topic-metadata">

**Author:** [@Dmitri\_Koulikoff](https://www.ruby-forum.com/u/Dmitri_Koulikoff)\
**Replies:** 0\
**Last updated:** [November 5, 2009, 12:45am UTC](https://www.ruby-forum.com/t/some-tiny-but-usefill-fix/178466 "2009-11-05T00:45:39Z")

</div>

Dear David! I use rpec for the several years and almost in every prject I apply the following patch. Today I thought that maybe you will accept it so that others may have it’s benefit. diff --git a/vendor/plugins/…

---

## [Unable to build gem](https://www.ruby-forum.com/t/unable-to-build-gem/178448)

<div class="topic-metadata">

**Author:** [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Replies:** 1\
**Last updated:** [November 5, 2009, 12:15am UTC](https://www.ruby-forum.com/t/unable-to-build-gem/178448 "2009-11-05T00:15:47Z")

</div>

Is the following expected? C:\\dev\\ruby\\downloads\\rspec\>rake gem (in C:/dev/ruby/downloads/rspec) in rdoc 2.4.3 rake aborted! Don’t know how to build task ‘lib/spec/matchers/extensions/ instance\_exec.rb’ (See full …

---

## [\[RSpec\] Testing "validates\_uniquesness of"](https://www.ruby-forum.com/t/rspec-testing-validates-uniquesness-of/178462)

<div class="topic-metadata">

**Author:** [@Joseph.DelCioppio](https://www.ruby-forum.com/u/Joseph.DelCioppio)\
**Replies:** 1\
**Last updated:** [November 5, 2009, 12:15am UTC](https://www.ruby-forum.com/t/rspec-testing-validates-uniquesness-of/178462 "2009-11-05T00:15:47Z")

</div>

Guys, Getting used to doing BDD, and in my current project I’m trying to spec out my model, and in particular the fact that my model must validate that one of its fields are unique; in this case, the customer’s email…

---

## [Be\_none and be\_any don't seem to work properly](https://www.ruby-forum.com/t/be-none-and-be-any-dont-seem-to-work-properly/177581)

<div class="topic-metadata">

**Author:** [@iain](https://www.ruby-forum.com/u/iain)\
**Replies:** 3\
**Last updated:** [November 4, 2009, 4:26pm UTC](https://www.ruby-forum.com/t/be-none-and-be-any-dont-seem-to-work-properly/177581 "2009-11-04T16:26:56Z")

</div>

Hi all! I’m testing some named scopes. I use be\_all(&:some\_predicate) to test if all the elements in the collection are valid, which works, but when I try to test the inverse, it fails. You can see the complete code …

---

## [ThreadError on click\_button](https://www.ruby-forum.com/t/threaderror-on-click-button/178210)

<div class="topic-metadata">

**Author:** [@comtux](https://www.ruby-forum.com/u/comtux)\
**Replies:** 1\
**Last updated:** [November 3, 2009, 9:27pm UTC](https://www.ruby-forum.com/t/threaderror-on-click-button/178210 "2009-11-03T21:27:24Z")

</div>

I get the following error ThreadError in ‘Managing InvoicePayments viewing index lists all InvoicePayments’ stopping only thread note: use sleep to stop forever (eval):2:in \`click\_button’ when running rake spec usi…

---

## [Cucumber table diff haml problem](https://www.ruby-forum.com/t/cucumber-table-diff-haml-problem/178358)

<div class="topic-metadata">

**Author:** [@tick](https://www.ruby-forum.com/u/tick)\
**Replies:** 2\
**Last updated:** [November 3, 2009, 2:12pm UTC](https://www.ruby-forum.com/t/cucumber-table-diff-haml-problem/178358 "2009-11-03T14:12:46Z")

</div>

Inspired by the latest railscast I tried to do some table diffing: But my problem is that the haml generated table does not produce the same html as the erb generated one. And table diffing seems to depend on a rather…

---

## [Spec runner](https://www.ruby-forum.com/t/spec-runner/178319)

<div class="topic-metadata">

**Author:** [@brianspaid](https://www.ruby-forum.com/u/brianspaid)\
**Replies:** 2\
**Last updated:** [November 2, 2009, 11:44pm UTC](https://www.ruby-forum.com/t/spec-runner/178319 "2009-11-02T23:44:50Z")

</div>

How do I just invoke the spec runner through code? I have a watchr file that I want to run the specs when files change, but I am shelling out right now, so i though i’d speed it up by keeping it ruby. I tried digging…

---

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

<div class="topic-metadata">

**Author:** [@brianspaid](https://www.ruby-forum.com/u/brianspaid)\
**Replies:** 2\
**Last updated:** [November 2, 2009, 9:09pm UTC](https://www.ruby-forum.com/t/undefined-method-get/178239 "2009-11-02T21:09:44Z")

</div>

So here’s the deal. Was using rack-test in rspec, cause I like passing paths instead of an action name, but it doesn’t have access to the session, flash, cookies, etc. So I tried to switch to normal rspec and here’s w…

---

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

<div class="topic-metadata">

**Author:** [@tornado](https://www.ruby-forum.com/u/tornado)\
**Replies:** 2\
**Last updated:** [November 2, 2009, 4:58pm UTC](https://www.ruby-forum.com/t/problem-with-before-filters/226055 "2009-11-02T16:58:38Z")

</div>

Following is the scenario. describe BbPostsController, “POST Create” do context “Admin” do fixtures :users, :bb\_posts, :user\_channels, :channels, :channel\_features it “should save post” do login\_as(:amit) # Added …

---

## [Webrat, Rails and controller sessions](https://www.ruby-forum.com/t/webrat-rails-and-controller-sessions/178185)

<div class="topic-metadata">

**Author:** [@dracko](https://www.ruby-forum.com/u/dracko)\
**Replies:** 0\
**Last updated:** [October 30, 2009, 10:42am UTC](https://www.ruby-forum.com/t/webrat-rails-and-controller-sessions/178185 "2009-10-30T10:42:43Z")

</div>

When I ran ‘rake spec’, it generated a spec\_helper.rb with the following line: require ‘webrat/integrations/rspec-rails’ It seems that this file changed to webrat/rspec-rails on last webrat gem. But changing to “req…

---

## [At\_exit in spec file?](https://www.ruby-forum.com/t/at-exit-in-spec-file/178058)

<div class="topic-metadata">

**Author:** [@student](https://www.ruby-forum.com/u/student)\
**Replies:** 13\
**Last updated:** [October 29, 2009, 8:18pm UTC](https://www.ruby-forum.com/t/at-exit-in-spec-file/178058 "2009-10-29T20:18:10Z")

</div>

I need to perform some work (shutdown mysql servers & delete their data directories) at the end of my tests. Naturally, I would like to use at\_exit. HOWEVER, when I do, the spec file gets loaded twice (and the tests…

---

## [Cyclomatic complexity](https://www.ruby-forum.com/t/cyclomatic-complexity/178143)

<div class="topic-metadata">

**Author:** [@Elza\_M](https://www.ruby-forum.com/u/Elza_M)\
**Replies:** 2\
**Last updated:** [October 29, 2009, 6:38pm UTC](https://www.ruby-forum.com/t/cyclomatic-complexity/178143 "2009-10-29T18:38:04Z")

</div>

Hi, Someone can help me? I am using Rspec to create tests and Rcov to have some code coverage information, however my client would like to have some information on cyclomatic complexity. Can I use any option of Rcov t…

---

## [HOWTO: Background tasks during test (ugly)](https://www.ruby-forum.com/t/howto-background-tasks-during-test-ugly/178103)

<div class="topic-metadata">

**Author:** [@student](https://www.ruby-forum.com/u/student)\
**Replies:** 5\
**Last updated:** [October 29, 2009, 5:40pm UTC](https://www.ruby-forum.com/t/howto-background-tasks-during-test-ugly/178103 "2009-10-29T17:40:42Z")

</div>

I am writing a script that reads connection information from a config file, and based, on what it finds, connects to multiple mysql servers and performs tasks. To test this script, I need to set up test servers, but …

---

## [Problem with should\_receive in controller spec](https://www.ruby-forum.com/t/problem-with-should-receive-in-controller-spec/178115)

<div class="topic-metadata">

**Author:** [@tornado](https://www.ruby-forum.com/u/tornado)\
**Replies:** 1\
**Last updated:** [October 29, 2009, 2:31pm UTC](https://www.ruby-forum.com/t/problem-with-should-receive-in-controller-spec/178115 "2009-10-29T14:31:35Z")

</div>

I am trying to write controller spec but i am getting some problem. Following is the controller code: def create @bb\_post = @feature.posts.new( params\[ :bb\_post \] ) if @bb\_post.save flash\[ :notice \] = ‘Blog post was…

---

## [Spec failing to run specs when spec.opts is present on 1.2.9](https://www.ruby-forum.com/t/spec-failing-to-run-specs-when-spec-opts-is-present-on-1-2-9/177722)

<div class="topic-metadata">

**Author:** [@paul](https://www.ruby-forum.com/u/paul)\
**Replies:** 4\
**Last updated:** [October 29, 2009, 9:31am UTC](https://www.ruby-forum.com/t/spec-failing-to-run-specs-when-spec-opts-is-present-on-1-2-9/177722 "2009-10-29T09:31:54Z")

</div>

Hi I ran across the following when running spec on an old merb app. $ cat spec/spec.opts $ spec spec/models/topic\_spec.rb Options written to spec/spec.opts. You can now use these options with: spec --options spec/sp…

---

## [Have\_same\_elements\_of proposal](https://www.ruby-forum.com/t/have-same-elements-of-proposal/178091)

<div class="topic-metadata">

**Author:** [@dracko](https://www.ruby-forum.com/u/dracko)\
**Replies:** 2\
**Last updated:** [October 29, 2009, 3:05am UTC](https://www.ruby-forum.com/t/have-same-elements-of-proposal/178091 "2009-10-29T03:05:01Z")

</div>

How about having this matcher along the default available matchers? require ‘set’ Spec::Matchers.define :have\_same\_elements\_of do |expected| match do |actual| expected.to\_set == actual.to\_set end end Example: \[1,…

---

## [Spec\_server not reloading model classes](https://www.ruby-forum.com/t/spec-server-not-reloading-model-classes/164169)

<div class="topic-metadata">

**Author:** [@arvliet](https://www.ruby-forum.com/u/arvliet)\
**Replies:** 24\
**Last updated:** [October 28, 2009, 10:54pm UTC](https://www.ruby-forum.com/t/spec-server-not-reloading-model-classes/164169 "2009-10-28T22:54:09Z")

</div>

Hi, I’m using the latest rspec-rails 1.2.2 with rails 2.3.2, and I’m trying to get it to work with spec\_server. This is on Mac/Leopard, with the stock ruby, all gems installed in /Library/Ruby/. I have configured: c…

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

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