-
-
Notifications
You must be signed in to change notification settings - Fork 397
/
syntax_configuration.feature
68 lines (60 loc) · 2.13 KB
/
syntax_configuration.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
Feature: Syntax Configuration
In addition to the long-supported `should` syntax, rspec-expectations
supports an alternate `expect` syntax. If you want your project to
only use one syntax, you can configure the available syntaxes.
Background:
Given a file named "syntaxes_spec.rb" with:
"""ruby
describe "using the should syntax" do
specify { 3.should eq(3) }
specify { 3.should_not eq(4) }
specify { lambda { raise "boom" }.should raise_error("boom") }
specify { lambda { }.should_not raise_error }
end
describe "using the expect syntax" do
specify { expect(3).to eq(3) }
specify { expect(3).not_to eq(4) }
specify { expect { raise "boom" }.to raise_error("boom") }
specify { expect { }.not_to raise_error }
end
"""
Scenario: Both syntaxes are available by default
When I run `rspec syntaxes_spec.rb`
Then the examples should all pass
Scenario: Disable should syntax
Given a file named "disable_should_syntax.rb" with:
"""ruby
RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = :expect
end
end
"""
When I run `rspec disable_should_syntax.rb syntaxes_spec.rb`
Then the output should contain all of these:
| 8 examples, 4 failures |
| undefined method `should' |
Scenario: Disable expect syntax
Given a file named "disable_expect_syntax.rb" with:
"""ruby
RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = :should
end
end
"""
When I run `rspec disable_expect_syntax.rb syntaxes_spec.rb`
Then the output should contain all of these:
| 8 examples, 4 failures |
| undefined method `expect' |
Scenario: Explicitly enable both syntaxes
Given a file named "enable_both_syntaxes.rb" with:
"""ruby
RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = [:should, :expect]
end
end
"""
When I run `rspec enable_both_syntaxes.rb syntaxes_spec.rb`
Then the examples should all pass