Skip to content

Commit

Permalink
Merge pull request #66 from abdullahallmehedi/49514_RSpec_for_UsersCo…
Browse files Browse the repository at this point in the history
…urse_Model

RSpec for UsersCourse Model 49514
  • Loading branch information
dieunb committed Dec 24, 2015
2 parents a2f8e22 + dad9aae commit 0c700fa
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions spec/factories/users_courses.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require "faker"

FactoryGirl.define do
factory :users_course do
user
course
end
end
32 changes: 32 additions & 0 deletions spec/models/users_course_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require "rails_helper"

describe UsersCourse do
let(:demo_obj) {FactoryGirl.build :users_course}
subject {FactoryGirl.create :users_course}

it {is_expected.to be_an UsersCourse}
it {expect belong_to :user}
it {expect belong_to :course}

it "triggers .appened_assigned_users on save" do
expect(demo_obj).to receive :appened_assigned_users
demo_obj.save
end

it "triggers .appened_removed_users on destroy" do
demo_obj.save
expect(demo_obj).to receive :appened_removed_users
demo_obj.destroy
end

it {expect(demo_obj.course.assigned_users).not_to include demo_obj.user}
context "checking callbacks internal functionality" do
before {demo_obj.save}

it {expect(demo_obj.course.assigned_users).to include demo_obj.user}
it "appened_removed_users" do
demo_obj.destroy
expect(demo_obj.course.assigned_users).to include demo_obj.user
end
end
end

0 comments on commit 0c700fa

Please sign in to comment.