Module: FixtureHelperMethods
- Defined in:
- lib/jasmine_fixtures.rb
Instance Method Summary collapse
-
#html_for(selector) ⇒ Object
From the controller spec response body, extracts html identified by the css selector.
-
#save_fixture(content, name) ⇒ Object
Saves the content to a fixture file using the given name.
Instance Method Details
#html_for(selector) ⇒ Object
From the controller spec response body, extracts html identified by the css selector.
18 19 20 21 22 23 24 25 |
# File 'lib/jasmine_fixtures.rb', line 18 def html_for(selector) doc = Nokogiri::HTML(response.body) remove_third_party_scripts(doc) content = doc.css(selector).first.to_s convert_body_tag_to_div(content) end |
#save_fixture(content, name) ⇒ Object
Saves the content to a fixture file using the given name
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/jasmine_fixtures.rb', line 3 def save_fixture(content, name) fixture_path = File.join(Rails.root, '/spec/javascripts/fixtures') FileUtils.mkdir_p(fixture_path) unless File.exists?(fixture_path) content = convert_body_tag_to_div(content) fixture_file = File.join(fixture_path, "#{name}") File.open(fixture_file, 'w') do |file| file.puts(content) end end |