Module: ApiFixtures::DSL

Defined in:
lib/api_fixtures/dsl.rb

Defined Under Namespace

Modules: InstanceDSL

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/api_fixtures/dsl.rb', line 11

def self.extended(base)
  base.class_attribute :api_fixture_paths
  base.send(:include, InstanceDSL)

  before_hook = [:before, :setup].find {|hook| base.respond_to?(hook) }
  after_hook  = [:after, :teardown].find {|hook| base.respond_to?(hook) }

  base.send(before_hook) do
    ApiFixtures::Fixtures.clear
    (api_fixture_paths || []).each do |path|
      ApiFixtures::Fixtures.fixture('GET', path)
    end
  end

  base.send(after_hook) do
    ApiFixtures::Fixtures.assert_expected_calls(self)
  end
end

Instance Method Details

#api_fixtures(*paths) ⇒ Object



30
31
32
33
34
# File 'lib/api_fixtures/dsl.rb', line 30

def api_fixtures(*paths)
  self.api_fixture_paths ||= []
  self.api_fixture_paths += paths
  self.api_fixture_paths.uniq!
end