Class: Kontrast::TestBuilder
- Inherits:
-
Object
- Object
- Kontrast::TestBuilder
- Defined in:
- lib/kontrast/test_builder.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#suite ⇒ Object
readonly
Returns the value of attribute suite.
-
#url_params ⇒ Object
Returns the value of attribute url_params.
Instance Method Summary collapse
-
#initialize ⇒ TestBuilder
constructor
A new instance of TestBuilder.
- #lazy_api_endpoints(&block) ⇒ Object
-
#method_missing(name, *args) ⇒ Object
Adds a given test from config to the suite.
-
#tests(param = nil) ⇒ Object
Needed in case someone tries to name a test “tests”.
Constructor Details
#initialize ⇒ TestBuilder
Returns a new instance of TestBuilder.
9 10 11 12 13 14 |
# File 'lib/kontrast/test_builder.rb', line 9 def initialize @suite = TestSuite.new @prefix = nil @headers = {} @url_params = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
Adds a given test from config to the suite
37 38 39 |
# File 'lib/kontrast/test_builder.rb', line 37 def method_missing(name, *args) @suite << PageTest.new(@prefix, name.to_s, args.first, url_params: @url_params) end |
Instance Attribute Details
#headers ⇒ Object
Returns the value of attribute headers.
7 8 9 |
# File 'lib/kontrast/test_builder.rb', line 7 def headers @headers end |
#prefix ⇒ Object
Returns the value of attribute prefix.
7 8 9 |
# File 'lib/kontrast/test_builder.rb', line 7 def prefix @prefix end |
#suite ⇒ Object (readonly)
Returns the value of attribute suite.
6 7 8 |
# File 'lib/kontrast/test_builder.rb', line 6 def suite @suite end |
#url_params ⇒ Object
Returns the value of attribute url_params.
7 8 9 |
# File 'lib/kontrast/test_builder.rb', line 7 def url_params @url_params end |
Instance Method Details
#lazy_api_endpoints(&block) ⇒ Object
32 33 34 |
# File 'lib/kontrast/test_builder.rb', line 32 def lazy_api_endpoints(&block) @suite.lazy_tests << LazyTest.new(@prefix, @headers.dup, block) end |
#tests(param = nil) ⇒ Object
Needed in case someone tries to name a test “tests”
17 18 19 20 21 22 |
# File 'lib/kontrast/test_builder.rb', line 17 def tests(param = nil) if param raise ConfigurationException.new("'tests' is not a valid name for a test.") end return @suite.tests end |