# RSpec

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

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

---

## [First Post (Best Practices)](https://www.ruby-forum.com/t/first-post-best-practices/188530)

<div class="topic-metadata">

**Author:** [@Ants\_P](https://www.ruby-forum.com/u/Ants_P)\
**Replies:** 4\
**Last updated:** [May 14, 2010, 12:48am UTC](https://www.ruby-forum.com/t/first-post-best-practices/188530 "2010-05-14T00:48:17Z")

</div>

Hello everyone, I’m just working my way through the RSpec/Cucumber book, I love the tool but not so much the learning curve :frowning: Starting with my first view, is it okay for me, in the BDD world, to do the fol…

---

## [Does rspec 2 have fixture support?](https://www.ruby-forum.com/t/does-rspec-2-have-fixture-support/188235)

<div class="topic-metadata">

**Author:** [@SiSiSi](https://www.ruby-forum.com/u/SiSiSi)\
**Replies:** 3\
**Last updated:** [May 14, 2010, 12:20am UTC](https://www.ruby-forum.com/t/does-rspec-2-have-fixture-support/188235 "2010-05-14T00:20:11Z")

</div>

Am I right in thinking that rspec 2, being based on Micronaut, has no Rails fixture support? I tried to get my specs running under rspec-\* 2.0.0.beta.8 and Rails 3 edge, but no dice on the fixture front. I’ve tried co…

---

## [Question about 'its' method in rspec2](https://www.ruby-forum.com/t/question-about-its-method-in-rspec2/188503)

<div class="topic-metadata">

**Author:** [@petr.blaho](https://www.ruby-forum.com/u/petr.blaho)\
**Replies:** 1\
**Last updated:** [May 13, 2010, 3:00am UTC](https://www.ruby-forum.com/t/question-about-its-method-in-rspec2/188503 "2010-05-13T03:00:31Z")

</div>

Hi there, is ‘its’ method implemented in rspec2? I use rspec2 with rails3 and want to use syntax like in this example: describe Array do subject { Array.new(4) } its(:length) { should == 4 } end Is it possible? W…

---

## [Versions of RSpec & Rails](https://www.ruby-forum.com/t/versions-of-rspec-rails/188472)

<div class="topic-metadata">

**Author:** [@saschap](https://www.ruby-forum.com/u/saschap)\
**Replies:** 1\
**Last updated:** [May 12, 2010, 3:55pm UTC](https://www.ruby-forum.com/t/versions-of-rspec-rails/188472 "2010-05-12T15:55:22Z")

</div>

Hello. I’m new to ROR and i’m trying to use RSpec. I use Rails 2.3.5. I installed RSpec and RSpec-Rails as Plugin in my Project and i installed the Gem. Then i user script/generate rspec to generate the needed files…

---

## [Survey: roles in controller specs](https://www.ruby-forum.com/t/survey-roles-in-controller-specs/188433)

<div class="topic-metadata">

**Author:** [@chrisfinne](https://www.ruby-forum.com/u/chrisfinne)\
**Replies:** 1\
**Last updated:** [May 11, 2010, 11:33pm UTC](https://www.ruby-forum.com/t/survey-roles-in-controller-specs/188433 "2010-05-11T23:33:10Z")

</div>

I have a bit of a question on how people are organizing their controller specs, once you take user roles into account. I’m not entirely sure that I’ve found a way to do it that feels “natural” to me. So, say I’ve go…

---

## [Questions about meta-programming in a shared\_examples group](https://www.ruby-forum.com/t/questions-about-meta-programming-in-a-shared-examples-group/188381)

<div class="topic-metadata">

**Author:** [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Replies:** 1\
**Last updated:** [May 11, 2010, 7:53am UTC](https://www.ruby-forum.com/t/questions-about-meta-programming-in-a-shared-examples-group/188381 "2010-05-11T07:53:34Z")

</div>

I’ve created a shared\_examples group that helps me dry up the testing of a large set of similar rails controllers. These controllers have an html interface but mostly what I am testing with the shared\_examples group i…

---

## [What are the common causes of rspec hanging?](https://www.ruby-forum.com/t/what-are-the-common-causes-of-rspec-hanging/188287)

<div class="topic-metadata">

**Author:** [@RFine](https://www.ruby-forum.com/u/RFine)\
**Replies:** 1\
**Last updated:** [May 10, 2010, 9:46am UTC](https://www.ruby-forum.com/t/what-are-the-common-causes-of-rspec-hanging/188287 "2010-05-10T09:46:56Z")

</div>

I’m responsible for a relatively large RoR application, and have been struggling with intermittent rspec “hangs” for over a year despite many debugging attempts. I realize that we can’t debug my personal application …

---

## [RSpec newb - why is my negative test not passing?](https://www.ruby-forum.com/t/rspec-newb-why-is-my-negative-test-not-passing/188234)

<div class="topic-metadata">

**Author:** [@Jferg](https://www.ruby-forum.com/u/Jferg)\
**Replies:** 2\
**Last updated:** [May 9, 2010, 5:00am UTC](https://www.ruby-forum.com/t/rspec-newb-why-is-my-negative-test-not-passing/188234 "2010-05-09T05:00:23Z")

</div>

Why won’t this test work? I am trying to use RSpec to drive a negative test where my code will throw an exception which it does however, the test does not pass. It fails due to my exception. However, I am using sho…

---

## [Rspec model generation problem](https://www.ruby-forum.com/t/rspec-model-generation-problem/188200)

<div class="topic-metadata">

**Author:** [@tornado](https://www.ruby-forum.com/u/tornado)\
**Replies:** 1\
**Last updated:** [May 7, 2010, 3:16pm UTC](https://www.ruby-forum.com/t/rspec-model-generation-problem/188200 "2010-05-07T15:16:31Z")

</div>

Hello, I am currently working on Ubuntu machine in which there is already a spec file generated which has some models So i just updated by entering the command “ruby script/generate rspec” Now when i try to generate …

---

## [Rspec model generate problem](https://www.ruby-forum.com/t/rspec-model-generate-problem/197134)

<div class="topic-metadata">

**Author:** [@tornado](https://www.ruby-forum.com/u/tornado)\
**Replies:** 0\
**Last updated:** [May 7, 2010, 3:06pm UTC](https://www.ruby-forum.com/t/rspec-model-generate-problem/197134 "2010-05-07T15:06:12Z")

</div>

Hello, I am currently working on Ubuntu machine in which there is already a spec file generated which has some models So i just updated by entering the command “ruby script/generate rspec” Now when i try to generate …

---

## [Expecting an array but getting a string using webrat](https://www.ruby-forum.com/t/expecting-an-array-but-getting-a-string-using-webrat/188047)

<div class="topic-metadata">

**Author:** [@frank](https://www.ruby-forum.com/u/frank)\
**Replies:** 2\
**Last updated:** [May 7, 2010, 2:53pm UTC](https://www.ruby-forum.com/t/expecting-an-array-but-getting-a-string-using-webrat/188047 "2010-05-07T14:53:01Z")

</div>

Hi Guys, I’m new to webrat and I’ve encountered a problem. I have a nested form that I’ve created using the steps similar to the Rails Casts As context, I have a form for programming exercises with a title and descr…

---

## [Rspec beta8: helper methods issues](https://www.ruby-forum.com/t/rspec-beta8-helper-methods-issues/188197)

<div class="topic-metadata">

**Author:** [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Replies:** 2\
**Last updated:** [May 7, 2010, 1:48pm UTC](https://www.ruby-forum.com/t/rspec-beta8-helper-methods-issues/188197 "2010-05-07T13:48:03Z")

</div>

Hello everybody, I am experiencing the following problems, I googled quickly but I couldn’t find any documentation or solution to those issues: the generator rails g rspec:helper does nothing; there seems to be no w…

---

## [And\_return question](https://www.ruby-forum.com/t/and-return-question/188154)

<div class="topic-metadata">

**Author:** [@pkoebbe](https://www.ruby-forum.com/u/pkoebbe)\
**Replies:** 2\
**Last updated:** [May 7, 2010, 1:14pm UTC](https://www.ruby-forum.com/t/and-return-question/188154 "2010-05-07T13:14:41Z")

</div>

Are these two forms theoretically functionally equivalent: car = stub\_model(Car) Car.stub(:new).and\_return(car) Car.stub(:new).and\_return(stub\_model(Car)) I ask because I thought they were, but just hit somet…

---

## [Failing test despite "expected" and "got" being identical](https://www.ruby-forum.com/t/failing-test-despite-expected-and-got-being-identical/188157)

<div class="topic-metadata">

**Author:** [@ben\_rooney](https://www.ruby-forum.com/u/ben_rooney)\
**Replies:** 0\
**Last updated:** [May 6, 2010, 5:55pm UTC](https://www.ruby-forum.com/t/failing-test-despite-expected-and-got-being-identical/188157 "2010-05-06T17:55:44Z")

</div>

Thanks guys The law of posting questions came into force. About three minutes after posting my q, I found my mistake (which was exactly as you said). I figured I must have done something wrong, so went back and start…

---

## [Failing test despite "expected" and "got" being identical](https://www.ruby-forum.com/t/failing-test-despite-expected-and-got-being-identical/188132)

<div class="topic-metadata">

**Author:** [@ben\_rooney](https://www.ruby-forum.com/u/ben_rooney)\
**Replies:** 2\
**Last updated:** [May 6, 2010, 5:07pm UTC](https://www.ruby-forum.com/t/failing-test-despite-expected-and-got-being-identical/188132 "2010-05-06T17:07:09Z")

</div>

Slightly flummoxed on this one. Spec::Mocks::MockExpectationError in ‘ChartEventsController handling GET /chart\_events should find all chart\_events given a value’ expected: (\[:all, {:conditions=\>\[“value LIKE ?”, “%cha…

---

## [Kernel#debugger reminder method is unhelpful](https://www.ruby-forum.com/t/kernel-debugger-reminder-method-is-unhelpful/187989)

<div class="topic-metadata">

**Author:** [@timhunter](https://www.ruby-forum.com/u/timhunter)\
**Replies:** 2\
**Last updated:** [May 3, 2010, 10:20pm UTC](https://www.ruby-forum.com/t/kernel-debugger-reminder-method-is-unhelpful/187989 "2010-05-03T22:20:25Z")

</div>

I’m not exactly sure what the motivation behind the “debugger” catch was, perhaps a convenience method to allow your code to remain littered with debugger statements? At any rate, it’s obstructed my normal use of rub…

---

## [Error: can't convert Rspec::Mocks::Mock to String](https://www.ruby-forum.com/t/error-cant-convert-rspec-mock-to-string/187967)

<div class="topic-metadata">

**Author:** [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Replies:** 2\
**Last updated:** [May 3, 2010, 3:32pm UTC](https://www.ruby-forum.com/t/error-cant-convert-rspec-mock-to-string/187967 "2010-05-03T15:32:25Z")

</div>

Hello \*, I started today to test rspec current beta with ruby 1.9.2 and rails 3.0. I created a basic app with a scaffold. I am experiencing a lot of failures in the geneated controller spec. I am pasting the complete …

---

## [Named route failing in class spec](https://www.ruby-forum.com/t/named-route-failing-in-class-spec/187925)

<div class="topic-metadata">

**Author:** [@cghost](https://www.ruby-forum.com/u/cghost)\
**Replies:** 4\
**Last updated:** [May 2, 2010, 8:46pm UTC](https://www.ruby-forum.com/t/named-route-failing-in-class-spec/187925 "2010-05-02T20:46:22Z")

</div>

I have something like: class Foo def initialize(template) @template = template end def link link\_to “foo”, foo\_path end def method\_missing(\*args, &block) @template.send(\*args, &block) end end … before(:all) …

---

## [Update\_attributes fails in rake spec but not in script/spec?](https://www.ruby-forum.com/t/update-attributes-fails-in-rake-spec-but-not-in-script-spec/187882)

<div class="topic-metadata">

**Author:** [@cghost](https://www.ruby-forum.com/u/cghost)\
**Replies:** 3\
**Last updated:** [May 1, 2010, 2:29pm UTC](https://www.ruby-forum.com/t/update-attributes-fails-in-rake-spec-but-not-in-script-spec/187882 "2010-05-01T14:29:46Z")

</div>

Hi, So I just wrote a spec, and tested it by running script/spec models/result\_list\_spec.rb I get: … Finished in 28.558841 seconds 5 examples, 0 failures So then I did: rake spec and I get a bunch of errors on …

---

## [Multiple return values with stub](https://www.ruby-forum.com/t/multiple-return-values-with-stub/187872)

<div class="topic-metadata">

**Author:** [@pkoebbe](https://www.ruby-forum.com/u/pkoebbe)\
**Replies:** 2\
**Last updated:** [April 30, 2010, 7:29pm UTC](https://www.ruby-forum.com/t/multiple-return-values-with-stub/187872 "2010-04-30T19:29:43Z")

</div>

I have a helper method def login\_as(role) user = stub\_model(User) user.stub(:is\_administrator?).and\_return(role == :admin) User.stub(:find\_by\_id).and\_return(user) session\[:user\_id\] = user.id us…

---

## [Running code on error](https://www.ruby-forum.com/t/running-code-on-error/187835)

<div class="topic-metadata">

**Author:** [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Replies:** 3\
**Last updated:** [April 30, 2010, 6:43pm UTC](https://www.ruby-forum.com/t/running-code-on-error/187835 "2010-04-30T18:43:27Z")

</div>

describe “Test” do after(:each) do if ERRORS #execute custom code here end it “should explode” do #Test.explode --\> “fizzle” Test.explode.should == “KABOOM” end end Let’s say I have the above test and the valida…

---

## [Future of RSpec Integration Testing](https://www.ruby-forum.com/t/future-of-rspec-integration-testing/187816)

<div class="topic-metadata">

**Author:** [@sjames](https://www.ruby-forum.com/u/sjames)\
**Replies:** 4\
**Last updated:** [April 30, 2010, 4:49pm UTC](https://www.ruby-forum.com/t/future-of-rspec-integration-testing/187816 "2010-04-30T16:49:49Z")

</div>

Greetings. My team at work is trying to decide between Cucumber and RSpec integration tests for all future integration-style testing. The team is divided on this, so I thought I’d approach the community to see what t…

---

## [More rspec questions](https://www.ruby-forum.com/t/more-rspec-questions/187695)

<div class="topic-metadata">

**Author:** [@cghost](https://www.ruby-forum.com/u/cghost)\
**Replies:** 11\
**Last updated:** [April 29, 2010, 8:53pm UTC](https://www.ruby-forum.com/t/more-rspec-questions/187695 "2010-04-29T20:53:21Z")

</div>

Hi everyone, I still am on my quest to understand Rspec, and I have a few new questions… If I have a “complex” method which calls other methods, say something like: class Foo def complex\_method setup setup\_somet…

---

## [Cucumber login problem](https://www.ruby-forum.com/t/cucumber-login-problem/187810)

<div class="topic-metadata">

**Author:** [@tornado](https://www.ruby-forum.com/u/tornado)\
**Replies:** 1\
**Last updated:** [April 29, 2010, 6:14pm UTC](https://www.ruby-forum.com/t/cucumber-login-problem/187810 "2010-04-29T18:14:05Z")

</div>

Hello all, I am facing a weird problem.I am just trying to login but after entering correct parameters it is showing error as invalid username and password. I think there is some configuration or fixtures problem beca…

---

## [Google App Engine](https://www.ruby-forum.com/t/google-app-engine/187748)

<div class="topic-metadata">

**Author:** [@jhagemeier](https://www.ruby-forum.com/u/jhagemeier)\
**Replies:** 2\
**Last updated:** [April 29, 2010, 5:46pm UTC](https://www.ruby-forum.com/t/google-app-engine/187748 "2010-04-29T17:46:34Z")

</div>

Can someone provide instructions for setting up rspec with Rails on Google App Engine?

---

## [Testing against a live environment](https://www.ruby-forum.com/t/testing-against-a-live-environment/187647)

<div class="topic-metadata">

**Author:** [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Replies:** 7\
**Last updated:** [April 29, 2010, 4:42pm UTC](https://www.ruby-forum.com/t/testing-against-a-live-environment/187647 "2010-04-29T16:42:10Z")

</div>

I have a series of tests I want to automate, which involve running shell scripts in a “live” environment (i.e. nothing mocked or stubbed), and then verifying the state of the system. I thought that, even though it doe…

---

## [Rspec doesnt recognize a custom mime type](https://www.ruby-forum.com/t/rspec-doesnt-recognize-a-custom-mime-type/187802)

<div class="topic-metadata">

**Author:** [@jollyroger](https://www.ruby-forum.com/u/jollyroger)\
**Replies:** 3\
**Last updated:** [April 29, 2010, 3:27pm UTC](https://www.ruby-forum.com/t/rspec-doesnt-recognize-a-custom-mime-type/187802 "2010-04-29T15:27:13Z")

</div>

Hey guys, I have a custom MIME type registered like that: cat config/initializers/mime\_types.rb Mime::Type.register “lightbox”, :lightbox → This works perfectly well in my application. However my corresponding spec…

---

## [Rcov not working?](https://www.ruby-forum.com/t/rcov-not-working/187777)

<div class="topic-metadata">

**Author:** [@cghost](https://www.ruby-forum.com/u/cghost)\
**Replies:** 1\
**Last updated:** [April 29, 2010, 6:28am UTC](https://www.ruby-forum.com/t/rcov-not-working/187777 "2010-04-29T06:28:05Z")

</div>

I followed the instructions in the rspec book to setup rcov. I appened to the end of my RAILS\_ROOT/Rakefile: require ‘rake’ require ‘spec/rake/spectask’ namespace :spec do desc “Run specs with RCov” Spec::Rake::Sp…

---

## [.size.should === (4..5)](https://www.ruby-forum.com/t/size-should-4-5/187749)

<div class="topic-metadata">

**Author:** [@aidy\_lewis](https://www.ruby-forum.com/u/aidy_lewis)\
**Replies:** 2\
**Last updated:** [April 28, 2010, 8:32pm UTC](https://www.ruby-forum.com/t/size-should-4-5/187749 "2010-04-28T20:32:46Z")

</div>

Hi, I would like to test whether an array size is either of two integer obejects mark\_up\_parser.sorted\_xml.size.should === (4…5) However I am recieiving an exception of: expected: 4…5, got: 4 (using ===) Do I need…

---

## [Re: File creation](https://www.ruby-forum.com/t/re-file-creation/187747)

<div class="topic-metadata">

**Author:** [@ben\_rooney](https://www.ruby-forum.com/u/ben_rooney)\
**Replies:** 0\
**Last updated:** [April 28, 2010, 7:28pm UTC](https://www.ruby-forum.com/t/re-file-creation/187747 "2010-04-28T19:28:22Z")

</div>

Rick Many thanks - I think the idea of breaking out the actual file writing from the code generation is a great one. I don’t need to test File I/O I think I can assume that that works just fine… Many thanks for your…

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

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