Skip to content

Commit

Permalink
Add Rspec tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahoffline committed Aug 8, 2013
1 parent 60c1c16 commit 24a34be
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .rspec
@@ -0,0 +1,2 @@
--color
--format documentation
23 changes: 23 additions & 0 deletions spec/autoexpreso_spec.rb
@@ -0,0 +1,23 @@
require 'spec_helper'

describe AutoExpreso::Client do
let(:auto) { AutoExpreso::Client.new }

describe '#client' do
it 'returns a new Mechanize instance' do
expect(auto.client).to be_kind_of(Mechanize)
end
end

describe '#account' do
it 'returns a Hash' do
expect(auto.account).to be_a(Hash)
end
end

describe '#transactions' do
it 'returns an array' do
expect(auto.transactions).to be_a(Array)
end
end
end
31 changes: 31 additions & 0 deletions spec/data_utils_spec.rb
@@ -0,0 +1,31 @@
require 'spec_helper'

describe AutoExpreso::DataUtils do
let(:data_utils) { AutoExpreso::DataUtils }

describe '#attributes' do
it 'returns an array of symbols' do
expect(data_utils.attributes)
.to match_array [:account_name_id, :account_balance_id, :account_status_id,:account_last_payment_id, :account_last_payment_date_id]
end
end

describe '#form_data' do
it 'returns an OpenStruct instance' do
expect(data_utils.form_data).to be_a(OpenStruct)
end

it 'contains methods' do
expect(data_utils.form_data.methods(false))
.to match_array [:login_form_id, :login_form_id=, :login_form_username_name, :login_form_username_name=, :login_form_password_name, :login_form_password_name=, :account_name_id, :account_name_id=, :account_balance_id, :account_balance_id=, :account_status_id, :account_status_id=, :account_last_payment_id, :account_last_payment_id=, :account_last_payment_date_id, :account_last_payment_date_id=, :account_transaction_table_id, :account_transaction_table_id=]
end

it 'returns html attributes correctly' do
expect(data_utils.form_data.login_form_id).to eq('aspnetForm')
expect(data_utils.form_data.login_form_username_name).to eq('ctl00$ContentPlaceHolder1$Login1$uxUserNameField')
expect(data_utils.form_data.login_form_password_name).to eq('ctl00$ContentPlaceHolder1$Login1$uxPasswordField')
expect(data_utils.form_data.account_name_id).to eq('#ctl00_Content_uxLogonAccountName')
expect(data_utils.form_data.account_balance_id).to eq('#ctl00_Content_uxLogonBalanceAmount')
end
end
end
8 changes: 8 additions & 0 deletions spec/spec_helper.rb
@@ -0,0 +1,8 @@
require 'autoexpreso'

RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
config.filter_run :focus
config.order = 'random'
end

0 comments on commit 24a34be

Please sign in to comment.