Sha256: 9e04b4ad744dd5d0cdeadd3ccc04ed6d436fddfe617e6495db2bfe4b0fbfaf35

Contents?: true

Size: 1.3 KB

Versions: 37

Compression:

Stored size: 1.3 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:
      """ruby
      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 using expect syntax" do
          allow(null_object).to receive(:foo) { "bar" }
          expect(null_object.foo).to eq("bar")
        end

        it "allows explicit stubs using should syntax" 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

37 entries across 37 versions & 8 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/features/method_stubs/as_null_object.feature
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/features/method_stubs/as_null_object.feature
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/features/method_stubs/as_null_object.feature
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/method_stubs/as_null_object.feature
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/method_stubs/as_null_object.feature
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/method_stubs/as_null_object.feature
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/method_stubs/as_null_object.feature
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/method_stubs/as_null_object.feature
rspec-mocks-2.99.4 features/method_stubs/as_null_object.feature
vagrant-cloudstack-1.1.0 vendor/bundle/gems/rspec-mocks-2.14.6/features/method_stubs/as_null_object.feature
rspec-mocks-2.99.3 features/method_stubs/as_null_object.feature
rspec-mocks-2.99.2 features/method_stubs/as_null_object.feature
dxruby_rp5-0.0.4 spec/vendor/rspec-mocks-2.14.4/features/method_stubs/as_null_object.feature
rspec-mocks-2.99.1 features/method_stubs/as_null_object.feature
rspec-mocks-2.99.0 features/method_stubs/as_null_object.feature
rspec-mocks-2.99.0.rc1 features/method_stubs/as_null_object.feature
rspec-mocks-2.14.6 features/method_stubs/as_null_object.feature
rspec-mocks-2.99.0.beta2 features/method_stubs/as_null_object.feature
rspec-mocks-2.14.5 features/method_stubs/as_null_object.feature
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/rspec-mocks-2.14.4/features/method_stubs/as_null_object.feature