skink 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,7 @@ class Base
8
8
  raise NotImplementedError
9
9
  end
10
10
 
11
- def with_basic_auth(user_name, email_address)
11
+ def with_basic_auth(user_name, email_address, realm = nil)
12
12
  raise NotImplementedError
13
13
  end
14
14
 
@@ -6,6 +6,10 @@ class Response
6
6
  raise NotImplementedError
7
7
  end
8
8
 
9
+ def headers
10
+ raise NotImplementedError
11
+ end
12
+
9
13
  def body
10
14
  raise NotImplementedError
11
15
  end
@@ -14,7 +14,7 @@ class RackTestClient < Client::Base
14
14
  @app = rack_app
15
15
  end
16
16
 
17
- def with_basic_auth(user_name, password)
17
+ def with_basic_auth(user_name, password, realm = nil)
18
18
  authorize(user_name, password)
19
19
  end
20
20
 
@@ -13,6 +13,10 @@ class RackTestResponse < Client::Response
13
13
  native_response.status
14
14
  end
15
15
 
16
+ def headers
17
+ native_response.header
18
+ end
19
+
16
20
  def body
17
21
  native_response.body
18
22
  end
@@ -18,9 +18,13 @@ class ResourcefulClient < Client::Base
18
18
  @http_accessor ||= Resourceful::HttpAccessor.new
19
19
  end
20
20
 
21
- def with_basic_auth(user_name, password)
22
- #http_accessor.add_authenticator Resourceful::PromiscuousBasicAuthenticator.new(user_name, password)
23
- http_accessor.add_authenticator Resourceful::BasicAuthenticator.new("Restricted Area", user_name, password)
21
+ def with_basic_auth(user_name, password, realm = nil)
22
+ authenticator = if realm.nil?
23
+ Resourceful::PromiscuousBasicAuthenticator.new(user_name, password)
24
+ else
25
+ Resourceful::BasicAuthenticator.new(realm, user_name, password)
26
+ end
27
+ http_accessor.add_authenticator authenticator
24
28
  end
25
29
 
26
30
  def with_header(name, value)
@@ -13,6 +13,10 @@ class ResourcefulResponse < Client::Response
13
13
  native_response.code
14
14
  end
15
15
 
16
+ def headers
17
+ native_response.headers
18
+ end
19
+
16
20
  def body
17
21
  native_response.body || ""
18
22
  end
data/lib/skink/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Skink
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/skink.gemspec CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Skink::VERSION
9
9
  gem.authors = ["Todd Thomas"]
10
10
  gem.email = ["todd.thomas@openlogic.com"]
11
- gem.description = %q{A DSL for testing REST APIs}
11
+ gem.description = %q{A Ruby DSL for testing REST APIs.}
12
12
  gem.summary = %q{Skink is Capybara's smaller, more primitive companion.}
13
- gem.homepage = ""
13
+ gem.homepage = "https://github.com/toddthomas/skink.git"
14
14
 
15
15
  gem.add_dependency "rack-test"
16
16
  gem.add_dependency "openlogic-resourceful"
@@ -43,10 +43,17 @@ shared_examples "a REST API test language" do
43
43
  end
44
44
 
45
45
  it "is able to test requests which require basic authentication" do
46
+ with_basic_auth "admin", "admin"
47
+ get "/protected"
48
+ response.status_code.should == 200
49
+ response.body.should == "Welcome, authenticated client."
50
+ end
51
+
52
+ it "is able to test requests which require basic authentication for specified realm" do
46
53
  get "/protected"
47
54
  response.status_code.should == 401
48
55
 
49
- with_basic_auth "admin", "admin"
56
+ with_basic_auth "admin", "admin", "Restricted Area"
50
57
  get "/protected"
51
58
  response.status_code.should == 200
52
59
  response.body.should == "Welcome, authenticated client."
data/spec/spec_helper.rb CHANGED
@@ -4,10 +4,6 @@ $LOAD_PATH << File.join(__DIR__, "..", "lib")
4
4
 
5
5
  require 'skink/integrations/rspec'
6
6
 
7
- RSpec.configure do |config|
8
- config.include Skink::DSL
9
- end
10
-
11
7
  require 'test_server'
12
8
  Skink.rack_app = Rack::Builder.new do
13
9
  map "/" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skink
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -75,7 +75,7 @@ dependencies:
75
75
  - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
- description: A DSL for testing REST APIs
78
+ description: A Ruby DSL for testing REST APIs.
79
79
  email:
80
80
  - todd.thomas@openlogic.com
81
81
  executables: []
@@ -102,7 +102,7 @@ files:
102
102
  - spec/skink_dsl_spec.rb
103
103
  - spec/spec_helper.rb
104
104
  - spec/test_server.rb
105
- homepage: ''
105
+ homepage: https://github.com/toddthomas/skink.git
106
106
  licenses: []
107
107
  post_install_message:
108
108
  rdoc_options: []