forked from rspec/rspec-core
-
Notifications
You must be signed in to change notification settings - Fork 1
/
subject_example.rb
45 lines (39 loc) · 1.04 KB
/
subject_example.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
require File.dirname(__FILE__) + '/spec_helper'
module SubjectExample
class OneThing
attr_accessor :what_things_do
def initialize
self.what_things_do = "stuff"
end
end
# implicit subject
describe OneThing do
it "should do what things do" do
subject.what_things_do.should == "stuff"
end
it "should be a OneThing" do
should == subject
end
its(:what_things_do) { should == "stuff" }
end
# explicit subject
describe SubjectExample::OneThing do
subject { SubjectExample::OneThing.new }
it "should do what things do" do
subject.what_things_do.should == "stuff"
end
it "should be a OneThing" do
should == subject
end
its(:what_things_do) { should == "stuff" }
end
# modified subject
describe OneThing do
subject { SubjectExample::OneThing.new }
before { subject.what_things_do = "more stuff" }
it "should do what things do" do
subject.what_things_do.should == "more stuff"
end
its(:what_things_do) { should == "more stuff" }
end
end