/
basic_spec.rb
78 lines (72 loc) · 2.21 KB
/
basic_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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
require File.dirname(__FILE__) + "/acceptance_helper.rb"
feature "Acceptance spec execution", %q{
In order to write better software
As a ruby developer
I want to execute acceptance specs
} do
scenario "Minimal acceptance spec" do
spec_file = create_spec <<-SPEC
require '#{File.dirname(__FILE__) + "/../../lib/steak"}'
feature "Minimal spec" do
scenario "First scenario" do
true.should be_true
end
end
SPEC
output = run_spec spec_file
output.should =~ /1 example, 0 failures/
end
scenario "Minimal acceptance spec that fails" do
spec_file = create_spec <<-SPEC
require '#{File.dirname(__FILE__) + "/../../lib/steak"}'
feature "Minimal spec" do
scenario "First scenario" do
true.should be_false
end
end
SPEC
output = run_spec spec_file
output.should =~ /1 example, 1 failure/
end
scenario "Acceptance spec with background" do
spec_file = create_spec <<-SPEC
require '#{File.dirname(__FILE__) + "/../../lib/steak"}'
feature "Minimal spec" do
background do
@value = 17
end
scenario "First scenario" do
@value.should == 17
end
end
SPEC
output = run_spec spec_file
output.should =~ /1 example, 0 failures/
end
scenario "Acceptance spec metadata" do
spec_file = create_spec <<-SPEC
require '#{File.dirname(__FILE__) + "/../../lib/steak"}'
feature "Minimal spec" do
scenario "should have acceptance metadata" do
example.metadata[:type].should == :acceptance
example.metadata[:steak].should be_true
end
end
SPEC
output = run_spec spec_file
output.should =~ /1 example, 0 failures/
end
scenario "Regular specs doesn't have acceptance metadata" do
spec_file = create_spec <<-SPEC
require '#{File.dirname(__FILE__) + "/../../lib/steak"}'
describe "Regular spec" do
it "should not have acceptance metadata" do
example.metadata[:type].should_not == :acceptance
example.metadata[:steak].should_not be_true
end
end
SPEC
output = run_spec spec_file
output.should =~ /1 example, 0 failures/
end
end