rspec2 Questions

4

Solved

context 'with event_type is available create event' do let(:event_type) { EventType.where( name: 'visit_site').first } assert_difference 'Event.count' do Event.fire_event(event_type, @sponge,{})...
Pert asked 15/3, 2012 at 2:42

4

Solved

I try to test a class with RSpec2, that has some private methods, which are called from some public methods. I test the public methods with @foo.should_receive(:start_training).exactly(2).times ...
Crat asked 20/2, 2013 at 18:21

2

Solved

The following piece of code works as expected: Object.any_instance.should_receive(:subscribe) But when using the new rspec expectation it does not work: expect(Object.any_instance).to receive(:...
Dietary asked 10/7, 2013 at 9:11

8

Solved

I'm using rspec with the email-spec gem. I'm trying to do: last_delivery = ActionMailer::Base.deliveries.last last_delivery.body.should include "This is the text of the email" But that doesn't w...
Gaol asked 21/3, 2011 at 22:25

3

Solved

I am using FactoryGirl and Rspec for testing. The model sets a foreign key after init if it is nil. Therefore it uses data of another association. But how can I test it? Normally I would use a fact...

3

Solved

describe, context, feature, scenario: What is the difference(s) among the four and when do I use each one?
Zarah asked 25/7, 2012 at 6:15

6

Solved

When I assign in my controller @my_hash = { :my_key => :my_value } and test that controller by doing get 'index' assigns(:my_hash).should == { :my_key => :my_value } then I get the foll...
Premundane asked 3/12, 2010 at 17:33

4

Solved

I was wondering how to test a find_each call in rspec. I'm used to simply stubbing what I want my models to return so I don't rely on test data in the db like this: MyClass.stub(:find).and_return(...
Khaki asked 7/12, 2010 at 23:18

5

Solved

I have devise authentication and registration set up on my Rails app. I'm using after_sign_in_path_for() to customise the redirect when the user signs in based on various scenarios. What I'm askin...
Anaheim asked 12/7, 2011 at 0:26

7

Solved

I have started my journey with TDD in Rails and have run into a small issue regarding tests for model validations that I can't seem to find a solution to. Let's say I have a User model, class User...
Lotetgaronne asked 24/9, 2011 at 4:55

5

Solved

How to organize rspec 2 tests into 'unit' (fast) and 'integration' (slow) categories? I want to be able to run all unit tests with just rspec command, but not the 'integration' tests. I want to...
Waggon asked 5/4, 2012 at 13:10

9

Solved

I'm trying to write a request test that asserts that the proper links appear on the application layout depending in whether a user is logged in or out. FWIW, I'm using Devise for the authentication...
Reduplicative asked 15/6, 2011 at 19:52

6

Solved

I have read what the RSpec manual says about the difference, but some things are still confusing. Every other source, including "The RSpec Book" only explain about "let", and "The Rails 3 Way" is j...
Stanfordstang asked 16/4, 2012 at 11:17

8

Solved

I'd like to test if an email is delivered if I call a controller method with :post. I'll use email_spec so I tried this snipped here: http://rubydoc.info/gems/email_spec/1.2.1/file/README.rdoc#Test...
Fireresistant asked 2/9, 2011 at 13:50

6

Solved

How do you test redirect_to :back in rspec? I get ActionController::RedirectBackError: No HTTP_REFERER was set in the request to this action, so redirect_to :back could not be called successf...
Value asked 18/5, 2011 at 6:0

3

I have an odd situation whereby if I run an individual rspec model spec file all examples are green, if I test my entire spec/models folder all my examples are green. If I test the controllers they...
Canaster asked 20/7, 2011 at 17:10

4

Solved

I have two hashes containing arrays. In my case, the order of array elements is not important. Is there a simple way to match such hashes in RSpec2? { a: [1, 2] }.should == { a: [2, 1] } # how to ...
Aragon asked 6/7, 2012 at 16:50

6

Solved

Right now if I run my test suite using rake spec I get an error: 1) SegmentsController GET 'index' should work Failure/Error: get 'index' undefined method `locale' for # # ./spec/controllers/s...
Vaporescence asked 4/10, 2011 at 13:56

6

Solved

please guide how to disable one of the below test methods using RSpec. I am using Selenuim WebDriver + RSpec combinations to run tests. require 'rspec' require 'selenium-webdriver' describe 'Auto...
Drinkwater asked 4/12, 2014 at 7:49

6

Solved

The database is not being cleaned after each integration test. The value stays in the database. Is there an option I should have to make this happen? Thanks
Flamingo asked 9/4, 2011 at 21:58

4

Solved

I want to test an inclusion of a module into a class. I am trying define a new class in RSpec: describe Statusable do let(:test_class) do class ModelIncludingStatusable < ActiveRecord::Base ...
Roundshouldered asked 22/1, 2014 at 9:39

6

Solved

Solution Thanks to this gist form Steven Harman, I got it working. devise_mail_helpers.rb module Features module MailHelpers def last_email ActionMailer::Base.deliveries[0] end # Can be us...
Nipissing asked 6/9, 2013 at 15:47

5

Solved

I use: gem 'rails', '3.2.11' gem 'rspec-rails', '2.13.2' gem 'webrat', '0.7.3' gem 'factory_girl_rails', '4.1.0' gem 'spork', '~> 0.9.0.rc' I want to test my HP where I always have a link to ...
Deflower asked 18/7, 2013 at 15:57

7

Solved

Too often people write tests that don't clean up after themselves when they mess with state. Often this doesn't matter since objects tend to be torn down and recreated for most tests, but there are...
Laureenlaurel asked 10/5, 2011 at 6:26

3

I was wondering what would be the best way to pass variable between multiple contexts (or multiple its) in rspec but without using global variables? For example, I have this: describe "My test" ...
Windham asked 12/12, 2014 at 16:11

© 2022 - 2024 — McMap. All rights reserved.