lifx_dash 0.3.0 → 0.3.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 +4 -4
- data/.travis.yml +9 -8
- data/CHANGELOG.md +26 -18
- data/CODE_OF_CONDUCT.md +54 -30
- data/PULL_REQUEST_TEMPLATE.md +16 -0
- data/README.md +5 -5
- data/Rakefile +3 -5
- data/lib/lifx_dash/version.rb +1 -1
- data/lifx_dash.gemspec +7 -0
- metadata +9 -15
- data/.simplecov +0 -10
- data/features/lifx_dash.feature +0 -17
- data/features/step_definitions/lifx_dash_steps.rb +0 -4
- data/features/support/env.rb +0 -1
- data/test/lifx_dash/lifx_http_api_test.rb +0 -73
- data/test/test_helper.rb +0 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f0e67bbe784dc06c3c111d6933809d2404529d88047ee55dbbd816379a03ee06
|
|
4
|
+
data.tar.gz: 2ae77cef8817730f5ba6a15f60f0f4136763ffc80823910111ba6152de485e34
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1b6033ff970855599b43eb9752fafc2bc0f970773c9bbaa0cee7770c572ef596f57fe67cdf61a71c68e4badb2d3ca086ae8a06dd9686db98e0a523a7a6065a36
|
|
7
|
+
data.tar.gz: 597ef41ec1d531d32f9bf6a0d0ed5da1624f4455b401bdb45545b1ceff397654a3a996a61da86373fa2d3991ae4926d8de87beae23e21d759e2dcda9f6a5627a
|
data/.travis.yml
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
sudo: required
|
|
2
2
|
language: ruby
|
|
3
|
-
before_install:
|
|
4
|
-
- sudo apt-get install libpcap-dev -qq
|
|
5
|
-
- gem update --system
|
|
6
|
-
- gem --version
|
|
7
3
|
rvm:
|
|
8
4
|
- 2.1.10
|
|
9
5
|
- 2.2.9
|
|
10
6
|
- 2.3.6
|
|
11
7
|
- 2.4.3
|
|
12
|
-
- 2.5.
|
|
8
|
+
- 2.5.1
|
|
13
9
|
- ruby-head
|
|
10
|
+
|
|
11
|
+
before_install:
|
|
12
|
+
- sudo apt-get install libpcap-dev -qq
|
|
13
|
+
- gem update --system
|
|
14
|
+
- gem install bundler
|
|
15
|
+
|
|
14
16
|
matrix:
|
|
15
17
|
allow_failures:
|
|
16
18
|
- rvm: ruby-head
|
|
17
|
-
|
|
18
|
-
except:
|
|
19
|
-
- gh-pages
|
|
19
|
+
|
|
20
20
|
deploy:
|
|
21
21
|
provider: rubygems
|
|
22
22
|
api_key:
|
|
@@ -25,6 +25,7 @@ deploy:
|
|
|
25
25
|
on:
|
|
26
26
|
tags: true
|
|
27
27
|
repo: matthutchinson/lifx_dash
|
|
28
|
+
|
|
28
29
|
env:
|
|
29
30
|
global:
|
|
30
31
|
- CC_TEST_REPORTER_ID=71107cb58f585bf7506e53f33238f4bd4e9aa87215ed916a5b466ecd9b493209
|
data/CHANGELOG.md
CHANGED
|
@@ -1,29 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
# ChangeLog
|
|
2
2
|
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](KeepAChangelog) and this project
|
|
6
|
+
adheres to [Semantic Versioning](Semver).
|
|
5
7
|
|
|
6
8
|
## [Unreleased]
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
- Your contribution here!
|
|
9
11
|
|
|
10
|
-
## [0.1
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
## [0.3.1] - 2018-05-23
|
|
13
|
+
### Changed
|
|
14
|
+
- Adding links to gemspec
|
|
13
15
|
|
|
14
|
-
## [0.1.
|
|
15
|
-
|
|
16
|
+
## [0.1.3] - 2016-07-02
|
|
17
|
+
### Changed
|
|
18
|
+
- Mentioning libpcap dependency in README
|
|
19
|
+
- Refactoring Configuration - added CONFIG const and fixed sudo home dir issue
|
|
16
20
|
|
|
17
|
-
## [0.1.1]
|
|
18
|
-
|
|
21
|
+
## [0.1.1] - 2016-06-30
|
|
22
|
+
### Changed
|
|
23
|
+
- Testing auto-releasing gem from Travis CI
|
|
19
24
|
|
|
20
|
-
## [0.1.0]
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
## [0.1.0] - 2016-06-30
|
|
26
|
+
### Changed
|
|
27
|
+
- Initial gem release
|
|
28
|
+
- Dameonizing option for monitor command (writing to a log file)
|
|
29
|
+
- Built with gli command-suite gem
|
|
24
30
|
|
|
25
|
-
[Unreleased]: https://github.com/matthutchinson/lifx_dash/compare/v0.1
|
|
31
|
+
[Unreleased]: https://github.com/matthutchinson/lifx_dash/compare/v0.3.1...HEAD
|
|
32
|
+
[0.3.1]: https://github.com/matthutchinson/lifx_dash/compare/v0.1.3...v0.3.1
|
|
26
33
|
[0.1.3]: https://github.com/matthutchinson/lifx_dash/compare/v0.1.1...v0.1.3
|
|
27
34
|
[0.1.1]: https://github.com/matthutchinson/lifx_dash/compare/v0.1.0...v0.1.1
|
|
28
|
-
[0.1.0]: https://github.com/matthutchinson/lifx_dash/
|
|
29
|
-
[
|
|
35
|
+
[0.1.0]: https://github.com/matthutchinson/lifx_dash/compare/7cb5751...v0.1.0
|
|
36
|
+
[KeepAChangelog]: http://keepachangelog.com/en/1.0.0/
|
|
37
|
+
[Semver]: http://semver.org/spec/v2.0.0.html
|
data/CODE_OF_CONDUCT.md
CHANGED
|
@@ -1,24 +1,41 @@
|
|
|
1
|
-
# Contributor Code of Conduct
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
fostering an open and welcoming community, we pledge to respect all people who
|
|
5
|
-
contribute through reporting issues, posting feature requests, updating
|
|
6
|
-
documentation, submitting pull requests or patches, and other activities.
|
|
3
|
+
## Our Pledge
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
education, socio-economic status, nationality, personal appearance, race,
|
|
10
|
+
religion, or sexual identity and orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
12
22
|
|
|
13
23
|
Examples of unacceptable behavior by participants include:
|
|
14
24
|
|
|
15
|
-
* The use of sexualized language or imagery
|
|
16
|
-
|
|
17
|
-
* Trolling
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
18
28
|
* Public or private harassment
|
|
19
|
-
* Publishing
|
|
20
|
-
|
|
21
|
-
* Other
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
22
39
|
|
|
23
40
|
Project maintainers have the right and responsibility to remove, edit, or
|
|
24
41
|
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
@@ -26,25 +43,32 @@ that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
|
26
43
|
permanently any contributor for other behaviors that they deem inappropriate,
|
|
27
44
|
threatening, offensive, or harmful.
|
|
28
45
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
33
54
|
|
|
34
|
-
|
|
35
|
-
when an individual is representing the project or its community.
|
|
55
|
+
## Enforcement
|
|
36
56
|
|
|
37
57
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
38
|
-
reported by contacting
|
|
58
|
+
reported by contacting the project team at via [Github][maintainer]. All
|
|
39
59
|
complaints will be reviewed and investigated and will result in a response that
|
|
40
|
-
is deemed necessary and appropriate to the circumstances.
|
|
41
|
-
obligated to maintain confidentiality with regard to the reporter of an
|
|
42
|
-
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
43
69
|
|
|
44
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
45
|
-
version
|
|
46
|
-
[http://contributor-covenant.org/version/1/3/0/][version]
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
|
47
72
|
|
|
73
|
+
[homepage]: https://www.contributor-covenant.org
|
|
48
74
|
[maintainer]: https://github.com/matthutchinson
|
|
49
|
-
[homepage]: http://contributor-covenant.org
|
|
50
|
-
[version]: http://contributor-covenant.org/version/1/3/0/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
Explain what you're changing and why here.
|
|
3
|
+
|
|
4
|
+
---
|
|
5
|
+
#### :memo: Checklist
|
|
6
|
+
|
|
7
|
+
Please check this list and leave it intact for the reviewer. Thanks! :heart:
|
|
8
|
+
|
|
9
|
+
- [ ] Commit messages provide context (why not just what, some tips [here](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)).
|
|
10
|
+
- [ ] If relevant, mention GitHub issue number above and include in a commit message.
|
|
11
|
+
- [ ] Latest code from master merged.
|
|
12
|
+
- [ ] New behaviour has test coverage.
|
|
13
|
+
- [ ] Avoid duplicating code.
|
|
14
|
+
- [ ] No commented out code.
|
|
15
|
+
- [ ] Avoid comments for your code, write code that explains itself.
|
|
16
|
+
- [ ] Changes are simple, useful, clear and brief.
|
data/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# LifxDash
|
|
2
2
|
|
|
3
|
-
[](http://rubygems.org/gems/lifx_dash)
|
|
4
|
+
[](https://travis-ci.org/matthutchinson/lifx_dash)
|
|
5
|
+
[](https://depfu.com/github/matthutchinson/lifx_dash)
|
|
6
|
+
[](https://codeclimate.com/github/matthutchinson/lifx_dash/maintainability)
|
|
7
|
+
[](https://codeclimate.com/github/matthutchinson/lifx_dash/test_coverage)
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
data/Rakefile
CHANGED
|
@@ -4,8 +4,6 @@ require "cucumber"
|
|
|
4
4
|
require "cucumber/rake/task"
|
|
5
5
|
require 'rdoc/task'
|
|
6
6
|
|
|
7
|
-
task :default => ['test:coverage']
|
|
8
|
-
|
|
9
7
|
Rake::TestTask.new(:test) do |t|
|
|
10
8
|
t.libs << "test"
|
|
11
9
|
t.libs << "lib"
|
|
@@ -14,11 +12,10 @@ end
|
|
|
14
12
|
|
|
15
13
|
# test with code coverage (default)
|
|
16
14
|
namespace :test do
|
|
17
|
-
desc "Run all tests and
|
|
15
|
+
desc "Run all unit tests and generate a coverage report"
|
|
18
16
|
task :coverage do
|
|
19
17
|
ENV['COVERAGE'] = 'true'
|
|
20
|
-
Rake::Task[
|
|
21
|
-
Rake::Task['features'].execute
|
|
18
|
+
Rake::Task[:test].execute
|
|
22
19
|
end
|
|
23
20
|
end
|
|
24
21
|
|
|
@@ -36,3 +33,4 @@ RDoc::Task.new do |rd|
|
|
|
36
33
|
rd.rdoc_files.include("README.md", "LICENSE.txt", "lib/**/*.rb", "bin/**/*")
|
|
37
34
|
end
|
|
38
35
|
|
|
36
|
+
task :default => ['test:coverage', :features]
|
data/lib/lifx_dash/version.rb
CHANGED
data/lifx_dash.gemspec
CHANGED
|
@@ -21,6 +21,13 @@ Gem::Specification.new do |spec|
|
|
|
21
21
|
network packet sniffing.
|
|
22
22
|
EOF
|
|
23
23
|
|
|
24
|
+
spec.metadata = {
|
|
25
|
+
"homepage_uri" => "https://github.com/matthutchinson/lifx_dash",
|
|
26
|
+
"changelog_uri" => "https://github.com/matthutchinson/lifx_dash/blob/master/CHANGELOG.md",
|
|
27
|
+
"source_code_uri" => "https://github.com/matthutchinson/lifx_dash",
|
|
28
|
+
"bug_tracker_uri" => "https://github.com/matthutchinson/lifx_dash/issues",
|
|
29
|
+
}
|
|
30
|
+
|
|
24
31
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the
|
|
25
32
|
# 'allowed_push_host' to allow pushing to a single host or delete this section
|
|
26
33
|
# to allow pushing to any host.
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lifx_dash
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matthew Hutchinson
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-05-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: gli
|
|
@@ -167,21 +167,18 @@ extra_rdoc_files:
|
|
|
167
167
|
files:
|
|
168
168
|
- ".coveralls.yml"
|
|
169
169
|
- ".gitignore"
|
|
170
|
-
- ".simplecov"
|
|
171
170
|
- ".travis.yml"
|
|
172
171
|
- CHANGELOG.md
|
|
173
172
|
- CODE_OF_CONDUCT.md
|
|
174
173
|
- CONTRIBUTING.md
|
|
175
174
|
- Gemfile
|
|
176
175
|
- LICENSE.txt
|
|
176
|
+
- PULL_REQUEST_TEMPLATE.md
|
|
177
177
|
- README.md
|
|
178
178
|
- Rakefile
|
|
179
179
|
- bin/console
|
|
180
180
|
- bin/lifx_dash
|
|
181
181
|
- bin/setup
|
|
182
|
-
- features/lifx_dash.feature
|
|
183
|
-
- features/step_definitions/lifx_dash_steps.rb
|
|
184
|
-
- features/support/env.rb
|
|
185
182
|
- lib/lifx_dash.rb
|
|
186
183
|
- lib/lifx_dash/capturer.rb
|
|
187
184
|
- lib/lifx_dash/configuration.rb
|
|
@@ -194,12 +191,14 @@ files:
|
|
|
194
191
|
- man/lifx_dash.1
|
|
195
192
|
- man/lifx_dash.1.html
|
|
196
193
|
- man/lifx_dash.1.ronn
|
|
197
|
-
- test/lifx_dash/lifx_http_api_test.rb
|
|
198
|
-
- test/test_helper.rb
|
|
199
194
|
homepage: http://github.com/matthutchinson/lifx_dash
|
|
200
195
|
licenses:
|
|
201
196
|
- MIT
|
|
202
197
|
metadata:
|
|
198
|
+
homepage_uri: https://github.com/matthutchinson/lifx_dash
|
|
199
|
+
changelog_uri: https://github.com/matthutchinson/lifx_dash/blob/master/CHANGELOG.md
|
|
200
|
+
source_code_uri: https://github.com/matthutchinson/lifx_dash
|
|
201
|
+
bug_tracker_uri: https://github.com/matthutchinson/lifx_dash/issues
|
|
203
202
|
allowed_push_host: https://rubygems.org
|
|
204
203
|
post_install_message:
|
|
205
204
|
rdoc_options:
|
|
@@ -226,13 +225,8 @@ requirements:
|
|
|
226
225
|
- one or more LIFX bulbs
|
|
227
226
|
- root access
|
|
228
227
|
rubyforge_project:
|
|
229
|
-
rubygems_version: 2.7.
|
|
228
|
+
rubygems_version: 2.7.7
|
|
230
229
|
signing_key:
|
|
231
230
|
specification_version: 4
|
|
232
231
|
summary: Toggle LIFX lights with an Amazon Dash button
|
|
233
|
-
test_files:
|
|
234
|
-
- features/lifx_dash.feature
|
|
235
|
-
- features/step_definitions/lifx_dash_steps.rb
|
|
236
|
-
- features/support/env.rb
|
|
237
|
-
- test/lifx_dash/lifx_http_api_test.rb
|
|
238
|
-
- test/test_helper.rb
|
|
232
|
+
test_files: []
|
data/.simplecov
DELETED
data/features/lifx_dash.feature
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
Feature: Show help information
|
|
2
|
-
In order to show command line help
|
|
3
|
-
|
|
4
|
-
Scenario: Show general command line help
|
|
5
|
-
When I get help for "lifx_dash"
|
|
6
|
-
Then the output should contain " lifx_dash - Toggle LIFX lights with an Amazon Dash button"
|
|
7
|
-
Then the output should match / config - (.*)/
|
|
8
|
-
Then the output should match / help - (.*)/
|
|
9
|
-
Then the output should match / monitor - (.*)/
|
|
10
|
-
Then the output should match / snoop - (.*)/
|
|
11
|
-
And the exit status should be 0
|
|
12
|
-
|
|
13
|
-
Scenario: Show config help
|
|
14
|
-
When I run `lifx_dash help config`
|
|
15
|
-
Then the output should contain " config - Set (and persist) default options for commands"
|
|
16
|
-
Then the output should contain " -s, --[no-]show - Show the config file"
|
|
17
|
-
And the exit status should be 0
|
data/features/support/env.rb
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require 'aruba/cucumber'
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__)+'/../test_helper')
|
|
2
|
-
|
|
3
|
-
class TestLifxHTTPApi < MiniTest::Unit::TestCase
|
|
4
|
-
|
|
5
|
-
def setup
|
|
6
|
-
@logger = MiniTest::Mock.new
|
|
7
|
-
@api_client = LifxDash::LifxHTTPApi.new('my-token', @logger)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def test_toggles_lights_logging_successful
|
|
11
|
-
selector = "d073d500ec8e"
|
|
12
|
-
body = { results: [{ id: "d073d500ec8e", label: "Golden Boy", status: "ok" } ]}.to_json
|
|
13
|
-
stub_request(:post, lifx_url(selector)).to_return(body: body, status: 207)
|
|
14
|
-
|
|
15
|
-
@logger.expect(:info, nil, ["Toggling lights! (via #{LifxDash::LifxHTTPApi::BASE_URI})"])
|
|
16
|
-
@logger.expect(:info, nil, ["Lights toggled successfully!"])
|
|
17
|
-
@logger.expect(:info, nil, ["API reply (207): #{body}"])
|
|
18
|
-
@api_client.toggle(selector)
|
|
19
|
-
|
|
20
|
-
assert @logger.verify
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def test_toggles_lights_logging_warnings
|
|
24
|
-
selector = "all"
|
|
25
|
-
http_responses = {
|
|
26
|
-
401 => { error: "Invalid token" }, # invalid token in header
|
|
27
|
-
500 => nil, # server issue
|
|
28
|
-
207 => "{}" # server OK, but results not present
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
http_responses.each do |code, api_response_body|
|
|
32
|
-
stub_request(:post, lifx_url(selector)).
|
|
33
|
-
to_return(body: api_response_body.to_json, status: code)
|
|
34
|
-
|
|
35
|
-
@logger.expect(:info, nil, ["Toggling lights! (via #{LifxDash::LifxHTTPApi::BASE_URI})"])
|
|
36
|
-
@logger.expect(:warn, nil, ["Warning: Possible issue with LIFX lights or HTTP API response"])
|
|
37
|
-
@logger.expect(:warn, nil, ["API reply (#{code}): #{api_response_body.to_json}"])
|
|
38
|
-
@api_client.toggle(selector)
|
|
39
|
-
|
|
40
|
-
assert @logger.verify
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def test_raises_error_on_toggle_when_http_errors
|
|
45
|
-
assert_raises(Errno::ECONNRESET) do
|
|
46
|
-
@logger.expect(:info, nil, ["Toggling lights! (via #{LifxDash::LifxHTTPApi::BASE_URI})"])
|
|
47
|
-
@logger.expect(:error, nil, ["Error: POST request to #{LifxDash::LifxHTTPApi::BASE_URI} failed: Connection reset by peer"])
|
|
48
|
-
|
|
49
|
-
net_error = -> (uri) { raise Errno::ECONNRESET.new }
|
|
50
|
-
Net::HTTP::Post.stub :new, net_error do
|
|
51
|
-
@api_client.toggle('all')
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
assert @logger.verify
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def test_raises_error_on_toggle_with_bad_selector
|
|
59
|
-
assert_raises(URI::InvalidURIError) do
|
|
60
|
-
bad_selector = "im a bad bulb selector"
|
|
61
|
-
@logger.expect(:error, nil, ["Error: POST request to #{LifxDash::LifxHTTPApi::BASE_URI} failed: bad URI(is not URI?): #{lifx_url(bad_selector)}"])
|
|
62
|
-
@api_client.toggle(bad_selector)
|
|
63
|
-
|
|
64
|
-
assert @logger.verify
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
private
|
|
69
|
-
|
|
70
|
-
def lifx_url(selector)
|
|
71
|
-
"https://#{LifxDash::LifxHTTPApi::BASE_URI}/lights/#{selector}/toggle"
|
|
72
|
-
end
|
|
73
|
-
end
|