1
vote
3answers
14 views
FactoryGirl, has_one association and validation failed
These are 2 simple models:
class Post < ActiveRecord::Base
has_one :asset, :dependent => :destroy
validates :asset, presence: true
end
class Asset < ActiveRecord::Base
belongs_to ...
0
votes
0answers
7 views
A factory association with a name equal to the Table's name, FactoryGirl and RSpec
I have this model:
class Buyer < ActiveRecord::Base
attr_accessible :buyer_id
belongs_to :account, :foreign_key => :buyer_id
end
And this factory:
factory :buyer do
association ...
0
votes
1answer
8 views
Save a factory after build, with RSpec, FactoryGirl and Rails 3.2
I have an Account model with has_secure_password (that automagically creates 2 attr_accessors: password and password_confirmation, required on create). I'd like to avoid to specify those fields when I ...
0
votes
1answer
15 views
Rails + Rspec: How to test what a rake task “puts” / “print”?
I have a rake task that merely loops through all my products and increments a counter if the product saves. It then prints out that counter. How do I test what number it puts?
...
0
votes
2answers
26 views
Rails not recognizing relationships
Having issues trying to set up the relationship in my database.
I have a user and some comments (1:N)
Class User ..
...
has_many :comments
end
Class Comment ..
..
belongs_to :user
end
...
0
votes
1answer
17 views
How can I play sound on rspec success/failure when using guard
I had it configured once with autotest, but lately I'm using guard-rspec to run my specs in the background. I do have growl notifications but this requires reading the actual notification text which ...
0
votes
0answers
25 views
Where to put a massive string in RSpec?
The point of RSpec is to hide implementation details and provide a clean test suite and spec. I've created a stub for an HTTP request that returns a fairly large (100 or so lines) JSON response. This ...
0
votes
0answers
28 views
Rspec/Capybara doesn't know current_user
I have a Product model that belongs to a User, as an Owner. I test when the products are displayed in the product index page, a link to the delete action is present near the products the current user ...
1
vote
1answer
17 views
Rails “guard” doesn't start
New to TDD and trying to setup the environment with a new app. I created a new rails app and bundle installed the following:
group :test, :development do
gem 'turn'
gem 'rspec-rails'
gem ...
0
votes
1answer
29 views
Rspec / Capybara: Testing if a controller method is called
Given I set up a HomeController with an index action
class HomeController < ApplicationController
def index
@users = User.all
end
end
and routed to it via the root path,
root :to ...
1
vote
1answer
38 views
How to write integration test for complicated rails index (best practices)
Let's say I have a page which lists articles. The code in the controller used to be
# articles#index
@articles = Article.paginate(page: params[:page], per_page: 10, order: :title)
and my test was ...
0
votes
1answer
16 views
+100
Testing Carrierwave file uploads to s3 with Capybara and Rspec
I've implemented carrierwave file uploads to Amazon s3 just like in this Railscast.
I'm having trouble testing this though. I can attach a file with Capybara, but when I click the button to upload ...
1
vote
0answers
13 views
Zeus throwing errors when running RSpec
I'm running in to a situation which seems to happen to many users of Zeus and RSpec.
Let's say I have the following spec:
# spec/views/messages/show.html.erb
require 'spec_helper'
describe ...
0
votes
1answer
29 views
Mocks and Stubs. I don't get the basics
I am in the process of freeing myself from FactoryGirl (at least in the lib folder). So, I start writing strange stuff like "mock" and "stub". Can somebody help a novice out?
I have this module
...
0
votes
2answers
41 views
Capybara ambiguous match - should have_content
I'm using Capybara and Rspec in a Rails app, and I keep failing some of my tests with this message :
Failure/Error: it { should have_content('error') }
Capybara::Ambiguous:
Ambiguous match, found ...