Skip to content

Commit

Permalink
Merge pull request #13 from rpowelll/live-view-mode
Browse files Browse the repository at this point in the history
Check for valid LiveViewMode values
  • Loading branch information
ashfurrow authored Jul 28, 2016
2 parents 2f536ae + e6ef01b commit ccd267e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/playground_book_lint/page_manifest_linter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
module PlaygroundBookLint
# A linter for verifying the contents of a page's Manifest.plist
class PageManifestLinter < ManifestLinter
SUPPORTED_LIVE_VIEW_MODES = %w(VisibleByDefault HiddenByDefault).freeze

def lint
super()
# TODO: Check for valid LiveViewMode values.

live_view_mode = manifest_plist_contents['LiveViewMode']
unless live_view_mode.nil?
fail_lint "Unsopported LiveViewMoode '#{live_view_mode}'" unless SUPPORTED_LIVE_VIEW_MODES.include? live_view_mode
end
end
end
end
26 changes: 25 additions & 1 deletion spec/playground_book_lint/page_manifest_linter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module PlaygroundBookLint
include FakeFS::SpecHelpers
let(:page_manifest_linter) { PageManifestLinter.new }

it 'does not fail' do
it 'given a valid manifest does not fail' do
# TODO: We're not checking optional values yet, more tests to come.
# See page_manifest_linter.rb and https://github.com/ashfurrow/playground-book-lint/issues/3 for details.

Expand All @@ -15,5 +15,29 @@ module PlaygroundBookLint
expect { page_manifest_linter.lint }.to_not raise_error
end
end

describe 'context given a live view mode' do
it 'succeeds with valid values' do
FakeFS do
plist = {
'Name' => 'Test Page',
'LiveViewMode' => 'HiddenByDefault'
}.to_plist
File.open('Manifest.plist', 'w') { |f| f.write(plist) }
expect { page_manifest_linter.lint }.to_not raise_error
end
end

it 'fails with invalid values' do
FakeFS do
plist = {
'Name' => 'Test Page',
'LiveViewMode' => 'UnsupportedViewMode'
}.to_plist
File.open('Manifest.plist', 'w') { |f| f.write(plist) }
expect { page_manifest_linter.lint }.to raise_error(SystemExit)
end
end
end
end
end

0 comments on commit ccd267e

Please sign in to comment.