jasmine-rails 0.4.9 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/jasmine_rails/rspec.rb +8 -0
- data/lib/jasmine_rails/save_fixture.rb +43 -0
- data/lib/jasmine_rails/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 339815a911c1d5d3fdcdd0511764242d86cd8c90
|
4
|
+
data.tar.gz: f05e9405029133096f98263b75a2be56ac0353a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bf18be65fac776ce1367cf2c8b87d3c7c11dc08100d79111a12a66a6b0919cea01377a6e5081f041cf9a659e3f6495138588cc276b25fa7825215a0a581db02
|
7
|
+
data.tar.gz: be53a46065f51dc716d40fb832e018d5b999a431509e484f59b8c81636b91cc6f2cc2ffca6dcbda71585c9633d6edab3f31dcbf20a14deba66d4c78dd8c1004c
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
# Adds a save_fixture method takes the rendered content
|
4
|
+
# and stores it in a fixture file to be used with jasmine.
|
5
|
+
#
|
6
|
+
# example usage:
|
7
|
+
# save_fixture('name_of_fixture_file.html')
|
8
|
+
#
|
9
|
+
# jasmine-jquery can be configured to load the generated fixtures by:
|
10
|
+
# jasmine.getFixtures().fixturesPath = '/path/to/generated/fixture/directory';
|
11
|
+
#
|
12
|
+
# related resources:
|
13
|
+
# https://gist.github.com/725723
|
14
|
+
# http://pivotallabs.com/users/jb/blog/articles/1152-javascripttests-bind-reality-
|
15
|
+
module JasmineRails
|
16
|
+
module SaveFixture
|
17
|
+
FIXTURE_DIRECTORY = 'spec/javascripts/fixtures/generated'
|
18
|
+
|
19
|
+
# Saves the rendered as a fixture file.
|
20
|
+
def save_fixture(file_name, content = rendered)
|
21
|
+
fixture_path = File.join(Rails.root, FIXTURE_DIRECTORY, file_name)
|
22
|
+
fixture_directory = File.dirname(fixture_path)
|
23
|
+
FileUtils.mkdir_p fixture_directory unless File.exists?(fixture_directory)
|
24
|
+
|
25
|
+
File.open(fixture_path, 'w') do |file|
|
26
|
+
file.puts(content)
|
27
|
+
end
|
28
|
+
|
29
|
+
ignore_generated_fixtures
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
# create .gitignore to exclude generated fixtures from repository
|
35
|
+
def ignore_generated_fixtures
|
36
|
+
ignore_file = File.join(Rails.root, FIXTURE_DIRECTORY, '../.gitignore')
|
37
|
+
return if File.exists?(ignore_file)
|
38
|
+
File.open(ignore_file, 'w') do |file|
|
39
|
+
file.puts('generated')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jasmine-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Searls
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-11-
|
13
|
+
date: 2013-11-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -92,7 +92,9 @@ files:
|
|
92
92
|
- lib/jasmine-rails.rb
|
93
93
|
- lib/jasmine_rails/engine.rb
|
94
94
|
- lib/jasmine_rails/offline_asset_paths.rb
|
95
|
+
- lib/jasmine_rails/rspec.rb
|
95
96
|
- lib/jasmine_rails/runner.rb
|
97
|
+
- lib/jasmine_rails/save_fixture.rb
|
96
98
|
- lib/jasmine_rails/version.rb
|
97
99
|
- lib/tasks/jasmine-rails_tasks.rake
|
98
100
|
- MIT-LICENSE
|