Module: Cog::SpecHelpers
- Extended by:
- SpecHelpers
- Included in:
- SpecHelpers
- Defined in:
- lib/cog/spec_helpers.rb,
lib/cog/spec_helpers/runner.rb,
lib/cog/spec_helpers/matchers.rb,
lib/cog/spec_helpers/matchers/match_maker.rb
Overview
Modules and classes to help write specs for testing cog
Requiring the helpers will make extra Matchers available to your RSpec tests. These are useful for testing a Invocation, which is returned from a call to Runner#run
Defined Under Namespace
Modules: Matchers Classes: Invocation, Runner
Instance Method Summary collapse
-
#active_fixture_dir ⇒ String
Directory of the active fixture.
-
#active_home_fixture_dir ⇒ String
Directory of the active home fixture.
-
#cog_directory ⇒ String
Path to the cog directory in the active spec fixture.
-
#cogfile_path ⇒ String
Path to the Cogfile in the active spec fixture.
-
#generated_file(filename) ⇒ String
Absolute path to the generated file.
-
#generator(name) ⇒ String
Path to the generator with the given name.
-
#plugin(name) ⇒ String
Absolute file system path to the plugin directory.
-
#spec_root ⇒ String
Absolute path to the root spec directory.
-
#template(name) ⇒ String
Absolute file system path to the template.
-
#use_fixture(name) ⇒ nil
The next cog spec will execute in a fresh copy of the given fixture Fixture directories are stored in
spec/fixtures
. -
#use_home_fixture(name) ⇒ nil
The next cog spec will execute in a fresh copy of the given home fixture Home fixture directories are stored in
spec/home_fixtures
.
Instance Method Details
#active_fixture_dir ⇒ String
Returns directory of the active fixture.
47 48 49 |
# File 'lib/cog/spec_helpers.rb', line 47 def active_fixture_dir File.join spec_root, 'active_fixture' end |
#active_home_fixture_dir ⇒ String
Returns directory of the active home fixture.
52 53 54 |
# File 'lib/cog/spec_helpers.rb', line 52 def active_home_fixture_dir File.join spec_root, 'active_home_fixture' end |
#cog_directory ⇒ String
Returns path to the cog directory in the active spec fixture.
62 63 64 |
# File 'lib/cog/spec_helpers.rb', line 62 def cog_directory File.join active_fixture_dir, 'cog' end |
#cogfile_path ⇒ String
Returns path to the Cogfile in the active spec fixture.
57 58 59 |
# File 'lib/cog/spec_helpers.rb', line 57 def cogfile_path File.join active_fixture_dir, 'Cogfile' end |
#generated_file(filename) ⇒ String
Returns absolute path to the generated file.
86 87 88 |
# File 'lib/cog/spec_helpers.rb', line 86 def generated_file(filename) File. File.join(active_fixture_dir, 'src', filename) end |
#generator(name) ⇒ String
Returns path to the generator with the given name.
68 69 70 |
# File 'lib/cog/spec_helpers.rb', line 68 def generator(name) File. File.join(active_fixture_dir, 'cog', 'generators', "#{name}.rb") end |
#plugin(name) ⇒ String
Returns absolute file system path to the plugin directory.
80 81 82 |
# File 'lib/cog/spec_helpers.rb', line 80 def plugin(name) File. File.join(active_fixture_dir, 'cog', 'plugins', name.to_s) end |
#spec_root ⇒ String
Returns absolute path to the root spec directory.
42 43 44 |
# File 'lib/cog/spec_helpers.rb', line 42 def spec_root File. File.join(File.dirname(__FILE__), '..', '..', 'spec') end |
#template(name) ⇒ String
Returns absolute file system path to the template.
74 75 76 |
# File 'lib/cog/spec_helpers.rb', line 74 def template(name) File. File.join(active_fixture_dir, 'cog', 'templates', name.to_s) end |
#use_fixture(name) ⇒ nil
The next cog spec will execute in a fresh copy of the given fixture Fixture directories are stored in spec/fixtures
.
94 95 96 97 98 99 |
# File 'lib/cog/spec_helpers.rb', line 94 def use_fixture(name) path = File.join spec_root, 'fixtures', name.to_s copy_fixture path, active_fixture_dir Dir.chdir active_fixture_dir nil end |
#use_home_fixture(name) ⇒ nil
The next cog spec will execute in a fresh copy of the given home fixture Home fixture directories are stored in spec/home_fixtures
105 106 107 108 109 |
# File 'lib/cog/spec_helpers.rb', line 105 def use_home_fixture(name) path = File.join spec_root, 'home_fixtures', name.to_s copy_fixture path, active_home_fixture_dir nil end |