I am needing to achieve 100% code coverage for this class.
How would I test the following class in simplecov?
How can I test the save_user method in rspec?
class Log < ActiveRecord::Base
has_and_belongs_to_many :tags
has_one :asset
has_one :user
belongs_to :user
after_create :save_user
def save_user
self.user_id = :current_user
self.save()
end
end
describe Log do
context "When saving a user is should save to the database."
it "should call insert fields with appropriate arguments" do
expect(subject).to receive(:asset).with("TestData")
expect(subject).to receive(:user).with("DummyName")
expect(subject).to save_user
subject.foo
end
end