-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not reject FalseClass from tags/values
false is blank Loading production environment (Rails 6.0.3.6) [1] pry(main)> false.blank? => true Also spec out how Values should behave.
- Loading branch information
1 parent
0287553
commit 383f436
Showing
3 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
require "spec_helper" | ||
|
||
RSpec.describe InfluxDB::Rails::Tags do | ||
let(:config) { InfluxDB::Rails::Configuration.new } | ||
|
||
describe ".to_h" do | ||
it "returns TrueClass" do | ||
subject = InfluxDB::Rails::Tags.new(config: config, tags: { hans: true }) | ||
expect(subject.to_h).to a_hash_including(hans: true) | ||
end | ||
|
||
it "returns FalseClass" do | ||
subject = InfluxDB::Rails::Tags.new(config: config, tags: { hans: false }) | ||
expect(subject.to_h).to a_hash_including(hans: false) | ||
end | ||
|
||
it "returns strings" do | ||
subject = InfluxDB::Rails::Tags.new(config: config, tags: { hans: "franz" }) | ||
expect(subject.to_h).to a_hash_including(hans: "franz") | ||
end | ||
|
||
it "returns strings containing blank" do | ||
subject = InfluxDB::Rails::Tags.new(config: config, tags: { hans: "franz hans" }) | ||
expect(subject.to_h).to a_hash_including(hans: "franz hans") | ||
end | ||
|
||
it "removes empty strings" do | ||
subject = InfluxDB::Rails::Tags.new(config: config, tags: { hans: "", franz: " " }) | ||
expect(subject.to_h).not_to a_hash_including(hans: "", franz: " ") | ||
end | ||
|
||
it "returns symbols" do | ||
subject = InfluxDB::Rails::Tags.new(config: config, tags: { hans: :franz }) | ||
expect(subject.to_h).to a_hash_including(hans: :franz) | ||
end | ||
|
||
it "removes nil" do | ||
subject = InfluxDB::Rails::Tags.new(config: config, tags: { hans: nil }) | ||
expect(subject.to_h).not_to a_hash_including(hans: nil) | ||
end | ||
|
||
it "leaves arrays alone" do | ||
subject = InfluxDB::Rails::Tags.new(config: config, tags: { hans: [], franz: %w[a b] }) | ||
expect(subject.to_h).to a_hash_including(hans: [], franz: %w[a b]) | ||
end | ||
end | ||
end |