test/test_helper_generator.rb in padrino-gen-0.12.8.1 vs test/test_helper_generator.rb in padrino-gen-0.12.9
- old
+ new
@@ -17,10 +17,15 @@
out, err = capture_io { generate(:helper, 'demo', "-r=#{@apptmp}") }
assert_match(/not at the root/, out)
assert_no_file_exists("#{@apptmp}/app/helpers/demo_helper.rb")
end
+ it 'should fail with NameError if given invalid namespace names' do
+ capture_io { generate(:project, "sample", "--root=#{@apptmp}") }
+ assert_raises(::NameError) { capture_io { generate(:helper, "wrong/name", "--root=#{@apptmp}/sample") } }
+ end
+
it 'should generate helper within existing project' do
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon') }
capture_io { generate(:helper, 'DemoItems', "-r=#{@apptmp}/sample_project") }
assert_match_in_file(/module SampleProject/, @helper_path)
assert_match_in_file(/class App/, @helper_path)
@@ -91,9 +96,17 @@
it 'should generate helper test for steak' do
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=steak') }
capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
capture_io { generate(:helper, 'DemoItems','-a=/subby', "-r=#{@apptmp}/sample_project") }
assert_match_in_file(/describe "SampleProject::Subby::DemoItemsHelper" do/m, "#{@apptmp}/sample_project/spec/subby/helpers/demo_items_helper_spec.rb")
+ end
+
+ it "should generate helper test for testunit" do
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=testunit', '--script=none') }
+ capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
+ capture_io { generate(:helper, 'DemoItems','-a=/subby', "-r=#{@apptmp}/sample_project") }
+ assert_match_in_file(/class DemoItemsHelperTest < Test::Unit::TestCase/m, "#{@apptmp}/sample_project/test/subby/helpers/demo_items_helper_test.rb")
+ assert_match_in_file(/@helpers\.extend SampleProject::Subby::DemoItemsHelper/m, "#{@apptmp}/sample_project/test/subby/helpers/demo_items_helper_test.rb")
end
it 'should correctly generate file names' do
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=rspec') }
capture_io { generate(:helper, 'DemoItems', "-r=#{@apptmp}/sample_project") }