Module: RSpecSystem::Helpers
- Defined in:
- lib/rspec-system/helpers.rb,
lib/rspec-system/helpers/rcp.rb,
lib/rspec-system/helpers/shell.rb
Overview
This module contains the main rspec helpers that are to be used within rspec-system tests. These are the meat-and-potatoes of your system tests, and in theory there shouldn’t be anything you can’t do without the helpers here.
These helpers in particular are core to the framework. You can however combine these helpers to create your own more powerful helpers in rspec if you wish.
The helpers themselves are split into two main groups, Queries:
-
node
- queries and returns node information
And Actions:
-
shell
- runs a command on a node -
rcp
- remote copies to a node
Defined Under Namespace
Actions collapse
-
#rcp(options) {|result| ... } ⇒ RSpecSystem::Helpers::Rcp
Remotely copy files to a test host.
-
#shell(options) {|result| ... } ⇒ RSpecSystem::Helpers::Shell
Runs a shell command on a test host.
Queries collapse
-
#node(options = {}) ⇒ RSpecSystem::Node
Returns a particular node object from the current nodeset given a set of criteria.
Instance Method Details
#node(options = {}) ⇒ RSpecSystem::Node
Returns a particular node object from the current nodeset given a set of criteria.
If no options are supplied, it tries to return the default node.
166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/rspec-system/helpers.rb', line 166 def node( = {}) ns = RSpecSystem::NodeSet.create = { :name => ns.default_node.name, }.merge() name = [:name] if name.nil? raise "No nodes search specified, and no default" else return ns.nodes[name] end end |
#rcp(options) {|result| ... } ⇒ RSpecSystem::Helpers::Rcp
Remotely copy files to a test host
Just specify a source path, destination path, and optionally a destination node (if the default isn’t enough) and go.
The underlying implementation is actually performed by the particular node provider, however this abstraction should mean you shouldn’t need to worry about that.
152 153 154 |
# File 'lib/rspec-system/helpers.rb', line 152 def rcp(, &block) RSpecSystem::Helpers::Rcp.new(, self, &block) end |
#shell(options) ⇒ RSpecSystem::Helpers::Shell #shell(command) ⇒ RSpecSystem::Helpers::Shell
Runs a shell command on a test host.
When invoked as a block a result hash is yielded to the block as a parameter. Alternatively the result hash it is returned to the caller.
If you have only provided 1 node in your nodeset, or you have specified a a default you can avoid entering the name of the node if you wish. The method for simplicity can accept a string instead of an options hash and it knows to default everything else.
The underlying implementation is actually performed by the particular node provider, however this abstraction should mean you shouldn’t need to worry about that.
110 111 112 113 114 115 116 117 118 |
# File 'lib/rspec-system/helpers.rb', line 110 def shell(, &block) # If options is a string, turn the string into a command in the normal # options hash. if .is_a?(String) = {:c => } end RSpecSystem::Helpers::Shell.new(, self, &block) end |