# RSpec

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

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

---

## [@request not available in before(:all) but is available in before(:each) in RSpec-Rails](https://www.ruby-forum.com/t/request-not-available-in-before-all-but-is-available-in-before-each-in-rspec-rails/178075)

<div class="topic-metadata">

**Author:** [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Replies:** 2\
**Last updated:** [October 28, 2009, 8:59pm UTC](https://www.ruby-forum.com/t/request-not-available-in-before-all-but-is-available-in-before-each-in-rspec-rails/178075 "2009-10-28T20:59:12Z")

</div>

More playing with RSpec-Rails. I’ve noticed that I do not have access to the @request object in before (:all) but do in before(:each) Is this expected behavior?

---

## [Rspec Tutorial](https://www.ruby-forum.com/t/rspec-tutorial/177770)

<div class="topic-metadata">

**Author:** [@hanuma\_kanth](https://www.ruby-forum.com/u/hanuma_kanth)\
**Replies:** 10\
**Last updated:** [October 28, 2009, 8:07pm UTC](https://www.ruby-forum.com/t/rspec-tutorial/177770 "2009-10-28T20:07:06Z")

</div>

Dear Sir, Iam Hanumakanth working in Indigenius Solutins(www.indigenius.com) from india and i want some good examples of rspecs and also is there any way to create rspecs through the command line after creating the s…

---

## [Troble running controller spec](https://www.ruby-forum.com/t/troble-running-controller-spec/168551)

<div class="topic-metadata">

**Author:** [@tornado](https://www.ruby-forum.com/u/tornado)\
**Replies:** 14\
**Last updated:** [October 28, 2009, 5:14pm UTC](https://www.ruby-forum.com/t/troble-running-controller-spec/168551 "2009-10-28T17:14:58Z")

</div>

Hi, I am trying to execute controller spec by referring to RSpec book but it is diving me error. Following are the details: Ruby version : 1.8.6 (2007-03-13 patchlevel 0) \[i386-mswin32\] rspec - 1.2.4 rails - 2.1.2 …

---

## [Rspec rollback for multiple databases](https://www.ruby-forum.com/t/rspec-rollback-for-multiple-databases/178038)

<div class="topic-metadata">

**Author:** [@miv](https://www.ruby-forum.com/u/miv)\
**Replies:** 1\
**Last updated:** [October 28, 2009, 2:45pm UTC](https://www.ruby-forum.com/t/rspec-rollback-for-multiple-databases/178038 "2009-10-28T14:45:38Z")

</div>

Is there a way to user rspec with multiple databases in rails? I have several adapters and want to seamlesly run specs on them.I think it is appropriate to list all adapters for such feature.

---

## [How Can I inveke a code example in another one](https://www.ruby-forum.com/t/how-can-i-inveke-a-code-example-in-another-one/178029)

<div class="topic-metadata">

**Author:** [@zhjie685](https://www.ruby-forum.com/u/zhjie685)\
**Replies:** 1\
**Last updated:** [October 28, 2009, 12:48pm UTC](https://www.ruby-forum.com/t/how-can-i-inveke-a-code-example-in-another-one/178029 "2009-10-28T12:48:32Z")

</div>

Hi, I’m new to rspec. How could I transform the Unit:Tests code like def test\_logout login get :logout assert\_not\_logged\_in end def assert\_not\_logged\_in assert\_block { session\[“user”\].nil? } end that a test me…

---

## [Writing controller spec](https://www.ruby-forum.com/t/writing-controller-spec/177979)

<div class="topic-metadata">

**Author:** [@tornado](https://www.ruby-forum.com/u/tornado)\
**Replies:** 2\
**Last updated:** [October 28, 2009, 10:49am UTC](https://www.ruby-forum.com/t/writing-controller-spec/177979 "2009-10-28T10:49:44Z")

</div>

Hello everybody, I had written same scenario using normal code which is as follows : def valid\_attributes { :body =\> “test\_description”, :title =\> “test123”, } end describe BbPostsController, “POST Create” do be…

---

## [RSpec-Rails not tearing down the session?](https://www.ruby-forum.com/t/rspec-rails-not-tearing-down-the-session/178018)

<div class="topic-metadata">

**Author:** [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Replies:** 4\
**Last updated:** [October 28, 2009, 5:30am UTC](https://www.ruby-forum.com/t/rspec-rails-not-tearing-down-the-session/178018 "2009-10-28T05:30:06Z")

</div>

I noticed that a session that I am setting up in one exa,ple is still available in another. Is RSpec-Rails supposed to tear down the session or should I be doing this myself?

---

## [Testing url\_for](https://www.ruby-forum.com/t/testing-url-for/177985)

<div class="topic-metadata">

**Author:** [@dracko](https://www.ruby-forum.com/u/dracko)\
**Replies:** 4\
**Last updated:** [October 28, 2009, 1:24am UTC](https://www.ruby-forum.com/t/testing-url-for/177985 "2009-10-28T01:24:11Z")

</div>

Hi David, I’m giving a try to RSpec after we meet each other on Rails Summit Latin America and I must admit I’m enjoying using rspec/machinist/faker. Since I have not written any controllers yet, I hadn’t taken a chan…

---

## [Mocking problem in controller](https://www.ruby-forum.com/t/mocking-problem-in-controller/177990)

<div class="topic-metadata">

**Author:** [@drewB](https://www.ruby-forum.com/u/drewB)\
**Replies:** 2\
**Last updated:** [October 27, 2009, 10:27pm UTC](https://www.ruby-forum.com/t/mocking-problem-in-controller/177990 "2009-10-27T22:27:58Z")

</div>

I am having a lot of trouble figure out how to mock one my controller methods. I was hoping someone might be able to help me. Controller: def create … @objective = current\_user.objectives.create(params\[:objective\]…

---

## [Unable to use Rspec Framework in Watir](https://www.ruby-forum.com/t/unable-to-use-rspec-framework-in-watir/177818)

<div class="topic-metadata">

**Author:** [@abhisheksreepal](https://www.ruby-forum.com/u/abhisheksreepal)\
**Replies:** 3\
**Last updated:** [October 26, 2009, 11:25am UTC](https://www.ruby-forum.com/t/unable-to-use-rspec-framework-in-watir/177818 "2009-10-26T11:25:37Z")

</div>

Hi , My OS is Windows Xp. I have mentioned a code below.Initially I didn’t had safariwatir installed. When i was executing the code, I was getting an Error- No such File to Load -“safariwatir” I didn’t Know the Ro…

---

## [Can't get running a simple rspec test: assigns is always nil](https://www.ruby-forum.com/t/cant-get-running-a-simple-rspec-test-assigns-is-always-nil/177579)

<div class="topic-metadata">

**Author:** [@san](https://www.ruby-forum.com/u/san)\
**Replies:** 7\
**Last updated:** [October 26, 2009, 9:43am UTC](https://www.ruby-forum.com/t/cant-get-running-a-simple-rspec-test-assigns-is-always-nil/177579 "2009-10-26T09:43:10Z")

</div>

http://pastie.org/pastes/661816 hi, please have a look at my code. Perhaps anybody knows a solution for that problem.

---

## [Anyone using the rspec textmate bundle with Ruby 1.9.1](https://www.ruby-forum.com/t/anyone-using-the-rspec-textmate-bundle-with-ruby-1-9-1/177799)

<div class="topic-metadata">

**Author:** [@rykkers](https://www.ruby-forum.com/u/rykkers)\
**Replies:** 1\
**Last updated:** [October 23, 2009, 10:01pm UTC](https://www.ruby-forum.com/t/anyone-using-the-rspec-textmate-bundle-with-ruby-1-9-1/177799 "2009-10-23T22:01:23Z")

</div>

I’m now in the process of facing converting a rails app to use Ruby 1.9.1. Has anyone figured out how to use 1.9 with the RSpec bundle in textmate and preferably how to switch back and forth? – Rick DeNatale Blog: h…

---

## [Can't figure you why I am getting deliver\_from == Nil Using EmailSpec](https://www.ruby-forum.com/t/cant-figure-you-why-i-am-getting-deliver-from-nil-using-emailspec/177725)

<div class="topic-metadata">

**Author:** [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Replies:** 1\
**Last updated:** [October 23, 2009, 12:58am UTC](https://www.ruby-forum.com/t/cant-figure-you-why-i-am-getting-deliver-from-nil-using-emailspec/177725 "2009-10-23T00:58:07Z")

</div>

Using EmailSpec, I am testing the format of emails sent from an observer. I can verify the deliver\_to address, the bcc\_to address, and that the message body has the appropriate text. However, when I test the deliver\_…

---

## [How to mock active record relationships](https://www.ruby-forum.com/t/how-to-mock-active-record-relationships/177619)

<div class="topic-metadata">

**Author:** [@christoph](https://www.ruby-forum.com/u/christoph)\
**Replies:** 3\
**Last updated:** [October 22, 2009, 8:16am UTC](https://www.ruby-forum.com/t/how-to-mock-active-record-relationships/177619 "2009-10-22T08:16:38Z")

</div>

Hi I am new to Rspec and try to mock my controller that looks like def create @friendship = current\_user.friendships.build(:friend\_id =\> params\[:friend\_id\]) if @friendship.save flash\[:notice\] = “Added friend.” ren…

---

## [How can I spec protect method](https://www.ruby-forum.com/t/how-can-i-spec-protect-method/177663)

<div class="topic-metadata">

**Author:** [@Elza](https://www.ruby-forum.com/u/Elza)\
**Replies:** 1\
**Last updated:** [October 21, 2009, 7:40pm UTC](https://www.ruby-forum.com/t/how-can-i-spec-protect-method/177663 "2009-10-21T19:40:33Z")

</div>

How can I spec the 3rd line of my controller? update\_successful, error\_msg = update\_channels\_association def create @user = User.new(get\_param(:user, :hash)) if @user.save update\_successful, error\_msg = update\_chan…

---

## [Stub that returns hash values](https://www.ruby-forum.com/t/stub-that-returns-hash-values/177599)

<div class="topic-metadata">

**Author:** [@cgramona](https://www.ruby-forum.com/u/cgramona)\
**Replies:** 8\
**Last updated:** [October 21, 2009, 7:14pm UTC](https://www.ruby-forum.com/t/stub-that-returns-hash-values/177599 "2009-10-21T19:14:47Z")

</div>

Is it possible to create a stub that returns hash values. For example I would like to convert this: @siteItem = stub(‘plmSiteItem’, :one =\> “uno”) To something like this: @siteItem = stub(‘plmSiteItem’, {‘one’ =\> ‘un…

---

## [How can I test the values of css style attributes assigned to a div](https://www.ruby-forum.com/t/how-can-i-test-the-values-of-css-style-attributes-assigned-to-a-div/177657)

<div class="topic-metadata">

**Author:** [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Replies:** 1\
**Last updated:** [October 21, 2009, 6:10pm UTC](https://www.ruby-forum.com/t/how-can-i-test-the-values-of-css-style-attributes-assigned-to-a-div/177657 "2009-10-21T18:10:21Z")

</div>

My site allows users to change the backround color (among other things) for their page. These values are stored in database. Their choices (or the default) are placed on the page using a block at the end of the bl…

---

## [Controller code doesn't seem to be called within rspec test](https://www.ruby-forum.com/t/controller-code-doesnt-seem-to-be-called-within-rspec-test/177638)

<div class="topic-metadata">

**Author:** [@san](https://www.ruby-forum.com/u/san)\
**Replies:** 13\
**Last updated:** [October 21, 2009, 5:17pm UTC](https://www.ruby-forum.com/t/controller-code-doesnt-seem-to-be-called-within-rspec-test/177638 "2009-10-21T17:17:50Z")

</div>

i call current\_user in the index-method, but the test fails and says: “#User::CategoriesController:0xb7439484 expected :current\_user with (any args) once, but received it 0 times” Why?

---

## [Slides from "Uses & Abuses of Mocks & Stubs" at NWRUG](https://www.ruby-forum.com/t/slides-from-uses-abuses-of-mocks-stubs-at-nwrug/177457)

<div class="topic-metadata">

**Author:** [@Ashley\_M](https://www.ruby-forum.com/u/Ashley_M)\
**Replies:** 2\
**Last updated:** [October 21, 2009, 3:28pm UTC](https://www.ruby-forum.com/t/slides-from-uses-abuses-of-mocks-stubs-at-nwrug/177457 "2009-10-21T15:28:47Z")

</div>

Hi all I gave a presentation on mock objects this week at the North West Ruby User Group in Manchester\[1\]. I thought some of you may be interested in the slides, which are now on my blog\[2\]. Note that most of the sl…

---

## [Help in Stubing is\_admin? method](https://www.ruby-forum.com/t/help-in-stubing-is-admin-method/177534)

<div class="topic-metadata">

**Author:** [@Elza](https://www.ruby-forum.com/u/Elza)\
**Replies:** 2\
**Last updated:** [October 21, 2009, 2:17pm UTC](https://www.ruby-forum.com/t/help-in-stubing-is-admin-method/177534 "2009-10-21T14:17:56Z")

</div>

My controller def edit @user = User.find(get\_param(:id, :integer)) @user = current\_user if !is\_admin? end My spec describe “GET edit” do ############################################################## should\_requ…

---

## [Stub! and stubs](https://www.ruby-forum.com/t/stub-and-stubs/177189)

<div class="topic-metadata">

**Author:** [@sweb](https://www.ruby-forum.com/u/sweb)\
**Replies:** 6\
**Last updated:** [October 21, 2009, 11:00am UTC](https://www.ruby-forum.com/t/stub-and-stubs/177189 "2009-10-21T11:00:03Z")

</div>

I have an interesting setup: I am using rspec for mocking but I have mocha installed which give me access to any\_instance, expects, etc. The problem that I am having is that I want to stub out a method for the durat…

---

## [Factory\_girl Need help](https://www.ruby-forum.com/t/factory-girl-need-help/176715)

<div class="topic-metadata">

**Author:** [@mithunperera](https://www.ruby-forum.com/u/mithunperera)\
**Replies:** 3\
**Last updated:** [October 21, 2009, 10:55am UTC](https://www.ruby-forum.com/t/factory-girl-need-help/176715 "2009-10-21T10:55:22Z")

</div>

Hi please any body can help me to learn the basics of Factory girl method. If someone know about these please tell me. I want to learn this from the beginning. thanks, Mithun

---

## [Spec-ing private methods?](https://www.ruby-forum.com/t/spec-ing-private-methods/177320)

<div class="topic-metadata">

**Author:** [@Joaquin\_Rivera\_P](https://www.ruby-forum.com/u/Joaquin_Rivera_P)\
**Replies:** 19\
**Last updated:** [October 21, 2009, 9:40am UTC](https://www.ruby-forum.com/t/spec-ing-private-methods/177320 "2009-10-21T09:40:24Z")

</div>

hello there, how do you tipically spec private methods? The thing is Ã have something like this: def some\_method complex\_method + other\_complex\_methods end private def complex\_method… def other\_complex\_methods … …

---

## [Undefined method \`use\_transactional\_fixtures=' on windows with spec\_server](https://www.ruby-forum.com/t/undefined-method-use-transactional-fixtures-on-windows-with-spec-server/177615)

<div class="topic-metadata">

**Author:** [@globallyunique](https://www.ruby-forum.com/u/globallyunique)\
**Replies:** 1\
**Last updated:** [October 21, 2009, 2:19am UTC](https://www.ruby-forum.com/t/undefined-method-use-transactional-fixtures-on-windows-with-spec-server/177615 "2009-10-21T02:19:00Z")

</div>

Any suggestions for what to check when running on windows with: rspec (1.2.9) rspec-rails (1.2.9) rails 2.3.3 ruby 1.8.6 spec\_server Run autospec with --drb option and get the following exception. Run autospec or…

---

## [Help with controllers specs](https://www.ruby-forum.com/t/help-with-controllers-specs/177537)

<div class="topic-metadata">

**Author:** [@Elza\_Di\_Sirio](https://www.ruby-forum.com/u/Elza_Di_Sirio)\
**Replies:** 0\
**Last updated:** [October 19, 2009, 11:18pm UTC](https://www.ruby-forum.com/t/help-with-controllers-specs/177537 "2009-10-19T23:18:57Z")

</div>

I had some doubts while specing the action edit for User Model My controller def edit @user = User.find(get\_param(:id, :integer)) @user = current\_user if !is\_admin? end My spec describe “GET edit” do ###########…

---

## [Is it possible to access Example scope from Formatter?](https://www.ruby-forum.com/t/is-it-possible-to-access-example-scope-from-formatter/197005)

<div class="topic-metadata">

**Author:** [@juuser](https://www.ruby-forum.com/u/juuser)\
**Replies:** 2\
**Last updated:** [October 19, 2009, 9:56pm UTC](https://www.ruby-forum.com/t/is-it-possible-to-access-example-scope-from-formatter/197005 "2009-10-19T21:56:25Z")

</div>

Hello. I’m using Watir to perform some user interface tests. I’ve made my own custom html formatter to make a screenshot and capture html of the page, on which some spec fails. Now, the problem is simple - I have to …

---

## [Rake task lists](https://www.ruby-forum.com/t/rake-task-lists/177521)

<div class="topic-metadata">

**Author:** [@Bryan\_Kearney](https://www.ruby-forum.com/u/Bryan_Kearney)\
**Replies:** 0\
**Last updated:** [October 19, 2009, 6:43pm UTC](https://www.ruby-forum.com/t/rake-task-lists/177521 "2009-10-19T18:43:51Z")

</div>

Is this a known difference for windows systems? When I run rake --tasks I see one task for each spec in the file list? If I run the same on win32, all I get is the ‘all’ task. I scanned lists, and I did not see anythi…

---

## [How to write a correct RSpec for Polymorphic Association](https://www.ruby-forum.com/t/how-to-write-a-correct-rspec-for-polymorphic-association/177407)

<div class="topic-metadata">

**Author:** [@sergeyrgv](https://www.ruby-forum.com/u/sergeyrgv)\
**Replies:** 4\
**Last updated:** [October 19, 2009, 5:56pm UTC](https://www.ruby-forum.com/t/how-to-write-a-correct-rspec-for-polymorphic-association/177407 "2009-10-19T17:56:25Z")

</div>

I don’t know what is need to set in the variable ADDRESSES: Organization.stub!(:find\_by\_id).with(“100”).and\_return(mock\_organization(:id =\> “100”, :addresses =\> ??? )) Somebody help me. Any ideas? I tried to find the …

---

## [Is it possible to access Example scope from Formatter?](https://www.ruby-forum.com/t/is-it-possible-to-access-example-scope-from-formatter/177480)

<div class="topic-metadata">

**Author:** [@juuser](https://www.ruby-forum.com/u/juuser)\
**Replies:** 0\
**Last updated:** [October 18, 2009, 10:12pm UTC](https://www.ruby-forum.com/t/is-it-possible-to-access-example-scope-from-formatter/177480 "2009-10-18T22:12:48Z")

</div>

Hello. I’m using Watir to perform some user interface tests. I’ve made my own custom html formatter to make a screenshot and capture html of the page, on which some spec fails. Now, the problem is simple - I have to …

---

## [Help me with Controllers spec](https://www.ruby-forum.com/t/help-me-with-controllers-spec/177391)

<div class="topic-metadata">

**Author:** [@Elza](https://www.ruby-forum.com/u/Elza)\
**Replies:** 1\
**Last updated:** [October 16, 2009, 9:44am UTC](https://www.ruby-forum.com/t/help-me-with-controllers-spec/177391 "2009-10-16T09:44:59Z")

</div>

I am starting with Rspec and I am having some errors in the Get/index Can someone help me with this? describe BrandsController, ‘GET /index’ do ############################################################## should\_re…

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

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