Class: SnapshotUI::Snapshot::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/snapshot_ui/snapshot/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Context

Returns a new instance of Context.



8
9
10
11
12
13
14
# File 'lib/snapshot_ui/snapshot/context.rb', line 8

def initialize(context)
  @test_framework = context[:test_framework]
  @test_case_name = context[:test_case_name]
  @method_name = context[:method_name]
  @source_location = context[:source_location]
  @take_snapshot_index = context[:take_snapshot_index]
end

Instance Attribute Details

#method_nameObject (readonly)

Returns the value of attribute method_name.



6
7
8
# File 'lib/snapshot_ui/snapshot/context.rb', line 6

def method_name
  @method_name
end

#source_locationObject (readonly)

Returns the value of attribute source_location.



6
7
8
# File 'lib/snapshot_ui/snapshot/context.rb', line 6

def source_location
  @source_location
end

#take_snapshot_indexObject (readonly)

Returns the value of attribute take_snapshot_index.



6
7
8
# File 'lib/snapshot_ui/snapshot/context.rb', line 6

def take_snapshot_index
  @take_snapshot_index
end

#test_case_nameObject (readonly)

Returns the value of attribute test_case_name.



6
7
8
# File 'lib/snapshot_ui/snapshot/context.rb', line 6

def test_case_name
  @test_case_name
end

#test_frameworkObject (readonly)

Returns the value of attribute test_framework.



6
7
8
# File 'lib/snapshot_ui/snapshot/context.rb', line 6

def test_framework
  @test_framework
end

Instance Method Details

#nameObject



25
26
27
# File 'lib/snapshot_ui/snapshot/context.rb', line 25

def name
  method_name
end

#order_indexObject



33
34
35
# File 'lib/snapshot_ui/snapshot/context.rb', line 33

def order_index
  source_location.dup << take_snapshot_index
end

#test_groupObject



29
30
31
# File 'lib/snapshot_ui/snapshot/context.rb', line 29

def test_group
  test_case_name
end

#to_slugObject



16
17
18
19
20
21
22
23
# File 'lib/snapshot_ui/snapshot/context.rb', line 16

def to_slug
  test_path_without_extension =
    source_location[0]
      .delete_suffix(File.extname(source_location[0]))
      .delete_prefix(SnapshotUI.configuration.project_root_directory.to_s + "/")

  [test_path_without_extension, source_location[1], take_snapshot_index].join("_")
end