-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added specs for all_fixtures.js.erb, improved error handling
- Loading branch information
Michael Crismali
committed
Apr 23, 2015
1 parent
bbb2048
commit 9b45544
Showing
5 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
<% all_fixtures = MagicLamp.generate_all_fixtures.to_json rescue nil %> | ||
|
||
<% if all_fixtures %> | ||
|
||
MagicLamp.genie.cacheOnly = true; | ||
MagicLamp.genie.cache = <%= MagicLamp.generate_all_fixtures.to_json %>; | ||
|
||
<% else %> | ||
|
||
throw new Error(MagicLamp.genericError); | ||
|
||
<% end %> |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require "rails_helper" | ||
|
||
describe "All fixtures js erb" do | ||
subject do | ||
sprockets_env = Sprockets::Environment.new | ||
sprockets_env.append_path("app/assets/javascripts/") | ||
sprockets_env["magic_lamp/all_fixtures.js"].to_s | ||
end | ||
|
||
it "sets cache only to true" do | ||
expect(subject).to match(/MagicLamp.genie.cacheOnly = true/) | ||
end | ||
|
||
it "provides all of the fixtures as json in the cache" do | ||
excaped_json = Regexp.escape(MagicLamp.generate_all_fixtures.to_json) | ||
expect(subject).to match(/MagicLamp.genie.cache = #{excaped_json}/) | ||
end | ||
|
||
it "does not throw an error" do | ||
expect(subject).to_not match(/throw new Error\(MagicLamp.genericError\)/) | ||
end | ||
|
||
context "errors" do | ||
before do | ||
allow(MagicLamp).to receive(:generate_all_fixtures).and_raise("Some error") | ||
end | ||
|
||
it "throws an error" do | ||
expect(subject).to match(/throw new Error\(MagicLamp.genericError\)/) | ||
end | ||
end | ||
end |