mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
cherry-pick test and source doc from #20050
This commit is contained in:
parent
ce3d2fa05a
commit
e6be33f1dd
3 changed files with 20 additions and 0 deletions
|
@ -503,6 +503,14 @@ Adds a specified source to `Gemfile`:
|
|||
add_source "http://gems.github.com"
|
||||
```
|
||||
|
||||
This method also takes a block:
|
||||
|
||||
```ruby
|
||||
add_source "http://gems.github.com" do
|
||||
gem "rspec-rails"
|
||||
end
|
||||
```
|
||||
|
||||
### `inject_into_file`
|
||||
|
||||
Injects a block of code into a defined position in your file.
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
* Adding support for passing a block to the `add_source` action of a custom generator
|
||||
|
||||
*Mike Dalton*, *Hirofumi Wakasugi*
|
||||
|
||||
* `assert_file` understands paths with special characters
|
||||
(eg. `v0.1.4~alpha+nightly`).
|
||||
|
||||
|
|
|
@ -47,6 +47,14 @@ class ActionsTest < Rails::Generators::TestCase
|
|||
assert_file 'Gemfile', /source 'http:\/\/gems\.github\.com'/
|
||||
end
|
||||
|
||||
def test_add_source_with_block_adds_source_to_gemfile_with_gem
|
||||
run_generator
|
||||
action :add_source, 'http://gems.github.com' do
|
||||
gem 'rspec-rails'
|
||||
end
|
||||
assert_file 'Gemfile', /source 'http:\/\/gems\.github\.com' do\n gem 'rspec-rails'\nend/
|
||||
end
|
||||
|
||||
def test_gem_should_put_gem_dependency_in_gemfile
|
||||
run_generator
|
||||
action :gem, 'will-paginate'
|
||||
|
|
Loading…
Reference in a new issue