Sha256: 3dc9bfe8392f9a7f9847d59ecb4e13637a0cb4adf5ff196366d6d65df016c094

Contents?: true

Size: 1.11 KB

Versions: 132

Compression:

Stored size: 1.11 KB

Contents

Feature: as_null_object

  Use the `as_null_object` method to ignore any messages that aren't explicitly
  set as stubs or message expectations.

  EXCEPTION: `to_ary` will raise a NoMethodError unless explicitly stubbed in
  order to support `flatten` on an Array containing a double.

  Scenario: double acting as_null_object 
    Given a file named "as_null_object_spec.rb" with:
      """
      describe "a double with as_null_object called" do
        let(:null_object) { double('null object').as_null_object }

        it "responds to any method that is not defined" do
          null_object.should respond_to(:an_undefined_method)
        end

        it "allows explicit stubs" do
          null_object.stub(:foo) { "bar" }
          null_object.foo.should eq("bar")
        end

        it "allows explicit expectations" do
          null_object.should_receive(:something)
          null_object.something
        end

        it "supports Array#flatten" do
          [null_object].flatten.should eq([null_object])
        end
      end
      """
    When I run `rspec as_null_object_spec.rb`
    Then the examples should all pass

Version data entries

132 entries across 81 versions & 13 rubygems

Version Path
classiccms-0.5.16 vendor/bundle/gems/rspec-mocks-2.9.0/features/method_stubs/as_null_object.feature
classiccms-0.5.16 vendor/bundle/gems/rspec-mocks-2.10.1/features/method_stubs/as_null_object.feature
classiccms-0.5.15 vendor/bundle/gems/rspec-mocks-2.9.0/features/method_stubs/as_null_object.feature
classiccms-0.5.15 vendor/bundle/gems/rspec-mocks-2.10.1/features/method_stubs/as_null_object.feature
classiccms-0.5.14 vendor/bundle/gems/rspec-mocks-2.9.0/features/method_stubs/as_null_object.feature
classiccms-0.5.14 vendor/bundle/gems/rspec-mocks-2.10.1/features/method_stubs/as_null_object.feature
classiccms-0.5.13 vendor/bundle/gems/rspec-mocks-2.9.0/features/method_stubs/as_null_object.feature
classiccms-0.5.13 vendor/bundle/gems/rspec-mocks-2.10.1/features/method_stubs/as_null_object.feature
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/rspec-mocks-2.11.1/features/method_stubs/as_null_object.feature
classiccms-0.5.12 vendor/bundle/gems/rspec-mocks-2.9.0/features/method_stubs/as_null_object.feature
classiccms-0.5.12 vendor/bundle/gems/rspec-mocks-2.10.1/features/method_stubs/as_null_object.feature
classiccms-0.5.11 vendor/bundle/gems/rspec-mocks-2.9.0/features/method_stubs/as_null_object.feature
classiccms-0.5.11 vendor/bundle/gems/rspec-mocks-2.10.1/features/method_stubs/as_null_object.feature
classiccms-0.5.10 vendor/bundle/gems/rspec-mocks-2.9.0/features/method_stubs/as_null_object.feature
classiccms-0.5.10 vendor/bundle/gems/rspec-mocks-2.10.1/features/method_stubs/as_null_object.feature
classiccms-0.5.9 vendor/bundle/gems/rspec-mocks-2.10.1/features/method_stubs/as_null_object.feature
classiccms-0.5.9 vendor/bundle/gems/rspec-mocks-2.9.0/features/method_stubs/as_null_object.feature
classiccms-0.5.8 vendor/bundle/gems/rspec-mocks-2.9.0/features/method_stubs/as_null_object.feature
classiccms-0.5.8 vendor/bundle/gems/rspec-mocks-2.10.1/features/method_stubs/as_null_object.feature
rspec-mocks-2.11.2 features/method_stubs/as_null_object.feature