da-js 0.1.0 → 0.2.0
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +4 -1
- data/da-js.gemspec +5 -5
- data/features/conditional_visibility.feature +26 -0
- data/features/numeric_value.feature +60 -0
- data/features/step_definitions/change_tracker_steps.rb +1 -1
- data/features/step_definitions/conditional_visibility_steps.rb +37 -8
- data/features/step_definitions/numeric_value_steps.rb +21 -0
- data/features/step_definitions/shared_steps.rb +11 -1
- data/features/support/env.rb +1 -0
- data/features/support/testapp/testapp.rb +2 -1
- data/features/support/testapp/vendor/jquery-1.11.1.js +10308 -0
- data/features/support/testapp/views/conditional_visibility.erb +7 -2
- data/features/support/testapp/views/numeric_value.erb +17 -0
- data/lib/assets/javascripts/da-js/conditional_visibility.js.coffee +24 -12
- data/lib/assets/javascripts/da-js/numeric_value.js.coffee +24 -0
- data/lib/da-js/version.rb +1 -1
- metadata +139 -156
- data/features/support/testapp/vendor/jquery-1.7.1.js +0 -9266
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6330c64a5ac18fee03cfc476aa45c8a999a8f636
|
4
|
+
data.tar.gz: 312b0583a044dde7056ce27e0d1a847d703cbd1f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: da4b21324ac5b08380a16448fa3bbf8a3cfa36366d346b35216afc062a7f80f27daece0c75a825b0d1aef0dcfe8dfb9f19b5acee15bf502987023570bd189ff0
|
7
|
+
data.tar.gz: 99cdbc0654ae9f8cbee10ca6174d83126babe17f56d9d51705231bd615ad6c2dc1931eec3c256456245bf328edabb274f43ca07dd96358b77d849773c8e102ce
|
data/CHANGELOG.md
CHANGED
data/da-js.gemspec
CHANGED
@@ -18,14 +18,14 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_dependency "railties", ">= 3.1.0"
|
21
|
+
s.add_dependency "railties", ">= 3.1.0", "< 5"
|
22
22
|
s.add_dependency "sprockets", "~> 2.0"
|
23
23
|
s.add_dependency "coffee-script", "~> 2.2"
|
24
24
|
|
25
|
-
s.add_development_dependency "cucumber", "
|
26
|
-
s.add_development_dependency "rspec-expectations", "
|
27
|
-
s.add_development_dependency "sinatra"
|
25
|
+
s.add_development_dependency "cucumber", "~> 1.3"
|
26
|
+
s.add_development_dependency "rspec-expectations", "~> 2.7"
|
27
|
+
s.add_development_dependency "sinatra", "~> 1.4"
|
28
28
|
s.add_development_dependency "sinatra-contrib"
|
29
|
-
s.add_development_dependency "capybara-webkit", "
|
29
|
+
s.add_development_dependency "capybara-webkit", "~> 1.3"
|
30
30
|
s.add_development_dependency "launchy"
|
31
31
|
end
|
@@ -26,4 +26,30 @@ Feature: Conditional visibility for elements
|
|
26
26
|
|
27
27
|
When I trigger the "updateVisibilities" event on the form
|
28
28
|
Then the "Message" input should be hidden
|
29
|
+
|
30
|
+
|
31
|
+
Scenario: Manually configuring events triggering visibility re-calculations
|
32
|
+
# Assert default behaviour first
|
33
|
+
When I enter "foo" in the "amount" field
|
34
|
+
Then the "#amount_info" element should be hidden
|
35
|
+
When I blur the "amount" field
|
36
|
+
Then the "#amount_info" element should be visible
|
37
|
+
|
38
|
+
Given I visit the test page for "conditional visibility" with options "{events: 'keypress'}"
|
39
|
+
Then the "#amount_info" element should be hidden
|
40
|
+
When I enter "foo" in the "amount" field
|
41
|
+
Then the "#amount_info" element should be visible
|
42
|
+
|
43
|
+
|
44
|
+
Scenario: Using the triggered events
|
45
|
+
Given I bind an event listener to "shown.conditionalVisibility"
|
46
|
+
And I bind an event listener to "hidden.conditionalVisibility"
|
47
|
+
When I select "Other …" from the "Country" select
|
48
|
+
Then the event listener for "shown.conditionalVisibility" should have been called "1" time
|
49
|
+
And the event listener for "hidden.conditionalVisibility" should have been called "0" times
|
50
|
+
When I select "Austria" from the "Country" select
|
51
|
+
Then the event listener for "shown.conditionalVisibility" should have been called "1" times
|
52
|
+
And the event listener for "hidden.conditionalVisibility" should have been called "1" times
|
53
|
+
|
54
|
+
|
29
55
|
|
@@ -0,0 +1,60 @@
|
|
1
|
+
@javascript
|
2
|
+
Feature: Numeric value of input elements
|
3
|
+
|
4
|
+
Background:
|
5
|
+
Given I visit the test page for "numeric value"
|
6
|
+
|
7
|
+
Scenario Outline: English locale
|
8
|
+
When I fill in "textfield" with "<String>"
|
9
|
+
Then the numeric value of "textfield" should be "<Value>"
|
10
|
+
|
11
|
+
Examples:
|
12
|
+
| String | Value |
|
13
|
+
| 1 | 1 |
|
14
|
+
| 1.2 | 1.2 |
|
15
|
+
| 1234.56 | 1234.56 |
|
16
|
+
| 1,234.56 | 1234.56 |
|
17
|
+
| 1,234 | 1234 |
|
18
|
+
| abc | 0 |
|
19
|
+
| $ 3 | 0 |
|
20
|
+
| | 0 |
|
21
|
+
|
22
|
+
Scenario Outline: German locale
|
23
|
+
Given the HTML element has a lang attribute set to "de"
|
24
|
+
When I fill in "textfield" with "<String>"
|
25
|
+
Then the numeric value of "textfield" should be "<Value>"
|
26
|
+
|
27
|
+
Examples:
|
28
|
+
| String | Value |
|
29
|
+
| 1 | 1 |
|
30
|
+
| 1,2 | 1.2 |
|
31
|
+
| 1234,56 | 1234.56 |
|
32
|
+
| 1.234,56 | 1234.56 |
|
33
|
+
| 1.234 | 1234 |
|
34
|
+
| abc | 0 |
|
35
|
+
| € 5 | 0 |
|
36
|
+
| | 0 |
|
37
|
+
|
38
|
+
Scenario: Reading value from non-input elements
|
39
|
+
Then the numeric value of "non_input_element_english" should be "1234.56"
|
40
|
+
Given the HTML element has a lang attribute set to "de"
|
41
|
+
Then the numeric value of "non_input_element_german" should be "5678.9"
|
42
|
+
|
43
|
+
Scenario Outline: Ignoring the currency sign
|
44
|
+
When I fill in "textfield" with "<String>"
|
45
|
+
Then the numeric value (ignoring currency sign) of "textfield" should be "<Value>"
|
46
|
+
Examples:
|
47
|
+
| String | Value |
|
48
|
+
| € 1 | 1 |
|
49
|
+
| $123.45 | 123.45 |
|
50
|
+
| $$ 3 | 0 |
|
51
|
+
| €$ 7 | 0 |
|
52
|
+
|
53
|
+
Scenario Outline: Using `nullOnError`
|
54
|
+
When I fill in "textfield" with "<String>"
|
55
|
+
Then the numeric value (using `nullOnError: true`) of "textfield" should be "<Value>"
|
56
|
+
Examples:
|
57
|
+
| String | Value |
|
58
|
+
| 1,234 | 1234 |
|
59
|
+
| abc | null |
|
60
|
+
| € 5 | null |
|
@@ -1,29 +1,58 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
Given %r{^I bind an event listener to "([^"]*)"$} do |event|
|
2
|
+
page.execute_script %{
|
3
|
+
if (!window.eventCounts) window.eventCounts = {};
|
4
|
+
window.eventCounts['#{event}'] = 0;
|
5
|
+
$('body').on('#{event}', function(){ window.eventCounts['#{event}']++ });
|
6
|
+
}
|
3
7
|
end
|
4
8
|
|
5
|
-
Then
|
9
|
+
Then %r{^the event listener for "([^"]*)" should have been called "([^"]*)" times?$} do |event, counter|
|
10
|
+
actual = page.evaluate_script "window.eventCounts['#{event}']"
|
11
|
+
actual.should eq counter.to_i
|
12
|
+
end
|
13
|
+
|
14
|
+
Then %r{^the "([^"]*)" input should be hidden$} do |input|
|
15
|
+
find_field(input, visible: false).should_not be_visible
|
16
|
+
end
|
17
|
+
|
18
|
+
Then %r{^the "([^"]*)" input should be visible$} do |input|
|
6
19
|
find_field(input).should be_visible
|
7
20
|
end
|
8
21
|
|
9
|
-
|
22
|
+
Then %r{^the "([^"]*)" element should be hidden$} do |selector|
|
23
|
+
find(selector, visible: false).should_not be_visible
|
24
|
+
end
|
25
|
+
|
26
|
+
Then %r{^the "([^"]*)" element should be visible$} do |selector|
|
27
|
+
find(selector).should be_visible
|
28
|
+
end
|
29
|
+
|
30
|
+
When %r{^I select "([^"]*)" from the "([^"]*)" select$} do |option, input|
|
10
31
|
select option, :from => input
|
11
32
|
end
|
12
33
|
|
13
|
-
When
|
34
|
+
When %r{^I uncheck the "([^"]*)" checkbox$} do |input|
|
14
35
|
uncheck input
|
15
36
|
end
|
16
37
|
|
17
|
-
When
|
38
|
+
When %r{^I check the "([^"]*)" checkbox$} do |input|
|
18
39
|
check input
|
19
40
|
end
|
20
41
|
|
21
|
-
When
|
42
|
+
When %r{I enter "([^"]*)" in the "([^"]*)" field} do |value, input|
|
43
|
+
fill_in input, with: value
|
44
|
+
end
|
45
|
+
|
46
|
+
When %r{I blur the "([^"]*)" field} do |input|
|
47
|
+
find_field(input).trigger("blur")
|
48
|
+
end
|
49
|
+
|
50
|
+
When %r{^I set the "([^"]*)" checkbox to unchecked using JavaScript$} do |input|
|
22
51
|
id = find_field(input)["id"]
|
23
52
|
page.execute_script "$('##{id}')[0].checked = false"
|
24
53
|
end
|
25
54
|
|
26
|
-
When
|
55
|
+
When %r{^I trigger the "([^"]*)" event on the form$} do |event|
|
27
56
|
page.execute_script "$('form').trigger('#{event}')"
|
28
57
|
end
|
29
58
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Given %r{the HTML element has a lang attribute set to "([^"]*)"$} do |lang|
|
2
|
+
page.execute_script("$('html').attr('lang', '#{lang}')")
|
3
|
+
end
|
4
|
+
|
5
|
+
Then %r{^the numeric value of "([^"]*)" should be "([^"]*)"$} do |input, value|
|
6
|
+
page.evaluate_script("$('##{input}').numericValue()").should be_within(0.0001).of value.to_f
|
7
|
+
end
|
8
|
+
|
9
|
+
Then %r{^the numeric value \(ignoring currency sign\) of "([^"]*)" should be "([^"]*)"$} do |input, value|
|
10
|
+
page.evaluate_script("$('##{input}').numericValue({ignoreCurrencySign: true})").should be_within(0.0001).of value.to_f
|
11
|
+
end
|
12
|
+
|
13
|
+
Then %r{^the numeric value \(using `nullOnError: true`\) of "([^"]*)" should be "([^"]*)"$} do |input, value|
|
14
|
+
actual = page.evaluate_script("$('##{input}').numericValue({nullOnError: true})")
|
15
|
+
if value == "null"
|
16
|
+
actual.should eq("")
|
17
|
+
else
|
18
|
+
actual.should be_within(0.0001).of(value.to_f)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -1,5 +1,15 @@
|
|
1
1
|
require "active_support/inflector"
|
2
|
+
require "active_support/core_ext/object/to_query"
|
2
3
|
|
3
|
-
When
|
4
|
+
When %r{^I visit the test page for "([^"]*)"$} do |feature|
|
4
5
|
visit "/#{feature.parameterize '_'}"
|
5
6
|
end
|
7
|
+
|
8
|
+
When %r{^I visit the test page for "([^"]*)" with options "([^"]*)"?$} do |feature, options|
|
9
|
+
visit "/#{feature.parameterize '_'}?" + {options: options}.to_query
|
10
|
+
end
|
11
|
+
|
12
|
+
When %r{^I fill in "([^"]*)" with "([^"]*)"$} do |input, value|
|
13
|
+
fill_in input, :with => value
|
14
|
+
end
|
15
|
+
|
data/features/support/env.rb
CHANGED
@@ -3,9 +3,10 @@ require "sinatra/reloader" if development?
|
|
3
3
|
require "coffee_script"
|
4
4
|
|
5
5
|
set :app_file, __FILE__
|
6
|
+
disable :logging
|
6
7
|
|
7
8
|
before do
|
8
|
-
@jquery_version = params[:jquery] || "1.
|
9
|
+
@jquery_version = params[:jquery] || "1.11.1"
|
9
10
|
end
|
10
11
|
|
11
12
|
get "/vendor/:file" do |file|
|