Skip to content

Instantly share code, notes, and snippets.

@ghermeto
Created September 1, 2011 23:20
Show Gist options
  • Save ghermeto/1187556 to your computer and use it in GitHub Desktop.
Save ghermeto/1187556 to your computer and use it in GitHub Desktop.
Simple spec example
require 'spec_helper'
describe My::App do
before :each do
# this will be executed before each example
@app = My::App.new 'test'
end
it "should do something" do
# this is an example
@app.method.should == 'method'
end
it "should do something else" do
# this is another example
result = @app.one + 1
result.should == 2
end
end
$: << File.expand_path(File.dirname(__FILE__) + "/lib")
require 'rake'
require 'rspec/core/rake_task'
desc "Run all the specs"
RSpec::Core::RakeTask.new do |t|
t.pattern = ENV['spec'] || 'spec/**/*_spec.rb'
t.rspec_opts = ["--color"]
end
# you will require everything you need for your specs to run
require 'my-app' #<- change to your app
require 'rack/test' #<- great to test sinatra apps
require 'nokogiri'
# sinatra environment
set :environment, :test
set :run, false
set :raise_errors, true
set :logging, false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment