Tagged Questions
0
votes
0answers
9 views
Rails testing - Stubs and mocks
I am working on a rails project, in which model queries a service and gets the data from the service. Now, when I want to write tests for models and controllers I need to imitate the service.I am ...
0
votes
0answers
6 views
Rails testing setup method
Rails testing offers a method called setup which is called before each test case . (source : http://guides.rubyonrails.org/testing.html#setup-and-teardown).
In the example in the link, the method is ...
0
votes
1answer
27 views
Ruby on Rails Method Mocks in the Controller
I'm trying to mock a method call to an outside API inside one of my rails controllers (in this case, Instagram.get_access_token) and I'm having some trouble. As written, the code is still calling the ...
0
votes
0answers
33 views
undefined method relative_url_root for nil:NilClass when running rspec on namespaced controller
I'm working on a rails 2.3.18 to 3.2.x upgrade, and I've run into a problem with this one set of controller tests:
Error:
/actionpack-3.2.12/lib/action_controller/test_case.rb:514:in ...
0
votes
1answer
31 views
Dynamically generate factory attributes
I want to do following:
classes = ["WelcomeMailing", "NoticeMailing", "FeedbackMailing"] #......
FactoryGirl.define do
classes.each do |tclass|
cl_attributes = ["body", "subject", ...
0
votes
0answers
41 views
Rails 3: unit test works with ruby but not rake
I have the following class in a Rails 3 app:
class AssetAttribute < ActiveRecord::Base
...
def self.ANNOTATION
self.find_by_table_name('annotations')
end
...
end
In another class, I ...
17
votes
1answer
369 views
How to setup Rails-Angular project to test JS?
I am trying to setup my Rails-Angular project to provide JS tests. I have tried almost everything what I have found in Google:
Karma (formerly Testacular)
Jasmine + Jasmine-headless-WebKit
...
1
vote
2answers
86 views
Rails Mailer: change file when delivery_method :file
I want to have the file named Timestamp + normal_mail_name + ".eml"..
I looked into the rails source code, the mail-gem source code and the letter opener-gem.. Could you give me a hint how to ...
2
votes
1answer
97 views
Testing flash message method in application_helper.rb code in Rails
I'm a bit new to test driven development, and I want to learn how to cover as much code as possible so when I make more complex apps in Rails, I'll be able to prevent bugs from introduced.
I have ...
0
votes
2answers
67 views
Ruby on Rails: testing if values do exist?
I'm trying to test if my values are existing... Not sure how to do this, I'm just starting to learn Ruby on Rails. Hopefully someone can point me to the right direction?
Lets say I have this block of ...
3
votes
1answer
87 views
FactoryGirl define attribute by calling method on another factory
Here is an example from the FactoryGirl documentation:
FactoryGirl.define do
factory :post do
name "Post name"
user
end
end
In this example, user is invoking another factory. What I ...
0
votes
3answers
42 views
What should I test in views?
Testing and Rspec are new to me. Currently I'm using Rspec with Shoulda and Capybara to test my application. It's all fine to test models, controllers, helpers, routing and requests. But what should I ...
2
votes
1answer
87 views
Strategies for gem tests to ensure the gem works with Rails 3.x and 4.0?
I've seen a few examples of dummy Rails apps (for testing, so they live under test or spec dirs, typically) for use with the Appraisals gem that supposedly work with both Rails 3.x and Rails 4, but ...
3
votes
1answer
70 views
how to check/test specific field in json using rspec
This is my rspec code:-
it "which has max value" do
get :index, Devise.token_authentication_key => @user.authentication_token, business_id: @business.id, max: '1'
...
1
vote
1answer
79 views
Shoulda rspec matchers ensure_inclusion_of
I have a test using shoulda that is failing for reasons I don't understand. Any idea what the fix is for this? I hardcoded the array for testing purposes.
All my other shoulda matcher based tests are ...