Sha256: 565a9e5cac6a2101a9c5595d32c095e84d6c95b44a485ca5b1f846b73ae5e934

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

require 'test_helper'
require 'generators/batman/view_generator'

class ViewGeneratorTest < Rails::Generators::TestCase
  tests Batman::Generators::ViewGenerator

  test "simple view" do
    run_generator %w(Task index show)

    assert_file "#{javascripts_path}/batman/views/task_view.js.coffee" do |view|
      view_class       = Regexp.escape("class Sample.TaskView extends Batman.View")
      view_index_class = Regexp.escape("class Sample.TaskIndexView extends Sample.TaskView")
      view_show_class  = Regexp.escape("class Sample.TaskShowView extends Sample.TaskView")

      assert_match /#{view_class}/, view
      assert_match /#{view_index_class}/, view
      assert_match /#{view_show_class}/, view
    end
  end

  test "view pluralization [singular]" do
    run_generator %w(Task)
    assert_file "#{javascripts_path}/batman/views/task_view.js.coffee" do |view|
      view_class = Regexp.escape("class Sample.TaskView extends Batman.View")
      assert_match /#{view_class}/, view
    end
  end

  test "view pluralization [plural]" do
    run_generator %w(Tasks)
    assert_file "#{javascripts_path}/batman/views/tasks_view.js.coffee" do |view|
      view_class = Regexp.escape("class Sample.TasksView extends Batman.View")
      assert_match /#{view_class}/, view
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
batman-rails-0.15.2 test/view_generator_test.rb
batman-rails-0.15.1 test/view_generator_test.rb
batman-rails-0.15.0 test/view_generator_test.rb