From 6be72755a1362db604e0e81bb6297f3f43c2098e Mon Sep 17 00:00:00 2001 From: Novikov Andrey Date: Thu, 13 Dec 2012 16:53:45 +1000 Subject: [PATCH] Installed tools for testing * RSpec * FactoryGirl * Capybara --- .rspec | 2 ++ Gemfile | 7 +++++++ Gemfile.lock | 41 ++++++++++++++++++++++++++++++++++++++++- spec/factories/.gitkeep | 0 spec/spec_helper.rb | 34 ++++++++++++++++++++++++++++++++++ test/test_helper.rb | 12 +++++++----- 6 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 .rspec create mode 100644 spec/factories/.gitkeep create mode 100644 spec/spec_helper.rb diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..7438fbe --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--colour +--format documentation diff --git a/Gemfile b/Gemfile index e46bfdc..bef4f6a 100644 --- a/Gemfile +++ b/Gemfile @@ -47,3 +47,10 @@ group :development do gem "rvm-capistrano" gem 'ruby-debug' end + +gem 'rspec-rails', :group => [:development, :test] + +group :test do + gem 'factory_girl_rails' + gem 'capybara' +end diff --git a/Gemfile.lock b/Gemfile.lock index 8fa0e30..bfd95fd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -49,6 +49,15 @@ GEM net-sftp (>= 2.0.0) net-ssh (>= 2.0.14) net-ssh-gateway (>= 1.1.0) + capybara (1.1.1) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + selenium-webdriver (~> 2.0) + xpath (~> 0.1.4) + childprocess (0.2.2) + ffi (~> 1.0.6) chronic (0.8.0) coffee-rails (3.2.2) coffee-script (>= 2.2.0) @@ -62,11 +71,17 @@ GEM bcrypt-ruby (~> 3.0) orm_adapter (~> 0.0.3) warden (~> 1.1) + diff-lcs (1.1.3) dropbox-sdk (1.2) json erubis (2.7.0) execjs (1.4.0) multi_json (~> 1.0) + factory_girl (2.1.0) + factory_girl_rails (1.2.0) + factory_girl (~> 2.1.0) + railties (>= 3.0.0) + ffi (1.0.9) haml (3.1.7) highline (1.6.15) hike (1.2.1) @@ -82,6 +97,7 @@ GEM jquery-ui-themes (0.0.8) httparty json (1.7.5) + json_pure (1.6.0) kgio (2.7.4) libv8 (3.11.8.4) linecache (0.46) @@ -137,6 +153,19 @@ GEM rails (>= 3.1.3) redcarpet (2.2.2) ref (1.0.2) + rspec (2.6.0) + rspec-core (~> 2.6.0) + rspec-expectations (~> 2.6.0) + rspec-mocks (~> 2.6.0) + rspec-core (2.6.4) + rspec-expectations (2.6.0) + diff-lcs (~> 1.1.2) + rspec-mocks (2.6.0) + rspec-rails (2.6.1) + actionpack (~> 3.0) + activesupport (~> 3.0) + railties (~> 3.0) + rspec (~> 2.6.0) ruby-debug (0.10.4) columnize (>= 0.1) ruby-debug-base (~> 0.10.4.0) @@ -154,11 +183,16 @@ GEM tilt (~> 1.3) select2-rails (3.2.1) thor (~> 0.14) - sprockets (2.2.2) + selenium-webdriver (2.6.0) + childprocess (>= 0.2.1) + ffi (>= 1.0.7) hike (~> 1.2) + json_pure multi_json (~> 1.0) rack (~> 1.0) + rubyzip tilt (~> 1.1, != 1.3.0) + sprockets (2.2.2) therubyracer (0.11.0) ref thor (0.16.0) @@ -183,6 +217,8 @@ GEM whenever (0.8.0) activesupport (>= 2.3.4) chronic (>= 0.6.3) + xpath (0.1.4) + nokogiri (~> 1.3) PLATFORMS ruby @@ -192,10 +228,12 @@ DEPENDENCIES axlsx_rails backup (~> 3.0) capistrano + capybara coffee-rails (~> 3.2.0) devise (~> 1.5.0) dropbox-sdk (~> 1.2.0) erubis + factory_girl_rails haml jquery-rails jquery-ui-themes @@ -209,6 +247,7 @@ DEPENDENCIES rails (~> 3.2.0) recordselect redcarpet + rspec-rails ruby-debug russian rvm-capistrano diff --git a/spec/factories/.gitkeep b/spec/factories/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..140a66e --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,34 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +ENV["RAILS_ENV"] ||= 'test' +require File.expand_path("../../config/environment", __FILE__) +require 'rspec/rails' +require 'capybara/rspec' + +# Requires supporting ruby files with custom matchers and macros, etc, +# in spec/support/ and its subdirectories. +Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} + +RSpec.configure do |config| + # == Mock Framework + # + # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: + # + # config.mock_with :mocha + # config.mock_with :flexmock + # config.mock_with :rr + config.mock_with :rspec + + # Use FactoryGirl without annoying FactoryGirl prefix + config.include FactoryGirl::Syntax::Methods + + # Use Devise + config.include Devise::TestHelpers, :type => :controller + + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true +end diff --git a/test/test_helper.rb b/test/test_helper.rb index 8bf1192..884d494 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,13 +1,15 @@ ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' +require 'capybara/rails' class ActiveSupport::TestCase - # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. - # - # Note: You'll currently still have to declare fixtures explicitly in integration tests - # -- they do not yet inherit this setting - fixtures :all + include FactoryGirl::Syntax::Methods # Add more helper methods to be used by all tests here... end + +class ActionController::TestCase + include Devise::TestHelpers + include FactoryGirl::Syntax::Methods +end