kameleon 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  [![Build Status](https://secure.travis-ci.org/cs3b/kameleon.png?branch=master)](http://travis-ci.org/cs3b/kameleon)
4
4
 
5
+ [![CoderWall](http://api.coderwall.com/cs3b/endorsecount.png)](http://coderwall.com/cs3b)
6
+
5
7
  Kameleon is a high abstraction dsl for better writing acceptance and integrationtests using Capybara.
6
8
  And "better" means: more easily to mimic how user interact with browser.
7
9
 
@@ -20,7 +22,7 @@ Optionally is nice to use:
20
22
  Gemfile
21
23
 
22
24
  ``` ruby
23
- gem 'kameleon', '>= 0.2.0.alpha.2'
25
+ gem 'kameleon', '>= 0.2.0'
24
26
  ```
25
27
 
26
28
  Before you start using Kameleon ensure that capybara is properly loaded (in your test helper file)
@@ -244,4 +246,4 @@ Kameleon::Session.defined_areas.merge!({ :menu => [:xpath, "//nav/ul"],
244
246
  ## Credits
245
247
  * [Michał Czyż](http://selleo.com/people/michal-czyz)
246
248
  * [Radosław Jędryszczak](http://selleo.com/people/radoslaw-jedryszczak)
247
- * [Szymon Kieloch](http://selleo.com/people)
249
+ * [Szymon Kieloch](http://selleo.com/people/szymon-kieloch)
@@ -1,6 +1,8 @@
1
1
  require 'kameleon/utils/configuration'
2
2
 
3
3
  module Kameleon
4
+ class NotImplementedException < StandardError; end
5
+
4
6
  def self.configure(&block)
5
7
  yield(Kameleon::Utils::Configuration)
6
8
  end
@@ -98,13 +98,13 @@ module Kameleon
98
98
  class ScopeProxy < Struct.new(:world, :scope)
99
99
 
100
100
  Kameleon::DSL.instance_methods.each do |method|
101
- define_method method do |args|
101
+ define_method method do |*args|
102
102
  world.within(scope) do
103
- world.send(method, args)
103
+ world.send(method, *args)
104
104
  end
105
105
  end
106
106
  end
107
107
 
108
108
  end
109
109
  end
110
- end
110
+ end
@@ -23,9 +23,11 @@ module Kameleon
23
23
  case identifier
24
24
  when Array
25
25
  identifier.each { |identifier| prepare_actions(value => identifier) }
26
+ when Symbol
27
+ prepare_actions(value => identifier.to_s)
26
28
  else
27
29
  case value
28
- when Fixnum, String
30
+ when Fixnum, Float, String
29
31
  actions << Action.new(:fill_in, identifier, :with => value)
30
32
  when :check, :choose, :uncheck
31
33
  actions << Action.new(value, identifier)
@@ -53,12 +55,17 @@ module Kameleon
53
55
 
54
56
  def parse_params(params)
55
57
  params.each_pair do |option, id|
56
- if option.kind_of?(Array)
57
- option.each do |o|
58
- parse_params(o => id)
59
- end
60
- else
61
- actions << Action.new(action, option, :from => id)
58
+ case id
59
+ when Symbol
60
+ parse_params(option => id.to_s)
61
+ when String
62
+ if option.kind_of?(Array)
63
+ option.each do |o|
64
+ parse_params(o => id)
65
+ end
66
+ else
67
+ actions << Action.new(action, option.to_s, :from => id)
68
+ end
62
69
  end
63
70
  end
64
71
  end
@@ -20,7 +20,8 @@ module Kameleon
20
20
 
21
21
  def prepare_conditions(param)
22
22
  case param
23
- when String
23
+ when String, Fixnum
24
+ param = param.to_s
24
25
  conditions << Condition.new(:have_content, param)
25
26
  when Symbol
26
27
  prepare_conditions(:element => param)
@@ -52,13 +53,13 @@ module Kameleon
52
53
  when :element
53
54
  conditions.concat Element.new(values).conditions
54
55
  else
55
- raise "not implemented"
56
+ raise Kameleon::NotImplementedException, "Not implemented #{param}"
56
57
  end
57
58
  end
58
59
  when Array
59
- params.each { |parameter| prepare_conditions(parameter) }
60
+ param.each { |parameter| prepare_conditions(parameter) }
60
61
  else
61
- raise "not implemented"
62
+ raise Kameleon::NotImplementedException, "Not implemented #{param}"
62
63
  end
63
64
  end
64
65
  end
@@ -205,7 +206,7 @@ module Kameleon
205
206
  def condition
206
207
  Condition.new(nil, params, prepare_xpath) do |elements, xpath_query|
207
208
  texts = page.all(:xpath, xpath_query).map(&:text)
208
- texts.should == elements
209
+ texts.uniq.should == elements.uniq
209
210
  end
210
211
  end
211
212
 
@@ -227,6 +228,8 @@ module Kameleon
227
228
 
228
229
  def parse_params(params)
229
230
  case params
231
+ when Symbol
232
+ parse_params(params.to_s)
230
233
  when String
231
234
  conditions << Condition.new(:have_field, params, :with => value)
232
235
  when Array
@@ -250,6 +253,8 @@ module Kameleon
250
253
 
251
254
  def parse_params(params)
252
255
  case params
256
+ when Symbol
257
+ parse_params(params.to_s)
253
258
  when String
254
259
  conditions << condition(params)
255
260
  when Array
@@ -323,8 +328,18 @@ module Kameleon
323
328
  selected_value.each do |value|
324
329
  parse_params(value => identifier)
325
330
  end
331
+ when Symbol
332
+ parse_params(selected_value => identifier.to_s)
326
333
  when String
327
- conditions << Condition.new(matcher_method, identifier, :selected => selected_value)
334
+ value = case selected_value
335
+ when Symbol, Fixnum
336
+ selected_value.to_s
337
+ when String, Array
338
+ selected_value
339
+ else
340
+ raise "not supported"
341
+ end
342
+ conditions << Condition.new(matcher_method, identifier, :selected => value)
328
343
  else
329
344
  raise "not supported"
330
345
  end
@@ -355,4 +370,4 @@ module Kameleon
355
370
  end
356
371
 
357
372
  #! see :button, :buttons -> have_button(selector)
358
- #! see field that is :disabled, :readonly
373
+ #! see field that is :disabled, :readonly
@@ -9,7 +9,7 @@ RSpec.configure do |config|
9
9
  def config.escaped_path(*parts)
10
10
  Regexp.compile(parts.join('[\\\/]'))
11
11
  end
12
- escaped_group_file_path = config.escaped_path(%w[spec (requests|integration)])
12
+ escaped_group_file_path = config.escaped_path(%w[spec .*(requests|integration|acceptance)])
13
13
 
14
14
  config.include Capybara::DSL, :type => :request, :example_group => {:file_path => escaped_group_file_path}
15
15
  config.include Kameleon::DSL, :type => :request, :example_group => {:file_path => escaped_group_file_path}
@@ -1,6 +1,6 @@
1
1
  #! TODO
2
2
  # gemfile
3
- # gem 'ripl'
3
+ # gem 'pry'
4
4
  # gem 'database-cleaner'
5
5
 
6
6
  # spec_helper.rb
@@ -24,7 +24,7 @@ RSpec.configure do |config|
24
24
  config.after(:each) do
25
25
  if exception = example.instance_variable_get(:@exception)
26
26
  save_and_open_page unless Capybara.current_driver == :selenium
27
- Ripl.start :binding => binding
27
+ binding.pry
28
28
  end
29
29
  DatabaseCleaner.clean
30
30
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kameleon
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:
8
- - Michał Czyż [cs3b]
9
- - Radosław Jędryszczak [socjopata]
8
+ - Michal Czyz [cs3b]
9
+ - Radoslaw Jedryszczak [socjopata]
10
10
  - Szymon Kieloch [Skieloch]
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-05-03 00:00:00.000000000 Z
14
+ date: 2012-11-12 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec
@@ -61,6 +61,22 @@ dependencies:
61
61
  - - ! '>='
62
62
  - !ruby/object:Gem::Version
63
63
  version: '0'
64
+ - !ruby/object:Gem::Dependency
65
+ name: pry
66
+ requirement: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ type: :runtime
73
+ prerelease: false
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
64
80
  - !ruby/object:Gem::Dependency
65
81
  name: rspec
66
82
  requirement: !ruby/object:Gem::Requirement
@@ -157,6 +173,22 @@ dependencies:
157
173
  - - ! '>='
158
174
  - !ruby/object:Gem::Version
159
175
  version: '0'
176
+ - !ruby/object:Gem::Dependency
177
+ name: pry
178
+ requirement: !ruby/object:Gem::Requirement
179
+ none: false
180
+ requirements:
181
+ - - ! '>='
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ type: :development
185
+ prerelease: false
186
+ version_requirements: !ruby/object:Gem::Requirement
187
+ none: false
188
+ requirements:
189
+ - - ! '>='
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
160
192
  description: high abstraction dsl for end user perspective tests, kameleon - it's
161
193
  a polish word for chameleon
162
194
  email: michalczyz@gmail.com
@@ -164,28 +196,28 @@ executables: []
164
196
  extensions: []
165
197
  extra_rdoc_files: []
166
198
  files:
167
- - lib/kameleon.rb
168
- - lib/kameleon/utils/debug_console.rb
169
- - lib/kameleon/utils/configuration.rb
170
- - lib/kameleon/session.rb
171
- - lib/kameleon/dsl.rb
172
- - lib/kameleon/dsl/verify/presence.rb
173
- - lib/kameleon/dsl/verify/absence.rb
174
- - lib/kameleon/dsl/utils/debug.rb
175
199
  - lib/kameleon/dsl/act/form.rb
176
200
  - lib/kameleon/dsl/act/mouse.rb
177
201
  - lib/kameleon/dsl/context/scope.rb
178
- - lib/kameleon/ext/capybara/session_pool.rb
202
+ - lib/kameleon/dsl/utils/debug.rb
203
+ - lib/kameleon/dsl/verify/absence.rb
204
+ - lib/kameleon/dsl/verify/presence.rb
205
+ - lib/kameleon/dsl.rb
206
+ - lib/kameleon/ext/active_record/shared_single_connection.rb
179
207
  - lib/kameleon/ext/capybara/server.rb
180
- - lib/kameleon/ext/session/devise.rb
181
- - lib/kameleon/ext/ruby/deferred_garbage_collector.rb
182
- - lib/kameleon/ext/rspec/garbage_collector.rb
208
+ - lib/kameleon/ext/capybara/session_pool.rb
209
+ - lib/kameleon/ext/rspec/all.rb
183
210
  - lib/kameleon/ext/rspec/dsl.rb
211
+ - lib/kameleon/ext/rspec/garbage_collector.rb
212
+ - lib/kameleon/ext/rspec/headless.rb
184
213
  - lib/kameleon/ext/rspec/pool.rb
185
214
  - lib/kameleon/ext/rspec/transactional_examples.rb
186
- - lib/kameleon/ext/rspec/headless.rb
187
- - lib/kameleon/ext/rspec/all.rb
188
- - lib/kameleon/ext/active_record/shared_single_connection.rb
215
+ - lib/kameleon/ext/ruby/deferred_garbage_collector.rb
216
+ - lib/kameleon/ext/session/devise.rb
217
+ - lib/kameleon/session.rb
218
+ - lib/kameleon/utils/configuration.rb
219
+ - lib/kameleon/utils/debug_console.rb
220
+ - lib/kameleon.rb
189
221
  - LICENCE
190
222
  - README.md
191
223
  homepage: https://github.com/cs3b/kameleon