Class: TestCase
- Inherits:
-
Object
- Object
- TestCase
- Defined in:
- lib/zfben_hanoi/test_case.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #content ⇒ Object
- #create_temp_directory ⇒ Object
- #exist? ⇒ Boolean
- #html_fixtures ⇒ Object
-
#initialize(path, test_directory) ⇒ TestCase
constructor
A new instance of TestCase.
- #name ⇒ Object
- #relative_path ⇒ Object
- #target ⇒ Object
- #temp_directory ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(path, test_directory) ⇒ TestCase
Returns a new instance of TestCase.
4 5 6 |
# File 'lib/zfben_hanoi/test_case.rb', line 4 def initialize(path, test_directory) @path, @test_directory = path, test_directory end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
2 3 4 |
# File 'lib/zfben_hanoi/test_case.rb', line 2 def path @path end |
Instance Method Details
#content ⇒ Object
16 17 18 |
# File 'lib/zfben_hanoi/test_case.rb', line 16 def content File.new(@path).read end |
#create_temp_directory ⇒ Object
32 33 34 |
# File 'lib/zfben_hanoi/test_case.rb', line 32 def create_temp_directory FileUtils.mkdir_p temp_directory end |
#exist? ⇒ Boolean
20 21 22 |
# File 'lib/zfben_hanoi/test_case.rb', line 20 def exist? File.exist?(path) end |
#html_fixtures ⇒ Object
40 41 42 43 44 |
# File 'lib/zfben_hanoi/test_case.rb', line 40 def html_fixtures path = File.dirname(File.(@path).gsub(@test_directory, "#{@test_directory}/fixtures")) path = File.(path + "/#{name.gsub(/(_test|_spec)/, '_fixtures.html')}") File.new(path).read rescue "" end |
#name ⇒ Object
8 9 10 |
# File 'lib/zfben_hanoi/test_case.rb', line 8 def name @name ||= File.basename(@path, '.js') end |
#relative_path ⇒ Object
24 25 26 |
# File 'lib/zfben_hanoi/test_case.rb', line 24 def relative_path @relative_path ||= @path.gsub("#{@test_directory}/", "") end |
#target ⇒ Object
12 13 14 |
# File 'lib/zfben_hanoi/test_case.rb', line 12 def target "/javascripts/#{relative_path.gsub(/(_test|_spec)/, '')}" end |
#temp_directory ⇒ Object
36 37 38 |
# File 'lib/zfben_hanoi/test_case.rb', line 36 def temp_directory @temp_directory ||= File.dirname(File.(@path).gsub(@test_directory, "#{@test_directory}/tmp")) end |
#url ⇒ Object
28 29 30 |
# File 'lib/zfben_hanoi/test_case.rb', line 28 def url "/test/#{relative_path.gsub('.js', '')}.html" end |