Sha256: 72b7ccb8bc95791f1a77d743a0a6df9e92c71a44c9a743b8d75cd0116cf744d2

Contents?: true

Size: 1.36 KB

Versions: 16

Compression:

Stored size: 1.36 KB

Contents

Feature: expect error

  Expect a proc to change the state of some object.
  
  Scenario: expect error
    Given a file named "expect_error.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.rb"
    Then the stdout should match "2 examples, 1 failure"
    Then the stdout should match "expected NameError but nothing was raised"

  Scenario: expect no error
    Given a file named "expect_no_error.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.rb"
    Then the stdout should match "2 examples, 1 failure"
    Then the stdout should match "undefined method `non_existent_message'"

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
rspec-core-2.0.0.beta.2 features-pending/expectations/expect_error.feature
rspec-core-2.0.0.beta.1 features-pending/expectations/expect_error.feature
rspec-core-2.0.0.a10 features-pending/expectations/expect_error.feature
rspec-core-2.0.0.a9 features-pending/expectations/expect_error.feature
rspec-core-2.0.0.a8 features-pending/expectations/expect_error.feature
rspec-core-2.0.0.a7 features-pending/expectations/expect_error.feature
rspec-core-2.0.0.a6 features-pending/expectations/expect_error.feature
rspec-core-2.0.0.a5 features-pending/expectations/expect_error.feature
rspec-core-2.0.0.a4 features-pending/expectations/expect_error.feature
rspec-core-2.0.0.a3 features-pending/expectations/expect_error.feature
rspec-core-2.0.0.a2 features-pending/expectations/expect_error.feature
rspec-core-2.0.0.a1 features-pending/expectations/expect_error.feature
rspec-1.2.7 features/expectations/expect_error.feature
rspec-1.2.8 features/expectations/expect_error.feature
rspec-1.2.5 features/expectations/expect_error.feature
rspec-1.2.6 features/expectations/expect_error.feature