require_relative "../test_helper" class AddOnTest < IntegrationTestCase def test_metrics_add_on run_hoboken(:generate) do bin_path = File.expand_path("../../../bin/hoboken", __FILE__) execute("#{bin_path} add:metrics") assert_file("Gemfile", /flog/, /flay/, /simplecov/) assert_file("tasks/metrics.rake") assert_file("test/test_helper.rb", < <%= javascript_tag :app %> CODE ) end end def test_sprockets_add_on_modular run_hoboken(:generate, type: :modular) do bin_path = File.expand_path("../../../bin/hoboken", __FILE__) execute("#{bin_path} add:sprockets") assert_file("assets/styles.css") assert_file("assets/app.js") assert_file("Gemfile", "sprockets", "uglifier", "yui-compressor") assert_file("tasks/sprockets.rake") assert_file("middleware/sprockets_chain.rb") assert_file("helpers/sprockets.rb") assert_file("app.rb", < <%= javascript_tag :app %> CODE ) end end def test_travis_add_on run_hoboken(:generate) do bin_path = File.expand_path("../../../bin/hoboken", __FILE__) execute("#{bin_path} add:travis") assert_file(".travis.yml", "language: ruby") end end def test_sequel_add_on run_hoboken(:generate) do bin_path = File.expand_path("../../../bin/hoboken", __FILE__) execute("#{bin_path} add:sequel") assert_file("Gemfile", "sequel", "sqlite3") assert_file("tasks/sequel.rake") assert_file("config.ru", /require "logger"/) assert_file("config.ru", /require "sequel"/) assert_file("config.ru", < 0 app = Sinatra::Application app.set :database, db run app CODE ) assert_file("test/test_helper.rb", /require "sequel"/) assert_file("test/test_helper.rb", < 0 end end end end CODE ) end end def test_omniauth_add_on run_hoboken(:generate) do bin_path = File.expand_path("../../../bin/hoboken", __FILE__) execute("(echo 'twitter' && echo '0.0.1') | #{bin_path} add:omniauth") assert_file("Gemfile", "omniauth-twitter") assert_file("app.rb", /require "omniauth-twitter"/) assert_file("app.rb", <Login' end get "/auth/:provider/callback" do # TODO: Insert real authentication logic... MultiJson.encode(request.env['omniauth.auth']) end get "/auth/failure" do # TODO: Insert real error handling logic... halt 401, params[:message] end CODE ) end assert_file("test/unit/app_test.rb", <<-CODE setup do OmniAuth.config.test_mode = true end test "GET /login" do get "/login" assert_equal('Login', last_response.body) end test "GET /auth/twitter/callback" do auth_hash = { "provider" => "twitter", "uid" => "123545", "info" => { "name" => "John Doe" } } OmniAuth.config.mock_auth[:twitter] = auth_hash get "/auth/fitbit/callback" assert_equal(MultiJson.encode(auth_hash), last_response.body) end test "GET /auth/failure" do OmniAuth.config.mock_auth[:twitter] = :invalid_credentials get "/auth/failure" assert_response :not_authorized end CODE ) end end