Created
December 30, 2018 09:42
-
-
Save satooshi/ecfa3fd8e3c32819746432819678a0ff 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
# spec/models/cat_spec.rb | |
require 'rails_helper.rb' | |
RSpec.describe Cat, type: :model do | |
# this is a test target model | |
let(:cat) { Cat.new(status: status) } | |
# this block describes Cat#nyan instance method | |
# when you reference an instance method, write `Class#method` | |
# and for a class method, write 'Class.method' | |
describe '#nyan' do | |
# this is the test target | |
# and can be referenced as `subject` | |
subject { cat.nyan } | |
# and this block describes test conditions | |
context 'When a cat is hungry' do | |
# this is the first test condition | |
let(:status) { :hungry } | |
# and the expectation under the test condition | |
it 'says nyaaaan' do | |
expect(subject).to eq('nyaaaan') | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment