Last active
January 1, 2016 02:09
-
-
Save subicura/8077364 to your computer and use it in GitHub Desktop.
remotty rspec guide
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 "User Model" do | |
context "Association" do | |
it { should have_many(:groups) } | |
end | |
context "Validation" do | |
it "name과 email속성을 가진다." do | |
expect(build(:user)).to be_valid | |
end | |
it "name은 필수 항목이다." do | |
expect(build(:user, name: nil)).to have(1).errors_on(:name) | |
end | |
it "email은 필수 항목이다." do | |
expect(User.new(email: nil)).to have(1).errors_on(:email) | |
end | |
it "email은 유일해야 한다." do | |
create(:user, email: '[email protected]') | |
user = build(:user, email: '[email protected]') | |
expect(user).to have(1).errors_on(:email) | |
end | |
end | |
context "Instance method" do | |
end | |
context "Class method" do | |
describe "filter name by letter" do | |
before :each do | |
@jang = create(:user, name: 'Jang') | |
@lee = create(:user, name: 'Lee') | |
@jeo = create(:user, name: 'Jeo') | |
@kim = create(:user, name: 'Kim') | |
end | |
context "matching letters" do | |
it "returns a sorted array of results that match" do | |
expect(User.by_letter('e')).to eq [@jeo, @lee] | |
end | |
end | |
context "non-matching letters" do | |
it "returns a sorted array of results that match" do | |
expect(User.by_letter('e')).to_not include [@kim, @jang] | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment