mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 18:39:52 +01:00
Merge branch 'master' into about-page
This commit is contained in:
commit
63cecdf23e
10 changed files with 96 additions and 14 deletions
6
Gemfile
6
Gemfile
|
@ -28,7 +28,6 @@ gem 'nprogress-rails'
|
|||
gem 'font-awesome-rails', '~> 4.2.0.0'
|
||||
|
||||
group :development do
|
||||
gem 'thin'
|
||||
gem 'spring'
|
||||
end
|
||||
|
||||
|
@ -37,10 +36,13 @@ group :production do
|
|||
end
|
||||
|
||||
group :development, :test do
|
||||
gem 'thin'
|
||||
gem 'rspec-rails', '~> 3.0.0'
|
||||
gem 'shoulda-matchers'
|
||||
gem 'factory_girl_rails'
|
||||
gem 'faker'
|
||||
gem 'capybara'
|
||||
gem 'poltergeist'
|
||||
gem 'simplecov'
|
||||
gem 'database_cleaner'
|
||||
end
|
||||
|
||||
|
|
25
Gemfile.lock
25
Gemfile.lock
|
@ -35,6 +35,13 @@ GEM
|
|||
sass (~> 3.2)
|
||||
bootstrap_form (2.2.0)
|
||||
builder (3.2.2)
|
||||
capybara (2.4.3)
|
||||
mime-types (>= 1.16)
|
||||
nokogiri (>= 1.3.3)
|
||||
rack (>= 1.0.0)
|
||||
rack-test (>= 0.5.4)
|
||||
xpath (~> 2.0)
|
||||
cliver (0.3.2)
|
||||
coffee-rails (4.1.0)
|
||||
coffee-script (>= 2.2.0)
|
||||
railties (>= 4.0.0, < 5.0)
|
||||
|
@ -43,6 +50,7 @@ GEM
|
|||
execjs
|
||||
coffee-script-source (1.8.0)
|
||||
daemons (1.1.9)
|
||||
database_cleaner (1.3.0)
|
||||
devise (3.4.1)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
|
@ -85,12 +93,20 @@ GEM
|
|||
mail (2.6.1)
|
||||
mime-types (>= 1.16, < 3)
|
||||
mime-types (2.4.3)
|
||||
mini_portile (0.6.0)
|
||||
minitest (5.4.2)
|
||||
multi_json (1.10.1)
|
||||
mysql2 (0.3.16)
|
||||
nokogiri (1.6.3.1)
|
||||
mini_portile (= 0.6.0)
|
||||
nprogress-rails (0.1.6.3)
|
||||
orm_adapter (0.5.0)
|
||||
pg (0.17.1)
|
||||
poltergeist (1.5.1)
|
||||
capybara (~> 2.1)
|
||||
cliver (~> 0.3.1)
|
||||
multi_json (~> 1.0)
|
||||
websocket-driver (>= 0.2.0)
|
||||
rack (1.5.2)
|
||||
rack-test (0.6.2)
|
||||
rack (>= 1.0)
|
||||
|
@ -140,8 +156,6 @@ GEM
|
|||
sdoc (0.4.1)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
rdoc (~> 4.0)
|
||||
shoulda-matchers (2.7.0)
|
||||
activesupport (>= 3.0.0)
|
||||
simplecov (0.9.1)
|
||||
docile (~> 1.1.0)
|
||||
multi_json (~> 1.0)
|
||||
|
@ -177,7 +191,10 @@ GEM
|
|||
raindrops (~> 0.7)
|
||||
warden (1.2.3)
|
||||
rack (>= 1.0)
|
||||
websocket-driver (0.4.0)
|
||||
will_paginate (3.0.7)
|
||||
xpath (2.0.0)
|
||||
nokogiri (~> 1.3)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
@ -187,7 +204,9 @@ DEPENDENCIES
|
|||
bootstrap-material-design
|
||||
bootstrap-sass (~> 3.2.0.1)
|
||||
bootstrap_form
|
||||
capybara
|
||||
coffee-rails (~> 4.1.0)
|
||||
database_cleaner
|
||||
devise
|
||||
factory_girl_rails
|
||||
faker
|
||||
|
@ -201,11 +220,11 @@ DEPENDENCIES
|
|||
mysql2
|
||||
nprogress-rails
|
||||
pg
|
||||
poltergeist
|
||||
rails (= 4.1.7)
|
||||
rspec-rails (~> 3.0.0)
|
||||
sass-rails (~> 4.0.3)
|
||||
sdoc (~> 0.4.1)
|
||||
shoulda-matchers
|
||||
simplecov
|
||||
spring
|
||||
thin
|
||||
|
|
|
@ -21,7 +21,7 @@ Rails.application.configure do
|
|||
config.action_controller.perform_caching = false
|
||||
|
||||
# Raise exceptions instead of rendering exception templates.
|
||||
config.action_dispatch.show_exceptions = false
|
||||
config.action_dispatch.show_exceptions = true # was: false
|
||||
|
||||
# Disable request forgery protection in test environment.
|
||||
config.action_controller.allow_forgery_protection = false
|
||||
|
|
22
spec/features/user_feature_spec.rb
Normal file
22
spec/features/user_feature_spec.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
require 'rails_helper'
|
||||
|
||||
feature "User", :type => :feature do
|
||||
before do
|
||||
@user1 = create(:user)
|
||||
@user2 = create(:user)
|
||||
end
|
||||
|
||||
scenario "gets asked a question", js: true do
|
||||
visit "/@#{@user1.screen_name}"
|
||||
|
||||
page.driver.render Rails.root.join("tmp/#{Time.now.to_i}_1.png"), full: true
|
||||
|
||||
fill_in "qb-question", with: Faker::Lorem.sentence
|
||||
click_button "Ask"
|
||||
wait_for_ajax
|
||||
|
||||
page.driver.render Rails.root.join("tmp/#{Time.now.to_i}_2.png"), full: true
|
||||
|
||||
expect(page).to have_text("Question asked successfully.")
|
||||
end
|
||||
end
|
|
@ -1,5 +1,4 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe User, :type => :model do
|
||||
# TODO: specs for user model
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ RSpec.configure do |config|
|
|||
# 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
|
||||
config.use_transactional_fixtures = false
|
||||
|
||||
# RSpec Rails can automatically mix in different behaviours to your tests
|
||||
# based on their file location, for example enabling you to call `get` and
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe UserController, :type => :request do
|
||||
RSpec.describe "user page", :type => :request do
|
||||
before do
|
||||
# we need at least 2 users to test meaningfully
|
||||
@user1 = create(:user)
|
||||
@user2 = create(:user)
|
||||
@user = create(:user)
|
||||
end
|
||||
|
||||
it 'shows the user page' do
|
||||
get "/@#{@user1.screen_name}"
|
||||
assert_select "h3.text-muted", :text => @user1.screen_name
|
||||
get "/@#{@user.screen_name}"
|
||||
assert_select "h3.text-muted", :text => @user.screen_name
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
require 'simplecov'
|
||||
SimpleCov.start
|
||||
|
||||
require 'capybara/poltergeist'
|
||||
Capybara.register_driver :poltergeist do |app|
|
||||
Capybara::Poltergeist::Driver.new(app, js_errors: false)
|
||||
end
|
||||
Capybara.javascript_driver = :poltergeist
|
||||
|
||||
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
||||
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
||||
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
||||
|
|
21
spec/support/database_cleaner.rb
Normal file
21
spec/support/database_cleaner.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
RSpec.configure do |config|
|
||||
config.before(:suite) do
|
||||
DatabaseCleaner.clean_with :truncation
|
||||
end
|
||||
|
||||
config.before(:each) do
|
||||
DatabaseCleaner.strategy = :transaction
|
||||
end
|
||||
|
||||
config.before(:each, js: true) do
|
||||
DatabaseCleaner.strategy = :truncation
|
||||
end
|
||||
|
||||
config.before(:each) do
|
||||
DatabaseCleaner.start
|
||||
end
|
||||
|
||||
config.after(:each) do
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
end
|
15
spec/support/wait_for_ajax.rb
Normal file
15
spec/support/wait_for_ajax.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
module WaitForAjax
|
||||
def wait_for_ajax
|
||||
Timeout.timeout(Capybara.default_wait_time) do
|
||||
loop until finished_all_ajax_requests?
|
||||
end
|
||||
end
|
||||
|
||||
def finished_all_ajax_requests?
|
||||
page.evaluate_script('jQuery.active').zero?
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.include WaitForAjax, type: :feature
|
||||
end
|
Loading…
Reference in a new issue