test_example.rb in toadhopper-sinatra-0.10.1 vs test_example.rb in toadhopper-sinatra-1.0.0
- old
+ new
@@ -1,67 +1,56 @@
-require 'test/unit'
-
-require 'rr'
-class Test::Unit::TestCase
- include RR::Adapters::TestUnit
-end
-
-require 'rack/test'
-
toadhopper_dir = "#{File.dirname(__FILE__)}/../toadhopper"
raise "#{toadhopper_dir} does not exist" unless File.directory?(toadhopper_dir)
$:.unshift "#{toadhopper_dir}/lib"
$:.unshift "#{File.dirname(__FILE__)}/lib"
require "#{File.dirname(__FILE__)}/example"
-
Sinatra::Application.set :environment, :production
-class Sinatra::ToadHopper::TestExample < Test::Unit::TestCase
-
- include Rack::Test::Methods
+require 'exemplor'
- def app; Sinatra::Application end
+require 'rack/test'
+require 'rr'
- def setup
- app.set :environment, :production
-
- @toadhopper = ::ToadHopper.new("")
- stub(::ToadHopper).new do |api_key|
- @api_key = api_key
- @toadhopper
- end
- stub(@toadhopper).post! do |*args|
- @error, @options, @header = *args
- end
-
- post "/register", :name => "Billy", :password => "Bob"
+eg.helpers do
+ include Rack::Test::Methods
+ include RR::Adapters::RRMethods
+ def app
+ Sinatra::Application
end
+end
- def test_api_key_set
- assert_equal "apikey", @api_key
+eg.setup do
+ RR.reset
+
+ @toadhopper = ::ToadHopper.new("")
+ stub(::ToadHopper).new do |api_key|
+ @api_key = api_key
+ @toadhopper
end
- def test_filter_set
- assert_equal [/password/], @toadhopper.filters
+
+ stub(@toadhopper).post! do |*args|
+ @error, @options, @header = *args
end
- def test_reported_error
- assert_equal RuntimeError, @error.class
- assert_equal "Kaboom!", @error.message
- end
+end
- def test_options
- assert_equal ENV.to_hash, @options[:environment]
- assert_equal "http://example.org/register", @options[:url]
- assert @options[:request]
- assert @options[:request].respond_to?(:params)
- assert @options[:framework_env] = "production"
- assert @options[:project_root] = app.root
- assert @options[:session] = {:user_id => 42}
- assert @options[:notifier_name] = "toadhopper-sinatra"
- end
+eg "Posting" do
+ post "/register", :name => "Billy", :password => "Bob"
- def test_header_options
- assert_equal "toadhopper-sinatra", @header['X-Hoptoad-Client-Name']
- end
-
+ Check(@api_key).is("apikey")
+
+ Check(@toadhopper.filters).is([/password/])
+
+ Check(@error.class).is(RuntimeError)
+ Check(@error.message).is("Kaboom!")
+
+ Check(@options[:environment]).is(ENV.to_hash)
+ Check(@options[:url]).is("http://example.org/register")
+ Check(@options[:params]).is({"name"=>"Billy", "password"=>"Bob"})
+ Check(@options[:framework_env]).is("production")
+ Check(@options[:project_root]).is(app.root)
+ Check(@options[:session]).is({:user_id => 42})
+ Check(@options[:notifier_name]).is("toadhopper-sinatra")
+
+ Check(@header['X-Hoptoad-Client-Name']).is("toadhopper-sinatra")
end
\ No newline at end of file