capybara-basic_auth_helper 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 50df5c8bfc6fd0df40d0a9c538af9849bc76933d
4
+ data.tar.gz: 1ff84e0a05997dadc46fa0aa55421fba319f983e
5
+ SHA512:
6
+ metadata.gz: 56093c1c6635f7dd9c9b9cf867795ebf2f5254ef6f9913d65db429b1160150dd15ac88237acd3569e046c9a4546460be135e73995287d903fab16fc8d564c08d
7
+ data.tar.gz: b26a0172182ea5f002824f51d69016f392fff19252e823237d49968d968d7b5e0098fa81997142ae54e76654546086283d6a53d3ab32ca9cd5bb7615893630e9
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capybara-basic_auth_helper.gemspec
4
+ gemspec
@@ -0,0 +1,61 @@
1
+ # Capybara::BasicAuthHelper [![Build Status](https://travis-ci.org/damncabbage/capybara-basic_auth_helper.png)](https://travis-ci.org/damncabbage/capybara-basic_auth_helper)
2
+
3
+ A tiny gem that provides `basic_auth(username, password)` for Capybara integration specs.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ group :test do
10
+ gem 'capybara-basic_auth_helper'
11
+ end
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Add the following to your `spec/spec_helper.rb`:
18
+
19
+ require 'capybara/basic_auth_helper'
20
+
21
+
22
+ ## Usage
23
+
24
+ From within your integration specs:
25
+
26
+ ```ruby
27
+ # spec/integrations/sample_spec.rb
28
+ require 'spec_helper'
29
+
30
+ describe "A Sample Spec" do
31
+ it "visits a page" do
32
+ basic_auth 'admin', '12345' # <=== This bit.
33
+ visit '/admin'
34
+ expect(page).to have_content('Control Panel')
35
+ end
36
+ end
37
+ ```
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create new Pull Request
46
+
47
+ ## License
48
+
49
+ Copyright 2013, Rob Howard
50
+
51
+ Licensed under the Apache License, Version 2.0 (the "License");
52
+ you may not use this file except in compliance with the License.
53
+ You may obtain a copy of the License at
54
+
55
+ http://www.apache.org/licenses/LICENSE-2.0
56
+
57
+ Unless required by applicable law or agreed to in writing, software
58
+ distributed under the License is distributed on an "AS IS" BASIS,
59
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
60
+ See the License for the specific language governing permissions and
61
+ limitations under the License.
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ # RSpec
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ task :default => :spec
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capybara/basic_auth_helper/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capybara-basic_auth_helper"
8
+ spec.version = Capybara::BasicAuthHelper::VERSION
9
+ spec.authors = ["Rob Howard"]
10
+ spec.email = ["rob@robhoward.id.au"]
11
+ spec.description = %q{Provides basic_auth(username, password) for Capybara specs.}
12
+ spec.summary = spec.description
13
+ spec.homepage = "https://github.com/damncabbage/capybara-basic_auth_helper"
14
+ spec.license = "Apache License, Version 2.0"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec", "~> 2.0"
24
+ end
@@ -0,0 +1,20 @@
1
+ require "capybara/basic_auth_helper/version"
2
+
3
+ # Source: http://stackoverflow.com/a/4345708/3528
4
+ module Capybara
5
+ module BasicAuthHelper
6
+
7
+ def basic_auth(name, password)
8
+ if page.driver.respond_to?(:basic_auth)
9
+ page.driver.basic_auth(name, password)
10
+ elsif page.driver.respond_to?(:basic_authorize)
11
+ page.driver.basic_authorize(name, password)
12
+ elsif page.driver.respond_to?(:browser) && page.driver.browser.respond_to?(:basic_authorize)
13
+ page.driver.browser.basic_authorize(name, password)
14
+ else
15
+ raise "I don't know how to log in!"
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ require 'capybara/basic_auth_helper'
2
+
3
+ RSpec.configure do |c|
4
+ c.include Capybara::BasicAuthHelper, :type => :feature
5
+ end
@@ -0,0 +1,5 @@
1
+ module Capybara
2
+ module BasicAuthHelper
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe Capybara::BasicAuthHelper do
4
+ include Capybara::BasicAuthHelper
5
+
6
+ let(:page) { double(:driver => driver) }
7
+ let(:driver) { double }
8
+
9
+ let(:username) { "admin1" }
10
+ let(:password) { "12345pw" }
11
+
12
+ it "handles rack-test's basic_authorize" do
13
+ driver.stub(:basic_authorize)
14
+ expect(driver).to receive(:basic_authorize).with(username, password)
15
+ basic_auth(username, password)
16
+ end
17
+
18
+ # TODO: Which driver is this?
19
+ it "handles ???'s basic_auth" do
20
+ driver.stub(:basic_auth)
21
+ expect(driver).to receive(:basic_auth).with(username, password)
22
+ basic_auth(username, password)
23
+ end
24
+
25
+ it "handles Selenium's brower.basic_authorize" do
26
+ browser = double
27
+ driver.stub(:browser => browser)
28
+ browser.stub(:basic_authorize)
29
+
30
+ expect(browser).to receive(:basic_authorize).with(username, password)
31
+ basic_auth(username, password)
32
+ end
33
+
34
+ it "explodes if none of the other attempts worked" do
35
+ expect {
36
+ basic_auth(username, password)
37
+ }.to raise_error
38
+ end
39
+ end
@@ -0,0 +1 @@
1
+ require 'capybara/basic_auth_helper'
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capybara-basic_auth_helper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Rob Howard
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ description: Provides basic_auth(username, password) for Capybara specs.
56
+ email:
57
+ - rob@robhoward.id.au
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - .travis.yml
64
+ - Gemfile
65
+ - README.md
66
+ - Rakefile
67
+ - capybara-basic_auth_helper.gemspec
68
+ - lib/capybara/basic_auth_helper.rb
69
+ - lib/capybara/basic_auth_helper/rspec.rb
70
+ - lib/capybara/basic_auth_helper/version.rb
71
+ - spec/helper_spec.rb
72
+ - spec/spec_helper.rb
73
+ homepage: https://github.com/damncabbage/capybara-basic_auth_helper
74
+ licenses:
75
+ - Apache License, Version 2.0
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.0.3
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Provides basic_auth(username, password) for Capybara specs.
97
+ test_files:
98
+ - spec/helper_spec.rb
99
+ - spec/spec_helper.rb