middleman-core 3.3.12 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/cucumber.yml +2 -0
- data/features/asset_hash.feature +9 -0
- data/features/chained_templates.feature +4 -1
- data/features/cli/preview_server.feature +532 -0
- data/features/i18n_link_to.feature +209 -0
- data/features/javascript-testing.feature +18 -0
- data/features/redirects.feature +1 -0
- data/features/relative_assets.feature +11 -0
- data/features/support/env.rb +3 -0
- data/fixtures/asset-hash-app/source/fonts/fontawesome-webfont.woff +0 -0
- data/fixtures/asset-hash-app/source/fonts/fontawesome-webfont.woff2 +0 -0
- data/fixtures/asset-hash-app/source/stylesheets/uses_fonts.css +4 -0
- data/fixtures/chained-app/source/test.erb.combobreaker.str.erb +8 -0
- data/fixtures/javascript-app/config.rb +0 -0
- data/fixtures/javascript-app/source/index.html +17 -0
- data/fixtures/preview-server-app/bin/dns_server.rb +33 -0
- data/fixtures/preview-server-app/config-complications.rb +11 -0
- data/fixtures/preview-server-app/config-empty.rb +0 -0
- data/fixtures/preview-server-app/config.rb +11 -0
- data/fixtures/preview-server-app/source/index.html.erb +1 -0
- data/fixtures/preview-server-app/source/layout.erb +9 -0
- data/fixtures/preview-server-app/source/layouts/custom.erb +8 -0
- data/fixtures/preview-server-app/source/real.html +1 -0
- data/fixtures/preview-server-app/source/real/index.html.erb +5 -0
- data/fixtures/preview-server-app/source/should_be_ignored.html +1 -0
- data/fixtures/preview-server-app/source/should_be_ignored2.html +1 -0
- data/fixtures/preview-server-app/source/should_be_ignored3.html +1 -0
- data/fixtures/preview-server-app/source/static.html +1 -0
- data/fixtures/relative-assets-app/source/absolute_image_relative_css.html.erb +9 -0
- data/fixtures/relative-assets-app/source/javascripts/app.js +3 -0
- data/fixtures/relative-assets-app/source/relative_image.html.erb +1 -0
- data/fixtures/relative-assets-app/source/relative_image_absolute_css.html.erb +9 -0
- data/lib/middleman-core/application.rb +11 -5
- data/lib/middleman-core/cli/build.rb +3 -1
- data/lib/middleman-core/cli/bundler.rb +1 -1
- data/lib/middleman-core/cli/extension.rb +2 -2
- data/lib/middleman-core/cli/init.rb +3 -3
- data/lib/middleman-core/cli/server.rb +9 -1
- data/lib/middleman-core/configuration.rb +0 -2
- data/lib/middleman-core/core_extensions/data.rb +2 -2
- data/lib/middleman-core/core_extensions/external_helpers.rb +2 -1
- data/lib/middleman-core/core_extensions/file_watcher.rb +7 -0
- data/lib/middleman-core/core_extensions/front_matter.rb +13 -4
- data/lib/middleman-core/core_extensions/rendering.rb +20 -6
- data/lib/middleman-core/core_extensions/request.rb +2 -2
- data/lib/middleman-core/dns_resolver.rb +73 -0
- data/lib/middleman-core/dns_resolver/basic_network_resolver.rb +52 -0
- data/lib/middleman-core/dns_resolver/hosts_resolver.rb +63 -0
- data/lib/middleman-core/dns_resolver/local_link_resolver.rb +44 -0
- data/lib/middleman-core/dns_resolver/network_resolver.rb +42 -0
- data/lib/middleman-core/extension.rb +0 -1
- data/lib/middleman-core/meta_pages.rb +1 -1
- data/lib/middleman-core/preview_server.rb +94 -37
- data/lib/middleman-core/preview_server/checks.rb +81 -0
- data/lib/middleman-core/preview_server/information.rb +273 -0
- data/lib/middleman-core/preview_server/network_interface_inventory.rb +65 -0
- data/lib/middleman-core/preview_server/server_hostname.rb +39 -0
- data/lib/middleman-core/preview_server/server_information.rb +144 -0
- data/lib/middleman-core/preview_server/server_information_validator.rb +18 -0
- data/lib/middleman-core/preview_server/server_ip_address.rb +55 -0
- data/lib/middleman-core/preview_server/server_url.rb +50 -0
- data/lib/middleman-core/preview_server/tcp_port_prober.rb +29 -0
- data/lib/middleman-core/sitemap.rb +4 -4
- data/lib/middleman-core/sitemap/extensions/ignores.rb +5 -1
- data/lib/middleman-core/sitemap/extensions/proxies.rb +0 -1
- data/lib/middleman-core/sitemap/extensions/redirects.rb +2 -1
- data/lib/middleman-core/sitemap/queryable.rb +2 -1
- data/lib/middleman-core/sitemap/store.rb +3 -3
- data/lib/middleman-core/step_definitions.rb +1 -0
- data/lib/middleman-core/step_definitions/builder_steps.rb +7 -7
- data/lib/middleman-core/step_definitions/commandline_steps.rb +88 -0
- data/lib/middleman-core/step_definitions/server_steps.rb +25 -28
- data/lib/middleman-core/templates/extension/Gemfile +0 -1
- data/lib/middleman-core/templates/extension/Rakefile +1 -1
- data/lib/middleman-core/util.rb +24 -0
- data/lib/middleman-core/version.rb +1 -1
- data/lib/middleman-more/core_extensions/default_helpers.rb +49 -8
- data/lib/middleman-more/core_extensions/i18n.rb +101 -27
- data/lib/middleman-more/extensions/asset_hash.rb +1 -1
- data/lib/middleman-more/extensions/asset_host.rb +1 -1
- data/lib/middleman-more/extensions/automatic_image_sizes.rb +7 -0
- data/lib/middleman-more/extensions/cache_buster.rb +1 -1
- data/lib/middleman-more/extensions/lorem.rb +2 -2
- data/lib/middleman-more/extensions/minify_javascript.rb +6 -4
- data/lib/middleman-more/extensions/relative_assets.rb +4 -8
- data/middleman-core.gemspec +3 -3
- data/spec/middleman-core/dns_resolver_spec.rb +118 -0
- data/spec/middleman-core/preview_server/server_hostname_spec.rb +39 -0
- data/spec/middleman-core/preview_server/server_ip_address_spec.rb +43 -0
- data/spec/spec_helper.rb +26 -0
- metadata +81 -17
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Middleman
|
|
2
|
+
class PreviewServer
|
|
3
|
+
# Validate user input
|
|
4
|
+
class ServerInformationValidator
|
|
5
|
+
# Validate the input
|
|
6
|
+
#
|
|
7
|
+
# @param [ServerInformation] information
|
|
8
|
+
# The information instance which holds information about the preview
|
|
9
|
+
# server settings
|
|
10
|
+
#
|
|
11
|
+
# @param [Array] checks
|
|
12
|
+
# A list of checks which should be evaluated
|
|
13
|
+
def validate(information, checks)
|
|
14
|
+
checks.each { |c| c.validate information }
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require 'ipaddr'
|
|
2
|
+
require 'forwardable'
|
|
3
|
+
|
|
4
|
+
module Middleman
|
|
5
|
+
class PreviewServer
|
|
6
|
+
class ServerIpAddress
|
|
7
|
+
def self.new(ip_address)
|
|
8
|
+
@parser = []
|
|
9
|
+
@parser << ServerIpv6Address
|
|
10
|
+
@parser << ServerIpv4Address
|
|
11
|
+
|
|
12
|
+
@parser.find { |p| p.match? ip_address }.new(ip_address)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class BasicServerIpAddress < SimpleDelegator
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class ServerIpv4Address < BasicServerIpAddress
|
|
20
|
+
def to_browser
|
|
21
|
+
__getobj__.to_s
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.match?(*)
|
|
25
|
+
true
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
class ServerIpv6Address < BasicServerIpAddress
|
|
30
|
+
def to_s
|
|
31
|
+
__getobj__.sub(/%.*$/, '')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def to_browser
|
|
35
|
+
format('[%s]', to_s)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
if RUBY_VERSION < '2'
|
|
39
|
+
def self.match?(str)
|
|
40
|
+
str = str.to_s.sub(/%.*$/, '')
|
|
41
|
+
IPAddr.new(str).ipv6?
|
|
42
|
+
rescue StandardError
|
|
43
|
+
false
|
|
44
|
+
end
|
|
45
|
+
else
|
|
46
|
+
def self.match?(str)
|
|
47
|
+
str = str.to_s.sub(/%.*$/, '')
|
|
48
|
+
IPAddr.new(str).ipv6?
|
|
49
|
+
rescue IPAddr::InvalidAddressError, IPAddr::AddressFamilyError
|
|
50
|
+
false
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'ipaddr'
|
|
2
|
+
|
|
3
|
+
module Middleman
|
|
4
|
+
class PreviewServer
|
|
5
|
+
# This builds the server urls for the preview server
|
|
6
|
+
class ServerUrl
|
|
7
|
+
private
|
|
8
|
+
|
|
9
|
+
attr_reader :hosts, :port, :https
|
|
10
|
+
|
|
11
|
+
public
|
|
12
|
+
|
|
13
|
+
def initialize(opts={})
|
|
14
|
+
@hosts = opts.fetch(:hosts)
|
|
15
|
+
@port = opts.fetch(:port)
|
|
16
|
+
@https = opts.fetch(:https, false)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Return bind addresses
|
|
20
|
+
#
|
|
21
|
+
# @return [Array]
|
|
22
|
+
# List of bind addresses of format host:port
|
|
23
|
+
def to_bind_addresses
|
|
24
|
+
hosts.map { |l| format('"%s:%s"', l.to_s, port) }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Return server urls
|
|
28
|
+
#
|
|
29
|
+
# @return [Array]
|
|
30
|
+
# List of urls of format http://host:port
|
|
31
|
+
def to_urls
|
|
32
|
+
hosts.map { |l| format('"%s://%s:%s"', https? ? 'https' : 'http', l.to_browser, port) }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Return server config urls
|
|
36
|
+
#
|
|
37
|
+
# @return [Array]
|
|
38
|
+
# List of urls of format http://host:port/__middleman
|
|
39
|
+
def to_config_urls
|
|
40
|
+
hosts.map { |l| format('"%s://%s:%s/__middleman"', https? ? 'https' : 'http', l.to_browser, port) }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
def https?
|
|
46
|
+
https == true
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Middleman
|
|
2
|
+
class PreviewServer
|
|
3
|
+
# Probe for tcp ports
|
|
4
|
+
#
|
|
5
|
+
# This one first tries `try_port` if this is not available use the free
|
|
6
|
+
# port returned by TCPServer.
|
|
7
|
+
class TcpPortProber
|
|
8
|
+
# Check for port
|
|
9
|
+
#
|
|
10
|
+
# @param [Integer] try_port
|
|
11
|
+
# The port to be checked
|
|
12
|
+
#
|
|
13
|
+
# @return [Integer]
|
|
14
|
+
# The port
|
|
15
|
+
def port(try_port)
|
|
16
|
+
server = TCPServer.open(try_port)
|
|
17
|
+
server.close
|
|
18
|
+
|
|
19
|
+
try_port
|
|
20
|
+
rescue
|
|
21
|
+
server = TCPServer.open(0)
|
|
22
|
+
port = server.addr[1]
|
|
23
|
+
server.close
|
|
24
|
+
|
|
25
|
+
port
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -28,16 +28,16 @@ module Middleman
|
|
|
28
28
|
root_dotfiles: proc { |file| file.start_with?('.') },
|
|
29
29
|
|
|
30
30
|
# Files starting with an dot, but not .htaccess
|
|
31
|
-
source_dotfiles: proc
|
|
31
|
+
source_dotfiles: proc do |file|
|
|
32
32
|
file =~ %r{/\.} && file !~ %r{/\.(htaccess|htpasswd|nojekyll)}
|
|
33
|
-
|
|
33
|
+
end,
|
|
34
34
|
|
|
35
35
|
# Files starting with an underscore, but not a double-underscore
|
|
36
36
|
partials: proc { |file| file =~ %r{/_[^_]} },
|
|
37
37
|
|
|
38
|
-
layout: proc
|
|
38
|
+
layout: proc do |file, sitemap_app|
|
|
39
39
|
file.start_with?(File.join(sitemap_app.config[:source], 'layout.')) || file.start_with?(File.join(sitemap_app.config[:source], 'layouts/'))
|
|
40
|
-
|
|
40
|
+
end
|
|
41
41
|
}, 'Callbacks that can exclude paths from the sitemap'
|
|
42
42
|
|
|
43
43
|
# Include instance methods
|
|
@@ -59,7 +59,11 @@ module Middleman
|
|
|
59
59
|
elsif path.is_a? String
|
|
60
60
|
path_clean = ::Middleman::Util.normalize_path(path)
|
|
61
61
|
if path_clean.include?('*') # It's a glob
|
|
62
|
-
|
|
62
|
+
if defined? File::FNM_EXTGLOB
|
|
63
|
+
@ignored_callbacks << proc { |p| File.fnmatch(path_clean, p, File::FNM_EXTGLOB) }
|
|
64
|
+
else
|
|
65
|
+
@ignored_callbacks << proc { |p| File.fnmatch(path_clean, p) }
|
|
66
|
+
end
|
|
63
67
|
else
|
|
64
68
|
# Add a specific-path ignore unless that path is already covered
|
|
65
69
|
return if ignored?(path_clean)
|
|
@@ -80,7 +80,7 @@ module Middleman
|
|
|
80
80
|
url = ::Middleman::Util.url_for(store.app, @request_path,
|
|
81
81
|
relative: false,
|
|
82
82
|
find_resource: true
|
|
83
|
-
|
|
83
|
+
)
|
|
84
84
|
|
|
85
85
|
if output
|
|
86
86
|
output.call(path, url)
|
|
@@ -88,6 +88,7 @@ module Middleman
|
|
|
88
88
|
<<-END
|
|
89
89
|
<html>
|
|
90
90
|
<head>
|
|
91
|
+
<link rel="canonical" href="#{url}" />
|
|
91
92
|
<meta http-equiv=refresh content="0; url=#{url}" />
|
|
92
93
|
<meta name="robots" content="noindex,follow" />
|
|
93
94
|
<meta http-equiv="cache-control" content="no-cache" />
|
|
@@ -125,7 +125,8 @@ module Middleman
|
|
|
125
125
|
unless VALID_OPERATORS.include? opts[:operator]
|
|
126
126
|
raise OperatorNotSupportedError
|
|
127
127
|
end
|
|
128
|
-
@attribute
|
|
128
|
+
@attribute = opts[:attribute]
|
|
129
|
+
@operator = opts[:operator]
|
|
129
130
|
end
|
|
130
131
|
end
|
|
131
132
|
end
|
|
@@ -231,10 +231,10 @@ module Middleman
|
|
|
231
231
|
private
|
|
232
232
|
|
|
233
233
|
def reset_lookup_cache!
|
|
234
|
-
@lock.synchronize
|
|
234
|
+
@lock.synchronize do
|
|
235
235
|
@_lookup_by_path = {}
|
|
236
236
|
@_lookup_by_destination_path = {}
|
|
237
|
-
|
|
237
|
+
end
|
|
238
238
|
end
|
|
239
239
|
|
|
240
240
|
# Removes the templating extensions, while keeping the others
|
|
@@ -242,7 +242,7 @@ module Middleman
|
|
|
242
242
|
# @return [String]
|
|
243
243
|
def remove_templating_extensions(path)
|
|
244
244
|
# Strip templating extensions as long as Tilt knows them
|
|
245
|
-
path = path.sub(File.extname(path)
|
|
245
|
+
path = path.sub(/#{::Regexp.escape(File.extname(path))}$/, '') while ::Tilt[path]
|
|
246
246
|
path
|
|
247
247
|
end
|
|
248
248
|
|
|
@@ -3,6 +3,7 @@ require 'aruba/jruby'
|
|
|
3
3
|
require 'middleman-core/step_definitions/middleman_steps'
|
|
4
4
|
require 'middleman-core/step_definitions/builder_steps'
|
|
5
5
|
require 'middleman-core/step_definitions/server_steps'
|
|
6
|
+
require 'middleman-core/step_definitions/commandline_steps'
|
|
6
7
|
|
|
7
8
|
# Monkeypatch for windows support
|
|
8
9
|
module ArubaMonkeypatch
|
|
@@ -6,8 +6,8 @@ end
|
|
|
6
6
|
|
|
7
7
|
Given /^app "([^\"]*)" is using config "([^\"]*)"$/ do |path, config_name|
|
|
8
8
|
target = File.join(PROJECT_ROOT_PATH, 'fixtures', path)
|
|
9
|
-
config_path = File.join(
|
|
10
|
-
config_dest = File.join(
|
|
9
|
+
config_path = File.join(current_directory, "config-#{config_name}.rb")
|
|
10
|
+
config_dest = File.join(current_directory, 'config.rb')
|
|
11
11
|
FileUtils.cp(config_path, config_dest)
|
|
12
12
|
end
|
|
13
13
|
|
|
@@ -22,12 +22,12 @@ Given /^a fixture app "([^\"]*)"$/ do |path|
|
|
|
22
22
|
|
|
23
23
|
# This step can be reentered from several places but we don't want
|
|
24
24
|
# to keep re-copying and re-cd-ing into ever-deeper directories
|
|
25
|
-
next if File.basename(
|
|
25
|
+
next if File.basename(current_directory) == path
|
|
26
26
|
|
|
27
27
|
step %Q{a directory named "#{path}"}
|
|
28
28
|
|
|
29
29
|
target_path = File.join(PROJECT_ROOT_PATH, 'fixtures', path)
|
|
30
|
-
FileUtils.cp_r(target_path,
|
|
30
|
+
FileUtils.cp_r(target_path, current_directory)
|
|
31
31
|
|
|
32
32
|
step %Q{I cd to "#{path}"}
|
|
33
33
|
end
|
|
@@ -58,12 +58,12 @@ Given /^a successfully built app at "([^\"]*)" with flags "([^\"]*)"$/ do |path,
|
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
Given /^a modification time for a file named "([^\"]*)"$/ do |file|
|
|
61
|
-
target = File.join(
|
|
61
|
+
target = File.join(current_directory, file)
|
|
62
62
|
@modification_times[target] = File.mtime(target)
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
Then /^the file "([^\"]*)" should not have been updated$/ do |file|
|
|
66
|
-
target = File.join(
|
|
66
|
+
target = File.join(current_directory, file)
|
|
67
67
|
File.mtime(target).should == @modification_times[target]
|
|
68
68
|
end
|
|
69
69
|
|
|
@@ -73,5 +73,5 @@ Then /^the file "([^"]*)" should contain '([^']*)'$/ do |file, partial_content|
|
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
And /the file "(.*)" should be gzipped/ do |file|
|
|
76
|
-
expect(File.binread(File.join(
|
|
76
|
+
expect(File.binread(File.join(current_directory, file), 2)).to eq(['1F8B'].pack('H*'))
|
|
77
77
|
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
When /^I stop (?:middleman|all commands) if the output( of the last command)? contains:$/ do |last_command, expected|
|
|
2
|
+
begin
|
|
3
|
+
Timeout.timeout(exit_timeout) do
|
|
4
|
+
loop do
|
|
5
|
+
fail "You need to start middleman interactively first." unless @interactive
|
|
6
|
+
|
|
7
|
+
if unescape(@interactive.output) =~ Regexp.new(unescape(expected))
|
|
8
|
+
only_processes.each { |p| p.terminate }
|
|
9
|
+
break
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
sleep 0.1
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
rescue ChildProcess::TimeoutError, TimeoutError
|
|
16
|
+
@interactive.terminate
|
|
17
|
+
ensure
|
|
18
|
+
announcer.stdout @interactive.stdout
|
|
19
|
+
announcer.stderr @interactive.stderr
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Make it just a long running process
|
|
24
|
+
Given /`(.*?)` is running in background/ do |cmd|
|
|
25
|
+
run(cmd, 120)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
Given /I have a local hosts file with:/ do |string|
|
|
29
|
+
step 'I set the environment variables to:', table(
|
|
30
|
+
%(
|
|
31
|
+
| variable | value |
|
|
32
|
+
| MM_HOSTSRC | .hosts |
|
|
33
|
+
)
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
step 'a file named ".hosts" with:', string
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
Given /I start a dns server with:/ do |string|
|
|
40
|
+
@dns_server.terminate if defined? @dns_server
|
|
41
|
+
|
|
42
|
+
port = 5300
|
|
43
|
+
db_file = 'dns.db'
|
|
44
|
+
|
|
45
|
+
step 'I set the environment variables to:', table(
|
|
46
|
+
%(
|
|
47
|
+
| variable | value |
|
|
48
|
+
| MM_DNSRC | 127.0.0.1:#{port}|
|
|
49
|
+
)
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
set_env 'PATH', File.expand_path(File.join(current_dir, 'bin')) + ':' + ENV['PATH']
|
|
53
|
+
write_file db_file, string
|
|
54
|
+
|
|
55
|
+
@dns_server = run("dns_server.rb #{db_file} #{port}", 120)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
Given /I start a mdns server with:/ do |string|
|
|
59
|
+
@mdns_server.terminate if defined? @mdns_server
|
|
60
|
+
|
|
61
|
+
port = 5301
|
|
62
|
+
db_file = 'mdns.db'
|
|
63
|
+
|
|
64
|
+
step 'I set the environment variables to:', table(
|
|
65
|
+
%(
|
|
66
|
+
| variable | value |
|
|
67
|
+
| MM_MDNSRC | 127.0.0.1:#{port}|
|
|
68
|
+
)
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
set_env 'PATH', File.expand_path(File.join(current_dir, 'bin')) + ':' + ENV['PATH']
|
|
72
|
+
write_file db_file, string
|
|
73
|
+
|
|
74
|
+
@mdns_server = run("dns_server.rb #{db_file} #{port}", 120)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
Given /I start a mdns server for the local hostname/ do
|
|
78
|
+
step %(I start a mdns server with:), "#{Socket.gethostname}: 127.0.0.1"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Make sure each and every process is really dead
|
|
82
|
+
After do
|
|
83
|
+
only_processes.each { |p| p.terminate }
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
Before '@ruby-2.1' do
|
|
87
|
+
skip_this_scenario if RUBY_VERSION < '2.1'
|
|
88
|
+
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
require 'rack/test'
|
|
1
|
+
require 'rspec/expectations'
|
|
2
|
+
require 'capybara/cucumber'
|
|
4
3
|
|
|
5
4
|
Given /^a clean server$/ do
|
|
6
5
|
@initialize_commands = []
|
|
@@ -32,8 +31,7 @@ Given /^current environment is "([^\"]*)"$/ do |env|
|
|
|
32
31
|
end
|
|
33
32
|
|
|
34
33
|
Given /^the Server is running$/ do
|
|
35
|
-
root_dir = File.expand_path(
|
|
36
|
-
|
|
34
|
+
root_dir = File.expand_path(current_directory)
|
|
37
35
|
|
|
38
36
|
if File.exists?(File.join(root_dir, 'source'))
|
|
39
37
|
ENV['MM_SOURCE'] = 'source'
|
|
@@ -49,7 +47,7 @@ Given /^the Server is running$/ do
|
|
|
49
47
|
set :show_exceptions, false
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
|
|
50
|
+
in_current_directory do
|
|
53
51
|
@server_inst = Middleman::Application.server.inst do
|
|
54
52
|
initialize_commands.each do |p|
|
|
55
53
|
instance_exec(&p)
|
|
@@ -57,8 +55,7 @@ Given /^the Server is running$/ do
|
|
|
57
55
|
end
|
|
58
56
|
end
|
|
59
57
|
|
|
60
|
-
|
|
61
|
-
@browser = ::Rack::Test::Session.new(::Rack::MockSession.new(app_rack))
|
|
58
|
+
Capybara.app = @server_inst.class.to_rack_app
|
|
62
59
|
end
|
|
63
60
|
|
|
64
61
|
Given /^the Server is running at "([^\"]*)"$/ do |app_path|
|
|
@@ -71,61 +68,61 @@ Given /^a template named "([^\"]*)" with:$/ do |name, string|
|
|
|
71
68
|
end
|
|
72
69
|
|
|
73
70
|
When /^I go to "([^\"]*)"$/ do |url|
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
in_current_directory do
|
|
72
|
+
visit(URI.encode(url).to_s)
|
|
76
73
|
end
|
|
77
74
|
end
|
|
78
75
|
|
|
79
76
|
Then /^going to "([^\"]*)" should not raise an exception$/ do |url|
|
|
80
|
-
|
|
81
|
-
expect{
|
|
77
|
+
in_current_directory do
|
|
78
|
+
expect{ visit(URI.encode(url).to_s) }.to_not raise_exception
|
|
82
79
|
end
|
|
83
80
|
end
|
|
84
81
|
|
|
85
82
|
Then /^the content type should be "([^\"]*)"$/ do |expected|
|
|
86
|
-
|
|
87
|
-
expect(
|
|
83
|
+
in_current_directory do
|
|
84
|
+
expect(page.response_headers['Content-Type']).to start_with expected
|
|
88
85
|
end
|
|
89
86
|
end
|
|
90
87
|
|
|
91
88
|
Then /^I should see "([^\"]*)"$/ do |expected|
|
|
92
|
-
|
|
93
|
-
expect(
|
|
89
|
+
in_current_directory do
|
|
90
|
+
expect(page.body).to include expected
|
|
94
91
|
end
|
|
95
92
|
end
|
|
96
93
|
|
|
97
94
|
Then /^I should see '([^\']*)'$/ do |expected|
|
|
98
|
-
|
|
99
|
-
expect(
|
|
95
|
+
in_current_directory do
|
|
96
|
+
expect(page.body).to include expected
|
|
100
97
|
end
|
|
101
98
|
end
|
|
102
99
|
|
|
103
100
|
Then /^I should see:$/ do |expected|
|
|
104
|
-
|
|
105
|
-
expect(
|
|
101
|
+
in_current_directory do
|
|
102
|
+
expect(page.body).to include expected
|
|
106
103
|
end
|
|
107
104
|
end
|
|
108
105
|
|
|
109
106
|
Then /^I should not see "([^\"]*)"$/ do |expected|
|
|
110
|
-
|
|
111
|
-
expect(
|
|
107
|
+
in_current_directory do
|
|
108
|
+
expect(page.body).not_to include expected
|
|
112
109
|
end
|
|
113
110
|
end
|
|
114
111
|
|
|
115
112
|
Then /^I should not see:$/ do |expected|
|
|
116
|
-
|
|
117
|
-
expect(
|
|
113
|
+
in_current_directory do
|
|
114
|
+
expect(page.body).not_to include expected
|
|
118
115
|
end
|
|
119
116
|
end
|
|
120
117
|
|
|
121
118
|
Then /^the status code should be "([^\"]*)"$/ do |expected|
|
|
122
|
-
|
|
123
|
-
expect(
|
|
119
|
+
in_current_directory do
|
|
120
|
+
expect(page.status_code).to eq expected.to_i
|
|
124
121
|
end
|
|
125
122
|
end
|
|
126
123
|
|
|
127
124
|
Then /^I should see "([^\"]*)" lines$/ do |lines|
|
|
128
|
-
|
|
129
|
-
expect(
|
|
125
|
+
in_current_directory do
|
|
126
|
+
expect(page.body.chomp.split($/).length).to eq lines.to_i
|
|
130
127
|
end
|
|
131
128
|
end
|