Sha256: a26fe5b23424e592a310b32c605ff3713c16d0ea792433cecab0216ca7ef208e
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
Feature: expect error Expect a proc to raise an error when called. Scenario: expect error Given a file named "expect_error_spec.rb" with: """ describe Object, "#non_existent_message" do it "should raise" do expect{Object.non_existent_message}.to raise_error(NameError) end end #deliberate failure describe Object, "#public_instance_methods" do it "should raise" do expect{Object.public_instance_methods}.to raise_error(NameError) end end """ When I run "rspec ./expect_error_spec.rb" Then the output should contain "2 examples, 1 failure" Then the output should contain "expected NameError but nothing was raised" Scenario: expect no error Given a file named "expect_no_error_spec.rb" with: """ describe Object, "#public_instance_methods" do it "should not raise" do expect{Object.public_instance_methods}.to_not raise_error(NameError) end end #deliberate failure describe Object, "#non_existent_message" do it "should not raise" do expect{Object.non_existent_message}.to_not raise_error(NameError) end end """ When I run "rspec ./expect_no_error_spec.rb" Then the output should contain "2 examples, 1 failure" Then the output should contain "undefined method `non_existent_message'"
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rspec-expectations-2.4.0 | features/built_in_matchers/expect_error.feature |
rspec-expectations-2.0.0.rc | features/matchers/expect_error.feature |