Class: Webspicy::Tester
- Inherits:
-
Object
- Object
- Webspicy::Tester
- Defined in:
- lib/webspicy/tester.rb,
lib/webspicy/tester/asserter.rb,
lib/webspicy/tester/assertions.rb
Defined Under Namespace
Modules: Assertions Classes: Asserter
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #call(err = $stderr, out = $stdout) ⇒ Object
-
#initialize(config) ⇒ Tester
constructor
A new instance of Tester.
-
#load ⇒ Object
protected.
- #rspec_config! ⇒ Object
- #rspec_service!(on, service, client, scope) ⇒ Object
Constructor Details
#initialize(config) ⇒ Tester
Returns a new instance of Tester.
4 5 6 7 |
# File 'lib/webspicy/tester.rb', line 4 def initialize(config) @config = Configuration.dress(config) @test_suite = load end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/webspicy/tester.rb', line 8 def config @config end |
Instance Method Details
#call(err = $stderr, out = $stdout) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/webspicy/tester.rb', line 10 def call(err=$stderr, out=$stdout) $_rspec_core_load_started_at = nil = RSpec::Core::ConfigurationOptions.new(config.) conf = RSpec::Core::Configuration.new RSpec::Core::Runner.new(, conf).run(err, out) end |
#load ⇒ Object
protected
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/webspicy/tester.rb', line 19 def load tester = self RSpec.reset rspec_config! RSpec.describe "Webspicy test suite" do before(:all) do tester.config.listeners(:before_all).each do |l| l.call(tester.config) end end after(:all) do tester.config.listeners(:after_all).each do |l| l.call(tester.config) end end tester.config.each_scope do |scope| client = scope.get_client scope.each_resource do |resource| scope.each_service(resource) do |service| tester.rspec_service!(self, service, client, scope) end end end end self end |
#rspec_config! ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/webspicy/tester.rb', line 56 def rspec_config! RSpec.shared_examples "a successful test case invocation" do |client, test_case, counterexample| around(:each) do |example| client.around(test_case) do client.before(test_case) test_case.instrument(client) @invocation = client.call(test_case) example.run client.after(test_case) end end let(:invocation) do @invocation end it 'meets its specification' do expect(invocation.done?).to eq(true) expect(invocation.expected_status_unmet).to(be_nil) expect(invocation.expected_content_type_unmet).to(be_nil) expect(invocation.expected_headers_unmet).to(be_nil) if test_case.has_expected_headers? expect(invocation.expected_schema_unmet).to(be_nil) expect(invocation.assertions_unmet).to(be_nil) if test_case.has_assertions? expect(invocation.postconditions_unmet).to(be_nil) if test_case.service.has_postconditions? and not(counterexample) expect(invocation.expected_error_unmet).to(be_nil) if test_case.has_expected_error? end end end |
#rspec_service!(on, service, client, scope) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/webspicy/tester.rb', line 46 def rspec_service!(on, service, client, scope) on.describe service do scope.each_testcase(service) do |test_case, counterexample| describe test_case do include_examples 'a successful test case invocation', client, test_case, counterexample end end end end |