Skip to content

Instantly share code, notes, and snippets.

@peterhellberg
Created May 7, 2012 13:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterhellberg/2627790 to your computer and use it in GitHub Desktop.
Save peterhellberg/2627790 to your computer and use it in GitHub Desktop.
Testing Sinatra helpers (in isolation) that depend on the params hash being present
# encoding: UTF-8
module MyHelpers
def foo
"#{params[:bar]}"
end
end
# encoding: UTF-8
require_relative "spec_helper"
require_relative "../lib/my_helpers.rb"
class FakeApp
attr_accessor :params
include MyHelpers
def initialize(params = {})
@params = params
end
end
describe MyHelpers do
subject { FakeApp }
describe "foo" do
it "returns the bar param" do
s(bar: 'baz').foo.must_equal 'baz'
end
end
end
# encoding: UTF-8
require 'bundler'
Bundler.setup
Bundler.require
require 'minitest/pride'
require 'minitest/autorun'
require 'minitest/spec'
require 'rack/test'
class MiniTest::Spec
include Rack::Test::Methods
end
def s(*args)
subject.new(*args)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment