Sha256: 46b3eeb6c6df7c99bf9bf5dc28aa5a1d5442834837f0bacd5d6b3de5b05505bd

Contents?: true

Size: 1.15 KB

Versions: 22

Compression:

Stored size: 1.15 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 = double('foo')
          [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

22 entries across 20 versions & 4 rubygems

Version Path
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/rspec-mocks-2.8.0/features/method_stubs/as_null_object.feature
resque-pool-0.3.0.beta.2 vendor/bundle/ruby/1.8/gems/rspec-mocks-2.8.0/features/method_stubs/as_null_object.feature
horseman-0.0.4 vendor/ruby/1.9.1/gems/rspec-mocks-2.8.0/features/method_stubs/as_null_object.feature
horseman-0.0.4 vendor/ruby/1.9.1/gems/rspec-mocks-2.7.0/features/method_stubs/as_null_object.feature
horseman-0.0.3 vendor/ruby/1.9.1/gems/rspec-mocks-2.8.0/features/method_stubs/as_null_object.feature
horseman-0.0.3 vendor/ruby/1.9.1/gems/rspec-mocks-2.7.0/features/method_stubs/as_null_object.feature
horseman-0.0.2 vendor/ruby/1.9.1/gems/rspec-mocks-2.7.0/features/method_stubs/as_null_object.feature
rspec-mocks-2.8.0 features/method_stubs/as_null_object.feature
nutshell-crm-0.0.6.alpha vendor/bundle/gems/rspec-mocks-2.7.0/features/method_stubs/as_null_object.feature
rspec-mocks-2.8.0.rc2 features/method_stubs/as_null_object.feature
nutshell-crm-0.0.5 vendor/bundle/gems/rspec-mocks-2.7.0/features/method_stubs/as_null_object.feature
nutshell-crm-0.0.4 vendor/bundle/gems/rspec-mocks-2.7.0/features/method_stubs/as_null_object.feature
nutshell-crm-0.0.3 vendor/bundle/gems/rspec-mocks-2.7.0/features/method_stubs/as_null_object.feature
nutshell-crm-0.0.2 vendor/bundle/gems/rspec-mocks-2.7.0/features/method_stubs/as_null_object.feature
nutshell-crm-0.0.1 vendor/bundle/gems/rspec-mocks-2.7.0/features/method_stubs/as_null_object.feature
rspec-mocks-2.8.0.rc1 features/method_stubs/as_null_object.feature
rspec-mocks-2.7.0 features/method_stubs/as_null_object.feature
rspec-mocks-2.7.0.rc1 features/method_stubs/as_null_object.feature
rspec-mocks-2.6.0 features/method_stubs/as_null_object.feature
rspec-mocks-2.6.0.rc6 features/method_stubs/as_null_object.feature