Module: Webspec
- Includes:
- HTTParty
- Defined in:
- lib/webspec.rb,
lib/webspec/run.rb,
lib/webspec/example.rb,
lib/webspec/version.rb,
lib/webspec/example_group.rb
Defined Under Namespace
Classes: Example, ExampleGroup, Formatter, Run
Constant Summary
collapse
- VERSION =
"0.1.0"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.api_key ⇒ Object
Returns the value of attribute api_key.
13
14
15
|
# File 'lib/webspec.rb', line 13
def api_key
@api_key
end
|
Class Method Details
.allow_net_connect ⇒ Object
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/webspec.rb', line 61
def allow_net_connect
if defined?(FakeWeb)
allow_net_connect = FakeWeb.allow_net_connect
FakeWeb.allow_net_connect = true
yield
FakeWeb.allow_net_connect = allow_net_connect
else
yield
end
end
|
.base_url ⇒ Object
15
16
17
|
# File 'lib/webspec.rb', line 15
def base_url
ENV['WEBSPEC_URL'] || "https://webspec.shellyapp.com"
end
|
19
20
21
|
# File 'lib/webspec.rb', line 19
def configure_rspec
RSpec.configuration.add_formatter(Webspec::Formatter)
end
|
.create_example(example_params, run, parent = nil) ⇒ Object
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/webspec.rb', line 50
def create_example(example_params, run, parent = nil)
allow_net_connect do
url = "#{base_url}/projects/#{api_key}/runs/#{run.id}/examples.json"
response = post(url, :body => {
:example => example_params,
:parent_id => (parent.id if parent)
})
Webspec::Example.new(response.to_hash.merge(:run => run))
end
end
|
.create_example_group(example_group_params, run, parent = nil) ⇒ Object
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/webspec.rb', line 39
def create_example_group(example_group_params, run, parent = nil)
allow_net_connect do
url = "#{base_url}/projects/#{api_key}/runs/#{run.id}/example_groups.json"
response = post(url, :body => {
:example_group => example_group_params,
:parent_id => (parent.id if parent)
})
Webspec::ExampleGroup.new(response.to_hash.merge(:run => run))
end
end
|
.create_run(run_params = {}) ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/webspec.rb', line 23
def create_run(run_params = {})
allow_net_connect do
url = "#{base_url}/projects/#{api_key}/runs.json"
response = post(url, :body => {:run => run_params})
Webspec::Run.new(response.to_hash)
end
end
|
.update_run(run_id, run_params = {}) ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/webspec.rb', line 31
def update_run(run_id, run_params = {})
allow_net_connect do
url = "#{base_url}/projects/#{api_key}/runs/#{run_id}.json"
response = put(url, :body => {:run => run_params})
Webspec::Run.new(response.to_hash)
end
end
|