Class: DaVinciPlanNetTestKit::Generator::ReadTestGenerator
- Inherits:
-
Object
- Object
- DaVinciPlanNetTestKit::Generator::ReadTestGenerator
- Defined in:
- lib/davinci_plan_net_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_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/davinci_plan_net_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/davinci_plan_net_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/davinci_plan_net_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/davinci_plan_net_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/davinci_plan_net_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/davinci_plan_net_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/davinci_plan_net_test_kit/generator/read_test_generator.rb', line 59 def class_name "#{Naming.upper_camel_case_for_profile()}ReadTest" end |
#conformance_expectation ⇒ Object
71 72 73 |
# File 'lib/davinci_plan_net_test_kit/generator/read_test_generator.rb', line 71 def conformance_expectation read_interaction[:expectation] end |
#generate ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/davinci_plan_net_test_kit/generator/read_test_generator.rb', line 75 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/davinci_plan_net_test_kit/generator/read_test_generator.rb', line 63 def module_name "DaVinciPlanNet#{.reformatted_version.upcase}" end |
#output ⇒ Object
31 32 33 |
# File 'lib/davinci_plan_net_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/davinci_plan_net_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/davinci_plan_net_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/davinci_plan_net_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/davinci_plan_net_test_kit/generator/read_test_generator.rb', line 47 def read_interaction self.class.read_interaction() end |
#resource_type ⇒ Object
67 68 69 |
# File 'lib/davinci_plan_net_test_kit/generator/read_test_generator.rb', line 67 def resource_type .resource end |
#template ⇒ Object
27 28 29 |
# File 'lib/davinci_plan_net_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/davinci_plan_net_test_kit/generator/read_test_generator.rb', line 55 def test_id "davinci_plan_net_#{.reformatted_version}_#{profile_identifier}_read_test" end |