write some file change and deletion tests for better data coverage
This commit is contained in:
parent
b8b48afcbb
commit
86cd626084
8 changed files with 53 additions and 67 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -17,3 +17,4 @@ tmp
|
|||
Makefile
|
||||
.mm-pid-*
|
||||
.idea
|
||||
*.sublime-workspace
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
SimpleCov.start do
|
||||
add_filter '/features/'
|
||||
add_filter '/spec/'
|
||||
add_filter '/vendor'
|
||||
add_filter '/step_definitions/'
|
||||
end
|
|
@ -5,11 +5,35 @@ Feature: Local Data API
|
|||
Given the Server is running at "basic-data-app"
|
||||
When I go to "/data.html"
|
||||
Then I should see "One:Two"
|
||||
When the file "data/test.yml" has the contents
|
||||
"""
|
||||
-
|
||||
title: "Three"
|
||||
-
|
||||
title: "Four"
|
||||
"""
|
||||
When I go to "/data.html"
|
||||
Then I should see "Three:Four"
|
||||
When the file "data/test.yml" is removed
|
||||
When I go to "/data.html"
|
||||
Then I should see "No Test Data"
|
||||
|
||||
Scenario: Rendering json
|
||||
Given the Server is running at "basic-data-app"
|
||||
When I go to "/data3.html"
|
||||
Then I should see "One:Two"
|
||||
When the file "data/test2.json" has the contents
|
||||
"""
|
||||
[
|
||||
{ "title": "Three" },
|
||||
{ "title": "Four" }
|
||||
]
|
||||
"""
|
||||
When I go to "/data3.html"
|
||||
Then I should see "Three:Four"
|
||||
When the file "data/test2.json" is removed
|
||||
When I go to "/data3.html"
|
||||
Then I should see "No Test Data"
|
||||
|
||||
Scenario: Using data in config.rb
|
||||
Given the Server is running at "data-app"
|
||||
|
|
|
@ -1 +1,5 @@
|
|||
<%= data.test.map { |r| r.title }.join(":") %>
|
||||
<% if data.respond_to?(:test) %>
|
||||
<%= data.test.map { |r| r.title }.join(":") %>
|
||||
<% else %>
|
||||
No Test Data
|
||||
<% end %>
|
|
@ -1 +1,5 @@
|
|||
<%= data.test2.map { |r| r.title }.join(":") %>
|
||||
<% if data.respond_to?(:test2) %>
|
||||
<%= data.test2.map { |r| r.title }.join(":") %>
|
||||
<% else %>
|
||||
No Test Data
|
||||
<% end %>
|
|
@ -170,7 +170,7 @@ module Middleman
|
|||
# @private
|
||||
# @return [Middleman::Util::Cache] The cache
|
||||
def self.cache
|
||||
@_cache ||= ::Middleman::Util::Cache.new
|
||||
@_cache ||= ::Tilt::Cache.new
|
||||
end
|
||||
delegate :cache, :to => :"self.class"
|
||||
|
||||
|
|
|
@ -146,62 +146,5 @@ module Middleman
|
|||
end
|
||||
end.flatten.compact
|
||||
end
|
||||
|
||||
# Simple shared cache implementation
|
||||
class Cache
|
||||
# Initialize
|
||||
def initialize
|
||||
self.clear
|
||||
end
|
||||
|
||||
# Either get the cached key or save the contents of the block
|
||||
#
|
||||
# @param key Anything Hash can use as a key
|
||||
def fetch(*key)
|
||||
@cache[key] ||= yield
|
||||
end
|
||||
|
||||
# Whether the key is in the cache
|
||||
#
|
||||
# @param key Anything Hash can use as a key
|
||||
# @return [Boolean]
|
||||
def has_key?(key)
|
||||
@cache.has_key?(key)
|
||||
end
|
||||
|
||||
# Get a specific key
|
||||
#
|
||||
# @param key Anything Hash can use as a key
|
||||
def get(key)
|
||||
@cache[key]
|
||||
end
|
||||
|
||||
# Array of keys
|
||||
# @return [Array]
|
||||
def keys
|
||||
@cache.keys
|
||||
end
|
||||
|
||||
# Clear the entire cache
|
||||
# @return [void]
|
||||
def clear
|
||||
@cache = {}
|
||||
end
|
||||
|
||||
# Set a specific key
|
||||
#
|
||||
# @param key Anything Hash can use as a key
|
||||
# @param value Cached value
|
||||
# @return [void]
|
||||
def set(key, value)
|
||||
@cache[key] = value
|
||||
end
|
||||
|
||||
# Remove a specific key
|
||||
# @param key Anything Hash can use as a key
|
||||
def remove(*key)
|
||||
@cache.delete(key)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
16
middleman.sublime-project
Normal file
16
middleman.sublime-project
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"folders":
|
||||
[
|
||||
{
|
||||
"path": ".",
|
||||
"folder_exclude_patterns": [".sass-cache", ".bundle", "tmp", "coverage"],
|
||||
"file_exclude_patterns": ["*.sublime-workspace"]
|
||||
}
|
||||
],
|
||||
|
||||
"settings":
|
||||
{
|
||||
"tab_size": 2,
|
||||
"translate_tabs_to_spaces": true
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue