Sha256: 11cc3925179c1c88b4f0f861680474c1ce743b4ec8421e33a3bd977c83c573bd

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

Feature: expect error

  Expect a proc to change the state of some object.
  
  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

5 entries across 5 versions & 1 rubygems

Version Path
rspec-expectations-2.0.0.beta.22 features/matchers/expect_error.feature
rspec-expectations-2.0.0.beta.20 features/matchers/expect_error.feature
rspec-expectations-2.0.0.beta.19 features/matchers/expect_error.feature
rspec-expectations-2.0.0.beta.18 features/matchers/expect_error.feature
rspec-expectations-2.0.0.beta.17 features/matchers/expect_error.feature