/
example_spec.rb
62 lines (49 loc) · 1.72 KB
/
example_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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require 'spec_helper'
describe Rspec::Core::Example, :parent_metadata => 'sample' do
before do
behaviour = stub('behaviour',
:metadata => Rspec::Core::Metadata.new.process(
'behaviour_name',
:caller => ['foo_spec.rb:37']
)
).as_null_object
@example = Rspec::Core::Example.new(behaviour, 'description', {}, (lambda {}))
end
describe "attr readers" do
it "should have one for the parent behaviour" do
@example.should respond_to(:behaviour)
end
it "should have one for it's description" do
@example.should respond_to(:description)
end
it "should have one for it's metadata" do
@example.should respond_to(:metadata)
end
it "should have one for it's block" do
@example.should respond_to(:example_block)
end
end
describe '#inspect' do
it "should return 'behaviour_name - description'" do
@example.inspect.should == 'behaviour_name - description'
end
end
describe '#to_s' do
it "should return #inspect" do
@example.to_s.should == @example.inspect
end
end
describe "accessing metadata within a running example" do
it "should have a reference to itself when running" do
running_example.description.should == "should have a reference to itself when running"
end
it "should be able to access the behaviours top level metadata as if it were its own" do
running_example.behaviour.metadata.should include(:parent_metadata => 'sample')
running_example.metadata.should include(:parent_metadata => 'sample')
end
end
describe "#run" do
pending "should run after(:each) when the example fails"
pending "should run after(:each) when the example raises an Exception"
end
end