File: type_matchers.feature

package info (click to toggle)
ruby-rspec-mocks 2.14.5-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 868 kB
  • ctags: 725
  • sloc: ruby: 8,227; makefile: 4
file content (26 lines) | stat: -rw-r--r-- 858 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Feature: stub with argument constraints

  You can further specify the behavior by constraining the type,
  format and/or number of arguments with the `#with()` method
  chained off of `#stub()`

  Scenario: an_instance_of argument matcher
    Given a file named "stub_an_instance_of_args_spec.rb" with:
      """ruby
      describe "stubbed an_instance_of() args spec" do
        it "works" do
          object = Object.new
          object.stub(:foo).with(an_instance_of(Symbol)) do
            "symbol"
          end
          object.stub(:foo).with(an_instance_of(String)) do
            "string"
          end

          object.foo("bar").should eq("string")
          object.foo(:that).should eq("symbol")
        end
      end
      """
    When I run `rspec stub_an_instance_of_args_spec.rb`
    Then the output should contain "1 example, 0 failures"