Class: Acop::RSpecWriter
- Inherits:
-
Object
- Object
- Acop::RSpecWriter
- Defined in:
- lib/acop/rspec_writer.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
writeonly
Sets the attribute file.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #append_file(url) ⇒ Object
- #close_file ⇒ Object
-
#initialize(url) ⇒ RSpecWriter
constructor
A new instance of RSpecWriter.
- #write_file(url) ⇒ Object
- #write_requires ⇒ Object
- #write_rspec(url) ⇒ Object
Constructor Details
#initialize(url) ⇒ RSpecWriter
Returns a new instance of RSpecWriter.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/acop/rspec_writer.rb', line 6 def initialize(url) @url = url Dir.mkdir("./spec") unless File.exists?("./spec") if File.exists?("./spec/acop_spec.rb") @file = File.open("./spec/acop_accessibility_spec.rb", 'a') append_file(@url) else @file = File.open("./spec/acop_accessibility_spec.rb", 'w') write_file(@url) end close_file end |
Instance Attribute Details
#file=(value) ⇒ Object (writeonly)
Sets the attribute file
3 4 5 |
# File 'lib/acop/rspec_writer.rb', line 3 def file=(value) @file = value end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'lib/acop/rspec_writer.rb', line 4 def url @url end |
Instance Method Details
#append_file(url) ⇒ Object
19 20 21 |
# File 'lib/acop/rspec_writer.rb', line 19 def append_file(url) write_rspec(url) end |
#close_file ⇒ Object
45 46 47 |
# File 'lib/acop/rspec_writer.rb', line 45 def close_file @file.close end |
#write_file(url) ⇒ Object
23 24 25 26 |
# File 'lib/acop/rspec_writer.rb', line 23 def write_file(url) write_requires write_rspec(url) end |
#write_requires ⇒ Object
28 29 30 |
# File 'lib/acop/rspec_writer.rb', line 28 def write_requires @file.puts "require 'rspec/expectations'" end |
#write_rspec(url) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/acop/rspec_writer.rb', line 32 def write_rspec(url) @file.puts "describe '#{url.chomp}' do" @file.puts " it 'should pass accessibility tests' do" @file.puts " output = `acop -u #{url.chomp}`" @file.puts " output = output.split(\"\\n\").reject! {|line| line[0] == '='}" @file.puts " puts '== ACCESSIBILITY ISSUES =='" @file.puts " puts output" @file.puts " output.should be_empty" @file.puts " end" @file.puts "end" @file.puts end |