Sha256: 4d513307853af8967c42032637086cc8efd1d66103458e521888b90a7b8fa0cf

Contents?: true

Size: 1.78 KB

Versions: 32

Compression:

Stored size: 1.78 KB

Contents

Feature: expect change

  Expect some code (wrapped in a proc) to change the state of some object.
  
  Scenario: expecting change
    Given a file named "expect_change.rb" with:
      """
      class Counter
        class << self
          def increment
            @count ||= 0
            @count += 1
          end
          
          def count
            @count ||= 0
          end
        end
      end
      
      describe Counter, "#increment" do
        it "should increment the count" do
          expect{Counter.increment}.to change{Counter.count}.from(0).to(1)
        end

        # deliberate failure
        it "should increment the count by 2" do
          expect{Counter.increment}.to change{Counter.count}.by(2)
        end
      end
      """
    When I run "spec expect_change.rb"
    Then the stdout should include "2 examples, 1 failure"
    Then the stdout should include "should have been changed by 2, but was changed by 1"

  Scenario: expecting no change
    Given a file named "expect_no_change.rb" with:
      """
      class Counter
        class << self
          def increment
            @count ||= 0
            @count += 1
          end
          
          def count
            @count ||= 0
          end
        end
      end

      describe Counter, "#increment" do
        it "should not increment the count by 2" do
          expect{Counter.increment}.to_not change{Counter.count}.from(0).to(2)
        end

        # deliberate failure
        it "should not increment the count by 1" do
          expect{Counter.increment}.to_not change{Counter.count}.by(1)
        end
      end
      """
    When I run "spec expect_no_change.rb"
    Then the stdout should include "2 examples, 1 failure"
    Then the stdout should include "should not have changed, but did change from 1 to 2"

Version data entries

32 entries across 32 versions & 11 rubygems

Version Path
rspec-instructure-1.3.3 features/expectations/expect_change.feature
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rspec-1.3.2/features/expectations/expect_change.feature
rspec-1.3.2 features/expectations/expect_change.feature
rspec-1.3.1 features/expectations/expect_change.feature
rspec-1.3.1.rc features/expectations/expect_change.feature
rspec-1.3.0 features/expectations/expect_change.feature
hubbub-0.0.11 lib/vendor/plugins/rspec/features/expectations/expect_change.feature
hubbub-0.0.10 lib/vendor/plugins/rspec/features/expectations/expect_change.feature
hubbub-0.0.9 lib/vendor/plugins/rspec/features/expectations/expect_change.feature
hubbub-0.0.8 lib/vendor/plugins/rspec/features/expectations/expect_change.feature
hubbub-0.0.6 lib/vendor/plugins/rspec/features/expectations/expect_change.feature
simple-templater-0.0.1.4 gems/gems/rspec-1.2.9/features/expectations/expect_change.feature
media-path-0.1.2 vendor/rspec/features/expectations/expect_change.feature
simple-templater-0.0.1.3 vendor/rspec/features/expectations/expect_change.feature
pupu-0.0.2.pre vendor/rspec/features/expectations/expect_change.feature
media-path-0.1.1.pre vendor/rspec/features/expectations/expect_change.feature
simple-templater-0.0.1.2 vendor/rspec/features/expectations/expect_change.feature
media-path-0.1.1 vendor/rspec/features/expectations/expect_change.feature
simple-templater-0.0.1.1 vendor/rspec/features/expectations/expect_change.feature
pupu-0.0.2 vendor/rspec/features/expectations/expect_change.feature