Class: Webspicy::Web::Specification::Post::SemanticsPreservedByRefactoring
- Inherits:
-
Object
- Object
- Webspicy::Web::Specification::Post::SemanticsPreservedByRefactoring
- Includes:
- Specification::Post
- Defined in:
- lib/webspicy/web/specification/post/semantics_preserved_by_refactoring.rb
Constant Summary collapse
- MATCH =
/The data output semantics is preserved by the refactoring/
Constants included from Specification::Condition
Specification::Condition::MATCH_ALL
Instance Attribute Summary
Attributes included from Specification::Condition
#matching_description, #tester
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Specification::Post
Methods included from Specification::Condition
#bind, #fail!, #sooner_or_later, #to_s
Class Method Details
.match(service, descr) ⇒ Object
10 11 12 13 |
# File 'lib/webspicy/web/specification/post/semantics_preserved_by_refactoring.rb', line 10 def self.match(service, descr) return nil unless descr =~ MATCH SemanticsPreservedByRefactoring.new end |
Instance Method Details
#check! ⇒ Object
18 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 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/webspicy/web/specification/post/semantics_preserved_by_refactoring.rb', line 18 def check! test_id = { description: test_case.description, seeds: test_case.seeds, url: test_case.service.specification.url, method: test_case.service.method, params: test_case.params, headers: test_case.headers.reject{|k| k == 'Authorization' }, metadata: test_case., } sha1 = Digest::SHA1.hexdigest(test_id.to_json) record_file_path = config.folder/".morpheus/#{sha1}.key.json" record_file_path.parent.mkdir_p record_file_path.write(JSON.pretty_generate(test_id)) response = invocation.response test_data = { status: response.status, headers: response.headers, body: JSON.parse(response.body), } case ENV['MORPHEUS'].upcase when 'RECORD' expected_file_path = config.folder/".morpheus/#{sha1}.expected.json" expected_file_path.write(JSON.pretty_generate(test_data)) when 'CHECK' expected_file_path = config.folder/".morpheus/#{sha1}.expected.json" expected = expected_file_path.load actual_file_path = config.folder/".morpheus/#{sha1}.actual.json" actual_file_path.write(JSON.pretty_generate(test_data)) actual = actual_file_path.load fail!("Semantics has changed.") unless values_equal?(actual, expected) end end |
#instrument ⇒ Object
15 16 |
# File 'lib/webspicy/web/specification/post/semantics_preserved_by_refactoring.rb', line 15 def instrument end |