Class: Webspicy::Tester
- Inherits:
-
Object
show all
- 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
Instance Method Summary
collapse
Constructor Details
#initialize(config) ⇒ Tester
4
5
6
|
# File 'lib/webspicy/tester.rb', line 4
def initialize(config)
@config = Configuration.dress(config)
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
7
8
9
|
# File 'lib/webspicy/tester.rb', line 7
def config
@config
end
|
Instance Method Details
#call ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/webspicy/tester.rb', line 9
def call
rspec_config!
config.each_scope do |scope|
client = scope.get_client
scope.each_resource do |resource|
scope.each_service(resource) do |service|
rspec_service!(service, client, scope)
end
end
end
RSpec::Core::Runner.run config.rspec_options
end
|
#rspec_config! ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/webspicy/tester.rb', line 32
def rspec_config!
return if @rspec_config
RSpec.shared_examples "a successful test case invocation" do |client, test_case, counterexample|
before(:all) do
@invocation ||= begin
client.before(test_case)
test_case.instrument(client)
client.call(test_case)
end
end
let(:invocation) do
@invocation
end
it 'meets the HTTP 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.).to(be_nil) if test_case.
expect(invocation.expected_schema_unmet).to(be_nil)
end
it 'meets all specific assertions' do
expect(invocation.assertions_unmet).to(be_nil)
end if test_case.has_assertions?
it 'meets declarative postconditions' do
expect(invocation.postconditions_unmet).to(be_nil)
end if test_case.service.has_postconditions? and not(counterexample)
it 'meets the specific error messages, if any (backward compatibility)' do
expect(@invocation.expected_error_unmet).to(be_nil)
end if test_case.has_expected_error?
end
@rspec_config = true
end
|
#rspec_service!(service, client, scope) ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'lib/webspicy/tester.rb', line 22
def rspec_service!(service, client, scope)
RSpec.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
|