# RSpec

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

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

---

## [Rspec bug, on Mysql::Error: MySQL server has gone away: ROLLBACK TO SAVEPOINT active\_record\_1](https://www.ruby-forum.com/t/rspec-bug-on-mysql-mysql-server-has-gone-away-rollback-to-savepoint-active-record-1/185517)

<div class="topic-metadata">

**Author:** [@poldz](https://www.ruby-forum.com/u/poldz)\
**Replies:** 0\
**Last updated:** [March 22, 2010, 4:56am UTC](https://www.ruby-forum.com/t/rspec-bug-on-mysql-mysql-server-has-gone-away-rollback-to-savepoint-active-record-1/185517 "2010-03-22T04:56:14Z")

</div>

hello can anybody help me with this bug, (this sometimes occur sometimes passes) ActiveRecord::StatementInvalid in ‘MailReader on Simple Tasks should not accept duplicate email’ Mysql::Error: MySQL server has go…

---

## [Autotest, rails and view specs](https://www.ruby-forum.com/t/autotest-rails-and-view-specs/185512)

<div class="topic-metadata">

**Author:** [@brunopires](https://www.ruby-forum.com/u/brunopires)\
**Replies:** 1\
**Last updated:** [March 22, 2010, 2:43am UTC](https://www.ruby-forum.com/t/autotest-rails-and-view-specs/185512 "2010-03-22T02:43:21Z")

</div>

Hi, I’ve read in \[1\] that autotest “does not work with view specs for rails versions \< 2.3”, but I didn’t find a reason about that. Is it just a bug? – \[\]'s Bruno \[1\] http://wiki.github.com/dchelimsky/rspec/spork-a…

---

## [Insufficient database clean-up between specs](https://www.ruby-forum.com/t/insufficient-database-clean-up-between-specs/185163)

<div class="topic-metadata">

**Author:** [@jollyroger](https://www.ruby-forum.com/u/jollyroger)\
**Replies:** 3\
**Last updated:** [March 20, 2010, 1:29pm UTC](https://www.ruby-forum.com/t/insufficient-database-clean-up-between-specs/185163 "2010-03-20T13:29:09Z")

</div>

Hey guys, unfortunately I’ve got one more issue with rspec right now. It seems like rspec isnt properly cleaning up the database after each spec. I have the following spec: ##########################################…

---

## [Stub vs stub!](https://www.ruby-forum.com/t/stub-vs-stub/185425)

<div class="topic-metadata">

**Author:** [@nickh](https://www.ruby-forum.com/u/nickh)\
**Replies:** 8\
**Last updated:** [March 20, 2010, 11:46am UTC](https://www.ruby-forum.com/t/stub-vs-stub/185425 "2010-03-20T11:46:42Z")

</div>

RSpec’s changelog says that in version 1.2.5: “also alias\_method :stub, :stub!, so you can stub with less bang” which I’ve been taking advantage of a lot. However, I just ran into a situation where using #stub caused …

---

## [How does one define dependencies on a specTask?](https://www.ruby-forum.com/t/how-does-one-define-dependencies-on-a-spectask/185377)

<div class="topic-metadata">

**Author:** [@jwjwjw](https://www.ruby-forum.com/u/jwjwjw)\
**Replies:** 1\
**Last updated:** [March 19, 2010, 12:58am UTC](https://www.ruby-forum.com/t/how-does-one-define-dependencies-on-a-spectask/185377 "2010-03-19T00:58:58Z")

</div>

I get that you create dependencies on a normal rake task like this: task :codeGen do do the code generation end task :compile =\> :codeGen do do the compilation end but what is the syntax for a specTask? Spec::Rake:…

---

## [How to mock a Net::Http object?](https://www.ruby-forum.com/t/how-to-mock-a-net-http-object/184421)

<div class="topic-metadata">

**Author:** [@rubyernewbie](https://www.ruby-forum.com/u/rubyernewbie)\
**Replies:** 2\
**Last updated:** [March 19, 2010, 12:02am UTC](https://www.ruby-forum.com/t/how-to-mock-a-net-http-object/184421 "2010-03-19T00:02:45Z")

</div>

one\_data = Net::HTTP.post\_form(URI.parse(country\_site), {‘country’ =\> “american”}) two\_data = Net::HTTP.post\_form(URI.parse(visit\_site), {‘country’ =\> “english”}) I have a code similar like above code in my applicati…

---

## [Shared\_example can't have the same name even if defined it different specs](https://www.ruby-forum.com/t/shared-example-cant-have-the-same-name-even-if-defined-it-different-specs/185369)

<div class="topic-metadata">

**Author:** [@drewB](https://www.ruby-forum.com/u/drewB)\
**Replies:** 1\
**Last updated:** [March 18, 2010, 10:43pm UTC](https://www.ruby-forum.com/t/shared-example-cant-have-the-same-name-even-if-defined-it-different-specs/185369 "2010-03-18T22:43:47Z")

</div>

I am writing some specs related to permissions for different kinds of users. Every user has some common examples to test in many different specs. For example, all users can view, and edit their profile. Also, all us…

---

## [Rspec doubles & rails metal](https://www.ruby-forum.com/t/rspec-doubles-rails-metal/185341)

<div class="topic-metadata">

**Author:** [@Nash](https://www.ruby-forum.com/u/Nash)\
**Replies:** 1\
**Last updated:** [March 18, 2010, 1:51pm UTC](https://www.ruby-forum.com/t/rspec-doubles-rails-metal/185341 "2010-03-18T13:51:32Z")

</div>

Hi, I’ve created a cucumber test to test a metal I’ve created that connects to a third party. I’m using rspec mocks to create a stub for the 3 party. It seems that stubbing/mocking isn’t extending all the way to the …

---

## [Rspec with out Active Record](https://www.ruby-forum.com/t/rspec-with-out-active-record/185342)

<div class="topic-metadata">

**Author:** [@harinionrails](https://www.ruby-forum.com/u/harinionrails)\
**Replies:** 2\
**Last updated:** [March 18, 2010, 1:44pm UTC](https://www.ruby-forum.com/t/rspec-with-out-active-record/185342 "2010-03-18T13:44:30Z")

</div>

I want to use rspec with my application where we don’t have database. I want to know how to use fixtures with out ORM layer.

---

## [Strange validation errors](https://www.ruby-forum.com/t/strange-validation-errors/185162)

<div class="topic-metadata">

**Author:** [@jollyroger](https://www.ruby-forum.com/u/jollyroger)\
**Replies:** 2\
**Last updated:** [March 18, 2010, 11:31am UTC](https://www.ruby-forum.com/t/strange-validation-errors/185162 "2010-03-18T11:31:02Z")

</div>

Hey guys, I’m having a serious rspec-problem at the moment: I keep getting strange, empty validation errors when I run the whole spec-suite: ################################################################# 1) Acti…

---

## [Autospec with RSpec 2 beta for Rails 3](https://www.ruby-forum.com/t/autospec-with-rspec-2-beta-for-rails-3/185288)

<div class="topic-metadata">

**Author:** [@DEfusion](https://www.ruby-forum.com/u/DEfusion)\
**Replies:** 6\
**Last updated:** [March 17, 2010, 5:58pm UTC](https://www.ruby-forum.com/t/autospec-with-rspec-2-beta-for-rails-3/185288 "2010-03-17T17:58:42Z")

</div>

I can’t seem to find autospec installed anywhere after installing the latest Rails 3 beta. I’ve tried copying the contents of a script/ autospec from a Rails 2 application but that includes all the test/ file none of …

---

## [Testing the \<=\> operator](https://www.ruby-forum.com/t/testing-the-operator/185210)

<div class="topic-metadata">

**Author:** [@Chris\_DiMartino](https://www.ruby-forum.com/u/Chris_DiMartino)\
**Replies:** 1\
**Last updated:** [March 16, 2010, 5:58am UTC](https://www.ruby-forum.com/t/testing-the-operator/185210 "2010-03-16T05:58:22Z")

</div>

I’m having trouble getting rspec to allow me to test my Comparable class. I would like to test the \<=\> method, but rspec is giving me unexpected results: @hand = Hand.new(‘R’) @other\_hand = Hand.new(‘S’) @hand.sho…

---

## [Is share\_examples\_for deprecated?](https://www.ruby-forum.com/t/is-share-examples-for-deprecated/184700)

<div class="topic-metadata">

**Author:** [@nickh](https://www.ruby-forum.com/u/nickh)\
**Replies:** 7\
**Last updated:** [March 15, 2010, 9:01pm UTC](https://www.ruby-forum.com/t/is-share-examples-for-deprecated/184700 "2010-03-15T21:01:08Z")

</div>

API Dock says that “share\_examples\_for” is deprecated. If that’s correct, what should we be using instead? http://apidock.com/rspec/Spec/Extensions/Main/share\_examples\_for Thanks, Nick

---

## [Problwm with Webrat and Selenium](https://www.ruby-forum.com/t/problwm-with-webrat-and-selenium/185175)

<div class="topic-metadata">

**Author:** [@railslist](https://www.ruby-forum.com/u/railslist)\
**Replies:** 0\
**Last updated:** [March 15, 2010, 3:54pm UTC](https://www.ruby-forum.com/t/problwm-with-webrat-and-selenium/185175 "2010-03-15T15:54:53Z")

</div>

Hello Everyone, I am having problem running Webrat steps through Firefox using Selenium. I doesn’t give me any error, but it never does anything. Well, I am using Windows XP (I know…) Here are the gems I am using: …

---

## [Spec-ing a nested object is saved on the specs of the object it is nested into](https://www.ruby-forum.com/t/spec-ing-a-nested-object-is-saved-on-the-specs-of-the-object-it-is-nested-into/185047)

<div class="topic-metadata">

**Author:** [@joahking](https://www.ruby-forum.com/u/joahking)\
**Replies:** 2\
**Last updated:** [March 15, 2010, 2:47pm UTC](https://www.ruby-forum.com/t/spec-ing-a-nested-object-is-saved-on-the-specs-of-the-object-it-is-nested-into/185047 "2010-03-15T14:47:36Z")

</div>

hi there, I have a Rails model A, that has\_one model B, model A have a method called save\_nested\_b that: context ‘invalid B params’ \*\* context ‘no nested B exists’ =\> do nothing \*\* context ‘nested B exists’ =\> re…

---

## [\[rails\] mock controllers, different behaviour between ruby 1.8.7 and 	ruby 1.9.1](https://www.ruby-forum.com/t/rails-mock-controllers-different-behaviour-between-ruby-1-8-7-and-ruby-1-9-1/185167)

<div class="topic-metadata">

**Author:** [@giorgian](https://www.ruby-forum.com/u/giorgian)\
**Replies:** 1\
**Last updated:** [March 15, 2010, 1:47pm UTC](https://www.ruby-forum.com/t/rails-mock-controllers-different-behaviour-between-ruby-1-8-7-and-ruby-1-9-1/185167 "2010-03-15T13:47:18Z")

</div>

Hi, I wanted to test something like this: /lib/rest\_verification.rb module RestVerification def self.included(base) # :nodoc: base.extend(ClassMethods) end module ClassMethods def verify\_rest\_actions verify :met…

---

## [AmbiguousReturnError](https://www.ruby-forum.com/t/ambiguousreturnerror/185132)

<div class="topic-metadata">

**Author:** [@barunio](https://www.ruby-forum.com/u/barunio)\
**Replies:** 2\
**Last updated:** [March 14, 2010, 11:48pm UTC](https://www.ruby-forum.com/t/ambiguousreturnerror/185132 "2010-03-14T23:48:03Z")

</div>

I’m trying to use RSpec to test some screen-scraping code. Because I don’t want to hit external websites for my tests, I’m stubbing out the html I expect to receive, and trying to focus my tests on making sure the co…

---

## [Autotest & rspec2](https://www.ruby-forum.com/t/autotest-rspec2/185122)

<div class="topic-metadata">

**Author:** [@jeroen](https://www.ruby-forum.com/u/jeroen)\
**Replies:** 2\
**Last updated:** [March 14, 2010, 7:53pm UTC](https://www.ruby-forum.com/t/autotest-rspec2/185122 "2010-03-14T19:53:22Z")

</div>

Hi guys, I’m trying to find some information on how to get autotest to run the rspec2 tests. I have my project setup so “rake spec” runs the specs properly, but autotest seems to ignore/don’t know that there are specs …

---

## [Access to controller and request objects in controller specs (rails 3)](https://www.ruby-forum.com/t/access-to-controller-and-request-objects-in-controller-specs-rails-3/185121)

<div class="topic-metadata">

**Author:** [@stevehodgkiss](https://www.ruby-forum.com/u/stevehodgkiss)\
**Replies:** 1\
**Last updated:** [March 14, 2010, 4:26pm UTC](https://www.ruby-forum.com/t/access-to-controller-and-request-objects-in-controller-specs-rails-3/185121 "2010-03-14T16:26:10Z")

</div>

Hi Rails 3 provides @controller and @request as instance variables in controller tests, whats the equivalent in rspec controller tests? I’m using warden for authentication and need to be able to stub @request.env\[‘wa…

---

## [Testing file upload (Sinatra, RSpec, Rack-Test)](https://www.ruby-forum.com/t/testing-file-upload-sinatra-rspec-rack-test/185103)

<div class="topic-metadata">

**Author:** [@polunochnik](https://www.ruby-forum.com/u/polunochnik)\
**Replies:** 1\
**Last updated:** [March 13, 2010, 8:21pm UTC](https://www.ruby-forum.com/t/testing-file-upload-sinatra-rspec-rack-test/185103 "2010-03-13T20:21:24Z")

</div>

Hi. I have a simple application and I want to add a file upload functionality. How can I write a spec? Here’s my try. directory structure app: controller.rb controller.spec.rb files: \[\] fixtures: \[test\_file.png\] c…

---

## [Testing a rails controller \*outside\* of spec/controllers](https://www.ruby-forum.com/t/testing-a-rails-controller-outside-of-spec-controllers/184970)

<div class="topic-metadata">

**Author:** [@NicolSSSSs\_Sanguine](https://www.ruby-forum.com/u/NicolSSSSs_Sanguine)\
**Replies:** 10\
**Last updated:** [March 11, 2010, 2:43pm UTC](https://www.ruby-forum.com/t/testing-a-rails-controller-outside-of-spec-controllers/184970 "2010-03-11T14:43:39Z")

</div>

We have an app that has “extensions” that are built as rails engines. Each engine needs some code in the controllers, which we solved as “include this module, call a method”. In order to test it, though, we don’t want…

---

## [How to test helpers in a Sinatra app?](https://www.ruby-forum.com/t/how-to-test-helpers-in-a-sinatra-app/184939)

<div class="topic-metadata">

**Author:** [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Replies:** 0\
**Last updated:** [March 10, 2010, 6:03pm UTC](https://www.ruby-forum.com/t/how-to-test-helpers-in-a-sinatra-app/184939 "2010-03-10T18:03:00Z")

</div>

I am using rspec and trying to test some helpers, but for some reason can’t get rspec to read my methods in my helpers.rb file. I include the helpers file in the helpers spec…in the spec I run a test with a method fro…

---

## [Spork in RSpec 2](https://www.ruby-forum.com/t/spork-in-rspec-2/184927)

<div class="topic-metadata">

**Author:** [@Ashley\_M](https://www.ruby-forum.com/u/Ashley_M)\
**Replies:** 2\
**Last updated:** [March 10, 2010, 3:08pm UTC](https://www.ruby-forum.com/t/spork-in-rspec-2/184927 "2010-03-10T15:08:19Z")

</div>

Hi I’ve just started using RSpec 2 in Rails 3 and I’m incredibly frustrated by the time it takes to boot Rails, it’s a real TDD bottleneck. The obvious solution is Spork, which is currently not possible with RSpec 2 …

---

## [Webrat methods are undefined](https://www.ruby-forum.com/t/webrat-methods-are-undefined/158833)

<div class="topic-metadata">

**Author:** [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Replies:** 16\
**Last updated:** [March 10, 2010, 3:06pm UTC](https://www.ruby-forum.com/t/webrat-methods-are-undefined/158833 "2010-03-10T15:06:17Z")

</div>

I am sure it is just a configuration issue, but when I use any of the steps in the webrat\_steps.rb file, I get messages like: undefined method \`click\_link’ I have the webrat gem installed (0.3.4). I have the aslakhell…

---

## [Undefined method 'post'](https://www.ruby-forum.com/t/undefined-method-post/184564)

<div class="topic-metadata">

**Author:** [@tornado](https://www.ruby-forum.com/u/tornado)\
**Replies:** 7\
**Last updated:** [March 8, 2010, 12:12pm UTC](https://www.ruby-forum.com/t/undefined-method-post/184564 "2010-03-08T12:12:52Z")

</div>

Hello all, I am facing a strange problem. I have generated rspec for a particular project.Similarly created a spec controller.Under that controller i have written post :create action When i run my spec i get an error…

---

## [How to pass objects from spec to formatter from before :all block?](https://www.ruby-forum.com/t/how-to-pass-objects-from-spec-to-formatter-from-before-all-block/184685)

<div class="topic-metadata">

**Author:** [@juuser](https://www.ruby-forum.com/u/juuser)\
**Replies:** 5\
**Last updated:** [March 7, 2010, 2:53pm UTC](https://www.ruby-forum.com/t/how-to-pass-objects-from-spec-to-formatter-from-before-all-block/184685 "2010-03-07T14:53:59Z")

</div>

Hello. I need to pass something from before :all to formatter. I know that i could use options hash from spec and then get the value back in formatter, but it doesn’t work when i’m doing it from before :all. So, this…

---

## [Newlines in step arguments Was How can I pass an XML block](https://www.ruby-forum.com/t/newlines-in-step-arguments-was-how-can-i-pass-an-xml-block/184691)

<div class="topic-metadata">

**Author:** [@Ed\_Howland](https://www.ruby-forum.com/u/Ed_Howland)\
**Replies:** 0\
**Last updated:** [March 6, 2010, 8:38pm UTC](https://www.ruby-forum.com/t/newlines-in-step-arguments-was-how-can-i-pass-an-xml-block/184691 "2010-03-06T20:38:55Z")

</div>

On Tue, Apr 14, 2009 at 10:03 PM, Stephen E. removed\_email\_address@domain.invalid wrote: On Tue, Apr 14, 2009 at 10:37 PM, Stephen E. removed\_email\_address@domain.invalid wrote: All right, never mind. Having been …

---

## [RSpec 2 / Rails 3 autoload](https://www.ruby-forum.com/t/rspec-2-rails-3-autoload/184682)

<div class="topic-metadata">

**Author:** [@Ashley\_M](https://www.ruby-forum.com/u/Ashley_M)\
**Replies:** 0\
**Last updated:** [March 6, 2010, 5:45pm UTC](https://www.ruby-forum.com/t/rspec-2-rails-3-autoload/184682 "2010-03-06T17:45:40Z")

</div>

Hi For the last 18 months I’ve been used to writing specs like this, which was written with Merb 1.1.0.pre and RSpec 1.3: module LanguageRepository describe DataMapperAdapter do it\_should\_behave\_like “Contract: Lang…

---

## [Rspec-2 update](https://www.ruby-forum.com/t/rspec-2-update/184538)

<div class="topic-metadata">

**Author:** [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Replies:** 2\
**Last updated:** [March 4, 2010, 3:01pm UTC](https://www.ruby-forum.com/t/rspec-2-update/184538 "2010-03-04T15:01:16Z")

</div>

Hey all, rspec-2 is moving along nicely and we’re at the point now where we’d love to see more people starting to use it, provide feedback, and hopefully start contributing as well. You can find the rspec-2 repositor…

---

## [Rspec-2 for rails-2?](https://www.ruby-forum.com/t/rspec-2-for-rails-2/184542)

<div class="topic-metadata">

**Author:** [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Replies:** 2\
**Last updated:** [March 4, 2010, 2:46pm UTC](https://www.ruby-forum.com/t/rspec-2-for-rails-2/184542 "2010-03-04T14:46:02Z")

</div>

Hey all, rspec-rails-2 will only work with rails-3 (not rails-2). My suspicion is that once rspec-2 is out, folks are going to want to start using it with their existing rails-2 projects (because it offers some sweet …

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

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