# RSpec

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

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

---

## [Should validate\_numericality\_of with greater\_than\_or\_equal\_to](https://www.ruby-forum.com/t/should-validate-numericality-of-with-greater-than-or-equal-to/211435)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [September 4, 2011, 7:31am UTC](https://www.ruby-forum.com/t/should-validate-numericality-of-with-greater-than-or-equal-to/211435 "2011-09-04T07:31:41Z")

</div>

Hello, I have this in my spec it { should validate\_numericality\_of(:amount).greater\_than\_or\_equal\_to(0) } but I get error: Failure/Error: it { should validate\_numericality\_of(:amount).greater\_than\_or\_equal\_to(0) } …

---

## [Rspec assert inclusion in](https://www.ruby-forum.com/t/rspec-assert-inclusion-in/211432)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 3\
**Last updated:** [September 4, 2011, 6:18am UTC](https://www.ruby-forum.com/t/rspec-assert-inclusion-in/211432 "2011-09-04T06:18:56Z")

</div>

hello, I would like to assert that an attribute of a model has value among those in an array. How would I do it in rspec? Something like this… describe OptionType do context “shoulda validations” do it { assert\_con…

---

## [Rspec and shoulda have\_indices](https://www.ruby-forum.com/t/rspec-and-shoulda-have-indices/211382)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 6\
**Last updated:** [September 4, 2011, 3:34am UTC](https://www.ruby-forum.com/t/rspec-and-shoulda-have-indices/211382 "2011-09-04T03:34:33Z")

</div>

Hello, I am developing a rails 3.1 app. My Gemfile has shoulda gems Gemfile … gem “shoulda” gem “shoulda-matchers” In a model spec I have spec file it { should have\_indices(\[:user, :currency\]) } And I get this e…

---

## [Can we use Cucumber for bakend testing?](https://www.ruby-forum.com/t/can-we-use-cucumber-for-bakend-testing/211401)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [September 2, 2011, 7:27pm UTC](https://www.ruby-forum.com/t/can-we-use-cucumber-for-bakend-testing/211401 "2011-09-02T19:27:23Z")

</div>

Hi guys, I am interested in getting information regarding using Cucumber for backend testing?

---

## [Redirect App for RSpec 2](https://www.ruby-forum.com/t/redirect-app-for-rspec-2/211334)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [September 1, 2011, 6:26pm UTC](https://www.ruby-forum.com/t/redirect-app-for-rspec-2/211334 "2011-09-01T18:26:17Z")

</div>

Hi, My name is Rahul and I’m an RoR developer. I would like to volunteer and write an app to manage redirects on the rspec.info site. Please let me know if anyone else hasn’t taken this up already. Thanks, Rahul

---

## [Write an app to manage redirects](https://www.ruby-forum.com/t/write-an-app-to-manage-redirects/211335)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [September 1, 2011, 5:25pm UTC](https://www.ruby-forum.com/t/write-an-app-to-manage-redirects/211335 "2011-09-01T17:25:14Z")

</div>

Hi Can i be allowed to “write an app to manage redirects” Regards, Srinivasan

---

## [Selectively ignoring exceptions in examples](https://www.ruby-forum.com/t/selectively-ignoring-exceptions-in-examples/211333)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [September 1, 2011, 4:35pm UTC](https://www.ruby-forum.com/t/selectively-ignoring-exceptions-in-examples/211333 "2011-09-01T16:35:16Z")

</div>

Hi all Long time since I’ve posted here, hope you’re all well :slight\_smile: I have a question about ignoring exceptions when they’re not interesting. For example, I have a few cases in my code along these lines it …

---

## [Better visualizations of spec running time besides --profile?](https://www.ruby-forum.com/t/better-visualizations-of-spec-running-time-besides-profile/211301)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 3\
**Last updated:** [September 1, 2011, 10:19am UTC](https://www.ruby-forum.com/t/better-visualizations-of-spec-running-time-besides-profile/211301 "2011-09-01T10:19:00Z")

</div>

We have about 2,000 specs in a Rails app that take roughly 80 seconds to run, and I’m trying to improve the performance of things a bit. While the profile mode has proven useful so far, it only shows the top ten slowe…

---

## [Getting Desired behaviour when I run the program, but spec still fails](https://www.ruby-forum.com/t/getting-desired-behaviour-when-i-run-the-program-but-spec-still-fails/211266)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 2\
**Last updated:** [August 31, 2011, 1:41pm UTC](https://www.ruby-forum.com/t/getting-desired-behaviour-when-i-run-the-program-but-spec-still-fails/211266 "2011-08-31T13:41:17Z")

</div>

I’m not doing something right with the following spec and code: My problem lies in the last Spec: it “should load the contents of the text file into the action list” do @menu.action\_list.empty?.should == false @menu…

---

## [Selectively ignoring exceptions in examples](https://www.ruby-forum.com/t/selectively-ignoring-exceptions-in-examples/211218)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 6\
**Last updated:** [August 31, 2011, 12:30am UTC](https://www.ruby-forum.com/t/selectively-ignoring-exceptions-in-examples/211218 "2011-08-31T00:30:44Z")

</div>

Hi all Long time since I’ve posted to rspec-users. Glad to see the place is still here and hope you’re all well :slight\_smile: I have a question about ignoring exceptions when they’re not interesting. For example, I …

---

## [Testing a before\_filter with a Rails.env condition](https://www.ruby-forum.com/t/testing-a-before-filter-with-a-rails-env-condition/211231)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 2\
**Last updated:** [August 30, 2011, 6:09am UTC](https://www.ruby-forum.com/t/testing-a-before-filter-with-a-rails-env-condition/211231 "2011-08-30T06:09:29Z")

</div>

Hi We have the occasional ApplicationController before\_filter that is conditioned by the Rails.env and we like the following style: before\_filter :check\_for\_something if Rails.env == ‘production’ And wish to spec thi…

---

## [Selectively running slow specs on file change with Guard](https://www.ruby-forum.com/t/selectively-running-slow-specs-on-file-change-with-guard/211228)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [August 30, 2011, 1:22am UTC](https://www.ruby-forum.com/t/selectively-running-slow-specs-on-file-change-with-guard/211228 "2011-08-30T01:22:44Z")

</div>

Hi all (again) Sorry for the new thread, but I don’t have a copy of my own email in my inbox to reply to. Anyway I managed to cobble together a hack to make Guard filter slow specs by default, but unfilter them if th…

---

## [Troubles running rspec](https://www.ruby-forum.com/t/troubles-running-rspec/211178)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [August 28, 2011, 12:48pm UTC](https://www.ruby-forum.com/t/troubles-running-rspec/211178 "2011-08-28T12:48:32Z")

</div>

developing a 3.1 app. trying to run spec on and get this error: bundle exec rake spec DEPRECATION WARNING: you are using a deprecated constant that will be removed from a future version of RSpec. /home/slava/.rvm/ge…

---

## [Warn on stubbing nonexistent method?](https://www.ruby-forum.com/t/warn-on-stubbing-nonexistent-method/211144)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 2\
**Last updated:** [August 26, 2011, 10:18pm UTC](https://www.ruby-forum.com/t/warn-on-stubbing-nonexistent-method/211144 "2011-08-26T22:18:52Z")

</div>

Hello. Perhaps rspec-mocks could warn if it stubs a not yet existing method? class A end describe RSpec do it ‘should’ do a = A.new a.stub!(:nonexistent\_method) {} end end This might help the development proces…

---

## [Tests that require a logged in user / session cookie](https://www.ruby-forum.com/t/tests-that-require-a-logged-in-user-session-cookie/211073)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 7\
**Last updated:** [August 26, 2011, 5:16pm UTC](https://www.ruby-forum.com/t/tests-that-require-a-logged-in-user-session-cookie/211073 "2011-08-26T17:16:53Z")

</div>

Hi, I’m fairly new to RSpec with Rails and I’m trying to work out how I can write request specs for resources that require a logged in user. I can’t get this one to pass: describe “GET /admin/account” do it “should …

---

## [Slightly confusing error message](https://www.ruby-forum.com/t/slightly-confusing-error-message/211020)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 5\
**Last updated:** [August 26, 2011, 5:13pm UTC](https://www.ruby-forum.com/t/slightly-confusing-error-message/211020 "2011-08-26T17:13:46Z")

</div>

This error message: it ‘should’ do proc { eval(“a=”)}.should raise\_exception(/SyntaxError/) end expected Exception with message matching /SyntaxError/, got #\<SyntaxError: (eval):1: syntax error, unexpected end-of…

---

## [How should I interpret RCov, code coverage?](https://www.ruby-forum.com/t/how-should-i-interpret-rcov-code-coverage/211083)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 3\
**Last updated:** [August 26, 2011, 1:55pm UTC](https://www.ruby-forum.com/t/how-should-i-interpret-rcov-code-coverage/211083 "2011-08-26T13:55:17Z")

</div>

First of all I’m new to RCov. I’m having a rails application with around 20 models and 20 controllers helpers and others. And I’ve got an unusual good RCov test coverage, 39%(total) and 31%(code coverage) - and this…

---

## [Rspec macro style](https://www.ruby-forum.com/t/rspec-macro-style/211107)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [August 26, 2011, 8:20am UTC](https://www.ruby-forum.com/t/rspec-macro-style/211107 "2011-08-26T08:20:51Z")

</div>

One of the things that always annoys me when I write/use typical macros in my specs is how the backtrace from failures don’t include the caller of the macro. Not a huge deal because the example name can be used to tra…

---

## [Doesn't rspec check the existence of template file](https://www.ruby-forum.com/t/doesnt-rspec-check-the-existence-of-template-file/211089)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 2\
**Last updated:** [August 25, 2011, 5:03pm UTC](https://www.ruby-forum.com/t/doesnt-rspec-check-the-existence-of-template-file/211089 "2011-08-25T17:03:24Z")

</div>

Hey, I am using rspec (1.3.0) and rspec-rails (1.3.2) for my current rails2 project, I found that in my controller test, rspec doesn’t check the existence of view template. For example, it “should render show templat…

---

## [\[JRuby\] simulating a java exception in a spec](https://www.ruby-forum.com/t/jruby-simulating-a-java-exception-in-a-spec/210991)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 3\
**Last updated:** [August 23, 2011, 10:25pm UTC](https://www.ruby-forum.com/t/jruby-simulating-a-java-exception-in-a-spec/210991 "2011-08-23T22:25:48Z")

</div>

JRuby 1.6.2 rspec-core (2.6.4) rspec-expectations (2.6.0) rspec-mocks (2.6.0) rspec-rails (2.6.1) I’m sure this has more to do with the way JRuby wraps Java exceptions but I figured I’d post here in case anyone her…

---

## [Pretty inspect for diff?](https://www.ruby-forum.com/t/pretty-inspect-for-diff/211019)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [August 23, 2011, 8:27pm UTC](https://www.ruby-forum.com/t/pretty-inspect-for-diff/211019 "2011-08-23T20:27:52Z")

</div>

Hello. I noticed this test “failed” message: The salient part is this diff: Diff: @@ -1,4 +1,4 @@ -{"blank\_outs"=\>\[\["0:00:56.0", "0:00:57.0"\], \["0:01:05", “0:01:14.500”\]\], +{“imdb\_id”=\>“tt1727587”, “mut…

---

## [Ruby 1.8.6](https://www.ruby-forum.com/t/ruby-1-8-6/210950)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 5\
**Last updated:** [August 23, 2011, 7:48pm UTC](https://www.ruby-forum.com/t/ruby-1-8-6/210950 "2011-08-23T19:48:07Z")

</div>

Hey all, It’s growing increasingly difficult for RSpec to support Ruby 1.8.6 as other libraries that rspec’s development environment relies on drop support. Noting that 1.8.7 was released over three years ago (6/1/200…

---

## [Route is valid but not found :(](https://www.ruby-forum.com/t/route-is-valid-but-not-found/210952)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 11\
**Last updated:** [August 23, 2011, 3:00pm UTC](https://www.ruby-forum.com/t/route-is-valid-but-not-found/210952 "2011-08-23T15:00:25Z")

</div>

Hi, guys, After reading the rspec book (dec 2010 edition), I went on to write controller specs for an application I’m porting over from rails 2.3.x to rails 3. I ran ‘rake routes’ and got the following: parts GET …

---

## [Cucumber: Running a single feature / scenario](https://www.ruby-forum.com/t/cucumber-running-a-single-feature-scenario/147429)

<div class="topic-metadata">

**Author:** [@mwalsh](https://www.ruby-forum.com/u/mwalsh)\
**Replies:** 8\
**Last updated:** [August 23, 2011, 2:40pm UTC](https://www.ruby-forum.com/t/cucumber-running-a-single-feature-scenario/147429 "2011-08-23T14:40:39Z")

</div>

Am taking cucumber for a first spin today - first impressions are good. How do I go about running a single feature or scenario so I don’t have to run the whole lot when I’m working on a particular one? cheers, Matt h…

---

## [Inheriting test cases vs. mixing them in](https://www.ruby-forum.com/t/inheriting-test-cases-vs-mixing-them-in/210998)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [August 23, 2011, 3:48am UTC](https://www.ruby-forum.com/t/inheriting-test-cases-vs-mixing-them-in/210998 "2011-08-23T03:48:39Z")

</div>

I’ve come across an interesting blog post showing how to inherit tests: How does it stack against the usual mixing/shared\_examples\_for, beautifully described in http://blog.davidchelimsky.net/2010/11/07/specifying-…

---

## [Mock weirdness](https://www.ruby-forum.com/t/mock-weirdness/210961)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 2\
**Last updated:** [August 22, 2011, 4:08pm UTC](https://www.ruby-forum.com/t/mock-weirdness/210961 "2011-08-22T16:08:00Z")

</div>

Hi, I have a strange problem with mocking an object that has a method called ‘load’. With Rails 2.3 and rspec-rails 1.3 I could do sth like this: describe Foo do let(:bar) { mock(Bar).as\_null\_object } before(:each) …

---

## [Inheriting test cases vs. mixing them in](https://www.ruby-forum.com/t/inheriting-test-cases-vs-mixing-them-in/210953)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [August 22, 2011, 9:13am UTC](https://www.ruby-forum.com/t/inheriting-test-cases-vs-mixing-them-in/210953 "2011-08-22T09:13:53Z")

</div>

I’ve come across an interesting blog post showing how to inherit tests: How does it stack against the usual mixing/shared\_examples\_for, beautifully described in http://blog.davidchelimsky.net/2010/11/07/specifying-…

---

## [Problem with rspec test, undefined method 'post'](https://www.ruby-forum.com/t/problem-with-rspec-test-undefined-method-post/210946)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [August 22, 2011, 1:35am UTC](https://www.ruby-forum.com/t/problem-with-rspec-test-undefined-method-post/210946 "2011-08-22T01:35:02Z")

</div>

I am writing a spec to test the behavior of the mashup\_controller when someone sends a query through a URL. I need to simulate the parameters contained in the URL, and i read that the post() method will do that, howev…

---

## [\[Cucumber\] Cucumber::Ast::Table values dynamic modfication](https://www.ruby-forum.com/t/cucumber-cucumber-table-values-dynamic-modfication/210835)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [August 18, 2011, 6:03pm UTC](https://www.ruby-forum.com/t/cucumber-cucumber-table-values-dynamic-modfication/210835 "2011-08-18T18:03:50Z")

</div>

Hello there! We have a web table that has values generated on action date: If user logged in successfully today then we have on the web page: |action | user | date | comment | |log-in | user1 | 18/Aug/2011 | …

---

## [\[ANN\] rspec-http 0.9 with header matchers released](https://www.ruby-forum.com/t/ann-rspec-http-0-9-with-header-matchers-released/210807)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [August 17, 2011, 11:55pm UTC](https://www.ruby-forum.com/t/ann-rspec-http-0-9-with-header-matchers-released/210807 "2011-08-17T23:55:36Z")

</div>

Hello everyone, Someone I was pairing with this evening needed this for one of their projects, so I’ve added matchers for headers to rspec-http and pushed an updated gem. You can now do response.should have\_header(‘C…

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

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