Skip to content

Commit

Permalink
Merge pull request #10 from parndt/patch-2
Browse files Browse the repository at this point in the history
Updated readme for Ruby syntax highlighting
  • Loading branch information
stevehodgkiss committed Jul 25, 2012
2 parents 13a8b3e + 162335d commit ccd97c3
Showing 1 changed file with 50 additions and 44 deletions.
94 changes: 50 additions & 44 deletions README.md
Expand Up @@ -6,60 +6,66 @@ Test Rails generators with RSpec using the standard Rails::Generators::TestCase


Gemfile: Gemfile:


group :test do ```ruby
gem "generator_spec" group :test do
end gem "generator_spec"
end
```


Spec: Spec:


# spec/lib/generators/test/test_generator_spec.rb ```ruby
# spec/lib/generators/test/test_generator_spec.rb


require "generator_spec/test_case" require "generator_spec/test_case"

describe TestGenerator do
include GeneratorSpec::TestCase
destination File.expand_path("../../tmp", __FILE__)
arguments %w(something)


before(:all) do describe TestGenerator do
prepare_destination include GeneratorSpec::TestCase
run_generator destination File.expand_path("../../tmp", __FILE__)
end arguments %w(something)


it "creates a test initializer" do before(:all) do
assert_file "config/initializers/test.rb", "# Initializer" prepare_destination
end run_generator
end end

it "creates a test initializer" do
assert_file "config/initializers/test.rb", "# Initializer"
end
end
```


An RSpec file matching DSL is also provided, taken with permission from [beard](https://github.com/carlhuda/beard/blob/master/spec/support/matcher.rb) by [carlhuda](https://github.com/carlhuda). An RSpec file matching DSL is also provided, taken with permission from [beard](https://github.com/carlhuda/beard/blob/master/spec/support/matcher.rb) by [carlhuda](https://github.com/carlhuda).


describe TestGenerator, "using custom matcher" do ```ruby
include GeneratorSpec::TestCase describe TestGenerator, "using custom matcher" do
destination File.expand_path("../../tmp", __FILE__) include GeneratorSpec::TestCase
destination File.expand_path("../../tmp", __FILE__)
before do
prepare_destination before do
run_generator prepare_destination
end run_generator
end


specify do specify do
destination_root.should have_structure { destination_root.should have_structure {
no_file "test.rb" no_file "test.rb"
directory "config" do directory "config" do
directory "initializers" do directory "initializers" do
file "test.rb" do file "test.rb" do
contains "# Initializer" contains "# Initializer"
end
end
end end
directory "db" do end
directory "migrate" do end
file "123_create_tests.rb" directory "db" do
migration "create_tests" do directory "migrate" do
contains "class TestMigration" file "123_create_tests.rb"
end migration "create_tests" do
end contains "class TestMigration"
end end
} end
end end
end }
end
end
```

0 comments on commit ccd97c3

Please sign in to comment.