-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from nepalez/feature/const
Feature/const
- Loading branch information
Showing
11 changed files
with
151 additions
and
54 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
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
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
2 changes: 1 addition & 1 deletion
2
lib/fixturama/stubs/actions/raise.rb → lib/fixturama/stubs/chain/actions/raise.rb
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
2 changes: 1 addition & 1 deletion
2
lib/fixturama/stubs/actions/return.rb → lib/fixturama/stubs/chain/actions/return.rb
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
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
module Fixturama | ||
# | ||
# Definition for stubbing a constant | ||
# | ||
class Stubs::Const | ||
attr_reader :const, :value | ||
|
||
# | ||
# Human-readable representation of the chain | ||
# @return [String] | ||
# | ||
def to_s | ||
const.to_s | ||
end | ||
alias to_str to_s | ||
|
||
# | ||
# Overload the definition for the constant | ||
# @option [Object] value | ||
# @return [self] | ||
# | ||
def update!(value:, **) | ||
@value = value | ||
self | ||
end | ||
|
||
# | ||
# Apply the stub to RSpec example | ||
# @return [self] | ||
# | ||
def apply!(example) | ||
example.send(:stub_const, const, value) | ||
self | ||
end | ||
|
||
private | ||
|
||
def initialize(const:, **) | ||
@const = const.to_s | ||
end | ||
end | ||
end |
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 | Diff line number | Diff line change |
---|---|---|
|
@@ -45,3 +45,6 @@ | |
- return: 6 | ||
repeat: 2 | ||
- return: 0 | ||
|
||
- const: TIMEOUT | ||
value: 10 |