mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
more test fixes
This commit is contained in:
parent
765de5ab11
commit
d3d32731e1
7 changed files with 29 additions and 131 deletions
|
@ -197,13 +197,16 @@ Feature: Collections
|
||||||
Given a fixture app "collections-app"
|
Given a fixture app "collections-app"
|
||||||
And a file named "config.rb" with:
|
And a file named "config.rb" with:
|
||||||
"""
|
"""
|
||||||
|
Dir.chdir(ENV['MM_ROOT'])
|
||||||
|
ignore "/description_template.html"
|
||||||
|
|
||||||
live {
|
live {
|
||||||
Dir["descriptions/*.txt"]
|
Dir["descriptions/*.txt"]
|
||||||
}.each do |description_name|
|
}.each do |description_name|
|
||||||
base = File.basename(description_name, '.txt')
|
base = File.basename(description_name, '.txt')
|
||||||
proxy "#{base}.html", "/description_template.html", locals: {
|
proxy "#{base}.html", "/description_template.html", locals: {
|
||||||
contents: File.read(description_name)
|
contents: File.read(description_name)
|
||||||
}, ignore: true
|
}
|
||||||
end
|
end
|
||||||
"""
|
"""
|
||||||
And a file named "source/description_template.html.erb" with:
|
And a file named "source/description_template.html.erb" with:
|
||||||
|
@ -233,4 +236,4 @@ Feature: Collections
|
||||||
When I go to "test1.html"
|
When I go to "test1.html"
|
||||||
Then I should see 'Not Found'
|
Then I should see 'Not Found'
|
||||||
When I go to "test2.html"
|
When I go to "test2.html"
|
||||||
Then I should see 'Test2'
|
Then I should see 'Test2'
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
Feature: Honour working directory
|
|
||||||
Honour the working directory during testing
|
|
||||||
In order to support helpers which work with the current directories
|
|
||||||
|
|
||||||
Scenario: Set working directory for helpers in tests
|
|
||||||
Given a fixture app "empty-app"
|
|
||||||
And a file named "source/index.html.erb" with:
|
|
||||||
"""
|
|
||||||
<%= Dir.getwd %>
|
|
||||||
"""
|
|
||||||
And the Server is running
|
|
||||||
When I go to "/index.html"
|
|
||||||
Then I should see:
|
|
||||||
"""
|
|
||||||
aruba
|
|
||||||
"""
|
|
||||||
|
|
||||||
Scenario: Set working directory for config.rb in tests
|
|
||||||
Given a fixture app "empty-app"
|
|
||||||
And a file named "config.rb" with:
|
|
||||||
"""
|
|
||||||
set :my_working_directory, Dir.getwd
|
|
||||||
"""
|
|
||||||
And a file named "source/index.html.erb" with:
|
|
||||||
"""
|
|
||||||
<%= config[:my_working_directory] %>
|
|
||||||
"""
|
|
||||||
And the Server is running
|
|
||||||
When I go to "/index.html"
|
|
||||||
Then I should see:
|
|
||||||
"""
|
|
||||||
aruba
|
|
||||||
"""
|
|
|
@ -1,16 +0,0 @@
|
||||||
collection :articles,
|
|
||||||
where: proc { |resource|
|
|
||||||
uri_match resource.url, 'blog/{year}-{month}-{day}-{title}.html'
|
|
||||||
}
|
|
||||||
|
|
||||||
collection :tags,
|
|
||||||
where: proc { |resource|
|
|
||||||
resource.data.tags
|
|
||||||
},
|
|
||||||
group_by: proc { |resource|
|
|
||||||
if resource.data.tags.is_a? String
|
|
||||||
resource.data.tags.split(',').map(&:strip)
|
|
||||||
else
|
|
||||||
resource.data.tags
|
|
||||||
end
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<!-- ARTICLES -->
|
|
||||||
<% collected.articles.each do |article| %>
|
|
||||||
<li>
|
|
||||||
<a href="<%= article.url %>">Article: <%= article.data.title %></a>
|
|
||||||
<time><%= article.data.date.strftime('%b %e') %></time>
|
|
||||||
</li>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<!-- TAGS -->
|
|
||||||
<% collected[:tags].each do |k, items| %>
|
|
||||||
<li>
|
|
||||||
<%= k %>
|
|
||||||
<% items.each do |article| %>
|
|
||||||
<%= article.data.title %>
|
|
||||||
<% end %>
|
|
||||||
</li>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,15 +1,11 @@
|
||||||
Then /^the file "([^\"]*)" has the contents$/ do |path, contents|
|
Then /^the file "([^\"]*)" has the contents$/ do |path, contents|
|
||||||
write_file(path, contents)
|
File.write(File.expand_path(path), contents)
|
||||||
|
|
||||||
# cd(".") do
|
@server_inst.files.find_new_files!
|
||||||
@server_inst.files.find_new_files!
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the file "([^\"]*)" is removed$/ do |path|
|
Then /^the file "([^\"]*)" is removed$/ do |path|
|
||||||
step %Q{I remove the file "#{path}"}
|
File.delete(File.expand_path(path))
|
||||||
|
|
||||||
# cd(".") do
|
@server_inst.files.find_new_files!
|
||||||
@server_inst.files.find_new_files!
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -42,18 +42,16 @@ Given /^the Server is running$/ do
|
||||||
|
|
||||||
initialize_commands = @initialize_commands || []
|
initialize_commands = @initialize_commands || []
|
||||||
|
|
||||||
# cd(".") do
|
@server_inst = ::Middleman::Application.new do
|
||||||
@server_inst = ::Middleman::Application.new do
|
config[:watcher_disable] = true
|
||||||
config[:watcher_disable] = true
|
config[:show_exceptions] = false
|
||||||
config[:show_exceptions] = false
|
|
||||||
|
|
||||||
initialize_commands.each do |p|
|
initialize_commands.each do |p|
|
||||||
instance_exec(&p)
|
instance_exec(&p)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Capybara.app = ::Middleman::Rack.new(@server_inst).to_app
|
Capybara.app = ::Middleman::Rack.new(@server_inst).to_app
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Given /^the Server is running at "([^\"]*)"$/ do |app_path|
|
Given /^the Server is running at "([^\"]*)"$/ do |app_path|
|
||||||
|
@ -66,73 +64,49 @@ Given /^a template named "([^\"]*)" with:$/ do |name, string|
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^I go to "([^\"]*)"$/ do |url|
|
When /^I go to "([^\"]*)"$/ do |url|
|
||||||
# cd(".") do
|
visit(URI.encode(url).to_s)
|
||||||
visit(URI.encode(url).to_s)
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^going to "([^\"]*)" should not raise an exception$/ do |url|
|
Then /^going to "([^\"]*)" should not raise an exception$/ do |url|
|
||||||
# cd(".") do
|
expect{ visit(URI.encode(url).to_s) }.to_not raise_exception
|
||||||
expect{ visit(URI.encode(url).to_s) }.to_not raise_exception
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the content type should be "([^\"]*)"$/ do |expected|
|
Then /^the content type should be "([^\"]*)"$/ do |expected|
|
||||||
# cd(".") do
|
expect(page.response_headers['Content-Type']).to start_with expected
|
||||||
expect(page.response_headers['Content-Type']).to start_with expected
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see "([^\"]*)"$/ do |expected|
|
Then /^I should see "([^\"]*)"$/ do |expected|
|
||||||
# cd(".") do
|
expect(page.body).to include expected
|
||||||
expect(page.body).to include expected
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see '([^\']*)'$/ do |expected|
|
Then /^I should see '([^\']*)'$/ do |expected|
|
||||||
# cd(".") do
|
expect(page.body).to include expected
|
||||||
expect(page.body).to include expected
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see:$/ do |expected|
|
Then /^I should see:$/ do |expected|
|
||||||
# cd(".") do
|
expect(page.body).to include expected
|
||||||
expect(page.body).to include expected
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should not see "([^\"]*)"$/ do |expected|
|
Then /^I should not see "([^\"]*)"$/ do |expected|
|
||||||
# cd(".") do
|
expect(page.body).not_to include expected
|
||||||
expect(page.body).not_to include expected
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see content matching %r{(.*)}$/ do |expected|
|
Then /^I should see content matching %r{(.*)}$/ do |expected|
|
||||||
# cd(".") do
|
expect(page.body).to match(expected)
|
||||||
expect(page.body).to match(expected)
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should not see content matching %r{(.*)}$/ do |expected|
|
Then /^I should not see content matching %r{(.*)}$/ do |expected|
|
||||||
# cd(".") do
|
expect(page.body).to_not match(expected)
|
||||||
expect(page.body).to_not match(expected)
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should not see:$/ do |expected|
|
Then /^I should not see:$/ do |expected|
|
||||||
# cd(".") do
|
expect(page.body).not_to include expected
|
||||||
expect(page.body).not_to include expected
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the status code should be "([^\"]*)"$/ do |expected|
|
Then /^the status code should be "([^\"]*)"$/ do |expected|
|
||||||
# cd(".") do
|
expect(page.status_code).to eq expected.to_i
|
||||||
expect(page.status_code).to eq expected.to_i
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see "([^\"]*)" lines$/ do |lines|
|
Then /^I should see "([^\"]*)" lines$/ do |lines|
|
||||||
# cd(".") do
|
expect(page.body.chomp.split($/).length).to eq lines.to_i
|
||||||
expect(page.body.chomp.split($/).length).to eq lines.to_i
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -52,7 +52,7 @@ Gem::Specification.new do |s|
|
||||||
s.add_dependency('execjs', ['~> 2.0'])
|
s.add_dependency('execjs', ['~> 2.0'])
|
||||||
|
|
||||||
# Testing
|
# Testing
|
||||||
s.add_dependency('contracts', ['~> 0.9.0'])
|
s.add_dependency('contracts', ['~> 0.11.0'])
|
||||||
|
|
||||||
# Hash stuff
|
# Hash stuff
|
||||||
s.add_dependency('hashie', ['~> 3.4'])
|
s.add_dependency('hashie', ['~> 3.4'])
|
||||||
|
|
Loading…
Reference in a new issue