# RSpec

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

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

---

## [2 almost identical tests need different assertions to work and I can't figure out why](https://www.ruby-forum.com/t/2-almost-identical-tests-need-different-assertions-to-work-and-i-cant-figure-out-why/220687)

<div class="topic-metadata">

**Author:** [@aris](https://www.ruby-forum.com/u/aris)\
**Replies:** 0\
**Last updated:** [June 16, 2012, 11:38pm UTC](https://www.ruby-forum.com/t/2-almost-identical-tests-need-different-assertions-to-work-and-i-cant-figure-out-why/220687 "2012-06-16T23:38:26Z")

</div>

Hey everyone, I am learning bdd and do deffently like it on the whole. I ran into a strange situation I got around it but it left a question in my mind and I would appreciate help in removing it :wink: So hear is what…

---

## [Rspec include paths](https://www.ruby-forum.com/t/rspec-include-paths/220427)

<div class="topic-metadata">

**Author:** [@aris](https://www.ruby-forum.com/u/aris)\
**Replies:** 0\
**Last updated:** [June 8, 2012, 11:03pm UTC](https://www.ruby-forum.com/t/rspec-include-paths/220427 "2012-06-08T23:03:07Z")

</div>

'm using rspec 2.10 with Rails 3.2.1 and have problems with classes not being found. I have put a class called DbTasks under a dir app/util. Under spec, i’ve created file util/db\_tasks\_spec.rb which runs afer i includ…

---

## [RSpec fails testing on ActiveRecord](https://www.ruby-forum.com/t/rspec-fails-testing-on-activerecord/220128)

<div class="topic-metadata">

**Author:** [@Gurdipe\_D](https://www.ruby-forum.com/u/Gurdipe_D)\
**Replies:** 0\
**Last updated:** [May 29, 2012, 5:49pm UTC](https://www.ruby-forum.com/t/rspec-fails-testing-on-activerecord/220128 "2012-05-29T17:49:15Z")

</div>

Hi, I’m new to RoR, and following the RoR 3.2 Tutorial from Michael H… When it comes to execute testing (chap. 3.2.1), RSpec returns a hundred of errors starting with this one (and all looking the same more or less): …

---

## [Received unexpected message :id= with (20)](https://www.ruby-forum.com/t/received-unexpected-message-id-with-20/219985)

<div class="topic-metadata">

**Author:** [@Gurdipe\_D](https://www.ruby-forum.com/u/Gurdipe_D)\
**Replies:** 0\
**Last updated:** [May 24, 2012, 12:27am UTC](https://www.ruby-forum.com/t/received-unexpected-message-id-with-20/219985 "2012-05-24T00:27:45Z")

</div>

Please help me to understand this error message: PostsController#create when logged in should create a new post and redirect to a successful message page Failure/Error: post ‘create’, { post: {title: ‘New post’, Moc…

---

## [Rspec-mocks and rspec-rails-2.10.1 are released!](https://www.ruby-forum.com/t/rspec-mocks-and-rspec-rails-2-10-1-are-released/219509)

<div class="topic-metadata">

**Author:** [@Gurdipe\_D](https://www.ruby-forum.com/u/Gurdipe_D)\
**Replies:** 1\
**Last updated:** [May 8, 2012, 8:15pm UTC](https://www.ruby-forum.com/t/rspec-mocks-and-rspec-rails-2-10-1-are-released/219509 "2012-05-08T20:15:06Z")

</div>

These are patch releases recommended for anybody who has already upgraded to 2.10. rspec-mocks-2.10.1 full changelog: Bug fixes fix regression of edge case behavior fixed failure of object.should\_receive(:messa…

---

## [Testing parameter passed to controller new method (undefined method 'stringify\_keys')](https://www.ruby-forum.com/t/testing-parameter-passed-to-controller-new-method-undefined-method-stringify-keys/219004)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [April 18, 2012, 4:06pm UTC](https://www.ruby-forum.com/t/testing-parameter-passed-to-controller-new-method-undefined-method-stringify-keys/219004 "2012-04-18T16:06:47Z")

</div>

I’m trying to test passing a parameter to the new method of my controller and am coming up with the “undefined method ‘stringify\_keys’” error when I use this code: get “new”, { :company\_id =\> ‘1’ } I have seen other …

---

## [Simple code dosn't work](https://www.ruby-forum.com/t/simple-code-dosnt-work/216365)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [April 5, 2012, 12:02am UTC](https://www.ruby-forum.com/t/simple-code-dosnt-work/216365 "2012-04-05T00:02:05Z")

</div>

This is my 1st post. So please don’t mess with me, if I did something wrong. Really need help on this one. Thx! using Ruby 1.9.3, Rails 3.2.1, RSpec 2.8.0 require ‘rubygems’ require ‘rspec’ test\_array = \[1,2,3,4,5…

---

## [The test is failing Whyy?](https://www.ruby-forum.com/t/the-test-is-failing-whyy/218565)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [April 4, 2012, 12:47pm UTC](https://www.ruby-forum.com/t/the-test-is-failing-whyy/218565 "2012-04-04T12:47:58Z")

</div>

I am actually a newbie in Ruby rails nd Rspec… So it could be something basic… Plz helpp This is my rspec test code:: describe “GET new” do it “assigns a new kase as @kase” do get :new assigns(:kase).should be\_a\_ne…

---

## [Isolating controller tests from models](https://www.ruby-forum.com/t/isolating-controller-tests-from-models/218425)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [March 31, 2012, 7:11am UTC](https://www.ruby-forum.com/t/isolating-controller-tests-from-models/218425 "2012-03-31T07:11:45Z")

</div>

This is a rehash of a question I posed at: ruby on rails 3 - isolating controller tests from models - Stack Overflow The basic question: If I have a FoosController and a Foo model, can I run FoosController rspec tests…

---

## [Sufficiently tested?](https://www.ruby-forum.com/t/sufficiently-tested/217710)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [March 27, 2012, 10:40am UTC](https://www.ruby-forum.com/t/sufficiently-tested/217710 "2012-03-27T10:40:06Z")

</div>

Hi everybody, I have a general question about how many different cases have to be covered in one Example. Considering the famous Fizzbuzz program, you should test if your output is either “Fizz”, “buzz”, “Fizzbuzz” o…

---

## [Mocking a reference to a polymorphic model?](https://www.ruby-forum.com/t/mocking-a-reference-to-a-polymorphic-model/218157)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [March 22, 2012, 6:27pm UTC](https://www.ruby-forum.com/t/mocking-a-reference-to-a-polymorphic-model/218157 "2012-03-22T18:27:23Z")

</div>

The basic question: how do you mock a reference to a polymorphic class in RSpec? Trying the obvious thing leads to an error of the form: undefined method \`base\_class’ for Post:Class === The details: file: app/models…

---

## [Rspec not loading fixtures](https://www.ruby-forum.com/t/rspec-not-loading-fixtures/218156)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [March 22, 2012, 3:54pm UTC](https://www.ruby-forum.com/t/rspec-not-loading-fixtures/218156 "2012-03-22T15:54:16Z")

</div>

I am taking over a code base and am trying to run the tests. I am somewhat new to RSpec so this might be a trivial problem. Basically I can tell that the fixtures are not getting loaded. All 100 tests fail with a simi…

---

## [What RSpec approach could I use for this](https://www.ruby-forum.com/t/what-rspec-approach-could-i-use-for-this/217521)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [March 3, 2012, 10:55pm UTC](https://www.ruby-forum.com/t/what-rspec-approach-could-i-use-for-this/217521 "2012-03-03T22:55:55Z")

</div>

Background: So I have roughly: class A def calculate\_input\_datetimes # do stuff to calculate datetimes - then for each one identified process\_datetimes(my\_datetime\_start, my\_datetime\_end) end def process\_datetimes…

---

## [Using fakeweb only if flag is given](https://www.ruby-forum.com/t/using-fakeweb-only-if-flag-is-given/217417)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [March 1, 2012, 11:00am UTC](https://www.ruby-forum.com/t/using-fakeweb-only-if-flag-is-given/217417 "2012-03-01T11:00:56Z")

</div>

Hi, I’m using the gem fakeweb to simulate the comunication between my ruby-app and different other apps when running my rspecs. The advantage is, that the specs work much faster and it is not nessessary that the othe…

---

## [Testing Signin for Admin\_Employee](https://www.ruby-forum.com/t/testing-signin-for-admin-employee/217192)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [February 23, 2012, 5:32pm UTC](https://www.ruby-forum.com/t/testing-signin-for-admin-employee/217192 "2012-02-23T17:32:06Z")

</div>

I am following railstutorial 2nd edition and in it we have a Signin test in our integration tests as follows: require ‘spec\_helper’ describe “Authentication” do subject { page } describe "signin" do before { vis…

---

## [Such a simple test fails. But why?](https://www.ruby-forum.com/t/such-a-simple-test-fails-but-why/216849)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [February 16, 2012, 11:14am UTC](https://www.ruby-forum.com/t/such-a-simple-test-fails-but-why/216849 "2012-02-16T11:14:12Z")

</div>

I just tried to integrate a simple test to check some options passed as argument to a class to be executed: require 'spec\_helper' module PropertyInjector describe Options do describe "#source folder option" do …

---

## [Should I use cucumber or Controller RSpecs or both?](https://www.ruby-forum.com/t/should-i-use-cucumber-or-controller-rspecs-or-both/216770)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [February 15, 2012, 10:23am UTC](https://www.ruby-forum.com/t/should-i-use-cucumber-or-controller-rspecs-or-both/216770 "2012-02-15T10:23:42Z")

</div>

Hi All, I’d like to get some other’s opinions on testing controllers. Say I have a model and I want to prevent deletion of instances of it. The controllers’s destroy action simply redirects to an error page - nothing…

---

## [RSpec spec works on rails 3.2.0, fails on 3.2.0](https://www.ruby-forum.com/t/rspec-spec-works-on-rails-3-2-0-fails-on-3-2-0/216812)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [February 14, 2012, 8:14pm UTC](https://www.ruby-forum.com/t/rspec-spec-works-on-rails-3-2-0-fails-on-3-2-0/216812 "2012-02-14T20:14:22Z")

</div>

I have a spec that passes in rails 3.2.0, but fails in 3.2.1, and I have no idea why. Here’s the spec: it “can be shown on the company menu” do doclib = Factory(:document\_library, title: ‘Test’, menu: false, company…

---

## [Rspec testing (gunfight at coral)](https://www.ruby-forum.com/t/rspec-testing-gunfight-at-coral/216677)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [February 10, 2012, 3:30pm UTC](https://www.ruby-forum.com/t/rspec-testing-gunfight-at-coral/216677 "2012-02-10T15:30:49Z")

</div>

Can any one give me an explanation on whats going on in this exercise. And any advice on how i should go about it. I dont need any exact codes just yet. But at least a good idea on how to start will be good Thanks Ex…

---

## [Render\_template on create and update action - unexpected result with namespaced controllers](https://www.ruby-forum.com/t/render-template-on-create-and-update-action-unexpected-result-with-namespaced-controllers/215105)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 2\
**Last updated:** [January 29, 2012, 11:22pm UTC](https://www.ruby-forum.com/t/render-template-on-create-and-update-action-unexpected-result-with-namespaced-controllers/215105 "2012-01-29T23:22:03Z")

</div>

All, I’ve been having issues with my namespaced controllers and specs. I receive the following errors only on my create and update actions (with invalid parameters) and only on my namespaced controllers. My non-nam…

---

## [RSpec Requestable Examples](https://www.ruby-forum.com/t/rspec-requestable-examples/216182)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 3\
**Last updated:** [January 29, 2012, 9:46pm UTC](https://www.ruby-forum.com/t/rspec-requestable-examples/216182 "2012-01-29T21:46:21Z")

</div>

I would be interested to hear any thoughts from the community about the ability to request specific examples from a shared example group as expressed in the rspec-requestable-examples gem. Here’s the post that introdu…

---

## [Rails 3.2.1 breaks stub?](https://www.ruby-forum.com/t/rails-3-2-1-breaks-stub/216190)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 3\
**Last updated:** [January 29, 2012, 4:04pm UTC](https://www.ruby-forum.com/t/rails-3-2-1-breaks-stub/216190 "2012-01-29T16:04:48Z")

</div>

Hi, First things first: Thanks for the GREAT gem and all of the work that you and others put into this - it is much appreciated! I read on David C.'s blog that Rails 3.2 broke “stub\_model” and that upgrading to rspec…

---

## [Method calls count weirdness](https://www.ruby-forum.com/t/method-calls-count-weirdness/216173)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [January 27, 2012, 6:35pm UTC](https://www.ruby-forum.com/t/method-calls-count-weirdness/216173 "2012-01-27T18:35:37Z")

</div>

Hi, I see a really weird behavior there, the following test passes: it “test”, :focus do doc = Factory.build(:document) doc.should\_receive(:update\_project!).exactly(2).times doc.save end But when I do: def update…

---

## [What is the pattern for testing a time argument using argument matcher](https://www.ruby-forum.com/t/what-is-the-pattern-for-testing-a-time-argument-using-argument-matcher/216146)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 2\
**Last updated:** [January 26, 2012, 5:47pm UTC](https://www.ruby-forum.com/t/what-is-the-pattern-for-testing-a-time-argument-using-argument-matcher/216146 "2012-01-26T17:47:05Z")

</div>

Say I do: object.method 5.days.ago In the test I want to test using should\_receive like: object.should\_receive(:method).with(5.days.ago) This will fail since two time objects aren’t exact the same. What is the gener…

---

## [Id getting overwritten with 0 when testing](https://www.ruby-forum.com/t/id-getting-overwritten-with-0-when-testing/216095)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 15\
**Last updated:** [January 26, 2012, 5:09am UTC](https://www.ruby-forum.com/t/id-getting-overwritten-with-0-when-testing/216095 "2012-01-26T05:09:53Z")

</div>

My code that saves a record works fine in development or production, or from the console. I can take the code in my test and run it in the console, and it works fine. But when I run it under a model rspec, the ids are…

---

## [Nested resource view spec seems to be referring to a non-existent route](https://www.ruby-forum.com/t/nested-resource-view-spec-seems-to-be-referring-to-a-non-existent-route/216031)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [January 23, 2012, 11:51am UTC](https://www.ruby-forum.com/t/nested-resource-view-spec-seems-to-be-referring-to-a-non-existent-route/216031 "2012-01-23T11:51:37Z")

</div>

Hi all, In a view spec for a nested resource, do I need to instantiate/stub the parent resource before I stub the nested resource? I am asking this because all my view specs are failing for a new nested resource I ha…

---

## [NoMethodError: undefined method \`expect'](https://www.ruby-forum.com/t/nomethoderror-undefined-method-expect/215866)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [January 18, 2012, 12:30am UTC](https://www.ruby-forum.com/t/nomethoderror-undefined-method-expect/215866 "2012-01-18T00:30:26Z")

</div>

Ideas? ruby-1.9.2-p290 :002 \> require ‘rspec’ =\> true ruby-1.9.2-p290 :003 \> RSpec::Version::STRING =\> “2.8.0” ruby-1.9.2-p290 :004 \> describe ‘division by zero’ do ruby-1.9.2-p290 :005 \> expect { 2/0 }.to rais…

---

## [List of examples](https://www.ruby-forum.com/t/list-of-examples/215863)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [January 17, 2012, 10:06pm UTC](https://www.ruby-forum.com/t/list-of-examples/215863 "2012-01-17T22:06:28Z")

</div>

Hi all, I want to write a test grid over rspec && spork. For example we have grid with several nodes. Each has spork running on it. Master node accept some filters like --tag tag:value to run It select all examples …

---

## [Does jruby rspec have to use selenium?](https://www.ruby-forum.com/t/does-jruby-rspec-have-to-use-selenium/215823)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 2\
**Last updated:** [January 17, 2012, 7:23am UTC](https://www.ruby-forum.com/t/does-jruby-rspec-have-to-use-selenium/215823 "2012-01-17T07:23:22Z")

</div>

With jruby and rspec requests, do you have to use selenium webdriver? I’m confused, with ruby and rubyonrails using cucumber with capybara, I didn’t have to set the default driver, what was it using and can i use that …

---

## [Rspec output on windows](https://www.ruby-forum.com/t/rspec-output-on-windows/215816)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 2\
**Last updated:** [January 16, 2012, 10:13pm UTC](https://www.ruby-forum.com/t/rspec-output-on-windows/215816 "2012-01-16T22:13:36Z")

</div>

I have rails 3.1.3 and rspec 2.8.0 on windows 7 (32bit) installed. When running rspec I receive the following output: ←\[32m.←\[0m←\[32m.←\[0m Finished in 0.33 seconds ←\[32m2 examples, 0 failures←\[0m I have no glue how …

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

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