-
-
Notifications
You must be signed in to change notification settings - Fork 763
/
configure_expectation_framework.feature
86 lines (72 loc) · 2.36 KB
/
configure_expectation_framework.feature
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
79
80
81
82
83
84
85
86
Feature: configure expectation framework
By default, RSpec is configured to include rspec-expectations for expressing
desired outcomes. You can also configure RSpec to use:
* rspec/expectations (explicitly)
* stdlib assertions
* test/unit assertions in ruby 1.8
* minitest assertions in ruby 1.9
* rspec/expecations _and_ stlib assertions
Note that when you do not use rspec-expectations, you must explicitly
provide a description to every example. You cannot rely on the generated
descriptions provided by rspec-expectations.
Scenario: configure rspec-expectations (explicitly)
Given a file named "example_spec.rb" with:
"""
RSpec.configure do |config|
config.expect_with :rspec
end
describe 5 do
it "is greater than 4" do
5.should be > 4
end
end
"""
When I run `rspec example_spec.rb`
Then the examples should all pass
Scenario: configure test/unit assertions (passing examples)
Given a file named "example_spec.rb" with:
"""
RSpec.configure do |config|
config.expect_with :stdlib
end
describe 5 do
it "is greater than 4" do
assert 5 > 4, "expected 5 to be greater than 4"
end
specify { assert 5 < 6 }
end
"""
When I run `rspec example_spec.rb`
Then the output should contain "2 examples, 0 failures"
Scenario: configure test/unit assertions (failing examples)
Given a file named "example_spec.rb" with:
"""
RSpec.configure do |config|
config.expect_with :stdlib
end
describe 5 do
it "is greater than 6 (no it isn't!)" do
assert 5 > 6, "errantly expected 5 to be greater than 5"
end
specify { assert 5 > 6 }
end
"""
When I run `rspec example_spec.rb`
Then the output should contain "2 examples, 2 failures"
Scenario: configure rspec/expecations AND test/unit assertions
Given a file named "example_spec.rb" with:
"""
RSpec.configure do |config|
config.expect_with :rspec, :stdlib
end
describe 5 do
it "is greater than 4" do
assert 5 > 4, "expected 5 to be greater than 4"
end
it "is less than 6" do
5.should be < 6
end
end
"""
When I run `rspec example_spec.rb`
Then the examples should all pass