cucumber-sammies 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1493e1ca46f94974635f114d9c67c651b1ed51be
4
- data.tar.gz: ab713fc9ce8690970eb22037ca4f467c840dfd52
3
+ metadata.gz: ad1a61c559f37d8924f68d5b07ba90af4b4cf4de
4
+ data.tar.gz: 915dc6786ea5add4cd7e5fc037caf3b88fc1d81d
5
5
  SHA512:
6
- metadata.gz: 8c185e173ad04bd24193823bc09f550f5fda65226d2b2f7b170e61fb5d42457d52204e6d64e12a6a3c6e37c7b5b38794829d525ec913d095afaa42fa569b70c5
7
- data.tar.gz: 21e55714cd0997c6d868a5f777d3f4eb50c1eab7887218baef171364d92510fe7f8d0ac90e1b451ac0714da8c45dbd72fb40b01b47a83efbf5acf4ff0ca4d96b
6
+ metadata.gz: f6d112211ab84bc13082e96888c6cbae533e4b8238aadc98e0760c4beae121f0c87c59af63f60ba0a731e856211ed6b0db962ac53d2c2d975ebc8b7933256067
7
+ data.tar.gz: 96aa6bda9fc40f7d081250e31cc042f24e806fc778fd6d342f7ff840dcc050a77b4eb229f1cc34ab8d7cd3c87af0a8a3b22bf87d1bb8cc0efb8f8f330f253473
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  ![Cucumber Sandwhiches](./sammies.jpg)
8
8
 
9
- Simple & tasty step definitions for your Rails application that are meant to compliment [Speewald](https://github.com/makandra/spreewald).
9
+ Simple & tasty Cucumber step definitions for your Rails application(https://github.com/makandra/spreewald). Many of these steps were originally created by [Spreewald](https://github.com/makandra/spreewald).
10
10
 
11
11
  ## Installation
12
12
 
@@ -26,13 +26,13 @@ Or install it yourself as:
26
26
 
27
27
  ## Usage
28
28
 
29
- To use `cucumber-sammies` in your cucumber tests, add this line to your `features/support/env.rb` file.
29
+ To use `cucumber-sammies` in your cucumber tests, add a line like this to your `features/support/env.rb` file.
30
30
 
31
31
  ```ruby
32
- require 'cucumber/sammies/step_definitions/*'
32
+ require 'cucumber/sammies/step_definitions/form_steps'
33
33
  ```
34
34
 
35
- Or your can require individual step definition files by replacing `*` with the file name you want.
35
+ All the steps can be found in the [step_definitions directory](https://github.com/starfighterheavy/cucumber-sammies/tree/master/lib/cucumber/sammies/step_definitions)
36
36
 
37
37
  ## Development
38
38
 
@@ -42,7 +42,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
42
42
 
43
43
  ## Contributing
44
44
 
45
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cucumber-sammies. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/starfighterheavy/cucumber-sammies. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
46
46
 
47
47
  ## License
48
48
 
@@ -50,4 +50,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
50
50
 
51
51
  ## Code of Conduct
52
52
 
53
- Everyone interacting in the Cucumber::Sammies project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/cucumber-sammies/blob/master/CODE_OF_CONDUCT.md).
53
+ Everyone interacting in the Cucumber::Sammies project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/starfighterheavy/cucumber-sammies/blob/master/CODE_OF_CONDUCT.md).
@@ -6,6 +6,14 @@ Then /^the page body should include "(.*)"$/ do |content|
6
6
  expect(page.body).to include(content)
7
7
  end
8
8
 
9
+ Then /^I should see "(.*)"$/ do |content|
10
+ expect(page).to have_content(content)
11
+ end
12
+
13
+ Then /^I should not see "(.*)"$/ do |content|
14
+ expect(page).not_to have_content(content)
15
+ end
16
+
9
17
  Then(/^I see the (.*) flash message$/) do |message|
10
18
  expect(page).to have_content(resolve_locale(message))
11
19
  end
@@ -10,6 +10,10 @@ When(/^I click the "(.*)" submit button$/) do |link|
10
10
  find(link).click
11
11
  end
12
12
 
13
+ When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
14
+ select(value, :from => field)
15
+ end
16
+
13
17
  When(/^I check the ([^"]+) box$/) do |label|
14
18
  check resolve_locale(label)
15
19
  end
@@ -42,3 +46,7 @@ def select_year_month(year:, month:, day: nil, field:)
42
46
  select month, :from => "#{field}_2i"
43
47
  select day, :from => "#{field}_3i" if day
44
48
  end
49
+
50
+ When /^(?:|I )fill in "([^"]*)" (?:with|for) "([^"]*)"$/ do |field, value|
51
+ fill_in(field, :with => value)
52
+ end
@@ -1,3 +1,5 @@
1
+ require_relative '../support/resolvers'
2
+
1
3
  Then(/^I am taken to (a|an|the) (.*) page$/) do |inclusive, path|
2
4
  path.split(' ').each do |part|
3
5
  expect(current_path.split('/')).to include(part)
@@ -15,6 +17,39 @@ When /^I visit "(.*)"$/ do |path|
15
17
  visit path
16
18
  end
17
19
 
20
+ When /^(?:|I )go to the (.+) page$/ do |page_name|
21
+ visit resolve_path(page_name)
22
+ end
23
+
24
+ When /^(?:|I )press "([^"]*)"$/ do |button|
25
+ click_button(button)
26
+ end
27
+
28
+ When /^(?:|I )follow "([^"]*)"$/ do |link|
29
+ click_link(link)
30
+ end
31
+
32
+ When /^I click on "([^\"]+)"$/ do |text|
33
+ contains_text = %{contains(., \"#{text}\")}
34
+ # find the innermost selector that matches
35
+ element = page.find(:xpath, ".//*[#{contains_text} and not (./*[#{contains_text}])]")
36
+ element.click
37
+ end
38
+
18
39
  Then(/^I wait ([0-9]+) seconds$/) do |seconds|
19
40
  sleep seconds.to_i
20
41
  end
42
+
43
+ Then /^(?:|I )should be on the (.+) page$/ do |page_name|
44
+ fragment = URI.parse(current_url).fragment
45
+ fragment.sub!(/[#?].*/, '') if fragment # most js frameworks will usually use ? and # for params, we dont care about those
46
+ current_path = URI.parse(current_url).path
47
+ current_path << "##{fragment}" if fragment.present?
48
+ expected_path = resolve_path(page_name)
49
+
50
+ # Consider two pages equal if they only differ by a trailing slash.
51
+ current_path = expected_path if current_path.chomp("/") == expected_path.chomp("/")
52
+ current_path = expected_path if current_path.gsub("/#", "#") == expected_path.gsub("/#", "#")
53
+
54
+ current_path.should == expected_path
55
+ end
@@ -0,0 +1,72 @@
1
+ # From: https://raw.githubusercontent.com/starfighterheavy/spreewald/master/lib/spreewald/timecop_steps.rb
2
+
3
+ if defined?(Timecop)
4
+
5
+ module TimecopHarness
6
+
7
+ # When you have to make your rails app time zone aware you have to go 100%
8
+ # otherwise you are better off ignoring time zones at all.
9
+ # https://makandracards.com/makandra/8723-guide-to-localizing-a-rails-application
10
+
11
+ def use_timezones?
12
+ active_record_loaded = defined?(ActiveRecord::Base)
13
+ (!active_record_loaded || ActiveRecord::Base.default_timezone != :local) && Time.zone
14
+ end
15
+
16
+ def parse_time(str)
17
+ if use_timezones?
18
+ Time.zone.parse(str)
19
+ else
20
+ Time.parse(str)
21
+ end
22
+ end
23
+
24
+ def current_time
25
+ if use_timezones?
26
+ Time.current
27
+ else
28
+ Time.now
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ World(TimecopHarness)
35
+
36
+ # Example:
37
+ #
38
+ # Given the date is 2012-02-10
39
+ # Given the time is 2012-02-10 13:40
40
+ When /^the (?:date|time) is "?(\d{4}-\d{2}-\d{2}(?: \d{1,2}:\d{2})?)"?$/ do |time|
41
+ Timecop.travel(parse_time(time))
42
+ end
43
+
44
+ # Example:
45
+ #
46
+ # Given the time is 13:40
47
+ When /^the time is "?(\d{1,2}:\d{2})"?$/ do |time_without_date|
48
+ Timecop.travel(parse_time(time_without_date)) # date will be today
49
+ end
50
+
51
+ # Example:
52
+ #
53
+ # When it is 10 minutes later
54
+ # When it is a few hours earlier
55
+ When /^it is (\d+|a|some|a few) (seconds?|minutes?|hours?|days?|weeks?|months?|years?) (later|earlier)$/ do |amount, unit, direction|
56
+ amount = case amount
57
+ when 'a'
58
+ 1
59
+ when 'some', 'a few'
60
+ 10
61
+ else
62
+ amount.to_i
63
+ end
64
+ amount = -amount if direction == 'earlier'
65
+ Timecop.travel(current_time + amount.send(unit))
66
+ end
67
+
68
+ After do
69
+ Timecop.return
70
+ end
71
+
72
+ end
@@ -9,3 +9,7 @@ end
9
9
  Then /^I sleep (.*) seconds$/ do |seconds|
10
10
  sleep seconds.to_f
11
11
  end
12
+
13
+ Then /^it should work$/ do
14
+ pending
15
+ end
@@ -0,0 +1,25 @@
1
+ module Resolvers
2
+ def resolve_locale(str)
3
+ str = str.gsub(/\s/, '.')
4
+ I18n.t(str)
5
+ end
6
+
7
+ def resolve_path(str)
8
+ send(str.gsub(' ', '_') + '_path')
9
+ end
10
+
11
+ def resolve_ivar(str)
12
+ model = str.gsub(' ', '_')
13
+ instance_variable_get("@#{model}")
14
+ end
15
+
16
+ def set_ivar(str, value)
17
+ model = str.gsub(' ', '_')
18
+ instance_variable_set("@#{model}", value)
19
+ end
20
+
21
+ def resolve_class(str)
22
+ str.singularize.titleize.gsub(' ', '').constantize
23
+ end
24
+ end
25
+ World(Resolvers)
@@ -1,5 +1,5 @@
1
1
  module Cucumber
2
2
  module Sammies
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-sammies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Kirst
@@ -62,9 +62,10 @@ files:
62
62
  - lib/cucumber/sammies/step_definitions/environment_steps.rb
63
63
  - lib/cucumber/sammies/step_definitions/form_steps.rb
64
64
  - lib/cucumber/sammies/step_definitions/navigation_steps.rb
65
- - lib/cucumber/sammies/step_definitions/resolvers.rb
66
65
  - lib/cucumber/sammies/step_definitions/table_steps.rb
66
+ - lib/cucumber/sammies/step_definitions/time_steps.rb
67
67
  - lib/cucumber/sammies/step_definitions/troubleshooting_steps.rb
68
+ - lib/cucumber/sammies/support/resolvers.rb
68
69
  - lib/cucumber/sammies/version.rb
69
70
  - sammies.jpg
70
71
  homepage: https://github.com/starfighterheavy/cucumber-sammies
@@ -1,23 +0,0 @@
1
- def resolve_locale(str)
2
- str = str.gsub(/\s/, '.')
3
- I18n.t(str)
4
- end
5
-
6
- def resolve_path(str)
7
- str.gsub(' ', '_') + '_path'
8
- end
9
-
10
- def resolve_ivar(str)
11
- model = str.gsub(' ', '_')
12
- instance_variable_get("@#{model}")
13
- end
14
-
15
- def set_ivar(str, value)
16
- model = str.gsub(' ', '_')
17
- instance_variable_set("@#{model}", value)
18
- end
19
-
20
-
21
- def resolve_class(str)
22
- str.singularize.titleize.gsub(' ', '').constantize
23
- end