Skip to content

Commit

Permalink
Fix the tests!
Browse files Browse the repository at this point in the history
  • Loading branch information
theycallmeswift committed May 31, 2017
1 parent 9ff3e54 commit 434a0cb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ group :development do
end

group :development, :test do
gem 'pry'
gem 'rake'
end

Expand All @@ -27,4 +28,4 @@ group :test do
gem 'faker'
gem 'minitest'
gem 'rack-test'
end
end
10 changes: 9 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ GEM
capybara_minitest_spec (1.0.5)
capybara (>= 2)
minitest (>= 4)
coderay (1.1.1)
concurrent-ruby (1.0.5)
coveralls (0.8.20)
json (>= 1.8, < 3)
Expand All @@ -54,6 +55,7 @@ GEM
i18n (~> 0.5)
i18n (0.8.1)
json (2.0.4)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
Expand All @@ -71,6 +73,10 @@ GEM
mini_portile2 (~> 2.1.0)
plucky (0.7.0)
mongo (~> 1.5)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
public_suffix (2.0.5)
rack (1.6.5)
rack-protection (1.5.3)
Expand Down Expand Up @@ -99,6 +105,7 @@ GEM
sinatra-contrib
skylight (1.2.0)
activesupport (>= 3.0.0)
slop (3.6.0)
term-ansicolor (1.5.0)
tins (~> 1.0)
thor (0.19.4)
Expand Down Expand Up @@ -127,6 +134,7 @@ DEPENDENCIES
faker
minitest
mongo_mapper
pry
rack-test
rake
sinatra
Expand All @@ -139,4 +147,4 @@ RUBY VERSION
ruby 2.4.0p0

BUNDLED WITH
1.14.5
1.14.6
5 changes: 3 additions & 2 deletions no_light_sinatra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
c.project_id = 141503
c.project_key = '94823b6fc825a7bd16f6fc359d0ac501'
c.logger.level = Logger::DEBUG
c.environment = ENV['RACK_ENV']
c.ignore_environments = %w(test)
c.blacklist_keys = [/password/i]
end

class NoLightSinatra < Sinatra::Base
use Airbrake::Rack::Middleware
# use Airbrake::Rack::Middleware
set public_folder: 'public', static: true

configure do
DEFAULT_BRANDING = 'dell'
DEFAULT_BRANDING = ''
ENVIRONMENTS = {
'development' => { 'uri' => 'mongodb://localhost/no_light_development' },
'test' => { 'uri' => 'mongodb://localhost/no_light_test' },
Expand Down
7 changes: 4 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'bundler'
require 'coveralls'
require 'pry'

Bundler.setup
Bundler.require
Expand All @@ -20,7 +21,7 @@
require 'faker'

require 'database_cleaner'
DatabaseCleaner.strategy = :truncation
DatabaseCleaner[:mongo_mapper].strategy = :truncation

require 'find'
%w{./config/initializers ./lib}.each do |load_path|
Expand All @@ -31,10 +32,10 @@ class MiniTest::Spec
include Rack::Test::Methods

before(:each) do
DatabaseCleaner.start
DatabaseCleaner[:mongo_mapper].start
end

after(:each) do
DatabaseCleaner.clean
DatabaseCleaner[:mongo_mapper].clean
end
end
8 changes: 4 additions & 4 deletions spec/visitor_can_submit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def app
fill_in_submission(name: 'Mike Swift')

page.text.must_have_content 'Submission received'
page.text.must_have_content 'IT TOOK YOU %s SECONDS' % [last_submission.to_min_secs]
page.text.must_have_content 'IT TOOK YOU %s MINUTES' % [last_submission.to_min_secs]
page.text.must_have_content 'YOU WROTE %s LINES OF CODE / %s BYTES.' % [last_submission.lines, last_submission.bytes]
end

Expand All @@ -25,7 +25,7 @@ def app
submit_an_entry.call

page.text.must_have_content 'Submission received'
page.text.must_have_content 'IT TOOK YOU %s SECONDS' % [last_submission.to_min_secs]
page.text.must_have_content 'IT TOOK YOU %s MINUTES' % [last_submission.to_min_secs]
page.text.must_have_content 'YOU WROTE %s LINES OF CODE / %s BYTES.' % [last_submission.lines, last_submission.bytes]

# Attempt to re-submit the exact same entry.
Expand All @@ -41,9 +41,9 @@ def app
fill_in_submission(name: 'Mike Swift', hackathon: 'treehacks')

page.text.must_have_content 'Submission received'
page.text.must_have_content 'IT TOOK YOU %s SECONDS' % [last_submission.to_min_secs]
page.text.must_have_content 'IT TOOK YOU %s MINUTES' % [last_submission.to_min_secs]
page.text.must_have_content 'YOU WROTE %s LINES OF CODE / %s BYTES.' % [last_submission.lines, last_submission.bytes]
end
end

private

Expand Down

0 comments on commit 434a0cb

Please sign in to comment.