Class: AppTester::Test Abstract
- Includes:
- RSpec::Matchers
- Defined in:
- lib/app-tester/test.rb
Overview
This class is abstract.
Main object that hold all the data needed to run a test
Defined Under Namespace
Classes: BacktraceObject
Instance Attribute Summary collapse
-
#connection ⇒ Faraday::Connection
readonly
connection handler.
-
#name ⇒ String
readonly
name for this test.
-
#options ⇒ AppTester::Options
readonly
the options that the user defined when he created the framework.
-
#parser ⇒ AppTester::Parser
readonly
user selected options on command line.
-
#self_before_instance_eval ⇒ Object
writeonly
Sets the attribute self_before_instance_eval.
-
#source ⇒ Proc
readonly
block of code that holds the test to be executed.
Instance Method Summary collapse
- #arguments ⇒ Object
- #get(url = "", parameters = {}) ⇒ Object
-
#initialize(name, options = { }, &block) ⇒ Test
constructor
A new instance of Test.
- #post(url = "", parameters = {}) ⇒ Object
-
#run(arguments = ARGV) ⇒ Object
Run test.
-
#set_cmd_options {|@parser| ... } ⇒ Object
Defines command options (arguments) that this test supports.
Constructor Details
Instance Attribute Details
#connection ⇒ Faraday::Connection (readonly)
connection handler
11 12 13 |
# File 'lib/app-tester/test.rb', line 11 def connection @connection end |
#name ⇒ String (readonly)
name for this test
11 12 13 |
# File 'lib/app-tester/test.rb', line 11 def name @name end |
#options ⇒ AppTester::Options (readonly)
the options that the user defined when he created the framework
11 12 13 |
# File 'lib/app-tester/test.rb', line 11 def @options end |
#parser ⇒ AppTester::Parser (readonly)
user selected options on command line
11 12 13 |
# File 'lib/app-tester/test.rb', line 11 def parser @parser end |
#self_before_instance_eval=(value) ⇒ Object (writeonly)
Sets the attribute self_before_instance_eval
19 20 21 |
# File 'lib/app-tester/test.rb', line 19 def self_before_instance_eval=(value) @self_before_instance_eval = value end |
#source ⇒ Proc (readonly)
block of code that holds the test to be executed
11 12 13 |
# File 'lib/app-tester/test.rb', line 11 def source @source end |
Instance Method Details
#arguments ⇒ Object
36 37 38 |
# File 'lib/app-tester/test.rb', line 36 def arguments @parser. end |
#get(url = "", parameters = {}) ⇒ Object
40 41 42 |
# File 'lib/app-tester/test.rb', line 40 def get url="", parameters={} connection.get url, parameters end |
#post(url = "", parameters = {}) ⇒ Object
44 45 46 |
# File 'lib/app-tester/test.rb', line 44 def post url="", parameters={} connection.post url, parameters end |
#run(arguments = ARGV) ⇒ Object
Run test
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/app-tester/test.rb', line 51 def run(arguments=ARGV) append_help_option @parser.parse!(arguments) @parser.check_mandatory_arguments @connection = AppTester::Connection.new @parser.[:server], @options @self_before_instance_eval = eval "self", @source.binding begin self.instance_eval &@source rescue RSpec::Expectations::ExpectationNotMetError => excp unless defined? IS_RSPEC # Extract and create a backtrace object backtrace = excp.backtrace.map { |x| x.match(/^(.+?):(\d+)(|:in `(.+)')$/); BacktraceObject.new($1, $2, $4) } line_number = 0 # Because the correct line number is not the first on the error stack we need to iterate it and find what we want backtrace.each do |backtrace_entry| line_number = backtrace_entry.line_number if backtrace_entry.where == "block in <main>" end puts "#{AppTester::Utils::Strings::FAILED} #{excp.} on line #{line_number}" end end end |
#set_cmd_options {|@parser| ... } ⇒ Object
Defines command options (arguments) that this test supports
32 33 34 |
# File 'lib/app-tester/test.rb', line 32 def yield(@parser) if block_given? end |