Skip to content

Commit c9476b1

Browse files
committed
Merge pull request #91 from rusikf/patch-9
refactoring tests
2 parents d064e8d + 8e9147f commit c9476b1

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

test/lib/generators/haml/controller_generator_test.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
require 'lib/generators/haml/testing_helper'
33

44
class Haml::Generators::ControllerGeneratorTest < Rails::Generators::TestCase
5-
destination File.join(Rails.root)
5+
destination Rails.root
66
tests Rails::Generators::ControllerGenerator
7-
arguments %w(Account foo bar --template-engine haml)
87

98
setup :prepare_destination
109
setup :copy_routes
1110

12-
test "should invoke template engine" do
13-
run_generator
14-
assert_file "app/views/account/foo.html.haml", %r(app/views/account/foo\.html\.haml)
15-
assert_file "app/views/account/bar.html.haml", %r(app/views/account/bar\.html\.haml)
16-
end
11+
arguments %w(Account foo bar --template-engine haml)
12+
13+
test "should invoke haml engine" do
14+
run_generator
15+
assert_file "app/views/account/foo.html.haml"
16+
assert_file "app/views/account/bar.html.haml"
17+
end
1718
end

test/test_helper.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,24 @@
77
class TestApp < Rails::Application
88
config.root = File.dirname(__FILE__)
99
end
10-
Rails.application = TestApp
1110

1211
module Rails
1312
def self.root
1413
@root ||= File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp', 'rails'))
1514
end
1615
end
17-
Rails.application.config.root = Rails.root
1816

1917
# Call configure to load the settings from
2018
# Rails.application.config.generators to Rails::Generators
21-
Rails::Generators.configure! Rails.application.config.generators
19+
Rails.application.load_generators
2220

2321
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
2422

2523
def copy_routes
26-
routes = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'routes.rb'))
24+
routes = File.join(File.dirname(__FILE__), 'fixtures', 'routes.rb')
2725
destination = File.join(Rails.root, "config")
2826
FileUtils.mkdir_p(destination)
29-
FileUtils.cp File.expand_path(routes), destination
27+
FileUtils.cp File.expand_path(routes), File.expand_path(destination)
3028
end
3129

3230
# Asserts the given class exists in the given content. When a block is given,

0 commit comments

Comments
 (0)