| 38 | | assert_equal %w(app1.capistrano.test app2.capistrano.test), @config.roles[:app].map { |s| s.host } |
|---|
| | 50 | assert_role_equals %w(app1.capistrano.test app2.capistrano.test) |
|---|
| | 51 | end |
|---|
| | 52 | |
|---|
| | 53 | def test_role_with_block_and_strings_should_add_both_to_roles_collection |
|---|
| | 54 | @config.role :app, 'app1.capistrano.test' do |
|---|
| | 55 | 'app2.capistrano.test' |
|---|
| | 56 | end |
|---|
| | 57 | assert_role_equals %w(app1.capistrano.test app2.capistrano.test) |
|---|
| | 58 | end |
|---|
| | 59 | |
|---|
| | 60 | def test_role_block_returning_array_should_add_each_to_roles_collection |
|---|
| | 61 | @config.role :app do |
|---|
| | 62 | ['app1.capistrano.test', 'app2.capistrano.test'] |
|---|
| | 63 | end |
|---|
| | 64 | assert_role_equals %w(app1.capistrano.test app2.capistrano.test) |
|---|
| | 73 | |
|---|
| | 74 | def test_role_with_options_should_apply_options_to_block_results |
|---|
| | 75 | @config.role :app, :extra => :value do |
|---|
| | 76 | ['app1.capistrano.test', 'app2.capistrano.test'] |
|---|
| | 77 | end |
|---|
| | 78 | @config.roles[:app].each do |server| |
|---|
| | 79 | assert_equal({:extra => :value}, server.options) |
|---|
| | 80 | end |
|---|
| | 81 | end |
|---|
| | 82 | |
|---|
| | 83 | def test_options_should_apply_only_to_this_argument_set |
|---|
| | 84 | @config.role :app, 'app1.capistrano.test', 'app2.capistrano.test' do |
|---|
| | 85 | ['app3.capistrano.test', 'app4.capistrano.test'] |
|---|
| | 86 | end |
|---|
| | 87 | @config.role :app, 'app5.capistrano.test', 'app6.capistrano.test', :extra => :value do |
|---|
| | 88 | ['app7.capistrano.test', 'app8.capistrano.test'] |
|---|
| | 89 | end |
|---|
| | 90 | @config.role :app, 'app9.capistrano.test' |
|---|
| | 91 | |
|---|
| | 92 | option_hosts = ['app5.capistrano.test', 'app6.capistrano.test', 'app7.capistrano.test', 'app8.capistrano.test'] |
|---|
| | 93 | @config.roles[:app].each do |server| |
|---|
| | 94 | if (option_hosts.include? server.host) |
|---|
| | 95 | assert_equal({:extra => :value}, server.options) |
|---|
| | 96 | else |
|---|
| | 97 | assert_not_equal({:extra => :value}, server.options) |
|---|
| | 98 | end |
|---|
| | 99 | end |
|---|
| | 100 | end |
|---|
| | 101 | |
|---|
| | 102 | # Here, the source should be more readable than the method name |
|---|
| | 103 | def test_role_block_returns_options_hash_is_merged_with_role_options_argument |
|---|
| | 104 | @config.role :app, :first => :one, :second => :two do |
|---|
| | 105 | ['app1.capistrano.test', 'app2.capistrano.test', {:second => :please, :third => :three}] |
|---|
| | 106 | end |
|---|
| | 107 | @config.roles[:app].each do |server| |
|---|
| | 108 | assert_equal({:first => :one, :second => :please, :third => :three}, server.options) |
|---|
| | 109 | end |
|---|
| | 110 | end |
|---|
| | 111 | |
|---|
| | 112 | def test_role_block_can_override_role_options_argument |
|---|
| | 113 | @config.role :app, :value => :wrong do |
|---|
| | 114 | Capistrano::ServerDefinition.new('app.capistrano.test') |
|---|
| | 115 | end |
|---|
| | 116 | @config.roles[:app].servers |
|---|
| | 117 | @config.roles[:app].servers.each do |server| |
|---|
| | 118 | assert_not_equal({:value => :wrong}, server.options) |
|---|
| | 119 | end |
|---|
| | 120 | end |
|---|
| | 121 | |
|---|
| | 122 | def test_role_block_can_return_nil |
|---|
| | 123 | @config.role :app do |
|---|
| | 124 | nil |
|---|
| | 125 | end |
|---|
| | 126 | assert_role_equals ([]) |
|---|
| | 127 | end |
|---|
| | 128 | |
|---|
| | 129 | def test_role_block_can_return_empty_array |
|---|
| | 130 | @config.role :app do |
|---|
| | 131 | [] |
|---|
| | 132 | end |
|---|
| | 133 | assert_role_equals ([]) |
|---|
| | 134 | end |
|---|