Class: IpaTestKit::Generator::ReadTestGenerator
- Inherits:
-
Object
- Object
- IpaTestKit::Generator::ReadTestGenerator
- Defined in:
- lib/ipa_test_kit/generator/read_test_generator.rb
Instance Attribute Summary collapse
-
#base_output_dir ⇒ Object
Returns the value of attribute base_output_dir.
-
#group_metadata ⇒ Object
Returns the value of attribute group_metadata.
Class Method Summary collapse
Instance Method Summary collapse
- #base_output_file_name ⇒ Object
- #class_name ⇒ Object
- #conformance_expectation ⇒ Object
- #generate ⇒ Object
-
#initialize(group_metadata, base_output_dir) ⇒ ReadTestGenerator
constructor
A new instance of ReadTestGenerator.
- #module_name ⇒ Object
- #output ⇒ Object
- #output_file_directory ⇒ Object
- #output_file_name ⇒ Object
- #profile_identifier ⇒ Object
- #read_interaction ⇒ Object
- #resource_collection_string ⇒ Object
- #resource_type ⇒ Object
- #template ⇒ Object
- #test_id ⇒ Object
Constructor Details
#initialize(group_metadata, base_output_dir) ⇒ ReadTestGenerator
Returns a new instance of ReadTestGenerator.
22 23 24 25 |
# File 'lib/ipa_test_kit/generator/read_test_generator.rb', line 22 def initialize(, base_output_dir) self. = self.base_output_dir = base_output_dir end |
Instance Attribute Details
#base_output_dir ⇒ Object
Returns the value of attribute base_output_dir.
20 21 22 |
# File 'lib/ipa_test_kit/generator/read_test_generator.rb', line 20 def base_output_dir @base_output_dir end |
#group_metadata ⇒ Object
Returns the value of attribute group_metadata.
20 21 22 |
# File 'lib/ipa_test_kit/generator/read_test_generator.rb', line 20 def @group_metadata end |
Class Method Details
.generate(ig_metadata, base_output_dir) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/ipa_test_kit/generator/read_test_generator.rb', line 8 def generate(, base_output_dir) .groups .reject { |group| SpecialCases.exclude_group? group } .select { |group| read_interaction(group).present? } .each { |group| new(group, base_output_dir).generate } end |
.read_interaction(group_metadata) ⇒ Object
15 16 17 |
# File 'lib/ipa_test_kit/generator/read_test_generator.rb', line 15 def read_interaction() .interactions.find { |interaction| interaction[:code] == 'read' } end |
Instance Method Details
#base_output_file_name ⇒ Object
35 36 37 |
# File 'lib/ipa_test_kit/generator/read_test_generator.rb', line 35 def base_output_file_name "#{class_name.underscore}.rb" end |
#class_name ⇒ Object
59 60 61 |
# File 'lib/ipa_test_kit/generator/read_test_generator.rb', line 59 def class_name "#{Naming.upper_camel_case_for_profile()}ReadTest" end |
#conformance_expectation ⇒ Object
79 80 81 |
# File 'lib/ipa_test_kit/generator/read_test_generator.rb', line 79 def conformance_expectation read_interaction[:expectation] end |
#generate ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/ipa_test_kit/generator/read_test_generator.rb', line 83 def generate FileUtils.mkdir_p(output_file_directory) File.open(output_file_name, 'w') { |f| f.write(output) } .add_test( id: test_id, file_name: base_output_file_name ) end |
#module_name ⇒ Object
63 64 65 |
# File 'lib/ipa_test_kit/generator/read_test_generator.rb', line 63 def module_name "Ipa#{.reformatted_version.upcase}" end |
#output ⇒ Object
31 32 33 |
# File 'lib/ipa_test_kit/generator/read_test_generator.rb', line 31 def output @output ||= ERB.new(template).result(binding) end |
#output_file_directory ⇒ Object
39 40 41 |
# File 'lib/ipa_test_kit/generator/read_test_generator.rb', line 39 def output_file_directory File.join(base_output_dir, profile_identifier) end |
#output_file_name ⇒ Object
43 44 45 |
# File 'lib/ipa_test_kit/generator/read_test_generator.rb', line 43 def output_file_name File.join(output_file_directory, base_output_file_name) end |
#profile_identifier ⇒ Object
51 52 53 |
# File 'lib/ipa_test_kit/generator/read_test_generator.rb', line 51 def profile_identifier Naming.snake_case_for_profile() end |
#read_interaction ⇒ Object
47 48 49 |
# File 'lib/ipa_test_kit/generator/read_test_generator.rb', line 47 def read_interaction self.class.read_interaction() end |
#resource_collection_string ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/ipa_test_kit/generator/read_test_generator.rb', line 71 def resource_collection_string if .delayed? && resource_type != 'Provenance' "scratch.dig(:references, '#{resource_type}')" else 'all_scratch_resources' end end |
#resource_type ⇒ Object
67 68 69 |
# File 'lib/ipa_test_kit/generator/read_test_generator.rb', line 67 def resource_type .resource end |
#template ⇒ Object
27 28 29 |
# File 'lib/ipa_test_kit/generator/read_test_generator.rb', line 27 def template @template ||= File.read(File.join(__dir__, 'templates', 'read.rb.erb')) end |
#test_id ⇒ Object
55 56 57 |
# File 'lib/ipa_test_kit/generator/read_test_generator.rb', line 55 def test_id "ipa_#{.reformatted_version}_#{profile_identifier}_read_test" end |