From d9a32f9167ea3652078f5171f31e96a4d5bc64d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20G=C3=BCnther?= Date: Tue, 17 Sep 2013 12:55:00 +0200 Subject: [PATCH 1/5] Add basic test setup with an empty test --- padrino-performance/test/helper.rb | 18 ++++++++++++++++++ .../test/test_padrino_performance.rb | 5 +++++ 2 files changed, 23 insertions(+) create mode 100644 padrino-performance/test/helper.rb create mode 100644 padrino-performance/test/test_padrino_performance.rb diff --git a/padrino-performance/test/helper.rb b/padrino-performance/test/helper.rb new file mode 100644 index 000000000..7ab4c2999 --- /dev/null +++ b/padrino-performance/test/helper.rb @@ -0,0 +1,18 @@ +require File.expand_path('../../../load_paths', __FILE__) +require File.join(File.dirname(__FILE__), '..', '..', 'padrino-core', 'test', 'mini_shoulda') + +require 'padrino-core' +require 'rack' +require 'rack/test' + +class MiniTest::Spec + include Rack::Test::Methods + + # Sets up a Sinatra::Base subclass defined with the block + # given. Used in setup or individual spec methods to establish + # the application. + def mock_app(base = Padrino::Application, &block) + @app = Sinatra.new(base, &block) + end +end + diff --git a/padrino-performance/test/test_padrino_performance.rb b/padrino-performance/test/test_padrino_performance.rb new file mode 100644 index 000000000..711eaa860 --- /dev/null +++ b/padrino-performance/test/test_padrino_performance.rb @@ -0,0 +1,5 @@ +require File.expand_path(File.dirname(__FILE__) + '/helper') + +describe "Padrino Performance" do + +end From b656340e3ee198dc63f1d98a66fd94db4ad36699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20G=C3=BCnther?= Date: Tue, 17 Sep 2013 21:11:08 +0200 Subject: [PATCH 2/5] Using RbConfig for more precise output of OS --- padrino-performance/lib/padrino-performance/os.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/padrino-performance/lib/padrino-performance/os.rb b/padrino-performance/lib/padrino-performance/os.rb index cbba69012..3829b11e6 100644 --- a/padrino-performance/lib/padrino-performance/os.rb +++ b/padrino-performance/lib/padrino-performance/os.rb @@ -4,11 +4,11 @@ module Performance # Source: http://stackoverflow.com/questions/170956/how-can-i-find-which-operating-system-my-ruby-program-is-running-on module OS def self.windows? - (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil + (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RbConfig::CONFIG['target_os']) != nil end def self.mac? - (/darwin/ =~ RUBY_PLATFORM) != nil + (/darwin/ =~ RbConfig::CONFIG['target_os']) != nil end def self.unix? From 1cc3c10610bdaaaa2974cc5689433057b552eb69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20G=C3=BCnther?= Date: Tue, 17 Sep 2013 21:43:46 +0200 Subject: [PATCH 3/5] Complete test for os module --- padrino-helpers/test/test_output_helpers.rb | 4 +- padrino-performance/test/helper.rb | 1 + padrino-performance/test/test_os.rb | 61 +++++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 padrino-performance/test/test_os.rb diff --git a/padrino-helpers/test/test_output_helpers.rb b/padrino-helpers/test/test_output_helpers.rb index 2140bec26..d56c49afa 100644 --- a/padrino-helpers/test/test_output_helpers.rb +++ b/padrino-helpers/test/test_output_helpers.rb @@ -79,8 +79,8 @@ def app should "work for slim templates" do visit '/slim/capture_concat' - # TODO Get Slim concat working - # assert_have_selector 'p', :content => "Concat Line 3", :count => 1 + #TODO Get Slim concat working + assert_have_selector 'p', :content => "Concat Line 3", :count => 1 end end diff --git a/padrino-performance/test/helper.rb b/padrino-performance/test/helper.rb index 7ab4c2999..5ad3ddd0d 100644 --- a/padrino-performance/test/helper.rb +++ b/padrino-performance/test/helper.rb @@ -2,6 +2,7 @@ require File.join(File.dirname(__FILE__), '..', '..', 'padrino-core', 'test', 'mini_shoulda') require 'padrino-core' +require 'padrino-performance' require 'rack' require 'rack/test' diff --git a/padrino-performance/test/test_os.rb b/padrino-performance/test/test_os.rb new file mode 100644 index 000000000..89bdb5a7f --- /dev/null +++ b/padrino-performance/test/test_os.rb @@ -0,0 +1,61 @@ +require File.expand_path(File.dirname(__FILE__) + '/helper') + +describe "Padrino Performance OS Module" do + WINDOWS_RELATED_SYSTEMS = %w(cygwin mswin mingw bccwin wince emx) + + context "#windows?" do + should "return false if OS is now windows" do + RbConfig::CONFIG['target_os'] = "linux" + refute(Padrino::Performance::OS.windows?, "No non windows system given") + end + + should "return true if we have some windows instance" do + WINDOWS_RELATED_SYSTEMS.each do |system| + RbConfig::CONFIG['target_os'] = system + assert(Padrino::Performance::OS.windows?, "#{system} is no windows related operation system.") + end + end + end + + context "#mac?" do + should "return true if we have darwin running" do + RbConfig::CONFIG['target_os'] = 'darwin' + assert(Padrino::Performance::OS.mac?, "We have no Mac related system running") + end + + should "return false if we have linux running" do + RbConfig::CONFIG['target_os'] = 'linux' + refute(Padrino::Performance::OS.mac?, "We have no Mac related system running") + end + end + + context "#unix?" do + should "return true if OS is not windows" do + RbConfig::CONFIG['target_os'] = 'linux' + assert(Padrino::Performance::OS.unix?, "We have no windows related system running") + end + + should "return false if OS is windows" do + WINDOWS_RELATED_SYSTEMS.each do |system| + RbConfig::CONFIG['target_os'] = system + refute(Padrino::Performance::OS.unix?, "#{system} is windows related operation system.") + end + end + end + + context "#linux?" do + should "return true if we have no Windows or Mac related OS" do + RbConfig::CONFIG['target_os'] = 'linux' + assert(Padrino::Performance::OS.linux?, 'We have either Mac or Windows operation system.') + end + + should "return false if we have a Windows or Mac related OS" do + RbConfig::CONFIG['target_os'] = 'mingw' + refute(Padrino::Performance::OS.linux?, 'We a Windows related operation system.') + + RbConfig::CONFIG['target_os'] = 'darwin' + refute(Padrino::Performance::OS.linux?, 'We a darwin operation system.') + end + end + +end From 85687dfccb164ed555613e172098e7e5908f650d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20G=C3=BCnther?= Date: Tue, 17 Sep 2013 21:45:12 +0200 Subject: [PATCH 4/5] Get rid of unused mock_app method --- padrino-performance/test/helper.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/padrino-performance/test/helper.rb b/padrino-performance/test/helper.rb index 5ad3ddd0d..2e6d9aa59 100644 --- a/padrino-performance/test/helper.rb +++ b/padrino-performance/test/helper.rb @@ -8,12 +8,5 @@ class MiniTest::Spec include Rack::Test::Methods - - # Sets up a Sinatra::Base subclass defined with the block - # given. Used in setup or individual spec methods to establish - # the application. - def mock_app(base = Padrino::Application, &block) - @app = Sinatra.new(base, &block) - end end From cebbbbb0f2f2f4fd5959923fcc661fa8609d6def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20G=C3=BCnther?= Date: Tue, 17 Sep 2013 22:10:37 +0200 Subject: [PATCH 5/5] Make slim template concat TODO a TODO again --- padrino-helpers/test/test_output_helpers.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/padrino-helpers/test/test_output_helpers.rb b/padrino-helpers/test/test_output_helpers.rb index d56c49afa..2140bec26 100644 --- a/padrino-helpers/test/test_output_helpers.rb +++ b/padrino-helpers/test/test_output_helpers.rb @@ -79,8 +79,8 @@ def app should "work for slim templates" do visit '/slim/capture_concat' - #TODO Get Slim concat working - assert_have_selector 'p', :content => "Concat Line 3", :count => 1 + # TODO Get Slim concat working + # assert_have_selector 'p', :content => "Concat Line 3", :count => 1 end end