ruby_raider 0.3.3 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,213 +0,0 @@
1
- require 'pathname'
2
- require 'yaml'
3
- require_relative 'spec_helper'
4
- require_relative '../lib/ruby_raider'
5
- require_relative '../lib/generators/common_generator'
6
-
7
- describe RubyRaider do
8
- let(:raider) { RubyRaider }
9
- let(:name) {'test'}
10
-
11
- context 'with path from config file' do
12
- before(:all) do
13
- CommonGenerator.new(%w[rspec cucumber test]).invoke(:generate_config_file)
14
- FileUtils.cp_lr('test/config', './')
15
- end
16
-
17
- it 'creates a page' do
18
- raider.new.invoke(:page, nil, %W[#{name}])
19
- expect(Pathname.new("page_objects/pages/#{name}_page.rb")).to be_file
20
- end
21
-
22
- it 'creates a feature' do
23
- raider.new.invoke(:feature, nil, %W[#{name}])
24
- expect(Pathname.new("features/#{name}.feature")).to be_file
25
- end
26
-
27
- it 'creates a spec' do
28
- raider.new.invoke(:spec, nil, %W[#{name}])
29
- expect(Pathname.new("spec/#{name}_spec.rb")).to be_file
30
- end
31
-
32
- it 'creates a helper' do
33
- raider.new.invoke(:helper, nil, %W[#{name}])
34
- expect(Pathname.new("helpers/#{name}_helper.rb")).to be_file
35
- end
36
-
37
- it 'deletes a page' do
38
- raider.new.invoke(:page, nil, %W[#{name}])
39
- raider.new.invoke(:page, nil, %W[#{name} --delete])
40
- expect(Pathname.new("page_objects/pages/#{name}_page.rb")).to_not be_file
41
- end
42
-
43
- it 'deletes a feature' do
44
- raider.new.invoke(:feature, nil, %W[#{name}])
45
- raider.new.invoke(:feature, nil, %W[#{name} --delete])
46
- expect(Pathname.new("features/#{name}.feature")).to_not be_file
47
- end
48
-
49
- it 'deletes a spec' do
50
- raider.new.invoke(:spec, nil, %W[#{name}])
51
- raider.new.invoke(:spec, nil, %W[#{name} --delete])
52
- expect(Pathname.new("spec/#{name}_spec.rb")).to_not be_file
53
- end
54
-
55
- it 'deletes a helper' do
56
- raider.new.invoke(:helper, nil, %W[#{name}])
57
- raider.new.invoke(:helper, nil, %W[#{name} --delete])
58
- expect(Pathname.new("helpers/#{name}_helper.rb")).to_not be_file
59
- end
60
-
61
- after(:all) do
62
- folders = %w[test config page_objects features helpers]
63
- folders.each do |folder|
64
- FileUtils.rm_rf(folder)
65
- end
66
- FileUtils.rm('spec/test_spec.rb') if Pathname.new('spec/test_spec.rb').exist?
67
- end
68
- end
69
-
70
- context 'with path option' do
71
- let(:path) { 'test_folder' }
72
-
73
- it 'creates a page' do
74
- raider.new.invoke(:page, nil, %W[#{name} --path #{path}])
75
- expect(Pathname.new("#{path}/#{name}_page.rb")).to be_file
76
- end
77
-
78
- it 'creates a feature' do
79
- raider.new.invoke(:feature, nil, %W[#{name} --path #{path}])
80
- expect(Pathname.new("#{path}/#{name}.feature")).to be_file
81
- end
82
-
83
- it 'creates a spec' do
84
- raider.new.invoke(:spec, nil, %W[#{name} --path #{path}])
85
- expect(Pathname.new("#{path}/#{name}_spec.rb")).to be_file
86
- end
87
-
88
- it 'creates a helper' do
89
- raider.new.invoke(:helper, nil, %W[#{name} --path #{path}])
90
- expect(Pathname.new("#{path}/#{name}_helper.rb")).to be_file
91
- end
92
-
93
- after(:each) do
94
- FileUtils.rm_rf(path)
95
- end
96
- end
97
-
98
- context 'changes the default path' do
99
- let(:path) { 'test_folder' }
100
-
101
- before(:all) do
102
- CommonGenerator.new(%w[rspec cucumber test]).invoke(:generate_config_file)
103
- FileUtils.cp_lr('test/config', './')
104
- end
105
-
106
- it 'changes the path for pages' do
107
- raider.new.invoke(:path, nil, %W[#{path}])
108
- config = YAML.load_file('config/config.yml')
109
- expect(config['page_path']).to eql path
110
- end
111
-
112
- it 'changes the path for features' do
113
- raider.new.invoke(:path, nil, %W[#{path} -f])
114
- config = YAML.load_file('config/config.yml')
115
- expect(config['feature_path']).to eql path
116
- end
117
-
118
- it 'changes the path for specs' do
119
- raider.new.invoke(:path, nil, %W[#{path} -s])
120
- config = YAML.load_file('config/config.yml')
121
- expect(config['spec_path']).to eql path
122
- end
123
-
124
- it 'creates page' do
125
- raider.new.invoke(:path, nil, %W[#{path}])
126
- raider.new.invoke(:page, nil, %W[#{name}])
127
- expect(Pathname.new("#{path}/#{name}_page.rb")).to be_file
128
- end
129
-
130
- it 'creates feature' do
131
- raider.new.invoke(:path, nil, %W[#{path} -f])
132
- raider.new.invoke(:feature, nil, %W[#{name}])
133
- expect(Pathname.new("#{path}/#{name}.feature")).to be_file
134
- end
135
-
136
- it 'creates spec' do
137
- raider.new.invoke(:path, nil, %W[#{path} -s])
138
- raider.new.invoke(:spec, nil, %W[#{name}])
139
- expect(Pathname.new("#{path}/#{name}_spec.rb")).to be_file
140
- end
141
-
142
- it 'creates spec' do
143
- raider.new.invoke(:path, nil, %W[#{path} -h])
144
- raider.new.invoke(:helper, nil, %W[#{name}])
145
- expect(Pathname.new("#{path}/#{name}_helper.rb")).to be_file
146
- end
147
-
148
- after(:all) do
149
- folders = %w[test_folder test config]
150
- folders.each do |folder|
151
- FileUtils.rm_rf(folder)
152
- end
153
- end
154
- end
155
-
156
- context 'updates the config file' do
157
- before(:all) do
158
- CommonGenerator.new(%w[rspec selenium test]).invoke(:generate_config_file)
159
- FileUtils.cp_lr('test/config', './')
160
- end
161
-
162
- it 'updates the url' do
163
- raider.new.invoke(:url, nil, %W[test.com])
164
- config = YAML.load_file('config/config.yml')
165
- expect(config['url']).to eql 'test.com'
166
- end
167
-
168
- it 'updates the browser' do
169
- raider.new.invoke(:browser, nil, %W[:firefox])
170
- config = YAML.load_file('config/config.yml')
171
- expect(config['browser']).to eql ':firefox'
172
- end
173
-
174
- after(:all) do
175
- folders = %w[test config]
176
- folders.each do |folder|
177
- FileUtils.rm_rf(folder)
178
- end
179
- end
180
- end
181
-
182
- context 'scaffolding' do
183
- before(:all) do
184
- CommonGenerator.new(%w[rspec selenium test]).invoke(:generate_config_file)
185
- FileUtils.cp_lr('test/config', './')
186
- end
187
-
188
- context 'with a spec folder' do
189
- it 'scaffolds for rspec' do
190
- raider.new.invoke(:scaffold, nil, %W[#{name}])
191
- expect(Pathname.new("page_objects/pages/#{name}_page.rb")).to be_file
192
- expect(Pathname.new("spec/#{name}_spec.rb")).to be_file
193
- end
194
- end
195
-
196
- context 'with a features folder' do
197
- it 'scaffolds for cucumber' do
198
- FileUtils.mkdir 'features'
199
- raider.new.invoke(:scaffold, nil, %W[#{name}])
200
- expect(Pathname.new("page_objects/pages/#{name}_page.rb")).to be_file
201
- expect(Pathname.new("features/#{name}.feature")).to be_file
202
- end
203
- end
204
-
205
- after(:all) do
206
- folders = %w[test config page_objects features]
207
- folders.each do |folder|
208
- FileUtils.rm_rf(folder)
209
- end
210
- FileUtils.rm('spec/test_spec.rb') if Pathname.new('spec/test_spec.rb').exist?
211
- end
212
- end
213
- end