forked from thoughtbot/guides
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unit_test_spec.rb
46 lines (39 loc) · 898 Bytes
/
unit_test_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
describe SomeClass do
context "when defining a subject" do
# GOOD
# it's okay to define a `subject` here:
subject { "foo" }
it { should eq "foo" }
end
context "when using an explicit subject" do
subject { "foo" }
it "should equal foo" do
# BAD
# although it's valid RSpec code and this test passes,
# it's not okay to use `subject` here:
expect(subject).to eq "foo"
end
end
describe '.some_class_method' do
it 'does something' do
# ...
end
end
describe '#some_instance_method' do
it 'does something' do
expect(something).to eq 'something'
end
end
describe '#another_instance_method' do
context 'when in one case' do
it 'does something' do
# ...
end
end
context 'when in other case' do
it 'does something else' do
# ...
end
end
end
end