Created
December 17, 2013 00:58
-
-
Save jacobsmith/7998115 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe Student do | |
before do | |
@student = FactoryGirl.create(:student) | |
end | |
subject { @student } | |
it { should respond_to(:name) } | |
it { should respond_to(:section) } | |
describe "should be invalid" do | |
describe "without name" do | |
before { @student.name = nil } | |
it { should_not be_valid} | |
end | |
describe "without section" do | |
before { @student.section = nil } | |
it { should_not be_valid} | |
end | |
end #describe "should be invalid" | |
describe "it should have an assignment" do | |
before do | |
student_assignment = FactoryGirl.create(:assignment) | |
end | |
@student.assignment.name.should eq "Homework" | |
end #describe "it should have an assignment" | |
end #describe Student |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A couple points
@student.assignment.name...
needs to be wrapped in anit
block to be considered a test.assignment
needs to be associated to a student in order to retrieve it.subject(:student) { FactoryGirl.create(:student) }
instead of thebefore
block andsubject
.