Class: Showcase::PreviewsTest

Inherits:
ActionView::TestCase
  • Object
show all
Defined in:
lib/showcase/previews_test.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.inherited(test_class) ⇒ Object



4
5
6
7
# File 'lib/showcase/previews_test.rb', line 4

def self.inherited(test_class)
  super
  test_class.prepare
end

.prepareObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/showcase/previews_test.rb', line 9

def self.prepare
  tree = Showcase::Path.tree
  tree.flat_map(&:ordered_paths).each do |path|
    test "Showcase: automatically renders showcase/previews/#{path.id}" do
      render "showcase/engine/preview", preview: path.preview_for(view)
      assert_showcase_preview(path.id)
    end
  end

  test "Showcase: isn't empty" do
    assert_not_empty tree, "Showcase couldn't find any samples to generate tests for"
  end
end

.test(name = nil, showcase: nil, &block) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/showcase/previews_test.rb', line 23

def self.test(name = nil, showcase: nil, &block)
  if name
    super(name, &block)
  else
    super "Showcase: showcase/previews/#{showcase}" do
      path = Showcase::Path.new(showcase)
      render "showcase/engine/preview", preview: path.preview_for(view)

      assert_showcase_preview(path.id)
      instance_eval(&block)
    end
  end
end

Instance Method Details

#assert_showcase_preview(id) ⇒ Object

Override ‘assert_showcase_preview` to add custom assertions.



38
39
# File 'lib/showcase/previews_test.rb', line 38

def assert_showcase_preview(id)
end