# RSpec

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

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

---

## [Test execution time filtering](https://www.ruby-forum.com/t/test-execution-time-filtering/210728)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 4\
**Last updated:** [August 17, 2011, 1:00pm UTC](https://www.ruby-forum.com/t/test-execution-time-filtering/210728 "2011-08-17T13:00:26Z")

</div>

As I understand it, RSpec runs in two passes. The first pass reads your code and invokes factory methods to generate instances of example- group and example subclasses. The second pass then invokes these generated i…

---

## [Rspec with ActionMailer and .deliver](https://www.ruby-forum.com/t/rspec-with-actionmailer-and-deliver/209988)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 3\
**Last updated:** [August 16, 2011, 6:30pm UTC](https://www.ruby-forum.com/t/rspec-with-actionmailer-and-deliver/209988 "2011-08-16T18:30:43Z")

</div>

I’m in the process of migrating from Rails 2 with rspec 1 to Rails 3 with rspec 2, the process has been going pretty well, however, today I came across an issue that I wanted to share. I have a controller that sends …

---

## [Specs doesn't run](https://www.ruby-forum.com/t/specs-doesnt-run/210733)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [August 16, 2011, 2:31pm UTC](https://www.ruby-forum.com/t/specs-doesnt-run/210733 "2011-08-16T14:31:09Z")

</div>

Rails 2.3.8 GEMFILE group :development do gem “rspec”, “1.3.0” gem “rspec-rails”, “1.3.2” gem “guard-rspec” #GitHub - guard/guard-rspec: Guard::RSpec automatically run your specs (much like autotest) end S…

---

## [How to detect test fail on after(:each) method?](https://www.ruby-forum.com/t/how-to-detect-test-fail-on-after-each-method/210734)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [August 16, 2011, 2:11pm UTC](https://www.ruby-forum.com/t/how-to-detect-test-fail-on-after-each-method/210734 "2011-08-16T14:11:21Z")

</div>

Hi All: I am working on a test, and I need to detect if the test failed on the after(:each) method, just to call a WebService. Thanks!

---

## [Webrat and Rails 2.3.12](https://www.ruby-forum.com/t/webrat-and-rails-2-3-12/210731)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [August 16, 2011, 9:47am UTC](https://www.ruby-forum.com/t/webrat-and-rails-2-3-12/210731 "2011-08-16T09:47:08Z")

</div>

Im trying to integrate webrat in a rails 2.3.12: I get this OUTPUT: 1) NoMethodError in ‘Campaign in first step testing request’ undefined method \`visit’ for #Spec::Rails::Example::ModelExampleGroup::Subclass\_1::Sub…

---

## [Devise, RSpec and Webrat](https://www.ruby-forum.com/t/devise-rspec-and-webrat/210732)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [August 16, 2011, 6:59am UTC](https://www.ruby-forum.com/t/devise-rspec-and-webrat/210732 "2011-08-16T06:59:27Z")

</div>

My app is builded with rails 2.3.12, rspec-rails 1.3.2, webrat 0.7.3. My spec\_helper.rb ENV\[“RAILS\_ENV”\] ||= ‘test’ require File.expand\_path(File.join(File.dirname(FILE),’…’,‘config’,‘environment’)) require ‘spec/au…

---

## [Stub in config.before](https://www.ruby-forum.com/t/stub-in-config-before/210693)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 5\
**Last updated:** [August 15, 2011, 3:12pm UTC](https://www.ruby-forum.com/t/stub-in-config-before/210693 "2011-08-15T15:12:35Z")

</div>

I was trying to stub something “globally”, across all tests today, and had some trouble. I tried RSpec.configure do |config| config.before(:all) do MyClass.stub(:my\_method) end end seems that stub is not availab…

---

## [Improving TextMate RSpec Bundle's error output](https://www.ruby-forum.com/t/improving-textmate-rspec-bundles-error-output/210651)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [August 13, 2011, 1:05am UTC](https://www.ruby-forum.com/t/improving-textmate-rspec-bundles-error-output/210651 "2011-08-13T01:05:36Z")

</div>

I just posted a pull request to improve the RSpec TextMate Bundle’s output in cases where the error occurs outside a spec – e.g. a syntax error. It’s currently quite ugly and my patch formats it as HTML and adds some …

---

## [ControllerExampleGroup.bypass\_rescue](https://www.ruby-forum.com/t/controllerexamplegroup-bypass-rescue/210553)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 5\
**Last updated:** [August 11, 2011, 3:29pm UTC](https://www.ruby-forum.com/t/controllerexamplegroup-bypass-rescue/210553 "2011-08-11T15:29:52Z")

</div>

As best I can tell, bypass\_rescue from rspec-rails-1 is no longer part of rspec-rails, ‘\> 2’. I had been using it on occasion for things like: describe CorrespondencesController do … describe ‘#show’ do it "should r…

---

## [Speccing a redirect in routes](https://www.ruby-forum.com/t/speccing-a-redirect-in-routes/210453)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 4\
**Last updated:** [August 9, 2011, 2:28pm UTC](https://www.ruby-forum.com/t/speccing-a-redirect-in-routes/210453 "2011-08-09T14:28:20Z")

</div>

Hi, I expected to be able to do something like this in a routing spec: { :get =\> ‘/legacy/route’ }.should redirect\_to(‘/shiny/new/route’) However there doesn’t appear to be a redirect\_to matcher, and digging deeper I…

---

## [Functional testing with(through?) chrome](https://www.ruby-forum.com/t/functional-testing-with-through-chrome/210380)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 4\
**Last updated:** [August 7, 2011, 1:04pm UTC](https://www.ruby-forum.com/t/functional-testing-with-through-chrome/210380 "2011-08-07T13:04:04Z")

</div>

Not sure if this can be done using RSpec and something else but I’m trying to test a website using Chrome specifically. The website seems to intermittently hang up Chrome but not Safari and it passes functional tests…

---

## [Named context or calling include\_context with block?](https://www.ruby-forum.com/t/named-context-or-calling-include-context-with-block/210392)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 5\
**Last updated:** [August 6, 2011, 6:49pm UTC](https://www.ruby-forum.com/t/named-context-or-calling-include-context-with-block/210392 "2011-08-06T18:49:50Z")

</div>

Hello, I’m playing around with Rspec again after going from test/unit to rspec then back to test/unit… :slight\_smile: Right off the bat, I find myself wanting to do something like this: DRY'ed rspec using shared\_con…

---

## [How to test modules and custom validators](https://www.ruby-forum.com/t/how-to-test-modules-and-custom-validators/210268)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 2\
**Last updated:** [August 5, 2011, 6:31am UTC](https://www.ruby-forum.com/t/how-to-test-modules-and-custom-validators/210268 "2011-08-05T06:31:16Z")

</div>

I’m trying to have most of the important stuff tested and in order to do that I run in front of some stuff I’m not quite sure which is the best way to test them. At this time I am having question around how to test m…

---

## [A bit confused with the use of assign() to test views](https://www.ruby-forum.com/t/a-bit-confused-with-the-use-of-assign-to-test-views/210253)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 4\
**Last updated:** [August 3, 2011, 2:00pm UTC](https://www.ruby-forum.com/t/a-bit-confused-with-the-use-of-assign-to-test-views/210253 "2011-08-03T14:00:01Z")

</div>

hi guys, I’m trying to pick up Rspec to port an existing application in rails 2.3.8 to rails 3. I’m using the pragmatic “The Rspec book” (dec 2010) as a reference. read around the book and the rspec docs. assign m…

---

## [Testing Routing Constraint =\> redirect example.com to www.example.com](https://www.ruby-forum.com/t/testing-routing-constraint-redirect-example-com-to-www-example-com/210188)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 3\
**Last updated:** [August 3, 2011, 7:13am UTC](https://www.ruby-forum.com/t/testing-routing-constraint-redirect-example-com-to-www-example-com/210188 "2011-08-03T07:13:43Z")

</div>

Hi All With the following route constraints(:host =\> “example.com”) do match “(\*x)” =\> redirect { |params, request| URI.parse(request.url).tap { |x| x.host = “www.example.com” }.to\_s } end I am wondering how or wh…

---

## [Best way to test tasks](https://www.ruby-forum.com/t/best-way-to-test-tasks/210236)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 4\
**Last updated:** [August 3, 2011, 7:08am UTC](https://www.ruby-forum.com/t/best-way-to-test-tasks/210236 "2011-08-03T07:08:10Z")

</div>

I have a task that runs frequently in order to get/import data from another system. Because of this I wanted to know which is the best way to test tasks in order to create the tests needed. Thanks in advance.

---

## [How can I add another 'requests'-like folder?](https://www.ruby-forum.com/t/how-can-i-add-another-requests-like-folder/210108)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 2\
**Last updated:** [July 31, 2011, 12:17am UTC](https://www.ruby-forum.com/t/how-can-i-add-another-requests-like-folder/210108 "2011-07-31T00:17:31Z")

</div>

I love conventions. But I am trying to write tests for an API,which lives in … api. I need to be making http requests, so all my tests work when put in spec/requests. How can I make that spec/api? (Obviously renaming …

---

## [How can I make before/after all a method?](https://www.ruby-forum.com/t/how-can-i-make-before-after-all-a-method/210078)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 2\
**Last updated:** [July 30, 2011, 1:34am UTC](https://www.ruby-forum.com/t/how-can-i-make-before-after-all-a-method/210078 "2011-07-30T01:34:53Z")

</div>

I would like to turn this: describe TestClass do before :all do set some config end after :all do restore some config end do a bunch of tests to this end into describe TestClass do with\_config\_value(X) do a bun…

---

## [Does anyone's rspec actually exit on the first ^C?](https://www.ruby-forum.com/t/does-anyones-rspec-actually-exit-on-the-first-c/210071)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [July 29, 2011, 8:41pm UTC](https://www.ruby-forum.com/t/does-anyones-rspec-actually-exit-on-the-first-c/210071 "2011-07-29T20:41:09Z")

</div>

So, you start running your (full and long) rspec suite (before a checkin), and you realize you \[forgot to migrate test|didn’t add some config value|missed a curly brace\]. You hit Ctrl+C and get this mesage Exiting… …

---

## [!~ seems to not work](https://www.ruby-forum.com/t/seems-to-not-work/210026)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 4\
**Last updated:** [July 29, 2011, 2:34pm UTC](https://www.ruby-forum.com/t/seems-to-not-work/210026 "2011-07-29T14:34:27Z")

</div>

‘abc’ ~! /def/ =\> true 'abc'.should !~ /def/ fails though. Seemed unexpected… -roger-

---

## [RSpec, shoulda-matchers and Rails model attributes validations](https://www.ruby-forum.com/t/rspec-shoulda-matchers-and-rails-model-attributes-validations/210025)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 2\
**Last updated:** [July 28, 2011, 9:13pm UTC](https://www.ruby-forum.com/t/rspec-shoulda-matchers-and-rails-model-attributes-validations/210025 "2011-07-28T21:13:21Z")

</div>

I was trying out RSpec framework in a project and got stopped doing the unit test of a model. In particular, doing the test for the associations and the ActiveRecord validations. I started writing the validations bu…

---

## [Looking for a fellow human: Agile, Mobile, Web, Rails Developer](https://www.ruby-forum.com/t/looking-for-a-fellow-human-agile-mobile-web-rails-developer/210030)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [July 28, 2011, 7:21pm UTC](https://www.ruby-forum.com/t/looking-for-a-fellow-human-agile-mobile-web-rails-developer/210030 "2011-07-28T19:21:18Z")

</div>

Not to spam the list, but I thought the RSpec and Cucumber communities may be appropriate to tap into. We’re looking for agilist web/mobile developer(s) over at Mutually Human. RSpec/Cuke creds hold special places i…

---

## [Run rspec by hand (without spec command)](https://www.ruby-forum.com/t/run-rspec-by-hand-without-spec-command/209899)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [July 28, 2011, 6:39pm UTC](https://www.ruby-forum.com/t/run-rspec-by-hand-without-spec-command/209899 "2011-07-28T18:39:20Z")

</div>

Guys, I’m trying to do something a little exotic here, using RSpec to test Objective-C code through MacRuby. I mean the major problems I already solved (how to load Objective-C into ruby, install rspec for native mac…

---

## [Is there a "safe\_stub"?](https://www.ruby-forum.com/t/is-there-a-safe-stub/209995)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 3\
**Last updated:** [July 28, 2011, 2:32am UTC](https://www.ruby-forum.com/t/is-there-a-safe-stub/209995 "2011-07-28T02:32:10Z")

</div>

Right now, #stub stubs a method even if it doesn’t exist. Is there a way to stub a method on an object, if and only if it already #responds\_to? that method? It would also be good if it raised an ArgumentError or the l…

---

## [\--profile and ci](https://www.ruby-forum.com/t/profile-and-ci/209964)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [July 27, 2011, 12:01pm UTC](https://www.ruby-forum.com/t/profile-and-ci/209964 "2011-07-27T12:01:18Z")

</div>

Hi all I’d like to keep the 10 slowest results shown when using --profile as an artifact of my ci builds. Is there some way to direct this particular output to a file/folder? Is there anything that produces an html …

---

## [Keeping my integration specs DRY](https://www.ruby-forum.com/t/keeping-my-integration-specs-dry/209908)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 3\
**Last updated:** [July 26, 2011, 2:01pm UTC](https://www.ruby-forum.com/t/keeping-my-integration-specs-dry/209908 "2011-07-26T14:01:41Z")

</div>

Hi Group, I’m finally taking the time to implement tests in some of my old apps. I’m using Rails 2.3.5, Rspec 1.3.1, Rspec-rails 1.3.3, and capybara. Here’s an example of my first test, but I’m wondering how I setup t…

---

## [Rspec and Lion?](https://www.ruby-forum.com/t/rspec-and-lion/209896)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [July 26, 2011, 4:12am UTC](https://www.ruby-forum.com/t/rspec-and-lion/209896 "2011-07-26T04:12:39Z")

</div>

Hey, Has anyone used rspec and lion much yet? I’m using the Fuubar instafail formatter, and finding that the entire output of the spec run is buffered till the script execution stops, at which point it’s displayed. N…

---

## [Adding a folder to my rspec execution path](https://www.ruby-forum.com/t/adding-a-folder-to-my-rspec-execution-path/209879)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 7\
**Last updated:** [July 25, 2011, 6:59pm UTC](https://www.ruby-forum.com/t/adding-a-folder-to-my-rspec-execution-path/209879 "2011-07-25T18:59:41Z")

</div>

Hi guys, I’m using RSpec with Capybara, and for that I created the spec/integration folder. But when I execute the command “bundle exec rspec spec” RSpec don’t execute my files on integration folder. I need to pass e…

---

## [How to modify RSpec.configuration correctly depending of the example groups](https://www.ruby-forum.com/t/how-to-modify-rspec-configuration-correctly-depending-of-the-example-groups/209783)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [July 22, 2011, 3:32pm UTC](https://www.ruby-forum.com/t/how-to-modify-rspec-configuration-correctly-depending-of-the-example-groups/209783 "2011-07-22T15:32:51Z")

</div>

Hi! I have a directory structure something similar to: spec/a/a\_helper.rb spec/a/a\_spec.rb spec/b/b\_spec.rb In a\_helper.rb i’d like to do something like this: RSpec.configure do |config| config.before :each do # …

---

## [Question regarding how to test posting form data with Net::HTTP](https://www.ruby-forum.com/t/question-regarding-how-to-test-posting-form-data-with-net-http/209753)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [July 21, 2011, 11:11pm UTC](https://www.ruby-forum.com/t/question-regarding-how-to-test-posting-form-data-with-net-http/209753 "2011-07-21T23:11:07Z")

</div>

So I have a class that does this: def perform @response = Net::HTTP.new(url.host, url.port).start {|http| http.request(do\_post) } unless @response.is\_a?(Net::HTTPSuccess) || @response.is\_a?(Net::HTTPRedirection) @…

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

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