1 |
# frozen_string_literal: true
|
|
2 |
|
|
3 |
module SpecSupport |
1✔ |
4 |
|
|
5 |
class Fixture |
1✔ |
6 |
def self.[](name) |
1✔ |
7 |
fixtures[name] |
68✔ |
8 |
end
|
|
9 |
|
|
10 |
def self.[]=(name, value) |
1✔ |
11 |
fixtures[name] = value |
19✔ |
12 |
end
|
|
13 |
|
|
14 |
def self.fixtures |
1✔ |
15 |
@fixtures ||= {}
|
87✔ |
16 |
end
|
|
17 |
|
|
18 |
def initialize(file, ext = :wsdl) |
1✔ |
19 |
self.file = file
|
70✔ |
20 |
self.ext = ext
|
70✔ |
21 |
end
|
|
22 |
|
|
23 |
attr_accessor :file, :ext |
1✔ |
24 |
|
|
25 |
def filename |
1✔ |
26 |
"#{file}.#{ext}"
|
89✔ |
27 |
end
|
|
28 |
|
|
29 |
def path |
1✔ |
30 |
File.expand_path("spec/fixtures/#{filename}") |
21✔ |
31 |
end
|
|
32 |
|
|
33 |
def read |
1✔ |
34 |
Fixture[filename] ||= File.read(path) |
68✔ |
35 |
end
|
|
36 |
end
|
|
37 |
|
|
38 |
def fixture(*args) |
1✔ |
39 |
Fixture.new(*args)
|
70✔ |
40 |
end
|
|
41 |
|
|
42 |
end
|