framework_fixture 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -5,4 +5,5 @@ rvm:
5
5
  - 1.9.3
6
6
  env:
7
7
  - RAILS=3
8
- - SINATRA=1
8
+ - SINATRA=1
9
+ - STASIS=0
@@ -6,7 +6,7 @@ $:.unshift lib unless $:.include?(lib)
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "framework_fixture"
9
- s.version = '0.2.0'
9
+ s.version = '0.2.1'
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.authors = ["Winton Welsh"]
12
12
  s.email = ["mail@wintoni.us"]
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.add_development_dependency "rails", "~> 3.0"
24
24
  s.add_development_dependency "sinatra", "~> 1.0"
25
25
  s.add_development_dependency "rspec", "~> 1.0"
26
+ s.add_development_dependency "stasis", "~> 0.0"
26
27
 
27
28
  s.add_dependency "rack-test", "=0.6.1"
28
29
  end
@@ -31,31 +31,34 @@ class FrameworkFixture
31
31
  @build += "/sinatra#{@exact_version[0..0]}"
32
32
  @app = lambda { Application.new }
33
33
  req = @build + "/application.rb"
34
+ elsif stasis
35
+ @build += "/stasis#{@exact_version[0..0]}"
36
+ @app = lambda do
37
+ Stasis.new(@build, "#{@build}_output")
38
+ end
34
39
  end
35
40
 
36
- if req
37
- if !File.exists?(req)
38
- if cmd
39
- puts "Generating framework build: #{cmd}"
40
- puts `#{cmd}`
41
- else
42
- FileUtils.mkdir_p @build
43
- end
41
+ unless File.exists?(@build)
42
+ if cmd
43
+ puts "Generating framework build: #{cmd}"
44
+ puts `#{cmd}`
45
+ else
46
+ FileUtils.mkdir_p @build
44
47
  end
45
-
46
- if config = @config[@framework][@loose_version]
47
- config.each do |dir, files|
48
- files.each do |f|
49
- if File.exists?(from = "#{@root}/#{dir}/#{File.basename(f)}")
50
- FileUtils.mkdir_p File.dirname("#{@build}/#{f}")
51
- FileUtils.cp from, "#{@build}/#{f}"
52
- end
48
+ end
49
+
50
+ if @config[@framework] && config = @config[@framework][@loose_version]
51
+ config.each do |dir, files|
52
+ files.each do |f|
53
+ if File.exists?(from = "#{@root}/#{dir}/#{File.basename(f)}")
54
+ FileUtils.mkdir_p File.dirname("#{@build}/#{f}")
55
+ FileUtils.cp from, "#{@build}/#{f}"
53
56
  end
54
57
  end
55
58
  end
56
-
57
- require req
58
59
  end
60
+
61
+ require req if req
59
62
  end
60
63
 
61
64
  def generate(root)
@@ -71,10 +74,6 @@ class FrameworkFixture
71
74
  @config = YAML::load(@config)
72
75
  end
73
76
 
74
- def rails
75
- @loose_version if @framework == 'rails'
76
- end
77
-
78
77
  def require_gem
79
78
  set_vars
80
79
 
@@ -89,10 +88,12 @@ class FrameworkFixture
89
88
  @framework = 'rails'
90
89
  elsif ENV['SINATRA']
91
90
  @framework = 'sinatra'
91
+ elsif ENV['STASIS']
92
+ @framework = 'stasis'
92
93
  end
93
94
 
94
95
  if @framework
95
- @loose_version = ENV['RAILS'] || ENV['SINATRA']
96
+ @loose_version = ENV['RAILS'] || ENV['SINATRA'] || ENV['STASIS']
96
97
 
97
98
  if @loose_version.match(/\d*/)[0].length == @loose_version.length
98
99
  @loose_version = "<#{@loose_version.to_i + 1}"
@@ -100,8 +101,10 @@ class FrameworkFixture
100
101
  end
101
102
  end
102
103
 
103
- def sinatra
104
- @loose_version if @framework == 'sinatra'
104
+ %w(rails sinatra stasis).each do |method|
105
+ define_method method do
106
+ @loose_version if @framework == method
107
+ end
105
108
  end
106
109
 
107
110
  FrameworkFixture.set_vars
@@ -3,15 +3,20 @@ require 'spec_helper'
3
3
  if FrameworkFixture.framework
4
4
  describe FrameworkFixture do
5
5
 
6
- include Rack::Test::Methods
7
-
8
- def app
9
- FrameworkFixture.app.call
6
+ unless ENV['STASIS']
7
+ include Rack::Test::Methods
8
+
9
+ def app
10
+ FrameworkFixture.app.call
11
+ end
10
12
  end
11
13
 
12
14
  before(:all) do
13
- @framework = ENV['RAILS'] ? 'rails' : ENV['SINATRA'] ? 'sinatra' : nil
14
- @exact_version = ENV['RAILS'] || ENV['SINATRA']
15
+ @framework = ENV['RAILS'] ?
16
+ 'rails' : ENV['SINATRA'] ?
17
+ 'sinatra' : ENV['STASIS'] ?
18
+ 'stasis' : nil
19
+ @exact_version = ENV['RAILS'] || ENV['SINATRA'] || ENV['STASIS']
15
20
  @loose_version = @exact_version ? "<#{@exact_version.to_i + 1}" : nil
16
21
  end
17
22
 
@@ -80,16 +85,22 @@ if FrameworkFixture.framework
80
85
  req += "/config/environment.rb"
81
86
  elsif @framework == 'sinatra'
82
87
  req += "/application.rb"
88
+ elsif @framework == 'stasis'
89
+ req = nil
90
+ end
91
+ if req
92
+ $".include?(req).should == true
83
93
  end
84
- $".include?(req).should == true
85
94
  end
86
95
  end
87
96
 
88
- describe :rack_test do
89
-
90
- it "should have a pulse" do
91
- get "/pulse"
92
- last_response.body.should == '1'
97
+ unless ENV['STASIS']
98
+ describe :rack_test do
99
+
100
+ it "should have a pulse" do
101
+ get "/pulse"
102
+ last_response.body.should == '1'
103
+ end
93
104
  end
94
105
  end
95
106
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: framework_fixture
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -75,6 +75,22 @@ dependencies:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
77
  version: '1.0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: stasis
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '0.0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '0.0'
78
94
  - !ruby/object:Gem::Dependency
79
95
  name: rack-test
80
96
  requirement: !ruby/object:Gem::Requirement
@@ -130,18 +146,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
146
  - - ! '>='
131
147
  - !ruby/object:Gem::Version
132
148
  version: '0'
133
- segments:
134
- - 0
135
- hash: -3136945747678737813
136
149
  required_rubygems_version: !ruby/object:Gem::Requirement
137
150
  none: false
138
151
  requirements:
139
152
  - - ! '>='
140
153
  - !ruby/object:Gem::Version
141
154
  version: '0'
142
- segments:
143
- - 0
144
- hash: -3136945747678737813
145
155
  requirements: []
146
156
  rubyforge_project:
147
157
  rubygems_version: 1.8.24