Sha256: d35e215297379c456be63d8c43c773aae1e3a6efb096ce98a44154b6fbc87c30

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 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 "spec expect_error_spec.rb"
    Then I should see "2 examples, 1 failure"
    Then I should see "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 "spec expect_no_error_spec.rb"
    Then I should see "2 examples, 1 failure"
    Then I should see "undefined method `non_existent_message'"

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rspec-expectations-2.0.0.beta.7 features/matchers/expect_error.feature
rspec-expectations-2.0.0.beta.6 features/matchers/expect_error.feature
rspec-expectations-2.0.0.beta.5 features/matchers/expect_error.feature
rspec-expectations-2.0.0.beta.4 features/matchers/expect_error.feature
rspec-expectations-2.0.0.beta.3 features/matchers/expect_error.feature