/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

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