Class: WebFixtures::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/web_fixtures/dsl.rb

Constant Summary collapse

@@default_options =
{
  :include_headers => true,
  :authenticate    => false,
  :root_path       => "./fixtures"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base, options = {}) ⇒ DSL

Returns a new instance of DSL.



13
14
15
16
# File 'lib/web_fixtures/dsl.rb', line 13

def initialize(base, options = {})
  @base = base
  @default_options = @@default_options.merge(options)
end

Instance Attribute Details

#baseObject

Returns the value of attribute base.



4
5
6
# File 'lib/web_fixtures/dsl.rb', line 4

def base
  @base
end

#default_optionsObject

Returns the value of attribute default_options.



5
6
7
# File 'lib/web_fixtures/dsl.rb', line 5

def default_options
  @default_options
end

Instance Method Details

#authenticate(choice) ⇒ Object



22
23
24
# File 'lib/web_fixtures/dsl.rb', line 22

def authenticate(choice)
  default_options[:authenticate] = choice
end

#delete(url, options = {}) ⇒ Object



42
43
44
# File 'lib/web_fixtures/dsl.rb', line 42

def delete(url, options = {})
  add_request(:delete, url, options)
end

#get(url, options = {}) ⇒ Object



30
31
32
# File 'lib/web_fixtures/dsl.rb', line 30

def get(url, options = {})
  add_request(:get, url, options)
end

#include_headers(choice) ⇒ Object



18
19
20
# File 'lib/web_fixtures/dsl.rb', line 18

def include_headers(choice)
  default_options[:include_headers] = choice
end

#post(url, options = {}) ⇒ Object



34
35
36
# File 'lib/web_fixtures/dsl.rb', line 34

def post(url, options = {})
  add_request(:post, url, options)
end

#put(url, options = {}) ⇒ Object



38
39
40
# File 'lib/web_fixtures/dsl.rb', line 38

def put(url, options = {})
  add_request(:put, url, options)
end

#storage_path(path) ⇒ Object



26
27
28
# File 'lib/web_fixtures/dsl.rb', line 26

def storage_path(path)
  default_options[:root_path] = path
end