Permalink
Browse files

update rspec tests: move DB to pg b/c of sqlite locking error, use po…

…ltergeist, added more tests, cleanup unused gems
  • Loading branch information...
1 parent aa8b315 commit 1b1abe1c980a1781945be7178a93506360a1d7e5 @kagemusha committed Sep 6, 2013
Showing with 61 additions and 79 deletions.
  1. +2 −5 Gemfile
  2. +0 −11 Gemfile.lock
  3. +9 −13 config/database.yml
  4. +1 −5 config/environments/test.rb
  5. +5 −5 db/schema.rb
  6. +5 −0 db/structure.sql
  7. +33 −20 spec/features/authentication_spec.rb
  8. +6 −20 spec/spec_helper.rb
View
@@ -23,11 +23,11 @@ group :production do
end
group :test, :development do
- gem 'sqlite3'
+ gem 'pg'
gem "rspec-rails", ">= 2.12.2"
gem "factory_girl_rails", ">= 4.2.0"
gem 'konacha'
- gem 'poltergeist' #replace capy-webkit
+ gem 'poltergeist'
end
group :development do
@@ -41,9 +41,6 @@ end
group :test do
gem "capybara", ">= 2.0.2"
-# gem "capybara-webkit"
- gem "database_cleaner", ">= 0.9.1"
- gem "email_spec", ">= 1.4.0"
gem 'capybara-screenshot'
end
View
@@ -27,7 +27,6 @@ GEM
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
- addressable (2.3.5)
arel (4.0.0)
atomic (1.1.13)
barber (0.4.2)
@@ -61,17 +60,13 @@ GEM
execjs
coffee-script-source (1.6.3)
colorize (0.5.8)
- database_cleaner (1.1.1)
debug_inspector (0.0.2)
devise (3.0.3)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
warden (~> 1.2.3)
diff-lcs (1.2.4)
- email_spec (1.5.0)
- launchy (~> 2.1)
- mail (~> 2.2)
ember-data-source (0.13)
ember-source
ember-rails (0.13.0)
@@ -115,8 +110,6 @@ GEM
colorize
railties (>= 3.1, < 5)
sprockets
- launchy (2.3.0)
- addressable (~> 2.3)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
@@ -181,7 +174,6 @@ GEM
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
- sqlite3 (1.3.8)
thor (0.18.1)
thread_safe (0.1.2)
atomic
@@ -210,9 +202,7 @@ DEPENDENCIES
capybara (>= 2.0.2)
capybara-screenshot
coffee-rails (~> 4.0.0)
- database_cleaner (>= 0.9.1)
devise
- email_spec (>= 1.4.0)
ember-rails
factory_girl_rails (>= 4.2.0)
haml (>= 3.1.7)
@@ -228,5 +218,4 @@ DEPENDENCIES
rspec-rails (>= 2.12.2)
ruby_parser (>= 3.1.1)
sass-rails (~> 4.0.0)
- sqlite3
uglifier (>= 1.3.0)
View
@@ -1,19 +1,15 @@
development:
- adapter: sqlite3
- database: db/development.sqlite3
- pool: 5
- timeout: 5000
+ adapter: postgresql
+ database: ember_rails_devise_dev
test:
- adapter: sqlite3
- database: db/test.sqlite3
- pool: 5
- timeout: 5000
+ adapter: postgresql
+ database: ember_rails_devise_test
#dummy to get assets:precompile to work
#see http://devcenter.heroku.com/articles/rails31_heroku_cedar
-production:
- adapter: postgresql
- database: crambear_production
- username: postgres
- password: pwwwwww23
+#production:
+# adapter: postgresql
+# database: crambear_production
+# username: postgres
+# password: pwwwwww23
@@ -7,12 +7,11 @@
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
+ config.eager_load = false
# Configure static asset server for tests with Cache-Control for performance
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"
- # Log error messages when you accidentally call methods on nil
- config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
@@ -29,9 +28,6 @@
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
- # Raise exception on mass assignment protection for Active Record models
- config.active_record.mass_assignment_sanitizer = :strict
-
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr
View
@@ -21,8 +21,8 @@
t.datetime "updated_at"
end
- add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"
- add_index "roles", ["name"], name: "index_roles_on_name"
+ add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id", using: :btree
+ add_index "roles", ["name"], name: "index_roles_on_name", using: :btree
create_table "users", force: true do |t|
t.string "email", default: "", null: false
@@ -40,14 +40,14 @@
t.string "name"
end
- add_index "users", ["email"], name: "index_users_on_email", unique: true
- add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
+ add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
+ add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
create_table "users_roles", id: false, force: true do |t|
t.integer "user_id"
t.integer "role_id"
end
- add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id"
+ add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id", using: :btree
end
View
@@ -0,0 +1,5 @@
+INSERT INTO schema_migrations (version) VALUES ('20130203231007');
+
+INSERT INTO schema_migrations (version) VALUES ('20130203231012');
+
+INSERT INTO schema_migrations (version) VALUES ('20130203231022');
@@ -3,45 +3,58 @@
feature "AUTHENTICATION", :js => true do
let(:user_name) { "Tester"}
- let(:email) {"test@test.com"}
+ let(:email) {"test1@test.com"}
let(:pw) {"tester"}
let(:register_fields) { {name: user_name, email: email, password: pw, password_confirmation: pw} }
+ let(:fail_msg) { "That email/password combo didn't work" }
+ before(:all) do
+ User.destroy_all
+ end
- scenario 'register,logout,login with valid email and password', :driver => :webkit do
+ scenario 'register,logout,login with valid email and password' do
+ User.destroy_all
visit "/#/registration"
submit_form register_fields, "Register"
page.should have_content "Hi #{user_name}"
page.should have_content "Logout"
click_button "Logout"
page.should have_content "Login"
visit "/#/login"
- submit_form({email: email, password: pw}, "Login")
+ login email, pw
page.should have_content "Hi #{user_name}"
end
- #this is failing even though works in above test
- #user seems to be created, screenshot (see submit_form) seems ok
- #so not sure what's amiss
- scenario 'login with valid credentials', :driver => :webkit do
- User.create! register_fields
+ scenario 'login with valid credentials' do
+ #User.create! register_fields
User.first.email.should == email
visit "/#/login"
- submit_form({email: email, password: pw}, "Login")
+ login email, pw
page.should have_content "Hi #{user_name}"
end
- #scenario 'with invalid email' do
- # sign_up_with 'invalid_email', 'password'
- #
- # expect(page).to have_content('Sign in')
- #end
- #
- #scenario 'with blank password' do
- # sign_up_with 'valid@example.com', ''
- #
- # expect(page).to have_content('Sign in')
- #end
+ scenario 'register with invalid email and password' do
+ visit "/#/registration"
+ register_fields[:email] = "xxeeegmail.com"
+ submit_form register_fields, "Register"
+ page.should have_content fail_msg
+ end
+
+ scenario 'login with invalid email or password' do
+ visit "/#/login"
+ login "guma@bearz.com", pw
+ page.should have_content fail_msg
+ login email, "happyburz"
+ page.should have_content fail_msg
+ end
+
+ after(:all) do
+ User.destroy_all
+ end
+
+ def login(email, pw)
+ submit_form({email: email, password: pw}, "Login")
+ end
def submit_form(fields, button)
fields.each_pair do |field, val|
fill_in field, with: val
View
@@ -2,26 +2,19 @@
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
-require 'email_spec'
require 'rspec/autorun'
require 'capybara/rails'
require 'capybara/rspec'
require 'capybara-screenshot/rspec'
+require 'capybara/poltergeist'
+
# 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|
- config.include(EmailSpec::Helpers)
- config.include(EmailSpec::Matchers)
- # ## 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"
@@ -35,22 +28,15 @@
# 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"
+ #config.order = "random"
config.before(:suite) do
- DatabaseCleaner.strategy = :truncation
- #Capybara.javascript_driver = :webkit
- #p "Example metadata: #{example.metadata[:type]}"
- end
- config.before(:each) do
- DatabaseCleaner.start
- end
- config.after(:each) do
- DatabaseCleaner.clean
+ Capybara.javascript_driver = :poltergeist
end
end

0 comments on commit 1b1abe1

Please sign in to comment.