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"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
Dir.chdir(ENV['MM_ROOT'])
|
||||
ignore "/description_template.html"
|
||||
|
||||
live {
|
||||
Dir["descriptions/*.txt"]
|
||||
}.each do |description_name|
|
||||
base = File.basename(description_name, '.txt')
|
||||
proxy "#{base}.html", "/description_template.html", locals: {
|
||||
contents: File.read(description_name)
|
||||
}, ignore: true
|
||||
}
|
||||
end
|
||||
"""
|
||||
And a file named "source/description_template.html.erb" with:
|
||||
|
@ -233,4 +236,4 @@ Feature: Collections
|
|||
When I go to "test1.html"
|
||||
Then I should see 'Not Found'
|
||||
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|
|
||||
write_file(path, contents)
|
||||
File.write(File.expand_path(path), contents)
|
||||
|
||||
# cd(".") do
|
||||
@server_inst.files.find_new_files!
|
||||
# end
|
||||
@server_inst.files.find_new_files!
|
||||
end
|
||||
|
||||
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!
|
||||
# end
|
||||
@server_inst.files.find_new_files!
|
||||
end
|
||||
|
|
|
@ -42,18 +42,16 @@ Given /^the Server is running$/ do
|
|||
|
||||
initialize_commands = @initialize_commands || []
|
||||
|
||||
# cd(".") do
|
||||
@server_inst = ::Middleman::Application.new do
|
||||
config[:watcher_disable] = true
|
||||
config[:show_exceptions] = false
|
||||
@server_inst = ::Middleman::Application.new do
|
||||
config[:watcher_disable] = true
|
||||
config[:show_exceptions] = false
|
||||
|
||||
initialize_commands.each do |p|
|
||||
instance_exec(&p)
|
||||
end
|
||||
initialize_commands.each do |p|
|
||||
instance_exec(&p)
|
||||
end
|
||||
end
|
||||
|
||||
Capybara.app = ::Middleman::Rack.new(@server_inst).to_app
|
||||
# end
|
||||
Capybara.app = ::Middleman::Rack.new(@server_inst).to_app
|
||||
end
|
||||
|
||||
Given /^the Server is running at "([^\"]*)"$/ do |app_path|
|
||||
|
@ -66,73 +64,49 @@ Given /^a template named "([^\"]*)" with:$/ do |name, string|
|
|||
end
|
||||
|
||||
When /^I go to "([^\"]*)"$/ do |url|
|
||||
# cd(".") do
|
||||
visit(URI.encode(url).to_s)
|
||||
# end
|
||||
visit(URI.encode(url).to_s)
|
||||
end
|
||||
|
||||
Then /^going to "([^\"]*)" should not raise an exception$/ do |url|
|
||||
# cd(".") do
|
||||
expect{ visit(URI.encode(url).to_s) }.to_not raise_exception
|
||||
# end
|
||||
expect{ visit(URI.encode(url).to_s) }.to_not raise_exception
|
||||
end
|
||||
|
||||
Then /^the content type should be "([^\"]*)"$/ do |expected|
|
||||
# cd(".") do
|
||||
expect(page.response_headers['Content-Type']).to start_with expected
|
||||
# end
|
||||
expect(page.response_headers['Content-Type']).to start_with expected
|
||||
end
|
||||
|
||||
Then /^I should see "([^\"]*)"$/ do |expected|
|
||||
# cd(".") do
|
||||
expect(page.body).to include expected
|
||||
# end
|
||||
expect(page.body).to include expected
|
||||
end
|
||||
|
||||
Then /^I should see '([^\']*)'$/ do |expected|
|
||||
# cd(".") do
|
||||
expect(page.body).to include expected
|
||||
# end
|
||||
expect(page.body).to include expected
|
||||
end
|
||||
|
||||
Then /^I should see:$/ do |expected|
|
||||
# cd(".") do
|
||||
expect(page.body).to include expected
|
||||
# end
|
||||
expect(page.body).to include expected
|
||||
end
|
||||
|
||||
Then /^I should not see "([^\"]*)"$/ do |expected|
|
||||
# cd(".") do
|
||||
expect(page.body).not_to include expected
|
||||
# end
|
||||
expect(page.body).not_to include expected
|
||||
end
|
||||
|
||||
Then /^I should see content matching %r{(.*)}$/ do |expected|
|
||||
# cd(".") do
|
||||
expect(page.body).to match(expected)
|
||||
# end
|
||||
expect(page.body).to match(expected)
|
||||
end
|
||||
|
||||
Then /^I should not see content matching %r{(.*)}$/ do |expected|
|
||||
# cd(".") do
|
||||
expect(page.body).to_not match(expected)
|
||||
# end
|
||||
expect(page.body).to_not match(expected)
|
||||
end
|
||||
|
||||
Then /^I should not see:$/ do |expected|
|
||||
# cd(".") do
|
||||
expect(page.body).not_to include expected
|
||||
# end
|
||||
expect(page.body).not_to include expected
|
||||
end
|
||||
|
||||
Then /^the status code should be "([^\"]*)"$/ do |expected|
|
||||
# cd(".") do
|
||||
expect(page.status_code).to eq expected.to_i
|
||||
# end
|
||||
expect(page.status_code).to eq expected.to_i
|
||||
end
|
||||
|
||||
Then /^I should see "([^\"]*)" lines$/ do |lines|
|
||||
# cd(".") do
|
||||
expect(page.body.chomp.split($/).length).to eq lines.to_i
|
||||
# end
|
||||
expect(page.body.chomp.split($/).length).to eq lines.to_i
|
||||
end
|
||||
|
|
|
@ -52,7 +52,7 @@ Gem::Specification.new do |s|
|
|||
s.add_dependency('execjs', ['~> 2.0'])
|
||||
|
||||
# Testing
|
||||
s.add_dependency('contracts', ['~> 0.9.0'])
|
||||
s.add_dependency('contracts', ['~> 0.11.0'])
|
||||
|
||||
# Hash stuff
|
||||
s.add_dependency('hashie', ['~> 3.4'])
|
||||
|
|
Loading…
Reference in a new issue