-
-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- useful in irb to explore the framework - also eliminated two require calls per example when using rspec-mocks with rspec-core - huge performance boost (20% range)
- Loading branch information
1 parent
beffc1e
commit be136a4
Showing
6 changed files
with
58 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,14 @@ | |||
# rspec-mocks-2.2 | |||
|
|||
## What's new | |||
|
|||
### `require "rspec/mocks/standalone"` | |||
|
|||
Sets up top-level environment to explore rspec-mocks. Mostly useful in irb: | |||
|
|||
$ irb | |||
> require 'rspec/mocks/standalone' | |||
> foo = double() | |||
> foo.stub(:bar) { :baz } | |||
> foo.bar | |||
=> :baz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,32 @@ | |||
Feature: standalone | |||
|
|||
require "rspec/mocks/standalone" to expose the mock framework | |||
outside the RSpec environment. This is especially useful for | |||
exploring rspec-mocks in irb. | |||
|
|||
Scenario: stub outside rspec | |||
Given a file named "example.rb" with: | |||
""" | |||
require "rspec/mocks/standalone" | |||
greeter = double("greeter") | |||
greeter.stub(:say_hi) { "Hello!" } | |||
puts greeter.say_hi | |||
""" | |||
When I run "ruby example.rb" | |||
Then the output should contain "Hello!" | |||
|
|||
Scenario: message expectation outside rspec | |||
Given a file named "example.rb" with: | |||
""" | |||
require "rspec/mocks/standalone" | |||
greeter = double("greeter") | |||
greeter.should_receive(:say_hi) | |||
RSpec::Mocks.verify | |||
""" | |||
When I run "ruby example.rb" | |||
Then the output should contain "say_hi(any args) (RSpec::Mocks::MockExpectationError)" | |||
Then the output should contain "expected: 1 time" | |||
Then the output should contain "received: 0 times" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
require 'rspec/mocks' | |||
|
|||
RSpec::Mocks.setup(self) |