Permalink
Browse files

extconf's generated .autotest configured for test or spec files

  • Loading branch information...
1 parent 342a0da commit 48f816655cf7944a504c51cc5369c7be3434851a @drnic drnic committed Nov 8, 2008
View
@@ -11,6 +11,7 @@ Feature: Write and test C-extensions
And file 'ext/my_ext/my_ext.c' is created
And file 'test/test_my_ext_extn.rb' is created
And file '.autotest' is created
+ And contents of file '.autotest' does match /test\/test_.*_extn\.rb/
Scenario: Run extconf generator with name of extension on rspec project
Given an existing newgem scaffold using options '-T rspec' [called 'my_project']
@@ -20,6 +21,7 @@ Feature: Write and test C-extensions
And file 'ext/my_ext/my_ext.c' is created
And file 'spec/my_ext_extn_spec.rb' is created
And file '.autotest' is created
+ And contents of file '.autotest' does match /spec\/.*_extn_spec\.rb/
Scenario: Run unit tests after executable generator should all pass for test/unit
Given an existing newgem scaffold [called 'my_project']
View
@@ -114,6 +114,15 @@ def setup_active_project_folder project_name
actual_output.should_not(match(/#{regex}/))
end
+Then %r{^contents of file '(.*)' (does|does not) match \/(.*)\/} do |file, does, regex|
+ in_project_folder do
+ actual_output = File.read(file)
+ (does == 'does') ?
+ actual_output.should(match(/#{regex}/)) :
+ actual_output.should_not(match(/#{regex}/))
+ end
+end
+
Then %r{^all (\d+) tests pass} do |expected_test_count|
expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
actual_output = File.read(@stdout)
@@ -32,11 +32,15 @@ def manifest
m.file "tasks/extconf.rake", "tasks/extconf.rake"
m.file "tasks/extconf_name.rake", "tasks/extconf/#{name}.rake"
- m.file "autotest.rb", ".autotest"
+ m.template "autotest.rb.erb", ".autotest"
m.readme "README.txt"
end
end
+ def using_rspec?
+ !Dir[File.join(destination_root, 'spec')].empty?
+ end
+
protected
def banner
<<-EOS
@@ -49,7 +53,4 @@ def banner
EOS
end
- def using_rspec?
- !Dir[File.join(destination_root, 'spec')].empty?
- end
end
@@ -1,6 +1,10 @@
Autotest.add_hook :initialize do |at|
at.add_mapping(/ext\/.*\/(.*)\.[ch]/) do |_, m|
+ <% if using_rspec? -%>
+ ["spec/#{m[1]}_extn_spec.rb"]
+ <% else -%>
["test/test_#{m[1]}_extn.rb"]
+ <% end -%>
end
end
@@ -114,6 +114,15 @@ def setup_active_project_folder project_name
actual_output.should_not(match(/#{regex}/))
end
+Then %r{^contents of file '(.*)' (does|does not) match \/(.*)\/} do |file, does, regex|
+ in_project_folder do
+ actual_output = File.read(file)
+ (does == 'does') ?
+ actual_output.should(match(/#{regex}/)) :
+ actual_output.should_not(match(/#{regex}/))
+ end
+end
+
Then %r{^all (\d+) tests pass} do |expected_test_count|
expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
actual_output = File.read(@stdout)

0 comments on commit 48f8166

Please sign in to comment.