mediawiki_selenium 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ff49ed757245b3019e90d0e6c97a2b1f50d0798
4
- data.tar.gz: 30e39088a9deffa94072fb2d6f1b8768548c6d9c
3
+ metadata.gz: 01bb1e36bd275e158439389152f9f0e75df02ee6
4
+ data.tar.gz: 6b5c1825eeeb66c8551de98bf2de03ce8637207b
5
5
  SHA512:
6
- metadata.gz: 1d2176c6a4c894d9d7e0198c5afb248a7b3a41a1f1a6d667612517133bfc3863f9f129c0d776d988196ec49c276ebae6043d6b75fe607a6909709a89fefa9c4b
7
- data.tar.gz: fd7d44415b1ea8397629c44fde70f300b390924c78a33735590c211bb7b2e9413bb9686eeee73d54dda70b276b036014af2152b55147098f57de0d9c90bde510
6
+ metadata.gz: f600a40695ac3fa6d2876ad0458318e63b75acf15d60e072c7693a9b24bb6d05f347eaa9cc236614e848ed30bdeb779a60f8a62b8a0988005aaf96a0323b73d2
7
+ data.tar.gz: 03493b1449b8d70a92a1221b5e6c80a2cfe89faec2290b889b68156c36c3e7dfd0cf83b72b66ebee859b679580db818a11940f32adeb4bd80997a1fa1e28b859
@@ -1,5 +1,10 @@
1
1
  ## Release notes
2
2
 
3
+ ### 1.6.1 2015-09-29
4
+ * Fixed bug in `UserFactory#user` and `UserFactory#password` that caused the
5
+ incorrect resolution of alternative users/passwords when in the context of
6
+ `Environment#as_user`
7
+
3
8
  ### 1.6.0 2015-09-25
4
9
  * Factored out all Cucumber specific functionality from the main framework
5
10
  classes to make way for alternative test harnesses
data/UPGRADE.md CHANGED
@@ -1,18 +1,50 @@
1
- # Upgrading from pre-1.0 releases to 1.0.0 and above
1
+ # Upgrading to various major and minor releases
2
2
 
3
- ## Update your `Gemfile`
3
+ You can check your current version by running `bundle list mediawiki_selenium`
4
+ in the root directory of your project.
5
+
6
+ ## From 1.x releases to 1.6.0
7
+
8
+ ### Update your `Gemfile`
9
+
10
+ First, update the `Gemfile` in your project's root directory to specify the
11
+ new version.
12
+
13
+ gem 'mediawiki_selenium', '~> 1.6.0'
14
+
15
+ ### Update `require` paths in `env.rb`
16
+
17
+ The 1.6 release of MW-Selenium decoupled much of the Cucumber specific
18
+ implementation to make room for alternative test harnesses such as RSpec. Some
19
+ support files were moved around to make this separation clearer.
20
+
21
+ Assuming you're using Cucumber, which is still the default harness, update the
22
+ first set of `require` statements in `tests/browser/features/support/env.rb`
23
+ to the following.
24
+
25
+ require 'mediawiki_selenium/cucumber'
26
+ require 'mediawiki_selenium/pages'
27
+ require 'mediawiki_selenium/step_definitions'
28
+
29
+ Note that you can always omit the page object and step definition statements
30
+ if they don't apply to your test cases. The only must have is the first
31
+ `require`.
32
+
33
+ ## From pre-1.0 releases to 1.x
34
+
35
+ ### Update your `Gemfile`
4
36
 
5
37
  First, update the `Gemfile` in your project's root directory to specify the
6
38
  new version.
7
39
 
8
- gem 'mediawiki_selenium', '~> 1.5.0'
40
+ gem 'mediawiki_selenium', '~> 1.6.0'
9
41
 
10
- ## Upgrade gems and dependencies
42
+ ### Upgrade gems and dependencies
11
43
 
12
44
  Now run `bundle install` to update your project's gem dependencies and
13
45
  `Gemfile.lock`.
14
46
 
15
- ## Run the initialization script
47
+ ### Run the initialization script
16
48
 
17
49
  Version 1.0 now includes an initialization script that can help with the setup
18
50
  of new and existing test suites. Run the script in your project's root
@@ -30,11 +62,11 @@ the Cucumber environment. Since you're working with an existing test suite,
30
62
  you may run into a conflict here. Just make sure that your `env.rb` contains
31
63
  the following before anything else.
32
64
 
33
- require 'mediawiki_selenium'
34
- require 'mediawiki_selenium/support'
65
+ require 'mediawiki_selenium/cucumber'
66
+ require 'mediawiki_selenium/pages'
35
67
  require 'mediawiki_selenium/step_definitions'
36
68
 
37
- ## Convert page object URLs
69
+ ### Convert page object URLs
38
70
 
39
71
  Convert all page object URLs so that they're defined relative to the root of
40
72
  any given wiki and no longer rely on the now deprecated `URL` module. In other
@@ -59,7 +91,7 @@ To something like this.
59
91
  # ...
60
92
  end
61
93
 
62
- ## Refactor direct use of `ENV`
94
+ ### Refactor direct use of `ENV`
63
95
 
64
96
  Change all references to `ENV` to use the appropriate `Environment` method.
65
97
 
@@ -96,7 +128,7 @@ To something like:
96
128
  end
97
129
  end
98
130
 
99
- ## Remove direct references to `@browser`
131
+ ### Remove direct references to `@browser`
100
132
 
101
133
  All references to `@browser` should use `Environment#browser` instead, since
102
134
  the latter will automatically configure and launch the browser the first time
@@ -114,7 +146,7 @@ Would be changed to:
114
146
  on(FlowPage).wait_until { browser.url =~ /Topic/ }
115
147
  end
116
148
 
117
- ## Refactor use of deprecated `APIPage`
149
+ ### Refactor use of deprecated `APIPage`
118
150
 
119
151
  API requests should be made directly using {MediawikiSelenium::ApiHelper#api}
120
152
  which returns an instance of [MediawikiApi::Client](https://doc.wikimedia.org/rubygems/mediawiki-ruby-api/).
@@ -1,3 +1,5 @@
1
+ require 'mediawiki_selenium'
2
+
1
3
  require 'mediawiki_selenium/cucumber/env'
2
4
  require 'mediawiki_selenium/cucumber/hooks'
3
5
  require 'mediawiki_selenium/cucumber/sauce'
@@ -146,7 +146,9 @@ module MediawikiSelenium
146
146
  # @yieldparam password [String] Alternative MediaWiki password.
147
147
  #
148
148
  def as_user(id, &blk)
149
- with(mediawiki_user: user(id), mediawiki_password: password(id), &blk)
149
+ record_alternatives([:mediawiki_user, :mediawiki_password], id) do
150
+ with(mediawiki_user: user(id), mediawiki_password: password(id), &blk)
151
+ end
150
152
  end
151
153
 
152
154
  # Browser with which to drive tests.
@@ -500,13 +502,7 @@ module MediawikiSelenium
500
502
  #
501
503
  def with_alternative(names, id, &blk)
502
504
  names = Array(names)
503
-
504
- original_alts = @_current_alternatives.dup
505
- @_current_alternatives.merge!(names.each.with_object({}) { |n, alts| alts[n] = id })
506
-
507
- with(lookup_all(names, id: id), &blk)
508
- ensure
509
- @_current_alternatives = original_alts
505
+ record_alternatives(names, id) { with(lookup_all(names, id: id), &blk) }
510
506
  end
511
507
 
512
508
  protected
@@ -529,6 +525,14 @@ module MediawikiSelenium
529
525
  key.to_s.downcase.to_sym
530
526
  end
531
527
 
528
+ def record_alternatives(names, id)
529
+ original_alts = @_current_alternatives.dup
530
+ @_current_alternatives.merge!(names.each.with_object({}) { |n, alts| alts[n] = id })
531
+ yield
532
+ ensure
533
+ @_current_alternatives = original_alts
534
+ end
535
+
532
536
  def with(overrides = {})
533
537
  overrides = normalize_config(overrides)
534
538
  original_config = @_config.dup
@@ -20,9 +20,19 @@ module MediawikiSelenium
20
20
  # @see Environment#password
21
21
  #
22
22
  [:user, :password].each do |name|
23
+ config_key = :"mediawiki_#{name}"
24
+
23
25
  define_method(name) do |id = nil|
24
26
  return super(id) unless lookup(:user_factory, default: false)
25
- factory.create(id || current_alternative(:"mediawiki_#{name}"))[name]
27
+
28
+ alt_id = current_alternative(config_key)
29
+
30
+ # When in the context of an alternative, try the explicit value first
31
+ if !alt_id.nil? && alt_id == id
32
+ lookup(config_key, default: -> { factory.create(alt_id)[name] })
33
+ else
34
+ factory.create(id || alt_id)[name]
35
+ end
26
36
  end
27
37
  end
28
38
 
@@ -1,3 +1,3 @@
1
1
  module MediawikiSelenium
2
- VERSION = '1.6.0'
2
+ VERSION = '1.6.1'
3
3
  end
@@ -40,7 +40,17 @@ module MediawikiSelenium
40
40
  it 'should be different from the primary account' do
41
41
  expect(api).to receive(:create_account).twice
42
42
 
43
- expect(subject).not_to eq(env.user)
43
+ expect(subject).not_to eq(env.send(method))
44
+ end
45
+ end
46
+
47
+ context 'within the implicit context of an alternative' do
48
+ subject { env.as_user(:b) { env.send(method) } }
49
+
50
+ it 'should use the already created alternative' do
51
+ expect(api).to receive(:create_account).twice
52
+
53
+ expect(subject).not_to eq(env.send(method))
44
54
  end
45
55
  end
46
56
  end
@@ -1,5 +1,3 @@
1
- require 'mediawiki_selenium'
2
-
3
1
  require 'mediawiki_selenium/cucumber'
4
2
  require 'mediawiki_selenium/pages'
5
3
  require 'mediawiki_selenium/step_definitions'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mediawiki_selenium
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris McMahon
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2015-09-25 00:00:00.000000000 Z
16
+ date: 2015-09-29 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: cucumber