# RSpec

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

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

---

## [Name of current example's file:line in a before block?](https://www.ruby-forum.com/t/name-of-current-examples-file-line-in-a-before-block/208327)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 2\
**Last updated:** [June 15, 2011, 9:52pm UTC](https://www.ruby-forum.com/t/name-of-current-examples-file-line-in-a-before-block/208327 "2011-06-15T21:52:06Z")

</div>

Hi, I have an idea for a tool I want to build. In a Cucumber Before() block, I can say: Before do |scenario| puts scenario.file\_colon\_line end That then gives me the information I’d need to run that test case (and …

---

## [How to mock when there seems to be a requirement for chained mocked calls?](https://www.ruby-forum.com/t/how-to-mock-when-there-seems-to-be-a-requirement-for-chained-mocked-calls/208280)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 4\
**Last updated:** [June 14, 2011, 8:35pm UTC](https://www.ruby-forum.com/t/how-to-mock-when-there-seems-to-be-a-requirement-for-chained-mocked-calls/208280 "2011-06-14T20:35:11Z")

</div>

I want to mock the following: MyModel.where("…").last I tried: MyModel.should\_receive(:where).and\_return(nil) but this of course doesn’t match the expectation since the call to .last was not mapped in the mock code…

---

## [Testing framework in 44 lines of ruby](https://www.ruby-forum.com/t/testing-framework-in-44-lines-of-ruby/208223)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 4\
**Last updated:** [June 12, 2011, 8:13pm UTC](https://www.ruby-forum.com/t/testing-framework-in-44-lines-of-ruby/208223 "2011-06-12T20:13:16Z")

</div>

Hi everyone, I just came across this post and was wondering if this is on target with how RSpec works under the hood? Patrick J. Collins http://collinatorstudios.com

---

## [Subdomain based namespacing makes RSpec incorrectly state that the route doesn't exist](https://www.ruby-forum.com/t/subdomain-based-namespacing-makes-rspec-incorrectly-state-that-the-route-doesnt-exist/208196)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [June 12, 2011, 3:44pm UTC](https://www.ruby-forum.com/t/subdomain-based-namespacing-makes-rspec-incorrectly-state-that-the-route-doesnt-exist/208196 "2011-06-12T15:44:41Z")

</div>

Hello, I’m doing namespace routing based on subdomain, rather than path, so that http://admin.example.com/pages leads to app/controllers/admin/ pages\_controller.rb. Cucumber is following this fine, but RSpec is compl…

---

## [Help with rspec](https://www.ruby-forum.com/t/help-with-rspec/208206)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [June 12, 2011, 2:33pm UTC](https://www.ruby-forum.com/t/help-with-rspec/208206 "2011-06-12T14:33:01Z")

</div>

Hi all, My name is Shlomi Zadok - I am an old time PHP (mainly Drupal) developer and I am doing my first application on Ruby on Rails ( I just love it!!) I am trying to test my application with rspec and I am having …

---

## [Rspec with debug does not pick up .rdebugrc settings](https://www.ruby-forum.com/t/rspec-with-debug-does-not-pick-up-rdebugrc-settings/208033)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [June 8, 2011, 5:46pm UTC](https://www.ruby-forum.com/t/rspec-with-debug-does-not-pick-up-rdebugrc-settings/208033 "2011-06-08T17:46:35Z")

</div>

Hi there, latest rspec2, running in debug mode, does not seem to pick up settings from project .rdebugrc or home ~/.rdebugrc. Wondering if others experience this and if its anything obvious TIA Andrew

---

## [Is "it\_should\_behave\_like" a code smell?](https://www.ruby-forum.com/t/is-it-should-behave-like-a-code-smell/207988)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [June 7, 2011, 6:21pm UTC](https://www.ruby-forum.com/t/is-it-should-behave-like-a-code-smell/207988 "2011-06-07T18:21:50Z")

</div>

Consider the following simple Rails app: ==== begin snippet ==== lib/herpable.rb module Herpable; …; end app/models/… class ClassOne; include Herpable; end class ClassTwo; include Herpable; end … ==== end snippet…

---

## [Rake 0.9.0 activated error + debugger not working?](https://www.ruby-forum.com/t/rake-0-9-0-activated-error-debugger-not-working/207956)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 9\
**Last updated:** [June 7, 2011, 12:48pm UTC](https://www.ruby-forum.com/t/rake-0-9-0-activated-error-debugger-not-working/207956 "2011-06-07T12:48:30Z")

</div>

Hi everyone, I am using rvm, and when I try to do rake spec, I get: “You have already activated rake 0.9.0, but your Gemfile requires rake 0.8.7. Consider using bundle exec.” … Is there a way to get around this so …

---

## [Request for comments: Scenario](https://www.ruby-forum.com/t/request-for-comments-scenario/207874)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 3\
**Last updated:** [June 5, 2011, 9:39pm UTC](https://www.ruby-forum.com/t/request-for-comments-scenario/207874 "2011-06-05T21:39:57Z")

</div>

I created a gem a few weeks ago that I think the RSpec community might be interested in: GitHub - tysonmote/scenario: Basic spec scenarios for RSpec. (dormant) (and that I’d love to get feedback on). It supports RSpe…

---

## [Not able to install rspec on Windows XP](https://www.ruby-forum.com/t/not-able-to-install-rspec-on-windows-xp/207865)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 2\
**Last updated:** [June 4, 2011, 6:02pm UTC](https://www.ruby-forum.com/t/not-able-to-install-rspec-on-windows-xp/207865 "2011-06-04T18:02:24Z")

</div>

Hi everyone, I have downloaded and saved the folder in C: \\Ruby192\\rspec-1.2.9.rc1\\rspec-1.2.9.rc1 I am into the folder mentioned below and is trying to install rspec but I am not able to do so…Can someone help me wi…

---

## [Migrating cucumber tm\_bundle to rspec 2](https://www.ruby-forum.com/t/migrating-cucumber-tm-bundle-to-rspec-2/207826)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 2\
**Last updated:** [June 4, 2011, 3:28pm UTC](https://www.ruby-forum.com/t/migrating-cucumber-tm-bundle-to-rspec-2/207826 "2011-06-04T15:28:41Z")

</div>

Hi there, I need some help migrating some code in the cucumber textmate bundle so I can run the specs with rspec2. The following code lives in support/spec/spec\_helper.rb and I think its purpose is to load the fixtu…

---

## [Error installing cucumber: - ERROR: Failed to build gem native extension](https://www.ruby-forum.com/t/error-installing-cucumber-error-failed-to-build-gem-native-extension/207816)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [June 3, 2011, 11:36am UTC](https://www.ruby-forum.com/t/error-installing-cucumber-error-failed-to-build-gem-native-extension/207816 "2011-06-03T11:36:50Z")

</div>

Hello All, I am installing cucumber on my windows XP machine by using the command “gem install cucumber -v 0.10.0” But gets the following error : Temporarily enhancing PATH to include DevKit… Building native extensi…

---

## [How to include module into shared example group in RSpec 2](https://www.ruby-forum.com/t/how-to-include-module-into-shared-example-group-in-rspec-2/207735)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 4\
**Last updated:** [June 1, 2011, 6:48pm UTC](https://www.ruby-forum.com/t/how-to-include-module-into-shared-example-group-in-rspec-2/207735 "2011-06-01T18:48:36Z")

</div>

Hi! We tried to upgrade our RSpec from 1.3.1 to 2.6 and are having some problems. It seems that shared example group includes modules differently in RSpec 2. Consider the following code: module MyModule def testing …

---

## [RSpec 2 not finding specs from subdirectories when trying to run specs from there](https://www.ruby-forum.com/t/rspec-2-not-finding-specs-from-subdirectories-when-trying-to-run-specs-from-there/207734)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 5\
**Last updated:** [June 1, 2011, 5:31pm UTC](https://www.ruby-forum.com/t/rspec-2-not-finding-specs-from-subdirectories-when-trying-to-run-specs-from-there/207734 "2011-06-01T17:31:17Z")

</div>

Hi! When having a file structure like this: project -spec -subdir -my\_spec.rb and then being in directory “project” and running command rspec spec everything works as expected. If running rspec spec/subdir to run …

---

## [How to include module into shared example group in RSpec 2](https://www.ruby-forum.com/t/how-to-include-module-into-shared-example-group-in-rspec-2/207736)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [June 1, 2011, 4:43pm UTC](https://www.ruby-forum.com/t/how-to-include-module-into-shared-example-group-in-rspec-2/207736 "2011-06-01T16:43:38Z")

</div>

Hi! We tried to upgrade our RSpec from 1.3.1 to 2.6 and are having some problems. It seems that shared example group includes modules differently in RSpec 2. Consider the following code: module MyModule def testing …

---

## [Hey rspec-users](https://www.ruby-forum.com/t/hey-rspec-users/207708)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [June 1, 2011, 3:05am UTC](https://www.ruby-forum.com/t/hey-rspec-users/207708 "2011-06-01T03:05:36Z")

</div>

Hey rspec-users I just wanted to share this opportunity with you, I’ve been making 200-300 dollars a day and I started only a week ago. Check out this news article and it will show you how to get started, it’s definit…

---

## [How do you test a module that extends ActiveSupport::Concern?](https://www.ruby-forum.com/t/how-do-you-test-a-module-that-extends-activesupport-concern/207687)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [May 31, 2011, 9:16pm UTC](https://www.ruby-forum.com/t/how-do-you-test-a-module-that-extends-activesupport-concern/207687 "2011-05-31T21:16:05Z")

</div>

I have a module that extends ActiveSupport::Concern. Here is the included block: included do after\_save :save\_tags has\_many :taggings, :as =\> :taggable has\_many :tags, :through =\> :taggings end How can I stub out …

---

## [RSpec and Rake](https://www.ruby-forum.com/t/rspec-and-rake/207576)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 2\
**Last updated:** [May 28, 2011, 4:45pm UTC](https://www.ruby-forum.com/t/rspec-and-rake/207576 "2011-05-28T16:45:05Z")

</div>

Guys, Just upgraded to rspec / rspec-rails 2.6 today and noticed that it pulled in rake 0.9.0 which was causing the rails 3.0.7 tasks to blowup. I’ve downgraded rake to 0.8.7. Are there any ‘side-effects’ that may i…

---

## [Simple routing spec issue - syntax error](https://www.ruby-forum.com/t/simple-routing-spec-issue-syntax-error/207502)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [May 27, 2011, 3:25am UTC](https://www.ruby-forum.com/t/simple-routing-spec-issue-syntax-error/207502 "2011-05-27T03:25:15Z")

</div>

Hi All, New to rspec. Done some Rails, done TDD in other languages, trying to get the two to meet. Getting a syntax error on my first routing spec: context “public routing” do it “routes / to public#landing” do { :g…

---

## [Fluent chaining drying](https://www.ruby-forum.com/t/fluent-chaining-drying/207422)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 5\
**Last updated:** [May 26, 2011, 6:29pm UTC](https://www.ruby-forum.com/t/fluent-chaining-drying/207422 "2011-05-26T18:29:57Z")

</div>

Hello all. Thanks to subjects, custom matchers and fluent chaining I was able to greatly simplify my spec. But now I want to DRY my custom matchers. I have two custom matchers: ‘have\_text’ and ‘have\_number’ and both …

---

## [Report testing](https://www.ruby-forum.com/t/report-testing/207489)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [May 26, 2011, 5:21pm UTC](https://www.ruby-forum.com/t/report-testing/207489 "2011-05-26T17:21:55Z")

</div>

Hi, Given i’m developing report charts with some data(on activerecord), i want to know what would be tested in this case ? For ex. A report for amount of created users along the time. thank you

---

## [Rspec-rails 2.0.0.beta.12 showing undefined method error for route\_to](https://www.ruby-forum.com/t/rspec-rails-2-0-0-beta-12-showing-undefined-method-error-for-route-to/190453)

<div class="topic-metadata">

**Author:** [@dazuma](https://www.ruby-forum.com/u/dazuma)\
**Replies:** 7\
**Last updated:** [May 26, 2011, 8:31am UTC](https://www.ruby-forum.com/t/rspec-rails-2-0-0-beta-12-showing-undefined-method-error-for-route-to/190453 "2011-05-26T08:31:54Z")

</div>

First of all, I’ve been trying to find an answer for this problem all over the internet without luck. The thing is that I am using RVM with ruby 1.9.2-head and I created a new empty gemset. Then I installed bundler ge…

---

## [For those using Rails with RSpec what do you guys use for creating Factories?](https://www.ruby-forum.com/t/for-those-using-rails-with-rspec-what-do-you-guys-use-for-creating-factories/207439)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 9\
**Last updated:** [May 26, 2011, 7:00am UTC](https://www.ruby-forum.com/t/for-those-using-rails-with-rspec-what-do-you-guys-use-for-creating-factories/207439 "2011-05-26T07:00:51Z")

</div>

I am using factory\_girl, and I have discovered that it is chiefly responsible for making my tests run slow. I have posted a question about this on Stack Overflow: Anyway, I was curious what you guys use to create Fa…

---

## [Newb struggling to get/keep RSpec stable](https://www.ruby-forum.com/t/newb-struggling-to-get-keep-rspec-stable/207449)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [May 26, 2011, 6:47am UTC](https://www.ruby-forum.com/t/newb-struggling-to-get-keep-rspec-stable/207449 "2011-05-26T06:47:54Z")

</div>

Long post but prolly simple if you understand Rails, RSpec & differences between webrat & capybara. I’m hoping someone can take a few moments to help me get a better understanding of my environment. I have a somewhat …

---

## [Rspec-rails-2.6.1 is released!](https://www.ruby-forum.com/t/rspec-rails-2-6-1-is-released/207456)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [May 26, 2011, 4:45am UTC](https://www.ruby-forum.com/t/rspec-rails-2-6-1-is-released/207456 "2011-05-26T04:45:09Z")

</div>

rspec-rails-2.6.1 is released! This is a bug fix release that is compatible with the rails-3.0.0 to 3.0.7, 3.0.8.rc1, and 3.1.0.rc1 (it is mostly, but not fully compatible with but not rails-3.1.0.beta1). rspec-rail…

---

## [How do you factor out common "before(:each)" calls so that multiple specs can use them?](https://www.ruby-forum.com/t/how-do-you-factor-out-common-before-each-calls-so-that-multiple-specs-can-use-them/207444)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 3\
**Last updated:** [May 26, 2011, 2:41am UTC](https://www.ruby-forum.com/t/how-do-you-factor-out-common-before-each-calls-so-that-multiple-specs-can-use-them/207444 "2011-05-26T02:41:50Z")

</div>

I’d like to factor this bunch of code so that all of my controller tests (well, almost all of them) use this before(:each) block: before(:each) do @user = User.new controller.stub(:authenticate\_user!) controller.stu…

---

## [RSpec 2: undefined method \`controller\_name' for :Class (NoMethodError)](https://www.ruby-forum.com/t/rspec-2-undefined-method-controller-name-for-class-nomethoderror/189970)

<div class="topic-metadata">

**Author:** [@kristianm](https://www.ruby-forum.com/u/kristianm)\
**Replies:** 1\
**Last updated:** [May 25, 2011, 8:37pm UTC](https://www.ruby-forum.com/t/rspec-2-undefined-method-controller-name-for-class-nomethoderror/189970 "2011-05-25T20:37:39Z")

</div>

describe ApplicationController, “handling AccessDenied exceptions” do class FooController \< ApplicationController def index raise AccessDenied end end controller\_name ‘foo’ # OUCH!!! it “redirects to the /401.html…

---

## [Help to spec a rails helper method that uses content\_for](https://www.ruby-forum.com/t/help-to-spec-a-rails-helper-method-that-uses-content-for/127054)

<div class="topic-metadata">

**Author:** [@Ben\_Aldred](https://www.ruby-forum.com/u/Ben_Aldred)\
**Replies:** 3\
**Last updated:** [May 25, 2011, 10:29am UTC](https://www.ruby-forum.com/t/help-to-spec-a-rails-helper-method-that-uses-content-for/127054 "2011-05-25T10:29:00Z")

</div>

Hi guys, I am a Rspec newbie and am having problems creating a spec for a RoR helper method. I have in fact already implemented the helper method and am trying to create retrospective specs. I know its the wrong wa…

---

## [Faça parte da minha rede no LinkedIn](https://www.ruby-forum.com/t/faca-parte-da-minha-rede-no-linkedin/207387)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [May 25, 2011, 5:22am UTC](https://www.ruby-forum.com/t/faca-parte-da-minha-rede-no-linkedin/207387 "2011-05-25T05:22:17Z")

</div>

LinkedIn Eu gostaria de adicioná-lo à minha rede profissional no LinkedIn. -Pedro Pedro Brasileiro System Analist na DETRAN-CE Brasil Confirme que você conhece Pedro Brasileiro

---

## [Autorun?](https://www.ruby-forum.com/t/autorun/207372)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 3\
**Last updated:** [May 24, 2011, 10:57pm UTC](https://www.ruby-forum.com/t/autorun/207372 "2011-05-24T22:57:45Z")

</div>

Hello all. I believe I was under the impression that with rspec 2, one didn’t need to require ‘autorun’ to have specs autorun. Can anybody tell me if this is the case or not? Thanks! -roger-

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

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