Class: Webspicy::Configuration
- Inherits:
-
Object
- Object
- Webspicy::Configuration
- Defined in:
- lib/webspicy/configuration.rb
Instance Attribute Summary collapse
-
#before_listeners ⇒ Object
readonly
Returns the list of listeners that must be called before each web service invocation.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#client ⇒ Object
Returns the value of attribute client.
-
#file_filter ⇒ Object
Returns the value of attribute file_filter.
-
#folder(folder = nil, &bl) ⇒ Object
readonly
Adds a folder to the list of folders where test case definitions are to be found.
-
#host ⇒ Object
Returns the value of attribute host.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#postconditions ⇒ Object
readonly
Returns the value of attribute postconditions.
-
#preconditions ⇒ Object
readonly
Returns the value of attribute preconditions.
-
#rspec_options ⇒ Object
readonly
Returns the value of attribute rspec_options.
-
#run_counterexamples ⇒ Object
Returns the value of attribute run_counterexamples.
-
#service_filter ⇒ Object
Returns the value of attribute service_filter.
Class Method Summary collapse
Instance Method Summary collapse
-
#before_each(&listener) ⇒ Object
Installs a listener that will be called before each web service invocation.
-
#data_system ⇒ Object
Returns the Data system to use for parsing schemas.
-
#dup(&bl) ⇒ Object
Duplicates this configuration and yields the block with the new one, if a block is given.
- #each_scope(&bl) ⇒ Object
-
#has_children? ⇒ Boolean
Returns whether this configuration has children configurations or not.
-
#initialize(folder = Path.pwd, parent = nil) {|_self| ... } ⇒ Configuration
constructor
A new instance of Configuration.
-
#postcondition(clazz) ⇒ Object
Registers a postcondition matcher.
-
#precondition(clazz) ⇒ Object
Registers a precondition matcher.
-
#run_counterexamples? ⇒ Boolean
Whether counter examples must be ran or not.
Constructor Details
#initialize(folder = Path.pwd, parent = nil) {|_self| ... } ⇒ Configuration
Returns a new instance of Configuration.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/webspicy/configuration.rb', line 4 def initialize(folder = Path.pwd, parent = nil) @folder = folder @parent = parent @children = [] @preconditions = [] @postconditions = [] @before_listeners = [] @rspec_options = @run_counterexamples = default_run_counterexamples @file_filter = default_file_filter @service_filter = default_service_filter @client = HttpClient Path.require_tree(folder/'support') if (folder/'support').exists? yield(self) if block_given? end |
Instance Attribute Details
#before_listeners ⇒ Object
Returns the list of listeners that must be called before each web service invocation.
207 208 209 |
# File 'lib/webspicy/configuration.rb', line 207 def before_listeners @before_listeners end |
#children ⇒ Object
Returns the value of attribute children.
72 73 74 |
# File 'lib/webspicy/configuration.rb', line 72 def children @children end |
#client ⇒ Object
Returns the value of attribute client.
195 196 197 |
# File 'lib/webspicy/configuration.rb', line 195 def client @client end |
#file_filter ⇒ Object
Returns the value of attribute file_filter.
145 146 147 |
# File 'lib/webspicy/configuration.rb', line 145 def file_filter @file_filter end |
#folder(folder = nil, &bl) ⇒ Object
Adds a folder to the list of folders where test case definitions are to be found.
56 57 58 |
# File 'lib/webspicy/configuration.rb', line 56 def folder @folder end |
#host ⇒ Object
Returns the value of attribute host.
128 129 130 |
# File 'lib/webspicy/configuration.rb', line 128 def host @host end |
#parent ⇒ Object
Returns the value of attribute parent.
40 41 42 |
# File 'lib/webspicy/configuration.rb', line 40 def parent @parent end |
#postconditions ⇒ Object
Returns the value of attribute postconditions.
86 87 88 |
# File 'lib/webspicy/configuration.rb', line 86 def postconditions @postconditions end |
#preconditions ⇒ Object
Returns the value of attribute preconditions.
79 80 81 |
# File 'lib/webspicy/configuration.rb', line 79 def preconditions @preconditions end |
#rspec_options ⇒ Object
Returns the value of attribute rspec_options.
221 222 223 |
# File 'lib/webspicy/configuration.rb', line 221 def @rspec_options end |
#run_counterexamples ⇒ Object
Returns the value of attribute run_counterexamples.
98 99 100 |
# File 'lib/webspicy/configuration.rb', line 98 def run_counterexamples @run_counterexamples end |
#service_filter ⇒ Object
Returns the value of attribute service_filter.
170 171 172 |
# File 'lib/webspicy/configuration.rb', line 170 def service_filter @service_filter end |
Class Method Details
.dress(arg, &bl) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/webspicy/configuration.rb', line 22 def self.dress(arg, &bl) return arg if arg.is_a?(Configuration) arg = Path(arg) if arg.file? c = Kernel.instance_eval arg.read, arg.to_s yield(c) if block_given? c elsif (arg/'config.rb').file? dress(arg/'config.rb', &bl) else raise ArgumentError, "Missing config.rb file" end end |
.inherits(*args, &bl) ⇒ Object
36 37 38 |
# File 'lib/webspicy/configuration.rb', line 36 def self.inherits(*args, &bl) dress(*args, &bl) end |
Instance Method Details
#before_each(&listener) ⇒ Object
Installs a listener that will be called before each web service invocation.
The ‘listener` must respond to `call`.
200 201 202 203 |
# File 'lib/webspicy/configuration.rb', line 200 def before_each(&listener) raise "Must respond to call" unless listener.respond_to?(:call) @before_listeners << listener end |
#data_system ⇒ Object
Returns the Data system to use for parsing schemas
The data system associated with a configuration is build when the configuration folder contains a ‘schema.fio` finitio file. When no such file can be found, the parent config is checked (if any). When no `schema.fio` file can be found, the method ends up returning the default Finition system.
247 248 249 250 251 252 253 254 255 256 |
# File 'lib/webspicy/configuration.rb', line 247 def data_system schema = self.folder/"schema.fio" if schema.file? Finitio::DEFAULT_SYSTEM.parse(schema.read) elsif not(self.parent.nil?) self.parent.data_system else Finitio::DEFAULT_SYSTEM end end |
#dup(&bl) ⇒ Object
Duplicates this configuration and yields the block with the new one, if a block is given.
The cloned configuration has all same values as the original but shares nothing with it. Therefore, affecting the new one has no effect on the original.
264 265 266 267 268 269 270 271 272 273 |
# File 'lib/webspicy/configuration.rb', line 264 def dup(&bl) super.tap do |d| d.children = [] d.preconditions = self.preconditions.dup d.postconditions = self.postconditions.dup d. = self..dup d.before_listeners = self.before_listeners.dup yield d if block_given? end end |
#each_scope(&bl) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/webspicy/configuration.rb', line 43 def each_scope(&bl) return enum_for(:each_scope) unless block_given? if has_children? children.each do |config| config.each_scope(&bl) end else yield Scope.new(self) end end |
#has_children? ⇒ Boolean
Returns whether this configuration has children configurations or not
90 91 92 |
# File 'lib/webspicy/configuration.rb', line 90 def has_children? !children.empty? end |
#postcondition(clazz) ⇒ Object
Registers a postcondition matcher
83 84 85 |
# File 'lib/webspicy/configuration.rb', line 83 def postcondition(clazz) postconditions << clazz end |
#precondition(clazz) ⇒ Object
Registers a precondition matcher
76 77 78 |
# File 'lib/webspicy/configuration.rb', line 76 def precondition(clazz) preconditions << clazz end |
#run_counterexamples? ⇒ Boolean
Whether counter examples must be ran or not.
101 102 103 |
# File 'lib/webspicy/configuration.rb', line 101 def run_counterexamples? @run_counterexamples end |