# RSpec

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

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

---

## [Programmatically counting RSpec tests?](https://www.ruby-forum.com/t/programmatically-counting-rspec-tests/189527)

<div class="topic-metadata">

**Author:** [@johnf](https://www.ruby-forum.com/u/johnf)\
**Replies:** 5\
**Last updated:** [June 2, 2010, 3:42pm UTC](https://www.ruby-forum.com/t/programmatically-counting-rspec-tests/189527 "2010-06-02T15:42:02Z")

</div>

If I have an object obj that is a SpecTask, and subsequently invoke it, is there a way to programmatically determine the number of tests that were successful, failed, and pending as a result of running that SpecTask? J…

---

## [RSpec book errata #57 - undefined method \`include' : what to do?](https://www.ruby-forum.com/t/rspec-book-errata-57-undefined-method-include-what-to-do/189505)

<div class="topic-metadata">

**Author:** [@kristianm](https://www.ruby-forum.com/u/kristianm)\
**Replies:** 1\
**Last updated:** [June 2, 2010, 3:32am UTC](https://www.ruby-forum.com/t/rspec-book-errata-57-undefined-method-include-what-to-do/189505 "2010-06-02T03:32:43Z")

</div>

http://pragprog.com/titles/achbd/errata nr 57: Ruby 1.8.7 expected \[\] to include “Welcome to Codebreaker!” Ruby 1.9.1 undefined method \`include’ for #Object:0x80b32c90 (NoMethodError) class Output def messages @m…

---

## [Re: Understanding how to better use stub! and stub\_chain](https://www.ruby-forum.com/t/re-understanding-how-to-better-use-stub-and-stub-chain/189449)

<div class="topic-metadata">

**Author:** [@mwalsh](https://www.ruby-forum.com/u/mwalsh)\
**Replies:** 1\
**Last updated:** [June 1, 2010, 4:10pm UTC](https://www.ruby-forum.com/t/re-understanding-how-to-better-use-stub-and-stub-chain/189449 "2010-06-01T16:10:08Z")

</div>

Did you try looking at the specs for any examples? I imagine there’d be a couple… :wink:

---

## [Understanding how to better use stub! and stub\_chain](https://www.ruby-forum.com/t/understanding-how-to-better-use-stub-and-stub-chain/189431)

<div class="topic-metadata">

**Author:** [@Joseph\_DelCioppio](https://www.ruby-forum.com/u/Joseph_DelCioppio)\
**Replies:** 0\
**Last updated:** [May 31, 2010, 9:46pm UTC](https://www.ruby-forum.com/t/understanding-how-to-better-use-stub-and-stub-chain/189431 "2010-05-31T21:46:44Z")

</div>

I’ve been looking through the RSpec source to better understand how RSpec works and I’ve got a question about the functionality of stub!. I noticed that you can pass a symbol to stub!, which is usually how I use it, s…

---

## [Failing RSpec test and I'm starting to think it may be a bug](https://www.ruby-forum.com/t/failing-rspec-test-and-im-starting-to-think-it-may-be-a-bug/189408)

<div class="topic-metadata">

**Author:** [@Joseph\_DelCioppio](https://www.ruby-forum.com/u/Joseph_DelCioppio)\
**Replies:** 2\
**Last updated:** [May 31, 2010, 4:31pm UTC](https://www.ruby-forum.com/t/failing-rspec-test-and-im-starting-to-think-it-may-be-a-bug/189408 "2010-05-31T16:31:11Z")

</div>

Guys, I’ve got an RSpec test that for the life of me I can’t get to work. I was hoping somebody could take a quick peek and let me know if they see something wrong here: Here is my code: output · GitHub Can anybod…

---

## [Autospec doing nothing](https://www.ruby-forum.com/t/autospec-doing-nothing/188291)

<div class="topic-metadata">

**Author:** [@bartolome](https://www.ruby-forum.com/u/bartolome)\
**Replies:** 4\
**Last updated:** [May 29, 2010, 5:30am UTC](https://www.ruby-forum.com/t/autospec-doing-nothing/188291 "2010-05-29T05:30:24Z")

</div>

Hi When I run autospec on a rails project I get nothing. flores@Suomi(9:41)~/Code/Sabbre/camisa10 % autospec (Not running features. To run features in autotest, set AUTOFEATURE=true.) (Not running features. To run…

---

## [\[Code Style\] Is there a more 'rspec' way for me to write this test?](https://www.ruby-forum.com/t/code-style-is-there-a-more-rspec-way-for-me-to-write-this-test/226065)

<div class="topic-metadata">

**Author:** [@Ben\_Buckley](https://www.ruby-forum.com/u/Ben_Buckley)\
**Replies:** 0\
**Last updated:** [May 28, 2010, 10:27am UTC](https://www.ruby-forum.com/t/code-style-is-there-a-more-rspec-way-for-me-to-write-this-test/226065 "2010-05-28T10:27:50Z")

</div>

Morning all, I have been playing with Ruby/RSpec on a small script to try and get to know the language and its idioms. I have got my tests working and removed some duplication, but I am conscious the code looks quite…

---

## [How do I improve the readability of my specs](https://www.ruby-forum.com/t/how-do-i-improve-the-readability-of-my-specs/189227)

<div class="topic-metadata">

**Author:** [@Nadal](https://www.ruby-forum.com/u/Nadal)\
**Replies:** 5\
**Last updated:** [May 27, 2010, 4:04pm UTC](https://www.ruby-forum.com/t/how-do-i-improve-the-readability-of-my-specs/189227 "2010-05-27T16:04:20Z")

</div>

Here is my spec. describe Exception2db do context “attributes” do subject { Exception2db.create(:exception =\> $exception\_data\_xml) } specify { subject.controller.should == 'exception2db/main' } specify { subject.erro…

---

## [As\_null\_object](https://www.ruby-forum.com/t/as-null-object/189229)

<div class="topic-metadata">

**Author:** [@rhydiant](https://www.ruby-forum.com/u/rhydiant)\
**Replies:** 3\
**Last updated:** [May 27, 2010, 7:09am UTC](https://www.ruby-forum.com/t/as-null-object/189229 "2010-05-27T07:09:49Z")

</div>

Given that RSpec has the following methods to create test doubles … double(:my\_test\_double) mock(:my\_mock\_object) stub(:my\_stub) Is there a way to/ plans to introduce a similar syntax for null objects? null\_object(…

---

## [Old crumbly rspec](https://www.ruby-forum.com/t/old-crumbly-rspec/189087)

<div class="topic-metadata">

**Author:** [@diabolist](https://www.ruby-forum.com/u/diabolist)\
**Replies:** 6\
**Last updated:** [May 27, 2010, 3:14am UTC](https://www.ruby-forum.com/t/old-crumbly-rspec/189087 "2010-05-27T03:14:34Z")

</div>

Hi List, Being pretty lazy here, but I figure you can help very quickly and others might benefit from the results. I write old crumbly rspec (see gist old crumbly rspec · GitHub), and I would like to improve, can you …

---

## [Why pending only works inside it](https://www.ruby-forum.com/t/why-pending-only-works-inside-it/189211)

<div class="topic-metadata">

**Author:** [@Nadal](https://www.ruby-forum.com/u/Nadal)\
**Replies:** 5\
**Last updated:** [May 26, 2010, 10:42pm UTC](https://www.ruby-forum.com/t/why-pending-only-works-inside-it/189211 "2010-05-26T22:42:56Z")

</div>

I wrote following code and it did not work. describe User do it { should validate\_presence\_of(:email) } pending “should raise an error when email is blank and record is saved with false option” end Then I put pendi…

---

## [Should RSpec add '.' to $LOAD\_PATH for ruby-1.9.2?](https://www.ruby-forum.com/t/should-rspec-add-to-load-path-for-ruby-1-9-2/189196)

<div class="topic-metadata">

**Author:** [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Replies:** 2\
**Last updated:** [May 26, 2010, 4:24pm UTC](https://www.ruby-forum.com/t/should-rspec-add-to-load-path-for-ruby-1-9-2/189196 "2010-05-26T16:24:45Z")

</div>

Ruby-1.9.2 removes ‘.’ from the $LOAD\_PATH. There have been a couple of issues reported against rspec-core-2 asking RSpec to add ‘.’ to $LOAD\_PATH for 1.9.2. My instinct is that this is the wrong way to go; that Ruby …

---

## [\[CUCUMBER\] Noob question](https://www.ruby-forum.com/t/cucumber-noob-question/189161)

<div class="topic-metadata">

**Author:** [@pitosalas](https://www.ruby-forum.com/u/pitosalas)\
**Replies:** 2\
**Last updated:** [May 26, 2010, 11:18am UTC](https://www.ruby-forum.com/t/cucumber-noob-question/189161 "2010-05-26T11:18:33Z")

</div>

Meta question: is this the right/best place to ask for assistance with Cucumber or am I in the wrong place? Anyway, here goes. I just started using cucumber and it’s very impressive! Check out this fragment: And I g…

---

## [Rspec Sinatra and Activerecord](https://www.ruby-forum.com/t/rspec-sinatra-and-activerecord/189160)

<div class="topic-metadata">

**Author:** [@Jay\_McGaffigan](https://www.ruby-forum.com/u/Jay_McGaffigan)\
**Replies:** 0\
**Last updated:** [May 25, 2010, 7:38pm UTC](https://www.ruby-forum.com/t/rspec-sinatra-and-activerecord/189160 "2010-05-25T19:38:31Z")

</div>

Hi, I have a sinatra app that I’ve integrated with Activerecord that I am trying to write some specs for. I have a simple spec where I am essentially getting “all” rows from my model table. However I’d like to stub …

---

## [Not able to run tests for rspec itself](https://www.ruby-forum.com/t/not-able-to-run-tests-for-rspec-itself/189044)

<div class="topic-metadata">

**Author:** [@Nadal](https://www.ruby-forum.com/u/Nadal)\
**Replies:** 4\
**Last updated:** [May 24, 2010, 1:15am UTC](https://www.ruby-forum.com/t/not-able-to-run-tests-for-rspec-itself/189044 "2010-05-24T01:15:36Z")

</div>

I am talking about rspec itself and running tests written for rspec. This is what I did. git clone GitHub - dchelimsky/rspec: Behaviour Driven Development framework for Ruby cd rspec rake test I am getting followi…

---

## [How do I isolation test against different gem versions?](https://www.ruby-forum.com/t/how-do-i-isolation-test-against-different-gem-versions/189063)

<div class="topic-metadata">

**Author:** [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Replies:** 3\
**Last updated:** [May 23, 2010, 7:58pm UTC](https://www.ruby-forum.com/t/how-do-i-isolation-test-against-different-gem-versions/189063 "2010-05-23T19:58:21Z")

</div>

I would like to support both ActiveRecord 2.x and ActiveModel 3.x for a given library. It is not clear to me how to write tests for this. If I require ‘active\_record’ then all of the dependencies are also loaded and a…

---

## [Not able to run tests on rails](https://www.ruby-forum.com/t/not-able-to-run-tests-on-rails/189045)

<div class="topic-metadata">

**Author:** [@Nadal](https://www.ruby-forum.com/u/Nadal)\
**Replies:** 1\
**Last updated:** [May 23, 2010, 3:21am UTC](https://www.ruby-forum.com/t/not-able-to-run-tests-on-rails/189045 "2010-05-23T03:21:03Z")

</div>

This is what I did. Please tell me where did I go wrong. I am using rails 2.3.5 rails demo cd demo ruby script/generate scaffold User name:string rake db:migrate rake db:test:prepare ruby script/plugin install git:…

---

## [Customize output of script/spec?](https://www.ruby-forum.com/t/customize-output-of-script-spec/189038)

<div class="topic-metadata">

**Author:** [@cghost](https://www.ruby-forum.com/u/cghost)\
**Replies:** 1\
**Last updated:** [May 22, 2010, 10:27pm UTC](https://www.ruby-forum.com/t/customize-output-of-script-spec/189038 "2010-05-22T22:27:53Z")

</div>

Hi, I am just curious-- is there any way to customize the output of the “expect”, “got” that is returned? I often find myself comparing big blocks of text that are virtually identical except one minor detail (like …

---

## [Good practices on spec'ing views?](https://www.ruby-forum.com/t/good-practices-on-specing-views/187845)

<div class="topic-metadata">

**Author:** [@stefankroes](https://www.ruby-forum.com/u/stefankroes)\
**Replies:** 7\
**Last updated:** [May 21, 2010, 9:29pm UTC](https://www.ruby-forum.com/t/good-practices-on-specing-views/187845 "2010-05-21T21:29:24Z")

</div>

Hey guys. I’ve been doing RSpec for more than a year by now, yet I cannot help but feel that I’ve never got a single view spec right. I can see that I have very few view specs and that my views tend be a lot messier t…

---

## [Strange issue with the 'its' construct](https://www.ruby-forum.com/t/strange-issue-with-the-its-construct/188935)

<div class="topic-metadata">

**Author:** [@tomtt](https://www.ruby-forum.com/u/tomtt)\
**Replies:** 2\
**Last updated:** [May 21, 2010, 2:53am UTC](https://www.ruby-forum.com/t/strange-issue-with-the-its-construct/188935 "2010-05-21T02:53:04Z")

</div>

The ‘its’ construct seems to not be working for me. I have narrowed it down to a basic example that I think should be working. Note that when I use a normal ‘it’ block with a subject in it, that works fine. Any insigh…

---

## [How I make browser act-as-robot-driven?](https://www.ruby-forum.com/t/how-i-make-browser-act-as-robot-driven/188898)

<div class="topic-metadata">

**Author:** [@audreylee88](https://www.ruby-forum.com/u/audreylee88)\
**Replies:** 2\
**Last updated:** [May 20, 2010, 10:44pm UTC](https://www.ruby-forum.com/t/how-i-make-browser-act-as-robot-driven/188898 "2010-05-20T22:44:10Z")

</div>

Dear list, Today I am working through the simple tutorial here: http://wiki.github.com/aslakhellesoy/cucumber/ruby-on-rails It has me install Cucumber-Rails and then create a feature. Then I watch the feature fail wh…

---

## [Quickcheck testing framework](https://www.ruby-forum.com/t/quickcheck-testing-framework/188696)

<div class="topic-metadata">

**Author:** [@sthorpe](https://www.ruby-forum.com/u/sthorpe)\
**Replies:** 5\
**Last updated:** [May 20, 2010, 5:18am UTC](https://www.ruby-forum.com/t/quickcheck-testing-framework/188696 "2010-05-20T05:18:37Z")

</div>

Hey all, I’m wondering if anyone has any experience with an automated test-case generation tool like Quickcheck (for erlang/haskell). I’d be interested in hearing any impressions, war stories, or dev workflows regardi…

---

## [How to separate unit and integration spec suites?](https://www.ruby-forum.com/t/how-to-separate-unit-and-integration-spec-suites/188890)

<div class="topic-metadata">

**Author:** [@Myron\_M](https://www.ruby-forum.com/u/Myron_M)\
**Replies:** 4\
**Last updated:** [May 20, 2010, 3:32am UTC](https://www.ruby-forum.com/t/how-to-separate-unit-and-integration-spec-suites/188890 "2010-05-20T03:32:41Z")

</div>

On my current rails project we’re using both rspec and cucumber. We’ve been diligent about keeping our specs as true unit tests, using nulldb and mocking/stubbing to disconnect the specs from the database and keep eac…

---

## [A full rails application with rspec test code](https://www.ruby-forum.com/t/a-full-rails-application-with-rspec-test-code/188709)

<div class="topic-metadata">

**Author:** [@Nadal](https://www.ruby-forum.com/u/Nadal)\
**Replies:** 1\
**Last updated:** [May 18, 2010, 4:39am UTC](https://www.ruby-forum.com/t/a-full-rails-application-with-rspec-test-code/188709 "2010-05-18T04:39:35Z")

</div>

I used bostonrb code base GitHub - bostonrb/bostonrb: Website for bostonrb.org to learn about shoulda. Similarly is there a decent rails based application with test code in rspec to see how to write good rspec test cod…

---

## [Failing Flash Spec](https://www.ruby-forum.com/t/failing-flash-spec/188672)

<div class="topic-metadata">

**Author:** [@Kwang\_how\_T](https://www.ruby-forum.com/u/Kwang_how_T)\
**Replies:** 6\
**Last updated:** [May 18, 2010, 4:32am UTC](https://www.ruby-forum.com/t/failing-flash-spec/188672 "2010-05-18T04:32:34Z")

</div>

I am having failing simple spec which I couldn’t figure out why :frowning: ffaker (0.4.0) machinist (1.0.6) rails (3.0.0.beta3) rspec (2.0.0.beta.8) rspec-core (2.0.0.beta.8) rspec-expectations (2.0.0.beta.8) rspec-mo…

---

## [Best practices for managing fixtures outside Rails?](https://www.ruby-forum.com/t/best-practices-for-managing-fixtures-outside-rails/188708)

<div class="topic-metadata">

**Author:** [@stu](https://www.ruby-forum.com/u/stu)\
**Replies:** 2\
**Last updated:** [May 17, 2010, 3:34am UTC](https://www.ruby-forum.com/t/best-practices-for-managing-fixtures-outside-rails/188708 "2010-05-17T03:34:12Z")

</div>

Hi, I have a non-Rails R. project that uses RSpec. It needs a shared collection of fixture-like objects created, although they have nothing to do with Rails, AR or database entries: w1 = Widget.new(10) w2 = Widget.…

---

## [Stubbing return arguments](https://www.ruby-forum.com/t/stubbing-return-arguments/188707)

<div class="topic-metadata">

**Author:** [@rhydiant](https://www.ruby-forum.com/u/rhydiant)\
**Replies:** 2\
**Last updated:** [May 17, 2010, 3:07am UTC](https://www.ruby-forum.com/t/stubbing-return-arguments/188707 "2010-05-17T03:07:17Z")

</div>

I’m writting a code example for the following method: def upload(email\_address, product\_data) errors = \[\] user = resolve\_user\_from(email\_address) product\_file\_name = ProductFileHandler.persist(user, product\_data,…

---

## [Spec/support directory outside Rails?](https://www.ruby-forum.com/t/spec-support-directory-outside-rails/188711)

<div class="topic-metadata">

**Author:** [@stu](https://www.ruby-forum.com/u/stu)\
**Replies:** 1\
**Last updated:** [May 17, 2010, 1:07am UTC](https://www.ruby-forum.com/t/spec-support-directory-outside-rails/188711 "2010-05-17T01:07:18Z")

</div>

Hi, I have a group of non-Rails R. projects that all make heavy use of RSpec. Each of these projects has a “spec” directory with a “helper.rb” file. All the \*\_spec.rb files in the spec directory tree do the usual r…

---

## [Running spec tests from ruby code](https://www.ruby-forum.com/t/running-spec-tests-from-ruby-code/188662)

<div class="topic-metadata">

**Author:** [@madscene](https://www.ruby-forum.com/u/madscene)\
**Replies:** 0\
**Last updated:** [May 15, 2010, 9:30pm UTC](https://www.ruby-forum.com/t/running-spec-tests-from-ruby-code/188662 "2010-05-15T21:30:01Z")

</div>

I’m trying to do some more custom testing with rails and I’m trying to write a rake task that will perform this testing. What I need the task to do is load the rails environment, run some MySql scripts and then run so…

---

## [RSpec and Factory Girl: Destroying an object](https://www.ruby-forum.com/t/rspec-and-factory-girl-destroying-an-object/188602)

<div class="topic-metadata">

**Author:** [@dazuma](https://www.ruby-forum.com/u/dazuma)\
**Replies:** 3\
**Last updated:** [May 15, 2010, 2:30am UTC](https://www.ruby-forum.com/t/rspec-and-factory-girl-destroying-an-object/188602 "2010-05-15T02:30:32Z")

</div>

Hi, I have a problem when testing the deletion of a record from the database. I am using RSpec methods to check if my account object is being destroyed. The factory creates an account object and saves it into the DB.…

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

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