Skip to content

Instantly share code, notes, and snippets.

@Jamedjo
Created June 16, 2013 15:09
Show Gist options
  • Save Jamedjo/5792332 to your computer and use it in GitHub Desktop.
Save Jamedjo/5792332 to your computer and use it in GitHub Desktop.
Sinatra with RSpec config,
source 'https://rubygems.org'
ruby '2.0.0'
gem 'sinatra'
gem 'rspec'
gem 'rack-test'
require 'myapp'
require 'spec_helper'
set :environment, :test
describe 'The MyApp site' do
it "returns somthing on the root url" do
get '/'
last_response.should be_ok
expect(last_response.body).to include "html"
end
end
require './myapp'
require 'rspec'
require 'rack/test'
def app
MyAppClassName
end
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# Require this file using `require "spec_helper"` to ensure that it is only
# loaded once.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
config.include Rack::Test::Methods
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
# config.filter_run :focus
# 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
@Jamedjo
Copy link
Author

Jamedjo commented Jun 16, 2013

  1. Generate spec folder and helpers from rspec --init
  2. Add config.include Rack::Test::Methods, correct requires and def app; MyApp; end
  3. Run with rspec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment