From 44bbaee60228e46bd11bb398ade55f63ddb5c541 Mon Sep 17 00:00:00 2001 From: miya0001 Date: Tue, 13 Oct 2015 23:48:00 +0900 Subject: [PATCH] add editorconfig and update tests --- Gemfile.lock | 41 +++++++++++-------- .../site-cookbooks/wpcli/recipes/install.rb | 8 ++++ .../wpcli/templates/default/editorconfig.erb | 21 ++++++++++ spec/default/wp-cli_spec.rb | 6 +++ spec/spec_helper.rb | 4 +- 5 files changed, 60 insertions(+), 20 deletions(-) create mode 100644 provision/site-cookbooks/wpcli/templates/default/editorconfig.erb diff --git a/Gemfile.lock b/Gemfile.lock index 675b15d..2483cdc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,34 +2,39 @@ GEM remote: https://rubygems.org/ specs: diff-lcs (1.2.5) - multi_json (1.10.1) + multi_json (1.11.2) net-scp (1.2.1) net-ssh (>= 2.6.5) net-ssh (2.9.2) + net-telnet (0.1.1) rake (10.4.2) - rspec (3.1.0) - rspec-core (~> 3.1.0) - rspec-expectations (~> 3.1.0) - rspec-mocks (~> 3.1.0) - rspec-core (3.1.7) - rspec-support (~> 3.1.0) - rspec-expectations (3.1.2) + rspec (3.3.0) + rspec-core (~> 3.3.0) + rspec-expectations (~> 3.3.0) + rspec-mocks (~> 3.3.0) + rspec-core (3.3.2) + rspec-support (~> 3.3.0) + rspec-expectations (3.3.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.1.0) - rspec-its (1.1.0) + rspec-support (~> 3.3.0) + rspec-its (1.2.0) rspec-core (>= 3.0.0) rspec-expectations (>= 3.0.0) - rspec-mocks (3.1.3) - rspec-support (~> 3.1.0) - rspec-support (3.1.2) - serverspec (2.7.2) + rspec-mocks (3.3.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.3.0) + rspec-support (3.3.0) + serverspec (2.24.1) multi_json rspec (~> 3.0) rspec-its - specinfra (~> 2.10) - specinfra (2.11.8) + specinfra (~> 2.43) + sfl (2.2) + specinfra (2.44.0) net-scp - net-ssh + net-ssh (~> 2.7) + net-telnet + sfl PLATFORMS ruby @@ -39,4 +44,4 @@ DEPENDENCIES serverspec BUNDLED WITH - 1.10.3 + 1.10.6 diff --git a/provision/site-cookbooks/wpcli/recipes/install.rb b/provision/site-cookbooks/wpcli/recipes/install.rb index 49f9b96..8b92a4c 100644 --- a/provision/site-cookbooks/wpcli/recipes/install.rb +++ b/provision/site-cookbooks/wpcli/recipes/install.rb @@ -276,3 +276,11 @@ EOH notifies :restart, "service[apache2]" end + +template File.join( node[:wpcli][:wp_docroot], ".editorconfig" ) do + source "editorconfig.erb" + owner node[:wpcli][:user] + group node[:wpcli][:group] + mode "0644" + action :create_if_missing +end diff --git a/provision/site-cookbooks/wpcli/templates/default/editorconfig.erb b/provision/site-cookbooks/wpcli/templates/default/editorconfig.erb new file mode 100644 index 0000000..e1cc194 --- /dev/null +++ b/provision/site-cookbooks/wpcli/templates/default/editorconfig.erb @@ -0,0 +1,21 @@ +# This file is for unifying the coding style for different editors and IDEs +# editorconfig.org + +# WordPress Coding Standards +# https://make.wordpress.org/core/handbook/coding-standards/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = tab + +[{.jshintrc,*.json,*.yml}] +indent_style = space +indent_size = 2 + +[{*.txt,wp-config-sample.php}] +end_of_line = crlf diff --git a/spec/default/wp-cli_spec.rb b/spec/default/wp-cli_spec.rb index 5ed77c8..b20c146 100644 --- a/spec/default/wp-cli_spec.rb +++ b/spec/default/wp-cli_spec.rb @@ -120,3 +120,9 @@ it { should be_file } it { should be_owned_by $conf['user'] } end + +describe file(File.join($conf['document_root'], '.editorconfig')) do + let(:disable_sudo) { true } + it { should be_file } + it { should be_owned_by $conf['user'] } +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0114a13..98c6e8c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -35,9 +35,9 @@ host = $conf['hostname'] config = Tempfile.new('', Dir.tmpdir) -`vagrant ssh-config #{host} > #{config.path}` +`unset RUBYLIB; vagrant ssh-config #{host} > #{config.path}` options = Net::SSH::Config.for(host, [config.path]) - +puts options.to_s set :host, host set :ssh_options, options