# RSpec

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

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

---

## [Fields\_for view spec](https://www.ruby-forum.com/t/fields-for-view-spec/205319)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 8\
**Last updated:** [May 3, 2011, 8:56pm UTC](https://www.ruby-forum.com/t/fields-for-view-spec/205319 "2011-05-03T20:56:47Z")

</div>

For some reason I can’t figure out how to make the fields\_for tags render in the trivial example below; however, it works in the browser. What does #build\_association do that my stubbed method does not replicate? (Or …

---

## [HTTP Status 406 When Testing :json](https://www.ruby-forum.com/t/http-status-406-when-testing-json/206466)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 3\
**Last updated:** [May 3, 2011, 9:16am UTC](https://www.ruby-forum.com/t/http-status-406-when-testing-json/206466 "2011-05-03T09:16:15Z")

</div>

Hello all, My first question, in my controllers, do I need to test respond\_to is returning the correct data for its mime-type? In my controller spec I have it “creates a list of available types for that category” do …

---

## [Simple Association Redirect on delete](https://www.ruby-forum.com/t/simple-association-redirect-on-delete/203842)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 4\
**Last updated:** [May 3, 2011, 5:39am UTC](https://www.ruby-forum.com/t/simple-association-redirect-on-delete/203842 "2011-05-03T05:39:31Z")

</div>

So am fairly new to rspec and am trying to get the hang of it, but have run into a few issues I cant figure out. Several times in my code I have model that belongs to a parent, when the model is deleted, instead of re…

---

## [How can I execute rspec directly from ruby code?](https://www.ruby-forum.com/t/how-can-i-execute-rspec-directly-from-ruby-code/226219)

<div class="topic-metadata">

**Author:** [@Pablo\_Cantero](https://www.ruby-forum.com/u/Pablo_Cantero)\
**Replies:** 0\
**Last updated:** [May 3, 2011, 5:34am UTC](https://www.ruby-forum.com/t/how-can-i-execute-rspec-directly-from-ruby-code/226219 "2011-05-03T05:34:33Z")

</div>

Hi Can I execute rspec directly from ruby code? I would like to do it similar I can do using Test::Unit Test::Unit::UI::Console::TestRunner.run(MySuite.new(MyTestCase)) I was looking on internet how to execute it, bu…

---

## [Problems with integration test](https://www.ruby-forum.com/t/problems-with-integration-test/206468)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 4\
**Last updated:** [May 2, 2011, 7:53pm UTC](https://www.ruby-forum.com/t/problems-with-integration-test/206468 "2011-05-02T19:53:34Z")

</div>

Hi guys, I’m writing a integration test and i’m still have problems with a form field. The RSpec continues to show me a message bellow: Failure/Error: fill\_in :password\_confirmation, :with =\> @attr\[:password\_confirm…

---

## [Stubbing corner case](https://www.ruby-forum.com/t/stubbing-corner-case/206140)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 3\
**Last updated:** [May 2, 2011, 7:52pm UTC](https://www.ruby-forum.com/t/stubbing-corner-case/206140 "2011-05-02T19:52:20Z")

</div>

Hi! I was just talking to @dchelimsky over Twitter about a weird corner case we’ve run into on 1.3.1 (I’ve also been able to reproduce it in 1.3.2) So we’re using this gem called ClassyStruct that’s a higher performin…

---

## [Rspec contribution at railsconf?](https://www.ruby-forum.com/t/rspec-contribution-at-railsconf/206368)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [May 2, 2011, 3:49pm UTC](https://www.ruby-forum.com/t/rspec-contribution-at-railsconf/206368 "2011-05-02T15:49:23Z")

</div>

Hi, I was curious if there was any interest in organizing a ‘bugmash’, if you will, of any outstanding rspec features or issues during railsconf. (maybe there is something planned that i missed?) I’m not sure how m…

---

## [Rails helper problem](https://www.ruby-forum.com/t/rails-helper-problem/206448)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 2\
**Last updated:** [May 1, 2011, 10:24pm UTC](https://www.ruby-forum.com/t/rails-helper-problem/206448 "2011-05-01T22:24:33Z")

</div>

Hi guys, I’m building a application using subdomains feature like basecamp. To create the correct link reference I use a with\_subdomain function whch take the subdmain name and create a subdomain name like subdomain.…

---

## [Rspec-2.6.0.rc3 is released](https://www.ruby-forum.com/t/rspec-2-6-0-rc3-is-released/206415)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [May 1, 2011, 3:02pm UTC](https://www.ruby-forum.com/t/rspec-2-6-0-rc3-is-released/206415 "2011-05-01T15:02:47Z")

</div>

This release addresses issues that were raised in the rspec-core-2.6.0.rc2 release. rspec-core-2.6.0.rc3 full changelog: Enhancements Clean up messages for filters/tags. rspec-mocks-2.6.0.rc3 full changelog: B…

---

## [Mock/stub ActiveMerchant? (or other cascading/multiple inheritance situation)](https://www.ruby-forum.com/t/mock-stub-activemerchant-or-other-cascading-multiple-inheritance-situation/206364)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 4\
**Last updated:** [April 30, 2011, 8:37am UTC](https://www.ruby-forum.com/t/mock-stub-activemerchant-or-other-cascading-multiple-inheritance-situation/206364 "2011-04-30T08:37:01Z")

</div>

I am a bit new to mocking. I am trying to stub the ActiveMerchant::Billing::PaypalGateway#authorize method but not clear how to do it. This is my code and spec. This is the pertinent code: module Payment def gatewa…

---

## [Parallelize RSpec](https://www.ruby-forum.com/t/parallelize-rspec/206357)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 7\
**Last updated:** [April 29, 2011, 5:27pm UTC](https://www.ruby-forum.com/t/parallelize-rspec/206357 "2011-04-29T17:27:11Z")

</div>

I am looking for some advice on the best way to parallelize a large set of browser-based regression tests written in rspec. Just as a note; we are running these specs with RSpec 2.5 on JRuby 1.6.1. Our current set …

---

## [Difference between validate and validate\_on\_create](https://www.ruby-forum.com/t/difference-between-validate-and-validate-on-create/206355)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 3\
**Last updated:** [April 28, 2011, 10:54pm UTC](https://www.ruby-forum.com/t/difference-between-validate-and-validate-on-create/206355 "2011-04-28T22:54:23Z")

</div>

i just ran into a problem with some test, and i am not exactly sure why, but the difference happened when i changed my model validation from: validate :custom\_validation to: validate\_on\_create :custom\_validation can…

---

## [Before(:each) \<- need some clarification](https://www.ruby-forum.com/t/before-each-need-some-clarification/206314)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 9\
**Last updated:** [April 28, 2011, 3:02pm UTC](https://www.ruby-forum.com/t/before-each-need-some-clarification/206314 "2011-04-28T15:02:10Z")

</div>

i am setting up a few objects that are interrelated for use in an rspec test… something like: describe Dimension do before(:each) do text = “string here” end it “should puts string” do puts text end end when i…

---

## [New goodness, Capybara::RSpecMatchers in helper specs](https://www.ruby-forum.com/t/new-goodness-capybara-rspecmatchers-in-helper-specs/206318)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [April 28, 2011, 12:15am UTC](https://www.ruby-forum.com/t/new-goodness-capybara-rspecmatchers-in-helper-specs/206318 "2011-04-28T00:15:57Z")

</div>

This is exciting news!! (“this adds capybara matchers to view and helper specs”) Now, if I just knew how to take advantage of it? Do I have to require something else in spec\_helper? I have already added included ge…

---

## [Slow test suite with Ruby 1.9.2 and Rspec 2.5](https://www.ruby-forum.com/t/slow-test-suite-with-ruby-1-9-2-and-rspec-2-5/206173)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 10\
**Last updated:** [April 27, 2011, 11:46pm UTC](https://www.ruby-forum.com/t/slow-test-suite-with-ruby-1-9-2-and-rspec-2-5/206173 "2011-04-27T23:46:57Z")

</div>

Hi, I’ve started a Rails 3 project using Ruby 1.9.2 and Rspec 2 and my test suite is now growing and I’m not happy with the amount of time it is tooking to run. I did a benchmark of it with Ruby Enterprise Edition 1.8…

---

## [Mocking/Stubbing behavior question](https://www.ruby-forum.com/t/mocking-stubbing-behavior-question/206204)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 7\
**Last updated:** [April 27, 2011, 5:47pm UTC](https://www.ruby-forum.com/t/mocking-stubbing-behavior-question/206204 "2011-04-27T17:47:10Z")

</div>

I’ve run into some strange behavior in porting my specs from rspec to rspec2. I am wondering if I am doing something wrong, or if I’ve misunderstood something, or if this is some kind of bug. Look at the specs below:…

---

## [Stubbing Model.find(id) issues](https://www.ruby-forum.com/t/stubbing-model-find-id-issues/206165)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 4\
**Last updated:** [April 26, 2011, 5:57am UTC](https://www.ruby-forum.com/t/stubbing-model-find-id-issues/206165 "2011-04-26T05:57:35Z")

</div>

I’ve started a fresh rails app with Employee belongs\_to Company. Here is the spec: describe Employee do example “stub should work with find(id)” do company = mock\_model Company Company.stub!(:find).with(company.id).…

---

## [New, clueless, confused.and thinking JQuery+MongoID is breaking my template code examples](https://www.ruby-forum.com/t/new-clueless-confused-and-thinking-jquery-mongoid-is-breaking-my-template-code-examples/203358)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [April 26, 2011, 2:00am UTC](https://www.ruby-forum.com/t/new-clueless-confused-and-thinking-jquery-mongoid-is-breaking-my-template-code-examples/203358 "2011-04-26T02:00:19Z")

</div>

If this is the wrong forum for this type of question please let me know…I don’t want to ruffle any feathers… I’ve been teaching myself RSpec and quite enjoying the ‘new’ book…but as I try to put it into practice I get…

---

## [Trying to fix NullDB for Rails3/RSpec2.5.1](https://www.ruby-forum.com/t/trying-to-fix-nulldb-for-rails3-rspec2-5-1/206137)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 3\
**Last updated:** [April 23, 2011, 6:33pm UTC](https://www.ruby-forum.com/t/trying-to-fix-nulldb-for-rails3-rspec2-5-1/206137 "2011-04-23T18:33:36Z")

</div>

I’m in the midst of upgrading an app from Rails 2.3 to Rails 3, and as part of the process, from RSpec to RSpec2. One thing that seems to have broken for me is the use of NullDB to nullify the database contextually fo…

---

## [Problems with latest version of RSpec: uninitialized constant ActiveRecord](https://www.ruby-forum.com/t/problems-with-latest-version-of-rspec-uninitialized-constant-activerecord/206034)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [April 22, 2011, 9:57pm UTC](https://www.ruby-forum.com/t/problems-with-latest-version-of-rspec-uninitialized-constant-activerecord/206034 "2011-04-22T21:57:32Z")

</div>

After doing a bundle update today I have hit a problem that I think is based in RSpec and I have not been able to solve. I can’t find any information on this via Google, Stackoverflow or other RSpec discussions so I t…

---

## [Faking Files, Data, Git interractions with mocks/stubs/fixtures](https://www.ruby-forum.com/t/faking-files-data-git-interractions-with-mocks-stubs-fixtures/205968)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 2\
**Last updated:** [April 22, 2011, 1:33am UTC](https://www.ruby-forum.com/t/faking-files-data-git-interractions-with-mocks-stubs-fixtures/205968 "2011-04-22T01:33:24Z")

</div>

I’m new to ruby and just learning cucumber and rspec. I have some examples(tests) that need to fake a directory structure and file grouping, fake a properly formatted json file and fake a ruby-git interraction (git.fe…

---

## [Routing assertions](https://www.ruby-forum.com/t/routing-assertions/206064)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [April 21, 2011, 12:46pm UTC](https://www.ruby-forum.com/t/routing-assertions/206064 "2011-04-21T12:46:08Z")

</div>

Hi Thanks for help me out I have two routes : match ‘admin/categories’ =\> ‘admin#categories’, :as =\> ‘admin\_category’ match ‘admin/categories/:sub\_category’ =\> ‘admin#categories’ In rspec For first route a…

---

## [Stubbing find in ActiveRecord considering only the first argument](https://www.ruby-forum.com/t/stubbing-find-in-activerecord-considering-only-the-first-argument/206050)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [April 21, 2011, 4:19am UTC](https://www.ruby-forum.com/t/stubbing-find-in-activerecord-considering-only-the-first-argument/206050 "2011-04-21T04:19:25Z")

</div>

For some unknown (yet) reason, an association is trying to call Model.find(1, conditions: nil) instead of Model.find(1), which doesn’t allow me to write “Model.stub!(:find).with(1).and\_returns(@model)”. Instead of try…

---

## [Added new cool matcher into my framework WatirSplash - #in](https://www.ruby-forum.com/t/added-new-cool-matcher-into-my-framework-watirsplash-in/205846)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 11\
**Last updated:** [April 20, 2011, 6:51pm UTC](https://www.ruby-forum.com/t/added-new-cool-matcher-into-my-framework-watirsplash-in/205846 "2011-04-20T18:51:40Z")

</div>

Hello! I’ve just added a new cool matcher #in into my framework WatirSplash and thought that this could be integrated into RSpec directly actually if there’s any interest. WatirSplash uses Watir (or Watir-like) frame…

---

## [Rails 3 / RSpec 2 use\_transactional\_fixtures and after\_commit](https://www.ruby-forum.com/t/rails-3-rspec-2-use-transactional-fixtures-and-after-commit/201795)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 4\
**Last updated:** [April 20, 2011, 5:30pm UTC](https://www.ruby-forum.com/t/rails-3-rspec-2-use-transactional-fixtures-and-after-commit/201795 "2011-04-20T17:30:31Z")

</div>

We’re migrating a Rails 2.3.x application to Rails 3 and RSpec 2.x. In Rails 2.3.x we were using https://github.com/freelancing-god/after\_commit to provide after\_commit functionality (now provided by Rails 3). The pl…

---

## [RSpec/Webrat Checking output is properly escaped](https://www.ruby-forum.com/t/rspec-webrat-checking-output-is-properly-escaped/205997)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [April 20, 2011, 3:43pm UTC](https://www.ruby-forum.com/t/rspec-webrat-checking-output-is-properly-escaped/205997 "2011-04-20T15:43:55Z")

</div>

I want to test that the JSON response from a create action is sanitized properly, but rspec or webrat appears to be parsing the output into proper HTML chars instead of escaped characters. I have verified that it esc…

---

## [How to pass command-line parameter to Rspec script?](https://www.ruby-forum.com/t/how-to-pass-command-line-parameter-to-rspec-script/205996)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [April 20, 2011, 8:18am UTC](https://www.ruby-forum.com/t/how-to-pass-command-line-parameter-to-rspec-script/205996 "2011-04-20T08:18:24Z")

</div>

Dear all, Anyone know how to pass command-line parameter to Rspec script? For example: I want to run the test.rb script. Suppose there is a parameter that is set in test.rb script is sleep. For the convenience,I want…

---

## ["can't convert Symbol into Integer" error with Rspec and Mongoid](https://www.ruby-forum.com/t/cant-convert-symbol-into-integer-error-with-rspec-and-mongoid/205979)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [April 20, 2011, 1:36am UTC](https://www.ruby-forum.com/t/cant-convert-symbol-into-integer-error-with-rspec-and-mongoid/205979 "2011-04-20T01:36:29Z")

</div>

I’m running into this error while trying to run a unit test on a Mongoid database: def show id=params\[:id\] @user=User.find(:first,id) end My test before(:each) do @user = Fabricate(:user) sign\_in @user end … …

---

## [Samples\_table](https://www.ruby-forum.com/t/samples-table/205964)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [April 19, 2011, 7:45pm UTC](https://www.ruby-forum.com/t/samples-table/205964 "2011-04-19T19:45:19Z")

</div>

Hey guys, I’m currently working on a project, that we use rspec. We don’t like cucumber too much, because it seems too “verbose”, but we like a lot the cucumber’s table, that we can use to specify some scenarios. In …

---

## [Rspec execution speed footprint](https://www.ruby-forum.com/t/rspec-execution-speed-footprint/205827)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 2\
**Last updated:** [April 17, 2011, 2:52am UTC](https://www.ruby-forum.com/t/rspec-execution-speed-footprint/205827 "2011-04-17T02:52:22Z")

</div>

Hi, I would like to figure out if it is possible for me to run my specs faster than it currently is. Before start optimizing my specs for speed, I tried to figure out what was the speed footprint of Rspec boot process…

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

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