From 92f1797dfbfcfc4aed1973425771647ce2481c0f Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Fri, 26 Jul 2013 00:41:21 +0200 Subject: [PATCH] rspec install Install Rspec FacoryGirl --- .gitignore | 1 + .rspec | 1 + Gemfile | 6 ++++- Gemfile.lock | 19 ++++++++++++++++ db/schema.rb | 10 -------- spec/factories/studien.rb | 12 ++++++++++ spec/factories/studium_factory.rb | 1 + spec/models/studium_spec.rb | 9 ++++++++ spec/spec_helper.rb | 38 +++++++++++++++++++++++++++++++ 9 files changed, 86 insertions(+), 11 deletions(-) create mode 100644 .rspec create mode 100644 spec/factories/studien.rb create mode 100644 spec/factories/studium_factory.rb create mode 100644 spec/models/studium_spec.rb create mode 100644 spec/spec_helper.rb diff --git a/.gitignore b/.gitignore index f66e129..2c9abc6 100755 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ /log/*.log /tmp /config/initializers/devise.rb +/app/doc/* diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..4e1e0d2 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--color diff --git a/Gemfile b/Gemfile index 3fb298c..7fce64e 100755 --- a/Gemfile +++ b/Gemfile @@ -70,4 +70,8 @@ gem 'haml' #gem 'gollum' gem 'awesome_nested_set' gem 'annotate', ">=2.5.0" -gem 'carrierwave' \ No newline at end of file +gem 'carrierwave' +group :development, :test do +gem 'factory_girl_rails' +gem 'rspec-rails' +end diff --git a/Gemfile.lock b/Gemfile.lock index 9508763..2f98cfb 100755 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -56,9 +56,15 @@ GEM orm_adapter (~> 0.1) railties (~> 3.1) warden (~> 1.2.1) + diff-lcs (1.2.4) erubis (2.7.0) execjs (1.4.0) multi_json (~> 1.0) + factory_girl (4.2.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.2.1) + factory_girl (~> 4.2.0) + railties (>= 3.0.0) formtastic (2.2.1) actionpack (>= 3.0) formtastic-bootstrap (2.0.0) @@ -123,6 +129,17 @@ GEM json (~> 1.4) ref (1.0.2) rolify (3.2.0) + rspec-core (2.14.4) + rspec-expectations (2.14.0) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.14.1) + rspec-rails (2.14.0) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 2.14.0) + rspec-expectations (~> 2.14.0) + rspec-mocks (~> 2.14.0) sass (3.2.5) sass-rails (3.2.6) railties (~> 3.2.0) @@ -165,6 +182,7 @@ DEPENDENCIES coffee-rails (~> 3.2.1) devise (~> 2.2.3) execjs (~> 1.4.0) + factory_girl_rails formtastic (~> 2.2.1) formtastic-bootstrap git @@ -175,6 +193,7 @@ DEPENDENCIES paperclip (~> 3.4.0) rails (= 3.2.9) rolify + rspec-rails sass-rails (~> 3.2.3) sqlite3 therubyracer diff --git a/db/schema.rb b/db/schema.rb index e41f87b..c642d5b 100755 --- a/db/schema.rb +++ b/db/schema.rb @@ -13,16 +13,6 @@ ActiveRecord::Schema.define(:version => 20130214233723) do - create_table "beispiel_translations", :force => true do |t| - t.string "locale" - t.text "desc" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "beispiele_id" - end - - add_index "beispiel_translations", ["locale"], :name => "index_beispiel_translations_on_locale" - create_table "beispiele", :force => true do |t| t.string "name" t.text "desc" diff --git a/spec/factories/studien.rb b/spec/factories/studien.rb new file mode 100644 index 0000000..4608747 --- /dev/null +++ b/spec/factories/studien.rb @@ -0,0 +1,12 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + + +FactoryGirl.define do + factory :studium do + zahl "066 506" + name "Automatisierung" + desc "TEST DESC" + typ "Master" + end + +end diff --git a/spec/factories/studium_factory.rb b/spec/factories/studium_factory.rb new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/spec/factories/studium_factory.rb @@ -0,0 +1 @@ + diff --git a/spec/models/studium_spec.rb b/spec/models/studium_spec.rb new file mode 100644 index 0000000..1e34d74 --- /dev/null +++ b/spec/models/studium_spec.rb @@ -0,0 +1,9 @@ +require 'spec_helper' + +describe Studium do + it "should not be valid without name" do + s = FactoryGirl.build(:studium, :name=>nil) + s.should_not be_valid + + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..d2cbea7 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,38 @@ +# 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 'rspec/autorun' + +# 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 + + # 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 + + # If true, the base class of anonymous controllers will be inferred + # automatically. This will be the default behavior in future versions of + # rspec-rails. + config.infer_base_class_for_anonymous_controllers = false + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = "random" +end