Class: Fakettp::Expectation
- Inherits:
-
Object
- Object
- Fakettp::Expectation
- Defined in:
- lib/fakettp/expectation.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- EXPECTATION_DIR =
File.join FAKETTP_BASE, 'tmp', 'expectations'
Class Method Summary collapse
Instance Method Summary collapse
- #execute(binding) ⇒ Object
-
#initialize(contents) ⇒ Expectation
constructor
A new instance of Expectation.
Constructor Details
#initialize(contents) ⇒ Expectation
Returns a new instance of Expectation.
7 8 9 |
# File 'lib/fakettp/expectation.rb', line 7 def initialize contents @contents = contents end |
Class Method Details
.<<(expectation) ⇒ Object
24 25 26 27 28 |
# File 'lib/fakettp/expectation.rb', line 24 def self.<< expectation File.open next_file_to_create, 'w' do |f| f.write expectation end end |
.clear_all ⇒ Object
16 17 18 |
# File 'lib/fakettp/expectation.rb', line 16 def self.clear_all FileUtils.rm_rf Dir.glob(File.join(EXPECTATION_DIR, '*')) end |
.empty? ⇒ Boolean
20 21 22 |
# File 'lib/fakettp/expectation.rb', line 20 def self.empty? files.empty? end |
.next ⇒ Object
30 31 32 33 34 35 |
# File 'lib/fakettp/expectation.rb', line 30 def self.next file = next_file_to_read contents = File.read file FileUtils.rm file Expectation.new contents end |
Instance Method Details
#execute(binding) ⇒ Object
11 12 13 14 |
# File 'lib/fakettp/expectation.rb', line 11 def execute binding eval @contents, binding # TODO: Include context of expectation file end |