Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add specs and .travis.yml #111

Merged
merged 6 commits into from
Feb 11, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add a couple of specs and a travis configuration
  • Loading branch information
erran committed Feb 11, 2015
commit adaee63571013da40c05733866f466fd74a8d5f4
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: ruby
rvm:
- 1.9.3
- 2.0.0
- 2.1.0
- 2.2.0
1 change: 1 addition & 0 deletions nexpose.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ Gem::Specification.new do |s|
s.add_runtime_dependency('rex', '~> 2.0.5', '>= 2.0.5')

s.add_development_dependency('bundler', '~> 1.3')
s.add_development_dependency('rspec', '~> 3.2')
end
33 changes: 33 additions & 0 deletions spec/nexpose/connection_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require 'spec_helper'

describe Nexpose::Connection do
describe '.from_uri' do
let(:username) { nil }
let(:password) { nil }
let(:silo_id) { nil }

subject(:connection) { Nexpose::Connection.from_uri(uri, username, password, silo_id) }

context 'with the default port' do
let(:uri) { 'https://nexpose.local:3780/' }

it 'initializes a new Connection' do
expect(connection.host).to eq('nexpose.local')
expect(connection.password).to eq(password)
expect(connection.port).to eq(3780)
expect(connection.username).to eq(username)
end
end

context 'with a non-default port' do
let(:uri) { 'https://nexpose.local:1234/' }

it 'initializes a new Connection' do
expect(connection.host).to eq('nexpose.local')
expect(connection.password).to eq(password)
expect(connection.port).to eq(1234)
expect(connection.username).to eq(username)
end
end
end
end
36 changes: 36 additions & 0 deletions spec/nexpose/util/sanititze_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require 'spec_helper'

describe Nexpose::Sanitize do
subject do
# Create a dummy class which has included the Sanitize module
dummy_class = Class.new { include Nexpose::Sanitize }
dummy_class.new
end

describe '#replace_entities' do
it 'replaces all instances of the ampersand character with &' do
observed = subject.replace_entities('one & two & three')
expect(observed).to eq('one & two & three')
end

it 'replaces all instances of the double quote character with "' do
observed = subject.replace_entities('Lorem "ipsum"')
expect(observed).to eq('Lorem "ipsum"')
end

it 'replaces all instances of the single quote character with '' do
observed = subject.replace_entities("Lorem 'ipsum'")
expect(observed).to eq('Lorem 'ipsum'')
end

it 'replaces all instances of the "greater than" character' do
observed = subject.replace_entities("n_bits >> m_bits")
expect(observed).to eq('n_bits >> m_bits')
end

it 'replaces all instances of the "less than" character' do
observed = subject.replace_entities("array << Time.now")
expect(observed).to eq('array &lt;&lt; Time.now')
end
end
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require 'nexpose'