PageRenderTime 48ms CodeModel.GetById 17ms app.highlight 24ms RepoModel.GetById 1ms app.codeStats 0ms

/vendor/bundle/jruby/2.1/gems/rspec-core-2.14.8/features/mock_framework_integration/use_mocha.feature

https://github.com/delowong/logstash
Gherkin Specification | 97 lines | 85 code | 12 blank | 0 comment | 2 complexity | b0e4bb96b744a3f4c649beb75f60910b MD5 | raw file
 1Feature: mock with mocha
 2
 3  Configure RSpec to use mocha as shown in the scenarios below.
 4
 5  Scenario: passing message expectation
 6    Given a file named "example_spec.rb" with:
 7      """ruby
 8      RSpec.configure do |config|
 9        config.mock_framework = :mocha
10      end
11
12      describe "mocking with RSpec" do
13        it "passes when it should" do
14          receiver = mock('receiver')
15          receiver.expects(:message).once
16          receiver.message
17        end
18      end
19      """
20    When I run `rspec example_spec.rb`
21    Then the examples should all pass
22
23  Scenario: failing message expecation
24    Given a file named "example_spec.rb" with:
25      """ruby
26      RSpec.configure do |config|
27        config.mock_framework = :mocha
28      end
29
30      describe "mocking with RSpec" do
31        it "fails when it should" do
32          receiver = mock('receiver')
33          receiver.expects(:message).once
34        end
35      end
36      """
37    When I run `rspec example_spec.rb`
38    Then the output should contain "1 example, 1 failure"
39
40  Scenario: failing message expectation in pending block (remains pending)
41    Given a file named "example_spec.rb" with:
42      """ruby
43      RSpec.configure do |config|
44        config.mock_framework = :mocha
45      end
46
47      describe "failed message expectation in a pending block" do
48        it "is listed as pending" do
49          pending do
50            receiver = mock('receiver')
51            receiver.expects(:message).once
52          end
53        end
54      end
55      """
56    When I run `rspec example_spec.rb`
57    Then the output should contain "1 example, 0 failures, 1 pending"
58    And the exit status should be 0
59
60  Scenario: passing message expectation in pending block (fails)
61    Given a file named "example_spec.rb" with:
62      """ruby
63      RSpec.configure do |config|
64        config.mock_framework = :mocha
65      end
66
67      describe "passing message expectation in a pending block" do
68        it "fails with FIXED" do
69          pending do
70            receiver = mock('receiver')
71            receiver.expects(:message).once
72            receiver.message
73          end
74        end
75      end
76      """
77    When I run `rspec example_spec.rb`
78    Then the output should contain "FIXED"
79    Then the output should contain "1 example, 1 failure"
80    And the exit status should be 1
81
82  Scenario: accessing RSpec.configuration.mock_framework.framework_name
83    Given a file named "example_spec.rb" with:
84      """ruby
85      RSpec.configure do |config|
86        config.mock_framework = :mocha
87      end
88
89      describe "RSpec.configuration.mock_framework.framework_name" do
90        it "returns :mocha" do
91          RSpec.configuration.mock_framework.framework_name.should eq(:mocha)
92        end
93      end
94      """
95    When I run `rspec example_spec.rb`
96    Then the examples should all pass
97