Created
September 1, 2011 23:20
-
-
Save ghermeto/1187556 to your computer and use it in GitHub Desktop.
Simple spec example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$: << 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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