|
4 | 4 |
|
5 | 5 | describe Bitshares::Client do |
6 | 6 |
|
| 7 | + before do |
| 8 | + Bitshares.configure(:rpc_username => ENV['BITSHARES_ACCOUNT']) |
| 9 | + Bitshares.configure(:rpc_password => ENV['BITSHARES_PASSWORD']) |
| 10 | + end |
| 11 | + |
7 | 12 | let(:client) { CLIENT } |
8 | 13 |
|
9 | 14 | context '#new' do |
|
31 | 36 | end |
32 | 37 |
|
33 | 38 | context '#rpc_request' do |
34 | | - it 'with invalid username raise Bitshares::Client::Err "Bad credentials"' do |
35 | | - stub_const('ENV', ENV.to_hash.merge('BITSHARES_ACCOUNT' => 'wrong_password')) |
36 | | - Bitshares::Client.init |
37 | | - expect(->{client.get_info}).to raise_error Bitshares::Client::Err, 'Bad credentials' |
38 | | - end |
| 39 | + context 'using ENV credentials' do |
| 40 | + it 'with invalid username raises Bitshares::Client::Err "Bad credentials"' do |
| 41 | + stub_const('ENV', ENV.to_hash.merge('BITSHARES_ACCOUNT' => 'wrong_username')) |
| 42 | + Bitshares::Client.init |
| 43 | + expect(->{client.get_info}).to raise_error Bitshares::Client::Err, 'Bad credentials' |
| 44 | + end |
39 | 45 |
|
40 | | - it 'with invalid password raise Bitshares::Client::Err "Bad credentials"' do |
41 | | - stub_const('ENV', ENV.to_hash.merge('BITSHARES_PASSWORD' => 'wrong_password')) |
42 | | - Bitshares::Client.init |
43 | | - expect(->{client.get_info}).to raise_error Bitshares::Client::Err, 'Bad credentials' |
44 | | - end |
| 46 | + it 'with invalid password raises Bitshares::Client::Err "Bad credentials"' do |
| 47 | + stub_const('ENV', ENV.to_hash.merge('BITSHARES_PASSWORD' => 'wrong_password')) |
| 48 | + Bitshares::Client.init |
| 49 | + expect(->{client.get_info}).to raise_error Bitshares::Client::Err, 'Bad credentials' |
| 50 | + end |
45 | 51 |
|
46 | | - it 'with valid credentials and invalid client command raises Bitshares::Client::Err' do |
47 | | - Bitshares::Client.init |
48 | | - expect(->{client.not_a_cmd}).to raise_error Bitshares::Client::Err |
| 52 | + it 'with valid credentials and invalid client command raises Bitshares::Client::Err' do |
| 53 | + Bitshares::Client.init |
| 54 | + expect(->{client.not_a_cmd}).to raise_error Bitshares::Client::Err |
| 55 | + end |
| 56 | + |
| 57 | + it 'with valid credentials and valid client command returns a Hash of returned JSON data' do |
| 58 | + Bitshares::Client.init |
| 59 | + expect(client.get_info.class).to eq Hash |
| 60 | + end |
49 | 61 | end |
50 | 62 |
|
51 | | - it 'with valid credentials and valid client command returns a Hash of returned JSON data' do |
52 | | - Bitshares::Client.init |
53 | | - expect(client.get_info.class).to eq Hash |
| 63 | + context 'using config credentials' do |
| 64 | + |
| 65 | + it 'with invalid username raises Bitshares::Client::Err "Bad credentials"' do |
| 66 | + Bitshares.configure(:rpc_username => 'wrong_username') |
| 67 | + stub_const('ENV', ENV.to_hash.merge('BITSHARES_ACCOUNT' => nil)) |
| 68 | + stub_const('ENV', ENV.to_hash.merge('BITSHARES_PASSWORD' => nil)) |
| 69 | + Bitshares::Client.init |
| 70 | + expect(->{client.get_info}).to raise_error Bitshares::Client::Err, 'Bad credentials' |
| 71 | + end |
| 72 | + |
| 73 | + it 'with invalid password raises Bitshares::Client::Err "Bad credentials"' do |
| 74 | + Bitshares.configure(:rpc_password => 'wrong_password') |
| 75 | + stub_const('ENV', ENV.to_hash.merge('BITSHARES_ACCOUNT' => nil)) |
| 76 | + stub_const('ENV', ENV.to_hash.merge('BITSHARES_PASSWORD' => nil)) |
| 77 | + Bitshares::Client.init |
| 78 | + expect(->{client.get_info}).to raise_error Bitshares::Client::Err, 'Bad credentials' |
| 79 | + end |
| 80 | + |
| 81 | + it 'with valid credentials and invalid client command raises Bitshares::Client::Err' do |
| 82 | + stub_const('ENV', ENV.to_hash.merge('BITSHARES_ACCOUNT' => nil)) |
| 83 | + stub_const('ENV', ENV.to_hash.merge('BITSHARES_PASSWORD' => nil)) |
| 84 | + Bitshares::Client.init |
| 85 | + expect(->{client.not_a_cmd}).to raise_error Bitshares::Client::Err |
| 86 | + end |
| 87 | + |
| 88 | + it 'with valid credentials and valid client command returns a Hash of returned JSON data' do |
| 89 | + stub_const('ENV', ENV.to_hash.merge('BITSHARES_ACCOUNT' => nil)) |
| 90 | + stub_const('ENV', ENV.to_hash.merge('BITSHARES_PASSWORD' => nil)) |
| 91 | + Bitshares::Client.init |
| 92 | + expect(client.get_info.class).to eq Hash |
| 93 | + end |
| 94 | + |
54 | 95 | end |
55 | 96 | end |
56 | 97 |
|
|
0 commit comments