From 2f94c0aa38aa291acfb72652df42814f70bff728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andres=20Keskk=C3=BCla?= Date: Wed, 27 Aug 2014 13:46:18 +0300 Subject: [PATCH 1/3] Introduced guard --- Gemfile | 5 +++++ Gemfile.lock | 44 ++++++++++++++++++++++++++++++++++++++++++++ Guardfile | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 Guardfile diff --git a/Gemfile b/Gemfile index 975b962fb..83d54f438 100644 --- a/Gemfile +++ b/Gemfile @@ -57,6 +57,11 @@ group :development do # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', '~> 0.4.0' + + gem 'guard', '~> 2.6.1' + + gem 'guard-rspec', '~> 4.3.1' + gem 'guard-rubocop', '~> 1.1.0' end group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 876fcd7cb..d24fe77af 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,6 +28,7 @@ GEM thread_safe (~> 0.1) tzinfo (~> 1.1) arel (5.0.1.20140414130214) + ast (2.0.0) bootstrap-sass (3.2.0.1) sass (~> 3.2) builder (3.2.2) @@ -40,6 +41,8 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) + celluloid (0.15.2) + timers (~> 1.1.0) cliver (0.3.2) coderay (1.1.0) coffee-rails (4.0.1) @@ -61,6 +64,20 @@ GEM fabrication (2.11.3) faker (1.3.0) i18n (~> 0.5) + ffi (1.9.3) + formatador (0.2.5) + guard (2.6.1) + formatador (>= 0.2.4) + listen (~> 2.7) + lumberjack (~> 1.0) + pry (>= 0.9.12) + thor (>= 0.18.1) + guard-rspec (4.3.1) + guard (~> 2.1) + rspec (>= 2.14, < 4.0) + guard-rubocop (1.1.0) + guard (~> 2.0) + rubocop (~> 0.20) haml (4.0.5) tilt haml-rails (0.5.3) @@ -82,6 +99,11 @@ GEM kgio (2.9.2) libv8 (3.16.14.3) libxml-ruby (2.7.0) + listen (2.7.9) + celluloid (>= 0.15.2) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) + lumberjack (1.0.9) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) @@ -92,6 +114,9 @@ GEM multi_json (1.10.1) nokogiri (1.6.2.1) mini_portile (= 0.6.0) + parser (2.2.0.pre.4) + ast (>= 1.1, < 3.0) + slop (~> 3.4, >= 3.4.5) pg (0.17.1) phantomjs (1.9.7.1) poltergeist (1.5.1) @@ -100,6 +125,7 @@ GEM multi_json (~> 1.0) websocket-driver (>= 0.2.0) polyglot (0.3.5) + powerpack (0.0.9) pry (0.10.1) coderay (~> 1.1.0) method_source (~> 0.8.1) @@ -125,11 +151,19 @@ GEM activesupport (= 4.1.4) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) + rainbow (2.0.0) raindrops (0.13.0) rake (10.3.2) + rb-fsevent (0.9.4) + rb-inotify (0.9.5) + ffi (>= 0.5.0) rdoc (4.1.1) json (~> 1.4) ref (1.0.5) + rspec (3.0.0) + rspec-core (~> 3.0.0) + rspec-expectations (~> 3.0.0) + rspec-mocks (~> 3.0.0) rspec-core (3.0.4) rspec-support (~> 3.0.0) rspec-expectations (3.0.4) @@ -146,6 +180,12 @@ GEM rspec-mocks (~> 3.0.0) rspec-support (~> 3.0.0) rspec-support (3.0.4) + rubocop (0.25.0) + parser (>= 2.2.0.pre.4, < 3.0) + powerpack (~> 0.0.6) + rainbow (>= 1.99.1, < 3.0) + ruby-progressbar (~> 1.4) + ruby-progressbar (1.5.1) sass (3.2.19) sass-rails (4.0.3) railties (>= 4.0.0, < 5.0) @@ -175,6 +215,7 @@ GEM thor (0.19.1) thread_safe (0.3.4) tilt (1.4.1) + timers (1.1.0) treetop (1.4.15) polyglot polyglot (>= 0.3.1) @@ -205,6 +246,9 @@ DEPENDENCIES epp (~> 1.4.0) fabrication (~> 2.11.3) faker (~> 1.3.0) + guard (~> 2.6.1) + guard-rspec (~> 4.3.1) + guard-rubocop (~> 1.1.0) haml-rails (~> 0.5.3) isikukood jbuilder (~> 2.0) diff --git a/Guardfile b/Guardfile new file mode 100644 index 000000000..a3419fe1e --- /dev/null +++ b/Guardfile @@ -0,0 +1,43 @@ +# A sample Guardfile +# More info at https://github.com/guard/guard#readme + +# Note: The cmd option is now required due to the increasing number of ways +# rspec may be run, below are examples of the most common uses. +# * bundler: 'bundle exec rspec' +# * bundler binstubs: 'bin/rspec' +# * spring: 'bin/rsspec' (This will use spring if running and you have +# installed the spring binstubs per the docs) +# * zeus: 'zeus rspec' (requires the server to be started separetly) +# * 'just' rspec: 'rspec' +group :red_green_refactor, halt_on_fail:true do + guard :rspec, cmd: 'bundle exec rspec' do + watch(%r{^spec/.+_spec\.rb$}) + watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } + watch('spec/spec_helper.rb') { "spec" } + + # Rails example + watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } + watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } + watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } + watch(%r{^spec/support/(.+)\.rb$}) { "spec" } + watch('config/routes.rb') { "spec/routing" } + watch('app/controllers/application_controller.rb') { "spec/controllers" } + watch('spec/rails_helper.rb') { "spec" } + + # epp tests + watch('app/helpers/epp/contacts_helper.rb') { 'spec/epp/contact_spec.rb' } + watch('app/helpers/epp/domains_helper.rb') { 'spec/epp/domain_spec.rb' } + # Capybara features specs + watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" } + + # Turnip features and steps + watch(%r{^spec/acceptance/(.+)\.feature$}) + watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } + end + + # Disabled rubocop in guard until old offenses are removed to reduce visual clutter + # guard :rubocop do + # watch(%r{.+\.rb$}) + # watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) } + # end +end From e7919e364478bc8d32f513b966cbbb7aa596589d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andres=20Keskk=C3=BCla?= Date: Wed, 27 Aug 2014 14:16:43 +0300 Subject: [PATCH 2/3] Fixed contact not saving password on create --- app/models/contact.rb | 2 +- spec/models/contact_spec.rb | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index 79ca7c971..e0d808c1b 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -124,7 +124,7 @@ class Contact < ActiveRecord::Base } contact_hash[:code] = ph[:id] if type == :create - + contact_hash[:auth_info] = ph[:authInfo][:pw] if type == :create contact_hash.delete_if { |_k, v| v.nil? } end diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index c264ce78e..944b8811d 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -87,10 +87,12 @@ end describe Contact, '.extract_params' do it 'returns params hash'do - ph = { id: '123123', email: 'jdoe@example.com', postalInfo: { name: 'fred', addr: { cc: 'EE' } } } + ph = { id: '123123', email: 'jdoe@example.com', authInfo: { pw: 'asde' }, + postalInfo: { name: 'fred', addr: { cc: 'EE' } } } expect(Contact.extract_attributes(ph)).to eq({ code: '123123', - email: 'jdoe@example.com' + email: 'jdoe@example.com', + auth_info: 'asde' }) end end From 055daf90b892ebfe44317d911a80a99ebe70eefb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andres=20Keskk=C3=BCla?= Date: Wed, 27 Aug 2014 15:13:43 +0300 Subject: [PATCH 3/3] Removed unnecessary documentation --- Gemfile | 3 +++ Guardfile | 11 ----------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/Gemfile b/Gemfile index 83d54f438..bcb6e495b 100644 --- a/Gemfile +++ b/Gemfile @@ -58,9 +58,12 @@ group :development do # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', '~> 0.4.0' + # run tests automatically gem 'guard', '~> 2.6.1' + # rspec support for guard gem 'guard-rspec', '~> 4.3.1' + # rubocop support for guard gem 'guard-rubocop', '~> 1.1.0' end diff --git a/Guardfile b/Guardfile index a3419fe1e..065ffb602 100644 --- a/Guardfile +++ b/Guardfile @@ -1,14 +1,3 @@ -# A sample Guardfile -# More info at https://github.com/guard/guard#readme - -# Note: The cmd option is now required due to the increasing number of ways -# rspec may be run, below are examples of the most common uses. -# * bundler: 'bundle exec rspec' -# * bundler binstubs: 'bin/rspec' -# * spring: 'bin/rsspec' (This will use spring if running and you have -# installed the spring binstubs per the docs) -# * zeus: 'zeus rspec' (requires the server to be started separetly) -# * 'just' rspec: 'rspec' group :red_green_refactor, halt_on_fail:true do guard :rspec, cmd: 'bundle exec rspec' do watch(%r{^spec/.+_spec\.rb$})