A bit: Change beforeto before :all(instead :each).
: rake_require.
Rake.application.rake_require 'lib/tasks/demo_tasks',
[Rails.root.to_s],
[]
def rake_require(file_name, paths=$LOAD_PATH, loaded=$")
fn = file_name + ".rake"
return false if loaded.include?(fn)
...
$" - Ruby, , require.
, rake_require , Ruby. , : Ruby , , , , Ruby, rake .
before :all , , let : , , .
, ? - , .
:
describe "test tasks" do
before :all do
Rake.application = Rake::Application.new
Rake.application.rake_require 'lib/tasks/demo_tasks', [Rails.root.to_s]
Rake::Task.define_task :environment
end
describe "demo:test" do
it "runs" do
Rake::Task["demo:test"].invoke
end
end
end
before, Rake::Task:
before :all do
@rake = Rake::Application.new
Rake.application = @rake
Rake.application.rake_require 'lib/tasks/demo_tasks', [Rails.root.to_s]
Rake::Task.define_task :environment
end
describe "demo:test" do
it "runs" do
@rake["demo:test"].invoke
, . , .