Module: Workbench
- Defined in:
- lib/workbench.rb,
lib/workbench/string_helpers.rb
Defined Under Namespace
Modules: StringHelpers
Constant Summary collapse
- COUNTERS =
Hash.new(0)
Class Method Summary collapse
-
.counter(key) ⇒ Object
The counter routine.
-
.reset_counters! ⇒ Object
Reset all counters.
Instance Method Summary collapse
-
#count_with(name) ⇒ Object
Declare that the next builder method is to count scoped to the following class,.
-
#use_class(name) ⇒ Object
Declare that the next builder method is to use the said class (Symbol such as :User or string such as “Models::User” are acceptable).
Class Method Details
.counter(key) ⇒ Object
The counter routine. Provide a key, get back an incrementer.
37 38 39 |
# File 'lib/workbench.rb', line 37 def self.counter(key) COUNTERS[key] += 1 end |
.reset_counters! ⇒ Object
Reset all counters. It doesn’t happen automatically, you’ll likley want to call this method before or after each test is run
43 44 45 |
# File 'lib/workbench.rb', line 43 def self.reset_counters! COUNTERS.clear end |
Instance Method Details
#count_with(name) ⇒ Object
Declare that the next builder method is to count scoped to the following class,
module Builders
extend Workbench
def book_defaults(u, n)
...
end
count_with :Book
def article_defaults(u, n)
...
end
end
new_book # n = 1 new_publication # n = 2 new_book # n = 3
expects a Symbol such as :User or string such as “Models::User” that maps to a valid class name.
32 33 34 |
# File 'lib/workbench.rb', line 32 def count_with(name) @next_count_with = name end |
#use_class(name) ⇒ Object
Declare that the next builder method is to use the said class (Symbol such as :User or string such as “Models::User” are acceptable)
8 9 10 |
# File 'lib/workbench.rb', line 8 def use_class(name) @next_class = name end |