From e2e3c1e3fb2a7903f1b25aadeb7cd8c8610bc62c Mon Sep 17 00:00:00 2001 From: Eliott Appleford Date: Thu, 3 Jul 2014 20:13:22 +0100 Subject: [PATCH 1/3] fix specs on windows --- Gemfile | 2 +- gem_rake_helper.rb | 4 +++- middleman-core/features/gzip.feature | 1 + .../features/more-implied_extensions.feature | 8 +------- .../features/twitter-bootstrap-compile.feature | 8 ++++---- .../source/stylesheets/style3.less | 4 ---- .../lib/middleman-core/step_definitions.rb | 16 ++++++++++++---- .../spec/middleman-core/binary_spec.rb | 4 ++-- 8 files changed, 24 insertions(+), 23 deletions(-) delete mode 100644 middleman-core/fixtures/more-implied-extensions-app/source/stylesheets/style3.less diff --git a/Gemfile b/Gemfile index 4c721ffa..84394d93 100644 --- a/Gemfile +++ b/Gemfile @@ -17,11 +17,11 @@ gem 'slim', require: false gem 'liquid', require: false gem 'less', '~> 2.3.0', require: false gem 'stylus', require: false +gem 'redcarpet', '~> 3.1', require: false gem 'asciidoctor', require: false platforms :ruby do gem 'therubyracer' - gem 'redcarpet', '~> 3.1' gem 'pry', require: false, group: :development end diff --git a/gem_rake_helper.rb b/gem_rake_helper.rb index 284cf5dc..5f95c90e 100644 --- a/gem_rake_helper.rb +++ b/gem_rake_helper.rb @@ -19,6 +19,7 @@ Cucumber::Rake::Task.new do |t| exempt_tags = ['--tags ~@wip'] exempt_tags << '--tags ~@nojava' if RUBY_PLATFORM == 'java' exempt_tags << '--tags ~@encoding' unless Object.const_defined?(:Encoding) + exempt_tags << '--tags ~@nowindows' if Gem.win_platform? exempt_tags << '--tags ~@travishatesme' if ENV['TRAVIS'] == 'true' t.cucumber_opts = "--color #{exempt_tags.join(' ')} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}" end @@ -27,6 +28,7 @@ Cucumber::Rake::Task.new(:cucumber_wip) do |t| exempt_tags = ['--tags @wip'] exempt_tags << '--tags ~@nojava' if RUBY_PLATFORM == 'java' exempt_tags << '--tags ~@encoding' unless Object.const_defined?(:Encoding) + exempt_tags << '--tags ~@nowindows' if Gem.win_platform? t.cucumber_opts = "--color #{exempt_tags.join(' ')} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}" end @@ -34,7 +36,7 @@ require 'rspec/core/rake_task' desc 'Run RSpec' RSpec::Core::RakeTask.new do |spec| spec.pattern = 'spec/**/*_spec.rb' - spec.rspec_opts = ['--color', '--format nested'] + spec.rspec_opts = ['--color', '--format documentation'] end desc 'Run tests, both RSpec and Cucumber' diff --git a/middleman-core/features/gzip.feature b/middleman-core/features/gzip.feature index 5a5a4265..93955a49 100644 --- a/middleman-core/features/gzip.feature +++ b/middleman-core/features/gzip.feature @@ -1,3 +1,4 @@ +@nowindows Feature: GZIP assets during build Scenario: Built assets should be gzipped diff --git a/middleman-core/features/more-implied_extensions.feature b/middleman-core/features/more-implied_extensions.feature index 31567443..10ee5b20 100644 --- a/middleman-core/features/more-implied_extensions.feature +++ b/middleman-core/features/more-implied_extensions.feature @@ -19,10 +19,7 @@ Feature: More default extensions When I go to "/stylesheets/style2.css" Then I should see "section" Then I should not see "I am in the layout" - When I go to "/stylesheets/style3.css" - Then I should see "color" - Then I should not see "I am in the layout" - + Scenario: Default extensions build Given a fixture app "more-implied-extensions-app" And a successfully built app at "more-implied-extensions-app" @@ -35,7 +32,6 @@ Feature: More default extensions | javascripts/app.js | | stylesheets/style.css | | stylesheets/style2.css | - | stylesheets/style3.css | And the file "test.html" should contain "Hello" And the file "test2.html" should contain "World" And the file "test3.html" should contain "Howdy" @@ -46,5 +42,3 @@ Feature: More default extensions And the file "stylesheets/style.css" should not contain "I am in the layout" And the file "stylesheets/style2.css" should contain "section" And the file "stylesheets/style2.css" should not contain "I am in the layout" - And the file "stylesheets/style3.css" should contain "color" - And the file "stylesheets/style3.css" should not contain "I am in the layout" \ No newline at end of file diff --git a/middleman-core/features/twitter-bootstrap-compile.feature b/middleman-core/features/twitter-bootstrap-compile.feature index 994cf11c..04ffc0ce 100644 --- a/middleman-core/features/twitter-bootstrap-compile.feature +++ b/middleman-core/features/twitter-bootstrap-compile.feature @@ -1,6 +1,6 @@ -@nojava -Feature: Compile a complicated Twitter bootstrap app +@nojava @nowindows +Feature: Compile a complicated Twitter bootstrap app Scenario: User drops Twitter Bootstrap source into an app - - Given a successfully built app at "twitter-bootstrap-app" \ No newline at end of file + + Given a successfully built app at "twitter-bootstrap-app" diff --git a/middleman-core/fixtures/more-implied-extensions-app/source/stylesheets/style3.less b/middleman-core/fixtures/more-implied-extensions-app/source/stylesheets/style3.less deleted file mode 100644 index 420d50d4..00000000 --- a/middleman-core/fixtures/more-implied-extensions-app/source/stylesheets/style3.less +++ /dev/null @@ -1,4 +0,0 @@ -@base: #f938ab; -.box { - color: @base; -} \ No newline at end of file diff --git a/middleman-core/lib/middleman-core/step_definitions.rb b/middleman-core/lib/middleman-core/step_definitions.rb index 4c14b091..95245f14 100644 --- a/middleman-core/lib/middleman-core/step_definitions.rb +++ b/middleman-core/lib/middleman-core/step_definitions.rb @@ -1,13 +1,21 @@ -MIDDLEMAN_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__))) -MIDDLEMAN_BIN_PATH = File.join(MIDDLEMAN_ROOT_PATH, 'bin') -ENV['PATH'] = "#{MIDDLEMAN_BIN_PATH}#{File::PATH_SEPARATOR}#{ENV['PATH']}" - require 'aruba/cucumber' require 'aruba/jruby' require 'middleman-core/step_definitions/middleman_steps' require 'middleman-core/step_definitions/builder_steps' require 'middleman-core/step_definitions/server_steps' +# Monkeypatch for windows support +module ArubaMonkeypatch + def detect_ruby(cmd) + if cmd.start_with?('middleman ') && Gem.win_platform? + "#{current_ruby} #{Dir.pwd}/bin/#{cmd}" + else + cmd.sub(/^ruby(?= )/, current_ruby) + end + end +end +World(ArubaMonkeypatch) + Before do @aruba_timeout_seconds = RUBY_PLATFORM == 'java' ? 120 : 60 end diff --git a/middleman-core/spec/middleman-core/binary_spec.rb b/middleman-core/spec/middleman-core/binary_spec.rb index 79944331..4f8d11d2 100644 --- a/middleman-core/spec/middleman-core/binary_spec.rb +++ b/middleman-core/spec/middleman-core/binary_spec.rb @@ -3,13 +3,13 @@ require 'middleman-core/util' describe "Middleman::Util#binary?" do %w(plain.txt unicode.txt unicode).each do |file| it "recognizes #{file} as not binary" do - expect(Middleman::Util.binary?(File.join(File.dirname(__FILE__), "binary_spec/#{file}"))).to be_false + expect(Middleman::Util.binary?(File.join(File.dirname(__FILE__), "binary_spec/#{file}"))).to be false end end %w(middleman.png middleman stars.svgz).each do |file| it "recognizes #{file} as binary" do - expect(Middleman::Util.binary?(File.join(File.dirname(__FILE__), "binary_spec/#{file}"))).to be_true + expect(Middleman::Util.binary?(File.join(File.dirname(__FILE__), "binary_spec/#{file}"))).to be true end end end From 5897c4c4a47d89d0bcd41ebdebe6e1b9f6f2cb69 Mon Sep 17 00:00:00 2001 From: Eliott Appleford Date: Sat, 5 Jul 2014 02:19:51 +0100 Subject: [PATCH 2/3] update gemfile --- Gemfile | 46 +++++++++---------- .../step_definitions/server_steps.rb | 14 +++--- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/Gemfile b/Gemfile index 84394d93..230b683f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,39 +1,37 @@ source 'https://rubygems.org' # Build and doc tools -gem 'rake', '~> 10.0.3', require: false -gem 'yard', '~> 0.8.0', require: false +gem 'rake', '~> 10.3', require: false +gem 'yard', '~> 0.8', require: false # Test tools -gem 'cucumber', '~> 1.3.1' -gem 'fivemat', '~> 1.2.1' -gem 'aruba', '~> 0.5.1' -gem 'rspec', '~> 2.12' -gem 'simplecov' +gem 'pry', '~> 0.10', group: :development +gem 'aruba', '~> 0.6' +gem 'rspec', '~> 3.0' +gem 'fivemat', '~> 1.3' +gem 'cucumber', '~> 1.3' # Optional middleman dependencies, included for tests -gem 'sinatra', require: false -gem 'slim', require: false -gem 'liquid', require: false -gem 'less', '~> 2.3.0', require: false -gem 'stylus', require: false -gem 'redcarpet', '~> 3.1', require: false -gem 'asciidoctor', require: false +gem 'less', '2.3.0', require: false +gem 'slim', '~> 2.0', require: false +gem 'liquid', '~> 2.6', require: false +gem 'stylus', '~> 1.0', require: false +gem 'sinatra','~> 1.4', require: false +gem 'asciidoctor', '~> 0.1', require: false -platforms :ruby do - gem 'therubyracer' - gem 'pry', require: false, group: :development -end +# For less, since it doesn't use ExecJS (which also means less wont work on windows) +gem 'therubyracer', platforms: :ruby +gem 'therubyrhino', platforms: :jruby -platforms :jruby do - gem 'therubyrhino' -end +# Redcarpet doesn't work on JRuby +gem 'redcarpet', '~> 3.1', require: false unless RUBY_ENGINE == 'jruby' # Code Quality -gem 'coveralls', require: false -gem 'rubocop', require: false +gem 'rubocop', '~> 0.24', require: false +gem 'simplecov', '0.7.1', require: false +gem 'coveralls', '~> 0.7', require: false # Middleman itself +gem 'middleman', path: 'middleman' gem 'middleman-core', path: 'middleman-core' gem 'middleman-sprockets', github: 'middleman/middleman-sprockets' -gem 'middleman', path: 'middleman' diff --git a/middleman-core/lib/middleman-core/step_definitions/server_steps.rb b/middleman-core/lib/middleman-core/step_definitions/server_steps.rb index 0dda0772..30098760 100644 --- a/middleman-core/lib/middleman-core/step_definitions/server_steps.rb +++ b/middleman-core/lib/middleman-core/step_definitions/server_steps.rb @@ -68,29 +68,29 @@ When /^I go to "([^\"]*)"$/ do |url| end Then /^going to "([^\"]*)" should not raise an exception$/ do |url| - lambda { @browser.get(URI.escape(url)) }.should_not raise_exception + expect(lambda { @browser.get(URI.escape(url)) }).to_not raise_exception end Then /^the content type should be "([^\"]*)"$/ do |expected| - @browser.last_response.content_type.should start_with(expected) + expect(@browser.last_response.content_type).to start_with(expected) end Then /^I should see "([^\"]*)"$/ do |expected| - @browser.last_response.body.should include(expected) + expect(@browser.last_response.body).to include(expected) end Then /^I should see '([^\']*)'$/ do |expected| - @browser.last_response.body.should include(expected) + expect(@browser.last_response.body).to include(expected) end Then /^I should see:$/ do |expected| - @browser.last_response.body.should include(expected) + expect(@browser.last_response.body).to include(expected) end Then /^I should not see "([^\"]*)"$/ do |expected| - @browser.last_response.body.should_not include(expected) + expect(@browser.last_response.body).to_not include(expected) end Then /^I should see "([^\"]*)" lines$/ do |lines| - @browser.last_response.body.chomp.split($/).length.should == lines.to_i + expect(@browser.last_response.body.chomp.split($/).length).to eq(lines.to_i) end From 21c2b737f5fee5f46821b27f4dcae6f07f05dd35 Mon Sep 17 00:00:00 2001 From: Eliott Appleford Date: Sun, 6 Jul 2014 04:02:43 +0100 Subject: [PATCH 3/3] fix gzip spec --- middleman-core/features/gzip.feature | 4 +--- .../lib/middleman-core/step_definitions/builder_steps.rb | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/middleman-core/features/gzip.feature b/middleman-core/features/gzip.feature index 93955a49..18669476 100644 --- a/middleman-core/features/gzip.feature +++ b/middleman-core/features/gzip.feature @@ -1,4 +1,3 @@ -@nowindows Feature: GZIP assets during build Scenario: Built assets should be gzipped @@ -10,8 +9,7 @@ Feature: GZIP assets during build | build/javascripts/test.js.gz | | build/stylesheets/test.css | | build/stylesheets/test.css.gz | - When I run `file build/javascripts/test.js.gz` - Then the output should contain "gzip" + And build/javascripts/test.js.gz should be binary Scenario: Preview server doesn't change Given the Server is running at "gzip-app" diff --git a/middleman-core/lib/middleman-core/step_definitions/builder_steps.rb b/middleman-core/lib/middleman-core/step_definitions/builder_steps.rb index eda6467b..ce942284 100644 --- a/middleman-core/lib/middleman-core/step_definitions/builder_steps.rb +++ b/middleman-core/lib/middleman-core/step_definitions/builder_steps.rb @@ -71,3 +71,7 @@ end Then /^the file "([^"]*)" should contain '([^']*)'$/ do |file, partial_content| check_file_content(file, partial_content, true) end + +And /(.*) should be binary/ do |file| + expect(File.binread(File.join(current_dir, file), 2)).to eq(['1F8B'].pack('H*')) +end