# RSpec

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

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

---

## [Modelling roles and responsibilities](https://www.ruby-forum.com/t/modelling-roles-and-responsibilities/214598)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 5\
**Last updated:** [December 7, 2011, 2:03pm UTC](https://www.ruby-forum.com/t/modelling-roles-and-responsibilities/214598 "2011-12-07T14:03:34Z")

</div>

Hi, reading “Growing Object-Oriented Software, guided by tests”, I came across the distinction of class, role and responsibility. While classes are classes and responsibilities could be mapped to public methods, I wo…

---

## [Rspect weird problem](https://www.ruby-forum.com/t/rspect-weird-problem/214575)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 4\
**Last updated:** [December 6, 2011, 10:45am UTC](https://www.ruby-forum.com/t/rspect-weird-problem/214575 "2011-12-06T10:45:25Z")

</div>

Hello everyone, this is really urgent so ill be quick, here is some ruby code that i know works: require 'csv' class Motorcycle attr\_reader :name, :weight @@count = 0 def self.find (name) found = nil Ob…

---

## [How to extend common helper methods to view specs?](https://www.ruby-forum.com/t/how-to-extend-common-helper-methods-to-view-specs/214570)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [December 6, 2011, 3:07am UTC](https://www.ruby-forum.com/t/how-to-extend-common-helper-methods-to-view-specs/214570 "2011-12-06T03:07:03Z")

</div>

Hi, there, I have some methods which I have written as helpers. They are in spec/support/controller\_macros.rb (yes, I will change the name soon). The 2 methods, login\_user and login\_admin\_user works in the controlle…

---

## [Spec'ing a block](https://www.ruby-forum.com/t/specing-a-block/214544)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 5\
**Last updated:** [December 5, 2011, 4:30pm UTC](https://www.ruby-forum.com/t/specing-a-block/214544 "2011-12-05T16:30:35Z")

</div>

Hi folks How would you spec something like this: as\_user username do FileUtils.chmod\_R 0755, "#{directory}/\*" end Where as\_user fires off a new process (and set uid to username). It seems that this won’t catch File…

---

## [Understanding of extend/include](https://www.ruby-forum.com/t/understanding-of-extend-include/214535)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [December 5, 2011, 2:06am UTC](https://www.ruby-forum.com/t/understanding-of-extend-include/214535 "2011-12-05T02:06:14Z")

</div>

hi, there I have been looking at https://www.relishapp.com/rspec/rspec-core/docs/helper-methods/define-helper-methods-in-a-module. This is the documentation for usage of extend and include. In the section, “Scenario:…

---

## [Having A Problem Understanding mocks with .build](https://www.ruby-forum.com/t/having-a-problem-understanding-mocks-with-build/214518)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 3\
**Last updated:** [December 4, 2011, 10:55pm UTC](https://www.ruby-forum.com/t/having-a-problem-understanding-mocks-with-build/214518 "2011-12-04T22:55:47Z")

</div>

Hello everyone, I am trying to do the following … before(:each) do @valid\_attributes = {:foo =\> ‘bar’} @event\_type = event\_category.event\_types.build(@valid\_attributes) $stderr.puts "\*\*\*\* #{@event\_type.class} \*\*\*\*\*" …

---

## [Cucumber is\_admin? testing](https://www.ruby-forum.com/t/cucumber-is-admin-testing/214163)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 22\
**Last updated:** [December 3, 2011, 1:28pm UTC](https://www.ruby-forum.com/t/cucumber-is-admin-testing/214163 "2011-12-03T13:28:33Z")

</div>

I don’t know where to put this post, but theme of this more similar to my issue. I have trite signin system, like this: ApplicationController: include SessionsHelper private helper\_method :current\_user def curre…

---

## [Testing Views with Rails 3 and Rspec2 - Can't stub request.path\_params\[:controller\]](https://www.ruby-forum.com/t/testing-views-with-rails-3-and-rspec2-cant-stub-request-path-params-controller/214478)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [December 2, 2011, 5:25pm UTC](https://www.ruby-forum.com/t/testing-views-with-rails-3-and-rspec2-cant-stub-request-path-params-controller/214478 "2011-12-02T17:25:33Z")

</div>

I am stuck to test a specific view which contains a request.path\_parameters\[:controller\] variable as the example below follows: \<%=link\_to "Store", admin\_stores\_url, { :id =\> "tab-3" ,:class =\> (admin\_stores\_path == …

---

## [Problem setting expectation for test with delayed::job](https://www.ruby-forum.com/t/problem-setting-expectation-for-test-with-delayed-job/214443)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 2\
**Last updated:** [December 2, 2011, 7:21am UTC](https://www.ruby-forum.com/t/problem-setting-expectation-for-test-with-delayed-job/214443 "2011-12-02T07:21:28Z")

</div>

I’ve got something like this: post\_observer.rb after\_create …stuff Delayed::Job.enqueue(PostSharer.new(post, post.user)) end … post\_sharer.rb class PostSharer \< Struct.new(:post, user) def perform # Delayed::Jo…

---

## [Is there a convention for testing that a record exists?](https://www.ruby-forum.com/t/is-there-a-convention-for-testing-that-a-record-exists/214360)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [November 30, 2011, 4:55am UTC](https://www.ruby-forum.com/t/is-there-a-convention-for-testing-that-a-record-exists/214360 "2011-11-30T04:55:14Z")

</div>

In the app I am working on, there are a lot of observers for various models which call Event.create! to log stuff… So within a particular example, various records might be created in order to test behavior-- and thi…

---

## [Differences between rake spec & rspec spec](https://www.ruby-forum.com/t/differences-between-rake-spec-rspec-spec/214341)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 0\
**Last updated:** [November 29, 2011, 1:23pm UTC](https://www.ruby-forum.com/t/differences-between-rake-spec-rspec-spec/214341 "2011-11-29T13:23:07Z")

</div>

Hi everyone, For the most part I’ve never had any issues running tests in a combination of rake spec and rspec spec. I ran into a weird issue today, when using CanCan and view tests. All the tests were passing under …

---

## [Oddness with messages\_path](https://www.ruby-forum.com/t/oddness-with-messages-path/214276)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 6\
**Last updated:** [November 28, 2011, 4:09pm UTC](https://www.ruby-forum.com/t/oddness-with-messages-path/214276 "2011-11-28T16:09:38Z")

</div>

I am working through the Rails Views chapter in the RSpec Book and noticed something odd when I created a spec for the edit view. I am getting the wrong value from the messages\_path helper. I was kind of wondering if …

---

## [Skipping slow specs in Guard but running them from that file](https://www.ruby-forum.com/t/skipping-slow-specs-in-guard-but-running-them-from-that-file/211227)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 6\
**Last updated:** [November 27, 2011, 11:24pm UTC](https://www.ruby-forum.com/t/skipping-slow-specs-in-guard-but-running-them-from-that-file/211227 "2011-11-27T23:24:35Z")

</div>

Hi all I’m trying to optimise my spec run time. I have 123 examples so far, which run in ~4.2 seconds on average. But 116 of those will run in ~0.18 seconds. So, obviously, I only want to run the slow ones when I chan…

---

## [Re: customize description and failure messages when writing rspec matcher dsl](https://www.ruby-forum.com/t/re-customize-description-and-failure-messages-when-writing-rspec-matcher-dsl/214297)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [November 27, 2011, 7:35pm UTC](https://www.ruby-forum.com/t/re-customize-description-and-failure-messages-when-writing-rspec-matcher-dsl/214297 "2011-11-27T19:35:55Z")

</div>

On Nov 24, 2011, at 12:48 AM, Anran Yang wrote: Dear all, I recently tried to write a custom matcher using rspec dsl, which I’d like to use as the following: :name, :vector =\> {}, \] end =========================…

---

## [Before(:all) leaves records in database](https://www.ruby-forum.com/t/before-all-leaves-records-in-database/214244)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 2\
**Last updated:** [November 25, 2011, 6:15pm UTC](https://www.ruby-forum.com/t/before-all-leaves-records-in-database/214244 "2011-11-25T18:15:21Z")

</div>

Hi, When I test my Rails controller, I find that records created in before(:all) remain in database while records created in before(:each) and let are wiped out after testing. This made me run “rake test:prepare” for…

---

## [Test for "lambda {.}.should change(x, y).by(z)" failing?](https://www.ruby-forum.com/t/test-for-lambda-should-change-x-y-by-z-failing/214180)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 2\
**Last updated:** [November 24, 2011, 11:21pm UTC](https://www.ruby-forum.com/t/test-for-lambda-should-change-x-y-by-z-failing/214180 "2011-11-24T23:21:18Z")

</div>

I wrote a test that looked like this: it “increases the user’s reputation” do lambda { @comment.update\_attribute(:helpful, true) }.should change(@seller.reload, :reputation\_score).by(Event.reputation\_change\_for(:mark…

---

## [Customize description and failure messages when writing rspec matcher dsl](https://www.ruby-forum.com/t/customize-description-and-failure-messages-when-writing-rspec-matcher-dsl/214194)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 1\
**Last updated:** [November 24, 2011, 5:26pm UTC](https://www.ruby-forum.com/t/customize-description-and-failure-messages-when-writing-rspec-matcher-dsl/214194 "2011-11-24T17:26:43Z")

</div>

rspec-users mailing list removed\_email\_address@domain.invalid http://rubyforge.org/mailman/listinfo/rspec-users

---

## [Rails code reloading in RSpec test environment?](https://www.ruby-forum.com/t/rails-code-reloading-in-rspec-test-environment/214136)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 6\
**Last updated:** [November 23, 2011, 1:33pm UTC](https://www.ruby-forum.com/t/rails-code-reloading-in-rspec-test-environment/214136 "2011-11-23T13:33:37Z")

</div>

Hi I’ve worked on a couple of Rails 3 apps recently and the test feedback loop is killing me. With no modifications, it takes 15-25 seconds to run a single example. I’ve avoided Spork so far, but I’ve tried Spin\[1\]. …

---

## [How do we test a Rails Model which does not have an equivalent table in the backend using RSpec](https://www.ruby-forum.com/t/how-do-we-test-a-rails-model-which-does-not-have-an-equivalent-table-in-the-backend-using-rspec/214081)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 3\
**Last updated:** [November 22, 2011, 5:10pm UTC](https://www.ruby-forum.com/t/how-do-we-test-a-rails-model-which-does-not-have-an-equivalent-table-in-the-backend-using-rspec/214081 "2011-11-22T17:10:41Z")

</div>

I have a Moderator model which basically queries web site related stat results from other models. An e.g. of displayed stats could be the total number of users belonging to a particular area out of many areas in a cit…

---

## [Problems with javascript testing](https://www.ruby-forum.com/t/problems-with-javascript-testing/214116)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [November 22, 2011, 11:35am UTC](https://www.ruby-forum.com/t/problems-with-javascript-testing/214116 "2011-11-22T11:35:34Z")

</div>

Hi all, I may be missing something simple here, but I’m having problems with attempting to get a javascript request test going. I’m not sure if this is the correct place to ask but perhaps someone will be able to dir…

---

## [Testing a post to a controller's create action](https://www.ruby-forum.com/t/testing-a-post-to-a-controllers-create-action/214036)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 10\
**Last updated:** [November 20, 2011, 1:57pm UTC](https://www.ruby-forum.com/t/testing-a-post-to-a-controllers-create-action/214036 "2011-11-20T13:57:53Z")

</div>

I just spent a lot of time trying to get a test to pass that would not pass no matter what I did, and I finally decided to just do something really simple to verify that even that was working-- and it’s not. class P…

---

## [How to create stub\_models with connections to other models](https://www.ruby-forum.com/t/how-to-create-stub-models-with-connections-to-other-models/214037)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 0\
**Last updated:** [November 19, 2011, 3:06am UTC](https://www.ruby-forum.com/t/how-to-create-stub-models-with-connections-to-other-models/214037 "2011-11-19T03:06:42Z")

</div>

Hello all, Please help with my question, detailed here: Thanks, Denise

---

## [What does :count actually mean in assert\_select?](https://www.ruby-forum.com/t/what-does-count-actually-mean-in-assert-select/214018)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [November 18, 2011, 6:26pm UTC](https://www.ruby-forum.com/t/what-does-count-actually-mean-in-assert-select/214018 "2011-11-18T18:26:13Z")

</div>

Hi guys, I tried reading up the RSPEC Book (Dec 2010) and googled a bit but I could not find anything. I’m using Rspec2. Example: spec/factories/categories.rb FactoryGirl.define do factory :category\_intakes, :clas…

---

## [How to access local variable(s) of controller methods called via RSpec in Rails 3](https://www.ruby-forum.com/t/how-to-access-local-variable-s-of-controller-methods-called-via-rspec-in-rails-3/213970)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 2\
**Last updated:** [November 18, 2011, 11:42am UTC](https://www.ruby-forum.com/t/how-to-access-local-variable-s-of-controller-methods-called-via-rspec-in-rails-3/213970 "2011-11-18T11:42:38Z")

</div>

Hi, I’m testing for action caching via RSpec. Currently the method that is cached is in a controller. I’m able to call this method using subject.send(:method\_name) Thanks to this ruby on rails - Rspec testing, callin…

---

## [Newbie cucumber tutorial](https://www.ruby-forum.com/t/newbie-cucumber-tutorial/156182)

<div class="topic-metadata">

**Author:** [@sackerson](https://www.ruby-forum.com/u/sackerson)\
**Replies:** 25\
**Last updated:** [November 16, 2011, 10:12pm UTC](https://www.ruby-forum.com/t/newbie-cucumber-tutorial/156182 "2011-11-16T22:12:10Z")

</div>

I got started with cucumber and it sure is fun. I’ve written up my initial experience in tutorial format here for any newbies who want to follow in my tracks: http://www.ultrasaurus.com/code/2008/12/rails-2-day-3.htm…

---

## [Need some advice on the best way to structure testable shared methods](https://www.ruby-forum.com/t/need-some-advice-on-the-best-way-to-structure-testable-shared-methods/213878)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 6\
**Last updated:** [November 16, 2011, 4:07am UTC](https://www.ruby-forum.com/t/need-some-advice-on-the-best-way-to-structure-testable-shared-methods/213878 "2011-11-16T04:07:33Z")

</div>

So, I recognize that there are many different ways to accomplish what I am trying to do, but none of them seem to be as elegant as I would like. I have a few classes which need to have shared functionality… So I coul…

---

## [Testing Custom Methods](https://www.ruby-forum.com/t/testing-custom-methods/213819)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 8\
**Last updated:** [November 15, 2011, 6:21pm UTC](https://www.ruby-forum.com/t/testing-custom-methods/213819 "2011-11-15T18:21:18Z")

</div>

I am attempting to test a custom method, and totally bombing out. describe Record do describe ‘#save\_cf\_data’ do before :each do @record = mock\_model(Record) end it “should have a birthday” do @record.save\_cf\_dat…

---

## [Problem with mocking helper methods](https://www.ruby-forum.com/t/problem-with-mocking-helper-methods/213868)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [November 15, 2011, 6:09am UTC](https://www.ruby-forum.com/t/problem-with-mocking-helper-methods/213868 "2011-11-15T06:09:20Z")

</div>

Given that I assume that rails helper image\_tag works as intended, I want to mock out call to this method in my helper. spec/helpers/some\_helper\_spec.rb: require ‘spec\_helper’ describe SomeHelper do it ‘allows stu…

---

## [Set\_fixture\_class works on individual test, but test suite fails](https://www.ruby-forum.com/t/set-fixture-class-works-on-individual-test-but-test-suite-fails/213865)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [November 15, 2011, 6:09am UTC](https://www.ruby-forum.com/t/set-fixture-class-works-on-individual-test-but-test-suite-fails/213865 "2011-11-15T06:09:20Z")

</div>

Hi all, I have a bug in my code that I have been unable to track down that deals with the set\_fixture\_class statement. Basically, set\_fixture\_class (and my tests) are working fine when I test one controller in isola…

---

## [Are there plans to introduce conf.simplecov option?](https://www.ruby-forum.com/t/are-there-plans-to-introduce-conf-simplecov-option/213869)

<div class="topic-metadata">

**Author:** [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Replies:** 1\
**Last updated:** [November 15, 2011, 5:26am UTC](https://www.ruby-forum.com/t/are-there-plans-to-introduce-conf-simplecov-option/213869 "2011-11-15T05:26:10Z")

</div>

Hi, I wanted to ask if there are plans to introduce Rspec.configure { | conf| conf.simplecov = true } option? I understand that it is easy to add “require ‘simplecov’; SimpleCov.start” into the spec\_helper.rb, but it…

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

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