# RSpec

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

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

---

## [Spec for authenticated user](https://www.ruby-forum.com/t/spec-for-authenticated-user/168926)

<div class="topic-metadata">

**Author:** [@manoah](https://www.ruby-forum.com/u/manoah)\
**Replies:** 3\
**Last updated:** [May 28, 2009, 5:09pm UTC](https://www.ruby-forum.com/t/spec-for-authenticated-user/168926 "2009-05-28T17:09:14Z")

</div>

before\_filter :requires\_user, :except =\> :create def show #------- # the currently authenticated user @user = user end How shall we check the currently authenticated user using rspec?

---

## [DeepTest with 1.2.6?](https://www.ruby-forum.com/t/deeptest-with-1-2-6/169001)

<div class="topic-metadata">

**Author:** [@scudco](https://www.ruby-forum.com/u/scudco)\
**Replies:** 2\
**Last updated:** [May 28, 2009, 4:51pm UTC](https://www.ruby-forum.com/t/deeptest-with-1-2-6/169001 "2009-05-28T16:51:34Z")

</div>

Just curious if anyone is running DeepTest with rspec 1.2.6. I can’t even do a ‘$ rake -T’ on the deep-test repo at git://github.com/qxjit/deep-test.git When I try to run deep\_test using their provided rspec example …

---

## [Thoughts on this?](https://www.ruby-forum.com/t/thoughts-on-this/168978)

<div class="topic-metadata">

**Author:** [@mwalsh](https://www.ruby-forum.com/u/mwalsh)\
**Replies:** 4\
**Last updated:** [May 28, 2009, 9:47am UTC](https://www.ruby-forum.com/t/thoughts-on-this/168978 "2009-05-28T09:47:02Z")

</div>

http://robertlally.com/post/bdd-not-so-much Matt W. http://blog.mattwynne.net

---

## [\[rspec\] http://rspec.info examples are broken](https://www.ruby-forum.com/t/rspec-http-rspec-info-examples-are-broken/168784)

<div class="topic-metadata">

**Author:** [@juuser](https://www.ruby-forum.com/u/juuser)\
**Replies:** 3\
**Last updated:** [May 28, 2009, 8:47am UTC](https://www.ruby-forum.com/t/rspec-http-rspec-info-examples-are-broken/168784 "2009-05-28T08:47:52Z")

</div>

It seems that some examples at http://rspec.info are broken with invalid html. For example: http://rspec.info/documentation/before\_and\_after.html All those spans there should not be visible, I think :slight\_smile: Isn…

---

## [Create\_\<association?\>](https://www.ruby-forum.com/t/create-association/168936)

<div class="topic-metadata">

**Author:** [@helix\_tp](https://www.ruby-forum.com/u/helix_tp)\
**Replies:** 1\
**Last updated:** [May 28, 2009, 8:41am UTC](https://www.ruby-forum.com/t/create-association/168936 "2009-05-28T08:41:59Z")

</div>

Any know issues with the dynamic create\_ method and factory\_girl? I have an object created by a factory: @order = Factory.create :payable\_order\_with\_line\_items and then I do: @order.create\_ship\_address(\<attributes f…

---

## [\[rspec\]spec\_server: already initialized constant MyTestClass](https://www.ruby-forum.com/t/rspec-spec-server-already-initialized-constant-mytestclass/166984)

<div class="topic-metadata">

**Author:** [@mwalsh](https://www.ruby-forum.com/u/mwalsh)\
**Replies:** 6\
**Last updated:** [May 27, 2009, 11:36pm UTC](https://www.ruby-forum.com/t/rspec-spec-server-already-initialized-constant-mytestclass/166984 "2009-05-27T23:36:35Z")

</div>

I’m creating a class in my spec file to test out a module, but when I run the spec a second time in spec\_server, I get the error above. I presume this is because rails is un-loading the class, and it’s not getting re-…

---

## [Cucmber Step to insert Test Data into Database](https://www.ruby-forum.com/t/cucmber-step-to-insert-test-data-into-database/168917)

<div class="topic-metadata">

**Author:** [@smitasreekanth](https://www.ruby-forum.com/u/smitasreekanth)\
**Replies:** 4\
**Last updated:** [May 27, 2009, 3:55pm UTC](https://www.ruby-forum.com/t/cucmber-step-to-insert-test-data-into-database/168917 "2009-05-27T15:55:08Z")

</div>

Hi, We run the feature created for a form to identify the fields and also to add data into the respective fields. But while running the cucumber features, all the scenario and steps are getting passed but the record …

---

## [Including extra directories for Autospec](https://www.ruby-forum.com/t/including-extra-directories-for-autospec/168180)

<div class="topic-metadata">

**Author:** [@scudco](https://www.ruby-forum.com/u/scudco)\
**Replies:** 6\
**Last updated:** [May 27, 2009, 10:40am UTC](https://www.ruby-forum.com/t/including-extra-directories-for-autospec/168180 "2009-05-27T10:40:39Z")

</div>

Is there a way to tell autospec for rails to run all the spec files in the spec directory a la spec/\*\*/\*\_spec.rb instead of just the ones in model/controller/etc? I’ve experimented with adding my own mappings in \<proj…

---

## [Fixture::FormatError parsing YAML](https://www.ruby-forum.com/t/fixture-formaterror-parsing-yaml/168244)

<div class="topic-metadata">

**Author:** [@wjsimacek](https://www.ruby-forum.com/u/wjsimacek)\
**Replies:** 3\
**Last updated:** [May 27, 2009, 10:31am UTC](https://www.ruby-forum.com/t/fixture-formaterror-parsing-yaml/168244 "2009-05-27T10:31:16Z")

</div>

Hi, I’m trying to test restful\_authentication plugin and am getting errors with my install. ==\>I’ve been through the YAML specification and actually copied the fixture file into word looking for tabs instead of space…

---

## [Problem with testing Rails action that uses return keyword](https://www.ruby-forum.com/t/problem-with-testing-rails-action-that-uses-return-keyword/168362)

<div class="topic-metadata">

**Author:** [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Replies:** 1\
**Last updated:** [May 27, 2009, 10:30am UTC](https://www.ruby-forum.com/t/problem-with-testing-rails-action-that-uses-return-keyword/168362 "2009-05-27T10:30:05Z")

</div>

Hi, I’m trying to test Rails action that looks like this: def create unless facebook\_session authentication\_failed and return end … @facebook\_user = facebook\_session.user … end authentication\_failed method redi…

---

## [RSpec support on .Net with Gallio](https://www.ruby-forum.com/t/rspec-support-on-net-with-gallio/168155)

<div class="topic-metadata">

**Author:** [@jbell38](https://www.ruby-forum.com/u/jbell38)\
**Replies:** 3\
**Last updated:** [May 27, 2009, 10:24am UTC](https://www.ruby-forum.com/t/rspec-support-on-net-with-gallio/168155 "2009-05-27T10:24:48Z")

</div>

Hi, I’m getting ready to produce an RSpec adapter for use with the Gallio test automation platform (http://www.gallio.org/) on the .Net DLR via IronRuby. The idea is to open up RSpec to a wider audience of .Net deve…

---

## [Passing param values](https://www.ruby-forum.com/t/passing-param-values/168563)

<div class="topic-metadata">

**Author:** [@manoah](https://www.ruby-forum.com/u/manoah)\
**Replies:** 3\
**Last updated:** [May 27, 2009, 5:45am UTC](https://www.ruby-forum.com/t/passing-param-values/168563 "2009-05-27T05:45:50Z")

</div>

My controller spec is like below describe UsersController do describe " create action" do before(:each) do @user = mock\_model(User,:user =\> “value”) controller.stub!(:require\_user).and\_return(@user) controller.stu…

---

## [How do I get additional information from the Matcher?](https://www.ruby-forum.com/t/how-do-i-get-additional-information-from-the-matcher/168460)

<div class="topic-metadata">

**Author:** [@figo2476](https://www.ruby-forum.com/u/figo2476)\
**Replies:** 1\
**Last updated:** [May 27, 2009, 5:41am UTC](https://www.ruby-forum.com/t/how-do-i-get-additional-information-from-the-matcher/168460 "2009-05-27T05:41:09Z")

</div>

Hi, I am trying to implement my own matcher which use a special algorithm to do the semantics diff-ing between two proprietary configuration file. When come to the report, I would like my formatter to be able to have …

---

## [How to spec two lines in application\_controller.rb](https://www.ruby-forum.com/t/how-to-spec-two-lines-in-application-controller-rb/168841)

<div class="topic-metadata">

**Author:** [@Hunt\_J](https://www.ruby-forum.com/u/Hunt_J)\
**Replies:** 2\
**Last updated:** [May 26, 2009, 6:52pm UTC](https://www.ruby-forum.com/t/how-to-spec-two-lines-in-application-controller-rb/168841 "2009-05-26T18:52:00Z")

</div>

I need to spec the following lines: helper :all # include all helpers, all the time protect\_from\_forgery # See ActionController::RequestForgeryProtection for detail Can anybody give me a hint? I create “application\_…

---

## [Get\_via\_redirect in controller specs](https://www.ruby-forum.com/t/get-via-redirect-in-controller-specs/168837)

<div class="topic-metadata">

**Author:** [@diabolist](https://www.ruby-forum.com/u/diabolist)\
**Replies:** 2\
**Last updated:** [May 26, 2009, 5:31pm UTC](https://www.ruby-forum.com/t/get-via-redirect-in-controller-specs/168837 "2009-05-26T17:31:27Z")

</div>

Want to do the following in my controller spec describe CheckoutController, “handling stale session” do before do session\[:order\_id\] = 5 Order.delete\_all end it “should not throw a 404” do get\_via\_direct :index e…

---

## [Spec for not null](https://www.ruby-forum.com/t/spec-for-not-null/168752)

<div class="topic-metadata">

**Author:** [@manoah](https://www.ruby-forum.com/u/manoah)\
**Replies:** 2\
**Last updated:** [May 26, 2009, 9:27am UTC](https://www.ruby-forum.com/t/spec-for-not-null/168752 "2009-05-26T09:27:41Z")

</div>

how should we check not null in rspec user\_valid = @user.valid? password\_credential\_valid = @password.valid? I am getting the below error Mock 'User\_1001' received unexpected message :valid? with (no args) D…

---

## [Modules and stub](https://www.ruby-forum.com/t/modules-and-stub/168721)

<div class="topic-metadata">

**Author:** [@sackerson](https://www.ruby-forum.com/u/sackerson)\
**Replies:** 5\
**Last updated:** [May 25, 2009, 7:51am UTC](https://www.ruby-forum.com/t/modules-and-stub/168721 "2009-05-25T07:51:02Z")

</div>

If there is a method defined on a module, how do I stub it? Imagine I have a module like this: Module Foo Module Bar def self.do\_something(path) … end end end Somewhere in the code, there is this call: Foo::Bar…

---

## [Is stubbing a call to super possible?](https://www.ruby-forum.com/t/is-stubbing-a-call-to-super-possible/116380)

<div class="topic-metadata">

**Author:** [@codejoy](https://www.ruby-forum.com/u/codejoy)\
**Replies:** 3\
**Last updated:** [May 25, 2009, 7:14am UTC](https://www.ruby-forum.com/t/is-stubbing-a-call-to-super-possible/116380 "2009-05-25T07:14:27Z")

</div>

Hi Is stubbing a call to super possible? I am testing a protected method called authorized in a Rails controller … part of the logic flow calls super which calls the method authorized in the application controller. …

---

## [Undefined method \`assert\_select'](https://www.ruby-forum.com/t/undefined-method-assert-select/168630)

<div class="topic-metadata">

**Author:** [@sackerson](https://www.ruby-forum.com/u/sackerson)\
**Replies:** 9\
**Last updated:** [May 25, 2009, 6:01am UTC](https://www.ruby-forum.com/t/undefined-method-assert-select/168630 "2009-05-25T06:01:59Z")

</div>

I’m having trouble getting the specs to run for a plugin where I want to fix a bug. (I’ve actually already found and fixed the bug, but I don’t want to submit a fix without a test!) When I started the specs weren’t ru…

---

## [Class method not being stubbed](https://www.ruby-forum.com/t/class-method-not-being-stubbed/168703)

<div class="topic-metadata">

**Author:** [@nickh](https://www.ruby-forum.com/u/nickh)\
**Replies:** 12\
**Last updated:** [May 24, 2009, 11:39pm UTC](https://www.ruby-forum.com/t/class-method-not-being-stubbed/168703 "2009-05-24T23:39:22Z")

</div>

Hi guys. I’m setting an expectation on a class method. For some reason, the method isn’t being stubbed, and the expectation isn’t seeing the call. In KeywordListsController#create, I call the private method #create\_k…

---

## [Writing specs pointed out I need to refactor my admin area](https://www.ruby-forum.com/t/writing-specs-pointed-out-i-need-to-refactor-my-admin-area/168665)

<div class="topic-metadata">

**Author:** [@fipa](https://www.ruby-forum.com/u/fipa)\
**Replies:** 2\
**Last updated:** [May 24, 2009, 8:03pm UTC](https://www.ruby-forum.com/t/writing-specs-pointed-out-i-need-to-refactor-my-admin-area/168665 "2009-05-24T20:03:02Z")

</div>

Hi, My app now nearly has 100% coverage and when refactoring the code, potential bugs are immediately pointed out. So that’s a big win. Moreover when writing specs for my controllers and views of the admin zone, I qu…

---

## [How to execute code if a rspec test fails](https://www.ruby-forum.com/t/how-to-execute-code-if-a-rspec-test-fails/168649)

<div class="topic-metadata">

**Author:** [@raginrish](https://www.ruby-forum.com/u/raginrish)\
**Replies:** 1\
**Last updated:** [May 24, 2009, 12:42am UTC](https://www.ruby-forum.com/t/how-to-execute-code-if-a-rspec-test-fails/168649 "2009-05-24T00:42:45Z")

</div>

I am trying to make a call to a class/fxn I made, depending on whether an Rspec test fails. If it fails, I want to make the call, otherwise I won’t need to. Is there some error message or specific syntax for checking …

---

## [RSpec for Rails plugin](https://www.ruby-forum.com/t/rspec-for-rails-plugin/168336)

<div class="topic-metadata">

**Author:** [@sackerson](https://www.ruby-forum.com/u/sackerson)\
**Replies:** 3\
**Last updated:** [May 24, 2009, 12:18am UTC](https://www.ruby-forum.com/t/rspec-for-rails-plugin/168336 "2009-05-24T00:18:01Z")

</div>

I’m trying to write specs to test a Rails plugin and I’m not clear on what needs to be installed and required. Works fine for many specs, but view testing fails (i.e. anything relying rspec-rails over just rspec). In…

---

## [Cucumber: Running one feature under one profile](https://www.ruby-forum.com/t/cucumber-running-one-feature-under-one-profile/168609)

<div class="topic-metadata">

**Author:** [@JohnnyH](https://www.ruby-forum.com/u/JohnnyH)\
**Replies:** 3\
**Last updated:** [May 23, 2009, 12:43am UTC](https://www.ruby-forum.com/t/cucumber-running-one-feature-under-one-profile/168609 "2009-05-23T00:43:30Z")

</div>

Hey Folks, I followed the instructions on http://wiki.github.com/aslakhellesoy/cucumber/setting-up-selenium and created 2 profiles: default and selenium. It works, but not if I want to run one feature under a specifc…

---

## [Latest cucumber 0.3.6 + rspec \>1.2.2 broken?](https://www.ruby-forum.com/t/latest-cucumber-0-3-6-rspec-1-2-2-broken/168606)

<div class="topic-metadata">

**Author:** [@ari](https://www.ruby-forum.com/u/ari)\
**Replies:** 2\
**Last updated:** [May 22, 2009, 9:49pm UTC](https://www.ruby-forum.com/t/latest-cucumber-0-3-6-rspec-1-2-2-broken/168606 "2009-05-22T21:49:03Z")

</div>

Hi all, It looks like the following line was removed from “/lib/spec/ expectations.rb” on April 11: attr\_accessor :differ When I try to use cucumber (version 0.3.6), it tries to call ::Spec:Expectations.differ= and …

---

## [Controller spec: testing that scope is set](https://www.ruby-forum.com/t/controller-spec-testing-that-scope-is-set/165912)

<div class="topic-metadata">

**Author:** [@wickie](https://www.ruby-forum.com/u/wickie)\
**Replies:** 21\
**Last updated:** [May 21, 2009, 10:52pm UTC](https://www.ruby-forum.com/t/controller-spec-testing-that-scope-is-set/165912 "2009-05-21T22:52:26Z")

</div>

In a Rails controller I set the scope on a model class in an around filter. I have defined expectations on the model classes, and ideally, I would add a further expectation for the scope. Is this already possible in s…

---

## [Using resource\_controller (make\_resourceful etc) and testing them](https://www.ruby-forum.com/t/using-resource-controller-make-resourceful-etc-and-testing-them/155396)

<div class="topic-metadata">

**Author:** [@diabolist](https://www.ruby-forum.com/u/diabolist)\
**Replies:** 5\
**Last updated:** [May 21, 2009, 9:17pm UTC](https://www.ruby-forum.com/t/using-resource-controller-make-resourceful-etc-and-testing-them/155396 "2009-05-21T21:17:45Z")

</div>

Hi all, Trying to get some opinions about the use of such plugins and in particular about how they test, and how we test with them. Can they work well with BDD or do they do to much magic and create difficulties for…

---

## [Autotest?](https://www.ruby-forum.com/t/autotest/168373)

<div class="topic-metadata">

**Author:** [@helix\_tp](https://www.ruby-forum.com/u/helix_tp)\
**Replies:** 14\
**Last updated:** [May 21, 2009, 6:25pm UTC](https://www.ruby-forum.com/t/autotest/168373 "2009-05-21T18:25:58Z")

</div>

Can someone point me to some decent doc on autotest? Everything I’m finding seems either pretty old, or says “autotest and rspec work out of the box”, which it isn’t for me… I installed the grosser-autotest gem (just…

---

## [Rspec-rails: how to run checks?](https://www.ruby-forum.com/t/rspec-rails-how-to-run-checks/168485)

<div class="topic-metadata">

**Author:** [@wickie](https://www.ruby-forum.com/u/wickie)\
**Replies:** 2\
**Last updated:** [May 21, 2009, 2:09pm UTC](https://www.ruby-forum.com/t/rspec-rails-how-to-run-checks/168485 "2009-05-21T14:09:19Z")

</div>

I’m trying to run the specs of the rspec-rails master branch, but both plain rake as well as rake spec fail. The default task fails because there is no cucumber.yml. rake spec fails, when it requires a file that is no…

---

## [\[Cucumber\] Fail a scenario from After or AfterStep](https://www.ruby-forum.com/t/cucumber-fail-a-scenario-from-after-or-afterstep/168043)

<div class="topic-metadata">

**Author:** [@luke001](https://www.ruby-forum.com/u/luke001)\
**Replies:** 19\
**Last updated:** [May 21, 2009, 2:02pm UTC](https://www.ruby-forum.com/t/cucumber-fail-a-scenario-from-after-or-afterstep/168043 "2009-05-21T14:02:53Z")

</div>

I’m trying to make sure that my cucumber selenium suite fails if my Rails app returns any 500 response codes. I’m working on what the best way to identify this state, but the question I’d like to put to the list is th…

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

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