# RSpec

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

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

---

## [How to write view specs with multiple forms](https://www.ruby-forum.com/t/how-to-write-view-specs-with-multiple-forms/213866)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [November 15, 2011, 4:45am UTC](https://www.ruby-forum.com/t/how-to-write-view-specs-with-multiple-forms/213866 "2011-11-15T04:45:32Z")

</div>

Hi guys, I don’t know how to write an spec for a view template with two or more forms. The follow content corresponds to the file named home.html.haml !!! 5 = form\_for(:session, :url =\> sessions\_path) do |f| .field …

---

## [Testing Custom methods](https://www.ruby-forum.com/t/testing-custom-methods/213867)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [November 14, 2011, 9:49pm UTC](https://www.ruby-forum.com/t/testing-custom-methods/213867 "2011-11-14T21:49:42Z")

</div>

I am attempting to test a custom method, and totally bombing out. describe Record do describe ‘#save\_cf\_data’ do before :each do @record = mock\_model(Record) end it “should have a birthday” do @record.save\_cf\_dat…

---

## [Rspec not finding my examples](https://www.ruby-forum.com/t/rspec-not-finding-my-examples/213823)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 2\
**Last updated:** [November 13, 2011, 7:52am UTC](https://www.ruby-forum.com/t/rspec-not-finding-my-examples/213823 "2011-11-13T07:52:43Z")

</div>

I am following the examples in chapter 2 of “Rails 3 in Action” and for some reason I have to specify the full path + file name to get my specs to run. The book and rspec docs led me to believe that I should be able t…

---

## [Re: RSpec file name with non-ASCII characters](https://www.ruby-forum.com/t/re-rspec-file-name-with-non-ascii-characters/213820)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [November 13, 2011, 12:34am UTC](https://www.ruby-forum.com/t/re-rspec-file-name-with-non-ascii-characters/213820 "2011-11-13T00:34:36Z")

</div>

At 19:29:22 -0200 on Wed, 9 Nov 2011, Samir B. removed\_email\_address@domain.invalid wrote: Hello, have you tried to put encoding: utf-8 in the begin of file? I did try that, but it seems to make sense that it didn’…

---

## [Using require\_relative to speed up rspec require time](https://www.ruby-forum.com/t/using-require-relative-to-speed-up-rspec-require-time/213814)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [November 12, 2011, 11:59pm UTC](https://www.ruby-forum.com/t/using-require-relative-to-speed-up-rspec-require-time/213814 "2011-11-12T23:59:26Z")

</div>

Hi, I noticed recently that require ‘rspec’ on my machine was taking close to half a second. That’s not a huge amount of time, but it is still the single slowest part of my test suite. It boils down to Ruby 1.9’s rat…

---

## [Problem with mocking helper methods](https://www.ruby-forum.com/t/problem-with-mocking-helper-methods/213793)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [November 11, 2011, 3:22pm UTC](https://www.ruby-forum.com/t/problem-with-mocking-helper-methods/213793 "2011-11-11T15:22:27Z")

</div>

Given that I assume that rails helper image\_tag works as intended, I want to mock out call to this method in my helper. spec/helpers/some\_helper\_spec.rb: require ‘spec\_helper’ describe SomeHelper do it ‘allows stu…

---

## [RSpec file name with non-ASCII characters](https://www.ruby-forum.com/t/rspec-file-name-with-non-ascii-characters/213715)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [November 10, 2011, 3:52pm UTC](https://www.ruby-forum.com/t/rspec-file-name-with-non-ascii-characters/213715 "2011-11-10T15:52:44Z")

</div>

On Mac OS X 10.6.8 with Ruby 1.9.3, using a spec file name containing a non-ASCII character (an em-dash) I’m getting the error "in '=~': invalid byte sequence in US-ASCII (ArgumentError)" on this line self\[:caller\].d…

---

## [Quick question on rspec-rails for Rails 3: how to stub AR class methods like :find?](https://www.ruby-forum.com/t/quick-question-on-rspec-rails-for-rails-3-how-to-stub-ar-class-methods-like-find/213687)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [November 9, 2011, 1:13am UTC](https://www.ruby-forum.com/t/quick-question-on-rspec-rails-for-rails-3-how-to-stub-ar-class-methods-like-find/213687 "2011-11-09T01:13:40Z")

</div>

Hey, I recently switched to Rails 3(.1) and, using rspec-rails 2.6.1, I find can no longer stub AR class methods, like :find. So, where Comment is an AR class, I can’t do this: Comment.should\_receive(:find).and\_retur…

---

## [Setting expections on chained calls](https://www.ruby-forum.com/t/setting-expections-on-chained-calls/213634)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 5\
**Last updated:** [November 8, 2011, 4:11pm UTC](https://www.ruby-forum.com/t/setting-expections-on-chained-calls/213634 "2011-11-08T16:11:40Z")

</div>

I’m pretty sure this has probably been discussed before. I’m using couchdb (couchrest\_model) When speccing my controller i want to set expectations that im calling my couch views correctly. The query interface has re…

---

## [Invitation to connect on LinkedIn](https://www.ruby-forum.com/t/invitation-to-connect-on-linkedin/213657)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [November 8, 2011, 9:12am UTC](https://www.ruby-forum.com/t/invitation-to-connect-on-linkedin/213657 "2011-11-08T09:12:01Z")

</div>

I’d like to add you to my professional network on LinkedIn. Robert Robert Dober Developpeur Ruby On Rails et Javascript. at Up & Net Paris Area, France Confirm that you know Robert Dober: – You are receiving I…

---

## [Weird behavior with should\_not\_receive](https://www.ruby-forum.com/t/weird-behavior-with-should-not-receive/213593)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 4\
**Last updated:** [November 7, 2011, 2:13pm UTC](https://www.ruby-forum.com/t/weird-behavior-with-should-not-receive/213593 "2011-11-07T14:13:18Z")

</div>

I recently saw a test passing when it should have failed, because the person who wrote it used should\_not\_receive instead of should\_receive. Here is a simple example illustrating the behavior: class MyTest def foo …

---

## [Any\_instance](https://www.ruby-forum.com/t/any-instance/213594)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [November 7, 2011, 8:26am UTC](https://www.ruby-forum.com/t/any-instance/213594 "2011-11-07T08:26:32Z")

</div>

Hello, I’m trying to stub out a method with the any\_instance method, this works well if I run the spec individually however when I do a full run it will call the actual method: example “” do Library::Class.any\_insta…

---

## [Rspec-2.8.0.rc1 is released](https://www.ruby-forum.com/t/rspec-2-8-0-rc1-is-released/213601)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [November 7, 2011, 12:27am UTC](https://www.ruby-forum.com/t/rspec-2-8-0-rc1-is-released/213601 "2011-11-07T00:27:29Z")

</div>

http://blog.davidchelimsky.net/2011/11/06/rspec-280rc1-is-released/ See the blog post for more information, but highlights include: tag overrides Now you can set tag/filter defaults in .rspec: –tag ~javascript or i…

---

## [Rspec help](https://www.ruby-forum.com/t/rspec-help/213546)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [November 4, 2011, 8:52pm UTC](https://www.ruby-forum.com/t/rspec-help/213546 "2011-11-04T20:52:22Z")

</div>

Hi all I’ve created a stack overflow question that I hope someone here can help me with. Thanks in advance, Denise

---

## [Problems matching generated html output](https://www.ruby-forum.com/t/problems-matching-generated-html-output/213506)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 5\
**Last updated:** [November 4, 2011, 12:49am UTC](https://www.ruby-forum.com/t/problems-matching-generated-html-output/213506 "2011-11-04T00:49:27Z")

</div>

So, I am writing tests for a presenter class that outputs html markup. I have a method that does something like this: def output things.map do |thing| content\_tag :div, :id =\> thing\[:id\] do \[content\_tag :p, thing\[:b…

---

## [API for defining top-level DSL methods?](https://www.ruby-forum.com/t/api-for-defining-top-level-dsl-methods/213412)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [November 1, 2011, 4:22pm UTC](https://www.ruby-forum.com/t/api-for-defining-top-level-dsl-methods/213412 "2011-11-01T16:22:23Z")

</div>

I am in the process of writing a simple DSL inside of rspec, which defines some methods that wrap describe/example and augment the metadata, like capybara’s “feature/scenario” methods. From the excellent RSpec book, I …

---

## [Noob (mock/stub) ActiveMerchant](https://www.ruby-forum.com/t/noob-mock-stub-activemerchant/213370)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [October 31, 2011, 8:02pm UTC](https://www.ruby-forum.com/t/noob-mock-stub-activemerchant/213370 "2011-10-31T20:02:38Z")

</div>

Hi Group I’m still waiting for the light to come on with stubbing/mocking and the syntax for each. I have simple method in my Order class like so… def credit\_card ActiveMerchant::Billing::CreditCard.new( :type …

---

## [Specs failing when run outside Spork with TypeError: superclass mismatch for class Attribute](https://www.ruby-forum.com/t/specs-failing-when-run-outside-spork-with-typeerror-superclass-mismatch-for-class-attribute/213361)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [October 31, 2011, 3:42pm UTC](https://www.ruby-forum.com/t/specs-failing-when-run-outside-spork-with-typeerror-superclass-mismatch-for-class-attribute/213361 "2011-10-31T15:42:34Z")

</div>

When I run my specs inside spork, they all just pass without any problems, but once I try to run them without spork, I end up with Failure/Error: Unable to find matching line from backtrace TypeError: superclass m…

---

## [Rspec 1.3.2, Rails 2.3.14 - plugins not loading](https://www.ruby-forum.com/t/rspec-1-3-2-rails-2-3-14-plugins-not-loading/213027)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 8\
**Last updated:** [October 28, 2011, 9:55pm UTC](https://www.ruby-forum.com/t/rspec-1-3-2-rails-2-3-14-plugins-not-loading/213027 "2011-10-28T21:55:12Z")

</div>

Hi there I have a weird situation. I have inherited a project in Rails 1.2.3 that has been upgraded to Rails 2.3.14 (and is running). I have installed Cucumber and Rspec to start to write features/tests for the new c…

---

## [Problem profiling rspec boot time with ruby-prof](https://www.ruby-forum.com/t/problem-profiling-rspec-boot-time-with-ruby-prof/213222)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [October 27, 2011, 1:25am UTC](https://www.ruby-forum.com/t/problem-profiling-rspec-boot-time-with-ruby-prof/213222 "2011-10-27T01:25:08Z")

</div>

We recently upgraded to rspec2 / rails 3 and our specs are taking a very long time to run. It takes nearly 12 minutes before the first dot comes out. Before the upgrade, our entire suite of 6000+ specs would run in …

---

## [Upgraded to rails 3.1.0 and found that string value of id has to be used instead of the integer valu](https://www.ruby-forum.com/t/upgraded-to-rails-3-1-0-and-found-that-string-value-of-id-has-to-be-used-instead-of-the-integer-valu/213152)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [October 25, 2011, 2:57pm UTC](https://www.ruby-forum.com/t/upgraded-to-rails-3-1-0-and-found-that-string-value-of-id-has-to-be-used-instead-of-the-integer-valu/213152 "2011-10-25T14:57:36Z")

</div>

My advance apologies if the title/subject is not too descriptive. Pre: I have just upgraded from rails 3.0.9 to rails 3.1.0 Before the upgrade, running ‘rake spec’ sees all my specs pass. After the upgrade, I seem to …

---

## [Rspec 2 and rails engines](https://www.ruby-forum.com/t/rspec-2-and-rails-engines/212978)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [October 19, 2011, 8:16pm UTC](https://www.ruby-forum.com/t/rspec-2-and-rails-engines/212978 "2011-10-19T20:16:36Z")

</div>

Anybody successfully working with rails 3 engines and rspec 2? If so, please weigh in on https://github.com/dchelimsky/rspec/issues/41. TIA, David

---

## [View spec for 'new' keeps failing despite generated html has expected attribute](https://www.ruby-forum.com/t/view-spec-for-new-keeps-failing-despite-generated-html-has-expected-attribute/212957)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [October 19, 2011, 9:40am UTC](https://www.ruby-forum.com/t/view-spec-for-new-keeps-failing-despite-generated-html-has-expected-attribute/212957 "2011-10-19T09:40:09Z")

</div>

Hi guys, I have created a new resource, brands and here’s the spec for ‘new’ which is failing. I do not know what’s going on despite checking it out for a few times already ------ app/views/brands/new.html.erb - sta…

---

## [Scope problems for before hooks using helper methods?](https://www.ruby-forum.com/t/scope-problems-for-before-hooks-using-helper-methods/212796)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 4\
**Last updated:** [October 14, 2011, 4:25pm UTC](https://www.ruby-forum.com/t/scope-problems-for-before-hooks-using-helper-methods/212796 "2011-10-14T16:25:41Z")

</div>

Hi, there, I believe I have some problem with scoping. I have a controller spec file which tests a brands resource. At the start of the file, I test the resource’s access for different users in a context block a) no…

---

## [Assert\_select - to do negative tests - need help with syntax please :)](https://www.ruby-forum.com/t/assert-select-to-do-negative-tests-need-help-with-syntax-please/212734)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 8\
**Last updated:** [October 14, 2011, 2:30pm UTC](https://www.ruby-forum.com/t/assert-select-to-do-negative-tests-need-help-with-syntax-please/212734 "2011-10-14T14:30:29Z")

</div>

Hi all, I am trying to figure out how to use assert\_select properly. When I created a new resource in rails 3 called Brands, the view specs for brands had a test which read: # Run the generator again with the --webra…

---

## [Helper methods can't be called within before hooks. Help, please](https://www.ruby-forum.com/t/helper-methods-cant-be-called-within-before-hooks-help-please/212797)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 2\
**Last updated:** [October 14, 2011, 10:46am UTC](https://www.ruby-forum.com/t/helper-methods-cant-be-called-within-before-hooks-help-please/212797 "2011-10-14T10:46:03Z")

</div>

Hi, there, I believe I have some problem with scoping. I have a controller spec file which tests a brands resource. At the start of the file, I test the resource’s access for different users in a context block a) no…

---

## [How do we include support helpers in request specs?](https://www.ruby-forum.com/t/how-do-we-include-support-helpers-in-request-specs/212800)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [October 14, 2011, 9:41am UTC](https://www.ruby-forum.com/t/how-do-we-include-support-helpers-in-request-specs/212800 "2011-10-14T09:41:46Z")

</div>

Hi, all :slight\_smile: I have some working support helpers defined in spec/support/ controller\_macros.rb. I’m running “rake spec” before a ‘git commit’ and observed that the spec request for my ‘brands’ controller, …

---

## [Running rspec causes errror =\> no such file to load -- rspec/rails](https://www.ruby-forum.com/t/running-rspec-causes-errror-no-such-file-to-load-rspec-rails/212794)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [October 14, 2011, 8:30am UTC](https://www.ruby-forum.com/t/running-rspec-causes-errror-no-such-file-to-load-rspec-rails/212794 "2011-10-14T08:30:06Z")

</div>

strange install related problems in my rails 3.1 app gemfile group :test, :development do … gem “rspec” gem “rspec-rails” gem ‘rspec-rails-ext’ gem ‘rspec-rails-matchers’ … end bundle show rspec-rails /home…

---

## [Instance variables from outer before blocks don't persist?](https://www.ruby-forum.com/t/instance-variables-from-outer-before-blocks-dont-persist/212762)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 2\
**Last updated:** [October 14, 2011, 3:24am UTC](https://www.ruby-forum.com/t/instance-variables-from-outer-before-blocks-dont-persist/212762 "2011-10-14T03:24:28Z")

</div>

Hmmm… I am used to doing this with Test::Unit & Shoulda… setup do @foo = Bar.new end context “something” setup do @foo.blah = 123 end should “make me say lol” do # …etc end end … But I just tried doing this…

---

## [Attempting to speed up my controller specs: using before all fails?](https://www.ruby-forum.com/t/attempting-to-speed-up-my-controller-specs-using-before-all-fails/212704)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 4\
**Last updated:** [October 13, 2011, 12:15am UTC](https://www.ruby-forum.com/t/attempting-to-speed-up-my-controller-specs-using-before-all-fails/212704 "2011-10-13T00:15:23Z")

</div>

I have a simple controller test, containing a.o. the following code: context "POST :create" do before (:each) do post :create, :user\_id =\> @user.id, :account =\> { .. some data ... } end it { response.…

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

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