# Rspec unit test for updating a property of a model

I know how to write simple RSpec tests and unit tests. I just want to know if this is good enough or if there are any improvements I can make.

I intend to test the the toggle_property method of the TaskItemUserReference model which updates the property, completed from false to true or vice versa.

Relationships

#Factories

FactoryGirl.define do
name Faker::Lorem.sentence(2)
end
end

FactoryGirl.define do
user
end
end

FactoryGirl.define do
name Faker::Lorem.sentence(3)
end
end

FactoryGirl.define do
user
active true
completed false
end
end

# RSPEC test
require "rails_helper"

let(:owner) { create(:user) }
let(:user) { create(:user) }

before do
user_id: user.id,
completed: true,
)
end

end
end
end


It looks like you don't need the whole user-task-task item setup for the test you provided. It's actually a TaskItemUserReference spec, not Task spec.

RSpec.describe TaskItemUserReference, type: :model do

describe "#toggle_property" do

• TaskItemUserReference seems to make sense. – Thorpe Obazee Aug 27 '17 at 14:00