ixtlan-guard 0.8.2 → 0.8.3
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.
- data/features/step_definitions/simple_steps.rb +160 -1
- data/lib/ixtlan/guard/railtie.rb +3 -2
- data/spec/guard_rails_spec.rb +3 -0
- metadata +4 -4
|
@@ -1 +1,160 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
require 'ruby-maven'
|
|
3
|
+
module Maven
|
|
4
|
+
class CucumberSteps
|
|
5
|
+
|
|
6
|
+
def initialize(options = {})
|
|
7
|
+
@options = {:ruby_version => RUBY_VERSION }
|
|
8
|
+
@options[:jruby_version] = JRUBY_VERSION if defined? JRUBY_VERSION
|
|
9
|
+
|
|
10
|
+
@options.merge!(options || {})
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def rmvn
|
|
14
|
+
@rmvn ||= Maven::RubyMaven.new
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def copy_tests(tests)
|
|
18
|
+
FileUtils.mkdir_p(@app_directory)
|
|
19
|
+
FileUtils.cp_r(File.join('templates', "tests-#{tests}", "."),
|
|
20
|
+
File.join(@app_directory, 'test'),
|
|
21
|
+
:remove_destination => true)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def copy_specs(specs)
|
|
25
|
+
FileUtils.mkdir_p(@app_directory)
|
|
26
|
+
FileUtils.cp_r(File.join('templates', "specs-#{specs}", "."),
|
|
27
|
+
File.join(@app_directory, 'spec'),
|
|
28
|
+
:remove_destination => true)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def copy_files(files)
|
|
32
|
+
FileUtils.mkdir_p(@app_directory)
|
|
33
|
+
FileUtils.cp_r(File.join('templates', "files-#{files}", "."),
|
|
34
|
+
@app_directory,
|
|
35
|
+
:remove_destination => true)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def create_rails_application(template)
|
|
39
|
+
name = template.sub(/.template$/, '')
|
|
40
|
+
@app_directory = File.join('target', name)
|
|
41
|
+
|
|
42
|
+
# rails version from gemspec
|
|
43
|
+
gemspec = File.read(Dir.glob("*.gemspec")[0])
|
|
44
|
+
rails_version = gemspec.split("\n").detect { |l| l =~ /development_dep.*rails/ }.sub(/'$/, '').sub(/.*'/, '')
|
|
45
|
+
|
|
46
|
+
rmvn.options['-Dplugin.version'] = @options[:plugin_version] if @options[:plugin_version]
|
|
47
|
+
rmvn.options['-Djruby.version'] = @options[:jruby_version] if @options[:jruby_version]
|
|
48
|
+
if @options[:ruby_version]
|
|
49
|
+
rversion = @options[:ruby_version] =~ /^1.8./ ? '--1.8': '--1.9'
|
|
50
|
+
rmvn.options['-Djruby.switches'] = rversion
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
rmvn.options['-Drails.version'] = rails_version
|
|
54
|
+
rmvn.options['-Dgem.home'] = ENV['GEM_HOME']
|
|
55
|
+
rmvn.options['-Dgem.path'] = ENV['GEM_PATH']
|
|
56
|
+
rmvn.options['-o'] = nil
|
|
57
|
+
|
|
58
|
+
FileUtils.rm_rf(@app_directory)
|
|
59
|
+
|
|
60
|
+
template_file = File.expand_path("templates/#{template}")
|
|
61
|
+
rmvn.exec("rails", "new", @app_directory, "-f", '--', '-e', "-Dtemplate=#{template_file}")
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def given_template(template)
|
|
65
|
+
create_rails_application(template)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def given_template_and_tests(template, tests)
|
|
69
|
+
create_rails_application(template)
|
|
70
|
+
copy_tests(tests)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def given_template_and_specs(template, specs)
|
|
74
|
+
create_rails_application(template)
|
|
75
|
+
copy_specs(specs)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def given_template_and_files(template, files)
|
|
79
|
+
create_rails_application(template)
|
|
80
|
+
copy_files(files)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def given_application(name)
|
|
84
|
+
@app_directory = File.join('target', name)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def given_application_and_tests(name, tests)
|
|
88
|
+
@app_directory = File.join('target', name)
|
|
89
|
+
copy_tests(tests)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def given_application_and_specs(name, specs)
|
|
93
|
+
@app_directory = File.join('target', name)
|
|
94
|
+
copy_specs(specs)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def given_application_and_files(name, files)
|
|
98
|
+
@app_directory = File.join('target', name)
|
|
99
|
+
copy_files(files)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def execute(args)
|
|
103
|
+
rmvn.options['-l'] = "output.log"
|
|
104
|
+
rmvn.exec_in(@app_directory, args.split(' '))
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def expected_output(expected)
|
|
108
|
+
result = File.read(File.join(@app_directory, "output.log"))
|
|
109
|
+
expected.split(/\"?\s+and\s+\"?/).each do |exp|
|
|
110
|
+
puts exp
|
|
111
|
+
yield(result =~ /.*#{exp}.*/)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
steps = Maven::CucumberSteps.new(:plugin_version => '0.29.0')
|
|
119
|
+
|
|
120
|
+
Given /^I create new rails application with template "(.*)"$/ do |template|
|
|
121
|
+
steps.given_template(template)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
Given /^I create new rails application with template "(.*)" and "(.*)" tests$/ do |template, tests|
|
|
125
|
+
steps.given_template_and_tests(template, tests)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
Given /^I create new rails application with template "(.*)" and "(.*)" specs$/ do |template, specs|
|
|
129
|
+
steps.given_template_and_specs(template, specs)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
Given /^I create new rails application with template "(.*)" and "(.*)" files$/ do |template, files|
|
|
133
|
+
steps.given_template_and_files(template, files)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
Given /^me an existing rails application "(.*)"$/ do |name|
|
|
137
|
+
steps.given_application(name)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
Given /^me an existing rails application "(.*)" and "(.*)" tests$/ do |name, tests|
|
|
141
|
+
steps.given_application_and_tests(name, tests)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
Given /^me an existing rails application "(.*)" and "(.*)" specs$/ do |name, specs|
|
|
145
|
+
steps.given_application_and_specs(name, specs)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
Given /^me an existing rails application "(.*)" and "(.*)" files$/ do |name, files|
|
|
149
|
+
steps.given_application_and_files(name, files)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
And /^I execute \"(.*)\"$/ do |args|
|
|
153
|
+
steps.execute(args)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
Then /^the output should contain \"(.*)\"$/ do |expected|
|
|
157
|
+
steps.expected_output(expected) do |exp|
|
|
158
|
+
exp.should_not be_nil
|
|
159
|
+
end
|
|
160
|
+
end
|
data/lib/ixtlan/guard/railtie.rb
CHANGED
|
@@ -26,8 +26,9 @@ module Ixtlan
|
|
|
26
26
|
|
|
27
27
|
app.config.guard = Ixtlan::Guard::Guard.new(options)
|
|
28
28
|
end
|
|
29
|
-
|
|
30
|
-
config.generators
|
|
29
|
+
|
|
30
|
+
gmethod = config.respond_to?(:generators)? :generators : :app_generators
|
|
31
|
+
config.send(gmethod) do
|
|
31
32
|
require 'rails/generators'
|
|
32
33
|
require 'rails/generators/rails/controller/controller_generator'
|
|
33
34
|
Rails::Generators::ControllerGenerator.hook_for :guard, :type => :boolean, :default => true do |controller|
|
data/spec/guard_rails_spec.rb
CHANGED
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: ixtlan-guard
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 0.8.
|
|
5
|
+
version: 0.8.3
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- mkristian
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date: 2012-
|
|
13
|
+
date: 2012-07-04 00:00:00 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: ixtlan-core
|
|
@@ -75,7 +75,7 @@ dependencies:
|
|
|
75
75
|
requirements:
|
|
76
76
|
- - "="
|
|
77
77
|
- !ruby/object:Gem::Version
|
|
78
|
-
version: 3.0.
|
|
78
|
+
version: 3.0.4.0.29.0
|
|
79
79
|
type: :development
|
|
80
80
|
version_requirements: *id006
|
|
81
81
|
description: simple authorization framework for rails controllers
|
|
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
169
169
|
requirements: []
|
|
170
170
|
|
|
171
171
|
rubyforge_project:
|
|
172
|
-
rubygems_version: 1.8.
|
|
172
|
+
rubygems_version: 1.8.24
|
|
173
173
|
signing_key:
|
|
174
174
|
specification_version: 3
|
|
175
175
|
summary: guard your controller actions
|