jasmine-fixtures-generator 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Jasmine Fixtures Generator [![Build Status](http://travis-ci.org/lporras/jasmine-fixtures-generator.png)](http://travis-ci.org/lporras/jasmine-fixtures-generator)
2
- Fixtures Generator for Jasmine under Rails 3.x (largelly based in [jasmine-fixtures](https://github.com/mavenlink/jasmine-fixtures) for Rails 2.x)
2
+ Fixtures Generator for Jasmine under Rails 3.x using rspec_controller or funtionals tests (largelly based in [jasmine-fixtures](https://github.com/mavenlink/jasmine-fixtures) for Rails 2.x)
3
3
 
4
4
 
5
5
  ## Installation
@@ -15,7 +15,13 @@ Add it to your Gemfile:
15
15
  Add the require in spec_helper.rb
16
16
 
17
17
  require 'jasmine_fixtures'
18
- '
18
+
19
+ or
20
+
21
+ Add the require in test_helper.rb if you don't use rspec
22
+
23
+ require 'jasmine_fixtures'
24
+
19
25
  ## Usage
20
26
 
21
27
  Run the generator:
@@ -17,6 +17,8 @@ require 'spec_helper'
17
17
  Using save_fixture method
18
18
  -------------------------
19
19
 
20
+ save_fixture('content', 'file_name.html') => will create a file called file_name.html on spec/javascripts/fixtures
21
+
20
22
  html_for('body') => will take only the content of <body> tag and will rename <body> to <div>
21
23
  to avoid nested <body> tags within the Jasmine runner
22
24
 
@@ -27,6 +29,8 @@ you can subvert this and use response.body or whatever is appropriate.
27
29
 
28
30
  ####Examples
29
31
 
32
+ #Rspec
33
+
30
34
  describe UsersController do
31
35
  #You need to render_views in each of your describes to get the content of the response
32
36
  render_views
@@ -36,7 +40,7 @@ describe UsersController do
36
40
  it "generates a new user signup page" do
37
41
  get :new
38
42
  response.should be_success
39
- save_fixture(html_for('body'), 'user-signup-page')
43
+ save_fixture(html_for('body'), 'user-signup-page.html')
40
44
  end
41
45
 
42
46
  #Example of an ajax request that doesn't have a body tag to strip out
@@ -48,4 +52,23 @@ describe UsersController do
48
52
  end
49
53
  end
50
54
  end
51
- end
55
+ end
56
+
57
+ #Funtionals
58
+
59
+ class UsersControllerTest < ActionController::TestCase
60
+
61
+ #Example of a standard request that would use html_for to strip <body>
62
+ test "GET#new generates a new user signup page" do
63
+ get :new
64
+ assert_response :success
65
+ save_fixture(html_for('body'), 'user-signup-page')
66
+ end
67
+
68
+ #Example of an ajax request that doesn't have a body tag to strip out
69
+ test "ajax POST#create generates successful signup response" do
70
+ post :create, :user => { :name => 'Bob', :password => 'something', :password_confirmation => 'something' }, :format => :js
71
+ assert_response :success
72
+ save_fixture(response.body, 'user-success-ajax-response')
73
+ end
74
+ end
@@ -1,7 +1,7 @@
1
1
  module Jasmine
2
2
  module Fixtures
3
3
  module Generator
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
6
6
  end
7
7
  end
@@ -47,4 +47,6 @@ end
47
47
 
48
48
  # Add fixture-generation methods to ControllerExampleGroup
49
49
  RSpec::Rails::ControllerExampleGroup.extend(FixtureHelperMethods) if defined?(RSpec)
50
- ActionController::TestCase.extend(FixtureHelperMethods) if defined?(ActionController::TestCase)
50
+ ActionController::TestCase.send(:include, FixtureHelperMethods) if defined?(ActionController::TestCase)
51
+
52
+ include FixtureHelperMethods
@@ -2,7 +2,6 @@ require 'test_helper'
2
2
  require 'jasmine_fixtures'
3
3
 
4
4
  class FixtureHelperMethodsTest < ActiveSupport::TestCase
5
- include FixtureHelperMethods
6
5
 
7
6
  test "#save_fixture creates an html file with the given name" do
8
7
  save_fixture("<p>prueba</p>", "test_file.html")
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Luis Porras