Skip to content

Commit

Permalink
Updated scaffold generator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iceburging committed Jan 22, 2010
1 parent 529bf9a commit b6ed84e
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions test/test_nifty_scaffold_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -504,19 +504,51 @@ class TestNiftyScaffoldGenerator < Test::Unit::TestCase
end
end

context "generator with factory_girl specified" do
rails_generator :nifty_scaffold, "line_item", "name:string", :fixture_framework => :factory_girl

should "have factory.rb file" do
assert_generated_file "test/factories.rb" do |body|
assert_match " Factory.define :line_item ", body
end
end

should "have controller tests using factories"
assert_generated_file "test/functional/line_items_controller_test.rb" do |body|
assert_match " Factory.", body
end
end
end

context "generator with shoulda and factory_girl specified" do
rails_generator :nifty_scaffold, "line_item", "name:string", :test_framework => :shoulda, :fixture_framework => :factory_girl

should "have controller and model tests using factories" do
should "have factory.rb file" do
assert_generated_file "test/factories.rb" do |body|
assert_match " Factory.define :line_item ", body
end
end

should "have controller tests using factories"
assert_generated_file "test/functional/line_items_controller_test.rb" do |body|
assert_match " Factory.", body
end
end
end

#TODO add an assertion for unit test
context "generator with rspec and factory_girl specified" do
rails_generator :nifty_scaffold, "line_item", "name:string", :test_framework => :rspec, :fixture_framework => :factory_girl

should "have factory.rb file" do
assert_generated_file "spec/factories.rb" do |body|
assert_match " Factory.define :line_item ", body
end
end

should "have controller tests using factories"
assert_generated_file "spec/controllers/line_items_controller_spec.rb" do |body|
assert_match " Factory.", body
end
end
end

Expand Down

0 comments on commit b6ed84e

Please sign in to comment.