Commit 4780cc6c authored by Vaz Allen's avatar Vaz Allen

Add RSpec and Capybara, and a basic feature spec

parent 526c9ebe
--format documentation --color
...@@ -23,3 +23,9 @@ group :production do ...@@ -23,3 +23,9 @@ group :production do
# use postgres in production, or move outside a group if your app uses postgres for development and production # use postgres in production, or move outside a group if your app uses postgres for development and production
gem 'pg' gem 'pg'
end end
group :test do
gem 'rspec'
gem 'capybara'
gem 'database_cleaner'
end
...@@ -14,16 +14,32 @@ GEM ...@@ -14,16 +14,32 @@ GEM
minitest (~> 5.1) minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4) thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1) tzinfo (~> 1.1)
addressable (2.4.0)
arel (6.0.3) arel (6.0.3)
backports (3.6.7) backports (3.6.7)
bond (0.5.1) bond (0.5.1)
builder (3.2.2) builder (3.2.2)
capybara (2.7.1)
addressable
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
coderay (1.1.0) coderay (1.1.0)
database_cleaner (1.3.0)
diff-lcs (1.2.5)
i18n (0.7.0) i18n (0.7.0)
json (1.8.3) json (1.8.3)
method_source (0.8.2) method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.0.0)
minitest (5.8.3) minitest (5.8.3)
multi_json (1.11.2) multi_json (1.11.2)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
pg (0.18.4) pg (0.18.4)
pry (0.10.3) pry (0.10.3)
coderay (~> 1.1.0) coderay (~> 1.1.0)
...@@ -44,6 +60,19 @@ GEM ...@@ -44,6 +60,19 @@ GEM
rack (>= 1.0) rack (>= 1.0)
rack-test (~> 0.6.2) rack-test (~> 0.6.2)
ripl (>= 0.7.0) ripl (>= 0.7.0)
rspec (3.4.0)
rspec-core (~> 3.4.0)
rspec-expectations (~> 3.4.0)
rspec-mocks (~> 3.4.0)
rspec-core (3.4.4)
rspec-support (~> 3.4.0)
rspec-expectations (3.4.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-mocks (3.4.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-support (3.4.1)
shotgun (0.9.1) shotgun (0.9.1)
rack (>= 1.0) rack (>= 1.0)
sinatra (1.4.6) sinatra (1.4.6)
...@@ -71,16 +100,21 @@ GEM ...@@ -71,16 +100,21 @@ GEM
sinatra (>= 1.2.1) sinatra (>= 1.2.1)
tzinfo (1.2.2) tzinfo (1.2.2)
thread_safe (~> 0.1) thread_safe (~> 0.1)
xpath (2.0.0)
nokogiri (~> 1.3)
PLATFORMS PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
activesupport activesupport
capybara
database_cleaner
pg pg
pry pry
puma puma
rake rake
rspec
shotgun shotgun
sinatra sinatra
sinatra-activerecord sinatra-activerecord
......
require_relative '../spec_helper'
# Make sure your specs are tagged with type: :feature if you
# want to use capybara methods (visit, fill_in, click_link, have_content, etc)
describe 'Home page', type: :feature do
before { visit '/' }
it 'should contain the text "Home Page"' do
expect(page).to have_content('Home Page')
end
end
ENV['RACK_ENV'] ||= 'test'
require_relative '../config/environment'
require 'rspec'
require 'capybara/rspec' # capybara will be loaded for tests tagged :feature
require 'database_cleaner'
Capybara.app = Sinatra::Application
RSpec.configure do |config|
# All of the following just ensures the database is wiped
# before every single test:
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment