spec/lib/ec2ssh/dsl_spec.rb in ec2ssh-3.1.1 vs spec/lib/ec2ssh/dsl_spec.rb in ec2ssh-4.0.0
- old
+ new
@@ -25,41 +25,39 @@
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' }
+ 'key1' => { 'ap-northeast-1' => Aws::Credentials.new('ACCESS_KEY1', 'SECRET1') },
+ 'key2' => { 'us-east-1' => Aws::Credentials.new('ACCESS_KEY2', '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' }
- }
+ it do
+ expect(result.aws_keys).to match(
+ 'key1' => { 'ap-northeast-1' => be_a(Aws::Credentials).and(have_attributes(access_key_id: 'ACCESS_KEY1', secret_access_key: 'SECRET1')) } ,
+ 'key2' => { 'us-east-1' => be_a(Aws::Credentials).and(have_attributes(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
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' }
+ 'key1' => { 'ap-northeast-1' => Aws::Credentials.new('ACCESS_KEY1', 'SECRET1') },
+ 'key2' => { 'us-east-1' => Aws::Credentials.new('ACCESS_KEY2', 'SECRET2') }
)
profiles 'default', 'myprofile'
regions 'ap-northeast-1', 'us-east-1'
host_line 'host lines'
reject {|instance| instance }
@@ -67,8 +65,43 @@
END
end
it do
expect { Ec2ssh::Dsl::Parser.parse dsl_str }.to raise_error Ec2ssh::DotfileValidationError
+ end
+ end
+
+ context 'with old structure 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
+
+ it { expect { Ec2ssh::Dsl::Parser.parse dsl_str }.to raise_error Ec2ssh::DotfileValidationError }
+ end
+
+ context 'with filters' do
+ let(:dsl_str) do
+<<-END
+regions 'ap-northeast-1', 'us-east-1'
+filters [{
+ name: 'instance-state-name',
+ values: ['running', 'stopped']
+}]
+END
+ end
+
+ subject(:result) { Ec2ssh::Dsl::Parser.parse dsl_str }
+
+ it do
+ expect(result.filters).to eq([{name:'instance-state-name', values:['running', 'stopped']}])
end
end
end