File: use_flexmock.feature

package info (click to toggle)
ruby-rspec 3.4.0c3e0m1s1-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 6,124 kB
  • sloc: ruby: 59,418; sh: 1,405; makefile: 98
file content (94 lines) | stat: -rw-r--r-- 2,875 bytes parent folder | download | duplicates (5)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Feature: mock with flexmock

  Configure RSpec to use flexmock as shown in the scenarios below.

  Scenario: Passing message expectation
    Given a file named "example_spec.rb" with:
      """ruby
      RSpec.configure do |config|
        config.mock_with :flexmock
      end

      RSpec.describe "mocking with Flexmock" do
        it "passes when it should" do
          receiver = flexmock('receiver')
          receiver.should_receive(:message).once
          receiver.message
        end
      end
      """
    When I run `rspec example_spec.rb`
    Then the examples should all pass

  Scenario: Failing message expectation
    Given a file named "example_spec.rb" with:
      """ruby
      RSpec.configure do |config|
        config.mock_with :flexmock
      end

      RSpec.describe "mocking with Flexmock" do
        it "fails when it should" do
          receiver = flexmock('receiver')
          receiver.should_receive(:message).once
        end
      end
      """
    When I run `rspec example_spec.rb`
    Then the output should contain "1 example, 1 failure"

  Scenario: Failing message expectation in pending example (remains pending)
    Given a file named "example_spec.rb" with:
      """ruby
      RSpec.configure do |config|
        config.mock_with :flexmock
      end

      RSpec.describe "failed message expectation in a pending example" do
        it "is listed as pending" do
          pending
          receiver = flexmock('receiver')
          receiver.should_receive(:message).once
        end
      end
      """
    When I run `rspec example_spec.rb`
    Then the output should contain "1 example, 0 failures, 1 pending"
    And the exit status should be 0

  Scenario: Passing message expectation in pending example (fails)
    Given a file named "example_spec.rb" with:
      """ruby
      RSpec.configure do |config|
        config.mock_with :flexmock
      end

      RSpec.describe "passing message expectation in a pending example" do
        it "fails with FIXED" do
          pending
          receiver = flexmock('receiver')
          receiver.should_receive(:message).once
          receiver.message
        end
      end
      """
    When I run `rspec example_spec.rb`
    Then the output should contain "FIXED"
    Then the output should contain "1 example, 1 failure"
    And the exit status should be 1

  Scenario: Accessing `RSpec.configuration.mock_framework.framework_name`
    Given a file named "example_spec.rb" with:
      """ruby
      RSpec.configure do |config|
        config.mock_with :flexmock
      end

      RSpec.describe "RSpec.configuration.mock_framework.framework_name" do
        it "returns :flexmock" do
          expect(RSpec.configuration.mock_framework.framework_name).to eq(:flexmock)
        end
      end
      """
    When I run `rspec example_spec.rb`
    Then the examples should all pass