# RSpec

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

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

---

## [Constant resolution fails in describes inside of modules using rspec 2 on ruby 1.9.1](https://www.ruby-forum.com/t/constant-resolution-fails-in-describes-inside-of-modules-using-rspec-2-on-ruby-1-9-1/198595)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 2\
**Last updated:** [November 4, 2010, 6:52pm UTC](https://www.ruby-forum.com/t/constant-resolution-fails-in-describes-inside-of-modules-using-rspec-2-on-ruby-1-9-1/198595 "2010-11-04T18:52:46Z")

</div>

Hi, I’ve converted a couple of my smaller libraries’ spec suites to rspec 2 with no trouble. (I’m enjoying the new version – thanks to all involved.) I’m trying to convert one a larger suite now and I’ve run into t…

---

## [Cucumber - before scenario outline, but just one time](https://www.ruby-forum.com/t/cucumber-before-scenario-outline-but-just-one-time/198576)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 2\
**Last updated:** [November 3, 2010, 8:57pm UTC](https://www.ruby-forum.com/t/cucumber-before-scenario-outline-but-just-one-time/198576 "2010-11-03T20:57:32Z")

</div>

If I have a Background section and a Scenario Outline, the Background runs once before each example in the scenario outline. Is there a hook that before the Scenario Outline, but not before each example? Jon

---

## [Rspec-2 around/before(:all) hooks](https://www.ruby-forum.com/t/rspec-2-around-before-all-hooks/198509)

<div class="topic-metadata">

**Author:** [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Replies:** 3\
**Last updated:** [November 3, 2010, 7:22pm UTC](https://www.ruby-forum.com/t/rspec-2-around-before-all-hooks/198509 "2010-11-03T19:22:40Z")

</div>

Rspec-2 around/before(:all) hooks I’m trying to create several model instances before all of our tests are run. I’m having trouble defining the behavior in my Rspec.configure block. I’ve tried before(:all) and aroun…

---

## [Rake task for focused examples](https://www.ruby-forum.com/t/rake-task-for-focused-examples/198543)

<div class="topic-metadata">

**Author:** [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Replies:** 3\
**Last updated:** [November 3, 2010, 4:44pm UTC](https://www.ruby-forum.com/t/rake-task-for-focused-examples/198543 "2010-11-03T16:44:43Z")

</div>

Hi, Is it possible to make a rake task to run examples with a certain filter on? In this case I want to run rake spec:focused and run only the examples with :focus =\> true. Toni

---

## [Hiding Test-Unit Generators?](https://www.ruby-forum.com/t/hiding-test-unit-generators/198540)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 1\
**Last updated:** [November 3, 2010, 2:15pm UTC](https://www.ruby-forum.com/t/hiding-test-unit-generators/198540 "2010-11-03T14:15:05Z")

</div>

Just curious if this was ever fixed?? On Jul 13, 2010, at 8:49 PM, Arco wrote: In a recent blog post, David wrote: Because RSpec is the test framework of record, Rails doesnt know to hide the test\_unit generators.…

---

## [Not sure why let is not doing the same thing as traditional test](https://www.ruby-forum.com/t/not-sure-why-let-is-not-doing-the-same-thing-as-traditional-test/198533)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 2\
**Last updated:** [November 3, 2010, 12:01pm UTC](https://www.ruby-forum.com/t/not-sure-why-let-is-not-doing-the-same-thing-as-traditional-test/198533 "2010-11-03T12:01:50Z")

</div>

Here is my test which passes. before do @page = Factory(:page) @note = Factory(:note, :page =\> @page, :title =\> ‘super cool’) end it ‘has size 1’ do @page.notes.size.should == 1 end I read rspec book and wanted t…

---

## [Testing attr\_accessible (and/or attr\_protected)](https://www.ruby-forum.com/t/testing-attr-accessible-and-or-attr-protected/198471)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 7\
**Last updated:** [November 2, 2010, 5:56pm UTC](https://www.ruby-forum.com/t/testing-attr-accessible-and-or-attr-protected/198471 "2010-11-02T17:56:13Z")

</div>

I’ve been puzzling over how to test that attr\_accessible has been set for the correct columns; but the tests I’ve come up with so far seem to fail to fail when I expect. I came across this old message from this list: …

---

## [Issue with AR::Base descendants with certain argument](https://www.ruby-forum.com/t/issue-with-ar-base-descendants-with-certain-argument/198240)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 10\
**Last updated:** [November 1, 2010, 8:56pm UTC](https://www.ruby-forum.com/t/issue-with-ar-base-descendants-with-certain-argument/198240 "2010-11-01T20:56:33Z")

</div>

Hi! I am trying to upgrade rspec-rails to 1.3.3, and one of my specs fails. In before :each I stub finder method like this: Payment.stub!(:find\_by\_id).with(@payment.id.to\_s).and\_return @payment Payment class is deriv…

---

## [How do I figure out which (wrong) file rspec is loading?](https://www.ruby-forum.com/t/how-do-i-figure-out-which-wrong-file-rspec-is-loading/198437)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 3\
**Last updated:** [November 1, 2010, 6:19pm UTC](https://www.ruby-forum.com/t/how-do-i-figure-out-which-wrong-file-rspec-is-loading/198437 "2010-11-01T18:19:42Z")

</div>

I’m using Rails 3.0.1, RSpec-Rails 2.0.1 and Webrat 0.7.1. I have the following test: describe PagesController do describe “GET ‘main’” do it “should have the right title” do get ‘main’ response.should have\_selecto…

---

## [What should I test/specify?](https://www.ruby-forum.com/t/what-should-i-test-specify/198366)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 6\
**Last updated:** [October 31, 2010, 4:17am UTC](https://www.ruby-forum.com/t/what-should-i-test-specify/198366 "2010-10-31T04:17:44Z")

</div>

Ok, so here’s the scenario. I have a top-level module, with a method called load\_file. It should take a file name, get the YAML module (Syck) to parse it, and then send the result to a class, which should convert tha…

---

## [Rspec error's when checking LayoutLinks from the railstutorials](https://www.ruby-forum.com/t/rspec-errors-when-checking-layoutlinks-from-the-railstutorials/197861)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 3\
**Last updated:** [October 30, 2010, 10:51pm UTC](https://www.ruby-forum.com/t/rspec-errors-when-checking-layoutlinks-from-the-railstutorials/197861 "2010-10-30T22:51:38Z")

</div>

I am following the rails tutorial: http://railstutorial.org/chapters/filling-in-the-layout#top Basically the test is something like: spec/requests/layout\_links\_spec.rb require ‘spec\_helper’ describe “LayoutLinks” do …

---

## [Rails Model Test](https://www.ruby-forum.com/t/rails-model-test/198329)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 0\
**Last updated:** [October 29, 2010, 7:33pm UTC](https://www.ruby-forum.com/t/rails-model-test/198329 "2010-10-29T19:33:23Z")

</div>

Given this model: class Organization \< ActiveRecord::Base has\_many :users validates :name, :presence =\> true validates :subdomain, :presence =\> true validate :has\_at\_least\_one\_user private def has\_at\_least\_one\_use…

---

## [Understanding routing specs that use constraints](https://www.ruby-forum.com/t/understanding-routing-specs-that-use-constraints/198249)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 1\
**Last updated:** [October 29, 2010, 12:36am UTC](https://www.ruby-forum.com/t/understanding-routing-specs-that-use-constraints/198249 "2010-10-29T00:36:35Z")

</div>

Hello all, I’m trying to perform a pretty simple routing constraint Here are my routes, my constraint, and my spec. As you can see, I’ve attempted to stub my RootConstraints.matches? method to just return true or fa…

---

## [Nested attributes in fixtures](https://www.ruby-forum.com/t/nested-attributes-in-fixtures/196362)

<div class="topic-metadata">

**Author:** [@Mack](https://www.ruby-forum.com/u/Mack)\
**Replies:** 7\
**Last updated:** [October 29, 2010, 12:13am UTC](https://www.ruby-forum.com/t/nested-attributes-in-fixtures/196362 "2010-10-29T00:13:25Z")

</div>

I’m unable to get nested attributes in fixtures to work with Rspec. The models and fixtures function fine outside of rspec, but I get a mysql error (Unknown column "\_attributes) when running tests with the same fixtur…

---

## [How to mock url\_for?](https://www.ruby-forum.com/t/how-to-mock-url-for/198180)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 1\
**Last updated:** [October 28, 2010, 4:41pm UTC](https://www.ruby-forum.com/t/how-to-mock-url-for/198180 "2010-10-28T16:41:09Z")

</div>

Hi, I am testing a model A, which calls inside url\_for method; rspec complains that url\_for is undefined (which I suppose is because url\_for is called outside view’s context) How can I mock url\_for rails method? Ple…

---

## [Autotest+RSpec2+Win32console = no color](https://www.ruby-forum.com/t/autotest-rspec2-win32console-no-color/198229)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 0\
**Last updated:** [October 28, 2010, 10:03am UTC](https://www.ruby-forum.com/t/autotest-rspec2-win32console-no-color/198229 "2010-10-28T10:03:44Z")

</div>

I have the same problem with the combination above with Ruby 1.9.2 on Windows XP, as described here: http://www.ruby-forum.com/topic/205569 Calling Rspec directly produces colored output, but autotest spits out ANSI …

---

## [Autotest with rspec2 notifications on windows](https://www.ruby-forum.com/t/autotest-with-rspec2-notifications-on-windows/198217)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 0\
**Last updated:** [October 28, 2010, 1:07am UTC](https://www.ruby-forum.com/t/autotest-with-rspec2-notifications-on-windows/198217 "2010-10-28T01:07:42Z")

</div>

Hello. I’ve been trying for the last 2 days to make autotest with rspec2 send notifications on windows7 but without any success. First i used only the autotest gem with autotest-growl and the latest version of growl f…

---

## [Fail to load spec/rake/spectask](https://www.ruby-forum.com/t/fail-to-load-spec-rake-spectask/198073)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 2\
**Last updated:** [October 26, 2010, 11:53pm UTC](https://www.ruby-forum.com/t/fail-to-load-spec-rake-spectask/198073 "2010-10-26T23:53:05Z")

</div>

Hi! I’m a newbie at Ruby. I’m trying to run rspec tests using rake. In my rake file I include spec/rake/spectask. It fails to load giving me the following message: rake aborted! no such file to load – spec/rake/spec…

---

## [Need help to figure out why this expectation isn't met](https://www.ruby-forum.com/t/need-help-to-figure-out-why-this-expectation-isnt-met/226094)

<div class="topic-metadata">

**Author:** [@Haim\_Ashkenazi](https://www.ruby-forum.com/u/Haim_Ashkenazi)\
**Replies:** 3\
**Last updated:** [October 26, 2010, 4:34pm UTC](https://www.ruby-forum.com/t/need-help-to-figure-out-why-this-expectation-isnt-met/226094 "2010-10-26T16:34:35Z")

</div>

rspec-users mailing list removed\_email\_address@domain.invalid http://rubyforge.org/mailman/listinfo/rspec-users

---

## [Why does this stub doesn't work?](https://www.ruby-forum.com/t/why-does-this-stub-doesnt-work/198010)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 4\
**Last updated:** [October 25, 2010, 2:13pm UTC](https://www.ruby-forum.com/t/why-does-this-stub-doesnt-work/198010 "2010-10-25T14:13:49Z")

</div>

rspec-users mailing list removed\_email\_address@domain.invalid http://rubyforge.org/mailman/listinfo/rspec-users

---

## [Spec'ing methods which essentially filter associations](https://www.ruby-forum.com/t/specing-methods-which-essentially-filter-associations/197988)

<div class="topic-metadata">

**Author:** [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Replies:** 3\
**Last updated:** [October 24, 2010, 9:30pm UTC](https://www.ruby-forum.com/t/specing-methods-which-essentially-filter-associations/197988 "2010-10-24T21:30:19Z")

</div>

I’ve been spec’ing for a long time, but I’ve never discovered the answer to this, so a definitive answer would be great! Whats the best way to spec a method which basically filters an association? class Thing \< Activ…

---

## [Symbols in strings out in stubbed response](https://www.ruby-forum.com/t/symbols-in-strings-out-in-stubbed-response/197980)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 4\
**Last updated:** [October 24, 2010, 1:37pm UTC](https://www.ruby-forum.com/t/symbols-in-strings-out-in-stubbed-response/197980 "2010-10-24T13:37:11Z")

</div>

I have a test that looks like this: describe ChannelsController, “GET edit” do it “assigns the greetings summary” do summary = {:total =\> 139, :submitted =\> 97, :published =\> 82, :removed =\> 12} Greeting.stub(:summa…

---

## [Tests Not Detected, Says 0 Examples](https://www.ruby-forum.com/t/tests-not-detected-says-0-examples/197882)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 2\
**Last updated:** [October 24, 2010, 7:09am UTC](https://www.ruby-forum.com/t/tests-not-detected-says-0-examples/197882 "2010-10-24T07:09:00Z")

</div>

Hi, I’m trying to get tests running on a gem I forked on github. When I try to run tests, it says “0 examples”, despite lots of tests in the /spec directory. Here is some pertinent information: Code at: GitHub - diss…

---

## [ExampleGroup in Rspec 2](https://www.ruby-forum.com/t/examplegroup-in-rspec-2/197894)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 0\
**Last updated:** [October 22, 2010, 8:06am UTC](https://www.ruby-forum.com/t/examplegroup-in-rspec-2/197894 "2010-10-22T08:06:48Z")

</div>

Hello, In Rspec 1.x I I could create custom ExampleGroups that would have behaviour similar to controller specs. How can I accomplish something similar to this in Rspec 2? I would like to create an example group to t…

---

## [New syntax question and mocking HTTP\_AUTHORIZATION](https://www.ruby-forum.com/t/new-syntax-question-and-mocking-http-authorization/197842)

<div class="topic-metadata">

**Author:** [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Replies:** 3\
**Last updated:** [October 21, 2010, 7:57pm UTC](https://www.ruby-forum.com/t/new-syntax-question-and-mocking-http-authorization/197842 "2010-10-21T19:57:32Z")

</div>

I am specing a sinatra app. it “should send non-valid user to /login” do get ‘/’ last\_response.headers\[‘Location’\].should == ‘/reports’ end this is working fine but I would like to know how to convert it to the new…

---

## [Lot of error when running all spec](https://www.ruby-forum.com/t/lot-of-error-when-running-all-spec/197860)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 1\
**Last updated:** [October 21, 2010, 2:38pm UTC](https://www.ruby-forum.com/t/lot-of-error-when-running-all-spec/197860 "2010-10-21T14:38:04Z")

</div>

Hi, I’m pretty new to rspec. I’m writing some spec for a Rails 3.0 app with Devise (branch omniauth), rspec 2.0.1 and factory\_girl. When I run spec file by file (ex: rspec spec/models/ document\_spec.rb) , it run some…

---

## [Rspec 2 - undefined method \`redirect\_to?' for #\<Rack::MockResponse:0xa43ef14\>](https://www.ruby-forum.com/t/rspec-2-undefined-method-redirect-to-for-rack-0xa43ef14/197778)

<div class="topic-metadata">

**Author:** [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Replies:** 2\
**Last updated:** [October 20, 2010, 10:36pm UTC](https://www.ruby-forum.com/t/rspec-2-undefined-method-redirect-to-for-rack-0xa43ef14/197778 "2010-10-20T22:36:00Z")

</div>

I try to test sinatra app using rspec 2.0.0 and rack-test 0.5.6 it “redirect non-authenticated user to logout page” do get ‘/’ last\_response.should be\_redirect\_to('/login) end and I get: undefined method \`redirect\_…

---

## [Testing initialize methods and chained methods](https://www.ruby-forum.com/t/testing-initialize-methods-and-chained-methods/197712)

<div class="topic-metadata">

**Author:** [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Replies:** 5\
**Last updated:** [October 20, 2010, 9:26am UTC](https://www.ruby-forum.com/t/testing-initialize-methods-and-chained-methods/197712 "2010-10-20T09:26:30Z")

</div>

I’m having some troubles understanding how to test a couple of things. Usually, if I’m having trouble testing something, it means that my design could probably be improved or changed, but in these cases I think I’m d…

---

## [Routing errors with Rails 3.0.1 and Rspec 2.0.1](https://www.ruby-forum.com/t/routing-errors-with-rails-3-0-1-and-rspec-2-0-1/197779)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 1\
**Last updated:** [October 20, 2010, 9:24am UTC](https://www.ruby-forum.com/t/routing-errors-with-rails-3-0-1-and-rspec-2-0-1/197779 "2010-10-20T09:24:37Z")

</div>

I’m sure something is borked in my app, but I can’t seem to track it down. A few commits back, my app was fully passing my spec suite. It was on Rails 3.0.0 and Rspec 2.0.0.beta.20. I’ve now upgraded to rails 3.0.1…

---

## ["contain" not defined in view spec](https://www.ruby-forum.com/t/contain-not-defined-in-view-spec/197685)

<div class="topic-metadata">

**Author:** [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Replies:** 4\
**Last updated:** [October 20, 2010, 12:50am UTC](https://www.ruby-forum.com/t/contain-not-defined-in-view-spec/197685 "2010-10-20T00:50:55Z")

</div>

Using Rails 2 and rspec-rails 2.0.1. I have the following view spec: require ‘spec\_helper’ describe “bookmarkers/show.html.haml” do include BookmarkersHelper before(:each) do @bookmarker = mock\_model(Bookmarker) @…

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

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