spec/lib/ec2ssh/dsl_spec.rb in ec2ssh-3.0.3 vs spec/lib/ec2ssh/dsl_spec.rb in ec2ssh-3.1.0.rc1

- old
+ new

@@ -1,30 +1,74 @@ require 'spec_helper' require 'ec2ssh/dsl' describe Ec2ssh::Dsl do - let(:dsl_str) do + context 'with profiles' do + let(:dsl_str) do <<-END +profiles 'default', 'myprofile' +regions 'ap-northeast-1', 'us-east-1' +host_line 'host lines' +reject {|instance| instance } +path 'path' +END + end + + subject(:result) { Ec2ssh::Dsl::Parser.parse dsl_str } + + its(:profiles) { should == ['default', 'myprofile'] } + its(:aws_keys) { should be_nil } + its(:regions) { should == ['ap-northeast-1', 'us-east-1'] } + its(:host_line) { should == 'host lines' } + it { expect(result.reject.call(123)).to eq(123) } + its(:path) { should == 'path' } + end + + context 'with aws_keys' do + let(:dsl_str) do +<<-END aws_keys( key1: { access_key_id: 'ACCESS_KEY1', secret_access_key: 'SECRET1' }, key2: { access_key_id: 'ACCESS_KEY2', secret_access_key: 'SECRET2' } ) regions 'ap-northeast-1', 'us-east-1' host_line 'host lines' reject {|instance| instance } path 'path' END + end + + subject(:result) { Ec2ssh::Dsl::Parser.parse dsl_str } + + its(:profiles) { should be_nil } + its(:aws_keys) do + should == { + key1: { access_key_id: 'ACCESS_KEY1', secret_access_key: 'SECRET1' }, + key2: { access_key_id: 'ACCESS_KEY2', secret_access_key: 'SECRET2' } + } + end + its(:regions) { should == ['ap-northeast-1', 'us-east-1'] } + its(:host_line) { should == 'host lines' } + it { expect(result.reject.call(123)).to eq(123) } + its(:path) { should == 'path' } end - subject(:result) { Ec2ssh::Dsl::Parser.parse dsl_str } + context 'with profiles and aws_keys both' do + let(:dsl_str) do +<<-END +aws_keys( + key1: { access_key_id: 'ACCESS_KEY1', secret_access_key: 'SECRET1' }, + key2: { access_key_id: 'ACCESS_KEY2', secret_access_key: 'SECRET2' } +) +profiles 'default', 'myprofile' +regions 'ap-northeast-1', 'us-east-1' +host_line 'host lines' +reject {|instance| instance } +path 'path' +END + end - its(:aws_keys) do - should == { - key1: { access_key_id: 'ACCESS_KEY1', secret_access_key: 'SECRET1' }, - key2: { access_key_id: 'ACCESS_KEY2', secret_access_key: 'SECRET2' } - } + it do + expect { Ec2ssh::Dsl::Parser.parse dsl_str }.to raise_error Ec2ssh::DotfileValidationError + end end - its(:regions) { should == ['ap-northeast-1', 'us-east-1'] } - its(:host_line) { should == 'host lines' } - it { expect(result.reject.call(123)).to eq(123) } - its(:path) { should == 'path' } end