# RSpec

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

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

---

## [Eq or == which is the preferred idiom?](https://www.ruby-forum.com/t/eq-or-which-is-the-preferred-idiom/209696)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 3\
**Last updated:** [July 20, 2011, 11:10pm UTC](https://www.ruby-forum.com/t/eq-or-which-is-the-preferred-idiom/209696 "2011-07-20T23:10:40Z")

</div>

for comparing objects properties, which notation is considered most idiomatic and best practice? Thanks, Jed S.

---

## [Testing complex-form-example helpers](https://www.ruby-forum.com/t/testing-complex-form-example-helpers/209620)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 4\
**Last updated:** [July 19, 2011, 2:56am UTC](https://www.ruby-forum.com/t/testing-complex-form-example-helpers/209620 "2011-07-19T02:56:25Z")

</div>

I am new to test-driven development and rspec, so I am writing an application\[1\] to practice. One of the patterns I am trying to implement is from Ryan B.’ complex-form-examples\[2\]. Ryan’s example doesn’t have any tes…

---

## [How to test block parameters which is sending to method with arguments?](https://www.ruby-forum.com/t/how-to-test-block-parameters-which-is-sending-to-method-with-arguments/209549)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 3\
**Last updated:** [July 18, 2011, 1:59pm UTC](https://www.ruby-forum.com/t/how-to-test-block-parameters-which-is-sending-to-method-with-arguments/209549 "2011-07-18T13:59:57Z")

</div>

Hai I would like to know how to test block parameters send to method with arguments… Problem: Here i would like to get weather report basing on city\_name. here my method name is request and i am sending :get\_citie…

---

## [\[Cucumber\] ANN: Cucumber with pure Java](https://www.ruby-forum.com/t/cucumber-ann-cucumber-with-pure-java/163862)

<div class="topic-metadata">

**Author:** [@aslakhellesoy](https://www.ruby-forum.com/u/aslakhellesoy)\
**Replies:** 5\
**Last updated:** [July 16, 2011, 2:47pm UTC](https://www.ruby-forum.com/t/cucumber-ann-cucumber-with-pure-java/163862 "2011-07-16T14:47:48Z")

</div>

Big news for all Java programmers out there. Now you can use Cucumber with pure Java! That’s right, you don’t have to write a single line of Ruby! (1) All of your step definitions can be written as annotated methods i…

---

## [Render expectation in Controller spec](https://www.ruby-forum.com/t/render-expectation-in-controller-spec/209459)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 3\
**Last updated:** [July 15, 2011, 2:36pm UTC](https://www.ruby-forum.com/t/render-expectation-in-controller-spec/209459 "2011-07-15T14:36:56Z")

</div>

Hello All, I am a rspec beginner and I am trying to find a way out to write render expectation in controller spec.All methods that I used seem to give me a No Method error. My controller code is as follows http://pa…

---

## [Rails: action helper for controller specs](https://www.ruby-forum.com/t/rails-action-helper-for-controller-specs/209417)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 2\
**Last updated:** [July 13, 2011, 7:52pm UTC](https://www.ruby-forum.com/t/rails-action-helper-for-controller-specs/209417 "2011-07-13T19:52:05Z")

</div>

Hey guys, just wrote a helper for controller specs in the rails. Link to the gist action helper for rspec · GitHub - to view with syntax highlight. Helper +action+ allows you to write something like describe “GET i…

---

## [Specing scopes that use includes()](https://www.ruby-forum.com/t/specing-scopes-that-use-includes/209371)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [July 13, 2011, 1:02pm UTC](https://www.ruby-forum.com/t/specing-scopes-that-use-includes/209371 "2011-07-13T13:02:56Z")

</div>

I’m a newcomer to the list. Appologies if this has been discussed before, but all I could find with regards to specing scopes relates to those that filter records or apply sorting. What’s the best way to spec a scope …

---

## [How to write render expectation in Controller Spec?](https://www.ruby-forum.com/t/how-to-write-render-expectation-in-controller-spec/209349)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 2\
**Last updated:** [July 13, 2011, 8:58am UTC](https://www.ruby-forum.com/t/how-to-write-render-expectation-in-controller-spec/209349 "2011-07-13T08:58:10Z")

</div>

Hello All, I am a rspec beginner and I am trying to find a way out to write render expectation in controller spec.I used the following ways render ‘/channels/createchannel.html.erb’ view.should\_receive(:render).with(…

---

## [Rspec2: checking a view calls a helper](https://www.ruby-forum.com/t/rspec2-checking-a-view-calls-a-helper/209203)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [July 13, 2011, 1:54am UTC](https://www.ruby-forum.com/t/rspec2-checking-a-view-calls-a-helper/209203 "2011-07-13T01:54:27Z")

</div>

I have a view which calls a helper. Lets’ call it “abc” So in my view, I write =abc #(I’m using haml) When I run the view in my webserver, all works fine But when I run my view spec, it tells me undefined local vari…

---

## [Rspec or Test:Unit](https://www.ruby-forum.com/t/rspec-or-test-unit/209279)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 2\
**Last updated:** [July 12, 2011, 11:44am UTC](https://www.ruby-forum.com/t/rspec-or-test-unit/209279 "2011-07-12T11:44:05Z")

</div>

Hello All, I want to know which out of Rspec and Test:Unit is the most used in the industry for unit/integration testing and why? Regards Chandrika

---

## [Help with the rspec and the xpath](https://www.ruby-forum.com/t/help-with-the-rspec-and-the-xpath/209278)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [July 10, 2011, 12:02pm UTC](https://www.ruby-forum.com/t/help-with-the-rspec-and-the-xpath/209278 "2011-07-10T12:02:51Z")

</div>

Hi Geeks, i need help with the rspec, Some time i having a problem with locating the element with the xpath Same element, i can able to select some time where some time i can not. Is there a bug or i need to do some s…

---

## [Feature request: easier to discover line number](https://www.ruby-forum.com/t/feature-request-easier-to-discover-line-number/208816)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 2\
**Last updated:** [July 7, 2011, 8:41pm UTC](https://www.ruby-forum.com/t/feature-request-easier-to-discover-line-number/208816 "2011-07-07T20:41:20Z")

</div>

Hello all. I love rspec 2’s new output. And have a tiny suggestion for it. Currently a failure trace looks like this by default: SensibleSwing::MainWindow should not show the normal buttons in create mode Failure/…

---

## [Caching in Rails by Default](https://www.ruby-forum.com/t/caching-in-rails-by-default/209019)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [July 3, 2011, 11:59am UTC](https://www.ruby-forum.com/t/caching-in-rails-by-default/209019 "2011-07-03T11:59:38Z")

</div>

So, maybe I need to go to the rails list with this, but I hit my error while testing so I figured I’d ask here first. Basically, Rails.cache.fetch is being persisted by default in my rails project between rspec runs.…

---

## [Can't access route variables](https://www.ruby-forum.com/t/cant-access-route-variables/209014)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [July 3, 2011, 9:56am UTC](https://www.ruby-forum.com/t/cant-access-route-variables/209014 "2011-07-03T09:56:40Z")

</div>

I’m testing methods in my ApplicationController using anonymous controller class (not sure if that’s relevant). I’ve somehow broken something such that I do not have access to the routing variables that rails generat…

---

## [Collection membership Error](https://www.ruby-forum.com/t/collection-membership-error/209005)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [July 2, 2011, 6:56pm UTC](https://www.ruby-forum.com/t/collection-membership-error/209005 "2011-07-02T18:56:46Z")

</div>

Using rspec version 2.6.4 I get an error with the Collection membership. Example: \[1,2\].should include(1) TypeError: wrong argument type Fixnum (expected Module) from (irb):1:in include' from (irb):1 from /home/a…

---

## [Feature request: warn on failed arity](https://www.ruby-forum.com/t/feature-request-warn-on-failed-arity/208900)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [June 30, 2011, 1:46am UTC](https://www.ruby-forum.com/t/feature-request-warn-on-failed-arity/208900 "2011-06-30T01:46:25Z")

</div>

Hello. Might be nice if the following warned: class A def go a, b end end a = A.new a.stub!(go) { } a.go # doesn’t have enough parameters, arity is wrong. Might be useful at times. Thanks much! -roger-

---

## ["user" received unexpected message :created\_at with (no args)](https://www.ruby-forum.com/t/user-received-unexpected-message-created-at-with-no-args/208892)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 4\
**Last updated:** [June 29, 2011, 9:29pm UTC](https://www.ruby-forum.com/t/user-received-unexpected-message-created-at-with-no-args/208892 "2011-06-29T21:29:31Z")

</div>

My method looks like: def self.can\_do\_this(user) return false if user.nil? ( (Time.now \>= user.created\_at) ? true : false ) end my spec: it “should allow you to do this” do user = stub(“user”) user.stub(:nil?).…

---

## [Time out long running tests using Rspec 2](https://www.ruby-forum.com/t/time-out-long-running-tests-using-rspec-2/208559)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [June 28, 2011, 1:10am UTC](https://www.ruby-forum.com/t/time-out-long-running-tests-using-rspec-2/208559 "2011-06-28T01:10:45Z")

</div>

I’m cross posting a query on timing out tests that came up on our local ruby list: In RSpec1, there was an option “timeout” using which we can fail all the long running tests i.e. “spec --timeout 2 spec/” will fail …

---

## [Tags and spec\_helper](https://www.ruby-forum.com/t/tags-and-spec-helper/208698)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [June 25, 2011, 4:24pm UTC](https://www.ruby-forum.com/t/tags-and-spec-helper/208698 "2011-06-25T16:24:54Z")

</div>

I’ve been trying to separate out some fast specs in a Rails app in a Gary Bernhardt style\[1\], and I experimented with using tags. The problem with using tags is that in order to scan the specs for examples that match …

---

## [Model Validation fails (correctly) in rails console but not in rspec](https://www.ruby-forum.com/t/model-validation-fails-correctly-in-rails-console-but-not-in-rspec/208724)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [June 25, 2011, 1:18pm UTC](https://www.ruby-forum.com/t/model-validation-fails-correctly-in-rails-console-but-not-in-rspec/208724 "2011-06-25T13:18:18Z")

</div>

Hi, I have been really stuck on this problem. My validation for my model fails (like it should) when I’m testing it out in rails console, but my rspec example fails because it validates anyway (which it shouldn’t). W…

---

## [Is there a way to run \`let\` once per context?](https://www.ruby-forum.com/t/is-there-a-way-to-run-let-once-per-context/208693)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 3\
**Last updated:** [June 24, 2011, 3:17pm UTC](https://www.ruby-forum.com/t/is-there-a-way-to-run-let-once-per-context/208693 "2011-06-24T15:17:16Z")

</div>

hello, I have a monolithic test that looks like this: ====== describe Model do describe “#method” do let!(:expensive) { … } it "should do a lot of things" do expensive.should be\_foo expensive.should be\_bar ex…

---

## [Re: stubbing /mocking ldap within a method](https://www.ruby-forum.com/t/re-stubbing-mocking-ldap-within-a-method/208627)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [June 22, 2011, 11:03pm UTC](https://www.ruby-forum.com/t/re-stubbing-mocking-ldap-within-a-method/208627 "2011-06-22T23:03:54Z")

</div>

Joe, Here is the solution I decided to go with, for now: describe Collaborator do describe “class\_methods” do subject {Collaborator} it { should respond\_to(:search\_ldap).with(1).argument } it "should format the sea…

---

## [How do I change www.example.com in rspec tests?](https://www.ruby-forum.com/t/how-do-i-change-www-example-com-in-rspec-tests/208622)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [June 22, 2011, 10:20pm UTC](https://www.ruby-forum.com/t/how-do-i-change-www-example-com-in-rspec-tests/208622 "2011-06-22T22:20:04Z")

</div>

It looks like request.host is set to www.example.com, how do I change that? I want to change it for all tests, and it seems that request is only available within the tests themselves (tried to do it in RSpec.configur…

---

## [Formatters extra data](https://www.ruby-forum.com/t/formatters-extra-data/208623)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [June 22, 2011, 8:47pm UTC](https://www.ruby-forum.com/t/formatters-extra-data/208623 "2011-06-22T20:47:53Z")

</div>

Hi David, Want to discuss possibilities of giving formatters more information form examples and example groups. I was about to create formatter with some additional info form running spec but came across the problem …

---

## [Rspec not returning exit code with --drb w/o spork running](https://www.ruby-forum.com/t/rspec-not-returning-exit-code-with-drb-w-o-spork-running/208614)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 2\
**Last updated:** [June 22, 2011, 6:45pm UTC](https://www.ruby-forum.com/t/rspec-not-returning-exit-code-with-drb-w-o-spork-running/208614 "2011-06-22T18:45:29Z")

</div>

I am seeing a problem with running rspec (rspec 2.6.0, rspec-core 2.6.4) with --drb (our default) when spork is not running. It fails to return a non-zero error code. Anyone has any suggestions where I should start lo…

---

## [Stubbing /mocking ldap within a method](https://www.ruby-forum.com/t/stubbing-mocking-ldap-within-a-method/208573)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [June 22, 2011, 12:01am UTC](https://www.ruby-forum.com/t/stubbing-mocking-ldap-within-a-method/208573 "2011-06-22T00:01:27Z")

</div>

given I have the following with the internal assignments to filter and ldap: class Collaborator def self.search\_ldap(term) last\_name = term.strip.split(/\[, \]/).first.downcase filter = Net::LDAP::Filter.eq(‘surName’,…

---

## [Stub an AR Model Instance Method](https://www.ruby-forum.com/t/stub-an-ar-model-instance-method/208194)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 4\
**Last updated:** [June 19, 2011, 3:12pm UTC](https://www.ruby-forum.com/t/stub-an-ar-model-instance-method/208194 "2011-06-19T15:12:37Z")

</div>

Obviously, I’m missing something very simple, can someone please explain how to stub an instance of an AR model method. This does not work: @widget = Widget.first # Widget has an instance method called ‘next\_seriel\_n…

---

## [How to mock/stub when there are multiple model objects?](https://www.ruby-forum.com/t/how-to-mock-stub-when-there-are-multiple-model-objects/208433)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 3\
**Last updated:** [June 18, 2011, 2:05am UTC](https://www.ruby-forum.com/t/how-to-mock-stub-when-there-are-multiple-model-objects/208433 "2011-06-18T02:05:01Z")

</div>

I’m a bit confused how to hook into a particular model object instance and mock/stub it? I understand how to hook into a class level method like: User.should\_receive(:where).and\_return(…) but what if my method looks…

---

## [RSpec 2.6 + Capybara 1.0 incompatibility](https://www.ruby-forum.com/t/rspec-2-6-capybara-1-0-incompatibility/208422)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 3\
**Last updated:** [June 17, 2011, 11:18pm UTC](https://www.ruby-forum.com/t/rspec-2-6-capybara-1-0-incompatibility/208422 "2011-06-17T23:18:35Z")

</div>

Hi. I use RSpec-Rails 2.6.1 together with Capybara 1.0.0. Whenever I start my integration (request) tests I get the following error: Failure/Error: page.execute\_script(’$ (“div.editable:first”).trigger(“mouseover”);…

---

## [Simple way to supply test input for gets?](https://www.ruby-forum.com/t/simple-way-to-supply-test-input-for-gets/208355)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [June 16, 2011, 12:13am UTC](https://www.ruby-forum.com/t/simple-way-to-supply-test-input-for-gets/208355 "2011-06-16T00:13:30Z")

</div>

Hi there, I’m pretty new to rspec and have not been able to figure out how to run a basic test that allows me to substitute test input for real user input collected by ‘gets.’ I have a command line program that asks t…

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

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