-
-
Save kivanio/b5156b84c3c85f663694 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module JasmineFixtures | |
extend ActiveSupport::Concern | |
# Saves the markup to a fixture file using the given name | |
def save_fixture(name) | |
response.should be_success | |
fixture_path = File.join(Rails.root, '/spec/javascripts/fixtures') | |
fixture_file = File.join(fixture_path, name) | |
fixture = case name | |
when /\.html$/ | |
response.body.sub(/.*<body/im, '<div').sub(/<\/body>.*/im, "</div>") | |
when /\.json$/ | |
JSON.pretty_generate(JSON.load(response.body)) | |
else | |
response.body | |
end | |
File.open(fixture_file, 'w') { |file| file.write(fixture)} | |
end | |
included do | |
include RSpec::Rails::ControllerExampleGroup | |
include ControllerMacros | |
render_views | |
before do | |
DatabaseCleaner.clean_with(:truncation) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment