OSS E1852.rb: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 27: Line 27:


== Participant Unit Test ==
== Participant Unit Test ==
We used factory methods to generate the necessary variables.


Methods tested in participant model:
<pre>
*team
let(:user) {
build( :student, id: 1, name: 'no name', fullname: 'no one') }
  let(:team) {
build( :assignment_team, id: 1, name: 'myTeam' ) }
  let(:team_user) {
build( :team_user, id: 1, user: user, team: team) }
 
  let(:topic){ build( :topic ) }
 
  let(:participant) {
build(:participant,
user: build( :student, name: "Jane", fullname: "Doe, Jane", id: 1 ) ) }
  let(:participant2) {
build(:participant,
user: build( :student, name: "John", fullname: "Doe, John", id: 2 ) ) }
  let(:participant3) {
build(:participant, can_review: false,
user: build(:student, name: "King", fullname: "Titan, King", id: 3 ) ) }
 
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }
 
</pre>
 
'''Methods tested in participant model''':
 
* team
<pre>
</pre>
* response : This method returns the response associated with the perticular participant. we use mock method to simulate return of the response from the participant response_map
<pre>
describe '#response' do
    it 'Returns the responses that are associated with this participant' do
      allow( participant ).to receive( :responses ).and_return( response )
      expect( participant.responses ).to eq( response )
    end
  end
</pre>


*response
*name
*name
*fullname
*fullname

Revision as of 21:23, 27 October 2018

This wiki page is for the description of changes made under E1852 OSS assignment for Fall 2018, CSC/ECE 517

Background

Expertiza is an open source web-based peer review system developed and maintained by students and faculty members at North Carolina State University. It enables students enrolled in a particular course to form online teams and complete assignments.

Problem

Participant model does not have any unit tests.


Work to be done

  • Write unit test using Rspec
  • Achieve path coverage more than 90%

Files Modified/Created

  • spec/models/particpant_spec.rb

Unit Test Description

Unit tests are used to test the functionality of methods in the model. there are two types of unit tests, Test Driven Development(TDD) and Behaviour Driven Development(BDD). BDD is preferred because of its simplicity. In this project, We are using RSpec for BDD.

doubt ? do I have to write more about RSpec????

Participant Unit Test

We used factory methods to generate the necessary variables.

let(:user) { 
	build( :student, id: 1, name: 'no name', fullname: 'no one') }
  let(:team) {	
	build( :assignment_team, id: 1, name: 'myTeam' ) }
  let(:team_user) { 
	build( :team_user, id: 1, user: user, team: team) }

  let(:topic){ build( :topic ) }

  let(:participant) {
	build(:participant,
	user: build( :student, name: "Jane", fullname: "Doe, Jane", id: 1 ) ) }
  let(:participant2) { 
	build(:participant, 
	user: build( :student, name: "John", fullname: "Doe, John", id: 2 ) ) }
  let(:participant3) { 
	build(:participant, can_review: false, 
	user: build(:student, name: "King", fullname: "Titan, King", id: 3 ) ) }

  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }

Methods tested in participant model:

  • team

  • response : This method returns the response associated with the perticular participant. we use mock method to simulate return of the response from the participant response_map
describe '#response' do
    it 'Returns the responses that are associated with this participant' do
      allow( participant ).to receive( :responses ).and_return( response )
      expect( participant.responses ).to eq( response )
    end
  end
  • name
  • fullname
  • handle
  • delete
  • force_delete
  • topic_name
  • able_to_review
  • email
  • score
  • get_permissions
  • get_authorization
  • sort_by_name

Running the Tests

To run the test run below command in terminal

 rspec spec/models/participant_spec.rb

External links

External links

References